From 50aaa27ed1e3d181ada436456389541be8d08064 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Sun, 1 Dec 2019 10:47:06 -0800 Subject: [PATCH 001/933] hoon: add +mino, a new virtual nock interpreter +mink, the current virtual nock interpreter, has a couple of problems. 1. it propagates blocks as a list of paths, which is inconsistent with the way the jet behaves (only a single path is ever blocked on, with exception semantics). 2. +mush was not updated after the change to molds to crash instead of bunting. it crashes when not given the right kind of data, which is inconsistent with the intended semantics of ++mink. 3. it "eats" hints, causing (for example) slogs to disappear when running without a mink jet. 4. the naming/style was typically cryptic. since +mink will never really be run, one could argue that its primary purpose is to be read. +mino (which will be renamed to +mink after some staging) has had its return type (+tono, to be renamed +tone) modified in the block case so that it only blocks on one path, has a corrected +mush, carefully "passes through" all hints to the underlying interpreter, and has more meaningful names, with the intention of improving readability. A generator (gen/mino.hoon) is also included in this commit; it contains tests that were used during the development of +mino. It should be removed before integration, and is included for posterity. The stack trace semantics are expected to change in the near future (since they are dependent on jets faithfully preserving the stack pushes of the pure nock, an onerous burden). They are, however, tested in gen/mino.hoon, which makes it unsuitable as a long-term test. --- bin/brass.pill | 4 +- bin/ivory.pill | 4 +- bin/solid.pill | 4 +- pkg/arvo/gen/mino.hoon | 139 +++++++++++++++++++++++++++++++ pkg/arvo/sys/hoon.hoon | 184 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 329 insertions(+), 6 deletions(-) create mode 100644 pkg/arvo/gen/mino.hoon diff --git a/bin/brass.pill b/bin/brass.pill index 7221c67262..cd460fdc06 100644 --- a/bin/brass.pill +++ b/bin/brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:407a763f44eb91db0dd4a1ec2dbd12ed4332b48decefd3999c4313844daa2c0b -size 7226043 +oid sha256:6ac64033689e7910f389da18b59e8d3b03479099ad6d254c1b0eab0079d22805 +size 7236757 diff --git a/bin/ivory.pill b/bin/ivory.pill index 4b1ec02f78..d2d65c5561 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f900509c3277b9eb194299605ce588f25dea6f92622748ced15554b7bb5914ce -size 1214375 +oid sha256:e8b72448edf98d72c5ba7ccdf64ab0fb6dd62312a5504e639db7b93bb4be52f0 +size 1234968 diff --git a/bin/solid.pill b/bin/solid.pill index 3bb4ecc0c6..8fff310449 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:df629686e06b0c56db132076439b03d095bb235fc1a77668022d110559d9b840 -size 9650987 +oid sha256:7cc9cdfe755d72f143d7cae47e059d93422e760796f701e46535f02b43ec4535 +size 9669049 diff --git a/pkg/arvo/gen/mino.hoon b/pkg/arvo/gen/mino.hoon new file mode 100644 index 0000000000..475fb2ba0c --- /dev/null +++ b/pkg/arvo/gen/mino.hoon @@ -0,0 +1,139 @@ +:: test the behavior of the new mink (temporary file) +:- %say +|= [[now=@da * [our=@p *]] *] +:- %noun +?> ?= [%2 *] + (mino [0 11 [%slog 1 2 leaf+"CHECK FOR ME"] 0 0] |=(* ~)) +=/ pass + |= [ref=* gof=*] + =/ fol [12 [1 ref] 1 gof] + =/ pro .*(~ fol) + ``pro +=/ good + |= =path + ^- ? + =/ raw=@t .^(@t %cx path) + =/ virt=tono + (mino [. !=(.^(@t %cx path))] pass) + ?. ?=(%0 -.virt) | + =(product.virt raw) +?> (good /(scot %p our)/home/(scot %da now)/gen/hello/hoon) +=/ scry + |= [a=* b=*] + ^- (unit (unit)) + =/ al=? (? a) + :: not a (list @ta), so mush will give an empty rose + =/ c=(pair path *) ((pair path *) b) + ?. &(=(a al) =(b c)) [~ ~] + ?. al ~ + ?~ p.c [~ ~] + ``q.c +?> ?& + =([%0 42] (mino [0 12 [1 0] [1 /foo] 1 42] scry)) + =([%1 /foo 42] (mino [0 12 [1 1] [1 /foo] 1 42] scry)) + =([%1 0 42] (mino [0 12 [1 1] [1 ~] 1 42] scry)) + ?=([%2 *] (mino [0 12 [1 0] [1 ~] 1 42] scry)) + .= :- 2 + :~ [%spot 1] + [%lose 2] + [%mean 3] + [%hand 4] + [%hunk 5] + == + %+ mino + :- 0 + :* 11 [%hunk 1 5] + 11 [%hand 1 4] + 11 [%mean 1 3] + 11 [%lose 1 2] + 11 [%spot 1 1] + 0 0 + == + |=(* ~) +== +=/ tests=(list [subject=* formula=* product=(unit *)]) + :~ :+ 0 [0 0] ~ + :+ 0 [0 1] `0 + :+ 0 [0 2] ~ + :+ [0 1 2] [0 2] `0 + :+ [0 1 2] [0 3] `[1 2] + :+ [0 1 2] [0 4] ~ + :+ [0 1 2] [0 5] ~ + :+ [0 1 2] [0 6] `1 + :+ [0 1 2] [0 7] `2 + :+ 0 [1 42] `42 + :+ 0 [1 1 2 3 4] `[1 2 3 4] + :+ [[0 3] 1 2 3] [2 [0 3] 0 2] `[2 3] + :+ 42 [3 0 1] `1 + :+ [0 42] [3 0 1] `0 + :+ 41 [4 0 1] `42 + :+ [0 41] [4 0 1] ~ + :+ [42 43] [5 [0 2] [0 3]] `1 + :+ [42 43] [5 [4 0 2] [0 3]] `0 + :+ [42 43] [5 0 1] ~ + :+ 0 [6 [1 0] [1 42] 0] `42 + :+ 0 [6 [1 1] [1 42] 0] ~ + :+ 0 [6 [1 0] [1 42] 1 43] `42 + :+ 0 [6 [1 1] [1 42] 1 43] `43 + :+ 0 [6 [1 2] [1 42] 1 42] ~ + :+ 0 [7 [1 2 3] 4 4 4 0 2] `5 + :+ 0 [8 [1 2 3] 4 4 4 0 4] `5 + :+ 0 [8 [1 2 3] 0 3] `0 + :+ 0 [9 2 1 [0 6] 42 0] `42 + :+ [0 0 42] [7 [10 [6 0 7] 0 1] 0 6] `42 + :+ [0 0] [10 [1 1 42] 0 2] `42 + :+ 0 [10 [1 1 42] 0 2] ~ + :+ 0 [10 [2 1 42] 0 1] ~ + :+ 0 [10 [3 1 42] 0 1] ~ + :+ [0 0] [10 [3 1 42] 0 1] `[0 42] + :+ [0 0] [10 [2 1 42] 0 1] `[42 0] + :+ [0 0 0] [10 [6 1 42] 0 1] `[0 42 0] + :+ [0 0 0] [10 [7 1 42] 0 1] `[0 0 42] + :+ 0 [11 %hint 1 42] `42 + :+ 0 [11 [%hint 1 42] 1 42] `42 + :+ 0 [11 [%hint 0] 1 42] ~ + :+ 0 != =< (fib 5) + |% + ++ dec + |= n=@ + ?: =(0 n) !! + =| i=@ + |- + =/ ip +(i) + ?: =(n ip) i + $(i ip) + ++ add + |= [a=@ b=@] + ?: =(0 a) b + $(a (dec a), b +(b)) + ++ mul + |= [a=@ b=@] + ?: |(=(0 a) =(0 b)) 0 + =/ r=@ a + |- + ?: =(b 1) r + $(b (dec b), r (add a r)) + ++ fib + |= n=@ + ?: =(0 n) 0 + =/ a=@ 1 + |- + ?: =(1 n) a + $(n (dec n), a (mul a n)) + -- + [~ :(mul 5 4 3 2)] + == +=/ scry |=(* ~) +|- ^- ? +?~ tests & +=/ t i.tests +=/ r (mino [subject.t formula.t] scry) +?~ product.t + ?. ?=(%0 -.r) + $(tests t.tests) + ~& [no-crash=t got=product.r] + %.n +?: &(?=(%0 -.r) =(product.r u.product.t)) + $(tests t.tests) +~& [failed=t got=r] +%.n diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 797388b5d1..530b877005 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -4012,6 +4012,10 @@ ++ pint {p/{p/@ q/@} q/{p/@ q/@}} :: line+column range ++ rule _|:($:nail $:edge) :: parsing rule ++ spot {p/path q/pint} :: range in file +++ tono $% {$0 product/*} :: success + {$1 block/*} :: single block + {$2 trace/(list {@ta *})} :: error report + == :: ++ tone $% {$0 p/*} :: success {$1 p/(list)} :: blocks {$2 p/(list {@ta *})} :: error report @@ -6319,6 +6323,186 @@ =+ ton=(mink [sub fol] |=({* *} ~)) ?.(?=({$0 *} ton) ~ [~ p.ton]) :: +++ mino !. + ~/ %mino + |= $: [subject=* formula=*] + scry=$-(^ (unit (unit))) + == + =| trace=(list [@ta *]) + |^ ^- tono + ?+ formula [%2 trace] + [^ *] + =/ head $(formula -.formula) + ?. ?=(%0 -.head) head + =/ tail $(formula +.formula) + ?. ?=(%0 -.tail) tail + [%0 product.head product.tail] + :: + [%0 axis=@] + =/ part (frag axis.formula subject) + ?~ part [%2 trace] + [%0 u.part] + :: + [%1 constant=*] + [%0 constant.formula] + :: + [%2 subject=* formula=*] + =/ subject $(formula subject.formula) + ?. ?=(%0 -.subject) subject + =/ formula $(formula formula.formula) + ?. ?=(%0 -.formula) formula + %= $ + subject product.subject + formula product.formula + == + :: + [%3 argument=*] + =/ argument $(formula argument.formula) + ?. ?=(%0 -.argument) argument + [%0 .?(product.argument)] + :: + [%4 argument=*] + =/ argument $(formula argument.formula) + ?. ?=(%0 -.argument) argument + ?^ product.argument [%2 trace] + [%0 .+(product.argument)] + :: + [%5 a=* b=*] + =/ a $(formula a.formula) + ?. ?=(%0 -.a) a + =/ b $(formula b.formula) + ?. ?=(%0 -.b) b + [%0 =(product.a product.b)] + :: + [%6 test=* yes=* no=*] + =/ result $(formula test.formula) + ?. ?=(%0 -.result) result + ?: =(& product.result) + $(formula yes.formula) + ?: =(| product.result) + $(formula no.formula) + [%2 trace] + :: + [%7 subject=* next=*] + =/ subject $(formula subject.formula) + ?. ?=(%0 -.subject) subject + %= $ + subject product.subject + formula next.formula + == + :: + [%8 head=* next=*] + =/ head $(formula head.formula) + ?. ?=(%0 -.head) head + %= $ + subject [product.head subject] + formula next.formula + == + :: + [%9 axis=@ core=*] + =/ core $(formula core.formula) + ?. ?=(%0 -.core) core + =/ arm (frag axis.formula product.core) + ?~ arm [%2 trace] + %= $ + subject product.core + formula u.arm + == + :: + [%10 [axis=@ value=*] target=*] + ?: =(0 axis.formula) [%2 trace] + =/ target $(formula target.formula) + ?. ?=(%0 -.target) target + =/ value $(formula value.formula) + ?. ?=(%0 -.value) value + =/ mutant=(unit *) + (edit axis.formula product.target product.value) + ?~ mutant [%2 trace] + [%0 u.mutant] + :: + [%11 tag=@ next=*] + %- tono + .* . + :+ 11 tag.formula + != $(formula next.formula) + :: + [%11 [tag=@ clue=*] next=*] + =/ clue $(formula clue.formula) + ?. ?=(%0 -.clue) clue + %- tono + .* . + :+ 11 [tag.formula 1 product.clue] + ?. ?=(?(%hunk %hand %lose %mean %spot) tag.formula) + != $(formula next.formula) + != %= $ + formula next.formula + trace :_ trace + [tag.formula product.clue] + == + :: + [%12 ref=* path=*] + =/ ref $(formula ref.formula) + ?. ?=(%0 -.ref) ref + =/ path $(formula path.formula) + ?. ?=(%0 -.path) path + =/ result (scry product.ref product.path) + ?~ result + [%1 product.path] + ?~ u.result + [%2 [%hunk (mush product.path)] trace] + [%0 u.u.result] + == + :: + ++ mush + |= path=* + ^- tank + :+ %rose ["/" "/" ""] + =| out=(list tank) + |- ^+ out + ?@ path + ?: =(0 path) + (flop out) + ~ + ?^ -.path ~ + %= $ + path +.path + out :_ out + leaf+(trip -.path) + == + :: + ++ frag + |= [axis=@ noun=*] + ^- (unit *) + ?: =(0 axis) ~ + |- + ?: =(1 axis) + `noun + ?@ noun ~ + %= $ + axis (mas axis) + noun ?: =(2 (cap axis)) + -.noun + +.noun + == + :: + ++ edit + |= [axis=@ target=* value=*] + ^- (unit *) + ?: =(1 axis) `value + ?@ target ~ + =/ left=? =(2 (cap axis)) + =/ mutant + %= $ + axis (mas axis) + target ?:(left -.target +.target) + == + ?~ mutant ~ + :- ~ + ?: left + [u.mutant +.target] + [-.target u.mutant] + -- +:: ++ mink !. ~/ %mink |= {{sub/* fol/*} gul/$-({* *} (unit (unit)))} From a233fd5eb37d6387660d8105f18619b130ac7d92 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Sun, 1 Dec 2019 15:25:08 -0800 Subject: [PATCH 002/933] jet +mino, allow one invalid branch in nock 6 - change the nock interpreter to bail [1 block] instead of [1 block ~] - modify mink jet to rewrite this error ball to the old style - add a mino jet that takes advantage of the new style %hand hints aren't handled by the normal interpreter, so they were disabled in the test generator. there was a mismatch in the case of a nock 6 with one invalid branch (either yes or no), which necessitated a little extra logic when compiling nock 6. invalid nock is rare in the wild and there are no tests for this (somewhat subtle) behavior. previously, either branch invalid was (incorrectly) considered an invalid formula and would not compile. --- pkg/arvo/gen/mino.hoon | 4 +- pkg/urbit/include/jets/w.h | 1 + pkg/urbit/jets/e/mink.c | 32 ++++++++++++++ pkg/urbit/jets/tree.c | 5 +++ pkg/urbit/noun/nock.c | 90 ++++++++++++++++++++++++++++++++++++-- 5 files changed, 127 insertions(+), 5 deletions(-) diff --git a/pkg/arvo/gen/mino.hoon b/pkg/arvo/gen/mino.hoon index 475fb2ba0c..522094e142 100644 --- a/pkg/arvo/gen/mino.hoon +++ b/pkg/arvo/gen/mino.hoon @@ -37,13 +37,13 @@ :~ [%spot 1] [%lose 2] [%mean 3] - [%hand 4] + :: [%hand 4] [%hunk 5] == %+ mino :- 0 :* 11 [%hunk 1 5] - 11 [%hand 1 4] + :: 11 [%hand 1 4] 11 [%mean 1 3] 11 [%lose 1 2] 11 [%spot 1 1] diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index 98d8e07db3..20b8da7a7b 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -111,6 +111,7 @@ u3_noun u3we_loss(u3_noun); u3_noun u3we_lune(u3_noun); u3_noun u3we_mink(u3_noun); + u3_noun u3we_mino(u3_noun); u3_noun u3we_mule(u3_noun); u3_noun u3we_repg(u3_noun); u3_noun u3we_rexp(u3_noun); diff --git a/pkg/urbit/jets/e/mink.c b/pkg/urbit/jets/e/mink.c index c17a024273..abf9e055b9 100644 --- a/pkg/urbit/jets/e/mink.c +++ b/pkg/urbit/jets/e/mink.c @@ -8,6 +8,38 @@ { u3_noun bus, fol, gul; + if ( c3n == u3r_mean(cor, u3x_sam_4, &bus, + u3x_sam_5, &fol, + u3x_sam_3, &gul, + 0) ) + { + return u3m_bail(c3__exit); + } + else { + u3_noun som; + + som = u3n_nock_et(u3k(gul), u3k(bus), u3k(fol)); + + c3_assert( c3y == u3du(som) ); + + if ( 1 == u3h(som) ) { + // legacy support: the interpreter now leaves the 0 off the end + // to match +tono. convert to +tone. + u3_noun mos = u3nt(1, u3k(u3t(som)), 0); + u3z(som); + return mos; + } + else { + return som; + } + } + } + + u3_noun + u3we_mino(u3_noun cor) + { + u3_noun bus, fol, gul; + if ( c3n == u3r_mean(cor, u3x_sam_4, &bus, u3x_sam_5, &fol, u3x_sam_3, &gul, diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 43c266a960..ca1a9c52be 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -849,6 +849,10 @@ static c3_c* _141_qua_mink_ha[] = { "fd66c7ed46e5440ea759e6ace2341e6170aec48c79de27ffff3d179d1b5e491e", 0 }; +static u3j_harm _141_qua_mino_a[] = {{".2", u3we_mino}, {}}; +static c3_c* _141_qua_mino_ha[] = { + 0 +}; static u3j_harm _141_qua_mule_a[] = {{".2", u3we_mule}, {}}; static c3_c* _141_qua_mule_ha[] = { "d54688d726565ddade7f2636741cad7209ea40fab28d3335555d8a02ff6001c4", @@ -882,6 +886,7 @@ static u3j_core _141_qua_d[] = { "sfix", 7, _141_qua_sfix_a, 0, _141_qua_sfix_ha }, { "mink", 7, _141_qua_mink_a, 0, _141_qua_mink_ha }, + { "mino", 7, _141_qua_mino_a, 0, _141_qua_mino_ha }, { "mule", 7, _141_qua_mule_a, 0, _141_qua_mule_ha }, {} }; diff --git a/pkg/urbit/noun/nock.c b/pkg/urbit/noun/nock.c index e2bfc0f7d3..a7669d0692 100644 --- a/pkg/urbit/noun/nock.c +++ b/pkg/urbit/noun/nock.c @@ -1100,6 +1100,68 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o los_o, c3_o tel_o) } } +static c3_t +_n_formulaic(u3_noun fol) +{ + u3_noun op, ar, a, b, c; + if ( c3n == u3r_cell(fol, &op, &ar) ) { + return 0; + } + if ( c3y == u3du(op) ) { + return _n_formulaic(op) && _n_formulaic(ar); + } + else switch ( op ) { + case 0: + return ( c3y == u3ud(ar) ); + case 1: + return 1; + case 3: + case 4: + return _n_formulaic(ar); + case 2: + case 5: + case 7: + case 8: + case 12: + return (c3y == u3r_cell(ar, &a, &b)) + && _n_formulaic(a) && _n_formulaic(b); + case 6: + return ( c3y == u3r_trel(ar, &a, &b, &c) ) + && _n_formulaic(a) && + (_n_formulaic(b) || _n_formulaic(c)); + case 9: + return (c3y == u3r_cell(ar, &a, &b)) + && (c3y == u3ud(a)) + && _n_formulaic(b); + case 10: + if ( c3n == u3r_cell(ar, &a, &b) ) { + return 0; + } + if ( c3n == u3du(a) ) { + return 0; + } + if ( c3n == u3ud(u3h(a)) ) { + return 0; + } + return _n_formulaic(u3t(a)) && _n_formulaic(b); + case 11: + if ( c3n == u3r_cell(ar, &a, &b) ) { + return 0; + } + if ( !_n_formulaic(b) ) { + return 0; + } + if ( c3y == u3ud(a) ) { + return 1; + } + else { + return ( c3y == u3ud(u3h(a)) ) && _n_formulaic(u3t(a)); + } + default: + return 0; + } +} + /* _n_comp(): compile nock formula to reversed opcode list * ops is a pointer to a list (to be emitted to) * fol is the nock formula to compile. RETAIN. @@ -1246,10 +1308,32 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) yep = u3_nul, nop = u3_nul; c3_w yep_w, nop_w; + c3_t yep_t, nop_t; u3x_trel(arg, &hed, &mid, &tel); + tot_w += _n_comp(ops, hed, c3n, c3n); - yep_w = _n_comp(&yep, mid, los_o, tel_o); - nop_w = _n_comp(&nop, tel, los_o, tel_o); + yep_t = _n_formulaic(mid); + nop_t = _n_formulaic(tel); + + if ( !yep_t && !nop_t ) { + u3m_bail(c3__exit); + break; + } + + if ( yep_t ) { + yep_w = _n_comp(&yep, mid, los_o, tel_o); + } + else { + ++yep_w; _n_emit(&yep, BAIL); + } + + if ( nop_t ) { + nop_w = _n_comp(&nop, tel, los_o, tel_o); + } + else { + ++nop_w; _n_emit(&nop, BAIL); + } + // SBIP and SBIN get sized during assembly ++yep_w; _n_emit(&yep, u3nc(SBIP, nop_w)); ++tot_w; _n_emit(ops, u3nc(SBIN, yep_w)); @@ -2086,7 +2170,7 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) u3t_on(noc_o); if ( c3n == u3du(x) ) { - u3m_bail(u3nt(1, o, 0)); + u3m_bail(u3nc(1, o)); return u3_none; } else if ( c3n == u3du(u3t(x)) ) { From 5093d420b31995d0b01a3a0c7ed5d410af419c5e Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Sun, 1 Dec 2019 16:22:04 -0800 Subject: [PATCH 003/933] hoon: add staging redirections for mook, mock. --- pkg/arvo/sys/hoon.hoon | 46 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 530b877005..19c46dba75 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -4020,6 +4020,10 @@ {$1 p/(list)} :: blocks {$2 p/(list {@ta *})} :: error report == :: +++ noot $% {$0 p/*} :: success + {$1 p/*} :: block + {$2 p/(list tank)} :: stack trace + == :: ++ toon $% {$0 p/*} :: success {$1 p/(list)} :: blocks {$2 p/(list tank)} :: stack trace @@ -6320,8 +6324,8 @@ ++ mack |= {sub/* fol/*} ^- (unit) - =+ ton=(mink [sub fol] |=({* *} ~)) - ?.(?=({$0 *} ton) ~ [~ p.ton]) + =+ ton=(mino [sub fol] |=({* *} ~)) + ?.(?=({$0 *} ton) ~ [~ product.ton]) :: ++ mino !. ~/ %mino @@ -6619,6 +6623,44 @@ |= {{sub/* fol/*} gul/$-({* *} (unit (unit)))} (mook (mink [sub fol] gul)) :: +++ moku + |= {{sub/* fol/*} gul/$-({* *} (unit (unit)))} + (moko (mino [sub fol] gul)) +:: +++ moko + |= ton/tono + ^- noot + ?. ?=({$2 *} ton) ton + :- %2 + =+ yel=(lent trace.ton) + =. trace.ton + ?. (gth yel 1.024) trace.ton + %+ weld + (scag 512 trace.ton) + ^- (list {@ta *}) + :_ (slag (sub yel 512) trace.ton) + :- %lose + %+ rap 3 + "[skipped {(scow %ud (sub yel 1.024))} frames]" + |- ^- (list tank) + ?~ trace.ton ~ + =+ rep=$(trace.ton t.trace.ton) + ?+ -.i.trace.ton rep + $hunk [(tank +.i.trace.ton) rep] + $lose [[%leaf (rip 3 (@ +.i.trace.ton))] rep] + $hand [[%leaf (scow %p (mug +.i.trace.ton))] rep] + $mean :_ rep + ?@ +.i.trace.ton [%leaf (rip 3 (@ +.i.trace.ton))] + =+ mac=(mack +.i.trace.ton +<.i.trace.ton) + ?~(mac [%leaf "####"] (tank u.mac)) + $spot :_ rep + =+ sot=(spot +.i.trace.ton) + :+ %rose [":" ~ ~] + :~ (smyt p.sot) + => [ud=|=(a/@u (scow %ud a)) q.sot] + leaf+"<[{(ud p.p)} {(ud q.p)}].[{(ud p.q)} {(ud q.q)}]>" + == == +:: ++ mook |= ton/tone ^- toon From 0d0549f6cb9ff4b84715bdff3387ac1170469488 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 5 Dec 2019 11:09:42 -0800 Subject: [PATCH 004/933] hoon: update pills before moving mink callers --- bin/brass.pill | 4 ++-- bin/ivory.pill | 4 ++-- bin/solid.pill | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/brass.pill b/bin/brass.pill index cd460fdc06..e5b10350ab 100644 --- a/bin/brass.pill +++ b/bin/brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6ac64033689e7910f389da18b59e8d3b03479099ad6d254c1b0eab0079d22805 -size 7236757 +oid sha256:94cc600771cf8528230a65c0dda7926d4afa896311a0ef1ccb80726bddea4f9d +size 7238857 diff --git a/bin/ivory.pill b/bin/ivory.pill index d2d65c5561..436add1e1b 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e8b72448edf98d72c5ba7ccdf64ab0fb6dd62312a5504e639db7b93bb4be52f0 -size 1234968 +oid sha256:19a531f781344cb4d036df3f22b907030baed6ec871fc76b07a79cca110a2816 +size 1235681 diff --git a/bin/solid.pill b/bin/solid.pill index 8fff310449..25ca2107b6 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7cc9cdfe755d72f143d7cae47e059d93422e760796f701e46535f02b43ec4535 -size 9669049 +oid sha256:fac4e4c7aaed0ec9b08e4213110b4b3f61e07721bd23a052c4a7dde352ec2e65 +size 9671175 From b3558dee29b60a7df158f788903937c2f36d5818 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 5 Dec 2019 12:29:30 -0800 Subject: [PATCH 005/933] hoon: moko does not crash When molds were changed to crash on bad input, mook was not updated. It relied on the old behavior of bunting on bad input. +moko (the replacement +mook) simply doesn't include stack items that don't have the proper type (in constrast to +mook, which currently crashes and used to leave a "blank"/bunted stack item for improperly typed values). --- pkg/arvo/sys/hoon.hoon | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 19c46dba75..967660480e 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -6645,17 +6645,27 @@ |- ^- (list tank) ?~ trace.ton ~ =+ rep=$(trace.ton t.trace.ton) + =* dat +.i.trace.ton ?+ -.i.trace.ton rep - $hunk [(tank +.i.trace.ton) rep] - $lose [[%leaf (rip 3 (@ +.i.trace.ton))] rep] - $hand [[%leaf (scow %p (mug +.i.trace.ton))] rep] - $mean :_ rep - ?@ +.i.trace.ton [%leaf (rip 3 (@ +.i.trace.ton))] - =+ mac=(mack +.i.trace.ton +<.i.trace.ton) - ?~(mac [%leaf "####"] (tank u.mac)) - $spot :_ rep - =+ sot=(spot +.i.trace.ton) + $hunk =/ sof=(unit tank) ((soft tank) dat) + ?~ sof rep + [u.sof rep] + $lose ?^ dat rep + :_ rep + leaf+(rip 3 dat) + $hand :_ rep + leaf+(scow %p (mug +.i.trace.ton)) + $mean ?@ dat [leaf+(rip 3 dat) rep] + =/ mac (mack dat -.dat) + ?~ mac [leaf+"####" rep] + =/ sof ((soft tank) u.mac) + ?~ sof rep + [u.sof rep] + $spot =/ sof=(unit spot) ((soft spot) dat) + ?~ sof rep + :_ rep :+ %rose [":" ~ ~] + =* sot u.sof :~ (smyt p.sot) => [ud=|=(a/@u (scow %ud a)) q.sot] leaf+"<[{(ud p.p)} {(ud q.p)}].[{(ud p.q)} {(ud q.q)}]>" From 4d71c1150c39a7a5ffbfa1da0880312feb69ebfb Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 5 Dec 2019 13:50:12 -0800 Subject: [PATCH 006/933] hoon, vere: move all mock and mook callers to moku/moko. --- pkg/arvo/app/aqua.hoon | 6 +- pkg/arvo/sys/hoon.hoon | 167 +----------------------------------- pkg/arvo/sys/vane/ford.hoon | 10 +-- pkg/arvo/sys/vane/gall.hoon | 8 +- pkg/urbit/noun/manage.c | 2 +- pkg/urbit/noun/vortex.c | 2 +- pkg/urbit/vere/pier.c | 2 +- 7 files changed, 19 insertions(+), 178 deletions(-) diff --git a/pkg/arvo/app/aqua.hoon b/pkg/arvo/app/aqua.hoon index b10b9556a0..18df2a92c7 100644 --- a/pkg/arvo/app/aqua.hoon +++ b/pkg/arvo/app/aqua.hoon @@ -189,7 +189,7 @@ ~& [who=who %wished (slum wish txt)] ..abet-pe :: - ++ mox |=(* (mock [snap +<] scry)) + ++ mox |=(* (moku [snap +<] scry)) :: :: Start/stop processing events. When stopped, events are added to :: our queue but not processed. @@ -333,8 +333,8 @@ =. this apex-aqua =< abet-aqua =. pil p ~& lent=(met 3 (jam boot-ova.pil)) - =/ res=toon :: (each * (list tank)) - (mock [boot-ova.pil [2 [0 3] [0 2]]] scry) + =/ res=noot :: (each * (list tank)) + (moku [boot-ova.pil [2 [0 3] [0 2]]] scry) =. fleet-snaps ~ ?- -.res %0 diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 967660480e..b656a3c6ef 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -4016,18 +4016,10 @@ {$1 block/*} :: single block {$2 trace/(list {@ta *})} :: error report == :: -++ tone $% {$0 p/*} :: success - {$1 p/(list)} :: blocks - {$2 p/(list {@ta *})} :: error report - == :: ++ noot $% {$0 p/*} :: success {$1 p/*} :: block {$2 p/(list tank)} :: stack trace == :: -++ toon $% {$0 p/*} :: success - {$1 p/(list)} :: blocks - {$2 p/(list tank)} :: stack trace - == :: ++ wonk =+ veq=$:edge :: product from edge |@ ++ $ ?~(q.veq !! p.u.q.veq) :: -- :: @@ -6507,122 +6499,6 @@ [-.target u.mutant] -- :: -++ mink !. - ~/ %mink - |= {{sub/* fol/*} gul/$-({* *} (unit (unit)))} - =+ tax=*(list {@ta *}) - |- ^- tone - ?@ fol - [%2 tax] - ?: ?=(^ -.fol) - =+ hed=$(fol -.fol) - ?: ?=($2 -.hed) - hed - =+ tal=$(fol +.fol) - ?- -.tal - $0 ?-(-.hed $0 [%0 p.hed p.tal], $1 hed) - $1 ?-(-.hed $0 tal, $1 [%1 (weld p.hed p.tal)]) - $2 tal - == - ?+ fol - [%2 tax] - :: - {$0 b/@} - ?: =(0 b.fol) [%2 tax] - ?: =(1 b.fol) [%0 sub] - ?: ?=(@ sub) [%2 tax] - =+ [now=(cap b.fol) lat=(mas b.fol)] - $(b.fol lat, sub ?:(=(2 now) -.sub +.sub)) - :: - {$1 b/*} - [%0 b.fol] - :: - {$2 b/{^ *}} - =+ ben=$(fol b.fol) - ?. ?=($0 -.ben) ben - ?>(?=(^ p.ben) $(sub -.p.ben, fol +.p.ben)) - ::?>(?=(^ p.ben) $([sub fol] p.ben) - :: - {$3 b/*} - =+ ben=$(fol b.fol) - ?. ?=($0 -.ben) ben - [%0 .?(p.ben)] - :: - {$4 b/*} - =+ ben=$(fol b.fol) - ?. ?=($0 -.ben) ben - ?. ?=(@ p.ben) [%2 tax] - [%0 .+(p.ben)] - :: - {$5 b/* c/*} - =+ hed=$(fol b.fol) - ?. ?=($0 -.hed) hed - =+ tal=$(fol c.fol) - ?. ?=($0 -.tal) tal - [%0 =(p.hed p.tal)] - :: - {$6 b/* c/* d/*} - =+ ben=$(fol b.fol) - ?. ?=($0 -.ben) ben - ?: =(& p.ben) $(fol c.fol) - ?: =(| p.ben) $(fol d.fol) - [%2 tax] - :: - {$7 b/* c/*} - =+ ben=$(fol b.fol) - ?. ?=($0 -.ben) ben - $(sub p.ben, fol c.fol) - :: - {$8 b/* c/*} - =+ ben=$(fol b.fol) - ?. ?=($0 -.ben) ben - $(sub [p.ben sub], fol c.fol) - :: - {$9 b/* c/*} - =+ ben=$(fol c.fol) - ?. ?=($0 -.ben) ben - =. sub p.ben - =+ lof=$(fol [0 b.fol]) - ?. ?=($0 -.lof) lof - $(fol p.lof) - :: - {$10 {b/@ c/*} d/*} - =+ bog=$(fol d.fol) - ?. ?=({$0 *} bog) bog - =+ lot=$(fol c.fol) - ?. ?=({$0 *} lot) lot - =+ [axe=b.fol big=p.bog lit=p.lot] - ^- tone - :- %0 - |- ^- p/* - ?: =(2 axe) [lit +.big] - ?: =(3 axe) [-.big lit] - =+ mor=(mas axe) - ?: =(2 (cap axe)) - [$(big -.big, axe mor) +.big] - [-.big $(big +.big, axe mor)] - :: - {$11 @ c/*} $(fol c.fol) - {$11 {b/* c/*} d/*} - =+ ben=$(fol c.fol) - ?. ?=($0 -.ben) ben - ?: ?=(?($hunk $hand $lose $mean $spot) b.fol) - $(fol d.fol, tax [[b.fol p.ben] tax]) - $(fol d.fol) - :: - {$12 b/* c/*} - =+ ref=$(fol b.fol) - =+ ben=$(fol c.fol) - ?. ?=($0 -.ref) ref - ?. ?=($0 -.ben) ben - =+ val=(gul p.ref p.ben) - ?~(val [%1 p.ben ~] ?~(u.val [%2 [[%hunk (mush p.ben)] tax]] [%0 u.u.val])) - == -:: -++ mock - |= {{sub/* fol/*} gul/$-({* *} (unit (unit)))} - (mook (mink [sub fol] gul)) -:: ++ moku |= {{sub/* fol/*} gul/$-({* *} (unit (unit)))} (moko (mino [sub fol] gul)) @@ -6671,41 +6547,6 @@ leaf+"<[{(ud p.p)} {(ud q.p)}].[{(ud p.q)} {(ud q.q)}]>" == == :: -++ mook - |= ton/tone - ^- toon - ?. ?=({$2 *} ton) ton - :- %2 - :: =. p.ton (moop p.ton) - =+ yel=(lent p.ton) - =. p.ton - ?. (gth yel 1.024) p.ton - %+ weld - (scag 512 p.ton) - ^- (list {@ta *}) - :_ (slag (sub yel 512) p.ton) - :- %lose - %+ rap 3 - "[skipped {(scow %ud (sub yel 1.024))} frames]" - |- ^- (list tank) - ?~ p.ton ~ - =+ rep=$(p.ton t.p.ton) - ?+ -.i.p.ton rep - $hunk [(tank +.i.p.ton) rep] - $lose [[%leaf (rip 3 (@ +.i.p.ton))] rep] - $hand [[%leaf (scow %p (mug +.i.p.ton))] rep] - $mean :_ rep - ?@ +.i.p.ton [%leaf (rip 3 (@ +.i.p.ton))] - =+ mac=(mack +.i.p.ton +<.i.p.ton) - ?~(mac [%leaf "####"] (tank u.mac)) - $spot :_ rep - =+ sot=(spot +.i.p.ton) - :+ %rose [":" ~ ~] - :~ (smyt p.sot) - => [ud=|=(a/@u (scow %ud a)) q.sot] - leaf+"<[{(ud p.p)} {(ud q.p)}].[{(ud p.q)} {(ud q.q)}]>" - == == -:: ++ mush :: sane name to leaf |= val/* ^- tank @@ -6715,10 +6556,10 @@ :: ++ mong |= {{gat/* sam/*} gul/$-({* *} (unit (unit)))} - ^- toon + ^- noot ?. &(?=(^ gat) ?=(^ +.gat)) [%2 ~] - (mock [gat(+< sam) %9 2 %0 1] gul) + (moku [gat(+< sam) %9 2 %0 1] gul) :: ++ mule :: typed virtual ~/ %mule @@ -6734,10 +6575,10 @@ ++ mute :: untyped virtual |= taq/_=>(~ ^?(|.(**))) ^- (each * (list tank)) - =/ ton (mock [taq %9 2 %0 1] |=((pair) ``.*(~ [%12 1+p 1+q]))) + =/ ton (moku [taq %9 2 %0 1] |=((pair) ``.*(~ [%12 1+p 1+q]))) ?- -.ton $0 [%& p.ton] - $1 [%| (turn p.ton |=(a/* (smyt (path a))))] + $1 [%| (smyt (path p.ton)) ~] $2 [%| p.ton] == :: +slum: slam a gate on a sample using raw nock, untyped diff --git a/pkg/arvo/sys/vane/ford.hoon b/pkg/arvo/sys/vane/ford.hoon index e5af1fb62a..6933c19533 100644 --- a/pkg/arvo/sys/vane/ford.hoon +++ b/pkg/arvo/sys/vane/ford.hoon @@ -2640,8 +2640,8 @@ (return-result %success %call [type.u.slit-result p.val]) :: %1 - =/ blocked-paths=(list path) ;;((list path) p.val) - (blocked-paths-to-receipt %call blocked-paths) + =/ blocked-path=path ;;(path p.val) + (blocked-paths-to-receipt %call blocked-path ~) :: %2 (return-error [[%leaf "ford: %call execution failed:"] p.val]) @@ -4752,7 +4752,7 @@ (return-result u.cached-result) :: =/ val - (mock [q.subject-vase nock.u.slim-result] intercepted-scry) + (moku [q.subject-vase nock.u.slim-result] intercepted-scry) :: val is a toon, which might be a list of blocks. :: ?- -.val @@ -4761,8 +4761,8 @@ (return-result %success %ride [type.u.slim-result p.val]) :: %1 - =/ blocked-paths=(list path) ;;((list path) p.val) - (blocked-paths-to-receipt %ride blocked-paths) + =/ blocked-path=path ;;(path p.val) + (blocked-paths-to-receipt %ride blocked-path ~) :: %2 (return-error [[%leaf "ford: %ride failed to execute:"] p.val]) diff --git a/pkg/arvo/sys/vane/gall.hoon b/pkg/arvo/sys/vane/gall.hoon index 1427ee5b08..ed1298ae50 100644 --- a/pkg/arvo/sys/vane/gall.hoon +++ b/pkg/arvo/sys/vane/gall.hoon @@ -1355,10 +1355,10 @@ ++ ap-mule |= run=_^?(|.(*step:agent)) ^- (each step:agent tang) - =/ res (mock [run %9 2 %0 1] (sloy ski)) + =/ res (moku [run %9 2 %0 1] (sloy ski)) ?- -.res %0 [%& !<(step:agent [-:!>(*step:agent) p.res])] - %1 [%| (turn p.res |=(a=* (smyt (path a))))] + %1 [%.n (smyt (path p.res)) ~] %2 [%| p.res] == :: +ap-mule-peek: same as +ap-mule but for (unit (unit cage)) @@ -1366,10 +1366,10 @@ ++ ap-mule-peek |= run=_^?(|.(*(unit (unit cage)))) ^- (each (unit (unit cage)) tang) - =/ res (mock [run %9 2 %0 1] (sloy ski)) + =/ res (moku [run %9 2 %0 1] (sloy ski)) ?- -.res %0 [%& !<((unit (unit cage)) [-:!>(*(unit (unit cage))) p.res])] - %1 [%| (turn p.res |=(a=* (smyt (path a))))] + %1 [%.n (smyt (path p.res)) ~] %2 [%| p.res] == :: +ap-ingest: call agent arm diff --git a/pkg/urbit/noun/manage.c b/pkg/urbit/noun/manage.c index 64a6621f1f..f2ab31a13a 100644 --- a/pkg/urbit/noun/manage.c +++ b/pkg/urbit/noun/manage.c @@ -1233,7 +1233,7 @@ u3m_soft(c3_w sec_w, tax = u3k(u3t(u3t(why))); } - mok = u3dc("mook", 2, tax); + mok = u3dc("moko", 2, tax); pro = u3nc(cod, u3k(u3t(mok))); u3z(mok); diff --git a/pkg/urbit/noun/vortex.c b/pkg/urbit/noun/vortex.c index 8bb1bae0e7..bbeb18bed2 100644 --- a/pkg/urbit/noun/vortex.c +++ b/pkg/urbit/noun/vortex.c @@ -344,7 +344,7 @@ u3v_punt(u3_noun blu, c3_l tab_l, u3_noun tac) void u3v_sway(u3_noun blu, c3_l tab_l, u3_noun tax) { - u3_noun mok = u3dc("mook", 2, tax); + u3_noun mok = u3dc("moko", 2, tax); u3v_punt(blu, tab_l, u3k(u3t(mok))); u3z(mok); diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index fff3f15581..c5201edae2 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -2076,7 +2076,7 @@ u3_pier_punt(c3_l tab_l, u3_noun tac) void u3_pier_sway(c3_l tab_l, u3_noun tax) { - u3_noun mok = u3dc("mook", 2, tax); + u3_noun mok = u3dc("moko", 2, tax); u3_pier_punt(tab_l, u3k(u3t(mok))); u3z(mok); From e5841d821d1fb2148a71ba17f90df2955eaa8887 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 5 Dec 2019 15:28:55 -0800 Subject: [PATCH 007/933] hoon: pills contain no references to toon/tone/mook/mock/mink --- bin/brass.pill | 4 ++-- bin/ivory.pill | 4 ++-- bin/solid.pill | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/brass.pill b/bin/brass.pill index e5b10350ab..387d8ae2fa 100644 --- a/bin/brass.pill +++ b/bin/brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:94cc600771cf8528230a65c0dda7926d4afa896311a0ef1ccb80726bddea4f9d -size 7238857 +oid sha256:c699aef29ad78fbdbdfef65d222532d9ad20ee76ab6f8da6e9aa2176f14cf88b +size 7231693 diff --git a/bin/ivory.pill b/bin/ivory.pill index 436add1e1b..d60948d8d0 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:19a531f781344cb4d036df3f22b907030baed6ec871fc76b07a79cca110a2816 -size 1235681 +oid sha256:66b042d0b9d708eafc31882cc1a4ec84a22243d4db33327382b2596e0796e2b7 +size 1233120 diff --git a/bin/solid.pill b/bin/solid.pill index 25ca2107b6..08eca45c19 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fac4e4c7aaed0ec9b08e4213110b4b3f61e07721bd23a052c4a7dde352ec2e65 -size 9671175 +oid sha256:a75413fbf202693427540f672e09abf697b7ff412ae56487f044f2d20fb7ba83 +size 9668909 From 66f85801274dc0352f3021ce8568c019a2fc7bb8 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 5 Dec 2019 15:34:00 -0800 Subject: [PATCH 008/933] vere: remove mink jet --- pkg/urbit/jets/e/mink.c | 32 -------------------------------- pkg/urbit/jets/tree.c | 6 ------ 2 files changed, 38 deletions(-) diff --git a/pkg/urbit/jets/e/mink.c b/pkg/urbit/jets/e/mink.c index abf9e055b9..963588e1a0 100644 --- a/pkg/urbit/jets/e/mink.c +++ b/pkg/urbit/jets/e/mink.c @@ -3,38 +3,6 @@ */ #include "all.h" - u3_noun - u3we_mink(u3_noun cor) - { - u3_noun bus, fol, gul; - - if ( c3n == u3r_mean(cor, u3x_sam_4, &bus, - u3x_sam_5, &fol, - u3x_sam_3, &gul, - 0) ) - { - return u3m_bail(c3__exit); - } - else { - u3_noun som; - - som = u3n_nock_et(u3k(gul), u3k(bus), u3k(fol)); - - c3_assert( c3y == u3du(som) ); - - if ( 1 == u3h(som) ) { - // legacy support: the interpreter now leaves the 0 off the end - // to match +tono. convert to +tone. - u3_noun mos = u3nt(1, u3k(u3t(som)), 0); - u3z(som); - return mos; - } - else { - return som; - } - } - } - u3_noun u3we_mino(u3_noun cor) { diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index ca1a9c52be..093c744856 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -844,11 +844,6 @@ static c3_c* _141_qua_sfix_ha[] = { 0 }; -static u3j_harm _141_qua_mink_a[] = {{".2", u3we_mink}, {}}; -static c3_c* _141_qua_mink_ha[] = { - "fd66c7ed46e5440ea759e6ace2341e6170aec48c79de27ffff3d179d1b5e491e", - 0 -}; static u3j_harm _141_qua_mino_a[] = {{".2", u3we_mino}, {}}; static c3_c* _141_qua_mino_ha[] = { 0 @@ -885,7 +880,6 @@ static u3j_core _141_qua_d[] = { "pose", 7, _141_qua_pose_a, 0, _141_qua_pose_ha }, { "sfix", 7, _141_qua_sfix_a, 0, _141_qua_sfix_ha }, - { "mink", 7, _141_qua_mink_a, 0, _141_qua_mink_ha }, { "mino", 7, _141_qua_mino_a, 0, _141_qua_mino_ha }, { "mule", 7, _141_qua_mule_a, 0, _141_qua_mule_ha }, {} From d6b28db52185fd24e5e2d7a1c31f5246f188e809 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 5 Dec 2019 15:50:36 -0800 Subject: [PATCH 009/933] hoon, vere: copy mino, etc. back to old names --- pkg/arvo/app/aqua.hoon | 6 +- pkg/arvo/gen/mino.hoon | 139 --------------------- pkg/arvo/sys/hoon.hoon | 242 +++++++++++++++++++++++++++++++++++- pkg/arvo/sys/vane/ford.hoon | 2 +- pkg/arvo/sys/vane/gall.hoon | 4 +- pkg/urbit/jets/e/mink.c | 21 ++++ pkg/urbit/jets/tree.c | 5 + 7 files changed, 271 insertions(+), 148 deletions(-) delete mode 100644 pkg/arvo/gen/mino.hoon diff --git a/pkg/arvo/app/aqua.hoon b/pkg/arvo/app/aqua.hoon index 18df2a92c7..b10b9556a0 100644 --- a/pkg/arvo/app/aqua.hoon +++ b/pkg/arvo/app/aqua.hoon @@ -189,7 +189,7 @@ ~& [who=who %wished (slum wish txt)] ..abet-pe :: - ++ mox |=(* (moku [snap +<] scry)) + ++ mox |=(* (mock [snap +<] scry)) :: :: Start/stop processing events. When stopped, events are added to :: our queue but not processed. @@ -333,8 +333,8 @@ =. this apex-aqua =< abet-aqua =. pil p ~& lent=(met 3 (jam boot-ova.pil)) - =/ res=noot :: (each * (list tank)) - (moku [boot-ova.pil [2 [0 3] [0 2]]] scry) + =/ res=toon :: (each * (list tank)) + (mock [boot-ova.pil [2 [0 3] [0 2]]] scry) =. fleet-snaps ~ ?- -.res %0 diff --git a/pkg/arvo/gen/mino.hoon b/pkg/arvo/gen/mino.hoon deleted file mode 100644 index 522094e142..0000000000 --- a/pkg/arvo/gen/mino.hoon +++ /dev/null @@ -1,139 +0,0 @@ -:: test the behavior of the new mink (temporary file) -:- %say -|= [[now=@da * [our=@p *]] *] -:- %noun -?> ?= [%2 *] - (mino [0 11 [%slog 1 2 leaf+"CHECK FOR ME"] 0 0] |=(* ~)) -=/ pass - |= [ref=* gof=*] - =/ fol [12 [1 ref] 1 gof] - =/ pro .*(~ fol) - ``pro -=/ good - |= =path - ^- ? - =/ raw=@t .^(@t %cx path) - =/ virt=tono - (mino [. !=(.^(@t %cx path))] pass) - ?. ?=(%0 -.virt) | - =(product.virt raw) -?> (good /(scot %p our)/home/(scot %da now)/gen/hello/hoon) -=/ scry - |= [a=* b=*] - ^- (unit (unit)) - =/ al=? (? a) - :: not a (list @ta), so mush will give an empty rose - =/ c=(pair path *) ((pair path *) b) - ?. &(=(a al) =(b c)) [~ ~] - ?. al ~ - ?~ p.c [~ ~] - ``q.c -?> ?& - =([%0 42] (mino [0 12 [1 0] [1 /foo] 1 42] scry)) - =([%1 /foo 42] (mino [0 12 [1 1] [1 /foo] 1 42] scry)) - =([%1 0 42] (mino [0 12 [1 1] [1 ~] 1 42] scry)) - ?=([%2 *] (mino [0 12 [1 0] [1 ~] 1 42] scry)) - .= :- 2 - :~ [%spot 1] - [%lose 2] - [%mean 3] - :: [%hand 4] - [%hunk 5] - == - %+ mino - :- 0 - :* 11 [%hunk 1 5] - :: 11 [%hand 1 4] - 11 [%mean 1 3] - 11 [%lose 1 2] - 11 [%spot 1 1] - 0 0 - == - |=(* ~) -== -=/ tests=(list [subject=* formula=* product=(unit *)]) - :~ :+ 0 [0 0] ~ - :+ 0 [0 1] `0 - :+ 0 [0 2] ~ - :+ [0 1 2] [0 2] `0 - :+ [0 1 2] [0 3] `[1 2] - :+ [0 1 2] [0 4] ~ - :+ [0 1 2] [0 5] ~ - :+ [0 1 2] [0 6] `1 - :+ [0 1 2] [0 7] `2 - :+ 0 [1 42] `42 - :+ 0 [1 1 2 3 4] `[1 2 3 4] - :+ [[0 3] 1 2 3] [2 [0 3] 0 2] `[2 3] - :+ 42 [3 0 1] `1 - :+ [0 42] [3 0 1] `0 - :+ 41 [4 0 1] `42 - :+ [0 41] [4 0 1] ~ - :+ [42 43] [5 [0 2] [0 3]] `1 - :+ [42 43] [5 [4 0 2] [0 3]] `0 - :+ [42 43] [5 0 1] ~ - :+ 0 [6 [1 0] [1 42] 0] `42 - :+ 0 [6 [1 1] [1 42] 0] ~ - :+ 0 [6 [1 0] [1 42] 1 43] `42 - :+ 0 [6 [1 1] [1 42] 1 43] `43 - :+ 0 [6 [1 2] [1 42] 1 42] ~ - :+ 0 [7 [1 2 3] 4 4 4 0 2] `5 - :+ 0 [8 [1 2 3] 4 4 4 0 4] `5 - :+ 0 [8 [1 2 3] 0 3] `0 - :+ 0 [9 2 1 [0 6] 42 0] `42 - :+ [0 0 42] [7 [10 [6 0 7] 0 1] 0 6] `42 - :+ [0 0] [10 [1 1 42] 0 2] `42 - :+ 0 [10 [1 1 42] 0 2] ~ - :+ 0 [10 [2 1 42] 0 1] ~ - :+ 0 [10 [3 1 42] 0 1] ~ - :+ [0 0] [10 [3 1 42] 0 1] `[0 42] - :+ [0 0] [10 [2 1 42] 0 1] `[42 0] - :+ [0 0 0] [10 [6 1 42] 0 1] `[0 42 0] - :+ [0 0 0] [10 [7 1 42] 0 1] `[0 0 42] - :+ 0 [11 %hint 1 42] `42 - :+ 0 [11 [%hint 1 42] 1 42] `42 - :+ 0 [11 [%hint 0] 1 42] ~ - :+ 0 != =< (fib 5) - |% - ++ dec - |= n=@ - ?: =(0 n) !! - =| i=@ - |- - =/ ip +(i) - ?: =(n ip) i - $(i ip) - ++ add - |= [a=@ b=@] - ?: =(0 a) b - $(a (dec a), b +(b)) - ++ mul - |= [a=@ b=@] - ?: |(=(0 a) =(0 b)) 0 - =/ r=@ a - |- - ?: =(b 1) r - $(b (dec b), r (add a r)) - ++ fib - |= n=@ - ?: =(0 n) 0 - =/ a=@ 1 - |- - ?: =(1 n) a - $(n (dec n), a (mul a n)) - -- - [~ :(mul 5 4 3 2)] - == -=/ scry |=(* ~) -|- ^- ? -?~ tests & -=/ t i.tests -=/ r (mino [subject.t formula.t] scry) -?~ product.t - ?. ?=(%0 -.r) - $(tests t.tests) - ~& [no-crash=t got=product.r] - %.n -?: &(?=(%0 -.r) =(product.r u.product.t)) - $(tests t.tests) -~& [failed=t got=r] -%.n diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index b656a3c6ef..8984ae84a2 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -4016,10 +4016,18 @@ {$1 block/*} :: single block {$2 trace/(list {@ta *})} :: error report == :: +++ tone $% {$0 product/*} :: success + {$1 block/*} :: single block + {$2 trace/(list {@ta *})} :: error report + == :: ++ noot $% {$0 p/*} :: success {$1 p/*} :: block {$2 p/(list tank)} :: stack trace == :: +++ toon $% {$0 p/*} :: success + {$1 p/*} :: block + {$2 p/(list tank)} :: stack trace + == :: ++ wonk =+ veq=$:edge :: product from edge |@ ++ $ ?~(q.veq !! p.u.q.veq) :: -- :: @@ -6498,11 +6506,239 @@ [u.mutant +.target] [-.target u.mutant] -- + :: +++ mink !. + ~/ %mink + |= $: [subject=* formula=*] + scry=$-(^ (unit (unit))) + == + =| trace=(list [@ta *]) + |^ ^- tone + ?+ formula [%2 trace] + [^ *] + =/ head $(formula -.formula) + ?. ?=(%0 -.head) head + =/ tail $(formula +.formula) + ?. ?=(%0 -.tail) tail + [%0 product.head product.tail] + :: + [%0 axis=@] + =/ part (frag axis.formula subject) + ?~ part [%2 trace] + [%0 u.part] + :: + [%1 constant=*] + [%0 constant.formula] + :: + [%2 subject=* formula=*] + =/ subject $(formula subject.formula) + ?. ?=(%0 -.subject) subject + =/ formula $(formula formula.formula) + ?. ?=(%0 -.formula) formula + %= $ + subject product.subject + formula product.formula + == + :: + [%3 argument=*] + =/ argument $(formula argument.formula) + ?. ?=(%0 -.argument) argument + [%0 .?(product.argument)] + :: + [%4 argument=*] + =/ argument $(formula argument.formula) + ?. ?=(%0 -.argument) argument + ?^ product.argument [%2 trace] + [%0 .+(product.argument)] + :: + [%5 a=* b=*] + =/ a $(formula a.formula) + ?. ?=(%0 -.a) a + =/ b $(formula b.formula) + ?. ?=(%0 -.b) b + [%0 =(product.a product.b)] + :: + [%6 test=* yes=* no=*] + =/ result $(formula test.formula) + ?. ?=(%0 -.result) result + ?: =(& product.result) + $(formula yes.formula) + ?: =(| product.result) + $(formula no.formula) + [%2 trace] + :: + [%7 subject=* next=*] + =/ subject $(formula subject.formula) + ?. ?=(%0 -.subject) subject + %= $ + subject product.subject + formula next.formula + == + :: + [%8 head=* next=*] + =/ head $(formula head.formula) + ?. ?=(%0 -.head) head + %= $ + subject [product.head subject] + formula next.formula + == + :: + [%9 axis=@ core=*] + =/ core $(formula core.formula) + ?. ?=(%0 -.core) core + =/ arm (frag axis.formula product.core) + ?~ arm [%2 trace] + %= $ + subject product.core + formula u.arm + == + :: + [%10 [axis=@ value=*] target=*] + ?: =(0 axis.formula) [%2 trace] + =/ target $(formula target.formula) + ?. ?=(%0 -.target) target + =/ value $(formula value.formula) + ?. ?=(%0 -.value) value + =/ mutant=(unit *) + (edit axis.formula product.target product.value) + ?~ mutant [%2 trace] + [%0 u.mutant] + :: + [%11 tag=@ next=*] + %- tone + .* . + :+ 11 tag.formula + != $(formula next.formula) + :: + [%11 [tag=@ clue=*] next=*] + =/ clue $(formula clue.formula) + ?. ?=(%0 -.clue) clue + %- tone + .* . + :+ 11 [tag.formula 1 product.clue] + ?. ?=(?(%hunk %hand %lose %mean %spot) tag.formula) + != $(formula next.formula) + != %= $ + formula next.formula + trace :_ trace + [tag.formula product.clue] + == + :: + [%12 ref=* path=*] + =/ ref $(formula ref.formula) + ?. ?=(%0 -.ref) ref + =/ path $(formula path.formula) + ?. ?=(%0 -.path) path + =/ result (scry product.ref product.path) + ?~ result + [%1 product.path] + ?~ u.result + [%2 [%hunk (mush product.path)] trace] + [%0 u.u.result] + == + :: + ++ mush + |= path=* + ^- tank + :+ %rose ["/" "/" ""] + =| out=(list tank) + |- ^+ out + ?@ path + ?: =(0 path) + (flop out) + ~ + ?^ -.path ~ + %= $ + path +.path + out :_ out + leaf+(trip -.path) + == + :: + ++ frag + |= [axis=@ noun=*] + ^- (unit *) + ?: =(0 axis) ~ + |- + ?: =(1 axis) + `noun + ?@ noun ~ + %= $ + axis (mas axis) + noun ?: =(2 (cap axis)) + -.noun + +.noun + == + :: + ++ edit + |= [axis=@ target=* value=*] + ^- (unit *) + ?: =(1 axis) `value + ?@ target ~ + =/ left=? =(2 (cap axis)) + =/ mutant + %= $ + axis (mas axis) + target ?:(left -.target +.target) + == + ?~ mutant ~ + :- ~ + ?: left + [u.mutant +.target] + [-.target u.mutant] + -- +:: +++ mock + |= {{sub/* fol/*} gul/$-({* *} (unit (unit)))} + (mook (mink [sub fol] gul)) :: ++ moku |= {{sub/* fol/*} gul/$-({* *} (unit (unit)))} (moko (mino [sub fol] gul)) :: +++ mook + |= ton/tone + ^- toon + ?. ?=({$2 *} ton) ton + :- %2 + =+ yel=(lent trace.ton) + =. trace.ton + ?. (gth yel 1.024) trace.ton + %+ weld + (scag 512 trace.ton) + ^- (list {@ta *}) + :_ (slag (sub yel 512) trace.ton) + :- %lose + %+ rap 3 + "[skipped {(scow %ud (sub yel 1.024))} frames]" + |- ^- (list tank) + ?~ trace.ton ~ + =+ rep=$(trace.ton t.trace.ton) + =* dat +.i.trace.ton + ?+ -.i.trace.ton rep + $hunk =/ sof=(unit tank) ((soft tank) dat) + ?~ sof rep + [u.sof rep] + $lose ?^ dat rep + :_ rep + leaf+(rip 3 dat) + $hand :_ rep + leaf+(scow %p (mug +.i.trace.ton)) + $mean ?@ dat [leaf+(rip 3 dat) rep] + =/ mac (mack dat -.dat) + ?~ mac [leaf+"####" rep] + =/ sof ((soft tank) u.mac) + ?~ sof rep + [u.sof rep] + $spot =/ sof=(unit spot) ((soft spot) dat) + ?~ sof rep + :_ rep + :+ %rose [":" ~ ~] + =* sot u.sof + :~ (smyt p.sot) + => [ud=|=(a/@u (scow %ud a)) q.sot] + leaf+"<[{(ud p.p)} {(ud q.p)}].[{(ud p.q)} {(ud q.q)}]>" + == == +:: ++ moko |= ton/tono ^- noot @@ -6556,10 +6792,10 @@ :: ++ mong |= {{gat/* sam/*} gul/$-({* *} (unit (unit)))} - ^- noot + ^- toon ?. &(?=(^ gat) ?=(^ +.gat)) [%2 ~] - (moku [gat(+< sam) %9 2 %0 1] gul) + (mock [gat(+< sam) %9 2 %0 1] gul) :: ++ mule :: typed virtual ~/ %mule @@ -6575,7 +6811,7 @@ ++ mute :: untyped virtual |= taq/_=>(~ ^?(|.(**))) ^- (each * (list tank)) - =/ ton (moku [taq %9 2 %0 1] |=((pair) ``.*(~ [%12 1+p 1+q]))) + =/ ton (mock [taq %9 2 %0 1] |=((pair) ``.*(~ [%12 1+p 1+q]))) ?- -.ton $0 [%& p.ton] $1 [%| (smyt (path p.ton)) ~] diff --git a/pkg/arvo/sys/vane/ford.hoon b/pkg/arvo/sys/vane/ford.hoon index 6933c19533..5eb799a172 100644 --- a/pkg/arvo/sys/vane/ford.hoon +++ b/pkg/arvo/sys/vane/ford.hoon @@ -4752,7 +4752,7 @@ (return-result u.cached-result) :: =/ val - (moku [q.subject-vase nock.u.slim-result] intercepted-scry) + (mock [q.subject-vase nock.u.slim-result] intercepted-scry) :: val is a toon, which might be a list of blocks. :: ?- -.val diff --git a/pkg/arvo/sys/vane/gall.hoon b/pkg/arvo/sys/vane/gall.hoon index ed1298ae50..b8806dd552 100644 --- a/pkg/arvo/sys/vane/gall.hoon +++ b/pkg/arvo/sys/vane/gall.hoon @@ -1355,7 +1355,7 @@ ++ ap-mule |= run=_^?(|.(*step:agent)) ^- (each step:agent tang) - =/ res (moku [run %9 2 %0 1] (sloy ski)) + =/ res (mock [run %9 2 %0 1] (sloy ski)) ?- -.res %0 [%& !<(step:agent [-:!>(*step:agent) p.res])] %1 [%.n (smyt (path p.res)) ~] @@ -1366,7 +1366,7 @@ ++ ap-mule-peek |= run=_^?(|.(*(unit (unit cage)))) ^- (each (unit (unit cage)) tang) - =/ res (moku [run %9 2 %0 1] (sloy ski)) + =/ res (mock [run %9 2 %0 1] (sloy ski)) ?- -.res %0 [%& !<((unit (unit cage)) [-:!>(*(unit (unit cage))) p.res])] %1 [%.n (smyt (path p.res)) ~] diff --git a/pkg/urbit/jets/e/mink.c b/pkg/urbit/jets/e/mink.c index 963588e1a0..45dde95414 100644 --- a/pkg/urbit/jets/e/mink.c +++ b/pkg/urbit/jets/e/mink.c @@ -23,3 +23,24 @@ return som; } } + + u3_noun + u3we_mink(u3_noun cor) + { + u3_noun bus, fol, gul; + + if ( c3n == u3r_mean(cor, u3x_sam_4, &bus, + u3x_sam_5, &fol, + u3x_sam_3, &gul, + 0) ) + { + return u3m_bail(c3__exit); + } + else { + u3_noun som; + + som = u3n_nock_et(u3k(gul), u3k(bus), u3k(fol)); + + return som; + } + } diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 093c744856..ce8fa6af09 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -848,6 +848,10 @@ static u3j_harm _141_qua_mino_a[] = {{".2", u3we_mino}, {}}; static c3_c* _141_qua_mino_ha[] = { 0 }; +static u3j_harm _141_qua_mink_a[] = {{".2", u3we_mink}, {}}; +static c3_c* _141_qua_mink_ha[] = { + 0 +}; static u3j_harm _141_qua_mule_a[] = {{".2", u3we_mule}, {}}; static c3_c* _141_qua_mule_ha[] = { "d54688d726565ddade7f2636741cad7209ea40fab28d3335555d8a02ff6001c4", @@ -881,6 +885,7 @@ static u3j_core _141_qua_d[] = { "sfix", 7, _141_qua_sfix_a, 0, _141_qua_sfix_ha }, { "mino", 7, _141_qua_mino_a, 0, _141_qua_mino_ha }, + { "mink", 7, _141_qua_mino_a, 0, _141_qua_mink_ha }, { "mule", 7, _141_qua_mule_a, 0, _141_qua_mule_ha }, {} }; From acb17c18ccc10f69b8bf022f08b79a910056d030 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 5 Dec 2019 16:21:10 -0800 Subject: [PATCH 010/933] hoon: pills refer to old names (mink etc), temp names remain --- bin/brass.pill | 4 ++-- bin/ivory.pill | 4 ++-- bin/solid.pill | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/brass.pill b/bin/brass.pill index 387d8ae2fa..0fec96affc 100644 --- a/bin/brass.pill +++ b/bin/brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c699aef29ad78fbdbdfef65d222532d9ad20ee76ab6f8da6e9aa2176f14cf88b -size 7231693 +oid sha256:314d426a33e0e6f6e9e466b401abf5d9f3daf71001dd9fff2ba04e59f87b4a11 +size 7235023 diff --git a/bin/ivory.pill b/bin/ivory.pill index d60948d8d0..85b6e7b842 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:66b042d0b9d708eafc31882cc1a4ec84a22243d4db33327382b2596e0796e2b7 -size 1233120 +oid sha256:908a3e644e568cdc7be68151e92cb1fb276a915f3fc638bec11ed74d0b4f3e43 +size 1233141 diff --git a/bin/solid.pill b/bin/solid.pill index 08eca45c19..de8cf8393b 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a75413fbf202693427540f672e09abf697b7ff412ae56487f044f2d20fb7ba83 -size 9668909 +oid sha256:665f1d94369d174aaa29a890372b83b60d36c8e45410edb889159c8541d80495 +size 9666711 From 9c5cbfcb19e92e59e11951e0d4cb2ace5de36abf Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 5 Dec 2019 16:25:41 -0800 Subject: [PATCH 011/933] hoon: expunge temporary names (mino, tono, etc) --- pkg/arvo/sys/hoon.hoon | 238 +---------------------------------------- 1 file changed, 1 insertion(+), 237 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 8984ae84a2..258ed620b5 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -4012,18 +4012,10 @@ ++ pint {p/{p/@ q/@} q/{p/@ q/@}} :: line+column range ++ rule _|:($:nail $:edge) :: parsing rule ++ spot {p/path q/pint} :: range in file -++ tono $% {$0 product/*} :: success - {$1 block/*} :: single block - {$2 trace/(list {@ta *})} :: error report - == :: ++ tone $% {$0 product/*} :: success {$1 block/*} :: single block {$2 trace/(list {@ta *})} :: error report == :: -++ noot $% {$0 p/*} :: success - {$1 p/*} :: block - {$2 p/(list tank)} :: stack trace - == :: ++ toon $% {$0 p/*} :: success {$1 p/*} :: block {$2 p/(list tank)} :: stack trace @@ -6324,189 +6316,9 @@ ++ mack |= {sub/* fol/*} ^- (unit) - =+ ton=(mino [sub fol] |=({* *} ~)) + =+ ton=(mink [sub fol] |=({* *} ~)) ?.(?=({$0 *} ton) ~ [~ product.ton]) :: -++ mino !. - ~/ %mino - |= $: [subject=* formula=*] - scry=$-(^ (unit (unit))) - == - =| trace=(list [@ta *]) - |^ ^- tono - ?+ formula [%2 trace] - [^ *] - =/ head $(formula -.formula) - ?. ?=(%0 -.head) head - =/ tail $(formula +.formula) - ?. ?=(%0 -.tail) tail - [%0 product.head product.tail] - :: - [%0 axis=@] - =/ part (frag axis.formula subject) - ?~ part [%2 trace] - [%0 u.part] - :: - [%1 constant=*] - [%0 constant.formula] - :: - [%2 subject=* formula=*] - =/ subject $(formula subject.formula) - ?. ?=(%0 -.subject) subject - =/ formula $(formula formula.formula) - ?. ?=(%0 -.formula) formula - %= $ - subject product.subject - formula product.formula - == - :: - [%3 argument=*] - =/ argument $(formula argument.formula) - ?. ?=(%0 -.argument) argument - [%0 .?(product.argument)] - :: - [%4 argument=*] - =/ argument $(formula argument.formula) - ?. ?=(%0 -.argument) argument - ?^ product.argument [%2 trace] - [%0 .+(product.argument)] - :: - [%5 a=* b=*] - =/ a $(formula a.formula) - ?. ?=(%0 -.a) a - =/ b $(formula b.formula) - ?. ?=(%0 -.b) b - [%0 =(product.a product.b)] - :: - [%6 test=* yes=* no=*] - =/ result $(formula test.formula) - ?. ?=(%0 -.result) result - ?: =(& product.result) - $(formula yes.formula) - ?: =(| product.result) - $(formula no.formula) - [%2 trace] - :: - [%7 subject=* next=*] - =/ subject $(formula subject.formula) - ?. ?=(%0 -.subject) subject - %= $ - subject product.subject - formula next.formula - == - :: - [%8 head=* next=*] - =/ head $(formula head.formula) - ?. ?=(%0 -.head) head - %= $ - subject [product.head subject] - formula next.formula - == - :: - [%9 axis=@ core=*] - =/ core $(formula core.formula) - ?. ?=(%0 -.core) core - =/ arm (frag axis.formula product.core) - ?~ arm [%2 trace] - %= $ - subject product.core - formula u.arm - == - :: - [%10 [axis=@ value=*] target=*] - ?: =(0 axis.formula) [%2 trace] - =/ target $(formula target.formula) - ?. ?=(%0 -.target) target - =/ value $(formula value.formula) - ?. ?=(%0 -.value) value - =/ mutant=(unit *) - (edit axis.formula product.target product.value) - ?~ mutant [%2 trace] - [%0 u.mutant] - :: - [%11 tag=@ next=*] - %- tono - .* . - :+ 11 tag.formula - != $(formula next.formula) - :: - [%11 [tag=@ clue=*] next=*] - =/ clue $(formula clue.formula) - ?. ?=(%0 -.clue) clue - %- tono - .* . - :+ 11 [tag.formula 1 product.clue] - ?. ?=(?(%hunk %hand %lose %mean %spot) tag.formula) - != $(formula next.formula) - != %= $ - formula next.formula - trace :_ trace - [tag.formula product.clue] - == - :: - [%12 ref=* path=*] - =/ ref $(formula ref.formula) - ?. ?=(%0 -.ref) ref - =/ path $(formula path.formula) - ?. ?=(%0 -.path) path - =/ result (scry product.ref product.path) - ?~ result - [%1 product.path] - ?~ u.result - [%2 [%hunk (mush product.path)] trace] - [%0 u.u.result] - == - :: - ++ mush - |= path=* - ^- tank - :+ %rose ["/" "/" ""] - =| out=(list tank) - |- ^+ out - ?@ path - ?: =(0 path) - (flop out) - ~ - ?^ -.path ~ - %= $ - path +.path - out :_ out - leaf+(trip -.path) - == - :: - ++ frag - |= [axis=@ noun=*] - ^- (unit *) - ?: =(0 axis) ~ - |- - ?: =(1 axis) - `noun - ?@ noun ~ - %= $ - axis (mas axis) - noun ?: =(2 (cap axis)) - -.noun - +.noun - == - :: - ++ edit - |= [axis=@ target=* value=*] - ^- (unit *) - ?: =(1 axis) `value - ?@ target ~ - =/ left=? =(2 (cap axis)) - =/ mutant - %= $ - axis (mas axis) - target ?:(left -.target +.target) - == - ?~ mutant ~ - :- ~ - ?: left - [u.mutant +.target] - [-.target u.mutant] - -- - :: ++ mink !. ~/ %mink |= $: [subject=* formula=*] @@ -6691,10 +6503,6 @@ |= {{sub/* fol/*} gul/$-({* *} (unit (unit)))} (mook (mink [sub fol] gul)) :: -++ moku - |= {{sub/* fol/*} gul/$-({* *} (unit (unit)))} - (moko (mino [sub fol] gul)) -:: ++ mook |= ton/tone ^- toon @@ -6739,50 +6547,6 @@ leaf+"<[{(ud p.p)} {(ud q.p)}].[{(ud p.q)} {(ud q.q)}]>" == == :: -++ moko - |= ton/tono - ^- noot - ?. ?=({$2 *} ton) ton - :- %2 - =+ yel=(lent trace.ton) - =. trace.ton - ?. (gth yel 1.024) trace.ton - %+ weld - (scag 512 trace.ton) - ^- (list {@ta *}) - :_ (slag (sub yel 512) trace.ton) - :- %lose - %+ rap 3 - "[skipped {(scow %ud (sub yel 1.024))} frames]" - |- ^- (list tank) - ?~ trace.ton ~ - =+ rep=$(trace.ton t.trace.ton) - =* dat +.i.trace.ton - ?+ -.i.trace.ton rep - $hunk =/ sof=(unit tank) ((soft tank) dat) - ?~ sof rep - [u.sof rep] - $lose ?^ dat rep - :_ rep - leaf+(rip 3 dat) - $hand :_ rep - leaf+(scow %p (mug +.i.trace.ton)) - $mean ?@ dat [leaf+(rip 3 dat) rep] - =/ mac (mack dat -.dat) - ?~ mac [leaf+"####" rep] - =/ sof ((soft tank) u.mac) - ?~ sof rep - [u.sof rep] - $spot =/ sof=(unit spot) ((soft spot) dat) - ?~ sof rep - :_ rep - :+ %rose [":" ~ ~] - =* sot u.sof - :~ (smyt p.sot) - => [ud=|=(a/@u (scow %ud a)) q.sot] - leaf+"<[{(ud p.p)} {(ud q.p)}].[{(ud p.q)} {(ud q.q)}]>" - == == -:: ++ mush :: sane name to leaf |= val/* ^- tank From 371f0be924b6f7c14b8db228be76cedc1c55d68a Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 5 Dec 2019 16:28:50 -0800 Subject: [PATCH 012/933] vere: restore calls to old names (mook) --- pkg/urbit/noun/manage.c | 2 +- pkg/urbit/noun/vortex.c | 2 +- pkg/urbit/vere/pier.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/urbit/noun/manage.c b/pkg/urbit/noun/manage.c index f2ab31a13a..64a6621f1f 100644 --- a/pkg/urbit/noun/manage.c +++ b/pkg/urbit/noun/manage.c @@ -1233,7 +1233,7 @@ u3m_soft(c3_w sec_w, tax = u3k(u3t(u3t(why))); } - mok = u3dc("moko", 2, tax); + mok = u3dc("mook", 2, tax); pro = u3nc(cod, u3k(u3t(mok))); u3z(mok); diff --git a/pkg/urbit/noun/vortex.c b/pkg/urbit/noun/vortex.c index bbeb18bed2..8bb1bae0e7 100644 --- a/pkg/urbit/noun/vortex.c +++ b/pkg/urbit/noun/vortex.c @@ -344,7 +344,7 @@ u3v_punt(u3_noun blu, c3_l tab_l, u3_noun tac) void u3v_sway(u3_noun blu, c3_l tab_l, u3_noun tax) { - u3_noun mok = u3dc("moko", 2, tax); + u3_noun mok = u3dc("mook", 2, tax); u3v_punt(blu, tab_l, u3k(u3t(mok))); u3z(mok); diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index c5201edae2..fff3f15581 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -2076,7 +2076,7 @@ u3_pier_punt(c3_l tab_l, u3_noun tac) void u3_pier_sway(c3_l tab_l, u3_noun tax) { - u3_noun mok = u3dc("moko", 2, tax); + u3_noun mok = u3dc("mook", 2, tax); u3_pier_punt(tab_l, u3k(u3t(mok))); u3z(mok); From 352c0c9f51508219bced5af7e260ffc299e0f7f6 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 5 Dec 2019 16:51:01 -0800 Subject: [PATCH 013/933] hoon: pills expunged of temporary names --- bin/brass.pill | 4 ++-- bin/ivory.pill | 4 ++-- bin/solid.pill | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/brass.pill b/bin/brass.pill index 0fec96affc..608c4feef7 100644 --- a/bin/brass.pill +++ b/bin/brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:314d426a33e0e6f6e9e466b401abf5d9f3daf71001dd9fff2ba04e59f87b4a11 -size 7235023 +oid sha256:b02c37028fb2d55b0a794e38afd608367474465911baf2983fda5e74136fd6c3 +size 7227913 diff --git a/bin/ivory.pill b/bin/ivory.pill index 85b6e7b842..2cdb3d7f5e 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:908a3e644e568cdc7be68151e92cb1fb276a915f3fc638bec11ed74d0b4f3e43 -size 1233141 +oid sha256:08e8aec9bb6ce147357d5639da11cd577292ce580530f901d4da667e3a5544d7 +size 1232513 diff --git a/bin/solid.pill b/bin/solid.pill index de8cf8393b..4b35c7bd69 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:665f1d94369d174aaa29a890372b83b60d36c8e45410edb889159c8541d80495 -size 9666711 +oid sha256:499a84c0445201de621fb9727b154b8fde554a58773b0ed9043d4fdde7eba080 +size 9659554 From 761458918f6b48ef7ff51d19d2c879883e7ad101 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 5 Dec 2019 16:56:52 -0800 Subject: [PATCH 014/933] vere: remove mino jet --- pkg/urbit/include/jets/w.h | 1 - pkg/urbit/jets/e/mink.c | 21 --------------------- pkg/urbit/jets/tree.c | 7 +------ 3 files changed, 1 insertion(+), 28 deletions(-) diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index 20b8da7a7b..98d8e07db3 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -111,7 +111,6 @@ u3_noun u3we_loss(u3_noun); u3_noun u3we_lune(u3_noun); u3_noun u3we_mink(u3_noun); - u3_noun u3we_mino(u3_noun); u3_noun u3we_mule(u3_noun); u3_noun u3we_repg(u3_noun); u3_noun u3we_rexp(u3_noun); diff --git a/pkg/urbit/jets/e/mink.c b/pkg/urbit/jets/e/mink.c index 45dde95414..c17a024273 100644 --- a/pkg/urbit/jets/e/mink.c +++ b/pkg/urbit/jets/e/mink.c @@ -3,27 +3,6 @@ */ #include "all.h" - u3_noun - u3we_mino(u3_noun cor) - { - u3_noun bus, fol, gul; - - if ( c3n == u3r_mean(cor, u3x_sam_4, &bus, - u3x_sam_5, &fol, - u3x_sam_3, &gul, - 0) ) - { - return u3m_bail(c3__exit); - } - else { - u3_noun som; - - som = u3n_nock_et(u3k(gul), u3k(bus), u3k(fol)); - - return som; - } - } - u3_noun u3we_mink(u3_noun cor) { diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index ce8fa6af09..d7171a70ff 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -844,10 +844,6 @@ static c3_c* _141_qua_sfix_ha[] = { 0 }; -static u3j_harm _141_qua_mino_a[] = {{".2", u3we_mino}, {}}; -static c3_c* _141_qua_mino_ha[] = { - 0 -}; static u3j_harm _141_qua_mink_a[] = {{".2", u3we_mink}, {}}; static c3_c* _141_qua_mink_ha[] = { 0 @@ -884,8 +880,7 @@ static u3j_core _141_qua_d[] = { "pose", 7, _141_qua_pose_a, 0, _141_qua_pose_ha }, { "sfix", 7, _141_qua_sfix_a, 0, _141_qua_sfix_ha }, - { "mino", 7, _141_qua_mino_a, 0, _141_qua_mino_ha }, - { "mink", 7, _141_qua_mino_a, 0, _141_qua_mink_ha }, + { "mink", 7, _141_qua_mink_a, 0, _141_qua_mink_ha }, { "mule", 7, _141_qua_mule_a, 0, _141_qua_mule_ha }, {} }; From a4866884810d99e16b38f7440811768dcef30ffd Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 5 Dec 2019 18:27:18 -0800 Subject: [PATCH 015/933] hoon: style issue in +mook --- bin/brass.pill | 4 ++-- bin/ivory.pill | 4 ++-- bin/solid.pill | 4 ++-- pkg/arvo/sys/hoon.hoon | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bin/brass.pill b/bin/brass.pill index 608c4feef7..231b5cd8e5 100644 --- a/bin/brass.pill +++ b/bin/brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b02c37028fb2d55b0a794e38afd608367474465911baf2983fda5e74136fd6c3 -size 7227913 +oid sha256:402ea0c12fb4f1692111a5f1fbbdac2cb09e04983d55e4b3e058008a47015a99 +size 7227902 diff --git a/bin/ivory.pill b/bin/ivory.pill index 2cdb3d7f5e..117ab3288e 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:08e8aec9bb6ce147357d5639da11cd577292ce580530f901d4da667e3a5544d7 -size 1232513 +oid sha256:69361c28dff1674f8f623ab1f47765816479589f9afb3c216dca118cb31fc249 +size 1232512 diff --git a/bin/solid.pill b/bin/solid.pill index 4b35c7bd69..6babce345d 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:499a84c0445201de621fb9727b154b8fde554a58773b0ed9043d4fdde7eba080 -size 9659554 +oid sha256:51336da73aa0f16ed1adb470ddf144599dc86c63629e9504489b57db814985fa +size 9659558 diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 258ed620b5..8390e91ef4 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -6530,7 +6530,7 @@ :_ rep leaf+(rip 3 dat) $hand :_ rep - leaf+(scow %p (mug +.i.trace.ton)) + leaf+(scow %p (mug dat)) $mean ?@ dat [leaf+(rip 3 dat) rep] =/ mac (mack dat -.dat) ?~ mac [leaf+"####" rep] From 44402bb2ec62fa5d18e991feb2e98c6da2b041f2 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 25 Feb 2020 13:30:54 -0800 Subject: [PATCH 016/933] hoon: remove unused +mush +mush was moved to be a helper of +mink, its only caller, but I neglected to remove the original code. --- pkg/arvo/sys/hoon.hoon | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 8390e91ef4..33ffdb9214 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -6547,13 +6547,6 @@ leaf+"<[{(ud p.p)} {(ud q.p)}].[{(ud p.q)} {(ud q.q)}]>" == == :: -++ mush :: sane name to leaf - |= val/* - ^- tank - :+ %rose - [['/' ~] ['/' ~] ~] - (turn ((list @ta) val) |=(a/@ta [%leaf (trip a)])) -:: ++ mong |= {{gat/* sam/*} gul/$-({* *} (unit (unit)))} ^- toon From 0671278a80acb1ac7b085e251e3fa5e6838d9911 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 25 Feb 2020 13:32:40 -0800 Subject: [PATCH 017/933] hoon: use constant hint pass-thru for +mink Instead of trying to hint computations (buying us %memo, etc), we simply pass through the nouns (with constant [1 noun] formulas) to the underlying runtime. This avoids spuriously product-hinting the +tone results of +mink as the previous version did. --- bin/brass.pill | 4 ++-- bin/ivory.pill | 4 ++-- bin/solid.pill | 4 ++-- pkg/arvo/sys/hoon.hoon | 26 +++++++++++++++----------- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/bin/brass.pill b/bin/brass.pill index 231b5cd8e5..ea78e57c35 100644 --- a/bin/brass.pill +++ b/bin/brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:402ea0c12fb4f1692111a5f1fbbdac2cb09e04983d55e4b3e058008a47015a99 -size 7227902 +oid sha256:362ba607d646cc053ef27c9cab1d7e6cf07856d0949cb5a48e17ef536e857613 +size 7227783 diff --git a/bin/ivory.pill b/bin/ivory.pill index 117ab3288e..7556df8b8e 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:69361c28dff1674f8f623ab1f47765816479589f9afb3c216dca118cb31fc249 -size 1232512 +oid sha256:96a610c515cb656bc7e92ad9ec89de768014d1dfad7f3884ed171e947fceec52 +size 1232435 diff --git a/bin/solid.pill b/bin/solid.pill index 6babce345d..19bdead6d8 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:51336da73aa0f16ed1adb470ddf144599dc86c63629e9504489b57db814985fa -size 9659558 +oid sha256:c746657cc34182f5e7ebdc15b68e0acfa063d211d44a38519ba95a8a056b18e9 +size 9649650 diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 33ffdb9214..ac05ae3b6a 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -6417,22 +6417,26 @@ [%0 u.mutant] :: [%11 tag=@ next=*] - %- tone - .* . - :+ 11 tag.formula - != $(formula next.formula) + =/ next $(formula next.formula) + ?. ?=(%0 -.next) next + :- %0 + .* subject + [11 tag.formula 1 product.next] :: [%11 [tag=@ clue=*] next=*] =/ clue $(formula clue.formula) ?. ?=(%0 -.clue) clue - %- tone - .* . - :+ 11 [tag.formula 1 product.clue] - ?. ?=(?(%hunk %hand %lose %mean %spot) tag.formula) - != $(formula next.formula) - != %= $ + =; next + ?. ?=(%0 -.next) next + :- %0 + .* subject + [11 [tag.formula 1 product.clue] 1 product.next] + %= $ formula next.formula - trace :_ trace + trace ?. ?= ?(%hunk %hand %lose %mean %spot) + tag.formula + trace + :_ trace [tag.formula product.clue] == :: From 282c4a423206ae48cdf798e5889ff553a26c002a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 24 Jan 2020 10:00:40 -0800 Subject: [PATCH 018/933] Revert "Remove non-shipping code." This reverts commit 7d4b35c86bdb54db5b13ed49e3027ac7eedb8e6f. To restore neo/arvo --- pkg/arvo/neo/arvo.hoon | 1085 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1085 insertions(+) create mode 100644 pkg/arvo/neo/arvo.hoon diff --git a/pkg/arvo/neo/arvo.hoon b/pkg/arvo/neo/arvo.hoon new file mode 100644 index 0000000000..84c55600a6 --- /dev/null +++ b/pkg/arvo/neo/arvo.hoon @@ -0,0 +1,1085 @@ +::BROKEN needs span/twig renaming at least +!: :: /sys/arvo +:: :: %reference/2 +:: %arvo: arvo microkernel. +:: +=< :: this lifecycle wrapper makes the arvo door + :: (multi-armed core) look like a gate (function + :: or single-armed core), to fit urbit's formal + :: lifecycle function. a practical interpreter + :: can ignore it. + :: + |= {now/@da ovo/ovum} + ~> %slog.[0 leaf+"arvo-event"] + .(+> +:(poke now ovo)) +=> +:: :: :: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: (1) public molds +:: :: :: +|% +++ arms (map chip dope) :: stated identity +++ bait :: analysis state + $: now/@da :: date + eny/@uvJ :: entropy + sky/roof :: namespace + == :: +++ card {p/@tas q/*} :: tagged event +++ case :: version + $% {$da p/@da} :: date + {$tas p/@tas} :: label + {$ud p/@ud} :: sequence + == :: +++ cave (cask maze) :: marked untyped vase +++ chip :: standard identity + $? $giv :: given name + $fam :: surname + $had :: fictitious name + $mid :: middle name + $gen :: generational suffix + == :: +++ desk @tas :: ship desk case spur +++ dope (pair @tas @t) :: term/unicode pair +++ duct (list wire) :: causal history +++ maze {p/* q/*} :: untyped vase +++ ovum (pair wire card) :: input or output +++ plum (pair term noun) :: deep file +++ ruby @pG :: 64-bit passcode +++ roof (room vase) :: namespace +++ rook (room maze) :: meta-namespace +++ room :: either namespace + |* vase/mold :: vase or maze + $- $: lyc/(unit (set ship)) :: leakset + car/term :: perspective + bem/beam :: path + == :: + %- unit :: ~: unknown + %- unit :: ~ ~: invalid + (cask vase) :: marked cargo +:: :: +++ ship @p :: network identity +++ vane :: kernel module + |* $: task/mold :: ->$ in request + gift/mold :: <-$ out result + sign/mold :: $<- in result + note/mold :: $-> out request + soul/mold :: current state + seed/mold :: prior state + == :: + =* move :: + $% {$give p/gift} :: return + {$pass p/path q/note} :: invoke + == :: + $_ =| soul :: active state + ^? |% :: + ++ load |~(seed +>) :: restore + ++ stay *soul :: preserve + ++ plow :: work in time + |_ $: now/@da :: date + eny/@e :: entropy + sky/roof :: namespace + == :: + ++ doze *(unit @da) :: awake when + ++ peek roof :: local namespace + ++ spin :: work on state + |_ $: hen/duct :: cause stack + moz/(list move) :: moves, inverted + == :: + ++ call |~(task +>) :: forward effect + ++ take |~({wire sign} +>) :: backward effect + -- :: + -- :: + -- :: +++ wire path :: cause +-- => +:: :: :: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: (2) state molds +:: :: :: +|% +++ evil :: evolvable state + |* {span/_span twig/_twig vase/_vase} :: injected molds + |% :: + ++ ball :: arvo vane move + $% {$give p/mill} :: vane "return" + {$pass p/wire q/(pair term mill)} :: vane "call" + == :: + ++ mall :: any arvo version + $? {$293 mast} :: kelvin 293, current + == :: + ++ mast :: system state + $: $= gut :: abdomen + $: run/(list move) :: worklist + out/(list ovum) :: unix output + but/(unit seed) :: reboot + == :: + $= hax :: thorax + $: sac/worm :: compiler cache + == :: + $= bug :: insect brain + $: noc/@ta :: process nonce + ver/(qual @tas @ud @ud @ud) :: vendor/version + == :: + $= mal :: mammal brain + $: off/? :: not yet booted + lac/_| :: not verbose + eny/@uvJ :: 512-bit entropy + lul/vase :: %lull, vane models + zus/vase :: %zuse, user lib + van/(map term vase) :: vanes + == :: + $= rep :: reptile brain + $: orb/@p :: ship + nym/arms :: name information + roy/(map @ud ruby) :: start secrets + fat/(map path (pair term noun)) :: boot filesystem + == == :: + ++ mill (each vase maze) :: vase or metavase + ++ move (pair duct ball) :: vane move + ++ worm :: compiler cache + $: nes/(set ^) :: ++nest + pay/(map (pair span twig) span) :: ++play + mit/(map (pair span twig) (pair span nock)) :: ++mint + == :: + -- :: +++ hoof @t :: hoon source file +++ live (evil) :: modern molds +++ seed (pair (unit hoof) hoof) :: hoon/arvo boot src +++ vile (evil typo twit vise) :: old molds +++ wasp :: arvo effect + $% {$wack p/@uvJ} :: add entropy + {$what p/(list (pair path (pair term noun)))} :: reset reptile files + {$whim p/arms} :: reset arms + {$wise p/(map @ud ruby)} :: reset secrets + {$whom p/@p} :: set identity; boot + == :: +-- => +:: :: :: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: (3) engines +:: :: :: +|% +:: :: ++le +++ le :: deep engine + =+ [now=*@da *mall:live] + =* :: + :: sys: system state + :: + sys -> + |% + :: :: ++abet:le + ++ abet :: complete cycle + ^- {(each (list ovum) seed) _sys} + ?^ but.gut + [[%| u.but.gut] sys] + [[%& (flop out.gut)] sys(out.gut ~)] + :: :: ++boot:le + ++ boot :: reboot + |= $: :: hyn: optional hoon.hoon source + :: ars: arvo.hoon source + :: + hyn/(unit @t) + ars/@t + == + ^- {* *} + ?~ hyn + :: hon: hoon kernel as a vase + :: are: arvo kernel as a vase + :: arc: arvo core as a vase + :: lod: load gate on arvo core + :: + =/ hon !>(..ride) + ~& [%compile-arvo `@p`(mug p.hon) `@p`(mug ars)] + =* are (slap hon (ream ars)) + =* arc (slot 7 are) + =* lod (slap arc [%limb %load]) + (^ q:(slam lod !>([now sys]))) + :: + :: compile the hoon.hoon source with the current compiler + :: + ~& [%hoon-compile `@p`(mug u.hyn)] + =+ raw=(ride %noun u.hyn) + :: + :: activate the new compiler gate + :: + =+ cop=.*(0 +.raw) + :: + :: find the hoon version number of the new kernel + :: + =+ nex=(@ .*(cop q:(~(mint ut p.raw) %noun [%limb %hoon]))) + ?> |(=(nex hoon) =(+(nex) hoon)) + :: + :: if we're upgrading language versions, recompile the compiler + :: + => ?: =(nex hoon) + [hot=`*`raw .] + ~& [%hoon-compile-upgrade nex] + =+ hot=.*(cop(+< [%noun u.hyn]) -.cop) + .(cop .*(0 +.hot)) + :: + :: extract the hoon core from the outer gate + :: + =+ hoc=.*(cop [0 7]) + :: + :: compute the span of the hoon.hoon core + :: + =+ hyp=-:.*(cop(+< [-.hot '+>']) -.cop) + :: + :: compile arvo + :: + ~& [%compile-arvo `@p`(mug hyp) `@p`(mug ars)] + =+ rav=.*(cop(+< [hyp ars]) -.cop) + :: + :: create the arvo kernel + :: + =+ arv=.*(hoc +.rav) + :: + :: extract the arvo core from the outer gate + :: + =+ voc=.*(arv [0 7]) + :: + :: compute the span of the arvo.hoon core + :: + =+ vip=-:.*(cop(+< [-.rav '+>']) -.cop) + :: + :: entry gate: ++load for the normal case, ++come for upgrade + :: + =+ gat=.*(voc +:.*(cop(+< [vip ?:(=(nex hoon) 'load' 'come')]) -.cop)) + :: + :: sample: [date system-state] + :: + =+ sam=[now sys] + :: + :: call into the new kernel + :: + (^ .*(gat(+< sam) -.gat)) + :: :: ++call:le + ++ call :: forward to vane + |= {hen/duct way/term hil/mill} + ^+ +> + (call:(spin way hen) hil) + :: :: ++doze:le + ++ doze :: next wakeup by vane + |= way/term + ^- (unit @da) + doze:(plow way) + :: :: ++emit:le + ++ emit :: emit move + |= mov/move:live + +>(run.gut [mov run.gut]) + :: :: ++grow:le + ++ grow :: hardcoded prefixes + |= lay/term + ^- term + ?+ lay !! + $a %ames + $b %behn + $c %clay + $d %dill + $e %eyre + $f %ford + $g %gall + $j %jael + == + :: :: ++loop:le + ++ loop :: main loop + ^+ . + :: done if stack is empty + :: + ?~ run.gut . + :: + :: mov: top move on stack + :: + =/ mov `move:live`i.run.gut + :: + :: pop top move off stack + :: + => .(run.gut t.run.gut) + :: + :: interpret top move + :: + ~& [%brhp -.q.mov] + ?- -.q.mov + :: + :: %give: return move + :: + $give + :: + :: the duct can't be empty + :: + ?> ?=(^ p.mov) + :: + :: tea: top wire on duct + :: nex: rest of duct + :: + =/ tea i.p.mov + =* nex t.p.mov + :: + :: route gift by wire + :: + ?. ?=({$$ *} tea) + :: + :: the caller was another vane + :: + ?> ?=({@tas *} tea) + (take nex i.tea t.tea p.q.mov) + :: + :: the caller was arvo itself + :: + ?: ?=({$unix $~} t.tea) + :: + :: the caller was unix i/o + :: + (unix nex (wile p.q.mov)) + ?> ?=({$arvo $~} t.tea) + :: + :: the caller was boot logic + :: + (warp nex ((hard wasp) (wile p.q.mov))) + :: + :: %pass: forward move + :: + $pass + :: tea: proximate cause of action + :: hen: ultimate cause of action + :: way: target + :: hil: event data + :: + =* tea p.q.mov + =* hen p.mov + =* way p.q.q.mov + =* hil q.q.q.mov + (call [tea hen] way hil) + == + :: :: ++pike:le + ++ pike :: event to %pass + |= $: :: way: event route + :: now: date + :: ovo: input ovum + :: + way/@tas + now/@da + ovo/ovum + == + ^+ +> + :: print event if in verbose mode + :: + ~? &(!lac.mal !=(%belt -.q.ovo)) [%unix -.q.ovo p.ovo] + :: + :: vax: card as vase + :: + =^ vax +> (open q.ovo) + :: + :: hen: fundamental cause (unix input channel) + :: tea: local cause (unix i/o) + :: mov: action (pass into event route) + :: + =* hen `duct`[p.ovo ~] + =* tea `wire`[%$ %unix ~] + =* mov `move:live`[hen %pass tea way %& vax] + :: + :: push move on stack, and work. + :: + loop:(emit mov) + :: :: ++open:le + ++ open :: input card to move + |= fav/card + ^- {vase _+>} + ?< off.mal + :: + :: gat: mold for correct unix task + :: vax: molded card + :: + =^ gat sac.hax (~(slap wa sac.hax) zus.mal [%limb %unix-task]) + =/ vax (slam gat [%noun fav]) + ~| [%le-open -.fav] + ?> =(fav q.vax) + [vax +>.$] + :: :: ++peek:le + ++ peek :: namespace + |= $: :: lyc: other ships result may leak to + :: cyr: general perspective, eg %cx + :: bem: name + :: + lyc/(unit (set ship)) + cyr/term + bem/beam + == + ^- (unit (unit cave)) + :: + :: way: vane to look in + :: car: perspective within vane + :: + =* way (grow (end 3 1 cyr)) + =* car (rsh 3 1 cyr) + (peek:(plow(eny.mal `@`0) way) lyc car bem) + :: :: ++plow:le + ++ plow :: plowing vane + |= way/term + (va-plow:(va-amid:va way) now eny.mal peek) + :: :: ++poke:le + ++ poke :: event from unix + |= $: :: ovo: event + :: + ovo/ovum + == + ^+ +> + ~& [%poke -.ovo] + ~| [%poke -.ovo] + ?+ -.q.ovo !! + :: + :: unix input, send to vane + :: + $belt (pike %dill now ovo) + $blew (pike %dill now ovo) + $born (pike %eyre now ovo) + $hail (pike %dill now ovo) + $hear (pike %ames now ovo) + $hook (pike %dill now ovo) + $into (pike %clay now ovo) + $they (pike %eyre now ovo) + $this (pike %eyre now ovo) + $thus (pike %eyre now ovo) + $wake (pike %behn now ovo) + :: + ?($wack $what $whom $whim $wise) + =/ wap ((hard wasp) q.ovo) + =* tea `wire`[%$ %arvo ~] + =* hen `duct`[tea [p.ovo ~]] + =* mov `move:live`[hen %give %& !>(wap)] + loop:(emit mov) + == + :: :: ++spin:le + ++ spin :: spinning vane + |= {way/term hen/duct} + (spin:(plow way) hen) + :: + ++ take + |= {hen/duct way/term tea/wire hil/mill} + ^+ +> + =< loop + (take:(spin way hen) tea hil) + :: :: ++unix:le + ++ unix :: return to unix + |= {hen/duct fav/card} + ^+ +> + ?> ?=({* $~} hen) + loop(out.gut [[i.hen fav] out.gut]) + :: :: ++va:le + ++ va :: vane engine + |_ $: :: way: vane name, eg `%ames` + :: vax: vane, or vane builder if `off.mal` + :: + way/term + vax/vase + == + :: :: ++va-abet:va:le + ++ va-abet :: resolve + ^+ ..va + ..va(van.mal (~(put by van.mal) way vax)) + :: :: ++va-amid:va:le + ++ va-amid :: load existing + |= way/term + ^+ +> + ?< off.mal + +>(way way, vax (~(got by van.mal) way)) + :: :: ++va-abut:va:le + ++ va-apex :: boot / reboot + |= $: way/term + src/hoof + == + ^+ +> + =. ^way way + =/ bun (~(get by van.mal) way) + ?~ bun + (va-create src) + (va-update(vax u.bun) src) + :: :: ++va-plow:va:le + ++ va-plow :: context awareness + |= $: :: now: date + :: eny: 512-bit entropy + :: sky: meta-typed namespace + :: + now/@da + eny/@uvJ + sky/rook + == + :: kys: user-typed namespace vase + :: sam: core sample + :: wok: plowing vase + :: + =* kys `vase`[-:!>(*roof) sky] + =* sam (slop !>(now) (slop !>(eny) kys)) + =^ wok sac.hax (~(open wa sac.hax) vax %plow %& sam) + |% + :: :: ++doze:va-plow:va:le + ++ doze :: next wakeup + ^- (unit @da) + =^ pro sac.hax (~(slap wa sac.hax) wok [%limb %doze]) + =. sac.hax (~(neat wa sac.hax) -:!>(*(unit @da)) %& pro) + ((unit @da) q.pro) + :: :: ++peek:va-plow:va:le + ++ peek :: internal peek + |= $: :: lyc: set of output ships + :: car: local perspective + :: bem: true path + :: + lyc/(unit (set ship)) + car/term + bem/beam + == + ^- (unit (unit cave)) + :: + :: yeb: namespace input + :: pro: namespace output + :: + =/ yeb !>([lyc car bem]) + =^ pro sac.hax (~(call wa sac.hax) wok %peek %& yeb) + =. sac.hax (~(neat wa sac.hax) -:!>([*mark *vase]) %& pro) + :: + :: detect unit cases + :: + ?~ q.pro ~ + ?~ +.q.pro [~ ~] + :: + :: dat: vase of [mark vase] + :: + =^ dat sac.hax (~(slot wa sac.hax) 7 pro) + ``[(mark -.q.dat) (^ +.q.dat)] + :: :: ++spin:va-plow:va:le + ++ spin :: causal action + |= hen/duct + :: + :: fox: spinning vase + :: + =* sam !>([hen *(list move)]) + =^ fox sac.hax (~(open wa sac.hax) vax %spin %& sam) + |% + :: :: ++abet:spin:va-plow: + ++ abet :: integrate + ^+ ..va + :: + :: vom: vase of (list move) + :: moz: actual output list (inverted order) + :: zax: new vase core + :: + =^ vom sac.hax (~(slot wa sac.hax) 13 fox) + =^ moz sac.hax (~(refine-moves me sac.hax) vom) + =^ zax sac.hax (~(slot wa sac.hax) 31 fox) + %= va-abet + vax zax + run.gut + %+ weld + %+ turn (flop moz) + |= mov/move:live + ?. ?=($pass -.q.mov) mov + :: + :: append vane label to pass return address + :: + mov(p.q [way p.q.mov]) + run.gut + == + :: :: ++call:spin:va-plow: + ++ call :: pass forward + |= $: :: hil: logical argument + :: + hil/mill + == + ^+ ..va + =^ nex sac.hax (~(call wa sac.hax) fox %cnhp hil) + abet(fox nex) + :: :: ++take:spin:va-plow: + ++ take :: pass backward + |= $: :: tea: return address + :: hil: logical result + :: + tea/wire + hil/mill + == + ^+ ..va + :: yet: return address as vase + :: sam: whole sample as mill + :: + =/ yet !>(tea) + =/ sam ^- mill + ?- -.hil + $& [%& (slop yet p.hil)] + $| [%| [[%cell p.yet p.p.hil] [q.yet q.p.hil]]] + == + =^ nex sac.hax (~(call wa sac.hax) fox %take sam) + abet(fox nex) + -- + -- + :: :: ++va-create:va:le + ++ va-create :: compile new vase + |= src/hoof + ^+ +> + :: no existing vase; compile new vase + :: + ~& [%vase-compile way `@p`(mug src)] + =. vax (slap zus.mal (ream src)) + ?: off.mal + +> + :: initialize vane + :: + va-settle + :: :: ++va-settle:va:le + ++ va-settle :: initialize with ship + ^+ . + .(vax (slam vax !>(orb.rep))) + :: :: ++va-update + ++ va-update :: replace existing + |= src/hoof + ^+ +> + ?: off.mal + :: replacing unbooted, weird but ok + :: + (va-create src) + :: + :: out: saved state from old vane + :: + =+ out=(slap vax [%limb %stay]) + :: + :: replace `vax` with new empty vane + :: + =. +>.$ (va-create src) + :: + :: initialize new vane with old state + :: + +>.$(vax (slam (slap vax [%limb %come]) out)) + -- + :: :: ++warp:le + ++ warp :: arvo effect + |= {hen/duct wap/wasp} + ^+ +> + ~& [%warp -.wap] + ?- -.wap + $wack +>(eny.mal (mix (shaz (mix now eny.mal)) (shaz p.wap))) + $what (what hen p.wap) + $whim +>(nym.rep p.wap) + $wise +>(roy.rep p.wap) + $whom (whom hen p.wap) + == + :: :: ++whom:le + ++ whom :: initialize ship + |= {hen/duct our/@p} + ^+ +> + :: initialization only happens once + :: + ?> =(& off.mal) + :: + :: continue working after initialization + :: + =< loop + :: + :: set all flags + :: + =: orb.rep our + off.mal | + == + :: + :: activate all vanes + :: + =. van.mal + %- ~(run by van.mal) + |=(vase (slam +< !>(our))) + :: + :: send vanes `[%boot ~]` card, in alphabetical order + :: + =/ fal (sort (turn (~(tap by van.mal)) |=({term *} +<-)) aor) + |- ^+ +>.^$ + ?~ fal +>.^$ + =. +>.^$ $(fal t.fal) + (emit [hen %pass [%$ %arvo ~] i.fal %& !>([%boot ~])]) + :: :: ++wile:le + ++ wile :: mill as card + |= hil/mill + ^- card + =. sac.hax (~(neat wa sac.hax) -:!>(*card) hil) + ?- -.hil + $| ((hard card) q.p.hil) + $& ((hard card) q.p.hil) + == + :: :: ++wilt:le + ++ wilt :: deep file as source + |= pet/plum + ^- hoof + ?>(?=({$hoon @tas} pet) +.pet) + :: :: ++wise:le + ++ wine :: load/reload vane + |= {way/term src/hoof} + ^+ +> + va-abet:(va-apex:va way src) + :: :: ++what:le + ++ what :: write deep storage + |= {hen/duct fal/(list (pair path plum))} + ^+ +> + :: dev: collated `fal` + :: + =/ dev + =| $= dev + $: :: use: non-system files + :: new: new set + :: del: installs + replacements + :: + use/(map path plum) + new/(set path) + del/(map path plum) + == + |- ^+ dev + ?~ fal dev + :: + :: pax: path of this file + :: pet: value of this file + :: + =+ [pax pet]=[p q]:i.fal + => .(fal t.fal) + :: + :: old: current value in deep storage + :: + =+ old=(~(get by fat.rep) pax) + :: + :: ignore unchanged data + :: + ?: =(old `pet) $ + :: + :: classify as user, system install or replacement + :: + ?. ?=({$neo *} pax) + $(use.dev (~(put by use.dev) pax pet)) + =? new.dev + =(~ old) + (~(put in new.dev) pax) + $(del.dev (~(put by del.dev) pax pet)) + :: + :: print new entries + :: + ~? !=(~ use.dev) + [%what-old (turn (~(tap by use.dev) ~) |=({path *} +<-))] + ~? !=(~ new.dev) + [%what-new (~(tap in new.dev) ~)] + ~? !=(~ use.dev) + [%what-del (turn (~(tap by del.dev) ~) |=({path *} +<-))] + :: + :: just adopt user changes, which have no systems impact + :: + =. fat.rep (~(uni by fat.rep) use.dev) + :: + :: but: kernel reboot operation, if any + :: + =/ but + ^- (unit seed) + :: + :: when we get new hoon and arvo system files, + :: we assume they match what's running now + :: + =/ hun ?: (~(has in new.dev) /neo/hoon) ~ + (~(get by del.dev) /neo/hoon) + =/ arv ?: (~(has in new.dev) /neo/arvo) ~ + (~(get by del.dev) /neo/hoon) + ?~ hun + ?~ arv ~ + :: + :: light reboot, arvo only + :: + ~& %light-reboot + `[~ (wilt u.arv)] + :: + :: heavy reboot, hoon and arvo + :: + ~& %heavy-reboot + `[`(wilt u.hun) (wilt ?^(arv u.arv (~(got by fat.rep) /neo/arvo)))] + ?^ but + :: stop working and set up reboot + :: + ~& %reboot + %= +>.$ + :: set boot hook for termination + :: + but.gut ?>(=(~ but.gut) but) + :: + :: finish write *after* reboot, not now, so that new code + :: can use the new kernel + :: + run.gut :_ run.gut + `move:live`[hen %give %& !>([%what (~(tap by del.dev))])] + :: + :: delete kernel source file from deep + :: storage, so that install causes vane upgrade, + :: and *does not* cause repeat kernel upgrade. + :: + fat.rep ?~ p.u.but + fat.rep + (~(del by fat.rep) /neo/hoon) + == + :: keep working after vane upgrades + :: + =< loop + :: + :: job: plan for upgrading + :: + =/ job + ^- $: lul/(unit hoof) + zus/(unit hoof) + vat/(list (pair term hoof)) + == + =< [lul zus (~(tap by van))] + :: + :: lul: shared structures + :: zus: shared library + :: + =/ lul (bind (~(get by del.dev) /neo/lull) wilt) + =/ zus (bind (~(get by del.dev) /neo/zuse) wilt) + :: + :: %lull is the subject of %zuse; if we have a new %lull, + :: but no new %zuse, get the running % + :: + =. zus ?^(zus zus ?~(lul ~ `(wilt (~(got by fat.rep) /neo/zuse)))) + :: + :: van: all vane upgrades, as [initial name source] + :: + =/ van + :: zyr: all system file replacements + :: van: accumulated upgrades + :: + =/ zyr (~(tap by del.dev)) + =| van/(map @tas hoof) + |- ^+ van + ?^ zyr + :: mor: process rest of `zyr` + :: + =/ mor $(zyr t.zyr) + ?. ?=({$neo $van @tas $~} p.i.zyr) + :: + :: ignore anything that isn't a vane + :: + mor + :: replaced vane in `/neo/vane/*/[nam]` + :: + =* nam `term`i.t.t.p.i.zyr + ~& [%new-vane nam `path`p.i.zyr `@p`(mug q.i.zyr)] + (~(put in mor) nam (wilt q.i.zyr)) + :: + :: if this is a new install after a heavy reboot, + :: or if we've adjusted %zuse or %lull, reboot all + :: running vanes + :: + ?. |((~(has in new.dev) /neo/hoon) ?=(^ zus)) van + :: + :: all running vanes + :: + %- ~(gas by van) + %+ skip + ^- (list (pair term hoof)) + %+ turn (~(tap by van.mal)) + |= {way/term vax/vase} + [way (wilt (~(got by fat.rep) [%neo %van way ~]))] + |= {way/term src/hoof} + (~(has in van) way) + . + :: upgrade %lull, vane shared structures + :: + => ?~ lul.job . + %= . + lul.mal ~& [%lull-boot `@p`(mug u.lul.job)] + (slap !>(..arms) (ream u.lul.job)) + == + :: upgrade %zuse, vane shared libraries + :: + => ?~ zus.job . + %= . + zus.mal ~& [%zuse-boot `@p`(mug u.zus.job)] + (slap lul.mal (ream u.zus.job)) + == + :: upgrade all indicated vanes + :: + |- ^+ +>.^$ + ?~ vat.job +>.^$ + ~& [%vane-boot p.i.vat.job `@p`(mug q.i.vat.job)] + $(vat.job t.vat.job, +>.^$ (wine i.vat.job)) + -- +:: :: ++me +++ me :: dynamic analysis + :: sac: compiler cache + :: + |_ sac/worm + :: :: ++refine-moves:me + ++ refine-moves :: move list from vase + |= vax/vase + ^- {(list move:live) worm} + ?: =(~ q.vax) [~ sac] + =^ hed sac (~(slot wa sac) 2 vax) + =^ tal sac (~(slot wa sac) 3 vax) + =^ mov sac (refine-move hed) + =^ moz sac $(vax tal) + [[mov moz] sac] + :: :: ++refine-move:me + ++ refine-move :: move from vase + |= vax/vase + ^- {move:live worm} + :: + :: den: ++duct vase + :: yat: card vase + :: + =^ hip sac (~(nell wa sac) p.vax) + ?> hip + =^ den sac (~(slot wa sac) 2 vax) + =^ yat sac (~(slot wa sac) 3 vax) + =. sac (~(neat wa sac) -:!>(*duct) %& den) + ?> hip + =^ del sac (refine-ball yat) + [[(duct q.den) del] sac] + :: :: ++refine-ball:me + ++ refine-ball :: ball from vase + |= vax/vase + ^- {ball:live worm} + :: + :: specialize span to actual card stem + :: + =^ hex sac (~(spec wa sac) vax) + ?+ -.q.hex ~|(%bad-move !!) + $give + =. sac (~(neat wa sac) -:!>([%give *card]) %& hex) + :: + :: yed: vase containing card + :: hil: card as mill + :: + =^ yed sac (~(slot wa sac) 3 hex) + =^ hil sac (refine-card yed) + [[%give hil] sac] + :: + $pass + =. sac (~(neat wa sac) -:!>([%pass *path *term *card]) %& hex) + :: + :: yed: vase containing card + :: hil: card as mill + :: + =^ yed sac (~(slot wa sac) 15 hex) + =^ hil sac (refine-card yed) + [[%pass (path +6:p.hex) (term +14:p.hex) hil] sac] + == + :: :: ++refine-card:me + ++ refine-card :: card from vase + |= vax/vase + ^- (pair mill worm) + :: + :: specialize span to actual card data + :: + =^ hex sac (~(spec wa sac) vax) + =^ hip sac (~(nell wa sac) p.hex) + ?> hip + ?. ?=($meta -.q.hex) + :: + :: for an non-meta card, the mill is the vase + :: + [[%& hex] sac] + :: + :: tiv: vase of vase of card + :: typ: vase of span + :: + =^ tiv sac (~(slot wa sac) 3 hex) + =^ hip sac (~(nell wa sac) p.tiv) + ?> hip + =^ typ sac (~(slot wa sac) 2 tiv) + =. sac (~(neat wa sac) -:!>(*span) %& hex) + :: + :: support for meta-meta-cards has been removed + :: + [[%| (^ q.tiv)] sac] + -- +-- +:: :: :: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: (4) interface +:: :: :: +=| sys/mall:live +|% +:: :: ++come +++ come :: load old-hoon, +11 + |= {now/@da old/mall:vile} + :: + :: if typed, would produce `{(list ovum) _+>}` + :: + ^- {* *} + :: trivial when arvo models don't change + :: + (load now old) +:: :: ++keep +++ keep :: timeout, +4 + |= {now/@da pax/path} + ^- (unit @da) + :: + :: XX: change interface to specify vane, not path + :: XX: rename "keep" to "doze" + :: way: vane of timeout + :: + ?> ?=({$$ @tas $~} pax) + =* way i.t.pax + (~(doze le now sys) way) +:: :: ++load +++ load :: load current, +86 + |= {now/@da new/mall:live} + :: + :: if typed, would produce `{(list ovum) _+>}` + :: + ^- {* *} + (poke(sys new) now *ovum) +:: :: ++peek +++ peek :: inspect, 87 + |= {now/@da pax/path} + ^- (unit *) + :: + :: XX: adapt external users to modern (unit (unit cage)) + :: + ?. ?=({@ta @ta @ta @ta *} pax) ~ + :: + :: lyc: access control, `[~ ~]` gets anything + :: cyr: perspective + :: bec: path head, `[ship desk case]` + :: tyl: path tail + :: nut: peek result + :: + =/ lyc `(unit (set ship))`[~ ~] + =/ cyr ?>(((sane %tas) i.pax) `@tas`i.pax) + =/ bec ^- beak + :+ (slav %p i.t.pax) + (slav %tas i.t.t.pax) + ((hard case) (slay i.t.t.t.pax)) + =* tyl t.t.t.t.pax + =/ nut (~(peek le now sys) lyc cyr bec tyl) + ?~ nut ~ + ?~ u.nut ~ + [~ +.q.u.u.nut] +:: :: ++poke +++ poke :: apply, 42 + |= {now/@da ovo/ovum} + :: + :: if typed, would produce `{(list ovum) _+>}` + :: + ^- {* *} + :: + :: iterate entropy, it can't hurt + :: + =. eny.mal.sys (mix (shaz now) eny.mal.sys) + :: + :: produce a new state, and either output or a reboot + :: + =^ new sys + =< abet + :: + :: as a hack for reboots, an empty ovum is a no-op + :: + ?: =(*ovum ovo) + ~(loop le now sys) + (~(poke le now sys) ovo) + ?- -.new + :: + :: no reboot; produce output and current core + :: + $& [`(list ovum)`p.new +>.$] + :: + :: reboot; produce loop result from new kernel + :: + $| ~(boot le now sys) + == +:: :: ++wish +++ wish :: compute, 20 + |= src/hoof + q:(slap ?:(off.mal.sys !>(+>) zus.mal.sys) (ream src)) +-- From d17856243e1b26aacc54a65ea4f9d89688cdf87e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 24 Jan 2020 10:21:56 -0800 Subject: [PATCH 019/933] arvo: updates neo, builds with +glass --- pkg/arvo/neo/arvo.hoon | 131 +++++++++++++++++++++-------------------- 1 file changed, 68 insertions(+), 63 deletions(-) diff --git a/pkg/arvo/neo/arvo.hoon b/pkg/arvo/neo/arvo.hoon index 84c55600a6..78fb6bc72b 100644 --- a/pkg/arvo/neo/arvo.hoon +++ b/pkg/arvo/neo/arvo.hoon @@ -1,4 +1,3 @@ -::BROKEN needs span/twig renaming at least !: :: /sys/arvo :: :: %reference/2 :: %arvo: arvo microkernel. @@ -6,7 +5,7 @@ =< :: this lifecycle wrapper makes the arvo door :: (multi-armed core) look like a gate (function :: or single-armed core), to fit urbit's formal - :: lifecycle function. a practical interpreter + :: lifecycle function. a practical interpreter :: can ignore it. :: |= {now/@da ovo/ovum} @@ -23,12 +22,15 @@ eny/@uvJ :: entropy sky/roof :: namespace == :: +++ beam {{p/ship q/desk r/case} s/path} :: global name +++ beak {p/ship q/desk r/case} :: garnish with beak ++ card {p/@tas q/*} :: tagged event ++ case :: version $% {$da p/@da} :: date {$tas p/@tas} :: label {$ud p/@ud} :: sequence == :: +++ cask |*(a/mold (pair mark a)) :: global data ++ cave (cask maze) :: marked untyped vase ++ chip :: standard identity $? $giv :: given name @@ -40,7 +42,10 @@ ++ desk @tas :: ship desk case spur ++ dope (pair @tas @t) :: term/unicode pair ++ duct (list wire) :: causal history +++ mark @tas :: content type ++ maze {p/* q/*} :: untyped vase +++ mill (each vase milt) :: vase+metavase +++ milt {p/* q/*} :: metavase ++ ovum (pair wire card) :: input or output ++ plum (pair term noun) :: deep file ++ ruby @pG :: 64-bit passcode @@ -94,9 +99,9 @@ :: :: :: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: (2) state molds :: :: :: -|% +|% ++ evil :: evolvable state - |* {span/_span twig/_twig vase/_vase} :: injected molds + |* {type/_type hoon/_hoon vase/_vase} :: injected molds |% :: ++ ball :: arvo vane move $% {$give p/mill} :: vane "return" @@ -109,7 +114,7 @@ $: $= gut :: abdomen $: run/(list move) :: worklist out/(list ovum) :: unix output - but/(unit seed) :: reboot + but/(unit seed) :: reboot == :: $= hax :: thorax $: sac/worm :: compiler cache @@ -136,14 +141,14 @@ ++ move (pair duct ball) :: vane move ++ worm :: compiler cache $: nes/(set ^) :: ++nest - pay/(map (pair span twig) span) :: ++play - mit/(map (pair span twig) (pair span nock)) :: ++mint + pay/(map (pair type hoon) type) :: ++play + mit/(map (pair type hoon) (pair type nock)) :: ++mint == :: -- :: ++ hoof @t :: hoon source file ++ live (evil) :: modern molds ++ seed (pair (unit hoof) hoof) :: hoon/arvo boot src -++ vile (evil typo twit vise) :: old molds +++ vile (evil typo hoon vise) :: old molds ++ wasp :: arvo effect $% {$wack p/@uvJ} :: add entropy {$what p/(list (pair path (pair term noun)))} :: reset reptile files @@ -159,7 +164,7 @@ :: :: ++le ++ le :: deep engine =+ [now=*@da *mall:live] - =* :: + =* :: :: sys: system state :: sys -> @@ -263,7 +268,7 @@ :: :: ++emit:le ++ emit :: emit move |= mov/move:live - +>(run.gut [mov run.gut]) + +>(run.gut [mov run.gut]) :: :: ++grow:le ++ grow :: hardcoded prefixes |= lay/term @@ -332,14 +337,14 @@ :: :: the caller was boot logic :: - (warp nex ((hard wasp) (wile p.q.mov))) + (warp nex ;;(wasp (wile p.q.mov))) :: :: %pass: forward move :: $pass :: tea: proximate cause of action :: hen: ultimate cause of action - :: way: target + :: way: target :: hil: event data :: =* tea p.q.mov @@ -440,7 +445,7 @@ $wake (pike %behn now ovo) :: ?($wack $what $whom $whim $wise) - =/ wap ((hard wasp) q.ovo) + =/ wap ;;(wasp q.ovo) =* tea `wire`[%$ %arvo ~] =* hen `duct`[tea [p.ovo ~]] =* mov `move:live`[hen %give %& !>(wap)] @@ -466,7 +471,7 @@ ++ va :: vane engine |_ $: :: way: vane name, eg `%ames` :: vax: vane, or vane builder if `off.mal` - :: + :: way/term vax/vase == @@ -508,9 +513,9 @@ =* kys `vase`[-:!>(*roof) sky] =* sam (slop !>(now) (slop !>(eny) kys)) =^ wok sac.hax (~(open wa sac.hax) vax %plow %& sam) - |% + |% :: :: ++doze:va-plow:va:le - ++ doze :: next wakeup + ++ doze :: next wakeup ^- (unit @da) =^ pro sac.hax (~(slap wa sac.hax) wok [%limb %doze]) =. sac.hax (~(neat wa sac.hax) -:!>(*(unit @da)) %& pro) @@ -549,7 +554,7 @@ :: :: fox: spinning vase :: - =* sam !>([hen *(list move)]) + =* sam !>([hen *(list move:live)]) =^ fox sac.hax (~(open wa sac.hax) vax %spin %& sam) |% :: :: ++abet:spin:va-plow: @@ -590,7 +595,7 @@ |= $: :: tea: return address :: hil: logical result :: - tea/wire + tea/wire hil/mill == ^+ ..va @@ -600,14 +605,14 @@ =/ yet !>(tea) =/ sam ^- mill ?- -.hil - $& [%& (slop yet p.hil)] - $| [%| [[%cell p.yet p.p.hil] [q.yet q.p.hil]]] + %& [%& (slop yet p.hil)] + %| [%| [[%cell p.yet p.p.hil] [q.yet q.p.hil]]] == =^ nex sac.hax (~(call wa sac.hax) fox %take sam) abet(fox nex) -- -- - :: :: ++va-create:va:le + :: :: ++va-create:va:le ++ va-create :: compile new vase |= src/hoof ^+ +> @@ -650,7 +655,7 @@ |= {hen/duct wap/wasp} ^+ +> ~& [%warp -.wap] - ?- -.wap + ?- -.wap $wack +>(eny.mal (mix (shaz (mix now eny.mal)) (shaz p.wap))) $what (what hen p.wap) $whim +>(nym.rep p.wap) @@ -662,7 +667,7 @@ |= {hen/duct our/@p} ^+ +> :: initialization only happens once - :: + :: ?> =(& off.mal) :: :: continue working after initialization @@ -678,12 +683,12 @@ :: activate all vanes :: =. van.mal - %- ~(run by van.mal) + %- ~(run by van.mal) |=(vase (slam +< !>(our))) :: :: send vanes `[%boot ~]` card, in alphabetical order :: - =/ fal (sort (turn (~(tap by van.mal)) |=({term *} +<-)) aor) + =/ fal (sort (turn ~(tap by van.mal) |=({term *} +<-)) aor) |- ^+ +>.^$ ?~ fal +>.^$ =. +>.^$ $(fal t.fal) @@ -694,8 +699,8 @@ ^- card =. sac.hax (~(neat wa sac.hax) -:!>(*card) hil) ?- -.hil - $| ((hard card) q.p.hil) - $& ((hard card) q.p.hil) + %| ;;(card q.p.hil) + %& ;;(card q.p.hil) == :: :: ++wilt:le ++ wilt :: deep file as source @@ -725,7 +730,7 @@ == |- ^+ dev ?~ fal dev - :: + :: :: pax: path of this file :: pet: value of this file :: @@ -745,18 +750,18 @@ ?. ?=({$neo *} pax) $(use.dev (~(put by use.dev) pax pet)) =? new.dev - =(~ old) + =(~ old) (~(put in new.dev) pax) $(del.dev (~(put by del.dev) pax pet)) :: :: print new entries :: - ~? !=(~ use.dev) - [%what-old (turn (~(tap by use.dev) ~) |=({path *} +<-))] - ~? !=(~ new.dev) - [%what-new (~(tap in new.dev) ~)] - ~? !=(~ use.dev) - [%what-del (turn (~(tap by del.dev) ~) |=({path *} +<-))] + ~? !=(~ use.dev) + [%what-old (turn ~(tap by use.dev) |=({path *} +<-))] + ~? !=(~ new.dev) + [%what-new ~(tap in new.dev)] + ~? !=(~ use.dev) + [%what-del (turn ~(tap by del.dev) |=({path *} +<-))] :: :: just adopt user changes, which have no systems impact :: @@ -767,7 +772,7 @@ =/ but ^- (unit seed) :: - :: when we get new hoon and arvo system files, + :: when we get new hoon and arvo system files, :: we assume they match what's running now :: =/ hun ?: (~(has in new.dev) /neo/hoon) ~ @@ -799,7 +804,7 @@ :: can use the new kernel :: run.gut :_ run.gut - `move:live`[hen %give %& !>([%what (~(tap by del.dev))])] + `move:live`[hen %give %& !>([%what ~(tap by del.dev)])] :: :: delete kernel source file from deep :: storage, so that install causes vane upgrade, @@ -813,14 +818,14 @@ :: =< loop :: - :: job: plan for upgrading + :: job: plan for upgrading :: =/ job ^- $: lul/(unit hoof) zus/(unit hoof) vat/(list (pair term hoof)) == - =< [lul zus (~(tap by van))] + =< [lul zus ~(tap by van)] :: :: lul: shared structures :: zus: shared library @@ -839,14 +844,14 @@ :: zyr: all system file replacements :: van: accumulated upgrades :: - =/ zyr (~(tap by del.dev)) + =/ zyr ~(tap by del.dev) =| van/(map @tas hoof) |- ^+ van ?^ zyr :: mor: process rest of `zyr` :: =/ mor $(zyr t.zyr) - ?. ?=({$neo $van @tas $~} p.i.zyr) + ?. ?=({$neo $van @tas $~} p.i.zyr) :: :: ignore anything that isn't a vane :: @@ -857,22 +862,22 @@ ~& [%new-vane nam `path`p.i.zyr `@p`(mug q.i.zyr)] (~(put in mor) nam (wilt q.i.zyr)) :: - :: if this is a new install after a heavy reboot, + :: if this is a new install after a heavy reboot, :: or if we've adjusted %zuse or %lull, reboot all :: running vanes :: ?. |((~(has in new.dev) /neo/hoon) ?=(^ zus)) van :: - :: all running vanes + :: all running vanes :: %- ~(gas by van) - %+ skip + %+ skip ^- (list (pair term hoof)) - %+ turn (~(tap by van.mal)) + %+ turn ~(tap by van.mal) |= {way/term vax/vase} [way (wilt (~(got by fat.rep) [%neo %van way ~]))] |= {way/term src/hoof} - (~(has in van) way) + (~(has by van) way) . :: upgrade %lull, vane shared structures :: @@ -933,16 +938,16 @@ :: :: specialize span to actual card stem :: - =^ hex sac (~(spec wa sac) vax) + =^ hex sac (~(sped wa sac) vax) ?+ -.q.hex ~|(%bad-move !!) $give =. sac (~(neat wa sac) -:!>([%give *card]) %& hex) :: :: yed: vase containing card :: hil: card as mill - :: + :: =^ yed sac (~(slot wa sac) 3 hex) - =^ hil sac (refine-card yed) + =^ hil sac (refine-card yed) [[%give hil] sac] :: $pass @@ -950,11 +955,11 @@ :: :: yed: vase containing card :: hil: card as mill - :: + :: =^ yed sac (~(slot wa sac) 15 hex) - =^ hil sac (refine-card yed) + =^ hil sac (refine-card yed) [[%pass (path +6:p.hex) (term +14:p.hex) hil] sac] - == + == :: :: ++refine-card:me ++ refine-card :: card from vase |= vax/vase @@ -962,10 +967,10 @@ :: :: specialize span to actual card data :: - =^ hex sac (~(spec wa sac) vax) + =^ hex sac (~(sped wa sac) vax) =^ hip sac (~(nell wa sac) p.hex) ?> hip - ?. ?=($meta -.q.hex) + ?. ?=($meta -.q.hex) :: :: for an non-meta card, the mill is the vase :: @@ -978,13 +983,13 @@ =^ hip sac (~(nell wa sac) p.tiv) ?> hip =^ typ sac (~(slot wa sac) 2 tiv) - =. sac (~(neat wa sac) -:!>(*span) %& hex) + =. sac (~(neat wa sac) -:!>(*type) %& hex) :: :: support for meta-meta-cards has been removed :: [[%| (^ q.tiv)] sac] - -- --- + -- :: me +-- :: :: :: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: (4) interface :: :: :: @@ -1040,8 +1045,8 @@ =/ bec ^- beak :+ (slav %p i.t.pax) (slav %tas i.t.t.pax) - ((hard case) (slay i.t.t.t.pax)) - =* tyl t.t.t.t.pax + ;;(case (slay i.t.t.t.pax)) + =* tyl t.t.t.t.pax =/ nut (~(peek le now sys) lyc cyr bec tyl) ?~ nut ~ ?~ u.nut ~ @@ -1058,9 +1063,9 @@ :: =. eny.mal.sys (mix (shaz now) eny.mal.sys) :: - :: produce a new state, and either output or a reboot + :: produce a new state, and either output or a reboot :: - =^ new sys + =^ new sys =< abet :: :: as a hack for reboots, an empty ovum is a no-op @@ -1072,11 +1077,11 @@ :: :: no reboot; produce output and current core :: - $& [`(list ovum)`p.new +>.$] + %& [`(list ovum)`p.new +>.$] :: :: reboot; produce loop result from new kernel :: - $| ~(boot le now sys) + %| ~(boot le now sys) == :: :: ++wish ++ wish :: compute, 20 From 191425a11e25802631f3d7a9594ff165706d4078 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 28 Jan 2020 11:20:09 -0800 Subject: [PATCH 020/933] arvo: adds +deep, prototype arvo filesystem engine --- pkg/arvo/gen/deep.hoon | 255 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100644 pkg/arvo/gen/deep.hoon diff --git a/pkg/arvo/gen/deep.hoon b/pkg/arvo/gen/deep.hoon new file mode 100644 index 0000000000..fcb1565a2e --- /dev/null +++ b/pkg/arvo/gen/deep.hoon @@ -0,0 +1,255 @@ +:- %say +|= $: {now/@da eny/@uvJ bec/beak} + * + == +:- %noun +=> +|% +:: fundamental hierarchical node XX s/b +arch +:: +++ node + =< |$ [item] + [fil=(unit item) dir=(map @ta $)] + :: + |% + ++ de + =| fat=(node) + |@ + :: + ++ get-node + |= pax=path + ^+ fat + ?~ pax fat + =/ kid (~(get by dir.fat) i.pax) + ?~ kid [~ ~] + $(fat u.kid, pax t.pax) + :: + ++ get + |= pax=path + ^+ fil.fat + fil:(get-node pax) + :: + ++ got + |= pax=path + (need (get pax)) + :: + ++ has + |= pax=path + ^- ? + !=(~ (get pax)) + :: + ++ put + |* [pax=path dat=*] + => .(dat `_?>(?=(^ fil.fat) u.fil.fat)`dat) + ^+ fat + ?~ pax fat(fil `dat) + =/ kid (~(get by dir.fat) i.pax) + =/ new (fall kid fat(fil ~, dir ~)) + fat(dir (~(put by dir.fat) i.pax $(fat new, pax t.pax))) + :: + ++ gas + |= lit=(list (pair path _?>(?=(^ fil.fat) u.fil.fat))) + ^+ fat + ?~ lit fat + $(fat (put p.i.lit q.i.lit), lit t.lit) + :: + ++ tap + =| pax=path + =| out=(list (pair path _?>(?=(^ fil.fat) u.fil.fat))) + |- ^+ out + =? out ?=(^ fil.fat) :_(out [pax u.fil.fat]) + =/ dir ~(tap by dir.fat) + |- ^+ out + ?~ dir out + %= $ + dir t.dir + out ^$(pax (weld pax /[p.i.dir]), fat q.i.dir) + == + -- :: de + -- :: node +-- +=> +|% ++$ hoof @t :: hoon source file ++$ news + $: :: use: non-system files + :: new: new set + :: sys: installs + replacements + :: + use=(map path plum) + new=(set path) + sys=(map path plum) + == ++$ plum (cask) ++$ seed [hoon=(unit hoof) arvo=hoof] ++$ sprig + $: lull=(unit hoof) + zuse=(unit hoof) + vane=(list (pair term hoof)) + == +:: +++ wilt :: deep file as source + |= =plum + ^- hoof + ?>(?=([%hoon @t] plum) q.plum) +:: +++ adapt + =* de de:node + |_ fat=(node plum) + :: + :: +group: collate changes + :: + ++ group + |= fal=(list (pair path plum)) + =| del=news + |- ^+ del + ?~ fal + ~? !=(~ use.del) + [%what-use ~(tap in ~(key by use.del))] + ~? !=(~ new.del) + [%what-new ~(tap in new.del)] + ~? !=(~ sys.del) + [%what-sys ~(tap in ~(key by sys.del))] + del + :: + =* pax p.i.fal + =* dat q.i.fal + =/ old (~(get de fat) pax) + :: + :: ignore unchanged data + :: + ?: =(old `dat) + $(fal t.fal) + :: + :: classify as user, system install or replacement + :: + ?. ?=([%sys *] pax) + =. use.del (~(put by use.del) pax dat) + $(fal t.fal) + =? new.del ?=(~ old) + (~(put in new.del) pax) + =. sys.del (~(put by sys.del) pax dat) + $(fal t.fal) + :: +usurp: consider self-replacement + :: + ++ usurp + |= del=news + ^- (unit seed) + :: + :: when we get new hoon and arvo system files, + :: we assume they match what's running now + :: + =* adopt-new + |=(=path ?:((~(has in new.del) path) ~ (~(get by sys.del) path))) + :: + =/ hun (adopt-new /sys/hoon) + =/ arv (adopt-new /sys/arvo) + ?~ hun + ?~ arv ~ + :: + :: light reboot, arvo only + :: + ~& %light-reboot + ``(wilt u.arv) + :: + :: heavy reboot, hoon and arvo + :: + ~& %heavy-reboot + :+ ~ + `(wilt u.hun) + (wilt ?^(arv u.arv (~(got de fat) /sys/arvo))) + :: +adorn: augment capabilities + :: + ++ adorn + |= [del=news force=?] + ^- sprig + :: lull: shared structures + :: + =/ lull + ?^ lul=(~(get by sys.del) /sys/lull) + `(wilt u.lul) + ?.(force ~ `(wilt (~(got de fat) /sys/lull))) + :: + :: zuse: shared library + :: + :: %lull is the subject of %zuse; force %zuse if we have a new %lull + :: + =/ zuse + =. force ?=(^ lull) + ?^ zus=(~(get by sys.del) /sys/zuse) + `(wilt u.zus) + ?.(force ~ `(wilt (~(got de fat) /sys/zuse))) + :: + :+ lull + zuse + :: + :: kernel modules + :: + :: %zuse is the subject of the vanes; force all if we have a new %zuse + :: + =/ current=(list (pair term hoof)) + =. force ?=(^ zuse) + ?. force ~ + %+ turn + ~(tap by dir:(~(get-node de fat) /sys/vane)) + |=([name=@ta (node plum)] [`@tas`name (wilt (need fil))]) + :: + =/ updates=(list (pair term hoof)) + %+ turn + %+ skim + ~(tap by sys.del) + |=([=path *] ?=([%sys %vane @tas ~] path)) + |= [=path =plum] + ?> ?=([%sys %vane @tas ~] path) + =* name i.t.t.path + ?> ((sane %tas) name) + [`@tas`name (wilt plum)] + :: + %+ sort + %~ tap by + %- ~(gas by *(map term hoof)) + (weld current updates) + |=([[a=@tas *] [b=@tas *]] (aor a b)) + -- :: adapt +:: +++ what + |= fat=(node plum) + :: + |= fal=(list (pair path plum)) + =/ del (~(group adapt fat) fal) + =/ but (~(usurp adapt fat) del) + =/ job (~(adorn adapt fat) del force=?=(^ but)) + :: + :: adopt system changes + :: + =. fat (~(gas de:node fat) ~(tap by sys.del)) + :: + :: just adopt user changes, which have no systems impact + :: + :: XX or ignore? useful for bootstrap? + :: + =. fat (~(gas de:node fat) ~(tap by use.del)) + :: + [[but job] fat] +-- +:: +=| fat=(node plum) +=^ one fat + %- (what fat) + :~ /sys/hoon^hoon+%a + /sys/arvo^hoon+%a + /sys/lull^hoon+%a + /sys/zuse^hoon+%a + /sys/vane/foo^hoon+%a + /sys/vane/bar^hoon+%a + /sys/vane/baz^hoon+%a + /app/dojo^hoon+%a + /lib/drum^hoon+%a + == +=^ two fat + %- (what fat) + :~ /sys/arvo^hoon+%b + /sys/lull^hoon+%b + /sys/vane/foo^hoon+%b + == +[one two fat] From 55e9bd7056d89838bc0f042bad5d53c9674ded32 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 27 Apr 2020 14:54:33 -0700 Subject: [PATCH 021/933] jets: Add +slaw jet which parses %ud and %tas. Falls back for other types. --- pkg/urbit/include/jets/w.h | 2 + pkg/urbit/jets/e/slaw.c | 105 +++++++++++++++++++++++++++++++++++++ pkg/urbit/jets/tree.c | 5 ++ 3 files changed, 112 insertions(+) create mode 100644 pkg/urbit/jets/e/slaw.c diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index 98d8e07db3..439c0be820 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -116,6 +116,8 @@ u3_noun u3we_rexp(u3_noun); u3_noun u3we_trip(u3_noun); + u3_noun u3we_slaw(u3_noun); + u3_noun u3we_pfix(u3_noun); u3_noun u3we_plug(u3_noun); u3_noun u3we_pose(u3_noun); diff --git a/pkg/urbit/jets/e/slaw.c b/pkg/urbit/jets/e/slaw.c new file mode 100644 index 0000000000..f27436ccd3 --- /dev/null +++ b/pkg/urbit/jets/e/slaw.c @@ -0,0 +1,105 @@ +/* j/3/slaw.c +** +*/ +#include "all.h" + +#include + +/* functions +*/ + + u3_noun + _parse_ud(u3_noun txt) { + c3_c* c = u3r_string(txt); + + // First character must represent a digit + c3_c* cur = c; + if (cur[0] > '9' || cur[0] < '0') { + c3_free(c); + return 0; + } + c3_w total = cur[0] - '0'; + cur++; + + int since_last_period = 0; + while (cur[0] != 0) { + since_last_period++; + if (cur[0] == '.') { + since_last_period = 0; + cur++; + continue; + } + + if (cur[0] > '9' || cur[0] < '0') { + c3_free(c); + return 0; + } + + total = u3qa_mul(total, 10); + total = u3qa_add(total, cur[0] - '0'); + cur++; + + if (since_last_period > 3) { + c3_free(c); + return 0; + } + } + + c3_free(c); + return u3nc(0, total); + } + + u3_noun + _parse_tas(u3_noun txt) { + // For any symbol which matches, txt will return itself as a + // value. Therefore, this is mostly checking validity. + c3_c* c = u3r_string(txt); + + // First character must represent a lowercase letter + c3_c* cur = c; + if (!islower(cur[0])) { + c3_free(c); + return 0; + } + cur++; + + while (cur[0] != 0) { + if (!(islower(cur[0]) || isdigit(cur[0]) || cur[0] == '-')) { + c3_free(c); + return 0; + } + + cur++; + } + + c3_free(c); + return u3nc(0, txt); + } + + u3_noun + u3we_slaw(u3_noun cor) + { + u3_noun mod; + u3_noun txt; + + if (c3n == u3r_mean(cor, u3x_sam_2, &mod, + u3x_sam_3, &txt, 0) || + !_(u3a_is_cat(mod))) { + return u3m_bail(c3__fail); + } + + switch (mod) { + /* TODO: case c3__p. Need background jets first. */ + + case c3__ud: + return _parse_ud(txt); + + // %ta is used once in link.hoon. don't bother. + + case c3__tas: + return _parse_tas(txt); + + default: + return u3_none; + } + } diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 43c266a960..75b8fc0e8d 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -607,6 +607,9 @@ static c3_c* _141_qua_trip_ha[] = { 0 }; +static u3j_harm _141_qua_slaw_a[] = {{".2", u3we_slaw}, {}}; + + static u3j_harm _141_qua__po_ind_a[] = {{".2", u3wcp_ind}, {}}; static c3_c* _141_qua__po_ind_ha[] = { "95bbe9867dbbd1b9ce12671d64cf7b1dee8d987c6770955a83c73291c4537a61", @@ -883,6 +886,8 @@ static u3j_core _141_qua_d[] = { "mink", 7, _141_qua_mink_a, 0, _141_qua_mink_ha }, { "mule", 7, _141_qua_mule_a, 0, _141_qua_mule_ha }, + + { "slaw", 7, _141_qua_slaw_a, 0, 0 }, {} }; static c3_c* _141_qua_ha[] = { From 716cd2013f16dd015a58c372997af799d95ad126 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 27 Apr 2020 16:25:30 -0700 Subject: [PATCH 022/933] jets: Start jetting +ob. Since the most used parser in +slaw is the @p one, that's up next. But first, we need to jet parts of +ob, which gets called through +fed:ag. --- pkg/arvo/sys/hoon.hoon | 10 ++++++++ pkg/urbit/include/jets/w.h | 2 ++ pkg/urbit/jets/c/ob.c | 48 ++++++++++++++++++++++++++++++++++++++ pkg/urbit/jets/e/slaw.c | 12 ++++++++++ pkg/urbit/jets/tree.c | 10 ++++++++ 5 files changed, 82 insertions(+) create mode 100644 pkg/urbit/jets/c/ob.c diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 9b809933b6..0e2f79efa4 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -3810,6 +3810,7 @@ -- :: ++ ob + ~% %ob + ~ |% :: +fein: conceal structure, v3. :: @@ -3817,6 +3818,7 @@ :: trivial to tell which planet a star has spawned under. :: ++ fein + ~/ %fein |= pyn/@ ^- @ ?: &((gte pyn 0x1.0000) (lte pyn 0xffff.ffff)) (add 0x1.0000 (feis (sub pyn 0x1.0000))) @@ -3832,6 +3834,7 @@ :: Restores obfuscated values that have been enciphered with +fein. :: ++ fynd + ~/ %fynd |= cry/@ ^- @ ?: &((gte cry 0x1.0000) (lte cry 0xffff.ffff)) (add 0x1.0000 (tail (sub cry 0x1.0000))) @@ -3848,6 +3851,7 @@ :: See: Black & Rogaway (2002), Ciphers for arbitrary finite domains. :: ++ feis + ~/ %feis |= m=@ ^- @ (fee 4 0xffff 0x1.0000 (mul 0xffff 0x1.0000) eff m) @@ -3855,6 +3859,7 @@ :: +tail: reverse +feis. :: ++ tail + ~/ %tail |= m=@ ^- @ (feen 4 0xffff 0x1.0000 (mul 0xffff 0x1.0000) eff m) @@ -3871,6 +3876,7 @@ :: m: an input value in the domain [0, k - 1] :: ++ fee + ~/ %fee |= [r=@ a=@ b=@ k=@ prf=$-([j=@ r=@] @) m=@] ^- @ =/ c (fe r a b prf m) @@ -3884,6 +3890,7 @@ :: +fee. :: ++ feen + ~/ %feen |= [r=@ a=@ b=@ k=@ prf=$-([j=@ r=@] @) m=@] ^- @ =/ c (fen r a b prf m) @@ -3899,6 +3906,7 @@ :: to support some legacy behaviour. See urbit/arvo#1105. :: ++ fe + ~/ %fe |= [r=@ a=@ b=@ prf=$-([j=@ r=@] @) m=@] =/ j 1 =/ ell (mod m a) @@ -3937,6 +3945,7 @@ :: to support some legacy behaviour. See urbit/arvo#1105. :: ++ fen + ~/ %fen |= [r=@ a=@ b=@ prf=$-([j=@ r=@] @) m=@] =/ j r :: @@ -3985,6 +3994,7 @@ :: +eff: a murmur3-based pseudorandom function. 'F' in B&R (2002). :: ++ eff + ~/ %eff |= [j=@ r=@] ^- @ (muk (snag j raku) 2 r) diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index 439c0be820..33c1610cee 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -76,6 +76,8 @@ u3_noun u3wcp_tos(u3_noun); u3_noun u3wcp_tod(u3_noun); + u3_noun u3wc_ob_eff(u3_noun); + /** Tier 4. **/ u3_noun u3wdb_bif(u3_noun); diff --git a/pkg/urbit/jets/c/ob.c b/pkg/urbit/jets/c/ob.c new file mode 100644 index 0000000000..5393406164 --- /dev/null +++ b/pkg/urbit/jets/c/ob.c @@ -0,0 +1,48 @@ +/* j/3/ob.c +** +*/ +#include "all.h" + +u3_noun +u3qc_ob_eff(u3_atom j, u3_atom r) +{ + c3_d found = 0; + switch (j) { + case 0: + found = 0xb76d5eed; + break; + case 1: + found = 0xee281300; + break; + case 2: + found = 0x85bcae01; + break; + case 3: + found = 0x4b387af7; + break; + default: + // the internal snag would have failed. + return u3m_bail(c3__exit); + } + + return u3qc_muk(u3i_chubs(1, &found), 2, r); +} + +u3_noun +u3wc_ob_eff(u3_noun cor) +{ + u3_noun j, r; + + if ( (c3n == u3r_mean(cor, u3x_sam_2, &j, + u3x_sam_3, &r, 0)) || + (c3n == u3ud(j)) || + (c3n == u3ud(r)) ) + { + fprintf(stderr, "u3wc_ob_eff failed to unpack\r\n"); + return u3m_bail(c3__exit); + } + else { + return u3qc_ob_eff(j, r); + } +} + diff --git a/pkg/urbit/jets/e/slaw.c b/pkg/urbit/jets/e/slaw.c index f27436ccd3..52cdfe6907 100644 --- a/pkg/urbit/jets/e/slaw.c +++ b/pkg/urbit/jets/e/slaw.c @@ -49,6 +49,18 @@ return u3nc(0, total); } + // parsing @p: + // + // +slaw calls +fed:ag directly. +fed:ag: + // + // - parses the text first into a number. + // - runs fynd:ob, which is the scrambler restore structure. And +fynd is + // unjetted. + // + // The actual +po stuff, like +ins:po, is jetted but it's jetted such that it + // pulls the tables out of the sample, so we can't just reuse it from other + // jets. + u3_noun _parse_tas(u3_noun txt) { // For any symbol which matches, txt will return itself as a diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 75b8fc0e8d..d3a3cac036 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -923,6 +923,14 @@ static c3_c* _141_tri__cofl_ha[] = { 0 }; + +static u3j_harm _141_tri__ob_eff_a[] = {{".2", u3wc_ob_eff}, {}}; +static u3j_core _141_tri__ob_d[] = + { { "eff", 7, _141_tri__ob_eff_a, 0, 0 }, + {} + }; + + static u3j_harm _141_tri__rd_add_a[] = {{".2", u3wer_add}, {}}; static c3_c* _141_tri__rd_add_ha[] = { "90dfaaadb2878d6d89a808ce4199e5bb239fa981e1c2edf24dc54aa3fcab55a5", @@ -1270,6 +1278,7 @@ static c3_c* _141_tri_shal_ha[] = { static u3j_core _141_tri_d[] = { { "qua", 3, 0, _141_qua_d, _141_qua_ha, _141_qua_ho }, + { "ob", 3, 0, _141_tri__ob_d, 0 }, { "cofl", 7, 0, _141_tri__cofl_d, _141_tri__cofl_ha }, { "rd", 7, 0, _141_tri__rd_d, _141_tri__rd_ha }, { "rs", 7, 0, _141_tri__rs_d, _141_tri__rs_ha }, @@ -1282,6 +1291,7 @@ static u3j_core _141_tri_d[] = { "shay", 7, _141_tri_shay_a, 0, _141_tri_shay_ha }, { "shas", 7, _141_tri_shas_a, 0, _141_tri_shas_ha }, { "shal", 7, _141_tri_shal_a, 0, _141_tri_shal_ha }, + {} }; static c3_c* _141_tri_ha[] = { From 17d895241d3e9c0f0a63fb23036583b468983f56 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 27 Apr 2020 17:37:04 -0700 Subject: [PATCH 023/933] jets: jet +fen:ob --- pkg/urbit/include/jets/w.h | 1 + pkg/urbit/jets/c/ob.c | 79 ++++++++++++++++++++++++++++++++++++++ pkg/urbit/jets/tree.c | 4 +- 3 files changed, 83 insertions(+), 1 deletion(-) diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index 33c1610cee..3809780073 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -76,6 +76,7 @@ u3_noun u3wcp_tos(u3_noun); u3_noun u3wcp_tod(u3_noun); + u3_noun u3wc_ob_fen(u3_noun); u3_noun u3wc_ob_eff(u3_noun); /** Tier 4. diff --git a/pkg/urbit/jets/c/ob.c b/pkg/urbit/jets/c/ob.c index 5393406164..4d6504582c 100644 --- a/pkg/urbit/jets/c/ob.c +++ b/pkg/urbit/jets/c/ob.c @@ -3,6 +3,85 @@ */ #include "all.h" +u3_noun +u3qc_ob_fen(u3_atom r, + u3_atom a, + u3_atom b, + u3j_site* prf_u, + u3_atom m) +{ + u3_atom j = r; + + u3_atom ahh; + u3_atom ale; + if (c3y == u3r_sing(u3qa_mod(r, 2), 0)) { + ahh = u3qa_mod(m, a); + ale = u3qa_div(m, a); + } else { + ahh = u3qa_div(m, a); + ale = u3qa_mod(m, a); + } + + u3_atom ell; + u3_atom arr; + if (c3y == u3r_sing(ale, a)) { + ell = ahh; + arr = ale; + } else { + ell = ale; + arr = ahh; + } + + while (1) { + if (c3y == u3qa_lth(j, 1)) { + return u3qa_add(u3qa_mul(arr, a), ell); + } + + u3_atom f = u3j_gate_slam(prf_u, u3nc(u3qa_sub(j, 1), ell)); + + u3_atom tmp; + if (c3y == u3r_sing(u3qa_mod(j, 2), 0)) { + tmp = u3qa_mod(u3qa_sub(u3qa_add(arr, b), u3qa_mod(f, b)), b); + } else { + tmp = u3qa_mod(u3qa_sub(u3qa_add(arr, a), u3qa_mod(f, a)), a); + } + + j = u3qa_sub(j, 1); + arr = ell; + ell = tmp; + } +} + +u3_noun +u3wc_ob_fen(u3_noun cor) +{ + u3_noun r, a, b, prf, m; + + if ( (c3n == u3r_mean(cor, u3x_sam_2, &r, + u3x_sam_6, &a, + u3x_sam_14, &b, + u3x_sam_30, &prf, + u3x_sam_31, &m, 0)) || + (c3n == u3ud(r)) || + (c3n == u3ud(a)) || + (c3n == u3ud(b)) || + (c3n == u3ud(m)) ) + { + fprintf(stderr, "u3wc_ob_fen failed to unpack\r\n"); + return u3m_bail(c3__exit); + } + else { + u3_noun pro; + u3j_site sit_u; + + u3j_gate_prep(&sit_u, u3k(prf)); + pro = u3qc_ob_fen(r, a, b, &sit_u, m); + u3j_gate_lose(&sit_u); + return pro; + } +} + + u3_noun u3qc_ob_eff(u3_atom j, u3_atom r) { diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index d3a3cac036..0bfad04d18 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -924,9 +924,11 @@ static c3_c* _141_tri__cofl_ha[] = { }; +static u3j_harm _141_tri__ob_fen_a[] = {{".2", u3wc_ob_fen}, {}}; static u3j_harm _141_tri__ob_eff_a[] = {{".2", u3wc_ob_eff}, {}}; static u3j_core _141_tri__ob_d[] = - { { "eff", 7, _141_tri__ob_eff_a, 0, 0 }, + { { "fen", 7, _141_tri__ob_fen_a, 0, 0 }, + { "eff", 7, _141_tri__ob_eff_a, 0, 0 }, {} }; From bc9c4b67d6c7972736ae5e494a6b036ae7d996b7 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 27 Apr 2020 17:41:34 -0700 Subject: [PATCH 024/933] jets: add the direct atom optimization to +mod +mod was going to libgmp when both operands fit in 31-bits. --- pkg/urbit/jets/a/mod.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/pkg/urbit/jets/a/mod.c b/pkg/urbit/jets/a/mod.c index f80834e1b8..80c8923ca6 100644 --- a/pkg/urbit/jets/a/mod.c +++ b/pkg/urbit/jets/a/mod.c @@ -10,15 +10,10 @@ u3qa_mod(u3_atom a, u3_atom b) { -#if 0 - if ( b == 3 && a == 2684227708 ) { - printf("dword at 0x27ff84ff8 is %" PRIu64 "\r\n", *(c3_d *)0x27ff84ff8); - *(c3_d *)0x27ff84ff8 = 25; - printf("see, we modified it\r\n"); - } -#endif if ( 0 == b ) { return u3m_bail(c3__exit); + } else if ( _(u3a_is_cat(a)) && _(u3a_is_cat(b)) ) { + return a % b; } else { mpz_t a_mp, b_mp; From ff86cbf12bc33ab6c64d3c25e9154eec9e2d6b7d Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 28 Apr 2020 10:54:30 -0700 Subject: [PATCH 025/933] jets: Implement most of +ob, minus the toplevel concealments. --- pkg/urbit/include/jets/w.h | 5 + pkg/urbit/include/noun/xtract.h | 2 + pkg/urbit/jets/c/ob.c | 378 +++++++++++++++++++++++++------- pkg/urbit/jets/tree.c | 12 +- 4 files changed, 319 insertions(+), 78 deletions(-) diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index 3809780073..1d931bcbe4 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -76,6 +76,11 @@ u3_noun u3wcp_tos(u3_noun); u3_noun u3wcp_tod(u3_noun); + u3_noun u3wc_ob_feis(u3_noun); + u3_noun u3wc_ob_tail(u3_noun); + u3_noun u3wc_ob_fee(u3_noun); + u3_noun u3wc_ob_feen(u3_noun); + u3_noun u3wc_ob_fe(u3_noun); u3_noun u3wc_ob_fen(u3_noun); u3_noun u3wc_ob_eff(u3_noun); diff --git a/pkg/urbit/include/noun/xtract.h b/pkg/urbit/include/noun/xtract.h index 594638f3f7..5e2f95dae4 100644 --- a/pkg/urbit/include/noun/xtract.h +++ b/pkg/urbit/include/noun/xtract.h @@ -21,6 +21,8 @@ # define u3x_sam_15 55 # define u3x_sam_30 110 # define u3x_sam_31 111 +# define u3x_sam_62 222 +# define u3x_sam_63 223 # define u3x_con 7 // context # define u3x_con_2 14 // context # define u3x_con_3 15 // context diff --git a/pkg/urbit/jets/c/ob.c b/pkg/urbit/jets/c/ob.c index 4d6504582c..c0649fa1c7 100644 --- a/pkg/urbit/jets/c/ob.c +++ b/pkg/urbit/jets/c/ob.c @@ -3,87 +3,21 @@ */ #include "all.h" +// Functions written in reverse order from the core because earlier functions +// depend on later functions. + +// We have to both suport passing u3qc_ob_eff around and passing a prepared +// gate which usually, but not necessarily points to it. So we have a +// trampoline which slams a gate, but have the same signature as the normal eff +// hash function. u3_noun -u3qc_ob_fen(u3_atom r, - u3_atom a, - u3_atom b, - u3j_site* prf_u, - u3_atom m) +_do_slam_gate(u3_atom j, u3_atom r, void* datum) { - u3_atom j = r; - - u3_atom ahh; - u3_atom ale; - if (c3y == u3r_sing(u3qa_mod(r, 2), 0)) { - ahh = u3qa_mod(m, a); - ale = u3qa_div(m, a); - } else { - ahh = u3qa_div(m, a); - ale = u3qa_mod(m, a); - } - - u3_atom ell; - u3_atom arr; - if (c3y == u3r_sing(ale, a)) { - ell = ahh; - arr = ale; - } else { - ell = ale; - arr = ahh; - } - - while (1) { - if (c3y == u3qa_lth(j, 1)) { - return u3qa_add(u3qa_mul(arr, a), ell); - } - - u3_atom f = u3j_gate_slam(prf_u, u3nc(u3qa_sub(j, 1), ell)); - - u3_atom tmp; - if (c3y == u3r_sing(u3qa_mod(j, 2), 0)) { - tmp = u3qa_mod(u3qa_sub(u3qa_add(arr, b), u3qa_mod(f, b)), b); - } else { - tmp = u3qa_mod(u3qa_sub(u3qa_add(arr, a), u3qa_mod(f, a)), a); - } - - j = u3qa_sub(j, 1); - arr = ell; - ell = tmp; - } + return u3j_gate_slam((u3j_site*)datum, u3nc(j, r)); } u3_noun -u3wc_ob_fen(u3_noun cor) -{ - u3_noun r, a, b, prf, m; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &r, - u3x_sam_6, &a, - u3x_sam_14, &b, - u3x_sam_30, &prf, - u3x_sam_31, &m, 0)) || - (c3n == u3ud(r)) || - (c3n == u3ud(a)) || - (c3n == u3ud(b)) || - (c3n == u3ud(m)) ) - { - fprintf(stderr, "u3wc_ob_fen failed to unpack\r\n"); - return u3m_bail(c3__exit); - } - else { - u3_noun pro; - u3j_site sit_u; - - u3j_gate_prep(&sit_u, u3k(prf)); - pro = u3qc_ob_fen(r, a, b, &sit_u, m); - u3j_gate_lose(&sit_u); - return pro; - } -} - - -u3_noun -u3qc_ob_eff(u3_atom j, u3_atom r) +u3qc_ob_eff(u3_atom j, u3_atom r, void* unused) { c3_d found = 0; switch (j) { @@ -121,7 +55,297 @@ u3wc_ob_eff(u3_noun cor) return u3m_bail(c3__exit); } else { - return u3qc_ob_eff(j, r); + return u3qc_ob_eff(j, r, 0); } } +u3_noun +u3qc_ob_fen(u3_atom r, + u3_atom a, + u3_atom b, + u3_atom(*prf_fun)(u3_atom j, u3_atom r, void* datum_u), + void* datum_u, + u3_atom m) +{ + u3_atom j = r; + + u3_atom ahh; + u3_atom ale; + if (c3y == u3r_sing(u3qa_mod(r, 2), 0)) { + ahh = u3qa_mod(m, a); + ale = u3qa_div(m, a); + } else { + ahh = u3qa_div(m, a); + ale = u3qa_mod(m, a); + } + + u3_atom ell; + u3_atom arr; + if (c3y == u3r_sing(ale, a)) { + ell = ahh; + arr = ale; + } else { + ell = ale; + arr = ahh; + } + + while (1) { + if (c3y == u3qa_lth(j, 1)) { + return u3qa_add(u3qa_mul(arr, a), ell); + } + + u3_atom f = (*prf_fun)(u3qa_sub(j, 1), ell, datum_u); + + u3_atom tmp; + if (c3y == u3r_sing(u3qa_mod(j, 2), 0)) { + tmp = u3qa_mod(u3qa_sub(u3qa_add(arr, b), u3qa_mod(f, b)), b); + } else { + tmp = u3qa_mod(u3qa_sub(u3qa_add(arr, a), u3qa_mod(f, a)), a); + } + + j = u3qa_sub(j, 1); + arr = ell; + ell = tmp; + } +} + +u3_noun +u3wc_ob_fen(u3_noun cor) +{ + u3_noun r, a, b, prf, m; + + if ( (c3n == u3r_mean(cor, u3x_sam_2, &r, + u3x_sam_6, &a, + u3x_sam_14, &b, + u3x_sam_30, &prf, + u3x_sam_31, &m, 0)) || + (c3n == u3ud(r)) || + (c3n == u3ud(a)) || + (c3n == u3ud(b)) || + (c3n == u3ud(m)) ) + { + fprintf(stderr, "u3wc_ob_fen failed to unpack\r\n"); + return u3m_bail(c3__exit); + } + else { + u3_noun pro; + u3j_site sit_u; + + u3j_gate_prep(&sit_u, u3k(prf)); + pro = u3qc_ob_fen(r, a, b, _do_slam_gate, &sit_u, m); + u3j_gate_lose(&sit_u); + return pro; + } +} + + +u3_noun +u3qc_ob_fe(u3_atom r, + u3_atom a, + u3_atom b, + u3_atom(*prf_fun)(u3_atom j, u3_atom r, void* datum_u), + void* datum_u, + u3_atom m) +{ + u3_atom j = 1; + u3_atom ell = u3qa_mod(m, a); + u3_atom arr = u3qa_div(m, a); + + while (1) { + if (c3y == u3qa_gth(j, r)) { + if (c3n == u3r_sing(u3qa_mod(r, 2), 0)) { + return u3qa_add(u3qa_mul(arr, a), ell); + } + + if (c3y == u3r_sing(arr, a)) { + return u3qa_add(u3qa_mul(arr, a), ell); + } + + return u3qa_add(u3qa_mul(ell, a), arr); + } + + // u3_atom f = u3j_gate_slam(prf_u, u3nc(u3qa_sub(j, 1), arr)); + u3_atom f = (*prf_fun)(u3qa_sub(j, 1), arr, datum_u); + + u3_atom tmp; + if (c3n == u3r_sing(u3qa_mod(j, 2), 0)) { + tmp = u3qa_mod(u3qa_add(f, ell), a); + } else { + tmp = u3qa_mod(u3qa_add(f, ell), b); + } + + j = u3qa_add(j, 1); + ell = arr; + arr = tmp; + } +} + +u3_noun +u3wc_ob_fe(u3_noun cor) +{ + u3_noun r, a, b, prf, m; + + if ( (c3n == u3r_mean(cor, u3x_sam_2, &r, + u3x_sam_6, &a, + u3x_sam_14, &b, + u3x_sam_30, &prf, + u3x_sam_31, &m, 0)) || + (c3n == u3ud(r)) || + (c3n == u3ud(a)) || + (c3n == u3ud(b)) || + (c3n == u3ud(m)) ) + { + fprintf(stderr, "u3wc_ob_fe failed to unpack\r\n"); + return u3m_bail(c3__exit); + } + else { + u3_noun pro; + u3j_site sit_u; + + u3j_gate_prep(&sit_u, u3k(prf)); + pro = u3qc_ob_fe(r, a, b, _do_slam_gate, &sit_u, m); + u3j_gate_lose(&sit_u); + return pro; + } +} + + +u3_noun +u3qc_ob_feen(u3_atom r, + u3_atom a, + u3_atom b, + u3_atom k, + u3_atom(*prf_fun)(u3_atom j, u3_atom r, void* datum_u), + void* datum_u, + u3_atom m) +{ + u3_atom c = u3qc_ob_fen(r, a, b, prf_fun, datum_u, m); + if (c3y == u3qa_lth(c, k)) { + return c; + } + + return u3qc_ob_fen(r, a, b, prf_fun, datum_u, c); +} + +u3_noun +u3wc_ob_feen(u3_noun cor) +{ + u3_noun r, a, b, k, prf, m; + + if ( (c3n == u3r_mean(cor, u3x_sam_2, &r, + u3x_sam_6, &a, + u3x_sam_14, &b, + u3x_sam_30, &k, + u3x_sam_62, &prf, + u3x_sam_63, &m, 0)) || + (c3n == u3ud(r)) || + (c3n == u3ud(a)) || + (c3n == u3ud(b)) || + (c3n == u3ud(k)) || + (c3n == u3ud(m)) ) + { + fprintf(stderr, "u3wc_ob_fe failed to unpack\r\n"); + return u3m_bail(c3__exit); + } + else { + u3_noun pro; + u3j_site sit_u; + + u3j_gate_prep(&sit_u, u3k(prf)); + pro = u3qc_ob_feen(r, a, b, k, _do_slam_gate, &sit_u, m); + u3j_gate_lose(&sit_u); + return pro; + } +} + + +u3_noun +u3qc_ob_fee(u3_atom r, + u3_atom a, + u3_atom b, + u3_atom k, + u3_atom(*prf_fun)(u3_atom j, u3_atom r, void* datum_u), + void* datum_u, + u3_atom m) +{ + u3_atom c = u3qc_ob_fe(r, a, b, prf_fun, datum_u, m); + if (c3y == u3qa_lth(c, k)) { + return c; + } + + return u3qc_ob_fe(r, a, b, prf_fun, datum_u, c); +} + +u3_noun +u3wc_ob_fee(u3_noun cor) +{ + u3_noun r, a, b, k, prf, m; + + if ( (c3n == u3r_mean(cor, u3x_sam_2, &r, + u3x_sam_6, &a, + u3x_sam_14, &b, + u3x_sam_30, &k, + u3x_sam_62, &prf, + u3x_sam_63, &m, 0)) || + (c3n == u3ud(r)) || + (c3n == u3ud(a)) || + (c3n == u3ud(b)) || + (c3n == u3ud(k)) || + (c3n == u3ud(m)) ) + { + return u3m_bail(c3__exit); + } + else { + u3_noun pro; + u3j_site sit_u; + + u3j_gate_prep(&sit_u, u3k(prf)); + pro = u3qc_ob_fee(r, a, b, k, _do_slam_gate, &sit_u, m); + u3j_gate_lose(&sit_u); + return pro; + } +} + +u3_noun +u3qc_ob_tail(u3_atom m) +{ + return u3qc_ob_feen(4, 0xffff, 0x10000, u3qa_mul(0xffff, 0x10000), + u3qc_ob_eff, (void*)0, m); +} + +u3_noun +u3wc_ob_tail(u3_noun cor) +{ + u3_noun m; + + if ( (c3n == u3r_mean(cor, u3x_sam, &m, 0)) || + (c3n == u3ud(m)) ) + { + return u3m_bail(c3__exit); + } + else { + return u3qc_ob_tail(m); + } +} + +u3_noun +u3qc_ob_feis(u3_atom m) +{ + return u3qc_ob_fee(4, 0xffff, 0x10000, u3qa_mul(0xffff, 0x10000), + u3qc_ob_eff, (void*)0, m); +} + +u3_noun +u3wc_ob_feis(u3_noun cor) +{ + u3_noun m; + + if ( (c3n == u3r_mean(cor, u3x_sam, &m, 0)) || + (c3n == u3ud(m)) ) + { + return u3m_bail(c3__exit); + } + else { + return u3qc_ob_feis(m); + } +} diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 0bfad04d18..fe40996f00 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -924,10 +924,20 @@ static c3_c* _141_tri__cofl_ha[] = { }; +static u3j_harm _141_tri__ob_feis_a[] = {{".2", u3wc_ob_feis}, {}}; +static u3j_harm _141_tri__ob_tail_a[] = {{".2", u3wc_ob_tail}, {}}; +static u3j_harm _141_tri__ob_fee_a[] = {{".2", u3wc_ob_fee}, {}}; +static u3j_harm _141_tri__ob_feen_a[] = {{".2", u3wc_ob_feen}, {}}; +static u3j_harm _141_tri__ob_fe_a[] = {{".2", u3wc_ob_fe}, {}}; static u3j_harm _141_tri__ob_fen_a[] = {{".2", u3wc_ob_fen}, {}}; static u3j_harm _141_tri__ob_eff_a[] = {{".2", u3wc_ob_eff}, {}}; static u3j_core _141_tri__ob_d[] = - { { "fen", 7, _141_tri__ob_fen_a, 0, 0 }, + { { "feis", 7, _141_tri__ob_feis_a, 0, 0 }, + { "tail", 7, _141_tri__ob_tail_a, 0, 0 }, + { "fee", 7, _141_tri__ob_fee_a, 0, 0 }, + { "feen", 7, _141_tri__ob_feen_a, 0, 0 }, + { "fe", 7, _141_tri__ob_fe_a, 0, 0 }, + { "fen", 7, _141_tri__ob_fen_a, 0, 0 }, { "eff", 7, _141_tri__ob_eff_a, 0, 0 }, {} }; From 91badd63762e7c9eb48c13c0ea6222e692f61333 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 28 Apr 2020 12:47:03 -0700 Subject: [PATCH 026/933] jets: Rest of +ob that we're going to jet, and make +po callable. All of the +ob jets that we need from the parsing jet are done. Also changed how +po works to case based lookup tables so we can call this code from other jets. (Also, linear search on every syllable in a @p is kinda bad.) --- pkg/urbit/include/jets/q.h | 5 + pkg/urbit/include/jets/w.h | 1 + pkg/urbit/jets/c/ob.c | 39 ++ pkg/urbit/jets/c/po.c | 883 +++++++++++++++++++++++++++++++++++-- pkg/urbit/jets/e/slaw.c | 13 + pkg/urbit/jets/tree.c | 4 +- 6 files changed, 917 insertions(+), 28 deletions(-) diff --git a/pkg/urbit/include/jets/q.h b/pkg/urbit/include/jets/q.h index 68f9466036..bd283fbba0 100644 --- a/pkg/urbit/include/jets/q.h +++ b/pkg/urbit/include/jets/q.h @@ -70,6 +70,11 @@ u3_noun u3qc_swp(u3_atom, u3_atom); u3_noun u3qc_sqt(u3_atom); + u3_noun u3qc_po_ind(u3_atom); + u3_noun u3qc_po_ins(u3_atom); + + u3_noun u3qc_ob_fynd(u3_atom); + /** Tier 4. **/ u3_noun u3qdb_bif(u3_noun, u3_noun); diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index 1d931bcbe4..57c1d3d574 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -76,6 +76,7 @@ u3_noun u3wcp_tos(u3_noun); u3_noun u3wcp_tod(u3_noun); + u3_noun u3wc_ob_fynd(u3_noun); u3_noun u3wc_ob_feis(u3_noun); u3_noun u3wc_ob_tail(u3_noun); u3_noun u3wc_ob_fee(u3_noun); diff --git a/pkg/urbit/jets/c/ob.c b/pkg/urbit/jets/c/ob.c index c0649fa1c7..e5999af90b 100644 --- a/pkg/urbit/jets/c/ob.c +++ b/pkg/urbit/jets/c/ob.c @@ -349,3 +349,42 @@ u3wc_ob_feis(u3_noun cor) return u3qc_ob_feis(m); } } + +u3_noun +u3qc_ob_fynd(u3_atom cry) +{ + c3_d BIGGEST_PLANET = 0xffffffffULL; + c3_d SMALLEST_MOON = 0x100000000ULL; + c3_d BIGGEST_MOON = 0xffffffffffffffffULL; + + c3_d MOON_MASK = 0xffffffff00000000ULL; + + if (c3y == u3qa_gte(cry, 0x10000) && + c3y == u3qa_lte(cry, u3i_chubs(1, &BIGGEST_PLANET))) { + return u3qa_add(0x10000, u3qc_ob_tail(u3qa_sub(cry, 0x10000))); + } + + if (c3y == u3qa_gte(cry, u3i_chubs(1, &SMALLEST_MOON)) && + c3y == u3qa_lte(cry, u3i_chubs(1, &BIGGEST_MOON))) { + u3_atom lo = u3qc_dis(cry, u3i_chubs(1, &BIGGEST_PLANET)); + u3_atom hi = u3qc_dis(cry, u3i_chubs(1, &MOON_MASK)); + return u3qc_con(hi, u3qc_ob_fynd(lo)); + } + + return cry; +} + +u3_noun +u3wc_ob_fynd(u3_noun cor) +{ + u3_noun m; + + if ( (c3n == u3r_mean(cor, u3x_sam, &m, 0)) || + (c3n == u3ud(m)) ) + { + return u3m_bail(c3__exit); + } + else { + return u3qc_ob_fynd(m); + } +} diff --git a/pkg/urbit/jets/c/po.c b/pkg/urbit/jets/c/po.c index b043d9afd4..a1cafa0f75 100644 --- a/pkg/urbit/jets/c/po.c +++ b/pkg/urbit/jets/c/po.c @@ -3,6 +3,820 @@ */ #include "all.h" +static u3_noun +find_prefix(char one, char two, char three) { + switch (one) { + case 'b': switch (two) { + case 'a': switch (three) { + case 'c': return u3nc(0, 238); + case 'l': return u3nc(0, 107); + case 'n': return u3nc(0, 92); + case 'r': return u3nc(0, 183); + case 't': return u3nc(0, 172); + default: return 0; + } + case 'i': switch (three) { + case 'c': return u3nc(0, 56); + case 'd': return u3nc(0, 106); + case 'l': return u3nc(0, 144); + case 'n': return u3nc(0, 2); + case 's': return u3nc(0, 60); + case 't': return u3nc(0, 182); + default: return 0; + } + case 'o': switch (three) { + case 'l': return u3nc(0, 45); + case 'n': return u3nc(0, 244); + case 'r': return u3nc(0, 188); + case 's': return u3nc(0, 171); + case 't': return u3nc(0, 98); + default: return 0; + } + default: return 0; + } + case 'd': switch (two) { + case 'a': switch (three) { + case 'b': return u3nc(0, 181); + case 'c': return u3nc(0, 117); + case 'l': return u3nc(0, 37); + case 'n': return u3nc(0, 234); + case 'p': return u3nc(0, 66); + case 'r': return u3nc(0, 23); + case 's': return u3nc(0, 61); + case 't': return u3nc(0, 215); + case 'v': return u3nc(0, 105); + default: return 0; + } + case 'i': switch (three) { + case 'b': return u3nc(0, 179); + case 'f': return u3nc(0, 57); + case 'g': return u3nc(0, 193); + case 'l': return u3nc(0, 49); + case 'n': return u3nc(0, 217); + case 'r': return u3nc(0, 11); + case 's': return u3nc(0, 129); + case 'v': return u3nc(0, 116); + default: return 0; + } + case 'o': switch (three) { + case 'c': return u3nc(0, 146); + case 'l': return u3nc(0, 102); + case 'n': return u3nc(0, 233); + case 'p': return u3nc(0, 18); + case 'r': return u3nc(0, 24); + case 's': return u3nc(0, 187); + case 't': return u3nc(0, 47); + case 'v': return u3nc(0, 236); + case 'z': return u3nc(0, 0); + default: return 0; + } + default: return 0; + } + case 'f': switch (two) { + case 'a': switch (three) { + case 'b': return u3nc(0, 120); + case 'd': return u3nc(0, 206); + case 'l': return u3nc(0, 152); + case 'm': return u3nc(0, 214); + case 'n': return u3nc(0, 158); + case 's': return u3nc(0, 195); + default: return 0; + } + case 'i': switch (three) { + case 'd': return u3nc(0, 8); + case 'g': return u3nc(0, 138); + case 'l': return u3nc(0, 194); + case 'n': return u3nc(0, 90); + case 'p': return u3nc(0, 255); + case 'r': return u3nc(0, 169); + case 't': return u3nc(0, 226); + default: return 0; + } + case 'o': switch (three) { + case 'd': return u3nc(0, 247); + case 'g': return u3nc(0, 20); + case 'l': return u3nc(0, 27); + case 'n': return u3nc(0, 91); + case 'p': return u3nc(0, 213); + case 'r': return u3nc(0, 50); + case 's': return u3nc(0, 46); + case 't': return u3nc(0, 221); + default: return 0; + } + default: return 0; + } + case 'h': switch (two) { + case 'a': switch (three) { + case 'b': return u3nc(0, 209); + case 'c': return u3nc(0, 174); + case 'd': return u3nc(0, 145); + case 'l': return u3nc(0, 203); + case 'n': return u3nc(0, 41); + case 'p': return u3nc(0, 156); + case 'r': return u3nc(0, 198); + case 's': return u3nc(0, 170); + case 't': return u3nc(0, 218); + case 'v': return u3nc(0, 176); + default: return 0; + } + case 'i': switch (three) { + case 'd': return u3nc(0, 7); + case 'l': return u3nc(0, 190); + case 'n': return u3nc(0, 200); + default: return 0; + } + case 'o': switch (three) { + case 'b': return u3nc(0, 197); + case 'c': return u3nc(0, 223); + case 'd': return u3nc(0, 26); + case 'l': return u3nc(0, 32); + case 'p': return u3nc(0, 22); + case 's': return u3nc(0, 180); + default: return 0; + } + default: return 0; + } + case 'l': switch (two) { + case 'a': switch (three) { + case 'b': return u3nc(0, 161); + case 'c': return u3nc(0, 34); + case 'd': return u3nc(0, 235); + case 'g': return u3nc(0, 205); + case 'n': return u3nc(0, 232); + case 'p': return u3nc(0, 240); + case 'r': return u3nc(0, 225); + case 's': return u3nc(0, 128); + case 't': return u3nc(0, 134); + case 'v': return u3nc(0, 252); + default: return 0; + } + case 'i': switch (three) { + case 'b': return u3nc(0, 39); + case 'd': return u3nc(0, 21); + case 'g': return u3nc(0, 111); + case 'n': return u3nc(0, 178); + case 's': return u3nc(0, 9); + case 't': return u3nc(0, 5); + case 'v': return u3nc(0, 36); + default: return 0; + } + case 'o': switch (three) { + case 'c': return u3nc(0, 69); + case 'd': return u3nc(0, 186); + case 'm': return u3nc(0, 166); + case 'n': return u3nc(0, 135); + case 'p': return u3nc(0, 63); + case 'r': return u3nc(0, 25); + case 's': return u3nc(0, 48); + default: return 0; + } + default: return 0; + } + case 'm': switch (two) { + case 'a': switch (three) { + case 'c': return u3nc(0, 191); + case 'g': return u3nc(0, 103); + case 'l': return u3nc(0, 110); + case 'p': return u3nc(0, 130); + case 'r': return u3nc(0, 1); + case 's': return u3nc(0, 202); + case 't': return u3nc(0, 253); + default: return 0; + } + case 'i': switch (three) { + case 'c': return u3nc(0, 157); + case 'd': return u3nc(0, 62); + case 'g': return u3nc(0, 199); + case 'l': return u3nc(0, 212); + case 'n': return u3nc(0, 79); + case 'p': return u3nc(0, 254); + case 'r': return u3nc(0, 31); + case 's': return u3nc(0, 126); + case 't': return u3nc(0, 196); + default: return 0; + } + case 'o': switch (three) { + case 'c': return u3nc(0, 148); + case 'd': return u3nc(0, 19); + case 'g': return u3nc(0, 162); + case 'l': return u3nc(0, 67); + case 'n': return u3nc(0, 122); + case 'p': return u3nc(0, 208); + case 'r': return u3nc(0, 93); + case 's': return u3nc(0, 231); + case 't': return u3nc(0, 82); + default: return 0; + } + default: return 0; + } + case 'n': switch (two) { + case 'a': switch (three) { + case 'c': return u3nc(0, 219); + case 'l': return u3nc(0, 230); + case 'm': return u3nc(0, 243); + case 'p': return u3nc(0, 87); + case 'r': return u3nc(0, 65); + case 't': return u3nc(0, 77); + case 'v': return u3nc(0, 137); + default: return 0; + } + case 'i': switch (three) { + case 'b': return u3nc(0, 140); + case 'd': return u3nc(0, 72); + case 'l': return u3nc(0, 210); + case 'm': return u3nc(0, 224); + case 's': return u3nc(0, 124); + default: return 0; + } + case 'o': switch (three) { + case 'c': return u3nc(0, 250); + case 'd': return u3nc(0, 136); + case 'l': return u3nc(0, 216); + case 'm': return u3nc(0, 139); + case 'p': return u3nc(0, 88); + case 'r': return u3nc(0, 97); + case 's': return u3nc(0, 211); + case 'v': return u3nc(0, 70); + default: return 0; + } + default: return 0; + } + case 'p': switch (two) { + case 'a': switch (three) { + case 'c': return u3nc(0, 149); + case 'd': return u3nc(0, 114); + case 'g': return u3nc(0, 141); + case 'l': return u3nc(0, 127); + case 'n': return u3nc(0, 78); + case 'r': return u3nc(0, 185); + case 's': return u3nc(0, 33); + case 't': return u3nc(0, 159); + default: return 0; + } + case 'i': switch (three) { + case 'c': return u3nc(0, 104); + case 'd': return u3nc(0, 43); + case 'l': return u3nc(0, 51); + case 'n': return u3nc(0, 165); + case 't': return u3nc(0, 242); + default: return 0; + } + case 'o': switch (three) { + case 'c': return u3nc(0, 173); + case 'd': return u3nc(0, 81); + case 'l': return u3nc(0, 239); + case 'n': return u3nc(0, 248); + case 's': return u3nc(0, 86); + default: return 0; + } + default: return 0; + } + case 'r': switch (two) { + case 'a': switch (three) { + case 'b': return u3nc(0, 131); + case 'c': return u3nc(0, 184); + case 'd': return u3nc(0, 201); + case 'g': return u3nc(0, 204); + case 'l': return u3nc(0, 143); + case 'm': return u3nc(0, 52); + case 'n': return u3nc(0, 123); + case 'p': return u3nc(0, 228); + case 'v': return u3nc(0, 150); + default: return 0; + } + case 'i': switch (three) { + case 'b': return u3nc(0, 222); + case 'c': return u3nc(0, 167); + case 'd': return u3nc(0, 147); + case 'g': return u3nc(0, 16); + case 'l': return u3nc(0, 64); + case 'n': return u3nc(0, 28); + case 'p': return u3nc(0, 151); + case 's': return u3nc(0, 220); + case 't': return u3nc(0, 80); + case 'v': return u3nc(0, 237); + default: return 0; + } + case 'o': switch (three) { + case 'c': return u3nc(0, 58); + case 'l': return u3nc(0, 133); + case 'n': return u3nc(0, 96); + case 'p': return u3nc(0, 75); + case 's': return u3nc(0, 245); + case 'v': return u3nc(0, 35); + default: return 0; + } + default: return 0; + } + case 's': switch (two) { + case 'a': switch (three) { + case 'b': return u3nc(0, 13); + case 'l': return u3nc(0, 115); + case 'm': return u3nc(0, 4); + case 'n': return u3nc(0, 68); + case 'p': return u3nc(0, 177); + case 'r': return u3nc(0, 229); + case 't': return u3nc(0, 38); + case 'v': return u3nc(0, 85); + default: return 0; + } + case 'i': switch (three) { + case 'b': return u3nc(0, 15); + case 'c': return u3nc(0, 74); + case 'd': return u3nc(0, 119); + case 'g': return u3nc(0, 6); + case 'l': return u3nc(0, 30); + case 'm': return u3nc(0, 163); + case 'p': return u3nc(0, 95); + case 't': return u3nc(0, 71); + case 'v': return u3nc(0, 112); + default: return 0; + } + case 'o': switch (three) { + case 'c': return u3nc(0, 100); + case 'g': return u3nc(0, 10); + case 'l': return u3nc(0, 17); + case 'm': return u3nc(0, 89); + case 'n': return u3nc(0, 164); + case 'p': return u3nc(0, 142); + case 'r': return u3nc(0, 251); + case 'v': return u3nc(0, 249); + default: return 0; + } + default: return 0; + } + case 't': switch (two) { + case 'a': switch (three) { + case 'b': return u3nc(0, 40); + case 'c': return u3nc(0, 160); + case 'd': return u3nc(0, 55); + case 'g': return u3nc(0, 113); + case 'l': return u3nc(0, 241); + case 'm': return u3nc(0, 83); + case 'n': return u3nc(0, 118); + case 'p': return u3nc(0, 168); + case 'r': return u3nc(0, 121); + case 's': return u3nc(0, 109); + default: return 0; + } + case 'i': switch (three) { + case 'c': return u3nc(0, 42); + case 'd': return u3nc(0, 175); + case 'l': return u3nc(0, 154); + case 'm': return u3nc(0, 108); + case 'n': return u3nc(0, 155); + case 'p': return u3nc(0, 73); + case 'r': return u3nc(0, 53); + default: return 0; + } + case 'o': switch (three) { + case 'b': return u3nc(0, 132); + case 'c': return u3nc(0, 189); + case 'd': return u3nc(0, 153); + case 'g': return u3nc(0, 29); + case 'l': return u3nc(0, 84); + case 'm': return u3nc(0, 192); + case 'n': return u3nc(0, 246); + case 'p': return u3nc(0, 207); + case 'r': return u3nc(0, 44); + default: return 0; + } + default: return 0; + } + case 'w': switch (two) { + case 'a': switch (three) { + case 'c': return u3nc(0, 12); + case 'l': return u3nc(0, 227); + case 'n': return u3nc(0, 3); + case 't': return u3nc(0, 101); + default: return 0; + } + case 'i': switch (three) { + case 'c': return u3nc(0, 99); + case 'd': return u3nc(0, 59); + case 'n': return u3nc(0, 54); + case 's': return u3nc(0, 14); + case 't': return u3nc(0, 76); + default: return 0; + } + case 'o': switch (three) { + case 'l': return u3nc(0, 125); + case 'r': return u3nc(0, 94); + default: return 0; + } + default: return 0; + } + default: return 0; + } +} + +static u3_noun +find_suffix(char one, char two, char three) { + switch (one) { + case 'b': switch (two) { + case 'e': switch (three) { + case 'c': return u3nc(0, 238); + case 'l': return u3nc(0, 107); + case 'n': return u3nc(0, 92); + case 'p': return u3nc(0, 183); + case 'r': return u3nc(0, 172); + case 's': return u3nc(0, 56); + case 't': return u3nc(0, 106); + case 'x': return u3nc(0, 144); + default: return 0; + } + case 'u': switch (three) { + case 'd': return u3nc(0, 2); + case 'r': return u3nc(0, 60); + case 's': return u3nc(0, 182); + default: return 0; + } + case 'y': switch (three) { + case 'l': return u3nc(0, 176); + case 'n': return u3nc(0, 45); + case 'r': return u3nc(0, 244); + case 't': return u3nc(0, 188); + default: return 0; + } + default: return 0; + } + case 'd': switch (two) { + case 'e': switch (three) { + case 'b': return u3nc(0, 171); + case 'c': return u3nc(0, 98); + case 'f': return u3nc(0, 181); + case 'g': return u3nc(0, 117); + case 'l': return u3nc(0, 37); + case 'm': return u3nc(0, 234); + case 'n': return u3nc(0, 66); + case 'p': return u3nc(0, 23); + case 'r': return u3nc(0, 61); + case 's': return u3nc(0, 215); + case 't': return u3nc(0, 105); + case 'v': return u3nc(0, 179); + case 'x': return u3nc(0, 57); + default: return 0; + } + case 'u': switch (three) { + case 'c': return u3nc(0, 193); + case 'l': return u3nc(0, 49); + case 'n': return u3nc(0, 217); + case 'r': return u3nc(0, 11); + case 's': return u3nc(0, 129); + case 't': return u3nc(0, 116); + case 'x': return u3nc(0, 146); + default: return 0; + } + case 'y': switch (three) { + case 'l': return u3nc(0, 102); + case 'n': return u3nc(0, 233); + case 'r': return u3nc(0, 18); + case 's': return u3nc(0, 24); + case 't': return u3nc(0, 187); + default: return 0; + } + default: return 0; + } + case 'f': switch (two) { + case 'e': switch (three) { + case 'b': return u3nc(0, 47); + case 'd': return u3nc(0, 236); + case 'l': return u3nc(0, 120); + case 'n': return u3nc(0, 206); + case 'p': return u3nc(0, 152); + case 'r': return u3nc(0, 158); + case 's': return u3nc(0, 255); + case 't': return u3nc(0, 214); + case 'x': return u3nc(0, 195); + default: return 0; + } + case 'u': switch (three) { + case 'l': return u3nc(0, 8); + case 'n': return u3nc(0, 138); + case 'r': return u3nc(0, 194); + case 's': return u3nc(0, 90); + default: return 0; + } + case 'y': switch (three) { + case 'l': return u3nc(0, 169); + case 'n': return u3nc(0, 226); + case 'r': return u3nc(0, 247); + default: return 0; + } + default: return 0; + } + case 'h': switch (two) { + case 'e': switch (three) { + case 'b': return u3nc(0, 20); + case 'c': return u3nc(0, 27); + case 'p': return u3nc(0, 91); + case 's': return u3nc(0, 213); + case 't': return u3nc(0, 50); + case 'x': return u3nc(0, 46); + default: return 0; + } + case 'u': switch (three) { + case 'l': return u3nc(0, 221); + case 's': return u3nc(0, 209); + case 't': return u3nc(0, 174); + default: return 0; + } + default: return 0; + } + case 'l': switch (two) { + case 'e': switch (three) { + case 'b': return u3nc(0, 145); + case 'c': return u3nc(0, 203); + case 'd': return u3nc(0, 41); + case 'g': return u3nc(0, 156); + case 'n': return u3nc(0, 198); + case 'p': return u3nc(0, 170); + case 'r': return u3nc(0, 218); + case 't': return u3nc(0, 7); + case 'v': return u3nc(0, 190); + case 'x': return u3nc(0, 200); + default: return 0; + } + case 'u': switch (three) { + case 'c': return u3nc(0, 197); + case 'd': return u3nc(0, 223); + case 'g': return u3nc(0, 26); + case 'n': return u3nc(0, 32); + case 'p': return u3nc(0, 22); + case 'r': return u3nc(0, 180); + case 's': return u3nc(0, 161); + case 't': return u3nc(0, 34); + case 'x': return u3nc(0, 235); + default: return 0; + } + case 'y': switch (three) { + case 'd': return u3nc(0, 205); + case 'n': return u3nc(0, 232); + case 'r': return u3nc(0, 240); + case 's': return u3nc(0, 225); + case 't': return u3nc(0, 128); + case 'x': return u3nc(0, 134); + default: return 0; + } + default: return 0; + } + case 'm': switch (two) { + case 'e': switch (three) { + case 'b': return u3nc(0, 114); + case 'c': return u3nc(0, 141); + case 'd': return u3nc(0, 127); + case 'g': return u3nc(0, 78); + case 'l': return u3nc(0, 185); + case 'p': return u3nc(0, 33); + case 'r': return u3nc(0, 159); + case 's': return u3nc(0, 104); + case 't': return u3nc(0, 43); + case 'v': return u3nc(0, 51); + case 'x': return u3nc(0, 165); + default: return 0; + } + case 'u': switch (three) { + case 'd': return u3nc(0, 242); + case 'g': return u3nc(0, 173); + case 'l': return u3nc(0, 81); + case 'n': return u3nc(0, 239); + case 'r': return u3nc(0, 248); + case 's': return u3nc(0, 93); + case 't': return u3nc(0, 86); + default: return 0; + } + case 'y': switch (three) { + case 'l': return u3nc(0, 191); + case 'n': return u3nc(0, 103); + case 'r': return u3nc(0, 110); + default: return 0; + } + default: return 0; + } + case 'n': switch (two) { + case 'e': switch (three) { + case 'b': return u3nc(0, 130); + case 'c': return u3nc(0, 1); + case 'd': return u3nc(0, 202); + case 'l': return u3nc(0, 253); + case 'm': return u3nc(0, 157); + case 'p': return u3nc(0, 62); + case 'r': return u3nc(0, 199); + case 's': return u3nc(0, 212); + case 't': return u3nc(0, 79); + case 'v': return u3nc(0, 254); + case 'x': return u3nc(0, 31); + default: return 0; + } + case 'u': switch (three) { + case 'b': return u3nc(0, 126); + case 'l': return u3nc(0, 196); + case 'm': return u3nc(0, 148); + case 'p': return u3nc(0, 19); + case 's': return u3nc(0, 162); + case 't': return u3nc(0, 67); + case 'x': return u3nc(0, 122); + default: return 0; + } + case 'y': switch (three) { + case 'd': return u3nc(0, 208); + case 'l': return u3nc(0, 231); + case 'm': return u3nc(0, 82); + case 'r': return u3nc(0, 219); + case 's': return u3nc(0, 230); + case 't': return u3nc(0, 243); + case 'x': return u3nc(0, 87); + default: return 0; + } + default: return 0; + } + case 'p': switch (two) { + case 'e': switch (three) { + case 'c': return u3nc(0, 252); + case 'd': return u3nc(0, 39); + case 'g': return u3nc(0, 21); + case 'l': return u3nc(0, 111); + case 'm': return u3nc(0, 178); + case 'n': return u3nc(0, 9); + case 'r': return u3nc(0, 5); + case 's': return u3nc(0, 36); + case 't': return u3nc(0, 69); + case 'x': return u3nc(0, 186); + default: return 0; + } + case 'u': switch (three) { + case 'b': return u3nc(0, 166); + case 'n': return u3nc(0, 135); + case 'r': return u3nc(0, 63); + case 't': return u3nc(0, 25); + default: return 0; + } + case 'y': switch (three) { + case 'l': return u3nc(0, 48); + case 'x': return u3nc(0, 149); + default: return 0; + } + default: return 0; + } + case 'r': switch (two) { + case 'e': switch (three) { + case 'b': return u3nc(0, 65); + case 'c': return u3nc(0, 77); + case 'd': return u3nc(0, 137); + case 'f': return u3nc(0, 140); + case 'g': return u3nc(0, 72); + case 'l': return u3nc(0, 210); + case 'm': return u3nc(0, 224); + case 'n': return u3nc(0, 124); + case 'p': return u3nc(0, 250); + case 's': return u3nc(0, 136); + case 't': return u3nc(0, 216); + case 'v': return u3nc(0, 139); + case 'x': return u3nc(0, 88); + default: return 0; + } + case 'u': switch (three) { + case 'c': return u3nc(0, 97); + case 'd': return u3nc(0, 211); + case 'l': return u3nc(0, 70); + case 'm': return u3nc(0, 131); + case 'n': return u3nc(0, 184); + case 'p': return u3nc(0, 201); + case 's': return u3nc(0, 143); + case 't': return u3nc(0, 52); + case 'x': return u3nc(0, 123); + default: return 0; + } + case 'y': switch (three) { + case 'c': return u3nc(0, 228); + case 'd': return u3nc(0, 204); + case 'g': return u3nc(0, 150); + case 'l': return u3nc(0, 222); + case 'm': return u3nc(0, 167); + case 'n': return u3nc(0, 147); + case 'p': return u3nc(0, 16); + case 's': return u3nc(0, 64); + case 't': return u3nc(0, 28); + case 'x': return u3nc(0, 151); + default: return 0; + } + default: return 0; + } + case 's': switch (two) { + case 'e': switch (three) { + case 'b': return u3nc(0, 220); + case 'c': return u3nc(0, 80); + case 'd': return u3nc(0, 237); + case 'f': return u3nc(0, 58); + case 'g': return u3nc(0, 133); + case 'l': return u3nc(0, 96); + case 'm': return u3nc(0, 75); + case 'n': return u3nc(0, 245); + case 'p': return u3nc(0, 35); + case 'r': return u3nc(0, 13); + case 't': return u3nc(0, 115); + case 'v': return u3nc(0, 4); + default: return 0; + } + case 'u': switch (three) { + case 'b': return u3nc(0, 68); + case 'd': return u3nc(0, 177); + case 'g': return u3nc(0, 229); + case 'l': return u3nc(0, 38); + case 'm': return u3nc(0, 85); + case 'n': return u3nc(0, 15); + case 'p': return u3nc(0, 74); + case 'r': return u3nc(0, 119); + case 't': return u3nc(0, 6); + default: return 0; + } + case 'y': switch (three) { + case 'd': return u3nc(0, 30); + case 'l': return u3nc(0, 163); + case 'm': return u3nc(0, 95); + case 'n': return u3nc(0, 71); + case 'p': return u3nc(0, 112); + case 'r': return u3nc(0, 100); + case 't': return u3nc(0, 10); + case 'x': return u3nc(0, 17); + default: return 0; + } + default: return 0; + } + case 't': switch (two) { + case 'e': switch (three) { + case 'b': return u3nc(0, 89); + case 'c': return u3nc(0, 164); + case 'd': return u3nc(0, 142); + case 'g': return u3nc(0, 251); + case 'l': return u3nc(0, 249); + case 'm': return u3nc(0, 40); + case 'n': return u3nc(0, 160); + case 'p': return u3nc(0, 55); + case 'r': return u3nc(0, 113); + case 's': return u3nc(0, 241); + case 'v': return u3nc(0, 83); + case 'x': return u3nc(0, 118); + default: return 0; + } + case 'u': switch (three) { + case 'c': return u3nc(0, 168); + case 'd': return u3nc(0, 121); + case 'g': return u3nc(0, 109); + case 'l': return u3nc(0, 42); + case 'n': return u3nc(0, 175); + case 's': return u3nc(0, 154); + case 'x': return u3nc(0, 108); + default: return 0; + } + case 'y': switch (three) { + case 'c': return u3nc(0, 155); + case 'd': return u3nc(0, 73); + case 'l': return u3nc(0, 53); + case 'n': return u3nc(0, 132); + case 'p': return u3nc(0, 189); + case 'r': return u3nc(0, 153); + case 'v': return u3nc(0, 29); + default: return 0; + } + default: return 0; + } + case 'w': switch (two) { + case 'e': switch (three) { + case 'b': return u3nc(0, 84); + case 'd': return u3nc(0, 192); + case 'g': return u3nc(0, 246); + case 'l': return u3nc(0, 207); + case 'n': return u3nc(0, 44); + case 'p': return u3nc(0, 12); + case 'r': return u3nc(0, 227); + case 's': return u3nc(0, 3); + case 't': return u3nc(0, 101); + case 'x': return u3nc(0, 99); + default: return 0; + } + case 'y': switch (three) { + case 'c': return u3nc(0, 59); + case 'd': return u3nc(0, 54); + case 'l': return u3nc(0, 14); + case 'n': return u3nc(0, 76); + case 't': return u3nc(0, 125); + case 'x': return u3nc(0, 94); + default: return 0; + } + default: return 0; + } + case 'z': switch (two) { + case 'o': switch (three) { + case 'd': return u3nc(0, 0); + default: return 0; + } + default: return 0; + } + default: return 0; + } +} + // good old linear search // @@ -32,36 +846,51 @@ } } - u3_noun - u3wcp_ins(u3_noun cor) - { - u3_noun x, a, buf; +u3_noun +u3qc_po_ins(u3_noun a) +{ + c3_y byt_y[3]; + u3r_bytes(0, 3, byt_y, a); - if ( (c3n == u3r_mean(cor, u3x_sam, &a, u3x_con_sam, &x, 0)) || - (c3n == u3du(x)) || - (c3n == u3ud(buf = u3h(x))) || - (c3n == u3ud(a)) ) - { - return u3m_bail(c3__exit); - } else { - return _po_find(buf, a); - } - } - u3_noun - u3wcp_ind(u3_noun cor) - { - u3_noun x, a, buf; + return find_prefix(byt_y[0], byt_y[1], byt_y[2]); +} - if ( (c3n == u3r_mean(cor, u3x_sam, &a, u3x_con_sam, &x, 0)) || - (c3n == u3du(x)) || - (c3n == u3ud(buf = u3t(x))) || - (c3n == u3ud(a)) ) - { - return u3m_bail(c3__exit); - } else { - return _po_find(buf, a); - } +u3_noun +u3wcp_ins(u3_noun cor) +{ + u3_noun a; + + if ( (c3n == u3r_mean(cor, u3x_sam, &a, 0)) || + (c3n == u3ud(a)) ) + { + return u3m_bail(c3__exit); + } else { + return u3qc_po_ins(a); } +} + +u3_noun +u3qc_po_ind(u3_noun a) +{ + c3_y byt_y[3]; + u3r_bytes(0, 3, byt_y, a); + + return find_suffix(byt_y[0], byt_y[1], byt_y[2]); +} + +u3_noun +u3wcp_ind(u3_noun cor) +{ + u3_noun a; + + if ( (c3n == u3r_mean(cor, u3x_sam, &a, 0)) || + (c3n == u3ud(a)) ) + { + return u3m_bail(c3__exit); + } else { + return u3qc_po_ind(a); + } +} u3_noun u3wcp_tos(u3_noun cor) diff --git a/pkg/urbit/jets/e/slaw.c b/pkg/urbit/jets/e/slaw.c index 52cdfe6907..c80a007204 100644 --- a/pkg/urbit/jets/e/slaw.c +++ b/pkg/urbit/jets/e/slaw.c @@ -61,6 +61,19 @@ // pulls the tables out of the sample, so we can't just reuse it from other // jets. + /* u3_noun */ + /* _parse_p(u3_noun txt) { */ + /* // The current parsing text code for @p in hoon is kinda nuts. it parses */ + /* // arbitrary lowercase ascii characters and then does a linear walk through */ + /* // the */ + + + /* // Run the result through the scrambler to resolve the textual name to the */ + /* // number. */ + /* return u3nc(0, u3qc_ob_fynd(raw)); */ + /* } */ + + u3_noun _parse_tas(u3_noun txt) { // For any symbol which matches, txt will return itself as a diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index fe40996f00..d595c06e7f 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -924,6 +924,7 @@ static c3_c* _141_tri__cofl_ha[] = { }; +static u3j_harm _141_tri__ob_fynd_a[] = {{".2", u3wc_ob_fynd}, {}}; static u3j_harm _141_tri__ob_feis_a[] = {{".2", u3wc_ob_feis}, {}}; static u3j_harm _141_tri__ob_tail_a[] = {{".2", u3wc_ob_tail}, {}}; static u3j_harm _141_tri__ob_fee_a[] = {{".2", u3wc_ob_fee}, {}}; @@ -932,7 +933,8 @@ static u3j_harm _141_tri__ob_fe_a[] = {{".2", u3wc_ob_fe}, {}}; static u3j_harm _141_tri__ob_fen_a[] = {{".2", u3wc_ob_fen}, {}}; static u3j_harm _141_tri__ob_eff_a[] = {{".2", u3wc_ob_eff}, {}}; static u3j_core _141_tri__ob_d[] = - { { "feis", 7, _141_tri__ob_feis_a, 0, 0 }, + { { "fynd", 7, _141_tri__ob_fynd_a, 0, 0 }, + { "feis", 7, _141_tri__ob_feis_a, 0, 0 }, { "tail", 7, _141_tri__ob_tail_a, 0, 0 }, { "fee", 7, _141_tri__ob_fee_a, 0, 0 }, { "feen", 7, _141_tri__ob_feen_a, 0, 0 }, From 1ef953c9ac2623c2a5f3e3c9b444463446c3c08c Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 28 Apr 2020 15:48:26 -0700 Subject: [PATCH 027/933] jets: hand rolled c parser for (slaw %p ...) This completes the c jetting for parsing %p strings in slaw. --- pkg/urbit/include/jets/q.h | 4 +- pkg/urbit/jets/c/po.c | 12 +- pkg/urbit/jets/e/slaw.c | 334 +++++++++++++++++++++++++++++++------ 3 files changed, 289 insertions(+), 61 deletions(-) diff --git a/pkg/urbit/include/jets/q.h b/pkg/urbit/include/jets/q.h index bd283fbba0..f5784a2dfc 100644 --- a/pkg/urbit/include/jets/q.h +++ b/pkg/urbit/include/jets/q.h @@ -70,8 +70,8 @@ u3_noun u3qc_swp(u3_atom, u3_atom); u3_noun u3qc_sqt(u3_atom); - u3_noun u3qc_po_ind(u3_atom); - u3_noun u3qc_po_ins(u3_atom); + u3_noun po_find_prefix(char one, char two, char three); + u3_noun po_find_suffix(char one, char two, char three); u3_noun u3qc_ob_fynd(u3_atom); diff --git a/pkg/urbit/jets/c/po.c b/pkg/urbit/jets/c/po.c index a1cafa0f75..7989ae6ea1 100644 --- a/pkg/urbit/jets/c/po.c +++ b/pkg/urbit/jets/c/po.c @@ -3,8 +3,8 @@ */ #include "all.h" -static u3_noun -find_prefix(char one, char two, char three) { +u3_noun +po_find_prefix(char one, char two, char three) { switch (one) { case 'b': switch (two) { case 'a': switch (three) { @@ -410,8 +410,8 @@ find_prefix(char one, char two, char three) { } } -static u3_noun -find_suffix(char one, char two, char three) { +u3_noun +po_find_suffix(char one, char two, char three) { switch (one) { case 'b': switch (two) { case 'e': switch (three) { @@ -852,7 +852,7 @@ u3qc_po_ins(u3_noun a) c3_y byt_y[3]; u3r_bytes(0, 3, byt_y, a); - return find_prefix(byt_y[0], byt_y[1], byt_y[2]); + return po_find_prefix(byt_y[0], byt_y[1], byt_y[2]); } u3_noun @@ -875,7 +875,7 @@ u3qc_po_ind(u3_noun a) c3_y byt_y[3]; u3r_bytes(0, 3, byt_y, a); - return find_suffix(byt_y[0], byt_y[1], byt_y[2]); + return po_find_suffix(byt_y[0], byt_y[1], byt_y[2]); } u3_noun diff --git a/pkg/urbit/jets/e/slaw.c b/pkg/urbit/jets/e/slaw.c index c80a007204..bcf91d20dd 100644 --- a/pkg/urbit/jets/e/slaw.c +++ b/pkg/urbit/jets/e/slaw.c @@ -7,72 +7,299 @@ /* functions */ +u3_noun +_parse_ud(u3_noun txt) { + c3_c* c = u3r_string(txt); - u3_noun - _parse_ud(u3_noun txt) { - c3_c* c = u3r_string(txt); + // First character must represent a digit + c3_c* cur = c; + if (cur[0] > '9' || cur[0] < '0') { + c3_free(c); + return 0; + } + c3_w total = cur[0] - '0'; + cur++; + + int since_last_period = 0; + while (cur[0] != 0) { + since_last_period++; + if (cur[0] == '.') { + since_last_period = 0; + cur++; + continue; + } - // First character must represent a digit - c3_c* cur = c; if (cur[0] > '9' || cur[0] < '0') { c3_free(c); return 0; } - c3_w total = cur[0] - '0'; + + total = u3qa_mul(total, 10); + total = u3qa_add(total, cur[0] - '0'); cur++; - int since_last_period = 0; - while (cur[0] != 0) { - since_last_period++; - if (cur[0] == '.') { - since_last_period = 0; - cur++; - continue; - } - - if (cur[0] > '9' || cur[0] < '0') { - c3_free(c); - return 0; - } - - total = u3qa_mul(total, 10); - total = u3qa_add(total, cur[0] - '0'); - cur++; - - if (since_last_period > 3) { - c3_free(c); - return 0; - } + if (since_last_period > 3) { + c3_free(c); + return 0; } - - c3_free(c); - return u3nc(0, total); } - // parsing @p: - // - // +slaw calls +fed:ag directly. +fed:ag: - // - // - parses the text first into a number. - // - runs fynd:ob, which is the scrambler restore structure. And +fynd is - // unjetted. - // - // The actual +po stuff, like +ins:po, is jetted but it's jetted such that it - // pulls the tables out of the sample, so we can't just reuse it from other - // jets. + c3_free(c); + return u3nc(0, total); +} - /* u3_noun */ - /* _parse_p(u3_noun txt) { */ - /* // The current parsing text code for @p in hoon is kinda nuts. it parses */ - /* // arbitrary lowercase ascii characters and then does a linear walk through */ - /* // the */ +// parsing @p: +// +// +slaw calls +fed:ag directly. +fed:ag: +// +// - parses the text first into a number. +// - runs fynd:ob, which is the scrambler restore structure. And +fynd is +// unjetted. +// +// The actual +po stuff, like +ins:po, is jetted but it's jetted such that it +// pulls the tables out of the sample, so we can't just reuse it from other +// jets. +u3_noun get_syllable(c3_c** cur_ptr, c3_c* one, c3_c* two, c3_c* three) { + if (islower((*cur_ptr)[0]) && islower((*cur_ptr)[1]) && + islower((*cur_ptr)[2])) { + *one = (*cur_ptr)[0]; + *two = (*cur_ptr)[1]; + *three = (*cur_ptr)[2]; + (*cur_ptr) += 3; + return c3y; + } else { + return c3n; + } +} - /* // Run the result through the scrambler to resolve the textual name to the */ - /* // number. */ - /* return u3nc(0, u3qc_ob_fynd(raw)); */ - /* } */ +static +u3_noun combine(u3_noun p, u3_noun q) +{ + if (_(u3a_is_atom(p))) { + return 0; + } + if (_(u3a_is_atom(q))) { + return 0; + } + + u3_noun ret = u3nc(0, u3qa_add(u3k(u3t(p)), u3qa_mul(256, u3k(u3t(q))))); + u3z(p); + u3z(q); + + return ret; +} + +#define ENSURE_NOT_END() do { \ + if (*cur == 0) { \ + c3_free(c); \ + return 0; \ + } \ + } while (0) + +#define CONSUME_HEP() do { \ + if (*cur != '-') { \ + c3_free(c); \ + return 0; \ + } \ + cur++; \ + } while (0) + +#define TRY_GET_SYLLABLE(prefix) \ + c3_c prefix##_one, prefix##_two, prefix##_three; \ + if (c3n == get_syllable(&cur, & prefix##_one, & prefix##_two, & prefix##_three)) { \ + c3_free(c); \ + return 0; \ + } + +u3_noun +_parse_p(u3_noun txt) { + c3_c* c = u3r_string(txt); + + c3_c* cur = c; + if (cur[0] != '~') { + c3_free(c); + return 0; + } + cur++; + + // We at least have a sig prefix. We're now going to parse tuples of three + // lowercase letters. Our naming pattern for the pieces we read is [a b c d + // ...] as we read them. + TRY_GET_SYLLABLE(a); + + // There was only one syllable. If it's a valid suffix syllable, then + // it's a galaxy. We don't even have to run this through the scrambler or + // check for validity since its already a (unit @). + if (*cur == 0) { + c3_free(c); + return po_find_suffix(a_one, a_two, a_three); + } + + TRY_GET_SYLLABLE(b); + + // There were only two syllables. If they are a valid prefix and suffix, then + // it's a star. + if (*cur == 0) { + u3_noun a_part = po_find_prefix(a_one, a_two, a_three); + u3_noun b_part = po_find_suffix(b_one, b_two, b_three); + u3_atom combined = combine(b_part, a_part); + c3_free(c); + return combined; + } + + // There must now be a - or it is invalid + CONSUME_HEP(); + + TRY_GET_SYLLABLE(c); + + ENSURE_NOT_END(); + + TRY_GET_SYLLABLE(d); + + if (*cur == 0) { + u3_noun a_part = po_find_prefix(a_one, a_two, a_three); + u3_noun b_part = po_find_suffix(b_one, b_two, b_three); + u3_noun c_part = po_find_prefix(c_one, c_two, c_three); + u3_noun d_part = po_find_suffix(d_one, d_two, d_three); + + u3_noun m = combine(d_part, combine(c_part, combine(b_part, a_part))); + c3_free(c); + + if (_(u3a_is_atom(m))) { + return 0; + } + + u3_atom raw = u3k(u3t(m)); + u3z(m); + return u3nc(0, u3qc_ob_fynd(raw)); + } + + // There must now be a - or it is invalid. + CONSUME_HEP(); + + // The next possible case is a "short" moon. (~ab-cd-ef) + TRY_GET_SYLLABLE(e); + + ENSURE_NOT_END(); + + TRY_GET_SYLLABLE(f); + + if (*cur == 0) { + u3_noun a_part = po_find_prefix(a_one, a_two, a_three); + u3_noun b_part = po_find_suffix(b_one, b_two, b_three); + u3_noun c_part = po_find_prefix(c_one, c_two, c_three); + u3_noun d_part = po_find_suffix(d_one, d_two, d_three); + u3_noun e_part = po_find_prefix(e_one, e_two, e_three); + u3_noun f_part = po_find_suffix(f_one, f_two, f_three); + + u3_noun m = combine(f_part, combine(e_part, combine(d_part, + combine(c_part, combine(b_part, a_part))))); + c3_free(c); + + if (_(u3a_is_atom(m))) { + return 0; + } + + u3_atom raw = u3k(u3t(m)); + u3z(m); + return u3nc(0, u3qc_ob_fynd(raw)); + } + + // There must now be a - or it is invalid. + CONSUME_HEP(); + + // The next possible case is a "long" moon. (~ab-cd-ef-gh) + TRY_GET_SYLLABLE(g); + + ENSURE_NOT_END(); + + TRY_GET_SYLLABLE(h); + + if (*cur == 0) { + u3_noun a_part = po_find_prefix(a_one, a_two, a_three); + u3_noun b_part = po_find_suffix(b_one, b_two, b_three); + u3_noun c_part = po_find_prefix(c_one, c_two, c_three); + u3_noun d_part = po_find_suffix(d_one, d_two, d_three); + u3_noun e_part = po_find_prefix(e_one, e_two, e_three); + u3_noun f_part = po_find_suffix(f_one, f_two, f_three); + u3_noun g_part = po_find_prefix(g_one, g_two, g_three); + u3_noun h_part = po_find_suffix(h_one, h_two, h_three); + + u3_noun m = combine(h_part, combine(g_part, combine(f_part, + combine(e_part, combine(d_part, combine(c_part, + combine(b_part, a_part))))))); + c3_free(c); + + if (_(u3a_is_atom(m))) { + return 0; + } + + u3_atom raw = u3k(u3t(m)); + u3z(m); + return u3nc(0, u3qc_ob_fynd(raw)); + } + + // At this point, the only thing it could be is a long comet, of the form + // ~ab-cd-ef-gh--ij-kl-mn-op + + CONSUME_HEP(); + CONSUME_HEP(); + + TRY_GET_SYLLABLE(i); + ENSURE_NOT_END(); + TRY_GET_SYLLABLE(j); + CONSUME_HEP(); + TRY_GET_SYLLABLE(k); + ENSURE_NOT_END(); + TRY_GET_SYLLABLE(l); + CONSUME_HEP(); + TRY_GET_SYLLABLE(m); + ENSURE_NOT_END(); + TRY_GET_SYLLABLE(n); + CONSUME_HEP(); + TRY_GET_SYLLABLE(o); + ENSURE_NOT_END(); + TRY_GET_SYLLABLE(p); + + if (*cur != 0) { + // We've parsed all of a comet shape, and there's still more in the + // string. Error. + c3_free(c); + return 0; + } + + // We have a long comet. Time to jam it all together. We rely on combine() + // for the error checking and we don't have to scramble comet names. + u3_noun a_part = po_find_prefix(a_one, a_two, a_three); + u3_noun b_part = po_find_suffix(b_one, b_two, b_three); + u3_noun c_part = po_find_prefix(c_one, c_two, c_three); + u3_noun d_part = po_find_suffix(d_one, d_two, d_three); + u3_noun e_part = po_find_prefix(e_one, e_two, e_three); + u3_noun f_part = po_find_suffix(f_one, f_two, f_three); + u3_noun g_part = po_find_prefix(g_one, g_two, g_three); + u3_noun h_part = po_find_suffix(h_one, h_two, h_three); + u3_noun i_part = po_find_prefix(i_one, i_two, i_three); + u3_noun j_part = po_find_suffix(j_one, j_two, j_three); + u3_noun k_part = po_find_prefix(k_one, k_two, k_three); + u3_noun l_part = po_find_suffix(l_one, l_two, l_three); + u3_noun m_part = po_find_prefix(m_one, m_two, m_three); + u3_noun n_part = po_find_suffix(n_one, n_two, n_three); + u3_noun o_part = po_find_prefix(o_one, o_two, o_three); + u3_noun p_part = po_find_suffix(p_one, p_two, p_three); + + c3_free(c); + + return combine(p_part, combine(o_part, combine(n_part, combine(m_part, + combine(l_part, combine(k_part, combine(j_part, combine(i_part, + combine(h_part, combine(g_part, combine(f_part, combine(e_part, + combine(d_part, combine(c_part, combine(b_part, a_part))))))))))))))); +} + +#undef ENSURE_NOT_END +#undef CONSUME_HEP +#undef TRY_GET_SYLLABLE u3_noun _parse_tas(u3_noun txt) { @@ -98,7 +325,7 @@ } c3_free(c); - return u3nc(0, txt); + return u3nc(0, u3k(txt)); } u3_noun @@ -114,7 +341,8 @@ } switch (mod) { - /* TODO: case c3__p. Need background jets first. */ + case 'p': + return _parse_p(txt); case c3__ud: return _parse_ud(txt); From b947b569bb564cd0132215bbf3dc869172b1b517 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 29 Apr 2020 16:28:36 -0700 Subject: [PATCH 028/933] jets: implement partial %da parser. This parses dates of the form '~2020.4.29', but not ones with time. This uses a hook to call back to +year, since jetting that would be a bit much. --- pkg/arvo/sys/hoon.hoon | 5 +- pkg/urbit/jets/e/slaw.c | 189 +++++++++++++++++++++++++++++----------- 2 files changed, 142 insertions(+), 52 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 0e2f79efa4..b0bdbd607e 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -2133,7 +2133,10 @@ :: 3f: scrambling :: :: 3g: molds and mold builders :: :: :: -~% %tri + ~ +~% %tri + + == + %year year + == |% :: :::: 3a: signed and modular ints :: diff --git a/pkg/urbit/jets/e/slaw.c b/pkg/urbit/jets/e/slaw.c index bcf91d20dd..b2901acdb2 100644 --- a/pkg/urbit/jets/e/slaw.c +++ b/pkg/urbit/jets/e/slaw.c @@ -98,8 +98,8 @@ u3_noun combine(u3_noun p, u3_noun q) } \ } while (0) -#define CONSUME_HEP() do { \ - if (*cur != '-') { \ +#define CONSUME(x) do { \ + if (*cur != x) { \ c3_free(c); \ return 0; \ } \ @@ -150,7 +150,7 @@ _parse_p(u3_noun txt) { } // There must now be a - or it is invalid - CONSUME_HEP(); + CONSUME('-'); TRY_GET_SYLLABLE(c); @@ -177,7 +177,7 @@ _parse_p(u3_noun txt) { } // There must now be a - or it is invalid. - CONSUME_HEP(); + CONSUME('-'); // The next possible case is a "short" moon. (~ab-cd-ef) TRY_GET_SYLLABLE(e); @@ -208,7 +208,7 @@ _parse_p(u3_noun txt) { } // There must now be a - or it is invalid. - CONSUME_HEP(); + CONSUME('-'); // The next possible case is a "long" moon. (~ab-cd-ef-gh) TRY_GET_SYLLABLE(g); @@ -244,21 +244,21 @@ _parse_p(u3_noun txt) { // At this point, the only thing it could be is a long comet, of the form // ~ab-cd-ef-gh--ij-kl-mn-op - CONSUME_HEP(); - CONSUME_HEP(); + CONSUME('-'); + CONSUME('-'); TRY_GET_SYLLABLE(i); ENSURE_NOT_END(); TRY_GET_SYLLABLE(j); - CONSUME_HEP(); + CONSUME('-'); TRY_GET_SYLLABLE(k); ENSURE_NOT_END(); TRY_GET_SYLLABLE(l); - CONSUME_HEP(); + CONSUME('-'); TRY_GET_SYLLABLE(m); ENSURE_NOT_END(); TRY_GET_SYLLABLE(n); - CONSUME_HEP(); + CONSUME('-'); TRY_GET_SYLLABLE(o); ENSURE_NOT_END(); TRY_GET_SYLLABLE(p); @@ -297,62 +297,149 @@ _parse_p(u3_noun txt) { combine(d_part, combine(c_part, combine(b_part, a_part))))))))))))))); } +#define PARSE_NONZERO_NUMBER(numname) \ + c3_w numname = 0; \ + do { \ + if (cur[0] > '9' || cur[0] < '1') { \ + c3_free(c); \ + return 0; \ + } \ + numname = cur[0] - '0'; \ + cur++; \ + while (isdigit(cur[0])) { \ + numname = u3qa_mul(numname, 10); \ + numname = u3qa_add(numname, cur[0] - '0'); \ + cur++; \ + } \ + } while (0) + +u3_noun +_parse_da(u3_noun cor, u3_noun txt) { + c3_c* c = u3r_string(txt); + + c3_c* cur = c; + CONSUME('~'); + + // Parse out an arbitrary year number. Starts with a nonzero digit followed + // by a series of any digits. + PARSE_NONZERO_NUMBER(year); + + fprintf(stderr, "Year: %d\r\n", year); + + // Parse the optional negative sign for BC dates. + u3_noun bc = c3n; + if (cur[0] == '-') { + bc = c3y; + cur++; + } + + CONSUME('.'); + + // Parse out a two digit month (mot:ag). Either a single digit 1-9 or 1[012]. + c3_w month; + if (cur[0] == '1') { + if (cur[1] <= '2' && cur[1] >= '0') { + // This is a two number month. + month = 10 + cur[1] - '0'; + cur += 2; + } else { + // This is January. + month = 1; + cur++; + } + } else if (cur[0] <= '9' && cur[0] >= '2') { + month = cur[0] - '0'; + cur++; + } else { + c3_free(c); + return 0; + } + + fprintf(stderr, "Month: %d\r\n", month); + + CONSUME('.'); + + // Parse out a two digit day (dip:ag). This number can be really big, so we + // can track number of days since September 1993. + PARSE_NONZERO_NUMBER(day); + + fprintf(stderr, "Day: %d\r\n", day); + + if (cur[0] == 0) { + fprintf(stderr, "Going fast path...\r\n"); + u3_noun hok = u3j_cook("u3we_slaw_parse_da", u3k(cor), "year"); + u3_noun res = u3n_slam_on(hok, u3nt(u3nc(bc, year), month, u3nc(day, u3nq(0, 0, 0, 0)))); + return u3nc(0, res); + } + + /* CONSUME('.'); */ + /* CONSUME('.'); */ + + // TODO: Cool. We've parsed a bunch of atoms. But the actual thing we return + // is the above run through the +year function which produces a @da. + return u3_none; +} + #undef ENSURE_NOT_END -#undef CONSUME_HEP +#undef CONSUME #undef TRY_GET_SYLLABLE +#undef PARSE_NONZERO_NUMBER - u3_noun - _parse_tas(u3_noun txt) { - // For any symbol which matches, txt will return itself as a - // value. Therefore, this is mostly checking validity. - c3_c* c = u3r_string(txt); +u3_noun +_parse_tas(u3_noun txt) { + // For any symbol which matches, txt will return itself as a + // value. Therefore, this is mostly checking validity. + c3_c* c = u3r_string(txt); - // First character must represent a lowercase letter - c3_c* cur = c; - if (!islower(cur[0])) { + // First character must represent a lowercase letter + c3_c* cur = c; + if (!islower(cur[0])) { + c3_free(c); + return 0; + } + cur++; + + while (cur[0] != 0) { + if (!(islower(cur[0]) || isdigit(cur[0]) || cur[0] == '-')) { c3_free(c); return 0; } + cur++; - - while (cur[0] != 0) { - if (!(islower(cur[0]) || isdigit(cur[0]) || cur[0] == '-')) { - c3_free(c); - return 0; - } - - cur++; - } - - c3_free(c); - return u3nc(0, u3k(txt)); } - u3_noun - u3we_slaw(u3_noun cor) - { - u3_noun mod; - u3_noun txt; + c3_free(c); + return u3nc(0, u3k(txt)); +} - if (c3n == u3r_mean(cor, u3x_sam_2, &mod, - u3x_sam_3, &txt, 0) || - !_(u3a_is_cat(mod))) { - return u3m_bail(c3__fail); - } +u3_noun +u3we_slaw(u3_noun cor) +{ + u3_noun mod; + u3_noun txt; - switch (mod) { - case 'p': - return _parse_p(txt); + if (c3n == u3r_mean(cor, u3x_sam_2, &mod, + u3x_sam_3, &txt, 0) || + !_(u3a_is_cat(mod))) { + return u3m_bail(c3__fail); + } - case c3__ud: - return _parse_ud(txt); + switch (mod) { + case c3__da: + return _parse_da(cor, txt); + + case 'p': + return _parse_p(txt); + + case c3__ud: + return _parse_ud(txt); // %ta is used once in link.hoon. don't bother. - case c3__tas: - return _parse_tas(txt); + case c3__tas: + return _parse_tas(txt); - default: - return u3_none; - } + default: + return u3_none; } +} From 799c7e2ba35eefb67f156148df685ea7f7ef71c9 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 30 Apr 2020 11:04:49 -0700 Subject: [PATCH 029/933] jets: finish the %da parser and test it. --- pkg/urbit/jets/e/slaw.c | 100 ++++++++++++++++++++++++++++++++++------ 1 file changed, 85 insertions(+), 15 deletions(-) diff --git a/pkg/urbit/jets/e/slaw.c b/pkg/urbit/jets/e/slaw.c index b2901acdb2..9476d004d9 100644 --- a/pkg/urbit/jets/e/slaw.c +++ b/pkg/urbit/jets/e/slaw.c @@ -313,6 +313,36 @@ _parse_p(u3_noun txt) { } \ } while (0) +#define PARSE_INCLUDING_ZERO_NUMBER(numname) \ + c3_w numname = 0; \ + do { \ + if (cur[0] > '9' || cur[0] < '0') { \ + c3_free(c); \ + return 0; \ + } \ + numname = cur[0] - '0'; \ + cur++; \ + while (isdigit(cur[0])) { \ + numname = u3qa_mul(numname, 10); \ + numname = u3qa_add(numname, cur[0] - '0'); \ + cur++; \ + } \ + } while (0) + +#define PARSE_HEX_DIGIT(out) \ + do { \ + if (cur[0] >= '0' && cur[0] <= '9') { \ + out = cur[0] - '0'; \ + } else if (cur[0] >= 'a' && cur[0] <= 'f') { \ + out = 10 + cur[0] - 'a'; \ + } else { \ + c3_free(c); \ + return 0; \ + } \ + cur++; \ + } while(0) + + u3_noun _parse_da(u3_noun cor, u3_noun txt) { c3_c* c = u3r_string(txt); @@ -324,12 +354,10 @@ _parse_da(u3_noun cor, u3_noun txt) { // by a series of any digits. PARSE_NONZERO_NUMBER(year); - fprintf(stderr, "Year: %d\r\n", year); - // Parse the optional negative sign for BC dates. - u3_noun bc = c3n; + u3_noun bc = c3y; if (cur[0] == '-') { - bc = c3y; + bc = c3n; cur++; } @@ -355,35 +383,77 @@ _parse_da(u3_noun cor, u3_noun txt) { return 0; } - fprintf(stderr, "Month: %d\r\n", month); - CONSUME('.'); // Parse out a two digit day (dip:ag). This number can be really big, so we // can track number of days since September 1993. PARSE_NONZERO_NUMBER(day); - fprintf(stderr, "Day: %d\r\n", day); - if (cur[0] == 0) { - fprintf(stderr, "Going fast path...\r\n"); + c3_free(c); u3_noun hok = u3j_cook("u3we_slaw_parse_da", u3k(cor), "year"); - u3_noun res = u3n_slam_on(hok, u3nt(u3nc(bc, year), month, u3nc(day, u3nq(0, 0, 0, 0)))); + u3_noun res = u3n_slam_on(hok, + u3nt(u3nc(bc, year), month, + u3nc(day, u3nq(0, 0, 0, 0)))); return u3nc(0, res); } - /* CONSUME('.'); */ - /* CONSUME('.'); */ + CONSUME('.'); + CONSUME('.'); - // TODO: Cool. We've parsed a bunch of atoms. But the actual thing we return - // is the above run through the +year function which produces a @da. - return u3_none; + PARSE_INCLUDING_ZERO_NUMBER(hour); + CONSUME('.'); + PARSE_INCLUDING_ZERO_NUMBER(minute); + CONSUME('.'); + PARSE_INCLUDING_ZERO_NUMBER(second); + + if (cur[0] == 0) { + c3_free(c); + u3_noun hok = u3j_cook("u3we_slaw_parse_da", u3k(cor), "year"); + u3_noun res = u3n_slam_on(hok, + u3nt(u3nc(bc, year), month, + u3nc(day, u3nq(hour, minute, second, 0)))); + return u3nc(0, res); + } + + CONSUME('.'); + CONSUME('.'); + + // Now we have to parse a list of hexidecimal numbers 0-f of length 4 only + // (zero padded otherwise) separated by dots. Wat. + u3_atom list = 0; + while (1) { + // Parse 4 hex digits + int one, two, three, four; + PARSE_HEX_DIGIT(one); + PARSE_HEX_DIGIT(two); + PARSE_HEX_DIGIT(three); + PARSE_HEX_DIGIT(four); + + int current = (one << 12) + (two << 8) + (three << 4) + four; + list = u3nc(current, list); + + if (cur[0] == 0) { + c3_free(c); + list = u3qb_flop(list); + + u3_noun hok = u3j_cook("u3we_slaw_parse_da", u3k(cor), "year"); + u3_noun res = u3n_slam_on(hok, + u3nt(u3nc(bc, year), month, + u3nc(day, + u3nq(hour, minute, second, list)))); + return u3nc(0, res); + } + + CONSUME('.'); + } } #undef ENSURE_NOT_END #undef CONSUME #undef TRY_GET_SYLLABLE #undef PARSE_NONZERO_NUMBER +#undef PARSE_HEX_DIGIT u3_noun _parse_tas(u3_noun txt) { From 8e975917e8332776a493548d872469ead511478f Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 30 Apr 2020 13:07:20 -0700 Subject: [PATCH 030/933] jets: (scow %ud ...) is jetted, along with its +scot equivalent. --- pkg/urbit/include/jets/w.h | 2 + pkg/urbit/jets/e/scow.c | 80 ++++++++++++++++++++++++++++++++++++++ pkg/urbit/jets/tree.c | 4 ++ 3 files changed, 86 insertions(+) create mode 100644 pkg/urbit/jets/e/scow.c diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index 57c1d3d574..b5da487f64 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -125,6 +125,8 @@ u3_noun u3we_rexp(u3_noun); u3_noun u3we_trip(u3_noun); + u3_noun u3we_scow(u3_noun); + u3_noun u3we_scot(u3_noun); u3_noun u3we_slaw(u3_noun); u3_noun u3we_pfix(u3_noun); diff --git a/pkg/urbit/jets/e/scow.c b/pkg/urbit/jets/e/scow.c new file mode 100644 index 0000000000..02dfc60450 --- /dev/null +++ b/pkg/urbit/jets/e/scow.c @@ -0,0 +1,80 @@ +/* j/3/scow.c +** +*/ +#include "all.h" + +#include + +u3_noun +_print_ud(u3_atom ud) +{ + // number of characters printed "between" periods. + int between = 0; + u3_atom list = 0; + + do { + if (between == 3) { + list = u3nc('.', list); + between = 0; + } + list = u3nc(u3qa_add(u3qa_mod(u3k(ud), 10), '0'), list); + between++; + ud = u3qa_div(ud, 10); + } while (c3n == u3r_sing(ud, 0)); + + return list; +} + +// +u3_noun +u3we_scow(u3_noun cor) +{ + u3_noun mod; + u3_noun atom; + + if (c3n == u3r_mean(cor, u3x_sam_2, &mod, + u3x_sam_3, &atom, 0) || + !_(u3a_is_cat(mod))) { + return u3m_bail(c3__fail); + } + + switch (mod) { + /* case c3__da: */ + /* return _parse_da(cor, txt); */ + + /* case 'p': */ + /* return _parse_p(txt); */ + + case c3__ud: + return _print_ud(atom); + + /* // %ta is used once in link.hoon. don't bother. */ + + /* case c3__tas: */ + /* return _parse_tas(txt); */ + + default: + return u3_none; + } +} + +u3_noun +u3we_scot(u3_noun cor) +{ + u3_noun mod; + u3_noun atom; + + if (c3n == u3r_mean(cor, u3x_sam_2, &mod, + u3x_sam_3, &atom, 0) || + !_(u3a_is_cat(mod))) { + return u3m_bail(c3__fail); + } + + switch (mod) { + case c3__ud: + return u3qc_rap(3, _print_ud(atom)); + + default: + return u3_none; + } +} diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index d595c06e7f..d3eb207665 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -608,6 +608,8 @@ static c3_c* _141_qua_trip_ha[] = { }; static u3j_harm _141_qua_slaw_a[] = {{".2", u3we_slaw}, {}}; +static u3j_harm _141_qua_scot_a[] = {{".2", u3we_scot}, {}}; +static u3j_harm _141_qua_scow_a[] = {{".2", u3we_scow}, {}}; static u3j_harm _141_qua__po_ind_a[] = {{".2", u3wcp_ind}, {}}; @@ -887,6 +889,8 @@ static u3j_core _141_qua_d[] = { "mink", 7, _141_qua_mink_a, 0, _141_qua_mink_ha }, { "mule", 7, _141_qua_mule_a, 0, _141_qua_mule_ha }, + { "scot", 7, _141_qua_scot_a, 0, 0 }, + { "scow", 7, _141_qua_scow_a, 0, 0 }, { "slaw", 7, _141_qua_slaw_a, 0, 0 }, {} }; From 3f0e17bf70736395376bb69b11f1bb28a5d180c0 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 30 Apr 2020 13:17:44 -0700 Subject: [PATCH 031/933] jets: implement +fein:ob for the @p printer. --- pkg/urbit/include/jets/q.h | 1 + pkg/urbit/include/jets/w.h | 1 + pkg/urbit/jets/c/ob.c | 39 ++++++++++++++++++++++++++++++++++++++ pkg/urbit/jets/tree.c | 4 +++- 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/pkg/urbit/include/jets/q.h b/pkg/urbit/include/jets/q.h index f5784a2dfc..7990b408b5 100644 --- a/pkg/urbit/include/jets/q.h +++ b/pkg/urbit/include/jets/q.h @@ -73,6 +73,7 @@ u3_noun po_find_prefix(char one, char two, char three); u3_noun po_find_suffix(char one, char two, char three); + u3_noun u3qc_ob_fein(u3_atom); u3_noun u3qc_ob_fynd(u3_atom); /** Tier 4. diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index b5da487f64..8990927d81 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -76,6 +76,7 @@ u3_noun u3wcp_tos(u3_noun); u3_noun u3wcp_tod(u3_noun); + u3_noun u3wc_ob_fein(u3_noun); u3_noun u3wc_ob_fynd(u3_noun); u3_noun u3wc_ob_feis(u3_noun); u3_noun u3wc_ob_tail(u3_noun); diff --git a/pkg/urbit/jets/c/ob.c b/pkg/urbit/jets/c/ob.c index e5999af90b..afcfb793c0 100644 --- a/pkg/urbit/jets/c/ob.c +++ b/pkg/urbit/jets/c/ob.c @@ -388,3 +388,42 @@ u3wc_ob_fynd(u3_noun cor) return u3qc_ob_fynd(m); } } + +u3_noun +u3qc_ob_fein(u3_atom pyn) +{ + c3_d BIGGEST_PLANET = 0xffffffffULL; + c3_d SMALLEST_MOON = 0x100000000ULL; + c3_d BIGGEST_MOON = 0xffffffffffffffffULL; + + c3_d MOON_MASK = 0xffffffff00000000ULL; + + if (c3y == u3qa_gte(pyn, 0x10000) && + c3y == u3qa_lte(pyn, u3i_chubs(1, &BIGGEST_PLANET))) { + return u3qa_add(0x10000, u3qc_ob_feis(u3qa_sub(pyn, 0x10000))); + } + + if (c3y == u3qa_gte(pyn, u3i_chubs(1, &SMALLEST_MOON)) && + c3y == u3qa_lte(pyn, u3i_chubs(1, &BIGGEST_MOON))) { + u3_atom lo = u3qc_dis(pyn, u3i_chubs(1, &BIGGEST_PLANET)); + u3_atom hi = u3qc_dis(pyn, u3i_chubs(1, &MOON_MASK)); + return u3qc_con(hi, u3qc_ob_fein(lo)); + } + + return pyn; +} + +u3_noun +u3wc_ob_fein(u3_noun cor) +{ + u3_noun m; + + if ( (c3n == u3r_mean(cor, u3x_sam, &m, 0)) || + (c3n == u3ud(m)) ) + { + return u3m_bail(c3__exit); + } + else { + return u3qc_ob_fein(m); + } +} diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index d3eb207665..5b91e95950 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -928,6 +928,7 @@ static c3_c* _141_tri__cofl_ha[] = { }; +static u3j_harm _141_tri__ob_fein_a[] = {{".2", u3wc_ob_fein}, {}}; static u3j_harm _141_tri__ob_fynd_a[] = {{".2", u3wc_ob_fynd}, {}}; static u3j_harm _141_tri__ob_feis_a[] = {{".2", u3wc_ob_feis}, {}}; static u3j_harm _141_tri__ob_tail_a[] = {{".2", u3wc_ob_tail}, {}}; @@ -937,7 +938,8 @@ static u3j_harm _141_tri__ob_fe_a[] = {{".2", u3wc_ob_fe}, {}}; static u3j_harm _141_tri__ob_fen_a[] = {{".2", u3wc_ob_fen}, {}}; static u3j_harm _141_tri__ob_eff_a[] = {{".2", u3wc_ob_eff}, {}}; static u3j_core _141_tri__ob_d[] = - { { "fynd", 7, _141_tri__ob_fynd_a, 0, 0 }, + { { "fein", 7, _141_tri__ob_fein_a, 0, 0 }, + { "fynd", 7, _141_tri__ob_fynd_a, 0, 0 }, { "feis", 7, _141_tri__ob_feis_a, 0, 0 }, { "tail", 7, _141_tri__ob_tail_a, 0, 0 }, { "fee", 7, _141_tri__ob_fee_a, 0, 0 }, From d61a54d52ab757e0e230ad47ee36c1a419354f06 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 30 Apr 2020 14:33:49 -0700 Subject: [PATCH 032/933] jets: implement (scow %p ...) for all ship types. While working on this, realized there were bad reference counts in my new +ob jets. This is likely to be a recurring problem here. I tried replacing the +ob jets with hooks, but I ran into a bunch of weirdness about calling these hooks from u3dc(). --- pkg/urbit/include/jets/q.h | 2 + pkg/urbit/jets/c/ob.c | 35 ++- pkg/urbit/jets/c/po.c | 619 +++++++++++++++++++++++++++++++++---- pkg/urbit/jets/e/scow.c | 55 +++- 4 files changed, 631 insertions(+), 80 deletions(-) diff --git a/pkg/urbit/include/jets/q.h b/pkg/urbit/include/jets/q.h index 7990b408b5..c441117003 100644 --- a/pkg/urbit/include/jets/q.h +++ b/pkg/urbit/include/jets/q.h @@ -72,6 +72,8 @@ u3_noun po_find_prefix(char one, char two, char three); u3_noun po_find_suffix(char one, char two, char three); + void po_to_prefix(u3_noun id, c3_y* a, c3_y* b, c3_y* c); + void po_to_suffix(u3_noun id, c3_y* a, c3_y* b, c3_y* c); u3_noun u3qc_ob_fein(u3_atom); u3_noun u3qc_ob_fynd(u3_atom); diff --git a/pkg/urbit/jets/c/ob.c b/pkg/urbit/jets/c/ob.c index afcfb793c0..60633c394d 100644 --- a/pkg/urbit/jets/c/ob.c +++ b/pkg/urbit/jets/c/ob.c @@ -148,8 +148,9 @@ u3qc_ob_fe(u3_atom r, u3_atom m) { u3_atom j = 1; - u3_atom ell = u3qa_mod(m, a); - u3_atom arr = u3qa_div(m, a); + u3_atom ell = u3qa_mod(u3k(m), u3k(a)); + u3_atom arr = u3qa_div(u3k(m), u3k(a)); + u3z(a); while (1) { if (c3y == u3qa_gth(j, r)) { @@ -220,7 +221,7 @@ u3qc_ob_feen(u3_atom r, u3_atom m) { u3_atom c = u3qc_ob_fen(r, a, b, prf_fun, datum_u, m); - if (c3y == u3qa_lth(c, k)) { + if (c3y == u3qa_lth(u3k(c), k)) { return c; } @@ -269,7 +270,7 @@ u3qc_ob_fee(u3_atom r, u3_atom m) { u3_atom c = u3qc_ob_fe(r, a, b, prf_fun, datum_u, m); - if (c3y == u3qa_lth(c, k)) { + if (c3y == u3qa_lth(u3k(c), k)) { return c; } @@ -359,15 +360,16 @@ u3qc_ob_fynd(u3_atom cry) c3_d MOON_MASK = 0xffffffff00000000ULL; - if (c3y == u3qa_gte(cry, 0x10000) && - c3y == u3qa_lte(cry, u3i_chubs(1, &BIGGEST_PLANET))) { + if (c3y == u3qa_gte(u3k(cry), 0x10000) && + c3y == u3qa_lte(u3k(cry), u3i_chubs(1, &BIGGEST_PLANET))) { return u3qa_add(0x10000, u3qc_ob_tail(u3qa_sub(cry, 0x10000))); } - if (c3y == u3qa_gte(cry, u3i_chubs(1, &SMALLEST_MOON)) && - c3y == u3qa_lte(cry, u3i_chubs(1, &BIGGEST_MOON))) { - u3_atom lo = u3qc_dis(cry, u3i_chubs(1, &BIGGEST_PLANET)); - u3_atom hi = u3qc_dis(cry, u3i_chubs(1, &MOON_MASK)); + if (c3y == u3qa_gte(u3k(cry), u3i_chubs(1, &SMALLEST_MOON)) && + c3y == u3qa_lte(u3k(cry), u3i_chubs(1, &BIGGEST_MOON))) { + u3_atom lo = u3qc_dis(u3k(cry), u3i_chubs(1, &BIGGEST_PLANET)); + u3_atom hi = u3qc_dis(u3k(cry), u3i_chubs(1, &MOON_MASK)); + u3z(cry); return u3qc_con(hi, u3qc_ob_fynd(lo)); } @@ -398,15 +400,16 @@ u3qc_ob_fein(u3_atom pyn) c3_d MOON_MASK = 0xffffffff00000000ULL; - if (c3y == u3qa_gte(pyn, 0x10000) && - c3y == u3qa_lte(pyn, u3i_chubs(1, &BIGGEST_PLANET))) { + if (c3y == u3qa_gte(u3k(pyn), 0x10000) && + c3y == u3qa_lte(u3k(pyn), u3i_chubs(1, &BIGGEST_PLANET))) { return u3qa_add(0x10000, u3qc_ob_feis(u3qa_sub(pyn, 0x10000))); } - if (c3y == u3qa_gte(pyn, u3i_chubs(1, &SMALLEST_MOON)) && - c3y == u3qa_lte(pyn, u3i_chubs(1, &BIGGEST_MOON))) { - u3_atom lo = u3qc_dis(pyn, u3i_chubs(1, &BIGGEST_PLANET)); - u3_atom hi = u3qc_dis(pyn, u3i_chubs(1, &MOON_MASK)); + if (c3y == u3qa_gte(u3k(pyn), u3i_chubs(1, &SMALLEST_MOON)) && + c3y == u3qa_lte(u3k(pyn), u3i_chubs(1, &BIGGEST_MOON))) { + u3_atom lo = u3qc_dis(u3k(pyn), u3i_chubs(1, &BIGGEST_PLANET)); + u3_atom hi = u3qc_dis(u3k(pyn), u3i_chubs(1, &MOON_MASK)); + u3z(pyn); return u3qc_con(hi, u3qc_ob_fein(lo)); } diff --git a/pkg/urbit/jets/c/po.c b/pkg/urbit/jets/c/po.c index 7989ae6ea1..95e359f87f 100644 --- a/pkg/urbit/jets/c/po.c +++ b/pkg/urbit/jets/c/po.c @@ -410,6 +410,271 @@ po_find_prefix(char one, char two, char three) { } } +void +po_to_prefix(u3_noun id, c3_y* a, c3_y* b, c3_y* c) +{ + switch (id) { + case 0: *a = 'd'; *b = 'o'; *c = 'z'; break; + case 1: *a = 'm'; *b = 'a'; *c = 'r'; break; + case 2: *a = 'b'; *b = 'i'; *c = 'n'; break; + case 3: *a = 'w'; *b = 'a'; *c = 'n'; break; + case 4: *a = 's'; *b = 'a'; *c = 'm'; break; + case 5: *a = 'l'; *b = 'i'; *c = 't'; break; + case 6: *a = 's'; *b = 'i'; *c = 'g'; break; + case 7: *a = 'h'; *b = 'i'; *c = 'd'; break; + case 8: *a = 'f'; *b = 'i'; *c = 'd'; break; + case 9: *a = 'l'; *b = 'i'; *c = 's'; break; + case 10: *a = 's'; *b = 'o'; *c = 'g'; break; + case 11: *a = 'd'; *b = 'i'; *c = 'r'; break; + case 12: *a = 'w'; *b = 'a'; *c = 'c'; break; + case 13: *a = 's'; *b = 'a'; *c = 'b'; break; + case 14: *a = 'w'; *b = 'i'; *c = 's'; break; + case 15: *a = 's'; *b = 'i'; *c = 'b'; break; + case 16: *a = 'r'; *b = 'i'; *c = 'g'; break; + case 17: *a = 's'; *b = 'o'; *c = 'l'; break; + case 18: *a = 'd'; *b = 'o'; *c = 'p'; break; + case 19: *a = 'm'; *b = 'o'; *c = 'd'; break; + case 20: *a = 'f'; *b = 'o'; *c = 'g'; break; + case 21: *a = 'l'; *b = 'i'; *c = 'd'; break; + case 22: *a = 'h'; *b = 'o'; *c = 'p'; break; + case 23: *a = 'd'; *b = 'a'; *c = 'r'; break; + case 24: *a = 'd'; *b = 'o'; *c = 'r'; break; + case 25: *a = 'l'; *b = 'o'; *c = 'r'; break; + case 26: *a = 'h'; *b = 'o'; *c = 'd'; break; + case 27: *a = 'f'; *b = 'o'; *c = 'l'; break; + case 28: *a = 'r'; *b = 'i'; *c = 'n'; break; + case 29: *a = 't'; *b = 'o'; *c = 'g'; break; + case 30: *a = 's'; *b = 'i'; *c = 'l'; break; + case 31: *a = 'm'; *b = 'i'; *c = 'r'; break; + case 32: *a = 'h'; *b = 'o'; *c = 'l'; break; + case 33: *a = 'p'; *b = 'a'; *c = 's'; break; + case 34: *a = 'l'; *b = 'a'; *c = 'c'; break; + case 35: *a = 'r'; *b = 'o'; *c = 'v'; break; + case 36: *a = 'l'; *b = 'i'; *c = 'v'; break; + case 37: *a = 'd'; *b = 'a'; *c = 'l'; break; + case 38: *a = 's'; *b = 'a'; *c = 't'; break; + case 39: *a = 'l'; *b = 'i'; *c = 'b'; break; + case 40: *a = 't'; *b = 'a'; *c = 'b'; break; + case 41: *a = 'h'; *b = 'a'; *c = 'n'; break; + case 42: *a = 't'; *b = 'i'; *c = 'c'; break; + case 43: *a = 'p'; *b = 'i'; *c = 'd'; break; + case 44: *a = 't'; *b = 'o'; *c = 'r'; break; + case 45: *a = 'b'; *b = 'o'; *c = 'l'; break; + case 46: *a = 'f'; *b = 'o'; *c = 's'; break; + case 47: *a = 'd'; *b = 'o'; *c = 't'; break; + case 48: *a = 'l'; *b = 'o'; *c = 's'; break; + case 49: *a = 'd'; *b = 'i'; *c = 'l'; break; + case 50: *a = 'f'; *b = 'o'; *c = 'r'; break; + case 51: *a = 'p'; *b = 'i'; *c = 'l'; break; + case 52: *a = 'r'; *b = 'a'; *c = 'm'; break; + case 53: *a = 't'; *b = 'i'; *c = 'r'; break; + case 54: *a = 'w'; *b = 'i'; *c = 'n'; break; + case 55: *a = 't'; *b = 'a'; *c = 'd'; break; + case 56: *a = 'b'; *b = 'i'; *c = 'c'; break; + case 57: *a = 'd'; *b = 'i'; *c = 'f'; break; + case 58: *a = 'r'; *b = 'o'; *c = 'c'; break; + case 59: *a = 'w'; *b = 'i'; *c = 'd'; break; + case 60: *a = 'b'; *b = 'i'; *c = 's'; break; + case 61: *a = 'd'; *b = 'a'; *c = 's'; break; + case 62: *a = 'm'; *b = 'i'; *c = 'd'; break; + case 63: *a = 'l'; *b = 'o'; *c = 'p'; break; + case 64: *a = 'r'; *b = 'i'; *c = 'l'; break; + case 65: *a = 'n'; *b = 'a'; *c = 'r'; break; + case 66: *a = 'd'; *b = 'a'; *c = 'p'; break; + case 67: *a = 'm'; *b = 'o'; *c = 'l'; break; + case 68: *a = 's'; *b = 'a'; *c = 'n'; break; + case 69: *a = 'l'; *b = 'o'; *c = 'c'; break; + case 70: *a = 'n'; *b = 'o'; *c = 'v'; break; + case 71: *a = 's'; *b = 'i'; *c = 't'; break; + case 72: *a = 'n'; *b = 'i'; *c = 'd'; break; + case 73: *a = 't'; *b = 'i'; *c = 'p'; break; + case 74: *a = 's'; *b = 'i'; *c = 'c'; break; + case 75: *a = 'r'; *b = 'o'; *c = 'p'; break; + case 76: *a = 'w'; *b = 'i'; *c = 't'; break; + case 77: *a = 'n'; *b = 'a'; *c = 't'; break; + case 78: *a = 'p'; *b = 'a'; *c = 'n'; break; + case 79: *a = 'm'; *b = 'i'; *c = 'n'; break; + case 80: *a = 'r'; *b = 'i'; *c = 't'; break; + case 81: *a = 'p'; *b = 'o'; *c = 'd'; break; + case 82: *a = 'm'; *b = 'o'; *c = 't'; break; + case 83: *a = 't'; *b = 'a'; *c = 'm'; break; + case 84: *a = 't'; *b = 'o'; *c = 'l'; break; + case 85: *a = 's'; *b = 'a'; *c = 'v'; break; + case 86: *a = 'p'; *b = 'o'; *c = 's'; break; + case 87: *a = 'n'; *b = 'a'; *c = 'p'; break; + case 88: *a = 'n'; *b = 'o'; *c = 'p'; break; + case 89: *a = 's'; *b = 'o'; *c = 'm'; break; + case 90: *a = 'f'; *b = 'i'; *c = 'n'; break; + case 91: *a = 'f'; *b = 'o'; *c = 'n'; break; + case 92: *a = 'b'; *b = 'a'; *c = 'n'; break; + case 93: *a = 'm'; *b = 'o'; *c = 'r'; break; + case 94: *a = 'w'; *b = 'o'; *c = 'r'; break; + case 95: *a = 's'; *b = 'i'; *c = 'p'; break; + case 96: *a = 'r'; *b = 'o'; *c = 'n'; break; + case 97: *a = 'n'; *b = 'o'; *c = 'r'; break; + case 98: *a = 'b'; *b = 'o'; *c = 't'; break; + case 99: *a = 'w'; *b = 'i'; *c = 'c'; break; + case 100: *a = 's'; *b = 'o'; *c = 'c'; break; + case 101: *a = 'w'; *b = 'a'; *c = 't'; break; + case 102: *a = 'd'; *b = 'o'; *c = 'l'; break; + case 103: *a = 'm'; *b = 'a'; *c = 'g'; break; + case 104: *a = 'p'; *b = 'i'; *c = 'c'; break; + case 105: *a = 'd'; *b = 'a'; *c = 'v'; break; + case 106: *a = 'b'; *b = 'i'; *c = 'd'; break; + case 107: *a = 'b'; *b = 'a'; *c = 'l'; break; + case 108: *a = 't'; *b = 'i'; *c = 'm'; break; + case 109: *a = 't'; *b = 'a'; *c = 's'; break; + case 110: *a = 'm'; *b = 'a'; *c = 'l'; break; + case 111: *a = 'l'; *b = 'i'; *c = 'g'; break; + case 112: *a = 's'; *b = 'i'; *c = 'v'; break; + case 113: *a = 't'; *b = 'a'; *c = 'g'; break; + case 114: *a = 'p'; *b = 'a'; *c = 'd'; break; + case 115: *a = 's'; *b = 'a'; *c = 'l'; break; + case 116: *a = 'd'; *b = 'i'; *c = 'v'; break; + case 117: *a = 'd'; *b = 'a'; *c = 'c'; break; + case 118: *a = 't'; *b = 'a'; *c = 'n'; break; + case 119: *a = 's'; *b = 'i'; *c = 'd'; break; + case 120: *a = 'f'; *b = 'a'; *c = 'b'; break; + case 121: *a = 't'; *b = 'a'; *c = 'r'; break; + case 122: *a = 'm'; *b = 'o'; *c = 'n'; break; + case 123: *a = 'r'; *b = 'a'; *c = 'n'; break; + case 124: *a = 'n'; *b = 'i'; *c = 's'; break; + case 125: *a = 'w'; *b = 'o'; *c = 'l'; break; + case 126: *a = 'm'; *b = 'i'; *c = 's'; break; + case 127: *a = 'p'; *b = 'a'; *c = 'l'; break; + case 128: *a = 'l'; *b = 'a'; *c = 's'; break; + case 129: *a = 'd'; *b = 'i'; *c = 's'; break; + case 130: *a = 'm'; *b = 'a'; *c = 'p'; break; + case 131: *a = 'r'; *b = 'a'; *c = 'b'; break; + case 132: *a = 't'; *b = 'o'; *c = 'b'; break; + case 133: *a = 'r'; *b = 'o'; *c = 'l'; break; + case 134: *a = 'l'; *b = 'a'; *c = 't'; break; + case 135: *a = 'l'; *b = 'o'; *c = 'n'; break; + case 136: *a = 'n'; *b = 'o'; *c = 'd'; break; + case 137: *a = 'n'; *b = 'a'; *c = 'v'; break; + case 138: *a = 'f'; *b = 'i'; *c = 'g'; break; + case 139: *a = 'n'; *b = 'o'; *c = 'm'; break; + case 140: *a = 'n'; *b = 'i'; *c = 'b'; break; + case 141: *a = 'p'; *b = 'a'; *c = 'g'; break; + case 142: *a = 's'; *b = 'o'; *c = 'p'; break; + case 143: *a = 'r'; *b = 'a'; *c = 'l'; break; + case 144: *a = 'b'; *b = 'i'; *c = 'l'; break; + case 145: *a = 'h'; *b = 'a'; *c = 'd'; break; + case 146: *a = 'd'; *b = 'o'; *c = 'c'; break; + case 147: *a = 'r'; *b = 'i'; *c = 'd'; break; + case 148: *a = 'm'; *b = 'o'; *c = 'c'; break; + case 149: *a = 'p'; *b = 'a'; *c = 'c'; break; + case 150: *a = 'r'; *b = 'a'; *c = 'v'; break; + case 151: *a = 'r'; *b = 'i'; *c = 'p'; break; + case 152: *a = 'f'; *b = 'a'; *c = 'l'; break; + case 153: *a = 't'; *b = 'o'; *c = 'd'; break; + case 154: *a = 't'; *b = 'i'; *c = 'l'; break; + case 155: *a = 't'; *b = 'i'; *c = 'n'; break; + case 156: *a = 'h'; *b = 'a'; *c = 'p'; break; + case 157: *a = 'm'; *b = 'i'; *c = 'c'; break; + case 158: *a = 'f'; *b = 'a'; *c = 'n'; break; + case 159: *a = 'p'; *b = 'a'; *c = 't'; break; + case 160: *a = 't'; *b = 'a'; *c = 'c'; break; + case 161: *a = 'l'; *b = 'a'; *c = 'b'; break; + case 162: *a = 'm'; *b = 'o'; *c = 'g'; break; + case 163: *a = 's'; *b = 'i'; *c = 'm'; break; + case 164: *a = 's'; *b = 'o'; *c = 'n'; break; + case 165: *a = 'p'; *b = 'i'; *c = 'n'; break; + case 166: *a = 'l'; *b = 'o'; *c = 'm'; break; + case 167: *a = 'r'; *b = 'i'; *c = 'c'; break; + case 168: *a = 't'; *b = 'a'; *c = 'p'; break; + case 169: *a = 'f'; *b = 'i'; *c = 'r'; break; + case 170: *a = 'h'; *b = 'a'; *c = 's'; break; + case 171: *a = 'b'; *b = 'o'; *c = 's'; break; + case 172: *a = 'b'; *b = 'a'; *c = 't'; break; + case 173: *a = 'p'; *b = 'o'; *c = 'c'; break; + case 174: *a = 'h'; *b = 'a'; *c = 'c'; break; + case 175: *a = 't'; *b = 'i'; *c = 'd'; break; + case 176: *a = 'h'; *b = 'a'; *c = 'v'; break; + case 177: *a = 's'; *b = 'a'; *c = 'p'; break; + case 178: *a = 'l'; *b = 'i'; *c = 'n'; break; + case 179: *a = 'd'; *b = 'i'; *c = 'b'; break; + case 180: *a = 'h'; *b = 'o'; *c = 's'; break; + case 181: *a = 'd'; *b = 'a'; *c = 'b'; break; + case 182: *a = 'b'; *b = 'i'; *c = 't'; break; + case 183: *a = 'b'; *b = 'a'; *c = 'r'; break; + case 184: *a = 'r'; *b = 'a'; *c = 'c'; break; + case 185: *a = 'p'; *b = 'a'; *c = 'r'; break; + case 186: *a = 'l'; *b = 'o'; *c = 'd'; break; + case 187: *a = 'd'; *b = 'o'; *c = 's'; break; + case 188: *a = 'b'; *b = 'o'; *c = 'r'; break; + case 189: *a = 't'; *b = 'o'; *c = 'c'; break; + case 190: *a = 'h'; *b = 'i'; *c = 'l'; break; + case 191: *a = 'm'; *b = 'a'; *c = 'c'; break; + case 192: *a = 't'; *b = 'o'; *c = 'm'; break; + case 193: *a = 'd'; *b = 'i'; *c = 'g'; break; + case 194: *a = 'f'; *b = 'i'; *c = 'l'; break; + case 195: *a = 'f'; *b = 'a'; *c = 's'; break; + case 196: *a = 'm'; *b = 'i'; *c = 't'; break; + case 197: *a = 'h'; *b = 'o'; *c = 'b'; break; + case 198: *a = 'h'; *b = 'a'; *c = 'r'; break; + case 199: *a = 'm'; *b = 'i'; *c = 'g'; break; + case 200: *a = 'h'; *b = 'i'; *c = 'n'; break; + case 201: *a = 'r'; *b = 'a'; *c = 'd'; break; + case 202: *a = 'm'; *b = 'a'; *c = 's'; break; + case 203: *a = 'h'; *b = 'a'; *c = 'l'; break; + case 204: *a = 'r'; *b = 'a'; *c = 'g'; break; + case 205: *a = 'l'; *b = 'a'; *c = 'g'; break; + case 206: *a = 'f'; *b = 'a'; *c = 'd'; break; + case 207: *a = 't'; *b = 'o'; *c = 'p'; break; + case 208: *a = 'm'; *b = 'o'; *c = 'p'; break; + case 209: *a = 'h'; *b = 'a'; *c = 'b'; break; + case 210: *a = 'n'; *b = 'i'; *c = 'l'; break; + case 211: *a = 'n'; *b = 'o'; *c = 's'; break; + case 212: *a = 'm'; *b = 'i'; *c = 'l'; break; + case 213: *a = 'f'; *b = 'o'; *c = 'p'; break; + case 214: *a = 'f'; *b = 'a'; *c = 'm'; break; + case 215: *a = 'd'; *b = 'a'; *c = 't'; break; + case 216: *a = 'n'; *b = 'o'; *c = 'l'; break; + case 217: *a = 'd'; *b = 'i'; *c = 'n'; break; + case 218: *a = 'h'; *b = 'a'; *c = 't'; break; + case 219: *a = 'n'; *b = 'a'; *c = 'c'; break; + case 220: *a = 'r'; *b = 'i'; *c = 's'; break; + case 221: *a = 'f'; *b = 'o'; *c = 't'; break; + case 222: *a = 'r'; *b = 'i'; *c = 'b'; break; + case 223: *a = 'h'; *b = 'o'; *c = 'c'; break; + case 224: *a = 'n'; *b = 'i'; *c = 'm'; break; + case 225: *a = 'l'; *b = 'a'; *c = 'r'; break; + case 226: *a = 'f'; *b = 'i'; *c = 't'; break; + case 227: *a = 'w'; *b = 'a'; *c = 'l'; break; + case 228: *a = 'r'; *b = 'a'; *c = 'p'; break; + case 229: *a = 's'; *b = 'a'; *c = 'r'; break; + case 230: *a = 'n'; *b = 'a'; *c = 'l'; break; + case 231: *a = 'm'; *b = 'o'; *c = 's'; break; + case 232: *a = 'l'; *b = 'a'; *c = 'n'; break; + case 233: *a = 'd'; *b = 'o'; *c = 'n'; break; + case 234: *a = 'd'; *b = 'a'; *c = 'n'; break; + case 235: *a = 'l'; *b = 'a'; *c = 'd'; break; + case 236: *a = 'd'; *b = 'o'; *c = 'v'; break; + case 237: *a = 'r'; *b = 'i'; *c = 'v'; break; + case 238: *a = 'b'; *b = 'a'; *c = 'c'; break; + case 239: *a = 'p'; *b = 'o'; *c = 'l'; break; + case 240: *a = 'l'; *b = 'a'; *c = 'p'; break; + case 241: *a = 't'; *b = 'a'; *c = 'l'; break; + case 242: *a = 'p'; *b = 'i'; *c = 't'; break; + case 243: *a = 'n'; *b = 'a'; *c = 'm'; break; + case 244: *a = 'b'; *b = 'o'; *c = 'n'; break; + case 245: *a = 'r'; *b = 'o'; *c = 's'; break; + case 246: *a = 't'; *b = 'o'; *c = 'n'; break; + case 247: *a = 'f'; *b = 'o'; *c = 'd'; break; + case 248: *a = 'p'; *b = 'o'; *c = 'n'; break; + case 249: *a = 's'; *b = 'o'; *c = 'v'; break; + case 250: *a = 'n'; *b = 'o'; *c = 'c'; break; + case 251: *a = 's'; *b = 'o'; *c = 'r'; break; + case 252: *a = 'l'; *b = 'a'; *c = 'v'; break; + case 253: *a = 'm'; *b = 'a'; *c = 't'; break; + case 254: *a = 'm'; *b = 'i'; *c = 'p'; break; + case 255: *a = 'f'; *b = 'i'; *c = 'p'; break; + default: u3m_bail(c3__exit); + } +} + + u3_noun po_find_suffix(char one, char two, char three) { switch (one) { @@ -817,34 +1082,269 @@ po_find_suffix(char one, char two, char three) { } } - - // good old linear search - // - static u3_noun - _po_find(u3_noun buf, - u3_noun a) - { - if ( !_(u3a_is_cat(a)) ) { - return u3_nul; - } - else { - c3_w i_w; - c3_w a_w = a; - - for ( i_w = 0; i_w < 256; i_w++ ) { - c3_y byt_y[3]; - c3_w but_w; - - u3r_bytes((i_w * 3), 3, byt_y, buf); - but_w = (byt_y[0] | (byt_y[1] << 8) | (byt_y[2] << 16)); - - if ( but_w == a_w ) { - return u3nc(u3_nul, i_w); - } - } - return u3_nul; - } +void +po_to_suffix(u3_noun id, c3_y* a, c3_y* b, c3_y* c) +{ + switch (id) { + case 0: *a = 'z'; *b = 'o'; *c = 'd'; break; + case 1: *a = 'n'; *b = 'e'; *c = 'c'; break; + case 2: *a = 'b'; *b = 'u'; *c = 'd'; break; + case 3: *a = 'w'; *b = 'e'; *c = 's'; break; + case 4: *a = 's'; *b = 'e'; *c = 'v'; break; + case 5: *a = 'p'; *b = 'e'; *c = 'r'; break; + case 6: *a = 's'; *b = 'u'; *c = 't'; break; + case 7: *a = 'l'; *b = 'e'; *c = 't'; break; + case 8: *a = 'f'; *b = 'u'; *c = 'l'; break; + case 9: *a = 'p'; *b = 'e'; *c = 'n'; break; + case 10: *a = 's'; *b = 'y'; *c = 't'; break; + case 11: *a = 'd'; *b = 'u'; *c = 'r'; break; + case 12: *a = 'w'; *b = 'e'; *c = 'p'; break; + case 13: *a = 's'; *b = 'e'; *c = 'r'; break; + case 14: *a = 'w'; *b = 'y'; *c = 'l'; break; + case 15: *a = 's'; *b = 'u'; *c = 'n'; break; + case 16: *a = 'r'; *b = 'y'; *c = 'p'; break; + case 17: *a = 's'; *b = 'y'; *c = 'x'; break; + case 18: *a = 'd'; *b = 'y'; *c = 'r'; break; + case 19: *a = 'n'; *b = 'u'; *c = 'p'; break; + case 20: *a = 'h'; *b = 'e'; *c = 'b'; break; + case 21: *a = 'p'; *b = 'e'; *c = 'g'; break; + case 22: *a = 'l'; *b = 'u'; *c = 'p'; break; + case 23: *a = 'd'; *b = 'e'; *c = 'p'; break; + case 24: *a = 'd'; *b = 'y'; *c = 's'; break; + case 25: *a = 'p'; *b = 'u'; *c = 't'; break; + case 26: *a = 'l'; *b = 'u'; *c = 'g'; break; + case 27: *a = 'h'; *b = 'e'; *c = 'c'; break; + case 28: *a = 'r'; *b = 'y'; *c = 't'; break; + case 29: *a = 't'; *b = 'y'; *c = 'v'; break; + case 30: *a = 's'; *b = 'y'; *c = 'd'; break; + case 31: *a = 'n'; *b = 'e'; *c = 'x'; break; + case 32: *a = 'l'; *b = 'u'; *c = 'n'; break; + case 33: *a = 'm'; *b = 'e'; *c = 'p'; break; + case 34: *a = 'l'; *b = 'u'; *c = 't'; break; + case 35: *a = 's'; *b = 'e'; *c = 'p'; break; + case 36: *a = 'p'; *b = 'e'; *c = 's'; break; + case 37: *a = 'd'; *b = 'e'; *c = 'l'; break; + case 38: *a = 's'; *b = 'u'; *c = 'l'; break; + case 39: *a = 'p'; *b = 'e'; *c = 'd'; break; + case 40: *a = 't'; *b = 'e'; *c = 'm'; break; + case 41: *a = 'l'; *b = 'e'; *c = 'd'; break; + case 42: *a = 't'; *b = 'u'; *c = 'l'; break; + case 43: *a = 'm'; *b = 'e'; *c = 't'; break; + case 44: *a = 'w'; *b = 'e'; *c = 'n'; break; + case 45: *a = 'b'; *b = 'y'; *c = 'n'; break; + case 46: *a = 'h'; *b = 'e'; *c = 'x'; break; + case 47: *a = 'f'; *b = 'e'; *c = 'b'; break; + case 48: *a = 'p'; *b = 'y'; *c = 'l'; break; + case 49: *a = 'd'; *b = 'u'; *c = 'l'; break; + case 50: *a = 'h'; *b = 'e'; *c = 't'; break; + case 51: *a = 'm'; *b = 'e'; *c = 'v'; break; + case 52: *a = 'r'; *b = 'u'; *c = 't'; break; + case 53: *a = 't'; *b = 'y'; *c = 'l'; break; + case 54: *a = 'w'; *b = 'y'; *c = 'd'; break; + case 55: *a = 't'; *b = 'e'; *c = 'p'; break; + case 56: *a = 'b'; *b = 'e'; *c = 's'; break; + case 57: *a = 'd'; *b = 'e'; *c = 'x'; break; + case 58: *a = 's'; *b = 'e'; *c = 'f'; break; + case 59: *a = 'w'; *b = 'y'; *c = 'c'; break; + case 60: *a = 'b'; *b = 'u'; *c = 'r'; break; + case 61: *a = 'd'; *b = 'e'; *c = 'r'; break; + case 62: *a = 'n'; *b = 'e'; *c = 'p'; break; + case 63: *a = 'p'; *b = 'u'; *c = 'r'; break; + case 64: *a = 'r'; *b = 'y'; *c = 's'; break; + case 65: *a = 'r'; *b = 'e'; *c = 'b'; break; + case 66: *a = 'd'; *b = 'e'; *c = 'n'; break; + case 67: *a = 'n'; *b = 'u'; *c = 't'; break; + case 68: *a = 's'; *b = 'u'; *c = 'b'; break; + case 69: *a = 'p'; *b = 'e'; *c = 't'; break; + case 70: *a = 'r'; *b = 'u'; *c = 'l'; break; + case 71: *a = 's'; *b = 'y'; *c = 'n'; break; + case 72: *a = 'r'; *b = 'e'; *c = 'g'; break; + case 73: *a = 't'; *b = 'y'; *c = 'd'; break; + case 74: *a = 's'; *b = 'u'; *c = 'p'; break; + case 75: *a = 's'; *b = 'e'; *c = 'm'; break; + case 76: *a = 'w'; *b = 'y'; *c = 'n'; break; + case 77: *a = 'r'; *b = 'e'; *c = 'c'; break; + case 78: *a = 'm'; *b = 'e'; *c = 'g'; break; + case 79: *a = 'n'; *b = 'e'; *c = 't'; break; + case 80: *a = 's'; *b = 'e'; *c = 'c'; break; + case 81: *a = 'm'; *b = 'u'; *c = 'l'; break; + case 82: *a = 'n'; *b = 'y'; *c = 'm'; break; + case 83: *a = 't'; *b = 'e'; *c = 'v'; break; + case 84: *a = 'w'; *b = 'e'; *c = 'b'; break; + case 85: *a = 's'; *b = 'u'; *c = 'm'; break; + case 86: *a = 'm'; *b = 'u'; *c = 't'; break; + case 87: *a = 'n'; *b = 'y'; *c = 'x'; break; + case 88: *a = 'r'; *b = 'e'; *c = 'x'; break; + case 89: *a = 't'; *b = 'e'; *c = 'b'; break; + case 90: *a = 'f'; *b = 'u'; *c = 's'; break; + case 91: *a = 'h'; *b = 'e'; *c = 'p'; break; + case 92: *a = 'b'; *b = 'e'; *c = 'n'; break; + case 93: *a = 'm'; *b = 'u'; *c = 's'; break; + case 94: *a = 'w'; *b = 'y'; *c = 'x'; break; + case 95: *a = 's'; *b = 'y'; *c = 'm'; break; + case 96: *a = 's'; *b = 'e'; *c = 'l'; break; + case 97: *a = 'r'; *b = 'u'; *c = 'c'; break; + case 98: *a = 'd'; *b = 'e'; *c = 'c'; break; + case 99: *a = 'w'; *b = 'e'; *c = 'x'; break; + case 100: *a = 's'; *b = 'y'; *c = 'r'; break; + case 101: *a = 'w'; *b = 'e'; *c = 't'; break; + case 102: *a = 'd'; *b = 'y'; *c = 'l'; break; + case 103: *a = 'm'; *b = 'y'; *c = 'n'; break; + case 104: *a = 'm'; *b = 'e'; *c = 's'; break; + case 105: *a = 'd'; *b = 'e'; *c = 't'; break; + case 106: *a = 'b'; *b = 'e'; *c = 't'; break; + case 107: *a = 'b'; *b = 'e'; *c = 'l'; break; + case 108: *a = 't'; *b = 'u'; *c = 'x'; break; + case 109: *a = 't'; *b = 'u'; *c = 'g'; break; + case 110: *a = 'm'; *b = 'y'; *c = 'r'; break; + case 111: *a = 'p'; *b = 'e'; *c = 'l'; break; + case 112: *a = 's'; *b = 'y'; *c = 'p'; break; + case 113: *a = 't'; *b = 'e'; *c = 'r'; break; + case 114: *a = 'm'; *b = 'e'; *c = 'b'; break; + case 115: *a = 's'; *b = 'e'; *c = 't'; break; + case 116: *a = 'd'; *b = 'u'; *c = 't'; break; + case 117: *a = 'd'; *b = 'e'; *c = 'g'; break; + case 118: *a = 't'; *b = 'e'; *c = 'x'; break; + case 119: *a = 's'; *b = 'u'; *c = 'r'; break; + case 120: *a = 'f'; *b = 'e'; *c = 'l'; break; + case 121: *a = 't'; *b = 'u'; *c = 'd'; break; + case 122: *a = 'n'; *b = 'u'; *c = 'x'; break; + case 123: *a = 'r'; *b = 'u'; *c = 'x'; break; + case 124: *a = 'r'; *b = 'e'; *c = 'n'; break; + case 125: *a = 'w'; *b = 'y'; *c = 't'; break; + case 126: *a = 'n'; *b = 'u'; *c = 'b'; break; + case 127: *a = 'm'; *b = 'e'; *c = 'd'; break; + case 128: *a = 'l'; *b = 'y'; *c = 't'; break; + case 129: *a = 'd'; *b = 'u'; *c = 's'; break; + case 130: *a = 'n'; *b = 'e'; *c = 'b'; break; + case 131: *a = 'r'; *b = 'u'; *c = 'm'; break; + case 132: *a = 't'; *b = 'y'; *c = 'n'; break; + case 133: *a = 's'; *b = 'e'; *c = 'g'; break; + case 134: *a = 'l'; *b = 'y'; *c = 'x'; break; + case 135: *a = 'p'; *b = 'u'; *c = 'n'; break; + case 136: *a = 'r'; *b = 'e'; *c = 's'; break; + case 137: *a = 'r'; *b = 'e'; *c = 'd'; break; + case 138: *a = 'f'; *b = 'u'; *c = 'n'; break; + case 139: *a = 'r'; *b = 'e'; *c = 'v'; break; + case 140: *a = 'r'; *b = 'e'; *c = 'f'; break; + case 141: *a = 'm'; *b = 'e'; *c = 'c'; break; + case 142: *a = 't'; *b = 'e'; *c = 'd'; break; + case 143: *a = 'r'; *b = 'u'; *c = 's'; break; + case 144: *a = 'b'; *b = 'e'; *c = 'x'; break; + case 145: *a = 'l'; *b = 'e'; *c = 'b'; break; + case 146: *a = 'd'; *b = 'u'; *c = 'x'; break; + case 147: *a = 'r'; *b = 'y'; *c = 'n'; break; + case 148: *a = 'n'; *b = 'u'; *c = 'm'; break; + case 149: *a = 'p'; *b = 'y'; *c = 'x'; break; + case 150: *a = 'r'; *b = 'y'; *c = 'g'; break; + case 151: *a = 'r'; *b = 'y'; *c = 'x'; break; + case 152: *a = 'f'; *b = 'e'; *c = 'p'; break; + case 153: *a = 't'; *b = 'y'; *c = 'r'; break; + case 154: *a = 't'; *b = 'u'; *c = 's'; break; + case 155: *a = 't'; *b = 'y'; *c = 'c'; break; + case 156: *a = 'l'; *b = 'e'; *c = 'g'; break; + case 157: *a = 'n'; *b = 'e'; *c = 'm'; break; + case 158: *a = 'f'; *b = 'e'; *c = 'r'; break; + case 159: *a = 'm'; *b = 'e'; *c = 'r'; break; + case 160: *a = 't'; *b = 'e'; *c = 'n'; break; + case 161: *a = 'l'; *b = 'u'; *c = 's'; break; + case 162: *a = 'n'; *b = 'u'; *c = 's'; break; + case 163: *a = 's'; *b = 'y'; *c = 'l'; break; + case 164: *a = 't'; *b = 'e'; *c = 'c'; break; + case 165: *a = 'm'; *b = 'e'; *c = 'x'; break; + case 166: *a = 'p'; *b = 'u'; *c = 'b'; break; + case 167: *a = 'r'; *b = 'y'; *c = 'm'; break; + case 168: *a = 't'; *b = 'u'; *c = 'c'; break; + case 169: *a = 'f'; *b = 'y'; *c = 'l'; break; + case 170: *a = 'l'; *b = 'e'; *c = 'p'; break; + case 171: *a = 'd'; *b = 'e'; *c = 'b'; break; + case 172: *a = 'b'; *b = 'e'; *c = 'r'; break; + case 173: *a = 'm'; *b = 'u'; *c = 'g'; break; + case 174: *a = 'h'; *b = 'u'; *c = 't'; break; + case 175: *a = 't'; *b = 'u'; *c = 'n'; break; + case 176: *a = 'b'; *b = 'y'; *c = 'l'; break; + case 177: *a = 's'; *b = 'u'; *c = 'd'; break; + case 178: *a = 'p'; *b = 'e'; *c = 'm'; break; + case 179: *a = 'd'; *b = 'e'; *c = 'v'; break; + case 180: *a = 'l'; *b = 'u'; *c = 'r'; break; + case 181: *a = 'd'; *b = 'e'; *c = 'f'; break; + case 182: *a = 'b'; *b = 'u'; *c = 's'; break; + case 183: *a = 'b'; *b = 'e'; *c = 'p'; break; + case 184: *a = 'r'; *b = 'u'; *c = 'n'; break; + case 185: *a = 'm'; *b = 'e'; *c = 'l'; break; + case 186: *a = 'p'; *b = 'e'; *c = 'x'; break; + case 187: *a = 'd'; *b = 'y'; *c = 't'; break; + case 188: *a = 'b'; *b = 'y'; *c = 't'; break; + case 189: *a = 't'; *b = 'y'; *c = 'p'; break; + case 190: *a = 'l'; *b = 'e'; *c = 'v'; break; + case 191: *a = 'm'; *b = 'y'; *c = 'l'; break; + case 192: *a = 'w'; *b = 'e'; *c = 'd'; break; + case 193: *a = 'd'; *b = 'u'; *c = 'c'; break; + case 194: *a = 'f'; *b = 'u'; *c = 'r'; break; + case 195: *a = 'f'; *b = 'e'; *c = 'x'; break; + case 196: *a = 'n'; *b = 'u'; *c = 'l'; break; + case 197: *a = 'l'; *b = 'u'; *c = 'c'; break; + case 198: *a = 'l'; *b = 'e'; *c = 'n'; break; + case 199: *a = 'n'; *b = 'e'; *c = 'r'; break; + case 200: *a = 'l'; *b = 'e'; *c = 'x'; break; + case 201: *a = 'r'; *b = 'u'; *c = 'p'; break; + case 202: *a = 'n'; *b = 'e'; *c = 'd'; break; + case 203: *a = 'l'; *b = 'e'; *c = 'c'; break; + case 204: *a = 'r'; *b = 'y'; *c = 'd'; break; + case 205: *a = 'l'; *b = 'y'; *c = 'd'; break; + case 206: *a = 'f'; *b = 'e'; *c = 'n'; break; + case 207: *a = 'w'; *b = 'e'; *c = 'l'; break; + case 208: *a = 'n'; *b = 'y'; *c = 'd'; break; + case 209: *a = 'h'; *b = 'u'; *c = 's'; break; + case 210: *a = 'r'; *b = 'e'; *c = 'l'; break; + case 211: *a = 'r'; *b = 'u'; *c = 'd'; break; + case 212: *a = 'n'; *b = 'e'; *c = 's'; break; + case 213: *a = 'h'; *b = 'e'; *c = 's'; break; + case 214: *a = 'f'; *b = 'e'; *c = 't'; break; + case 215: *a = 'd'; *b = 'e'; *c = 's'; break; + case 216: *a = 'r'; *b = 'e'; *c = 't'; break; + case 217: *a = 'd'; *b = 'u'; *c = 'n'; break; + case 218: *a = 'l'; *b = 'e'; *c = 'r'; break; + case 219: *a = 'n'; *b = 'y'; *c = 'r'; break; + case 220: *a = 's'; *b = 'e'; *c = 'b'; break; + case 221: *a = 'h'; *b = 'u'; *c = 'l'; break; + case 222: *a = 'r'; *b = 'y'; *c = 'l'; break; + case 223: *a = 'l'; *b = 'u'; *c = 'd'; break; + case 224: *a = 'r'; *b = 'e'; *c = 'm'; break; + case 225: *a = 'l'; *b = 'y'; *c = 's'; break; + case 226: *a = 'f'; *b = 'y'; *c = 'n'; break; + case 227: *a = 'w'; *b = 'e'; *c = 'r'; break; + case 228: *a = 'r'; *b = 'y'; *c = 'c'; break; + case 229: *a = 's'; *b = 'u'; *c = 'g'; break; + case 230: *a = 'n'; *b = 'y'; *c = 's'; break; + case 231: *a = 'n'; *b = 'y'; *c = 'l'; break; + case 232: *a = 'l'; *b = 'y'; *c = 'n'; break; + case 233: *a = 'd'; *b = 'y'; *c = 'n'; break; + case 234: *a = 'd'; *b = 'e'; *c = 'm'; break; + case 235: *a = 'l'; *b = 'u'; *c = 'x'; break; + case 236: *a = 'f'; *b = 'e'; *c = 'd'; break; + case 237: *a = 's'; *b = 'e'; *c = 'd'; break; + case 238: *a = 'b'; *b = 'e'; *c = 'c'; break; + case 239: *a = 'm'; *b = 'u'; *c = 'n'; break; + case 240: *a = 'l'; *b = 'y'; *c = 'r'; break; + case 241: *a = 't'; *b = 'e'; *c = 's'; break; + case 242: *a = 'm'; *b = 'u'; *c = 'd'; break; + case 243: *a = 'n'; *b = 'y'; *c = 't'; break; + case 244: *a = 'b'; *b = 'y'; *c = 'r'; break; + case 245: *a = 's'; *b = 'e'; *c = 'n'; break; + case 246: *a = 'w'; *b = 'e'; *c = 'g'; break; + case 247: *a = 'f'; *b = 'y'; *c = 'r'; break; + case 248: *a = 'm'; *b = 'u'; *c = 'r'; break; + case 249: *a = 't'; *b = 'e'; *c = 'l'; break; + case 250: *a = 'r'; *b = 'e'; *c = 'p'; break; + case 251: *a = 't'; *b = 'e'; *c = 'g'; break; + case 252: *a = 'p'; *b = 'e'; *c = 'c'; break; + case 253: *a = 'n'; *b = 'e'; *c = 'l'; break; + case 254: *a = 'n'; *b = 'e'; *c = 'v'; break; + case 255: *a = 'f'; *b = 'e'; *c = 's'; break; + default: u3m_bail(c3__exit); } +} u3_noun u3qc_po_ins(u3_noun a) @@ -892,42 +1392,37 @@ u3wcp_ind(u3_noun cor) } } - u3_noun - u3wcp_tos(u3_noun cor) +u3_noun +u3wcp_tos(u3_noun cor) +{ + u3_noun a; + + if ( (c3n == u3r_mean(cor, u3x_sam, &a, 0)) || + (c3n == u3ud(a)) || + (a >= 256) ) { - u3_noun x, a, buf; - - if ( (c3n == u3r_mean(cor, u3x_sam, &a, u3x_con_sam, &x, 0)) || - (c3n == u3du(x)) || - (c3n == u3ud(buf = u3h(x))) || - (c3n == u3ud(a)) || - (a >= 256) ) - { - return u3m_bail(c3__exit); - } - else { - c3_y byt_y[3]; - - u3r_bytes((a * 3), 3, byt_y, buf); - return (byt_y[0] | (byt_y[1] << 8) | (byt_y[2] << 16)); - } + return u3m_bail(c3__exit); } - u3_noun - u3wcp_tod(u3_noun cor) + else { + c3_y byt_y[3]; + po_to_prefix(a, &byt_y[0], &byt_y[1], &byt_y[2]); + return (byt_y[0] | (byt_y[1] << 8) | (byt_y[2] << 16)); + } +} + +u3_noun +u3wcp_tod(u3_noun cor) +{ + u3_noun a; + + if ( (c3n == u3r_mean(cor, u3x_sam, &a, 0)) || + (c3n == u3ud(a)) || + (a >= 256) ) { - u3_noun x, a, buf; - - if ( (c3n == u3r_mean(cor, u3x_sam, &a, u3x_con_sam, &x, 0)) || - (c3n == u3du(x)) || - (c3n == u3ud(buf = u3t(x))) || - (c3n == u3ud(a)) || - (a >= 256) ) - { - return u3m_bail(c3__exit); - } else { - c3_y byt_y[3]; - - u3r_bytes((a * 3), 3, byt_y, buf); - return (byt_y[0] | (byt_y[1] << 8) | (byt_y[2] << 16)); - } + return u3m_bail(c3__exit); + } else { + c3_y byt_y[3]; + po_to_suffix(a, &byt_y[0], &byt_y[1], &byt_y[2]); + return (byt_y[0] | (byt_y[1] << 8) | (byt_y[2] << 16)); } +} diff --git a/pkg/urbit/jets/e/scow.c b/pkg/urbit/jets/e/scow.c index 02dfc60450..7e9f23659d 100644 --- a/pkg/urbit/jets/e/scow.c +++ b/pkg/urbit/jets/e/scow.c @@ -5,6 +5,54 @@ #include +static +u3_noun +_print_p(u3_atom p) +{ + // Scramble the raw number to the concealed version. + u3_atom sxz = u3qc_ob_fein(p); + + // Simple galaxy case + if (c3y == u3qa_lte(u3k(sxz), 256)) { + c3_y a, b, c; + po_to_suffix(sxz, &a, &b, &c); + u3z(sxz); + return u3nq('~', a, b, u3nc(c, 0)); + } + + u3_atom dyy = u3qc_met(4, u3k(sxz)); + if (!_(u3a_is_cat(dyy))) { + return u3_none; + } + + u3_noun list = 0; + for (u3_atom imp = 0; imp != dyy; ++imp) { + u3_noun log = u3qc_end(4, 1, u3k(sxz)); + u3_noun prefix = u3qc_rsh(3, 1, u3k(log)); + u3_noun suffix = u3qc_end(3, 1, log); + + c3_y a, b, c, d, e, f; + po_to_prefix(prefix, &a, &b, &c); + po_to_suffix(suffix, &d, &e, &f); + + if (imp % 4 == 0) { + if (imp != 0) { + list = u3nt('-', '-', list); + } + } else { + list = u3nc('-', list); + } + + list = u3nq(a, b, c, u3nq(d, e, f, list)); + + sxz = u3qc_rsh(4, 1, sxz); + } + + u3z(sxz); + return u3nc('~', list); +} + +static u3_noun _print_ud(u3_atom ud) { @@ -42,8 +90,8 @@ u3we_scow(u3_noun cor) /* case c3__da: */ /* return _parse_da(cor, txt); */ - /* case 'p': */ - /* return _parse_p(txt); */ + case 'p': + return _print_p(atom); case c3__ud: return _print_ud(atom); @@ -71,6 +119,9 @@ u3we_scot(u3_noun cor) } switch (mod) { + case 'p': + return u3qc_rap(3, _print_p(atom)); + case c3__ud: return u3qc_rap(3, _print_ud(atom)); From e097bdda588672131f9ee1de75eb2f89a6bf3b5e Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 1 May 2020 14:10:47 -0700 Subject: [PATCH 033/933] jets: first pass as (scow %da ...) When trying to hook this up to +scot, I can reliably crash vere, so there's still a bug here around memory. --- pkg/urbit/jets/e/scow.c | 177 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 175 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/jets/e/scow.c b/pkg/urbit/jets/e/scow.c index 7e9f23659d..4627c30793 100644 --- a/pkg/urbit/jets/e/scow.c +++ b/pkg/urbit/jets/e/scow.c @@ -5,6 +5,167 @@ #include +static +c3_y to_digit(u3_atom tig) +{ + if (tig >= 10) { + return 87 + tig; + } else { + return '0' + tig; + } +} + +// gives the characters for a four 'digit' small hex atom. +static +void +_x_co_four(u3_atom src, c3_y* a, c3_y* b, c3_y* c, c3_y* d) +{ + *d = to_digit(src & 0xF); + src >>= 4; + *c = to_digit(src & 0xF); + src >>= 4; + *b = to_digit(src & 0xF); + src >>= 4; + *a = to_digit(src & 0xF); +} + +// The parser always prints two digits on 0 in y-co. +static +void +_y_co_two(u3_atom src, c3_y* a, c3_y* b) +{ + *b = to_digit(src % 10); + *a = to_digit(src / 10); +} + +// +static +u3_noun +_add_year(u3_atom year, u3_noun out) +{ + while (year > 0) { + out = u3nc(to_digit(year % 10), out); + year = year / 10; + } + + return out; +} + +static +u3_noun +_print_da(u3_atom cor, u3_atom raw_da) +{ + u3_noun hok = u3j_cook("u3we_scow_print_da", u3k(cor), "yore"); + u3_noun yod = u3n_slam_on(hok, u3k(raw_da)); + + u3_noun out = 0; + u3m_p("yod", yod); + + u3_atom age, year, month, day, hour, min, sec, f; + if (c3n == u3r_mean(yod, 4, &age, + 5, &year, + 6, &month, + 14, &day, + 30, &hour, + 62, &min, + 126, &sec, + 127, &f, + 0)) { + return u3m_bail(c3__exit); + } + + if (c3n == u3r_sing(f, 0)) { + u3_noun f_list = u3qb_flop(f); + + for (u3_noun cur = f_list; + _(u3a_is_cell(cur)); + cur = u3t(cur)) { + if (_(u3a_is_cat(u3h(cur)))) { + c3_y a, b, c, d; + _x_co_four(u3h(cur), &a, &b, &c, &d); + out = u3nq('.', a, b, u3nt(c, d, out)); + } else { + // No way to deal with big atoms. fall back. + u3z(yod); + u3z(out); + u3z(f_list); + return u3_none; + } + } + + u3z(f_list); + out = u3nc('.', out); + } + + // if there isn't a hex list and the h/m/s are all 0, skip printing hours. + if (c3n == u3r_sing(f, 0) || + c3n == u3r_sing(hour, 0) || + c3n == u3r_sing(min, 0) || + c3n == u3r_sing(sec, 0)) { + if (!_(u3a_is_cat(hour)) || + !_(u3a_is_cat(min)) || + !_(u3a_is_cat(sec))) { + // Input is weird, fallback to nock. + u3z(yod); + u3z(out); + return u3_none; + } + + c3_y sa, sb, ma, mb, ha, hb; + _y_co_two(sec, &sa, &sb); + out = u3nq('.', sa, sb, out); + + _y_co_two(min, &ma, &mb); + out = u3nq('.', ma, mb, out); + + _y_co_two(hour, &ha, &hb); + out = u3nq('.', ha, hb, out); + + out = u3nc('.', out); + } + + // We always print the Y.M.D. Unlike others, these numbers are unconstrained + // by length, but in practice, the month number and day number can only be up + // to two digits because of +yore. We still need to remove 0 prefixes, + // though. + if (!_(u3a_is_cat(day)) || day > 99 || + !_(u3a_is_cat(month)) || month > 99 || + !_(u3a_is_cat(year))) { + // Input is weird, fallback to nock. + u3z(yod); + u3z(out); + return u3_none; + } + + c3_y da, db; + _y_co_two(day, &da, &db); + out = u3nc(db, out); + if (da != '0') + out = u3nc(da, out); + out = u3nc('.', out); + + c3_y ma, mb; + _y_co_two(month, &ma, &mb); + out = u3nc(mb, out); + if (ma != '0') + out = u3nc(ma, out); + out = u3nc('.', out); + + // suffix the year with a '-' for BC dates + if (age == c3n) { + out = u3nc('-', out); + } + + // The year part is the only place where we have to explicitly loop over the + // input because it can be arbitrarily large or small. + out = _add_year(year, out); + + out = u3nc('~', out); + + u3z(yod); + return out; +} + static u3_noun _print_p(u3_atom p) @@ -83,12 +244,13 @@ u3we_scow(u3_noun cor) if (c3n == u3r_mean(cor, u3x_sam_2, &mod, u3x_sam_3, &atom, 0) || !_(u3a_is_cat(mod))) { + u3l_log("u3we_scow fail\r\n"); return u3m_bail(c3__fail); } switch (mod) { - /* case c3__da: */ - /* return _parse_da(cor, txt); */ + case c3__da: + return _print_da(cor, atom); case 'p': return _print_p(atom); @@ -115,10 +277,21 @@ u3we_scot(u3_noun cor) if (c3n == u3r_mean(cor, u3x_sam_2, &mod, u3x_sam_3, &atom, 0) || !_(u3a_is_cat(mod))) { + u3l_log("u3we_scot fail\r\n"); return u3m_bail(c3__fail); } switch (mod) { + // TODO: This causes a bail fail. why? + /* case c3__da: { */ + /* u3_noun x = _print_da(cor, atom); */ + /* if (x == u3_none) { */ + /* return x; */ + /* } */ + + /* return u3qc_rap(3, x); */ + /* } */ + case 'p': return u3qc_rap(3, _print_p(atom)); From 1eb2e58bb7d728e55ab29b0b2b2a336286644dc3 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 1 May 2020 16:16:00 -0700 Subject: [PATCH 034/933] jets: start trying to clean up memory leaks. This cleans up memory leaks in the %ud/%da parsers/renderers, while disabling everything else. There looks like there's a lot of leaks in the +ob core. --- pkg/urbit/include/jets/k.h | 6 ++++++ pkg/urbit/jets/a/div.c | 10 ++++++++++ pkg/urbit/jets/a/mod.c | 9 +++++++++ pkg/urbit/jets/c/con.c | 9 +++++++++ pkg/urbit/jets/e/scow.c | 26 ++++++++++++++++++-------- pkg/urbit/jets/e/slaw.c | 18 ++++++++++-------- pkg/urbit/jets/tree.c | 2 +- 7 files changed, 63 insertions(+), 17 deletions(-) diff --git a/pkg/urbit/include/jets/k.h b/pkg/urbit/include/jets/k.h index 7d6329c565..19eab297d0 100644 --- a/pkg/urbit/include/jets/k.h +++ b/pkg/urbit/include/jets/k.h @@ -5,7 +5,9 @@ /** Tier 1. **/ u3_noun u3ka_add(u3_noun a, u3_noun b); + u3_noun u3ka_div(u3_noun a, u3_noun b); u3_noun u3ka_sub(u3_noun a, u3_noun b); + u3_noun u3ka_mod(u3_noun a, u3_noun b); u3_noun u3ka_mul(u3_noun a, u3_noun b); u3_noun u3ka_gth(u3_noun a, u3_noun b); u3_noun u3ka_lte(u3_noun a, u3_noun b); @@ -18,6 +20,10 @@ /* u3kc: tier 3 functions */ + u3_noun + u3kc_con(u3_noun a, + u3_noun b); + /* u3kc_mix(): binary xor. */ u3_noun diff --git a/pkg/urbit/jets/a/div.c b/pkg/urbit/jets/a/div.c index fa28531607..c9e95de1db 100644 --- a/pkg/urbit/jets/a/div.c +++ b/pkg/urbit/jets/a/div.c @@ -44,3 +44,13 @@ return u3qa_div(a, b); } } + + +u3_noun +u3ka_div(u3_noun a, + u3_noun b) +{ + u3_noun c = u3qa_div(a, b); + u3z(a); u3z(b); + return c; +} diff --git a/pkg/urbit/jets/a/mod.c b/pkg/urbit/jets/a/mod.c index 80c8923ca6..af9f6662bb 100644 --- a/pkg/urbit/jets/a/mod.c +++ b/pkg/urbit/jets/a/mod.c @@ -41,3 +41,12 @@ return u3qa_mod(a, b); } } + +u3_noun +u3ka_mod(u3_noun a, + u3_noun b) +{ + u3_noun c = u3qa_mod(a, b); + u3z(a); u3z(b); + return c; +} diff --git a/pkg/urbit/jets/c/con.c b/pkg/urbit/jets/c/con.c index cf25e4033c..746cd79423 100644 --- a/pkg/urbit/jets/c/con.c +++ b/pkg/urbit/jets/c/con.c @@ -49,3 +49,12 @@ return u3qc_con(a, b); } } + +u3_noun +u3kc_con(u3_noun a, + u3_noun b) +{ + u3_noun c = u3qc_con(a, b); + u3z(a); u3z(b); + return c; +} diff --git a/pkg/urbit/jets/e/scow.c b/pkg/urbit/jets/e/scow.c index 4627c30793..f0d57778ba 100644 --- a/pkg/urbit/jets/e/scow.c +++ b/pkg/urbit/jets/e/scow.c @@ -55,7 +55,9 @@ static u3_noun _print_da(u3_atom cor, u3_atom raw_da) { + u3l_log("about to cook"); u3_noun hok = u3j_cook("u3we_scow_print_da", u3k(cor), "yore"); + u3l_log("cooked"); u3_noun yod = u3n_slam_on(hok, u3k(raw_da)); u3_noun out = 0; @@ -221,14 +223,17 @@ _print_ud(u3_atom ud) int between = 0; u3_atom list = 0; + u3k(ud); + do { if (between == 3) { list = u3nc('.', list); between = 0; } - list = u3nc(u3qa_add(u3qa_mod(u3k(ud), 10), '0'), list); + + list = u3nc(u3ka_add(u3ka_mod(ud, 10), '0'), list); between++; - ud = u3qa_div(ud, 10); + ud = u3ka_div(ud, 10); } while (c3n == u3r_sing(ud, 0)); return list; @@ -252,8 +257,8 @@ u3we_scow(u3_noun cor) case c3__da: return _print_da(cor, atom); - case 'p': - return _print_p(atom); + /* case 'p': */ + /* return _print_p(atom); */ case c3__ud: return _print_ud(atom); @@ -271,6 +276,7 @@ u3we_scow(u3_noun cor) u3_noun u3we_scot(u3_noun cor) { + /* u3l_log("u3we_scot"); */ u3_noun mod; u3_noun atom; @@ -292,11 +298,15 @@ u3we_scot(u3_noun cor) /* return u3qc_rap(3, x); */ /* } */ - case 'p': - return u3qc_rap(3, _print_p(atom)); + /* case 'p': */ + /* return u3qc_rap(3, _print_p(atom)); */ - case c3__ud: - return u3qc_rap(3, _print_ud(atom)); + case c3__ud: { + u3_atom tape = _print_ud(atom); + u3_atom ret = u3qc_rap(3, tape); + u3z(tape); + return ret; + } default: return u3_none; diff --git a/pkg/urbit/jets/e/slaw.c b/pkg/urbit/jets/e/slaw.c index 9476d004d9..97b35a573f 100644 --- a/pkg/urbit/jets/e/slaw.c +++ b/pkg/urbit/jets/e/slaw.c @@ -307,8 +307,8 @@ _parse_p(u3_noun txt) { numname = cur[0] - '0'; \ cur++; \ while (isdigit(cur[0])) { \ - numname = u3qa_mul(numname, 10); \ - numname = u3qa_add(numname, cur[0] - '0'); \ + numname = u3ka_mul(numname, 10); \ + numname = u3ka_add(numname, cur[0] - '0'); \ cur++; \ } \ } while (0) @@ -323,8 +323,8 @@ _parse_p(u3_noun txt) { numname = cur[0] - '0'; \ cur++; \ while (isdigit(cur[0])) { \ - numname = u3qa_mul(numname, 10); \ - numname = u3qa_add(numname, cur[0] - '0'); \ + numname = u3ka_mul(numname, 10); \ + numname = u3ka_add(numname, cur[0] - '0'); \ cur++; \ } \ } while (0) @@ -435,13 +435,15 @@ _parse_da(u3_noun cor, u3_noun txt) { if (cur[0] == 0) { c3_free(c); - list = u3qb_flop(list); + + u3_noun flopped = u3qb_flop(list); + u3z(list); u3_noun hok = u3j_cook("u3we_slaw_parse_da", u3k(cor), "year"); u3_noun res = u3n_slam_on(hok, u3nt(u3nc(bc, year), month, u3nc(day, - u3nq(hour, minute, second, list)))); + u3nq(hour, minute, second, flopped)))); return u3nc(0, res); } @@ -498,8 +500,8 @@ u3we_slaw(u3_noun cor) case c3__da: return _parse_da(cor, txt); - case 'p': - return _parse_p(txt); + /* case 'p': */ + /* return _parse_p(txt); */ case c3__ud: return _parse_ud(txt); diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 5b91e95950..6c24820cd6 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -1298,7 +1298,7 @@ static c3_c* _141_tri_shal_ha[] = { static u3j_core _141_tri_d[] = { { "qua", 3, 0, _141_qua_d, _141_qua_ha, _141_qua_ho }, - { "ob", 3, 0, _141_tri__ob_d, 0 }, + // { "ob", 3, 0, _141_tri__ob_d, 0 }, { "cofl", 7, 0, _141_tri__cofl_d, _141_tri__cofl_ha }, { "rd", 7, 0, _141_tri__rd_d, _141_tri__rd_ha }, { "rs", 7, 0, _141_tri__rs_d, _141_tri__rs_ha }, From bf1f08e6988acb8bdb576eb30ef84fe53ccde80e Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 4 May 2020 10:34:46 -0700 Subject: [PATCH 035/933] jets: Rebuild pills, the enabled jets here now don't leak memory. --- bin/brass.pill | 4 ++-- bin/ivory.pill | 4 ++-- bin/solid.pill | 4 ++-- pkg/arvo/sys/hoon.hoon | 1 + pkg/urbit/jets/c/ob.c | 49 +++++++++++++++++++++++---------------- pkg/urbit/jets/e/scow.c | 22 ++++++++---------- pkg/urbit/noun/allocate.c | 1 + pkg/urbit/noun/jets.c | 6 +++++ pkg/urbit/vere/walk.c | 1 + 9 files changed, 54 insertions(+), 38 deletions(-) diff --git a/bin/brass.pill b/bin/brass.pill index 25c6a104a3..4b1ad92dad 100644 --- a/bin/brass.pill +++ b/bin/brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:418f7512f9ff24de9c222cb4f666ef892c35376c7ee50f9f9e389c7ffa4711fc -size 10010102 +oid sha256:b1b680d53c24ddda774d51baa96d1d7c15d1f71ecbe17aaf82422fc878dd05d3 +size 10013370 diff --git a/bin/ivory.pill b/bin/ivory.pill index 9c8931628e..f0e317d9ef 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9d131da321b891c126f62cc587c5e27c257695ff9ae15e502356159fba7f9bf3 -size 1234415 +oid sha256:29473ada25ac5ce2dbd5c14ede755c375d29f2c6da13c03b727a55220627c756 +size 1234682 diff --git a/bin/solid.pill b/bin/solid.pill index c6ae2e308f..82d9ea5f56 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:816bb2cb6b59153c611ef8bc5342c2e02eb5ef3514f8f510c5aa2387df92e9a9 -size 12470565 +oid sha256:a46c3a2f749bca8d5e9d447060c8cb0ab5251522276bc8f8e956b06a64d83e17 +size 12473821 diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index b0bdbd607e..e483d7d3b4 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -2136,6 +2136,7 @@ ~% %tri + == %year year + %yore yore == |% :: diff --git a/pkg/urbit/jets/c/ob.c b/pkg/urbit/jets/c/ob.c index 60633c394d..b9fe3a5450 100644 --- a/pkg/urbit/jets/c/ob.c +++ b/pkg/urbit/jets/c/ob.c @@ -91,7 +91,7 @@ u3qc_ob_fen(u3_atom r, while (1) { if (c3y == u3qa_lth(j, 1)) { - return u3qa_add(u3qa_mul(arr, a), ell); + return u3ka_add(u3qa_mul(arr, a), ell); } u3_atom f = (*prf_fun)(u3qa_sub(j, 1), ell, datum_u); @@ -148,21 +148,20 @@ u3qc_ob_fe(u3_atom r, u3_atom m) { u3_atom j = 1; - u3_atom ell = u3qa_mod(u3k(m), u3k(a)); - u3_atom arr = u3qa_div(u3k(m), u3k(a)); - u3z(a); + u3_atom ell = u3qa_mod(m, a); + u3_atom arr = u3qa_div(m, a); while (1) { if (c3y == u3qa_gth(j, r)) { if (c3n == u3r_sing(u3qa_mod(r, 2), 0)) { - return u3qa_add(u3qa_mul(arr, a), ell); + return u3ka_add(u3ka_mul(arr, u3k(a)), ell); } if (c3y == u3r_sing(arr, a)) { - return u3qa_add(u3qa_mul(arr, a), ell); + return u3ka_add(u3ka_mul(arr, u3k(a)), ell); } - return u3qa_add(u3qa_mul(ell, a), arr); + return u3ka_add(u3ka_mul(ell, u3k(a)), arr); } // u3_atom f = u3j_gate_slam(prf_u, u3nc(u3qa_sub(j, 1), arr)); @@ -170,12 +169,13 @@ u3qc_ob_fe(u3_atom r, u3_atom tmp; if (c3n == u3r_sing(u3qa_mod(j, 2), 0)) { - tmp = u3qa_mod(u3qa_add(f, ell), a); + tmp = u3ka_mod(u3qa_add(f, ell), u3k(a)); } else { - tmp = u3qa_mod(u3qa_add(f, ell), b); + tmp = u3ka_mod(u3qa_add(f, ell), u3k(b)); } j = u3qa_add(j, 1); + u3z(ell); ell = arr; arr = tmp; } @@ -397,23 +397,32 @@ u3qc_ob_fein(u3_atom pyn) c3_d BIGGEST_PLANET = 0xffffffffULL; c3_d SMALLEST_MOON = 0x100000000ULL; c3_d BIGGEST_MOON = 0xffffffffffffffffULL; - c3_d MOON_MASK = 0xffffffff00000000ULL; - if (c3y == u3qa_gte(u3k(pyn), 0x10000) && - c3y == u3qa_lte(u3k(pyn), u3i_chubs(1, &BIGGEST_PLANET))) { - return u3qa_add(0x10000, u3qc_ob_feis(u3qa_sub(pyn, 0x10000))); + u3_atom biggest_plannet = u3i_chubs(1, &BIGGEST_PLANET); + + if (c3y == u3qa_gte(pyn, 0x10000) && + c3y == u3qa_lte(pyn, biggest_plannet)) { + u3_atom s = u3qa_sub(pyn, 0x10000); + u3_atom f = u3qc_ob_feis(s); + u3z(s); + u3z(biggest_plannet); + return u3ka_add(0x10000, f); } - if (c3y == u3qa_gte(u3k(pyn), u3i_chubs(1, &SMALLEST_MOON)) && - c3y == u3qa_lte(u3k(pyn), u3i_chubs(1, &BIGGEST_MOON))) { - u3_atom lo = u3qc_dis(u3k(pyn), u3i_chubs(1, &BIGGEST_PLANET)); - u3_atom hi = u3qc_dis(u3k(pyn), u3i_chubs(1, &MOON_MASK)); - u3z(pyn); - return u3qc_con(hi, u3qc_ob_fein(lo)); + if (c3y == u3qa_gte(pyn, u3i_chubs(1, &SMALLEST_MOON)) && + c3y == u3qa_lte(pyn, u3i_chubs(1, &BIGGEST_MOON))) { + u3_atom lo = u3qc_dis(pyn, biggest_plannet); + u3_atom hi = u3qc_dis(pyn, u3i_chubs(1, &MOON_MASK)); + + u3_atom fein_lo = u3qc_ob_fein(lo); + u3z(lo); + u3z(biggest_plannet); + return u3kc_con(hi, fein_lo); } - return pyn; + u3z(biggest_plannet); + return u3k(pyn); } u3_noun diff --git a/pkg/urbit/jets/e/scow.c b/pkg/urbit/jets/e/scow.c index f0d57778ba..f2c99654d8 100644 --- a/pkg/urbit/jets/e/scow.c +++ b/pkg/urbit/jets/e/scow.c @@ -55,13 +55,11 @@ static u3_noun _print_da(u3_atom cor, u3_atom raw_da) { - u3l_log("about to cook"); u3_noun hok = u3j_cook("u3we_scow_print_da", u3k(cor), "yore"); - u3l_log("cooked"); u3_noun yod = u3n_slam_on(hok, u3k(raw_da)); u3_noun out = 0; - u3m_p("yod", yod); + // u3m_p("yod", yod); u3_atom age, year, month, day, hour, min, sec, f; if (c3n == u3r_mean(yod, 4, &age, @@ -288,15 +286,15 @@ u3we_scot(u3_noun cor) } switch (mod) { - // TODO: This causes a bail fail. why? - /* case c3__da: { */ - /* u3_noun x = _print_da(cor, atom); */ - /* if (x == u3_none) { */ - /* return x; */ - /* } */ - - /* return u3qc_rap(3, x); */ - /* } */ + case c3__da: { + u3_noun x = _print_da(cor, atom); + if (x == u3_none) { + return x; + } + u3_noun ret = u3qc_rap(3, x); + u3z(x); + return ret; + } /* case 'p': */ /* return u3qc_rap(3, _print_p(atom)); */ diff --git a/pkg/urbit/noun/allocate.c b/pkg/urbit/noun/allocate.c index b743df1616..eef5b3fe6d 100644 --- a/pkg/urbit/noun/allocate.c +++ b/pkg/urbit/noun/allocate.c @@ -1002,6 +1002,7 @@ _me_gain_use(u3_noun dog) u3a_box* box_u = u3a_botox(dog_w); if ( 0x7fffffff == box_u->use_w ) { + u3l_log("fail in _me_gain_use"); u3m_bail(c3__fail); } else { diff --git a/pkg/urbit/noun/jets.c b/pkg/urbit/noun/jets.c index 2ae4aea40c..3864beebcb 100644 --- a/pkg/urbit/noun/jets.c +++ b/pkg/urbit/noun/jets.c @@ -950,11 +950,13 @@ _cj_hook_in(u3_noun cor, u3_noun roc, tem, got, pat, nam, huc; if ( c3n == u3du(cor) ) { + u3l_log("_cj_hook_in failure: c3n == u3du(cor)\r\n"); return u3m_bail(c3__fail); } loc = _cj_spot(cor, NULL); if ( u3_none == loc ) { + u3l_log("_cj_hook_in failure: u3_none == loc\r\n"); return u3m_bail(c3__fail); } @@ -1019,6 +1021,7 @@ _cj_hook_in(u3_noun cor, else { u3_noun sat = u3t(pat); if ( c3y == u3h(sat) ) { + u3l_log("_cj_hook_in failure: c3y == u3h(sat)\r\n"); return u3m_bail(c3__fail); } else { @@ -1158,11 +1161,13 @@ _cj_hank_fill(_cj_hank* han_u, u3_noun tam, u3_noun cor) u3j_site* sit_u = &(han_u->sit_u); if ( c3n == u3du(cor) ) { + u3l_log("fail in _cj_hank_fill (c3n == u3du(cor))"); return u3m_bail(c3__fail); } sit_u->bas = u3_none; if ( u3_none == (col = loc = _cj_spot(cor, NULL)) ) { + u3l_log("fail in _cj_hank_fill (_cj_spot(cor, NULL))"); return u3m_bail(c3__fail); } @@ -1205,6 +1210,7 @@ _cj_hank_fill(_cj_hank* han_u, u3_noun tam, u3_noun cor) else { u3_noun sat = u3t(pat); if ( c3y == u3h(sat) ) { + u3l_log("fail in _cj_hank_fill (c3y == u3h(sat))"); return u3m_bail(c3__fail); } else { diff --git a/pkg/urbit/vere/walk.c b/pkg/urbit/vere/walk.c index 1456d9aa8d..c607360e42 100644 --- a/pkg/urbit/vere/walk.c +++ b/pkg/urbit/vere/walk.c @@ -90,6 +90,7 @@ u3_walk_load(c3_c* pas_c) if ( fln_w != red_w ) { c3_free(pad_y); + u3l_log("u3_walk_load failed"); return u3m_bail(c3__fail); } else { From fa4dbfb9f6e719d6e4b63662494ee79431c468e6 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 4 May 2020 15:46:07 -0700 Subject: [PATCH 036/933] jets: remove +ob and add hooks for +fein and +fynd I'm not going to be able to debug the memory leaks in the +ob core jets, so remove those new jets and hooks to +fein and +fynd so they can be called from the @p parsing jets. This moves +fein adn +fynd to the toplevel because there appear to be issues with hooks referencing things that aren't in the directly jetted core. --- bin/brass.pill | 4 +- bin/ivory.pill | 4 +- bin/solid.pill | 4 +- pkg/arvo/sys/hoon.hoon | 80 ++++---- pkg/urbit/jets/c/ob.c | 441 ---------------------------------------- pkg/urbit/jets/e/scow.c | 45 ++-- pkg/urbit/jets/e/slaw.c | 29 +-- pkg/urbit/jets/tree.c | 23 --- 8 files changed, 76 insertions(+), 554 deletions(-) delete mode 100644 pkg/urbit/jets/c/ob.c diff --git a/bin/brass.pill b/bin/brass.pill index 4b1ad92dad..5b79a30f00 100644 --- a/bin/brass.pill +++ b/bin/brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b1b680d53c24ddda774d51baa96d1d7c15d1f71ecbe17aaf82422fc878dd05d3 -size 10013370 +oid sha256:ba7f42d7ef75e84599a26fa98f491cbf080d7dcbf1eec800f1422e94a0e32f08 +size 10013383 diff --git a/bin/ivory.pill b/bin/ivory.pill index f0e317d9ef..ba9afed629 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:29473ada25ac5ce2dbd5c14ede755c375d29f2c6da13c03b727a55220627c756 -size 1234682 +oid sha256:344c5ea8ba5a65e2958b9998fc5d22e03dd4324d6d83af3c834e082c923e5b89 +size 1234701 diff --git a/bin/solid.pill b/bin/solid.pill index 82d9ea5f56..521df7d011 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a46c3a2f749bca8d5e9d447060c8cb0ab5251522276bc8f8e956b06a64d83e17 -size 12473821 +oid sha256:d9cee942f6f8ff7cc2b6b72a8e301f3cfdcc409bc6097579aebde76a9784cd50 +size 12473831 diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index e483d7d3b4..18d5c5ed0b 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -2137,6 +2137,8 @@ == %year year %yore yore + %fein fein + %fynd fynd == |% :: @@ -3813,49 +3815,47 @@ (cut 3 [a 1] b) -- :: +:: +fein: conceal structure, v3. +:: +:: +fein conceals planet-sized atoms. The idea is that it should not be +:: trivial to tell which planet a star has spawned under. +:: +++ fein + ~/ %fein + |= pyn/@ ^- @ + ?: &((gte pyn 0x1.0000) (lte pyn 0xffff.ffff)) + (add 0x1.0000 (feis:ob (sub pyn 0x1.0000))) + ?: &((gte pyn 0x1.0000.0000) (lte pyn 0xffff.ffff.ffff.ffff)) + =/ lo (dis pyn 0xffff.ffff) + =/ hi (dis pyn 0xffff.ffff.0000.0000) + %+ con hi + $(pyn lo) + pyn +:: +:: +fynd: restore structure, v3. +:: +:: Restores obfuscated values that have been enciphered with +fein. +:: +++ fynd + ~/ %fynd + |= cry/@ ^- @ + ?: &((gte cry 0x1.0000) (lte cry 0xffff.ffff)) + (add 0x1.0000 (tail:ob (sub cry 0x1.0000))) + ?: &((gte cry 0x1.0000.0000) (lte cry 0xffff.ffff.ffff.ffff)) + =/ lo (dis cry 0xffff.ffff) + =/ hi (dis cry 0xffff.ffff.0000.0000) + %+ con hi + $(cry lo) + cry +:: ++ ob - ~% %ob + ~ |% - :: +fein: conceal structure, v3. - :: - :: +fein conceals planet-sized atoms. The idea is that it should not be - :: trivial to tell which planet a star has spawned under. - :: - ++ fein - ~/ %fein - |= pyn/@ ^- @ - ?: &((gte pyn 0x1.0000) (lte pyn 0xffff.ffff)) - (add 0x1.0000 (feis (sub pyn 0x1.0000))) - ?: &((gte pyn 0x1.0000.0000) (lte pyn 0xffff.ffff.ffff.ffff)) - =/ lo (dis pyn 0xffff.ffff) - =/ hi (dis pyn 0xffff.ffff.0000.0000) - %+ con hi - $(pyn lo) - pyn - :: - :: +fynd: restore structure, v3. - :: - :: Restores obfuscated values that have been enciphered with +fein. - :: - ++ fynd - ~/ %fynd - |= cry/@ ^- @ - ?: &((gte cry 0x1.0000) (lte cry 0xffff.ffff)) - (add 0x1.0000 (tail (sub cry 0x1.0000))) - ?: &((gte cry 0x1.0000.0000) (lte cry 0xffff.ffff.ffff.ffff)) - =/ lo (dis cry 0xffff.ffff) - =/ hi (dis cry 0xffff.ffff.0000.0000) - %+ con hi - $(cry lo) - cry - :: :: +feis: a four-round generalised Feistel cipher over the domain :: [0, 2^32 - 2^16 - 1]. :: :: See: Black & Rogaway (2002), Ciphers for arbitrary finite domains. :: ++ feis - ~/ %feis |= m=@ ^- @ (fee 4 0xffff 0x1.0000 (mul 0xffff 0x1.0000) eff m) @@ -3863,7 +3863,6 @@ :: +tail: reverse +feis. :: ++ tail - ~/ %tail |= m=@ ^- @ (feen 4 0xffff 0x1.0000 (mul 0xffff 0x1.0000) eff m) @@ -3880,7 +3879,6 @@ :: m: an input value in the domain [0, k - 1] :: ++ fee - ~/ %fee |= [r=@ a=@ b=@ k=@ prf=$-([j=@ r=@] @) m=@] ^- @ =/ c (fe r a b prf m) @@ -3894,7 +3892,6 @@ :: +fee. :: ++ feen - ~/ %feen |= [r=@ a=@ b=@ k=@ prf=$-([j=@ r=@] @) m=@] ^- @ =/ c (fen r a b prf m) @@ -3910,7 +3907,6 @@ :: to support some legacy behaviour. See urbit/arvo#1105. :: ++ fe - ~/ %fe |= [r=@ a=@ b=@ prf=$-([j=@ r=@] @) m=@] =/ j 1 =/ ell (mod m a) @@ -3949,7 +3945,6 @@ :: to support some legacy behaviour. See urbit/arvo#1105. :: ++ fen - ~/ %fen |= [r=@ a=@ b=@ prf=$-([j=@ r=@] @) m=@] =/ j r :: @@ -3998,7 +3993,6 @@ :: +eff: a murmur3-based pseudorandom function. 'F' in B&R (2002). :: ++ eff - ~/ %eff |= [j=@ r=@] ^- @ (muk (snag j raku) 2 r) @@ -5813,7 +5807,7 @@ ++ dim (ape dip) ++ dip (bass 10 ;~(plug sed:ab (star sid:ab))) ++ dum (bass 10 (plus sid:ab)) - ++ fed %+ cook fynd:ob + ++ fed %+ cook fynd ;~ pose %+ bass 0x1.0000.0000.0000.0000 :: oversized ;~ plug @@ -5925,7 +5919,7 @@ == :: $p - =+ sxz=(fein:ob q.p.lot) + =+ sxz=(fein q.p.lot) =+ dyx=(met 3 sxz) :- '~' ?: (lte dyx 1) diff --git a/pkg/urbit/jets/c/ob.c b/pkg/urbit/jets/c/ob.c deleted file mode 100644 index b9fe3a5450..0000000000 --- a/pkg/urbit/jets/c/ob.c +++ /dev/null @@ -1,441 +0,0 @@ -/* j/3/ob.c -** -*/ -#include "all.h" - -// Functions written in reverse order from the core because earlier functions -// depend on later functions. - -// We have to both suport passing u3qc_ob_eff around and passing a prepared -// gate which usually, but not necessarily points to it. So we have a -// trampoline which slams a gate, but have the same signature as the normal eff -// hash function. -u3_noun -_do_slam_gate(u3_atom j, u3_atom r, void* datum) -{ - return u3j_gate_slam((u3j_site*)datum, u3nc(j, r)); -} - -u3_noun -u3qc_ob_eff(u3_atom j, u3_atom r, void* unused) -{ - c3_d found = 0; - switch (j) { - case 0: - found = 0xb76d5eed; - break; - case 1: - found = 0xee281300; - break; - case 2: - found = 0x85bcae01; - break; - case 3: - found = 0x4b387af7; - break; - default: - // the internal snag would have failed. - return u3m_bail(c3__exit); - } - - return u3qc_muk(u3i_chubs(1, &found), 2, r); -} - -u3_noun -u3wc_ob_eff(u3_noun cor) -{ - u3_noun j, r; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &j, - u3x_sam_3, &r, 0)) || - (c3n == u3ud(j)) || - (c3n == u3ud(r)) ) - { - fprintf(stderr, "u3wc_ob_eff failed to unpack\r\n"); - return u3m_bail(c3__exit); - } - else { - return u3qc_ob_eff(j, r, 0); - } -} - -u3_noun -u3qc_ob_fen(u3_atom r, - u3_atom a, - u3_atom b, - u3_atom(*prf_fun)(u3_atom j, u3_atom r, void* datum_u), - void* datum_u, - u3_atom m) -{ - u3_atom j = r; - - u3_atom ahh; - u3_atom ale; - if (c3y == u3r_sing(u3qa_mod(r, 2), 0)) { - ahh = u3qa_mod(m, a); - ale = u3qa_div(m, a); - } else { - ahh = u3qa_div(m, a); - ale = u3qa_mod(m, a); - } - - u3_atom ell; - u3_atom arr; - if (c3y == u3r_sing(ale, a)) { - ell = ahh; - arr = ale; - } else { - ell = ale; - arr = ahh; - } - - while (1) { - if (c3y == u3qa_lth(j, 1)) { - return u3ka_add(u3qa_mul(arr, a), ell); - } - - u3_atom f = (*prf_fun)(u3qa_sub(j, 1), ell, datum_u); - - u3_atom tmp; - if (c3y == u3r_sing(u3qa_mod(j, 2), 0)) { - tmp = u3qa_mod(u3qa_sub(u3qa_add(arr, b), u3qa_mod(f, b)), b); - } else { - tmp = u3qa_mod(u3qa_sub(u3qa_add(arr, a), u3qa_mod(f, a)), a); - } - - j = u3qa_sub(j, 1); - arr = ell; - ell = tmp; - } -} - -u3_noun -u3wc_ob_fen(u3_noun cor) -{ - u3_noun r, a, b, prf, m; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &r, - u3x_sam_6, &a, - u3x_sam_14, &b, - u3x_sam_30, &prf, - u3x_sam_31, &m, 0)) || - (c3n == u3ud(r)) || - (c3n == u3ud(a)) || - (c3n == u3ud(b)) || - (c3n == u3ud(m)) ) - { - fprintf(stderr, "u3wc_ob_fen failed to unpack\r\n"); - return u3m_bail(c3__exit); - } - else { - u3_noun pro; - u3j_site sit_u; - - u3j_gate_prep(&sit_u, u3k(prf)); - pro = u3qc_ob_fen(r, a, b, _do_slam_gate, &sit_u, m); - u3j_gate_lose(&sit_u); - return pro; - } -} - - -u3_noun -u3qc_ob_fe(u3_atom r, - u3_atom a, - u3_atom b, - u3_atom(*prf_fun)(u3_atom j, u3_atom r, void* datum_u), - void* datum_u, - u3_atom m) -{ - u3_atom j = 1; - u3_atom ell = u3qa_mod(m, a); - u3_atom arr = u3qa_div(m, a); - - while (1) { - if (c3y == u3qa_gth(j, r)) { - if (c3n == u3r_sing(u3qa_mod(r, 2), 0)) { - return u3ka_add(u3ka_mul(arr, u3k(a)), ell); - } - - if (c3y == u3r_sing(arr, a)) { - return u3ka_add(u3ka_mul(arr, u3k(a)), ell); - } - - return u3ka_add(u3ka_mul(ell, u3k(a)), arr); - } - - // u3_atom f = u3j_gate_slam(prf_u, u3nc(u3qa_sub(j, 1), arr)); - u3_atom f = (*prf_fun)(u3qa_sub(j, 1), arr, datum_u); - - u3_atom tmp; - if (c3n == u3r_sing(u3qa_mod(j, 2), 0)) { - tmp = u3ka_mod(u3qa_add(f, ell), u3k(a)); - } else { - tmp = u3ka_mod(u3qa_add(f, ell), u3k(b)); - } - - j = u3qa_add(j, 1); - u3z(ell); - ell = arr; - arr = tmp; - } -} - -u3_noun -u3wc_ob_fe(u3_noun cor) -{ - u3_noun r, a, b, prf, m; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &r, - u3x_sam_6, &a, - u3x_sam_14, &b, - u3x_sam_30, &prf, - u3x_sam_31, &m, 0)) || - (c3n == u3ud(r)) || - (c3n == u3ud(a)) || - (c3n == u3ud(b)) || - (c3n == u3ud(m)) ) - { - fprintf(stderr, "u3wc_ob_fe failed to unpack\r\n"); - return u3m_bail(c3__exit); - } - else { - u3_noun pro; - u3j_site sit_u; - - u3j_gate_prep(&sit_u, u3k(prf)); - pro = u3qc_ob_fe(r, a, b, _do_slam_gate, &sit_u, m); - u3j_gate_lose(&sit_u); - return pro; - } -} - - -u3_noun -u3qc_ob_feen(u3_atom r, - u3_atom a, - u3_atom b, - u3_atom k, - u3_atom(*prf_fun)(u3_atom j, u3_atom r, void* datum_u), - void* datum_u, - u3_atom m) -{ - u3_atom c = u3qc_ob_fen(r, a, b, prf_fun, datum_u, m); - if (c3y == u3qa_lth(u3k(c), k)) { - return c; - } - - return u3qc_ob_fen(r, a, b, prf_fun, datum_u, c); -} - -u3_noun -u3wc_ob_feen(u3_noun cor) -{ - u3_noun r, a, b, k, prf, m; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &r, - u3x_sam_6, &a, - u3x_sam_14, &b, - u3x_sam_30, &k, - u3x_sam_62, &prf, - u3x_sam_63, &m, 0)) || - (c3n == u3ud(r)) || - (c3n == u3ud(a)) || - (c3n == u3ud(b)) || - (c3n == u3ud(k)) || - (c3n == u3ud(m)) ) - { - fprintf(stderr, "u3wc_ob_fe failed to unpack\r\n"); - return u3m_bail(c3__exit); - } - else { - u3_noun pro; - u3j_site sit_u; - - u3j_gate_prep(&sit_u, u3k(prf)); - pro = u3qc_ob_feen(r, a, b, k, _do_slam_gate, &sit_u, m); - u3j_gate_lose(&sit_u); - return pro; - } -} - - -u3_noun -u3qc_ob_fee(u3_atom r, - u3_atom a, - u3_atom b, - u3_atom k, - u3_atom(*prf_fun)(u3_atom j, u3_atom r, void* datum_u), - void* datum_u, - u3_atom m) -{ - u3_atom c = u3qc_ob_fe(r, a, b, prf_fun, datum_u, m); - if (c3y == u3qa_lth(u3k(c), k)) { - return c; - } - - return u3qc_ob_fe(r, a, b, prf_fun, datum_u, c); -} - -u3_noun -u3wc_ob_fee(u3_noun cor) -{ - u3_noun r, a, b, k, prf, m; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &r, - u3x_sam_6, &a, - u3x_sam_14, &b, - u3x_sam_30, &k, - u3x_sam_62, &prf, - u3x_sam_63, &m, 0)) || - (c3n == u3ud(r)) || - (c3n == u3ud(a)) || - (c3n == u3ud(b)) || - (c3n == u3ud(k)) || - (c3n == u3ud(m)) ) - { - return u3m_bail(c3__exit); - } - else { - u3_noun pro; - u3j_site sit_u; - - u3j_gate_prep(&sit_u, u3k(prf)); - pro = u3qc_ob_fee(r, a, b, k, _do_slam_gate, &sit_u, m); - u3j_gate_lose(&sit_u); - return pro; - } -} - -u3_noun -u3qc_ob_tail(u3_atom m) -{ - return u3qc_ob_feen(4, 0xffff, 0x10000, u3qa_mul(0xffff, 0x10000), - u3qc_ob_eff, (void*)0, m); -} - -u3_noun -u3wc_ob_tail(u3_noun cor) -{ - u3_noun m; - - if ( (c3n == u3r_mean(cor, u3x_sam, &m, 0)) || - (c3n == u3ud(m)) ) - { - return u3m_bail(c3__exit); - } - else { - return u3qc_ob_tail(m); - } -} - -u3_noun -u3qc_ob_feis(u3_atom m) -{ - return u3qc_ob_fee(4, 0xffff, 0x10000, u3qa_mul(0xffff, 0x10000), - u3qc_ob_eff, (void*)0, m); -} - -u3_noun -u3wc_ob_feis(u3_noun cor) -{ - u3_noun m; - - if ( (c3n == u3r_mean(cor, u3x_sam, &m, 0)) || - (c3n == u3ud(m)) ) - { - return u3m_bail(c3__exit); - } - else { - return u3qc_ob_feis(m); - } -} - -u3_noun -u3qc_ob_fynd(u3_atom cry) -{ - c3_d BIGGEST_PLANET = 0xffffffffULL; - c3_d SMALLEST_MOON = 0x100000000ULL; - c3_d BIGGEST_MOON = 0xffffffffffffffffULL; - - c3_d MOON_MASK = 0xffffffff00000000ULL; - - if (c3y == u3qa_gte(u3k(cry), 0x10000) && - c3y == u3qa_lte(u3k(cry), u3i_chubs(1, &BIGGEST_PLANET))) { - return u3qa_add(0x10000, u3qc_ob_tail(u3qa_sub(cry, 0x10000))); - } - - if (c3y == u3qa_gte(u3k(cry), u3i_chubs(1, &SMALLEST_MOON)) && - c3y == u3qa_lte(u3k(cry), u3i_chubs(1, &BIGGEST_MOON))) { - u3_atom lo = u3qc_dis(u3k(cry), u3i_chubs(1, &BIGGEST_PLANET)); - u3_atom hi = u3qc_dis(u3k(cry), u3i_chubs(1, &MOON_MASK)); - u3z(cry); - return u3qc_con(hi, u3qc_ob_fynd(lo)); - } - - return cry; -} - -u3_noun -u3wc_ob_fynd(u3_noun cor) -{ - u3_noun m; - - if ( (c3n == u3r_mean(cor, u3x_sam, &m, 0)) || - (c3n == u3ud(m)) ) - { - return u3m_bail(c3__exit); - } - else { - return u3qc_ob_fynd(m); - } -} - -u3_noun -u3qc_ob_fein(u3_atom pyn) -{ - c3_d BIGGEST_PLANET = 0xffffffffULL; - c3_d SMALLEST_MOON = 0x100000000ULL; - c3_d BIGGEST_MOON = 0xffffffffffffffffULL; - c3_d MOON_MASK = 0xffffffff00000000ULL; - - u3_atom biggest_plannet = u3i_chubs(1, &BIGGEST_PLANET); - - if (c3y == u3qa_gte(pyn, 0x10000) && - c3y == u3qa_lte(pyn, biggest_plannet)) { - u3_atom s = u3qa_sub(pyn, 0x10000); - u3_atom f = u3qc_ob_feis(s); - u3z(s); - u3z(biggest_plannet); - return u3ka_add(0x10000, f); - } - - if (c3y == u3qa_gte(pyn, u3i_chubs(1, &SMALLEST_MOON)) && - c3y == u3qa_lte(pyn, u3i_chubs(1, &BIGGEST_MOON))) { - u3_atom lo = u3qc_dis(pyn, biggest_plannet); - u3_atom hi = u3qc_dis(pyn, u3i_chubs(1, &MOON_MASK)); - - u3_atom fein_lo = u3qc_ob_fein(lo); - u3z(lo); - u3z(biggest_plannet); - return u3kc_con(hi, fein_lo); - } - - u3z(biggest_plannet); - return u3k(pyn); -} - -u3_noun -u3wc_ob_fein(u3_noun cor) -{ - u3_noun m; - - if ( (c3n == u3r_mean(cor, u3x_sam, &m, 0)) || - (c3n == u3ud(m)) ) - { - return u3m_bail(c3__exit); - } - else { - return u3qc_ob_fein(m); - } -} diff --git a/pkg/urbit/jets/e/scow.c b/pkg/urbit/jets/e/scow.c index f2c99654d8..e7839357e7 100644 --- a/pkg/urbit/jets/e/scow.c +++ b/pkg/urbit/jets/e/scow.c @@ -59,7 +59,6 @@ _print_da(u3_atom cor, u3_atom raw_da) u3_noun yod = u3n_slam_on(hok, u3k(raw_da)); u3_noun out = 0; - // u3m_p("yod", yod); u3_atom age, year, month, day, hour, min, sec, f; if (c3n == u3r_mean(yod, 4, &age, @@ -168,10 +167,11 @@ _print_da(u3_atom cor, u3_atom raw_da) static u3_noun -_print_p(u3_atom p) +_print_p(u3_atom cor, u3_atom p) { // Scramble the raw number to the concealed version. - u3_atom sxz = u3qc_ob_fein(p); + u3_noun hok = u3j_cook("u3we_scow_fein_p", u3k(cor), "fein"); + u3_atom sxz = u3n_slam_on(hok, u3k(p)); // Simple galaxy case if (c3y == u3qa_lte(u3k(sxz), 256)) { @@ -237,7 +237,6 @@ _print_ud(u3_atom ud) return list; } -// u3_noun u3we_scow(u3_noun cor) { @@ -255,8 +254,8 @@ u3we_scow(u3_noun cor) case c3__da: return _print_da(cor, atom); - /* case 'p': */ - /* return _print_p(atom); */ + case 'p': + return _print_p(cor, atom); case c3__ud: return _print_ud(atom); @@ -285,28 +284,28 @@ u3we_scot(u3_noun cor) return u3m_bail(c3__fail); } + u3_noun tape; switch (mod) { - case c3__da: { - u3_noun x = _print_da(cor, atom); - if (x == u3_none) { - return x; - } - u3_noun ret = u3qc_rap(3, x); - u3z(x); - return ret; - } + case c3__da: + tape = _print_da(cor, atom); + break; - /* case 'p': */ - /* return u3qc_rap(3, _print_p(atom)); */ + case 'p': + tape = _print_p(cor, atom); + break; - case c3__ud: { - u3_atom tape = _print_ud(atom); - u3_atom ret = u3qc_rap(3, tape); - u3z(tape); - return ret; - } + case c3__ud: + tape = _print_ud(atom); + break; default: return u3_none; } + + if (tape == u3_none) { + return tape; + } + u3_noun ret = u3qc_rap(3, tape); + u3z(tape); + return ret; } diff --git a/pkg/urbit/jets/e/slaw.c b/pkg/urbit/jets/e/slaw.c index 97b35a573f..1c5dfba30d 100644 --- a/pkg/urbit/jets/e/slaw.c +++ b/pkg/urbit/jets/e/slaw.c @@ -48,18 +48,7 @@ _parse_ud(u3_noun txt) { return u3nc(0, total); } -// parsing @p: -// -// +slaw calls +fed:ag directly. +fed:ag: -// -// - parses the text first into a number. -// - runs fynd:ob, which is the scrambler restore structure. And +fynd is -// unjetted. -// -// The actual +po stuff, like +ins:po, is jetted but it's jetted such that it -// pulls the tables out of the sample, so we can't just reuse it from other -// jets. - +static u3_noun get_syllable(c3_c** cur_ptr, c3_c* one, c3_c* two, c3_c* three) { if (islower((*cur_ptr)[0]) && islower((*cur_ptr)[1]) && islower((*cur_ptr)[2])) { @@ -114,7 +103,7 @@ u3_noun combine(u3_noun p, u3_noun q) } u3_noun -_parse_p(u3_noun txt) { +_parse_p(u3_noun cor, u3_noun txt) { c3_c* c = u3r_string(txt); c3_c* cur = c; @@ -173,7 +162,9 @@ _parse_p(u3_noun txt) { u3_atom raw = u3k(u3t(m)); u3z(m); - return u3nc(0, u3qc_ob_fynd(raw)); + + u3_noun hok = u3j_cook("u3we_slaw_fynd_p", u3k(cor), "fynd"); + return u3nc(0, u3n_slam_on(hok, u3k(raw))); } // There must now be a - or it is invalid. @@ -204,7 +195,8 @@ _parse_p(u3_noun txt) { u3_atom raw = u3k(u3t(m)); u3z(m); - return u3nc(0, u3qc_ob_fynd(raw)); + u3_noun hok = u3j_cook("u3we_slaw_fynd_p", u3k(cor), "fynd"); + return u3nc(0, u3n_slam_on(hok, u3k(raw))); } // There must now be a - or it is invalid. @@ -238,7 +230,8 @@ _parse_p(u3_noun txt) { u3_atom raw = u3k(u3t(m)); u3z(m); - return u3nc(0, u3qc_ob_fynd(raw)); + u3_noun hok = u3j_cook("u3we_slaw_fynd_p", u3k(cor), "fynd"); + return u3nc(0, u3n_slam_on(hok, u3k(raw))); } // At this point, the only thing it could be is a long comet, of the form @@ -500,8 +493,8 @@ u3we_slaw(u3_noun cor) case c3__da: return _parse_da(cor, txt); - /* case 'p': */ - /* return _parse_p(txt); */ + case 'p': + return _parse_p(cor, txt); case c3__ud: return _parse_ud(txt); diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 6c24820cd6..20d3c0c35b 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -928,28 +928,6 @@ static c3_c* _141_tri__cofl_ha[] = { }; -static u3j_harm _141_tri__ob_fein_a[] = {{".2", u3wc_ob_fein}, {}}; -static u3j_harm _141_tri__ob_fynd_a[] = {{".2", u3wc_ob_fynd}, {}}; -static u3j_harm _141_tri__ob_feis_a[] = {{".2", u3wc_ob_feis}, {}}; -static u3j_harm _141_tri__ob_tail_a[] = {{".2", u3wc_ob_tail}, {}}; -static u3j_harm _141_tri__ob_fee_a[] = {{".2", u3wc_ob_fee}, {}}; -static u3j_harm _141_tri__ob_feen_a[] = {{".2", u3wc_ob_feen}, {}}; -static u3j_harm _141_tri__ob_fe_a[] = {{".2", u3wc_ob_fe}, {}}; -static u3j_harm _141_tri__ob_fen_a[] = {{".2", u3wc_ob_fen}, {}}; -static u3j_harm _141_tri__ob_eff_a[] = {{".2", u3wc_ob_eff}, {}}; -static u3j_core _141_tri__ob_d[] = - { { "fein", 7, _141_tri__ob_fein_a, 0, 0 }, - { "fynd", 7, _141_tri__ob_fynd_a, 0, 0 }, - { "feis", 7, _141_tri__ob_feis_a, 0, 0 }, - { "tail", 7, _141_tri__ob_tail_a, 0, 0 }, - { "fee", 7, _141_tri__ob_fee_a, 0, 0 }, - { "feen", 7, _141_tri__ob_feen_a, 0, 0 }, - { "fe", 7, _141_tri__ob_fe_a, 0, 0 }, - { "fen", 7, _141_tri__ob_fen_a, 0, 0 }, - { "eff", 7, _141_tri__ob_eff_a, 0, 0 }, - {} - }; - static u3j_harm _141_tri__rd_add_a[] = {{".2", u3wer_add}, {}}; static c3_c* _141_tri__rd_add_ha[] = { @@ -1298,7 +1276,6 @@ static c3_c* _141_tri_shal_ha[] = { static u3j_core _141_tri_d[] = { { "qua", 3, 0, _141_qua_d, _141_qua_ha, _141_qua_ho }, - // { "ob", 3, 0, _141_tri__ob_d, 0 }, { "cofl", 7, 0, _141_tri__cofl_d, _141_tri__cofl_ha }, { "rd", 7, 0, _141_tri__rd_d, _141_tri__rd_ha }, { "rs", 7, 0, _141_tri__rs_d, _141_tri__rs_ha }, From 91582b046e7afafba03c2064abeb309175418593 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 4 May 2020 16:10:49 -0700 Subject: [PATCH 037/933] jets: jet +scot %uv and %uw. --- pkg/urbit/jets/e/scow.c | 82 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/pkg/urbit/jets/e/scow.c b/pkg/urbit/jets/e/scow.c index e7839357e7..81a0fd8880 100644 --- a/pkg/urbit/jets/e/scow.c +++ b/pkg/urbit/jets/e/scow.c @@ -15,6 +15,22 @@ c3_y to_digit(u3_atom tig) } } +static +c3_y to_w_digit(u3_atom tig) +{ + if (tig == 63) { + return '~'; + } else if (tig == 62) { + return '-'; + } else if (tig >= 36) { + return 29 + tig; + } else if (tig >= 10) { + return 87 + tig; + } else { + return '0' + tig; + } +} + // gives the characters for a four 'digit' small hex atom. static void @@ -229,7 +245,7 @@ _print_ud(u3_atom ud) between = 0; } - list = u3nc(u3ka_add(u3ka_mod(ud, 10), '0'), list); + list = u3nc(u3ka_add(u3qa_mod(ud, 10), '0'), list); between++; ud = u3ka_div(ud, 10); } while (c3n == u3r_sing(ud, 0)); @@ -237,6 +253,56 @@ _print_ud(u3_atom ud) return list; } +static +u3_noun +_print_uv(u3_atom uv) +{ + // number of characters printed "between" periods. + int between = 0; + u3_atom list = 0; + + u3k(uv); + + do { + if (between == 5) { + list = u3nc('.', list); + between = 0; + } + + u3_atom tig = u3qa_mod(uv, 32); + list = u3nc(to_digit(tig), list); + between++; + uv = u3ka_div(uv, 32); + } while (c3n == u3r_sing(uv, 0)); + + return u3nt('0', 'v', list); +} + +static +u3_noun +_print_uw(u3_atom uw) +{ + // number of characters printed "between" periods. + int between = 0; + u3_atom list = 0; + + u3k(uw); + + do { + if (between == 5) { + list = u3nc('.', list); + between = 0; + } + + u3_atom tig = u3qa_mod(uw, 64); + list = u3nc(to_w_digit(tig), list); + between++; + uw = u3ka_div(uw, 64); + } while (c3n == u3r_sing(uw, 0)); + + return u3nt('0', 'w', list); +} + u3_noun u3we_scow(u3_noun cor) { @@ -260,6 +326,12 @@ u3we_scow(u3_noun cor) case c3__ud: return _print_ud(atom); + case c3__uv: + return _print_uv(atom); + + case c3__uw: + return _print_uw(atom); + /* // %ta is used once in link.hoon. don't bother. */ /* case c3__tas: */ @@ -298,6 +370,14 @@ u3we_scot(u3_noun cor) tape = _print_ud(atom); break; + case c3__uv: + tape = _print_uv(atom); + break; + + case c3__uw: + tape = _print_uw(atom); + break; + default: return u3_none; } From d204c1d6654a78aa10e2e409f571170d2f130d4d Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 4 May 2020 16:32:21 -0700 Subject: [PATCH 038/933] jets: cleanups. --- pkg/urbit/jets/e/scow.c | 1 - pkg/urbit/jets/e/slaw.c | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/urbit/jets/e/scow.c b/pkg/urbit/jets/e/scow.c index 81a0fd8880..6e7c8b03a8 100644 --- a/pkg/urbit/jets/e/scow.c +++ b/pkg/urbit/jets/e/scow.c @@ -345,7 +345,6 @@ u3we_scow(u3_noun cor) u3_noun u3we_scot(u3_noun cor) { - /* u3l_log("u3we_scot"); */ u3_noun mod; u3_noun atom; diff --git a/pkg/urbit/jets/e/slaw.c b/pkg/urbit/jets/e/slaw.c index 1c5dfba30d..c432309a6e 100644 --- a/pkg/urbit/jets/e/slaw.c +++ b/pkg/urbit/jets/e/slaw.c @@ -31,15 +31,17 @@ _parse_ud(u3_noun txt) { if (cur[0] > '9' || cur[0] < '0') { c3_free(c); + u3z(total); return 0; } - total = u3qa_mul(total, 10); - total = u3qa_add(total, cur[0] - '0'); + total = u3ka_mul(total, 10); + total = u3ka_add(total, cur[0] - '0'); cur++; if (since_last_period > 3) { c3_free(c); + u3z(total); return 0; } } From 239cd93f3a01bf374ca132c9e256b94852508d34 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 5 May 2020 10:45:22 -0700 Subject: [PATCH 039/933] jets: further cleanups. --- pkg/urbit/jets/e/scow.c | 5 ----- pkg/urbit/jets/e/slaw.c | 8 ++------ 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/pkg/urbit/jets/e/scow.c b/pkg/urbit/jets/e/scow.c index 6e7c8b03a8..e665c619d8 100644 --- a/pkg/urbit/jets/e/scow.c +++ b/pkg/urbit/jets/e/scow.c @@ -332,11 +332,6 @@ u3we_scow(u3_noun cor) case c3__uw: return _print_uw(atom); - /* // %ta is used once in link.hoon. don't bother. */ - - /* case c3__tas: */ - /* return _parse_tas(txt); */ - default: return u3_none; } diff --git a/pkg/urbit/jets/e/slaw.c b/pkg/urbit/jets/e/slaw.c index c432309a6e..eb14abb787 100644 --- a/pkg/urbit/jets/e/slaw.c +++ b/pkg/urbit/jets/e/slaw.c @@ -75,7 +75,7 @@ u3_noun combine(u3_noun p, u3_noun q) return 0; } - u3_noun ret = u3nc(0, u3qa_add(u3k(u3t(p)), u3qa_mul(256, u3k(u3t(q))))); + u3_noun ret = u3nc(0, u3qa_add(u3t(p), u3qa_mul(256, u3t(q)))); u3z(p); u3z(q); @@ -109,11 +109,7 @@ _parse_p(u3_noun cor, u3_noun txt) { c3_c* c = u3r_string(txt); c3_c* cur = c; - if (cur[0] != '~') { - c3_free(c); - return 0; - } - cur++; + CONSUME('~'); // We at least have a sig prefix. We're now going to parse tuples of three // lowercase letters. Our naming pattern for the pieces we read is [a b c d From 9838763b5ef6993b5bdbb11322c9fab82c0f3f7d Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 5 May 2020 10:59:41 -0700 Subject: [PATCH 040/933] jets: patch minimization. --- pkg/urbit/include/jets/q.h | 3 --- pkg/urbit/include/jets/w.h | 10 ---------- pkg/urbit/jets/tree.c | 3 --- 3 files changed, 16 deletions(-) diff --git a/pkg/urbit/include/jets/q.h b/pkg/urbit/include/jets/q.h index c441117003..cfaf41a785 100644 --- a/pkg/urbit/include/jets/q.h +++ b/pkg/urbit/include/jets/q.h @@ -75,9 +75,6 @@ void po_to_prefix(u3_noun id, c3_y* a, c3_y* b, c3_y* c); void po_to_suffix(u3_noun id, c3_y* a, c3_y* b, c3_y* c); - u3_noun u3qc_ob_fein(u3_atom); - u3_noun u3qc_ob_fynd(u3_atom); - /** Tier 4. **/ u3_noun u3qdb_bif(u3_noun, u3_noun); diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index 8990927d81..3944ff037d 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -76,16 +76,6 @@ u3_noun u3wcp_tos(u3_noun); u3_noun u3wcp_tod(u3_noun); - u3_noun u3wc_ob_fein(u3_noun); - u3_noun u3wc_ob_fynd(u3_noun); - u3_noun u3wc_ob_feis(u3_noun); - u3_noun u3wc_ob_tail(u3_noun); - u3_noun u3wc_ob_fee(u3_noun); - u3_noun u3wc_ob_feen(u3_noun); - u3_noun u3wc_ob_fe(u3_noun); - u3_noun u3wc_ob_fen(u3_noun); - u3_noun u3wc_ob_eff(u3_noun); - /** Tier 4. **/ u3_noun u3wdb_bif(u3_noun); diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 20d3c0c35b..8593655dbb 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -927,8 +927,6 @@ static c3_c* _141_tri__cofl_ha[] = { 0 }; - - static u3j_harm _141_tri__rd_add_a[] = {{".2", u3wer_add}, {}}; static c3_c* _141_tri__rd_add_ha[] = { "90dfaaadb2878d6d89a808ce4199e5bb239fa981e1c2edf24dc54aa3fcab55a5", @@ -1288,7 +1286,6 @@ static u3j_core _141_tri_d[] = { "shay", 7, _141_tri_shay_a, 0, _141_tri_shay_ha }, { "shas", 7, _141_tri_shas_a, 0, _141_tri_shas_ha }, { "shal", 7, _141_tri_shal_a, 0, _141_tri_shal_ha }, - {} }; static c3_c* _141_tri_ha[] = { From ca1522062100f459764a10c64f5cd90813852a10 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 6 May 2020 11:30:53 -0700 Subject: [PATCH 041/933] jets: use u3a for strings instead. --- pkg/urbit/include/noun/allocate.h | 5 ++ pkg/urbit/jets/e/slaw.c | 78 +++++++++++++++---------------- pkg/urbit/noun/allocate.c | 13 ++++++ 3 files changed, 57 insertions(+), 39 deletions(-) diff --git a/pkg/urbit/include/noun/allocate.h b/pkg/urbit/include/noun/allocate.h index 2c9113d272..31edb8904d 100644 --- a/pkg/urbit/include/noun/allocate.h +++ b/pkg/urbit/include/noun/allocate.h @@ -523,3 +523,8 @@ void* ptr_v, void (*pat_f)(u3_atom, void*), c3_o (*cel_f)(u3_noun, void*)); + + /* u3a_string(): `a` as an on-loom c-string. + */ + c3_c* + u3a_string(u3_atom a); diff --git a/pkg/urbit/jets/e/slaw.c b/pkg/urbit/jets/e/slaw.c index eb14abb787..f4e21c75de 100644 --- a/pkg/urbit/jets/e/slaw.c +++ b/pkg/urbit/jets/e/slaw.c @@ -6,15 +6,15 @@ #include /* functions -*/ + */ u3_noun _parse_ud(u3_noun txt) { - c3_c* c = u3r_string(txt); + c3_c* c = u3a_string(txt); // First character must represent a digit c3_c* cur = c; if (cur[0] > '9' || cur[0] < '0') { - c3_free(c); + u3a_free(c); return 0; } c3_w total = cur[0] - '0'; @@ -30,7 +30,7 @@ _parse_ud(u3_noun txt) { } if (cur[0] > '9' || cur[0] < '0') { - c3_free(c); + u3a_free(c); u3z(total); return 0; } @@ -40,13 +40,13 @@ _parse_ud(u3_noun txt) { cur++; if (since_last_period > 3) { - c3_free(c); + u3a_free(c); u3z(total); return 0; } } - c3_free(c); + u3a_free(c); return u3nc(0, total); } @@ -84,14 +84,14 @@ u3_noun combine(u3_noun p, u3_noun q) #define ENSURE_NOT_END() do { \ if (*cur == 0) { \ - c3_free(c); \ + u3a_free(c); \ return 0; \ } \ } while (0) #define CONSUME(x) do { \ if (*cur != x) { \ - c3_free(c); \ + u3a_free(c); \ return 0; \ } \ cur++; \ @@ -100,13 +100,13 @@ u3_noun combine(u3_noun p, u3_noun q) #define TRY_GET_SYLLABLE(prefix) \ c3_c prefix##_one, prefix##_two, prefix##_three; \ if (c3n == get_syllable(&cur, & prefix##_one, & prefix##_two, & prefix##_three)) { \ - c3_free(c); \ + u3a_free(c); \ return 0; \ } u3_noun _parse_p(u3_noun cor, u3_noun txt) { - c3_c* c = u3r_string(txt); + c3_c* c = u3a_string(txt); c3_c* cur = c; CONSUME('~'); @@ -120,7 +120,7 @@ _parse_p(u3_noun cor, u3_noun txt) { // it's a galaxy. We don't even have to run this through the scrambler or // check for validity since its already a (unit @). if (*cur == 0) { - c3_free(c); + u3a_free(c); return po_find_suffix(a_one, a_two, a_three); } @@ -132,7 +132,7 @@ _parse_p(u3_noun cor, u3_noun txt) { u3_noun a_part = po_find_prefix(a_one, a_two, a_three); u3_noun b_part = po_find_suffix(b_one, b_two, b_three); u3_atom combined = combine(b_part, a_part); - c3_free(c); + u3a_free(c); return combined; } @@ -152,7 +152,7 @@ _parse_p(u3_noun cor, u3_noun txt) { u3_noun d_part = po_find_suffix(d_one, d_two, d_three); u3_noun m = combine(d_part, combine(c_part, combine(b_part, a_part))); - c3_free(c); + u3a_free(c); if (_(u3a_is_atom(m))) { return 0; @@ -185,7 +185,7 @@ _parse_p(u3_noun cor, u3_noun txt) { u3_noun m = combine(f_part, combine(e_part, combine(d_part, combine(c_part, combine(b_part, a_part))))); - c3_free(c); + u3a_free(c); if (_(u3a_is_atom(m))) { return 0; @@ -220,7 +220,7 @@ _parse_p(u3_noun cor, u3_noun txt) { u3_noun m = combine(h_part, combine(g_part, combine(f_part, combine(e_part, combine(d_part, combine(c_part, combine(b_part, a_part))))))); - c3_free(c); + u3a_free(c); if (_(u3a_is_atom(m))) { return 0; @@ -257,7 +257,7 @@ _parse_p(u3_noun cor, u3_noun txt) { if (*cur != 0) { // We've parsed all of a comet shape, and there's still more in the // string. Error. - c3_free(c); + u3a_free(c); return 0; } @@ -280,7 +280,7 @@ _parse_p(u3_noun cor, u3_noun txt) { u3_noun o_part = po_find_prefix(o_one, o_two, o_three); u3_noun p_part = po_find_suffix(p_one, p_two, p_three); - c3_free(c); + u3a_free(c); return combine(p_part, combine(o_part, combine(n_part, combine(m_part, combine(l_part, combine(k_part, combine(j_part, combine(i_part, @@ -292,7 +292,7 @@ _parse_p(u3_noun cor, u3_noun txt) { c3_w numname = 0; \ do { \ if (cur[0] > '9' || cur[0] < '1') { \ - c3_free(c); \ + u3a_free(c); \ return 0; \ } \ numname = cur[0] - '0'; \ @@ -308,7 +308,7 @@ _parse_p(u3_noun cor, u3_noun txt) { c3_w numname = 0; \ do { \ if (cur[0] > '9' || cur[0] < '0') { \ - c3_free(c); \ + u3a_free(c); \ return 0; \ } \ numname = cur[0] - '0'; \ @@ -320,23 +320,23 @@ _parse_p(u3_noun cor, u3_noun txt) { } \ } while (0) -#define PARSE_HEX_DIGIT(out) \ - do { \ - if (cur[0] >= '0' && cur[0] <= '9') { \ - out = cur[0] - '0'; \ - } else if (cur[0] >= 'a' && cur[0] <= 'f') { \ - out = 10 + cur[0] - 'a'; \ - } else { \ - c3_free(c); \ - return 0; \ - } \ - cur++; \ +#define PARSE_HEX_DIGIT(out) \ + do { \ + if (cur[0] >= '0' && cur[0] <= '9') { \ + out = cur[0] - '0'; \ + } else if (cur[0] >= 'a' && cur[0] <= 'f') { \ + out = 10 + cur[0] - 'a'; \ + } else { \ + u3a_free(c); \ + return 0; \ + } \ + cur++; \ } while(0) u3_noun _parse_da(u3_noun cor, u3_noun txt) { - c3_c* c = u3r_string(txt); + c3_c* c = u3a_string(txt); c3_c* cur = c; CONSUME('~'); @@ -370,7 +370,7 @@ _parse_da(u3_noun cor, u3_noun txt) { month = cur[0] - '0'; cur++; } else { - c3_free(c); + u3a_free(c); return 0; } @@ -381,7 +381,7 @@ _parse_da(u3_noun cor, u3_noun txt) { PARSE_NONZERO_NUMBER(day); if (cur[0] == 0) { - c3_free(c); + u3a_free(c); u3_noun hok = u3j_cook("u3we_slaw_parse_da", u3k(cor), "year"); u3_noun res = u3n_slam_on(hok, u3nt(u3nc(bc, year), month, @@ -399,7 +399,7 @@ _parse_da(u3_noun cor, u3_noun txt) { PARSE_INCLUDING_ZERO_NUMBER(second); if (cur[0] == 0) { - c3_free(c); + u3a_free(c); u3_noun hok = u3j_cook("u3we_slaw_parse_da", u3k(cor), "year"); u3_noun res = u3n_slam_on(hok, u3nt(u3nc(bc, year), month, @@ -425,7 +425,7 @@ _parse_da(u3_noun cor, u3_noun txt) { list = u3nc(current, list); if (cur[0] == 0) { - c3_free(c); + u3a_free(c); u3_noun flopped = u3qb_flop(list); u3z(list); @@ -452,26 +452,26 @@ u3_noun _parse_tas(u3_noun txt) { // For any symbol which matches, txt will return itself as a // value. Therefore, this is mostly checking validity. - c3_c* c = u3r_string(txt); + c3_c* c = u3a_string(txt); // First character must represent a lowercase letter c3_c* cur = c; if (!islower(cur[0])) { - c3_free(c); + u3a_free(c); return 0; } cur++; while (cur[0] != 0) { if (!(islower(cur[0]) || isdigit(cur[0]) || cur[0] == '-')) { - c3_free(c); + u3a_free(c); return 0; } cur++; } - c3_free(c); + u3a_free(c); return u3nc(0, u3k(txt)); } diff --git a/pkg/urbit/noun/allocate.c b/pkg/urbit/noun/allocate.c index eef5b3fe6d..383ccd58bf 100644 --- a/pkg/urbit/noun/allocate.c +++ b/pkg/urbit/noun/allocate.c @@ -2321,3 +2321,16 @@ u3a_walk_fore_unsafe(u3_noun a, a = *top; } } + +/* u3a_string(): `a` as an on-loom c-string. +*/ +c3_c* +u3a_string(u3_atom a) +{ + c3_w met_w = u3r_met(3, a); + c3_c* str_c = u3a_malloc(met_w + 1); + + u3r_bytes(0, met_w, (c3_y*)str_c, a); + str_c[met_w] = 0; + return str_c; +} From a7b272d85968218ac469db21d04c747854716df6 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 6 May 2020 11:49:03 -0700 Subject: [PATCH 042/933] jets: fail -> exit --- pkg/urbit/jets/e/slaw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/urbit/jets/e/slaw.c b/pkg/urbit/jets/e/slaw.c index f4e21c75de..7fed54e28f 100644 --- a/pkg/urbit/jets/e/slaw.c +++ b/pkg/urbit/jets/e/slaw.c @@ -484,7 +484,7 @@ u3we_slaw(u3_noun cor) if (c3n == u3r_mean(cor, u3x_sam_2, &mod, u3x_sam_3, &txt, 0) || !_(u3a_is_cat(mod))) { - return u3m_bail(c3__fail); + return u3m_bail(c3__exit); } switch (mod) { From 29f335d85db1759e1444d44f8c4c496de6327a2e Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 6 May 2020 12:44:41 -0700 Subject: [PATCH 043/933] jets: return u3_none in a lot of error cases. --- pkg/urbit/jets/e/slaw.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/urbit/jets/e/slaw.c b/pkg/urbit/jets/e/slaw.c index 7fed54e28f..28cc10ea51 100644 --- a/pkg/urbit/jets/e/slaw.c +++ b/pkg/urbit/jets/e/slaw.c @@ -15,7 +15,7 @@ _parse_ud(u3_noun txt) { c3_c* cur = c; if (cur[0] > '9' || cur[0] < '0') { u3a_free(c); - return 0; + return u3_none; } c3_w total = cur[0] - '0'; cur++; @@ -32,7 +32,7 @@ _parse_ud(u3_noun txt) { if (cur[0] > '9' || cur[0] < '0') { u3a_free(c); u3z(total); - return 0; + return u3_none; } total = u3ka_mul(total, 10); @@ -42,7 +42,7 @@ _parse_ud(u3_noun txt) { if (since_last_period > 3) { u3a_free(c); u3z(total); - return 0; + return u3_none; } } @@ -85,14 +85,14 @@ u3_noun combine(u3_noun p, u3_noun q) #define ENSURE_NOT_END() do { \ if (*cur == 0) { \ u3a_free(c); \ - return 0; \ + return u3_none; \ } \ } while (0) #define CONSUME(x) do { \ if (*cur != x) { \ u3a_free(c); \ - return 0; \ + return u3_none; \ } \ cur++; \ } while (0) @@ -101,7 +101,7 @@ u3_noun combine(u3_noun p, u3_noun q) c3_c prefix##_one, prefix##_two, prefix##_three; \ if (c3n == get_syllable(&cur, & prefix##_one, & prefix##_two, & prefix##_three)) { \ u3a_free(c); \ - return 0; \ + return u3_none; \ } u3_noun @@ -258,7 +258,7 @@ _parse_p(u3_noun cor, u3_noun txt) { // We've parsed all of a comet shape, and there's still more in the // string. Error. u3a_free(c); - return 0; + return u3_none; } // We have a long comet. Time to jam it all together. We rely on combine() @@ -293,7 +293,7 @@ _parse_p(u3_noun cor, u3_noun txt) { do { \ if (cur[0] > '9' || cur[0] < '1') { \ u3a_free(c); \ - return 0; \ + return u3_none; \ } \ numname = cur[0] - '0'; \ cur++; \ @@ -309,7 +309,7 @@ _parse_p(u3_noun cor, u3_noun txt) { do { \ if (cur[0] > '9' || cur[0] < '0') { \ u3a_free(c); \ - return 0; \ + return u3_none; \ } \ numname = cur[0] - '0'; \ cur++; \ @@ -328,7 +328,7 @@ _parse_p(u3_noun cor, u3_noun txt) { out = 10 + cur[0] - 'a'; \ } else { \ u3a_free(c); \ - return 0; \ + return u3_none; \ } \ cur++; \ } while(0) @@ -371,7 +371,7 @@ _parse_da(u3_noun cor, u3_noun txt) { cur++; } else { u3a_free(c); - return 0; + return u3_none; } CONSUME('.'); From a05360f97af716ddb52b7ae3ffc2334d966070cd Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 6 May 2020 15:13:59 -0700 Subject: [PATCH 044/933] jets: hook %ob, then %fein/%fynd --- bin/brass.pill | 4 +-- bin/ivory.pill | 4 +-- bin/solid.pill | 4 +-- pkg/arvo/sys/hoon.hoon | 78 ++++++++++++++++++++++------------------- pkg/urbit/jets/e/scow.c | 3 +- pkg/urbit/jets/e/slaw.c | 9 +++-- 6 files changed, 55 insertions(+), 47 deletions(-) diff --git a/bin/brass.pill b/bin/brass.pill index 5b79a30f00..e13d46f52f 100644 --- a/bin/brass.pill +++ b/bin/brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ba7f42d7ef75e84599a26fa98f491cbf080d7dcbf1eec800f1422e94a0e32f08 -size 10013383 +oid sha256:cdc31bb717626f95d7455349dac4f3171205667c4d08ed9fad071bd13266bab6 +size 10013218 diff --git a/bin/ivory.pill b/bin/ivory.pill index ba9afed629..712296e0e6 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:344c5ea8ba5a65e2958b9998fc5d22e03dd4324d6d83af3c834e082c923e5b89 -size 1234701 +oid sha256:0a637a7a8e2061caa09ea1cf62c2295a0b14920588d01338e9bd2f06eecf1c1f +size 1234571 diff --git a/bin/solid.pill b/bin/solid.pill index 521df7d011..eecb04dd53 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d9cee942f6f8ff7cc2b6b72a8e301f3cfdcc409bc6097579aebde76a9784cd50 -size 12473831 +oid sha256:d8eeac47513dba778cd83269996eb04f1519280ec5a36bf0395517451cd087d5 +size 12473677 diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 18d5c5ed0b..fd29ee537c 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -2137,8 +2137,7 @@ == %year year %yore yore - %fein fein - %fynd fynd + %ob ob == |% :: @@ -3815,41 +3814,46 @@ (cut 3 [a 1] b) -- :: -:: +fein: conceal structure, v3. -:: -:: +fein conceals planet-sized atoms. The idea is that it should not be -:: trivial to tell which planet a star has spawned under. -:: -++ fein - ~/ %fein - |= pyn/@ ^- @ - ?: &((gte pyn 0x1.0000) (lte pyn 0xffff.ffff)) - (add 0x1.0000 (feis:ob (sub pyn 0x1.0000))) - ?: &((gte pyn 0x1.0000.0000) (lte pyn 0xffff.ffff.ffff.ffff)) - =/ lo (dis pyn 0xffff.ffff) - =/ hi (dis pyn 0xffff.ffff.0000.0000) - %+ con hi - $(pyn lo) - pyn -:: -:: +fynd: restore structure, v3. -:: -:: Restores obfuscated values that have been enciphered with +fein. -:: -++ fynd - ~/ %fynd - |= cry/@ ^- @ - ?: &((gte cry 0x1.0000) (lte cry 0xffff.ffff)) - (add 0x1.0000 (tail:ob (sub cry 0x1.0000))) - ?: &((gte cry 0x1.0000.0000) (lte cry 0xffff.ffff.ffff.ffff)) - =/ lo (dis cry 0xffff.ffff) - =/ hi (dis cry 0xffff.ffff.0000.0000) - %+ con hi - $(cry lo) - cry -:: ++ ob + ~% %ob ..ob + == + %fein fein + %fynd fynd + == |% + :: + :: +fein: conceal structure, v3. + :: + :: +fein conceals planet-sized atoms. The idea is that it should not be + :: trivial to tell which planet a star has spawned under. + :: + ++ fein + ~/ %fein + |= pyn/@ ^- @ + ?: &((gte pyn 0x1.0000) (lte pyn 0xffff.ffff)) + (add 0x1.0000 (feis (sub pyn 0x1.0000))) + ?: &((gte pyn 0x1.0000.0000) (lte pyn 0xffff.ffff.ffff.ffff)) + =/ lo (dis pyn 0xffff.ffff) + =/ hi (dis pyn 0xffff.ffff.0000.0000) + %+ con hi + $(pyn lo) + pyn + :: + :: +fynd: restore structure, v3. + :: + :: Restores obfuscated values that have been enciphered with +fein. + :: + ++ fynd + ~/ %fynd + |= cry/@ ^- @ + ?: &((gte cry 0x1.0000) (lte cry 0xffff.ffff)) + (add 0x1.0000 (tail (sub cry 0x1.0000))) + ?: &((gte cry 0x1.0000.0000) (lte cry 0xffff.ffff.ffff.ffff)) + =/ lo (dis cry 0xffff.ffff) + =/ hi (dis cry 0xffff.ffff.0000.0000) + %+ con hi + $(cry lo) + cry :: +feis: a four-round generalised Feistel cipher over the domain :: [0, 2^32 - 2^16 - 1]. :: @@ -5807,7 +5811,7 @@ ++ dim (ape dip) ++ dip (bass 10 ;~(plug sed:ab (star sid:ab))) ++ dum (bass 10 (plus sid:ab)) - ++ fed %+ cook fynd + ++ fed %+ cook fynd:ob ;~ pose %+ bass 0x1.0000.0000.0000.0000 :: oversized ;~ plug @@ -5919,7 +5923,7 @@ == :: $p - =+ sxz=(fein q.p.lot) + =+ sxz=(fein:ob q.p.lot) =+ dyx=(met 3 sxz) :- '~' ?: (lte dyx 1) diff --git a/pkg/urbit/jets/e/scow.c b/pkg/urbit/jets/e/scow.c index e665c619d8..ea3f35c68d 100644 --- a/pkg/urbit/jets/e/scow.c +++ b/pkg/urbit/jets/e/scow.c @@ -186,7 +186,8 @@ u3_noun _print_p(u3_atom cor, u3_atom p) { // Scramble the raw number to the concealed version. - u3_noun hok = u3j_cook("u3we_scow_fein_p", u3k(cor), "fein"); + u3_noun ob = u3j_cook("u3we_scow_ob_p", u3k(cor), "ob"); + u3_noun hok = u3j_cook("u3we_scow_fein_p", ob, "fein"); u3_atom sxz = u3n_slam_on(hok, u3k(p)); // Simple galaxy case diff --git a/pkg/urbit/jets/e/slaw.c b/pkg/urbit/jets/e/slaw.c index 28cc10ea51..92ad23948d 100644 --- a/pkg/urbit/jets/e/slaw.c +++ b/pkg/urbit/jets/e/slaw.c @@ -161,7 +161,8 @@ _parse_p(u3_noun cor, u3_noun txt) { u3_atom raw = u3k(u3t(m)); u3z(m); - u3_noun hok = u3j_cook("u3we_slaw_fynd_p", u3k(cor), "fynd"); + u3_noun ob = u3j_cook("u3we_slaw_ob_p", u3k(cor), "ob"); + u3_noun hok = u3j_cook("u3we_slaw_fynd_p", ob, "fynd"); return u3nc(0, u3n_slam_on(hok, u3k(raw))); } @@ -193,7 +194,8 @@ _parse_p(u3_noun cor, u3_noun txt) { u3_atom raw = u3k(u3t(m)); u3z(m); - u3_noun hok = u3j_cook("u3we_slaw_fynd_p", u3k(cor), "fynd"); + u3_noun ob = u3j_cook("u3we_slaw_ob_p", u3k(cor), "ob"); + u3_noun hok = u3j_cook("u3we_slaw_fynd_p", ob, "fynd"); return u3nc(0, u3n_slam_on(hok, u3k(raw))); } @@ -228,7 +230,8 @@ _parse_p(u3_noun cor, u3_noun txt) { u3_atom raw = u3k(u3t(m)); u3z(m); - u3_noun hok = u3j_cook("u3we_slaw_fynd_p", u3k(cor), "fynd"); + u3_noun ob = u3j_cook("u3we_slaw_ob_p", u3k(cor), "ob"); + u3_noun hok = u3j_cook("u3we_slaw_fynd_p", ob, "fynd"); return u3nc(0, u3n_slam_on(hok, u3k(raw))); } From de91adb61a6c839c353b436af441235662cb6efc Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 6 May 2020 15:23:45 -0700 Subject: [PATCH 045/933] jets: more cleanups from review. --- pkg/urbit/jets/e/scow.c | 28 ++++++++++++++++------------ pkg/urbit/jets/e/slaw.c | 9 ++++++--- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/pkg/urbit/jets/e/scow.c b/pkg/urbit/jets/e/scow.c index ea3f35c68d..f20d446120 100644 --- a/pkg/urbit/jets/e/scow.c +++ b/pkg/urbit/jets/e/scow.c @@ -204,7 +204,7 @@ _print_p(u3_atom cor, u3_atom p) } u3_noun list = 0; - for (u3_atom imp = 0; imp != dyy; ++imp) { + for (c3_w imp = 0; imp != dyy; ++imp) { u3_noun log = u3qc_end(4, 1, u3k(sxz)); u3_noun prefix = u3qc_rsh(3, 1, u3k(log)); u3_noun suffix = u3qc_end(3, 1, log); @@ -249,7 +249,7 @@ _print_ud(u3_atom ud) list = u3nc(u3ka_add(u3qa_mod(ud, 10), '0'), list); between++; ud = u3ka_div(ud, 10); - } while (c3n == u3r_sing(ud, 0)); + } while (ud != 0); return list; } @@ -274,7 +274,7 @@ _print_uv(u3_atom uv) list = u3nc(to_digit(tig), list); between++; uv = u3ka_div(uv, 32); - } while (c3n == u3r_sing(uv, 0)); + } while (uv != 0); return u3nt('0', 'v', list); } @@ -299,7 +299,7 @@ _print_uw(u3_atom uw) list = u3nc(to_w_digit(tig), list); between++; uw = u3ka_div(uw, 64); - } while (c3n == u3r_sing(uw, 0)); + } while (uw != 0); return u3nt('0', 'w', list); } @@ -311,10 +311,12 @@ u3we_scow(u3_noun cor) u3_noun atom; if (c3n == u3r_mean(cor, u3x_sam_2, &mod, - u3x_sam_3, &atom, 0) || - !_(u3a_is_cat(mod))) { - u3l_log("u3we_scow fail\r\n"); - return u3m_bail(c3__fail); + u3x_sam_3, &atom, 0)) { + return u3m_bail(c3__exit); + } + + if (!_(u3a_is_cat(mod))) { + return u3_none; } switch (mod) { @@ -345,10 +347,12 @@ u3we_scot(u3_noun cor) u3_noun atom; if (c3n == u3r_mean(cor, u3x_sam_2, &mod, - u3x_sam_3, &atom, 0) || - !_(u3a_is_cat(mod))) { - u3l_log("u3we_scot fail\r\n"); - return u3m_bail(c3__fail); + u3x_sam_3, &atom, 0)) { + return u3m_bail(c3__exit); + } + + if (!_(u3a_is_cat(mod))) { + return u3_none; } u3_noun tape; diff --git a/pkg/urbit/jets/e/slaw.c b/pkg/urbit/jets/e/slaw.c index 92ad23948d..0e8aa11075 100644 --- a/pkg/urbit/jets/e/slaw.c +++ b/pkg/urbit/jets/e/slaw.c @@ -259,7 +259,7 @@ _parse_p(u3_noun cor, u3_noun txt) { if (*cur != 0) { // We've parsed all of a comet shape, and there's still more in the - // string. Error. + // string. Bail back to the interpreter. u3a_free(c); return u3_none; } @@ -485,11 +485,14 @@ u3we_slaw(u3_noun cor) u3_noun txt; if (c3n == u3r_mean(cor, u3x_sam_2, &mod, - u3x_sam_3, &txt, 0) || - !_(u3a_is_cat(mod))) { + u3x_sam_3, &txt, 0)) { return u3m_bail(c3__exit); } + if (!_(u3a_is_cat(mod))) { + return u3_none; + } + switch (mod) { case c3__da: return _parse_da(cor, txt); From 1695977655b651e2df6175d8bf4b27455621eda3 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 7 May 2020 15:48:48 -0700 Subject: [PATCH 046/933] u3: WIP refactors +uni:by jet --- pkg/urbit/jets/d/by_uni.c | 107 ++++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 52 deletions(-) diff --git a/pkg/urbit/jets/d/by_uni.c b/pkg/urbit/jets/d/by_uni.c index 10e621dea4..574558a045 100644 --- a/pkg/urbit/jets/d/by_uni.c +++ b/pkg/urbit/jets/d/by_uni.c @@ -11,12 +11,12 @@ u3_noun u3qdb_uni(u3_noun a, u3_noun b) { - if ( u3_nul == a ) { - return u3k(b); - } - else if ( u3_nul == b ) { + if ( u3_nul == b ) { return u3k(a); } + else if ( u3_nul == a ) { + return u3k(b); + } else { u3_noun n_a, l_a, r_a; u3_noun n_b, l_b, r_b; @@ -27,59 +27,62 @@ u3qdb_uni(u3_noun a, u3x_cell(n_a, &p_n_a, &q_n_a); u3x_cell(n_b, &p_n_b, &q_n_b); - if ( c3y == u3qc_mor(p_n_a, p_n_b) ) { - if ( c3y == u3r_sing(p_n_a, p_n_b) ) { - return u3nt(u3k(n_b), - u3qdb_uni(u3k(l_a), - u3k(l_b)), - u3qdb_uni(u3k(r_a), - u3k(r_b))); - } - else if ( c3y == u3qc_gor(p_n_b, p_n_a) ) { - return u3qdb_uni( - u3nt(u3k(n_a), - u3qdb_uni(u3k(l_a), - u3nt(u3k(n_b), - u3k(l_b), - u3k(u3_nul))), - u3k(r_a)), - u3k(r_b)); + if ( c3y == u3r_sing(p_n_a, p_n_b) ) { + return u3nt(u3k(n_b), + u3qdb_uni(l_a, l_b), + u3qdb_uni(r_a, r_b)); + } + else if ( c3y == u3qc_mor(p_n_a, p_n_b) ) { + u3_noun new_a, old_b; + + if ( c3y == u3qc_gor(p_n_b, p_n_a) ) { + u3_noun new_b = u3nt(u3k(n_b), u3k(l_b), u3_nul); + u3_noun new_la = u3qdb_uni(l_a, new_b); + u3z(new_b); + + new_a = u3nt(u3k(n_a), new_la, u3k(r_a)); + old_b = r_b; } else { - return u3qdb_uni( - u3nt(u3k(n_a), - u3k(l_a), - u3qdb_uni(u3k(r_a), - u3nt(u3k(n_b), - u3k(u3_nul), - u3k(r_b)))), - u3k(l_b)); + u3_noun new_b = u3nt(u3k(n_b), u3_nul, u3k(r_b)); + u3_noun new_ra = u3qdb_uni(r_a, new_b); + u3z(new_b); + + new_a = u3nt(u3k(n_a), u3k(l_a), new_ra); + old_b = l_b; + } + + { + u3_noun pro = u3qdb_uni(new_a, old_b); + u3z(new_a); + return pro; } } - else if ( c3y == u3r_sing(p_n_b, p_n_a) ) { - return u3nt(u3k(n_b), - u3qdb_uni(u3k(r_b), u3k(r_a)), - u3qdb_uni(u3k(l_b), u3k(l_a))); - } - else if ( c3y == u3qc_gor(p_n_a, p_n_b) ) { - return u3qdb_uni( - u3k(r_a), - u3nt(u3k(n_b), - u3qdb_uni(u3nt(u3k(n_a), - u3k(l_a), - u3k(u3_nul)), - u3k(l_b)), - u3k(r_b))); - } else { - return u3qdb_uni( - u3k(l_a), - u3nt(u3k(n_b), - u3k(l_b), - u3qdb_uni(u3k(r_b), - u3nt(u3k(n_a), - u3k(u3_nul), - u3k(r_a))))); + u3_noun old_a, new_b; + + if ( c3y == u3qc_gor(p_n_a, p_n_b) ) { + u3_noun new_a = u3nt(u3k(n_a), u3k(l_a), u3_nul); + u3_noun new_lb = u3qdb_uni(new_a, l_b); + u3z(new_a); + + new_b = u3nt(u3k(n_b), new_lb, u3k(r_b)); + old_a = r_a; + } + else { + u3_noun new_a = u3nt(u3k(n_a), u3_nul, u3k(r_a)); + u3_noun new_rb = u3qdb_uni(new_a, r_b); + u3z(new_a); + + new_b = u3nt(u3k(n_b), u3k(l_b), new_rb); + old_a = l_a; + } + + { + u3_noun pro = u3qdb_uni(old_a, new_b); + u3z(new_b); + return pro; + } } } } From 6b5422a8d713df014acaed78fc2326b22e946f2d Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 8 May 2020 11:36:08 -0700 Subject: [PATCH 047/933] jets: most review comments addressed --- pkg/urbit/include/jets/q.h | 8 ++-- pkg/urbit/jets/c/po.c | 39 +++++++--------- pkg/urbit/jets/e/scow.c | 63 +++++++++++-------------- pkg/urbit/jets/e/slaw.c | 96 ++++++++++++++++++-------------------- 4 files changed, 95 insertions(+), 111 deletions(-) diff --git a/pkg/urbit/include/jets/q.h b/pkg/urbit/include/jets/q.h index cfaf41a785..58051dd481 100644 --- a/pkg/urbit/include/jets/q.h +++ b/pkg/urbit/include/jets/q.h @@ -70,10 +70,10 @@ u3_noun u3qc_swp(u3_atom, u3_atom); u3_noun u3qc_sqt(u3_atom); - u3_noun po_find_prefix(char one, char two, char three); - u3_noun po_find_suffix(char one, char two, char three); - void po_to_prefix(u3_noun id, c3_y* a, c3_y* b, c3_y* c); - void po_to_suffix(u3_noun id, c3_y* a, c3_y* b, c3_y* c); + u3_noun u3_po_find_prefix(c3_y one, c3_y two, c3_y three); + u3_noun u3_po_find_suffix(c3_y one, c3_y two, c3_y three); + void u3_po_to_prefix(u3_noun id, c3_y* a, c3_y* b, c3_y* c); + void u3_po_to_suffix(u3_noun id, c3_y* a, c3_y* b, c3_y* c); /** Tier 4. **/ diff --git a/pkg/urbit/jets/c/po.c b/pkg/urbit/jets/c/po.c index 95e359f87f..c907ad48a1 100644 --- a/pkg/urbit/jets/c/po.c +++ b/pkg/urbit/jets/c/po.c @@ -4,7 +4,7 @@ #include "all.h" u3_noun -po_find_prefix(char one, char two, char three) { +u3_po_find_prefix(c3_y one, c3_y two, c3_y three) { switch (one) { case 'b': switch (two) { case 'a': switch (three) { @@ -411,7 +411,7 @@ po_find_prefix(char one, char two, char three) { } void -po_to_prefix(u3_noun id, c3_y* a, c3_y* b, c3_y* c) +u3_po_to_prefix(u3_noun id, c3_y* a, c3_y* b, c3_y* c) { switch (id) { case 0: *a = 'd'; *b = 'o'; *c = 'z'; break; @@ -674,9 +674,8 @@ po_to_prefix(u3_noun id, c3_y* a, c3_y* b, c3_y* c) } } - u3_noun -po_find_suffix(char one, char two, char three) { +u3_po_find_suffix(c3_y one, c3_y two, c3_y three) { switch (one) { case 'b': switch (two) { case 'e': switch (three) { @@ -1083,7 +1082,7 @@ po_find_suffix(char one, char two, char three) { } void -po_to_suffix(u3_noun id, c3_y* a, c3_y* b, c3_y* c) +u3_po_to_suffix(u3_noun id, c3_y* a, c3_y* b, c3_y* c) { switch (id) { case 0: *a = 'z'; *b = 'o'; *c = 'd'; break; @@ -1352,21 +1351,20 @@ u3qc_po_ins(u3_noun a) c3_y byt_y[3]; u3r_bytes(0, 3, byt_y, a); - return po_find_prefix(byt_y[0], byt_y[1], byt_y[2]); + return u3_po_find_prefix(byt_y[0], byt_y[1], byt_y[2]); } u3_noun u3wcp_ins(u3_noun cor) { u3_noun a; + u3x_mean(cor, u3x_sam, &a, 0); - if ( (c3n == u3r_mean(cor, u3x_sam, &a, 0)) || - (c3n == u3ud(a)) ) - { - return u3m_bail(c3__exit); - } else { - return u3qc_po_ins(a); + if ( c3n == u3ud(a) ) { + return u3m_bail(c3__fail); } + + return u3qc_po_ins(a); } u3_noun @@ -1375,21 +1373,20 @@ u3qc_po_ind(u3_noun a) c3_y byt_y[3]; u3r_bytes(0, 3, byt_y, a); - return po_find_suffix(byt_y[0], byt_y[1], byt_y[2]); + return u3_po_find_suffix(byt_y[0], byt_y[1], byt_y[2]); } u3_noun u3wcp_ind(u3_noun cor) { u3_noun a; + u3x_mean(cor, u3x_sam, &a, 0); - if ( (c3n == u3r_mean(cor, u3x_sam, &a, 0)) || - (c3n == u3ud(a)) ) - { - return u3m_bail(c3__exit); - } else { - return u3qc_po_ind(a); + if ( c3n == u3ud(a) ) { + return u3m_bail(c3__fail); } + + return u3qc_po_ind(a); } u3_noun @@ -1405,7 +1402,7 @@ u3wcp_tos(u3_noun cor) } else { c3_y byt_y[3]; - po_to_prefix(a, &byt_y[0], &byt_y[1], &byt_y[2]); + u3_po_to_prefix(a, &byt_y[0], &byt_y[1], &byt_y[2]); return (byt_y[0] | (byt_y[1] << 8) | (byt_y[2] << 16)); } } @@ -1422,7 +1419,7 @@ u3wcp_tod(u3_noun cor) return u3m_bail(c3__exit); } else { c3_y byt_y[3]; - po_to_suffix(a, &byt_y[0], &byt_y[1], &byt_y[2]); + u3_po_to_suffix(a, &byt_y[0], &byt_y[1], &byt_y[2]); return (byt_y[0] | (byt_y[1] << 8) | (byt_y[2] << 16)); } } diff --git a/pkg/urbit/jets/e/scow.c b/pkg/urbit/jets/e/scow.c index f20d446120..05b4f39383 100644 --- a/pkg/urbit/jets/e/scow.c +++ b/pkg/urbit/jets/e/scow.c @@ -6,7 +6,7 @@ #include static -c3_y to_digit(u3_atom tig) +c3_y to_digit(c3_y tig) { if (tig >= 10) { return 87 + tig; @@ -16,7 +16,7 @@ c3_y to_digit(u3_atom tig) } static -c3_y to_w_digit(u3_atom tig) +c3_y to_w_digit(c3_y tig) { if (tig == 63) { return '~'; @@ -34,7 +34,7 @@ c3_y to_w_digit(u3_atom tig) // gives the characters for a four 'digit' small hex atom. static void -_x_co_four(u3_atom src, c3_y* a, c3_y* b, c3_y* c, c3_y* d) +_x_co_four(c3_w src, c3_y* a, c3_y* b, c3_y* c, c3_y* d) { *d = to_digit(src & 0xF); src >>= 4; @@ -48,7 +48,7 @@ _x_co_four(u3_atom src, c3_y* a, c3_y* b, c3_y* c, c3_y* d) // The parser always prints two digits on 0 in y-co. static void -_y_co_two(u3_atom src, c3_y* a, c3_y* b) +_y_co_two(c3_w src, c3_y* a, c3_y* b) { *b = to_digit(src % 10); *a = to_digit(src / 10); @@ -57,7 +57,7 @@ _y_co_two(u3_atom src, c3_y* a, c3_y* b) // static u3_noun -_add_year(u3_atom year, u3_noun out) +_add_year(c3_w year, u3_noun out) { while (year > 0) { out = u3nc(to_digit(year % 10), out); @@ -69,7 +69,7 @@ _add_year(u3_atom year, u3_noun out) static u3_noun -_print_da(u3_atom cor, u3_atom raw_da) +_print_da(u3_noun cor, u3_atom raw_da) { u3_noun hok = u3j_cook("u3we_scow_print_da", u3k(cor), "yore"); u3_noun yod = u3n_slam_on(hok, u3k(raw_da)); @@ -89,7 +89,7 @@ _print_da(u3_atom cor, u3_atom raw_da) return u3m_bail(c3__exit); } - if (c3n == u3r_sing(f, 0)) { + if (f != 0) { u3_noun f_list = u3qb_flop(f); for (u3_noun cur = f_list; @@ -113,10 +113,7 @@ _print_da(u3_atom cor, u3_atom raw_da) } // if there isn't a hex list and the h/m/s are all 0, skip printing hours. - if (c3n == u3r_sing(f, 0) || - c3n == u3r_sing(hour, 0) || - c3n == u3r_sing(min, 0) || - c3n == u3r_sing(sec, 0)) { + if (f != 0 || hour != 0 || min != 0 || sec != 0) { if (!_(u3a_is_cat(hour)) || !_(u3a_is_cat(min)) || !_(u3a_is_cat(sec))) { @@ -155,15 +152,17 @@ _print_da(u3_atom cor, u3_atom raw_da) c3_y da, db; _y_co_two(day, &da, &db); out = u3nc(db, out); - if (da != '0') + if (da != '0') { out = u3nc(da, out); + } out = u3nc('.', out); c3_y ma, mb; _y_co_two(month, &ma, &mb); out = u3nc(mb, out); - if (ma != '0') + if (ma != '0') { out = u3nc(ma, out); + } out = u3nc('.', out); // suffix the year with a '-' for BC dates @@ -191,27 +190,29 @@ _print_p(u3_atom cor, u3_atom p) u3_atom sxz = u3n_slam_on(hok, u3k(p)); // Simple galaxy case - if (c3y == u3qa_lte(u3k(sxz), 256)) { + if (c3y == u3qa_lte(sxz, 256)) { c3_y a, b, c; - po_to_suffix(sxz, &a, &b, &c); + u3_po_to_suffix(sxz, &a, &b, &c); u3z(sxz); return u3nq('~', a, b, u3nc(c, 0)); } - u3_atom dyy = u3qc_met(4, u3k(sxz)); + u3_atom dyy = u3qc_met(4, sxz); if (!_(u3a_is_cat(dyy))) { + u3z(sxz); + u3z(dyy); return u3_none; } u3_noun list = 0; for (c3_w imp = 0; imp != dyy; ++imp) { - u3_noun log = u3qc_end(4, 1, u3k(sxz)); - u3_noun prefix = u3qc_rsh(3, 1, u3k(log)); - u3_noun suffix = u3qc_end(3, 1, log); + c3_w log = u3qc_end(4, 1, sxz); + c3_w prefix = u3qc_rsh(3, 1, log); + c3_w suffix = u3qc_end(3, 1, log); c3_y a, b, c, d, e, f; - po_to_prefix(prefix, &a, &b, &c); - po_to_suffix(suffix, &d, &e, &f); + u3_po_to_prefix(prefix, &a, &b, &c); + u3_po_to_suffix(suffix, &d, &e, &f); if (imp % 4 == 0) { if (imp != 0) { @@ -235,11 +236,9 @@ u3_noun _print_ud(u3_atom ud) { // number of characters printed "between" periods. - int between = 0; + c3_i between = 0; u3_atom list = 0; - u3k(ud); - do { if (between == 3) { list = u3nc('.', list); @@ -259,7 +258,7 @@ u3_noun _print_uv(u3_atom uv) { // number of characters printed "between" periods. - int between = 0; + c3_i between = 0; u3_atom list = 0; u3k(uv); @@ -270,7 +269,7 @@ _print_uv(u3_atom uv) between = 0; } - u3_atom tig = u3qa_mod(uv, 32); + c3_y tig = u3qa_mod(uv, 32); list = u3nc(to_digit(tig), list); between++; uv = u3ka_div(uv, 32); @@ -284,7 +283,7 @@ u3_noun _print_uw(u3_atom uw) { // number of characters printed "between" periods. - int between = 0; + c3_i between = 0; u3_atom list = 0; u3k(uw); @@ -295,7 +294,7 @@ _print_uw(u3_atom uw) between = 0; } - u3_atom tig = u3qa_mod(uw, 64); + c3_y tig = u3qa_mod(uw, 64); list = u3nc(to_w_digit(tig), list); between++; uw = u3ka_div(uw, 64); @@ -315,10 +314,6 @@ u3we_scow(u3_noun cor) return u3m_bail(c3__exit); } - if (!_(u3a_is_cat(mod))) { - return u3_none; - } - switch (mod) { case c3__da: return _print_da(cor, atom); @@ -351,10 +346,6 @@ u3we_scot(u3_noun cor) return u3m_bail(c3__exit); } - if (!_(u3a_is_cat(mod))) { - return u3_none; - } - u3_noun tape; switch (mod) { case c3__da: diff --git a/pkg/urbit/jets/e/slaw.c b/pkg/urbit/jets/e/slaw.c index 0e8aa11075..b2e8133c45 100644 --- a/pkg/urbit/jets/e/slaw.c +++ b/pkg/urbit/jets/e/slaw.c @@ -17,7 +17,7 @@ _parse_ud(u3_noun txt) { u3a_free(c); return u3_none; } - c3_w total = cur[0] - '0'; + u3_atom total = cur[0] - '0'; cur++; int since_last_period = 0; @@ -121,7 +121,7 @@ _parse_p(u3_noun cor, u3_noun txt) { // check for validity since its already a (unit @). if (*cur == 0) { u3a_free(c); - return po_find_suffix(a_one, a_two, a_three); + return u3_po_find_suffix(a_one, a_two, a_three); } TRY_GET_SYLLABLE(b); @@ -129,8 +129,8 @@ _parse_p(u3_noun cor, u3_noun txt) { // There were only two syllables. If they are a valid prefix and suffix, then // it's a star. if (*cur == 0) { - u3_noun a_part = po_find_prefix(a_one, a_two, a_three); - u3_noun b_part = po_find_suffix(b_one, b_two, b_three); + u3_noun a_part = u3_po_find_prefix(a_one, a_two, a_three); + u3_noun b_part = u3_po_find_suffix(b_one, b_two, b_three); u3_atom combined = combine(b_part, a_part); u3a_free(c); return combined; @@ -146,10 +146,10 @@ _parse_p(u3_noun cor, u3_noun txt) { TRY_GET_SYLLABLE(d); if (*cur == 0) { - u3_noun a_part = po_find_prefix(a_one, a_two, a_three); - u3_noun b_part = po_find_suffix(b_one, b_two, b_three); - u3_noun c_part = po_find_prefix(c_one, c_two, c_three); - u3_noun d_part = po_find_suffix(d_one, d_two, d_three); + u3_noun a_part = u3_po_find_prefix(a_one, a_two, a_three); + u3_noun b_part = u3_po_find_suffix(b_one, b_two, b_three); + u3_noun c_part = u3_po_find_prefix(c_one, c_two, c_three); + u3_noun d_part = u3_po_find_suffix(d_one, d_two, d_three); u3_noun m = combine(d_part, combine(c_part, combine(b_part, a_part))); u3a_free(c); @@ -163,7 +163,7 @@ _parse_p(u3_noun cor, u3_noun txt) { u3_noun ob = u3j_cook("u3we_slaw_ob_p", u3k(cor), "ob"); u3_noun hok = u3j_cook("u3we_slaw_fynd_p", ob, "fynd"); - return u3nc(0, u3n_slam_on(hok, u3k(raw))); + return u3nc(0, u3n_slam_on(hok, raw)); } // There must now be a - or it is invalid. @@ -177,12 +177,12 @@ _parse_p(u3_noun cor, u3_noun txt) { TRY_GET_SYLLABLE(f); if (*cur == 0) { - u3_noun a_part = po_find_prefix(a_one, a_two, a_three); - u3_noun b_part = po_find_suffix(b_one, b_two, b_three); - u3_noun c_part = po_find_prefix(c_one, c_two, c_three); - u3_noun d_part = po_find_suffix(d_one, d_two, d_three); - u3_noun e_part = po_find_prefix(e_one, e_two, e_three); - u3_noun f_part = po_find_suffix(f_one, f_two, f_three); + u3_noun a_part = u3_po_find_prefix(a_one, a_two, a_three); + u3_noun b_part = u3_po_find_suffix(b_one, b_two, b_three); + u3_noun c_part = u3_po_find_prefix(c_one, c_two, c_three); + u3_noun d_part = u3_po_find_suffix(d_one, d_two, d_three); + u3_noun e_part = u3_po_find_prefix(e_one, e_two, e_three); + u3_noun f_part = u3_po_find_suffix(f_one, f_two, f_three); u3_noun m = combine(f_part, combine(e_part, combine(d_part, combine(c_part, combine(b_part, a_part))))); @@ -196,7 +196,7 @@ _parse_p(u3_noun cor, u3_noun txt) { u3z(m); u3_noun ob = u3j_cook("u3we_slaw_ob_p", u3k(cor), "ob"); u3_noun hok = u3j_cook("u3we_slaw_fynd_p", ob, "fynd"); - return u3nc(0, u3n_slam_on(hok, u3k(raw))); + return u3nc(0, u3n_slam_on(hok, raw)); } // There must now be a - or it is invalid. @@ -210,14 +210,14 @@ _parse_p(u3_noun cor, u3_noun txt) { TRY_GET_SYLLABLE(h); if (*cur == 0) { - u3_noun a_part = po_find_prefix(a_one, a_two, a_three); - u3_noun b_part = po_find_suffix(b_one, b_two, b_three); - u3_noun c_part = po_find_prefix(c_one, c_two, c_three); - u3_noun d_part = po_find_suffix(d_one, d_two, d_three); - u3_noun e_part = po_find_prefix(e_one, e_two, e_three); - u3_noun f_part = po_find_suffix(f_one, f_two, f_three); - u3_noun g_part = po_find_prefix(g_one, g_two, g_three); - u3_noun h_part = po_find_suffix(h_one, h_two, h_three); + u3_noun a_part = u3_po_find_prefix(a_one, a_two, a_three); + u3_noun b_part = u3_po_find_suffix(b_one, b_two, b_three); + u3_noun c_part = u3_po_find_prefix(c_one, c_two, c_three); + u3_noun d_part = u3_po_find_suffix(d_one, d_two, d_three); + u3_noun e_part = u3_po_find_prefix(e_one, e_two, e_three); + u3_noun f_part = u3_po_find_suffix(f_one, f_two, f_three); + u3_noun g_part = u3_po_find_prefix(g_one, g_two, g_three); + u3_noun h_part = u3_po_find_suffix(h_one, h_two, h_three); u3_noun m = combine(h_part, combine(g_part, combine(f_part, combine(e_part, combine(d_part, combine(c_part, @@ -232,7 +232,7 @@ _parse_p(u3_noun cor, u3_noun txt) { u3z(m); u3_noun ob = u3j_cook("u3we_slaw_ob_p", u3k(cor), "ob"); u3_noun hok = u3j_cook("u3we_slaw_fynd_p", ob, "fynd"); - return u3nc(0, u3n_slam_on(hok, u3k(raw))); + return u3nc(0, u3n_slam_on(hok, raw)); } // At this point, the only thing it could be is a long comet, of the form @@ -266,22 +266,22 @@ _parse_p(u3_noun cor, u3_noun txt) { // We have a long comet. Time to jam it all together. We rely on combine() // for the error checking and we don't have to scramble comet names. - u3_noun a_part = po_find_prefix(a_one, a_two, a_three); - u3_noun b_part = po_find_suffix(b_one, b_two, b_three); - u3_noun c_part = po_find_prefix(c_one, c_two, c_three); - u3_noun d_part = po_find_suffix(d_one, d_two, d_three); - u3_noun e_part = po_find_prefix(e_one, e_two, e_three); - u3_noun f_part = po_find_suffix(f_one, f_two, f_three); - u3_noun g_part = po_find_prefix(g_one, g_two, g_three); - u3_noun h_part = po_find_suffix(h_one, h_two, h_three); - u3_noun i_part = po_find_prefix(i_one, i_two, i_three); - u3_noun j_part = po_find_suffix(j_one, j_two, j_three); - u3_noun k_part = po_find_prefix(k_one, k_two, k_three); - u3_noun l_part = po_find_suffix(l_one, l_two, l_three); - u3_noun m_part = po_find_prefix(m_one, m_two, m_three); - u3_noun n_part = po_find_suffix(n_one, n_two, n_three); - u3_noun o_part = po_find_prefix(o_one, o_two, o_three); - u3_noun p_part = po_find_suffix(p_one, p_two, p_three); + u3_noun a_part = u3_po_find_prefix(a_one, a_two, a_three); + u3_noun b_part = u3_po_find_suffix(b_one, b_two, b_three); + u3_noun c_part = u3_po_find_prefix(c_one, c_two, c_three); + u3_noun d_part = u3_po_find_suffix(d_one, d_two, d_three); + u3_noun e_part = u3_po_find_prefix(e_one, e_two, e_three); + u3_noun f_part = u3_po_find_suffix(f_one, f_two, f_three); + u3_noun g_part = u3_po_find_prefix(g_one, g_two, g_three); + u3_noun h_part = u3_po_find_suffix(h_one, h_two, h_three); + u3_noun i_part = u3_po_find_prefix(i_one, i_two, i_three); + u3_noun j_part = u3_po_find_suffix(j_one, j_two, j_three); + u3_noun k_part = u3_po_find_prefix(k_one, k_two, k_three); + u3_noun l_part = u3_po_find_suffix(l_one, l_two, l_three); + u3_noun m_part = u3_po_find_prefix(m_one, m_two, m_three); + u3_noun n_part = u3_po_find_suffix(n_one, n_two, n_three); + u3_noun o_part = u3_po_find_prefix(o_one, o_two, o_three); + u3_noun p_part = u3_po_find_suffix(p_one, p_two, p_three); u3a_free(c); @@ -358,7 +358,7 @@ _parse_da(u3_noun cor, u3_noun txt) { CONSUME('.'); // Parse out a two digit month (mot:ag). Either a single digit 1-9 or 1[012]. - c3_w month; + c3_y month; if (cur[0] == '1') { if (cur[1] <= '2' && cur[1] >= '0') { // This is a two number month. @@ -414,18 +414,18 @@ _parse_da(u3_noun cor, u3_noun txt) { CONSUME('.'); // Now we have to parse a list of hexidecimal numbers 0-f of length 4 only - // (zero padded otherwise) separated by dots. Wat. + // (zero padded otherwise) separated by dots. u3_atom list = 0; while (1) { // Parse 4 hex digits - int one, two, three, four; + c3_y one, two, three, four; PARSE_HEX_DIGIT(one); PARSE_HEX_DIGIT(two); PARSE_HEX_DIGIT(three); PARSE_HEX_DIGIT(four); - int current = (one << 12) + (two << 8) + (three << 4) + four; - list = u3nc(current, list); + c3_w current = (one << 12) + (two << 8) + (three << 4) + four; + list = u3nc(u3i_words(1, ¤t), list); if (cur[0] == 0) { u3a_free(c); @@ -489,10 +489,6 @@ u3we_slaw(u3_noun cor) return u3m_bail(c3__exit); } - if (!_(u3a_is_cat(mod))) { - return u3_none; - } - switch (mod) { case c3__da: return _parse_da(cor, txt); From 78d32f1129ac6d96d6b204d5df33357dd74180fb Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 8 May 2020 12:33:08 -0700 Subject: [PATCH 048/933] jet: final cleanup --- pkg/urbit/jets/e/scow.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/pkg/urbit/jets/e/scow.c b/pkg/urbit/jets/e/scow.c index 05b4f39383..38278105ec 100644 --- a/pkg/urbit/jets/e/scow.c +++ b/pkg/urbit/jets/e/scow.c @@ -237,7 +237,11 @@ _print_ud(u3_atom ud) { // number of characters printed "between" periods. c3_i between = 0; - u3_atom list = 0; + u3_noun list = 0; + + // increase input refcount to be consumed in u3ka_div(), which will free each + // intermediary state. + u3k(ud); do { if (between == 3) { @@ -259,8 +263,10 @@ _print_uv(u3_atom uv) { // number of characters printed "between" periods. c3_i between = 0; - u3_atom list = 0; + u3_noun list = 0; + // increase input refcount to be consumed in u3ka_div(), which will free each + // intermediary state. u3k(uv); do { @@ -284,8 +290,10 @@ _print_uw(u3_atom uw) { // number of characters printed "between" periods. c3_i between = 0; - u3_atom list = 0; + u3_noun list = 0; + // increase input refcount to be consumed in u3ka_div(), which will free each + // intermediary state. u3k(uw); do { @@ -306,8 +314,8 @@ _print_uw(u3_atom uw) u3_noun u3we_scow(u3_noun cor) { - u3_noun mod; - u3_noun atom; + u3_atom mod; + u3_atom atom; if (c3n == u3r_mean(cor, u3x_sam_2, &mod, u3x_sam_3, &atom, 0)) { @@ -338,8 +346,8 @@ u3we_scow(u3_noun cor) u3_noun u3we_scot(u3_noun cor) { - u3_noun mod; - u3_noun atom; + u3_atom mod; + u3_atom atom; if (c3n == u3r_mean(cor, u3x_sam_2, &mod, u3x_sam_3, &atom, 0)) { From 7149e591ef39df68ce1ef434d254c2a48d026f03 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 7 May 2020 14:52:47 -0700 Subject: [PATCH 049/933] jets: +run:by --- pkg/arvo/sys/hoon.hoon | 1 + pkg/urbit/include/jets/w.h | 1 + pkg/urbit/jets/d/by_run.c | 38 ++++++++++++++++++++++++++++++++++++++ pkg/urbit/jets/tree.c | 4 ++++ 4 files changed, 44 insertions(+) create mode 100644 pkg/urbit/jets/d/by_run.c diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 43dc11b615..b259b1ed04 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -1619,6 +1619,7 @@ [-.f a(l +.e, r +.f)] :: ++ run :: apply gate to values + ~/ %run |* b/gate |- ?~ a a diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index 98d8e07db3..c63026a192 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -89,6 +89,7 @@ u3_noun u3wdb_put(u3_noun); # define u3wdb_tap u3wdi_tap u3_noun u3wdb_uni(u3_noun); + u3_noun u3wdb_run(u3_noun); u3_noun u3wdi_bif(u3_noun); u3_noun u3wdi_del(u3_noun); diff --git a/pkg/urbit/jets/d/by_run.c b/pkg/urbit/jets/d/by_run.c new file mode 100644 index 0000000000..6fd2d2cf87 --- /dev/null +++ b/pkg/urbit/jets/d/by_run.c @@ -0,0 +1,38 @@ +/* j/4/by_run.c +** +*/ +#include "all.h" + +/* internal functions + */ +static u3_noun +_by_run(u3_noun a, u3j_site* sit_u) +{ + if (u3_nul == a) { + return 0; + } else { + u3_noun n_a, l_a, r_a; + u3_noun p_n_a, q_n_a; + u3x_trel(a, &n_a, &l_a, &r_a); + u3x_cell(n_a, &p_n_a, &q_n_a); + + u3_noun nu_q_n_a = u3j_gate_slam(sit_u, u3k(q_n_a)); + u3_noun nu_l = _by_run(l_a, sit_u); + u3_noun nu_r = _by_run(r_a, sit_u); + return u3nt(u3nc(u3k(p_n_a), nu_q_n_a), nu_l, nu_r); + } +} + +u3_noun +u3wdb_run(u3_noun cor) +{ + u3_noun a, b; + u3j_site sit_u; + + u3x_mean(cor, u3x_sam, &b, u3x_con_sam, &a, 0); + + u3j_gate_prep(&sit_u, u3k(b)); + u3_noun pro = _by_run(a, &sit_u); + u3j_gate_lose(&sit_u); + return pro; +} diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 43c266a960..283fae8191 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -1635,6 +1635,9 @@ static c3_c* _141_two__in_ha[] = { "2cc9f005fde5314e9ad545286493a8c81b5c3b775d645ad82954f405d9414a32", 0 }; + + static u3j_harm _141_two__by_run_a[] = {{".2", u3wdb_run, c3y}, {}}; + static u3j_harm _141_two__by_tap_a[] = {{".2", u3wdb_tap, c3y}, {}}; static c3_c* _141_two__by_tap_ha[] = { "7dde59e2bd7684e785ce9787bc394571bd1216d7a62398c703447fc951c6b352", @@ -1655,6 +1658,7 @@ static u3j_core _141_two__by_d[] = // { "int", 7, _141_two__by_int_a, 0, _141_two__by_int_ha }, { "jab", 7, _141_two__by_jab_a, 0, _141_two__by_jab_ha }, { "put", 7, _141_two__by_put_a, 0, _141_two__by_put_ha }, + { "run", 7, _141_two__by_run_a }, { "tap", 7, _141_two__by_tap_a, 0, _141_two__by_tap_ha }, // { "uni", 7, _141_two__by_uni_a, 0, _141_two__by_uni_ha }, {} From 3f293cae477ac9317ac26977f578ee2b3962f50a Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 7 May 2020 17:12:22 -0700 Subject: [PATCH 050/933] jets: +key:by and +wyt:by --- pkg/arvo/sys/hoon.hoon | 9 +++++++-- pkg/urbit/include/jets/w.h | 2 ++ pkg/urbit/jets/d/by_key.c | 35 +++++++++++++++++++++++++++++++++++ pkg/urbit/jets/tree.c | 6 +++++- 4 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 pkg/urbit/jets/d/by_key.c diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index b259b1ed04..b3a390d2a5 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -1603,6 +1603,7 @@ d(l a(r l.d)) :: ++ rep :: reduce to product + ~/ %rep |* b/_=>(~ |=({* *} +<+)) |- ?~ a +<+.b @@ -1692,12 +1693,16 @@ a(n n.a(q (b p.n.a q.n.a)), l $(a l.a), r $(a r.a)) :: ++ wyt :: depth of map - |- ^- @ + =< $ + ~% %wyt + ~ + |. ^- @ ?~(a 0 +((add $(a l.a) $(a r.a)))) :: ++ key :: set of keys + =< $ + ~/ %key =+ b=`(set _?>(?=(^ a) p.n.a))`~ - |- ^+ b + |. ^+ b ?~ a b $(a r.a, b $(a l.a, b (~(put in b) p.n.a))) :: diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index c63026a192..5b202c8fdb 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -86,10 +86,12 @@ u3_noun u3wdb_has(u3_noun); u3_noun u3wdb_int(u3_noun); u3_noun u3wdb_jab(u3_noun); + u3_noun u3wdb_key(u3_noun); u3_noun u3wdb_put(u3_noun); # define u3wdb_tap u3wdi_tap u3_noun u3wdb_uni(u3_noun); u3_noun u3wdb_run(u3_noun); +# define u3wdb_wyt u3wdi_wyt u3_noun u3wdi_bif(u3_noun); u3_noun u3wdi_del(u3_noun); diff --git a/pkg/urbit/jets/d/by_key.c b/pkg/urbit/jets/d/by_key.c new file mode 100644 index 0000000000..62a8d510d1 --- /dev/null +++ b/pkg/urbit/jets/d/by_key.c @@ -0,0 +1,35 @@ +/* j/4/by_run.c +** +*/ +#include "all.h" + +/* internal functions + */ +static u3_noun +_by_key(u3_noun a, u3_noun set) +{ + if (u3_nul == a) { + return u3k(set); + } else { + u3_noun n_a, l_a, r_a; + u3_noun p_n_a, q_n_a; + u3x_trel(a, &n_a, &l_a, &r_a); + u3x_cell(n_a, &p_n_a, &q_n_a); + + u3_noun with_set = u3qdi_put(set, p_n_a); + u3_noun left_set = _by_key(l_a, with_set); + u3z(with_set); + u3_noun right_set = _by_key(r_a, left_set); + u3z(left_set); + + return right_set; + } +} + +u3_noun +u3wdb_key(u3_noun cor) +{ + u3_noun a; + u3x_mean(cor, u3x_con_sam, &a, 0); + return _by_key(a, 0); +} diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 283fae8191..4150cc1c2f 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -1636,7 +1636,9 @@ static c3_c* _141_two__in_ha[] = { 0 }; - static u3j_harm _141_two__by_run_a[] = {{".2", u3wdb_run, c3y}, {}}; + static u3j_harm _141_two__by_key_a[] = {{".2", u3wdb_key}, {}}; + static u3j_harm _141_two__by_run_a[] = {{".2", u3wdb_run}, {}}; + static u3j_harm _141_two__by_wyt_a[] = {{".2", u3wdb_wyt}, {}}; static u3j_harm _141_two__by_tap_a[] = {{".2", u3wdb_tap, c3y}, {}}; static c3_c* _141_two__by_tap_ha[] = { @@ -1657,9 +1659,11 @@ static u3j_core _141_two__by_d[] = { "has", 7, _141_two__by_has_a, 0, _141_two__by_has_ha }, // { "int", 7, _141_two__by_int_a, 0, _141_two__by_int_ha }, { "jab", 7, _141_two__by_jab_a, 0, _141_two__by_jab_ha }, + { "key", 7, _141_two__by_key_a }, { "put", 7, _141_two__by_put_a, 0, _141_two__by_put_ha }, { "run", 7, _141_two__by_run_a }, { "tap", 7, _141_two__by_tap_a, 0, _141_two__by_tap_ha }, + { "wyt", 3, _141_two__by_wyt_a }, // { "uni", 7, _141_two__by_uni_a, 0, _141_two__by_uni_ha }, {} }; From 8791af0333acad377105fcc2d5f95bca04470e27 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 8 May 2020 14:48:27 -0700 Subject: [PATCH 051/933] jets: jet +apt:by As a lark, I put in a debugging printf on this function. It spammed the console. It's a highly recursive function so jet it. --- bin/solid.pill | 4 +- pkg/arvo/sys/hoon.hoon | 4 +- pkg/urbit/include/jets/w.h | 1 + pkg/urbit/jets/d/by_apt.c | 88 ++++++++++++++++++++++++++++++++++++++ pkg/urbit/jets/tree.c | 10 +++-- 5 files changed, 100 insertions(+), 7 deletions(-) create mode 100644 pkg/urbit/jets/d/by_apt.c diff --git a/bin/solid.pill b/bin/solid.pill index f815003a43..0632a79e2b 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ae57c51569ed4a705d80938aa0926b338e4d4a721f15af02105f3f6823c6ee3c -size 12862970 +oid sha256:489c0816c1e218d69e48125ec947c77be37b5be78a0e1a10dabf17684f9773e9 +size 12863802 diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index b3a390d2a5..2ebbfc5e73 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -1490,8 +1490,10 @@ $(a r.a, c (peg c 7)) :: ++ apt :: check correctness + =< $ + ~/ %apt =| {l/(unit) r/(unit)} - |- ^- ? + |. ^- ? ?~ a & ?& ?~(l & &((gor p.n.a u.l) !=(p.n.a u.l))) ?~(r & &((gor u.r p.n.a) !=(u.r p.n.a))) diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index 5b202c8fdb..92b149167e 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -78,6 +78,7 @@ /** Tier 4. **/ + u3_noun u3wdb_apt(u3_noun); u3_noun u3wdb_bif(u3_noun); u3_noun u3wdb_del(u3_noun); u3_noun u3wdb_dif(u3_noun); diff --git a/pkg/urbit/jets/d/by_apt.c b/pkg/urbit/jets/d/by_apt.c new file mode 100644 index 0000000000..a2350cccda --- /dev/null +++ b/pkg/urbit/jets/d/by_apt.c @@ -0,0 +1,88 @@ +/* j/4/by_apt.c +** +*/ +#include "all.h" + +static +c3_y _by_apt(u3_noun a, u3_noun l, u3_noun r) +{ + if (a == 0) { + return c3y; + } + + u3_noun n_a, l_a, r_a; + u3_noun p_n_a, q_n_a; + u3x_trel(a, &n_a, &l_a, &r_a); + u3x_cell(n_a, &p_n_a, &q_n_a); + + u3_noun u_l; + if (c3y == u3r_cell(l, 0, &u_l)) { + if (!_(u3qc_gor(p_n_a, u_l))) { + return c3n; + } + if (c3y == u3r_sing(p_n_a, u_l)) { + return c3n; + } + } + + u3_noun u_r; + if (c3y == u3r_cell(r, 0, &u_r)) { + if (!_(u3qc_gor(u_r, p_n_a))) { + return c3n; + } + if (c3y == u3r_sing(u_r, p_n_a)) { + return c3n; + } + } + + u3_noun n_l_a, l_l_a, r_l_a; + if (c3y == u3r_trel(l_a, &n_l_a, &l_l_a, &r_l_a)) { + u3_noun p_n_l_a; + u3x_cell(n_l_a, &p_n_l_a, 0); + + if (!_(u3qc_mor(p_n_a, p_n_l_a))) { + return c3n; + } + if (c3y == u3r_sing(p_n_a, p_n_l_a)) { + return c3n; + } + u3_noun nu_l = u3nc(0, p_n_a); + if (!_(_by_apt(l_a, nu_l, 0))) { + u3z(nu_l); + return c3n; + } + u3z(nu_l); + } + + u3_noun n_r_a, l_r_a, r_r_a; + if (c3y == u3r_trel(r_a, &n_r_a, &l_r_a, &r_r_a)) { + u3_noun p_n_r_a; + u3x_cell(n_r_a, &p_n_r_a, 0); + + if (!_(u3qc_mor(p_n_a, p_n_r_a))) { + return c3n; + } + if (c3y == u3r_sing(p_n_a, p_n_r_a)) { + return c3n; + } + u3_noun nu_r = u3nc(0, p_n_a); + if (!_(_by_apt(r_a, 0, nu_r))) { + u3z(nu_r); + return c3n; + } + u3z(nu_r); + } + + return c3y; +} + + +u3_noun +u3wdb_apt(u3_noun cor) +{ + u3_noun a; + u3x_mean(cor, u3x_con_sam, &a, 0); + + c3_y pro = _by_apt(a, 0, 0); + return pro; +} diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 4150cc1c2f..11edc9b1cd 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -1636,9 +1636,10 @@ static c3_c* _141_two__in_ha[] = { 0 }; - static u3j_harm _141_two__by_key_a[] = {{".2", u3wdb_key}, {}}; - static u3j_harm _141_two__by_run_a[] = {{".2", u3wdb_run}, {}}; - static u3j_harm _141_two__by_wyt_a[] = {{".2", u3wdb_wyt}, {}}; + static u3j_harm _141_two__by_apt_a[] = {{".2", u3wdb_apt, c3y}, {}}; + static u3j_harm _141_two__by_key_a[] = {{".2", u3wdb_key, c3y}, {}}; + static u3j_harm _141_two__by_run_a[] = {{".2", u3wdb_run, c3y}, {}}; + static u3j_harm _141_two__by_wyt_a[] = {{".2", u3wdb_wyt, c3y}, {}}; static u3j_harm _141_two__by_tap_a[] = {{".2", u3wdb_tap, c3y}, {}}; static c3_c* _141_two__by_tap_ha[] = { @@ -1651,7 +1652,8 @@ static c3_c* _141_two__in_ha[] = { // static c3_c* _141_two__by_uni_ha[] = {0}; static u3j_core _141_two__by_d[] = - { { "bif", 7, _141_two__by_bif_a, 0, _141_two__by_bif_ha }, + { { "apt", 7, _141_two__by_apt_a }, + { "bif", 7, _141_two__by_bif_a, 0, _141_two__by_bif_ha }, { "del", 7, _141_two__by_del_a, 0, _141_two__by_del_ha }, { "dif", 7, _141_two__by_dif_a, 0, _141_two__by_dif_ha }, { "gas", 7, _141_two__by_gas_a, 0, _141_two__by_gas_ha }, From 418feb9332dd0f56134f195e1c4e77f4ef133ee5 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 8 May 2020 15:24:38 -0700 Subject: [PATCH 052/933] jets: reenable +uni:by This passes booting and runing +test in -g mode. --- pkg/urbit/jets/d/by_uni.c | 7 +------ pkg/urbit/jets/tree.c | 6 +++--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/pkg/urbit/jets/d/by_uni.c b/pkg/urbit/jets/d/by_uni.c index 574558a045..b5135a2bc5 100644 --- a/pkg/urbit/jets/d/by_uni.c +++ b/pkg/urbit/jets/d/by_uni.c @@ -1,8 +1,5 @@ /* j/4/by_uni.c -** XXX THIS IS DISABLED -** specifically, s/hor/gor/g (already done?) -** and eliminate memory leaks -*/ + */ #include "all.h" /* functions @@ -87,8 +84,6 @@ u3qdb_uni(u3_noun a, } } -// XX disabled in tree.c, reference counts presumed wrong -// u3_noun u3wdb_uni(u3_noun cor) { diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 11edc9b1cd..249d5679f3 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -1648,8 +1648,8 @@ static c3_c* _141_two__in_ha[] = { }; // https://github.com/urbit/urbit/issues/328 - // static u3j_harm _141_two__by_uni_a[] = {{".2", u3wdb_uni, c3y}, {}}; - // static c3_c* _141_two__by_uni_ha[] = {0}; + static u3j_harm _141_two__by_uni_a[] = {{".2", u3wdb_uni, c3y}, {}}; + static c3_c* _141_two__by_uni_ha[] = {0}; static u3j_core _141_two__by_d[] = { { "apt", 7, _141_two__by_apt_a }, @@ -1666,7 +1666,7 @@ static u3j_core _141_two__by_d[] = { "run", 7, _141_two__by_run_a }, { "tap", 7, _141_two__by_tap_a, 0, _141_two__by_tap_ha }, { "wyt", 3, _141_two__by_wyt_a }, - // { "uni", 7, _141_two__by_uni_a, 0, _141_two__by_uni_ha }, + { "uni", 7, _141_two__by_uni_a, 0, _141_two__by_uni_ha }, {} }; static c3_c* _141_two__by_ha[] = { From f881810c4b32ebdccb759342d6760b6889fc97fe Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 11 May 2020 15:00:12 -0700 Subject: [PATCH 053/933] jets: final cleanup --- pkg/urbit/jets/e/slaw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/urbit/jets/e/slaw.c b/pkg/urbit/jets/e/slaw.c index b2e8133c45..2933afb966 100644 --- a/pkg/urbit/jets/e/slaw.c +++ b/pkg/urbit/jets/e/slaw.c @@ -415,7 +415,7 @@ _parse_da(u3_noun cor, u3_noun txt) { // Now we have to parse a list of hexidecimal numbers 0-f of length 4 only // (zero padded otherwise) separated by dots. - u3_atom list = 0; + u3_noun list = 0; while (1) { // Parse 4 hex digits c3_y one, two, three, four; From 30e1e9cddd7adb4d8c04dbc169ecdfb5c5e79a2f Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 11 May 2020 15:35:00 -0700 Subject: [PATCH 054/933] jets: +run:in --- pkg/urbit/include/jets/w.h | 1 + pkg/urbit/jets/d/in_run.c | 42 ++++++++++++++++++++++++++++++++++++++ pkg/urbit/jets/tree.c | 4 ++++ 3 files changed, 47 insertions(+) create mode 100644 pkg/urbit/jets/d/in_run.c diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index 92b149167e..2035053817 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -101,6 +101,7 @@ u3_noun u3wdi_has(u3_noun); u3_noun u3wdi_int(u3_noun); u3_noun u3wdi_put(u3_noun); + u3_noun u3wdi_run(u3_noun); u3_noun u3wdi_tap(u3_noun); u3_noun u3wdi_uni(u3_noun); u3_noun u3wdi_wyt(u3_noun); diff --git a/pkg/urbit/jets/d/in_run.c b/pkg/urbit/jets/d/in_run.c new file mode 100644 index 0000000000..1bfeb1b598 --- /dev/null +++ b/pkg/urbit/jets/d/in_run.c @@ -0,0 +1,42 @@ +/* j/4/in_run.c +** +*/ +#include "all.h" + +/* internal functions + */ +static +void +_in_run(u3_noun a, u3j_site* sit_u, u3_noun* out) +{ + if (u3_nul == a) { + return; + } else { + u3_noun n_a, l_a, r_a; + u3x_trel(a, &n_a, &l_a, &r_a); + + u3_noun nu_n_a = u3j_gate_slam(sit_u, u3k(n_a)); + + u3_noun nuout = u3qdi_put(*out, nu_n_a); + u3z(*out); + *out = nuout; + + _in_run(l_a, sit_u, out); + _in_run(r_a, sit_u, out); + } +} + +u3_noun +u3wdi_run(u3_noun cor) +{ + u3_noun a, b; + u3j_site sit_u; + + u3x_mean(cor, u3x_sam, &b, u3x_con_sam, &a, 0); + + u3j_gate_prep(&sit_u, u3k(b)); + u3_noun out = 0; + _in_run(a, &sit_u, &out); + u3j_gate_lose(&sit_u); + return out; +} diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 249d5679f3..866bc07dee 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -1572,6 +1572,9 @@ static c3_c* _141_two_xeb_ha[] = { "8369d11970bfa09bd20c5b112a353fa10e8e64c9c081e3a5b17bcf3700127add", 0 }; + + static u3j_harm _141_two__in_run_a[] = {{".2", u3wdi_run}, {}}; + static u3j_core _141_two__in_d[] = { { "bif", 7, _141_two__in_bif_a, 0, _141_two__in_bif_ha }, { "del", 7, _141_two__in_del_a, 0, _141_two__in_del_ha }, @@ -1580,6 +1583,7 @@ static u3j_core _141_two__in_d[] = { "has", 7, _141_two__in_has_a, 0, _141_two__in_has_ha }, // { "int", 7, _141_two__in_int_a, 0, _141_two__in_int_ha }, { "put", 7, _141_two__in_put_a, 0, _141_two__in_put_ha }, + { "run", 7, _141_two__in_run_a }, { "tap", 7, _141_two__in_tap_a, 0, _141_two__in_tap_ha }, { "wyt", 3, _141_two__in_wyt_a, 0, _141_two__in_wyt_ha }, { "uni", 7, _141_two__in_uni_a, 0, _141_two__in_uni_ha }, From 94c66ec433058f247c5eb20372fca72575695830 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 11 May 2020 16:31:46 -0700 Subject: [PATCH 055/933] jets: +apt:in --- bin/solid.pill | 4 +-- pkg/arvo/sys/hoon.hoon | 5 ++- pkg/urbit/include/jets/w.h | 1 + pkg/urbit/jets/d/in_apt.c | 66 ++++++++++++++++++++++++++++++++++++++ pkg/urbit/jets/tree.c | 4 ++- 5 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 pkg/urbit/jets/d/in_apt.c diff --git a/bin/solid.pill b/bin/solid.pill index 0632a79e2b..c15b1893e4 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:489c0816c1e218d69e48125ec947c77be37b5be78a0e1a10dabf17684f9773e9 -size 12863802 +oid sha256:e6ad17b4eff89b443bf300f1bdd6fcba9301d86ce23bfca77987247146549f88 +size 12863875 diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 2ebbfc5e73..1fbf99dc0b 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -1196,8 +1196,10 @@ ?|((b n.a) $(a l.a) $(a r.a)) :: ++ apt :: check correctness + =< $ + ~/ %apt =| {l/(unit) r/(unit)} - |- ^- ? + |. ^- ? ?~ a & ?& ?~(l & (gor n.a u.l)) ?~(r & (gor u.r n.a)) @@ -1346,6 +1348,7 @@ c(l a(r l.c)) :: ++ rep :: reduce to product + ~/ %rep |* b/_=>(~ |=({* *} +<+)) |- ?~ a +<+.b diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index 2035053817..a0c7aa030c 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -94,6 +94,7 @@ u3_noun u3wdb_run(u3_noun); # define u3wdb_wyt u3wdi_wyt + u3_noun u3wdi_apt(u3_noun); u3_noun u3wdi_bif(u3_noun); u3_noun u3wdi_del(u3_noun); u3_noun u3wdi_dif(u3_noun); diff --git a/pkg/urbit/jets/d/in_apt.c b/pkg/urbit/jets/d/in_apt.c new file mode 100644 index 0000000000..b252680429 --- /dev/null +++ b/pkg/urbit/jets/d/in_apt.c @@ -0,0 +1,66 @@ +/* j/4/in_apt.c +** +*/ +#include "all.h" + +static +c3_y _in_apt(u3_noun a, u3_noun l, u3_noun r) +{ + if (a == 0) { + return c3y; + } + + u3_noun n_a, l_a, r_a; + u3x_trel(a, &n_a, &l_a, &r_a); + + u3_noun u_l; + if (c3y == u3r_cell(l, 0, &u_l)) { + if (!_(u3qc_gor(n_a, u_l))) { + return c3n; + } + } + + u3_noun u_r; + if (c3y == u3r_cell(r, 0, &u_r)) { + if (!_(u3qc_gor(u_r, n_a))) { + return c3n; + } + } + + u3_noun n_l_a, l_l_a, r_l_a; + if (c3y == u3r_trel(l_a, &n_l_a, &l_l_a, &r_l_a)) { + if (!_(u3qc_mor(n_a, n_l_a))) { + return c3n; + } + u3_noun nu_l = u3nc(0, n_a); + if (!_(_in_apt(l_a, nu_l, 0))) { + u3z(nu_l); + return c3n; + } + u3z(nu_l); + } + + u3_noun n_r_a, l_r_a, r_r_a; + if (c3y == u3r_trel(r_a, &n_r_a, &l_r_a, &r_r_a)) { + if (!_(u3qc_mor(n_a, n_r_a))) { + return c3n; + } + u3_noun nu_r = u3nc(0, n_a); + if (!_(_in_apt(r_a, 0, nu_r))) { + u3z(nu_r); + return c3n; + } + u3z(nu_r); + } + + return c3y; +} + +u3_noun +u3wdi_apt(u3_noun cor) +{ + u3_noun a; + u3x_mean(cor, u3x_con_sam, &a, 0); + c3_y pro = _in_apt(a, 0, 0); + return pro; +} diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 866bc07dee..c47073f179 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -1573,10 +1573,12 @@ static c3_c* _141_two_xeb_ha[] = { 0 }; + static u3j_harm _141_two__in_apt_a[] = {{".2", u3wdi_apt}, {}}; static u3j_harm _141_two__in_run_a[] = {{".2", u3wdi_run}, {}}; static u3j_core _141_two__in_d[] = - { { "bif", 7, _141_two__in_bif_a, 0, _141_two__in_bif_ha }, + { { "apt", 7, _141_two__in_apt_a }, + { "bif", 7, _141_two__in_bif_a, 0, _141_two__in_bif_ha }, { "del", 7, _141_two__in_del_a, 0, _141_two__in_del_ha }, { "dif", 7, _141_two__in_dif_a, 0, _141_two__in_dif_ha }, { "gas", 7, _141_two__in_gas_a, 0, _141_two__in_gas_ha }, From 1f7caacd15b24af7fc70ab672d4c65eb09c746cd Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 12 May 2020 10:40:33 -0700 Subject: [PATCH 056/933] jet: +rep:in --- pkg/urbit/include/jets/w.h | 1 + pkg/urbit/jets/d/in_rep.c | 41 ++++++++++++++++++++++++++++++++++++++ pkg/urbit/jets/tree.c | 2 ++ 3 files changed, 44 insertions(+) create mode 100644 pkg/urbit/jets/d/in_rep.c diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index a0c7aa030c..a3271dc2f8 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -102,6 +102,7 @@ u3_noun u3wdi_has(u3_noun); u3_noun u3wdi_int(u3_noun); u3_noun u3wdi_put(u3_noun); + u3_noun u3wdi_rep(u3_noun); u3_noun u3wdi_run(u3_noun); u3_noun u3wdi_tap(u3_noun); u3_noun u3wdi_uni(u3_noun); diff --git a/pkg/urbit/jets/d/in_rep.c b/pkg/urbit/jets/d/in_rep.c new file mode 100644 index 0000000000..a7d7376c84 --- /dev/null +++ b/pkg/urbit/jets/d/in_rep.c @@ -0,0 +1,41 @@ +/* j/4/in_rep.c +** +*/ +#include "all.h" + +/* internal functions + */ +static +void +_in_rep(u3_noun a, u3j_site* sit_u, u3_noun* out) +{ + if (u3_nul == a) { + return; + } else { + u3_noun n_a, l_a, r_a; + u3x_trel(a, &n_a, &l_a, &r_a); + + // consumes out refcount + *out = u3j_gate_slam(sit_u, u3nc(u3k(n_a), *out)); + + _in_rep(l_a, sit_u, out); + _in_rep(r_a, sit_u, out); + } +} + +u3_noun +u3wdi_rep(u3_noun cor) +{ + u3_noun a, b; + u3j_site sit_u; + + u3x_mean(cor, u3x_sam, &b, u3x_con_sam, &a, 0); + + u3j_gate_prep(&sit_u, u3k(b)); + + u3_noun out = u3k(u3x_at(u3x_sam_3, b)); + _in_rep(a, &sit_u, &out); + + u3j_gate_lose(&sit_u); + return out; +} diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index c47073f179..124a39d30c 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -1574,6 +1574,7 @@ static c3_c* _141_two_xeb_ha[] = { }; static u3j_harm _141_two__in_apt_a[] = {{".2", u3wdi_apt}, {}}; + static u3j_harm _141_two__in_rep_a[] = {{".2", u3wdi_rep}, {}}; static u3j_harm _141_two__in_run_a[] = {{".2", u3wdi_run}, {}}; static u3j_core _141_two__in_d[] = @@ -1585,6 +1586,7 @@ static u3j_core _141_two__in_d[] = { "has", 7, _141_two__in_has_a, 0, _141_two__in_has_ha }, // { "int", 7, _141_two__in_int_a, 0, _141_two__in_int_ha }, { "put", 7, _141_two__in_put_a, 0, _141_two__in_put_ha }, + { "rep", 7, _141_two__in_rep_a }, { "run", 7, _141_two__in_run_a }, { "tap", 7, _141_two__in_tap_a, 0, _141_two__in_tap_ha }, { "wyt", 3, _141_two__in_wyt_a, 0, _141_two__in_wyt_ha }, From 6bec4807daa55e73613f58d75202badbb3ca168a Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 12 May 2020 10:54:59 -0700 Subject: [PATCH 057/933] jet: +rep:by --- pkg/urbit/include/jets/w.h | 1 + pkg/urbit/jets/tree.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index a3271dc2f8..64492c34e9 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -91,6 +91,7 @@ u3_noun u3wdb_put(u3_noun); # define u3wdb_tap u3wdi_tap u3_noun u3wdb_uni(u3_noun); +# define u3wdb_rep u3wdi_rep u3_noun u3wdb_run(u3_noun); # define u3wdb_wyt u3wdi_wyt diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 124a39d30c..57edcaeb46 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -1646,6 +1646,7 @@ static c3_c* _141_two__in_ha[] = { static u3j_harm _141_two__by_apt_a[] = {{".2", u3wdb_apt, c3y}, {}}; static u3j_harm _141_two__by_key_a[] = {{".2", u3wdb_key, c3y}, {}}; + static u3j_harm _141_two__by_rep_a[] = {{".2", u3wdb_rep, c3y}, {}}; static u3j_harm _141_two__by_run_a[] = {{".2", u3wdb_run, c3y}, {}}; static u3j_harm _141_two__by_wyt_a[] = {{".2", u3wdb_wyt, c3y}, {}}; @@ -1671,6 +1672,7 @@ static u3j_core _141_two__by_d[] = { "jab", 7, _141_two__by_jab_a, 0, _141_two__by_jab_ha }, { "key", 7, _141_two__by_key_a }, { "put", 7, _141_two__by_put_a, 0, _141_two__by_put_ha }, + { "rep", 7, _141_two__by_rep_a }, { "run", 7, _141_two__by_run_a }, { "tap", 7, _141_two__by_tap_a, 0, _141_two__by_tap_ha }, { "wyt", 3, _141_two__by_wyt_a }, From 3b645370e2d74dea6b26f595cfedbd1af5d9f239 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 12 May 2020 13:38:24 -0700 Subject: [PATCH 058/933] jets: +urn:by --- bin/solid.pill | 4 ++-- pkg/arvo/sys/hoon.hoon | 1 + pkg/urbit/include/jets/w.h | 1 + pkg/urbit/jets/d/by_urn.c | 38 ++++++++++++++++++++++++++++++++++++++ pkg/urbit/jets/tree.c | 2 ++ 5 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 pkg/urbit/jets/d/by_urn.c diff --git a/bin/solid.pill b/bin/solid.pill index c15b1893e4..e957ab79db 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e6ad17b4eff89b443bf300f1bdd6fcba9301d86ce23bfca77987247146549f88 -size 12863875 +oid sha256:bc9430cd9b988dbd594db4e5e69b2f16217eaccee54254d28a03eafcba9a0c4b +size 12863883 diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 1fbf99dc0b..d66874108a 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -1692,6 +1692,7 @@ :: :: ++ urn :: apply gate to nodes + ~/ %urn |* b/$-({* *} *) |- ?~ a ~ diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index 64492c34e9..718074fb67 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -91,6 +91,7 @@ u3_noun u3wdb_put(u3_noun); # define u3wdb_tap u3wdi_tap u3_noun u3wdb_uni(u3_noun); + u3_noun u3wdb_urn(u3_noun); # define u3wdb_rep u3wdi_rep u3_noun u3wdb_run(u3_noun); # define u3wdb_wyt u3wdi_wyt diff --git a/pkg/urbit/jets/d/by_urn.c b/pkg/urbit/jets/d/by_urn.c new file mode 100644 index 0000000000..886e249b3f --- /dev/null +++ b/pkg/urbit/jets/d/by_urn.c @@ -0,0 +1,38 @@ +/* j/4/by_urn.c +** +*/ +#include "all.h" + +/* internal functions + */ +static +u3_noun +_by_urn(u3_noun a, u3j_site* sit_u) +{ + if (u3_nul == a) { + return 0; + } else { + u3_noun n_a, l_a, r_a; + u3_noun p_n_a, q_n_a; + u3x_trel(a, &n_a, &l_a, &r_a); + u3x_cell(n_a, &p_n_a, &q_n_a); + + return u3nt(u3nc(u3k(p_n_a), u3j_gate_slam(sit_u, u3k(n_a))), + _by_urn(l_a, sit_u), + _by_urn(r_a, sit_u)); + } +} + +u3_noun +u3wdb_urn(u3_noun cor) +{ + u3_noun a, b; + u3j_site sit_u; + + u3x_mean(cor, u3x_sam, &b, u3x_con_sam, &a, 0); + + u3j_gate_prep(&sit_u, u3k(b)); + u3_noun pro = _by_urn(a, &sit_u); + u3j_gate_lose(&sit_u); + return pro; +} diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 57edcaeb46..16d9100dc9 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -1648,6 +1648,7 @@ static c3_c* _141_two__in_ha[] = { static u3j_harm _141_two__by_key_a[] = {{".2", u3wdb_key, c3y}, {}}; static u3j_harm _141_two__by_rep_a[] = {{".2", u3wdb_rep, c3y}, {}}; static u3j_harm _141_two__by_run_a[] = {{".2", u3wdb_run, c3y}, {}}; + static u3j_harm _141_two__by_urn_a[] = {{".2", u3wdb_urn, c3y}, {}}; static u3j_harm _141_two__by_wyt_a[] = {{".2", u3wdb_wyt, c3y}, {}}; static u3j_harm _141_two__by_tap_a[] = {{".2", u3wdb_tap, c3y}, {}}; @@ -1674,6 +1675,7 @@ static u3j_core _141_two__by_d[] = { "put", 7, _141_two__by_put_a, 0, _141_two__by_put_ha }, { "rep", 7, _141_two__by_rep_a }, { "run", 7, _141_two__by_run_a }, + { "urn", 7, _141_two__by_urn_a }, { "tap", 7, _141_two__by_tap_a, 0, _141_two__by_tap_ha }, { "wyt", 3, _141_two__by_wyt_a }, { "uni", 7, _141_two__by_uni_a, 0, _141_two__by_uni_ha }, From 6ae065e6522946acba253b54b62219b1eef12f84 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 12 May 2020 14:04:25 -0700 Subject: [PATCH 059/933] jets: +all:by and +any:by --- pkg/urbit/include/jets/w.h | 2 ++ pkg/urbit/jets/d/by_all.c | 47 ++++++++++++++++++++++++++++++++++++++ pkg/urbit/jets/d/by_any.c | 47 ++++++++++++++++++++++++++++++++++++++ pkg/urbit/jets/tree.c | 6 ++++- 4 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 pkg/urbit/jets/d/by_all.c create mode 100644 pkg/urbit/jets/d/by_any.c diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index 718074fb67..fedfa20398 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -78,6 +78,8 @@ /** Tier 4. **/ + u3_noun u3wdb_all(u3_noun); + u3_noun u3wdb_any(u3_noun); u3_noun u3wdb_apt(u3_noun); u3_noun u3wdb_bif(u3_noun); u3_noun u3wdb_del(u3_noun); diff --git a/pkg/urbit/jets/d/by_all.c b/pkg/urbit/jets/d/by_all.c new file mode 100644 index 0000000000..db58d73359 --- /dev/null +++ b/pkg/urbit/jets/d/by_all.c @@ -0,0 +1,47 @@ +/* j/4/by_all.c +** +*/ +#include "all.h" + +/* internal functions + */ +static u3_noun +_by_all(u3_noun a, u3j_site* sit_u) +{ + if (u3_nul == a) { + return c3y; + } else { + u3_noun n_a, l_a, r_a; + u3_noun q_n_a; + u3x_trel(a, &n_a, &l_a, &r_a); + u3x_cell(n_a, 0, &q_n_a); + + if (c3n == u3j_gate_slam(sit_u, u3k(q_n_a))) { + return c3n; + } + + if (c3n == _by_all(l_a, sit_u)) { + return c3n; + } + + if (c3n == _by_all(r_a, sit_u)) { + return c3n; + } + + return c3y; + } +} + +u3_noun +u3wdb_all(u3_noun cor) +{ + u3_noun a, b; + u3j_site sit_u; + + u3x_mean(cor, u3x_sam, &b, u3x_con_sam, &a, 0); + + u3j_gate_prep(&sit_u, u3k(b)); + u3_noun pro = _by_all(a, &sit_u); + u3j_gate_lose(&sit_u); + return pro; +} diff --git a/pkg/urbit/jets/d/by_any.c b/pkg/urbit/jets/d/by_any.c new file mode 100644 index 0000000000..7d3e67e421 --- /dev/null +++ b/pkg/urbit/jets/d/by_any.c @@ -0,0 +1,47 @@ +/* j/4/by_any.c +** +*/ +#include "all.h" + +/* internal functions + */ +static u3_noun +_by_any(u3_noun a, u3j_site* sit_u) +{ + if (u3_nul == a) { + return c3n; + } else { + u3_noun n_a, l_a, r_a; + u3_noun q_n_a; + u3x_trel(a, &n_a, &l_a, &r_a); + u3x_cell(n_a, 0, &q_n_a); + + if (c3y == u3j_gate_slam(sit_u, u3k(q_n_a))) { + return c3y; + } + + if (c3y == _by_any(l_a, sit_u)) { + return c3y; + } + + if (c3y == _by_any(r_a, sit_u)) { + return c3y; + } + + return c3n; + } +} + +u3_noun +u3wdb_any(u3_noun cor) +{ + u3_noun a, b; + u3j_site sit_u; + + u3x_mean(cor, u3x_sam, &b, u3x_con_sam, &a, 0); + + u3j_gate_prep(&sit_u, u3k(b)); + u3_noun pro = _by_any(a, &sit_u); + u3j_gate_lose(&sit_u); + return pro; +} diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 16d9100dc9..e09b3e9675 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -1644,6 +1644,8 @@ static c3_c* _141_two__in_ha[] = { 0 }; + static u3j_harm _141_two__by_all_a[] = {{".2", u3wdb_all, c3y}, {}}; + static u3j_harm _141_two__by_any_a[] = {{".2", u3wdb_any, c3y}, {}}; static u3j_harm _141_two__by_apt_a[] = {{".2", u3wdb_apt, c3y}, {}}; static u3j_harm _141_two__by_key_a[] = {{".2", u3wdb_key, c3y}, {}}; static u3j_harm _141_two__by_rep_a[] = {{".2", u3wdb_rep, c3y}, {}}; @@ -1662,7 +1664,9 @@ static c3_c* _141_two__in_ha[] = { static c3_c* _141_two__by_uni_ha[] = {0}; static u3j_core _141_two__by_d[] = - { { "apt", 7, _141_two__by_apt_a }, + { { "all", 7, _141_two__by_all_a }, + { "any", 7, _141_two__by_any_a }, + { "apt", 7, _141_two__by_apt_a }, { "bif", 7, _141_two__by_bif_a, 0, _141_two__by_bif_ha }, { "del", 7, _141_two__by_del_a, 0, _141_two__by_del_ha }, { "dif", 7, _141_two__by_dif_a, 0, _141_two__by_dif_ha }, From 2cb18404f8af1af5742103a88731638a68034e43 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 12 May 2020 14:29:36 -0700 Subject: [PATCH 060/933] jet: +find --- pkg/urbit/include/jets/w.h | 1 + pkg/urbit/jets/b/find.c | 47 ++++++++++++++++++++++++++++++++++++++ pkg/urbit/jets/tree.c | 3 +++ 3 files changed, 51 insertions(+) create mode 100644 pkg/urbit/jets/b/find.c diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index fedfa20398..91cb66fed2 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -20,6 +20,7 @@ u3_noun u3wb_bind(u3_noun); u3_noun u3wb_clap(u3_noun); u3_noun u3wb_drop(u3_noun); + u3_noun u3wb_find(u3_noun); u3_noun u3wb_flop(u3_noun); u3_noun u3wb_lent(u3_noun); u3_noun u3wb_levy(u3_noun); diff --git a/pkg/urbit/jets/b/find.c b/pkg/urbit/jets/b/find.c new file mode 100644 index 0000000000..7edfed3bc5 --- /dev/null +++ b/pkg/urbit/jets/b/find.c @@ -0,0 +1,47 @@ +/* j/2/find.c +** +*/ +#include "all.h" + + +/* functions +*/ +u3_noun +u3qb_find(u3_noun nedl, u3_noun hstk) +{ + c3_w i = 0; + + while ( 1 ) { + if ( u3_nul == nedl) { + return u3_nul; + } else if ( u3_nul == hstk ) { + return u3_nul; + } + + u3_noun n = nedl; + u3_noun h = hstk; + while (c3y == u3r_sing(u3h(n), u3h(h))) { + if ( u3_nul == u3t(n) ) { + return u3nc(0, i); + } + + n = u3t(n); + h = u3t(h); + } + + i = u3i_vint(i); + hstk = u3t(hstk); + } +} + +u3_noun +u3wb_find(u3_noun cor) +{ + u3_noun a, b; + + if ( c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0) ) { + return u3m_bail(c3__exit); + } else { + return u3qb_find(a, b); + } +} diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index e09b3e9675..1434e62c10 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -1286,6 +1286,8 @@ static c3_c* _141_tri_ha[] = { /* layer two */ +static u3j_harm _141_two_find_a[] = {{".2", u3wb_find, c3y}, {}}; + static u3j_harm _141_two_flop_a[] = {{".2", u3wb_flop, c3y}, {}}; static c3_c* _141_two_flop_ha[] = { "73ac3be0119bcb822621de738f90975d98ce1ff3fb9a52853adc638271f61cd2", @@ -1714,6 +1716,7 @@ static c3_c* _141_two_rub_ha[] = { static u3j_core _141_two_d[] = { { "tri", 3, 0, _141_tri_d, _141_tri_ha }, + { "find", 7, _141_two_find_a }, { "flop", 7, _141_two_flop_a, 0, _141_two_flop_ha }, { "lent", 7, _141_two_lent_a, 0, _141_two_lent_ha }, { "levy", 7, _141_two_levy_a, 0, _141_two_levy_ha }, From 8602ed8aa5c8741d481e372216416f5c68621864 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 13 May 2020 11:15:15 -0700 Subject: [PATCH 061/933] jets: fix memory leak in +run:in --- pkg/urbit/jets/d/in_run.c | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/urbit/jets/d/in_run.c b/pkg/urbit/jets/d/in_run.c index 1bfeb1b598..6d398cfa71 100644 --- a/pkg/urbit/jets/d/in_run.c +++ b/pkg/urbit/jets/d/in_run.c @@ -19,6 +19,7 @@ _in_run(u3_noun a, u3j_site* sit_u, u3_noun* out) u3_noun nuout = u3qdi_put(*out, nu_n_a); u3z(*out); + u3z(nu_n_a); *out = nuout; _in_run(l_a, sit_u, out); From 34c1f416f4d5832763659d0f89d4442bb6b146a7 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 13 May 2020 11:18:37 -0700 Subject: [PATCH 062/933] jets: +welp and +zing --- bin/solid.pill | 4 ++-- pkg/arvo/sys/hoon.hoon | 2 ++ pkg/urbit/include/jets/w.h | 2 ++ pkg/urbit/jets/b/zing.c | 44 ++++++++++++++++++++++++++++++++++++++ pkg/urbit/jets/tree.c | 6 ++++++ 5 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 pkg/urbit/jets/b/zing.c diff --git a/bin/solid.pill b/bin/solid.pill index e957ab79db..72209cb972 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bc9430cd9b988dbd594db4e5e69b2f16217eaccee54254d28a03eafcba9a0c4b -size 12863883 +oid sha256:0adaf644c2978ff78816762f68d7b517a845f4a6fb3d42d50e3c5574c6ebc53d +size 12863979 diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index d66874108a..20a83cd727 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -778,6 +778,7 @@ (weld (scag b a) [c (slag b a)]) :: ++ welp :: faceless weld + ~/ %welp =| {* *} |@ ++ $ @@ -787,6 +788,7 @@ -- :: ++ zing :: promote + ~/ %zing =| * |@ ++ $ diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index 91cb66fed2..33ea712aaa 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -39,6 +39,8 @@ u3_noun u3wb_sort(u3_noun); u3_noun u3wb_turn(u3_noun); u3_noun u3wb_weld(u3_noun); +# define u3wb_welp u3wb_weld + u3_noun u3wb_zing(u3_noun); /** Tier 3. **/ diff --git a/pkg/urbit/jets/b/zing.c b/pkg/urbit/jets/b/zing.c new file mode 100644 index 0000000000..20570b4127 --- /dev/null +++ b/pkg/urbit/jets/b/zing.c @@ -0,0 +1,44 @@ +/* j/2/zing.c +** +*/ +#include "all.h" + + +/* functions +*/ +u3_noun +u3qb_zing(u3_noun a) +{ + u3_noun top = u3qb_flop(a); + u3_noun top_orig = top; + u3_noun l = 0; + + while ( u3_nul != top ) { + u3_noun f = u3qb_flop(u3h(top)); + u3_noun f_orig = f; + + while ( u3_nul != f ) { + l = u3nc(u3k(u3h(f)), l); + f = u3t(f); + } + + u3z(f_orig); + top = u3t(top); + } + + u3z(top_orig); + + return l; +} + +u3_noun +u3wb_zing(u3_noun cor) +{ + u3_noun a; + + if ( c3n == u3r_mean(cor, u3x_sam, &a, 0) ) { + return u3m_bail(c3__exit); + } else { + return u3qb_zing(a); + } +} diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 1434e62c10..7b58f2e6fd 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -1373,6 +1373,10 @@ static c3_c* _141_two_turn_ha[] = { "cd4a292788acd440d6ace689f82fa999b342bb749585bc0e173098529bb75fb8", 0 }; + +static u3j_harm _141_two_welp_a[] = {{".2", u3wb_welp, c3y}, {}}; +static u3j_harm _141_two_zing_a[] = {{".2", u3wb_zing, c3y}, {}}; + static u3j_harm _141_two_weld_a[] = {{".2", u3wb_weld, c3y}, {}}; static c3_c* _141_two_weld_ha[] = { "d855628821d57392f575c5da000c7326eaaa19e08cda967a4772859269669df2", @@ -1735,6 +1739,8 @@ static u3j_core _141_two_d[] = { "sort", 7, _141_two_sort_a, 0, _141_two_sort_ha }, { "turn", 7, _141_two_turn_a, 0, _141_two_turn_ha }, { "weld", 7, _141_two_weld_a, 0, _141_two_weld_ha }, + { "welp", 7, _141_two_welp_a }, + { "zing", 7, _141_two_zing_a }, { "bex", 7, _141_two_bex_a, 0, _141_two_bex_ha }, { "cat", 7, _141_two_cat_a, 0, _141_two_cat_ha }, From a3ff85dc48e447826a1cf943abf2dfcab0931528 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 13 May 2020 16:17:18 -0700 Subject: [PATCH 063/933] Revert "Revert "u3: clear cached mugs on cell edit"" This reverts commit 5c211c682d9b9648b4d6113cbe97d066ad8fb032. --- pkg/urbit/noun/imprison.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/urbit/noun/imprison.c b/pkg/urbit/noun/imprison.c index be9decee5a..80b3b1a9ec 100644 --- a/pkg/urbit/noun/imprison.c +++ b/pkg/urbit/noun/imprison.c @@ -329,6 +329,7 @@ _mutate_cat(u3_noun big, c3_l axe_l, u3_noun som) *tar = _edit_or_mutate_cat(*tar, u3x_mas(axe_l), som); } } + cel_u->mug_w = 0; } } @@ -348,6 +349,7 @@ _mutate(u3_noun big, u3_noun axe, u3_noun som) ? &(cel_u->hed) : &(cel_u->tel); *tar = _edit_or_mutate(*tar, mor, som); + cel_u->mug_w = 0; u3z(mor); } } From 27a47cc72fad0679a87b451abbb667a51a626fed Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 14 May 2020 00:07:08 -0700 Subject: [PATCH 064/933] hoon: switches +mink %hunk from tank to (untyped) path a %hunk is the error-stack frame for a failed ([~ ~]) scry. this changes the frame type from tank to *, avoiding coordination overhead between +mink and the interpreter. --- pkg/arvo/sys/hoon.hoon | 23 +++-------------------- pkg/urbit/noun/nock.c | 40 ++-------------------------------------- 2 files changed, 5 insertions(+), 58 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index ac05ae3b6a..5174bfb571 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -6449,27 +6449,10 @@ ?~ result [%1 product.path] ?~ u.result - [%2 [%hunk (mush product.path)] trace] + [%2 [%hunk product.path] trace] [%0 u.u.result] == :: - ++ mush - |= path=* - ^- tank - :+ %rose ["/" "/" ""] - =| out=(list tank) - |- ^+ out - ?@ path - ?: =(0 path) - (flop out) - ~ - ?^ -.path ~ - %= $ - path +.path - out :_ out - leaf+(trip -.path) - == - :: ++ frag |= [axis=@ noun=*] ^- (unit *) @@ -6527,9 +6510,9 @@ =+ rep=$(trace.ton t.trace.ton) =* dat +.i.trace.ton ?+ -.i.trace.ton rep - $hunk =/ sof=(unit tank) ((soft tank) dat) + $hunk =/ sof=(unit path) ((soft path) dat) ?~ sof rep - [u.sof rep] + [(smyt u.sof) rep] $lose ?^ dat rep :_ rep leaf+(rip 3 dat) diff --git a/pkg/urbit/noun/nock.c b/pkg/urbit/noun/nock.c index a7669d0692..d12816cd70 100644 --- a/pkg/urbit/noun/nock.c +++ b/pkg/urbit/noun/nock.c @@ -7,41 +7,6 @@ // along with some other debugging info # undef VERBOSE_BYTECODE -/* _n_mush_in(): see _n_mush(). -*/ -static u3_noun -_n_mush_in(u3_noun val) -{ - if ( c3n == u3du(val) ) { - return u3_nul; - } - else { - u3_noun h_val = u3h(val); - u3_noun ite; - - if ( c3n == u3ud(h_val) ) { - ite = u3nc(c3__leaf, u3_nul); - } else { - ite = u3nc(c3__leaf, u3qe_trip(h_val)); - } - return u3nc(ite, _n_mush_in(u3t(val))); - } -} - -/* _n_mush(): tank from failed path request. -*/ -static u3_noun -_n_mush(u3_noun val) -{ - u3_noun pro; - - pro = u3nt(c3__rose, - u3nt(u3nc('/', u3_nul), u3nc('/', u3_nul), u3_nul), - _n_mush_in(val)); - u3z(val); - return pro; -} - #if 0 // Retained for debugging purposes. static u3_noun _n_nock_on(u3_noun bus, u3_noun fol); @@ -396,7 +361,7 @@ _n_nock_on(u3_noun bus, u3_noun fol) // // replace with proper error stack push // - u3t_push(u3nc(c3__hunk, _n_mush(gof))); + u3t_push(u3nc(c3__hunk, gof)); return u3m_bail(c3__exit); } else { @@ -2174,8 +2139,7 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) return u3_none; } else if ( c3n == u3du(u3t(x)) ) { - // replace with proper error stack push - u3t_push(u3nc(c3__hunk, _n_mush(o))); + u3t_push(u3nc(c3__hunk, o)); u3m_bail(c3__exit); return u3_none; } From 3fd545e40fc03cac0ea6b85f2ed49ea868fee2c3 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 14 May 2020 11:00:52 -0700 Subject: [PATCH 065/933] hoon: switches %hunk to scry sample --- pkg/arvo/sys/hoon.hoon | 5 +++-- pkg/urbit/noun/nock.c | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 5174bfb571..cdec3926b6 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -6449,7 +6449,7 @@ ?~ result [%1 product.path] ?~ u.result - [%2 [%hunk product.path] trace] + [%2 [%hunk product.ref product.path] trace] [%0 u.u.result] == :: @@ -6510,7 +6510,8 @@ =+ rep=$(trace.ton t.trace.ton) =* dat +.i.trace.ton ?+ -.i.trace.ton rep - $hunk =/ sof=(unit path) ((soft path) dat) + $hunk ?@ dat rep + =/ sof=(unit path) ((soft path) +.dat) ?~ sof rep [(smyt u.sof) rep] $lose ?^ dat rep diff --git a/pkg/urbit/noun/nock.c b/pkg/urbit/noun/nock.c index d12816cd70..ec1a35498a 100644 --- a/pkg/urbit/noun/nock.c +++ b/pkg/urbit/noun/nock.c @@ -351,7 +351,7 @@ _n_nock_on(u3_noun bus, u3_noun fol) u3_noun val; u3t_off(noc_o); - val = u3m_soft_esc(ref, u3k(gof)); + val = u3m_soft_esc(u3k(ref), u3k(gof)); u3t_on(noc_o); if ( !_(u3du(val)) ) { @@ -361,12 +361,13 @@ _n_nock_on(u3_noun bus, u3_noun fol) // // replace with proper error stack push // - u3t_push(u3nc(c3__hunk, gof)); + u3t_push(u3nt(c3__hunk, ref, gof)); return u3m_bail(c3__exit); } else { u3_noun pro; + u3z(ref); u3z(gof); u3z(fol); pro = u3k(u3t(u3t(val))); @@ -2131,7 +2132,7 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) top = _n_swap(mov, off); // [ref bus] wish_in: u3t_off(noc_o); - x = u3m_soft_esc(*top, u3k(o)); + x = u3m_soft_esc(u3k(*top), u3k(o)); u3t_on(noc_o); if ( c3n == u3du(x) ) { @@ -2139,12 +2140,13 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) return u3_none; } else if ( c3n == u3du(u3t(x)) ) { - u3t_push(u3nc(c3__hunk, o)); + u3t_push(u3nt(c3__hunk, *top, o)); u3m_bail(c3__exit); return u3_none; } else { u3z(o); + u3z(*top); *top = u3k(u3t(u3t(x))); u3z(x); BURN(); From 953091a920bccc260cb2c707ec0566cec4cbad52 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 14 May 2020 00:08:30 -0700 Subject: [PATCH 066/933] hoon: refactors stack-trace production in +mook --- pkg/arvo/sys/hoon.hoon | 106 +++++++++++++++++++++++++++-------------- 1 file changed, 69 insertions(+), 37 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index cdec3926b6..a90f432bca 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -6489,51 +6489,83 @@ ++ mock |= {{sub/* fol/*} gul/$-({* *} (unit (unit)))} (mook (mink [sub fol] gul)) +:: +mook: convert $tone to %toon, rendering stack frames if present :: ++ mook - |= ton/tone + |= ton=tone ^- toon - ?. ?=({$2 *} ton) ton - :- %2 - =+ yel=(lent trace.ton) - =. trace.ton + ?. ?=([%2 *] ton) + ton + |^ [%2 (turn skip rend)] + :: + ++ skip + ^+ trace.ton + =/ yel (lent trace.ton) ?. (gth yel 1.024) trace.ton %+ weld (scag 512 trace.ton) - ^- (list {@ta *}) + ^+ trace.ton :_ (slag (sub yel 512) trace.ton) :- %lose - %+ rap 3 - "[skipped {(scow %ud (sub yel 1.024))} frames]" - |- ^- (list tank) - ?~ trace.ton ~ - =+ rep=$(trace.ton t.trace.ton) - =* dat +.i.trace.ton - ?+ -.i.trace.ton rep - $hunk ?@ dat rep - =/ sof=(unit path) ((soft path) +.dat) - ?~ sof rep - [(smyt u.sof) rep] - $lose ?^ dat rep - :_ rep - leaf+(rip 3 dat) - $hand :_ rep - leaf+(scow %p (mug dat)) - $mean ?@ dat [leaf+(rip 3 dat) rep] - =/ mac (mack dat -.dat) - ?~ mac [leaf+"####" rep] - =/ sof ((soft tank) u.mac) - ?~ sof rep - [u.sof rep] - $spot =/ sof=(unit spot) ((soft spot) dat) - ?~ sof rep - :_ rep - :+ %rose [":" ~ ~] - =* sot u.sof - :~ (smyt p.sot) - => [ud=|=(a/@u (scow %ud a)) q.sot] - leaf+"<[{(ud p.p)} {(ud q.p)}].[{(ud p.q)} {(ud q.q)}]>" - == == + (crip "[skipped {(scow %ud (sub yel 1.024))} frames]") + :: + :: +rend: raw stack frame to tank + :: + :: supported frame types: + :: + :: $% :: %hunk: failed scry ([~ ~]) + :: :: %lose: skipped frames + :: :: %hand: mug any + :: :: %mean: ~_ + :: :: %spot: source location + :: :: + :: [%hunk ref=* path] + :: [%lose cord] + :: [%hand *] + :: [%mean $@(cord (trap tank))] + :: [%spot spot] + :: == + :: + ++ rend + |= [tag=@ta dat=*] + ^- tank + ?+ tag + :: + leaf+"mook.{(rip 3 tag)}" + :: + %hunk + ?@ dat leaf+"mook.hunk" + =/ sof=(unit path) ((soft path) +.dat) + ?~ sof leaf+"mook.hunk" + (smyt u.sof) + :: + %lose + ?^ dat leaf+"mook.lose" + leaf+(rip 3 dat) + :: + %hand + leaf+(scow %p (mug dat)) + :: + %mean + ?@ dat leaf+(rip 3 dat) + =/ mac (mack dat -.dat) + ?~ mac leaf+"####" + =/ sof ((soft tank) u.mac) + ?~ sof leaf+"mook.mean" + u.sof + :: + %spot + =/ sof=(unit spot) ((soft spot) dat) + ?~ sof leaf+"mook.spot" + :+ %rose [":" ~ ~] + :~ (smyt p.u.sof) + =* l p.q.u.sof + =* r q.q.u.sof + =/ ud |=(a=@u (scow %ud a)) + leaf+"<[{(ud p.l)} {(ud q.l)}].[{(ud p.r)} {(ud q.r)}]>" + == + == + -- :: ++ mong |= {{gat/* sam/*} gul/$-({* *} (unit (unit)))} From e7d8a64a213874f7002bc5e05fb93d63ce4725db Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 14 May 2020 13:21:43 -0700 Subject: [PATCH 067/933] hoon: refactors nock %6 in +mink --- pkg/arvo/sys/hoon.hoon | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index a90f432bca..cc2f8eaeda 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -6373,11 +6373,11 @@ [%6 test=* yes=* no=*] =/ result $(formula test.formula) ?. ?=(%0 -.result) result - ?: =(& product.result) - $(formula yes.formula) - ?: =(| product.result) - $(formula no.formula) - [%2 trace] + ?+ product.result + [%2 trace] + %& $(formula yes.formula) + %| $(formula no.formula) + == :: [%7 subject=* next=*] =/ subject $(formula subject.formula) From 56418b7ad7b638fe0d452c9ad7e631d7c255c09c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 14 May 2020 13:21:59 -0700 Subject: [PATCH 068/933] hoon: refactors nock %11 in +mink --- pkg/arvo/sys/hoon.hoon | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index cc2f8eaeda..67cdcd6199 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -6426,19 +6426,15 @@ [%11 [tag=@ clue=*] next=*] =/ clue $(formula clue.formula) ?. ?=(%0 -.clue) clue - =; next - ?. ?=(%0 -.next) next - :- %0 - .* subject - [11 [tag.formula 1 product.clue] 1 product.next] - %= $ - formula next.formula - trace ?. ?= ?(%hunk %hand %lose %mean %spot) - tag.formula - trace - :_ trace - [tag.formula product.clue] - == + =/ next + =? trace + ?=(?(%hunk %hand %lose %mean %spot) tag.formula) + [[tag.formula product.clue] trace] + $(formula next.formula) + ?. ?=(%0 -.next) next + :- %0 + .* subject + [11 [tag.formula 1 product.clue] 1 product.next] :: [%12 ref=* path=*] =/ ref $(formula ref.formula) From c44f1f2de60ec01b7d77f86c9b4a8e7401443330 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 14 May 2020 13:28:04 -0700 Subject: [PATCH 069/933] jets: review comments --- pkg/urbit/jets/b/find.c | 2 +- pkg/urbit/jets/d/by_apt.c | 22 ++++---- pkg/urbit/jets/d/in_apt.c | 22 ++++---- pkg/urbit/jets/tree.c | 107 +++++++++++++++++++++++++------------- 4 files changed, 98 insertions(+), 55 deletions(-) diff --git a/pkg/urbit/jets/b/find.c b/pkg/urbit/jets/b/find.c index 7edfed3bc5..c8aab5efa6 100644 --- a/pkg/urbit/jets/b/find.c +++ b/pkg/urbit/jets/b/find.c @@ -9,7 +9,7 @@ u3_noun u3qb_find(u3_noun nedl, u3_noun hstk) { - c3_w i = 0; + u3_atom i = 0; while ( 1 ) { if ( u3_nul == nedl) { diff --git a/pkg/urbit/jets/d/by_apt.c b/pkg/urbit/jets/d/by_apt.c index a2350cccda..c580087d4b 100644 --- a/pkg/urbit/jets/d/by_apt.c +++ b/pkg/urbit/jets/d/by_apt.c @@ -4,7 +4,7 @@ #include "all.h" static -c3_y _by_apt(u3_noun a, u3_noun l, u3_noun r) +c3_o _by_apt(u3_noun a, u3_noun l, u3_noun r) { if (a == 0) { return c3y; @@ -15,8 +15,9 @@ c3_y _by_apt(u3_noun a, u3_noun l, u3_noun r) u3x_trel(a, &n_a, &l_a, &r_a); u3x_cell(n_a, &p_n_a, &q_n_a); - u3_noun u_l; - if (c3y == u3r_cell(l, 0, &u_l)) { + if ( u3_nul != l ) { + u3_noun u_l; + u3x_cell(l, 0, &u_l); if (!_(u3qc_gor(p_n_a, u_l))) { return c3n; } @@ -25,8 +26,9 @@ c3_y _by_apt(u3_noun a, u3_noun l, u3_noun r) } } - u3_noun u_r; - if (c3y == u3r_cell(r, 0, &u_r)) { + if ( u3_nul != r ) { + u3_noun u_r; + u3x_cell(r, 0, &u_r); if (!_(u3qc_gor(u_r, p_n_a))) { return c3n; } @@ -35,9 +37,10 @@ c3_y _by_apt(u3_noun a, u3_noun l, u3_noun r) } } - u3_noun n_l_a, l_l_a, r_l_a; - if (c3y == u3r_trel(l_a, &n_l_a, &l_l_a, &r_l_a)) { + if ( u3_nul != l_a ) { + u3_noun n_l_a, l_l_a, r_l_a; u3_noun p_n_l_a; + u3x_trel(l_a, &n_l_a, &l_l_a, &r_l_a); u3x_cell(n_l_a, &p_n_l_a, 0); if (!_(u3qc_mor(p_n_a, p_n_l_a))) { @@ -54,9 +57,10 @@ c3_y _by_apt(u3_noun a, u3_noun l, u3_noun r) u3z(nu_l); } - u3_noun n_r_a, l_r_a, r_r_a; - if (c3y == u3r_trel(r_a, &n_r_a, &l_r_a, &r_r_a)) { + if ( u3_nul != r_a ) { + u3_noun n_r_a, l_r_a, r_r_a; u3_noun p_n_r_a; + u3x_trel(r_a, &n_r_a, &l_r_a, &r_r_a); u3x_cell(n_r_a, &p_n_r_a, 0); if (!_(u3qc_mor(p_n_a, p_n_r_a))) { diff --git a/pkg/urbit/jets/d/in_apt.c b/pkg/urbit/jets/d/in_apt.c index b252680429..fe041c77fa 100644 --- a/pkg/urbit/jets/d/in_apt.c +++ b/pkg/urbit/jets/d/in_apt.c @@ -4,7 +4,7 @@ #include "all.h" static -c3_y _in_apt(u3_noun a, u3_noun l, u3_noun r) +c3_o _in_apt(u3_noun a, u3_noun l, u3_noun r) { if (a == 0) { return c3y; @@ -13,22 +13,25 @@ c3_y _in_apt(u3_noun a, u3_noun l, u3_noun r) u3_noun n_a, l_a, r_a; u3x_trel(a, &n_a, &l_a, &r_a); - u3_noun u_l; - if (c3y == u3r_cell(l, 0, &u_l)) { + if ( u3_nul != l ) { + u3_noun u_l; + u3x_cell(l, 0, &u_l); if (!_(u3qc_gor(n_a, u_l))) { return c3n; } } - u3_noun u_r; - if (c3y == u3r_cell(r, 0, &u_r)) { + if ( u3_nul != r ) { + u3_noun u_r; + u3r_cell(r, 0, &u_r); if (!_(u3qc_gor(u_r, n_a))) { return c3n; } } - u3_noun n_l_a, l_l_a, r_l_a; - if (c3y == u3r_trel(l_a, &n_l_a, &l_l_a, &r_l_a)) { + if ( u3_nul != l_a ) { + u3_noun n_l_a, l_l_a, r_l_a; + u3x_trel(l_a, &n_l_a, &l_l_a, &r_l_a); if (!_(u3qc_mor(n_a, n_l_a))) { return c3n; } @@ -40,8 +43,9 @@ c3_y _in_apt(u3_noun a, u3_noun l, u3_noun r) u3z(nu_l); } - u3_noun n_r_a, l_r_a, r_r_a; - if (c3y == u3r_trel(r_a, &n_r_a, &l_r_a, &r_r_a)) { + if ( u3_nul != r_a ) { + u3_noun n_r_a, l_r_a, r_r_a; + u3x_trel(r_a, &n_r_a, &l_r_a, &r_r_a); if (!_(u3qc_mor(n_a, n_r_a))) { return c3n; } diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 7b58f2e6fd..1e5e6ab7f9 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -1287,7 +1287,9 @@ static c3_c* _141_tri_ha[] = { /* layer two */ static u3j_harm _141_two_find_a[] = {{".2", u3wb_find, c3y}, {}}; - +static c3_c* _141_two_find_ha[] = { + 0 +}; static u3j_harm _141_two_flop_a[] = {{".2", u3wb_flop, c3y}, {}}; static c3_c* _141_two_flop_ha[] = { "73ac3be0119bcb822621de738f90975d98ce1ff3fb9a52853adc638271f61cd2", @@ -1373,15 +1375,19 @@ static c3_c* _141_two_turn_ha[] = { "cd4a292788acd440d6ace689f82fa999b342bb749585bc0e173098529bb75fb8", 0 }; - -static u3j_harm _141_two_welp_a[] = {{".2", u3wb_welp, c3y}, {}}; -static u3j_harm _141_two_zing_a[] = {{".2", u3wb_zing, c3y}, {}}; - static u3j_harm _141_two_weld_a[] = {{".2", u3wb_weld, c3y}, {}}; static c3_c* _141_two_weld_ha[] = { "d855628821d57392f575c5da000c7326eaaa19e08cda967a4772859269669df2", 0 }; +static u3j_harm _141_two_welp_a[] = {{".2", u3wb_welp, c3y}, {}}; +static c3_c* _141_two_welp_ha[] = { + 0 +}; +static u3j_harm _141_two_zing_a[] = {{".2", u3wb_zing, c3y}, {}}; +static c3_c* _141_two_zing_ha[] = { + 0 +}; static u3j_harm _141_two_bex_a[] = {{".2", u3wc_bex, c3y}, {}}; static c3_c* _141_two_bex_ha[] = { @@ -1528,6 +1534,10 @@ static c3_c* _141_two_xeb_ha[] = { 0 }; + static u3j_harm _141_two__in_apt_a[] = {{".2", u3wdi_apt}, {}}; + static c3_c* _141_two__in_apt_ha[] = { + 0 + }; static u3j_harm _141_two__in_bif_a[] = {{".2", u3wdi_bif}, {}}; static c3_c* _141_two__in_bif_ha[] = { "7ccbde61c80246056f6acfd8dc30f560af9e5abd44841c22ba0f49951dbc2f2a", @@ -1563,6 +1573,14 @@ static c3_c* _141_two_xeb_ha[] = { "4a9fd615fecd2fd36485b3a2f24cdc13afc86f9a478362934b4654297496a03c", 0 }; + static u3j_harm _141_two__in_rep_a[] = {{".2", u3wdi_rep}, {}}; + static c3_c* _141_two__in_rep_ha[] = { + 0 + }; + static u3j_harm _141_two__in_run_a[] = {{".2", u3wdi_run}, {}}; + static c3_c* _141_two__in_run_ha[] = { + 0 + }; static u3j_harm _141_two__in_tap_a[] = {{".2", u3wdi_tap}, {}}; static c3_c* _141_two__in_tap_ha[] = { "7dde59e2bd7684e785ce9787bc394571bd1216d7a62398c703447fc951c6b352", @@ -1579,12 +1597,8 @@ static c3_c* _141_two_xeb_ha[] = { 0 }; - static u3j_harm _141_two__in_apt_a[] = {{".2", u3wdi_apt}, {}}; - static u3j_harm _141_two__in_rep_a[] = {{".2", u3wdi_rep}, {}}; - static u3j_harm _141_two__in_run_a[] = {{".2", u3wdi_run}, {}}; - static u3j_core _141_two__in_d[] = - { { "apt", 7, _141_two__in_apt_a }, + { { "apt", 7, _141_two__in_apt_a, 0, _141_two__in_apt_ha }, { "bif", 7, _141_two__in_bif_a, 0, _141_two__in_bif_ha }, { "del", 7, _141_two__in_del_a, 0, _141_two__in_del_ha }, { "dif", 7, _141_two__in_dif_a, 0, _141_two__in_dif_ha }, @@ -1592,18 +1606,29 @@ static u3j_core _141_two__in_d[] = { "has", 7, _141_two__in_has_a, 0, _141_two__in_has_ha }, // { "int", 7, _141_two__in_int_a, 0, _141_two__in_int_ha }, { "put", 7, _141_two__in_put_a, 0, _141_two__in_put_ha }, - { "rep", 7, _141_two__in_rep_a }, - { "run", 7, _141_two__in_run_a }, + { "rep", 7, _141_two__in_rep_a, 0, _141_two__in_rep_ha }, + { "run", 7, _141_two__in_run_a, 0, _141_two__in_run_ha }, { "tap", 7, _141_two__in_tap_a, 0, _141_two__in_tap_ha }, - { "wyt", 3, _141_two__in_wyt_a, 0, _141_two__in_wyt_ha }, { "uni", 7, _141_two__in_uni_a, 0, _141_two__in_uni_ha }, + { "wyt", 3, _141_two__in_wyt_a, 0, _141_two__in_wyt_ha }, {} }; static c3_c* _141_two__in_ha[] = { "abf20b11b7d7f9aa8cc7b4de01c15ec3aca3ea07ca09a461a3277fe24c640849", 0 }; - + static u3j_harm _141_two__by_all_a[] = {{".2", u3wdb_all, c3y}, {}}; + static c3_c* _141_two__by_all_ha[] = { + 0 + }; + static u3j_harm _141_two__by_any_a[] = {{".2", u3wdb_any, c3y}, {}}; + static c3_c* _141_two__by_any_ha[] = { + 0 + }; + static u3j_harm _141_two__by_apt_a[] = {{".2", u3wdb_apt, c3y}, {}}; + static c3_c* _141_two__by_apt_ha[] = { + 0 + }; static u3j_harm _141_two__by_bif_a[] = {{".2", u3wdb_bif, c3y}, {}}; static c3_c* _141_two__by_bif_ha[] = { "09ce4cf00dd9b4f95d4d93a984ffab94cb99cb6017bb73531245ea4813855f4e", @@ -1644,35 +1669,45 @@ static c3_c* _141_two__in_ha[] = { "8bc992aefabd2e0f43c900f2c4f3b06cf330973774d8f43428049cc3b3cb5b94", 0 }; + static u3j_harm _141_two__by_key_a[] = {{".2", u3wdb_key, c3y}, {}}; + static c3_c* _141_two__by_key_ha[] = { + 0 + }; static u3j_harm _141_two__by_put_a[] = {{".2", u3wdb_put, c3y}, {}}; static c3_c* _141_two__by_put_ha[] = { "2cc9f005fde5314e9ad545286493a8c81b5c3b775d645ad82954f405d9414a32", 0 }; - - static u3j_harm _141_two__by_all_a[] = {{".2", u3wdb_all, c3y}, {}}; - static u3j_harm _141_two__by_any_a[] = {{".2", u3wdb_any, c3y}, {}}; - static u3j_harm _141_two__by_apt_a[] = {{".2", u3wdb_apt, c3y}, {}}; - static u3j_harm _141_two__by_key_a[] = {{".2", u3wdb_key, c3y}, {}}; static u3j_harm _141_two__by_rep_a[] = {{".2", u3wdb_rep, c3y}, {}}; + static c3_c* _141_two__by_rep_ha[] = { + 0 + }; static u3j_harm _141_two__by_run_a[] = {{".2", u3wdb_run, c3y}, {}}; - static u3j_harm _141_two__by_urn_a[] = {{".2", u3wdb_urn, c3y}, {}}; - static u3j_harm _141_two__by_wyt_a[] = {{".2", u3wdb_wyt, c3y}, {}}; - + static c3_c* _141_two__by_run_ha[] = { + 0 + }; static u3j_harm _141_two__by_tap_a[] = {{".2", u3wdb_tap, c3y}, {}}; static c3_c* _141_two__by_tap_ha[] = { "7dde59e2bd7684e785ce9787bc394571bd1216d7a62398c703447fc951c6b352", 0 }; - - // https://github.com/urbit/urbit/issues/328 static u3j_harm _141_two__by_uni_a[] = {{".2", u3wdb_uni, c3y}, {}}; - static c3_c* _141_two__by_uni_ha[] = {0}; + static c3_c* _141_two__by_uni_ha[] = { + 0 + }; + static u3j_harm _141_two__by_urn_a[] = {{".2", u3wdb_urn, c3y}, {}}; + static c3_c* _141_two__by_urn_ha[] = { + 0 + }; + static u3j_harm _141_two__by_wyt_a[] = {{".2", u3wdb_wyt, c3y}, {}}; + static c3_c* _141_two__by_wyt_ha[] = { + 0 + }; static u3j_core _141_two__by_d[] = - { { "all", 7, _141_two__by_all_a }, - { "any", 7, _141_two__by_any_a }, - { "apt", 7, _141_two__by_apt_a }, + { { "all", 7, _141_two__by_all_a, 0, _141_two__by_all_ha }, + { "any", 7, _141_two__by_any_a, 0, _141_two__by_any_ha }, + { "apt", 7, _141_two__by_apt_a, 0, _141_two__by_apt_ha }, { "bif", 7, _141_two__by_bif_a, 0, _141_two__by_bif_ha }, { "del", 7, _141_two__by_del_a, 0, _141_two__by_del_ha }, { "dif", 7, _141_two__by_dif_a, 0, _141_two__by_dif_ha }, @@ -1681,14 +1716,14 @@ static u3j_core _141_two__by_d[] = { "has", 7, _141_two__by_has_a, 0, _141_two__by_has_ha }, // { "int", 7, _141_two__by_int_a, 0, _141_two__by_int_ha }, { "jab", 7, _141_two__by_jab_a, 0, _141_two__by_jab_ha }, - { "key", 7, _141_two__by_key_a }, + { "key", 7, _141_two__by_key_a, 0, _141_two__by_key_ha }, { "put", 7, _141_two__by_put_a, 0, _141_two__by_put_ha }, - { "rep", 7, _141_two__by_rep_a }, - { "run", 7, _141_two__by_run_a }, - { "urn", 7, _141_two__by_urn_a }, + { "rep", 7, _141_two__by_rep_a, 0, _141_two__by_rep_ha }, + { "run", 7, _141_two__by_run_a, 0, _141_two__by_run_ha }, { "tap", 7, _141_two__by_tap_a, 0, _141_two__by_tap_ha }, - { "wyt", 3, _141_two__by_wyt_a }, { "uni", 7, _141_two__by_uni_a, 0, _141_two__by_uni_ha }, + { "urn", 7, _141_two__by_urn_a, 0, _141_two__by_urn_ha }, + { "wyt", 3, _141_two__by_wyt_a, 0, _141_two__by_wyt_ha }, {} }; static c3_c* _141_two__by_ha[] = { @@ -1720,7 +1755,7 @@ static c3_c* _141_two_rub_ha[] = { static u3j_core _141_two_d[] = { { "tri", 3, 0, _141_tri_d, _141_tri_ha }, - { "find", 7, _141_two_find_a }, + { "find", 7, _141_two_find_a, 0, _141_two_find_ha }, { "flop", 7, _141_two_flop_a, 0, _141_two_flop_ha }, { "lent", 7, _141_two_lent_a, 0, _141_two_lent_ha }, { "levy", 7, _141_two_levy_a, 0, _141_two_levy_ha }, @@ -1739,8 +1774,8 @@ static u3j_core _141_two_d[] = { "sort", 7, _141_two_sort_a, 0, _141_two_sort_ha }, { "turn", 7, _141_two_turn_a, 0, _141_two_turn_ha }, { "weld", 7, _141_two_weld_a, 0, _141_two_weld_ha }, - { "welp", 7, _141_two_welp_a }, - { "zing", 7, _141_two_zing_a }, + { "welp", 7, _141_two_welp_a, 0, _141_two_welp_ha }, + { "zing", 7, _141_two_zing_a, 0, _141_two_zing_ha }, { "bex", 7, _141_two_bex_a, 0, _141_two_bex_ha }, { "cat", 7, _141_two_cat_a, 0, _141_two_cat_ha }, From 8abcd4d6e1c75d6e794145045033bd5978eb943d Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 14 May 2020 13:29:57 -0700 Subject: [PATCH 070/933] jets: add empty hashes --- pkg/urbit/jets/tree.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 8593655dbb..141e9a6021 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -608,9 +608,17 @@ static c3_c* _141_qua_trip_ha[] = { }; static u3j_harm _141_qua_slaw_a[] = {{".2", u3we_slaw}, {}}; +static c3_c* _141_qua_slaw_ha[] = { + 0 +}; static u3j_harm _141_qua_scot_a[] = {{".2", u3we_scot}, {}}; +static c3_c* _141_qua_scot_ha[] = { + 0 +}; static u3j_harm _141_qua_scow_a[] = {{".2", u3we_scow}, {}}; - +static c3_c* _141_qua_scow_ha[] = { + 0 +}; static u3j_harm _141_qua__po_ind_a[] = {{".2", u3wcp_ind}, {}}; static c3_c* _141_qua__po_ind_ha[] = { @@ -889,9 +897,9 @@ static u3j_core _141_qua_d[] = { "mink", 7, _141_qua_mink_a, 0, _141_qua_mink_ha }, { "mule", 7, _141_qua_mule_a, 0, _141_qua_mule_ha }, - { "scot", 7, _141_qua_scot_a, 0, 0 }, - { "scow", 7, _141_qua_scow_a, 0, 0 }, - { "slaw", 7, _141_qua_slaw_a, 0, 0 }, + { "scot", 7, _141_qua_scot_a, 0, _141_qua_scot_ha }, + { "scow", 7, _141_qua_scow_a, 0, _141_qua_scow_ha }, + { "slaw", 7, _141_qua_slaw_a, 0, _141_qua_slaw_ha }, {} }; static c3_c* _141_qua_ha[] = { From 0ca2bd824590c27003b8a3c19ef14ce55e207c8e Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 13 May 2020 16:50:13 -0700 Subject: [PATCH 071/933] jets: hook up preexisting +repn jet. The C code for +repn was written, but never hooked up. --- pkg/urbit/include/jets/w.h | 1 + pkg/urbit/jets/tree.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index 98d8e07db3..ad2a7b8269 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -66,6 +66,7 @@ u3_noun u3wc_rep(u3_noun); u3_noun u3wc_rev(u3_noun); u3_noun u3wc_rip(u3_noun); + u3_noun u3wc_repn(u3_noun); u3_noun u3wc_ripn(u3_noun); u3_noun u3wc_rsh(u3_noun); u3_noun u3wc_swp(u3_noun); diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 43c266a960..ad46a71329 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -1496,6 +1496,10 @@ static c3_c* _141_two_rip_ha[] = { "e8e0b834aded0d2738bcf38a93bf373d412a51e0cee7f274277a6393e634a65e", 0 }; +static u3j_harm _141_two_repn_a[] = {{".2", u3wc_repn, c3y}, {}}; +static c3_c* _141_two_repn_ha[] = { + 0 +}; static u3j_harm _141_two_ripn_a[] = {{".2", u3wc_ripn, c3y}, {}}; static c3_c* _141_two_ripn_ha[] = { "2759a6931e9ef9a52c8eee43108843d94d3932a6b04f86cb6ba1555343293a28", @@ -1732,6 +1736,7 @@ static u3j_core _141_two_d[] = { "rep", 7, _141_two_rep_a, 0, _141_two_rep_ha }, { "rev", 7, _141_two_rev_a, 0, _141_two_rev_ha }, { "rip", 7, _141_two_rip_a, 0, _141_two_rip_ha }, + { "repn", 7, _141_two_repn_a, 0, _141_two_repn_ha }, { "ripn", 7, _141_two_ripn_a, 0, _141_two_ripn_ha }, { "rsh", 7, _141_two_rsh_a, 0, _141_two_rsh_ha }, { "swp", 7, _141_two_swp_a, 0, _141_two_swp_ha }, From 5141dc4de9e4b2fd52945ed19035d3f0b6e82a05 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 14 May 2020 18:43:59 -0700 Subject: [PATCH 072/933] hoon: refactors +edit and +frag in +mink --- pkg/arvo/sys/hoon.hoon | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 67cdcd6199..6c3b08801d 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -6451,35 +6451,33 @@ :: ++ frag |= [axis=@ noun=*] - ^- (unit *) + ^- (unit) ?: =(0 axis) ~ - |- - ?: =(1 axis) - `noun + |- ^- (unit) + ?: =(1 axis) `noun ?@ noun ~ + =/ pick (cap axis) %= $ axis (mas axis) - noun ?: =(2 (cap axis)) - -.noun - +.noun + noun ?-(pick %2 -.noun, %3 +.noun) == :: ++ edit |= [axis=@ target=* value=*] - ^- (unit *) + ^- (unit) ?: =(1 axis) `value ?@ target ~ - =/ left=? =(2 (cap axis)) + =/ pick (cap axis) =/ mutant %= $ axis (mas axis) - target ?:(left -.target +.target) + target ?-(pick %2 -.target, %3 +.target) == ?~ mutant ~ - :- ~ - ?: left - [u.mutant +.target] - [-.target u.mutant] + ?- pick + %2 `[u.mutant +.target] + %3 `[-.target u.mutant] + == -- :: ++ mock From 7ad707edc54e5d5446994fd49b35d4888336c5a9 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 14 May 2020 17:52:23 -0700 Subject: [PATCH 073/933] hoon: adds +mole and +mure -- unitary virtualization --- pkg/arvo/sys/hoon.hoon | 16 ++++++++++++++++ pkg/urbit/include/jets/w.h | 1 + pkg/urbit/jets/e/mole.c | 16 ++++++++++++++++ pkg/urbit/jets/e/mule.c | 26 ++++++++++---------------- pkg/urbit/jets/tree.c | 5 +++++ 5 files changed, 48 insertions(+), 16 deletions(-) create mode 100644 pkg/urbit/jets/e/mole.c diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 6c3b08801d..8457947b8a 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -4046,6 +4046,7 @@ ~% %qua + == + %mure mure %mute mute %show show == @@ -6560,6 +6561,14 @@ == == -- +:: +mole: typed unitary virtual +:: +++ mole + ~/ %mole + |* tap=(trap) + ^- (unit _$:tap) + =/ mur (mure tap) + ?~(mur ~ `$:tap) :: ++ mong |= {{gat/* sam/*} gul/$-({* *} (unit (unit)))} @@ -6578,6 +6587,13 @@ %| [%| p=p.mud] == -- +:: +mure: untyped unitary virtual +:: +++ mure + |= tap=(trap) + ^- (unit) + =/ ton (mink [tap %9 2 %0 1] |=((pair) ``.*(~ [%12 1+p 1+q]))) + ?.(?=(%0 -.ton) ~ `product.ton) :: ++ mute :: untyped virtual |= taq/_=>(~ ^?(|.(**))) diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index 98d8e07db3..3d6270aedd 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -111,6 +111,7 @@ u3_noun u3we_loss(u3_noun); u3_noun u3we_lune(u3_noun); u3_noun u3we_mink(u3_noun); + u3_noun u3we_mole(u3_noun); u3_noun u3we_mule(u3_noun); u3_noun u3we_repg(u3_noun); u3_noun u3we_rexp(u3_noun); diff --git a/pkg/urbit/jets/e/mole.c b/pkg/urbit/jets/e/mole.c new file mode 100644 index 0000000000..ee32472ec4 --- /dev/null +++ b/pkg/urbit/jets/e/mole.c @@ -0,0 +1,16 @@ +/* j/5/mule.c +** +*/ +#include "all.h" + +u3_noun +u3we_mole(u3_noun cor) +{ + u3_noun hok = u3j_cook("u3we_mole-mure", u3k(cor), "mure"); + + // just like +mule and +mute, this takes advantage of the fact that + // +mure's result is identical to that of +mole, and safely produces + // a statically-typed value while only evaluating the trap once. + // + return u3n_slam_on(hok, u3k(u3x_at(u3x_sam, cor))); +} diff --git a/pkg/urbit/jets/e/mule.c b/pkg/urbit/jets/e/mule.c index 3f74b73267..f27b294fad 100644 --- a/pkg/urbit/jets/e/mule.c +++ b/pkg/urbit/jets/e/mule.c @@ -3,21 +3,15 @@ */ #include "all.h" - u3_noun - u3we_mule(u3_noun cor) - { - u3_noun tap; +u3_noun +u3we_mule(u3_noun cor) +{ + u3_noun hok = u3j_cook("u3we_mule-mute", u3k(cor), "mute"); - if ( c3n == u3r_mean(cor, u3x_sam, &tap, 0) ) { - return u3m_bail(c3__exit); - } - else { - u3_noun hok = u3j_cook("u3we_mule-mute", u3k(cor), "mute"); - /* this takes advantage of the fact that mute's result, at the typeless - * C/Nock level, is identical to what a typed mule would produce, - * without running the formula twice. - */ - return u3n_slam_on(hok, u3k(tap)); - } - } + // this takes advantage of the fact that +mute's result is + // identical to that of +mule, and safely produces a statically-typed + // value while only evaluating the trap once. + // + return u3n_slam_on(hok, u3k(u3x_at(u3x_sam, cor))); +} diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index d7171a70ff..db94b2228a 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -848,6 +848,10 @@ static u3j_harm _141_qua_mink_a[] = {{".2", u3we_mink}, {}}; static c3_c* _141_qua_mink_ha[] = { 0 }; +static u3j_harm _141_qua_mole_a[] = {{".2", u3we_mole}, {}}; +static c3_c* _141_qua_mole_ha[] = { + 0 +}; static u3j_harm _141_qua_mule_a[] = {{".2", u3we_mule}, {}}; static c3_c* _141_qua_mule_ha[] = { "d54688d726565ddade7f2636741cad7209ea40fab28d3335555d8a02ff6001c4", @@ -881,6 +885,7 @@ static u3j_core _141_qua_d[] = { "sfix", 7, _141_qua_sfix_a, 0, _141_qua_sfix_ha }, { "mink", 7, _141_qua_mink_a, 0, _141_qua_mink_ha }, + { "mole", 7, _141_qua_mole_a, 0, _141_qua_mole_ha }, { "mule", 7, _141_qua_mule_a, 0, _141_qua_mule_ha }, {} }; From dae21cdbe752e54049f9d9d9abfa4ce269cd2822 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 14 May 2020 18:30:45 -0700 Subject: [PATCH 074/933] hoon: modernizes virtualization style --- pkg/arvo/sys/hoon.hoon | 51 ++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 8457947b8a..4a65e4aecf 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -6314,11 +6314,14 @@ :: :::: 4n: virtualization :: +:: +mack: untyped, scry-less, unitary virtualization +:: ++ mack - |= {sub/* fol/*} + |= [sub=* fol=*] ^- (unit) - =+ ton=(mink [sub fol] |=({* *} ~)) - ?.(?=({$0 *} ton) ~ [~ product.ton]) + =/ ton (mink [sub fol] |~(^ ~)) + ?.(?=(%0 -.ton) ~ `product.ton) +:: +mink: raw virtual nock :: ++ mink !. ~/ %mink @@ -6480,9 +6483,10 @@ %3 `[-.target u.mutant] == -- +:: +mock: virtual nock :: ++ mock - |= {{sub/* fol/*} gul/$-({* *} (unit (unit)))} + |= [[sub=* fol=*] gul=$-(^ (unit (unit)))] (mook (mink [sub fol] gul)) :: +mook: convert $tone to %toon, rendering stack frames if present :: @@ -6569,24 +6573,23 @@ ^- (unit _$:tap) =/ mur (mure tap) ?~(mur ~ `$:tap) +:: +mong: virtual slam :: ++ mong - |= {{gat/* sam/*} gul/$-({* *} (unit (unit)))} + |= [[gat=* sam=*] gul=$-(^ (unit (unit)))] ^- toon - ?. &(?=(^ gat) ?=(^ +.gat)) - [%2 ~] + ?. ?=([* ^] gat) [%2 ~] (mock [gat(+< sam) %9 2 %0 1] gul) +:: +mule: typed virtual :: -++ mule :: typed virtual +++ mule ~/ %mule - =+ taq=|.(**) - |@ ++ $ - =+ mud=(mute taq) - ?- -.mud - %& [%& p=$:taq] - %| [%| p=p.mud] - == - -- + |* tap=(trap) + =/ mud (mute tap) + ?- -.mud + %& [%& p=$:tap] + %| [%| p=p.mud] + == :: +mure: untyped unitary virtual :: ++ mure @@ -6594,15 +6597,19 @@ ^- (unit) =/ ton (mink [tap %9 2 %0 1] |=((pair) ``.*(~ [%12 1+p 1+q]))) ?.(?=(%0 -.ton) ~ `product.ton) +:: +mute: untyped virtual :: -++ mute :: untyped virtual - |= taq/_=>(~ ^?(|.(**))) +++ mute + |= tap=(trap) ^- (each * (list tank)) - =/ ton (mock [taq %9 2 %0 1] |=((pair) ``.*(~ [%12 1+p 1+q]))) + =/ ton (mock [tap %9 2 %0 1] |=((pair) ``.*(~ [%12 1+p 1+q]))) ?- -.ton - $0 [%& p.ton] - $1 [%| (smyt (path p.ton)) ~] - $2 [%| p.ton] + %0 [%& p.ton] + :: + %1 =/ sof=(unit path) ((soft path) p.ton) + [%| ?~(sof leaf+"mute.hunk" (smyt u.sof)) ~] + :: + %2 [%| p.ton] == :: +slum: slam a gate on a sample using raw nock, untyped :: From 981f4ed99822a20818e9308f85ca39f6976e60f3 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 14 May 2020 13:23:36 -0700 Subject: [PATCH 075/933] pill: updates solid --- bin/solid.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index 19bdead6d8..c23641b108 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c746657cc34182f5e7ebdc15b68e0acfa063d211d44a38519ba95a8a056b18e9 -size 9649650 +oid sha256:94afb9973bf06ef1a1ea286b08594256abac9ee7f44ef24ca6594bc6b5d2007c +size 9650284 From 1c9e004fb4d8a9322c82fdf7259a665dfd2a90aa Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 14 May 2020 19:12:12 -0700 Subject: [PATCH 076/933] hoon: switches +soft to use +mole --- pkg/arvo/sys/hoon.hoon | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 4a65e4aecf..25f208fd7e 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -6618,15 +6618,11 @@ |= [gat=* sam=*] ^- * .*(gat [%9 2 %10 [6 %1 sam] %0 1]) +:: +soft: virtual clam :: -++ soft :: maybe remold - |* han/$-(* *) - |= fud/* ^- (unit han) - =+ result=(mule |.((han fud))) - ?- -.result - %| ~ - %& [~ p.result] - == +++ soft + |* han=$-(* *) + |=(fud=* (mole |.((han fud)))) :: :::: 4o: molds and mold builders :: From 593fcdc915da461ed41e6c328ed77d69e92874d9 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 14 May 2020 20:01:25 -0700 Subject: [PATCH 077/933] pill: solid and ivory --- bin/ivory.pill | 4 ++-- bin/solid.pill | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/ivory.pill b/bin/ivory.pill index 7556df8b8e..c49825bdbd 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:96a610c515cb656bc7e92ad9ec89de768014d1dfad7f3884ed171e947fceec52 -size 1232435 +oid sha256:61a38233c95cd8e0c0790e33c134c1aab607659a16abce22e85f56b6c77b19c5 +size 1232440 diff --git a/bin/solid.pill b/bin/solid.pill index c23641b108..ed55f21d40 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:94afb9973bf06ef1a1ea286b08594256abac9ee7f44ef24ca6594bc6b5d2007c -size 9650284 +oid sha256:df7e73129cc484fba44301eec4230b9ec3dc533163db36b885074ff8b018b6c8 +size 9650082 From 8f79e50640bd637533da11ed7d326bb2efe35da7 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 20 May 2020 12:07:48 -0700 Subject: [PATCH 078/933] hoon: clean up +mook comments --- pkg/arvo/sys/hoon.hoon | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 25f208fd7e..2a83216fb0 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -6488,7 +6488,7 @@ ++ mock |= [[sub=* fol=*] gul=$-(^ (unit (unit)))] (mook (mink [sub fol] gul)) -:: +mook: convert $tone to %toon, rendering stack frames if present +:: +mook: convert $tone to $toon, rendering stack frames :: ++ mook |= ton=tone @@ -6510,19 +6510,11 @@ :: :: +rend: raw stack frame to tank :: - :: supported frame types: - :: - :: $% :: %hunk: failed scry ([~ ~]) - :: :: %lose: skipped frames - :: :: %hand: mug any - :: :: %mean: ~_ - :: :: %spot: source location - :: :: - :: [%hunk ref=* path] - :: [%lose cord] - :: [%hand *] - :: [%mean $@(cord (trap tank))] - :: [%spot spot] + :: $% [%hunk ref=* path] :: failed scry ([~ ~]) + :: [%lose cord] :: skipped frames + :: [%hand *] :: mug any + :: [%mean $@(cord (trap tank))] :: ~_ et al + :: [%spot spot] :: source location :: == :: ++ rend From 1be3552eb27fe5393387d2c27f4fd8c2920fc3d4 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 20 May 2020 13:12:12 -0700 Subject: [PATCH 079/933] jets: fix broken jets so ~marzod can boot. This fixes an off by one error in ship name printing, and disables the +apt:{by,in} jets. I've tried debugging the +apt jets and am making no progress other than finding a bug in the recursion; this isn't enough to get ~marzod to boot, though. --- pkg/urbit/jets/d/by_apt.c | 15 ++++++++------- pkg/urbit/jets/d/in_apt.c | 13 +++++++------ pkg/urbit/jets/e/scow.c | 2 +- pkg/urbit/jets/tree.c | 4 ++-- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/pkg/urbit/jets/d/by_apt.c b/pkg/urbit/jets/d/by_apt.c index c580087d4b..e8e7278bdd 100644 --- a/pkg/urbit/jets/d/by_apt.c +++ b/pkg/urbit/jets/d/by_apt.c @@ -3,6 +3,7 @@ */ #include "all.h" +// l and r are keys, p.n.a-s. static c3_o _by_apt(u3_noun a, u3_noun l, u3_noun r) { @@ -18,7 +19,7 @@ c3_o _by_apt(u3_noun a, u3_noun l, u3_noun r) if ( u3_nul != l ) { u3_noun u_l; u3x_cell(l, 0, &u_l); - if (!_(u3qc_gor(p_n_a, u_l))) { + if (c3n == u3qc_gor(p_n_a, u_l)) { return c3n; } if (c3y == u3r_sing(p_n_a, u_l)) { @@ -29,7 +30,7 @@ c3_o _by_apt(u3_noun a, u3_noun l, u3_noun r) if ( u3_nul != r ) { u3_noun u_r; u3x_cell(r, 0, &u_r); - if (!_(u3qc_gor(u_r, p_n_a))) { + if (c3n == u3qc_gor(u_r, p_n_a)) { return c3n; } if (c3y == u3r_sing(u_r, p_n_a)) { @@ -43,14 +44,14 @@ c3_o _by_apt(u3_noun a, u3_noun l, u3_noun r) u3x_trel(l_a, &n_l_a, &l_l_a, &r_l_a); u3x_cell(n_l_a, &p_n_l_a, 0); - if (!_(u3qc_mor(p_n_a, p_n_l_a))) { + if (c3n == u3qc_mor(p_n_a, p_n_l_a)) { return c3n; } if (c3y == u3r_sing(p_n_a, p_n_l_a)) { return c3n; } u3_noun nu_l = u3nc(0, p_n_a); - if (!_(_by_apt(l_a, nu_l, 0))) { + if (c3n == _by_apt(l_a, nu_l, r)) { u3z(nu_l); return c3n; } @@ -63,14 +64,14 @@ c3_o _by_apt(u3_noun a, u3_noun l, u3_noun r) u3x_trel(r_a, &n_r_a, &l_r_a, &r_r_a); u3x_cell(n_r_a, &p_n_r_a, 0); - if (!_(u3qc_mor(p_n_a, p_n_r_a))) { + if (c3n == u3qc_mor(p_n_a, p_n_r_a)) { return c3n; } if (c3y == u3r_sing(p_n_a, p_n_r_a)) { return c3n; } u3_noun nu_r = u3nc(0, p_n_a); - if (!_(_by_apt(r_a, 0, nu_r))) { + if (c3n == _by_apt(r_a, l, nu_r)) { u3z(nu_r); return c3n; } @@ -80,7 +81,7 @@ c3_o _by_apt(u3_noun a, u3_noun l, u3_noun r) return c3y; } - +// TODO: +apt:in and +apt:by are disabled since it breaks ames in some way? u3_noun u3wdb_apt(u3_noun cor) { diff --git a/pkg/urbit/jets/d/in_apt.c b/pkg/urbit/jets/d/in_apt.c index fe041c77fa..bcc4882c8e 100644 --- a/pkg/urbit/jets/d/in_apt.c +++ b/pkg/urbit/jets/d/in_apt.c @@ -16,7 +16,7 @@ c3_o _in_apt(u3_noun a, u3_noun l, u3_noun r) if ( u3_nul != l ) { u3_noun u_l; u3x_cell(l, 0, &u_l); - if (!_(u3qc_gor(n_a, u_l))) { + if (c3n == u3qc_gor(n_a, u_l)) { return c3n; } } @@ -24,7 +24,7 @@ c3_o _in_apt(u3_noun a, u3_noun l, u3_noun r) if ( u3_nul != r ) { u3_noun u_r; u3r_cell(r, 0, &u_r); - if (!_(u3qc_gor(u_r, n_a))) { + if (c3n == u3qc_gor(u_r, n_a)) { return c3n; } } @@ -32,11 +32,11 @@ c3_o _in_apt(u3_noun a, u3_noun l, u3_noun r) if ( u3_nul != l_a ) { u3_noun n_l_a, l_l_a, r_l_a; u3x_trel(l_a, &n_l_a, &l_l_a, &r_l_a); - if (!_(u3qc_mor(n_a, n_l_a))) { + if (c3n == u3qc_mor(n_a, n_l_a)) { return c3n; } u3_noun nu_l = u3nc(0, n_a); - if (!_(_in_apt(l_a, nu_l, 0))) { + if (c3n == _in_apt(l_a, nu_l, r)) { u3z(nu_l); return c3n; } @@ -46,11 +46,11 @@ c3_o _in_apt(u3_noun a, u3_noun l, u3_noun r) if ( u3_nul != r_a ) { u3_noun n_r_a, l_r_a, r_r_a; u3x_trel(r_a, &n_r_a, &l_r_a, &r_r_a); - if (!_(u3qc_mor(n_a, n_r_a))) { + if (c3n == u3qc_mor(n_a, n_r_a)) { return c3n; } u3_noun nu_r = u3nc(0, n_a); - if (!_(_in_apt(r_a, 0, nu_r))) { + if (c3n == _in_apt(r_a, l, nu_r)) { u3z(nu_r); return c3n; } @@ -60,6 +60,7 @@ c3_o _in_apt(u3_noun a, u3_noun l, u3_noun r) return c3y; } +// TODO: +apt:in and +apt:by are disabled since it breaks ames in some way? u3_noun u3wdi_apt(u3_noun cor) { diff --git a/pkg/urbit/jets/e/scow.c b/pkg/urbit/jets/e/scow.c index 38278105ec..2d41502928 100644 --- a/pkg/urbit/jets/e/scow.c +++ b/pkg/urbit/jets/e/scow.c @@ -190,7 +190,7 @@ _print_p(u3_atom cor, u3_atom p) u3_atom sxz = u3n_slam_on(hok, u3k(p)); // Simple galaxy case - if (c3y == u3qa_lte(sxz, 256)) { + if (c3y == u3qa_lth(sxz, 256)) { c3_y a, b, c; u3_po_to_suffix(sxz, &a, &b, &c); u3z(sxz); diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index b790aa868f..d28b83e6f3 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -1619,7 +1619,7 @@ static c3_c* _141_two_xeb_ha[] = { }; static u3j_core _141_two__in_d[] = - { { "apt", 7, _141_two__in_apt_a, 0, _141_two__in_apt_ha }, + { // { "apt", 7, _141_two__in_apt_a, 0, _141_two__in_apt_ha }, { "bif", 7, _141_two__in_bif_a, 0, _141_two__in_bif_ha }, { "del", 7, _141_two__in_del_a, 0, _141_two__in_del_ha }, { "dif", 7, _141_two__in_dif_a, 0, _141_two__in_dif_ha }, @@ -1728,7 +1728,7 @@ static c3_c* _141_two__in_ha[] = { static u3j_core _141_two__by_d[] = { { "all", 7, _141_two__by_all_a, 0, _141_two__by_all_ha }, { "any", 7, _141_two__by_any_a, 0, _141_two__by_any_ha }, - { "apt", 7, _141_two__by_apt_a, 0, _141_two__by_apt_ha }, + // { "apt", 7, _141_two__by_apt_a, 0, _141_two__by_apt_ha }, { "bif", 7, _141_two__by_bif_a, 0, _141_two__by_bif_ha }, { "del", 7, _141_two__by_del_a, 0, _141_two__by_del_ha }, { "dif", 7, _141_two__by_dif_a, 0, _141_two__by_dif_ha }, From a7168478f3daed9df6db089cb1acbd648422486a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 20 May 2020 17:20:51 -0700 Subject: [PATCH 080/933] gall: cleans up blocked-scry handling in %gall virtualization --- bin/solid.pill | 2 +- pkg/arvo/sys/vane/gall.hoon | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index eae8d462dc..3ba74e4e18 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:20219ec89d58a89285733db183b89e5f19e5bb7764bed43218c0c83902dd1e56 +oid sha256:f850ff15c0dff1814039240e00dc0ebe8d8328064e76faaa24d06df348b89078 size 12878034 diff --git a/pkg/arvo/sys/vane/gall.hoon b/pkg/arvo/sys/vane/gall.hoon index 50432b9879..2f87d12d34 100644 --- a/pkg/arvo/sys/vane/gall.hoon +++ b/pkg/arvo/sys/vane/gall.hoon @@ -1453,7 +1453,7 @@ =/ res (mock [run %9 2 %0 1] (sloy ski)) ?- -.res %0 [%& !<(step:agent [-:!>(*step:agent) p.res])] - %1 [%.n (smyt (path p.res)) ~] + %1 [%| (smyt ;;(path p.res)) ~] %2 [%| p.res] == :: +ap-mule-peek: same as +ap-mule but for (unit (unit cage)) @@ -1464,7 +1464,7 @@ =/ res (mock [run %9 2 %0 1] (sloy ski)) ?- -.res %0 [%& !<((unit (unit cage)) [-:!>(*(unit (unit cage))) p.res])] - %1 [%.n (smyt (path p.res)) ~] + %1 [%| (smyt ;;(path p.res)) ~] %2 [%| p.res] == :: +ap-ingest: call agent arm From a5f779d8f9f124a339dfcc5a681e3ee4d38c7a06 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 21 May 2020 14:28:06 -0700 Subject: [PATCH 081/933] test: adds trivial unit tests for nock 6 invariants --- pkg/arvo/tests/sys/hoon/mock.hoon | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 pkg/arvo/tests/sys/hoon/mock.hoon diff --git a/pkg/arvo/tests/sys/hoon/mock.hoon b/pkg/arvo/tests/sys/hoon/mock.hoon new file mode 100644 index 0000000000..411ffa592f --- /dev/null +++ b/pkg/arvo/tests/sys/hoon/mock.hoon @@ -0,0 +1,32 @@ +/+ *test +|% +:: nock 6 should allow invalid formulas in unevaluated branches +:: +++ test-conditional-skips + ;: weld + %+ expect-eq + !> 43 + !> .*(~ [%6 [%1 1] 0 [%1 43]]) + :: + %- expect-fail + |. .*(~ [%6 [%1 0] 0 [%1 43]]) + :: + %+ expect-eq + !> 42 + !> .*(~ [%6 [%1 0] [%1 42] 0]) + :: + %- expect-fail + |. .*(~ [%6 [%1 1] [%1 42] 0]) + :: + %+ expect-eq + !> 42 + !> .*(~ [%6 [%1 0] [%1 42] %1 43]) + :: + %+ expect-eq + !> 43 + !> .*(~ [%6 [%1 1] [%1 42] %1 43]) + :: + %- expect-fail + |. .*(~ [%6 [%1 2] [%1 42] %1 43]) + == +-- From 3df005ad50d250c8cd6a595d1e38b0ec21b23d7a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 21 May 2020 14:29:04 -0700 Subject: [PATCH 082/933] u3: fixes bug in nock 6 compilation (increment uninitialized) --- pkg/urbit/noun/nock.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/urbit/noun/nock.c b/pkg/urbit/noun/nock.c index ec1a35498a..808c0affec 100644 --- a/pkg/urbit/noun/nock.c +++ b/pkg/urbit/noun/nock.c @@ -1290,14 +1290,14 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) yep_w = _n_comp(&yep, mid, los_o, tel_o); } else { - ++yep_w; _n_emit(&yep, BAIL); + yep_w = 1; _n_emit(&yep, BAIL); } if ( nop_t ) { - nop_w = _n_comp(&nop, tel, los_o, tel_o); + nop_w = _n_comp(&nop, tel, los_o, tel_o); } else { - ++nop_w; _n_emit(&nop, BAIL); + nop_w = 1; _n_emit(&nop, BAIL); } // SBIP and SBIN get sized during assembly From b224ac087815e6fb01d63877da966e3bc4202c71 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 25 Jun 2020 20:20:57 +0200 Subject: [PATCH 083/933] ames: improve scry interface No longer abuse the desk field, instead making use of the path. Reject any scries outside of the local ship, empty desk and current time as invalid. --- pkg/arvo/app/dbug.hoon | 4 ++-- pkg/arvo/sys/vane/ames.hoon | 43 +++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/pkg/arvo/app/dbug.hoon b/pkg/arvo/app/dbug.hoon index 320a03dbae..16c052b34b 100644 --- a/pkg/arvo/app/dbug.hoon +++ b/pkg/arvo/app/dbug.hoon @@ -491,11 +491,11 @@ ++ v-ames |% ++ peers - (scry (map ship ?(%alien %known)) %a %peers ~) + (scry (map ship ?(%alien %known)) %ax %$ /peers) :: ++ peer |= who=ship - (scry ship-state:ames %a %peer /(scot %p who)) + (scry ship-state:ames %ax %$ /peers/(scot %p who)) :: ++ peer-to-json =, ames diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index 0baaccccac..4acabf3cef 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -691,35 +691,37 @@ -- :: +scry: dereference namespace :: -:: The ones producing vases are expected to be used like this: -:: -:: &tang [(sell .^(vase %a /=peer=/~zod)) ~] -:: ++ scry |= [fur=(unit (set monk)) ren=@tas why=shop syd=desk lot=coin tyl=path] ^- (unit (unit cage)) - ?. =(lot [%$ %da now]) ~ - ?. =(%$ ren) [~ ~] - ?. =([%& our] why) - [~ ~] - ?+ syd ~ - %peers - ?^ tyl [~ ~] + :: only respond for the local identity, %$ desk, current timestamp + :: + ?. ?& =(&+our why) + =([%$ %da now] lot) + =(%$ syd) + == + ~ + :: /ax/peers (map ship ?(%alien known)) + :: /ax/peers/[ship] ship-state + :: /ax/bones/[ship] [snd=(set bone) rcv=(set bone)] + :: /ax/snd-bones/[ship]/[bone] vase + :: + ?. ?=(%x ren) ~ + ?+ tyl [~ ~] + [%peers ~] :^ ~ ~ %noun !> ^- (map ship ?(%alien %known)) (~(run by peers.ames-state) head) :: - %peer - ?. ?=([@ ~] tyl) [~ ~] - =/ who (slaw %p i.tyl) + [%peers @ ~] + =/ who (slaw %p i.t.tyl) ?~ who [~ ~] ?~ peer=(~(get by peers.ames-state) u.who) [~ ~] ``noun+!>(u.peer) :: - %bones - ?. ?=([@ ~] tyl) [~ ~] - =/ who (slaw %p i.tyl) + [%bones @ ~] + =/ who (slaw %p i.t.tyl) ?~ who [~ ~] =/ per (~(get by peers.ames-state) u.who) ?. ?=([~ %known *] per) [~ ~] @@ -728,11 +730,10 @@ [snd=~(key by snd) rcv=~(key by rcv)] ``noun+!>(res) :: - %snd-bone - ?. ?=([@ @ ~] tyl) [~ ~] - =/ who (slaw %p i.tyl) + [%snd-bones @ @ ~] + =/ who (slaw %p i.t.tyl) ?~ who [~ ~] - =/ ost (slaw %ud i.t.tyl) + =/ ost (slaw %ud i.t.t.tyl) ?~ ost [~ ~] =/ per (~(get by peers.ames-state) u.who) ?. ?=([~ %known *] per) [~ ~] From 55447845918e1a749dcde7a6aa40c5a856e29a75 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 25 Jun 2020 21:34:39 +0200 Subject: [PATCH 084/933] vere: scry ames protocol version out of arvo Instead of assuming 0. We still use 0 in the fallback case for now. --- pkg/arvo/sys/vane/ames.hoon | 4 ++++ pkg/urbit/vere/io/ames.c | 42 ++++++++++++++++++++++++++++++++----- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index 4acabf3cef..4d80fa748f 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -701,6 +701,7 @@ =(%$ syd) == ~ + :: /ax/protocol/version @ :: /ax/peers (map ship ?(%alien known)) :: /ax/peers/[ship] ship-state :: /ax/bones/[ship] [snd=(set bone) rcv=(set bone)] @@ -708,6 +709,9 @@ :: ?. ?=(%x ren) ~ ?+ tyl [~ ~] + [%protocol %version ~] + ``noun+!>(protocol-version) + :: [%peers ~] :^ ~ ~ %noun !> ^- (map ship ?(%alien %known)) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 41f6edaa11..dd4e72a82d 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -42,6 +42,8 @@ c3_w imp_w[256]; // imperial IPs time_t imp_t[256]; // imperial IP timestamps c3_o imp_o[256]; // imperial print status + c3_o fit_o; // filtering active + c3_y ver_y; // protocol version } u3_ames; /* _ames_alloc(): libuv buffer allocator. @@ -368,12 +370,11 @@ _ames_recv_cb(uv_udp_t* wax_u, { u3_ames* sam_u = wax_u->data; - // data present, and protocol version in header matches 0 + // data present, and protocol version in header matches ours // - // XX inflexible, scry version out of ames - // - if ( (0 < nrd_i) - && (0 == (0x7 & *((c3_w*)buf_u->base))) ) + if ( (0 < nrd_i) + && ( (c3n == sam_u->fit_o) + || (sam_u->ver_y == (0x7 & *((c3_w*)buf_u->base))) ) ) { u3_noun wir = u3nc(c3__ames, u3_nul); u3_noun cad; @@ -701,6 +702,31 @@ _ames_io_exit(u3_auto* car_u) uv_close(&sam_u->had_u, _ames_exit_cb); } +/* _ames_prot_scry_cb(): receive protocol version +*/ +static void +_ames_prot_scry_cb(void* vod_p, u3_noun nun) +{ + u3_ames* sam_u = vod_p; + u3_weak ver = u3r_at(7, nun); + + if (u3_none == ver) { + // assume protocol version 0 + // + sam_u->ver_y = 0; + } + else if ( (c3n == u3a_is_cat(ver)) + || (7 < ver) ) { + u3m_p("ames: strange protocol", ver); + sam_u->ver_y = 0; + } + else { + sam_u->ver_y = ver; + } + + sam_u->fit_o = c3y; +} + /* u3_ames_io_init(): initialize ames I/O. */ u3_auto* @@ -712,6 +738,7 @@ u3_ames_io_init(u3_pier* pir_u) sam_u->por_s = pir_u->por_s; sam_u->fak_o = pir_u->fak_o; sam_u->dop_d = 0; + sam_u->fit_o = c3n; c3_assert( !uv_udp_init(u3L, &sam_u->wax_u) ); sam_u->wax_u.data = sam_u; @@ -722,6 +749,11 @@ u3_ames_io_init(u3_pier* pir_u) u3_Host.ops_u.net = c3n; } + // scry the protocol version out of arvo + // + u3_lord_peek_last(pir_u->god_u, u3_nul, c3_s2('a', 'x'), u3_nul, + u3nt(u3i_string("protocol"), u3i_string("version"), u3_nul), + sam_u, _ames_prot_scry_cb); u3_auto* car_u = &sam_u->car_u; car_u->nam_m = c3__ames; From 31d776c50bafb77463a3314c1878e6af8ec4e3a1 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 24 Jun 2020 16:26:32 +0200 Subject: [PATCH 085/933] arvo: allow the empty desk (%$) in scries +slaw fails to parse empty strings as %tas, so we special-case it here. --- pkg/arvo/sys/arvo.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index 0bbf9622f8..3cd0181997 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -191,7 +191,7 @@ ?. ?=({@ @ @ @ *} u.pux) ~ =+ :* hyr=(slaw %tas i.u.pux) fal=(slaw %p i.t.u.pux) - dyc=(slaw %tas i.t.t.u.pux) + dyc=?~(i.t.t.u.pux (some %$) (slaw %tas i.t.t.u.pux)) ved=(slay i.t.t.t.u.pux) tyl=t.t.t.t.u.pux == From 92beeca9f0349dd96ada2ff3985ad5d598681361 Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 3 Jul 2020 00:51:54 +0200 Subject: [PATCH 086/933] ames: add scry endpoint for forward lane Finds the lane for that peer, or their galaxy. Intended for use in the runtime, to enable stateless forwarding. --- pkg/arvo/sys/vane/ames.hoon | 40 +++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index 4d80fa748f..a8f91372d6 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -701,14 +701,15 @@ =(%$ syd) == ~ - :: /ax/protocol/version @ - :: /ax/peers (map ship ?(%alien known)) - :: /ax/peers/[ship] ship-state - :: /ax/bones/[ship] [snd=(set bone) rcv=(set bone)] - :: /ax/snd-bones/[ship]/[bone] vase + :: /ax/protocol/version @ + :: /ax/peers (map ship ?(%alien known)) + :: /ax/peers/[ship] ship-state + :: /ax/peers/[ship]/forward-lane (unit lane) + :: /ax/bones/[ship] [snd=(set bone) rcv=(set bone)] + :: /ax/snd-bones/[ship]/[bone] vase :: ?. ?=(%x ren) ~ - ?+ tyl [~ ~] + ?+ tyl ~ [%protocol %version ~] ``noun+!>(protocol-version) :: @@ -717,12 +718,35 @@ !> ^- (map ship ?(%alien %known)) (~(run by peers.ames-state) head) :: - [%peers @ ~] + [%peers @ *] =/ who (slaw %p i.t.tyl) ?~ who [~ ~] ?~ peer=(~(get by peers.ames-state) u.who) [~ ~] - ``noun+!>(u.peer) + ?+ t.t.tyl [~ ~] + ~ ``noun+!>(u.peer) + :: + [%forward-lane ~] + ::TODO (list lane) instead? + ::TODO refactor wrt +send-blob to share routing logic + :: find lane for u.who, or their galaxy + :: + :^ ~ ~ %noun + !> ^- (unit lane) + =/ ship-state (~(get by peers.ames-state) u.who) + ?. ?=([~ %known *] ship-state) + ~ + =/ peer-state +.u.ship-state + ?. =(~ route.peer-state) ::NOTE avoid tmi + `lane:(need route.peer-state) + |- ^- (unit lane) + ?: ?=(%czar (clan:title sponsor.peer-state)) + `[%& sponsor.peer-state] + =/ next (~(get by peers.ames-state) sponsor.peer-state) + ?. ?=([~ %known *] next) + ~ + $(peer-state +.u.next) + == :: [%bones @ ~] =/ who (slaw %p i.t.tyl) From 70bdc4a67540f5babeffe50cdff0c758a23dbc1c Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 3 Jul 2020 01:08:10 +0200 Subject: [PATCH 087/933] vere: account for scry callback changes --- pkg/urbit/vere/io/ames.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 7c3b2c62a8..9cb1b32751 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -712,7 +712,7 @@ static void _ames_prot_scry_cb(void* vod_p, u3_noun nun) { u3_ames* sam_u = vod_p; - u3_weak ver = u3r_at(7, nun); + u3_weak ver = u3r_at(15, nun); //TODO nun is [~ %noun ~ x] now? if (u3_none == ver) { // assume protocol version 0 @@ -721,7 +721,7 @@ _ames_prot_scry_cb(void* vod_p, u3_noun nun) } else if ( (c3n == u3a_is_cat(ver)) || (7 < ver) ) { - u3m_p("ames: strange protocol", ver); + u3m_p("ames: strange protocol", nun); sam_u->ver_y = 0; } else { From 95d90a362ee1a4b5c3a10c9274ef9ecc8c995829 Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 3 Jul 2020 01:14:03 +0200 Subject: [PATCH 088/933] vere: initial stateless forwarding in ames.c When receiving a packet for which we are not the recipient, attempt to forward it statelessly. This means scrying a lane for the recipient out of ames, then (if necessary) updating the origin lane in the packet and sending the updates packet over the lane resulting from the scry. Remaining work listed among the TODOs: - implement a cap on the amount of pending to-forward packets we hold, - handle version mismatches in the sponsee case, - track counters around filtering & forwarding packets, - test for memory leaks more aggressively. --- pkg/urbit/vere/io/ames.c | 316 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 293 insertions(+), 23 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 9cb1b32751..80e3f98873 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -30,6 +30,7 @@ */ typedef struct _u3_ames { // packet network state u3_auto car_u; // driver + u3_pier* pir_u; // pier union { // uv_udp_t wax_u; // uv_handle_t had_u; // @@ -43,10 +44,41 @@ c3_w imp_w[256]; // imperial IPs time_t imp_t[256]; // imperial IP timestamps c3_o imp_o[256]; // imperial print status + c3_o see_o; // can scry c3_o fit_o; // filtering active c3_y ver_y; // protocol version } u3_ames; +/* u3_head: ames packet header +*/ + typedef struct _u3_head { + c3_y ver_y; // protocol version + c3_l mug_l; // truncated mug hash of u3_body + c3_y sac_y; // sender class + c3_y rac_y; // receiver class + c3_o enc_o; // encrypted? + } u3_head; + +/* u3_body: ames packet body +*/ + typedef struct _u3_body { + u3_noun sen; // sender + u3_noun rec; // receiver + u3_noun con; // (jam [origin content]) + } u3_body; + +/* u3_panc: deconstructed incoming packet +*/ + typedef struct _u3_panc { + u3_ames* sam_u; // ames backpointer + u3_noun ore; // origin lane + u3_head hed_u; // header + u3_body bod_u; // body + } u3_panc; + +//TODO cap forwarding queue, maintain a counter. +// keep linked list in u3_ames for garbage collection, cancelling on-exit + /* _ames_alloc(): libuv buffer allocator. */ static void @@ -72,6 +104,27 @@ _ames_pact_free(u3_pact* pac_u) c3_free(pac_u); } +/* _ames_panc_free(): lose refcounts and free struct +*/ +static void +_ames_panc_free(u3_panc* pac_u) { + u3z(pac_u->ore); + u3z(pac_u->bod_u.sen); + u3z(pac_u->bod_u.rec); + u3z(pac_u->bod_u.con); + c3_free(pac_u); +} + +/* _ca_mug_body(): truncated mug hash of bytes +*/ +static c3_l +_ca_mug_body(c3_w len_w, c3_y* byt_y) +{ + // mask off ((1 << 20) - 1) + // + return u3r_mug_bytes(byt_y, len_w) & 0xfffff; +} + /* _ames_send_cb(): send callback. */ static void @@ -234,6 +287,49 @@ u3_ames_encode_lane(u3_lane lan) { return u3ke_jam(u3nt(c3__ipv4, u3i_words(1, &lan.pip_w), lan.por_s)); } +/* _ames_lane_from_sockaddr(): sockaddr_in to lane noun +*/ +static u3_noun +_ames_lane_from_sockaddr(struct sockaddr_in* add_u) +{ + u3_lane lan_u; + lan_u.por_s = ntohs(add_u->sin_port); + lan_u.pip_w = ntohl(add_u->sin_addr.s_addr); + return u3_ames_encode_lane(lan_u); +} + +/* _ames_serialize_packet(): u3_panc to atom (retains pac_u) +*/ +static u3_noun +_ames_serialize_packet(u3_panc* pac_u) +{ + u3_body* bod_u = &pac_u->bod_u; + c3_w bod_w = u3r_met(3, bod_u->con); + + u3_head* hed_u = &pac_u->hed_u; + c3_w hed_w = hed_u->ver_y + | (hed_u->mug_l << 3) + | (hed_u->sac_y << 23) + | (hed_u->rac_y << 25) + | (hed_u->enc_o << 26); + + c3_y sen_y = 2 << hed_u->sac_y; + c3_y rec_y = 2 << hed_u->rac_y; + + // allocate, then write: header (4 bytes), sender, recipient, body + // + c3_y* pac_y = c3_malloc( 4 + sen_y + rec_y + bod_w ); + memcpy(pac_y, &hed_w, 4); + u3r_bytes(0, sen_y, pac_y + 4, bod_u->sen); + u3r_bytes(0, rec_y, pac_y + 4 + sen_y, bod_u->rec); + u3r_bytes(0, bod_w, pac_y + 4 + sen_y + rec_y, bod_u->con); + + u3_noun pac = u3i_bytes(4 + sen_y + rec_y + bod_w, pac_y); + + c3_free(pac_y); + return pac; +} + /* _ames_czar(): galaxy address resolution. */ static void @@ -437,6 +533,105 @@ _ames_hear_bail(u3_ovum* egg_u, u3_noun lud) u3_ovum_free(egg_u); } +/* _ames_put_packet(): add packet to queue, drop old packets on pressure +*/ +static void +_ames_put_packet(u3_ames* sam_u, + u3_noun msg, + u3_noun lan) +{ + u3_noun wir = u3nc(c3__ames, u3_nul); + u3_noun cad = u3nt(c3__hear, u3nc(c3n, lan), msg); // trnasfer, unchanged + + u3_auto_peer( + u3_auto_plan(&sam_u->car_u, + u3_ovum_init(0, c3__a, wir, cad)), + 0, 0, _ames_hear_bail); + + _ames_cap_queue(sam_u); +} + +/* _ames_forward(): forward pac_u onto lan +*/ +static void +_ames_forward(u3_panc* pac_u, u3_noun lan) +{ + c3_o nal = c3n; + + // repack the maybe-updated packet + // + { + // unpack (jam [(unit lane) body]) + // + u3_noun lon, bod; + { + u3_noun old = u3ke_cue(pac_u->bod_u.con); + u3x_cell(old, &lon, &bod); + u3k(lon); u3k(bod); + u3z(old); + } + + // only replace the lane if it was ~ + // + if (u3_nul == lon) { + u3z(lon); + lon = u3nt(u3_nul, c3n, u3k(pac_u->ore)); + //TODO ore is always opaque lane. what about the sender=galaxy case? + nal = c3y; + } + + pac_u->bod_u.con = u3ke_jam(u3nc(lon, bod)); + } + + // if we updated the origin lane, serialize the body to update the mug hash + // + //TODO refactor into serialize_packet? + if (c3y == nal) { + c3_w bod_w = u3r_met(3, pac_u->bod_u.con); + c3_y sen_y = 2 << pac_u->hed_u.sac_y; + c3_y rec_y = 2 << pac_u->hed_u.rac_y; + c3_y* bod_y = c3_malloc(sen_y + rec_y + bod_w); + u3r_bytes(0, sen_y, bod_y, pac_u->bod_u.sen); + u3r_bytes(0, rec_y, bod_y + sen_y, pac_u->bod_u.rec); + u3r_bytes(0, bod_w, bod_y + sen_y + rec_y, pac_u->bod_u.con); + u3_noun bod = u3i_bytes(sen_y + rec_y + bod_w, bod_y); + + pac_u->hed_u.mug_l = u3r_mug(bod) & ((1 << 20) - 1); + + c3_free(bod_y); + u3z(bod); + } + + u3l_log("ames: forwarding!\n"); + _ames_ef_send(pac_u->sam_u, lan, _ames_serialize_packet(pac_u)); +} + +/* _ames_lane_scry_cb(): learn lane to forward packet on +*/ +static void +_ames_lane_scry_cb(void* vod_p, u3_noun nun) +{ + u3_panc* pac_u = vod_p; + u3_weak lan = u3r_at(15, nun); //TODO why [~ %noun ~ lane] + + // if scry fails, remember we can't scry, and just inject the packet + // + if (u3_none == lan) { + u3l_log("ames: giving up scry\n"); + pac_u->sam_u->see_o = c3n; + _ames_put_packet(pac_u->sam_u, _ames_serialize_packet(pac_u), pac_u->ore); + } + // if there is a lane, forward the packet on it + // + else if (u3_nul != lan) { + _ames_forward(pac_u, u3k(u3t(lan))); + } + // if there is no lane, drop the packet + + _ames_panc_free(pac_u); + u3z(nun); +} + /* _ames_recv_cb(): receive callback. */ static void @@ -448,37 +643,110 @@ _ames_recv_cb(uv_udp_t* wax_u, { u3_ames* sam_u = wax_u->data; - // data present, and protocol version in header matches ours + c3_o pas_o = c3y; + + // ensure a sane message size // - if ( (0 < nrd_i) - && ( (c3n == sam_u->fit_o) - || (sam_u->ver_y == (0x7 & *((c3_w*)buf_u->base))) ) ) + if (4 >= nrd_i) { + pas_o = c3n; + } + + // ensure the protocol version matches ours + // + if ( c3y == pas_o + && (c3y == sam_u->fit_o) + && (sam_u->ver_y != (0x7 & *((c3_w*)buf_u->base))) ) { - u3_noun wir = u3nc(c3__ames, u3_nul); - u3_noun cad; + pas_o = c3n; + //TODO counter + //TODO unless sender is our sponsee (transitively?) + //TODO how does this interact with forwards? + } + if (c3y == pas_o) { + c3_y* byt_y = (c3_y*)buf_u->base; + c3_y* bod_y = byt_y + 4; + u3_head hed_u; + + // unpack the packet header + // { - u3_noun msg = u3i_bytes((c3_w)nrd_i, (c3_y*)buf_u->base); - u3_noun lan; + c3_w hed_w = (byt_y[0] << 0) + | (byt_y[1] << 8) + | (byt_y[2] << 16) + | (byt_y[3] << 24); - { - struct sockaddr_in* add_u = (struct sockaddr_in *)adr_u; - u3_lane lan_u; - - lan_u.por_s = ntohs(add_u->sin_port); - lan_u.pip_w = ntohl(add_u->sin_addr.s_addr); - lan = u3_ames_encode_lane(lan_u); - } - - cad = u3nt(c3__hear, u3nc(c3n, lan), msg); + hed_u.ver_y = hed_w & 0x7; + hed_u.mug_l = (hed_w >> 3) & ((1 << 20) - 1); + hed_u.sac_y = (hed_w >> 23) & 0x3; + hed_u.rac_y = (hed_w >> 25) & 0x3; + hed_u.enc_o = (hed_w >> 26) & 0x1; } - u3_auto_peer( - u3_auto_plan(&sam_u->car_u, - u3_ovum_init(0, c3__a, wir, cad)), - 0, 0, _ames_hear_bail); + // ensure the mug is valid + // + if ( hed_u.mug_l != _ca_mug_body(nrd_i - 4, bod_y) ) { + pas_o = c3n; + //TODO counter? + } + // if we can scry, we might want to forward statelessly + // + else if (c3y == sam_u->see_o) { + c3_y sen_y = 2 << hed_u.sac_y; + c3_y rec_y = 2 << hed_u.rac_y; - _ames_cap_queue(sam_u); + u3_noun sen = u3i_bytes(sen_y, bod_y); + u3_noun rec = u3i_bytes(rec_y, bod_y + sen_y); + + c3_d rec_d[2]; + u3r_chubs(0, 2, rec_d, rec); + + // if we are not the recipient, attempt to forward statelessly + // + if ( (rec_d[0] != sam_u->who_d[0]) + || (rec_d[1] != sam_u->who_d[1]) ) + { + pas_o = c3n; + //TODO counter? + + // store the packet details for later processing + // + u3_noun con = u3i_bytes(nrd_i - 4 - sen_y - rec_y, + bod_y + sen_y + rec_y); + u3_panc* pac_u = c3_calloc(sizeof(*pac_u)); + pac_u->sam_u = sam_u; + pac_u->hed_u = hed_u; + pac_u->bod_u.sen = sen; + pac_u->bod_u.rec = rec; + pac_u->bod_u.con = con; + pac_u->ore = _ames_lane_from_sockaddr((struct sockaddr_in *)adr_u); + + // if the recipient is a galaxy, their lane is always &+~gax + // + if ( (c3y == u3a_is_cat(rec)) + && (256 > rec) ) { + _ames_forward(pac_u, u3nc(c3y, u3k(rec))); + } + // otherwise, scry the lane out of ames + // + else { + u3_noun pax = u3nq(u3i_string("peers"), + u3dc("scot", 'p', u3k(rec)), + u3i_string("forward-lane"), + u3_nul); + u3_lord_peek_last(sam_u->pir_u->god_u, u3_nul, c3_s2('a', 'x'), u3_nul, + pax, pac_u, _ames_lane_scry_cb); + } + } + } + } + + // if we passed the filter, inject the packet + // + if (c3y == pas_o) { + u3_noun ore = _ames_lane_from_sockaddr((struct sockaddr_in *)adr_u); + u3_noun msg = u3i_bytes((c3_w)nrd_i, (c3_y*)buf_u->base); + _ames_put_packet(sam_u, msg, ore); } c3_free(buf_u->base); @@ -747,11 +1015,13 @@ u3_auto* u3_ames_io_init(u3_pier* pir_u) { u3_ames* sam_u = c3_calloc(sizeof(*sam_u)); + sam_u->pir_u = pir_u; //TODO de-dupe the below using this? sam_u->who_d[0] = pir_u->who_d[0]; sam_u->who_d[1] = pir_u->who_d[1]; sam_u->por_s = pir_u->por_s; sam_u->fak_o = pir_u->fak_o; sam_u->dop_d = 0; + sam_u->see_o = c3y; sam_u->fit_o = c3n; c3_assert( !uv_udp_init(u3L, &sam_u->wax_u) ); From b864d3068598880b05f4d11ac52dac5f28a187f5 Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 6 Jul 2020 22:48:02 +0200 Subject: [PATCH 089/933] vere: use pier data directly in ames.c Instead of copying it into the local struct. Arguably the port should still be present in the ames struct, since it's written to. There's a comment for removing it from the _pier_ struct though, which seems like the better change, but out of scope for here. --- pkg/urbit/vere/io/ames.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 80e3f98873..3d97401554 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -35,9 +35,6 @@ uv_udp_t wax_u; // uv_handle_t had_u; // }; // - c3_d who_d[2]; // identity - c3_o fak_o; // fake keys - c3_s por_s; // public IPv4 port c3_c* dns_c; // domain XX multiple/fallback c3_d dop_d; // drop count c3_d fal_d; // crash count @@ -703,8 +700,8 @@ _ames_recv_cb(uv_udp_t* wax_u, // if we are not the recipient, attempt to forward statelessly // - if ( (rec_d[0] != sam_u->who_d[0]) - || (rec_d[1] != sam_u->who_d[1]) ) + if ( (rec_d[0] != sam_u->pir_u->who_d[0]) + || (rec_d[1] != sam_u->pir_u->who_d[1]) ) { pas_o = c3n; //TODO counter? @@ -757,13 +754,13 @@ _ames_recv_cb(uv_udp_t* wax_u, static void _ames_io_start(u3_ames* sam_u) { - c3_s por_s = sam_u->por_s; - u3_noun who = u3i_chubs(2, sam_u->who_d); + c3_s por_s = sam_u->pir_u->por_s; + u3_noun who = u3i_chubs(2, sam_u->pir_u->who_d); u3_noun rac = u3do("clan:title", u3k(who)); c3_i ret_i; if ( c3__czar == rac ) { - c3_y num_y = (c3_y)sam_u->who_d[0]; + c3_y num_y = (c3_y)sam_u->pir_u->who_d[0]; c3_s zar_s = _ames_czar_port(num_y); if ( 0 == por_s ) { @@ -806,14 +803,14 @@ _ames_io_start(u3_ames* sam_u) uv_udp_getsockname(&sam_u->wax_u, (struct sockaddr *)&add_u, &add_i); c3_assert(add_u.sin_port); - sam_u->por_s = ntohs(add_u.sin_port); + sam_u->pir_u->por_s = ntohs(add_u.sin_port); } if ( c3y == u3_Host.ops_u.net ) { - u3l_log("ames: live on %d\n", sam_u->por_s); + u3l_log("ames: live on %d\n", sam_u->pir_u->por_s); } else { - u3l_log("ames: live on %d (localhost only)\n", sam_u->por_s); + u3l_log("ames: live on %d (localhost only)\n", sam_u->pir_u->por_s); } uv_udp_recv_start(&sam_u->wax_u, _ames_alloc, _ames_recv_cb); @@ -843,7 +840,7 @@ _ames_ef_turf(u3_ames* sam_u, u3_noun tuf) u3z(tuf); } - else if ( (c3n == sam_u->fak_o) && (0 == sam_u->dns_c) ) { + else if ( (c3n == sam_u->pir_u->fak_o) && (0 == sam_u->dns_c) ) { u3l_log("ames: turf: no domains\n"); } @@ -1015,11 +1012,7 @@ u3_auto* u3_ames_io_init(u3_pier* pir_u) { u3_ames* sam_u = c3_calloc(sizeof(*sam_u)); - sam_u->pir_u = pir_u; //TODO de-dupe the below using this? - sam_u->who_d[0] = pir_u->who_d[0]; - sam_u->who_d[1] = pir_u->who_d[1]; - sam_u->por_s = pir_u->por_s; - sam_u->fak_o = pir_u->fak_o; + sam_u->pir_u = pir_u; sam_u->dop_d = 0; sam_u->see_o = c3y; sam_u->fit_o = c3n; @@ -1029,7 +1022,7 @@ u3_ames_io_init(u3_pier* pir_u) // Disable networking for fake ships // - if ( c3y == sam_u->fak_o ) { + if ( c3y == sam_u->pir_u->fak_o ) { u3_Host.ops_u.net = c3n; } From 1eab1660a7c368f4d809ce16a1c8bf8bc8fd7d7a Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 8 Jul 2020 01:15:29 +0200 Subject: [PATCH 090/933] vere: limit ames.c forwarding queue to 1k Keeps a counter, increments and decrements when starting and completing forwarding logic respectively. Once the counter hits 1000, further packets are dropped instead of forwarded. Ideally you want to drop the oldest packets first, but this'd imply removing scry events from the event log, which ames.c shouldn't know how to do. Perhaps once u3_lord_peek_cancel or similar gets implemented, we can do this sanely. Until then, this isn't the end of the world. --- pkg/urbit/vere/io/ames.c | 72 +++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 26 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 3d97401554..c1b97bfc8c 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -44,6 +44,7 @@ c3_o see_o; // can scry c3_o fit_o; // filtering active c3_y ver_y; // protocol version + c3_d foq_d; // forward queue size } u3_ames; /* u3_head: ames packet header @@ -73,8 +74,7 @@ u3_body bod_u; // body } u3_panc; -//TODO cap forwarding queue, maintain a counter. -// keep linked list in u3_ames for garbage collection, cancelling on-exit +//TODO keep linked list in u3_ames for garbage collection, cancelling on-exit /* _ames_alloc(): libuv buffer allocator. */ @@ -599,7 +599,7 @@ _ames_forward(u3_panc* pac_u, u3_noun lan) u3z(bod); } - u3l_log("ames: forwarding!\n"); + pac_u->sam_u->foq_d--; _ames_ef_send(pac_u->sam_u, lan, _ames_serialize_packet(pac_u)); } @@ -614,6 +614,7 @@ _ames_lane_scry_cb(void* vod_p, u3_noun nun) // if scry fails, remember we can't scry, and just inject the packet // if (u3_none == lan) { + pac_u->sam_u->foq_d--; u3l_log("ames: giving up scry\n"); pac_u->sam_u->see_o = c3n; _ames_put_packet(pac_u->sam_u, _ames_serialize_packet(pac_u), pac_u->ore); @@ -704,35 +705,53 @@ _ames_recv_cb(uv_udp_t* wax_u, || (rec_d[1] != sam_u->pir_u->who_d[1]) ) { pas_o = c3n; - //TODO counter? - // store the packet details for later processing + // if the queue is full, and we can't forward synchronously, + // just drop the packet // - u3_noun con = u3i_bytes(nrd_i - 4 - sen_y - rec_y, - bod_y + sen_y + rec_y); - u3_panc* pac_u = c3_calloc(sizeof(*pac_u)); - pac_u->sam_u = sam_u; - pac_u->hed_u = hed_u; - pac_u->bod_u.sen = sen; - pac_u->bod_u.rec = rec; - pac_u->bod_u.con = con; - pac_u->ore = _ames_lane_from_sockaddr((struct sockaddr_in *)adr_u); - - // if the recipient is a galaxy, their lane is always &+~gax + //TODO drop oldest item in forward queue in favor of this one. + // ames.c doesn't/shouldn't know about the shape of scry events, + // so can't pluck these out of the event queue like it does in + // _ames_cap_queue. as such, blocked on u3_lord_peek_cancel or w/e. // - if ( (c3y == u3a_is_cat(rec)) - && (256 > rec) ) { - _ames_forward(pac_u, u3nc(c3y, u3k(rec))); + if ( (1000 < sam_u->foq_d) + && !((c3y == u3a_is_cat(rec)) && (256 > rec)) ) + { + u3z(sen); u3z(rec); } - // otherwise, scry the lane out of ames + // otherwise, proceed with forwarding // else { - u3_noun pax = u3nq(u3i_string("peers"), - u3dc("scot", 'p', u3k(rec)), - u3i_string("forward-lane"), - u3_nul); - u3_lord_peek_last(sam_u->pir_u->god_u, u3_nul, c3_s2('a', 'x'), u3_nul, - pax, pac_u, _ames_lane_scry_cb); + sam_u->foq_d++; + + // store the packet details for later processing + // + u3_noun con = u3i_bytes(nrd_i - 4 - sen_y - rec_y, + bod_y + sen_y + rec_y); + u3_panc* pac_u = c3_calloc(sizeof(*pac_u)); + pac_u->sam_u = sam_u; + pac_u->hed_u = hed_u; + pac_u->bod_u.sen = sen; + pac_u->bod_u.rec = rec; + pac_u->bod_u.con = con; + pac_u->ore = _ames_lane_from_sockaddr((struct sockaddr_in *)adr_u); + + // if the recipient is a galaxy, their lane is always &+~gax + // + if ( (c3y == u3a_is_cat(rec)) + && (256 > rec) ) { + _ames_forward(pac_u, u3nc(c3y, u3k(rec))); + } + // otherwise, if there's space in the queue, scry the lane out of ames + // + else { + u3_noun pax = u3nq(u3i_string("peers"), + u3dc("scot", 'p', u3k(rec)), + u3i_string("forward-lane"), + u3_nul); + u3_lord_peek_last(sam_u->pir_u->god_u, u3_nul, c3_s2('a', 'x'), + u3_nul, pax, pac_u, _ames_lane_scry_cb); + } } } } @@ -1016,6 +1035,7 @@ u3_ames_io_init(u3_pier* pir_u) sam_u->dop_d = 0; sam_u->see_o = c3y; sam_u->fit_o = c3n; + sam_u->foq_d = 0; c3_assert( !uv_udp_init(u3L, &sam_u->wax_u) ); sam_u->wax_u.data = sam_u; From c58ac8e6f4d79a2ff685b3eb2143707d54e8df38 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 8 Jul 2020 01:31:41 +0200 Subject: [PATCH 091/933] vere: clean up packets forwarded to galaxies In the forward-to-galaxy case, we don't go through _ames_lane_scry_cb, instead calling _ames_forward directly, meaning _ames_panc_free wouldn't get called on those packets. Now, we move the _ames_panc_free call into _ames_forward, and only keep it in the "scry failed" section of _ames_lane_scry_cb. By moving that call into the --- pkg/urbit/vere/io/ames.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index c1b97bfc8c..355b1986c8 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -548,7 +548,7 @@ _ames_put_packet(u3_ames* sam_u, _ames_cap_queue(sam_u); } -/* _ames_forward(): forward pac_u onto lan +/* _ames_forward(): forward pac_u onto lan, then free pac_u */ static void _ames_forward(u3_panc* pac_u, u3_noun lan) @@ -601,6 +601,7 @@ _ames_forward(u3_panc* pac_u, u3_noun lan) pac_u->sam_u->foq_d--; _ames_ef_send(pac_u->sam_u, lan, _ames_serialize_packet(pac_u)); + _ames_panc_free(pac_u); } /* _ames_lane_scry_cb(): learn lane to forward packet on @@ -618,6 +619,7 @@ _ames_lane_scry_cb(void* vod_p, u3_noun nun) u3l_log("ames: giving up scry\n"); pac_u->sam_u->see_o = c3n; _ames_put_packet(pac_u->sam_u, _ames_serialize_packet(pac_u), pac_u->ore); + _ames_panc_free(pac_u); } // if there is a lane, forward the packet on it // @@ -626,7 +628,6 @@ _ames_lane_scry_cb(void* vod_p, u3_noun nun) } // if there is no lane, drop the packet - _ames_panc_free(pac_u); u3z(nun); } From 57a0b6f654bdfa5a62880d0b54208d89cd204d78 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 8 Jul 2020 02:04:55 +0200 Subject: [PATCH 092/933] vere: add ames counters for forwarded packets Track the amount of packets we forward, and the amount we drop due to forward queue pressure. Once every 1000 packets, printf the total. --- pkg/urbit/vere/io/ames.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 355b1986c8..1bc8801ab0 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -45,6 +45,8 @@ c3_o fit_o; // filtering active c3_y ver_y; // protocol version c3_d foq_d; // forward queue size + c3_d fow_d; // forwarded count + c3_d fod_d; // forwards dropped count } u3_ames; /* u3_head: ames packet header @@ -599,6 +601,11 @@ _ames_forward(u3_panc* pac_u, u3_noun lan) u3z(bod); } + pac_u->sam_u->fow_d++; + if ( 0 == (pac_u->sam_u->fow_d % 1000) ) { + u3l_log("ames: forwarded %" PRIu64 " total\n", pac_u->sam_u->fow_d); + } + pac_u->sam_u->foq_d--; _ames_ef_send(pac_u->sam_u, lan, _ames_serialize_packet(pac_u)); _ames_panc_free(pac_u); @@ -718,6 +725,11 @@ _ames_recv_cb(uv_udp_t* wax_u, if ( (1000 < sam_u->foq_d) && !((c3y == u3a_is_cat(rec)) && (256 > rec)) ) { + sam_u->fod_d++; + if ( 0 == (sam_u->fod_d % 1000) ) { + u3l_log("ames: dropped %" PRIu64 " forwards total\n", sam_u->fod_d); + } + u3z(sen); u3z(rec); } // otherwise, proceed with forwarding From 9262ea1e68fe819bf4b0f7e4cea379eb73817a53 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 8 Jul 2020 17:00:59 +0200 Subject: [PATCH 093/933] vere: add ames counters for filtered packets Track the amount of packets we drop for mismatching protocol version or invalid mug hash. --- pkg/urbit/vere/io/ames.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 1bc8801ab0..5efe0039c4 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -44,6 +44,8 @@ c3_o see_o; // can scry c3_o fit_o; // filtering active c3_y ver_y; // protocol version + c3_d vet_d; // version mismatches filtered + c3_d mut_d; // invalid mugs filtered c3_d foq_d; // forward queue size c3_d fow_d; // forwarded count c3_d fod_d; // forwards dropped count @@ -664,9 +666,13 @@ _ames_recv_cb(uv_udp_t* wax_u, && (sam_u->ver_y != (0x7 & *((c3_w*)buf_u->base))) ) { pas_o = c3n; - //TODO counter //TODO unless sender is our sponsee (transitively?) //TODO how does this interact with forwards? + + sam_u->vet_d++; + if ( 0 == (sam_u->vet_d % 100) ) { + u3l_log("ames: %" PRIu64 " dropped for version mismatch\n", sam_u->vet_d); + } } if (c3y == pas_o) { @@ -693,7 +699,10 @@ _ames_recv_cb(uv_udp_t* wax_u, // if ( hed_u.mug_l != _ca_mug_body(nrd_i - 4, bod_y) ) { pas_o = c3n; - //TODO counter? + sam_u->mut_d++; + if ( 0 == (sam_u->mut_d % 100) ) { + u3l_log("ames: %" PRIu64 " dropped for invalid mug\n", sam_u->mut_d); + } } // if we can scry, we might want to forward statelessly // From c41bbbefb6b7855c76cf91846cb98c733bb95191 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 9 Jul 2020 00:02:58 +0200 Subject: [PATCH 094/933] vere: track pending forward packets Store them in ames.c state as a doubly linked list. This allows us to clean up not-yet-forwarded packets on-exit gracefully, rather than just letting them disappear into the void. We could probably get away with a singly linked list instead, but then we would need to depend on scry responses being given in request-order. --- pkg/urbit/vere/io/ames.c | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 5efe0039c4..e50552a9cb 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -13,6 +13,9 @@ #include "all.h" #include "vere/vere.h" +struct _u3_panc; +typedef struct _u3_panc u3_panc; + /* u3_pact: ames packet, coming or going. */ typedef struct _u3_pact { @@ -46,6 +49,7 @@ c3_y ver_y; // protocol version c3_d vet_d; // version mismatches filtered c3_d mut_d; // invalid mugs filtered + u3_panc* pac_u; // packets pending forwards c3_d foq_d; // forward queue size c3_d fow_d; // forwarded count c3_d fod_d; // forwards dropped count @@ -71,12 +75,14 @@ /* u3_panc: deconstructed incoming packet */ - typedef struct _u3_panc { + struct _u3_panc { u3_ames* sam_u; // ames backpointer + u3_panc* pre_u; // previous packet + u3_panc* nex_u; // next packet u3_noun ore; // origin lane u3_head hed_u; // header u3_body bod_u; // body - } u3_panc; + }; //TODO keep linked list in u3_ames for garbage collection, cancelling on-exit @@ -105,10 +111,20 @@ _ames_pact_free(u3_pact* pac_u) c3_free(pac_u); } -/* _ames_panc_free(): lose refcounts and free struct +/* _ames_panc_free(): remove references, lose refcounts and free struct */ static void _ames_panc_free(u3_panc* pac_u) { + if (0 != pac_u->nex_u) { + pac_u->nex_u->pre_u = pac_u->pre_u; + } + if (0 != pac_u->pre_u) { + pac_u->pre_u->nex_u = pac_u->nex_u; + } else { + c3_assert(pac_u == pac_u->sam_u->pac_u); + pac_u->sam_u->pac_u = pac_u->nex_u; + } + u3z(pac_u->ore); u3z(pac_u->bod_u.sen); u3z(pac_u->bod_u.rec); @@ -758,6 +774,12 @@ _ames_recv_cb(uv_udp_t* wax_u, pac_u->bod_u.con = con; pac_u->ore = _ames_lane_from_sockaddr((struct sockaddr_in *)adr_u); + if (0 != sam_u->pac_u) { + pac_u->nex_u = sam_u->pac_u; + sam_u->pac_u->pre_u = pac_u; + } + sam_u->pac_u = pac_u; + // if the recipient is a galaxy, their lane is always &+~gax // if ( (c3y == u3a_is_cat(rec)) @@ -1000,6 +1022,14 @@ static void _ames_exit_cb(uv_handle_t* had_u) { u3_ames* sam_u = had_u->data; + + u3_panc* pac_u = sam_u->pac_u; + while (0 != pac_u) { + u3_panc* nex_u = pac_u->nex_u; + _ames_panc_free(pac_u); + pac_u = nex_u; + } + c3_free(sam_u); } From 6704cc8061962471358649f7fd230f7b86345bde Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 15 Jul 2020 20:30:39 +0200 Subject: [PATCH 095/933] vere: refactor origin update into serialization Instead of updating the origin lane and mug prior to serializing the packet, we now treat that as part of the serialization logic. Since we don't want to do this always (we might want to serialize the packet as-is), we add a flag to _ames_serialize_packet for this behavior. --- pkg/urbit/vere/io/ames.c | 146 ++++++++++++++++++++------------------- 1 file changed, 76 insertions(+), 70 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index e50552a9cb..c19198fc50 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -315,35 +315,85 @@ _ames_lane_from_sockaddr(struct sockaddr_in* add_u) return u3_ames_encode_lane(lan_u); } -/* _ames_serialize_packet(): u3_panc to atom (retains pac_u) +/* _ames_serialize_packet(): u3_panc to atom, updating the origin lane if dop_o +** (retains pac_u) */ static u3_noun -_ames_serialize_packet(u3_panc* pac_u) +_ames_serialize_packet(u3_panc* pac_u, c3_o dop_o) { - u3_body* bod_u = &pac_u->bod_u; - c3_w bod_w = u3r_met(3, bod_u->con); + c3_y sen_y = 2 << pac_u->hed_u.sac_y; + c3_y rec_y = 2 << pac_u->hed_u.rac_y; + c3_o nal_o = c3n; - u3_head* hed_u = &pac_u->hed_u; - c3_w hed_w = hed_u->ver_y - | (hed_u->mug_l << 3) - | (hed_u->sac_y << 23) - | (hed_u->rac_y << 25) - | (hed_u->enc_o << 26); - - c3_y sen_y = 2 << hed_u->sac_y; - c3_y rec_y = 2 << hed_u->rac_y; - - // allocate, then write: header (4 bytes), sender, recipient, body + // update the body's lane, if desired // - c3_y* pac_y = c3_malloc( 4 + sen_y + rec_y + bod_w ); - memcpy(pac_y, &hed_w, 4); - u3r_bytes(0, sen_y, pac_y + 4, bod_u->sen); - u3r_bytes(0, rec_y, pac_y + 4 + sen_y, bod_u->rec); - u3r_bytes(0, bod_w, pac_y + 4 + sen_y + rec_y, bod_u->con); + if (c3y == dop_o) { + // unpack (jam [(unit lane) body]) + // + u3_noun lon, bod; + { + u3_noun old = u3qe_cue(pac_u->bod_u.con); + u3x_cell(old, &lon, &bod); + u3k(lon); u3k(bod); + u3z(old); + } - u3_noun pac = u3i_bytes(4 + sen_y + rec_y + bod_w, pac_y); + // only replace the lane if it was ~ + // + //NOTE this sets an opaque lane even in the "sender is galaxy" case, + // but that doesn't matter: ames.hoon ignores origin in that case, + // always using the appropriate galaxy lane instead. + // + if (u3_nul == lon) { + u3z(lon); + lon = u3nt(u3_nul, c3n, u3k(pac_u->ore)); + nal_o = c3y; + + u3z(pac_u->bod_u.con); + pac_u->bod_u.con = u3ke_jam(u3nc(lon, bod)); + } + else { + u3z(lon); u3z(bod); + } + } + + // serialize the packet + // + u3_noun pac; + { + // start with the body + // + u3_body* bod_u = &pac_u->bod_u; + c3_w bod_w = u3r_met(3, bod_u->con); + + c3_y* pac_y = c3_malloc( 4 + sen_y + rec_y + bod_w ); + u3r_bytes(0, sen_y, pac_y + 4, bod_u->sen); + u3r_bytes(0, rec_y, pac_y + 4 + sen_y, bod_u->rec); + u3r_bytes(0, bod_w, pac_y + 4 + sen_y + rec_y, bod_u->con); + + // if we updated the origin lane, we need to update the mug too + // + if (c3y == nal_o) { + u3_noun bod = u3i_bytes(sen_y + rec_y + bod_w, pac_y + 4); + pac_u->hed_u.mug_l = u3r_mug(bod) & ((1 << 20) - 1); + u3z(bod); + } + + // now we can serialize the head + // + u3_head* hed_u = &pac_u->hed_u; + c3_w hed_w = hed_u->ver_y + | (hed_u->mug_l << 3) + | (hed_u->sac_y << 23) + | (hed_u->rac_y << 25) + | (hed_u->enc_o << 26); + + memcpy(pac_y, &hed_w, 4); + + pac = u3i_bytes(4 + sen_y + rec_y + bod_w, pac_y); + c3_free(pac_y); + } - c3_free(pac_y); return pac; } @@ -573,59 +623,13 @@ _ames_put_packet(u3_ames* sam_u, static void _ames_forward(u3_panc* pac_u, u3_noun lan) { - c3_o nal = c3n; - - // repack the maybe-updated packet - // - { - // unpack (jam [(unit lane) body]) - // - u3_noun lon, bod; - { - u3_noun old = u3ke_cue(pac_u->bod_u.con); - u3x_cell(old, &lon, &bod); - u3k(lon); u3k(bod); - u3z(old); - } - - // only replace the lane if it was ~ - // - if (u3_nul == lon) { - u3z(lon); - lon = u3nt(u3_nul, c3n, u3k(pac_u->ore)); - //TODO ore is always opaque lane. what about the sender=galaxy case? - nal = c3y; - } - - pac_u->bod_u.con = u3ke_jam(u3nc(lon, bod)); - } - - // if we updated the origin lane, serialize the body to update the mug hash - // - //TODO refactor into serialize_packet? - if (c3y == nal) { - c3_w bod_w = u3r_met(3, pac_u->bod_u.con); - c3_y sen_y = 2 << pac_u->hed_u.sac_y; - c3_y rec_y = 2 << pac_u->hed_u.rac_y; - c3_y* bod_y = c3_malloc(sen_y + rec_y + bod_w); - u3r_bytes(0, sen_y, bod_y, pac_u->bod_u.sen); - u3r_bytes(0, rec_y, bod_y + sen_y, pac_u->bod_u.rec); - u3r_bytes(0, bod_w, bod_y + sen_y + rec_y, pac_u->bod_u.con); - u3_noun bod = u3i_bytes(sen_y + rec_y + bod_w, bod_y); - - pac_u->hed_u.mug_l = u3r_mug(bod) & ((1 << 20) - 1); - - c3_free(bod_y); - u3z(bod); - } - pac_u->sam_u->fow_d++; if ( 0 == (pac_u->sam_u->fow_d % 1000) ) { u3l_log("ames: forwarded %" PRIu64 " total\n", pac_u->sam_u->fow_d); } pac_u->sam_u->foq_d--; - _ames_ef_send(pac_u->sam_u, lan, _ames_serialize_packet(pac_u)); + _ames_ef_send(pac_u->sam_u, lan, _ames_serialize_packet(pac_u, c3y)); _ames_panc_free(pac_u); } @@ -643,7 +647,9 @@ _ames_lane_scry_cb(void* vod_p, u3_noun nun) pac_u->sam_u->foq_d--; u3l_log("ames: giving up scry\n"); pac_u->sam_u->see_o = c3n; - _ames_put_packet(pac_u->sam_u, _ames_serialize_packet(pac_u), pac_u->ore); + _ames_put_packet(pac_u->sam_u, + _ames_serialize_packet(pac_u, c3n), + pac_u->ore); _ames_panc_free(pac_u); } // if there is a lane, forward the packet on it From bd378591f29974cd2ae308d0c39933c7b875353b Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 15 Jul 2020 22:50:23 +0200 Subject: [PATCH 096/933] vere: pack & unpack packet header correctly "encrypted" flag lives at the 27th bit, the 26th would overlap with the receiver rank. --- pkg/urbit/vere/io/ames.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index c19198fc50..be08556c45 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -386,7 +386,7 @@ _ames_serialize_packet(u3_panc* pac_u, c3_o dop_o) | (hed_u->mug_l << 3) | (hed_u->sac_y << 23) | (hed_u->rac_y << 25) - | (hed_u->enc_o << 26); + | (hed_u->enc_o << 27); memcpy(pac_y, &hed_w, 4); @@ -714,7 +714,7 @@ _ames_recv_cb(uv_udp_t* wax_u, hed_u.mug_l = (hed_w >> 3) & ((1 << 20) - 1); hed_u.sac_y = (hed_w >> 23) & 0x3; hed_u.rac_y = (hed_w >> 25) & 0x3; - hed_u.enc_o = (hed_w >> 26) & 0x1; + hed_u.enc_o = (hed_w >> 27) & 0x1; } // ensure the mug is valid From e98742cf8fc0b2905b1305a79a7f71efb5c6b3c2 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 15 Jul 2020 22:52:55 +0200 Subject: [PATCH 097/933] vere: adjust forwarding printf frequency Also removes stale comments. --- pkg/urbit/vere/io/ames.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index be08556c45..0d34ae2dad 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -84,8 +84,6 @@ typedef struct _u3_panc u3_panc; u3_body bod_u; // body }; -//TODO keep linked list in u3_ames for garbage collection, cancelling on-exit - /* _ames_alloc(): libuv buffer allocator. */ static void @@ -608,7 +606,7 @@ _ames_put_packet(u3_ames* sam_u, u3_noun lan) { u3_noun wir = u3nc(c3__ames, u3_nul); - u3_noun cad = u3nt(c3__hear, u3nc(c3n, lan), msg); // trnasfer, unchanged + u3_noun cad = u3nt(c3__hear, u3nc(c3n, lan), msg); u3_auto_peer( u3_auto_plan(&sam_u->car_u, @@ -624,7 +622,7 @@ static void _ames_forward(u3_panc* pac_u, u3_noun lan) { pac_u->sam_u->fow_d++; - if ( 0 == (pac_u->sam_u->fow_d % 1000) ) { + if ( 0 == (pac_u->sam_u->fow_d % 10000) ) { u3l_log("ames: forwarded %" PRIu64 " total\n", pac_u->sam_u->fow_d); } From 6e0a7d009aa5cc485dc667df3b01cede46a761e0 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 16 Jul 2020 01:56:55 +0200 Subject: [PATCH 098/933] ames: produce (list lane) instead of (unit lane) Making this change now allows us to more easily supply and handle multiple lanes in the future. Updates the runtime to handle these results properly, forwarding to every lane that was returned in the scry. Sneaks in some comment cleanup in ames.hoon. --- pkg/arvo/sys/vane/ames.hoon | 12 +++++------- pkg/urbit/vere/io/ames.c | 24 ++++++++++++++++-------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index a8f91372d6..34b26b0bbe 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -702,7 +702,7 @@ == ~ :: /ax/protocol/version @ - :: /ax/peers (map ship ?(%alien known)) + :: /ax/peers (map ship ?(%alien %known)) :: /ax/peers/[ship] ship-state :: /ax/peers/[ship]/forward-lane (unit lane) :: /ax/bones/[ship] [snd=(set bone) rcv=(set bone)] @@ -727,21 +727,19 @@ ~ ``noun+!>(u.peer) :: [%forward-lane ~] - ::TODO (list lane) instead? - ::TODO refactor wrt +send-blob to share routing logic :: find lane for u.who, or their galaxy :: :^ ~ ~ %noun - !> ^- (unit lane) + !> ^- (list lane) =/ ship-state (~(get by peers.ames-state) u.who) ?. ?=([~ %known *] ship-state) ~ =/ peer-state +.u.ship-state ?. =(~ route.peer-state) ::NOTE avoid tmi - `lane:(need route.peer-state) - |- ^- (unit lane) + [lane:(need route.peer-state)]~ + |- ^- (list lane) ?: ?=(%czar (clan:title sponsor.peer-state)) - `[%& sponsor.peer-state] + [%& sponsor.peer-state]~ =/ next (~(get by peers.ames-state) sponsor.peer-state) ?. ?=([~ %known *] next) ~ diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 0d34ae2dad..f92b7f79b7 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -616,18 +616,26 @@ _ames_put_packet(u3_ames* sam_u, _ames_cap_queue(sam_u); } -/* _ames_forward(): forward pac_u onto lan, then free pac_u +/* _ames_forward(): forward pac_u onto the (list lane) las, then free pac_u */ static void -_ames_forward(u3_panc* pac_u, u3_noun lan) +_ames_forward(u3_panc* pac_u, u3_noun las) { pac_u->sam_u->fow_d++; if ( 0 == (pac_u->sam_u->fow_d % 10000) ) { u3l_log("ames: forwarded %" PRIu64 " total\n", pac_u->sam_u->fow_d); } + { + u3_noun pac = _ames_serialize_packet(pac_u, c3y); + while (u3_nul != las) { + _ames_ef_send(pac_u->sam_u, u3h(las), u3k(pac)); + las = u3t(las); + } + u3z(pac); + } + pac_u->sam_u->foq_d--; - _ames_ef_send(pac_u->sam_u, lan, _ames_serialize_packet(pac_u, c3y)); _ames_panc_free(pac_u); } @@ -637,11 +645,11 @@ static void _ames_lane_scry_cb(void* vod_p, u3_noun nun) { u3_panc* pac_u = vod_p; - u3_weak lan = u3r_at(15, nun); //TODO why [~ %noun ~ lane] + u3_weak las = u3r_at(15, nun); //TODO why [~ %noun ~ lane] // if scry fails, remember we can't scry, and just inject the packet // - if (u3_none == lan) { + if (u3_none == las) { pac_u->sam_u->foq_d--; u3l_log("ames: giving up scry\n"); pac_u->sam_u->see_o = c3n; @@ -652,8 +660,8 @@ _ames_lane_scry_cb(void* vod_p, u3_noun nun) } // if there is a lane, forward the packet on it // - else if (u3_nul != lan) { - _ames_forward(pac_u, u3k(u3t(lan))); + else if (u3_nul != las) { + _ames_forward(pac_u, u3k(las)); } // if there is no lane, drop the packet @@ -788,7 +796,7 @@ _ames_recv_cb(uv_udp_t* wax_u, // if ( (c3y == u3a_is_cat(rec)) && (256 > rec) ) { - _ames_forward(pac_u, u3nc(c3y, u3k(rec))); + _ames_forward(pac_u, u3nc(u3nc(c3y, u3k(rec)), u3_nul)); } // otherwise, if there's space in the queue, scry the lane out of ames // From 4ce3d2d208607178568de3a46ec544ea7030a089 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 16 Jul 2020 02:04:25 +0200 Subject: [PATCH 099/933] vere: properly free nouns when not forwarding --- pkg/urbit/vere/io/ames.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index f92b7f79b7..07a6331ee6 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -744,11 +744,16 @@ _ames_recv_cb(uv_udp_t* wax_u, c3_d rec_d[2]; u3r_chubs(0, 2, rec_d, rec); + // if we are the recipient, simply let it pass the filter + // + if ( (rec_d[0] == sam_u->pir_u->who_d[0]) + && (rec_d[1] == sam_u->pir_u->who_d[1]) ) + { + u3z(sen); u3z(rec); + } // if we are not the recipient, attempt to forward statelessly // - if ( (rec_d[0] != sam_u->pir_u->who_d[0]) - || (rec_d[1] != sam_u->pir_u->who_d[1]) ) - { + else { pas_o = c3n; // if the queue is full, and we can't forward synchronously, From 899899161c46a440bf215a4107dc2163b19a4d55 Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 17 Jul 2020 01:30:23 +0200 Subject: [PATCH 100/933] vere: account for scry callback bugfix The addition of ~ was, indeed, in error. See also 406c865. --- pkg/urbit/vere/io/ames.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 07a6331ee6..ac49837c35 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -645,7 +645,7 @@ static void _ames_lane_scry_cb(void* vod_p, u3_noun nun) { u3_panc* pac_u = vod_p; - u3_weak las = u3r_at(15, nun); //TODO why [~ %noun ~ lane] + u3_weak las = u3r_at(7, nun); // if scry fails, remember we can't scry, and just inject the packet // @@ -1065,7 +1065,7 @@ static void _ames_prot_scry_cb(void* vod_p, u3_noun nun) { u3_ames* sam_u = vod_p; - u3_weak ver = u3r_at(15, nun); //TODO nun is [~ %noun ~ x] now? + u3_weak ver = u3r_at(7, nun); if (u3_none == ver) { // assume protocol version 0 From c008804e5282c7aa24ef7425be79125df1a68603 Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 17 Jul 2020 15:43:46 +0200 Subject: [PATCH 101/933] vere: punt on protocol version mismatch handling --- pkg/urbit/vere/io/ames.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index ac49837c35..91ebbebb1c 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -694,8 +694,6 @@ _ames_recv_cb(uv_udp_t* wax_u, && (sam_u->ver_y != (0x7 & *((c3_w*)buf_u->base))) ) { pas_o = c3n; - //TODO unless sender is our sponsee (transitively?) - //TODO how does this interact with forwards? sam_u->vet_d++; if ( 0 == (sam_u->vet_d % 100) ) { From ff6e26f069a01e6fddd8f79f631c439a182c8f60 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 23 Jul 2020 21:47:15 -0700 Subject: [PATCH 102/933] vere: corrects database/disk error printfs --- pkg/urbit/vere/db/lmdb.c | 40 ++++++++++++++++++++-------------------- pkg/urbit/vere/disk.c | 10 +++++----- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pkg/urbit/vere/db/lmdb.c b/pkg/urbit/vere/db/lmdb.c index ef77ba01f3..6160c2b4c9 100644 --- a/pkg/urbit/vere/db/lmdb.c +++ b/pkg/urbit/vere/db/lmdb.c @@ -38,7 +38,7 @@ u3_lmdb_init(const c3_c* pax_c, size_t siz_i) c3_w ret_w; if ( (ret_w = mdb_env_create(&env_u)) ) { - fprintf(stderr, "lmdb: init fail: %s\n", mdb_strerror(ret_w)); + fprintf(stderr, "lmdb: init fail: %s\r\n", mdb_strerror(ret_w)); return 0; } @@ -61,7 +61,7 @@ u3_lmdb_init(const c3_c* pax_c, size_t siz_i) } if ( (ret_w = mdb_env_open(env_u, pax_c, 0, 0664)) ) { - fprintf(stderr, "lmdb: failed to open event log: %s\n", + fprintf(stderr, "lmdb: failed to open event log: %s\r\n", mdb_strerror(ret_w)); // XX dispose env_u // @@ -93,7 +93,7 @@ u3_lmdb_gulf(MDB_env* env_u, c3_d* low_d, c3_d* hig_d) // XX why no MDB_RDONLY? // if ( (ret_w = mdb_txn_begin(env_u, 0, 0, &txn_u)) ) { - fprintf(stderr, "lmdb: gulf: txn_begin fail: %s\n", mdb_strerror(ret_w)); + fprintf(stderr, "lmdb: gulf: txn_begin fail: %s\r\n", mdb_strerror(ret_w)); return c3n; } @@ -103,7 +103,7 @@ u3_lmdb_gulf(MDB_env* env_u, c3_d* low_d, c3_d* hig_d) c3_w ops_w = MDB_CREATE | MDB_INTEGERKEY; if ( (ret_w = mdb_dbi_open(txn_u, "EVENTS", ops_w, &mdb_u)) ) { - fprintf(stderr, "lmdb: gulf: dbi_open fail: %s\n", mdb_strerror(ret_w)); + fprintf(stderr, "lmdb: gulf: dbi_open fail: %s\r\n", mdb_strerror(ret_w)); // XX confirm // mdb_txn_abort(txn_u); @@ -120,7 +120,7 @@ u3_lmdb_gulf(MDB_env* env_u, c3_d* low_d, c3_d* hig_d) // creates a cursor to point to the last event // if ( (ret_w = mdb_cursor_open(txn_u, mdb_u, &cur_u)) ) { - fprintf(stderr, "lmdb: gulf: cursor_open fail: %s\n", + fprintf(stderr, "lmdb: gulf: cursor_open fail: %s\r\n", mdb_strerror(ret_w)); // XX confirm // @@ -140,7 +140,7 @@ u3_lmdb_gulf(MDB_env* env_u, c3_d* low_d, c3_d* hig_d) return c3y; } else if ( ret_w ) { - fprintf(stderr, "lmdb: gulf: head fail: %s\n", + fprintf(stderr, "lmdb: gulf: head fail: %s\r\n", mdb_strerror(ret_w)); mdb_cursor_close(cur_u); mdb_txn_abort(txn_u); @@ -191,7 +191,7 @@ u3_lmdb_read(MDB_env* env_u, // create a read-only transaction. // if ( (ret_w = mdb_txn_begin(env_u, 0, MDB_RDONLY, &txn_u)) ) { - fprintf(stderr, "lmdb: read txn_begin fail: %s\n", mdb_strerror(ret_w)); + fprintf(stderr, "lmdb: read txn_begin fail: %s\r\n", mdb_strerror(ret_w)); return c3n; } @@ -201,7 +201,7 @@ u3_lmdb_read(MDB_env* env_u, c3_w ops_w = MDB_CREATE | MDB_INTEGERKEY; if ( (ret_w = mdb_dbi_open(txn_u, "EVENTS", ops_w, &mdb_u)) ) { - fprintf(stderr, "lmdb: read: dbi_open fail: %s\n", mdb_strerror(ret_w)); + fprintf(stderr, "lmdb: read: dbi_open fail: %s\r\n", mdb_strerror(ret_w)); // XX confirm // mdb_txn_abort(txn_u); @@ -220,7 +220,7 @@ u3_lmdb_read(MDB_env* env_u, // creates a cursor to iterate over keys starting at [eve_d] // if ( (ret_w = mdb_cursor_open(txn_u, mdb_u, &cur_u)) ) { - fprintf(stderr, "lmdb: read: cursor_open fail: %s\n", + fprintf(stderr, "lmdb: read: cursor_open fail: %s\r\n", mdb_strerror(ret_w)); // XX confirm // @@ -312,7 +312,7 @@ u3_lmdb_save(MDB_env* env_u, // create a write transaction // if ( (ret_w = mdb_txn_begin(env_u, 0, 0, &txn_u)) ) { - fprintf(stderr, "lmdb: write: txn_begin fail: %s\n", mdb_strerror(ret_w)); + fprintf(stderr, "lmdb: write: txn_begin fail: %s\r\n", mdb_strerror(ret_w)); return c3n; } @@ -322,7 +322,7 @@ u3_lmdb_save(MDB_env* env_u, c3_w ops_w = MDB_CREATE | MDB_INTEGERKEY; if ( (ret_w = mdb_dbi_open(txn_u, "EVENTS", ops_w, &mdb_u)) ) { - fprintf(stderr, "lmdb: write: dbi_open fail: %s\n", mdb_strerror(ret_w)); + fprintf(stderr, "lmdb: write: dbi_open fail: %s\r\n", mdb_strerror(ret_w)); mdb_txn_abort(txn_u); return c3n; } @@ -343,7 +343,7 @@ u3_lmdb_save(MDB_env* env_u, MDB_val val_u = { .mv_size = siz_i[i_d], .mv_data = byt_p[i_d] }; if ( (ret_w = mdb_put(txn_u, mdb_u, &key_u, &val_u, ops_w)) ) { - fprintf(stderr, "lmdb: write failed on event %" PRIu64 "\n", key_d); + fprintf(stderr, "lmdb: write failed on event %" PRIu64 "\r\n", key_d); mdb_txn_abort(txn_u); return c3n; } @@ -354,7 +354,7 @@ u3_lmdb_save(MDB_env* env_u, // commit transaction // if ( (ret_w = mdb_txn_commit(txn_u)) ) { - fprintf(stderr, "lmdb: write failed: %s\n", mdb_strerror(ret_w)); + fprintf(stderr, "lmdb: write failed: %s\r\n", mdb_strerror(ret_w)); return c3n; } @@ -376,7 +376,7 @@ u3_lmdb_read_meta(MDB_env* env_u, // create a read transaction // if ( (ret_w = mdb_txn_begin(env_u, 0, MDB_RDONLY, &txn_u)) ) { - fprintf(stderr, "lmdb: meta read: txn_begin fail: %s\n", + fprintf(stderr, "lmdb: meta read: txn_begin fail: %s\r\n", mdb_strerror(ret_w)); return read_f(ptr_v, 0, 0); } @@ -384,7 +384,7 @@ u3_lmdb_read_meta(MDB_env* env_u, // open the database in the transaction // if ( (ret_w = mdb_dbi_open(txn_u, "META", 0, &mdb_u)) ) { - fprintf(stderr, "lmdb: meta read: dbi_open fail: %s\n", + fprintf(stderr, "lmdb: meta read: dbi_open fail: %s\r\n", mdb_strerror(ret_w)); mdb_txn_abort(txn_u); return read_f(ptr_v, 0, 0); @@ -396,7 +396,7 @@ u3_lmdb_read_meta(MDB_env* env_u, MDB_val val_u; if ( (ret_w = mdb_get(txn_u, mdb_u, &key_u, &val_u)) ) { - fprintf(stderr, "lmdb: read failed: %s\n", mdb_strerror(ret_w)); + fprintf(stderr, "lmdb: read failed: %s\r\n", mdb_strerror(ret_w)); mdb_txn_abort(txn_u); return read_f(ptr_v, 0, 0); } @@ -425,7 +425,7 @@ u3_lmdb_save_meta(MDB_env* env_u, // create a write transaction // if ( (ret_w = mdb_txn_begin(env_u, 0, 0, &txn_u)) ) { - fprintf(stderr, "lmdb: meta write: txn_begin fail: %s\n", + fprintf(stderr, "lmdb: meta write: txn_begin fail: %s\r\n", mdb_strerror(ret_w)); return c3n; } @@ -433,7 +433,7 @@ u3_lmdb_save_meta(MDB_env* env_u, // opens the database in the transaction // if ( (ret_w = mdb_dbi_open(txn_u, "META", MDB_CREATE, &mdb_u)) ) { - fprintf(stderr, "lmdb: meta write: dbi_open fail: %s\n", + fprintf(stderr, "lmdb: meta write: dbi_open fail: %s\r\n", mdb_strerror(ret_w)); mdb_txn_abort(txn_u); return c3n; @@ -446,7 +446,7 @@ u3_lmdb_save_meta(MDB_env* env_u, MDB_val val_u = { .mv_size = val_i, .mv_data = val_p }; if ( (ret_w = mdb_put(txn_u, mdb_u, &key_u, &val_u, 0)) ) { - fprintf(stderr, "lmdb: write failed: %s\n", mdb_strerror(ret_w)); + fprintf(stderr, "lmdb: write failed: %s\r\n", mdb_strerror(ret_w)); mdb_txn_abort(txn_u); return c3n; } @@ -455,7 +455,7 @@ u3_lmdb_save_meta(MDB_env* env_u, // commit txn // if ( (ret_w = mdb_txn_commit(txn_u)) ) { - fprintf(stderr, "lmdb: meta write: commit failed: %s\n", + fprintf(stderr, "lmdb: meta write: commit failed: %s\r\n", mdb_strerror(ret_w)); return c3n; } diff --git a/pkg/urbit/vere/disk.c b/pkg/urbit/vere/disk.c index feea9697f1..2d494c4374 100644 --- a/pkg/urbit/vere/disk.c +++ b/pkg/urbit/vere/disk.c @@ -692,7 +692,7 @@ u3_disk_init(c3_c* pax_c, u3_disk_cb cb_u) // { if ( 0 == (log_u->dir_u = u3_foil_folder(pax_c)) ) { - fprintf(stderr, "disk: failed to load pier at %s", pax_c); + fprintf(stderr, "disk: failed to load pier at %s\r\n", pax_c); c3_free(log_u); return 0; } @@ -707,7 +707,7 @@ u3_disk_init(c3_c* pax_c, u3_disk_cb cb_u) strcat(urb_c, "/.urb"); if ( 0 == (log_u->urb_u = u3_foil_folder(urb_c)) ) { - fprintf(stderr, "disk: failed to load /.urb in %s", pax_c); + fprintf(stderr, "disk: failed to load /.urb in %s\r\n", pax_c); c3_free(urb_c); c3_free(log_u); return 0; @@ -740,7 +740,7 @@ u3_disk_init(c3_c* pax_c, u3_disk_cb cb_u) strcat(log_c, "/.urb/log"); if ( 0 == (log_u->com_u = u3_foil_folder(log_c)) ) { - fprintf(stderr, "disk: failed to load /.urb/log in %s", pax_c); + fprintf(stderr, "disk: failed to load /.urb/log in %s\r\n", pax_c); c3_free(log_c); c3_free(log_u); return 0; @@ -755,7 +755,7 @@ u3_disk_init(c3_c* pax_c, u3_disk_cb cb_u) const size_t siz_i = 1099511627776; if ( 0 == (log_u->mdb_u = u3_lmdb_init(log_c, siz_i)) ) { - fprintf(stderr, "disk: failed to initialize database"); + fprintf(stderr, "disk: failed to initialize database\r\n"); c3_free(log_c); c3_free(log_u); return 0; @@ -772,7 +772,7 @@ u3_disk_init(c3_c* pax_c, u3_disk_cb cb_u) c3_d fir_d; if ( c3n == u3_lmdb_gulf(log_u->mdb_u, &fir_d, &log_u->dun_d) ) { - fprintf(stderr, "disk: failed to load latest event from database"); + fprintf(stderr, "disk: failed to load latest event from database\r\n"); c3_free(log_u); return 0; } From e4de1538246dc1829e248eb4071552a96ff70f5a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 23 Jul 2020 21:49:13 -0700 Subject: [PATCH 103/933] vere: bail on failed pier initialization --- pkg/urbit/vere/pier.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index 9c66b5315a..fe3b1be7f7 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -1210,7 +1210,13 @@ _pier_init(c3_w wag_w, c3_c* pax_c) u3_pier* u3_pier_stay(c3_w wag_w, u3_noun pax) { - u3_pier* pir_u = _pier_init(wag_w, u3r_string(pax)); + u3_pier* pir_u; + + if ( !(pir_u = _pier_init(wag_w, u3r_string(pax))) ) { + fprintf(stderr, "pier: stay: init fail\r\n"); + u3_king_bail(); + return 0; + } if ( c3n == u3_disk_read_meta(pir_u->log_u, pir_u->who_d, &pir_u->fak_o, &pir_u->lif_w) ) @@ -1420,7 +1426,13 @@ u3_pier_boot(c3_w wag_w, // config flags u3_noun pil, // type-of/path-to pill u3_noun pax) // path to pier { - u3_pier* pir_u = _pier_init(wag_w, u3r_string(pax)); + u3_pier* pir_u; + + if ( !(pir_u = _pier_init(wag_w, u3r_string(pax))) ) { + fprintf(stderr, "pier: boot: init fail\r\n"); + u3_king_bail(); + return 0; + } if ( c3n == _pier_boot_plan(pir_u, who, ven, pil) ) { fprintf(stderr, "pier: boot plan fail\r\n"); From fc92fd36111afc01292b8f7175611f1ebc788f82 Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Fri, 24 Jul 2020 16:29:39 -0700 Subject: [PATCH 104/933] king: use c vere's heuristics for finding the serf binary --- pkg/hs/urbit-king/TODO.md | 6 ------ pkg/hs/urbit-king/lib/Urbit/King/Config.hs | 2 +- pkg/hs/urbit-king/lib/Urbit/King/Main.hs | 2 +- pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs | 13 ++++++++++--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/pkg/hs/urbit-king/TODO.md b/pkg/hs/urbit-king/TODO.md index f1a292b859..d76f845308 100644 --- a/pkg/hs/urbit-king/TODO.md +++ b/pkg/hs/urbit-king/TODO.md @@ -63,12 +63,6 @@ Polish: changed too quickly. -# Finding the Serf Executable - -- [ ] Right now, `urbit-worker` is found by looking it up in the PATH. This - is wrong, but what is right? - - # Take Advantage of New IPC Features - [ ] Hook up `scry` to drivers. diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Config.hs b/pkg/hs/urbit-king/lib/Urbit/King/Config.hs index 7cb9ceb2c9..4ccece736d 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Config.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Config.hs @@ -14,7 +14,7 @@ import qualified Urbit.Vere.Serf as Serf data PierConfig = PierConfig { _pcPierPath :: FilePath , _pcDryRun :: Bool - , _pcSerfExe :: Text + , _pcSerfExe :: Maybe Text , _pcSerfFlags :: [Serf.Flag] } deriving (Show) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs index 2fb280d2da..4e2def18d5 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs @@ -144,7 +144,7 @@ toPierConfig pierPath o@(CLI.Opts{..}) = PierConfig { .. } where _pcPierPath = pierPath _pcDryRun = oDryRun || isJust oDryFrom - _pcSerfExe = fromMaybe "urbit-worker" oSerfExe + _pcSerfExe = oSerfExe _pcSerfFlags = toSerfFlags o toNetworkConfig :: CLI.Opts -> NetworkConfig diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs index 78b6d9e5da..bf8c4ae252 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs @@ -122,17 +122,24 @@ runSerf -> RAcquire e Serf runSerf vSlog pax = do env <- ask - Serf.withSerf (config env) + heuSerf <- heuristicallyFindSerf + Serf.withSerf (config env heuSerf) where slog txt = atomically (readTVar vSlog) >>= (\f -> f txt) - config env = Serf.Config - { scSerf = env ^. pierConfigL . pcSerfExe . to unpack + config env heuSerf = Serf.Config + { scSerf = env ^. pierConfigL . pcSerfExe . to (unpack . fromMaybe heuSerf) , scPier = pax , scFlag = env ^. pierConfigL . pcSerfFlags , scSlog = \(pri, tank) -> printTank slog pri tank , scStdr = \txt -> slog (txt <> "\r\n") , scDead = pure () -- TODO: What can be done? } + heuristicallyFindSerf = serfPrgm <$> listToMaybe <$> getArgs + serfPrgm = \case + Just (stripSuffix "urbit" -> Just pfix) -> pfix <> "urbit-worker" + Just (stripSuffix "urbit-king" -> Just pfix) -> pfix <> "urbit-worker" + _ -> "urbit-worker" + -- Boot a new ship. ------------------------------------------------------------ From 1e995e8f11077a450b52aca42a63dd082d7401ef Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Fri, 24 Jul 2020 21:05:23 -0700 Subject: [PATCH 105/933] king: wtf use getExecutablePath --- pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs index bf8c4ae252..4a954f869e 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs @@ -25,6 +25,8 @@ import Urbit.King.App import Urbit.Vere.Pier.Types import Control.Monad.STM (retry) +import System.Environment (getExecutablePath) +import System.FilePath (splitFileName, ()) import System.Posix.Files (ownerModes, setFileMode) import Urbit.EventLog.LMDB (EventLog) import Urbit.King.API (TermConn) @@ -122,24 +124,25 @@ runSerf -> RAcquire e Serf runSerf vSlog pax = do env <- ask - heuSerf <- heuristicallyFindSerf - Serf.withSerf (config env heuSerf) + serfProg <- io getSerfProg + Serf.withSerf (config env serfProg) where slog txt = atomically (readTVar vSlog) >>= (\f -> f txt) - config env heuSerf = Serf.Config - { scSerf = env ^. pierConfigL . pcSerfExe . to (unpack . fromMaybe heuSerf) + config env serfProg = Serf.Config + { scSerf = env ^. pierConfigL . pcSerfExe . to (maybe serfProg unpack) , scPier = pax , scFlag = env ^. pierConfigL . pcSerfFlags , scSlog = \(pri, tank) -> printTank slog pri tank , scStdr = \txt -> slog (txt <> "\r\n") , scDead = pure () -- TODO: What can be done? } - heuristicallyFindSerf = serfPrgm <$> listToMaybe <$> getArgs - serfPrgm = \case - Just (stripSuffix "urbit" -> Just pfix) -> pfix <> "urbit-worker" - Just (stripSuffix "urbit-king" -> Just pfix) -> pfix <> "urbit-worker" - _ -> "urbit-worker" - + getSerfProg :: IO FilePath + getSerfProg = do + (path, filename) <- splitFileName <$> getExecutablePath + pure $ case filename of + "urbit" -> path "urbit-worker" + "urbit-king" -> path "urbit-worker" + _ -> "urbit-worker" -- Boot a new ship. ------------------------------------------------------------ From c2df8f49d06943a130337b3a49303c03fe17e289 Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 27 Jul 2020 16:36:35 +0200 Subject: [PATCH 106/933] vere: fix refcounting in _ames_forward Make sure we fully lose the list of lanes that's passed in, not just the individual items. --- pkg/urbit/vere/io/ames.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 91ebbebb1c..c1e1fe5d60 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -627,12 +627,13 @@ _ames_forward(u3_panc* pac_u, u3_noun las) } { + u3_noun los = las; u3_noun pac = _ames_serialize_packet(pac_u, c3y); while (u3_nul != las) { - _ames_ef_send(pac_u->sam_u, u3h(las), u3k(pac)); + _ames_ef_send(pac_u->sam_u, u3k(u3h(las)), u3k(pac)); las = u3t(las); } - u3z(pac); + u3z(los); u3z(pac); } pac_u->sam_u->foq_d--; From 231ea7715d05af31aa9de403da990673d74bd887 Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 27 Jul 2020 16:56:26 +0200 Subject: [PATCH 107/933] vere: include forwarding and filtering in stats Print statistics for recently added behavior in _ames_io_info. --- pkg/urbit/vere/io/ames.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index c1e1fe5d60..4c0dde6851 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -1089,8 +1089,13 @@ static void _ames_io_info(u3_auto* car_u) { u3_ames* sam_u = (u3_ames*)car_u; - u3l_log(" dropped: %" PRIu64 "\n", sam_u->dop_d); - u3l_log(" crashed: %" PRIu64 "\n", sam_u->fal_d); + u3l_log(" dropped: %" PRIu64 "\n", sam_u->dop_d); + u3l_log(" forwards dropped: %" PRIu64 "\n", sam_u->fod_d); + u3l_log(" forwards pending: %" PRIu64 "\n", sam_u->foq_d); + u3l_log(" forwarded: %" PRIu64 "\n", sam_u->fow_d); + u3l_log(" filtered (ver): %" PRIu64 "\n", sam_u->vet_d); + u3l_log(" filtered (mug): %" PRIu64 "\n", sam_u->mut_d); + u3l_log(" crashed: %" PRIu64 "\n", sam_u->fal_d); } /* u3_ames_io_init(): initialize ames I/O. From 176ed23c85d182fa738429707f5ba08549b6dc3a Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 27 Jul 2020 17:24:33 +0200 Subject: [PATCH 108/933] vere: parse packet header only once Instead of picking out the protocol version separately from building the u3_head struct, parse into that struct once, and then use that going forward. --- pkg/urbit/vere/io/ames.c | 41 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 4c0dde6851..27c49e6813 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -679,20 +679,36 @@ _ames_recv_cb(uv_udp_t* wax_u, unsigned flg_i) { u3_ames* sam_u = wax_u->data; - - c3_o pas_o = c3y; + c3_o pas_o = c3y; + c3_y* byt_y = (c3_y*)buf_u->base; + c3_y* bod_y = byt_y + 4; + u3_head hed_u; // ensure a sane message size // if (4 >= nrd_i) { pas_o = c3n; } + // unpack the packet header + // + else { + c3_w hed_w = (byt_y[0] << 0) + | (byt_y[1] << 8) + | (byt_y[2] << 16) + | (byt_y[3] << 24); + + hed_u.ver_y = hed_w & 0x7; + hed_u.mug_l = (hed_w >> 3) & ((1 << 20) - 1); + hed_u.sac_y = (hed_w >> 23) & 0x3; + hed_u.rac_y = (hed_w >> 25) & 0x3; + hed_u.enc_o = (hed_w >> 27) & 0x1; + } // ensure the protocol version matches ours // if ( c3y == pas_o && (c3y == sam_u->fit_o) - && (sam_u->ver_y != (0x7 & *((c3_w*)buf_u->base))) ) + && (sam_u->ver_y != hed_u.ver_y) ) { pas_o = c3n; @@ -703,25 +719,6 @@ _ames_recv_cb(uv_udp_t* wax_u, } if (c3y == pas_o) { - c3_y* byt_y = (c3_y*)buf_u->base; - c3_y* bod_y = byt_y + 4; - u3_head hed_u; - - // unpack the packet header - // - { - c3_w hed_w = (byt_y[0] << 0) - | (byt_y[1] << 8) - | (byt_y[2] << 16) - | (byt_y[3] << 24); - - hed_u.ver_y = hed_w & 0x7; - hed_u.mug_l = (hed_w >> 3) & ((1 << 20) - 1); - hed_u.sac_y = (hed_w >> 23) & 0x3; - hed_u.rac_y = (hed_w >> 25) & 0x3; - hed_u.enc_o = (hed_w >> 27) & 0x1; - } - // ensure the mug is valid // if ( hed_u.mug_l != _ca_mug_body(nrd_i - 4, bod_y) ) { From 46966c20677a88659f2bc649606ca3992af631f7 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 27 Jul 2020 11:59:04 -0700 Subject: [PATCH 109/933] pill: updates all --- bin/brass.pill | 4 ++-- bin/ivory.pill | 4 ++-- bin/solid.pill | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/brass.pill b/bin/brass.pill index 49f198b642..1fb9455f0b 100644 --- a/bin/brass.pill +++ b/bin/brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5f283336929733f6492f7fe230c949749cea43c8a1fb18959742b2ff88e9d239 -size 10418083 +oid sha256:fb5f4e0d57a17d068f7606dc245ec786862b5522a6d6a78484c10b804df55c6e +size 4453633 diff --git a/bin/ivory.pill b/bin/ivory.pill index 46e236c236..2c6600ce55 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8d2579ed2b72828ced40789c0eae516a832c66f8f9dcd06af4ba5ec4cb4e2ac6 -size 1236461 +oid sha256:85706d503bd88b8a78224aa97b09d2b5b004afff7ca9d28680f8ddb7eff36f56 +size 1311412 diff --git a/bin/solid.pill b/bin/solid.pill index 3ba74e4e18..3d7c973a08 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f850ff15c0dff1814039240e00dc0ebe8d8328064e76faaa24d06df348b89078 -size 12878034 +oid sha256:9f23812618c63622aee1a56deafb066cb41915db0f8250ba8ad91b57d04fcd8f +size 6181413 From 3af8c7c88bf493358e6ea1c1e70b82e5e036f4ea Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 27 Jul 2020 17:39:16 +0200 Subject: [PATCH 110/933] vere: keep pending forwards out of loom Use C structures for storing the packets-pending-forward, instead of keeping them around as nouns. Also adds a check to make sure the content is cue-able, dropping the packet early if it isn't. --- pkg/urbit/vere/io/ames.c | 220 ++++++++++++++++++++++----------------- 1 file changed, 122 insertions(+), 98 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 27c49e6813..88f6a71c02 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -68,9 +68,10 @@ typedef struct _u3_panc u3_panc; /* u3_body: ames packet body */ typedef struct _u3_body { - u3_noun sen; // sender - u3_noun rec; // receiver - u3_noun con; // (jam [origin content]) + c3_d sen_d[2]; // sender + c3_d rec_d[2]; // receiver + c3_w con_w; // jam size + c3_y* con_y; // (jam [origin content]) } u3_body; /* u3_panc: deconstructed incoming packet @@ -124,9 +125,7 @@ _ames_panc_free(u3_panc* pac_u) { } u3z(pac_u->ore); - u3z(pac_u->bod_u.sen); - u3z(pac_u->bod_u.rec); - u3z(pac_u->bod_u.con); + c3_free(pac_u->bod_u.con_y); c3_free(pac_u); } @@ -330,7 +329,8 @@ _ames_serialize_packet(u3_panc* pac_u, c3_o dop_o) // u3_noun lon, bod; { - u3_noun old = u3qe_cue(pac_u->bod_u.con); + //NOTE we checked for cue safety in _ames_recv_cb + u3_noun old = u3ke_cue(u3i_bytes(pac_u->bod_u.con_w, pac_u->bod_u.con_y)); u3x_cell(old, &lon, &bod); u3k(lon); u3k(bod); u3z(old); @@ -347,8 +347,12 @@ _ames_serialize_packet(u3_panc* pac_u, c3_o dop_o) lon = u3nt(u3_nul, c3n, u3k(pac_u->ore)); nal_o = c3y; - u3z(pac_u->bod_u.con); - pac_u->bod_u.con = u3ke_jam(u3nc(lon, bod)); + c3_free(pac_u->bod_u.con_y); + u3_noun jam = u3ke_jam(u3nc(lon, bod)); + pac_u->bod_u.con_w = u3r_met(3, jam); + pac_u->bod_u.con_y = c3_malloc(pac_u->bod_u.con_w); + u3r_bytes(0, pac_u->bod_u.con_w, pac_u->bod_u.con_y, jam); + u3z(jam); } else { u3z(lon); u3z(bod); @@ -362,17 +366,20 @@ _ames_serialize_packet(u3_panc* pac_u, c3_o dop_o) // start with the body // u3_body* bod_u = &pac_u->bod_u; - c3_w bod_w = u3r_met(3, bod_u->con); - - c3_y* pac_y = c3_malloc( 4 + sen_y + rec_y + bod_w ); - u3r_bytes(0, sen_y, pac_y + 4, bod_u->sen); - u3r_bytes(0, rec_y, pac_y + 4 + sen_y, bod_u->rec); - u3r_bytes(0, bod_w, pac_y + 4 + sen_y + rec_y, bod_u->con); + c3_y* pac_y = c3_malloc(4 + sen_y + rec_y + bod_u->con_w); + { + u3_atom sen = u3i_chubs(2, bod_u->sen_d); + u3_atom rec = u3i_chubs(2, bod_u->rec_d); + u3r_bytes(0, sen_y, pac_y + 4, sen); + u3r_bytes(0, rec_y, pac_y + 4 + sen_y, rec); + u3z(sen); u3z(rec); + } + memcpy(pac_y + 4 + sen_y + rec_y, bod_u->con_y, bod_u->con_w); // if we updated the origin lane, we need to update the mug too // if (c3y == nal_o) { - u3_noun bod = u3i_bytes(sen_y + rec_y + bod_w, pac_y + 4); + u3_noun bod = u3i_bytes(sen_y + rec_y + bod_u->con_w, pac_y + 4); pac_u->hed_u.mug_l = u3r_mug(bod) & ((1 << 20) - 1); u3z(bod); } @@ -388,7 +395,7 @@ _ames_serialize_packet(u3_panc* pac_u, c3_o dop_o) memcpy(pac_y, &hed_w, 4); - pac = u3i_bytes(4 + sen_y + rec_y + bod_w, pac_y); + pac = u3i_bytes(4 + sen_y + rec_y + bod_u->con_w, pac_y); c3_free(pac_y); } @@ -718,98 +725,114 @@ _ames_recv_cb(uv_udp_t* wax_u, } } + // ensure the mug is valid + // + if ( c3y == pas_o + && (hed_u.mug_l != _ca_mug_body(nrd_i - 4, bod_y)) ) + { + pas_o = c3n; + + sam_u->mut_d++; + if ( 0 == (sam_u->mut_d % 100) ) { + u3l_log("ames: %" PRIu64 " dropped for invalid mug\n", sam_u->mut_d); + } + } + + // unpack the body + // + c3_y sen_y = 2 << hed_u.sac_y; + c3_y rec_y = 2 << hed_u.rac_y; + c3_d sen_d[2]; + c3_d rec_d[2]; + c3_w con_w = nrd_i - 4 - sen_y - rec_y; + c3_y* con_y = NULL; if (c3y == pas_o) { - // ensure the mug is valid + u3_noun sen = u3i_bytes(sen_y, bod_y); + u3_noun rec = u3i_bytes(rec_y, bod_y + sen_y); + u3r_chubs(0, 2, rec_d, rec); + u3r_chubs(0, 2, sen_d, sen); + u3z(sen); u3z(rec); + + con_y = c3_malloc(con_w); + memcpy(con_y, bod_y + sen_y + rec_y, con_w); + + // ensure the content is cue-able // - if ( hed_u.mug_l != _ca_mug_body(nrd_i - 4, bod_y) ) { + u3_noun con = u3i_bytes(con_w, con_y); + u3_noun pro = u3m_soft(0, u3qe_cue, con); + if (u3_blip != u3h(pro)) { pas_o = c3n; - sam_u->mut_d++; - if ( 0 == (sam_u->mut_d % 100) ) { - u3l_log("ames: %" PRIu64 " dropped for invalid mug\n", sam_u->mut_d); + } + u3z(pro); + } + + // if we can scry, + // and we are not the recipient, + // we might want to forward statelessly + // + if ( c3y == pas_o + && c3y == sam_u->see_o + && ( (rec_d[0] != sam_u->pir_u->who_d[0]) + || (rec_d[1] != sam_u->pir_u->who_d[1]) ) ) + { + pas_o = c3n; + + // if the queue is full, and we can't forward synchronously, + // just drop the packet + // + //TODO drop oldest item in forward queue in favor of this one. + // ames.c doesn't/shouldn't know about the shape of scry events, + // so can't pluck these out of the event queue like it does in + // _ames_cap_queue. as such, blocked on u3_lord_peek_cancel or w/e. + // + if ( (1000 < sam_u->foq_d) + && !(rec_d[1] == 0 && (256 > rec_d[0])) ) + { + c3_free(con_y); + + sam_u->fod_d++; + if ( 0 == (sam_u->fod_d % 1000) ) { + u3l_log("ames: dropped %" PRIu64 " forwards total\n", sam_u->fod_d); } } - // if we can scry, we might want to forward statelessly + // otherwise, proceed with forwarding // - else if (c3y == sam_u->see_o) { - c3_y sen_y = 2 << hed_u.sac_y; - c3_y rec_y = 2 << hed_u.rac_y; + else { + sam_u->foq_d++; - u3_noun sen = u3i_bytes(sen_y, bod_y); - u3_noun rec = u3i_bytes(rec_y, bod_y + sen_y); - - c3_d rec_d[2]; - u3r_chubs(0, 2, rec_d, rec); - - // if we are the recipient, simply let it pass the filter + // store the packet details for later processing // - if ( (rec_d[0] == sam_u->pir_u->who_d[0]) - && (rec_d[1] == sam_u->pir_u->who_d[1]) ) - { - u3z(sen); u3z(rec); + u3_panc* pac_u = c3_calloc(sizeof(*pac_u)); + pac_u->sam_u = sam_u; + pac_u->hed_u = hed_u; + pac_u->bod_u.sen_d[0] = sen_d[0]; + pac_u->bod_u.sen_d[1] = sen_d[1]; + pac_u->bod_u.rec_d[0] = rec_d[0]; + pac_u->bod_u.rec_d[1] = rec_d[1]; + pac_u->bod_u.con_w = con_w; + pac_u->bod_u.con_y = con_y; + pac_u->ore = _ames_lane_from_sockaddr((struct sockaddr_in *)adr_u); + + if (0 != sam_u->pac_u) { + pac_u->nex_u = sam_u->pac_u; + sam_u->pac_u->pre_u = pac_u; } - // if we are not the recipient, attempt to forward statelessly + sam_u->pac_u = pac_u; + + // if the recipient is a galaxy, their lane is always &+~gax + // + if ( (rec_d[1] == 0) && (256 > rec_d[0]) ) { + _ames_forward(pac_u, u3nc(u3nc(c3y, rec_d[0]), u3_nul)); + } + // otherwise, if there's space in the queue, scry the lane out of ames // else { - pas_o = c3n; - - // if the queue is full, and we can't forward synchronously, - // just drop the packet - // - //TODO drop oldest item in forward queue in favor of this one. - // ames.c doesn't/shouldn't know about the shape of scry events, - // so can't pluck these out of the event queue like it does in - // _ames_cap_queue. as such, blocked on u3_lord_peek_cancel or w/e. - // - if ( (1000 < sam_u->foq_d) - && !((c3y == u3a_is_cat(rec)) && (256 > rec)) ) - { - sam_u->fod_d++; - if ( 0 == (sam_u->fod_d % 1000) ) { - u3l_log("ames: dropped %" PRIu64 " forwards total\n", sam_u->fod_d); - } - - u3z(sen); u3z(rec); - } - // otherwise, proceed with forwarding - // - else { - sam_u->foq_d++; - - // store the packet details for later processing - // - u3_noun con = u3i_bytes(nrd_i - 4 - sen_y - rec_y, - bod_y + sen_y + rec_y); - u3_panc* pac_u = c3_calloc(sizeof(*pac_u)); - pac_u->sam_u = sam_u; - pac_u->hed_u = hed_u; - pac_u->bod_u.sen = sen; - pac_u->bod_u.rec = rec; - pac_u->bod_u.con = con; - pac_u->ore = _ames_lane_from_sockaddr((struct sockaddr_in *)adr_u); - - if (0 != sam_u->pac_u) { - pac_u->nex_u = sam_u->pac_u; - sam_u->pac_u->pre_u = pac_u; - } - sam_u->pac_u = pac_u; - - // if the recipient is a galaxy, their lane is always &+~gax - // - if ( (c3y == u3a_is_cat(rec)) - && (256 > rec) ) { - _ames_forward(pac_u, u3nc(u3nc(c3y, u3k(rec)), u3_nul)); - } - // otherwise, if there's space in the queue, scry the lane out of ames - // - else { - u3_noun pax = u3nq(u3i_string("peers"), - u3dc("scot", 'p', u3k(rec)), - u3i_string("forward-lane"), - u3_nul); - u3_lord_peek_last(sam_u->pir_u->god_u, u3_nul, c3_s2('a', 'x'), - u3_nul, pax, pac_u, _ames_lane_scry_cb); - } - } + u3_noun pax = u3nq(u3i_string("peers"), + u3dc("scot", 'p', u3i_chubs(2, rec_d)), + u3i_string("forward-lane"), + u3_nul); + u3_lord_peek_last(sam_u->pir_u->god_u, u3_nul, c3_s2('a', 'x'), + u3_nul, pax, pac_u, _ames_lane_scry_cb); } } } @@ -817,6 +840,7 @@ _ames_recv_cb(uv_udp_t* wax_u, // if we passed the filter, inject the packet // if (c3y == pas_o) { + c3_free(con_y); u3_noun ore = _ames_lane_from_sockaddr((struct sockaddr_in *)adr_u); u3_noun msg = u3i_bytes((c3_w)nrd_i, (c3_y*)buf_u->base); _ames_put_packet(sam_u, msg, ore); From 58f8fe04ec8dc54762695dee92a6aff301bc247f Mon Sep 17 00:00:00 2001 From: botter-nidnul <55599302+botter-nidnul@users.noreply.github.com> Date: Mon, 27 Jul 2020 22:06:36 -0500 Subject: [PATCH 111/933] vere: change lmdb mapsize for aarch64 Adds aarch64 lines to pkg/urbit/configure and defines a new macro, U3_CPU_aarch64. That macro is used in pkg/urbit/vere/disk.c to change the lmdb mapsize from 1TB to 60GB for aarch64 on linux. Uses #if defined instead of #ifdef in anticipation of aarch64 on macos being a thing before the end of the year. --- pkg/urbit/configure | 4 ++++ pkg/urbit/vere/disk.c | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/urbit/configure b/pkg/urbit/configure index 6157fb544b..23c9dd579a 100755 --- a/pkg/urbit/configure +++ b/pkg/urbit/configure @@ -46,6 +46,10 @@ case $(tr A-Z a-z <<< $cpu) in x86_64) defmacro U3_OS_ENDIAN_little 1 ;; + aarch64) + defmacro U3_OS_ENDIAN_little 1 + defmacro U3_CPU_aarch64 1 + ;; *) echo "Unknown or unsupported CPU: '$cpu'" >&2 exit 1 diff --git a/pkg/urbit/vere/disk.c b/pkg/urbit/vere/disk.c index feea9697f1..41c8d96b4e 100644 --- a/pkg/urbit/vere/disk.c +++ b/pkg/urbit/vere/disk.c @@ -752,7 +752,11 @@ u3_disk_init(c3_c* pax_c, u3_disk_cb cb_u) // "[..] on 64-bit there is no penalty for making this huge (say 1TB)." // { - const size_t siz_i = 1099511627776; + #if defined(U3_CPU_aarch64) && defined(U3_OS_linux) + const size_t siz_i = 64424509440; + #else + const size_t siz_i = 1099511627776; + #endif if ( 0 == (log_u->mdb_u = u3_lmdb_init(log_c, siz_i)) ) { fprintf(stderr, "disk: failed to initialize database"); From 790e2dd5ec58e908c18c78bca3f3eec587ba27e5 Mon Sep 17 00:00:00 2001 From: botter-nidnul <55599302+botter-nidnul@users.noreply.github.com> Date: Mon, 27 Jul 2020 22:59:46 -0500 Subject: [PATCH 112/933] libsigsegv: disable stack vma check on arm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds the equivalent arm patches to the i386 patches added in #3054 These result in a dramatic speedup in running `=a (bex 1.000.000.000)` just as they do on x86_x64 This also sneaks in a hack to `/nix/nixcrpkgs/pkgs/libsigsegv/builder.sh` that allows libsigsegv to configure itself properly when cross compiling release binaries from x86_64 to aarch64. It won’t trigger for you, since you’re not doing that (yet) but it will make it a little easier for me to maintain my aarch64 static release binaries if that `if [ $host = aarch64-linux-musleabi ]` section is upstreamed. --- nix/nixcrpkgs/pkgs/libsigsegv/builder.sh | 24 ++++++++++++++++++++++-- nix/pkgs/urbit/libsigsegv_fix.patch | 10 ++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/nix/nixcrpkgs/pkgs/libsigsegv/builder.sh b/nix/nixcrpkgs/pkgs/libsigsegv/builder.sh index 39d7ddc016..f5e7072de6 100644 --- a/nix/nixcrpkgs/pkgs/libsigsegv/builder.sh +++ b/nix/nixcrpkgs/pkgs/libsigsegv/builder.sh @@ -3,7 +3,7 @@ source $setup tar -xf $src cd libsigsegv-$version -patch -p1 << 'HEREDOC' +patch -p1 << 'PATCH_I386' --- a/src/fault-linux-i386.h 2020-06-25 23:46:02.099235491 +0000 +++ b/src/fault-linux-i386.h 2020-06-25 23:45:48.679156892 +0000 @@ -18,6 +18,7 @@ @@ -14,12 +14,32 @@ patch -p1 << 'HEREDOC' #if defined __x86_64__ /* 64 bit registers */ -HEREDOC +PATCH_I386 +patch -p1 << 'PATCH_ARM' +--- a/src/fault-linux-arm.h ++++ b/src/fault-linux-arm.h +@@ -17,6 +17,7 @@ + + #include "fault-posix-ucontext.h" + ++#define HAVE_STACKVMA 0 + #if defined(__aarch64__) || defined(__ARM_64BIT_STATE) || defined(__ARM_PCS_AAPCS64) /* 64-bit */ + + /* See glibc/sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h. + +PATCH_ARM cd .. mkdir build cd build +# Hack +if [ $host = aarch64-linux-musleabi ] +then + sed -i 's/^CFG_FAULT=$/CFG_FAULT=fault-linux-arm.h/' \ + ../libsigsegv-$version/configure +fi + ../libsigsegv-$version/configure \ --host=$host \ --prefix=$out \ diff --git a/nix/pkgs/urbit/libsigsegv_fix.patch b/nix/pkgs/urbit/libsigsegv_fix.patch index a3b630860d..3f69cef520 100644 --- a/nix/pkgs/urbit/libsigsegv_fix.patch +++ b/nix/pkgs/urbit/libsigsegv_fix.patch @@ -7,4 +7,14 @@ +#define HAVE_STACKVMA 0 #if defined __x86_64__ /* 64 bit registers */ + +--- a/src/fault-linux-arm.h ++++ b/src/fault-linux-arm.h +@@ -17,6 +17,7 @@ + #include "fault-posix-ucontext.h" + ++#define HAVE_STACKVMA 0 + #if defined(__aarch64__) || defined(__ARM_64BIT_STATE) || defined(__ARM_PCS_AAPCS64) /* 64-bit */ + + /* See glibc/sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h. From d7b94e12192716c866148a8489430db3bc0c1b9e Mon Sep 17 00:00:00 2001 From: botter <55599302+botter-nidnul@users.noreply.github.com> Date: Tue, 28 Jul 2020 02:12:36 -0500 Subject: [PATCH 113/933] pkg/urbit/configure: cpu=$(uname -m) make pkg/urbit/configure actually able to detect CPU architecture when $HOST doesn't exist --- pkg/urbit/configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/urbit/configure b/pkg/urbit/configure index 23c9dd579a..e7c2def8c9 100755 --- a/pkg/urbit/configure +++ b/pkg/urbit/configure @@ -30,7 +30,7 @@ if [ -n "${HOST-}" ] then os=$(sed 's$^[^-]*-\([^-]*\)-.*$\1$' <<< "$HOST") cpu=$(sed 's$-.*$$' <<< ${HOST}) else os=$(uname -s) - cpu=$(uname -p) + cpu=$(uname -m) fi case $(tr A-Z a-z <<< $cpu) in From 89967db876784502e6259d91e3bf0ec8f6b39c35 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 28 Jul 2020 14:06:00 -0700 Subject: [PATCH 114/933] ur: adds initial, untested hash-consing module --- pkg/urbit/include/ur/hashcons.h | 95 ++++++++ pkg/urbit/ur/hashcons.c | 390 ++++++++++++++++++++++++++++++++ 2 files changed, 485 insertions(+) create mode 100644 pkg/urbit/include/ur/hashcons.h create mode 100644 pkg/urbit/ur/hashcons.c diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h new file mode 100644 index 0000000000..c3f7143b19 --- /dev/null +++ b/pkg/urbit/include/ur/hashcons.h @@ -0,0 +1,95 @@ +#include +#include +#include + +typedef uint8_t ur_bool_t; + +#if (32 == (CHAR_BIT * __SIZEOF_INT__)) +# define ur_lz32 __builtin_ctz +#elif (32 == (CHAR_BIT * __SIZEOF_LONG__)) +# define ur_lz32 __builtin_ctzl +#else +# error "port me" +#endif + +#if (64 == (CHAR_BIT * __SIZEOF_LONG__)) +# define ur_lz64 __builtin_ctzl +#elif (64 == (CHAR_BIT * __SIZEOF_LONG_LONG__)) +# define ur_lz64 __builtin_ctzll +#else +# error "port me" +#endif + +#define ur_mask_3(a) (a & 0x7) +#define ur_mask_8(a) (a & 0xff) +#define ur_mask_31(a) (a & 0x7fffffff) +#define ur_mask_62(a) (a & 0x3fffffffffffffffULL) + +#define ur_met0_32(a) ( 32 - ur_lz32(a) ) +#define ur_met0_64(a) ( 64 - ur_lz64(a) ) + +#define ur_met3_32(a) \ + ({ uint8_t _a = ur_met0_32(a); \ + ( (_a >> 3) + !!ur_mask_3(_a) ); }) \ + +#define ur_met3_64(a) \ + ({ uint8_t _a = ur_met0_64(a); \ + ( (_a >> 3) + !!ur_mask_3(_a) ); }) \ + +#define ur_nref_tag(ref) ( ref >> 62 ) +#define ur_nref_idx(ref) ur_mask_62(ref) + +typedef struct ur_pail32_s { + uint8_t fill; + uint32_t data[10]; +} ur_pail32_t; + +typedef struct ur_dict32_s { + uint64_t prev; + uint64_t size; + ur_pail32_t *buckets; +} ur_dict32_t; + +typedef struct ur_pail64_s { + uint8_t fill; + uint64_t data[10]; +} ur_pail64_t; + +typedef struct ur_dict64_s { + uint64_t prev; + uint64_t size; + ur_pail64_t *buckets; +} ur_dict64_t; + +typedef uint32_t ur_mug; +typedef uint64_t ur_nref; +typedef enum { + ur_direct = 0, + ur_iatom = 1, + ur_icell = 2, +} ur_tag; + +typedef struct ur_cells_s { + ur_dict64_t dict; + uint64_t prev; + uint64_t size; + uint64_t fill; + ur_mug *mugs; + ur_nref *heads; + ur_nref *tails; +} ur_cells_t; + +typedef struct ur_atoms_s { + ur_dict64_t dict; + uint64_t prev; + uint64_t size; + uint64_t fill; + ur_mug *mugs; + uint8_t **bytes; + uint64_t *lens; +} ur_atoms_t; + +typedef struct ur_root_s { + ur_cells_t cells; + ur_atoms_t atoms; +} ur_root_t; diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c new file mode 100644 index 0000000000..f97e727671 --- /dev/null +++ b/pkg/urbit/ur/hashcons.c @@ -0,0 +1,390 @@ +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include "noun/hashcons.h" + +ur_mug +ur_mug_bytes(const uint8_t *byt, uint64_t len) +{ + uint32_t seed = 0xcafebabe; + ur_mug mug; + + while ( 1 ) { + uint32_t raw; + MurmurHash3_x86_32(byt, len, seed, &raw); + mug = (raw >> 31) ^ ( ur_mask_31(raw) ); + + if ( 0 == mug ) { + seed++; + } + else { + return mug; + } + } +} + +ur_mug +ur_mug32(uint32_t x) +{ + uint8_t byt[4] = { + ur_mask_8(x >> 0), + ur_mask_8(x >> 8), + ur_mask_8(x >> 16), + ur_mask_8(x >> 24) + }; + + return ur_mug_bytes(byt, ur_met3_32(x)); +} + +ur_mug +ur_mug64(uint64_t x) +{ + uint8_t byt[8] = { + ur_mask_8(x >> 0), + ur_mask_8(x >> 8), + ur_mask_8(x >> 16), + ur_mask_8(x >> 24), + ur_mask_8(x >> 32), + ur_mask_8(x >> 40), + ur_mask_8(x >> 48), + ur_mask_8(x >> 56) + }; + + return ur_mug_bytes(byt, ur_met3_64(x)); +} + +ur_mug +ur_mug_both(ur_mug hed, ur_mug tal) +{ + return ur_mug32(hed ^ (0x7fffffff ^ tal)); +} + +ur_mug +ur_nref_mug(ur_root_t *r, ur_nref ref) +{ + switch ( ur_nref_tag(ref) ) { + default: assert(0); + + case ur_direct: return ur_mug64(ref); + case ur_iatom: return r->atoms.mugs[ur_nref_idx(ref)]; + case ur_icell: return r->cells.mugs[ur_nref_idx(ref)]; + } +} + +ur_bool_t +ur_deep(ur_nref ref) +{ + return ur_icell == ur_nref_tag(ref); +} + +ur_nref +ur_head(ur_root_t *r, ur_nref ref) +{ + assert( ur_deep(ref) ); + return r->cells.heads[ur_nref_idx(ref)]; +} + +ur_nref +ur_tail(ur_root_t *r, ur_nref ref) +{ + assert( ur_deep(ref) ); + return r->cells.tails[ur_nref_idx(ref)]; +} + +void +ur_dict64_grow(ur_root_t *r, ur_dict64_t *dict, uint64_t prev, uint64_t size) +{ + ur_pail64_t *buckets, *old_buckets = dict->buckets; + uint64_t old_size = dict->size; + uint64_t next = prev + size; + uint64_t i; + + buckets = calloc(next, sizeof(*buckets)); + + for ( i = 0; i < old_size; i++ ) { + ur_pail64_t *old_bucket = &(old_buckets[i]); + uint64_t old_fill = old_bucket->fill; + uint64_t j; + + for ( j = 0; j < old_fill; j++ ) { + ur_nref ref = (ur_nref)old_bucket->data[old_fill]; + ur_mug mug = ur_nref_mug(r, ref); + + ur_pail64_t *bucket = &(buckets[ mug % next ]); + uint64_t new_fill = bucket->fill; + + if( 10 == new_fill ) { + free(buckets); + return ur_dict64_grow(r, dict, size, next); + } + + bucket->data[new_fill] = (uint64_t)ref; + bucket->fill = 1 + new_fill; + } + } + + free(old_buckets); + + dict->prev = size; + dict->size = next; + dict->buckets = buckets; +} + +void +ur_atoms_grow(ur_atoms_t *atoms) +{ + uint64_t prev = atoms->prev; + uint64_t size = atoms->size; + uint64_t next = prev + size; + uint8_t **bytes = atoms->bytes; + uint64_t *lens = atoms->lens; + ur_mug *mugs = atoms->mugs; + + atoms->bytes = malloc(next * (sizeof(*atoms->bytes) + + sizeof(*atoms->lens) + + sizeof(*atoms->mugs))); + assert( atoms->bytes ); + + atoms->lens = (void*)(atoms->bytes + (next * sizeof(*atoms->bytes))); + atoms->mugs = (void*)(atoms->lens + (next * sizeof(*atoms->lens))); + + if ( bytes ) { + memcpy(atoms->bytes, bytes, size * (sizeof(*bytes))); + memcpy(atoms->lens, lens, size * (sizeof(*lens))); + memcpy(atoms->mugs, mugs, size * (sizeof(*mugs))); + + free(bytes); + } +} + +void +ur_cells_grow(ur_cells_t *cells) +{ + uint64_t prev = cells->prev; + uint64_t size = cells->size; + uint64_t next = prev + size; + ur_nref *heads = cells->heads; + ur_nref *tails = cells->tails; + ur_mug *mugs = cells->mugs; + + cells->heads = malloc(next * (sizeof(*cells->heads) + + sizeof(*cells->heads) + + sizeof(*cells->mugs))); + assert( cells->heads ); + + cells->tails = (void*)(cells->heads + (next * sizeof(*cells->heads))); + cells->mugs = (void*)(cells->tails + (next * sizeof(*cells->tails))); + + if ( heads ) { + memcpy(cells->heads, heads, size * (sizeof(*heads))); + memcpy(cells->tails, tails, size * (sizeof(*tails))); + memcpy(cells->mugs, mugs, size * (sizeof(*mugs))); + + free(heads); + } +} + +void +ur_bytes(ur_root_t *r, ur_nref ref, uint8_t **byt, uint64_t *len) +{ + assert( !ur_deep(ref) ); + switch ( ur_nref_tag(ref) ) { + default: assert(0); + + case ur_direct: { + *len = ur_met3_64(ref); + // XX little-endian + // + *byt = (uint8_t*)&ref; + } break; + + case ur_iatom: { + uint64_t idx = ur_nref_idx(ref); + *len = r->atoms.lens[idx]; + *byt = r->atoms.bytes[idx]; + } break; + } +} + +static ur_nref +_coin_unsafe(ur_atoms_t *atoms, ur_mug mug, uint8_t *byt, uint64_t len) +{ + uint64_t fill = atoms->fill; + ur_nref tom = ( fill & ((uint64_t)ur_iatom << 62) ); + uint8_t *copy = malloc(len); + + // XX necessary? + // + assert( 62 >= ur_met0_64(fill) ); + + assert(copy); + memcpy(copy, byt, len); + + atoms->bytes[fill] = copy; + atoms->lens[fill] = len; + atoms->mugs[fill] = mug; + + return tom; +} + +static ur_nref +_cons_unsafe(ur_cells_t *cells, ur_mug mug, ur_nref hed, ur_nref tal) +{ + uint64_t fill = cells->fill; + ur_nref cel = ( fill & ((uint64_t)ur_icell << 62) ); + + // XX necessary? + // + assert( 62 >= ur_met0_64(fill) ); + + cells->mugs[fill] = mug; + cells->heads[fill] = hed; + cells->tails[fill] = tal; + cells->fill = 1 + fill; + + return cel; +} + +ur_nref +ur_coin_bytes(ur_root_t *r, uint8_t *byt, uint64_t len) +{ + ur_atoms_t *atoms = &(r->atoms); + ur_dict64_t *dict = &(atoms->dict); + ur_mug mug = ur_mug_bytes(byt, len); + + while ( 1 ) { + uint64_t idx = ( mug % dict->size ); + ur_pail64_t *bucket = &(dict->buckets[idx]); + uint8_t i, b_fill = bucket->fill; + ur_nref tom; + + for ( i = 0; i < b_fill; i++ ) { + uint8_t *t_byt; + uint64_t t_len; + tom = (ur_nref)bucket->data[i]; + + ur_bytes(r, tom, &t_byt, &t_len); + + if ( (t_len == len) + && (0 == memcmp(t_byt, byt, len)) ) + { + return tom; + } + } + + if ( 10 == b_fill ) { + ur_dict64_grow(r, dict, dict->prev, dict->size); + continue; + } + + if ( atoms->fill == atoms->size ) { + ur_atoms_grow(atoms); + } + + tom = _coin_unsafe(atoms, mug, byt, len); + + bucket->data[b_fill] = (uint64_t)tom; + bucket->fill = 1 + b_fill; + + return tom; + } +} + +ur_nref +ur_coin64(ur_root_t *r, uint64_t n) +{ + if ( ur_direct == ur_nref_tag(n) ) { + return n; + } + else { + // XX little-endian + // + return ur_coin_bytes(r, (uint8_t*)&n, ur_met3_64(n)); + } +} + +ur_nref +ur_cons(ur_root_t *r, ur_nref hed, ur_nref tal) +{ + ur_cells_t *cells = &(r->cells); + ur_dict64_t *dict = &(cells->dict); + ur_mug mug = ur_mug_both(ur_nref_mug(r, hed), + ur_nref_mug(r, tal)); + + while ( 1 ) { + uint64_t idx = ( mug % cells->size ); + ur_pail64_t *bucket = &(dict->buckets[idx]); + uint8_t i, b_fill = bucket->fill; + ur_nref cel; + + for ( i = 0; i < b_fill; i++ ) { + cel = (ur_nref)bucket->data[i]; + + if ( (hed == ur_head(r, cel)) + && (tal == ur_tail(r, cel)) ) + { + return cel; + } + } + + if ( 10 == b_fill ) { + ur_dict64_grow(r, dict, dict->prev, dict->size); + continue; + } + + if ( cells->fill == cells->size ) { + ur_cells_grow(cells); + } + + cel = _cons_unsafe(cells, mug, hed, tal); + + bucket->data[b_fill] = (uint64_t)cel; + bucket->fill = 1 + b_fill; + + return cel; + } +} + +ur_root_t* +ur_hcon_init(void) +{ + ur_root_t *r = calloc(1, sizeof(*r)); + assert( r ); + + { + ur_dict64_t *dict; + uint64_t fib11 = 89, fib12 = 144; + + // allocate atom storage + // + r->atoms.prev = fib11; + r->atoms.size = fib12; + ur_atoms_grow(&(r->atoms)); + + // allocate atom hashtable + // + dict = &(r->atoms.dict); + ur_dict64_grow(r, dict, fib11, fib12); + + // allocate cell storage + // + r->cells.prev = fib11; + r->cells.size = fib12; + ur_cells_grow(&(r->cells)); + + // allocate cell hashtable + // + dict = &(r->cells.dict); + ur_dict64_grow(r, dict, fib11, fib12); + } + + return r; +} From 24d87239171c7016d32fc157029d75ae0430559b Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 28 Jul 2020 14:20:37 -0700 Subject: [PATCH 115/933] ur: fixes a variety of bugs uncovered in local testing --- pkg/urbit/include/ur/hashcons.h | 12 +++---- pkg/urbit/ur/hashcons.c | 60 ++++++++++++++++++++------------- 2 files changed, 42 insertions(+), 30 deletions(-) diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index c3f7143b19..69e34b378b 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -5,17 +5,17 @@ typedef uint8_t ur_bool_t; #if (32 == (CHAR_BIT * __SIZEOF_INT__)) -# define ur_lz32 __builtin_ctz +# define ur_lz32 __builtin_clz #elif (32 == (CHAR_BIT * __SIZEOF_LONG__)) -# define ur_lz32 __builtin_ctzl +# define ur_lz32 __builtin_clzl #else # error "port me" #endif #if (64 == (CHAR_BIT * __SIZEOF_LONG__)) -# define ur_lz64 __builtin_ctzl +# define ur_lz64 __builtin_clzl #elif (64 == (CHAR_BIT * __SIZEOF_LONG_LONG__)) -# define ur_lz64 __builtin_ctzll +# define ur_lz64 __builtin_clzll #else # error "port me" #endif @@ -25,8 +25,8 @@ typedef uint8_t ur_bool_t; #define ur_mask_31(a) (a & 0x7fffffff) #define ur_mask_62(a) (a & 0x3fffffffffffffffULL) -#define ur_met0_32(a) ( 32 - ur_lz32(a) ) -#define ur_met0_64(a) ( 64 - ur_lz64(a) ) +#define ur_met0_32(a) ( (a) ? 32 - ur_lz32(a) : 0 ) +#define ur_met0_64(a) ( (a) ? 64 - ur_lz64(a) : 0 ) #define ur_met3_32(a) \ ({ uint8_t _a = ur_met0_32(a); \ diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index f97e727671..c321d8fc2b 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -9,7 +9,7 @@ #include -#include "noun/hashcons.h" +#include "ur/hashcons.h" ur_mug ur_mug_bytes(const uint8_t *byt, uint64_t len) @@ -64,7 +64,9 @@ ur_mug64(uint64_t x) ur_mug ur_mug_both(ur_mug hed, ur_mug tal) { - return ur_mug32(hed ^ (0x7fffffff ^ tal)); + // XX not correct per u3r_mug, but necessary to avoid collisions + // + return ur_mug32(hed ^ (0x7fffffff ^ ur_mug32(tal))); } ur_mug @@ -111,17 +113,18 @@ ur_dict64_grow(ur_root_t *r, ur_dict64_t *dict, uint64_t prev, uint64_t size) for ( i = 0; i < old_size; i++ ) { ur_pail64_t *old_bucket = &(old_buckets[i]); - uint64_t old_fill = old_bucket->fill; - uint64_t j; + uint8_t old_fill = old_bucket->fill; + uint8_t j; for ( j = 0; j < old_fill; j++ ) { - ur_nref ref = (ur_nref)old_bucket->data[old_fill]; + ur_nref ref = (ur_nref)old_bucket->data[j]; ur_mug mug = ur_nref_mug(r, ref); - ur_pail64_t *bucket = &(buckets[ mug % next ]); - uint64_t new_fill = bucket->fill; + uint64_t idx = ( mug % next ); + ur_pail64_t *bucket = &(buckets[idx]); + uint8_t new_fill = bucket->fill; - if( 10 == new_fill ) { + if ( 10 == new_fill ) { free(buckets); return ur_dict64_grow(r, dict, size, next); } @@ -148,21 +151,24 @@ ur_atoms_grow(ur_atoms_t *atoms) uint64_t *lens = atoms->lens; ur_mug *mugs = atoms->mugs; - atoms->bytes = malloc(next * (sizeof(*atoms->bytes) - + sizeof(*atoms->lens) - + sizeof(*atoms->mugs))); + atoms->bytes = malloc(next * ( sizeof(*atoms->bytes) + + sizeof(*atoms->lens) + + sizeof(*atoms->mugs) )); assert( atoms->bytes ); - atoms->lens = (void*)(atoms->bytes + (next * sizeof(*atoms->bytes))); - atoms->mugs = (void*)(atoms->lens + (next * sizeof(*atoms->lens))); + atoms->lens = (void*)((char*)atoms->bytes + (next * sizeof(*atoms->bytes))); + atoms->mugs = (void*)((char*)atoms->lens + (next * sizeof(*atoms->lens))); if ( bytes ) { memcpy(atoms->bytes, bytes, size * (sizeof(*bytes))); - memcpy(atoms->lens, lens, size * (sizeof(*lens))); - memcpy(atoms->mugs, mugs, size * (sizeof(*mugs))); + memcpy(atoms->lens, lens, size * (sizeof(*lens))); + memcpy(atoms->mugs, mugs, size * (sizeof(*mugs))); free(bytes); } + + atoms->prev = size; + atoms->size = next; } void @@ -175,21 +181,24 @@ ur_cells_grow(ur_cells_t *cells) ur_nref *tails = cells->tails; ur_mug *mugs = cells->mugs; - cells->heads = malloc(next * (sizeof(*cells->heads) - + sizeof(*cells->heads) - + sizeof(*cells->mugs))); + cells->heads = malloc(next * ( sizeof(*cells->heads) + + sizeof(*cells->heads) + + sizeof(*cells->mugs) )); assert( cells->heads ); - cells->tails = (void*)(cells->heads + (next * sizeof(*cells->heads))); - cells->mugs = (void*)(cells->tails + (next * sizeof(*cells->tails))); + cells->tails = (void*)((char*)cells->heads + (next * sizeof(*cells->heads))); + cells->mugs = (void*)((char*)cells->tails + (next * sizeof(*cells->tails))); if ( heads ) { memcpy(cells->heads, heads, size * (sizeof(*heads))); memcpy(cells->tails, tails, size * (sizeof(*tails))); - memcpy(cells->mugs, mugs, size * (sizeof(*mugs))); + memcpy(cells->mugs, mugs, size * (sizeof(*mugs))); free(heads); } + + cells->prev = size; + cells->size = next; } void @@ -218,7 +227,8 @@ static ur_nref _coin_unsafe(ur_atoms_t *atoms, ur_mug mug, uint8_t *byt, uint64_t len) { uint64_t fill = atoms->fill; - ur_nref tom = ( fill & ((uint64_t)ur_iatom << 62) ); + ur_tag tag = ur_iatom; + ur_nref tom = ( fill | ((uint64_t)tag << 62) ); uint8_t *copy = malloc(len); // XX necessary? @@ -231,6 +241,7 @@ _coin_unsafe(ur_atoms_t *atoms, ur_mug mug, uint8_t *byt, uint64_t len) atoms->bytes[fill] = copy; atoms->lens[fill] = len; atoms->mugs[fill] = mug; + atoms->fill = 1 + fill; return tom; } @@ -239,7 +250,8 @@ static ur_nref _cons_unsafe(ur_cells_t *cells, ur_mug mug, ur_nref hed, ur_nref tal) { uint64_t fill = cells->fill; - ur_nref cel = ( fill & ((uint64_t)ur_icell << 62) ); + ur_tag tag = ur_icell; + ur_nref cel = ( fill | ((uint64_t)tag << 62) ); // XX necessary? // @@ -320,7 +332,7 @@ ur_cons(ur_root_t *r, ur_nref hed, ur_nref tal) ur_nref_mug(r, tal)); while ( 1 ) { - uint64_t idx = ( mug % cells->size ); + uint64_t idx = ( mug % dict->size ); ur_pail64_t *bucket = &(dict->buckets[idx]); uint8_t i, b_fill = bucket->fill; ur_nref cel; From 15f60af86f4c05858b34c38ceea59d368f57de87 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 28 Jul 2020 15:52:32 -0700 Subject: [PATCH 116/933] ur: adds hashcons module to build --- pkg/urbit/Makefile | 3 ++- pkg/urbit/include/ur/hashcons.h | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pkg/urbit/Makefile b/pkg/urbit/Makefile index 972310caac..76e65e89e3 100644 --- a/pkg/urbit/Makefile +++ b/pkg/urbit/Makefile @@ -2,12 +2,13 @@ include config.mk jets = jets/tree.c $(wildcard jets/*/*.c) noun = $(wildcard noun/*.c) +ur = $(wildcard ur/*.c) vere = $(wildcard vere/*.c) $(wildcard vere/*/*.c) daemon = $(wildcard daemon/*.c) worker = $(wildcard worker/*.c) tests = $(wildcard tests/*.c) -common = $(jets) $(noun) $(vere) +common = $(jets) $(noun) $(ur) $(vere) headers = $(shell find include -type f) common_objs = $(shell echo $(common) | sed 's/\.c/.o/g') diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index 69e34b378b..7c77268b50 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -93,3 +93,15 @@ typedef struct ur_root_s { ur_cells_t cells; ur_atoms_t atoms; } ur_root_t; + +ur_nref +ur_coin_bytes(ur_root_t *r, uint8_t *byt, uint64_t len); + +ur_nref +ur_coin64(ur_root_t *r, uint64_t n); + +ur_nref +ur_cons(ur_root_t *r, ur_nref hed, ur_nref tal); + +ur_root_t* +ur_hcon_init(void); From b61c016b93b4b7f7e15b9a5a1da71f84698d0dd9 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 28 Jul 2020 15:52:56 -0700 Subject: [PATCH 117/933] serf: WIP adds uniq: global deduplicator --- pkg/urbit/worker/main.c | 420 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 420 insertions(+) diff --git a/pkg/urbit/worker/main.c b/pkg/urbit/worker/main.c index 7bc494e269..b5872620fe 100644 --- a/pkg/urbit/worker/main.c +++ b/pkg/urbit/worker/main.c @@ -22,6 +22,8 @@ #include #include +#include "ur/hashcons.h" + static u3_serf u3V; // one serf per process static u3_moat inn_u; // input stream static u3_mojo out_u; // output stream @@ -288,6 +290,421 @@ _cw_queu(c3_i argc, c3_c* argv[]) } } + +// stack frame for recording head vs tail iteration +// +// In Hoon, this structure would be as follows: +// +// $% [%root ~] +// [%head cell=^] +// [%tail cell=^ hed-mug=@] +// == +// + +#define STACK_ROOT 0 +#define STACK_HEAD 1 +#define STACK_TAIL 2 + +typedef struct ur_temp_s +{ + uint64_t prev; + uint64_t size; + void *base; + void *top; +} ur_temp_t; + +void +ur_temp_init(ur_temp_t *t) +{ + uint64_t fib19 = 4181, fib20 = 6765; + + t->prev = fib19; + t->size = fib20; + t->base = malloc(fib20); + t->top = t->base; +} + +void* +ur_temp_push(ur_temp_t *t, size_t wide) +{ + uint64_t fill = t->top - t->base; + uint64_t grow = t->size + wide; + + if ( fill > (t->size + wide) ) { + uint64_t next = t->prev + t->size; + t->base = realloc(t->base, next); + t->top = t->base + fill; + } + + { + void* ptr = t->top; + t->top += wide; + return ptr; + } +} + +void* +ur_temp_peek(ur_temp_t *t, size_t wide) +{ + return t->top - wide; +} + +void +ur_temp_pop(ur_temp_t *t, size_t wide) +{ + t->top -= wide; + assert( t->top >= t->base ); +} + +typedef struct _ur_frame_s +{ + c3_y tag_y; + u3a_cell* cel_u; + ur_nref ref; +} _ur_frame_t; + +typedef struct _ur_stack_s +{ + uint32_t prev; + uint32_t size; + uint32_t fill; + _ur_frame_t *entries; +} _ur_stack_t; + +static inline void +_stack_push(_ur_stack_t *s, c3_y tag_y, u3a_cell* cel_u, ur_nref ref) +{ + if ( s->fill == s->size ) { + uint32_t next = s->prev + s->size; + s->entries = realloc(s->entries, next * sizeof(_ur_frame_t)); + s->prev = s->size; + s->size = next; + } + + _ur_frame_t* fam_u = &(s->entries[s->fill++]); + fam_u->tag_y = tag_y; + fam_u->cel_u = cel_u; + fam_u->ref = ref; +} + +static ur_nref +_from_loom(ur_root_t *r, u3_noun a) +{ + ur_nref ref; + + _ur_stack_t s; + s.prev = 89; + s.size = 144; + s.fill = 0; + s.entries = malloc((s.prev + s.size) * sizeof(_ur_frame_t)); + _stack_push(&s, STACK_ROOT, 0, 0); + + // ur_temp_t t; + // ur_temp_init(&t); + + // { + // _ur_frame_t *fam_u = ur_temp_push(&t, sizeof(_ur_frame_t)); + // fam_u->tag_y = STACK_ROOT; + // } + + advance: { + // u3 direct == ur direct + // + if ( c3y == u3a_is_cat(a) ) { + ref = (ur_nref)a; + goto retreat; + } + else { + u3a_noun* som_u = u3a_to_ptr(a); + u3a_box* box_u = u3a_botox(som_u); + c3_w* box_w = (void*)box_u; + + // all bits set == already reallocated + // + if ( 0xffffffff == box_w[0] ) { + ref = ( ((uint64_t)box_w[2]) << 32 + | ((uint64_t)box_w[1]) ); + goto retreat; + } + else if ( c3y == u3a_is_atom(a) ) { + u3a_atom* vat_u = (u3a_atom*)som_u; + + // coin an nref + // + switch ( vat_u->len_w ) { + case 2: { + ref = ur_coin64(r, ( ((uint64_t)vat_u->buf_w[1]) << 32 + | ((uint64_t)vat_u->buf_w[0]) )); + } break; + + case 1: { + ref = ur_coin64(r, (uint64_t)vat_u->buf_w[0]); + } break; + + + default: { + c3_assert( vat_u->len_w ); + + uint8_t *byt = (uint8_t*)vat_u->buf_w; + uint64_t len = u3r_met(3, a); + + ref = ur_coin_bytes(r, byt, len); + } break; + } + + // overwrite u3a_atom with reallocated reference + // + box_w[0] = 0xffffffff; + box_w[1] = ref & 0xffffffff; + box_w[2] = ref >> 32; + + goto retreat; + } + else { + u3a_cell* cel_u = (u3a_cell*)som_u; + _stack_push(&s, STACK_HEAD, cel_u, 0); + // { + // _ur_frame_t *fam_u = ur_temp_push(&t, sizeof(_ur_frame_t)); + // fam_u->tag_y = STACK_HEAD; + // fam_u->cel_u = cel_u; + // } + a = cel_u->hed; + goto advance; + } + } + } + + retreat: { + _ur_frame_t fam_u = s.entries[--s.fill]; + + // c3_y tag_y; + // u3a_cell* cel_u; + // ur_nref hed; + // { + // _ur_frame_t *fam_u = ur_temp_peek(&t, sizeof(_ur_frame_t)); + + // tag_y = fam_u->tag_y; + // cel_u = fam_u->cel_u; + // hed = fam_u->ref; + + // ur_temp_pop(&t, sizeof(_ur_frame_t)); + // } + + switch ( fam_u.tag_y ) { + // switch ( tag_y ) { + default: { + c3_assert(0); + } + + case STACK_ROOT: { + break; + } + + case STACK_HEAD: { + _stack_push(&s, STACK_TAIL, fam_u.cel_u, ref); + // { + // _ur_frame_t *fam_u = ur_temp_push(&t, sizeof(_ur_frame_t)); + // fam_u->tag_y = STACK_TAIL; + // fam_u->cel_u = cel_u; + // fam_u->ref = ref; + // } + + a = fam_u.cel_u->tel; + // a = cel_u->tel; + goto advance; + } + + case STACK_TAIL: { + u3a_cell* cel_u = fam_u.cel_u; + u3a_box* box_u = u3a_botox(cel_u); + c3_w* box_w = (void*)box_u; + + ref = ur_cons(r, fam_u.ref, ref); + // ref = ur_cons(r, hed, ref); + + // overwrite u3a_atom with reallocated reference + // + box_w[0] = 0xffffffff; + box_w[1] = ref & 0xffffffff; + box_w[2] = ref >> 32; + + goto retreat; + } + } + } + + free(s.entries); + // free(t.base); + + return ref; +} + +typedef struct ur_nvec_s { + void* data; + uint64_t fill; + ur_nref* refs; +} ur_nvec_t; + +void +ur_nvec_init(ur_nvec_t *v, uint64_t size, void* ptr) +{ + v->data = ptr; + v->fill = 0; + v->refs = calloc(size, sizeof(ur_nref)); +} + +// XX u3h_use() +static c3_w +_hamt_count(u3p(u3h_root) har_p) +{ + u3h_root* har_u = u3to(u3h_root, har_p); + return har_u->use_w; +} + +static void +_from_hamt(u3_noun kev, void* ptr) +{ + ur_nvec_t *v = (ur_nvec_t*)ptr; + ur_root_t *r = v->data; + + v->refs[v->fill++] = _from_loom(r, kev); +} + +static u3_noun +_ref_to_noun(ur_nref ref, u3_noun* vat, u3_noun* cel) +{ + switch ( ur_nref_tag(ref) ) { + default: assert(0); + + case ur_direct: { + if ( 0x7fffffffULL > ref ) { + return (u3_atom)ref; + } + else { + c3_w wor_w[2]; + + wor_w[0] = ref & 0xffffffff; + wor_w[1] = ref >> 32; + + return u3i_words(2, wor_w); + } + } break; + + case ur_iatom: return vat[ur_nref_idx(ref)]; + + case ur_icell: return cel[ur_nref_idx(ref)]; + } +} + +void +do_stuff(void) +{ + ur_root_t *r = ur_hcon_init(); + + // allow read/write on the whole loom, bypassing page tracking + // + if ( 0 != mprotect((void *)u3_Loom, u3a_bytes, (PROT_READ | PROT_WRITE)) ) { + c3_assert(0); + } + + fprintf(stderr, "hc: cells fill %" PRIu64 " size %" PRIu64 "\r\n", r->cells.fill, r->cells.size); + fprintf(stderr, "hc: atoms fill %" PRIu64 " size %" PRIu64 "\r\n", r->atoms.fill, r->atoms.size); + + ur_nref ken = _from_loom(r, u3A->roc); + + fprintf(stderr, "hc: cells fill %" PRIu64 " size %" PRIu64 "\r\n", r->cells.fill, r->cells.size); + fprintf(stderr, "hc: atoms fill %" PRIu64 " size %" PRIu64 "\r\n", r->atoms.fill, r->atoms.size); + + + c3_w cod_w = _hamt_count(u3R->jed.cod_p); + ur_nvec_t v; + + fprintf(stderr, "hc: cold count %u\r\n", cod_w); + + ur_nvec_init(&v, cod_w, r); + u3h_walk_with(u3R->jed.cod_p, _from_hamt, &v); + + fprintf(stderr, "hc: cells fill %" PRIu64 " size %" PRIu64 "\r\n", r->cells.fill, r->cells.size); + fprintf(stderr, "hc: atoms fill %" PRIu64 " size %" PRIu64 "\r\n", r->atoms.fill, r->atoms.size); + + u3m_pave(c3y, c3n); + // XX wtf? + u3R->jed.hot_p = u3h_new(); + + u3_atom *vat; + u3_noun *cel; + + { + ur_atoms_t *atoms = &(r->atoms); + uint64_t *lens = atoms->lens; + uint8_t **byts = atoms->bytes; + uint64_t i, fill = atoms->fill; + + vat = calloc(fill, sizeof(u3_atom)); + + for ( i = 0; i < fill; i++ ) { + vat[i] = u3i_bytes(lens[i], byts[i]); + // XX mug? + } + } + + { + ur_cells_t *cells = &(r->cells); + ur_nref *heds = cells->heads, *tals = cells->tails; + uint64_t i, fill = cells->fill; + u3_noun hed, tal; + + cel = calloc(fill, sizeof(u3_noun)); + + for ( i = 0; i < fill; i++ ) { + hed = _ref_to_noun(heds[i], vat, cel); + tal = _ref_to_noun(tals[i], vat, cel); + cel[i] = u3nc(hed, tal); + // XX mug? + } + } + + u3A->roc = cel[ur_nref_idx(ken)]; + + { + uint32_t i; + ur_nref ref; + u3_noun kev; + + for ( i = 0; i < cod_w; i++) { + ref = v.refs[i]; + kev = cel[ur_nref_idx(ref)]; + u3h_put(u3R->jed.cod_p, u3h(kev), u3k(u3t(kev))); + u3z(kev); + } + } + + // mark all pages dirty + // + memset((void*)u3P.dit_w, 0xff, u3a_pages >> 3); +} + +/* _cw_uniq(); deduplicate persistent nouns +*/ +static void +_cw_uniq(c3_i argc, c3_c* argv[]) +{ + c3_assert( 3 <= argc ); + + c3_c* dir_c = argv[2]; + c3_d eve_d = u3m_boot(dir_c); + + u3_serf_grab(); + + do_stuff(); + + u3_serf_grab(); + + u3A->ent_d = eve_d; + + u3e_save(); +} + /* _cw_pack(); compact memory, save, and exit. */ static void @@ -362,6 +779,9 @@ main(c3_i argc, c3_c* argv[]) else if ( 0 == strcmp("queu", argv[1]) ) { _cw_queu(argc, argv); } + else if ( 0 == strcmp("uniq", argv[1]) ) { + _cw_uniq(argc, argv); + } else if ( 0 == strcmp("pack", argv[1]) ) { _cw_pack(argc, argv); } From 29810b5b1b7bcae68dfd66bd27cea7a12ae18b05 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 29 Jul 2020 12:58:35 -0700 Subject: [PATCH 118/933] ur: removes unusable width-abstraction in ur_dict* types --- pkg/urbit/include/ur/hashcons.h | 61 +++++++++++++----------------- pkg/urbit/ur/hashcons.c | 66 ++++++++++++++++----------------- 2 files changed, 57 insertions(+), 70 deletions(-) diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index 7c77268b50..bfb1efbb7a 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -39,28 +39,6 @@ typedef uint8_t ur_bool_t; #define ur_nref_tag(ref) ( ref >> 62 ) #define ur_nref_idx(ref) ur_mask_62(ref) -typedef struct ur_pail32_s { - uint8_t fill; - uint32_t data[10]; -} ur_pail32_t; - -typedef struct ur_dict32_s { - uint64_t prev; - uint64_t size; - ur_pail32_t *buckets; -} ur_dict32_t; - -typedef struct ur_pail64_s { - uint8_t fill; - uint64_t data[10]; -} ur_pail64_t; - -typedef struct ur_dict64_s { - uint64_t prev; - uint64_t size; - ur_pail64_t *buckets; -} ur_dict64_t; - typedef uint32_t ur_mug; typedef uint64_t ur_nref; typedef enum { @@ -69,24 +47,35 @@ typedef enum { ur_icell = 2, } ur_tag; +typedef struct ur_pail_s { + uint8_t fill; + ur_nref refs[10]; +} ur_pail_t; + +typedef struct ur_dict_s { + uint64_t prev; + uint64_t size; + ur_pail_t *buckets; +} ur_dict_t; + typedef struct ur_cells_s { - ur_dict64_t dict; - uint64_t prev; - uint64_t size; - uint64_t fill; - ur_mug *mugs; - ur_nref *heads; - ur_nref *tails; + ur_dict_t dict; + uint64_t prev; + uint64_t size; + uint64_t fill; + ur_mug *mugs; + ur_nref *heads; + ur_nref *tails; } ur_cells_t; typedef struct ur_atoms_s { - ur_dict64_t dict; - uint64_t prev; - uint64_t size; - uint64_t fill; - ur_mug *mugs; - uint8_t **bytes; - uint64_t *lens; + ur_dict_t dict; + uint64_t prev; + uint64_t size; + uint64_t fill; + ur_mug *mugs; + uint8_t **bytes; + uint64_t *lens; } ur_atoms_t; typedef struct ur_root_s { diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index c321d8fc2b..1017989816 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -102,34 +102,32 @@ ur_tail(ur_root_t *r, ur_nref ref) } void -ur_dict64_grow(ur_root_t *r, ur_dict64_t *dict, uint64_t prev, uint64_t size) +ur_dict_grow(ur_root_t *r, ur_dict_t *dict, uint64_t prev, uint64_t size) { - ur_pail64_t *buckets, *old_buckets = dict->buckets; + ur_pail_t *buckets, *old_buckets = dict->buckets; uint64_t old_size = dict->size; - uint64_t next = prev + size; - uint64_t i; + uint64_t i, next = prev + size; buckets = calloc(next, sizeof(*buckets)); for ( i = 0; i < old_size; i++ ) { - ur_pail64_t *old_bucket = &(old_buckets[i]); - uint8_t old_fill = old_bucket->fill; - uint8_t j; + ur_pail_t *old_bucket = &(old_buckets[i]); + uint8_t j, old_fill = old_bucket->fill; for ( j = 0; j < old_fill; j++ ) { - ur_nref ref = (ur_nref)old_bucket->data[j]; + ur_nref ref = old_bucket->refs[j]; ur_mug mug = ur_nref_mug(r, ref); - uint64_t idx = ( mug % next ); - ur_pail64_t *bucket = &(buckets[idx]); - uint8_t new_fill = bucket->fill; + uint64_t idx = ( mug % next ); + ur_pail_t *bucket = &(buckets[idx]); + uint8_t new_fill = bucket->fill; if ( 10 == new_fill ) { free(buckets); - return ur_dict64_grow(r, dict, size, next); + return ur_dict_grow(r, dict, size, next); } - bucket->data[new_fill] = (uint64_t)ref; + bucket->refs[new_fill] = ref; bucket->fill = 1 + new_fill; } } @@ -154,11 +152,11 @@ ur_atoms_grow(ur_atoms_t *atoms) atoms->bytes = malloc(next * ( sizeof(*atoms->bytes) + sizeof(*atoms->lens) + sizeof(*atoms->mugs) )); - assert( atoms->bytes ); - atoms->lens = (void*)((char*)atoms->bytes + (next * sizeof(*atoms->bytes))); atoms->mugs = (void*)((char*)atoms->lens + (next * sizeof(*atoms->lens))); + assert( atoms->bytes ); + if ( bytes ) { memcpy(atoms->bytes, bytes, size * (sizeof(*bytes))); memcpy(atoms->lens, lens, size * (sizeof(*lens))); @@ -184,11 +182,11 @@ ur_cells_grow(ur_cells_t *cells) cells->heads = malloc(next * ( sizeof(*cells->heads) + sizeof(*cells->heads) + sizeof(*cells->mugs) )); - assert( cells->heads ); - cells->tails = (void*)((char*)cells->heads + (next * sizeof(*cells->heads))); cells->mugs = (void*)((char*)cells->tails + (next * sizeof(*cells->tails))); + assert( cells->heads ); + if ( heads ) { memcpy(cells->heads, heads, size * (sizeof(*heads))); memcpy(cells->tails, tails, size * (sizeof(*tails))); @@ -269,19 +267,19 @@ ur_nref ur_coin_bytes(ur_root_t *r, uint8_t *byt, uint64_t len) { ur_atoms_t *atoms = &(r->atoms); - ur_dict64_t *dict = &(atoms->dict); + ur_dict_t *dict = &(atoms->dict); ur_mug mug = ur_mug_bytes(byt, len); while ( 1 ) { - uint64_t idx = ( mug % dict->size ); - ur_pail64_t *bucket = &(dict->buckets[idx]); - uint8_t i, b_fill = bucket->fill; + uint64_t idx = ( mug % dict->size ); + ur_pail_t *bucket = &(dict->buckets[idx]); + uint8_t i, b_fill = bucket->fill; ur_nref tom; for ( i = 0; i < b_fill; i++ ) { uint8_t *t_byt; uint64_t t_len; - tom = (ur_nref)bucket->data[i]; + tom = bucket->refs[i]; ur_bytes(r, tom, &t_byt, &t_len); @@ -293,7 +291,7 @@ ur_coin_bytes(ur_root_t *r, uint8_t *byt, uint64_t len) } if ( 10 == b_fill ) { - ur_dict64_grow(r, dict, dict->prev, dict->size); + ur_dict_grow(r, dict, dict->prev, dict->size); continue; } @@ -303,7 +301,7 @@ ur_coin_bytes(ur_root_t *r, uint8_t *byt, uint64_t len) tom = _coin_unsafe(atoms, mug, byt, len); - bucket->data[b_fill] = (uint64_t)tom; + bucket->refs[b_fill] = tom; bucket->fill = 1 + b_fill; return tom; @@ -327,18 +325,18 @@ ur_nref ur_cons(ur_root_t *r, ur_nref hed, ur_nref tal) { ur_cells_t *cells = &(r->cells); - ur_dict64_t *dict = &(cells->dict); + ur_dict_t *dict = &(cells->dict); ur_mug mug = ur_mug_both(ur_nref_mug(r, hed), ur_nref_mug(r, tal)); while ( 1 ) { - uint64_t idx = ( mug % dict->size ); - ur_pail64_t *bucket = &(dict->buckets[idx]); - uint8_t i, b_fill = bucket->fill; + uint64_t idx = ( mug % dict->size ); + ur_pail_t *bucket = &(dict->buckets[idx]); + uint8_t i, b_fill = bucket->fill; ur_nref cel; for ( i = 0; i < b_fill; i++ ) { - cel = (ur_nref)bucket->data[i]; + cel = bucket->refs[i]; if ( (hed == ur_head(r, cel)) && (tal == ur_tail(r, cel)) ) @@ -348,7 +346,7 @@ ur_cons(ur_root_t *r, ur_nref hed, ur_nref tal) } if ( 10 == b_fill ) { - ur_dict64_grow(r, dict, dict->prev, dict->size); + ur_dict_grow(r, dict, dict->prev, dict->size); continue; } @@ -358,7 +356,7 @@ ur_cons(ur_root_t *r, ur_nref hed, ur_nref tal) cel = _cons_unsafe(cells, mug, hed, tal); - bucket->data[b_fill] = (uint64_t)cel; + bucket->refs[b_fill] = cel; bucket->fill = 1 + b_fill; return cel; @@ -372,7 +370,7 @@ ur_hcon_init(void) assert( r ); { - ur_dict64_t *dict; + ur_dict_t *dict; uint64_t fib11 = 89, fib12 = 144; // allocate atom storage @@ -384,7 +382,7 @@ ur_hcon_init(void) // allocate atom hashtable // dict = &(r->atoms.dict); - ur_dict64_grow(r, dict, fib11, fib12); + ur_dict_grow(r, dict, fib11, fib12); // allocate cell storage // @@ -395,7 +393,7 @@ ur_hcon_init(void) // allocate cell hashtable // dict = &(r->cells.dict); - ur_dict64_grow(r, dict, fib11, fib12); + ur_dict_grow(r, dict, fib11, fib12); } return r; From 072307addde39cb3a31851b5e1b8fe48616ed9cb Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 29 Jul 2020 13:52:57 -0700 Subject: [PATCH 119/933] u3: refactors global deduplicator in u3u_uniq() --- pkg/urbit/include/all.h | 1 + pkg/urbit/include/noun/hashtable.h | 5 + pkg/urbit/include/noun/urth.h | 8 + pkg/urbit/include/ur/hashcons.h | 8 + pkg/urbit/noun/hashtable.c | 9 + pkg/urbit/noun/urth.c | 364 ++++++++++++++++++++++++++ pkg/urbit/ur/hashcons.c | 11 + pkg/urbit/worker/main.c | 396 +---------------------------- 8 files changed, 407 insertions(+), 395 deletions(-) create mode 100644 pkg/urbit/include/noun/urth.h create mode 100644 pkg/urbit/noun/urth.c diff --git a/pkg/urbit/include/all.h b/pkg/urbit/include/all.h index 04ff196449..b138c6d408 100644 --- a/pkg/urbit/include/all.h +++ b/pkg/urbit/include/all.h @@ -27,6 +27,7 @@ # include "noun/serial.h" // u3s: serialization # include "noun/trace.h" // u3t: profiling / tracing # include "noun/xtract.h" // u3x: noun access (error crashes) +# include "noun/urth.h" // u3u: off-loom integration # include "noun/vortex.h" // u3v: arvo kernel # include "noun/zave.h" // u3z: memoization diff --git a/pkg/urbit/include/noun/hashtable.h b/pkg/urbit/include/noun/hashtable.h index bf9f50e176..64818de921 100644 --- a/pkg/urbit/include/noun/hashtable.h +++ b/pkg/urbit/include/noun/hashtable.h @@ -177,3 +177,8 @@ */ u3p(u3h_root) u3h_take(u3p(u3h_root) har_p); + + /* u3h_wyt(): number of entries + */ + c3_w + u3h_wyt(u3p(u3h_root) har_p); diff --git a/pkg/urbit/include/noun/urth.h b/pkg/urbit/include/noun/urth.h new file mode 100644 index 0000000000..d777debc5e --- /dev/null +++ b/pkg/urbit/include/noun/urth.h @@ -0,0 +1,8 @@ +/* include/noun/urth.h +*/ + /** Functions. + **/ + /* u3u_uniq(): hash-cons roots off-loom, reallocate on loom. + */ + void + u3u_uniq(void); diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index bfb1efbb7a..3eaa61724b 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -47,6 +47,11 @@ typedef enum { ur_icell = 2, } ur_tag; +typedef struct ur_nvec_s { + uint64_t fill; + ur_nref* refs; +} ur_nvec_t; + typedef struct ur_pail_s { uint8_t fill; ur_nref refs[10]; @@ -94,3 +99,6 @@ ur_cons(ur_root_t *r, ur_nref hed, ur_nref tal); ur_root_t* ur_hcon_init(void); + +void +ur_nvec_init(ur_nvec_t *v, uint64_t size); diff --git a/pkg/urbit/noun/hashtable.c b/pkg/urbit/noun/hashtable.c index 1838c8945d..8ae60209ea 100644 --- a/pkg/urbit/noun/hashtable.c +++ b/pkg/urbit/noun/hashtable.c @@ -1180,3 +1180,12 @@ u3h_discount(u3p(u3h_root) har_p) return tot_w; } + +/* u3h_wyt(): number of entries +*/ +c3_w +u3h_wyt(u3p(u3h_root) har_p) +{ + u3h_root* har_u = u3to(u3h_root, har_p); + return har_u->use_w; +} diff --git a/pkg/urbit/noun/urth.c b/pkg/urbit/noun/urth.c new file mode 100644 index 0000000000..c5a40373d8 --- /dev/null +++ b/pkg/urbit/noun/urth.c @@ -0,0 +1,364 @@ +/* noun/urth.c +** +*/ +#include +#include +#include +#include + +#include "all.h" +#include "ur/hashcons.h" + +/* _cu_met_3(): atom bytewidth a la u3r_met(3, ...) +*/ +static inline c3_w +_cu_met_3(u3a_atom* vat_u) +{ + c3_w len_w = vat_u->len_w; + c3_w* buf_w = vat_u->buf_w; + + if ( !len_w ) { + return 0; + } + else { + c3_w gal_w = len_w - 1; + c3_w daz_w = buf_w[gal_w]; + + return (gal_w << 2) + + ((daz_w >> 24) ? 4 : (daz_w >> 16) ? 3 : (daz_w >> 8) ? 2 : 1); + } +} + +// XX this is morally correct, but not useful +// for deduplicating the loom +// +#if 0 +static inline ur_nref +_cu_atom_to_ref(u3a_atom* vat_u, ur_root_t *r) +{ + ur_nref ref; + + switch ( vat_u->len_w ) { + case 2: { + ref = ur_coin64(r, ( ((c3_d)vat_u->buf_w[1]) << 32 + | ((c3_d)vat_u->buf_w[0]) )); + } break; + + case 1: { + ref = ur_coin64(r, (c3_d)vat_u->buf_w[0]); + } break; + + + default: { + c3_assert( vat_u->len_w ); + + c3_y* byt_y = (c3_y*)vat_u->buf_w; + c3_w len_w = _cu_met_3(vat_u); + + ref = ur_coin_bytes(r, byt_y, (c3_d)len_w); + } break; + } + + return ref; +} +#endif + +/* _cu_atom_to_ref(): indirect u3 atom to ur_nref. +*/ +static inline ur_nref +_cu_atom_to_ref(u3a_atom* vat_u, ur_root_t *r) +{ + c3_assert( vat_u->len_w ); + + c3_y* byt_y = (c3_y*)vat_u->buf_w; + c3_w len_w = _cu_met_3(vat_u); + + return ur_coin_bytes(r, byt_y, (c3_d)len_w); +} + +/* _cu_box_check(): check loom allocation box for relocation pointer. +*/ +static inline c3_o +_cu_box_check(u3a_noun* som_u, ur_nref* ref) +{ + u3a_box* box_u = u3a_botox(som_u); + c3_w* box_w = (void*)box_u; + + if ( 0xffffffff == box_w[0] ) { + *ref = ( ((c3_d)box_w[2]) << 32 + | ((c3_d)box_w[1]) ); + return c3y; + } + + return c3n; +} + +/* _cu_box_stash(): overwrite an allocation box with relocation pointer. +*/ +static inline void +_cu_box_stash(u3a_noun* som_u, ur_nref ref) +{ + u3a_box* box_u = u3a_botox(som_u); + c3_w* box_w = (void*)box_u; + + // overwrite u3a_atom with reallocated reference + // + box_w[0] = 0xffffffff; + box_w[1] = ref & 0xffffffff; + box_w[2] = ref >> 32; +} + +// stack frame for recording head vs tail iteration +// +// In Hoon, this structure would be as follows: +// +// $% [%root ~] +// [%head cell=^] +// [%tail cell=^ hed-mug=@] +// == +// + +#define STACK_ROOT 0 +#define STACK_HEAD 1 +#define STACK_TAIL 2 + +typedef struct _cu_frame_s +{ + c3_y tag_y; + u3a_cell* cel_u; + ur_nref ref; +} _cu_frame; + +typedef struct _cu_stack_s +{ + c3_w pre_w; + c3_w siz_w; + c3_w fil_w; + _cu_frame* fam_u; +} _cu_stack; + +/* _cu_stack_push(): push a "stack" frame. +*/ +static inline void +_cu_stack_push(_cu_stack *s, c3_y tag_y, u3a_cell* cel_u, ur_nref ref) +{ + if ( s->fil_w == s->siz_w ) { + c3_w nex_w = s->pre_w + s->siz_w; + s->fam_u = c3_realloc(s->fam_u, nex_w * sizeof(*s->fam_u)); + s->pre_w = s->siz_w; + s->siz_w = nex_w; + } + + _cu_frame* fam_u = &(s->fam_u[s->fil_w++]); + fam_u->tag_y = tag_y; + fam_u->cel_u = cel_u; + fam_u->ref = ref; +} + +/* _cu_from_loom(): reallocate [a] off loom, in [r]. +*/ +static ur_nref +_cu_from_loom(ur_root_t *r, u3_noun a) +{ + ur_nref ref; + + _cu_stack s = { .pre_w = 89, .siz_w = 144, .fil_w = 0, .fam_u = 0 }; + s.fam_u = c3_malloc((s.pre_w + s.siz_w) * sizeof(*s.fam_u)); + _cu_stack_push(&s, STACK_ROOT, 0, 0); + + advance: { + // u3 direct == ur direct + // + if ( c3y == u3a_is_cat(a) ) { + ref = (ur_nref)a; + goto retreat; + } + else { + u3a_noun* som_u = u3a_to_ptr(a); + + // all bits set == already reallocated + // + if ( c3y == _cu_box_check(som_u, &ref) ) { + goto retreat; + } + else if ( c3y == u3a_is_atom(a) ) { + ref = _cu_atom_to_ref((u3a_atom*)som_u, r); + _cu_box_stash(som_u, ref); + goto retreat; + } + else { + u3a_cell* cel_u = (u3a_cell*)som_u; + _cu_stack_push(&s, STACK_HEAD, cel_u, 0); + a = cel_u->hed; + goto advance; + } + } + } + + retreat: { + _cu_frame fam_u = s.fam_u[--s.fil_w]; + + switch ( fam_u.tag_y ) { + default: c3_assert(0); + case STACK_ROOT: break; + + case STACK_HEAD: { + _cu_stack_push(&s, STACK_TAIL, fam_u.cel_u, ref); + a = fam_u.cel_u->tel; + goto advance; + } + + case STACK_TAIL: { + u3a_cell* cel_u = fam_u.cel_u; + ref = ur_cons(r, fam_u.ref, ref); + _cu_box_stash((u3a_noun*)cel_u, ref); + goto retreat; + } + } + } + + free(s.fam_u); + + return ref; +} + +/* _cu_ref_to_noun(): lookup/allocate [ref] on the loom. +*/ +static u3_noun +_cu_ref_to_noun(ur_nref ref, u3_noun* vat, u3_noun* cel) +{ + switch ( ur_nref_tag(ref) ) { + default: assert(0); + + case ur_direct: { + if ( 0x7fffffffULL > ref ) { + return (u3_atom)ref; + } + else { + c3_w wor_w[2]; + + wor_w[0] = ref & 0xffffffff; + wor_w[1] = ref >> 32; + + return u3i_words(2, wor_w); + } + } break; + + case ur_iatom: return vat[ur_nref_idx(ref)]; + + case ur_icell: return cel[ur_nref_idx(ref)]; + } +} + +typedef struct _cu_vec_s { + ur_nvec_t* vec_u; + ur_root_t* rot_u; +} _cu_vec; + +/* _cu_hamt_walk(): reallocate key/value pair in hamt walk. +*/ +static void +_cu_hamt_walk(u3_noun kev, void* ptr) +{ + _cu_vec* dat_u = (_cu_vec*)ptr; + ur_nvec_t* vec_u = dat_u->vec_u; + ur_root_t* rot_u = dat_u->rot_u; + + vec_u->refs[vec_u->fill++] = _cu_from_loom(rot_u, kev); +} + +/* u3u_uniq(): hash-cons roots off-loom, reallocate on loom. +*/ +void +u3u_uniq(void) +{ + c3_assert( &(u3H->rod_u) == u3R ); + + ur_root_t *r = ur_hcon_init(); + + // allow read/write on the whole loom, bypassing page tracking + // + if ( 0 != mprotect((void *)u3_Loom, u3a_bytes, (PROT_READ | PROT_WRITE)) ) { + c3_assert(0); + } + + fprintf(stderr, "hc: cells fill %" PRIu64 " size %" PRIu64 "\r\n", r->cells.fill, r->cells.size); + fprintf(stderr, "hc: atoms fill %" PRIu64 " size %" PRIu64 "\r\n", r->atoms.fill, r->atoms.size); + + ur_nref ken = _cu_from_loom(r, u3A->roc); + + fprintf(stderr, "hc: cells fill %" PRIu64 " size %" PRIu64 "\r\n", r->cells.fill, r->cells.size); + fprintf(stderr, "hc: atoms fill %" PRIu64 " size %" PRIu64 "\r\n", r->atoms.fill, r->atoms.size); + + + c3_w cod_w = u3h_wyt(u3R->jed.cod_p); + ur_nvec_t v; + + fprintf(stderr, "hc: cold count %u\r\n", cod_w); + + { + _cu_vec dat_u = { .vec_u = &v, .rot_u = r }; + ur_nvec_init(&v, cod_w); + u3h_walk_with(u3R->jed.cod_p, _cu_hamt_walk, &dat_u); + } + + + fprintf(stderr, "hc: cells fill %" PRIu64 " size %" PRIu64 "\r\n", r->cells.fill, r->cells.size); + fprintf(stderr, "hc: atoms fill %" PRIu64 " size %" PRIu64 "\r\n", r->atoms.fill, r->atoms.size); + + u3m_pave(c3y, c3n); + // XX wtf? + u3R->jed.hot_p = u3h_new(); + + u3_atom *vat; + u3_noun *cel; + + { + ur_atoms_t *atoms = &(r->atoms); + uint64_t *lens = atoms->lens; + uint8_t **byts = atoms->bytes; + uint64_t i, fill = atoms->fill; + + vat = calloc(fill, sizeof(u3_atom)); + + for ( i = 0; i < fill; i++ ) { + vat[i] = u3i_bytes(lens[i], byts[i]); + // XX mug? + } + } + + { + ur_cells_t *cells = &(r->cells); + ur_nref *heds = cells->heads, *tals = cells->tails; + uint64_t i, fill = cells->fill; + u3_noun hed, tal; + + cel = calloc(fill, sizeof(u3_noun)); + + for ( i = 0; i < fill; i++ ) { + hed = _cu_ref_to_noun(heds[i], vat, cel); + tal = _cu_ref_to_noun(tals[i], vat, cel); + cel[i] = u3nc(hed, tal); + // XX mug? + } + } + + u3A->roc = cel[ur_nref_idx(ken)]; + + { + uint32_t i; + ur_nref ref; + u3_noun kev; + + for ( i = 0; i < cod_w; i++) { + ref = v.refs[i]; + kev = cel[ur_nref_idx(ref)]; + u3h_put(u3R->jed.cod_p, u3h(kev), u3k(u3t(kev))); + u3z(kev); + } + } + + // mark all pages dirty + // + memset((void*)u3P.dit_w, 0xff, u3a_pages >> 3); +} diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 1017989816..0ca5809758 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -270,6 +270,10 @@ ur_coin_bytes(ur_root_t *r, uint8_t *byt, uint64_t len) ur_dict_t *dict = &(atoms->dict); ur_mug mug = ur_mug_bytes(byt, len); + // XX should check for <= 62 bits, coin direct + // XX conflicts with current u3u_uniq() use-case + // + while ( 1 ) { uint64_t idx = ( mug % dict->size ); ur_pail_t *bucket = &(dict->buckets[idx]); @@ -398,3 +402,10 @@ ur_hcon_init(void) return r; } + +void +ur_nvec_init(ur_nvec_t *v, uint64_t size) +{ + v->fill = 0; + v->refs = calloc(size, sizeof(ur_nref)); +} diff --git a/pkg/urbit/worker/main.c b/pkg/urbit/worker/main.c index b5872620fe..512fd908f8 100644 --- a/pkg/urbit/worker/main.c +++ b/pkg/urbit/worker/main.c @@ -290,400 +290,6 @@ _cw_queu(c3_i argc, c3_c* argv[]) } } - -// stack frame for recording head vs tail iteration -// -// In Hoon, this structure would be as follows: -// -// $% [%root ~] -// [%head cell=^] -// [%tail cell=^ hed-mug=@] -// == -// - -#define STACK_ROOT 0 -#define STACK_HEAD 1 -#define STACK_TAIL 2 - -typedef struct ur_temp_s -{ - uint64_t prev; - uint64_t size; - void *base; - void *top; -} ur_temp_t; - -void -ur_temp_init(ur_temp_t *t) -{ - uint64_t fib19 = 4181, fib20 = 6765; - - t->prev = fib19; - t->size = fib20; - t->base = malloc(fib20); - t->top = t->base; -} - -void* -ur_temp_push(ur_temp_t *t, size_t wide) -{ - uint64_t fill = t->top - t->base; - uint64_t grow = t->size + wide; - - if ( fill > (t->size + wide) ) { - uint64_t next = t->prev + t->size; - t->base = realloc(t->base, next); - t->top = t->base + fill; - } - - { - void* ptr = t->top; - t->top += wide; - return ptr; - } -} - -void* -ur_temp_peek(ur_temp_t *t, size_t wide) -{ - return t->top - wide; -} - -void -ur_temp_pop(ur_temp_t *t, size_t wide) -{ - t->top -= wide; - assert( t->top >= t->base ); -} - -typedef struct _ur_frame_s -{ - c3_y tag_y; - u3a_cell* cel_u; - ur_nref ref; -} _ur_frame_t; - -typedef struct _ur_stack_s -{ - uint32_t prev; - uint32_t size; - uint32_t fill; - _ur_frame_t *entries; -} _ur_stack_t; - -static inline void -_stack_push(_ur_stack_t *s, c3_y tag_y, u3a_cell* cel_u, ur_nref ref) -{ - if ( s->fill == s->size ) { - uint32_t next = s->prev + s->size; - s->entries = realloc(s->entries, next * sizeof(_ur_frame_t)); - s->prev = s->size; - s->size = next; - } - - _ur_frame_t* fam_u = &(s->entries[s->fill++]); - fam_u->tag_y = tag_y; - fam_u->cel_u = cel_u; - fam_u->ref = ref; -} - -static ur_nref -_from_loom(ur_root_t *r, u3_noun a) -{ - ur_nref ref; - - _ur_stack_t s; - s.prev = 89; - s.size = 144; - s.fill = 0; - s.entries = malloc((s.prev + s.size) * sizeof(_ur_frame_t)); - _stack_push(&s, STACK_ROOT, 0, 0); - - // ur_temp_t t; - // ur_temp_init(&t); - - // { - // _ur_frame_t *fam_u = ur_temp_push(&t, sizeof(_ur_frame_t)); - // fam_u->tag_y = STACK_ROOT; - // } - - advance: { - // u3 direct == ur direct - // - if ( c3y == u3a_is_cat(a) ) { - ref = (ur_nref)a; - goto retreat; - } - else { - u3a_noun* som_u = u3a_to_ptr(a); - u3a_box* box_u = u3a_botox(som_u); - c3_w* box_w = (void*)box_u; - - // all bits set == already reallocated - // - if ( 0xffffffff == box_w[0] ) { - ref = ( ((uint64_t)box_w[2]) << 32 - | ((uint64_t)box_w[1]) ); - goto retreat; - } - else if ( c3y == u3a_is_atom(a) ) { - u3a_atom* vat_u = (u3a_atom*)som_u; - - // coin an nref - // - switch ( vat_u->len_w ) { - case 2: { - ref = ur_coin64(r, ( ((uint64_t)vat_u->buf_w[1]) << 32 - | ((uint64_t)vat_u->buf_w[0]) )); - } break; - - case 1: { - ref = ur_coin64(r, (uint64_t)vat_u->buf_w[0]); - } break; - - - default: { - c3_assert( vat_u->len_w ); - - uint8_t *byt = (uint8_t*)vat_u->buf_w; - uint64_t len = u3r_met(3, a); - - ref = ur_coin_bytes(r, byt, len); - } break; - } - - // overwrite u3a_atom with reallocated reference - // - box_w[0] = 0xffffffff; - box_w[1] = ref & 0xffffffff; - box_w[2] = ref >> 32; - - goto retreat; - } - else { - u3a_cell* cel_u = (u3a_cell*)som_u; - _stack_push(&s, STACK_HEAD, cel_u, 0); - // { - // _ur_frame_t *fam_u = ur_temp_push(&t, sizeof(_ur_frame_t)); - // fam_u->tag_y = STACK_HEAD; - // fam_u->cel_u = cel_u; - // } - a = cel_u->hed; - goto advance; - } - } - } - - retreat: { - _ur_frame_t fam_u = s.entries[--s.fill]; - - // c3_y tag_y; - // u3a_cell* cel_u; - // ur_nref hed; - // { - // _ur_frame_t *fam_u = ur_temp_peek(&t, sizeof(_ur_frame_t)); - - // tag_y = fam_u->tag_y; - // cel_u = fam_u->cel_u; - // hed = fam_u->ref; - - // ur_temp_pop(&t, sizeof(_ur_frame_t)); - // } - - switch ( fam_u.tag_y ) { - // switch ( tag_y ) { - default: { - c3_assert(0); - } - - case STACK_ROOT: { - break; - } - - case STACK_HEAD: { - _stack_push(&s, STACK_TAIL, fam_u.cel_u, ref); - // { - // _ur_frame_t *fam_u = ur_temp_push(&t, sizeof(_ur_frame_t)); - // fam_u->tag_y = STACK_TAIL; - // fam_u->cel_u = cel_u; - // fam_u->ref = ref; - // } - - a = fam_u.cel_u->tel; - // a = cel_u->tel; - goto advance; - } - - case STACK_TAIL: { - u3a_cell* cel_u = fam_u.cel_u; - u3a_box* box_u = u3a_botox(cel_u); - c3_w* box_w = (void*)box_u; - - ref = ur_cons(r, fam_u.ref, ref); - // ref = ur_cons(r, hed, ref); - - // overwrite u3a_atom with reallocated reference - // - box_w[0] = 0xffffffff; - box_w[1] = ref & 0xffffffff; - box_w[2] = ref >> 32; - - goto retreat; - } - } - } - - free(s.entries); - // free(t.base); - - return ref; -} - -typedef struct ur_nvec_s { - void* data; - uint64_t fill; - ur_nref* refs; -} ur_nvec_t; - -void -ur_nvec_init(ur_nvec_t *v, uint64_t size, void* ptr) -{ - v->data = ptr; - v->fill = 0; - v->refs = calloc(size, sizeof(ur_nref)); -} - -// XX u3h_use() -static c3_w -_hamt_count(u3p(u3h_root) har_p) -{ - u3h_root* har_u = u3to(u3h_root, har_p); - return har_u->use_w; -} - -static void -_from_hamt(u3_noun kev, void* ptr) -{ - ur_nvec_t *v = (ur_nvec_t*)ptr; - ur_root_t *r = v->data; - - v->refs[v->fill++] = _from_loom(r, kev); -} - -static u3_noun -_ref_to_noun(ur_nref ref, u3_noun* vat, u3_noun* cel) -{ - switch ( ur_nref_tag(ref) ) { - default: assert(0); - - case ur_direct: { - if ( 0x7fffffffULL > ref ) { - return (u3_atom)ref; - } - else { - c3_w wor_w[2]; - - wor_w[0] = ref & 0xffffffff; - wor_w[1] = ref >> 32; - - return u3i_words(2, wor_w); - } - } break; - - case ur_iatom: return vat[ur_nref_idx(ref)]; - - case ur_icell: return cel[ur_nref_idx(ref)]; - } -} - -void -do_stuff(void) -{ - ur_root_t *r = ur_hcon_init(); - - // allow read/write on the whole loom, bypassing page tracking - // - if ( 0 != mprotect((void *)u3_Loom, u3a_bytes, (PROT_READ | PROT_WRITE)) ) { - c3_assert(0); - } - - fprintf(stderr, "hc: cells fill %" PRIu64 " size %" PRIu64 "\r\n", r->cells.fill, r->cells.size); - fprintf(stderr, "hc: atoms fill %" PRIu64 " size %" PRIu64 "\r\n", r->atoms.fill, r->atoms.size); - - ur_nref ken = _from_loom(r, u3A->roc); - - fprintf(stderr, "hc: cells fill %" PRIu64 " size %" PRIu64 "\r\n", r->cells.fill, r->cells.size); - fprintf(stderr, "hc: atoms fill %" PRIu64 " size %" PRIu64 "\r\n", r->atoms.fill, r->atoms.size); - - - c3_w cod_w = _hamt_count(u3R->jed.cod_p); - ur_nvec_t v; - - fprintf(stderr, "hc: cold count %u\r\n", cod_w); - - ur_nvec_init(&v, cod_w, r); - u3h_walk_with(u3R->jed.cod_p, _from_hamt, &v); - - fprintf(stderr, "hc: cells fill %" PRIu64 " size %" PRIu64 "\r\n", r->cells.fill, r->cells.size); - fprintf(stderr, "hc: atoms fill %" PRIu64 " size %" PRIu64 "\r\n", r->atoms.fill, r->atoms.size); - - u3m_pave(c3y, c3n); - // XX wtf? - u3R->jed.hot_p = u3h_new(); - - u3_atom *vat; - u3_noun *cel; - - { - ur_atoms_t *atoms = &(r->atoms); - uint64_t *lens = atoms->lens; - uint8_t **byts = atoms->bytes; - uint64_t i, fill = atoms->fill; - - vat = calloc(fill, sizeof(u3_atom)); - - for ( i = 0; i < fill; i++ ) { - vat[i] = u3i_bytes(lens[i], byts[i]); - // XX mug? - } - } - - { - ur_cells_t *cells = &(r->cells); - ur_nref *heds = cells->heads, *tals = cells->tails; - uint64_t i, fill = cells->fill; - u3_noun hed, tal; - - cel = calloc(fill, sizeof(u3_noun)); - - for ( i = 0; i < fill; i++ ) { - hed = _ref_to_noun(heds[i], vat, cel); - tal = _ref_to_noun(tals[i], vat, cel); - cel[i] = u3nc(hed, tal); - // XX mug? - } - } - - u3A->roc = cel[ur_nref_idx(ken)]; - - { - uint32_t i; - ur_nref ref; - u3_noun kev; - - for ( i = 0; i < cod_w; i++) { - ref = v.refs[i]; - kev = cel[ur_nref_idx(ref)]; - u3h_put(u3R->jed.cod_p, u3h(kev), u3k(u3t(kev))); - u3z(kev); - } - } - - // mark all pages dirty - // - memset((void*)u3P.dit_w, 0xff, u3a_pages >> 3); -} - /* _cw_uniq(); deduplicate persistent nouns */ static void @@ -696,7 +302,7 @@ _cw_uniq(c3_i argc, c3_c* argv[]) u3_serf_grab(); - do_stuff(); + u3u_uniq(); u3_serf_grab(); From 90f2d1e4be4f7e956978e11761d5772588e08512 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 29 Jul 2020 13:56:09 -0700 Subject: [PATCH 120/933] serf: adds uniq command to urbt-worker usage string --- pkg/urbit/worker/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/urbit/worker/main.c b/pkg/urbit/worker/main.c index 512fd908f8..b57d38fc39 100644 --- a/pkg/urbit/worker/main.c +++ b/pkg/urbit/worker/main.c @@ -339,13 +339,15 @@ _cw_usage(c3_i argc, c3_c* argv[]) " %s grab \n\n" " compact persistent state:\n" " %s pack \n\n" + " deduplicate persistent state:\n" + " %s uniq \n\n" " jam persistent state:\n" " %s cram \n\n" " cue persistent state:\n" " %s queu \n\n" " run as a 'serf':\n" " %s serf \n", - argv[0], argv[0], argv[0], argv[0], argv[0], argv[0]); + argv[0], argv[0], argv[0], argv[0], argv[0], argv[0], argv[0]); } /* main(): main() when run as urbit-worker From 9b2a267c1dc3253b199979e84b793f0aa0226dc4 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 29 Jul 2020 15:30:09 -0700 Subject: [PATCH 121/933] u3: refactors on-loom reallocation in u3u_uniq() --- pkg/urbit/noun/urth.c | 138 ++++++++++++++++++++++++------------------ 1 file changed, 80 insertions(+), 58 deletions(-) diff --git a/pkg/urbit/noun/urth.c b/pkg/urbit/noun/urth.c index c5a40373d8..5aa92d1ed9 100644 --- a/pkg/urbit/noun/urth.c +++ b/pkg/urbit/noun/urth.c @@ -222,10 +222,48 @@ _cu_from_loom(ur_root_t *r, u3_noun a) return ref; } +typedef struct _cu_vec_s { + ur_nvec_t* vec_u; + ur_root_t* rot_u; +} _cu_vec; + +/* _cu_hamt_walk(): reallocate key/value pair in hamt walk. +*/ +static void +_cu_hamt_walk(u3_noun kev, void* ptr) +{ + _cu_vec* dat_u = (_cu_vec*)ptr; + ur_nvec_t* vec_u = dat_u->vec_u; + ur_root_t* rot_u = dat_u->rot_u; + + vec_u->refs[vec_u->fill++] = _cu_from_loom(rot_u, kev); +} + +typedef struct _cu_loom_s { + u3_atom *vat; + u3_noun *cel; +} _cu_loom; + +/* _cu_atoms_to_loom(): allocate all indirect atoms on the loom. +*/ +static void +_cu_atoms_to_loom(ur_root_t* rot_u, _cu_loom* lom_u) +{ + c3_d* len_d = rot_u->atoms.lens; + c3_y** byt_y = rot_u->atoms.bytes; + c3_d fil_d = rot_u->atoms.fill; + u3_atom* vat = lom_u->vat = calloc(fil_d, sizeof(u3_atom)); + c3_d i_d; + + for ( i_d = 0; i_d < fil_d; i_d++ ) { + vat[i_d] = u3i_bytes(len_d[i_d], byt_y[i_d]); + } +} + /* _cu_ref_to_noun(): lookup/allocate [ref] on the loom. */ static u3_noun -_cu_ref_to_noun(ur_nref ref, u3_noun* vat, u3_noun* cel) +_cu_ref_to_noun(ur_nref ref, _cu_loom* lom_u) { switch ( ur_nref_tag(ref) ) { default: assert(0); @@ -244,27 +282,28 @@ _cu_ref_to_noun(ur_nref ref, u3_noun* vat, u3_noun* cel) } } break; - case ur_iatom: return vat[ur_nref_idx(ref)]; + case ur_iatom: return lom_u->vat[ur_nref_idx(ref)]; - case ur_icell: return cel[ur_nref_idx(ref)]; + case ur_icell: return lom_u->cel[ur_nref_idx(ref)]; } } -typedef struct _cu_vec_s { - ur_nvec_t* vec_u; - ur_root_t* rot_u; -} _cu_vec; - -/* _cu_hamt_walk(): reallocate key/value pair in hamt walk. +/* _cu_cells_to_loom(): allocate all cells on the loom. */ static void -_cu_hamt_walk(u3_noun kev, void* ptr) +_cu_cells_to_loom(ur_root_t* rot_u, _cu_loom* lom_u) { - _cu_vec* dat_u = (_cu_vec*)ptr; - ur_nvec_t* vec_u = dat_u->vec_u; - ur_root_t* rot_u = dat_u->rot_u; + ur_nref* hed = rot_u->cells.heads; + ur_nref* tal = rot_u->cells.tails; + c3_d fil_d = rot_u->cells.fill; + u3_noun* cel = lom_u->cel = calloc(fil_d, sizeof(u3_noun)); + c3_d i_d; - vec_u->refs[vec_u->fill++] = _cu_from_loom(rot_u, kev); + for ( i_d = 0; i_d < fil_d; i_d++ ) { + cel[i_d] = u3nc(_cu_ref_to_noun(hed[i_d], lom_u), + _cu_ref_to_noun(tal[i_d], lom_u)); + // XX mug? + } } /* u3u_uniq(): hash-cons roots off-loom, reallocate on loom. @@ -278,6 +317,8 @@ u3u_uniq(void) // allow read/write on the whole loom, bypassing page tracking // + // NB: u3e_save() will reinstate protection flags + // if ( 0 != mprotect((void *)u3_Loom, u3a_bytes, (PROT_READ | PROT_WRITE)) ) { c3_assert(0); } @@ -302,61 +343,42 @@ u3u_uniq(void) u3h_walk_with(u3R->jed.cod_p, _cu_hamt_walk, &dat_u); } - fprintf(stderr, "hc: cells fill %" PRIu64 " size %" PRIu64 "\r\n", r->cells.fill, r->cells.size); fprintf(stderr, "hc: atoms fill %" PRIu64 " size %" PRIu64 "\r\n", r->atoms.fill, r->atoms.size); + // NB: hot jet state is not yet re-established + // u3m_pave(c3y, c3n); - // XX wtf? - u3R->jed.hot_p = u3h_new(); - - u3_atom *vat; - u3_noun *cel; { - ur_atoms_t *atoms = &(r->atoms); - uint64_t *lens = atoms->lens; - uint8_t **byts = atoms->bytes; - uint64_t i, fill = atoms->fill; + _cu_loom lom_u; + _cu_atoms_to_loom(r, &lom_u); + _cu_cells_to_loom(r, &lom_u); - vat = calloc(fill, sizeof(u3_atom)); + // restore kernel reference (always a cell) + // + u3A->roc = lom_u.cel[ur_nref_idx(ken)]; - for ( i = 0; i < fill; i++ ) { - vat[i] = u3i_bytes(lens[i], byts[i]); - // XX mug? + // restore cold jet state (always cells) + // + { + c3_w i_w; + ur_nref ref; + u3_noun kev; + + for ( i_w = 0; i_w < cod_w; i_w++) { + ref = v.refs[i_w]; + kev = lom_u.cel[ur_nref_idx(ref)]; + u3h_put(u3R->jed.cod_p, u3h(kev), u3k(u3t(kev))); + u3z(kev); + } } } - { - ur_cells_t *cells = &(r->cells); - ur_nref *heds = cells->heads, *tals = cells->tails; - uint64_t i, fill = cells->fill; - u3_noun hed, tal; - - cel = calloc(fill, sizeof(u3_noun)); - - for ( i = 0; i < fill; i++ ) { - hed = _cu_ref_to_noun(heds[i], vat, cel); - tal = _cu_ref_to_noun(tals[i], vat, cel); - cel[i] = u3nc(hed, tal); - // XX mug? - } - } - - u3A->roc = cel[ur_nref_idx(ken)]; - - { - uint32_t i; - ur_nref ref; - u3_noun kev; - - for ( i = 0; i < cod_w; i++) { - ref = v.refs[i]; - kev = cel[ur_nref_idx(ref)]; - u3h_put(u3R->jed.cod_p, u3h(kev), u3k(u3t(kev))); - u3z(kev); - } - } + // allocate new hot jet state; re-establish warm + // + u3j_boot(c3y); + u3j_ream(); // mark all pages dirty // From 87b10abee4d9ba27278f87c669e5c883a2fac232 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 30 Jul 2020 14:42:16 -0700 Subject: [PATCH 122/933] ur: adds ur_hcon_info() to print memory measurements --- pkg/urbit/include/ur/hashcons.h | 3 + pkg/urbit/ur/hashcons.c | 101 ++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index 3eaa61724b..8f7f451918 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -97,6 +97,9 @@ ur_coin64(ur_root_t *r, uint64_t n); ur_nref ur_cons(ur_root_t *r, ur_nref hed, ur_nref tal); +void +ur_hcon_info(FILE *f, ur_root_t *r); + ur_root_t* ur_hcon_init(void); diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 0ca5809758..43cbadc995 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -367,6 +367,107 @@ ur_cons(ur_root_t *r, ur_nref hed, ur_nref tal) } } +static void +_print_memory(FILE *f, const char *c, uint64_t bytes) +{ + if ( !bytes ) { + fprintf(f, "%s: B/0\r\n", c); + } + else { + uint32_t g = (bytes / 1000000000); + uint32_t m = (bytes % 1000000000) / 1000000; + uint32_t k = (bytes % 1000000) / 1000; + uint32_t b = (bytes % 1000); + + if ( g ) { + fprintf(f, "%s: GB/%d.%03d.%03d.%03d\r\n", c, g, m, k, b); + } + else if ( m ) { + fprintf(f, "%s: MB/%d.%03d.%03d\r\n", c, m, k, b); + } + else if ( k ) { + fprintf(f, "%s: KB/%d.%03d\r\n", c, k, b); + } + else if ( b ) { + fprintf(f, "%s: B/%d\r\n", c, b); + } + } +} + +static uint64_t +_dict_info(FILE *f, ur_dict_t *dict) +{ + uint64_t data = dict->size * sizeof(*dict->buckets); + _print_memory(f, " dict", data); + return data; +} + +static uint64_t +_atoms_info(FILE *f, ur_atoms_t *atoms) +{ + uint64_t total = 0; + uint64_t size = atoms->size; + uint64_t fill = atoms->fill; + uint64_t refs = size * ( sizeof(*atoms->bytes) + + sizeof(*atoms->lens) + + sizeof(*atoms->mugs) ); + uint64_t i, data = 0; + + fprintf(f, " atoms (%" PRIu64 "):\r\n", fill); + + _print_memory(f, " refs", refs); + total += refs; + + for ( i = 0; i < fill; i++ ) { + data += atoms->lens[i]; + } + _print_memory(f, " data", data); + total += data; + + total += _dict_info(f, &(atoms->dict)); + _print_memory(f, " total", total); + return total; +} + +static uint64_t +_cells_info(FILE *f, ur_cells_t *cells) +{ + uint64_t total = 0; + uint64_t size = cells->size; + uint64_t fill = cells->fill; + uint64_t refs = size * ( sizeof(*cells->heads) + + sizeof(*cells->heads) + + sizeof(*cells->mugs) ); + + fprintf(f, " cells (%" PRIu64 "):\r\n", fill); + + _print_memory(f, " refs", refs); + total += refs; + + total += _dict_info(f, &(cells->dict)); + _print_memory(f, " total", total); + return total; +} + +void +ur_hcon_info(FILE *f, ur_root_t *r) +{ + uint64_t total = 0; + + fprintf(stderr, "hash-cons arena:\r\n"); + + { + uint64_t root = sizeof(*r); + _print_memory(f, " root", root); + total += root; + } + + total += _atoms_info(f, &(r->atoms)); + total += _cells_info(f, &(r->cells)); + + _print_memory(f, "total", total); +} + ur_root_t* ur_hcon_init(void) { From d7f6e79409368ee70d36e4251476f402865b4c31 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 30 Jul 2020 14:42:34 -0700 Subject: [PATCH 123/933] u3: refactors u3u_uniq, prints memory measurements --- pkg/urbit/noun/urth.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/pkg/urbit/noun/urth.c b/pkg/urbit/noun/urth.c index 5aa92d1ed9..1c335e348b 100644 --- a/pkg/urbit/noun/urth.c +++ b/pkg/urbit/noun/urth.c @@ -323,34 +323,34 @@ u3u_uniq(void) c3_assert(0); } - fprintf(stderr, "hc: cells fill %" PRIu64 " size %" PRIu64 "\r\n", r->cells.fill, r->cells.size); - fprintf(stderr, "hc: atoms fill %" PRIu64 " size %" PRIu64 "\r\n", r->atoms.fill, r->atoms.size); - + // reallocate kernel + // ur_nref ken = _cu_from_loom(r, u3A->roc); - fprintf(stderr, "hc: cells fill %" PRIu64 " size %" PRIu64 "\r\n", r->cells.fill, r->cells.size); - fprintf(stderr, "hc: atoms fill %" PRIu64 " size %" PRIu64 "\r\n", r->atoms.fill, r->atoms.size); - - - c3_w cod_w = u3h_wyt(u3R->jed.cod_p); - ur_nvec_t v; - - fprintf(stderr, "hc: cold count %u\r\n", cod_w); - + // reallocate cold jet state + // + ur_nvec_t cod_u; { - _cu_vec dat_u = { .vec_u = &v, .rot_u = r }; - ur_nvec_init(&v, cod_w); + c3_w cod_w = u3h_wyt(u3R->jed.cod_p); + _cu_vec dat_u = { .vec_u = &cod_u, .rot_u = r }; + ur_nvec_init(&cod_u, cod_w); u3h_walk_with(u3R->jed.cod_p, _cu_hamt_walk, &dat_u); } - fprintf(stderr, "hc: cells fill %" PRIu64 " size %" PRIu64 "\r\n", r->cells.fill, r->cells.size); - fprintf(stderr, "hc: atoms fill %" PRIu64 " size %" PRIu64 "\r\n", r->atoms.fill, r->atoms.size); + // print [rot_u] measurements + // + ur_hcon_info(stderr, r); + fprintf(stderr, "\r\n"); - // NB: hot jet state is not yet re-established + // reinitialize looom + // + // NB: hot jet state is not yet re-established // u3m_pave(c3y, c3n); { + // reallocate all nouns on the loom + // _cu_loom lom_u; _cu_atoms_to_loom(r, &lom_u); _cu_cells_to_loom(r, &lom_u); @@ -362,12 +362,13 @@ u3u_uniq(void) // restore cold jet state (always cells) // { - c3_w i_w; + c3_d max_d = cod_u.fill; + c3_d i_d; ur_nref ref; u3_noun kev; - for ( i_w = 0; i_w < cod_w; i_w++) { - ref = v.refs[i_w]; + for ( i_d = 0; i_d < max_d; i_d++) { + ref = cod_u.refs[i_d]; kev = lom_u.cel[ur_nref_idx(ref)]; u3h_put(u3R->jed.cod_p, u3h(kev), u3k(u3t(kev))); u3z(kev); From 52c86946d7c82df9ed6e898b499fefbed3d738a5 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 30 Jul 2020 14:51:39 -0700 Subject: [PATCH 124/933] u3: moves event-number tracking inside u3u_uniq() --- pkg/urbit/noun/urth.c | 24 +++++++++++++++--------- pkg/urbit/worker/main.c | 5 ++--- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/pkg/urbit/noun/urth.c b/pkg/urbit/noun/urth.c index 1c335e348b..adac66eef4 100644 --- a/pkg/urbit/noun/urth.c +++ b/pkg/urbit/noun/urth.c @@ -313,8 +313,6 @@ u3u_uniq(void) { c3_assert( &(u3H->rod_u) == u3R ); - ur_root_t *r = ur_hcon_init(); - // allow read/write on the whole loom, bypassing page tracking // // NB: u3e_save() will reinstate protection flags @@ -323,23 +321,27 @@ u3u_uniq(void) c3_assert(0); } - // reallocate kernel + // stash event number // - ur_nref ken = _cu_from_loom(r, u3A->roc); + c3_d eve_d = u3A->ent_d; - // reallocate cold jet state + + // reallocate kernel and cold jet state // + ur_root_t* rot_u = ur_hcon_init(); + ur_nref ken = _cu_from_loom(rot_u, u3A->roc); + ur_nvec_t cod_u; { c3_w cod_w = u3h_wyt(u3R->jed.cod_p); - _cu_vec dat_u = { .vec_u = &cod_u, .rot_u = r }; + _cu_vec dat_u = { .vec_u = &cod_u, .rot_u = rot_u }; ur_nvec_init(&cod_u, cod_w); u3h_walk_with(u3R->jed.cod_p, _cu_hamt_walk, &dat_u); } // print [rot_u] measurements // - ur_hcon_info(stderr, r); + ur_hcon_info(stderr, rot_u); fprintf(stderr, "\r\n"); // reinitialize looom @@ -352,8 +354,8 @@ u3u_uniq(void) // reallocate all nouns on the loom // _cu_loom lom_u; - _cu_atoms_to_loom(r, &lom_u); - _cu_cells_to_loom(r, &lom_u); + _cu_atoms_to_loom(rot_u, &lom_u); + _cu_cells_to_loom(rot_u, &lom_u); // restore kernel reference (always a cell) // @@ -381,6 +383,10 @@ u3u_uniq(void) u3j_boot(c3y); u3j_ream(); + // restore event number + // + u3A->ent_d = eve_d; + // mark all pages dirty // memset((void*)u3P.dit_w, 0xff, u3a_pages >> 3); diff --git a/pkg/urbit/worker/main.c b/pkg/urbit/worker/main.c index b57d38fc39..76eba3004e 100644 --- a/pkg/urbit/worker/main.c +++ b/pkg/urbit/worker/main.c @@ -298,7 +298,8 @@ _cw_uniq(c3_i argc, c3_c* argv[]) c3_assert( 3 <= argc ); c3_c* dir_c = argv[2]; - c3_d eve_d = u3m_boot(dir_c); + + u3m_boot(dir_c); u3_serf_grab(); @@ -306,8 +307,6 @@ _cw_uniq(c3_i argc, c3_c* argv[]) u3_serf_grab(); - u3A->ent_d = eve_d; - u3e_save(); } From cd7f0267a983939db26c99c1b7548399ffce6c77 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 30 Jul 2020 15:19:26 -0700 Subject: [PATCH 125/933] ur: add *_free functions for all dynamic allocations --- pkg/urbit/include/ur/hashcons.h | 6 +++++ pkg/urbit/ur/hashcons.c | 41 +++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index 8f7f451918..adf889a469 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -100,8 +100,14 @@ ur_cons(ur_root_t *r, ur_nref hed, ur_nref tal); void ur_hcon_info(FILE *f, ur_root_t *r); +void +ur_hcon_free(ur_root_t *r); + ur_root_t* ur_hcon_init(void); +void +ur_nvec_free(ur_nvec_t *v); + void ur_nvec_init(ur_nvec_t *v, uint64_t size); diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 43cbadc995..74807a17ad 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -468,6 +468,41 @@ ur_hcon_info(FILE *f, ur_root_t *r) _print_memory(f, "total", total); } +static void +_dict_free(ur_dict_t *dict) +{ + free(dict->buckets); +} + +static void +_atoms_free(ur_atoms_t *atoms) +{ + uint8_t **bytes = atoms->bytes; + uint64_t i, fill = atoms->fill; + + for ( i = 0; i < fill; i++ ) { + free(bytes[i]); + } + + _dict_free(&(atoms->dict)); + free(bytes); +} + +static void +_cells_free(ur_cells_t *cells) +{ + _dict_free(&(cells->dict)); + free(cells->heads); +} + +void +ur_hcon_free(ur_root_t *r) +{ + _atoms_free(&(r->atoms)); + _cells_free(&(r->cells)); + free(r); +} + ur_root_t* ur_hcon_init(void) { @@ -504,6 +539,12 @@ ur_hcon_init(void) return r; } +void +ur_nvec_free(ur_nvec_t *v) +{ + free(v->refs); +} + void ur_nvec_init(ur_nvec_t *v, uint64_t size) { From 993f4b83f4df7a65f76ce03df93871fbf59f659c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 30 Jul 2020 15:20:42 -0700 Subject: [PATCH 126/933] u3: free all dynamic allocations in u3u_uniq() --- pkg/urbit/noun/urth.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/urbit/noun/urth.c b/pkg/urbit/noun/urth.c index adac66eef4..fbfe5e6ef0 100644 --- a/pkg/urbit/noun/urth.c +++ b/pkg/urbit/noun/urth.c @@ -244,6 +244,15 @@ typedef struct _cu_loom_s { u3_noun *cel; } _cu_loom; +/* _cu_loom_free(): dispose loom relocation pointers +*/ +static void +_cu_loom_free(_cu_loom* lom_u) +{ + free(lom_u->vat); + free(lom_u->cel); +} + /* _cu_atoms_to_loom(): allocate all indirect atoms on the loom. */ static void @@ -376,8 +385,15 @@ u3u_uniq(void) u3z(kev); } } + + _cu_loom_free(&lom_u); } + // dispose off-loom structures + // + ur_nvec_free(&cod_u); + ur_hcon_free(rot_u); + // allocate new hot jet state; re-establish warm // u3j_boot(c3y); From 71a0e61c2e9cad155ae019fce03425b877ab4387 Mon Sep 17 00:00:00 2001 From: Fang Date: Sat, 1 Aug 2020 01:05:33 +0200 Subject: [PATCH 127/933] vere: fix missing u3z --- pkg/urbit/vere/io/ames.c | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 88f6a71c02..b385ccf480 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -1102,6 +1102,7 @@ _ames_prot_scry_cb(void* vod_p, u3_noun nun) } sam_u->fit_o = c3y; + u3z(nun); } /* _ames_io_info(): print status info. From 11c86df3ced168b90be7353f0098a90bbf86df16 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 4 Aug 2020 13:24:28 -0400 Subject: [PATCH 128/933] natpmp: Make haskell bindings to libnatpmp and add them to the build. --- pkg/hs/natpmp-static/LICENSE | 26 + pkg/hs/natpmp-static/Setup.hs | 2 + pkg/hs/natpmp-static/cbits/binding.c | 75 +++ pkg/hs/natpmp-static/cbits/binding.h | 8 + pkg/hs/natpmp-static/cbits/getgateway.c | 573 ++++++++++++++++++ pkg/hs/natpmp-static/cbits/getgateway.h | 49 ++ pkg/hs/natpmp-static/cbits/natpmp.c | 379 ++++++++++++ pkg/hs/natpmp-static/cbits/natpmp.h | 219 +++++++ .../natpmp-static/hsrc_lib/Network/NATPMP.hsc | 264 ++++++++ pkg/hs/natpmp-static/natpmp-static.cabal | 88 +++ pkg/hs/stack.yaml | 1 + pkg/hs/urbit-king/package.yaml | 1 + 12 files changed, 1685 insertions(+) create mode 100644 pkg/hs/natpmp-static/LICENSE create mode 100644 pkg/hs/natpmp-static/Setup.hs create mode 100644 pkg/hs/natpmp-static/cbits/binding.c create mode 100644 pkg/hs/natpmp-static/cbits/binding.h create mode 100644 pkg/hs/natpmp-static/cbits/getgateway.c create mode 100644 pkg/hs/natpmp-static/cbits/getgateway.h create mode 100644 pkg/hs/natpmp-static/cbits/natpmp.c create mode 100644 pkg/hs/natpmp-static/cbits/natpmp.h create mode 100644 pkg/hs/natpmp-static/hsrc_lib/Network/NATPMP.hsc create mode 100644 pkg/hs/natpmp-static/natpmp-static.cabal diff --git a/pkg/hs/natpmp-static/LICENSE b/pkg/hs/natpmp-static/LICENSE new file mode 100644 index 0000000000..7fff2c26ae --- /dev/null +++ b/pkg/hs/natpmp-static/LICENSE @@ -0,0 +1,26 @@ +Copyright (c) 2007-2011, Thomas BERNARD +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + diff --git a/pkg/hs/natpmp-static/Setup.hs b/pkg/hs/natpmp-static/Setup.hs new file mode 100644 index 0000000000..9a994af677 --- /dev/null +++ b/pkg/hs/natpmp-static/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/pkg/hs/natpmp-static/cbits/binding.c b/pkg/hs/natpmp-static/cbits/binding.c new file mode 100644 index 0000000000..aa024555a7 --- /dev/null +++ b/pkg/hs/natpmp-static/cbits/binding.c @@ -0,0 +1,75 @@ +/* $Id: natpmpc.c,v 1.13 2012/08/21 17:23:38 nanard Exp $ */ +/* libnatpmp +Copyright (c) 2007-2011, Thomas BERNARD +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include + +#include +#include +#include "natpmp.h" + +// Additional binding code in C to make this more convenient to call from +// Haskell. libnatpmp expects that code which uses it to select() on an +// internal socket, which we don't want to expose to the Haskell bindings user. +// +// This is mostly an adaptation of the code in the demo natpmpc.c to use the +// select() loop. +int readNatResponseSynchronously(natpmp_t* natpmp, natpmpresp_t * response) +{ + fd_set fds; + struct timeval timeout; + int r; + int sav_errno; + + do { + FD_ZERO(&fds); + FD_SET(natpmp->s, &fds); + getnatpmprequesttimeout(natpmp, &timeout); + r = select(FD_SETSIZE, &fds, NULL, NULL, &timeout); + if(r<0) { + fprintf(stderr, "select()"); + return 1; + } + r = readnatpmpresponseorretry(natpmp, response); + sav_errno = errno; + /* printf("readnatpmpresponseorretry returned %d (%s)\n", */ + /* r, r==0?"OK":(r==NATPMP_TRYAGAIN?"TRY AGAIN":"FAILED")); */ + if(r<0 && r!=NATPMP_TRYAGAIN) { +#ifdef ENABLE_STRNATPMPERR + fprintf(stderr, "readnatpmpresponseorretry() failed : %s\n", + strnatpmperr(r)); +#endif + fprintf(stderr, " errno=%d '%s'\n", + sav_errno, strerror(sav_errno)); + } + } while(r==NATPMP_TRYAGAIN); + + return r; +} diff --git a/pkg/hs/natpmp-static/cbits/binding.h b/pkg/hs/natpmp-static/cbits/binding.h new file mode 100644 index 0000000000..f781c8a20b --- /dev/null +++ b/pkg/hs/natpmp-static/cbits/binding.h @@ -0,0 +1,8 @@ +#ifndef __NATPMP_BINDING_H__ +#define __NATPMP_BINDING_H__ + +#include "natpmp.h" + +int readNatResponseSynchronously(natpmp_t* natpmp, natpmpresp_t * response); + +#endif diff --git a/pkg/hs/natpmp-static/cbits/getgateway.c b/pkg/hs/natpmp-static/cbits/getgateway.c new file mode 100644 index 0000000000..dfb9f3e21d --- /dev/null +++ b/pkg/hs/natpmp-static/cbits/getgateway.c @@ -0,0 +1,573 @@ +/* $Id: getgateway.c,v 1.25 2014/04/22 10:28:57 nanard Exp $ */ +/* libnatpmp + +Copyright (c) 2007-2014, Thomas BERNARD +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ +#include +#include +#ifndef WIN32 +#include +#endif +#if !defined(_MSC_VER) +#include +#endif +/* There is no portable method to get the default route gateway. + * So below are four (or five ?) differents functions implementing this. + * Parsing /proc/net/route is for linux. + * sysctl is the way to access such informations on BSD systems. + * Many systems should provide route information through raw PF_ROUTE + * sockets. + * In MS Windows, default gateway is found by looking into the registry + * or by using GetBestRoute(). */ +#ifdef __linux__ +#define USE_PROC_NET_ROUTE +#undef USE_SOCKET_ROUTE +#undef USE_SYSCTL_NET_ROUTE +#endif + +#if defined(BSD) || defined(__FreeBSD_kernel__) +#undef USE_PROC_NET_ROUTE +#define USE_SOCKET_ROUTE +#undef USE_SYSCTL_NET_ROUTE +#endif + +#ifdef __APPLE__ +#undef USE_PROC_NET_ROUTE +#undef USE_SOCKET_ROUTE +#define USE_SYSCTL_NET_ROUTE +#endif + +#if (defined(sun) && defined(__SVR4)) +#undef USE_PROC_NET_ROUTE +#define USE_SOCKET_ROUTE +#undef USE_SYSCTL_NET_ROUTE +#endif + +#ifdef WIN32 +#undef USE_PROC_NET_ROUTE +#undef USE_SOCKET_ROUTE +#undef USE_SYSCTL_NET_ROUTE +//#define USE_WIN32_CODE +#define USE_WIN32_CODE_2 +#endif + +#ifdef __CYGWIN__ +#undef USE_PROC_NET_ROUTE +#undef USE_SOCKET_ROUTE +#undef USE_SYSCTL_NET_ROUTE +#define USE_WIN32_CODE +#include +#include +#include +#include +#endif + +#ifdef __HAIKU__ +#include +#include +#include +#include +#define USE_HAIKU_CODE +#endif + +#ifdef USE_SYSCTL_NET_ROUTE +#include +#include +#include +#include +#endif +#ifdef USE_SOCKET_ROUTE +#include +#include +#include +#include +#include +#endif + +#ifdef USE_WIN32_CODE +#include +#include +#define MAX_KEY_LENGTH 255 +#define MAX_VALUE_LENGTH 16383 +#endif + +#ifdef USE_WIN32_CODE_2 +#include +#include +#endif + +#include "getgateway.h" + +#ifndef WIN32 +#define SUCCESS (0) +#define FAILED (-1) +#endif + +#ifdef USE_PROC_NET_ROUTE +/* + parse /proc/net/route which is as follow : + +Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT +wlan0 0001A8C0 00000000 0001 0 0 0 00FFFFFF 0 0 0 +eth0 0000FEA9 00000000 0001 0 0 0 0000FFFF 0 0 0 +wlan0 00000000 0101A8C0 0003 0 0 0 00000000 0 0 0 +eth0 00000000 00000000 0001 0 0 1000 00000000 0 0 0 + + One header line, and then one line by route by route table entry. +*/ +int getdefaultgateway(in_addr_t * addr) +{ + unsigned long d, g; + char buf[256]; + int line = 0; + FILE * f; + char * p; + f = fopen("/proc/net/route", "r"); + if(!f) + return FAILED; + while(fgets(buf, sizeof(buf), f)) { + if(line > 0) { /* skip the first line */ + p = buf; + /* skip the interface name */ + while(*p && !isspace(*p)) + p++; + while(*p && isspace(*p)) + p++; + if(sscanf(p, "%lx%lx", &d, &g)==2) { + if(d == 0 && g != 0) { /* default */ + *addr = g; + fclose(f); + return SUCCESS; + } + } + } + line++; + } + /* default route not found ! */ + if(f) + fclose(f); + return FAILED; +} +#endif /* #ifdef USE_PROC_NET_ROUTE */ + + +#ifdef USE_SYSCTL_NET_ROUTE + +#define ROUNDUP(a) \ + ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) + +int getdefaultgateway(in_addr_t * addr) +{ +#if 0 + /* net.route.0.inet.dump.0.0 ? */ + int mib[] = {CTL_NET, PF_ROUTE, 0, AF_INET, + NET_RT_DUMP, 0, 0/*tableid*/}; +#endif + /* net.route.0.inet.flags.gateway */ + int mib[] = {CTL_NET, PF_ROUTE, 0, AF_INET, + NET_RT_FLAGS, RTF_GATEWAY}; + size_t l; + char * buf, * p; + struct rt_msghdr * rt; + struct sockaddr * sa; + struct sockaddr * sa_tab[RTAX_MAX]; + int i; + int r = FAILED; + if(sysctl(mib, sizeof(mib)/sizeof(int), 0, &l, 0, 0) < 0) { + return FAILED; + } + if(l>0) { + buf = malloc(l); + if(sysctl(mib, sizeof(mib)/sizeof(int), buf, &l, 0, 0) < 0) { + free(buf); + return FAILED; + } + for(p=buf; prtm_msglen) { + rt = (struct rt_msghdr *)p; + sa = (struct sockaddr *)(rt + 1); + for(i=0; irtm_addrs & (1 << i)) { + sa_tab[i] = sa; + sa = (struct sockaddr *)((char *)sa + ROUNDUP(sa->sa_len)); + } else { + sa_tab[i] = NULL; + } + } + if( ((rt->rtm_addrs & (RTA_DST|RTA_GATEWAY)) == (RTA_DST|RTA_GATEWAY)) + && sa_tab[RTAX_DST]->sa_family == AF_INET + && sa_tab[RTAX_GATEWAY]->sa_family == AF_INET) { + if(((struct sockaddr_in *)sa_tab[RTAX_DST])->sin_addr.s_addr == 0) { + *addr = ((struct sockaddr_in *)(sa_tab[RTAX_GATEWAY]))->sin_addr.s_addr; + r = SUCCESS; + } + } + } + free(buf); + } + return r; +} +#endif /* #ifdef USE_SYSCTL_NET_ROUTE */ + + +#ifdef USE_SOCKET_ROUTE +/* Thanks to Darren Kenny for this code */ +#define NEXTADDR(w, u) \ + if (rtm_addrs & (w)) {\ + l = sizeof(struct sockaddr); memmove(cp, &(u), l); cp += l;\ + } + +#define rtm m_rtmsg.m_rtm + +struct { + struct rt_msghdr m_rtm; + char m_space[512]; +} m_rtmsg; + +int getdefaultgateway(in_addr_t *addr) +{ + int s, seq, l, rtm_addrs, i; + pid_t pid; + struct sockaddr so_dst, so_mask; + char *cp = m_rtmsg.m_space; + struct sockaddr *gate = NULL, *sa; + struct rt_msghdr *msg_hdr; + + pid = getpid(); + seq = 0; + rtm_addrs = RTA_DST | RTA_NETMASK; + + memset(&so_dst, 0, sizeof(so_dst)); + memset(&so_mask, 0, sizeof(so_mask)); + memset(&rtm, 0, sizeof(struct rt_msghdr)); + + rtm.rtm_type = RTM_GET; + rtm.rtm_flags = RTF_UP | RTF_GATEWAY; + rtm.rtm_version = RTM_VERSION; + rtm.rtm_seq = ++seq; + rtm.rtm_addrs = rtm_addrs; + + so_dst.sa_family = AF_INET; + so_mask.sa_family = AF_INET; + + NEXTADDR(RTA_DST, so_dst); + NEXTADDR(RTA_NETMASK, so_mask); + + rtm.rtm_msglen = l = cp - (char *)&m_rtmsg; + + s = socket(PF_ROUTE, SOCK_RAW, 0); + + if (write(s, (char *)&m_rtmsg, l) < 0) { + close(s); + return FAILED; + } + + do { + l = read(s, (char *)&m_rtmsg, sizeof(m_rtmsg)); + } while (l > 0 && (rtm.rtm_seq != seq || rtm.rtm_pid != pid)); + + close(s); + + msg_hdr = &rtm; + + cp = ((char *)(msg_hdr + 1)); + if (msg_hdr->rtm_addrs) { + for (i = 1; i; i <<= 1) + if (i & msg_hdr->rtm_addrs) { + sa = (struct sockaddr *)cp; + if (i == RTA_GATEWAY ) + gate = sa; + + cp += sizeof(struct sockaddr); + } + } else { + return FAILED; + } + + + if (gate != NULL ) { + *addr = ((struct sockaddr_in *)gate)->sin_addr.s_addr; + return SUCCESS; + } else { + return FAILED; + } +} +#endif /* #ifdef USE_SOCKET_ROUTE */ + +#ifdef USE_WIN32_CODE +LIBSPEC int getdefaultgateway(in_addr_t * addr) +{ + HKEY networkCardsKey; + HKEY networkCardKey; + HKEY interfacesKey; + HKEY interfaceKey; + DWORD i = 0; + DWORD numSubKeys = 0; + TCHAR keyName[MAX_KEY_LENGTH]; + DWORD keyNameLength = MAX_KEY_LENGTH; + TCHAR keyValue[MAX_VALUE_LENGTH]; + DWORD keyValueLength = MAX_VALUE_LENGTH; + DWORD keyValueType = REG_SZ; + TCHAR gatewayValue[MAX_VALUE_LENGTH]; + DWORD gatewayValueLength = MAX_VALUE_LENGTH; + DWORD gatewayValueType = REG_MULTI_SZ; + int done = 0; + + //const char * networkCardsPath = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards"; + //const char * interfacesPath = "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces"; +#ifdef UNICODE + LPCTSTR networkCardsPath = L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards"; + LPCTSTR interfacesPath = L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces"; +#define STR_SERVICENAME L"ServiceName" +#define STR_DHCPDEFAULTGATEWAY L"DhcpDefaultGateway" +#define STR_DEFAULTGATEWAY L"DefaultGateway" +#else + LPCTSTR networkCardsPath = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards"; + LPCTSTR interfacesPath = "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces"; +#define STR_SERVICENAME "ServiceName" +#define STR_DHCPDEFAULTGATEWAY "DhcpDefaultGateway" +#define STR_DEFAULTGATEWAY "DefaultGateway" +#endif + // The windows registry lists its primary network devices in the following location: + // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards + // + // Each network device has its own subfolder, named with an index, with various properties: + // -NetworkCards + // -5 + // -Description = Broadcom 802.11n Network Adapter + // -ServiceName = {E35A72F8-5065-4097-8DFE-C7790774EE4D} + // -8 + // -Description = Marvell Yukon 88E8058 PCI-E Gigabit Ethernet Controller + // -ServiceName = {86226414-5545-4335-A9D1-5BD7120119AD} + // + // The above service name is the name of a subfolder within: + // HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces + // + // There may be more subfolders in this interfaces path than listed in the network cards path above: + // -Interfaces + // -{3a539854-6a70-11db-887c-806e6f6e6963} + // -DhcpIPAddress = 0.0.0.0 + // -[more] + // -{E35A72F8-5065-4097-8DFE-C7790774EE4D} + // -DhcpIPAddress = 10.0.1.4 + // -DhcpDefaultGateway = 10.0.1.1 + // -[more] + // -{86226414-5545-4335-A9D1-5BD7120119AD} + // -DhcpIpAddress = 10.0.1.5 + // -DhcpDefaultGateay = 10.0.1.1 + // -[more] + // + // In order to extract this information, we enumerate each network card, and extract the ServiceName value. + // This is then used to open the interface subfolder, and attempt to extract a DhcpDefaultGateway value. + // Once one is found, we're done. + // + // It may be possible to simply enumerate the interface folders until we find one with a DhcpDefaultGateway value. + // However, the technique used is the technique most cited on the web, and we assume it to be more correct. + + if(ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE, // Open registry key or predifined key + networkCardsPath, // Name of registry subkey to open + 0, // Reserved - must be zero + KEY_READ, // Mask - desired access rights + &networkCardsKey)) // Pointer to output key + { + // Unable to open network cards keys + return -1; + } + + if(ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE, // Open registry key or predefined key + interfacesPath, // Name of registry subkey to open + 0, // Reserved - must be zero + KEY_READ, // Mask - desired access rights + &interfacesKey)) // Pointer to output key + { + // Unable to open interfaces key + RegCloseKey(networkCardsKey); + return -1; + } + + // Figure out how many subfolders are within the NetworkCards folder + RegQueryInfoKey(networkCardsKey, NULL, NULL, NULL, &numSubKeys, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + + //printf( "Number of subkeys: %u\n", (unsigned int)numSubKeys); + + // Enumrate through each subfolder within the NetworkCards folder + for(i = 0; i < numSubKeys && !done; i++) + { + keyNameLength = MAX_KEY_LENGTH; + if(ERROR_SUCCESS == RegEnumKeyEx(networkCardsKey, // Open registry key + i, // Index of subkey to retrieve + keyName, // Buffer that receives the name of the subkey + &keyNameLength, // Variable that receives the size of the above buffer + NULL, // Reserved - must be NULL + NULL, // Buffer that receives the class string + NULL, // Variable that receives the size of the above buffer + NULL)) // Variable that receives the last write time of subkey + { + if(RegOpenKeyEx(networkCardsKey, keyName, 0, KEY_READ, &networkCardKey) == ERROR_SUCCESS) + { + keyValueLength = MAX_VALUE_LENGTH; + if(ERROR_SUCCESS == RegQueryValueEx(networkCardKey, // Open registry key + STR_SERVICENAME, // Name of key to query + NULL, // Reserved - must be NULL + &keyValueType, // Receives value type + (LPBYTE)keyValue, // Receives value + &keyValueLength)) // Receives value length in bytes + { +// printf("keyValue: %s\n", keyValue); + if(RegOpenKeyEx(interfacesKey, keyValue, 0, KEY_READ, &interfaceKey) == ERROR_SUCCESS) + { + gatewayValueLength = MAX_VALUE_LENGTH; + if(ERROR_SUCCESS == RegQueryValueEx(interfaceKey, // Open registry key + STR_DHCPDEFAULTGATEWAY, // Name of key to query + NULL, // Reserved - must be NULL + &gatewayValueType, // Receives value type + (LPBYTE)gatewayValue, // Receives value + &gatewayValueLength)) // Receives value length in bytes + { + // Check to make sure it's a string + if((gatewayValueType == REG_MULTI_SZ || gatewayValueType == REG_SZ) && (gatewayValueLength > 1)) + { + //printf("gatewayValue: %s\n", gatewayValue); + done = 1; + } + } + else if(ERROR_SUCCESS == RegQueryValueEx(interfaceKey, // Open registry key + STR_DEFAULTGATEWAY, // Name of key to query + NULL, // Reserved - must be NULL + &gatewayValueType, // Receives value type + (LPBYTE)gatewayValue,// Receives value + &gatewayValueLength)) // Receives value length in bytes + { + // Check to make sure it's a string + if((gatewayValueType == REG_MULTI_SZ || gatewayValueType == REG_SZ) && (gatewayValueLength > 1)) + { + //printf("gatewayValue: %s\n", gatewayValue); + done = 1; + } + } + RegCloseKey(interfaceKey); + } + } + RegCloseKey(networkCardKey); + } + } + } + + RegCloseKey(interfacesKey); + RegCloseKey(networkCardsKey); + + if(done) + { +#if UNICODE + char tmp[32]; + for(i = 0; i < 32; i++) { + tmp[i] = (char)gatewayValue[i]; + if(!tmp[i]) + break; + } + tmp[31] = '\0'; + *addr = inet_addr(tmp); +#else + *addr = inet_addr(gatewayValue); +#endif + return 0; + } + + return -1; +} +#endif /* #ifdef USE_WIN32_CODE */ + +#ifdef USE_WIN32_CODE_2 +int getdefaultgateway(in_addr_t *addr) +{ + MIB_IPFORWARDROW ip_forward; + memset(&ip_forward, 0, sizeof(ip_forward)); + if(GetBestRoute(inet_addr("0.0.0.0"), 0, &ip_forward) != NO_ERROR) + return -1; + *addr = ip_forward.dwForwardNextHop; + return 0; +} +#endif /* #ifdef USE_WIN32_CODE_2 */ + +#ifdef USE_HAIKU_CODE +int getdefaultgateway(in_addr_t *addr) +{ + int fd, ret = -1; + struct ifconf config; + void *buffer = NULL; + struct ifreq *interface; + + if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + return -1; + } + if (ioctl(fd, SIOCGRTSIZE, &config, sizeof(config)) != 0) { + goto fail; + } + if (config.ifc_value < 1) { + goto fail; /* No routes */ + } + if ((buffer = malloc(config.ifc_value)) == NULL) { + goto fail; + } + config.ifc_len = config.ifc_value; + config.ifc_buf = buffer; + if (ioctl(fd, SIOCGRTTABLE, &config, sizeof(config)) != 0) { + goto fail; + } + for (interface = buffer; + (uint8_t *)interface < (uint8_t *)buffer + config.ifc_len; ) { + struct route_entry route = interface->ifr_route; + int intfSize; + if (route.flags & (RTF_GATEWAY | RTF_DEFAULT)) { + *addr = ((struct sockaddr_in *)route.gateway)->sin_addr.s_addr; + ret = 0; + break; + } + intfSize = sizeof(route) + IF_NAMESIZE; + if (route.destination != NULL) { + intfSize += route.destination->sa_len; + } + if (route.mask != NULL) { + intfSize += route.mask->sa_len; + } + if (route.gateway != NULL) { + intfSize += route.gateway->sa_len; + } + interface = (struct ifreq *)((uint8_t *)interface + intfSize); + } +fail: + free(buffer); + close(fd); + return ret; +} +#endif /* #ifdef USE_HAIKU_CODE */ + +#if !defined(USE_PROC_NET_ROUTE) && !defined(USE_SOCKET_ROUTE) && !defined(USE_SYSCTL_NET_ROUTE) && !defined(USE_WIN32_CODE) && !defined(USE_WIN32_CODE_2) && !defined(USE_HAIKU_CODE) +int getdefaultgateway(in_addr_t * addr) +{ + return -1; +} +#endif diff --git a/pkg/hs/natpmp-static/cbits/getgateway.h b/pkg/hs/natpmp-static/cbits/getgateway.h new file mode 100644 index 0000000000..5d3df73125 --- /dev/null +++ b/pkg/hs/natpmp-static/cbits/getgateway.h @@ -0,0 +1,49 @@ +/* $Id: getgateway.h,v 1.8 2014/04/22 09:15:40 nanard Exp $ */ +/* libnatpmp +Copyright (c) 2007-2014, Thomas BERNARD +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ +#ifndef __GETGATEWAY_H__ +#define __GETGATEWAY_H__ + +#ifdef WIN32 +#if !defined(_MSC_VER) || _MSC_VER >= 1600 +#include +#else +typedef unsigned long uint32_t; +typedef unsigned short uint16_t; +#endif +#define in_addr_t uint32_t +#endif +/* #include "declspec.h" */ + +/* getdefaultgateway() : + * return value : + * 0 : success + * -1 : failure */ +/* LIBSPEC */int getdefaultgateway(in_addr_t * addr); + +#endif diff --git a/pkg/hs/natpmp-static/cbits/natpmp.c b/pkg/hs/natpmp-static/cbits/natpmp.c new file mode 100644 index 0000000000..3a49812921 --- /dev/null +++ b/pkg/hs/natpmp-static/cbits/natpmp.c @@ -0,0 +1,379 @@ +/* $Id: natpmp.c,v 1.20 2015/05/27 12:43:15 nanard Exp $ */ +/* libnatpmp +Copyright (c) 2007-2015, Thomas BERNARD +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ +#ifdef __linux__ +#define _BSD_SOURCE 1 +#endif +#include +#include +#if !defined(_MSC_VER) +#include +#endif +#ifdef WIN32 +#include +#include +#include +#include +#define EWOULDBLOCK WSAEWOULDBLOCK +#define ECONNREFUSED WSAECONNREFUSED +#include "wingettimeofday.h" +#define gettimeofday natpmp_gettimeofday +#else +#include +#include +#include +#include +#include +#define closesocket close +#endif +#include "natpmp.h" +#include "getgateway.h" +#include + +LIBSPEC int initnatpmp(natpmp_t * p, int forcegw, in_addr_t forcedgw) +{ +#ifdef WIN32 + u_long ioctlArg = 1; +#else + int flags; +#endif + struct sockaddr_in addr; + if(!p) + return NATPMP_ERR_INVALIDARGS; + memset(p, 0, sizeof(natpmp_t)); + p->s = socket(PF_INET, SOCK_DGRAM, 0); + if(p->s < 0) + return NATPMP_ERR_SOCKETERROR; +#ifdef WIN32 + if(ioctlsocket(p->s, FIONBIO, &ioctlArg) == SOCKET_ERROR) + return NATPMP_ERR_FCNTLERROR; +#else + if((flags = fcntl(p->s, F_GETFL, 0)) < 0) + return NATPMP_ERR_FCNTLERROR; + if(fcntl(p->s, F_SETFL, flags | O_NONBLOCK) < 0) + return NATPMP_ERR_FCNTLERROR; +#endif + + if(forcegw) { + p->gateway = forcedgw; + } else { + if(getdefaultgateway(&(p->gateway)) < 0) + return NATPMP_ERR_CANNOTGETGATEWAY; + } + + memset(&addr, 0, sizeof(addr)); + addr.sin_family = AF_INET; + addr.sin_port = htons(NATPMP_PORT); + addr.sin_addr.s_addr = p->gateway; + if(connect(p->s, (struct sockaddr *)&addr, sizeof(addr)) < 0) + return NATPMP_ERR_CONNECTERR; + return 0; +} + +LIBSPEC int closenatpmp(natpmp_t * p) +{ + if(!p) + return NATPMP_ERR_INVALIDARGS; + if(closesocket(p->s) < 0) + return NATPMP_ERR_CLOSEERR; + return 0; +} + +int sendpendingrequest(natpmp_t * p) +{ + int r; +/* struct sockaddr_in addr;*/ + if(!p) + return NATPMP_ERR_INVALIDARGS; +/* memset(&addr, 0, sizeof(addr)); + addr.sin_family = AF_INET; + addr.sin_port = htons(NATPMP_PORT); + addr.sin_addr.s_addr = p->gateway; + r = (int)sendto(p->s, p->pending_request, p->pending_request_len, 0, + (struct sockaddr *)&addr, sizeof(addr));*/ + r = (int)send(p->s, (const char *)p->pending_request, p->pending_request_len, 0); + return (r<0) ? NATPMP_ERR_SENDERR : r; +} + +int sendnatpmprequest(natpmp_t * p) +{ + int n; + if(!p) + return NATPMP_ERR_INVALIDARGS; + /* TODO : check if no request is already pending */ + p->has_pending_request = 1; + p->try_number = 1; + n = sendpendingrequest(p); + gettimeofday(&p->retry_time, NULL); // check errors ! + p->retry_time.tv_usec += 250000; /* add 250ms */ + if(p->retry_time.tv_usec >= 1000000) { + p->retry_time.tv_usec -= 1000000; + p->retry_time.tv_sec++; + } + return n; +} + +LIBSPEC int getnatpmprequesttimeout(natpmp_t * p, struct timeval * timeout) +{ + struct timeval now; + if(!p || !timeout) + return NATPMP_ERR_INVALIDARGS; + if(!p->has_pending_request) + return NATPMP_ERR_NOPENDINGREQ; + if(gettimeofday(&now, NULL) < 0) + return NATPMP_ERR_GETTIMEOFDAYERR; + timeout->tv_sec = p->retry_time.tv_sec - now.tv_sec; + timeout->tv_usec = p->retry_time.tv_usec - now.tv_usec; + if(timeout->tv_usec < 0) { + timeout->tv_usec += 1000000; + timeout->tv_sec--; + } + return 0; +} + +LIBSPEC int sendpublicaddressrequest(natpmp_t * p) +{ + if(!p) + return NATPMP_ERR_INVALIDARGS; + //static const unsigned char request[] = { 0, 0 }; + p->pending_request[0] = 0; + p->pending_request[1] = 0; + p->pending_request_len = 2; + // TODO: return 0 instead of sizeof(request) ?? + return sendnatpmprequest(p); +} + +LIBSPEC int sendnewportmappingrequest(natpmp_t * p, int protocol, + uint16_t privateport, uint16_t publicport, + uint32_t lifetime) +{ + if(!p || (protocol!=NATPMP_PROTOCOL_TCP && protocol!=NATPMP_PROTOCOL_UDP)) + return NATPMP_ERR_INVALIDARGS; + p->pending_request[0] = 0; + p->pending_request[1] = protocol; + p->pending_request[2] = 0; + p->pending_request[3] = 0; + /* break strict-aliasing rules : + *((uint16_t *)(p->pending_request + 4)) = htons(privateport); */ + p->pending_request[4] = (privateport >> 8) & 0xff; + p->pending_request[5] = privateport & 0xff; + /* break stric-aliasing rules : + *((uint16_t *)(p->pending_request + 6)) = htons(publicport); */ + p->pending_request[6] = (publicport >> 8) & 0xff; + p->pending_request[7] = publicport & 0xff; + /* break stric-aliasing rules : + *((uint32_t *)(p->pending_request + 8)) = htonl(lifetime); */ + p->pending_request[8] = (lifetime >> 24) & 0xff; + p->pending_request[9] = (lifetime >> 16) & 0xff; + p->pending_request[10] = (lifetime >> 8) & 0xff; + p->pending_request[11] = lifetime & 0xff; + p->pending_request_len = 12; + return sendnatpmprequest(p); +} + +LIBSPEC int readnatpmpresponse(natpmp_t * p, natpmpresp_t * response) +{ + unsigned char buf[16]; + struct sockaddr_in addr; + socklen_t addrlen = sizeof(addr); + int n; + if(!p) + return NATPMP_ERR_INVALIDARGS; + n = recvfrom(p->s, (char *)buf, sizeof(buf), 0, + (struct sockaddr *)&addr, &addrlen); + if(n<0) +#ifdef WIN32 + switch(WSAGetLastError()) { +#else + switch(errno) { +#endif + /*case EAGAIN:*/ + case EWOULDBLOCK: + n = NATPMP_TRYAGAIN; + break; + case ECONNREFUSED: + n = NATPMP_ERR_NOGATEWAYSUPPORT; + break; + default: + n = NATPMP_ERR_RECVFROM; + } + /* check that addr is correct (= gateway) */ + else if(addr.sin_addr.s_addr != p->gateway) + n = NATPMP_ERR_WRONGPACKETSOURCE; + else { + response->resultcode = ntohs(*((uint16_t *)(buf + 2))); + response->epoch = ntohl(*((uint32_t *)(buf + 4))); + if(buf[0] != 0) + n = NATPMP_ERR_UNSUPPORTEDVERSION; + else if(buf[1] < 128 || buf[1] > 130) + n = NATPMP_ERR_UNSUPPORTEDOPCODE; + else if(response->resultcode != 0) { + switch(response->resultcode) { + case 1: + n = NATPMP_ERR_UNSUPPORTEDVERSION; + break; + case 2: + n = NATPMP_ERR_NOTAUTHORIZED; + break; + case 3: + n = NATPMP_ERR_NETWORKFAILURE; + break; + case 4: + n = NATPMP_ERR_OUTOFRESOURCES; + break; + case 5: + n = NATPMP_ERR_UNSUPPORTEDOPCODE; + break; + default: + n = NATPMP_ERR_UNDEFINEDERROR; + } + } else { + response->type = buf[1] & 0x7f; + if(buf[1] == 128) + //response->publicaddress.addr = *((uint32_t *)(buf + 8)); + response->pnu.publicaddress.addr.s_addr = *((uint32_t *)(buf + 8)); + else { + response->pnu.newportmapping.privateport = ntohs(*((uint16_t *)(buf + 8))); + response->pnu.newportmapping.mappedpublicport = ntohs(*((uint16_t *)(buf + 10))); + response->pnu.newportmapping.lifetime = ntohl(*((uint32_t *)(buf + 12))); + } + n = 0; + } + } + return n; +} + +int readnatpmpresponseorretry(natpmp_t * p, natpmpresp_t * response) +{ + int n; + if(!p || !response) + return NATPMP_ERR_INVALIDARGS; + if(!p->has_pending_request) + return NATPMP_ERR_NOPENDINGREQ; + n = readnatpmpresponse(p, response); + if(n<0) { + if(n==NATPMP_TRYAGAIN) { + struct timeval now; + gettimeofday(&now, NULL); // check errors ! + if(timercmp(&now, &p->retry_time, >=)) { + int delay, r; + if(p->try_number >= 9) { + return NATPMP_ERR_NOGATEWAYSUPPORT; + } + /*printf("retry! %d\n", p->try_number);*/ + delay = 250 * (1<try_number); // ms + /*for(i=0; itry_number; i++) + delay += delay;*/ + p->retry_time.tv_sec += (delay / 1000); + p->retry_time.tv_usec += (delay % 1000) * 1000; + if(p->retry_time.tv_usec >= 1000000) { + p->retry_time.tv_usec -= 1000000; + p->retry_time.tv_sec++; + } + p->try_number++; + r = sendpendingrequest(p); + if(r<0) + return r; + } + } + } else { + p->has_pending_request = 0; + } + return n; +} + +#ifdef ENABLE_STRNATPMPERR +LIBSPEC const char * strnatpmperr(int r) +{ + const char * s; + switch(r) { + case NATPMP_ERR_INVALIDARGS: + s = "invalid arguments"; + break; + case NATPMP_ERR_SOCKETERROR: + s = "socket() failed"; + break; + case NATPMP_ERR_CANNOTGETGATEWAY: + s = "cannot get default gateway ip address"; + break; + case NATPMP_ERR_CLOSEERR: +#ifdef WIN32 + s = "closesocket() failed"; +#else + s = "close() failed"; +#endif + break; + case NATPMP_ERR_RECVFROM: + s = "recvfrom() failed"; + break; + case NATPMP_ERR_NOPENDINGREQ: + s = "no pending request"; + break; + case NATPMP_ERR_NOGATEWAYSUPPORT: + s = "the gateway does not support nat-pmp"; + break; + case NATPMP_ERR_CONNECTERR: + s = "connect() failed"; + break; + case NATPMP_ERR_WRONGPACKETSOURCE: + s = "packet not received from the default gateway"; + break; + case NATPMP_ERR_SENDERR: + s = "send() failed"; + break; + case NATPMP_ERR_FCNTLERROR: + s = "fcntl() failed"; + break; + case NATPMP_ERR_GETTIMEOFDAYERR: + s = "gettimeofday() failed"; + break; + case NATPMP_ERR_UNSUPPORTEDVERSION: + s = "unsupported nat-pmp version error from server"; + break; + case NATPMP_ERR_UNSUPPORTEDOPCODE: + s = "unsupported nat-pmp opcode error from server"; + break; + case NATPMP_ERR_UNDEFINEDERROR: + s = "undefined nat-pmp server error"; + break; + case NATPMP_ERR_NOTAUTHORIZED: + s = "not authorized"; + break; + case NATPMP_ERR_NETWORKFAILURE: + s = "network failure"; + break; + case NATPMP_ERR_OUTOFRESOURCES: + s = "nat-pmp server out of resources"; + break; + default: + s = "Unknown libnatpmp error"; + } + return s; +} +#endif + diff --git a/pkg/hs/natpmp-static/cbits/natpmp.h b/pkg/hs/natpmp-static/cbits/natpmp.h new file mode 100644 index 0000000000..7889d206fe --- /dev/null +++ b/pkg/hs/natpmp-static/cbits/natpmp.h @@ -0,0 +1,219 @@ +/* $Id: natpmp.h,v 1.20 2014/04/22 09:15:40 nanard Exp $ */ +/* libnatpmp +Copyright (c) 2007-2014, Thomas BERNARD +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ +#ifndef __NATPMP_H__ +#define __NATPMP_H__ + +/* NAT-PMP Port as defined by the NAT-PMP draft */ +#define NATPMP_PORT (5351) + +#include +#if !defined(_MSC_VER) +#include +#endif /* !defined(_MSC_VER) */ + +#ifdef WIN32 +#include +#if !defined(_MSC_VER) || _MSC_VER >= 1600 +#include +#else /* !defined(_MSC_VER) || _MSC_VER >= 1600 */ +typedef unsigned long uint32_t; +typedef unsigned short uint16_t; +#endif /* !defined(_MSC_VER) || _MSC_VER >= 1600 */ +#define in_addr_t uint32_t +#include "declspec.h" +#else /* WIN32 */ +#define LIBSPEC +#include +#endif /* WIN32 */ + +/* causes problem when installing. Maybe should it be inlined ? */ +/* #include "declspec.h" */ + +typedef struct { + int s; /* socket */ + in_addr_t gateway; /* default gateway (IPv4) */ + int has_pending_request; + unsigned char pending_request[12]; + int pending_request_len; + int try_number; + struct timeval retry_time; +} natpmp_t; + +typedef struct { + uint16_t type; /* NATPMP_RESPTYPE_* */ + uint16_t resultcode; /* NAT-PMP response code */ + uint32_t epoch; /* Seconds since start of epoch */ + union { + struct { + //in_addr_t addr; + struct in_addr addr; + } publicaddress; + struct { + uint16_t privateport; + uint16_t mappedpublicport; + uint32_t lifetime; + } newportmapping; + } pnu; +} natpmpresp_t; + +/* possible values for type field of natpmpresp_t */ +#define NATPMP_RESPTYPE_PUBLICADDRESS (0) +#define NATPMP_RESPTYPE_UDPPORTMAPPING (1) +#define NATPMP_RESPTYPE_TCPPORTMAPPING (2) + +/* Values to pass to sendnewportmappingrequest() */ +#define NATPMP_PROTOCOL_UDP (1) +#define NATPMP_PROTOCOL_TCP (2) + +/* return values */ +/* NATPMP_ERR_INVALIDARGS : invalid arguments passed to the function */ +#define NATPMP_ERR_INVALIDARGS (-1) +/* NATPMP_ERR_SOCKETERROR : socket() failed. check errno for details */ +#define NATPMP_ERR_SOCKETERROR (-2) +/* NATPMP_ERR_CANNOTGETGATEWAY : can't get default gateway IP */ +#define NATPMP_ERR_CANNOTGETGATEWAY (-3) +/* NATPMP_ERR_CLOSEERR : close() failed. check errno for details */ +#define NATPMP_ERR_CLOSEERR (-4) +/* NATPMP_ERR_RECVFROM : recvfrom() failed. check errno for details */ +#define NATPMP_ERR_RECVFROM (-5) +/* NATPMP_ERR_NOPENDINGREQ : readnatpmpresponseorretry() called while + * no NAT-PMP request was pending */ +#define NATPMP_ERR_NOPENDINGREQ (-6) +/* NATPMP_ERR_NOGATEWAYSUPPORT : the gateway does not support NAT-PMP */ +#define NATPMP_ERR_NOGATEWAYSUPPORT (-7) +/* NATPMP_ERR_CONNECTERR : connect() failed. check errno for details */ +#define NATPMP_ERR_CONNECTERR (-8) +/* NATPMP_ERR_WRONGPACKETSOURCE : packet not received from the network gateway */ +#define NATPMP_ERR_WRONGPACKETSOURCE (-9) +/* NATPMP_ERR_SENDERR : send() failed. check errno for details */ +#define NATPMP_ERR_SENDERR (-10) +/* NATPMP_ERR_FCNTLERROR : fcntl() failed. check errno for details */ +#define NATPMP_ERR_FCNTLERROR (-11) +/* NATPMP_ERR_GETTIMEOFDAYERR : gettimeofday() failed. check errno for details */ +#define NATPMP_ERR_GETTIMEOFDAYERR (-12) + +/* */ +#define NATPMP_ERR_UNSUPPORTEDVERSION (-14) +#define NATPMP_ERR_UNSUPPORTEDOPCODE (-15) + +/* Errors from the server : */ +#define NATPMP_ERR_UNDEFINEDERROR (-49) +#define NATPMP_ERR_NOTAUTHORIZED (-51) +#define NATPMP_ERR_NETWORKFAILURE (-52) +#define NATPMP_ERR_OUTOFRESOURCES (-53) + +/* NATPMP_TRYAGAIN : no data available for the moment. try again later */ +#define NATPMP_TRYAGAIN (-100) + +#ifdef __cplusplus +extern "C" { +#endif + +/* initnatpmp() + * initialize a natpmp_t object + * With forcegw=1 the gateway is not detected automaticaly. + * Return values : + * 0 = OK + * NATPMP_ERR_INVALIDARGS + * NATPMP_ERR_SOCKETERROR + * NATPMP_ERR_FCNTLERROR + * NATPMP_ERR_CANNOTGETGATEWAY + * NATPMP_ERR_CONNECTERR */ +LIBSPEC int initnatpmp(natpmp_t * p, int forcegw, in_addr_t forcedgw); + +/* closenatpmp() + * close resources associated with a natpmp_t object + * Return values : + * 0 = OK + * NATPMP_ERR_INVALIDARGS + * NATPMP_ERR_CLOSEERR */ +LIBSPEC int closenatpmp(natpmp_t * p); + +/* sendpublicaddressrequest() + * send a public address NAT-PMP request to the network gateway + * Return values : + * 2 = OK (size of the request) + * NATPMP_ERR_INVALIDARGS + * NATPMP_ERR_SENDERR */ +LIBSPEC int sendpublicaddressrequest(natpmp_t * p); + +/* sendnewportmappingrequest() + * send a new port mapping NAT-PMP request to the network gateway + * Arguments : + * protocol is either NATPMP_PROTOCOL_TCP or NATPMP_PROTOCOL_UDP, + * lifetime is in seconds. + * To remove a port mapping, set lifetime to zero. + * To remove all port mappings to the host, set lifetime and both ports + * to zero. + * Return values : + * 12 = OK (size of the request) + * NATPMP_ERR_INVALIDARGS + * NATPMP_ERR_SENDERR */ +LIBSPEC int sendnewportmappingrequest(natpmp_t * p, int protocol, + uint16_t privateport, uint16_t publicport, + uint32_t lifetime); + +/* getnatpmprequesttimeout() + * fills the timeval structure with the timeout duration of the + * currently pending NAT-PMP request. + * Return values : + * 0 = OK + * NATPMP_ERR_INVALIDARGS + * NATPMP_ERR_GETTIMEOFDAYERR + * NATPMP_ERR_NOPENDINGREQ */ +LIBSPEC int getnatpmprequesttimeout(natpmp_t * p, struct timeval * timeout); + +/* readnatpmpresponseorretry() + * fills the natpmpresp_t structure if possible + * Return values : + * 0 = OK + * NATPMP_TRYAGAIN + * NATPMP_ERR_INVALIDARGS + * NATPMP_ERR_NOPENDINGREQ + * NATPMP_ERR_NOGATEWAYSUPPORT + * NATPMP_ERR_RECVFROM + * NATPMP_ERR_WRONGPACKETSOURCE + * NATPMP_ERR_UNSUPPORTEDVERSION + * NATPMP_ERR_UNSUPPORTEDOPCODE + * NATPMP_ERR_NOTAUTHORIZED + * NATPMP_ERR_NETWORKFAILURE + * NATPMP_ERR_OUTOFRESOURCES + * NATPMP_ERR_UNSUPPORTEDOPCODE + * NATPMP_ERR_UNDEFINEDERROR */ +LIBSPEC int readnatpmpresponseorretry(natpmp_t * p, natpmpresp_t * response); + +#ifdef ENABLE_STRNATPMPERR +LIBSPEC const char * strnatpmperr(int t); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/pkg/hs/natpmp-static/hsrc_lib/Network/NATPMP.hsc b/pkg/hs/natpmp-static/hsrc_lib/Network/NATPMP.hsc new file mode 100644 index 0000000000..c0526356bb --- /dev/null +++ b/pkg/hs/natpmp-static/hsrc_lib/Network/NATPMP.hsc @@ -0,0 +1,264 @@ +{-# LANGUAGE ForeignFunctionInterface, DeriveDataTypeable #-} + +-- | This module is a thin wrapper above libnatpmp.h and getgateway.h. + +module Network.NATPMP (Error(..), + NatPmpResponse(..), + ProtocolType(..), + initNatPmp, + closeNatPmp, + getDefaultGateway, + getPublicAddress, + setPortMapping) where + +#include + +#include +#include +#include + +import Prelude +import Foreign +import Foreign.C + +import Network.Socket + + +-- Opaque type for the internals of nat pmp +data NatPmpStruct +type NatPmpHandle = Ptr NatPmpStruct + +-- The response type, in its internal form. This struct is a C tagged union +-- with additional data, but we need to read and write from its C form. +-- +-- TODO: What's easier? Exposing the internal C sum type here using Storable, +-- or manual translation? +data NatPmpResponse + = NatPmpResponsePublicAddress HostAddress + | NatPmpResponseUDPPortMapping Word16 Word16 Word32 + | NatPmpResponseTCPPortMapping Word16 Word16 Word32 + deriving (Show) + +instance Storable NatPmpResponse where + sizeOf _ = #{size natpmpresp_t} + alignment _ = alignment (undefined :: CString) + + peek p = do + t <- uintToEnum <$> (#{peek natpmpresp_t, type} p) + case t of + RTPublicAddress -> + NatPmpResponsePublicAddress <$> + (#{peek natpmpresp_t, pnu.publicaddress.addr} p) + RTUDPPortMapping -> + NatPmpResponseUDPPortMapping + <$> (#{peek natpmpresp_t, pnu.newportmapping.privateport} p) + <*> (#{peek natpmpresp_t, pnu.newportmapping.mappedpublicport} p) + <*> (#{peek natpmpresp_t, pnu.newportmapping.lifetime} p) + RTTCPPortMapping -> + NatPmpResponseTCPPortMapping + <$> (#{peek natpmpresp_t, pnu.newportmapping.privateport} p) + <*> (#{peek natpmpresp_t, pnu.newportmapping.mappedpublicport} p) + <*> (#{peek natpmpresp_t, pnu.newportmapping.lifetime} p) + + poke _ _ = error "Responses are an output data structure; poke makes no sense" + +type NatPmpResponseHandle = Ptr NatPmpResponse + +foreign import ccall unsafe "getgateway.h getdefaultgateway" _get_default_gateway :: Ptr CUInt -> IO CInt + +foreign import ccall unsafe "natpmp.h initnatpmp" _init_nat_pmp :: NatPmpHandle -> CInt -> CInt -> IO CInt +foreign import ccall unsafe "natpmp.h closenatpmp" _close_nat_pmp :: NatPmpHandle -> IO CInt +foreign import ccall unsafe "natpmp.h sendpublicaddressrequest" sendPublicAddressRequest :: NatPmpHandle -> IO CInt +foreign import ccall unsafe "natpmp.h sendnewportmappingrequest" sendNewPortMappingRequest :: NatPmpHandle -> CInt -> CUShort -> CUShort -> CUInt -> IO CInt + +foreign import ccall unsafe "binding.h readNatResponseSynchronously" readNatResponseSynchronously :: NatPmpHandle -> NatPmpResponseHandle -> IO CInt + +--foreign import ccall unsafe "binding.h reatNatResponseSynchronously" + +-- Give the type system some help +_peekCUInt :: Ptr CUInt -> IO CUInt +_peekCUInt = peek + +uintToEnum :: Enum e => CUInt -> e +uintToEnum = toEnum . fromIntegral + +intToEnum :: Enum e => CInt -> e +intToEnum = toEnum . fromIntegral + +-- intFromEnum :: Enum e => e -> CInt +-- intFromEnum = fromIntegral . fromEnum + + +-- Fetches the default gateway as an ipv4 address +getDefaultGateway :: IO (Maybe HostAddress) +getDefaultGateway = + alloca $ \(pReturnAddr :: Ptr CUInt) -> do + ret <- _get_default_gateway pReturnAddr + case ret of + 0 -> (Just . fromIntegral) <$> _peekCUInt pReturnAddr + _ -> pure Nothing + +-- TODO: Unsure about how to actually bind this library together. So RespType +-- is an enum which is just the integer in a low level + +data RespType + = RTPublicAddress + | RTUDPPortMapping + | RTTCPPortMapping + deriving (Eq, Show) + +instance Enum RespType where + fromEnum RTPublicAddress = 0 + fromEnum RTUDPPortMapping = 1 + fromEnum RTTCPPortMapping = 2 + + toEnum 0 = RTPublicAddress + toEnum 1 = RTUDPPortMapping + toEnum 2 = RTTCPPortMapping + toEnum unmatched = error ("RespType.toEnum: Cannot match " ++ show unmatched) + +data ProtocolType + = PTUDP + | PTTCP + deriving (Eq, Show) + +instance Enum ProtocolType where + fromEnum PTUDP = 1 + fromEnum PTTCP = 2 + + toEnum 1 = PTUDP + toEnum 2 = PTTCP + toEnum x = error ("ProtocolType.toEnum: Cannot match " ++ show x) + + + +data Error + = ErrInvalidArgs + | ErrSocketError + | ErrCannotGetGateway + | ErrCloseErr + | ErrRecvFrom + | ErrNoPendingReq + | ErrNoGatewaySupport + | ErrConnectErr + | ErrWrongPacketSource + | ErrSendErr + | ErrFcntlError + | ErrGetTimeOfDayError + -- + | ErrUnsuportedVersion + | ErrUnsupportedOpcode + -- + | ErrUndefinedError + | ErrNotAuthorized + | ErrNetworkFailure + | ErrOutOfResources + -- + | ErrTryAgain + | ErrHaskellBindingsErr + deriving (Eq, Show) + +instance Enum Error where + fromEnum ErrInvalidArgs = -1 + fromEnum ErrSocketError = -2 + fromEnum ErrCannotGetGateway = -3 + fromEnum ErrCloseErr = -4 + fromEnum ErrRecvFrom = -5 + fromEnum ErrNoPendingReq = -6 + fromEnum ErrNoGatewaySupport = -7 + fromEnum ErrConnectErr = -8 + fromEnum ErrWrongPacketSource = -9 + fromEnum ErrSendErr = -10 + fromEnum ErrFcntlError = -11 + fromEnum ErrGetTimeOfDayError = -12 + -- + fromEnum ErrUnsuportedVersion = -14 + fromEnum ErrUnsupportedOpcode = -15 + -- + fromEnum ErrUndefinedError = -49 + fromEnum ErrNotAuthorized = -51 + fromEnum ErrNetworkFailure = -52 + fromEnum ErrOutOfResources = -53 + -- + fromEnum ErrTryAgain = -100 + fromEnum ErrHaskellBindingsErr = -200 + + toEnum (-1) = ErrInvalidArgs + toEnum (-2) = ErrSocketError + toEnum (-3) = ErrCannotGetGateway + toEnum (-4) = ErrCloseErr + toEnum (-5) = ErrRecvFrom + toEnum (-6) = ErrNoPendingReq + toEnum (-7) = ErrNoGatewaySupport + toEnum (-8) = ErrConnectErr + toEnum (-9) = ErrWrongPacketSource + toEnum (-10) = ErrSendErr + toEnum (-11) = ErrFcntlError + toEnum (-12) = ErrGetTimeOfDayError + -- + toEnum (-14) = ErrUnsuportedVersion + toEnum (-15) = ErrUnsupportedOpcode + -- + toEnum (-49) = ErrUndefinedError + toEnum (-51) = ErrNotAuthorized + toEnum (-52) = ErrNetworkFailure + toEnum (-53) = ErrOutOfResources + -- + toEnum (-100) = ErrTryAgain + toEnum (-200) = ErrHaskellBindingsErr + toEnum unmatched = error ("Error.toEnum: Cannot match " ++ show unmatched) + + +initNatPmp :: IO (Either Error NatPmpHandle) +initNatPmp = do + natpmp <- mallocBytes #{size natpmp_t} + ret <- _init_nat_pmp natpmp 0 0 + case ret of + 0 -> pure $ Right natpmp + _ -> do + free natpmp + pure $ Left $ intToEnum ret + +closeNatPmp :: NatPmpHandle -> IO (Either Error ()) +closeNatPmp handle = do + ret <- _close_nat_pmp handle + free handle + case ret of + 0 -> pure $ Right () + _ -> pure $ Left $ intToEnum ret + + +-- Public interface for getting the public IPv4 address +getPublicAddress :: NatPmpHandle -> IO (Either Error HostAddress) +getPublicAddress natpmp = do + sendRetcode <- sendPublicAddressRequest natpmp + case sendRetcode of + 2 -> alloca $ \(pResponse :: NatPmpResponseHandle) -> do + respRetcode <- readNatResponseSynchronously natpmp pResponse + case respRetcode of + 0 -> peek pResponse >>= \case + NatPmpResponsePublicAddress addr -> pure $ Right addr + _ -> pure $ Left ErrHaskellBindingsErr + _ -> pure $ Left $ intToEnum respRetcode + _ -> pure $ Left $ intToEnum sendRetcode + + +setPortMapping :: NatPmpHandle -> ProtocolType -> Word16 -> Word16 -> Word32 + -> IO (Either Error ()) +setPortMapping natpmp protocol privatePort publicPort lifetime = do + let protocolNum = fromEnum protocol + sendResp <- + sendNewPortMappingRequest natpmp + (fromIntegral protocolNum) (CUShort privatePort) (CUShort publicPort) + (CUInt lifetime) + + case sendResp of + 12 -> alloca $ \(pResponse :: NatPmpResponseHandle) -> do + respRetcode <- readNatResponseSynchronously natpmp pResponse + case respRetcode of + 0 -> peek pResponse >>= \case + NatPmpResponseUDPPortMapping _ _ _ -> pure $ Right () + NatPmpResponseTCPPortMapping _ _ _ -> pure $ Right () + _ -> pure $ Left ErrHaskellBindingsErr + _ -> pure $ Left $ intToEnum respRetcode + x -> pure $ Left $ intToEnum x diff --git a/pkg/hs/natpmp-static/natpmp-static.cabal b/pkg/hs/natpmp-static/natpmp-static.cabal new file mode 100644 index 0000000000..2f8dfaadbc --- /dev/null +++ b/pkg/hs/natpmp-static/natpmp-static.cabal @@ -0,0 +1,88 @@ +cabal-version: >=1.10 +-- Initial package description 'natpmp-static.cabal' generated by 'cabal +-- init'. For further documentation, see +-- http://haskell.org/cabal/users-guide/ + +name: natpmp-static +version: 0.1.0.0 +synopsis: Haskell bindings to libnatpmp +description: + libnatpmp is a C library to communicate with routers and request + that they port forward traffic from the outside internet to your + program. + . + natpmp-static has Haskell bindings to libnatpmp to allow Haskell + programs to punch NAT holes in routers, containing a vendored copy + of the libnatpmp code so that we build Urbit's "almost static" + builds which we distribute. + . + See for upstream source. + +-- bug-reports: +license: BSD3 +license-file: LICENSE +author: Elliot Glaysher +maintainer: elliot@tlon.io +copyright: (c) 2020 Tlon. +stability: experimental +build-type: Simple + +library + hs-Source-Dirs: hsrc_lib + default-language: Haskell2010 + build-depends: base + , network + build-tools: hsc2hs + + Include-dirs: cbits + Includes: natpmp.h getgateway.h + C-Sources: cbits/natpmp.c cbits/getgateway.c cbits/binding.c + cc-options: -Wall -Os -g -fPIC + ghc-options: -Wall -fprof-auto -fPIC + + exposed-modules: Network.NATPMP + -- other-modules: + -- other-extensions: + + default-extensions: ApplicativeDo + , BangPatterns + , BlockArguments + , DataKinds + , DefaultSignatures + , DeriveAnyClass + , DeriveDataTypeable + , DeriveFoldable + , DeriveGeneric + , DeriveTraversable + , DerivingStrategies + , EmptyCase + , EmptyDataDecls + , FlexibleContexts + , FlexibleInstances + , FunctionalDependencies + , GADTs + , GeneralizedNewtypeDeriving + , LambdaCase + , MagicHash + , MultiParamTypeClasses + , NamedFieldPuns + , NoImplicitPrelude + , NumericUnderscores + , OverloadedStrings + , PartialTypeSignatures + , PatternSynonyms + , QuasiQuotes + , Rank2Types + , RankNTypes + , RecordWildCards + , ScopedTypeVariables + , StandaloneDeriving + , TemplateHaskell + , TupleSections + , TypeApplications + , TypeFamilies + , TypeOperators + , UnboxedTuples + , UnicodeSyntax + , ViewPatterns + diff --git a/pkg/hs/stack.yaml b/pkg/hs/stack.yaml index 74bad3fe51..5ab38228ba 100644 --- a/pkg/hs/stack.yaml +++ b/pkg/hs/stack.yaml @@ -2,6 +2,7 @@ resolver: lts-14.21 packages: - lmdb-static + - natpmp-static - proto - racquire - terminal-progress-bar diff --git a/pkg/hs/urbit-king/package.yaml b/pkg/hs/urbit-king/package.yaml index d1e8b6a774..aca5523962 100644 --- a/pkg/hs/urbit-king/package.yaml +++ b/pkg/hs/urbit-king/package.yaml @@ -64,6 +64,7 @@ dependencies: - mtl - multimap - murmur3 + - natpmp-static - network - optparse-applicative - para From 225d2a288b940cb4a06214c1c843822f4aa971a5 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 4 Aug 2020 15:10:28 -0400 Subject: [PATCH 129/933] king: Add CLI options for NAT traversal. (Not yet hooked up to anything.) --- pkg/hs/urbit-king/lib/Urbit/King/CLI.hs | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs index b5edbcd2f9..8824a7c960 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs @@ -13,11 +13,15 @@ import Options.Applicative.Help.Pretty import Data.Word (Word16) import System.Environment (getProgName) +import Data.IP +import Network.Socket + -------------------------------------------------------------------------------- data KingOpts = KingOpts { koSharedHttpPort :: Maybe Word16 , koSharedHttpsPort :: Maybe Word16 + , koIPSource :: Maybe IPSource } deriving (Show) @@ -55,6 +59,11 @@ data PillSource | PillSourceURL String deriving (Show) +data IPSource + = IPSourceManual HostAddress + | IPSourceNAT + deriving (Show) + data New = New { nPillSource :: PillSource , nPierPath :: Maybe FilePath -- Derived from ship name if not specified. @@ -195,6 +204,23 @@ pillFromURL = PillSourceURL <$> strOption <> value defaultPillURL <> help "URL to pill file") +ipFromNAT :: Parser IPSource +ipFromNAT = flag' IPSourceNAT + ( long "ip-from-nat" + <> help "Try to fetch the local IP from the NAT gateway") + +ipReader :: ReadM HostAddress +ipReader = eitherReader $ \arg -> + case readMay arg :: Maybe IPv4 of + Nothing -> Left ("Cannot parse ipv4 address: " ++ arg) + Just ipv4 -> Right $ toHostAddress ipv4 + +ipFromManual :: Parser IPSource +ipFromManual = IPSourceManual <$> option ipReader + ( long "ip-manual" + <> metavar "IPv4" + <> help "Manually specify the external IP") + pierPath :: Parser FilePath pierPath = strArgument (metavar "PIER" <> help "Path to pier") @@ -347,6 +373,8 @@ runOneShip = (,,) <$> fmap Run pierPath <*> opts <*> df kingOpts :: Parser KingOpts kingOpts = do + koIPSource <- optional (ipFromManual <|> ipFromNAT) + koSharedHttpPort <- optional $ option auto From 08d22b14d3f2742775b519bc4d278caea740ff1b Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 4 Aug 2020 13:52:19 -0700 Subject: [PATCH 130/933] u3: fixes bug in snapshot image truncation --- pkg/urbit/noun/events.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/noun/events.c b/pkg/urbit/noun/events.c index b010fd13e0..d12dc81ffe 100644 --- a/pkg/urbit/noun/events.c +++ b/pkg/urbit/noun/events.c @@ -621,7 +621,7 @@ _ce_patch_apply(u3_ce_patch* pat_u) if ( u3P.nor_u.pgs_w > pat_u->con_u->nor_w ) { c3_w ret_w; - ret_w = ftruncate(u3P.nor_u.fid_i, u3P.nor_u.pgs_w << (u3a_page + 2)); + ret_w = ftruncate(u3P.nor_u.fid_i, pat_u->con_u->nor_w << (u3a_page + 2)); if (ret_w){ fprintf(stderr, "loom: patch apply truncate north: %s\r\n", strerror(errno)); c3_assert(0); @@ -631,7 +631,7 @@ _ce_patch_apply(u3_ce_patch* pat_u) if ( u3P.sou_u.pgs_w > pat_u->con_u->sou_w ) { c3_w ret_w; - ret_w = ftruncate(u3P.sou_u.fid_i, u3P.sou_u.pgs_w << (u3a_page + 2)); + ret_w = ftruncate(u3P.sou_u.fid_i, pat_u->con_u->sou_w << (u3a_page + 2)); if (ret_w){ fprintf(stderr, "loom: patch apply truncate south: %s\r\n", strerror(errno)); c3_assert(0); From d39d7246d18f81984efb4df15c5d2fde933d4d67 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 4 Aug 2020 16:52:40 -0400 Subject: [PATCH 131/933] king: move MultiEyreApi to a new RunningEnv. There was a TODO in runShips about how the different layers of the RIO environment had to be changed, so that there was a layer between KingEnv and PierEnv for things shared between individual Piers, but which weren't used outside of any PierEnv. This addresses those TODOs by creating RunningEnv, which for now just owns MultiEyreApi and makes it so we don't have to pass the entire thing around explicitly. The IP handling stuff will go in RunningEnv in a following patch. --- pkg/hs/urbit-king/lib/Urbit/King/App.hs | 74 +++++++++- pkg/hs/urbit-king/lib/Urbit/King/Main.hs | 164 +++++++++++------------ pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs | 27 ++-- pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs | 11 +- 4 files changed, 164 insertions(+), 112 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/App.hs b/pkg/hs/urbit-king/lib/Urbit/King/App.hs index bd8b6b1a53..0d758b692c 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/App.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/App.hs @@ -9,6 +9,8 @@ module Urbit.King.App , kingEnvKillSignal , killKingActionL , onKillKingSigL + , RunningEnv + , runRunningEnv , PierEnv , runPierEnv , killPierActionL @@ -17,6 +19,8 @@ module Urbit.King.App , HasKingId(..) , HasProcId(..) , HasKingEnv(..) + , HasMultiEyreApi(..) + , HasRunningEnv(..) , HasPierEnv(..) , module Urbit.King.Config ) @@ -30,6 +34,7 @@ import System.Posix.Internals (c_getpid) import System.Posix.Types (CPid(..)) import System.Random (randomIO) import Urbit.King.App.Class (HasStderrLogFunc(..)) +import Urbit.Vere.Eyre.Multi (MultiEyreApi) -- KingEnv --------------------------------------------------------------------- @@ -70,7 +75,6 @@ instance HasProcId KingEnv where instance HasKingId KingEnv where kingIdL = kingEnvKingId - -- Running KingEnvs ------------------------------------------------------------ runKingEnvStderr :: Bool -> RIO KingEnv a -> IO a @@ -121,14 +125,64 @@ killKingActionL :: HasKingEnv e => Getter e (STM ()) killKingActionL = kingEnvL . kingEnvKillSignal . to (\kil -> void (tryPutTMVar kil ())) +-- RunningEnv ------------------------------------------------------------------ + +-- The running environment is everything in King, eyre configuration shared +-- across ships, and IP information shared across ships. +-- +-- TODO: Implement that IP information for real. + +class HasMultiEyreApi a where + multiEyreApiL :: Lens' a MultiEyreApi + +class (HasKingEnv a, HasMultiEyreApi a) => HasRunningEnv a where + runningEnvL :: Lens' a RunningEnv + +data RunningEnv = RunningEnv + { _runningEnvKingEnv :: !KingEnv + , _runningEnvMultiEyreApi :: MultiEyreApi + } + +makeLenses ''RunningEnv + +instance HasKingEnv RunningEnv where + kingEnvL = runningEnvKingEnv + +instance HasLogFunc RunningEnv where + logFuncL = kingEnvL . logFuncL + +instance HasStderrLogFunc RunningEnv where + stderrLogFuncL = kingEnvL . stderrLogFuncL + +instance HasProcId RunningEnv where + procIdL = kingEnvL . procIdL + +instance HasKingId RunningEnv where + kingIdL = kingEnvL . kingEnvKingId + +instance HasMultiEyreApi RunningEnv where + multiEyreApiL = runningEnvMultiEyreApi + +-- Running Running Envs -------------------------------------------------------- + +runRunningEnv :: MultiEyreApi -> RIO RunningEnv () -> RIO KingEnv () +runRunningEnv multi action = do + king <- ask + + let runningEnv = RunningEnv { _runningEnvKingEnv = king + , _runningEnvMultiEyreApi = multi + } + + io (runRIO runningEnv action) -- PierEnv --------------------------------------------------------------------- -class (HasKingEnv a, HasPierConfig a, HasNetworkConfig a) => HasPierEnv a where +class (HasKingEnv a, HasRunningEnv a, HasPierConfig a, HasNetworkConfig a) => + HasPierEnv a where pierEnvL :: Lens' a PierEnv data PierEnv = PierEnv - { _pierEnvKingEnv :: !KingEnv + { _pierEnvRunningEnv :: !RunningEnv , _pierEnvPierConfig :: !PierConfig , _pierEnvNetworkConfig :: !NetworkConfig , _pierEnvKillSignal :: !(TMVar ()) @@ -137,7 +191,13 @@ data PierEnv = PierEnv makeLenses ''PierEnv instance HasKingEnv PierEnv where - kingEnvL = pierEnvKingEnv + kingEnvL = pierEnvRunningEnv . kingEnvL + +instance HasRunningEnv PierEnv where + runningEnvL = pierEnvRunningEnv + +instance HasMultiEyreApi PierEnv where + multiEyreApiL = pierEnvRunningEnv . multiEyreApiL instance HasPierEnv PierEnv where pierEnvL = id @@ -180,11 +240,11 @@ killPierActionL = -- Running Pier Envs ----------------------------------------------------------- runPierEnv - :: PierConfig -> NetworkConfig -> TMVar () -> RIO PierEnv a -> RIO KingEnv a + :: PierConfig -> NetworkConfig -> TMVar () -> RIO PierEnv a -> RIO RunningEnv a runPierEnv pierConfig networkConfig vKill action = do - app <- ask + running <- ask - let pierEnv = PierEnv { _pierEnvKingEnv = app + let pierEnv = PierEnv { _pierEnvRunningEnv = running , _pierEnvPierConfig = pierConfig , _pierEnvNetworkConfig = networkConfig , _pierEnvKillSignal = vKill diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs index 2fb280d2da..bcdc9c1837 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs @@ -82,7 +82,7 @@ import Urbit.Arvo import Urbit.King.Config import Urbit.Vere.Dawn import Urbit.Vere.Pier -import Urbit.Vere.Eyre.Multi (multiEyre, MultiEyreApi, MultiEyreConf(..)) +import Urbit.Vere.Eyre.Multi (multiEyre, MultiEyreConf(..)) import Urbit.Vere.Pier.Types import Urbit.Vere.Serf import Urbit.King.App @@ -184,12 +184,11 @@ tryBootFromPill -> Bool -> Ship -> LegacyBootEvent - -> MultiEyreApi -> RIO PierEnv () -tryBootFromPill oExit pill lite ship boot multi = do +tryBootFromPill oExit pill lite ship boot = do mStart <- newEmptyMVar vSlog <- logSlogs - runOrExitImmediately vSlog (bootedPier vSlog) oExit mStart multi + runOrExitImmediately vSlog (bootedPier vSlog) oExit mStart where bootedPier vSlog = do view pierPathL >>= lockFile @@ -203,9 +202,8 @@ runOrExitImmediately -> RAcquire PierEnv (Serf, Log.EventLog) -> Bool -> MVar () - -> MultiEyreApi -> RIO PierEnv () -runOrExitImmediately vSlog getPier oExit mStart multi = do +runOrExitImmediately vSlog getPier oExit mStart = do rwith getPier (if oExit then shutdownImmediately else runPier) where shutdownImmediately :: (Serf, Log.EventLog) -> RIO PierEnv () @@ -216,19 +214,18 @@ runOrExitImmediately vSlog getPier oExit mStart multi = do runPier :: (Serf, Log.EventLog) -> RIO PierEnv () runPier serfLog = do - runRAcquire (Pier.pier serfLog vSlog mStart multi) + runRAcquire (Pier.pier serfLog vSlog mStart) tryPlayShip :: Bool -> Bool -> Maybe Word64 -> MVar () - -> MultiEyreApi -> RIO PierEnv () -tryPlayShip exitImmediately fullReplay playFrom mStart multi = do +tryPlayShip exitImmediately fullReplay playFrom mStart = do when fullReplay wipeSnapshot vSlog <- logSlogs - runOrExitImmediately vSlog (resumeShip vSlog) exitImmediately mStart multi + runOrExitImmediately vSlog (resumeShip vSlog) exitImmediately mStart where wipeSnapshot = do shipPath <- view pierPathL @@ -444,7 +441,7 @@ validateNounVal inpVal = do -------------------------------------------------------------------------------- -pillFrom :: CLI.PillSource -> RIO KingEnv Pill +pillFrom :: CLI.PillSource -> RIO RunningEnv Pill pillFrom = \case CLI.PillSourceFile pillPath -> do logDebug $ display $ "boot: reading pill from " ++ (pack pillPath :: Text) @@ -475,41 +472,44 @@ newShip CLI.New{..} opts = do -} multi <- multiEyre (MultiEyreConf Nothing Nothing True) - case nBootType of - CLI.BootComet -> do - pill <- pillFrom nPillSource - putStrLn "boot: retrieving list of stars currently accepting comets" - starList <- dawnCometList - putStrLn ("boot: " ++ (tshow $ length starList) ++ - " star(s) currently accepting comets") - putStrLn "boot: mining a comet" - eny <- io $ Sys.randomIO - let seed = mineComet (Set.fromList starList) eny - putStrLn ("boot: found comet " ++ renderShip (sShip seed)) - bootFromSeed multi pill seed - - CLI.BootFake name -> do - pill <- pillFrom nPillSource - ship <- shipFrom name - runTryBootFromPill multi pill name ship (Fake ship) - - CLI.BootFromKeyfile keyFile -> do - text <- readFileUtf8 keyFile - asAtom <- case cordToUW (Cord $ T.strip text) of - Nothing -> error "Couldn't parse keyfile. Hint: keyfiles start with 0w?" - Just (UW a) -> pure a - - asNoun <- cueExn asAtom - seed :: Seed <- case fromNoun asNoun of - Nothing -> error "Keyfile does not seem to contain a seed." - Just s -> pure s - - pill <- pillFrom nPillSource - - bootFromSeed multi pill seed - + -- here we are with a king env, and we now need a multi env. + runRunningEnv multi go where - shipFrom :: Text -> RIO KingEnv Ship + go :: RIO RunningEnv () + go = case nBootType of + CLI.BootComet -> do + pill <- pillFrom nPillSource + putStrLn "boot: retrieving list of stars currently accepting comets" + starList <- dawnCometList + putStrLn ("boot: " ++ (tshow $ length starList) ++ + " star(s) currently accepting comets") + putStrLn "boot: mining a comet" + eny <- io $ Sys.randomIO + let seed = mineComet (Set.fromList starList) eny + putStrLn ("boot: found comet " ++ renderShip (sShip seed)) + bootFromSeed pill seed + + CLI.BootFake name -> do + pill <- pillFrom nPillSource + ship <- shipFrom name + runTryBootFromPill pill name ship (Fake ship) + + CLI.BootFromKeyfile keyFile -> do + text <- readFileUtf8 keyFile + asAtom <- case cordToUW (Cord $ T.strip text) of + Nothing -> error "Couldn't parse keyfile. Hint: keyfiles start with 0w?" + Just (UW a) -> pure a + + asNoun <- cueExn asAtom + seed :: Seed <- case fromNoun asNoun of + Nothing -> error "Keyfile does not seem to contain a seed." + Just s -> pure s + + pill <- pillFrom nPillSource + + bootFromSeed pill seed + + shipFrom :: Text -> RIO RunningEnv Ship shipFrom name = case Ob.parsePatp name of Left x -> error "Invalid ship name" Right p -> pure $ Ship $ fromIntegral $ Ob.fromPatp p @@ -519,7 +519,7 @@ newShip CLI.New{..} opts = do Just x -> x Nothing -> "./" <> unpack name - nameFromShip :: Ship -> RIO KingEnv Text + nameFromShip :: Ship -> RIO RunningEnv Text nameFromShip s = name where nameWithSig = Ob.renderPatp $ Ob.patp $ fromIntegral s @@ -527,8 +527,8 @@ newShip CLI.New{..} opts = do Nothing -> error "Urbit.ob didn't produce string with ~" Just x -> pure x - bootFromSeed :: MultiEyreApi -> Pill -> Seed -> RIO KingEnv () - bootFromSeed multi pill seed = do + bootFromSeed :: Pill -> Seed -> RIO RunningEnv () + bootFromSeed pill seed = do ethReturn <- dawnVent seed case ethReturn of @@ -536,19 +536,22 @@ newShip CLI.New{..} opts = do Right dawn -> do let ship = sShip $ dSeed dawn name <- nameFromShip ship - runTryBootFromPill multi pill name ship (Dawn dawn) + runTryBootFromPill pill name ship (Dawn dawn) -- Now that we have all the information for running an application with a -- PierConfig, do so. - runTryBootFromPill multi pill name ship bootEvent = do - vKill <- view kingEnvKillSignal + runTryBootFromPill :: Pill -> Text -> Ship -> LegacyBootEvent + -> RIO RunningEnv () + runTryBootFromPill pill name ship bootEvent = do + env <- ask + let vKill = (env ^. kingEnvL) ^. kingEnvKillSignal let pierConfig = toPierConfig (pierPath name) opts let networkConfig = toNetworkConfig opts runPierEnv pierConfig networkConfig vKill $ - tryBootFromPill True pill nLite ship bootEvent multi + tryBootFromPill True pill nLite ship bootEvent ------ tryBootFromPill (CLI.oExit opts) pill nLite flags ship bootEvent -runShipEnv :: CLI.Run -> CLI.Opts -> TMVar () -> RIO PierEnv a -> RIO KingEnv a +runShipEnv :: CLI.Run -> CLI.Opts -> TMVar () -> RIO PierEnv a -> RIO RunningEnv a runShipEnv (CLI.Run pierPath) opts vKill act = do runPierEnv pierConfig netConfig vKill act where @@ -556,8 +559,8 @@ runShipEnv (CLI.Run pierPath) opts vKill act = do netConfig = toNetworkConfig opts runShip - :: CLI.Run -> CLI.Opts -> Bool -> MultiEyreApi -> RIO PierEnv () -runShip (CLI.Run pierPath) opts daemon multi = do + :: CLI.Run -> CLI.Opts -> Bool -> RIO PierEnv () +runShip (CLI.Run pierPath) opts daemon = do mStart <- newEmptyMVar if daemon then runPier mStart @@ -580,7 +583,6 @@ runShip (CLI.Run pierPath) opts daemon multi = do (CLI.oFullReplay opts) (CLI.oDryFrom opts) mStart - multi startBrowser :: HasLogFunc e => FilePath -> RIO e () @@ -674,15 +676,15 @@ main = do TODO Use logging system instead of printing. -} runShipRestarting - :: CLI.Run -> CLI.Opts -> MultiEyreApi -> RIO KingEnv () -runShipRestarting r o multi = do + :: CLI.Run -> CLI.Opts -> RIO RunningEnv () +runShipRestarting r o = do let pier = pack (CLI.rPierPath r) - loop = runShipRestarting r o multi + loop = runShipRestarting r o onKill <- view onKillKingSigL vKillPier <- newEmptyTMVarIO - tid <- asyncBound $ runShipEnv r o vKillPier $ runShip r o True multi + tid <- asyncBound $ runShipEnv r o vKillPier $ runShip r o True let onShipExit = Left <$> waitCatchSTM tid onKillRequ = Right <$> onKill @@ -707,10 +709,12 @@ runShipRestarting r o multi = do TODO This is messy and shared a lot of logic with `runShipRestarting`. -} runShipNoRestart - :: CLI.Run -> CLI.Opts -> Bool -> MultiEyreApi -> RIO KingEnv () -runShipNoRestart r o d multi = do - vKill <- view kingEnvKillSignal -- killing ship same as killing king - tid <- asyncBound (runShipEnv r o vKill $ runShip r o d multi) + :: CLI.Run -> CLI.Opts -> Bool -> RIO RunningEnv () +runShipNoRestart r o d = do + -- killing ship same as killing king + env <- ask + let vKill = (env ^. kingEnvL) ^. kingEnvKillSignal + tid <- asyncBound (runShipEnv r o vKill $ runShip r o d) onKill <- view onKillKingSigL let pier = pack (CLI.rPierPath r) @@ -740,31 +744,21 @@ runShips CLI.KingOpts {..} ships = do -- a king-wide option. } - - {- - TODO Need to rework RIO environment to fix this. Should have a - bunch of nested contexts: - - - King has started. King has Id. Logging available. - - In running environment. MultiEyre and global config available. - - In pier environment: pier path and config available. - - In running ship environment: serf state, event queue available. - -} multi <- multiEyre meConf - go multi ships + runRunningEnv multi (go ships) where - go :: MultiEyreApi -> [(CLI.Run, CLI.Opts, Bool)] -> RIO KingEnv () - go me = \case + go :: [(CLI.Run, CLI.Opts, Bool)] -> RIO RunningEnv () + go = \case [] -> pure () - [rod] -> runSingleShip rod me - ships -> runMultipleShips (ships <&> \(r, o, _) -> (r, o)) me + [rod] -> runSingleShip rod + ships -> runMultipleShips (ships <&> \(r, o, _) -> (r, o)) -- TODO Duplicated logic. -runSingleShip :: (CLI.Run, CLI.Opts, Bool) -> MultiEyreApi -> RIO KingEnv () -runSingleShip (r, o, d) multi = do - shipThread <- async (runShipNoRestart r o d multi) +runSingleShip :: (CLI.Run, CLI.Opts, Bool) -> RIO RunningEnv () +runSingleShip (r, o, d) = do + shipThread <- async (runShipNoRestart r o d) {- Wait for the ship to go down. @@ -784,10 +778,10 @@ runSingleShip (r, o, d) multi = do pure () -runMultipleShips :: [(CLI.Run, CLI.Opts)] -> MultiEyreApi -> RIO KingEnv () -runMultipleShips ships multi = do +runMultipleShips :: [(CLI.Run, CLI.Opts)] -> RIO RunningEnv () +runMultipleShips ships = do shipThreads <- for ships $ \(r, o) -> do - async (runShipRestarting r o multi) + async (runShipRestarting r o) {- Since `spin` never returns, this will run until the main diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs index 2aeb33f630..3c0df3079a 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs @@ -11,7 +11,7 @@ where import Urbit.Prelude hiding (Builder) import Urbit.Arvo hiding (ServerId, reqUrl, secure) -import Urbit.King.App (HasKingId(..), HasPierEnv(..)) +import Urbit.King.App (HasKingId(..), HasMultiEyreApi(..), HasPierEnv(..)) import Urbit.King.Config import Urbit.Vere.Eyre.Multi import Urbit.Vere.Eyre.PortsFile @@ -170,16 +170,18 @@ execRespActs (Drv v) who reqId ev = readMVar v >>= \case atomically (routeRespAct who (sLiveReqs sv) reqId act) startServ - :: (HasPierConfig e, HasLogFunc e, HasNetworkConfig e) - => MultiEyreApi - -> Ship + :: (HasPierConfig e, HasLogFunc e, HasMultiEyreApi e, HasNetworkConfig e) + => Ship -> Bool -> HttpServerConf -> (EvErr -> STM ()) -> RIO e Serv -startServ multi who isFake conf plan = do +startServ who isFake conf plan = do logDebug (displayShow ("EYRE", "startServ")) + env <- ask + let multi = env ^. multiEyreApiL + let vLive = meaLive multi srvId <- io $ ServId . UV . fromIntegral <$> (randomIO :: IO Word32) @@ -281,16 +283,15 @@ _bornFailed env _ = runRIO env $ do pure () -- TODO What should this do? eyre' - :: HasPierEnv e - => MultiEyreApi - -> Ship + :: (HasPierEnv e, HasMultiEyreApi e) + => Ship -> Bool -> RIO e ([Ev], RAcquire e (DriverApi HttpServerEf)) -eyre' multi who isFake = do +eyre' who isFake = do ventQ :: TQueue EvErr <- newTQueueIO env <- ask - let (bornEvs, startDriver) = eyre env multi who (writeTQueue ventQ) isFake + let (bornEvs, startDriver) = eyre env who (writeTQueue ventQ) isFake let runDriver = do diOnEffect <- startDriver @@ -315,14 +316,14 @@ eyre :: forall e . (HasPierEnv e) => e - -> MultiEyreApi -> Ship -> (EvErr -> STM ()) -> Bool -> ([Ev], RAcquire e (HttpServerEf -> IO ())) -eyre env multi who plan isFake = (initialEvents, runHttpServer) +eyre env who plan isFake = (initialEvents, runHttpServer) where king = fromIntegral (env ^. kingIdL) + multi = env ^. multiEyreApiL initialEvents :: [Ev] initialEvents = [bornEv king] @@ -343,7 +344,7 @@ eyre env multi who plan isFake = (initialEvents, runHttpServer) restart :: Drv -> HttpServerConf -> RIO e Serv restart (Drv var) conf = do logDebug "Restarting http server" - let startAct = startServ multi who isFake conf plan + let startAct = startServ who isFake conf plan res <- fromEither =<< restartService var startAct kill logDebug "Done restating http server" pure res diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs index 78b6d9e5da..20a22dde99 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs @@ -30,7 +30,6 @@ import Urbit.EventLog.LMDB (EventLog) import Urbit.King.API (TermConn) import Urbit.Noun.Time (Wen) import Urbit.TermSize (TermSize(..)) -import Urbit.Vere.Eyre.Multi (MultiEyreApi) import Urbit.Vere.Serf (Serf) import qualified Data.Text as T @@ -260,9 +259,8 @@ pier :: (Serf, EventLog) -> TVar (Text -> IO ()) -> MVar () - -> MultiEyreApi -> RAcquire PierEnv () -pier (serf, log) vSlog startedSig multi = do +pier (serf, log) vSlog startedSig = do let logId = Log.identity log :: LogIdentity let ship = who logId :: Ship @@ -311,7 +309,7 @@ pier (serf, log) vSlog startedSig multi = do let err = atomically . Term.trace muxed . (<> "\r\n") let siz = TermSize { tsWide = 80, tsTall = 24 } let fak = isFake logId - drivers env multi ship fak compute (siz, muxed) err sigint + drivers env ship fak compute (siz, muxed) err sigint scrySig <- newEmptyTMVarIO onKill <- view onKillPierSigL @@ -412,7 +410,6 @@ data Drivers = Drivers drivers :: HasPierEnv e => e - -> MultiEyreApi -> Ship -> Bool -> (RunReq -> STM ()) @@ -420,11 +417,11 @@ drivers -> (Text -> RIO e ()) -> IO () -> RAcquire e ([Ev], RAcquire e Drivers) -drivers env multi who isFake plan termSys stderr serfSIGINT = do +drivers env who isFake plan termSys stderr serfSIGINT = do (behnBorn, runBehn) <- rio Behn.behn' (termBorn, runTerm) <- rio (Term.term' termSys serfSIGINT) (amesBorn, runAmes) <- rio (Ames.ames' who isFake stderr) - (httpBorn, runEyre) <- rio (Eyre.eyre' multi who isFake) + (httpBorn, runEyre) <- rio (Eyre.eyre' who isFake) (clayBorn, runClay) <- rio Clay.clay' (irisBorn, runIris) <- rio Iris.client' From 99d205674914f60ac6d4217138d2fe400ceeecef Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 4 Aug 2020 13:56:33 -0700 Subject: [PATCH 132/933] u3: refactors snapshot patch application --- pkg/urbit/noun/events.c | 55 ++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/pkg/urbit/noun/events.c b/pkg/urbit/noun/events.c index d12dc81ffe..289c30d399 100644 --- a/pkg/urbit/noun/events.c +++ b/pkg/urbit/noun/events.c @@ -609,44 +609,47 @@ _ce_image_sync(u3e_image* img_u) c3_sync(img_u->fid_i); } -/* _ce_patch_apply(): apply patch to image. +/* _ce_image_resize(): resize image, truncating if it shrunk. +*/ +static void +_ce_image_resize(u3e_image* img_u, c3_w pgs_w) +{ + if ( img_u->pgs_w > pgs_w ) { + if ( ftruncate(img_u->fid_i, pgs_w << (u3a_page + 2)) ) { + fprintf(stderr, "loom: image truncate %s: %s\r\n", + img_u->nam_c, + strerror(errno)); + c3_assert(0); + } + } + + img_u->pgs_w = pgs_w; +} + +/* _ce_patch_apply(): apply patch to images. */ static void _ce_patch_apply(u3_ce_patch* pat_u) { c3_w i_w; - //u3l_log("image: nor_w %d, new %d\r\n", u3P.nor_u.pgs_w, pat_u->con_u->nor_w); - //u3l_log("image: sou_w %d, new %d\r\n", u3P.sou_u.pgs_w, pat_u->con_u->sou_w); + // resize images + // + _ce_image_resize(&u3P.nor_u, pat_u->con_u->nor_w); + _ce_image_resize(&u3P.sou_u, pat_u->con_u->sou_w); - if ( u3P.nor_u.pgs_w > pat_u->con_u->nor_w ) { - c3_w ret_w; - ret_w = ftruncate(u3P.nor_u.fid_i, pat_u->con_u->nor_w << (u3a_page + 2)); - if (ret_w){ - fprintf(stderr, "loom: patch apply truncate north: %s\r\n", strerror(errno)); - c3_assert(0); - } - } - u3P.nor_u.pgs_w = pat_u->con_u->nor_w; - - if ( u3P.sou_u.pgs_w > pat_u->con_u->sou_w ) { - c3_w ret_w; - ret_w = ftruncate(u3P.sou_u.fid_i, pat_u->con_u->sou_w << (u3a_page + 2)); - if (ret_w){ - fprintf(stderr, "loom: patch apply truncate south: %s\r\n", strerror(errno)); - c3_assert(0); - } - } - u3P.sou_u.pgs_w = pat_u->con_u->sou_w; - - if ( (-1 == lseek(pat_u->mem_i, 0, SEEK_SET)) || - (-1 == lseek(u3P.nor_u.fid_i, 0, SEEK_SET)) || - (-1 == lseek(u3P.sou_u.fid_i, 0, SEEK_SET)) ) + // seek to begining of patch and images + // + if ( (-1 == lseek(pat_u->mem_i, 0, SEEK_SET)) + || (-1 == lseek(u3P.nor_u.fid_i, 0, SEEK_SET)) + || (-1 == lseek(u3P.sou_u.fid_i, 0, SEEK_SET)) ) { fprintf(stderr, "loom: patch apply seek 0: %s\r\n", strerror(errno)); c3_assert(0); } + // write patch pages into the appropriate image + // for ( i_w = 0; i_w < pat_u->con_u->pgs_w; i_w++ ) { c3_w pag_w = pat_u->con_u->mem_u[i_w].pag_w; c3_w mem_w[1 << u3a_page]; From b5a9a7d538ce7e7ee83c2c3a81d51cebea3aa26f Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 5 Aug 2020 01:24:01 +0200 Subject: [PATCH 133/933] vere: move scry api into pier.c, interleave events Scries were being prioritized over events, in the IPC queue. If scry requests came in faster than we could process them (as is easily the case for ames forward requests), this would cause scries to completely clog the IPC queue, preventing any events from being processed at all. The short-term solution implemented here is to simply alternate between scry requests and events when building/sending a work batch. To accomplish this, we separate scry requests into their own queue. We keep this in pier.c, and pass them on to lord.c interleaved with regular events in _pier_work_send. The interleaving of regular events (as opposed to doing scries with the highest priority) complicates the situation around auto-filled scry cases (for scrying at "the latest timestamp"). To ensure we're always scrying at a sane latest timestamp, we keep a queue of u3_pico, instead of fully-qualified scry requests. Where necessary, lord.c fills in the missing path elements right before sending it over the pipe. --- pkg/urbit/include/vere/vere.h | 96 ++++++++++++++++++------- pkg/urbit/vere/io/ames.c | 4 +- pkg/urbit/vere/lord.c | 105 +++++++++------------------ pkg/urbit/vere/pier.c | 130 +++++++++++++++++++++++++++++++++- 4 files changed, 232 insertions(+), 103 deletions(-) diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index de8379d3ba..fb89231b77 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -381,6 +381,36 @@ */ typedef void (*u3_peek_cb)(void*, u3_noun); + /* u3_pico_type: kinds of proto-peek + */ + typedef enum { + u3_pico_full = 0, + u3_pico_mine = 1, + u3_pico_last = 2 + } u3_pico_type; + + /* u3_pico: proto-peek + */ + typedef struct _u3_pico { + struct _u3_pico* nex_u; // next in queue + void* ptr_v; // context + u3_peek_cb fun_f; // callback + u3_noun gan; // leakset + u3_pico_type typ_e; // type-tagged + union { // + u3_noun ful; // full: /care/beam + struct { // mine: + c3_m car_m; // care + u3_noun pax; // /desk/case/path + } min_u; // + struct { // last: + c3_m car_m; // care + u3_atom des; // desk + u3_noun pax; // /path + } las_u; + }; + } u3_pico; + /* u3_peek: namespace read request */ typedef struct _u3_peek { @@ -603,6 +633,10 @@ u3_play* pay_u; // recompute u3_work* wok_u; // work }; + struct { + u3_pico* ent_u; + u3_pico* ext_u; + } pec_u; // XX remove c3_s por_s; // UDP port u3_save* sav_u; // autosave @@ -958,35 +992,11 @@ void u3_lord_play(u3_lord* god_u, u3_info fon_u); - /* u3_lord_peek(): read namespace. + /* u3_lord_peek_pico(): read namespace, injecting what's missing. */ void - u3_lord_peek(u3_lord* god_u, - u3_noun gan, - u3_noun ful, - void* ptr_v, - u3_peek_cb fun_f); - - /* u3_lord_peek_mine(): read namespace, injecting ship. - */ - void - u3_lord_peek_mine(u3_lord* god_u, - u3_noun gan, - c3_m car_m, - u3_noun pax, - void* ptr_v, - u3_peek_cb fun_f); - - /* u3_lord_peek_last(): read namespace, injecting ship and case. - */ - void - u3_lord_peek_last(u3_lord* god_u, - u3_noun gan, - c3_m car_m, - u3_atom des, - u3_noun pax, - void* ptr_v, - u3_peek_cb fun_f); + u3_lord_peek_pico(u3_lord* god_u, + u3_pico* pic_u); /** Filesystem (new api). **/ @@ -1199,6 +1209,38 @@ void u3_newt_mojo_stop(u3_mojo* moj_u, u3_moor_bail bal_f); + /** Pier scries. + **/ + /* u3_pier_peek(): read namespace. + */ + void + u3_pier_peek(u3_pier* pir_u, + u3_noun gan, + u3_noun ful, + void* ptr_v, + u3_peek_cb fun_f); + + /* u3_pier_peek_mine(): read namespace, injecting ship. + */ + void + u3_pier_peek_mine(u3_pier* pir_u, + u3_noun gan, + c3_m car_m, + u3_noun pax, + void* ptr_v, + u3_peek_cb fun_f); + + /* u3_pier_peek_last(): read namespace, injecting ship and case. + */ + void + u3_pier_peek_last(u3_pier* pir_u, + u3_noun gan, + c3_m car_m, + u3_atom des, + u3_noun pax, + void* ptr_v, + u3_peek_cb fun_f); + /** Pier control. **/ /* u3_pier_exit(): trigger a gentle shutdown. diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index b385ccf480..9a480c9939 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -831,7 +831,7 @@ _ames_recv_cb(uv_udp_t* wax_u, u3dc("scot", 'p', u3i_chubs(2, rec_d)), u3i_string("forward-lane"), u3_nul); - u3_lord_peek_last(sam_u->pir_u->god_u, u3_nul, c3_s2('a', 'x'), + u3_pier_peek_last(sam_u->pir_u, u3_nul, c3_s2('a', 'x'), u3_nul, pax, pac_u, _ames_lane_scry_cb); } } @@ -1143,7 +1143,7 @@ u3_ames_io_init(u3_pier* pir_u) // scry the protocol version out of arvo // - u3_lord_peek_last(pir_u->god_u, u3_nul, c3_s2('a', 'x'), u3_nul, + u3_pier_peek_last(pir_u, u3_nul, c3_s2('a', 'x'), u3_nul, u3nt(u3i_string("protocol"), u3i_string("version"), u3_nul), sam_u, _ames_prot_scry_cb); diff --git a/pkg/urbit/vere/lord.c b/pkg/urbit/vere/lord.c index fef5584c5d..f0616eead0 100644 --- a/pkg/urbit/vere/lord.c +++ b/pkg/urbit/vere/lord.c @@ -803,92 +803,53 @@ _lord_writ_plan(u3_lord* god_u, u3_writ* wit_u) _lord_writ_send(god_u, wit_u); } -/* u3_lord_peek(): read namespace. +/* u3_lord_peek_pico(): read namespace, injecting what's missing. */ void -u3_lord_peek(u3_lord* god_u, - u3_noun gan, - u3_noun ful, - void* ptr_v, - u3_peek_cb fun_f) +u3_lord_peek_pico(u3_lord* god_u, + u3_pico* pic_u) { u3_writ* wit_u = _lord_writ_new(god_u); wit_u->typ_e = u3_writ_peek; wit_u->pek_u = c3_calloc(sizeof(*wit_u->pek_u)); - wit_u->pek_u->ptr_v = ptr_v; - wit_u->pek_u->fun_f = fun_f; + wit_u->pek_u->ptr_v = pic_u->ptr_v; + wit_u->pek_u->fun_f = pic_u->fun_f; wit_u->pek_u->now = u3_time_in_tv(&wit_u->tim_u); - wit_u->pek_u->gan = gan; - wit_u->pek_u->ful = ful; + wit_u->pek_u->gan = pic_u->gan; - // XX cache check + // construct the full scry path // + switch ( pic_u->typ_e ) { + default: c3_assert(0); - _lord_writ_plan(god_u, wit_u); -} + case u3_pico_full: { + wit_u->pek_u->ful = pic_u->ful; + } break; -/* u3_lord_peek_mine(): read namespace, injecting ship (our). -*/ -void -u3_lord_peek_mine(u3_lord* god_u, - u3_noun gan, - c3_m car_m, - u3_noun pax, - void* ptr_v, - u3_peek_cb fun_f) -{ - u3_writ* wit_u = _lord_writ_new(god_u); - wit_u->typ_e = u3_writ_peek; - wit_u->pek_u = c3_calloc(sizeof(*wit_u->pek_u)); - wit_u->pek_u->ptr_v = ptr_v; - wit_u->pek_u->fun_f = fun_f; - wit_u->pek_u->now = u3_time_in_tv(&wit_u->tim_u); - wit_u->pek_u->gan = gan; + case u3_pico_mine: { + // XX cache + // + u3_pier* pir_u = god_u->cb_u.ptr_v; // XX do better + u3_noun our = u3dc("scot", 'p', u3i_chubs(2, pir_u->who_d)); + wit_u->pek_u->ful = u3nt(pic_u->min_u.car_m, our, pic_u->min_u.pax); + } break; - { - // XX cache - // - u3_pier* pir_u = god_u->cb_u.ptr_v; // XX do better - u3_noun our = u3dc("scot", 'p', u3i_chubs(2, pir_u->who_d)); - wit_u->pek_u->ful = u3nt(car_m, our, pax); + case u3_pico_last: { + // XX cache + // + u3_pier* pir_u = god_u->cb_u.ptr_v; // XX do better + u3_noun our = u3dc("scot", 'p', u3i_chubs(2, pir_u->who_d)); + u3_noun cas = u3dc("scot", c3__da, u3k(wit_u->pek_u->now)); + + wit_u->pek_u->ful = u3nc(pic_u->las_u.car_m, + u3nq(our, + pic_u->las_u.des, + cas, + pic_u->las_u.pax)); + } break; } - // XX cache check - // - - _lord_writ_plan(god_u, wit_u); -} - -/* u3_lord_peek_last(): read namespace, injecting ship (our) and case (now). -*/ -void -u3_lord_peek_last(u3_lord* god_u, - u3_noun gan, - c3_m car_m, - u3_atom des, - u3_noun pax, - void* ptr_v, - u3_peek_cb fun_f) -{ - u3_writ* wit_u = _lord_writ_new(god_u); - wit_u->typ_e = u3_writ_peek; - wit_u->pek_u = c3_calloc(sizeof(*wit_u->pek_u)); - wit_u->pek_u->ptr_v = ptr_v; - wit_u->pek_u->fun_f = fun_f; - wit_u->pek_u->now = u3_time_in_tv(&wit_u->tim_u); - wit_u->pek_u->gan = gan; - - { - // XX cache - // - u3_pier* pir_u = god_u->cb_u.ptr_v; // XX do better - u3_noun our = u3dc("scot", 'p', u3i_chubs(2, pir_u->who_d)); - u3_noun cas = u3dc("scot", c3__da, u3k(wit_u->pek_u->now)); - - wit_u->pek_u->ful = u3nc(car_m, u3nq(our, des, cas, pax)); - } - - // NB, won't be cached, result shouldn't be + // XX cache check, unless last // _lord_writ_plan(god_u, wit_u); } diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index 9c66b5315a..a78b46b709 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -26,6 +26,44 @@ #undef VERBOSE_PIER +/* _pier_peek_new(): add a new u3_pico to the peek queue +*/ +static u3_pico* +_pier_peek_new(u3_pier* pir_u) +{ + u3_pico* pic_u = c3_calloc(sizeof(*pic_u)); + + if (!pir_u->pec_u.ent_u) { + c3_assert( !pir_u->pec_u.ext_u ); + pir_u->pec_u.ent_u = pir_u->pec_u.ext_u = pic_u; + } + else { + pir_u->pec_u.ent_u->nex_u = pic_u; + pir_u->pec_u.ent_u = pic_u; + } + + return pic_u; +} + +/* _pier_peek_next(): pop u3_pico off of peek queue +*/ +static u3_pico* +_pier_peek_next(u3_pier* pir_u) +{ + u3_pico* pic_u = pir_u->pec_u.ext_u; + + if (pic_u) { + pir_u->pec_u.ext_u = pic_u->nex_u; + if (!pir_u->pec_u.ext_u) { + pir_u->pec_u.ent_u = 0; + } + + pic_u->nex_u = 0; + } + + return pic_u; +} + /* _pier_work_send(): send new events for processing */ static void @@ -60,13 +98,32 @@ _pier_work_send(u3_work* wok_u) { u3_ovum* egg_u; u3_noun ovo; + u3_pico* pic_u; - while ( len_w-- && car_u && (egg_u = u3_auto_next(car_u, &ovo)) ) { + while ( len_w-- && car_u && (egg_u = u3_auto_next(car_u, &ovo)) ) { u3_lord_work(god_u, egg_u, ovo); // queue events depth first // car_u = egg_u->car_u; + + // interleave scry requests + // + if ( len_w + && (pic_u = _pier_peek_next(pir_u)) ) + { + len_w--; + u3_lord_peek_pico(god_u, pic_u); + c3_free(pic_u); + } + } + + // if there's room left in the batch, fill it up with remaining scries + // + while ( len_w-- && (pic_u = _pier_peek_next(pir_u)) ) + { + u3_lord_peek_pico(god_u, pic_u); + c3_free(pic_u); } } } @@ -353,6 +410,75 @@ u3_pier_spin(u3_pier* pir_u) } } +/* u3_pier_peek(): read namespace. +*/ +void +u3_pier_peek(u3_pier* pir_u, + u3_noun gan, + u3_noun ful, + void* ptr_v, + u3_peek_cb fun_f) +{ + u3_pico* pic_u = _pier_peek_new(pir_u); + + pic_u->ptr_v = ptr_v; + pic_u->fun_f = fun_f; + pic_u->gan = gan; + // + pic_u->typ_e = u3_pico_full; + pic_u->ful = ful; + + u3_pier_spin(pir_u); +} + +/* u3_pier_peek_mine(): read namespace, injecting ship. +*/ +void +u3_pier_peek_mine(u3_pier* pir_u, + u3_noun gan, + c3_m car_m, + u3_noun pax, + void* ptr_v, + u3_peek_cb fun_f) +{ + u3_pico* pic_u = _pier_peek_new(pir_u); + + pic_u->ptr_v = ptr_v; + pic_u->fun_f = fun_f; + pic_u->gan = gan; + // + pic_u->typ_e = u3_pico_mine; + pic_u->min_u.car_m = car_m; + pic_u->min_u.pax = pax; + + u3_pier_spin(pir_u); +} + +/* u3_pier_peek_last(): read namespace, injecting ship and case. +*/ +void +u3_pier_peek_last(u3_pier* pir_u, + u3_noun gan, + c3_m car_m, + u3_atom des, + u3_noun pax, + void* ptr_v, + u3_peek_cb fun_f) +{ + u3_pico* pic_u = _pier_peek_new(pir_u); + + pic_u->ptr_v = ptr_v; + pic_u->fun_f = fun_f; + pic_u->gan = gan; + // + pic_u->typ_e = u3_pico_last; + pic_u->las_u.car_m = car_m; + pic_u->las_u.des = des; + pic_u->las_u.pax = pax; + + u3_pier_spin(pir_u); +} + /* _pier_work_init(): begin processing new events */ static void @@ -1024,7 +1150,7 @@ _pier_on_lord_live(void* ptr_v) // run the requested scry, jam to disk, then exit // u3l_log("pier: scry\n"); - u3_lord_peek_last(god_u, u3_nul, u3k(car), u3k(dek), u3k(pax), + u3_pier_peek_last(pir_u, u3_nul, u3k(car), u3k(dek), u3k(pax), pir_u, _pier_on_scry_done); } u3z(pex); From 8a7aca15db3809d401cb1debb6dd0e237e5c29ca Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 5 Aug 2020 01:29:37 +0200 Subject: [PATCH 134/933] vere: improves ames.c code style Avoid intermediate noun allocations, superfluous typedefs, constant calculations, etc. --- pkg/urbit/vere/io/ames.c | 137 +++++++++++++++++++-------------------- 1 file changed, 65 insertions(+), 72 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 9a480c9939..2bfafca835 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -13,9 +13,6 @@ #include "all.h" #include "vere/vere.h" -struct _u3_panc; -typedef struct _u3_panc u3_panc; - /* u3_pact: ames packet, coming or going. */ typedef struct _u3_pact { @@ -32,27 +29,27 @@ typedef struct _u3_panc u3_panc; /* u3_ames: ames networking. */ typedef struct _u3_ames { // packet network state - u3_auto car_u; // driver - u3_pier* pir_u; // pier + u3_auto car_u; // driver + u3_pier* pir_u; // pier union { // - uv_udp_t wax_u; // - uv_handle_t had_u; // + uv_udp_t wax_u; // + uv_handle_t had_u; // }; // - c3_c* dns_c; // domain XX multiple/fallback - c3_d dop_d; // drop count - c3_d fal_d; // crash count - c3_w imp_w[256]; // imperial IPs - time_t imp_t[256]; // imperial IP timestamps - c3_o imp_o[256]; // imperial print status - c3_o see_o; // can scry - c3_o fit_o; // filtering active - c3_y ver_y; // protocol version - c3_d vet_d; // version mismatches filtered - c3_d mut_d; // invalid mugs filtered - u3_panc* pac_u; // packets pending forwards - c3_d foq_d; // forward queue size - c3_d fow_d; // forwarded count - c3_d fod_d; // forwards dropped count + c3_c* dns_c; // domain XX multiple/fallback + c3_d dop_d; // drop count + c3_d fal_d; // crash count + c3_w imp_w[256]; // imperial IPs + time_t imp_t[256]; // imperial IP timestamps + c3_o imp_o[256]; // imperial print status + c3_o see_o; // can scry + c3_o fit_o; // filtering active + c3_y ver_y; // protocol version + c3_d vet_d; // version mismatches filtered + c3_d mut_d; // invalid mugs filtered + struct _u3_panc* pac_u; // packets pending forwards + c3_d foq_d; // forward queue size + c3_d fow_d; // forwarded count + c3_d fod_d; // forwards dropped count } u3_ames; /* u3_head: ames packet header @@ -76,14 +73,14 @@ typedef struct _u3_panc u3_panc; /* u3_panc: deconstructed incoming packet */ - struct _u3_panc { - u3_ames* sam_u; // ames backpointer - u3_panc* pre_u; // previous packet - u3_panc* nex_u; // next packet - u3_noun ore; // origin lane - u3_head hed_u; // header - u3_body bod_u; // body - }; + typedef struct _u3_panc { + u3_ames* sam_u; // ames backpointer + struct _u3_panc* pre_u; // previous packet + struct _u3_panc* nex_u; // next packet + u3_noun ore; // origin lane + u3_head hed_u; // header + u3_body bod_u; // body + } u3_panc; /* _ames_alloc(): libuv buffer allocator. */ @@ -379,9 +376,8 @@ _ames_serialize_packet(u3_panc* pac_u, c3_o dop_o) // if we updated the origin lane, we need to update the mug too // if (c3y == nal_o) { - u3_noun bod = u3i_bytes(sen_y + rec_y + bod_u->con_w, pac_y + 4); - pac_u->hed_u.mug_l = u3r_mug(bod) & ((1 << 20) - 1); - u3z(bod); + pac_u->hed_u.mug_l = _ca_mug_body(sen_y + rec_y + bod_u->con_w, + pac_y + 4); } // now we can serialize the head @@ -705,7 +701,7 @@ _ames_recv_cb(uv_udp_t* wax_u, | (byt_y[3] << 24); hed_u.ver_y = hed_w & 0x7; - hed_u.mug_l = (hed_w >> 3) & ((1 << 20) - 1); + hed_u.mug_l = (hed_w >> 3) & 0xfffff; //NOTE ((1 << 20) - 1) hed_u.sac_y = (hed_w >> 23) & 0x3; hed_u.rac_y = (hed_w >> 25) & 0x3; hed_u.enc_o = (hed_w >> 27) & 0x1; @@ -758,11 +754,8 @@ _ames_recv_cb(uv_udp_t* wax_u, // ensure the content is cue-able // - u3_noun con = u3i_bytes(con_w, con_y); - u3_noun pro = u3m_soft(0, u3qe_cue, con); - if (u3_blip != u3h(pro)) { - pas_o = c3n; - } + u3_noun pro = u3m_soft(0, u3ke_cue, u3i_bytes(con_w, con_y)); + pas_o = (u3_blip == u3h(pro)) ? c3y : c3n; u3z(pro); } @@ -822,7 +815,7 @@ _ames_recv_cb(uv_udp_t* wax_u, // if the recipient is a galaxy, their lane is always &+~gax // if ( (rec_d[1] == 0) && (256 > rec_d[0]) ) { - _ames_forward(pac_u, u3nc(u3nc(c3y, rec_d[0]), u3_nul)); + _ames_forward(pac_u, u3nc(u3nc(c3y, (c3_y)rec_d[0]), u3_nul)); } // otherwise, if there's space in the queue, scry the lane out of ames // @@ -951,6 +944,32 @@ _ames_ef_turf(u3_ames* sam_u, u3_noun tuf) } } +/* _ames_prot_scry_cb(): receive protocol version +*/ +static void +_ames_prot_scry_cb(void* vod_p, u3_noun nun) +{ + u3_ames* sam_u = vod_p; + u3_weak ver = u3r_at(7, nun); + + if (u3_none == ver) { + // assume protocol version 0 + // + sam_u->ver_y = 0; + } + else if ( (c3n == u3a_is_cat(ver)) + || (7 < ver) ) { + u3m_p("ames: strange protocol", nun); + sam_u->ver_y = 0; + } + else { + sam_u->ver_y = ver; + } + + sam_u->fit_o = c3y; + u3z(nun); +} + /* _ames_io_talk(): start receiving ames traffic. */ static void @@ -967,6 +986,12 @@ _ames_io_talk(u3_auto* car_u) u3_auto_plan(car_u, u3_ovum_init(0, c3__a, wir, cad)); } + + // scry the protocol version out of arvo + // + u3_pier_peek_last(car_u->pir_u, u3_nul, c3_s2('a', 'x'), u3_nul, + u3nt(u3i_string("protocol"), u3i_string("version"), u3_nul), + sam_u, _ames_prot_scry_cb); } /* _ames_kick_newt(): apply packet network outputs. @@ -1079,32 +1104,6 @@ _ames_io_exit(u3_auto* car_u) uv_close(&sam_u->had_u, _ames_exit_cb); } -/* _ames_prot_scry_cb(): receive protocol version -*/ -static void -_ames_prot_scry_cb(void* vod_p, u3_noun nun) -{ - u3_ames* sam_u = vod_p; - u3_weak ver = u3r_at(7, nun); - - if (u3_none == ver) { - // assume protocol version 0 - // - sam_u->ver_y = 0; - } - else if ( (c3n == u3a_is_cat(ver)) - || (7 < ver) ) { - u3m_p("ames: strange protocol", nun); - sam_u->ver_y = 0; - } - else { - sam_u->ver_y = ver; - } - - sam_u->fit_o = c3y; - u3z(nun); -} - /* _ames_io_info(): print status info. */ static void @@ -1141,12 +1140,6 @@ u3_ames_io_init(u3_pier* pir_u) u3_Host.ops_u.net = c3n; } - // scry the protocol version out of arvo - // - u3_pier_peek_last(pir_u, u3_nul, c3_s2('a', 'x'), u3_nul, - u3nt(u3i_string("protocol"), u3i_string("version"), u3_nul), - sam_u, _ames_prot_scry_cb); - u3_auto* car_u = &sam_u->car_u; car_u->nam_m = c3__ames; car_u->liv_o = c3n; From 7aecd3064eeea05fadc9ee17c027264f2afca382 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 5 Aug 2020 01:38:00 +0200 Subject: [PATCH 135/933] vere: store lanes as structs, not nouns This was the last bit of forwarding state we were still keeping on the loom. It's all C structs now. --- pkg/urbit/vere/io/ames.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 2bfafca835..540346b7fe 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -77,7 +77,7 @@ u3_ames* sam_u; // ames backpointer struct _u3_panc* pre_u; // previous packet struct _u3_panc* nex_u; // next packet - u3_noun ore; // origin lane + u3_lane ore_u; // origin lane u3_head hed_u; // header u3_body bod_u; // body } u3_panc; @@ -121,7 +121,6 @@ _ames_panc_free(u3_panc* pac_u) { pac_u->sam_u->pac_u = pac_u->nex_u; } - u3z(pac_u->ore); c3_free(pac_u->bod_u.con_y); c3_free(pac_u); } @@ -298,15 +297,15 @@ u3_ames_encode_lane(u3_lane lan) { return u3ke_jam(u3nt(c3__ipv4, u3i_words(1, &lan.pip_w), lan.por_s)); } -/* _ames_lane_from_sockaddr(): sockaddr_in to lane noun +/* _ames_lane_from_sockaddr(): sockaddr_in to lane struct */ -static u3_noun +static u3_lane _ames_lane_from_sockaddr(struct sockaddr_in* add_u) { u3_lane lan_u; lan_u.por_s = ntohs(add_u->sin_port); lan_u.pip_w = ntohl(add_u->sin_addr.s_addr); - return u3_ames_encode_lane(lan_u); + return lan_u; } /* _ames_serialize_packet(): u3_panc to atom, updating the origin lane if dop_o @@ -341,7 +340,7 @@ _ames_serialize_packet(u3_panc* pac_u, c3_o dop_o) // if (u3_nul == lon) { u3z(lon); - lon = u3nt(u3_nul, c3n, u3k(pac_u->ore)); + lon = u3nt(u3_nul, c3n, u3_ames_encode_lane(pac_u->ore_u)); nal_o = c3y; c3_free(pac_u->bod_u.con_y); @@ -606,10 +605,10 @@ _ames_hear_bail(u3_ovum* egg_u, u3_noun lud) static void _ames_put_packet(u3_ames* sam_u, u3_noun msg, - u3_noun lan) + u3_lane lan_u) { u3_noun wir = u3nc(c3__ames, u3_nul); - u3_noun cad = u3nt(c3__hear, u3nc(c3n, lan), msg); + u3_noun cad = u3nt(c3__hear, u3nc(c3n, u3_ames_encode_lane(lan_u)), msg); u3_auto_peer( u3_auto_plan(&sam_u->car_u, @@ -659,7 +658,7 @@ _ames_lane_scry_cb(void* vod_p, u3_noun nun) pac_u->sam_u->see_o = c3n; _ames_put_packet(pac_u->sam_u, _ames_serialize_packet(pac_u, c3n), - pac_u->ore); + pac_u->ore_u); _ames_panc_free(pac_u); } // if there is a lane, forward the packet on it @@ -804,7 +803,7 @@ _ames_recv_cb(uv_udp_t* wax_u, pac_u->bod_u.rec_d[1] = rec_d[1]; pac_u->bod_u.con_w = con_w; pac_u->bod_u.con_y = con_y; - pac_u->ore = _ames_lane_from_sockaddr((struct sockaddr_in *)adr_u); + pac_u->ore_u = _ames_lane_from_sockaddr((struct sockaddr_in *)adr_u); if (0 != sam_u->pac_u) { pac_u->nex_u = sam_u->pac_u; @@ -834,9 +833,9 @@ _ames_recv_cb(uv_udp_t* wax_u, // if (c3y == pas_o) { c3_free(con_y); - u3_noun ore = _ames_lane_from_sockaddr((struct sockaddr_in *)adr_u); - u3_noun msg = u3i_bytes((c3_w)nrd_i, (c3_y*)buf_u->base); - _ames_put_packet(sam_u, msg, ore); + u3_lane ore_u = _ames_lane_from_sockaddr((struct sockaddr_in *)adr_u); + u3_noun msg = u3i_bytes((c3_w)nrd_i, (c3_y*)buf_u->base); + _ames_put_packet(sam_u, msg, ore_u); } c3_free(buf_u->base); From 78529c926fe48155759572d3b24844decc2b6e59 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 5 Aug 2020 16:40:27 +0200 Subject: [PATCH 136/933] vere: don't decrement prematurely Previously, we decremented len_w eagerly, regardless of whether u3_auto_next succeeded in getting a next event or not. Now, we only decrement len_w if we actually managed to get a next event, resulting in better behavior in the "no next" case. Also lightly touches up style a couple lines down, for consistency. --- pkg/urbit/vere/pier.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index a78b46b709..5c68ac13d0 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -100,7 +100,8 @@ _pier_work_send(u3_work* wok_u) u3_noun ovo; u3_pico* pic_u; - while ( len_w-- && car_u && (egg_u = u3_auto_next(car_u, &ovo)) ) { + while ( len_w && car_u && (egg_u = u3_auto_next(car_u, &ovo)) ) { + len_w--; u3_lord_work(god_u, egg_u, ovo); // queue events depth first @@ -109,8 +110,7 @@ _pier_work_send(u3_work* wok_u) // interleave scry requests // - if ( len_w - && (pic_u = _pier_peek_next(pir_u)) ) + if ( len_w && (pic_u = _pier_peek_next(pir_u)) ) { len_w--; u3_lord_peek_pico(god_u, pic_u); From 25a48064390c3c80aa8cbeab146d7149c16cf21b Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 5 Aug 2020 16:42:25 +0200 Subject: [PATCH 137/933] vere: reduce "dropped forwards" printf frequency --- pkg/urbit/vere/io/ames.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 540346b7fe..1cc69322ad 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -783,7 +783,7 @@ _ames_recv_cb(uv_udp_t* wax_u, c3_free(con_y); sam_u->fod_d++; - if ( 0 == (sam_u->fod_d % 1000) ) { + if ( 0 == (sam_u->fod_d % 100000) ) { u3l_log("ames: dropped %" PRIu64 " forwards total\n", sam_u->fod_d); } } From 86b445b7cb4a1ad3739fa1e24861f8e2204edf38 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 5 Aug 2020 15:33:37 -0400 Subject: [PATCH 138/933] king: First attempt at integration with NATPMP. This sets up a separate thread to handle scheduling of lease renewals. --- .../natpmp-static/hsrc_lib/Network/NATPMP.hsc | 15 +- pkg/hs/urbit-king/lib/Urbit/King/App.hs | 26 ++- pkg/hs/urbit-king/lib/Urbit/King/Main.hs | 16 +- pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs | 173 ++++++++++++++++++ pkg/hs/urbit-king/package.yaml | 1 + 5 files changed, 214 insertions(+), 17 deletions(-) create mode 100644 pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs diff --git a/pkg/hs/natpmp-static/hsrc_lib/Network/NATPMP.hsc b/pkg/hs/natpmp-static/hsrc_lib/Network/NATPMP.hsc index c0526356bb..c48dd2a234 100644 --- a/pkg/hs/natpmp-static/hsrc_lib/Network/NATPMP.hsc +++ b/pkg/hs/natpmp-static/hsrc_lib/Network/NATPMP.hsc @@ -3,13 +3,14 @@ -- | This module is a thin wrapper above libnatpmp.h and getgateway.h. module Network.NATPMP (Error(..), - NatPmpResponse(..), - ProtocolType(..), - initNatPmp, - closeNatPmp, - getDefaultGateway, - getPublicAddress, - setPortMapping) where + NatPmpResponse(..), + ProtocolType(..), + NatPmpHandle, + initNatPmp, + closeNatPmp, + getDefaultGateway, + getPublicAddress, + setPortMapping) where #include diff --git a/pkg/hs/urbit-king/lib/Urbit/King/App.hs b/pkg/hs/urbit-king/lib/Urbit/King/App.hs index 0d758b692c..225e7f4b45 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/App.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/App.hs @@ -35,7 +35,7 @@ import System.Posix.Types (CPid(..)) import System.Random (randomIO) import Urbit.King.App.Class (HasStderrLogFunc(..)) import Urbit.Vere.Eyre.Multi (MultiEyreApi) - +import Urbit.Vere.Ports (PortControlApi, HasPortControlApi(..)) -- KingEnv --------------------------------------------------------------------- @@ -135,12 +135,14 @@ killKingActionL = class HasMultiEyreApi a where multiEyreApiL :: Lens' a MultiEyreApi -class (HasKingEnv a, HasMultiEyreApi a) => HasRunningEnv a where +class (HasKingEnv a, HasMultiEyreApi a, HasPortControlApi a) => + HasRunningEnv a where runningEnvL :: Lens' a RunningEnv data RunningEnv = RunningEnv - { _runningEnvKingEnv :: !KingEnv - , _runningEnvMultiEyreApi :: MultiEyreApi + { _runningEnvKingEnv :: !KingEnv + , _runningEnvMultiEyreApi :: MultiEyreApi + , _runningEnvPortControlApi :: PortControlApi } makeLenses ''RunningEnv @@ -163,14 +165,19 @@ instance HasKingId RunningEnv where instance HasMultiEyreApi RunningEnv where multiEyreApiL = runningEnvMultiEyreApi +instance HasPortControlApi RunningEnv where + portControlApiL = runningEnvPortControlApi + -- Running Running Envs -------------------------------------------------------- -runRunningEnv :: MultiEyreApi -> RIO RunningEnv () -> RIO KingEnv () -runRunningEnv multi action = do +runRunningEnv :: MultiEyreApi -> PortControlApi -> RIO RunningEnv () + -> RIO KingEnv () +runRunningEnv multi ports action = do king <- ask - let runningEnv = RunningEnv { _runningEnvKingEnv = king - , _runningEnvMultiEyreApi = multi + let runningEnv = RunningEnv { _runningEnvKingEnv = king + , _runningEnvMultiEyreApi = multi + , _runningEnvPortControlApi = ports } io (runRIO runningEnv action) @@ -199,6 +206,9 @@ instance HasRunningEnv PierEnv where instance HasMultiEyreApi PierEnv where multiEyreApiL = pierEnvRunningEnv . multiEyreApiL +instance HasPortControlApi PierEnv where + portControlApiL = pierEnvRunningEnv . portControlApiL + instance HasPierEnv PierEnv where pierEnvL = id diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs index bcdc9c1837..df3c4257d0 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs @@ -82,6 +82,7 @@ import Urbit.Arvo import Urbit.King.Config import Urbit.Vere.Dawn import Urbit.Vere.Pier +import Urbit.Vere.Ports import Urbit.Vere.Eyre.Multi (multiEyre, MultiEyreConf(..)) import Urbit.Vere.Pier.Types import Urbit.Vere.Serf @@ -472,8 +473,12 @@ newShip CLI.New{..} opts = do -} multi <- multiEyre (MultiEyreConf Nothing Nothing True) + -- TODO: We hit the same problem as above: we need the running options to + -- determine how to configure the ports + ports <- buildInactivePorts + -- here we are with a king env, and we now need a multi env. - runRunningEnv multi go + runRunningEnv multi ports go where go :: RIO RunningEnv () go = case nBootType of @@ -585,6 +590,11 @@ runShip (CLI.Run pierPath) opts daemon = do mStart +buildPortHandler :: (HasLogFunc e) => Maybe CLI.IPSource -> RIO e PortControlApi +buildPortHandler Nothing = buildInactivePorts +buildPortHandler (Just CLI.IPSourceNAT) = buildNATPorts +buildPortHandler (Just (CLI.IPSourceManual _)) = error "wut do" + startBrowser :: HasLogFunc e => FilePath -> RIO e () startBrowser pierPath = runRAcquire $ do -- lockFile pierPath @@ -746,7 +756,9 @@ runShips CLI.KingOpts {..} ships = do multi <- multiEyre meConf - runRunningEnv multi (go ships) + ports <- buildPortHandler koIPSource + + runRunningEnv multi ports (go ships) where go :: [(CLI.Run, CLI.Opts, Bool)] -> RIO RunningEnv () go = \case diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs new file mode 100644 index 0000000000..7a4cadb966 --- /dev/null +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs @@ -0,0 +1,173 @@ +module Urbit.Vere.Ports where + +-- (PortControlApi, +-- buildInactivePorts) +import Control.Monad.STM (check) +import Urbit.Prelude +import Network.NATPMP +import Data.Time.Clock.POSIX +import Data.Heap + +-- This module deals with ports and port requests. When a component wants to +-- ensure that it is externally reachable, possibly from outside a NAT, it +-- makes a request to this module to hole-punch. + +class HasPortControlApi a where + portControlApiL :: Lens' a PortControlApi + +data PortControlApi = PortControlApi + { pAddPortRequest :: Word16 -> IO () + , pRemovePortRequest :: Word16 -> IO () + } + +-- Builds a Ports struct which does nothing when called. +buildInactivePorts :: RIO e PortControlApi +buildInactivePorts = pure $ PortControlApi noop noop + where + noop x = pure () + +-- Builds a Ports struct which tries to hole-punch by talking to the NAT +-- gateway over NAT-PMP. +buildNATPorts :: (HasLogFunc e) => RIO e PortControlApi +buildNATPorts = do + q <- newTQueueIO + async $ portThread q + pure $ PortControlApi (addRequest q) (removeRequest q) + where + addRequest :: TQueue PortThreadMsg -> Word16 -> IO () + addRequest q port = do + resp <- newEmptyTMVarIO + atomically $ + writeTQueue q (PTMInitialRequestOpen port (putTMVar resp True)) + atomically $ takeTMVar resp + pure () + + removeRequest :: TQueue PortThreadMsg -> Word16 -> IO () + removeRequest q port = atomically $ writeTQueue q (PTMRequestClose port) + +portLeaseLifetime :: Word32 +portLeaseLifetime = 15 * 60 + +-- Be paranoid and renew leases a full minute before they would naturally expire. +portRenewalTime :: Word32 +portRenewalTime = portLeaseLifetime - 60 + +-- Messages sent from the main thread to the port mapping communication thread. +data PortThreadMsg + = PTMInitialRequestOpen Word16 (STM ()) + -- ^ Does the open request, and then calls the passed in stm action to + -- singal completion to the main thread. We want to block on the initial + -- setting opening because we want the forwarding set up before we actually + -- start using the port. + + | PTMRequestOpen Word16 + -- ^ Repeating open command we send to ourselves. + + | PTMRequestClose Word16 + -- ^ Close command. No synchronization because there's nothing we can do if + -- it fails. + +-- The port thread is an async which reads commands from an STM queue and then +-- executes them. This thread is here to bind the semantics that we want to how +-- NAT-PMP sees the world. We want for an RAcquire to be able to start a +-- request for port forwarding and then to release it when it goes out of +-- scope. OTOH, NAT-PMP is all timeout based, and we want that timeout to be +-- fairly short, such as 15 minutes, so the portThread needs to keep track of +-- the time of the next port request. +portThread :: (HasLogFunc e) => TQueue PortThreadMsg -> RIO e () +portThread q = do + pmp <- io $ initNatPmp + case pmp of + Left err -> do + logError "error initializing NatPmp" + loopErr q + Right pmp -> loop pmp mempty + where + loop :: NatPmpHandle -> MinPrioHeap POSIXTime PortThreadMsg -> RIO e () + loop pmp nextRenew = forever $ do + now <- io $ getPOSIXTime + delay <- case viewHead nextRenew of + Nothing -> newTVarIO False + Just (fireTime, _) -> do + let timeTo = fireTime - now + let ms = round $ timeTo * 1000 + registerDelay ms + command <- atomically $ + (Left <$> fini delay) <|> (Right <$> readTQueue q) + case command of + Left () -> do + -- the timeout has fired, meaning the top of the heap should be + -- popped and rerun. + case (Data.Heap.view nextRenew) of + Nothing -> error "Internal heap managing error." + Just ((_, msg), rest) -> handlePTM pmp msg rest + Right msg -> handlePTM pmp msg nextRenew + + handlePTM :: NatPmpHandle + -> PortThreadMsg + -> MinPrioHeap POSIXTime PortThreadMsg + -> RIO e () + handlePTM pmp msg nextRenew = case msg of + PTMInitialRequestOpen p notifyComplete -> do + io $ setPortMapping pmp PTUDP p p portLeaseLifetime + let filteredPort = filterPort p nextRenew + now <- io $ getPOSIXTime + let repeatMsg = PTMRequestOpen p + let withRenew = + insert (now + (fromIntegral portRenewalTime), repeatMsg) + filteredPort + atomically notifyComplete + loop pmp withRenew + + PTMRequestOpen p -> do + io $ setPortMapping pmp PTUDP p p portLeaseLifetime + let filteredPort = filterPort p nextRenew + now <- io $ getPOSIXTime + let withRenew = + insert (now + (fromIntegral portRenewalTime), msg) filteredPort + loop pmp withRenew + + PTMRequestClose p -> do + io $ setPortMapping pmp PTUDP p p 0 + let removed = filterPort p nextRenew + loop pmp removed + + filterPort :: Word16 + -> MinPrioHeap POSIXTime PortThreadMsg + -> MinPrioHeap POSIXTime PortThreadMsg + filterPort p = Data.Heap.filter okPort + where + -- initial requests should never be in the heap + okPort (_, PTMInitialRequestOpen _ _) = False + okPort (_, PTMRequestOpen x) = p /= x + okPort (_, PTMRequestClose x) = p /= x + + -- block (retry) until the delay TVar is set to True + fini :: TVar Bool -> STM () + fini = check <=< readTVar + + -- The NAT system is considered "off" but we still need to signal back to + -- the main thread that blocking actions are copmlete + loopErr q = forever $ do + (atomically $ readTQueue q) >>= \case + PTMInitialRequestOpen _ onComplete -> atomically onComplete + PTMRequestOpen _ -> pure () + PTMRequestClose _ -> pure () + +-- Acquire a port for the duration of the RAcquire. +requestPortAccess :: forall e. (HasPortControlApi e) => Word16 -> RAcquire e () +requestPortAccess port = do + mkRAcquire request release + where + request :: RIO e () + request = do + env <- ask + let api = env ^. portControlApiL + io $ (pAddPortRequest api) port + + release :: () -> RIO e () + release _ = do + env <- ask + let api = env ^. portControlApiL + io $ (pRemovePortRequest api) port + diff --git a/pkg/hs/urbit-king/package.yaml b/pkg/hs/urbit-king/package.yaml index aca5523962..8ad6ca2311 100644 --- a/pkg/hs/urbit-king/package.yaml +++ b/pkg/hs/urbit-king/package.yaml @@ -50,6 +50,7 @@ dependencies: - Glob - hashable - hashtables + - heap - http-client - http-client-tls - http-types From f8601d9a6aa066d45e6737b8048c5af42c680118 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 6 Aug 2020 20:22:46 +0200 Subject: [PATCH 139/933] vere: move u3_pico lifecycle functions into ward.c Now we free the struct _and its nouns_ in the same place, rather than transferring the nouns into lord.c, but still freeing the struct locally. This means the lord needs to explicitly retain the nouns in the u3_pico. --- pkg/urbit/include/vere/vere.h | 10 ++++++++++ pkg/urbit/vere/lord.c | 10 +++++----- pkg/urbit/vere/pier.c | 26 ++++++++++++------------- pkg/urbit/vere/ward.c | 36 +++++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 19 deletions(-) diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index fb89231b77..8e8b83bfcd 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -793,6 +793,16 @@ void u3_ovum_free(u3_ovum *egg_u); + /* u3_pico_init(): initialize a scry request struct + */ + u3_pico* + u3_pico_init(); + + /* u3_pico_free(): dispose a scry request struct + */ + void + u3_pico_free(u3_pico* pic_u); + /* u3_mcut_char(): measure/cut character. */ c3_w diff --git a/pkg/urbit/vere/lord.c b/pkg/urbit/vere/lord.c index f0616eead0..20302be534 100644 --- a/pkg/urbit/vere/lord.c +++ b/pkg/urbit/vere/lord.c @@ -815,7 +815,7 @@ u3_lord_peek_pico(u3_lord* god_u, wit_u->pek_u->ptr_v = pic_u->ptr_v; wit_u->pek_u->fun_f = pic_u->fun_f; wit_u->pek_u->now = u3_time_in_tv(&wit_u->tim_u); - wit_u->pek_u->gan = pic_u->gan; + wit_u->pek_u->gan = u3k(pic_u->gan); // construct the full scry path // @@ -823,7 +823,7 @@ u3_lord_peek_pico(u3_lord* god_u, default: c3_assert(0); case u3_pico_full: { - wit_u->pek_u->ful = pic_u->ful; + wit_u->pek_u->ful = u3k(pic_u->ful); } break; case u3_pico_mine: { @@ -831,7 +831,7 @@ u3_lord_peek_pico(u3_lord* god_u, // u3_pier* pir_u = god_u->cb_u.ptr_v; // XX do better u3_noun our = u3dc("scot", 'p', u3i_chubs(2, pir_u->who_d)); - wit_u->pek_u->ful = u3nt(pic_u->min_u.car_m, our, pic_u->min_u.pax); + wit_u->pek_u->ful = u3nt(pic_u->min_u.car_m, our, u3k(pic_u->min_u.pax)); } break; case u3_pico_last: { @@ -843,9 +843,9 @@ u3_lord_peek_pico(u3_lord* god_u, wit_u->pek_u->ful = u3nc(pic_u->las_u.car_m, u3nq(our, - pic_u->las_u.des, + u3k(pic_u->las_u.des), cas, - pic_u->las_u.pax)); + u3k(pic_u->las_u.pax))); } break; } diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index 5c68ac13d0..e99a4adfaf 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -26,13 +26,11 @@ #undef VERBOSE_PIER -/* _pier_peek_new(): add a new u3_pico to the peek queue +/* _pier_peek_plan(): add a u3_pico to the peek queue */ -static u3_pico* -_pier_peek_new(u3_pier* pir_u) +static void +_pier_peek_plan(u3_pier* pir_u, u3_pico* pic_u) { - u3_pico* pic_u = c3_calloc(sizeof(*pic_u)); - if (!pir_u->pec_u.ent_u) { c3_assert( !pir_u->pec_u.ext_u ); pir_u->pec_u.ent_u = pir_u->pec_u.ext_u = pic_u; @@ -42,7 +40,7 @@ _pier_peek_new(u3_pier* pir_u) pir_u->pec_u.ent_u = pic_u; } - return pic_u; + u3_pier_spin(pir_u); } /* _pier_peek_next(): pop u3_pico off of peek queue @@ -114,7 +112,7 @@ _pier_work_send(u3_work* wok_u) { len_w--; u3_lord_peek_pico(god_u, pic_u); - c3_free(pic_u); + u3_pico_free(pic_u); } } @@ -123,7 +121,7 @@ _pier_work_send(u3_work* wok_u) while ( len_w-- && (pic_u = _pier_peek_next(pir_u)) ) { u3_lord_peek_pico(god_u, pic_u); - c3_free(pic_u); + u3_pico_free(pic_u); } } } @@ -419,7 +417,7 @@ u3_pier_peek(u3_pier* pir_u, void* ptr_v, u3_peek_cb fun_f) { - u3_pico* pic_u = _pier_peek_new(pir_u); + u3_pico* pic_u = u3_pico_init(); pic_u->ptr_v = ptr_v; pic_u->fun_f = fun_f; @@ -428,7 +426,7 @@ u3_pier_peek(u3_pier* pir_u, pic_u->typ_e = u3_pico_full; pic_u->ful = ful; - u3_pier_spin(pir_u); + _pier_peek_plan(pir_u, pic_u); } /* u3_pier_peek_mine(): read namespace, injecting ship. @@ -441,7 +439,7 @@ u3_pier_peek_mine(u3_pier* pir_u, void* ptr_v, u3_peek_cb fun_f) { - u3_pico* pic_u = _pier_peek_new(pir_u); + u3_pico* pic_u = u3_pico_init(); pic_u->ptr_v = ptr_v; pic_u->fun_f = fun_f; @@ -451,7 +449,7 @@ u3_pier_peek_mine(u3_pier* pir_u, pic_u->min_u.car_m = car_m; pic_u->min_u.pax = pax; - u3_pier_spin(pir_u); + _pier_peek_plan(pir_u, pic_u); } /* u3_pier_peek_last(): read namespace, injecting ship and case. @@ -465,7 +463,7 @@ u3_pier_peek_last(u3_pier* pir_u, void* ptr_v, u3_peek_cb fun_f) { - u3_pico* pic_u = _pier_peek_new(pir_u); + u3_pico* pic_u = u3_pico_init(); pic_u->ptr_v = ptr_v; pic_u->fun_f = fun_f; @@ -476,7 +474,7 @@ u3_pier_peek_last(u3_pier* pir_u, pic_u->las_u.des = des; pic_u->las_u.pax = pax; - u3_pier_spin(pir_u); + _pier_peek_plan(pir_u, pic_u); } /* _pier_work_init(): begin processing new events diff --git a/pkg/urbit/vere/ward.c b/pkg/urbit/vere/ward.c index bb9b092129..7ff997deb5 100644 --- a/pkg/urbit/vere/ward.c +++ b/pkg/urbit/vere/ward.c @@ -168,6 +168,42 @@ u3_ovum_free(u3_ovum *egg_u) c3_free(egg_u); } +/* u3_pico_init(): initialize a scry request struct +*/ +u3_pico* +u3_pico_init() +{ + u3_pico* pic_u = c3_calloc(sizeof(*pic_u)); + return pic_u; +} + +/* u3_pico_free(): dispose a scry request struct +*/ +void +u3_pico_free(u3_pico* pic_u) +{ + u3z(pic_u->gan); + + switch ( pic_u->typ_e ) { + default: c3_assert(0); + + case u3_pico_full: { + u3z(pic_u->ful); + } break; + + case u3_pico_mine: { + u3z(pic_u->min_u.pax); + } break; + + case u3_pico_last: { + u3z(pic_u->las_u.des); + u3z(pic_u->las_u.pax); + } break; + } + + c3_free(pic_u); +} + /* u3_mcut_char(): measure/cut character. */ c3_w From 00eb249e550f03c7cfef4a9319f7da9a2a981794 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 6 Aug 2020 20:24:43 +0200 Subject: [PATCH 140/933] vere: rename u3_lord_peek_pico to u3_lord_peek --- pkg/urbit/include/vere/vere.h | 5 ++--- pkg/urbit/vere/lord.c | 5 ++--- pkg/urbit/vere/pier.c | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index 8e8b83bfcd..e84aa31106 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -1002,11 +1002,10 @@ void u3_lord_play(u3_lord* god_u, u3_info fon_u); - /* u3_lord_peek_pico(): read namespace, injecting what's missing. + /* u3_lord_peek(): read namespace, injecting what's missing. */ void - u3_lord_peek_pico(u3_lord* god_u, - u3_pico* pic_u); + u3_lord_peek(u3_lord* god_u, u3_pico* pic_u); /** Filesystem (new api). **/ diff --git a/pkg/urbit/vere/lord.c b/pkg/urbit/vere/lord.c index 20302be534..23ad0bca9d 100644 --- a/pkg/urbit/vere/lord.c +++ b/pkg/urbit/vere/lord.c @@ -803,11 +803,10 @@ _lord_writ_plan(u3_lord* god_u, u3_writ* wit_u) _lord_writ_send(god_u, wit_u); } -/* u3_lord_peek_pico(): read namespace, injecting what's missing. +/* u3_lord_peek(): read namespace, injecting what's missing. */ void -u3_lord_peek_pico(u3_lord* god_u, - u3_pico* pic_u) +u3_lord_peek(u3_lord* god_u, u3_pico* pic_u) { u3_writ* wit_u = _lord_writ_new(god_u); wit_u->typ_e = u3_writ_peek; diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index e99a4adfaf..19c09eeae8 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -111,7 +111,7 @@ _pier_work_send(u3_work* wok_u) if ( len_w && (pic_u = _pier_peek_next(pir_u)) ) { len_w--; - u3_lord_peek_pico(god_u, pic_u); + u3_lord_peek(god_u, pic_u); u3_pico_free(pic_u); } } @@ -120,7 +120,7 @@ _pier_work_send(u3_work* wok_u) // while ( len_w-- && (pic_u = _pier_peek_next(pir_u)) ) { - u3_lord_peek_pico(god_u, pic_u); + u3_lord_peek(god_u, pic_u); u3_pico_free(pic_u); } } From 34cfc9a6fcb54457c19b1d975fec9475ca778ae3 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 6 Aug 2020 20:33:10 +0200 Subject: [PATCH 141/933] vere: when scry crashes, produce fake result of ~ In the long term, we don't want to pretend we got "no result", and handle crashes by whatever behavior is appropriate. In the short term, we don't want to burden callsites with crash handling, so we punt on the problem by producing ~. --- pkg/urbit/vere/lord.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/urbit/vere/lord.c b/pkg/urbit/vere/lord.c index 23ad0bca9d..8634514e9b 100644 --- a/pkg/urbit/vere/lord.c +++ b/pkg/urbit/vere/lord.c @@ -349,6 +349,8 @@ _lord_plea_peek_bail(u3_lord* god_u, u3_peek* pek_u, u3_noun dud) { u3_pier_punt_goof("peek", dud); + pek_u->fun_f(pek_u->ptr_v, u3_nul); + u3z(pek_u->now); u3z(pek_u->gan); u3z(pek_u->ful); From 1691c984dd4e46e97228e62fab0218936a905915 Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Thu, 30 Jul 2020 15:47:38 -0700 Subject: [PATCH 142/933] king: ames: add stderr when sending before having turfs --- pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs index 1463898109..0a37898bbc 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs @@ -229,7 +229,7 @@ ames env who isFake enqueueEv stderr = (initialEvents, runAmes) NewtEfSend (_id, ()) dest (MkBytes bs) -> do atomically (readTVar aTurfs) >>= \case - Nothing -> pure () + Nothing -> stderr "ames: send before turfs" >> pure () Just turfs -> sendPacket drv mode dest bs sendPacket :: AmesDrv -> NetworkMode -> AmesDest -> ByteString -> RIO e () From 61c64584aad0320d834798d3323f3d974dc78c2f Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 6 Aug 2020 22:02:41 +0200 Subject: [PATCH 143/933] vere: don't crash the process on scry crash The fake result introduced in 34cfc9a6f isn't very useful if the process ends up crashing anyway... --- pkg/urbit/vere/lord.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/urbit/vere/lord.c b/pkg/urbit/vere/lord.c index 8634514e9b..3b3d806a09 100644 --- a/pkg/urbit/vere/lord.c +++ b/pkg/urbit/vere/lord.c @@ -355,8 +355,6 @@ _lord_plea_peek_bail(u3_lord* god_u, u3_peek* pek_u, u3_noun dud) u3z(pek_u->gan); u3z(pek_u->ful); c3_free(pek_u); - - _lord_bail(god_u); } /* _lord_plea_peek_done(): hear serf %peek %done From a3e33644a9a4ff8064319a5207a9c04d9fb1d535 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 6 Aug 2020 11:37:04 -0400 Subject: [PATCH 144/933] king: port forward ames traffic behind a NAT. Tested with a comet trying to receive traffic from a planet in the cloud. (h/t ~master-morzod) --- pkg/hs/natpmp-static/cbits/natpmp.h | 2 ++ pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs | 8 ++++-- pkg/hs/urbit-king/lib/Urbit/Vere/Ames/UDP.hs | 26 +++++++++++++++----- pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs | 24 +++++++++++++----- 4 files changed, 46 insertions(+), 14 deletions(-) diff --git a/pkg/hs/natpmp-static/cbits/natpmp.h b/pkg/hs/natpmp-static/cbits/natpmp.h index 7889d206fe..3f721b7b95 100644 --- a/pkg/hs/natpmp-static/cbits/natpmp.h +++ b/pkg/hs/natpmp-static/cbits/natpmp.h @@ -32,6 +32,8 @@ POSSIBILITY OF SUCH DAMAGE. /* NAT-PMP Port as defined by the NAT-PMP draft */ #define NATPMP_PORT (5351) +#define ENABLE_STRNATPMPERR + #include #if !defined(_MSC_VER) #include diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs index 1463898109..ebab5fe752 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs @@ -10,6 +10,7 @@ import Network.Socket hiding (recvFrom, sendTo) import Urbit.Arvo hiding (Fake) import Urbit.King.Config import Urbit.Vere.Pier.Types +import Urbit.Vere.Ports import Urbit.King.App (HasKingId(..), HasPierEnv(..)) import Urbit.Vere.Ames.DNS (NetworkMode(..), ResolvServ(..)) @@ -105,7 +106,10 @@ udpPort isFake who = do mPort <- view (networkConfigL . ncAmesPort) pure $ maybe (listenPort mode who) fromIntegral mPort -udpServ :: (HasLogFunc e, HasNetworkConfig e) => Bool -> Ship -> RIO e UdpServ +udpServ :: (HasLogFunc e, HasNetworkConfig e, HasPortControlApi e) + => Bool + -> Ship + -> RIO e UdpServ udpServ isFake who = do mode <- netMode isFake port <- udpPort isFake who @@ -170,7 +174,7 @@ ames' who isFake stderr = do -} ames :: forall e - . (HasLogFunc e, HasNetworkConfig e, HasKingId e) + . (HasLogFunc e, HasNetworkConfig e, HasPortControlApi e, HasKingId e) => e -> Ship -> Bool diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/UDP.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/UDP.hs index 47a9b24fbf..c140e940ee 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/UDP.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/UDP.hs @@ -33,6 +33,7 @@ module Urbit.Vere.Ames.UDP where import Urbit.Prelude +import Urbit.Vere.Ports import Network.Socket hiding (recvFrom, sendTo) @@ -151,7 +152,10 @@ fakeUdpServ = do Real UDP server. See module-level docs. -} realUdpServ - :: forall e . HasLogFunc e => PortNumber -> HostAddress -> RIO e UdpServ + :: forall e . (HasLogFunc e, HasPortControlApi e) + => PortNumber + -> HostAddress + -> RIO e UdpServ realUdpServ por hos = do logDebug $ displayShow ("AMES", "UDP", "Starting real UDP server.") @@ -197,11 +201,21 @@ realUdpServ por hos = do logWarn "AMES: UDP: Dropping outbound packet because queue is full." tOpen <- async $ forever $ do - sk <- forceBind por hos - atomically (writeTVar vSock (Just sk)) - broken <- atomically (takeTMVar vFail) - logWarn "AMES: UDP: Closing broken socket." - io (close broken) + sk <- forceBind por hos + sn <- io $ getSocketName sk + + let waitForRelease = do + atomically (writeTVar vSock (Just sk)) + broken <- atomically (takeTMVar vFail) + logWarn "AMES: UDP: Closing broken socket." + io (close broken) + + case sn of + (SockAddrInet boundPort _) -> + -- When we're on IPv4, maybe port forward at the NAT. + rwith (requestPortAccess $ fromIntegral boundPort) $ + \() -> waitForRelease + _ -> waitForRelease tSend <- async $ forever $ join $ atomically $ do (adr, byt) <- readTBQueue qSend diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs index 7a4cadb966..c7984a6835 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs @@ -1,7 +1,9 @@ -module Urbit.Vere.Ports where +module Urbit.Vere.Ports (HasPortControlApi(..), + PortControlApi(..), + buildInactivePorts, + buildNATPorts, + requestPortAccess) where --- (PortControlApi, --- buildInactivePorts) import Control.Monad.STM (check) import Urbit.Prelude import Network.NATPMP @@ -74,12 +76,14 @@ data PortThreadMsg -- scope. OTOH, NAT-PMP is all timeout based, and we want that timeout to be -- fairly short, such as 15 minutes, so the portThread needs to keep track of -- the time of the next port request. -portThread :: (HasLogFunc e) => TQueue PortThreadMsg -> RIO e () +portThread :: forall e. (HasLogFunc e) + => TQueue PortThreadMsg + -> RIO e () portThread q = do pmp <- io $ initNatPmp case pmp of Left err -> do - logError "error initializing NatPmp" + logError "ports: error initializing NAT-PMP. Falling back to null." loopErr q Right pmp -> loop pmp mempty where @@ -90,7 +94,7 @@ portThread q = do Nothing -> newTVarIO False Just (fireTime, _) -> do let timeTo = fireTime - now - let ms = round $ timeTo * 1000 + let ms = round $ timeTo * 1000000 registerDelay ms command <- atomically $ (Left <$> fini delay) <|> (Right <$> readTQueue q) @@ -109,6 +113,9 @@ portThread q = do -> RIO e () handlePTM pmp msg nextRenew = case msg of PTMInitialRequestOpen p notifyComplete -> do + logInfo $ + displayShow ("ports: sending initial request to NAT-PMP for port ", p) + -- TODO: Some error checking would be nice. io $ setPortMapping pmp PTUDP p p portLeaseLifetime let filteredPort = filterPort p nextRenew now <- io $ getPOSIXTime @@ -120,6 +127,9 @@ portThread q = do loop pmp withRenew PTMRequestOpen p -> do + logInfo $ + displayShow ("ports: sending renewing request to NAT-PMP for port ", + p) io $ setPortMapping pmp PTUDP p p portLeaseLifetime let filteredPort = filterPort p nextRenew now <- io $ getPOSIXTime @@ -128,6 +138,8 @@ portThread q = do loop pmp withRenew PTMRequestClose p -> do + logInfo $ + displayShow ("ports: releasing lease for ", p) io $ setPortMapping pmp PTUDP p p 0 let removed = filterPort p nextRenew loop pmp removed From c142184cd44dee2a84f59f4905e4290597ddc1ba Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 6 Aug 2020 23:47:35 +0200 Subject: [PATCH 145/933] vere: add 'ax' to motes.h --- pkg/urbit/include/c/motes.h | 1 + pkg/urbit/vere/io/ames.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/include/c/motes.h b/pkg/urbit/include/c/motes.h index 8f9f040136..40fcedc688 100644 --- a/pkg/urbit/include/c/motes.h +++ b/pkg/urbit/include/c/motes.h @@ -26,6 +26,7 @@ # define c3__at c3_s2('a','t') # define c3__atom c3_s4('a','t','o','m') # define c3__auth c3_s4('a','u','t','h') +# define c3__ax c3_s2('a','x') # define c3__axe c3_s3('a','x','e') # define c3__axil c3_s4('a','x','i','l') # define c3__axis c3_s4('a','x','i','s') diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 1cc69322ad..d11b910e68 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -823,7 +823,7 @@ _ames_recv_cb(uv_udp_t* wax_u, u3dc("scot", 'p', u3i_chubs(2, rec_d)), u3i_string("forward-lane"), u3_nul); - u3_pier_peek_last(sam_u->pir_u, u3_nul, c3_s2('a', 'x'), + u3_pier_peek_last(sam_u->pir_u, u3_nul, c3__ax, u3_nul, pax, pac_u, _ames_lane_scry_cb); } } @@ -988,7 +988,7 @@ _ames_io_talk(u3_auto* car_u) // scry the protocol version out of arvo // - u3_pier_peek_last(car_u->pir_u, u3_nul, c3_s2('a', 'x'), u3_nul, + u3_pier_peek_last(car_u->pir_u, u3_nul, c3__ax, u3_nul, u3nt(u3i_string("protocol"), u3i_string("version"), u3_nul), sam_u, _ames_prot_scry_cb); } From b4a72f316026b990a84d22d267e15c84e56db198 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 6 Aug 2020 23:56:05 +0200 Subject: [PATCH 146/933] vere: make note of litte-endianness dependency --- pkg/urbit/vere/io/ames.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index d11b910e68..4922832d5a 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -388,6 +388,8 @@ _ames_serialize_packet(u3_panc* pac_u, c3_o dop_o) | (hed_u->rac_y << 25) | (hed_u->enc_o << 27); + // XX assumes little-endian + // memcpy(pac_y, &hed_w, 4); pac = u3i_bytes(4 + sen_y + rec_y + bod_u->con_w, pac_y); From 96723b3de0525bb870ccb178114f18a7e1c5be00 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 7 Aug 2020 12:41:49 -0400 Subject: [PATCH 147/933] nat-pmp: Add readme talking about providence. --- pkg/hs/natpmp-static/README.txt | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 pkg/hs/natpmp-static/README.txt diff --git a/pkg/hs/natpmp-static/README.txt b/pkg/hs/natpmp-static/README.txt new file mode 100644 index 0000000000..87e6e25e36 --- /dev/null +++ b/pkg/hs/natpmp-static/README.txt @@ -0,0 +1,5 @@ +This is a vendored copy of libnatpmp-20150609, along with haskell bindings to +the library. Only the C code which was needed for these bindings was copied out +of the distribution. + +Original code: http://miniupnp.free.fr/libnatpmp.html From 6368aa2b023b4ccb0a7164148dbc8e2bac5bdc6d Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 7 Aug 2020 12:42:00 -0400 Subject: [PATCH 148/933] king: Turn NAT-PMP on by default, with a flag to disable. Also: error checking. --- pkg/hs/urbit-king/lib/Urbit/King/CLI.hs | 34 ++++------------- pkg/hs/urbit-king/lib/Urbit/King/Main.hs | 9 ++--- pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs | 45 +++++++++++++++-------- 3 files changed, 41 insertions(+), 47 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs index 8824a7c960..b2a7a903e1 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs @@ -13,15 +13,12 @@ import Options.Applicative.Help.Pretty import Data.Word (Word16) import System.Environment (getProgName) -import Data.IP -import Network.Socket - -------------------------------------------------------------------------------- data KingOpts = KingOpts { koSharedHttpPort :: Maybe Word16 , koSharedHttpsPort :: Maybe Word16 - , koIPSource :: Maybe IPSource + , koUseNATPMP :: Bool } deriving (Show) @@ -59,11 +56,6 @@ data PillSource | PillSourceURL String deriving (Show) -data IPSource - = IPSourceManual HostAddress - | IPSourceNAT - deriving (Show) - data New = New { nPillSource :: PillSource , nPierPath :: Maybe FilePath -- Derived from ship name if not specified. @@ -204,22 +196,12 @@ pillFromURL = PillSourceURL <$> strOption <> value defaultPillURL <> help "URL to pill file") -ipFromNAT :: Parser IPSource -ipFromNAT = flag' IPSourceNAT - ( long "ip-from-nat" - <> help "Try to fetch the local IP from the NAT gateway") - -ipReader :: ReadM HostAddress -ipReader = eitherReader $ \arg -> - case readMay arg :: Maybe IPv4 of - Nothing -> Left ("Cannot parse ipv4 address: " ++ arg) - Just ipv4 -> Right $ toHostAddress ipv4 - -ipFromManual :: Parser IPSource -ipFromManual = IPSourceManual <$> option ipReader - ( long "ip-manual" - <> metavar "IPv4" - <> help "Manually specify the external IP") +enableNAT :: Parser Bool +enableNAT = (flag' False + ( long "no-port-forwarding" + <> help "Disable trying to ask the router to forward ames ports")) + <|> + (pure True) pierPath :: Parser FilePath pierPath = strArgument (metavar "PIER" <> help "Path to pier") @@ -373,7 +355,7 @@ runOneShip = (,,) <$> fmap Run pierPath <*> opts <*> df kingOpts :: Parser KingOpts kingOpts = do - koIPSource <- optional (ipFromManual <|> ipFromNAT) + koUseNATPMP <- enableNAT koSharedHttpPort <- optional diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs index df3c4257d0..a85d604c4f 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs @@ -590,10 +590,9 @@ runShip (CLI.Run pierPath) opts daemon = do mStart -buildPortHandler :: (HasLogFunc e) => Maybe CLI.IPSource -> RIO e PortControlApi -buildPortHandler Nothing = buildInactivePorts -buildPortHandler (Just CLI.IPSourceNAT) = buildNATPorts -buildPortHandler (Just (CLI.IPSourceManual _)) = error "wut do" +buildPortHandler :: (HasLogFunc e) => Bool -> RIO e PortControlApi +buildPortHandler False = buildInactivePorts +buildPortHandler True = buildNATPorts startBrowser :: HasLogFunc e => FilePath -> RIO e () startBrowser pierPath = runRAcquire $ do @@ -756,7 +755,7 @@ runShips CLI.KingOpts {..} ships = do multi <- multiEyre meConf - ports <- buildPortHandler koIPSource + ports <- buildPortHandler koUseNATPMP runRunningEnv multi ports (go ships) where diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs index c7984a6835..0a352d716a 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs @@ -115,27 +115,40 @@ portThread q = do PTMInitialRequestOpen p notifyComplete -> do logInfo $ displayShow ("ports: sending initial request to NAT-PMP for port ", p) - -- TODO: Some error checking would be nice. - io $ setPortMapping pmp PTUDP p p portLeaseLifetime - let filteredPort = filterPort p nextRenew - now <- io $ getPOSIXTime - let repeatMsg = PTMRequestOpen p - let withRenew = - insert (now + (fromIntegral portRenewalTime), repeatMsg) - filteredPort - atomically notifyComplete - loop pmp withRenew + ret <- io $ setPortMapping pmp PTUDP p p portLeaseLifetime + case ret of + Left err -> do + logError $ + displayShow ("ports: failed to request NAT-PMP for port ", p, + ":", err, ", disabling NAT-PMP") + loopErr q + Right _ -> do + let filteredPort = filterPort p nextRenew + now <- io $ getPOSIXTime + let repeatMsg = PTMRequestOpen p + let withRenew = + insert (now + (fromIntegral portRenewalTime), repeatMsg) + filteredPort + atomically notifyComplete + loop pmp withRenew PTMRequestOpen p -> do logInfo $ displayShow ("ports: sending renewing request to NAT-PMP for port ", p) - io $ setPortMapping pmp PTUDP p p portLeaseLifetime - let filteredPort = filterPort p nextRenew - now <- io $ getPOSIXTime - let withRenew = - insert (now + (fromIntegral portRenewalTime), msg) filteredPort - loop pmp withRenew + ret <- io $ setPortMapping pmp PTUDP p p portLeaseLifetime + case ret of + Left err -> do + logError $ + displayShow ("ports: failed to request NAT-PMP for port ", p, + ":", err, ", disabling NAT-PMP") + loopErr q + Right _ -> do + let filteredPort = filterPort p nextRenew + now <- io $ getPOSIXTime + let withRenew = + insert (now + (fromIntegral portRenewalTime), msg) filteredPort + loop pmp withRenew PTMRequestClose p -> do logInfo $ From 149565cd97f46860a80d3bfb6a2cbc7978024426 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 7 Aug 2020 13:04:57 -0400 Subject: [PATCH 149/933] king: get tests passing after nat-pmp changes --- pkg/hs/urbit-king/lib/Urbit/King/Main.hs | 4 +- pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs | 4 +- pkg/hs/urbit-king/test/AmesTests.hs | 51 +++++++++++++---------- 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs index a85d604c4f..9ea53916c8 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs @@ -475,7 +475,7 @@ newShip CLI.New{..} opts = do -- TODO: We hit the same problem as above: we need the running options to -- determine how to configure the ports - ports <- buildInactivePorts + let ports = buildInactivePorts -- here we are with a king env, and we now need a multi env. runRunningEnv multi ports go @@ -591,7 +591,7 @@ runShip (CLI.Run pierPath) opts daemon = do buildPortHandler :: (HasLogFunc e) => Bool -> RIO e PortControlApi -buildPortHandler False = buildInactivePorts +buildPortHandler False = pure $ buildInactivePorts buildPortHandler True = buildNATPorts startBrowser :: HasLogFunc e => FilePath -> RIO e () diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs index 0a352d716a..fd8ab1a633 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs @@ -23,8 +23,8 @@ data PortControlApi = PortControlApi } -- Builds a Ports struct which does nothing when called. -buildInactivePorts :: RIO e PortControlApi -buildInactivePorts = pure $ PortControlApi noop noop +buildInactivePorts :: PortControlApi +buildInactivePorts = PortControlApi noop noop where noop x = pure () diff --git a/pkg/hs/urbit-king/test/AmesTests.hs b/pkg/hs/urbit-king/test/AmesTests.hs index 6be3e5c8c9..6356a7148c 100644 --- a/pkg/hs/urbit-king/test/AmesTests.hs +++ b/pkg/hs/urbit-king/test/AmesTests.hs @@ -15,6 +15,7 @@ import Urbit.Noun.Time import Urbit.Prelude import Urbit.Vere.Ames import Urbit.Vere.Pier.Types +import Urbit.Vere.Ports import Control.Concurrent (runInBoundThread) import Data.LargeWord (LargeKey(..)) @@ -27,7 +28,8 @@ import qualified Urbit.EventLog.LMDB as Log -------------------------------------------------------------------------------- -type HasAmes e = (HasLogFunc e, HasNetworkConfig e, HasKingId e) +type HasAmes e = (HasLogFunc e, HasNetworkConfig e, HasKingId e, + HasPortControlApi e) -- Utils ----------------------------------------------------------------------- @@ -41,9 +43,10 @@ sendEf :: Galaxy -> Wen -> Bytes -> NewtEf sendEf g w bs = NewtEfSend (0, ()) (EachYes g) bs data NetworkTestApp = NetworkTestApp - { _ntaLogFunc :: !LogFunc - , _ntaNetworkConfig :: !NetworkConfig - , _ntaKingId :: !Word16 + { _ntaLogFunc :: !LogFunc + , _ntaNetworkConfig :: !NetworkConfig + , _ntaPortControlApi :: PortControlApi + , _ntaKingId :: !Word16 } makeLenses ''NetworkTestApp @@ -57,20 +60,25 @@ instance HasNetworkConfig NetworkTestApp where instance HasKingId NetworkTestApp where kingIdL = ntaKingId +instance HasPortControlApi NetworkTestApp where + portControlApiL = ntaPortControlApi + runNetworkApp :: RIO NetworkTestApp a -> IO a -runNetworkApp = runRIO NetworkTestApp - { _ntaLogFunc = mkLogFunc (\_ _ _ _ -> pure ()) - , _ntaKingId = 34 - , _ntaNetworkConfig = NetworkConfig { _ncNetMode = NMNormal - , _ncAmesPort = Nothing - , _ncNoAmes = False - , _ncNoHttp = False - , _ncNoHttps = False - , _ncHttpPort = Nothing - , _ncHttpsPort = Nothing - , _ncLocalPort = Nothing - } - } +runNetworkApp = + runRIO NetworkTestApp + { _ntaLogFunc = mkLogFunc (\_ _ _ _ -> pure ()) + , _ntaKingId = 34 + , _ntaPortControlApi = buildInactivePorts + , _ntaNetworkConfig = NetworkConfig { _ncNetMode = NMNormal + , _ncAmesPort = Nothing + , _ncNoAmes = False + , _ncNoHttp = False + , _ncNoHttps = False + , _ncHttpPort = Nothing + , _ncHttpsPort = Nothing + , _ncLocalPort = Nothing + } + } runGala :: forall e @@ -110,8 +118,7 @@ sendThread cb (to, val) = void $ mkRAcquire start cancel zodSelfMsg :: Property zodSelfMsg = forAll arbitrary (ioProperty . runNetworkApp . runTest) where - runTest - :: (HasLogFunc e, HasNetworkConfig e, HasKingId e) => Bytes -> RIO e Bool + runTest :: (HasAmes e) => Bytes -> RIO e Bool runTest val = runRAcquire $ do env <- ask (zodQ, zod) <- runGala 0 @@ -121,15 +128,13 @@ zodSelfMsg = forAll arbitrary (ioProperty . runNetworkApp . runTest) twoTalk :: Property twoTalk = forAll arbitrary (ioProperty . runNetworkApp . runTest) where - runTest :: (HasLogFunc e, HasNetworkConfig e, HasKingId e) - => (Word8, Word8, Bytes) -> RIO e Bool + runTest :: (HasAmes e) => (Word8, Word8, Bytes) -> RIO e Bool runTest (aliceShip, bobShip, val) = if aliceShip == bobShip then pure True else go aliceShip bobShip val - go :: (HasLogFunc e, HasNetworkConfig e, HasKingId e) - => Word8 -> Word8 -> Bytes -> RIO e Bool + go :: (HasAmes e) => Word8 -> Word8 -> Bytes -> RIO e Bool go aliceShip bobShip val = runRAcquire $ do (aliceQ, alice) <- runGala aliceShip (bobQ, bob) <- runGala bobShip From 4c4712f4e8e6f7cdb250742b2093eb333dc3c9d4 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 7 Aug 2020 13:18:16 -0400 Subject: [PATCH 150/933] king: fix dawn to use the wrapped ethereum server. --- pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs index ae79088da3..9091539a6d 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs @@ -18,6 +18,8 @@ import Network.Ethereum.Api.Types hiding (blockNumber) import Network.Ethereum.Web3 import Network.HTTP.Client.TLS +import Data.Solidity.Prim.Address (fromHexString) + import qualified Crypto.Hash.SHA256 as SHA256 import qualified Crypto.Hash.SHA512 as SHA512 import qualified Crypto.Sign.Ed25519 as Ed @@ -25,14 +27,13 @@ import qualified Data.Binary as B import qualified Data.ByteArray as BA import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as C -import qualified Network.Ethereum.Ens as Ens +-- import qualified Network.Ethereum.Ens as Ens import qualified Network.HTTP.Client as C import qualified Urbit.Azimuth as AZ import qualified Urbit.Ob as Ob -- During boot, use the infura provider -provider = HttpProvider - "https://mainnet.infura.io/v3/196a7f37c7d54211b4a07904ec73ad87" +provider = HttpProvider "http://eth-mainnet.urbit.org:8545" -- Conversion Utilities -------------------------------------------------------- @@ -224,8 +225,16 @@ dawnVent dSeed@(Seed ship life ring oaf) = do block <- blockNumber putStrLn ("boot: ethereum block #" ++ tshow block) - putStrLn "boot: retrieving azimuth contract" - azimuth <- withAccount () $ Ens.resolve "azimuth.eth" + -- TODO: Eventually look up the contract from ENS. Right now, our infura + -- node is filtering everything except for a very small set of contracts, + -- so just hard code the address. + -- + -- putStrLn "boot: retrieving azimuth contract" + -- azimuth <- withAccount () $ Ens.resolve "azimuth.eth" + let azimuthAddr = "0x223c067f8cf28ae173ee5cafea60ca44c335fecb" + let azimuth = case fromHexString azimuthAddr of + Left _ -> error "Impossible" + Right x -> x immediateSponsor <- validateShipAndGetImmediateSponsor block azimuth dSeed dSponsor <- getSponsorshipChain block azimuth immediateSponsor From 556d92107a3438aecf8845070e82a1c7660fc9bf Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Sun, 9 Aug 2020 22:12:44 -0700 Subject: [PATCH 151/933] king: eyre: add missing printouts with ports --- pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs | 18 +++++++++++++----- pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs index 2aeb33f630..faf0232077 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs @@ -176,8 +176,9 @@ startServ -> Bool -> HttpServerConf -> (EvErr -> STM ()) + -> (Text -> RIO e ()) -> RIO e Serv -startServ multi who isFake conf plan = do +startServ multi who isFake conf plan stderr = do logDebug (displayShow ("EYRE", "startServ")) let vLive = meaLive multi @@ -270,6 +271,10 @@ startServ multi who isFake conf plan = do fil = pierPath <> "/.http.ports" logDebug $ displayShow ("EYRE", "All Servers Started.", srvId, por, fil) + for secPor $ \p -> + stderr ("http: secure web interface live on https://localhost:" <> tshow p) + stderr ("http: web interface live on http://localhost:" <> tshow insPor) + stderr ("http: loopback live on http://localhost:" <> tshow lopPor) pure (Serv srvId conf lop ins mSec por fil vLive) @@ -285,12 +290,14 @@ eyre' => MultiEyreApi -> Ship -> Bool + -> (Text -> RIO e ()) -> RIO e ([Ev], RAcquire e (DriverApi HttpServerEf)) -eyre' multi who isFake = do +eyre' multi who isFake stderr = do ventQ :: TQueue EvErr <- newTQueueIO env <- ask - let (bornEvs, startDriver) = eyre env multi who (writeTQueue ventQ) isFake + let (bornEvs, startDriver) = + eyre env multi who (writeTQueue ventQ) isFake stderr let runDriver = do diOnEffect <- startDriver @@ -319,8 +326,9 @@ eyre -> Ship -> (EvErr -> STM ()) -> Bool + -> (Text -> RIO e ()) -> ([Ev], RAcquire e (HttpServerEf -> IO ())) -eyre env multi who plan isFake = (initialEvents, runHttpServer) +eyre env multi who plan isFake stderr = (initialEvents, runHttpServer) where king = fromIntegral (env ^. kingIdL) @@ -343,7 +351,7 @@ eyre env multi who plan isFake = (initialEvents, runHttpServer) restart :: Drv -> HttpServerConf -> RIO e Serv restart (Drv var) conf = do logDebug "Restarting http server" - let startAct = startServ multi who isFake conf plan + let startAct = startServ multi who isFake conf plan stderr res <- fromEither =<< restartService var startAct kill logDebug "Done restating http server" pure res diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs index 78b6d9e5da..b8c6d5c45d 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs @@ -424,7 +424,7 @@ drivers env multi who isFake plan termSys stderr serfSIGINT = do (behnBorn, runBehn) <- rio Behn.behn' (termBorn, runTerm) <- rio (Term.term' termSys serfSIGINT) (amesBorn, runAmes) <- rio (Ames.ames' who isFake stderr) - (httpBorn, runEyre) <- rio (Eyre.eyre' multi who isFake) + (httpBorn, runEyre) <- rio (Eyre.eyre' multi who isFake stderr) (clayBorn, runClay) <- rio Clay.clay' (irisBorn, runIris) <- rio Iris.client' From 4d8c6ad09a3b8d21f2f2c4e154331600c84d4a06 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 10 Aug 2020 13:02:13 -0400 Subject: [PATCH 152/933] nat-pmp: improve error and diagnostic messages --- pkg/hs/urbit-king/lib/Urbit/King/Main.hs | 6 ++- pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs | 65 ++++++++++++++++++----- 2 files changed, 58 insertions(+), 13 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs index 9ea53916c8..c178bbed84 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs @@ -92,6 +92,7 @@ import Control.Concurrent (myThreadId) import Control.Exception (AsyncException(UserInterrupt)) import Control.Lens ((&)) import System.Process (system) +import System.IO (hPutStrLn) import Text.Show.Pretty (pPrint) import Urbit.Noun.Conversions (cordToUW) import Urbit.Noun.Time (Wen) @@ -592,7 +593,10 @@ runShip (CLI.Run pierPath) opts daemon = do buildPortHandler :: (HasLogFunc e) => Bool -> RIO e PortControlApi buildPortHandler False = pure $ buildInactivePorts -buildPortHandler True = buildNATPorts +-- TODO: Figure out what to do about logging here. The "port: " messages are +-- the sort of thing that should be put on the muxed terminal log, but we don't +-- have that at this layer. +buildPortHandler True = buildNATPorts (io . hPutStrLn stderr . unpack) startBrowser :: HasLogFunc e => FilePath -> RIO e () startBrowser pierPath = runRAcquire $ do diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs index fd8ab1a633..dcec5f3c7e 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs @@ -9,6 +9,7 @@ import Urbit.Prelude import Network.NATPMP import Data.Time.Clock.POSIX import Data.Heap +import Network.Socket -- This module deals with ports and port requests. When a component wants to -- ensure that it is externally reachable, possibly from outside a NAT, it @@ -30,10 +31,12 @@ buildInactivePorts = PortControlApi noop noop -- Builds a Ports struct which tries to hole-punch by talking to the NAT -- gateway over NAT-PMP. -buildNATPorts :: (HasLogFunc e) => RIO e PortControlApi -buildNATPorts = do +buildNATPorts :: (HasLogFunc e) + => (Text -> RIO e ()) + -> RIO e PortControlApi +buildNATPorts stderr = do q <- newTQueueIO - async $ portThread q + async $ portThread q stderr pure $ PortControlApi (addRequest q) (removeRequest q) where addRequest :: TQueue PortThreadMsg -> Word16 -> IO () @@ -78,15 +81,39 @@ data PortThreadMsg -- the time of the next port request. portThread :: forall e. (HasLogFunc e) => TQueue PortThreadMsg + -> (Text -> RIO e ()) -> RIO e () -portThread q = do +portThread q stderr = do pmp <- io $ initNatPmp + --pmp <- pure $ Left ErrNoGatewaySupport case pmp of Left err -> do - logError "ports: error initializing NAT-PMP. Falling back to null." - loopErr q - Right pmp -> loop pmp mempty + ip <- likelyIPAddress + case ip of + Just (192, 168, c, d) -> do + stderr $ "port: you appear to be behind a router since your ip " ++ + "is 192.168." ++ (tshow c) ++ "." ++ (tshow d) ++ ", but " ++ + "we could not request port forwarding (NAT-PMP error: " ++ + (tshow err) ++ ")" + stderr $ "port: urbit performance will be degregaded unless you " ++ + "manually forward your ames port." + loopErr q + _ -> do + stderr $ "port: couldn't find router; assuming on public internet" + loopErr q + Right pmp -> foundRouter pmp where + foundRouter :: NatPmpHandle -> RIO e () + foundRouter pmp = do + pubAddr <- io $ getPublicAddress pmp + case pubAddr of + Left _ -> pure () + Right addr -> do + let (a, b, c, d) = hostAddressToTuple addr + stderr $ "port: router reports that our public IP is " ++ (tshow a) ++ + "." ++ (tshow b) ++ "." ++ (tshow c) ++ "." ++ (tshow d) + loop pmp mempty + loop :: NatPmpHandle -> MinPrioHeap POSIXTime PortThreadMsg -> RIO e () loop pmp nextRenew = forever $ do now <- io $ getPOSIXTime @@ -114,12 +141,12 @@ portThread q = do handlePTM pmp msg nextRenew = case msg of PTMInitialRequestOpen p notifyComplete -> do logInfo $ - displayShow ("ports: sending initial request to NAT-PMP for port ", p) + displayShow ("port: sending initial request to NAT-PMP for port ", p) ret <- io $ setPortMapping pmp PTUDP p p portLeaseLifetime case ret of Left err -> do logError $ - displayShow ("ports: failed to request NAT-PMP for port ", p, + displayShow ("port: failed to request NAT-PMP for port ", p, ":", err, ", disabling NAT-PMP") loopErr q Right _ -> do @@ -134,13 +161,13 @@ portThread q = do PTMRequestOpen p -> do logInfo $ - displayShow ("ports: sending renewing request to NAT-PMP for port ", + displayShow ("port: sending renewing request to NAT-PMP for port ", p) ret <- io $ setPortMapping pmp PTUDP p p portLeaseLifetime case ret of Left err -> do logError $ - displayShow ("ports: failed to request NAT-PMP for port ", p, + displayShow ("port: failed to request NAT-PMP for port ", p, ":", err, ", disabling NAT-PMP") loopErr q Right _ -> do @@ -152,7 +179,7 @@ portThread q = do PTMRequestClose p -> do logInfo $ - displayShow ("ports: releasing lease for ", p) + displayShow ("port: releasing lease for ", p) io $ setPortMapping pmp PTUDP p p 0 let removed = filterPort p nextRenew loop pmp removed @@ -179,6 +206,20 @@ portThread q = do PTMRequestOpen _ -> pure () PTMRequestClose _ -> pure () +-- When we were unable to connect to a router, get the ip address on the +-- default ipv4 interface to check if it +likelyIPAddress :: RIO e (Maybe (Word8, Word8, Word8, Word8)) +likelyIPAddress = do + -- Try opening a socket to 1.1.1.1 to get our own IP address. Since UDP is + -- stateless and we aren't sending anything, we aren't actually contacting + -- them in any way. + sock <- io $ socket AF_INET Datagram 0 + io $ connect sock (SockAddrInet 53 (tupleToHostAddress (8, 8, 8, 8))) + sockAddr <- io $ getSocketName sock + case sockAddr of + SockAddrInet _ addr -> pure $ Just $ hostAddressToTuple addr + _ -> pure $ Nothing + -- Acquire a port for the duration of the RAcquire. requestPortAccess :: forall e. (HasPortControlApi e) => Word16 -> RAcquire e () requestPortAccess port = do From 2e66ae10ec825aea914e8bb7b4517974570647ec Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 10 Aug 2020 13:15:03 -0400 Subject: [PATCH 153/933] natpmp: use MonadIO in the bindings to remove unsightly "io $" --- .../natpmp-static/hsrc_lib/Network/NATPMP.hsc | 34 +++++++++++-------- pkg/hs/natpmp-static/natpmp-static.cabal | 1 + pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs | 10 +++--- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/pkg/hs/natpmp-static/hsrc_lib/Network/NATPMP.hsc b/pkg/hs/natpmp-static/hsrc_lib/Network/NATPMP.hsc index c48dd2a234..74a947a1e9 100644 --- a/pkg/hs/natpmp-static/hsrc_lib/Network/NATPMP.hsc +++ b/pkg/hs/natpmp-static/hsrc_lib/Network/NATPMP.hsc @@ -12,6 +12,8 @@ module Network.NATPMP (Error(..), getPublicAddress, setPortMapping) where +import Control.Monad.IO.Unlift (MonadIO(..), MonadUnliftIO, withRunInIO) + #include #include @@ -210,31 +212,34 @@ instance Enum Error where toEnum unmatched = error ("Error.toEnum: Cannot match " ++ show unmatched) -initNatPmp :: IO (Either Error NatPmpHandle) +initNatPmp :: (MonadIO m) + => m (Either Error NatPmpHandle) initNatPmp = do - natpmp <- mallocBytes #{size natpmp_t} - ret <- _init_nat_pmp natpmp 0 0 + natpmp <- liftIO $ mallocBytes #{size natpmp_t} + ret <- liftIO $ _init_nat_pmp natpmp 0 0 case ret of 0 -> pure $ Right natpmp _ -> do - free natpmp + liftIO $ free natpmp pure $ Left $ intToEnum ret -closeNatPmp :: NatPmpHandle -> IO (Either Error ()) +closeNatPmp :: (MonadIO m) + => NatPmpHandle -> m (Either Error ()) closeNatPmp handle = do - ret <- _close_nat_pmp handle - free handle + ret <- liftIO $ _close_nat_pmp handle + liftIO $ free handle case ret of 0 -> pure $ Right () _ -> pure $ Left $ intToEnum ret -- Public interface for getting the public IPv4 address -getPublicAddress :: NatPmpHandle -> IO (Either Error HostAddress) +getPublicAddress :: (MonadIO m) + => NatPmpHandle -> m (Either Error HostAddress) getPublicAddress natpmp = do - sendRetcode <- sendPublicAddressRequest natpmp + sendRetcode <- liftIO $ sendPublicAddressRequest natpmp case sendRetcode of - 2 -> alloca $ \(pResponse :: NatPmpResponseHandle) -> do + 2 -> liftIO $ alloca $ \(pResponse :: NatPmpResponseHandle) -> do respRetcode <- readNatResponseSynchronously natpmp pResponse case respRetcode of 0 -> peek pResponse >>= \case @@ -244,17 +249,18 @@ getPublicAddress natpmp = do _ -> pure $ Left $ intToEnum sendRetcode -setPortMapping :: NatPmpHandle -> ProtocolType -> Word16 -> Word16 -> Word32 - -> IO (Either Error ()) +setPortMapping :: (MonadIO m) + => NatPmpHandle -> ProtocolType -> Word16 -> Word16 -> Word32 + -> m (Either Error ()) setPortMapping natpmp protocol privatePort publicPort lifetime = do let protocolNum = fromEnum protocol sendResp <- - sendNewPortMappingRequest natpmp + liftIO $ sendNewPortMappingRequest natpmp (fromIntegral protocolNum) (CUShort privatePort) (CUShort publicPort) (CUInt lifetime) case sendResp of - 12 -> alloca $ \(pResponse :: NatPmpResponseHandle) -> do + 12 -> liftIO $ alloca $ \(pResponse :: NatPmpResponseHandle) -> do respRetcode <- readNatResponseSynchronously natpmp pResponse case respRetcode of 0 -> peek pResponse >>= \case diff --git a/pkg/hs/natpmp-static/natpmp-static.cabal b/pkg/hs/natpmp-static/natpmp-static.cabal index 2f8dfaadbc..5c0baf5072 100644 --- a/pkg/hs/natpmp-static/natpmp-static.cabal +++ b/pkg/hs/natpmp-static/natpmp-static.cabal @@ -32,6 +32,7 @@ library default-language: Haskell2010 build-depends: base , network + , unliftio-core build-tools: hsc2hs Include-dirs: cbits diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs index dcec5f3c7e..046bdb138b 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs @@ -84,7 +84,7 @@ portThread :: forall e. (HasLogFunc e) -> (Text -> RIO e ()) -> RIO e () portThread q stderr = do - pmp <- io $ initNatPmp + pmp <- initNatPmp --pmp <- pure $ Left ErrNoGatewaySupport case pmp of Left err -> do @@ -105,7 +105,7 @@ portThread q stderr = do where foundRouter :: NatPmpHandle -> RIO e () foundRouter pmp = do - pubAddr <- io $ getPublicAddress pmp + pubAddr <- getPublicAddress pmp case pubAddr of Left _ -> pure () Right addr -> do @@ -142,7 +142,7 @@ portThread q stderr = do PTMInitialRequestOpen p notifyComplete -> do logInfo $ displayShow ("port: sending initial request to NAT-PMP for port ", p) - ret <- io $ setPortMapping pmp PTUDP p p portLeaseLifetime + ret <- setPortMapping pmp PTUDP p p portLeaseLifetime case ret of Left err -> do logError $ @@ -163,7 +163,7 @@ portThread q stderr = do logInfo $ displayShow ("port: sending renewing request to NAT-PMP for port ", p) - ret <- io $ setPortMapping pmp PTUDP p p portLeaseLifetime + ret <- setPortMapping pmp PTUDP p p portLeaseLifetime case ret of Left err -> do logError $ @@ -180,7 +180,7 @@ portThread q stderr = do PTMRequestClose p -> do logInfo $ displayShow ("port: releasing lease for ", p) - io $ setPortMapping pmp PTUDP p p 0 + setPortMapping pmp PTUDP p p 0 let removed = filterPort p nextRenew loop pmp removed From d4d99835b222c15bbcffe2e66f489dc65b5c9e45 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 10 Aug 2020 14:55:08 -0400 Subject: [PATCH 154/933] natpmp: aesthetic cleanups --- .../natpmp-static/hsrc_lib/Network/NATPMP.hsc | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/pkg/hs/natpmp-static/hsrc_lib/Network/NATPMP.hsc b/pkg/hs/natpmp-static/hsrc_lib/Network/NATPMP.hsc index 74a947a1e9..4f7cf387dd 100644 --- a/pkg/hs/natpmp-static/hsrc_lib/Network/NATPMP.hsc +++ b/pkg/hs/natpmp-static/hsrc_lib/Network/NATPMP.hsc @@ -12,8 +12,6 @@ module Network.NATPMP (Error(..), getPublicAddress, setPortMapping) where -import Control.Monad.IO.Unlift (MonadIO(..), MonadUnliftIO, withRunInIO) - #include #include @@ -23,9 +21,9 @@ import Control.Monad.IO.Unlift (MonadIO(..), MonadUnliftIO, withRunInIO) import Prelude import Foreign import Foreign.C - import Network.Socket +import Control.Monad.IO.Unlift (MonadIO(..), MonadUnliftIO, withRunInIO) -- Opaque type for the internals of nat pmp data NatPmpStruct @@ -33,9 +31,6 @@ type NatPmpHandle = Ptr NatPmpStruct -- The response type, in its internal form. This struct is a C tagged union -- with additional data, but we need to read and write from its C form. --- --- TODO: What's easier? Exposing the internal C sum type here using Storable, --- or manual translation? data NatPmpResponse = NatPmpResponsePublicAddress HostAddress | NatPmpResponseUDPPortMapping Word16 Word16 Word32 @@ -76,8 +71,6 @@ foreign import ccall unsafe "natpmp.h sendnewportmappingrequest" sendNewPortMapp foreign import ccall unsafe "binding.h readNatResponseSynchronously" readNatResponseSynchronously :: NatPmpHandle -> NatPmpResponseHandle -> IO CInt ---foreign import ccall unsafe "binding.h reatNatResponseSynchronously" - -- Give the type system some help _peekCUInt :: Ptr CUInt -> IO CUInt _peekCUInt = peek @@ -88,9 +81,6 @@ uintToEnum = toEnum . fromIntegral intToEnum :: Enum e => CInt -> e intToEnum = toEnum . fromIntegral --- intFromEnum :: Enum e => e -> CInt --- intFromEnum = fromIntegral . fromEnum - -- Fetches the default gateway as an ipv4 address getDefaultGateway :: IO (Maybe HostAddress) @@ -101,8 +91,6 @@ getDefaultGateway = 0 -> (Just . fromIntegral) <$> _peekCUInt pReturnAddr _ -> pure Nothing --- TODO: Unsure about how to actually bind this library together. So RespType --- is an enum which is just the integer in a low level data RespType = RTPublicAddress @@ -120,6 +108,7 @@ instance Enum RespType where toEnum 2 = RTTCPPortMapping toEnum unmatched = error ("RespType.toEnum: Cannot match " ++ show unmatched) + data ProtocolType = PTUDP | PTTCP @@ -134,7 +123,6 @@ instance Enum ProtocolType where toEnum x = error ("ProtocolType.toEnum: Cannot match " ++ show x) - data Error = ErrInvalidArgs | ErrSocketError @@ -223,6 +211,7 @@ initNatPmp = do liftIO $ free natpmp pure $ Left $ intToEnum ret + closeNatPmp :: (MonadIO m) => NatPmpHandle -> m (Either Error ()) closeNatPmp handle = do From c1398c1b4ebc2392fa27291fcc667f16667a4e9a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 10 Aug 2020 12:44:52 -0700 Subject: [PATCH 155/933] ur: adds atom bloq measurement in ur_met() --- pkg/urbit/include/ur/hashcons.h | 7 ++++ pkg/urbit/noun/urth.c | 2 +- pkg/urbit/ur/hashcons.c | 74 +++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index adf889a469..7511f941d7 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -20,14 +20,21 @@ typedef uint8_t ur_bool_t; # error "port me" #endif +#define ur_lz8(a) ( ur_lz32(a) - 24 ) + #define ur_mask_3(a) (a & 0x7) #define ur_mask_8(a) (a & 0xff) #define ur_mask_31(a) (a & 0x7fffffff) #define ur_mask_62(a) (a & 0x3fffffffffffffffULL) +#define ur_met0_8(a) ( (a) ? 8 - ur_lz8(a) : 0 ) #define ur_met0_32(a) ( (a) ? 32 - ur_lz32(a) : 0 ) #define ur_met0_64(a) ( (a) ? 64 - ur_lz64(a) : 0 ) +#define ur_met3_8(a) \ + ({ uint8_t _a = ur_met0_8(a); \ + ( (_a >> 3) + !!ur_mask_3(_a) ); }) \ + #define ur_met3_32(a) \ ({ uint8_t _a = ur_met0_32(a); \ ( (_a >> 3) + !!ur_mask_3(_a) ); }) \ diff --git a/pkg/urbit/noun/urth.c b/pkg/urbit/noun/urth.c index fbfe5e6ef0..facd88ba19 100644 --- a/pkg/urbit/noun/urth.c +++ b/pkg/urbit/noun/urth.c @@ -353,7 +353,7 @@ u3u_uniq(void) ur_hcon_info(stderr, rot_u); fprintf(stderr, "\r\n"); - // reinitialize looom + // reinitialize loom // // NB: hot jet state is not yet re-established // diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 74807a17ad..142d5a8b7a 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -221,6 +221,80 @@ ur_bytes(ur_root_t *r, ur_nref ref, uint8_t **byt, uint64_t *len) } } +static inline uint64_t +_met0_bytes(uint8_t *byt, uint64_t len) +{ + // XX requires no trailing null bytes + // + uint64_t last = len - 1; + return (last << 3) + ur_met0_8(byt[last]); +} + +uint64_t +ur_met(ur_root_t *r, uint8_t bloq, ur_nref ref) +{ + assert( !ur_deep(ref) ); + + // these cases are the same, except for the + // bit-width calculation and the width of their operands + // + switch ( ur_nref_tag(ref) ) { + default: assert(0); + + case ur_direct: { + uint8_t m_bit = ur_met0_64(ref); + + switch ( bloq ) { + case 0: return m_bit; + case 1: return (m_bit + 1) >> 1; + case 2: return (m_bit + 3) >> 2; + + { + // hand-inline of ur_met3_64 + // + uint8_t m_byt = (m_bit >> 3) + !!ur_mask_3(m_bit); + + case 3: return m_byt; + default: { + uint8_t off = (bloq - 3); + return (m_byt + ((1 << off) - 1)) >> off; + } + } + } + } break; + + case ur_iatom: { + uint64_t m_bit; + + { + uint64_t idx = ur_nref_idx(ref); + uint64_t len = r->atoms.lens[idx]; + uint8_t *byt = r->atoms.bytes[idx]; + + m_bit = _met0_bytes(byt, len); + } + + switch ( bloq ) { + case 0: return m_bit; + case 1: return (m_bit + 1) >> 1; + case 2: return (m_bit + 3) >> 2; + + { + // hand-inline of ur_met3_64 + // + uint64_t m_byt = (m_bit >> 3) + !!ur_mask_3(m_bit); + + case 3: return m_byt; + default: { + uint8_t off = (bloq - 3); + return (m_byt + ((1ULL << off) - 1)) >> off; + } + } + } + } break; + } +} + static ur_nref _coin_unsafe(ur_atoms_t *atoms, ur_mug mug, uint8_t *byt, uint64_t len) { From ab217fc8746a43f474e36837ebc3e78ee47bdb28 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 10 Aug 2020 12:54:55 -0700 Subject: [PATCH 156/933] ur: adds dictionaries with noun keys and arbitrary 32/64-bit values --- pkg/urbit/include/ur/hashcons.h | 45 ++++++++ pkg/urbit/ur/hashcons.c | 191 ++++++++++++++++++++++++++++++-- 2 files changed, 228 insertions(+), 8 deletions(-) diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index 7511f941d7..a6b83f388c 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -59,6 +59,30 @@ typedef struct ur_nvec_s { ur_nref* refs; } ur_nvec_t; +typedef struct ur_pail32_s { + uint8_t fill; + ur_nref refs[10]; + uint32_t vals[10]; +} ur_pail32_t; + +typedef struct ur_dict32_s { + uint64_t prev; + uint64_t size; + ur_pail32_t *buckets; +} ur_dict32_t; + +typedef struct ur_pail64_s { + uint8_t fill; + ur_nref refs[10]; + uint64_t vals[10]; +} ur_pail64_t; + +typedef struct ur_dict64_s { + uint64_t prev; + uint64_t size; + ur_pail64_t *buckets; +} ur_dict64_t; + typedef struct ur_pail_s { uint8_t fill; ur_nref refs[10]; @@ -95,6 +119,27 @@ typedef struct ur_root_s { ur_atoms_t atoms; } ur_root_t; +void +ur_dict32_grow(ur_root_t *r, ur_dict32_t *dict, uint64_t prev, uint64_t size); + +ur_bool_t +ur_dict32_get(ur_root_t *r, ur_dict32_t *dict, ur_nref ref, uint32_t *out); + +void +ur_dict32_put(ur_root_t *r, ur_dict32_t *dict, ur_nref ref, uint32_t val); + +void +ur_dict64_grow(ur_root_t *r, ur_dict64_t *dict, uint64_t prev, uint64_t size); + +void +ur_dict_free(ur_dict_t *dict); + +ur_bool_t +ur_dict64_get(ur_root_t *r, ur_dict64_t *dict, ur_nref ref, uint64_t *out); + +void +ur_dict64_put(ur_root_t *r, ur_dict64_t *dict, ur_nref ref, uint64_t val); + ur_nref ur_coin_bytes(ur_root_t *r, uint8_t *byt, uint64_t len); diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 142d5a8b7a..b4489b58e5 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -100,6 +100,181 @@ ur_tail(ur_root_t *r, ur_nref ref) assert( ur_deep(ref) ); return r->cells.tails[ur_nref_idx(ref)]; } +void +ur_dict32_grow(ur_root_t *r, ur_dict32_t *dict, uint64_t prev, uint64_t size) +{ + ur_pail32_t *buckets, *old_buckets = dict->buckets; + uint64_t old_size = dict->size; + uint64_t i, next = prev + size; + + buckets = calloc(next, sizeof(*buckets)); + + for ( i = 0; i < old_size; i++ ) { + ur_pail32_t *old_bucket = &(old_buckets[i]); + uint8_t j, old_fill = old_bucket->fill; + + for ( j = 0; j < old_fill; j++ ) { + uint32_t val = old_bucket->vals[j]; + ur_nref ref = old_bucket->refs[j]; + ur_mug mug = ur_nref_mug(r, ref); + + uint64_t idx = ( mug % next ); + ur_pail32_t *bucket = &(buckets[idx]); + uint8_t new_fill = bucket->fill; + + if ( 10 == new_fill ) { + free(buckets); + return ur_dict32_grow(r, dict, size, next); + } + + bucket->refs[new_fill] = ref; + bucket->vals[new_fill] = val; + bucket->fill = 1 + new_fill; + } + } + + free(old_buckets); + + dict->prev = size; + dict->size = next; + dict->buckets = buckets; +} + +ur_bool_t +ur_dict32_get(ur_root_t *r, ur_dict32_t *dict, ur_nref ref, uint32_t *out) +{ + ur_mug mug = ur_nref_mug(r, ref); + uint64_t idx = ( mug % dict->size ); + + ur_pail32_t *bucket = &(dict->buckets[idx]); + uint8_t i, fill = bucket->fill; + + for ( i = 0; i < fill; i++ ) { + if ( ref == bucket->refs[i] ) { + *out = bucket->vals[i]; + return 1; + } + } + + return 0; +} + +void +ur_dict32_put(ur_root_t *r, ur_dict32_t *dict, ur_nref ref, uint32_t val) +{ + ur_mug mug = ur_nref_mug(r, ref); + + while ( 1 ) { + uint64_t idx = ( mug % dict->size ); + ur_pail32_t *bucket = &(dict->buckets[idx]); + uint8_t i, fill = bucket->fill; + + for ( i = 0; i < fill; i++ ) { + if ( ref == bucket->refs[i] ) { + bucket->vals[i] = val; + return; + } + } + + if ( 10 == fill ) { + ur_dict32_grow(r, dict, dict->prev, dict->size); + continue; + } + + bucket->refs[fill] = ref; + bucket->vals[fill] = val; + bucket->fill = 1 + fill; + break; + } +} + +void +ur_dict64_grow(ur_root_t *r, ur_dict64_t *dict, uint64_t prev, uint64_t size) +{ + ur_pail64_t *buckets, *old_buckets = dict->buckets; + uint64_t old_size = dict->size; + uint64_t i, next = prev + size; + + buckets = calloc(next, sizeof(*buckets)); + + for ( i = 0; i < old_size; i++ ) { + ur_pail64_t *old_bucket = &(old_buckets[i]); + uint8_t j, old_fill = old_bucket->fill; + + for ( j = 0; j < old_fill; j++ ) { + uint64_t val = old_bucket->vals[j]; + ur_nref ref = old_bucket->refs[j]; + ur_mug mug = ur_nref_mug(r, ref); + + uint64_t idx = ( mug % next ); + ur_pail64_t *bucket = &(buckets[idx]); + uint8_t new_fill = bucket->fill; + + if ( 10 == new_fill ) { + free(buckets); + return ur_dict64_grow(r, dict, size, next); + } + + bucket->refs[new_fill] = ref; + bucket->vals[new_fill] = val; + bucket->fill = 1 + new_fill; + } + } + + free(old_buckets); + + dict->prev = size; + dict->size = next; + dict->buckets = buckets; +} + +ur_bool_t +ur_dict64_get(ur_root_t *r, ur_dict64_t *dict, ur_nref ref, uint64_t *out) +{ + ur_mug mug = ur_nref_mug(r, ref); + uint64_t idx = ( mug % dict->size ); + + ur_pail64_t *bucket = &(dict->buckets[idx]); + uint8_t i, fill = bucket->fill; + + for ( i = 0; i < fill; i++ ) { + if ( ref == bucket->refs[i] ) { + *out = bucket->vals[i]; + return 1; + } + } + + return 0; +} + +void +ur_dict64_put(ur_root_t *r, ur_dict64_t *dict, ur_nref ref, uint64_t val) +{ + ur_mug mug = ur_nref_mug(r, ref); + + while ( 1 ) { + uint64_t idx = ( mug % dict->size ); + ur_pail64_t *bucket = &(dict->buckets[idx]); + uint8_t i, fill = bucket->fill; + + for ( i = 0; i < fill; i++ ) { + if ( ref == bucket->refs[i] ) { + bucket->vals[i] = val; + return; + } + } + + if ( 10 == fill ) { + ur_dict64_grow(r, dict, dict->prev, dict->size); + continue; + } + + bucket->refs[fill] = ref; + bucket->vals[fill] = val; + bucket->fill = 1 + fill; + break; + } +} void ur_dict_grow(ur_root_t *r, ur_dict_t *dict, uint64_t prev, uint64_t size) @@ -139,6 +314,12 @@ ur_dict_grow(ur_root_t *r, ur_dict_t *dict, uint64_t prev, uint64_t size) dict->buckets = buckets; } +void +ur_dict_free(ur_dict_t *dict) +{ + free(dict->buckets); +} + void ur_atoms_grow(ur_atoms_t *atoms) { @@ -542,12 +723,6 @@ ur_hcon_info(FILE *f, ur_root_t *r) _print_memory(f, "total", total); } -static void -_dict_free(ur_dict_t *dict) -{ - free(dict->buckets); -} - static void _atoms_free(ur_atoms_t *atoms) { @@ -558,14 +733,14 @@ _atoms_free(ur_atoms_t *atoms) free(bytes[i]); } - _dict_free(&(atoms->dict)); + ur_dict_free(&(atoms->dict)); free(bytes); } static void _cells_free(ur_cells_t *cells) { - _dict_free(&(cells->dict)); + ur_dict_free(&(cells->dict)); free(cells->heads); } From d0e5c658a9a5e14eb40d49a1f707257dcfd05fb0 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 10 Aug 2020 12:45:27 -0700 Subject: [PATCH 157/933] ur/u3: enforce ur_coin* invariants, deduplicate 32-61-bit direct atoms --- pkg/urbit/noun/urth.c | 52 ++++++++++++++++++++--------------------- pkg/urbit/ur/hashcons.c | 35 +++++++++++++++++++++------ 2 files changed, 54 insertions(+), 33 deletions(-) diff --git a/pkg/urbit/noun/urth.c b/pkg/urbit/noun/urth.c index facd88ba19..674b734c44 100644 --- a/pkg/urbit/noun/urth.c +++ b/pkg/urbit/noun/urth.c @@ -29,10 +29,6 @@ _cu_met_3(u3a_atom* vat_u) } } -// XX this is morally correct, but not useful -// for deduplicating the loom -// -#if 0 static inline ur_nref _cu_atom_to_ref(u3a_atom* vat_u, ur_root_t *r) { @@ -61,20 +57,6 @@ _cu_atom_to_ref(u3a_atom* vat_u, ur_root_t *r) return ref; } -#endif - -/* _cu_atom_to_ref(): indirect u3 atom to ur_nref. -*/ -static inline ur_nref -_cu_atom_to_ref(u3a_atom* vat_u, ur_root_t *r) -{ - c3_assert( vat_u->len_w ); - - c3_y* byt_y = (c3_y*)vat_u->buf_w; - c3_w len_w = _cu_met_3(vat_u); - - return ur_coin_bytes(r, byt_y, (c3_d)len_w); -} /* _cu_box_check(): check loom allocation box for relocation pointer. */ @@ -240,8 +222,9 @@ _cu_hamt_walk(u3_noun kev, void* ptr) } typedef struct _cu_loom_s { - u3_atom *vat; - u3_noun *cel; + ur_dict32_t map_u; // direct->indirect mapping + u3_atom *vat; // indirect atoms + u3_noun *cel; // cells } _cu_loom; /* _cu_loom_free(): dispose loom relocation pointers @@ -249,6 +232,7 @@ typedef struct _cu_loom_s { static void _cu_loom_free(_cu_loom* lom_u) { + ur_dict_free((ur_dict_t*)&(lom_u->map_u)); free(lom_u->vat); free(lom_u->cel); } @@ -278,16 +262,29 @@ _cu_ref_to_noun(ur_nref ref, _cu_loom* lom_u) default: assert(0); case ur_direct: { - if ( 0x7fffffffULL > ref ) { + if ( 0x7fffffffULL >= ref ) { return (u3_atom)ref; } else { - c3_w wor_w[2]; + c3_w val_w; - wor_w[0] = ref & 0xffffffff; - wor_w[1] = ref >> 32; + // XX the ur_root_t argument here is only used to dereference a mug, + // but these atoms are all direct, so it'll never be used + // + if ( ur_dict32_get(0, &lom_u->map_u, ref, &val_w) ) { + return (u3_atom)val_w; + } + else { + u3_atom vat; + { + c3_w wor_w[2] = { ref & 0xffffffff, ref >> 32 }; + vat = val_w = u3i_words(2, wor_w); + } - return u3i_words(2, wor_w); + ur_dict32_put(0, &lom_u->map_u, ref, val_w); + + return vat; + } } } break; @@ -362,7 +359,10 @@ u3u_uniq(void) { // reallocate all nouns on the loom // - _cu_loom lom_u; + _cu_loom lom_u = {0}; + + ur_dict32_grow(0, &lom_u.map_u, 89, 144); + _cu_atoms_to_loom(rot_u, &lom_u); _cu_cells_to_loom(rot_u, &lom_u); diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index b4489b58e5..e07e839809 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -518,17 +518,13 @@ _cons_unsafe(ur_cells_t *cells, ur_mug mug, ur_nref hed, ur_nref tal) return cel; } -ur_nref -ur_coin_bytes(ur_root_t *r, uint8_t *byt, uint64_t len) +static ur_nref +_coin_bytes_unsafe(ur_root_t *r, uint8_t *byt, uint64_t len) { ur_atoms_t *atoms = &(r->atoms); ur_dict_t *dict = &(atoms->dict); ur_mug mug = ur_mug_bytes(byt, len); - // XX should check for <= 62 bits, coin direct - // XX conflicts with current u3u_uniq() use-case - // - while ( 1 ) { uint64_t idx = ( mug % dict->size ); ur_pail_t *bucket = &(dict->buckets[idx]); @@ -567,6 +563,31 @@ ur_coin_bytes(ur_root_t *r, uint8_t *byt, uint64_t len) } } +ur_nref +ur_coin_bytes(ur_root_t *r, uint8_t *byt, uint64_t len) +{ + // strip trailing zeroes + // + while ( len && !byt[len - 1] ) { + len--; + } + + // produce a direct atom if possible + // + if ( 62 >= _met0_bytes(byt, len) ) { + uint64_t i, direct = 0; + + for ( i = 0; i < len; i++ ) { + direct |= byt[i] << (8 * i); + } + + return (ur_nref)direct; + } + else { + return _coin_bytes_unsafe(r, byt, len); + } +} + ur_nref ur_coin64(ur_root_t *r, uint64_t n) { @@ -576,7 +597,7 @@ ur_coin64(ur_root_t *r, uint64_t n) else { // XX little-endian // - return ur_coin_bytes(r, (uint8_t*)&n, ur_met3_64(n)); + return _coin_bytes_unsafe(r, (uint8_t*)&n, ur_met3_64(n)); } } From 039ef019b9de7dd425b53abccc241da6999441a1 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 10 Aug 2020 12:56:54 -0700 Subject: [PATCH 158/933] ur: adds ur_walk_fore - higher-ordered pre-order noun traversal --- pkg/urbit/include/ur/hashcons.h | 7 +++++ pkg/urbit/ur/hashcons.c | 51 +++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index a6b83f388c..374c520754 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -163,3 +163,10 @@ ur_nvec_free(ur_nvec_t *v); void ur_nvec_init(ur_nvec_t *v, uint64_t size); + +void +ur_walk_fore(ur_root_t *r, + ur_nref ref, + void *v, + void (*atom)(ur_root_t*, ur_nref, void*), + ur_bool_t (*cell)(ur_root_t*, ur_nref, void*)); diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index e07e839809..ced7cc37d1 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -821,3 +821,54 @@ ur_nvec_init(ur_nvec_t *v, uint64_t size) v->fill = 0; v->refs = calloc(size, sizeof(ur_nref)); } + +void +ur_walk_fore(ur_root_t *r, + ur_nref ref, + void *v, + void (*atom)(ur_root_t*, ur_nref, void*), + ur_bool_t (*cell)(ur_root_t*, ur_nref, void*)) +{ + uint64_t prev = 89, size = 144, fill = 0; + ur_nref *top, *don; + + don = malloc(size * sizeof(*don)); + top = don + ++fill; + *top = ref; + + while ( top != don ) { + // visit atom, pop stack + // + if ( !ur_deep(ref) ) { + atom(r, ref, v); + top--; fill--; + } + // visit cell, pop stack if false + // + else if ( !cell(r, ref, v) ) { + top--; fill--; + } + // push the tail, continue into the head + // + else { + *top = ur_tail(r, ref); + + // reallocate "stack" if full + // + if ( size == fill ) { + uint64_t next = prev + size; + don = realloc(don, next * sizeof(*don)); + top = don + fill; + prev = size; + size = next; + } + + top++; fill++; + *top = ur_head(r, ref); + } + + ref = *top; + } + + free(don); +} From 3e6fd0f8e89bf7cda0b5649ba40f1776222a1b6a Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 13 Aug 2020 10:08:02 -0400 Subject: [PATCH 159/933] natpmp: ~pilfer style nits --- .../Network/{NATPMP.hsc => NatPmp.hsc} | 66 ++++++++++--------- pkg/hs/natpmp-static/natpmp-static.cabal | 2 +- pkg/hs/urbit-king/lib/Urbit/King/CLI.hs | 4 +- pkg/hs/urbit-king/lib/Urbit/King/Main.hs | 2 +- pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs | 8 +-- 5 files changed, 44 insertions(+), 38 deletions(-) rename pkg/hs/natpmp-static/hsrc_lib/Network/{NATPMP.hsc => NatPmp.hsc} (85%) diff --git a/pkg/hs/natpmp-static/hsrc_lib/Network/NATPMP.hsc b/pkg/hs/natpmp-static/hsrc_lib/Network/NatPmp.hsc similarity index 85% rename from pkg/hs/natpmp-static/hsrc_lib/Network/NATPMP.hsc rename to pkg/hs/natpmp-static/hsrc_lib/Network/NatPmp.hsc index 4f7cf387dd..3fbb89296c 100644 --- a/pkg/hs/natpmp-static/hsrc_lib/Network/NATPMP.hsc +++ b/pkg/hs/natpmp-static/hsrc_lib/Network/NatPmp.hsc @@ -2,10 +2,12 @@ -- | This module is a thin wrapper above libnatpmp.h and getgateway.h. -module Network.NATPMP (Error(..), +module Network.NatPmp (Error(..), NatPmpResponse(..), ProtocolType(..), NatPmpHandle, + Port, + LifetimeSeconds, initNatPmp, closeNatPmp, getDefaultGateway, @@ -23,18 +25,21 @@ import Foreign import Foreign.C import Network.Socket -import Control.Monad.IO.Unlift (MonadIO(..), MonadUnliftIO, withRunInIO) +import Control.Monad.IO.Unlift (MonadIO(..)) -- Opaque type for the internals of nat pmp data NatPmpStruct type NatPmpHandle = Ptr NatPmpStruct +type Port = Word16 +type LifetimeSeconds = Word32 + -- The response type, in its internal form. This struct is a C tagged union -- with additional data, but we need to read and write from its C form. data NatPmpResponse = NatPmpResponsePublicAddress HostAddress - | NatPmpResponseUDPPortMapping Word16 Word16 Word32 - | NatPmpResponseTCPPortMapping Word16 Word16 Word32 + | NatPmpResponseUdpPortMapping Port Port LifetimeSeconds + | NatPmpResponseTcpPortMapping Port Port LifetimeSeconds deriving (Show) instance Storable NatPmpResponse where @@ -47,13 +52,13 @@ instance Storable NatPmpResponse where RTPublicAddress -> NatPmpResponsePublicAddress <$> (#{peek natpmpresp_t, pnu.publicaddress.addr} p) - RTUDPPortMapping -> - NatPmpResponseUDPPortMapping + RTUdpPortMapping -> + NatPmpResponseUdpPortMapping <$> (#{peek natpmpresp_t, pnu.newportmapping.privateport} p) <*> (#{peek natpmpresp_t, pnu.newportmapping.mappedpublicport} p) <*> (#{peek natpmpresp_t, pnu.newportmapping.lifetime} p) - RTTCPPortMapping -> - NatPmpResponseTCPPortMapping + RTTcpPortMapping -> + NatPmpResponseTcpPortMapping <$> (#{peek natpmpresp_t, pnu.newportmapping.privateport} p) <*> (#{peek natpmpresp_t, pnu.newportmapping.mappedpublicport} p) <*> (#{peek natpmpresp_t, pnu.newportmapping.lifetime} p) @@ -94,32 +99,32 @@ getDefaultGateway = data RespType = RTPublicAddress - | RTUDPPortMapping - | RTTCPPortMapping + | RTUdpPortMapping + | RTTcpPortMapping deriving (Eq, Show) instance Enum RespType where fromEnum RTPublicAddress = 0 - fromEnum RTUDPPortMapping = 1 - fromEnum RTTCPPortMapping = 2 + fromEnum RTUdpPortMapping = 1 + fromEnum RTTcpPortMapping = 2 toEnum 0 = RTPublicAddress - toEnum 1 = RTUDPPortMapping - toEnum 2 = RTTCPPortMapping + toEnum 1 = RTUdpPortMapping + toEnum 2 = RTTcpPortMapping toEnum unmatched = error ("RespType.toEnum: Cannot match " ++ show unmatched) data ProtocolType - = PTUDP - | PTTCP + = PTUdp + | PTTcp deriving (Eq, Show) instance Enum ProtocolType where - fromEnum PTUDP = 1 - fromEnum PTTCP = 2 + fromEnum PTUdp = 1 + fromEnum PTTcp = 2 - toEnum 1 = PTUDP - toEnum 2 = PTTCP + toEnum 1 = PTUdp + toEnum 2 = PTTcp toEnum x = error ("ProtocolType.toEnum: Cannot match " ++ show x) @@ -200,8 +205,7 @@ instance Enum Error where toEnum unmatched = error ("Error.toEnum: Cannot match " ++ show unmatched) -initNatPmp :: (MonadIO m) - => m (Either Error NatPmpHandle) +initNatPmp :: MonadIO m => m (Either Error NatPmpHandle) initNatPmp = do natpmp <- liftIO $ mallocBytes #{size natpmp_t} ret <- liftIO $ _init_nat_pmp natpmp 0 0 @@ -212,8 +216,7 @@ initNatPmp = do pure $ Left $ intToEnum ret -closeNatPmp :: (MonadIO m) - => NatPmpHandle -> m (Either Error ()) +closeNatPmp :: MonadIO m => NatPmpHandle -> m (Either Error ()) closeNatPmp handle = do ret <- liftIO $ _close_nat_pmp handle liftIO $ free handle @@ -223,8 +226,7 @@ closeNatPmp handle = do -- Public interface for getting the public IPv4 address -getPublicAddress :: (MonadIO m) - => NatPmpHandle -> m (Either Error HostAddress) +getPublicAddress :: MonadIO m => NatPmpHandle -> m (Either Error HostAddress) getPublicAddress natpmp = do sendRetcode <- liftIO $ sendPublicAddressRequest natpmp case sendRetcode of @@ -238,8 +240,12 @@ getPublicAddress natpmp = do _ -> pure $ Left $ intToEnum sendRetcode -setPortMapping :: (MonadIO m) - => NatPmpHandle -> ProtocolType -> Word16 -> Word16 -> Word32 +setPortMapping :: MonadIO m + => NatPmpHandle + -> ProtocolType + -> Port + -> Port + -> LifetimeSeconds -> m (Either Error ()) setPortMapping natpmp protocol privatePort publicPort lifetime = do let protocolNum = fromEnum protocol @@ -253,8 +259,8 @@ setPortMapping natpmp protocol privatePort publicPort lifetime = do respRetcode <- readNatResponseSynchronously natpmp pResponse case respRetcode of 0 -> peek pResponse >>= \case - NatPmpResponseUDPPortMapping _ _ _ -> pure $ Right () - NatPmpResponseTCPPortMapping _ _ _ -> pure $ Right () + NatPmpResponseUdpPortMapping _ _ _ -> pure $ Right () + NatPmpResponseTcpPortMapping _ _ _ -> pure $ Right () _ -> pure $ Left ErrHaskellBindingsErr _ -> pure $ Left $ intToEnum respRetcode x -> pure $ Left $ intToEnum x diff --git a/pkg/hs/natpmp-static/natpmp-static.cabal b/pkg/hs/natpmp-static/natpmp-static.cabal index 5c0baf5072..9ee268ab76 100644 --- a/pkg/hs/natpmp-static/natpmp-static.cabal +++ b/pkg/hs/natpmp-static/natpmp-static.cabal @@ -41,7 +41,7 @@ library cc-options: -Wall -Os -g -fPIC ghc-options: -Wall -fprof-auto -fPIC - exposed-modules: Network.NATPMP + exposed-modules: Network.NatPmp -- other-modules: -- other-extensions: diff --git a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs index b2a7a903e1..19ddb09f81 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs @@ -18,7 +18,7 @@ import System.Environment (getProgName) data KingOpts = KingOpts { koSharedHttpPort :: Maybe Word16 , koSharedHttpsPort :: Maybe Word16 - , koUseNATPMP :: Bool + , koUseNatPmp :: Bool } deriving (Show) @@ -355,7 +355,7 @@ runOneShip = (,,) <$> fmap Run pierPath <*> opts <*> df kingOpts :: Parser KingOpts kingOpts = do - koUseNATPMP <- enableNAT + koUseNatPmp <- enableNAT koSharedHttpPort <- optional diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs index c178bbed84..03b4d90ed3 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs @@ -759,7 +759,7 @@ runShips CLI.KingOpts {..} ships = do multi <- multiEyre meConf - ports <- buildPortHandler koUseNATPMP + ports <- buildPortHandler koUseNatPmp runRunningEnv multi ports (go ships) where diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs index 046bdb138b..a311c30717 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs @@ -6,7 +6,7 @@ module Urbit.Vere.Ports (HasPortControlApi(..), import Control.Monad.STM (check) import Urbit.Prelude -import Network.NATPMP +import Network.NatPmp import Data.Time.Clock.POSIX import Data.Heap import Network.Socket @@ -142,7 +142,7 @@ portThread q stderr = do PTMInitialRequestOpen p notifyComplete -> do logInfo $ displayShow ("port: sending initial request to NAT-PMP for port ", p) - ret <- setPortMapping pmp PTUDP p p portLeaseLifetime + ret <- setPortMapping pmp PTUdp p p portLeaseLifetime case ret of Left err -> do logError $ @@ -163,7 +163,7 @@ portThread q stderr = do logInfo $ displayShow ("port: sending renewing request to NAT-PMP for port ", p) - ret <- setPortMapping pmp PTUDP p p portLeaseLifetime + ret <- setPortMapping pmp PTUdp p p portLeaseLifetime case ret of Left err -> do logError $ @@ -180,7 +180,7 @@ portThread q stderr = do PTMRequestClose p -> do logInfo $ displayShow ("port: releasing lease for ", p) - setPortMapping pmp PTUDP p p 0 + setPortMapping pmp PTUdp p p 0 let removed = filterPort p nextRenew loop pmp removed From ac4b5a99e5108c1ca77f1e938cc634bb03c4800c Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 13 Aug 2020 10:19:35 -0400 Subject: [PATCH 160/933] natpmp: Rename RunningEnv to HostEnv. --- pkg/hs/urbit-king/lib/Urbit/King/App.hs | 72 ++++++++++++------------ pkg/hs/urbit-king/lib/Urbit/King/Main.hs | 28 ++++----- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/App.hs b/pkg/hs/urbit-king/lib/Urbit/King/App.hs index 225e7f4b45..b10ba12e3f 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/App.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/App.hs @@ -9,8 +9,8 @@ module Urbit.King.App , kingEnvKillSignal , killKingActionL , onKillKingSigL - , RunningEnv - , runRunningEnv + , HostEnv + , runHostEnv , PierEnv , runPierEnv , killPierActionL @@ -20,7 +20,7 @@ module Urbit.King.App , HasProcId(..) , HasKingEnv(..) , HasMultiEyreApi(..) - , HasRunningEnv(..) + , HasHostEnv(..) , HasPierEnv(..) , module Urbit.King.Config ) @@ -125,7 +125,7 @@ killKingActionL :: HasKingEnv e => Getter e (STM ()) killKingActionL = kingEnvL . kingEnvKillSignal . to (\kil -> void (tryPutTMVar kil ())) --- RunningEnv ------------------------------------------------------------------ +-- HostEnv ------------------------------------------------------------------ -- The running environment is everything in King, eyre configuration shared -- across ships, and IP information shared across ships. @@ -136,60 +136,60 @@ class HasMultiEyreApi a where multiEyreApiL :: Lens' a MultiEyreApi class (HasKingEnv a, HasMultiEyreApi a, HasPortControlApi a) => - HasRunningEnv a where - runningEnvL :: Lens' a RunningEnv + HasHostEnv a where + hostEnvL :: Lens' a HostEnv -data RunningEnv = RunningEnv - { _runningEnvKingEnv :: !KingEnv - , _runningEnvMultiEyreApi :: MultiEyreApi - , _runningEnvPortControlApi :: PortControlApi +data HostEnv = HostEnv + { _hostEnvKingEnv :: !KingEnv + , _hostEnvMultiEyreApi :: MultiEyreApi + , _hostEnvPortControlApi :: PortControlApi } -makeLenses ''RunningEnv +makeLenses ''HostEnv -instance HasKingEnv RunningEnv where - kingEnvL = runningEnvKingEnv +instance HasKingEnv HostEnv where + kingEnvL = hostEnvKingEnv -instance HasLogFunc RunningEnv where +instance HasLogFunc HostEnv where logFuncL = kingEnvL . logFuncL -instance HasStderrLogFunc RunningEnv where +instance HasStderrLogFunc HostEnv where stderrLogFuncL = kingEnvL . stderrLogFuncL -instance HasProcId RunningEnv where +instance HasProcId HostEnv where procIdL = kingEnvL . procIdL -instance HasKingId RunningEnv where +instance HasKingId HostEnv where kingIdL = kingEnvL . kingEnvKingId -instance HasMultiEyreApi RunningEnv where - multiEyreApiL = runningEnvMultiEyreApi +instance HasMultiEyreApi HostEnv where + multiEyreApiL = hostEnvMultiEyreApi -instance HasPortControlApi RunningEnv where - portControlApiL = runningEnvPortControlApi +instance HasPortControlApi HostEnv where + portControlApiL = hostEnvPortControlApi -- Running Running Envs -------------------------------------------------------- -runRunningEnv :: MultiEyreApi -> PortControlApi -> RIO RunningEnv () +runHostEnv :: MultiEyreApi -> PortControlApi -> RIO HostEnv () -> RIO KingEnv () -runRunningEnv multi ports action = do +runHostEnv multi ports action = do king <- ask - let runningEnv = RunningEnv { _runningEnvKingEnv = king - , _runningEnvMultiEyreApi = multi - , _runningEnvPortControlApi = ports + let hostEnv = HostEnv { _hostEnvKingEnv = king + , _hostEnvMultiEyreApi = multi + , _hostEnvPortControlApi = ports } - io (runRIO runningEnv action) + io (runRIO hostEnv action) -- PierEnv --------------------------------------------------------------------- -class (HasKingEnv a, HasRunningEnv a, HasPierConfig a, HasNetworkConfig a) => +class (HasKingEnv a, HasHostEnv a, HasPierConfig a, HasNetworkConfig a) => HasPierEnv a where pierEnvL :: Lens' a PierEnv data PierEnv = PierEnv - { _pierEnvRunningEnv :: !RunningEnv + { _pierEnvHostEnv :: !HostEnv , _pierEnvPierConfig :: !PierConfig , _pierEnvNetworkConfig :: !NetworkConfig , _pierEnvKillSignal :: !(TMVar ()) @@ -198,16 +198,16 @@ data PierEnv = PierEnv makeLenses ''PierEnv instance HasKingEnv PierEnv where - kingEnvL = pierEnvRunningEnv . kingEnvL + kingEnvL = pierEnvHostEnv . kingEnvL -instance HasRunningEnv PierEnv where - runningEnvL = pierEnvRunningEnv +instance HasHostEnv PierEnv where + hostEnvL = pierEnvHostEnv instance HasMultiEyreApi PierEnv where - multiEyreApiL = pierEnvRunningEnv . multiEyreApiL + multiEyreApiL = pierEnvHostEnv . multiEyreApiL instance HasPortControlApi PierEnv where - portControlApiL = pierEnvRunningEnv . portControlApiL + portControlApiL = pierEnvHostEnv . portControlApiL instance HasPierEnv PierEnv where pierEnvL = id @@ -250,11 +250,11 @@ killPierActionL = -- Running Pier Envs ----------------------------------------------------------- runPierEnv - :: PierConfig -> NetworkConfig -> TMVar () -> RIO PierEnv a -> RIO RunningEnv a + :: PierConfig -> NetworkConfig -> TMVar () -> RIO PierEnv a -> RIO HostEnv a runPierEnv pierConfig networkConfig vKill action = do running <- ask - let pierEnv = PierEnv { _pierEnvRunningEnv = running + let pierEnv = PierEnv { _pierEnvHostEnv = running , _pierEnvPierConfig = pierConfig , _pierEnvNetworkConfig = networkConfig , _pierEnvKillSignal = vKill diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs index 03b4d90ed3..502134a190 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs @@ -443,7 +443,7 @@ validateNounVal inpVal = do -------------------------------------------------------------------------------- -pillFrom :: CLI.PillSource -> RIO RunningEnv Pill +pillFrom :: CLI.PillSource -> RIO HostEnv Pill pillFrom = \case CLI.PillSourceFile pillPath -> do logDebug $ display $ "boot: reading pill from " ++ (pack pillPath :: Text) @@ -479,9 +479,9 @@ newShip CLI.New{..} opts = do let ports = buildInactivePorts -- here we are with a king env, and we now need a multi env. - runRunningEnv multi ports go + runHostEnv multi ports go where - go :: RIO RunningEnv () + go :: RIO HostEnv () go = case nBootType of CLI.BootComet -> do pill <- pillFrom nPillSource @@ -515,7 +515,7 @@ newShip CLI.New{..} opts = do bootFromSeed pill seed - shipFrom :: Text -> RIO RunningEnv Ship + shipFrom :: Text -> RIO HostEnv Ship shipFrom name = case Ob.parsePatp name of Left x -> error "Invalid ship name" Right p -> pure $ Ship $ fromIntegral $ Ob.fromPatp p @@ -525,7 +525,7 @@ newShip CLI.New{..} opts = do Just x -> x Nothing -> "./" <> unpack name - nameFromShip :: Ship -> RIO RunningEnv Text + nameFromShip :: Ship -> RIO HostEnv Text nameFromShip s = name where nameWithSig = Ob.renderPatp $ Ob.patp $ fromIntegral s @@ -533,7 +533,7 @@ newShip CLI.New{..} opts = do Nothing -> error "Urbit.ob didn't produce string with ~" Just x -> pure x - bootFromSeed :: Pill -> Seed -> RIO RunningEnv () + bootFromSeed :: Pill -> Seed -> RIO HostEnv () bootFromSeed pill seed = do ethReturn <- dawnVent seed @@ -547,7 +547,7 @@ newShip CLI.New{..} opts = do -- Now that we have all the information for running an application with a -- PierConfig, do so. runTryBootFromPill :: Pill -> Text -> Ship -> LegacyBootEvent - -> RIO RunningEnv () + -> RIO HostEnv () runTryBootFromPill pill name ship bootEvent = do env <- ask let vKill = (env ^. kingEnvL) ^. kingEnvKillSignal @@ -557,7 +557,7 @@ newShip CLI.New{..} opts = do tryBootFromPill True pill nLite ship bootEvent ------ tryBootFromPill (CLI.oExit opts) pill nLite flags ship bootEvent -runShipEnv :: CLI.Run -> CLI.Opts -> TMVar () -> RIO PierEnv a -> RIO RunningEnv a +runShipEnv :: CLI.Run -> CLI.Opts -> TMVar () -> RIO PierEnv a -> RIO HostEnv a runShipEnv (CLI.Run pierPath) opts vKill act = do runPierEnv pierConfig netConfig vKill act where @@ -689,7 +689,7 @@ main = do TODO Use logging system instead of printing. -} runShipRestarting - :: CLI.Run -> CLI.Opts -> RIO RunningEnv () + :: CLI.Run -> CLI.Opts -> RIO HostEnv () runShipRestarting r o = do let pier = pack (CLI.rPierPath r) loop = runShipRestarting r o @@ -722,7 +722,7 @@ runShipRestarting r o = do TODO This is messy and shared a lot of logic with `runShipRestarting`. -} runShipNoRestart - :: CLI.Run -> CLI.Opts -> Bool -> RIO RunningEnv () + :: CLI.Run -> CLI.Opts -> Bool -> RIO HostEnv () runShipNoRestart r o d = do -- killing ship same as killing king env <- ask @@ -761,9 +761,9 @@ runShips CLI.KingOpts {..} ships = do ports <- buildPortHandler koUseNatPmp - runRunningEnv multi ports (go ships) + runHostEnv multi ports (go ships) where - go :: [(CLI.Run, CLI.Opts, Bool)] -> RIO RunningEnv () + go :: [(CLI.Run, CLI.Opts, Bool)] -> RIO HostEnv () go = \case [] -> pure () [rod] -> runSingleShip rod @@ -771,7 +771,7 @@ runShips CLI.KingOpts {..} ships = do -- TODO Duplicated logic. -runSingleShip :: (CLI.Run, CLI.Opts, Bool) -> RIO RunningEnv () +runSingleShip :: (CLI.Run, CLI.Opts, Bool) -> RIO HostEnv () runSingleShip (r, o, d) = do shipThread <- async (runShipNoRestart r o d) @@ -793,7 +793,7 @@ runSingleShip (r, o, d) = do pure () -runMultipleShips :: [(CLI.Run, CLI.Opts)] -> RIO RunningEnv () +runMultipleShips :: [(CLI.Run, CLI.Opts)] -> RIO HostEnv () runMultipleShips ships = do shipThreads <- for ships $ \(r, o) -> do async (runShipRestarting r o) From 1183ac0b22e14c6ea11c458026e8295f8ced4a39 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 13 Aug 2020 11:12:26 -0400 Subject: [PATCH 161/933] natpmp: checkpoint while addressing comments --- .../natpmp-static/hsrc_lib/Network/NatPmp.hsc | 26 +- pkg/hs/urbit-king/lib/Urbit/King/App.hs | 8 +- pkg/hs/urbit-king/lib/Urbit/King/CLI.hs | 6 +- pkg/hs/urbit-king/lib/Urbit/King/Main.hs | 90 +++---- pkg/hs/urbit-king/lib/Urbit/Vere/Ames/UDP.hs | 3 +- pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs | 3 +- pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs | 253 +++++++++--------- pkg/hs/urbit-king/test/AmesTests.hs | 7 +- 8 files changed, 196 insertions(+), 200 deletions(-) diff --git a/pkg/hs/natpmp-static/hsrc_lib/Network/NatPmp.hsc b/pkg/hs/natpmp-static/hsrc_lib/Network/NatPmp.hsc index 3fbb89296c..e349d0a20a 100644 --- a/pkg/hs/natpmp-static/hsrc_lib/Network/NatPmp.hsc +++ b/pkg/hs/natpmp-static/hsrc_lib/Network/NatPmp.hsc @@ -206,20 +206,20 @@ instance Enum Error where initNatPmp :: MonadIO m => m (Either Error NatPmpHandle) -initNatPmp = do - natpmp <- liftIO $ mallocBytes #{size natpmp_t} - ret <- liftIO $ _init_nat_pmp natpmp 0 0 +initNatPmp = liftIO do + natpmp <- mallocBytes #{size natpmp_t} + ret <- _init_nat_pmp natpmp 0 0 case ret of 0 -> pure $ Right natpmp _ -> do - liftIO $ free natpmp + free natpmp pure $ Left $ intToEnum ret closeNatPmp :: MonadIO m => NatPmpHandle -> m (Either Error ()) -closeNatPmp handle = do - ret <- liftIO $ _close_nat_pmp handle - liftIO $ free handle +closeNatPmp handle = liftIO do + ret <- _close_nat_pmp handle + free handle case ret of 0 -> pure $ Right () _ -> pure $ Left $ intToEnum ret @@ -227,10 +227,10 @@ closeNatPmp handle = do -- Public interface for getting the public IPv4 address getPublicAddress :: MonadIO m => NatPmpHandle -> m (Either Error HostAddress) -getPublicAddress natpmp = do - sendRetcode <- liftIO $ sendPublicAddressRequest natpmp +getPublicAddress natpmp = liftIO do + sendRetcode <- sendPublicAddressRequest natpmp case sendRetcode of - 2 -> liftIO $ alloca $ \(pResponse :: NatPmpResponseHandle) -> do + 2 -> alloca $ \(pResponse :: NatPmpResponseHandle) -> do respRetcode <- readNatResponseSynchronously natpmp pResponse case respRetcode of 0 -> peek pResponse >>= \case @@ -247,15 +247,15 @@ setPortMapping :: MonadIO m -> Port -> LifetimeSeconds -> m (Either Error ()) -setPortMapping natpmp protocol privatePort publicPort lifetime = do +setPortMapping natpmp protocol privatePort publicPort lifetime = liftIO do let protocolNum = fromEnum protocol sendResp <- - liftIO $ sendNewPortMappingRequest natpmp + sendNewPortMappingRequest natpmp (fromIntegral protocolNum) (CUShort privatePort) (CUShort publicPort) (CUInt lifetime) case sendResp of - 12 -> liftIO $ alloca $ \(pResponse :: NatPmpResponseHandle) -> do + 12 -> alloca $ \(pResponse :: NatPmpResponseHandle) -> do respRetcode <- readNatResponseSynchronously natpmp pResponse case respRetcode of 0 -> peek pResponse >>= \case diff --git a/pkg/hs/urbit-king/lib/Urbit/King/App.hs b/pkg/hs/urbit-king/lib/Urbit/King/App.hs index b10ba12e3f..5c263748ce 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/App.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/App.hs @@ -141,8 +141,8 @@ class (HasKingEnv a, HasMultiEyreApi a, HasPortControlApi a) => data HostEnv = HostEnv { _hostEnvKingEnv :: !KingEnv - , _hostEnvMultiEyreApi :: MultiEyreApi - , _hostEnvPortControlApi :: PortControlApi + , _hostEnvMultiEyreApi :: !MultiEyreApi + , _hostEnvPortControlApi :: !PortControlApi } makeLenses ''HostEnv @@ -170,8 +170,8 @@ instance HasPortControlApi HostEnv where -- Running Running Envs -------------------------------------------------------- -runHostEnv :: MultiEyreApi -> PortControlApi -> RIO HostEnv () - -> RIO KingEnv () +runHostEnv :: MultiEyreApi -> PortControlApi -> RIO HostEnv a + -> RIO KingEnv a runHostEnv multi ports action = do king <- ask diff --git a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs index 19ddb09f81..c0e72369df 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs @@ -197,11 +197,9 @@ pillFromURL = PillSourceURL <$> strOption <> help "URL to pill file") enableNAT :: Parser Bool -enableNAT = (flag' False +enableNAT = not <$> switch ( long "no-port-forwarding" - <> help "Disable trying to ask the router to forward ames ports")) - <|> - (pure True) + <> help "Disable trying to ask the router to forward ames ports") pierPath :: Parser FilePath pierPath = strArgument (metavar "PIER" <> help "Path to pier") diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs index 502134a190..7ee35b5445 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs @@ -474,47 +474,45 @@ newShip CLI.New{..} opts = do -} multi <- multiEyre (MultiEyreConf Nothing Nothing True) - -- TODO: We hit the same problem as above: we need the running options to - -- determine how to configure the ports + -- TODO: We hit the same problem as above: we need a host env to boot a ship + -- because it may autostart the ship, so build an inactive port configuration. let ports = buildInactivePorts -- here we are with a king env, and we now need a multi env. - runHostEnv multi ports go + runHostEnv multi ports $ case nBootType of + CLI.BootComet -> do + pill <- pillFrom nPillSource + putStrLn "boot: retrieving list of stars currently accepting comets" + starList <- dawnCometList + putStrLn ("boot: " ++ (tshow $ length starList) ++ + " star(s) currently accepting comets") + putStrLn "boot: mining a comet" + eny <- io $ Sys.randomIO + let seed = mineComet (Set.fromList starList) eny + putStrLn ("boot: found comet " ++ renderShip (sShip seed)) + bootFromSeed pill seed + + CLI.BootFake name -> do + pill <- pillFrom nPillSource + ship <- shipFrom name + runTryBootFromPill pill name ship (Fake ship) + + CLI.BootFromKeyfile keyFile -> do + text <- readFileUtf8 keyFile + asAtom <- case cordToUW (Cord $ T.strip text) of + Nothing -> error "Couldn't parse keyfile. Hint: keyfiles start with 0w?" + Just (UW a) -> pure a + + asNoun <- cueExn asAtom + seed :: Seed <- case fromNoun asNoun of + Nothing -> error "Keyfile does not seem to contain a seed." + Just s -> pure s + + pill <- pillFrom nPillSource + + bootFromSeed pill seed + where - go :: RIO HostEnv () - go = case nBootType of - CLI.BootComet -> do - pill <- pillFrom nPillSource - putStrLn "boot: retrieving list of stars currently accepting comets" - starList <- dawnCometList - putStrLn ("boot: " ++ (tshow $ length starList) ++ - " star(s) currently accepting comets") - putStrLn "boot: mining a comet" - eny <- io $ Sys.randomIO - let seed = mineComet (Set.fromList starList) eny - putStrLn ("boot: found comet " ++ renderShip (sShip seed)) - bootFromSeed pill seed - - CLI.BootFake name -> do - pill <- pillFrom nPillSource - ship <- shipFrom name - runTryBootFromPill pill name ship (Fake ship) - - CLI.BootFromKeyfile keyFile -> do - text <- readFileUtf8 keyFile - asAtom <- case cordToUW (Cord $ T.strip text) of - Nothing -> error "Couldn't parse keyfile. Hint: keyfiles start with 0w?" - Just (UW a) -> pure a - - asNoun <- cueExn asAtom - seed :: Seed <- case fromNoun asNoun of - Nothing -> error "Keyfile does not seem to contain a seed." - Just s -> pure s - - pill <- pillFrom nPillSource - - bootFromSeed pill seed - shipFrom :: Text -> RIO HostEnv Ship shipFrom name = case Ob.parsePatp name of Left x -> error "Invalid ship name" @@ -525,7 +523,7 @@ newShip CLI.New{..} opts = do Just x -> x Nothing -> "./" <> unpack name - nameFromShip :: Ship -> RIO HostEnv Text + nameFromShip :: HasKingEnv e => Ship -> RIO e Text nameFromShip s = name where nameWithSig = Ob.renderPatp $ Ob.patp $ fromIntegral s @@ -546,16 +544,17 @@ newShip CLI.New{..} opts = do -- Now that we have all the information for running an application with a -- PierConfig, do so. - runTryBootFromPill :: Pill -> Text -> Ship -> LegacyBootEvent + runTryBootFromPill :: Pill + -> Text + -> Ship + -> LegacyBootEvent -> RIO HostEnv () runTryBootFromPill pill name ship bootEvent = do - env <- ask - let vKill = (env ^. kingEnvL) ^. kingEnvKillSignal + vKill <- asks (^. kingEnvL . kingEnvKillSignal) let pierConfig = toPierConfig (pierPath name) opts let networkConfig = toNetworkConfig opts runPierEnv pierConfig networkConfig vKill $ tryBootFromPill True pill nLite ship bootEvent ------- tryBootFromPill (CLI.oExit opts) pill nLite flags ship bootEvent runShipEnv :: CLI.Run -> CLI.Opts -> TMVar () -> RIO PierEnv a -> RIO HostEnv a runShipEnv (CLI.Run pierPath) opts vKill act = do @@ -591,8 +590,8 @@ runShip (CLI.Run pierPath) opts daemon = do mStart -buildPortHandler :: (HasLogFunc e) => Bool -> RIO e PortControlApi -buildPortHandler False = pure $ buildInactivePorts +buildPortHandler :: HasLogFunc e => Bool -> RIO e PortControlApi +buildPortHandler False = pure buildInactivePorts -- TODO: Figure out what to do about logging here. The "port: " messages are -- the sort of thing that should be put on the muxed terminal log, but we don't -- have that at this layer. @@ -725,8 +724,7 @@ runShipNoRestart :: CLI.Run -> CLI.Opts -> Bool -> RIO HostEnv () runShipNoRestart r o d = do -- killing ship same as killing king - env <- ask - let vKill = (env ^. kingEnvL) ^. kingEnvKillSignal + vKill <- asks (^. kingEnvL . kingEnvKillSignal) tid <- asyncBound (runShipEnv r o vKill $ runShip r o d) onKill <- view onKillKingSigL diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/UDP.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/UDP.hs index c140e940ee..0dc758b46b 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/UDP.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/UDP.hs @@ -152,7 +152,8 @@ fakeUdpServ = do Real UDP server. See module-level docs. -} realUdpServ - :: forall e . (HasLogFunc e, HasPortControlApi e) + :: forall e + . (HasLogFunc e, HasPortControlApi e) => PortNumber -> HostAddress -> RIO e UdpServ diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs index 3c0df3079a..641b7061a3 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs @@ -179,8 +179,7 @@ startServ startServ who isFake conf plan = do logDebug (displayShow ("EYRE", "startServ")) - env <- ask - let multi = env ^. multiEyreApiL + multi <- asks (^. multiEyreApiL) let vLive = meaLive multi diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs index a311c30717..f02659427f 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs @@ -23,32 +23,31 @@ data PortControlApi = PortControlApi , pRemovePortRequest :: Word16 -> IO () } --- Builds a Ports struct which does nothing when called. +-- | Builds a PortControlApi struct which does nothing when called. buildInactivePorts :: PortControlApi buildInactivePorts = PortControlApi noop noop - where - noop x = pure () + where + noop x = pure () --- Builds a Ports struct which tries to hole-punch by talking to the NAT --- gateway over NAT-PMP. +-- | Builds a PortControlApi struct which tries to hole-punch by talking to the +-- NAT gateway over NAT-PMP. buildNATPorts :: (HasLogFunc e) => (Text -> RIO e ()) -> RIO e PortControlApi buildNATPorts stderr = do q <- newTQueueIO async $ portThread q stderr - pure $ PortControlApi (addRequest q) (removeRequest q) - where - addRequest :: TQueue PortThreadMsg -> Word16 -> IO () - addRequest q port = do - resp <- newEmptyTMVarIO - atomically $ - writeTQueue q (PTMInitialRequestOpen port (putTMVar resp True)) - atomically $ takeTMVar resp - pure () - removeRequest :: TQueue PortThreadMsg -> Word16 -> IO () - removeRequest q port = atomically $ writeTQueue q (PTMRequestClose port) + let addRequest port = do + resp <- newEmptyTMVarIO + atomically $ + writeTQueue q (PTMInitialRequestOpen port (putTMVar resp True)) + atomically $ takeTMVar resp + pure () + + let removeRequest port = atomically $ writeTQueue q (PTMRequestClose port) + + pure $ PortControlApi addRequest removeRequest portLeaseLifetime :: Word32 portLeaseLifetime = 15 * 60 @@ -102,120 +101,120 @@ portThread q stderr = do stderr $ "port: couldn't find router; assuming on public internet" loopErr q Right pmp -> foundRouter pmp - where - foundRouter :: NatPmpHandle -> RIO e () - foundRouter pmp = do - pubAddr <- getPublicAddress pmp - case pubAddr of - Left _ -> pure () - Right addr -> do - let (a, b, c, d) = hostAddressToTuple addr - stderr $ "port: router reports that our public IP is " ++ (tshow a) ++ - "." ++ (tshow b) ++ "." ++ (tshow c) ++ "." ++ (tshow d) - loop pmp mempty + where + foundRouter :: NatPmpHandle -> RIO e () + foundRouter pmp = do + pubAddr <- getPublicAddress pmp + case pubAddr of + Left _ -> pure () + Right addr -> do + let (a, b, c, d) = hostAddressToTuple addr + stderr $ "port: router reports that our public IP is " ++ (tshow a) ++ + "." ++ (tshow b) ++ "." ++ (tshow c) ++ "." ++ (tshow d) + loop pmp mempty - loop :: NatPmpHandle -> MinPrioHeap POSIXTime PortThreadMsg -> RIO e () - loop pmp nextRenew = forever $ do - now <- io $ getPOSIXTime - delay <- case viewHead nextRenew of - Nothing -> newTVarIO False - Just (fireTime, _) -> do - let timeTo = fireTime - now - let ms = round $ timeTo * 1000000 - registerDelay ms - command <- atomically $ - (Left <$> fini delay) <|> (Right <$> readTQueue q) - case command of - Left () -> do - -- the timeout has fired, meaning the top of the heap should be - -- popped and rerun. - case (Data.Heap.view nextRenew) of - Nothing -> error "Internal heap managing error." - Just ((_, msg), rest) -> handlePTM pmp msg rest - Right msg -> handlePTM pmp msg nextRenew + loop :: NatPmpHandle -> MinPrioHeap POSIXTime PortThreadMsg -> RIO e () + loop pmp nextRenew = forever $ do + now <- io $ getPOSIXTime + delay <- case viewHead nextRenew of + Nothing -> newTVarIO False + Just (fireTime, _) -> do + let timeTo = fireTime - now + let ms = round $ timeTo * 1000000 + registerDelay ms + command <- atomically $ + (Left <$> fini delay) <|> (Right <$> readTQueue q) + case command of + Left () -> do + -- the timeout has fired, meaning the top of the heap should be + -- popped and rerun. + case (Data.Heap.view nextRenew) of + Nothing -> error "Internal heap managing error." + Just ((_, msg), rest) -> handlePTM pmp msg rest + Right msg -> handlePTM pmp msg nextRenew - handlePTM :: NatPmpHandle - -> PortThreadMsg - -> MinPrioHeap POSIXTime PortThreadMsg - -> RIO e () - handlePTM pmp msg nextRenew = case msg of - PTMInitialRequestOpen p notifyComplete -> do - logInfo $ - displayShow ("port: sending initial request to NAT-PMP for port ", p) - ret <- setPortMapping pmp PTUdp p p portLeaseLifetime - case ret of - Left err -> do - logError $ - displayShow ("port: failed to request NAT-PMP for port ", p, - ":", err, ", disabling NAT-PMP") - loopErr q - Right _ -> do - let filteredPort = filterPort p nextRenew - now <- io $ getPOSIXTime - let repeatMsg = PTMRequestOpen p - let withRenew = - insert (now + (fromIntegral portRenewalTime), repeatMsg) - filteredPort - atomically notifyComplete - loop pmp withRenew + handlePTM :: NatPmpHandle + -> PortThreadMsg + -> MinPrioHeap POSIXTime PortThreadMsg + -> RIO e () + handlePTM pmp msg nextRenew = case msg of + PTMInitialRequestOpen p notifyComplete -> do + logInfo $ + displayShow ("port: sending initial request to NAT-PMP for port ", p) + ret <- setPortMapping pmp PTUdp p p portLeaseLifetime + case ret of + Left err -> do + logError $ + displayShow ("port: failed to request NAT-PMP for port ", p, + ":", err, ", disabling NAT-PMP") + loopErr q + Right _ -> do + let filteredPort = filterPort p nextRenew + now <- io $ getPOSIXTime + let repeatMsg = PTMRequestOpen p + let withRenew = + insert (now + fromIntegral portRenewalTime, repeatMsg) + filteredPort + atomically notifyComplete + loop pmp withRenew - PTMRequestOpen p -> do - logInfo $ - displayShow ("port: sending renewing request to NAT-PMP for port ", - p) - ret <- setPortMapping pmp PTUdp p p portLeaseLifetime - case ret of - Left err -> do - logError $ - displayShow ("port: failed to request NAT-PMP for port ", p, - ":", err, ", disabling NAT-PMP") - loopErr q - Right _ -> do - let filteredPort = filterPort p nextRenew - now <- io $ getPOSIXTime - let withRenew = - insert (now + (fromIntegral portRenewalTime), msg) filteredPort - loop pmp withRenew + PTMRequestOpen p -> do + logInfo $ + displayShow ("port: sending renewing request to NAT-PMP for port ", + p) + ret <- setPortMapping pmp PTUdp p p portLeaseLifetime + case ret of + Left err -> do + logError $ + displayShow ("port: failed to request NAT-PMP for port ", p, + ":", err, ", disabling NAT-PMP") + loopErr q + Right _ -> do + let filteredPort = filterPort p nextRenew + now <- io $ getPOSIXTime + let withRenew = + insert (now + (fromIntegral portRenewalTime), msg) filteredPort + loop pmp withRenew - PTMRequestClose p -> do - logInfo $ - displayShow ("port: releasing lease for ", p) - setPortMapping pmp PTUdp p p 0 - let removed = filterPort p nextRenew - loop pmp removed + PTMRequestClose p -> do + logInfo $ + displayShow ("port: releasing lease for ", p) + setPortMapping pmp PTUdp p p 0 + let removed = filterPort p nextRenew + loop pmp removed - filterPort :: Word16 - -> MinPrioHeap POSIXTime PortThreadMsg - -> MinPrioHeap POSIXTime PortThreadMsg - filterPort p = Data.Heap.filter okPort - where - -- initial requests should never be in the heap - okPort (_, PTMInitialRequestOpen _ _) = False - okPort (_, PTMRequestOpen x) = p /= x - okPort (_, PTMRequestClose x) = p /= x + filterPort :: Word16 + -> MinPrioHeap POSIXTime PortThreadMsg + -> MinPrioHeap POSIXTime PortThreadMsg + filterPort p = Data.Heap.filter okPort + where + -- initial requests should never be in the heap + okPort (_, PTMInitialRequestOpen _ _) = False + okPort (_, PTMRequestOpen x) = p /= x + okPort (_, PTMRequestClose x) = p /= x - -- block (retry) until the delay TVar is set to True - fini :: TVar Bool -> STM () - fini = check <=< readTVar + -- block (retry) until the delay TVar is set to True + fini :: TVar Bool -> STM () + fini = check <=< readTVar - -- The NAT system is considered "off" but we still need to signal back to - -- the main thread that blocking actions are copmlete - loopErr q = forever $ do - (atomically $ readTQueue q) >>= \case - PTMInitialRequestOpen _ onComplete -> atomically onComplete - PTMRequestOpen _ -> pure () - PTMRequestClose _ -> pure () + -- The NAT system is considered "off" but we still need to signal back to + -- the main thread that blocking actions are copmlete + loopErr q = forever $ do + (atomically $ readTQueue q) >>= \case + PTMInitialRequestOpen _ onComplete -> atomically onComplete + PTMRequestOpen _ -> pure () + PTMRequestClose _ -> pure () -- When we were unable to connect to a router, get the ip address on the -- default ipv4 interface to check if it -likelyIPAddress :: RIO e (Maybe (Word8, Word8, Word8, Word8)) -likelyIPAddress = do +likelyIPAddress :: MonadIO m => m (Maybe (Word8, Word8, Word8, Word8)) +likelyIPAddress = liftIO do -- Try opening a socket to 1.1.1.1 to get our own IP address. Since UDP is -- stateless and we aren't sending anything, we aren't actually contacting -- them in any way. - sock <- io $ socket AF_INET Datagram 0 - io $ connect sock (SockAddrInet 53 (tupleToHostAddress (8, 8, 8, 8))) - sockAddr <- io $ getSocketName sock + sock <- socket AF_INET Datagram 0 + connect sock (SockAddrInet 53 (tupleToHostAddress (8, 8, 8, 8))) + sockAddr <- getSocketName sock case sockAddr of SockAddrInet _ addr -> pure $ Just $ hostAddressToTuple addr _ -> pure $ Nothing @@ -224,16 +223,14 @@ likelyIPAddress = do requestPortAccess :: forall e. (HasPortControlApi e) => Word16 -> RAcquire e () requestPortAccess port = do mkRAcquire request release - where - request :: RIO e () - request = do - env <- ask - let api = env ^. portControlApiL - io $ (pAddPortRequest api) port + where + request :: RIO e () + request = do + api <- asks (^. portControlApiL) + io $ pAddPortRequest api port - release :: () -> RIO e () - release _ = do - env <- ask - let api = env ^. portControlApiL - io $ (pRemovePortRequest api) port + release :: () -> RIO e () + release _ = do + api <- asks (^. portControlApiL) + io $ pRemovePortRequest api port diff --git a/pkg/hs/urbit-king/test/AmesTests.hs b/pkg/hs/urbit-king/test/AmesTests.hs index 6356a7148c..334acccd16 100644 --- a/pkg/hs/urbit-king/test/AmesTests.hs +++ b/pkg/hs/urbit-king/test/AmesTests.hs @@ -28,8 +28,11 @@ import qualified Urbit.EventLog.LMDB as Log -------------------------------------------------------------------------------- -type HasAmes e = (HasLogFunc e, HasNetworkConfig e, HasKingId e, - HasPortControlApi e) +type HasAmes e = + ( HasLogFunc e + , HasNetworkConfig e + , HasKingId e + , HasPortControlApi e) -- Utils ----------------------------------------------------------------------- From a3336fde4145dbe22a6f959816a984131739f05c Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 13 Aug 2020 11:49:38 -0400 Subject: [PATCH 162/933] natpmp: more nits --- .../natpmp-static/hsrc_lib/Network/NatPmp.hsc | 22 ++++++------ pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs | 34 ++++++++----------- pkg/hs/urbit-king/test/AmesTests.hs | 2 +- 3 files changed, 27 insertions(+), 31 deletions(-) diff --git a/pkg/hs/natpmp-static/hsrc_lib/Network/NatPmp.hsc b/pkg/hs/natpmp-static/hsrc_lib/Network/NatPmp.hsc index e349d0a20a..f410625d62 100644 --- a/pkg/hs/natpmp-static/hsrc_lib/Network/NatPmp.hsc +++ b/pkg/hs/natpmp-static/hsrc_lib/Network/NatPmp.hsc @@ -91,8 +91,7 @@ intToEnum = toEnum . fromIntegral getDefaultGateway :: IO (Maybe HostAddress) getDefaultGateway = alloca $ \(pReturnAddr :: Ptr CUInt) -> do - ret <- _get_default_gateway pReturnAddr - case ret of + _get_default_gateway pReturnAddr >>= \case 0 -> (Just . fromIntegral) <$> _peekCUInt pReturnAddr _ -> pure Nothing @@ -151,7 +150,7 @@ data Error | ErrOutOfResources -- | ErrTryAgain - | ErrHaskellBindingsErr + | ErrHaskellBindings deriving (Eq, Show) instance Enum Error where @@ -177,7 +176,7 @@ instance Enum Error where fromEnum ErrOutOfResources = -53 -- fromEnum ErrTryAgain = -100 - fromEnum ErrHaskellBindingsErr = -200 + fromEnum ErrHaskellBindings = -200 toEnum (-1) = ErrInvalidArgs toEnum (-2) = ErrSocketError @@ -201,7 +200,7 @@ instance Enum Error where toEnum (-53) = ErrOutOfResources -- toEnum (-100) = ErrTryAgain - toEnum (-200) = ErrHaskellBindingsErr + toEnum (-200) = ErrHaskellBindings toEnum unmatched = error ("Error.toEnum: Cannot match " ++ show unmatched) @@ -225,7 +224,7 @@ closeNatPmp handle = liftIO do _ -> pure $ Left $ intToEnum ret --- Public interface for getting the public IPv4 address +-- | Public interface for getting the public IPv4 address getPublicAddress :: MonadIO m => NatPmpHandle -> m (Either Error HostAddress) getPublicAddress natpmp = liftIO do sendRetcode <- sendPublicAddressRequest natpmp @@ -235,11 +234,12 @@ getPublicAddress natpmp = liftIO do case respRetcode of 0 -> peek pResponse >>= \case NatPmpResponsePublicAddress addr -> pure $ Right addr - _ -> pure $ Left ErrHaskellBindingsErr + _ -> pure $ Left ErrHaskellBindings _ -> pure $ Left $ intToEnum respRetcode _ -> pure $ Left $ intToEnum sendRetcode - +-- | Requests that the router maps the privatePort on our local computer in our +-- private network to publicPort on the public internet. setPortMapping :: MonadIO m => NatPmpHandle -> ProtocolType @@ -251,8 +251,8 @@ setPortMapping natpmp protocol privatePort publicPort lifetime = liftIO do let protocolNum = fromEnum protocol sendResp <- sendNewPortMappingRequest natpmp - (fromIntegral protocolNum) (CUShort privatePort) (CUShort publicPort) - (CUInt lifetime) + (fromIntegral protocolNum) (CUShort privatePort) (CUShort publicPort) + (CUInt lifetime) case sendResp of 12 -> alloca $ \(pResponse :: NatPmpResponseHandle) -> do @@ -261,6 +261,6 @@ setPortMapping natpmp protocol privatePort publicPort lifetime = liftIO do 0 -> peek pResponse >>= \case NatPmpResponseUdpPortMapping _ _ _ -> pure $ Right () NatPmpResponseTcpPortMapping _ _ _ -> pure $ Right () - _ -> pure $ Left ErrHaskellBindingsErr + _ -> pure $ Left ErrHaskellBindings _ -> pure $ Left $ intToEnum respRetcode x -> pure $ Left $ intToEnum x diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs index f02659427f..588cf74fe3 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs @@ -1,5 +1,5 @@ module Urbit.Vere.Ports (HasPortControlApi(..), - PortControlApi(..), + PortControlApi, buildInactivePorts, buildNATPorts, requestPortAccess) where @@ -83,12 +83,9 @@ portThread :: forall e. (HasLogFunc e) -> (Text -> RIO e ()) -> RIO e () portThread q stderr = do - pmp <- initNatPmp - --pmp <- pure $ Left ErrNoGatewaySupport - case pmp of + initNatPmp >>= \case Left err -> do - ip <- likelyIPAddress - case ip of + likelyIPAddress >>= \case Just (192, 168, c, d) -> do stderr $ "port: you appear to be behind a router since your ip " ++ "is 192.168." ++ (tshow c) ++ "." ++ (tshow d) ++ ", but " ++ @@ -104,8 +101,7 @@ portThread q stderr = do where foundRouter :: NatPmpHandle -> RIO e () foundRouter pmp = do - pubAddr <- getPublicAddress pmp - case pubAddr of + getPublicAddress pmp >>= \case Left _ -> pure () Right addr -> do let (a, b, c, d) = hostAddressToTuple addr @@ -114,7 +110,7 @@ portThread q stderr = do loop pmp mempty loop :: NatPmpHandle -> MinPrioHeap POSIXTime PortThreadMsg -> RIO e () - loop pmp nextRenew = forever $ do + loop pmp nextRenew = do now <- io $ getPOSIXTime delay <- case viewHead nextRenew of Nothing -> newTVarIO False @@ -141,20 +137,19 @@ portThread q stderr = do PTMInitialRequestOpen p notifyComplete -> do logInfo $ displayShow ("port: sending initial request to NAT-PMP for port ", p) - ret <- setPortMapping pmp PTUdp p p portLeaseLifetime - case ret of + setPortMapping pmp PTUdp p p portLeaseLifetime >>= \case Left err -> do logError $ displayShow ("port: failed to request NAT-PMP for port ", p, ":", err, ", disabling NAT-PMP") loopErr q Right _ -> do - let filteredPort = filterPort p nextRenew + let filteredHeap = filterPort p nextRenew now <- io $ getPOSIXTime let repeatMsg = PTMRequestOpen p let withRenew = insert (now + fromIntegral portRenewalTime, repeatMsg) - filteredPort + filteredHeap atomically notifyComplete loop pmp withRenew @@ -170,10 +165,10 @@ portThread q stderr = do ":", err, ", disabling NAT-PMP") loopErr q Right _ -> do - let filteredPort = filterPort p nextRenew + let filteredHeap = filterPort p nextRenew now <- io $ getPOSIXTime let withRenew = - insert (now + (fromIntegral portRenewalTime), msg) filteredPort + insert (now + (fromIntegral portRenewalTime), msg) filteredHeap loop pmp withRenew PTMRequestClose p -> do @@ -198,22 +193,23 @@ portThread q stderr = do fini = check <=< readTVar -- The NAT system is considered "off" but we still need to signal back to - -- the main thread that blocking actions are copmlete + -- the main thread that blocking actions are complete. loopErr q = forever $ do - (atomically $ readTQueue q) >>= \case + readTQueueIO q >>= \case PTMInitialRequestOpen _ onComplete -> atomically onComplete PTMRequestOpen _ -> pure () PTMRequestClose _ -> pure () -- When we were unable to connect to a router, get the ip address on the --- default ipv4 interface to check if it +-- default ipv4 interface to check if we look like we're on an internal network +-- or not. likelyIPAddress :: MonadIO m => m (Maybe (Word8, Word8, Word8, Word8)) likelyIPAddress = liftIO do -- Try opening a socket to 1.1.1.1 to get our own IP address. Since UDP is -- stateless and we aren't sending anything, we aren't actually contacting -- them in any way. sock <- socket AF_INET Datagram 0 - connect sock (SockAddrInet 53 (tupleToHostAddress (8, 8, 8, 8))) + connect sock (SockAddrInet 53 (tupleToHostAddress (1, 1, 1, 1))) sockAddr <- getSocketName sock case sockAddr of SockAddrInet _ addr -> pure $ Just $ hostAddressToTuple addr diff --git a/pkg/hs/urbit-king/test/AmesTests.hs b/pkg/hs/urbit-king/test/AmesTests.hs index 334acccd16..41080dd145 100644 --- a/pkg/hs/urbit-king/test/AmesTests.hs +++ b/pkg/hs/urbit-king/test/AmesTests.hs @@ -48,7 +48,7 @@ sendEf g w bs = NewtEfSend (0, ()) (EachYes g) bs data NetworkTestApp = NetworkTestApp { _ntaLogFunc :: !LogFunc , _ntaNetworkConfig :: !NetworkConfig - , _ntaPortControlApi :: PortControlApi + , _ntaPortControlApi :: !PortControlApi , _ntaKingId :: !Word16 } From b4878a8b032822c99d1fac09a2907f032bebf4ea Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 13 Aug 2020 13:36:20 -0400 Subject: [PATCH 163/933] natpmp: Separate out the PortThreadMsgs from the heap actions. --- pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs | 86 +++++++++++------------ 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs index 588cf74fe3..873d7e1d30 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs @@ -41,7 +41,7 @@ buildNATPorts stderr = do let addRequest port = do resp <- newEmptyTMVarIO atomically $ - writeTQueue q (PTMInitialRequestOpen port (putTMVar resp True)) + writeTQueue q (PTMRequestOpen port (putTMVar resp True)) atomically $ takeTMVar resp pure () @@ -58,19 +58,21 @@ portRenewalTime = portLeaseLifetime - 60 -- Messages sent from the main thread to the port mapping communication thread. data PortThreadMsg - = PTMInitialRequestOpen Word16 (STM ()) + = PTMRequestOpen Word16 (STM ()) -- ^ Does the open request, and then calls the passed in stm action to -- singal completion to the main thread. We want to block on the initial -- setting opening because we want the forwarding set up before we actually -- start using the port. - | PTMRequestOpen Word16 - -- ^ Repeating open command we send to ourselves. - | PTMRequestClose Word16 -- ^ Close command. No synchronization because there's nothing we can do if -- it fails. +-- We get requests to acquire a port as an RAII condition, but the actual APIs +-- are timeout based, so we have to maintain a heap of the next timer to +-- rerequest port access. +data RenewAction = RenewAction Word16 + -- The port thread is an async which reads commands from an STM queue and then -- executes them. This thread is here to bind the semantics that we want to how -- NAT-PMP sees the world. We want for an RAcquire to be able to start a @@ -109,7 +111,7 @@ portThread q stderr = do "." ++ (tshow b) ++ "." ++ (tshow c) ++ "." ++ (tshow d) loop pmp mempty - loop :: NatPmpHandle -> MinPrioHeap POSIXTime PortThreadMsg -> RIO e () + loop :: NatPmpHandle -> MinPrioHeap POSIXTime RenewAction -> RIO e () loop pmp nextRenew = do now <- io $ getPOSIXTime delay <- case viewHead nextRenew of @@ -121,20 +123,15 @@ portThread q stderr = do command <- atomically $ (Left <$> fini delay) <|> (Right <$> readTQueue q) case command of - Left () -> do - -- the timeout has fired, meaning the top of the heap should be - -- popped and rerun. - case (Data.Heap.view nextRenew) of - Nothing -> error "Internal heap managing error." - Just ((_, msg), rest) -> handlePTM pmp msg rest + Left () -> handleRenew pmp nextRenew Right msg -> handlePTM pmp msg nextRenew handlePTM :: NatPmpHandle -> PortThreadMsg - -> MinPrioHeap POSIXTime PortThreadMsg + -> MinPrioHeap POSIXTime RenewAction -> RIO e () handlePTM pmp msg nextRenew = case msg of - PTMInitialRequestOpen p notifyComplete -> do + PTMRequestOpen p notifyComplete -> do logInfo $ displayShow ("port: sending initial request to NAT-PMP for port ", p) setPortMapping pmp PTUdp p p portLeaseLifetime >>= \case @@ -144,33 +141,16 @@ portThread q stderr = do ":", err, ", disabling NAT-PMP") loopErr q Right _ -> do + -- Filter any existing references to this port on the heap to ensure + -- we don't double up on tasks. let filteredHeap = filterPort p nextRenew now <- io $ getPOSIXTime - let repeatMsg = PTMRequestOpen p let withRenew = - insert (now + fromIntegral portRenewalTime, repeatMsg) + insert (now + fromIntegral portRenewalTime, RenewAction p) filteredHeap atomically notifyComplete loop pmp withRenew - PTMRequestOpen p -> do - logInfo $ - displayShow ("port: sending renewing request to NAT-PMP for port ", - p) - ret <- setPortMapping pmp PTUdp p p portLeaseLifetime - case ret of - Left err -> do - logError $ - displayShow ("port: failed to request NAT-PMP for port ", p, - ":", err, ", disabling NAT-PMP") - loopErr q - Right _ -> do - let filteredHeap = filterPort p nextRenew - now <- io $ getPOSIXTime - let withRenew = - insert (now + (fromIntegral portRenewalTime), msg) filteredHeap - loop pmp withRenew - PTMRequestClose p -> do logInfo $ displayShow ("port: releasing lease for ", p) @@ -178,15 +158,36 @@ portThread q stderr = do let removed = filterPort p nextRenew loop pmp removed + handleRenew :: NatPmpHandle + -> MinPrioHeap POSIXTime RenewAction + -> RIO e () + handleRenew pmp nextRenew = do + case (Data.Heap.view nextRenew) of + Nothing -> error "Internal heap managing error." + Just ((_, RenewAction p), rest) -> do + logInfo $ + displayShow ("port: sending renewing request to NAT-PMP for port ", + p) + setPortMapping pmp PTUdp p p portLeaseLifetime >>= \case + Left err -> do + logError $ + displayShow ("port: failed to request NAT-PMP for port ", p, + ":", err, ", disabling NAT-PMP") + loopErr q + Right _ -> do + -- We don't need to filter the port because we just did. + now <- io $ getPOSIXTime + let withRenew = + insert (now + (fromIntegral portRenewalTime), RenewAction p) + rest + loop pmp withRenew + filterPort :: Word16 - -> MinPrioHeap POSIXTime PortThreadMsg - -> MinPrioHeap POSIXTime PortThreadMsg + -> MinPrioHeap POSIXTime RenewAction + -> MinPrioHeap POSIXTime RenewAction filterPort p = Data.Heap.filter okPort where - -- initial requests should never be in the heap - okPort (_, PTMInitialRequestOpen _ _) = False - okPort (_, PTMRequestOpen x) = p /= x - okPort (_, PTMRequestClose x) = p /= x + okPort (_, RenewAction x) = p /= x -- block (retry) until the delay TVar is set to True fini :: TVar Bool -> STM () @@ -195,9 +196,8 @@ portThread q stderr = do -- The NAT system is considered "off" but we still need to signal back to -- the main thread that blocking actions are complete. loopErr q = forever $ do - readTQueueIO q >>= \case - PTMInitialRequestOpen _ onComplete -> atomically onComplete - PTMRequestOpen _ -> pure () + (atomically $ readTQueue q) >>= \case + PTMRequestOpen _ onComplete -> atomically onComplete PTMRequestClose _ -> pure () -- When we were unable to connect to a router, get the ip address on the From 14d1b59117ab1494ac8a840eb5d6b240debab39c Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 14 Aug 2020 10:23:39 -0400 Subject: [PATCH 164/933] natpmp: even more cleanup --- pkg/hs/urbit-king/lib/Urbit/King/App.hs | 12 ++-- pkg/hs/urbit-king/lib/Urbit/King/CLI.hs | 6 +- pkg/hs/urbit-king/lib/Urbit/King/Main.hs | 6 +- pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs | 2 +- pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs | 87 ++++++++++++----------- 5 files changed, 59 insertions(+), 54 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/App.hs b/pkg/hs/urbit-king/lib/Urbit/King/App.hs index 5c263748ce..9f152c6f2b 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/App.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/App.hs @@ -127,10 +127,8 @@ killKingActionL = -- HostEnv ------------------------------------------------------------------ --- The running environment is everything in King, eyre configuration shared --- across ships, and IP information shared across ships. --- --- TODO: Implement that IP information for real. +-- The host environment is everything in King, eyre configuration shared +-- across ships, and nat punching data. class HasMultiEyreApi a where multiEyreApiL :: Lens' a MultiEyreApi @@ -189,7 +187,7 @@ class (HasKingEnv a, HasHostEnv a, HasPierConfig a, HasNetworkConfig a) => pierEnvL :: Lens' a PierEnv data PierEnv = PierEnv - { _pierEnvHostEnv :: !HostEnv + { _pierEnvHostEnv :: !HostEnv , _pierEnvPierConfig :: !PierConfig , _pierEnvNetworkConfig :: !NetworkConfig , _pierEnvKillSignal :: !(TMVar ()) @@ -252,9 +250,9 @@ killPierActionL = runPierEnv :: PierConfig -> NetworkConfig -> TMVar () -> RIO PierEnv a -> RIO HostEnv a runPierEnv pierConfig networkConfig vKill action = do - running <- ask + host <- ask - let pierEnv = PierEnv { _pierEnvHostEnv = running + let pierEnv = PierEnv { _pierEnvHostEnv = host , _pierEnvPierConfig = pierConfig , _pierEnvNetworkConfig = networkConfig , _pierEnvKillSignal = vKill diff --git a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs index c0e72369df..8494f9e21b 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs @@ -196,8 +196,8 @@ pillFromURL = PillSourceURL <$> strOption <> value defaultPillURL <> help "URL to pill file") -enableNAT :: Parser Bool -enableNAT = not <$> switch +enableNat :: Parser Bool +enableNat = not <$> switch ( long "no-port-forwarding" <> help "Disable trying to ask the router to forward ames ports") @@ -353,7 +353,7 @@ runOneShip = (,,) <$> fmap Run pierPath <*> opts <*> df kingOpts :: Parser KingOpts kingOpts = do - koUseNatPmp <- enableNAT + koUseNatPmp <- enableNat koSharedHttpPort <- optional diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs index 7ee35b5445..7e77bd894f 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs @@ -550,7 +550,7 @@ newShip CLI.New{..} opts = do -> LegacyBootEvent -> RIO HostEnv () runTryBootFromPill pill name ship bootEvent = do - vKill <- asks (^. kingEnvL . kingEnvKillSignal) + vKill <- view (kingEnvL . kingEnvKillSignal) let pierConfig = toPierConfig (pierPath name) opts let networkConfig = toNetworkConfig opts runPierEnv pierConfig networkConfig vKill $ @@ -595,7 +595,7 @@ buildPortHandler False = pure buildInactivePorts -- TODO: Figure out what to do about logging here. The "port: " messages are -- the sort of thing that should be put on the muxed terminal log, but we don't -- have that at this layer. -buildPortHandler True = buildNATPorts (io . hPutStrLn stderr . unpack) +buildPortHandler True = buildNatPorts (io . hPutStrLn stderr . unpack) startBrowser :: HasLogFunc e => FilePath -> RIO e () startBrowser pierPath = runRAcquire $ do @@ -724,7 +724,7 @@ runShipNoRestart :: CLI.Run -> CLI.Opts -> Bool -> RIO HostEnv () runShipNoRestart r o d = do -- killing ship same as killing king - vKill <- asks (^. kingEnvL . kingEnvKillSignal) + vKill <- view (kingEnvL . kingEnvKillSignal) tid <- asyncBound (runShipEnv r o vKill $ runShip r o d) onKill <- view onKillKingSigL diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs index 641b7061a3..aec3d0473c 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs @@ -179,7 +179,7 @@ startServ startServ who isFake conf plan = do logDebug (displayShow ("EYRE", "startServ")) - multi <- asks (^. multiEyreApiL) + multi <- view multiEyreApiL let vLive = meaLive multi diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs index 873d7e1d30..40e06b7b1b 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs @@ -1,16 +1,17 @@ module Urbit.Vere.Ports (HasPortControlApi(..), PortControlApi, buildInactivePorts, - buildNATPorts, + buildNatPorts, requestPortAccess) where import Control.Monad.STM (check) import Urbit.Prelude import Network.NatPmp import Data.Time.Clock.POSIX -import Data.Heap import Network.Socket +import qualified Data.Heap as DH + -- This module deals with ports and port requests. When a component wants to -- ensure that it is externally reachable, possibly from outside a NAT, it -- makes a request to this module to hole-punch. @@ -31,21 +32,21 @@ buildInactivePorts = PortControlApi noop noop -- | Builds a PortControlApi struct which tries to hole-punch by talking to the -- NAT gateway over NAT-PMP. -buildNATPorts :: (HasLogFunc e) +buildNatPorts :: (HasLogFunc e) => (Text -> RIO e ()) -> RIO e PortControlApi -buildNATPorts stderr = do +buildNatPorts stderr = do q <- newTQueueIO async $ portThread q stderr let addRequest port = do resp <- newEmptyTMVarIO atomically $ - writeTQueue q (PTMRequestOpen port (putTMVar resp True)) + writeTQueue q (PTMOpen port (putTMVar resp True)) atomically $ takeTMVar resp pure () - let removeRequest port = atomically $ writeTQueue q (PTMRequestClose port) + let removeRequest port = atomically $ writeTQueue q (PTMClose port) pure $ PortControlApi addRequest removeRequest @@ -58,13 +59,13 @@ portRenewalTime = portLeaseLifetime - 60 -- Messages sent from the main thread to the port mapping communication thread. data PortThreadMsg - = PTMRequestOpen Word16 (STM ()) + = PTMOpen Word16 (STM ()) -- ^ Does the open request, and then calls the passed in stm action to -- singal completion to the main thread. We want to block on the initial -- setting opening because we want the forwarding set up before we actually -- start using the port. - | PTMRequestClose Word16 + | PTMClose Word16 -- ^ Close command. No synchronization because there's nothing we can do if -- it fails. @@ -88,19 +89,25 @@ portThread q stderr = do initNatPmp >>= \case Left err -> do likelyIPAddress >>= \case - Just (192, 168, c, d) -> do - stderr $ "port: you appear to be behind a router since your ip " ++ - "is 192.168." ++ (tshow c) ++ "." ++ (tshow d) ++ ", but " ++ - "we could not request port forwarding (NAT-PMP error: " ++ - (tshow err) ++ ")" - stderr $ "port: urbit performance will be degregaded unless you " ++ - "manually forward your ames port." - loopErr q - _ -> do - stderr $ "port: couldn't find router; assuming on public internet" - loopErr q + Just ip@(192, 168, c, d) -> warnBehindRouterAndErr ip err + Just ip@(10, _, _, _) -> warnBehindRouterAndErr ip err + _ -> assumeOnPublicInternet Right pmp -> foundRouter pmp where + warnBehindRouterAndErr (a, b, c, d) err = do + stderr $ "port: you appear to be behind a router since your ip " ++ + "is " ++ (tshow a) ++ "." ++ (tshow b) ++ "." ++ (tshow c) ++ + "." ++ (tshow d) ++ ", but " ++ + "we could not request port forwarding (NAT-PMP error: " ++ + (tshow err) ++ ")" + stderr $ "port: urbit performance will be degregaded unless you " ++ + "manually forward your ames port." + loopErr q + + assumeOnPublicInternet = do + stderr $ "port: couldn't find router; assuming on public internet" + loopErr q + foundRouter :: NatPmpHandle -> RIO e () foundRouter pmp = do getPublicAddress pmp >>= \case @@ -111,10 +118,10 @@ portThread q stderr = do "." ++ (tshow b) ++ "." ++ (tshow c) ++ "." ++ (tshow d) loop pmp mempty - loop :: NatPmpHandle -> MinPrioHeap POSIXTime RenewAction -> RIO e () + loop :: NatPmpHandle -> DH.MinPrioHeap POSIXTime RenewAction -> RIO e () loop pmp nextRenew = do now <- io $ getPOSIXTime - delay <- case viewHead nextRenew of + delay <- case DH.viewHead nextRenew of Nothing -> newTVarIO False Just (fireTime, _) -> do let timeTo = fireTime - now @@ -123,15 +130,15 @@ portThread q stderr = do command <- atomically $ (Left <$> fini delay) <|> (Right <$> readTQueue q) case command of - Left () -> handleRenew pmp nextRenew + Left () -> handleRenew pmp nextRenew Right msg -> handlePTM pmp msg nextRenew handlePTM :: NatPmpHandle -> PortThreadMsg - -> MinPrioHeap POSIXTime RenewAction + -> DH.MinPrioHeap POSIXTime RenewAction -> RIO e () handlePTM pmp msg nextRenew = case msg of - PTMRequestOpen p notifyComplete -> do + PTMOpen p notifyComplete -> do logInfo $ displayShow ("port: sending initial request to NAT-PMP for port ", p) setPortMapping pmp PTUdp p p portLeaseLifetime >>= \case @@ -146,12 +153,12 @@ portThread q stderr = do let filteredHeap = filterPort p nextRenew now <- io $ getPOSIXTime let withRenew = - insert (now + fromIntegral portRenewalTime, RenewAction p) - filteredHeap + DH.insert (now + fromIntegral portRenewalTime, RenewAction p) + filteredHeap atomically notifyComplete loop pmp withRenew - PTMRequestClose p -> do + PTMClose p -> do logInfo $ displayShow ("port: releasing lease for ", p) setPortMapping pmp PTUdp p p 0 @@ -159,10 +166,10 @@ portThread q stderr = do loop pmp removed handleRenew :: NatPmpHandle - -> MinPrioHeap POSIXTime RenewAction + -> DH.MinPrioHeap POSIXTime RenewAction -> RIO e () handleRenew pmp nextRenew = do - case (Data.Heap.view nextRenew) of + case (DH.view nextRenew) of Nothing -> error "Internal heap managing error." Just ((_, RenewAction p), rest) -> do logInfo $ @@ -178,16 +185,16 @@ portThread q stderr = do -- We don't need to filter the port because we just did. now <- io $ getPOSIXTime let withRenew = - insert (now + (fromIntegral portRenewalTime), RenewAction p) - rest + DH.insert (now + fromIntegral portRenewalTime, RenewAction p) + rest loop pmp withRenew filterPort :: Word16 - -> MinPrioHeap POSIXTime RenewAction - -> MinPrioHeap POSIXTime RenewAction - filterPort p = Data.Heap.filter okPort - where - okPort (_, RenewAction x) = p /= x + -> DH.MinPrioHeap POSIXTime RenewAction + -> DH.MinPrioHeap POSIXTime RenewAction + filterPort p = DH.filter okPort + where + okPort (_, RenewAction x) = p /= x -- block (retry) until the delay TVar is set to True fini :: TVar Bool -> STM () @@ -197,8 +204,8 @@ portThread q stderr = do -- the main thread that blocking actions are complete. loopErr q = forever $ do (atomically $ readTQueue q) >>= \case - PTMRequestOpen _ onComplete -> atomically onComplete - PTMRequestClose _ -> pure () + PTMOpen _ onComplete -> atomically onComplete + PTMClose _ -> pure () -- When we were unable to connect to a router, get the ip address on the -- default ipv4 interface to check if we look like we're on an internal network @@ -222,11 +229,11 @@ requestPortAccess port = do where request :: RIO e () request = do - api <- asks (^. portControlApiL) + api <- view portControlApiL io $ pAddPortRequest api port release :: () -> RIO e () release _ = do - api <- asks (^. portControlApiL) + api <- view portControlApiL io $ pRemovePortRequest api port From eedb1389750ba0a07f6715ebe856894dc1b49ff7 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 14 Aug 2020 10:56:31 -0700 Subject: [PATCH 165/933] ur: refactors indirect-atom (re-)allocation --- pkg/urbit/ur/hashcons.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index ced7cc37d1..fd544957f4 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -482,18 +482,14 @@ _coin_unsafe(ur_atoms_t *atoms, ur_mug mug, uint8_t *byt, uint64_t len) uint64_t fill = atoms->fill; ur_tag tag = ur_iatom; ur_nref tom = ( fill | ((uint64_t)tag << 62) ); - uint8_t *copy = malloc(len); // XX necessary? // assert( 62 >= ur_met0_64(fill) ); - assert(copy); - memcpy(copy, byt, len); - - atoms->bytes[fill] = copy; - atoms->lens[fill] = len; - atoms->mugs[fill] = mug; + atoms->bytes[fill] = byt; + atoms->lens[fill] = len; + atoms->mugs[fill] = mug; atoms->fill = 1 + fill; return tom; @@ -584,7 +580,11 @@ ur_coin_bytes(ur_root_t *r, uint8_t *byt, uint64_t len) return (ur_nref)direct; } else { - return _coin_bytes_unsafe(r, byt, len); + uint8_t *copy = malloc(len); + assert( copy ); + memcpy(copy, byt, len); + + return _coin_bytes_unsafe(r, copy, len); } } @@ -595,9 +595,20 @@ ur_coin64(ur_root_t *r, uint64_t n) return n; } else { - // XX little-endian - // - return _coin_bytes_unsafe(r, (uint8_t*)&n, ur_met3_64(n)); + uint8_t *byt = malloc(8); + assert( byt ); + assert( 8 == ur_met3_64(n) ); + + byt[0] = ur_mask_8(n); + byt[1] = ur_mask_8(n >> 8); + byt[2] = ur_mask_8(n >> 16); + byt[3] = ur_mask_8(n >> 24); + byt[4] = ur_mask_8(n >> 32); + byt[5] = ur_mask_8(n >> 40); + byt[6] = ur_mask_8(n >> 48); + byt[7] = ur_mask_8(n >> 56); + + return _coin_bytes_unsafe(r, byt, 8); } } From 377ee490f3cfc2d4593a7797de5f22e56c0ce172 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 14 Aug 2020 11:12:55 -0700 Subject: [PATCH 166/933] u3: corrects _cu_from_loom() stack struct comment --- pkg/urbit/noun/urth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/noun/urth.c b/pkg/urbit/noun/urth.c index 674b734c44..aa3557bd12 100644 --- a/pkg/urbit/noun/urth.c +++ b/pkg/urbit/noun/urth.c @@ -95,8 +95,8 @@ _cu_box_stash(u3a_noun* som_u, ur_nref ref) // In Hoon, this structure would be as follows: // // $% [%root ~] -// [%head cell=^] -// [%tail cell=^ hed-mug=@] +// [%head loom-cell=^] +// [%tail loom-cell=^ off-loom-head=*] // == // From ee8c8ed1bd32b38be946f25d70b215ba665ed5db Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 11 Aug 2020 19:02:23 -0700 Subject: [PATCH 167/933] ur: implements jam --- pkg/urbit/include/ur/hashcons.h | 3 + pkg/urbit/tests/ur_tests.c | 157 +++++++++++++++ pkg/urbit/ur/hashcons.c | 334 ++++++++++++++++++++++++++++++++ 3 files changed, 494 insertions(+) create mode 100644 pkg/urbit/tests/ur_tests.c diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index 374c520754..b0ccd3de20 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -170,3 +170,6 @@ ur_walk_fore(ur_root_t *r, void *v, void (*atom)(ur_root_t*, ur_nref, void*), ur_bool_t (*cell)(ur_root_t*, ur_nref, void*)); + +uint64_t +ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt); diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c new file mode 100644 index 0000000000..0653ced129 --- /dev/null +++ b/pkg/urbit/tests/ur_tests.c @@ -0,0 +1,157 @@ +#include "all.h" +#include "ur/hashcons.h" + +static c3_i +_test_jam(const c3_c* cap_c, + ur_root_t* rot_u, + ur_nref ref, + c3_w len_w, + const c3_y* res_y) +{ + c3_d i_d, len_d; + c3_y* out_y; + c3_i ret_i; + + ur_jam(rot_u, ref, &len_d, &out_y); + + if ( 0 != memcmp(out_y, res_y, len_w) ) { + fprintf(stderr, "\033[31m%s fail\033[0m\r\n", cap_c); + + fprintf(stderr, " actual: { "); + for ( i_d = 0; i_d < len_d; i_d++ ) { + fprintf(stderr, "0x%x, ", out_y[i_d]); + } + fprintf(stderr, "}\r\n"); + fprintf(stderr, " expect: { "); + for ( i_d = 0; i_d < len_w; i_d++ ) { + fprintf(stderr, "0x%x, ", res_y[i_d]); + } + fprintf(stderr, "}\r\n"); + + ret_i = 0; + } + else { + ret_i = 1; + } + + c3_free(out_y); + + return ret_i; +} + +static c3_i +_test_ur(void) +{ + ur_root_t* rot_u = ur_hcon_init(); + c3_d i_d, len_d; + c3_y* byt_y; + c3_i res_i = 1; + +# define nc(a, b) ur_cons(rot_u, a, b) +# define nt(a, b, c) nc(a, nc(b, c)) + + { + c3_c* cap_c = "jam 0"; + c3_y res_y[1] = { 0x2 }; + ur_nref ref = 0; + res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + } + + { + c3_c* cap_c = "jam 1"; + c3_y res_y[1] = { 0xc }; + ur_nref ref = 1; + res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + } + + { + c3_c* cap_c = "jam 2"; + c3_y res_y[1] = { 0x48 }; + ur_nref ref = 2; + res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + } + + { + c3_c* cap_c = "jam %fast"; + c3_y res_y[6] = { 0xc0, 0x37, 0xb, 0x9b, 0xa3, 0x3 }; + ur_nref ref = c3__fast; + res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + } + + { + c3_c* cap_c = "jam %full"; + c3_y res_y[6] = { 0xc0, 0x37, 0xab, 0x63, 0x63, 0x3 }; + ur_nref ref = c3__full; + res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + } + + { + c3_c* cap_c = "jam [0 0]"; + c3_y res_y[1] = { 0x29 }; + ur_nref ref = nc(0, 0); + res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + } + + { + c3_c* cap_c = "jam [1 1]"; + c3_y res_y[2] = { 0x31, 0x3 }; + ur_nref ref = nc(1, 1); + res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + } + + { + c3_c* cap_c = "jam [2 3]"; + c3_y res_y[2] = { 0x21, 0xd1 }; + ur_nref ref = nc(2, 3); + res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + } + + { + c3_c* cap_c = "jam [%fast %full]"; + c3_y res_y[11] = { 0x1, 0xdf, 0x2c, 0x6c, 0x8e, 0xe, 0x7c, 0xb3, 0x3a, 0x36, 0x36 }; + ur_nref ref = nc(c3__fast, c3__full); + res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + } + + { + c3_c* cap_c = "jam [1 1 1]"; + c3_y res_y[2] = { 0x71, 0xcc }; + ur_nref ref = nc(1, nc(1, 1)); + res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + } + + { + c3_c* cap_c = "jam [%fast %full %fast]"; + c3_y res_y[12] = { 0x1, 0xdf, 0x2c, 0x6c, 0x8e, 0x1e, 0xf0, 0xcd, 0xea, 0xd8, 0xd8, 0x93 }; + ur_nref ref = nc(c3__fast, nc(c3__full, c3__fast)); + res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + } + + { + c3_c* cap_c = "jam [[0 0] [[0 0] 1 1] 1 1]"; + c3_y res_y[6] = { 0xa5, 0x35, 0x19, 0xf3, 0x18, 0x5 }; + ur_nref ref = nc(nc(0, 0), nc(nc(nc(0, 0), nc(1, 1)), nc(1, 1))); + res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + } + + { + c3_c* cap_c = "jam big"; + c3_y res_y[14] = { 0x15, 0x17, 0xb2, 0xd0, 0x85, 0x59, 0xb8, 0x61, 0x87, 0x5f, 0x10, 0x54, 0x55, 0x5 }; + ur_nref ref = nc(nc(nc(1, nc(nc(2, nc(nc(3, nc(nc(4, nc(nt(5, 6, nc(7, nc(nc(8, 0), 0))), 0)), 0)), 0)), 0)), 0), 0); + res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + } + + return res_i; +} + +int +main(int argc, char* argv[]) +{ + if ( !_test_ur() ) { + fprintf(stderr, "ur test failed\r\n"); + return 1; + } + + fprintf(stderr, "ur ok\n"); + return 0; +} diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index fd544957f4..96966762fc 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -883,3 +883,337 @@ ur_walk_fore(ur_root_t *r, free(don); } + +typedef struct ur_bsw_s { + uint64_t prev; + uint64_t size; + uint64_t fill; + uint64_t bits; + uint8_t off; + uint8_t *bytes; +} ur_bsw_t; + +static inline void +ur_bsw_grow(ur_bsw_t *bsw) +{ + uint64_t prev = bsw->prev; + uint64_t size = bsw->size; + uint64_t next = prev + size; + + // fprintf(stderr, "bsw: grow: %" PRIu64 "-%" PRIu64" fill: %" PRIu64 "\r\n", size, next, bsw->fill); + + bsw->bytes = realloc(bsw->bytes, next); + assert(bsw->bytes); + memset(bsw->bytes + size, 0, prev); + + bsw->prev = size; + bsw->size = next; +} + +static void +ur_bsw_bit(ur_bsw_t *bsw, uint8_t bit) +{ + uint64_t fill = bsw->fill; + uint8_t off = bsw->off; + uint8_t old = bsw->bytes[fill]; + + bsw->bytes[fill] = old ^ ((bit & 1) << off); + + if ( 7 == off ) { + if ( ++fill == bsw->size ) { + ur_bsw_grow(bsw); + } + + bsw->fill = fill; + bsw->off = 0; + } + else { + bsw->off = 1 + off; + } + + bsw->bits++; + + // if ( (bsw->fill << 3) + bsw->off != bsw->bits ) { + // fprintf(stderr, "bit fill: %" PRIu64 " off: %u bits: %" PRIu64 ", calc: %" PRIu64 "\r\n", + // bsw->fill, + // bsw->off, + // bsw->bits, + // (bsw->fill << 3) + bsw->off); + // assert(0); + // } +} + +static void +ur_bsw_bits(ur_bsw_t *bsw, uint8_t len, uint8_t byt) +{ + uint64_t fill = bsw->fill; + uint8_t off = bsw->off; + + // XX + assert( 8 > len ); + + { + uint8_t rest = 8 - off; + uint8_t old = bsw->bytes[fill]; + + if ( len < rest ) { + uint8_t left = (byt & ((1 << len) - 1)) << off; + + bsw->bytes[fill] = old ^ left; + bsw->off = off + len; + } + else { + uint8_t left, right; + + left = (byt & ((1 << rest) - 1)) << off; + off = len - rest; + right = (byt >> rest) & ((1 << off) - 1); + + if ( (fill + 1 + !!off) >= bsw->size ) { + ur_bsw_grow(bsw); + } + + bsw->bytes[fill] = old ^ left; + fill++; + bsw->bytes[fill] = right; + + bsw->fill = fill; + bsw->off = off; + } + } + + bsw->bits += len; + + // if ( (bsw->fill << 3) + bsw->off != bsw->bits ) { + // fprintf(stderr, "bits fill: %" PRIu64 " off: %u bits: %" PRIu64 ", calc: %" PRIu64 "\r\n", + // bsw->fill, + // bsw->off, + // bsw->bits, + // (bsw->fill << 3) + bsw->off); + // assert(0); + // } +} + +static void +ur_bsw_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) +{ + uint64_t fill = bsw->fill; + uint64_t full = fill + len; + uint8_t off = bsw->off; + + // XX + assert(len); + + if ( (full + !!off) >= bsw->size ) { + uint64_t prev = bsw->prev; + + // be sure to grow sufficiently + // + if ( len > prev ) { + bsw->prev = len; + } + + ur_bsw_grow(bsw); + } + + if ( !off ) { + memcpy(bsw->bytes + fill, byt, len); + } + else { + uint8_t rest = 8 - off; + uint8_t left, right, old = bsw->bytes[fill]; + uint64_t i; + + for ( i = 0; i < len; i++ ) { + left = (byt[i] & ((1 << rest) - 1)) << off; + right = (byt[i] >> rest) & ((1 << off) - 1); + + bsw->bytes[fill++] = old ^ left; + old = right; + } + + bsw->bytes[fill] = old; + + assert( full == fill ); + } + + bsw->fill = full; + bsw->bits += len << 3; + + // if ( (bsw->fill << 3) + bsw->off != bsw->bits ) { + // fprintf(stderr, "bytes fill: %" PRIu64 " off: %u bits: %" PRIu64 ", calc: %" PRIu64 "\r\n", + // bsw->fill, + // bsw->off, + // bsw->bits, + // (bsw->fill << 3) + bsw->off); + // assert(0); + // } +} + +static void +ur_bsw64(ur_bsw_t *bsw, uint8_t len_bit, uint64_t val) +{ + // assumes little-endian + // + uint8_t *byt = (uint8_t*)&val; + uint8_t len_byt = len_bit >> 3; + uint8_t low = ur_mask_3(len_bit); + + if ( len_byt ) { + ur_bsw_bytes(bsw, len_byt, byt); + } + + if ( low ) { + ur_bsw_bits(bsw, low, byt[len_byt]); + } +} + +static inline void +ur_bsw_mat64(ur_bsw_t *bsw, uint8_t len_bit, uint64_t val) +{ + if ( 0 == val ) { + ur_bsw_bit(bsw, 1); + } + else { + uint8_t len_len = ur_met0_64(len_bit); + + ur_bsw64(bsw, len_len + 1, 1ULL << len_len); + ur_bsw64(bsw, len_len - 1, len_bit); + ur_bsw64(bsw, len_bit, val); + } +} + + +static inline void +ur_bsw_mat_bytes(ur_bsw_t *bsw, uint64_t len_bit, uint64_t len, uint8_t *byt) +{ + // write run-length + // + { + uint8_t len_len = ur_met0_64(len_bit); + + // XX + assert( 64 > len_len ); + + ur_bsw64(bsw, len_len + 1, 1ULL << len_len); + ur_bsw64(bsw, len_len - 1, len_bit); + } + + // write bytes + // + { + uint8_t low = ur_mask_3(len_bit); + + if ( !low ) { + ur_bsw_bytes(bsw, len, byt); + } + else { + uint64_t last = len - 1; + ur_bsw_bytes(bsw, last, byt); + ur_bsw_bits(bsw, low, byt[last]); + } + } +} + +static inline void +_jam_mat(ur_root_t *r, ur_nref ref, ur_bsw_t *bsw, uint64_t len_bit) +{ + switch ( ur_nref_tag(ref) ) { + default: assert(0); + + case ur_direct: { + ur_bsw_mat64(bsw, len_bit, ref); + } break; + + case ur_iatom: { + uint64_t len; + uint8_t *byt; + ur_bytes(r, ref, &byt, &len); + ur_bsw_mat_bytes(bsw, len_bit, len, byt); + } break; + } +} + +typedef struct _jam_s { + ur_dict64_t dict; + ur_bsw_t bsw; +} _jam_t; + +static void +_jam_atom(ur_root_t *r, ur_nref ref, void *ptr) +{ + _jam_t *j = ptr; + ur_dict64_t *dict = &(j->dict); + ur_bsw_t *bsw = &j->bsw; + uint64_t bak, len_bit; + + len_bit = ur_met(r, 0, ref); + + if ( !ur_dict64_get(r, dict, ref, &bak) ) { + ur_dict64_put(r, dict, ref, bsw->bits); + + ur_bsw_bit(bsw, 0); + _jam_mat(r, ref, bsw, len_bit); + } + else { + uint64_t bak_bit = ur_met0_64(bak); + + if ( len_bit <= bak_bit ) { + ur_bsw_bit(bsw, 0); + _jam_mat(r, ref, bsw, len_bit); + } + else { + ur_bsw_bit(bsw, 1); + ur_bsw_bit(bsw, 1); + ur_bsw_mat64(bsw, bak_bit, bak); + } + } +} + +static ur_bool_t +_jam_cell(ur_root_t *r, ur_nref ref, void *ptr) +{ + _jam_t *j = ptr; + ur_dict64_t *dict = &(j->dict); + ur_bsw_t *bsw = &j->bsw; + uint64_t bak; + + if ( !ur_dict64_get(r, dict, ref, &bak) ) { + ur_dict64_put(r, dict, ref, bsw->bits); + + ur_bsw_bit(bsw, 1); + ur_bsw_bit(bsw, 0); + + return 1; // true + } + else { + ur_bsw_bit(bsw, 1); + ur_bsw_bit(bsw, 1); + ur_bsw_mat64(bsw, ur_met0_64(bak), bak); + + return 0; // false + } +} + +uint64_t +ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt) +{ + _jam_t j = {0}; + { + uint64_t fib11 = 89, fib12 = 144; + + j.bsw.prev = fib11; + j.bsw.size = fib12; + j.bsw.bytes = calloc(j.bsw.size, 1); + + ur_dict64_grow(r, &j.dict, fib11, fib12); + } + + ur_walk_fore(r, ref, &j, _jam_atom, _jam_cell); + ur_dict_free((ur_dict_t*)&j.dict); + + *len = j.bsw.fill + !!j.bsw.off; + *byt = j.bsw.bytes; + + return j.bsw.bits; +} From 509c0744453724a36a96ade022a7848de63d9bbb Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 14 Aug 2020 11:14:32 -0700 Subject: [PATCH 168/933] ur: implements cue --- pkg/urbit/include/ur/hashcons.h | 14 ++ pkg/urbit/tests/ur_tests.c | 62 +++-- pkg/urbit/ur/hashcons.c | 392 ++++++++++++++++++++++++++++++++ 3 files changed, 454 insertions(+), 14 deletions(-) diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index b0ccd3de20..17ca35a330 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -173,3 +173,17 @@ ur_walk_fore(ur_root_t *r, uint64_t ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt); + +typedef enum { + ur_cue_good = 0, + ur_cue_gone = 1 +} ur_cue_res_e; + +typedef enum { + ur_jam_atom = 0, + ur_jam_cell = 1, + ur_jam_back = 2 +} ur_cue_tag_e; + +ur_cue_res_e +ur_cue(ur_root_t *r, uint64_t len, const uint8_t *byt, ur_nref *out); diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index 0653ced129..c563bf303f 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -15,7 +15,7 @@ _test_jam(const c3_c* cap_c, ur_jam(rot_u, ref, &len_d, &out_y); if ( 0 != memcmp(out_y, res_y, len_w) ) { - fprintf(stderr, "\033[31m%s fail\033[0m\r\n", cap_c); + fprintf(stderr, "\033[31mjam %s fail\033[0m\r\n", cap_c); fprintf(stderr, " actual: { "); for ( i_d = 0; i_d < len_d; i_d++ ) { @@ -39,6 +39,27 @@ _test_jam(const c3_c* cap_c, return ret_i; } +static c3_i +_test_cue(const c3_c* cap_c, + ur_root_t* rot_u, + ur_nref ref, + c3_w len_w, + const c3_y* res_y) +{ + ur_nref out; + + if ( ur_cue_good != ur_cue(rot_u, len_w, res_y, &out) ) { + fprintf(stderr, "\033[31mcue %s fail 1\033[0m\r\n", cap_c); + return 0; + } + else if ( ref != out ) { + fprintf(stderr, "\033[31mcue %s fail 2 ref=%" PRIu64 " out=%" PRIu64 " \033[0m\r\n", cap_c, ref, out); + return 0; + } + + return 1; +} + static c3_i _test_ur(void) { @@ -51,94 +72,107 @@ _test_ur(void) # define nt(a, b, c) nc(a, nc(b, c)) { - c3_c* cap_c = "jam 0"; + c3_c* cap_c = "0"; c3_y res_y[1] = { 0x2 }; ur_nref ref = 0; res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); } { - c3_c* cap_c = "jam 1"; + c3_c* cap_c = "1"; c3_y res_y[1] = { 0xc }; ur_nref ref = 1; res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); } { - c3_c* cap_c = "jam 2"; + c3_c* cap_c = "2"; c3_y res_y[1] = { 0x48 }; ur_nref ref = 2; res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); } { - c3_c* cap_c = "jam %fast"; + c3_c* cap_c = "%fast"; c3_y res_y[6] = { 0xc0, 0x37, 0xb, 0x9b, 0xa3, 0x3 }; ur_nref ref = c3__fast; res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); } { - c3_c* cap_c = "jam %full"; + c3_c* cap_c = "%full"; c3_y res_y[6] = { 0xc0, 0x37, 0xab, 0x63, 0x63, 0x3 }; ur_nref ref = c3__full; res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); } { - c3_c* cap_c = "jam [0 0]"; + c3_c* cap_c = "[0 0]"; c3_y res_y[1] = { 0x29 }; ur_nref ref = nc(0, 0); res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); } { - c3_c* cap_c = "jam [1 1]"; + c3_c* cap_c = "[1 1]"; c3_y res_y[2] = { 0x31, 0x3 }; ur_nref ref = nc(1, 1); res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); } { - c3_c* cap_c = "jam [2 3]"; + c3_c* cap_c = "[2 3]"; c3_y res_y[2] = { 0x21, 0xd1 }; ur_nref ref = nc(2, 3); res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); } { - c3_c* cap_c = "jam [%fast %full]"; + c3_c* cap_c = "[%fast %full]"; c3_y res_y[11] = { 0x1, 0xdf, 0x2c, 0x6c, 0x8e, 0xe, 0x7c, 0xb3, 0x3a, 0x36, 0x36 }; ur_nref ref = nc(c3__fast, c3__full); res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); } { - c3_c* cap_c = "jam [1 1 1]"; + c3_c* cap_c = "[1 1 1]"; c3_y res_y[2] = { 0x71, 0xcc }; ur_nref ref = nc(1, nc(1, 1)); res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); } { - c3_c* cap_c = "jam [%fast %full %fast]"; + c3_c* cap_c = "[%fast %full %fast]"; c3_y res_y[12] = { 0x1, 0xdf, 0x2c, 0x6c, 0x8e, 0x1e, 0xf0, 0xcd, 0xea, 0xd8, 0xd8, 0x93 }; ur_nref ref = nc(c3__fast, nc(c3__full, c3__fast)); res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); } { - c3_c* cap_c = "jam [[0 0] [[0 0] 1 1] 1 1]"; + c3_c* cap_c = "[[0 0] [[0 0] 1 1] 1 1]"; c3_y res_y[6] = { 0xa5, 0x35, 0x19, 0xf3, 0x18, 0x5 }; ur_nref ref = nc(nc(0, 0), nc(nc(nc(0, 0), nc(1, 1)), nc(1, 1))); res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); } { - c3_c* cap_c = "jam big"; + c3_c* cap_c = "big"; c3_y res_y[14] = { 0x15, 0x17, 0xb2, 0xd0, 0x85, 0x59, 0xb8, 0x61, 0x87, 0x5f, 0x10, 0x54, 0x55, 0x5 }; ur_nref ref = nc(nc(nc(1, nc(nc(2, nc(nc(3, nc(nc(4, nc(nt(5, 6, nc(7, nc(nc(8, 0), 0))), 0)), 0)), 0)), 0)), 0), 0); res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); + res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); } return res_i; diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 96966762fc..2b694bc821 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -1115,6 +1115,192 @@ ur_bsw_mat_bytes(ur_bsw_t *bsw, uint64_t len_bit, uint64_t len, uint8_t *byt) } } +typedef struct ur_bsr_s { + uint64_t left; + uint64_t bits; + uint8_t off; + const uint8_t *bytes; +} ur_bsr_t; + +static inline ur_cue_res_e +ur_bsr_bit(ur_bsr_t *bsr, uint8_t *out) +{ + uint8_t left = bsr->left; + + if ( !left ) { + return ur_cue_gone; + } + else { + uint8_t byt = bsr->bytes[0]; + uint8_t off = bsr->off; + uint8_t bit = (byt >> off) & 1; + + if ( 7 == off ) { + left--; + + if ( left ) { + bsr->bytes++; + bsr->left = left; + } + else { + bsr->bytes = 0; + bsr->left = 0; + } + + bsr->off = 0; + } + else { + bsr->off = 1 + off; + } + + bsr->bits++; + + *out = bit; + + return ur_cue_good; + } +} + +static inline ur_cue_res_e +ur_bsr_tag(ur_bsr_t *bsr, ur_cue_tag_e *out) +{ + ur_cue_res_e res; + uint8_t bit; + + if ( ur_cue_good != (res = ur_bsr_bit(bsr, &bit)) ) { + return res; + } + else if ( 0 == bit ) { + *out = ur_jam_atom; + return ur_cue_good; + } + else if ( ur_cue_good != (res = ur_bsr_bit(bsr, &bit)) ) { + return res; + } + + *out = ( 0 == bit ) ? ur_jam_cell : ur_jam_back; + return ur_cue_good; +} + +static inline ur_cue_res_e +ur_bsr_zeros(ur_bsr_t *bsr, uint8_t *out) +{ + ur_cue_res_e res; + uint8_t bit, len = 0; + + while ( (ur_cue_good == (res = ur_bsr_bit(bsr, &bit))) && (0 == bit) ) { + len++; + } + + if ( ur_cue_good != res ) { + return res; + } + else { + *out = len; + return ur_cue_good; + } +} + +static inline uint64_t +ur_bsr64(ur_bsr_t *bsr, uint8_t len) +{ + uint64_t acc = 0; + uint64_t i; + uint8_t bit; + + for ( i = 0; i < len; i++ ) { + if ( ur_cue_good != ur_bsr_bit(bsr, &bit) ) { + bsr->bits += len - i; + bsr->bytes = 0; + return acc; + } + + acc ^= (uint64_t)bit << i; + } + + return acc; +} + +static inline void +ur_bsr_bytes(ur_bsr_t *bsr, uint64_t len, uint8_t *out) +{ + uint8_t left = bsr->left; + uint8_t off = bsr->off; + ur_bool_t end = len >= left; + + if ( !left ) { + return; + } + + if ( !off ) { + if ( end ) { + memcpy(out, bsr->bytes, left); + bsr->bytes = 0; + left = 0; + } + else { + memcpy(out, bsr->bytes, len); + bsr->bytes += len; + left -= len; + } + } + // the most-significant bits from a byte in the stream + // become the least-significant bits of an output byte, and vice-versa + // + else { + uint8_t rest = 8 - off; + const uint8_t *bytes = bsr->bytes; + uint8_t byt = bytes[0]; + uint8_t l, m; + uint64_t max = end ? (left - 1) : len; + uint64_t i; + + for ( i = 0; i < max; i++ ) { + m = byt >> off; + byt = bytes[1 + i]; + l = byt & ((1 << off) - 1); + out[i] = m ^ (l << rest); + } + + if ( end ) { + out[max] = bytes[max] >> off; + + bsr->bytes = 0; + left = 0; + } + else { + bsr->bytes += max; + left -= max; + } + } + + bsr->left = left; + bsr->bits += len << 3; +} + +static inline ur_cue_res_e +ur_bsr_mat(ur_bsr_t *bsr, uint64_t *out) +{ + uint8_t len; + + if ( ur_cue_gone == ur_bsr_zeros(bsr, &len) ) { + return ur_cue_gone; + } + + // XX + assert( 64 > len ); + + if ( !len ) { + *out = 0; + } + else { + len--; + *out = ur_bsr64(bsr, len) ^ (1ULL << len); + } + + return ur_cue_good; +} + static inline void _jam_mat(ur_root_t *r, ur_nref ref, ur_bsw_t *bsw, uint64_t len_bit) { @@ -1217,3 +1403,209 @@ ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt) return j.bsw.bits; } + +typedef struct _cue_s { + ur_dict64_t dict; + ur_bsr_t bsr; +} _cue_t; + +static inline ur_cue_res_e +_cue_atom(ur_root_t *r, _cue_t *c, ur_nref *out) +{ + ur_bsr_t *bsr = &c->bsr; + ur_cue_res_e res; + uint64_t len; + + if ( ur_cue_good != (res = ur_bsr_mat(bsr, &len)) ) { + return res; + } + + if ( 62 >= len ) { + *out = (ur_nref)ur_bsr64(bsr, len); + } + else { + uint8_t *byt = calloc(len, 1); + ur_bsr_bytes(bsr, len, byt); + + // strip trailing zeroes + // + while ( len && !byt[len - 1] ) { + len--; + } + + *out = _coin_bytes_unsafe(r, byt, len); + } + + return ur_cue_good; +} + +static inline ur_cue_res_e +_cue_back(ur_bsr_t *bsr, uint64_t *out) +{ + ur_cue_res_e res; + uint64_t len; + + if ( ur_cue_good != (res = ur_bsr_mat(bsr, &len)) ) { + return res; + } + + // XX + assert( 62 >= len ); + + *out = ur_bsr64(bsr, len); + return ur_cue_good; +} + +#define STACK_ROOT 0 +#define STACK_HEAD 1 +#define STACK_TAIL 2 + +// stack frame for recording head vs tail iteration +// +// In Hoon, this structure would be as follows: +// +// $% [%root ~] +// [%head cursor=@] +// [%tail cursor=@ hed-ref=*] +// == +// +typedef struct _cue_frame_s { + uint8_t tag; + uint64_t bits; + ur_nref ref; +} _cue_frame_t; + +typedef struct _cue_stack_s { + uint32_t prev; + uint32_t size; + uint32_t fill; + _cue_frame_t* f; +} _cue_stack_t; + +static inline void +_cue_stack_push(_cue_stack_t *s, uint8_t tag, uint64_t bits, ur_nref ref) +{ + if ( s->fill == s->size ) { + uint32_t next = s->prev + s->size; + s->f = realloc(s->f, next * sizeof(*s->f)); + s->prev = s->size; + s->size = next; + } + + _cue_frame_t* f = &(s->f[s->fill++]); + f->tag = tag; + f->bits = bits; + f->ref = ref; +} + +ur_cue_res_e +ur_cue(ur_root_t *r, uint64_t len, const uint8_t *byt, ur_nref *out) +{ + ur_cue_res_e res; + ur_nref ref; + _cue_t c = {0}; + _cue_stack_t s = { .prev = 89, .size = 144, .fill = 0, .f = 0 }; + + // init bitstream-reader + // + c.bsr.left = len; + c.bsr.bytes = byt; + + // init dictionary + // + { + uint64_t fib11 = 89, fib12 = 144; + ur_dict64_grow(r, &c.dict, fib11, fib12); + } + + // setup stack + // + s.f = malloc(s.size * sizeof(*s.f)); + _cue_stack_push(&s, STACK_ROOT, 0, 0); + + // advance into buffer + // + advance: { + uint64_t bits = c.bsr.bits; + ur_cue_tag_e tag; + + if ( ur_cue_good != (res = ur_bsr_tag(&c.bsr, &tag)) ) { + goto perfect; + } + + switch ( tag ) { + default: assert(0); + + case ur_jam_atom: { + if ( ur_cue_good != (res = _cue_atom(r, &c, &ref)) ) { + goto perfect; + } + else { + ur_dict64_put(r, &c.dict, bits, (uint64_t)ref); + goto retreat; + } + } + + case ur_jam_back: { + uint64_t bak, val; + + if ( ur_cue_good != (res = _cue_back(&c.bsr, &bak)) ) { + goto perfect; + } + else if ( !ur_dict64_get(r, &c.dict, bak, &val) ) { + // XX distinguish bad backref? + // + res = ur_cue_gone; + goto perfect; + } + + ref = (ur_nref)val; + goto retreat; + } + + case ur_jam_cell: { + _cue_stack_push(&s, STACK_HEAD, bits, 0); + goto advance; + } + } + } + + // retreat down the stack + // + retreat: { + _cue_frame_t f = s.f[--s.fill]; + + switch ( f.tag ) { + default: assert(0); + + case STACK_ROOT: { + res = ur_cue_good; + goto perfect; + } + + case STACK_HEAD: { + _cue_stack_push(&s, STACK_TAIL, f.bits, ref); + goto advance; + } + + case STACK_TAIL: { + ref = ur_cons(r, f.ref, ref); + ur_dict64_put(r, &c.dict, f.bits, (uint64_t)ref); + goto retreat; + } + } + } + + // we done + // + perfect: { + ur_dict_free((ur_dict_t*)&c.dict); + free(s.f); + + if ( ur_cue_good == res ) { + *out = ref; + } + + return res; + } +} From 8ab60b913332defd310cc67a6165434f4562b0f0 Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Fri, 14 Aug 2020 19:25:07 -0700 Subject: [PATCH 169/933] king: configure logging via cli flags --- pkg/hs/urbit-king/lib/Urbit/King/App.hs | 44 +++++---- pkg/hs/urbit-king/lib/Urbit/King/CLI.hs | 108 ++++++++++++++++++----- pkg/hs/urbit-king/lib/Urbit/King/Main.hs | 44 +++++---- 3 files changed, 139 insertions(+), 57 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/App.hs b/pkg/hs/urbit-king/lib/Urbit/King/App.hs index bd8b6b1a53..0cf1b07c6f 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/App.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/App.hs @@ -25,13 +25,16 @@ where import Urbit.King.Config import Urbit.Prelude -import System.Directory (createDirectoryIfMissing, getHomeDirectory) +import System.Directory ( createDirectoryIfMissing + , getAppUserDataDirectory + ) import System.Posix.Internals (c_getpid) import System.Posix.Types (CPid(..)) import System.Random (randomIO) import Urbit.King.App.Class (HasStderrLogFunc(..)) + -- KingEnv --------------------------------------------------------------------- class HasKingId a where @@ -80,29 +83,34 @@ runKingEnvStderr verb inner = do withLogFunc logOptions $ \logFunc -> runKingEnv logFunc logFunc inner -runKingEnvLogFile :: Bool -> RIO KingEnv a -> IO a -runKingEnvLogFile verb inner = withLogFileHandle $ \h -> do - logOptions <- - logOptionsHandle h verb <&> setLogUseTime True <&> setLogUseLoc False - stderrLogOptions <- - logOptionsHandle stderr verb <&> setLogUseTime False <&> setLogUseLoc False +runKingEnvLogFile :: Bool -> Maybe FilePath -> RIO KingEnv a -> IO a +runKingEnvLogFile verb fileM inner = do + logFile <- case fileM of + Just f -> pure f + Nothing -> defaultLogFile + withLogFileHandle logFile $ \h -> do + logOptions <- + logOptionsHandle h verb <&> setLogUseTime True <&> setLogUseLoc False + stderrLogOptions <- + logOptionsHandle stderr verb <&> setLogUseTime False <&> setLogUseLoc False - withLogFunc stderrLogOptions $ \stderrLogFunc -> withLogFunc logOptions - $ \logFunc -> runKingEnv logFunc stderrLogFunc inner + withLogFunc stderrLogOptions $ \stderrLogFunc -> withLogFunc logOptions + $ \logFunc -> runKingEnv logFunc stderrLogFunc inner -withLogFileHandle :: (Handle -> IO a) -> IO a -withLogFileHandle act = do - home <- getHomeDirectory - let logDir = home ".urbit" - createDirectoryIfMissing True logDir - withFile (logDir "king.log") AppendMode $ \handle -> do +withLogFileHandle :: FilePath -> (Handle -> IO a) -> IO a +withLogFileHandle f act = + withFile f AppendMode $ \handle -> do hSetBuffering handle LineBuffering act handle +defaultLogFile :: IO FilePath +defaultLogFile = do + logDir <- getAppUserDataDirectory "urbit" + createDirectoryIfMissing True logDir + pure (logDir "king.log") + runKingEnvNoLog :: RIO KingEnv a -> IO a -runKingEnvNoLog act = withFile "/dev/null" AppendMode $ \handle -> do - logOptions <- logOptionsHandle handle True - withLogFunc logOptions $ \logFunc -> runKingEnv logFunc logFunc act +runKingEnvNoLog act = runKingEnv mempty mempty act runKingEnv :: LogFunc -> LogFunc -> RIO KingEnv a -> IO a runKingEnv logFunc stderr action = do diff --git a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs index b5edbcd2f9..218412eea4 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs @@ -6,21 +6,23 @@ -} module Urbit.King.CLI where -import ClassyPrelude +import ClassyPrelude hiding (log) import Options.Applicative import Options.Applicative.Help.Pretty import Data.Word (Word16) +import RIO (LogLevel(..)) import System.Environment (getProgName) -------------------------------------------------------------------------------- -data KingOpts = KingOpts - { koSharedHttpPort :: Maybe Word16 - , koSharedHttpsPort :: Maybe Word16 +data Host = Host + { hSharedHttpPort :: Maybe Word16 + , hSharedHttpsPort :: Maybe Word16 } deriving (Show) +-- | Options for each running pier. data Opts = Opts { oQuiet :: Bool , oHashless :: Bool @@ -44,6 +46,19 @@ data Opts = Opts } deriving (Show) +-- | Options for the logging subsystem. +data Log = Log + { lTarget :: Maybe (LogTarget FilePath) + , lLevel :: Maybe LogLevel + } + deriving (Show) + +data LogTarget a + = LogOff + | LogStderr + | LogFile a + deriving (Show) + data BootType = BootComet | BootFake Text @@ -102,8 +117,8 @@ data Bug deriving (Show) data Cmd - = CmdNew New Opts - | CmdRun KingOpts [(Run, Opts, Bool)] + = CmdNew New Opts + | CmdRun Host [(Run, Opts, Bool)] | CmdBug Bug | CmdCon FilePath deriving (Show) @@ -135,7 +150,7 @@ footNote exe = string $ intercalate "\n" -------------------------------------------------------------------------------- -parseArgs :: IO Cmd +parseArgs :: IO (Cmd, Log) parseArgs = do nm <- getProgName @@ -293,7 +308,7 @@ opts = do oVerbose <- switch $ short 'v' <> long "verbose" - <> help "Verbose" + <> help "Puts the serf and king into verbose mode" <> hidden oExit <- switch $ short 'x' @@ -332,22 +347,69 @@ opts = do oFullReplay <- switch $ long "full-log-replay" - <> help "Ignores the snapshot and recomputes state from log" + <> help "Ignores snapshot and recomputes state from event log" <> hidden pure (Opts{..}) -newShip :: Parser Cmd -newShip = CmdNew <$> new <*> opts +log :: Parser Log +log = do + lTarget <- + optional + $ ( flag' LogStderr + $ long "log-to-stderr" + <> long "stderr" + <> help "Display logs on stderr" + <> hidden + ) + <|> ( fmap LogFile . strOption + $ long "log-to" + <> metavar "LOG_FILE" + <> help "Append logs to the given file" + <> hidden + ) + <|> ( flag' LogOff + $ long "no-logging" + <> help "Disable logging entirely" + <> hidden + ) + + lLevel <- + optional + $ ( flag' LevelDebug + $ long "log-debug" + <> help "Log errors, warnings, info, and debug messages" + <> hidden + ) + <|> ( flag' LevelInfo + $ long "log-info" + <> help "Log errors, warnings, and info (default)" + <> hidden + ) + <|> ( flag' LevelWarn + $ long "log-warn" + <> help "Log errors and warnings" + <> hidden + ) + <|> ( flag' LevelError + $ long "log-error" + <> help "Log errors only" + <> hidden + ) + + pure (Log{..}) + +newShip :: Parser (Cmd, Log) +newShip = (,) <$> (CmdNew <$> new <*> opts) <*> log runOneShip :: Parser (Run, Opts, Bool) runOneShip = (,,) <$> fmap Run pierPath <*> opts <*> df where df = switch (short 'd' <> long "daemon" <> help "Daemon mode" <> hidden) -kingOpts :: Parser KingOpts -kingOpts = do - koSharedHttpPort <- +host :: Parser Host +host = do + hSharedHttpPort <- optional $ option auto $ metavar "PORT" @@ -355,7 +417,7 @@ kingOpts = do <> help "HTTP port" <> hidden - koSharedHttpsPort <- + hSharedHttpsPort <- optional $ option auto $ metavar "PORT" @@ -363,10 +425,10 @@ kingOpts = do <> help "HTTPS port" <> hidden - pure (KingOpts{..}) + pure (Host{..}) -runShip :: Parser Cmd -runShip = CmdRun <$> kingOpts <*> some runOneShip +runShip :: Parser (Cmd, Log) +runShip = (,) <$> (CmdRun <$> host <*> some runOneShip) <*> log valPill :: Parser Bug valPill = do @@ -410,8 +472,8 @@ browseEvs = EventBrowser <$> pierPath checkDawn :: Parser Bug checkDawn = CheckDawn <$> keyfilePath -bugCmd :: Parser Cmd -bugCmd = fmap CmdBug +bugCmd :: Parser (Cmd, Log) +bugCmd = (flip (,) <$> log <*>) $ fmap CmdBug $ subparser $ command "validate-pill" ( info (valPill <**> helper) @@ -446,15 +508,15 @@ bugCmd = fmap CmdBug $ progDesc "Shows the list of stars accepting comets" ) -conCmd :: Parser Cmd -conCmd = CmdCon <$> pierPath +conCmd :: Parser (Cmd, Log) +conCmd = (,) <$> (CmdCon <$> pierPath) <*> log allFx :: Parser Bug allFx = do bPierPath <- strArgument (metavar "PIER" <> help "Path to pier") pure CollectAllFX{..} -cmd :: Parser Cmd +cmd :: Parser (Cmd, Log) cmd = subparser $ command "new" ( info (newShip <**> helper) $ progDesc "Boot a new ship." diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs index 2fb280d2da..e6e39650b0 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs @@ -621,12 +621,12 @@ checkComet = do main :: IO () main = do - args <- CLI.parseArgs + (args, log) <- CLI.parseArgs hSetBuffering stdout NoBuffering setupSignalHandlers - runKingEnv args $ case args of + runKingEnv args log $ case args of CLI.CmdRun ko ships -> runShips ko ships CLI.CmdNew n o -> newShip n o CLI.CmdBug (CLI.CollectAllFX pax ) -> collectAllFx pax @@ -640,11 +640,12 @@ main = do CLI.CmdCon pier -> connTerm pier where - runKingEnv args = + runKingEnv args log = let verb = verboseLogging args - in if willRunTerminal args - then runKingEnvLogFile verb - else runKingEnvStderr verb + in case logTarget (CLI.lTarget log) args of + CLI.LogFile f -> runKingEnvLogFile verb f + CLI.LogStderr -> runKingEnvStderr verb + CLI.LogOff -> runKingEnvNoLog setupSignalHandlers = do mainTid <- myThreadId @@ -657,12 +658,23 @@ main = do CLI.CmdRun ko ships -> any CLI.oVerbose (ships <&> \(_, o, _) -> o) _ -> False - willRunTerminal :: CLI.Cmd -> Bool - willRunTerminal = \case - CLI.CmdCon _ -> True - CLI.CmdRun ko [(_,_,daemon)] -> not daemon - CLI.CmdRun ko _ -> False - _ -> False + -- If the user hasn't specified where to log, what we do depends on what + -- command she has issued. Notably, the LogFile Nothing outcome means that + -- runKingEnvLogFile should run an IO action to get the official app data + -- directory and open a canonically named log file there. + logTarget :: Maybe (CLI.LogTarget FilePath) + -> CLI.Cmd + -> CLI.LogTarget (Maybe FilePath) + logTarget = \case + Just (CLI.LogFile f) -> const $ CLI.LogFile (Just f) + Just CLI.LogStderr -> const $ CLI.LogStderr + Just CLI.LogOff -> const $ CLI.LogOff + Nothing -> \case + CLI.CmdCon _ -> CLI.LogFile Nothing + CLI.CmdRun ko [(_,_,daemon)] | daemon -> CLI.LogStderr + | otherwise -> CLI.LogFile Nothing + CLI.CmdRun ko _ -> CLI.LogStderr + _ -> CLI.LogStderr {- @@ -731,11 +743,11 @@ runShipNoRestart r o d multi = do cancel tid logTrace $ display (pier <> " terminated.") -runShips :: CLI.KingOpts -> [(CLI.Run, CLI.Opts, Bool)] -> RIO KingEnv () -runShips CLI.KingOpts {..} ships = do +runShips :: CLI.Host -> [(CLI.Run, CLI.Opts, Bool)] -> RIO KingEnv () +runShips CLI.Host {..} ships = do let meConf = MultiEyreConf - { mecHttpPort = fromIntegral <$> koSharedHttpPort - , mecHttpsPort = fromIntegral <$> koSharedHttpsPort + { mecHttpPort = fromIntegral <$> hSharedHttpPort + , mecHttpsPort = fromIntegral <$> hSharedHttpsPort , mecLocalhostOnly = False -- TODO Localhost-only needs to be -- a king-wide option. } From 2d1f3cdfa06d899a1188e3b57621f3934fb05c0f Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Sun, 16 Aug 2020 10:33:52 -0700 Subject: [PATCH 170/933] king: thread LogLevel through, make output better --- pkg/hs/urbit-king/lib/Urbit/King/App.hs | 23 ++++++++++++++++------- pkg/hs/urbit-king/lib/Urbit/King/CLI.hs | 10 +++++----- pkg/hs/urbit-king/lib/Urbit/King/Main.hs | 10 ++++++---- pkg/hs/urbit-king/lib/Urbit/Prelude.hs | 7 +++---- pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs | 4 ++-- 5 files changed, 32 insertions(+), 22 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/App.hs b/pkg/hs/urbit-king/lib/Urbit/King/App.hs index 0cf1b07c6f..a4354d72ed 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/App.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/App.hs @@ -76,23 +76,32 @@ instance HasKingId KingEnv where -- Running KingEnvs ------------------------------------------------------------ -runKingEnvStderr :: Bool -> RIO KingEnv a -> IO a -runKingEnvStderr verb inner = do +runKingEnvStderr :: Bool -> LogLevel -> RIO KingEnv a -> IO a +runKingEnvStderr verb lvl inner = do logOptions <- - logOptionsHandle stderr verb <&> setLogUseTime True <&> setLogUseLoc False + logOptionsHandle stderr verb + <&> setLogUseTime True + <&> setLogUseLoc False + <&> setLogMinLevel lvl withLogFunc logOptions $ \logFunc -> runKingEnv logFunc logFunc inner -runKingEnvLogFile :: Bool -> Maybe FilePath -> RIO KingEnv a -> IO a -runKingEnvLogFile verb fileM inner = do +runKingEnvLogFile :: Bool -> LogLevel -> Maybe FilePath -> RIO KingEnv a -> IO a +runKingEnvLogFile verb lvl fileM inner = do logFile <- case fileM of Just f -> pure f Nothing -> defaultLogFile withLogFileHandle logFile $ \h -> do logOptions <- - logOptionsHandle h verb <&> setLogUseTime True <&> setLogUseLoc False + logOptionsHandle h verb + <&> setLogUseTime True + <&> setLogUseLoc False + <&> setLogMinLevel lvl stderrLogOptions <- - logOptionsHandle stderr verb <&> setLogUseTime False <&> setLogUseLoc False + logOptionsHandle stderr verb + <&> setLogUseTime False + <&> setLogUseLoc False + <&> setLogMinLevel lvl withLogFunc stderrLogOptions $ \stderrLogFunc -> withLogFunc logOptions $ \logFunc -> runKingEnv logFunc stderrLogFunc inner diff --git a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs index 218412eea4..283761e622 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs @@ -49,7 +49,7 @@ data Opts = Opts -- | Options for the logging subsystem. data Log = Log { lTarget :: Maybe (LogTarget FilePath) - , lLevel :: Maybe LogLevel + , lLevel :: LogLevel } deriving (Show) @@ -375,20 +375,19 @@ log = do ) lLevel <- - optional - $ ( flag' LevelDebug + ( flag' LevelDebug $ long "log-debug" <> help "Log errors, warnings, info, and debug messages" <> hidden ) <|> ( flag' LevelInfo $ long "log-info" - <> help "Log errors, warnings, and info (default)" + <> help "Log errors, warnings, and info" <> hidden ) <|> ( flag' LevelWarn $ long "log-warn" - <> help "Log errors and warnings" + <> help "Log errors and warnings (default)" <> hidden ) <|> ( flag' LevelError @@ -396,6 +395,7 @@ log = do <> help "Log errors only" <> hidden ) + <|> pure LevelWarn pure (Log{..}) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs index e6e39650b0..998ca8f594 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs @@ -641,10 +641,12 @@ main = do where runKingEnv args log = - let verb = verboseLogging args - in case logTarget (CLI.lTarget log) args of - CLI.LogFile f -> runKingEnvLogFile verb f - CLI.LogStderr -> runKingEnvStderr verb + let + verb = verboseLogging args + CLI.Log {..} = log + in case logTarget lTarget args of + CLI.LogFile f -> runKingEnvLogFile verb lLevel f + CLI.LogStderr -> runKingEnvStderr verb lLevel CLI.LogOff -> runKingEnvNoLog setupSignalHandlers = do diff --git a/pkg/hs/urbit-king/lib/Urbit/Prelude.hs b/pkg/hs/urbit-king/lib/Urbit/Prelude.hs index a19d44cc54..eee5cef166 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Prelude.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Prelude.hs @@ -34,10 +34,9 @@ import Text.Show.Pretty (pPrint, ppShow) import RIO (RIO, runRIO) import RIO (Utf8Builder, display, displayShow) import RIO (threadDelay) - -import RIO (HasLogFunc, LogFunc, logDebug, logError, logFuncL, logInfo, - logOptionsHandle, logOther, logWarn, mkLogFunc, setLogUseLoc, - setLogUseTime, withLogFunc) +import RIO (HasLogFunc, LogFunc, LogLevel(..), logDebug, logError, logFuncL, + logInfo, logOptionsHandle, logOther, logWarn, mkLogFunc, + setLogMinLevel, setLogUseLoc, setLogUseTime, withLogFunc) io :: MonadIO m => IO a -> m a io = liftIO diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs index 78b6d9e5da..9e2ab32b30 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs @@ -494,7 +494,7 @@ router slog waitFx Drivers {..} = do logEvent :: HasLogFunc e => Ev -> RIO e () logEvent ev = do - logTrace $ "<- " <> display (summarizeEvent ev) + logInfo $ "<- " <> display (summarizeEvent ev) logDebug $ "[EVENT]\n" <> display pretty where pretty :: Text @@ -502,7 +502,7 @@ logEvent ev = do logEffect :: HasLogFunc e => Lenient Ef -> RIO e () logEffect ef = do - logTrace $ " -> " <> display (summarizeEffect ef) + logInfo $ " -> " <> display (summarizeEffect ef) logDebug $ display $ "[EFFECT]\n" <> pretty ef where pretty :: Lenient Ef -> Text From 81e3a8f927b492cb9ac7bb51b1a6debae9ebf429 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 17 Aug 2020 10:58:48 -0400 Subject: [PATCH 171/933] natpmp: cleanups for ~master-morzod --- pkg/hs/natpmp-static/cbits/binding.c | 3 ++- pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/hs/natpmp-static/cbits/binding.c b/pkg/hs/natpmp-static/cbits/binding.c index aa024555a7..d665530c5f 100644 --- a/pkg/hs/natpmp-static/cbits/binding.c +++ b/pkg/hs/natpmp-static/cbits/binding.c @@ -54,7 +54,8 @@ int readNatResponseSynchronously(natpmp_t* natpmp, natpmpresp_t * response) getnatpmprequesttimeout(natpmp, &timeout); r = select(FD_SETSIZE, &fds, NULL, NULL, &timeout); if(r<0) { - fprintf(stderr, "select()"); + fprintf(stderr, "select(): errno=%d '%s'\n", + sav_errno, strerror(sav_errno)); return 1; } r = readnatpmpresponseorretry(natpmp, response); diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs index 40e06b7b1b..adf3382e2e 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs @@ -60,8 +60,8 @@ portRenewalTime = portLeaseLifetime - 60 -- Messages sent from the main thread to the port mapping communication thread. data PortThreadMsg = PTMOpen Word16 (STM ()) - -- ^ Does the open request, and then calls the passed in stm action to - -- singal completion to the main thread. We want to block on the initial + -- ^ Does the open request, and then runs the passed in stm action to + -- signal completion to the main thread. We want to block on the initial -- setting opening because we want the forwarding set up before we actually -- start using the port. @@ -89,7 +89,7 @@ portThread q stderr = do initNatPmp >>= \case Left err -> do likelyIPAddress >>= \case - Just ip@(192, 168, c, d) -> warnBehindRouterAndErr ip err + Just ip@(192, 168, _, _) -> warnBehindRouterAndErr ip err Just ip@(10, _, _, _) -> warnBehindRouterAndErr ip err _ -> assumeOnPublicInternet Right pmp -> foundRouter pmp From b25c0b344379c717ec335fa36d27a6ecf3509222 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 17 Aug 2020 13:08:22 -0400 Subject: [PATCH 172/933] natpmp: oops. missed a sav_errno --- pkg/hs/natpmp-static/cbits/binding.c | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/hs/natpmp-static/cbits/binding.c b/pkg/hs/natpmp-static/cbits/binding.c index d665530c5f..d15b57be47 100644 --- a/pkg/hs/natpmp-static/cbits/binding.c +++ b/pkg/hs/natpmp-static/cbits/binding.c @@ -53,6 +53,7 @@ int readNatResponseSynchronously(natpmp_t* natpmp, natpmpresp_t * response) FD_SET(natpmp->s, &fds); getnatpmprequesttimeout(natpmp, &timeout); r = select(FD_SETSIZE, &fds, NULL, NULL, &timeout); + sav_errno = errno; if(r<0) { fprintf(stderr, "select(): errno=%d '%s'\n", sav_errno, strerror(sav_errno)); From 6a236a2749c8306c64084289f26581d751e5ea13 Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Mon, 17 Aug 2020 11:24:17 -0700 Subject: [PATCH 173/933] king: use XDG cache directory for default log location --- pkg/hs/urbit-king/lib/Urbit/King/App.hs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/App.hs b/pkg/hs/urbit-king/lib/Urbit/King/App.hs index a4354d72ed..e5a1649af2 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/App.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/App.hs @@ -26,7 +26,8 @@ import Urbit.King.Config import Urbit.Prelude import System.Directory ( createDirectoryIfMissing - , getAppUserDataDirectory + , getXdgDirectory + , XdgDirectory(XdgCache) ) import System.Posix.Internals (c_getpid) import System.Posix.Types (CPid(..)) @@ -83,7 +84,6 @@ runKingEnvStderr verb lvl inner = do <&> setLogUseTime True <&> setLogUseLoc False <&> setLogMinLevel lvl - withLogFunc logOptions $ \logFunc -> runKingEnv logFunc logFunc inner runKingEnvLogFile :: Bool -> LogLevel -> Maybe FilePath -> RIO KingEnv a -> IO a @@ -102,7 +102,6 @@ runKingEnvLogFile verb lvl fileM inner = do <&> setLogUseTime False <&> setLogUseLoc False <&> setLogMinLevel lvl - withLogFunc stderrLogOptions $ \stderrLogFunc -> withLogFunc logOptions $ \logFunc -> runKingEnv logFunc stderrLogFunc inner @@ -114,7 +113,7 @@ withLogFileHandle f act = defaultLogFile :: IO FilePath defaultLogFile = do - logDir <- getAppUserDataDirectory "urbit" + logDir <- getXdgDirectory XdgCache "urbit" createDirectoryIfMissing True logDir pure (logDir "king.log") From e160620256f27cc391e56cd2fe3cc77090b4b936 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 17 Aug 2020 15:24:52 -0700 Subject: [PATCH 174/933] ur: refactors jam/cue tests --- pkg/urbit/tests/ur_tests.c | 201 ++++++++++++++++++------------------- 1 file changed, 97 insertions(+), 104 deletions(-) diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index c563bf303f..98f83e5873 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -1,181 +1,174 @@ -#include "all.h" +#include +#include +#include +#include +#include +#include + #include "ur/hashcons.h" -static c3_i -_test_jam(const c3_c* cap_c, - ur_root_t* rot_u, - ur_nref ref, - c3_w len_w, - const c3_y* res_y) +static int +_test_jam_spec(const char *cap, + ur_root_t *r, + ur_nref ref, + size_t len, + const uint8_t *res) { - c3_d i_d, len_d; - c3_y* out_y; - c3_i ret_i; + uint64_t i, out_len; + uint8_t *out; + int ret; - ur_jam(rot_u, ref, &len_d, &out_y); + ur_jam(r, ref, &out_len, &out); - if ( 0 != memcmp(out_y, res_y, len_w) ) { - fprintf(stderr, "\033[31mjam %s fail\033[0m\r\n", cap_c); + if ( 0 != memcmp(out, res, len) ) { + fprintf(stderr, "\033[31mjam %s fail\033[0m\r\n", cap); fprintf(stderr, " actual: { "); - for ( i_d = 0; i_d < len_d; i_d++ ) { - fprintf(stderr, "0x%x, ", out_y[i_d]); + for ( i = 0; i < out_len; i++ ) { + fprintf(stderr, "0x%x, ", out[i]); } fprintf(stderr, "}\r\n"); fprintf(stderr, " expect: { "); - for ( i_d = 0; i_d < len_w; i_d++ ) { - fprintf(stderr, "0x%x, ", res_y[i_d]); + for ( i = 0; i < len; i++ ) { + fprintf(stderr, "0x%x, ", res[i]); } fprintf(stderr, "}\r\n"); - ret_i = 0; + ret = 0; } else { - ret_i = 1; + ret = 1; } - c3_free(out_y); + free(out); - return ret_i; + return ret; } -static c3_i -_test_cue(const c3_c* cap_c, - ur_root_t* rot_u, - ur_nref ref, - c3_w len_w, - const c3_y* res_y) +static int +_test_cue_spec(const char *cap, + ur_root_t* r, + ur_nref ref, + size_t len, + const uint8_t *res) { ur_nref out; - if ( ur_cue_good != ur_cue(rot_u, len_w, res_y, &out) ) { - fprintf(stderr, "\033[31mcue %s fail 1\033[0m\r\n", cap_c); + if ( ur_cue_good != ur_cue(r, len, res, &out) ) { + fprintf(stderr, "\033[31mcue %s fail 1\033[0m\r\n", cap); return 0; } else if ( ref != out ) { - fprintf(stderr, "\033[31mcue %s fail 2 ref=%" PRIu64 " out=%" PRIu64 " \033[0m\r\n", cap_c, ref, out); + fprintf(stderr, "\033[31mcue %s fail 2 ref=%" PRIu64 " out=%" PRIu64 " \033[0m\r\n", cap, ref, out); return 0; } return 1; } -static c3_i -_test_ur(void) +static int +_test_jam_cue(void) { - ur_root_t* rot_u = ur_hcon_init(); - c3_d i_d, len_d; - c3_y* byt_y; - c3_i res_i = 1; + ur_root_t *r = ur_hcon_init(); + int ret = 1; -# define nc(a, b) ur_cons(rot_u, a, b) -# define nt(a, b, c) nc(a, nc(b, c)) +# define NC(a, b) ur_cons(r, a, b) +# define NT(a, b, c) NC(a, NC(b, c)) + +# define FAST 0x74736166 +# define FULL 0x6c6c7566 + +# define TEST_CASE(a, b) \ + const char* cap = a; \ + ur_nref ref = b; \ + ret &= _test_jam_spec(cap, r, ref, sizeof(res), res); \ + ret &= _test_cue_spec(cap, r, ref, sizeof(res), res); \ { - c3_c* cap_c = "0"; - c3_y res_y[1] = { 0x2 }; - ur_nref ref = 0; - res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); - res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); + uint8_t res[1] = { 0x2 }; + TEST_CASE("0", 0); } { - c3_c* cap_c = "1"; - c3_y res_y[1] = { 0xc }; - ur_nref ref = 1; - res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); - res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); + uint8_t res[1] = { 0xc }; + TEST_CASE("1", 1); } { - c3_c* cap_c = "2"; - c3_y res_y[1] = { 0x48 }; - ur_nref ref = 2; - res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); - res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); + uint8_t res[1] = { 0x48 }; + TEST_CASE("2", 2); } { - c3_c* cap_c = "%fast"; - c3_y res_y[6] = { 0xc0, 0x37, 0xb, 0x9b, 0xa3, 0x3 }; - ur_nref ref = c3__fast; - res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); - res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); + uint8_t res[6] = { 0xc0, 0x37, 0xb, 0x9b, 0xa3, 0x3 }; + TEST_CASE("%fast", FAST); } { - c3_c* cap_c = "%full"; - c3_y res_y[6] = { 0xc0, 0x37, 0xab, 0x63, 0x63, 0x3 }; - ur_nref ref = c3__full; - res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); - res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); + uint8_t res[6] = { 0xc0, 0x37, 0xab, 0x63, 0x63, 0x3 }; + TEST_CASE("%full", FULL); } { - c3_c* cap_c = "[0 0]"; - c3_y res_y[1] = { 0x29 }; - ur_nref ref = nc(0, 0); - res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); - res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); + uint8_t res[1] = { 0x29 }; + TEST_CASE("[0 0]", NC(0, 0)); } { - c3_c* cap_c = "[1 1]"; - c3_y res_y[2] = { 0x31, 0x3 }; - ur_nref ref = nc(1, 1); - res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); - res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); + uint8_t res[2] = { 0x31, 0x3 }; + TEST_CASE("[1 1]", NC(1, 1)); } { - c3_c* cap_c = "[2 3]"; - c3_y res_y[2] = { 0x21, 0xd1 }; - ur_nref ref = nc(2, 3); - res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); - res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); + uint8_t res[2] = { 0x21, 0xd1 }; + TEST_CASE("[2 3]", NC(2, 3)); } { - c3_c* cap_c = "[%fast %full]"; - c3_y res_y[11] = { 0x1, 0xdf, 0x2c, 0x6c, 0x8e, 0xe, 0x7c, 0xb3, 0x3a, 0x36, 0x36 }; - ur_nref ref = nc(c3__fast, c3__full); - res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); - res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); + uint8_t res[11] = { 0x1, 0xdf, 0x2c, 0x6c, 0x8e, 0xe, 0x7c, 0xb3, 0x3a, 0x36, 0x36 }; + TEST_CASE("[%fast %full]", NC(FAST, FULL)); } { - c3_c* cap_c = "[1 1 1]"; - c3_y res_y[2] = { 0x71, 0xcc }; - ur_nref ref = nc(1, nc(1, 1)); - res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); - res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); + uint8_t res[2] = { 0x71, 0xcc }; + TEST_CASE("[1 1 1]", NC(1, NC(1, 1))); } { - c3_c* cap_c = "[%fast %full %fast]"; - c3_y res_y[12] = { 0x1, 0xdf, 0x2c, 0x6c, 0x8e, 0x1e, 0xf0, 0xcd, 0xea, 0xd8, 0xd8, 0x93 }; - ur_nref ref = nc(c3__fast, nc(c3__full, c3__fast)); - res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); - res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); + uint8_t res[12] = { 0x1, 0xdf, 0x2c, 0x6c, 0x8e, 0x1e, 0xf0, 0xcd, 0xea, 0xd8, 0xd8, 0x93 }; + TEST_CASE("[%fast %full %fast]", NC(FAST, NC(FULL, FAST))); } { - c3_c* cap_c = "[[0 0] [[0 0] 1 1] 1 1]"; - c3_y res_y[6] = { 0xa5, 0x35, 0x19, 0xf3, 0x18, 0x5 }; - ur_nref ref = nc(nc(0, 0), nc(nc(nc(0, 0), nc(1, 1)), nc(1, 1))); - res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); - res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); + uint8_t res[6] = { 0xa5, 0x35, 0x19, 0xf3, 0x18, 0x5 }; + TEST_CASE("[[0 0] [[0 0] 1 1] 1 1]", NC(NC(0, 0), NC(NC(NC(0, 0), NC(1, 1)), NC(1, 1)))); } { - c3_c* cap_c = "big"; - c3_y res_y[14] = { 0x15, 0x17, 0xb2, 0xd0, 0x85, 0x59, 0xb8, 0x61, 0x87, 0x5f, 0x10, 0x54, 0x55, 0x5 }; - ur_nref ref = nc(nc(nc(1, nc(nc(2, nc(nc(3, nc(nc(4, nc(nt(5, 6, nc(7, nc(nc(8, 0), 0))), 0)), 0)), 0)), 0)), 0), 0); - res_i &= _test_jam(cap_c, rot_u, ref, sizeof(res_y), res_y); - res_i &= _test_cue(cap_c, rot_u, ref, sizeof(res_y), res_y); + uint8_t res[14] = { 0x15, 0x17, 0xb2, 0xd0, 0x85, 0x59, 0xb8, 0x61, 0x87, 0x5f, 0x10, 0x54, 0x55, 0x5 }; + TEST_CASE("deep", NC(NC(NC(1, NC(NC(2, NC(NC(3, NC(NC(4, NC(NT(5, 6, NC(7, NC(NC(8, 0), 0))), 0)), 0)), 0)), 0)), 0), 0)); } - return res_i; + { + uint8_t inp[33] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + uint8_t res[35] = { 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8 }; + TEST_CASE("wide", ur_coin_bytes(r, inp, sizeof(inp))); + } + + return ret; +} + +static int +_test_ur(void) +{ + int ret = 1; + + if ( !_test_jam_cue() ) { + fprintf(stderr, "ur test jam/cue failed\r\n"); + ret = 0; + } + + return ret; } int From 9282247ba5716c1ae9584034b1e69fc39a694c86 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 17 Aug 2020 17:45:00 -0700 Subject: [PATCH 175/933] ur: adds tests for bitstream write functions (ur_bsw*) --- pkg/urbit/include/ur/hashcons.h | 32 +++ pkg/urbit/tests/ur_tests.c | 333 ++++++++++++++++++++++++++++++++ pkg/urbit/ur/hashcons.c | 315 +++++++++++++++++------------- 3 files changed, 545 insertions(+), 135 deletions(-) diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index 17ca35a330..1f492168d2 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -171,6 +171,38 @@ ur_walk_fore(ur_root_t *r, void (*atom)(ur_root_t*, ur_nref, void*), ur_bool_t (*cell)(ur_root_t*, ur_nref, void*)); + +typedef struct ur_bsw_s { + uint64_t prev; + uint64_t size; + uint64_t fill; + uint64_t bits; + uint8_t off; + uint8_t *bytes; +} ur_bsw_t; + +void +ur_bsw_grow(ur_bsw_t *bsw); + +ur_bool_t +ur_bsw_sane(ur_bsw_t *bsw); + +void +ur_bsw_bit(ur_bsw_t *bsw, uint8_t bit); + +void +ur_bsw8(ur_bsw_t *bsw, uint8_t len, uint8_t byt); +void +ur_bsw8_slow(ur_bsw_t *bsw, uint8_t len, uint8_t byt); + +void +ur_bsw64(ur_bsw_t *bsw, uint8_t len_bit, uint64_t val); +void +ur_bsw64_slow(ur_bsw_t *bsw, uint8_t len, uint64_t val); + +void +ur_bsw_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt); + uint64_t ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt); diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index 98f83e5873..c32f616d6f 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -7,6 +7,334 @@ #include "ur/hashcons.h" +static void +_bsw_init(ur_bsw_t *bsw, uint64_t prev, uint64_t size) +{ + bsw->prev = prev; + bsw->size = size; + bsw->bits = 0; + bsw->fill = 0; + bsw->off = 0; + + free(bsw->bytes); + bsw->bytes = calloc(size, 1); +} + +static int +_bsw_bit_check(const char* cap, ur_bsw_t *bsw, uint8_t byt, uint8_t off) +{ + int ret = 1; + + if ( !ur_bsw_sane(bsw) ) { + fprintf(stderr, "%s: insane off=%u fill=%" PRIu64 " bits=%" PRIu64 "\r\n", + cap, bsw->off, bsw->fill, bsw->bits); + ret = 0; + } + + if ( byt != bsw->bytes[0] ) { + fprintf(stderr, "%s: bytes fail (%u, %u)\r\n", cap, byt, bsw->bytes[0]); + ret = 0; + } + + if ( off != bsw->off ) { + fprintf(stderr, "%s: offset fail (%u, %u)\r\n", cap, off, bsw->off); + ret = 0; + } + + return ret; +} + +static int +_test_bsw_bit_ones(void) +{ + int ret = 1; + ur_bsw_t bsw = {0}; + _bsw_init(&bsw, 1, 1); + + ret &= _bsw_bit_check("bsw ones init", &bsw, 0x0, 0); + + ur_bsw_bit(&bsw, 1); + ret &= _bsw_bit_check("bsw ones a", &bsw, 0x1, 1); + + ur_bsw_bit(&bsw, 1); + ret &= _bsw_bit_check("bsw ones b", &bsw, 0x3, 2); + + ur_bsw_bit(&bsw, 1); + ret &= _bsw_bit_check("bsw ones c", &bsw, 0x7, 3); + + ur_bsw_bit(&bsw, 1); + ret &= _bsw_bit_check("bsw ones d", &bsw, 0xf, 4); + + ur_bsw_bit(&bsw, 1); + ret &= _bsw_bit_check("bsw ones e", &bsw, 0x1f, 5); + + ur_bsw_bit(&bsw, 1); + ret &= _bsw_bit_check("bsw ones f", &bsw, 0x3f, 6); + + ur_bsw_bit(&bsw, 1); + ret &= _bsw_bit_check("bsw ones g", &bsw, 0x7f, 7); + + ur_bsw_bit(&bsw, 1); + ret &= _bsw_bit_check("bsw ones h", &bsw, 0xff, 0); + + if ( bsw.size != 2 ) { + fprintf(stderr, "bsw ones grow: fail\r\n"); + ret = 0; + } + + free(bsw.bytes); + + return ret; +} + +static int +_test_bsw_bit_zeros(void) +{ + int ret = 1; + ur_bsw_t bsw = {0}; + _bsw_init(&bsw, 1, 1); + + ret &= _bsw_bit_check("bsw zeros init", &bsw, 0x0, 0); + + ur_bsw_bit(&bsw, 0); + ret &= _bsw_bit_check("bsw zeros a", &bsw, 0x0, 1); + + ur_bsw_bit(&bsw, 0); + ret &= _bsw_bit_check("bsw zeros b", &bsw, 0x0, 2); + + ur_bsw_bit(&bsw, 0); + ret &= _bsw_bit_check("bsw zeros c", &bsw, 0x0, 3); + + ur_bsw_bit(&bsw, 0); + ret &= _bsw_bit_check("bsw zeros d", &bsw, 0x0, 4); + + ur_bsw_bit(&bsw, 0); + ret &= _bsw_bit_check("bsw zeros e", &bsw, 0x0, 5); + + ur_bsw_bit(&bsw, 0); + ret &= _bsw_bit_check("bsw zeros f", &bsw, 0x0, 6); + + ur_bsw_bit(&bsw, 0); + ret &= _bsw_bit_check("bsw zeros g", &bsw, 0x0, 7); + + ur_bsw_bit(&bsw, 0); + ret &= _bsw_bit_check("bsw zeros h", &bsw, 0x0, 0); + + if ( bsw.size != 2 ) { + fprintf(stderr, "bsw zeros grow: fail\r\n"); + ret = 0; + } + + free(bsw.bytes); + + return ret; +} + +static int +_test_bsw_bit_alt(void) +{ + int ret = 1; + ur_bsw_t bsw = {0}; + _bsw_init(&bsw, 1, 1); + + ret &= _bsw_bit_check("bsw alt init", &bsw, 0x0, 0); + + ur_bsw_bit(&bsw, 0); + ret &= _bsw_bit_check("bsw alt a", &bsw, 0x0, 1); + + ur_bsw_bit(&bsw, 1); + ret &= _bsw_bit_check("bsw alt b", &bsw, 0x2, 2); + + ur_bsw_bit(&bsw, 0); + ret &= _bsw_bit_check("bsw alt c", &bsw, 0x2, 3); + + ur_bsw_bit(&bsw, 1); + ret &= _bsw_bit_check("bsw alt d", &bsw, 0xa, 4); + + ur_bsw_bit(&bsw, 0); + ret &= _bsw_bit_check("bsw alt e", &bsw, 0xa, 5); + + ur_bsw_bit(&bsw, 1); + ret &= _bsw_bit_check("bsw alt f", &bsw, 0x2a, 6); + + ur_bsw_bit(&bsw, 0); + ret &= _bsw_bit_check("bsw alt g", &bsw, 0x2a, 7); + + ur_bsw_bit(&bsw, 1); + ret &= _bsw_bit_check("bsw alt h", &bsw, 0xaa, 0); + + if ( bsw.size != 2 ) { + fprintf(stderr, "bsw alt grow: fail\r\n"); + ret = 0; + } + + free(bsw.bytes); + + return ret; +} + +static int +_test_bsw_bit(void) +{ + return _test_bsw_bit_ones() + & _test_bsw_bit_zeros() + & _test_bsw_bit_alt(); +} + +static int +_bsw_cmp_check(const char* cap, uint8_t val, uint8_t off, uint8_t len, ur_bsw_t *a, ur_bsw_t *b) +{ + int ret = 1; + + if ( !ur_bsw_sane(a) ) { + fprintf(stderr, "%s: val 0x%02x off %u, len %u: a insane off=%u fill=%" PRIu64 " bits=%" PRIu64 "\r\n", + cap, val, off, len, a->off, a->fill, a->bits); + ret = 0; + } + if ( !ur_bsw_sane(b) ) { + fprintf(stderr, "%s: val 0x%02x off %u len %u: b insane off=%u fill=%" PRIu64 " bits=%" PRIu64 "\r\n", + cap, val, off, len, b->off, b->fill, b->bits); + ret = 0; + } + + if ( a->bytes[0] != b->bytes[0] ) { + fprintf(stderr, "%s: val 0x%02x off %u len %u: bytes fail (0x%02x, 0x%02x)\r\n", + cap, val, off, len, a->bytes[0], b->bytes[0]); + ret = 0; + } + + if ( a->off != b->off ) { + fprintf(stderr, "%s: val 0x%02x off %u len %u: offset fail (%u, %u)\r\n", + cap, val, off, len, a->off, b->off); + ret = 0; + } + + if ( a->fill != b->fill ) { + fprintf(stderr, "%s: val 0x%02x off %u len %u: fill fail (%" PRIu64 ", %" PRIu64 ")\r\n", + cap, val, off, len, a->fill, b->fill); + ret = 0; + } + + return ret; +} + +static int +_test_bsw8_loop(const char* cap, uint8_t val) +{ + int ret = 1; + ur_bsw_t a = {0}; + ur_bsw_t b = {0}; + uint8_t i, j; + + for ( i = 0; i < 8; i++) { + for ( j = 0; j <= 8; j++ ) { + _bsw_init(&a, 1, 1); + _bsw_init(&b, 1, 1); + a.off = a.bits = b.off = b.bits = i; + + ur_bsw8_slow(&a, j, val); + ur_bsw8(&b, j, val); + + ret &= _bsw_cmp_check(cap, val, i, j, &a, &b); + } + } + + return ret; +} + +static int +_test_bsw8(void) +{ + return _test_bsw8_loop("bsw bits ones", 0xff) + & _test_bsw8_loop("bsw bits zeros", 0x0) + & _test_bsw8_loop("bsw bits alt 1", 0xaa) + & _test_bsw8_loop("bsw bits alt 2", 0x55); +} + +static int +_test_bsw64_loop(const char* cap, uint64_t val) +{ + int ret = 1; + ur_bsw_t a = {0}; + ur_bsw_t b = {0}; + uint8_t i, j; + + for ( i = 0; i < 8; i++) { + for ( j = 0; j <= 64; j++ ) { + _bsw_init(&a, 1, 1); + _bsw_init(&b, 1, 1); + a.off = a.bits = b.off = b.bits = i; + + ur_bsw64_slow(&a, j, val); + ur_bsw64(&b, j, val); + + ret &= _bsw_cmp_check(cap, val, i, j, &a, &b); + } + } + + return ret; +} + +static int +_test_bsw64(void) +{ + return _test_bsw64_loop("bsw 64 ones", 0xffffffffffffffffULL) + & _test_bsw64_loop("bsw 64 zeros", 0x0ULL) + & _test_bsw64_loop("bsw 64 alt 1", 0xaaaaaaaaaaaaaaaaULL) + & _test_bsw64_loop("bsw 64 alt 2", 0x5555555555555555ULL); +} + +static int +_test_bsw_bytes_loop(const char* cap, uint64_t len, uint8_t val) +{ + int ret = 1; + ur_bsw_t a = {0}; + ur_bsw_t b = {0}; + uint8_t i, j, *byt; + + for ( i = 0; i < 8; i++) { + _bsw_init(&a, 1, 1); + _bsw_init(&b, 1, 1); + a.off = a.bits = b.off = b.bits = i; + byt = malloc(len); + + for ( j = 0; j < len; j++ ) { + ur_bsw8_slow(&a, 8, val); + byt[j] = val; + } + + ur_bsw_bytes(&b, len, byt); + free(byt); + + ret &= _bsw_cmp_check(cap, val, 8, i, &a, &b); + } + + return ret; +} + +static int +_test_bsw_bytes(void) +{ + return _test_bsw_bytes_loop("bsw bytes nought", 0, 0x0) + & _test_bsw_bytes_loop("bsw bytes ones odd", 3, 0xff) + & _test_bsw_bytes_loop("bsw bytes ones even", 4, 0xff) + & _test_bsw_bytes_loop("bsw bytes zeros odd", 5, 0x0) + & _test_bsw_bytes_loop("bsw bytes zeros even", 6, 0x0) + & _test_bsw_bytes_loop("bsw bytes alt 1 odd", 7, 0xaa) + & _test_bsw_bytes_loop("bsw bytes alt 1 even", 8, 0xaa) + & _test_bsw_bytes_loop("bsw bytes alt 2 odd", 9, 0x55) + & _test_bsw_bytes_loop("bsw bytes alt 2 odd", 10, 0x55); +} + +static int +_test_bsw(void) +{ + return _test_bsw_bit() + & _test_bsw8() + & _test_bsw64() + & _test_bsw_bytes(); +} + static int _test_jam_spec(const char *cap, ur_root_t *r, @@ -163,6 +491,11 @@ _test_ur(void) { int ret = 1; + if ( !_test_bsw() ) { + fprintf(stderr, "ur test bsw failed\r\n"); + ret = 0; + } + if ( !_test_jam_cue() ) { fprintf(stderr, "ur test jam/cue failed\r\n"); ret = 0; diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 2b694bc821..62739903cc 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -884,24 +884,13 @@ ur_walk_fore(ur_root_t *r, free(don); } -typedef struct ur_bsw_s { - uint64_t prev; - uint64_t size; - uint64_t fill; - uint64_t bits; - uint8_t off; - uint8_t *bytes; -} ur_bsw_t; - -static inline void +void ur_bsw_grow(ur_bsw_t *bsw) { uint64_t prev = bsw->prev; uint64_t size = bsw->size; uint64_t next = prev + size; - // fprintf(stderr, "bsw: grow: %" PRIu64 "-%" PRIu64" fill: %" PRIu64 "\r\n", size, next, bsw->fill); - bsw->bytes = realloc(bsw->bytes, next); assert(bsw->bytes); memset(bsw->bytes + size, 0, prev); @@ -910,21 +899,23 @@ ur_bsw_grow(ur_bsw_t *bsw) bsw->size = next; } -static void -ur_bsw_bit(ur_bsw_t *bsw, uint8_t bit) +ur_bool_t +ur_bsw_sane(ur_bsw_t *bsw) +{ + return ( (8 > bsw->off) + && ((bsw->fill << 3) + bsw->off == bsw->bits) ); +} + +static inline void +_bsw_bit_unsafe(ur_bsw_t *bsw, uint8_t bit) { uint64_t fill = bsw->fill; uint8_t off = bsw->off; - uint8_t old = bsw->bytes[fill]; - bsw->bytes[fill] = old ^ ((bit & 1) << off); + bsw->bytes[fill] ^= (bit & 1) << off; if ( 7 == off ) { - if ( ++fill == bsw->size ) { - ur_bsw_grow(bsw); - } - - bsw->fill = fill; + bsw->fill = 1 + fill; bsw->off = 0; } else { @@ -932,92 +923,81 @@ ur_bsw_bit(ur_bsw_t *bsw, uint8_t bit) } bsw->bits++; - - // if ( (bsw->fill << 3) + bsw->off != bsw->bits ) { - // fprintf(stderr, "bit fill: %" PRIu64 " off: %u bits: %" PRIu64 ", calc: %" PRIu64 "\r\n", - // bsw->fill, - // bsw->off, - // bsw->bits, - // (bsw->fill << 3) + bsw->off); - // assert(0); - // } } -static void -ur_bsw_bits(ur_bsw_t *bsw, uint8_t len, uint8_t byt) +void +ur_bsw_bit(ur_bsw_t *bsw, uint8_t bit) { - uint64_t fill = bsw->fill; - uint8_t off = bsw->off; - - // XX - assert( 8 > len ); - + if ( (7 == bsw->off) + && ((1 + bsw->fill) == bsw->size) ) { - uint8_t rest = 8 - off; - uint8_t old = bsw->bytes[fill]; - - if ( len < rest ) { - uint8_t left = (byt & ((1 << len) - 1)) << off; - - bsw->bytes[fill] = old ^ left; - bsw->off = off + len; - } - else { - uint8_t left, right; - - left = (byt & ((1 << rest) - 1)) << off; - off = len - rest; - right = (byt >> rest) & ((1 << off) - 1); - - if ( (fill + 1 + !!off) >= bsw->size ) { - ur_bsw_grow(bsw); - } - - bsw->bytes[fill] = old ^ left; - fill++; - bsw->bytes[fill] = right; - - bsw->fill = fill; - bsw->off = off; - } - } - - bsw->bits += len; - - // if ( (bsw->fill << 3) + bsw->off != bsw->bits ) { - // fprintf(stderr, "bits fill: %" PRIu64 " off: %u bits: %" PRIu64 ", calc: %" PRIu64 "\r\n", - // bsw->fill, - // bsw->off, - // bsw->bits, - // (bsw->fill << 3) + bsw->off); - // assert(0); - // } -} - -static void -ur_bsw_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) -{ - uint64_t fill = bsw->fill; - uint64_t full = fill + len; - uint8_t off = bsw->off; - - // XX - assert(len); - - if ( (full + !!off) >= bsw->size ) { - uint64_t prev = bsw->prev; - - // be sure to grow sufficiently - // - if ( len > prev ) { - bsw->prev = len; - } - ur_bsw_grow(bsw); } + _bsw_bit_unsafe(bsw, bit); +} + +static inline void +_bsw8_unsafe(ur_bsw_t *bsw, uint8_t len, uint8_t byt) +{ + uint64_t fill = bsw->fill; + uint8_t off = bsw->off; + uint8_t rest = 8 - off; + uint8_t old = bsw->bytes[fill]; + + if ( len < rest ) { + uint8_t left = (byt & ((1 << len) - 1)) << off; + + bsw->bytes[fill] = old ^ left; + bsw->off = off + len; + } + else { + uint8_t left, right; + + left = (byt & ((1 << rest) - 1)) << off; + off = len - rest; + right = (byt >> rest) & ((1 << off) - 1); + + bsw->bytes[fill] = old ^ left; + fill++; + bsw->bytes[fill] = right; + + bsw->fill = fill; + bsw->off = off; + } + + bsw->bits += len; +} + +void +ur_bsw8(ur_bsw_t *bsw, uint8_t len, uint8_t byt) +{ + if ( bsw->fill + !!((bsw->off + len) >> 3) >= bsw->size ) { + ur_bsw_grow(bsw); + } + + _bsw8_unsafe(bsw, (len > 8) ? 8 : len, byt); +} + +void +ur_bsw8_slow(ur_bsw_t *bsw, uint8_t len, uint8_t byt) +{ + while ( len ) { + ur_bsw_bit(bsw, byt); + byt >>= 1; + len--; + } +} + +static inline void +_bsw_bytes_unsafe(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) +{ + uint64_t fill = bsw->fill; + uint8_t off = bsw->off; + if ( !off ) { memcpy(bsw->bytes + fill, byt, len); + fill += len; } else { uint8_t rest = 8 - off; @@ -1033,25 +1013,32 @@ ur_bsw_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) } bsw->bytes[fill] = old; - - assert( full == fill ); } - bsw->fill = full; + bsw->fill = fill; bsw->bits += len << 3; - - // if ( (bsw->fill << 3) + bsw->off != bsw->bits ) { - // fprintf(stderr, "bytes fill: %" PRIu64 " off: %u bits: %" PRIu64 ", calc: %" PRIu64 "\r\n", - // bsw->fill, - // bsw->off, - // bsw->bits, - // (bsw->fill << 3) + bsw->off); - // assert(0); - // } } -static void -ur_bsw64(ur_bsw_t *bsw, uint8_t len_bit, uint64_t val) +void +ur_bsw_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) +{ + if ( (bsw->fill + len + !!bsw->off) >= bsw->size ) { + uint64_t prev = bsw->prev; + + // be sure to grow sufficiently + // + if ( len > prev ) { + bsw->prev = len; + } + + ur_bsw_grow(bsw); + } + + _bsw_bytes_unsafe(bsw, len, byt); +} + +static inline void +_bsw64_unsafe(ur_bsw_t *bsw, uint8_t len_bit, uint64_t val) { // assumes little-endian // @@ -1060,44 +1047,74 @@ ur_bsw64(ur_bsw_t *bsw, uint8_t len_bit, uint64_t val) uint8_t low = ur_mask_3(len_bit); if ( len_byt ) { - ur_bsw_bytes(bsw, len_byt, byt); + _bsw_bytes_unsafe(bsw, len_byt, byt); } if ( low ) { - ur_bsw_bits(bsw, low, byt[len_byt]); + _bsw8_unsafe(bsw, low, byt[len_byt]); + } +} + +void +ur_bsw64(ur_bsw_t *bsw, uint8_t len, uint64_t val) +{ + uint8_t bits = bsw->off + len; + + if ( bsw->fill + (bits >> 3) + !!ur_mask_3(bits) >= bsw->size ) { + ur_bsw_grow(bsw); + } + + _bsw64_unsafe(bsw, (len > 64) ? 64 : len, val); +} + +void +ur_bsw64_slow(ur_bsw_t *bsw, uint8_t len, uint64_t val) +{ + while ( len ) { + ur_bsw_bit(bsw, val & 0xff); + val >>= 1; + len--; } } static inline void -ur_bsw_mat64(ur_bsw_t *bsw, uint8_t len_bit, uint64_t val) +_bsw_mat64_unsafe(ur_bsw_t *bsw, uint8_t len_len, uint8_t len, uint64_t val) { if ( 0 == val ) { - ur_bsw_bit(bsw, 1); + _bsw_bit_unsafe(bsw, 1); } else { - uint8_t len_len = ur_met0_64(len_bit); - - ur_bsw64(bsw, len_len + 1, 1ULL << len_len); - ur_bsw64(bsw, len_len - 1, len_bit); - ur_bsw64(bsw, len_bit, val); + _bsw64_unsafe(bsw, len_len + 1, 1ULL << len_len); + _bsw64_unsafe(bsw, len_len - 1, len); + _bsw64_unsafe(bsw, len, val); } } +void +ur_bsw_mat64(ur_bsw_t *bsw, uint8_t len, uint64_t val) +{ + len = ( len > 64 ) ? 64 : len; + + { + uint8_t len_len = ur_met0_64(len); + uint8_t next = ( 0 == val ) ? 1 : len + (2 * len_len); + uint8_t bits = bsw->off + next; + + if ( bsw->fill + (bits >> 3) + !!ur_mask_3(bits) >= bsw->size ) { + ur_bsw_grow(bsw); + } + + _bsw_mat64_unsafe(bsw, len_len, len, val); + } +} static inline void -ur_bsw_mat_bytes(ur_bsw_t *bsw, uint64_t len_bit, uint64_t len, uint8_t *byt) +_bsw_mat_bytes_unsafe(ur_bsw_t *bsw, uint8_t len_len, uint64_t len_bit, uint64_t len, uint8_t *byt) { // write run-length // - { - uint8_t len_len = ur_met0_64(len_bit); - - // XX - assert( 64 > len_len ); - - ur_bsw64(bsw, len_len + 1, 1ULL << len_len); - ur_bsw64(bsw, len_len - 1, len_bit); - } + _bsw64_unsafe(bsw, len_len + 1, 1ULL << len_len); + _bsw64_unsafe(bsw, len_len - 1, len_bit); // write bytes // @@ -1105,16 +1122,44 @@ ur_bsw_mat_bytes(ur_bsw_t *bsw, uint64_t len_bit, uint64_t len, uint8_t *byt) uint8_t low = ur_mask_3(len_bit); if ( !low ) { - ur_bsw_bytes(bsw, len, byt); + _bsw_bytes_unsafe(bsw, len, byt); } else { - uint64_t last = len - 1; - ur_bsw_bytes(bsw, last, byt); - ur_bsw_bits(bsw, low, byt[last]); + len--; + _bsw_bytes_unsafe(bsw, len, byt); + _bsw8_unsafe(bsw, low, byt[len]); } } } +void +ur_bsw_mat_bytes(ur_bsw_t *bsw, uint64_t len_bit, uint64_t len, uint8_t *byt) +{ + uint8_t len_len = ur_met0_64(len_bit); + + // XX + assert( 64 > len_len ); + + { + uint8_t bits = bsw->off + (2 * len_len); + uint64_t need = len + (bits >> 3) + !!ur_mask_3(bits); + + if ( (bsw->fill + need) >= bsw->size ) { + uint64_t prev = bsw->prev; + + // be sure to grow sufficiently + // + if ( need > prev ) { + bsw->prev = need; + } + + ur_bsw_grow(bsw); + } + + _bsw_mat_bytes_unsafe(bsw, len_len, len_bit, len, byt); + } +} + typedef struct ur_bsr_s { uint64_t left; uint64_t bits; From a9d2a29bf2625e323b5615a0844e0eca62ad10fb Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 17 Aug 2020 18:35:00 -0700 Subject: [PATCH 176/933] ur: rewrites _bsw64_unsafe() for efficiency --- pkg/urbit/ur/hashcons.c | 172 ++++++++++++++++++++++++++++++---------- 1 file changed, 132 insertions(+), 40 deletions(-) diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 62739903cc..1893a6ee60 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -989,6 +989,138 @@ ur_bsw8_slow(ur_bsw_t *bsw, uint8_t len, uint8_t byt) } } +static inline void +_bsw64_unsafe(ur_bsw_t *bsw, uint8_t len, uint64_t val) +{ + uint64_t fill = bsw->fill; + uint8_t off = bsw->off; + uint8_t *bytes = bsw->bytes; + + bsw->bits += len; + + if ( off ) { + uint8_t rest = 8 - off; + + if ( len < rest ) { + bytes[fill] ^= (val & ((1 << len) - 1)) << off; + bsw->off = off + len; + return; + } + + bytes[fill++] ^= (val & ((1 << rest) - 1)) << off; + val >>= rest; + len -= rest; + } + + switch ( len >> 3 ) { + case 8: { + bytes[fill++] = ur_mask_8(val); + bytes[fill++] = ur_mask_8(val >> 8); + bytes[fill++] = ur_mask_8(val >> 16); + bytes[fill++] = ur_mask_8(val >> 24); + bytes[fill++] = ur_mask_8(val >> 32); + bytes[fill++] = ur_mask_8(val >> 40); + bytes[fill++] = ur_mask_8(val >> 48); + bytes[fill++] = ur_mask_8(val >> 56); + + // no offset is possible here + // + bsw->fill = fill; + bsw->off = 0; + return; + } + + case 7: { + bytes[fill++] = ur_mask_8(val); + bytes[fill++] = ur_mask_8(val >> 8); + bytes[fill++] = ur_mask_8(val >> 16); + bytes[fill++] = ur_mask_8(val >> 24); + bytes[fill++] = ur_mask_8(val >> 32); + bytes[fill++] = ur_mask_8(val >> 40); + bytes[fill++] = ur_mask_8(val >> 48); + val >>= 56; + } break; + + case 6: { + bytes[fill++] = ur_mask_8(val); + bytes[fill++] = ur_mask_8(val >> 8); + bytes[fill++] = ur_mask_8(val >> 16); + bytes[fill++] = ur_mask_8(val >> 24); + bytes[fill++] = ur_mask_8(val >> 32); + bytes[fill++] = ur_mask_8(val >> 40); + val >>= 48; + } break; + + case 5: { + bytes[fill++] = ur_mask_8(val); + bytes[fill++] = ur_mask_8(val >> 8); + bytes[fill++] = ur_mask_8(val >> 16); + bytes[fill++] = ur_mask_8(val >> 24); + bytes[fill++] = ur_mask_8(val >> 32); + val >>= 40; + } break; + + case 4: { + bytes[fill++] = ur_mask_8(val); + bytes[fill++] = ur_mask_8(val >> 8); + bytes[fill++] = ur_mask_8(val >> 16); + bytes[fill++] = ur_mask_8(val >> 24); + val >>= 32; + } break; + + case 3: { + bytes[fill++] = ur_mask_8(val); + bytes[fill++] = ur_mask_8(val >> 8); + bytes[fill++] = ur_mask_8(val >> 16); + val >>= 24; + } break; + + case 2: { + bytes[fill++] = ur_mask_8(val); + bytes[fill++] = ur_mask_8(val >> 8); + val >>= 16; + } break; + + case 1: { + bytes[fill++] = ur_mask_8(val); + val >>= 8; + } break; + } + + off = ur_mask_3(len); + + if ( off ) { + bytes[fill] = (uint8_t)(val & ((1 << off) - 1)); + } + + bsw->fill = fill; + bsw->off = off; +} + +void +ur_bsw64(ur_bsw_t *bsw, uint8_t len, uint64_t val) +{ + uint8_t bits = bsw->off + len; + + if ( bsw->fill + (bits >> 3) + !!ur_mask_3(bits) >= bsw->size ) { + ur_bsw_grow(bsw); + } + + _bsw64_unsafe(bsw, (len > 64) ? 64 : len, val); +} + +void +ur_bsw64_slow(ur_bsw_t *bsw, uint8_t len, uint64_t val) +{ + len = (len > 64) ? 64 : len; + + while ( len ) { + ur_bsw_bit(bsw, val & 0xff); + val >>= 1; + len--; + } +} + static inline void _bsw_bytes_unsafe(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) { @@ -1037,46 +1169,6 @@ ur_bsw_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) _bsw_bytes_unsafe(bsw, len, byt); } -static inline void -_bsw64_unsafe(ur_bsw_t *bsw, uint8_t len_bit, uint64_t val) -{ - // assumes little-endian - // - uint8_t *byt = (uint8_t*)&val; - uint8_t len_byt = len_bit >> 3; - uint8_t low = ur_mask_3(len_bit); - - if ( len_byt ) { - _bsw_bytes_unsafe(bsw, len_byt, byt); - } - - if ( low ) { - _bsw8_unsafe(bsw, low, byt[len_byt]); - } -} - -void -ur_bsw64(ur_bsw_t *bsw, uint8_t len, uint64_t val) -{ - uint8_t bits = bsw->off + len; - - if ( bsw->fill + (bits >> 3) + !!ur_mask_3(bits) >= bsw->size ) { - ur_bsw_grow(bsw); - } - - _bsw64_unsafe(bsw, (len > 64) ? 64 : len, val); -} - -void -ur_bsw64_slow(ur_bsw_t *bsw, uint8_t len, uint64_t val) -{ - while ( len ) { - ur_bsw_bit(bsw, val & 0xff); - val >>= 1; - len--; - } -} - static inline void _bsw_mat64_unsafe(ur_bsw_t *bsw, uint8_t len_len, uint8_t len, uint64_t val) { From 5b0c1320fbf850ca3d4f2750a3bf0584c6ca897d Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 17 Aug 2020 20:29:16 -0700 Subject: [PATCH 177/933] ur: refactors ur_bsw8 and ur_bsw_bytes internals --- pkg/urbit/ur/hashcons.c | 42 ++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 1893a6ee60..3786dde19c 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -943,24 +943,26 @@ _bsw8_unsafe(ur_bsw_t *bsw, uint8_t len, uint8_t byt) uint64_t fill = bsw->fill; uint8_t off = bsw->off; uint8_t rest = 8 - off; - uint8_t old = bsw->bytes[fill]; + uint8_t l, m; + // the least-significant bits of the input become the + // most-significant bits of a byte in the output stream + // if ( len < rest ) { - uint8_t left = (byt & ((1 << len) - 1)) << off; + l = byt & ((1 << len) - 1); - bsw->bytes[fill] = old ^ left; + bsw->bytes[fill] ^= l << off; bsw->off = off + len; } + // and vice-versa + // else { - uint8_t left, right; + l = byt & ((1 << rest) - 1); + m = byt >> rest; - left = (byt & ((1 << rest) - 1)) << off; - off = len - rest; - right = (byt >> rest) & ((1 << off) - 1); - - bsw->bytes[fill] = old ^ left; - fill++; - bsw->bytes[fill] = right; + bsw->bytes[fill++] ^= l << off; + off = len - rest; + bsw->bytes[fill] = m & ((1 << off) - 1); bsw->fill = fill; bsw->off = off; @@ -1131,20 +1133,22 @@ _bsw_bytes_unsafe(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) memcpy(bsw->bytes + fill, byt, len); fill += len; } + // the least-significant bits of the input become the + // most-significant bits of a byte in the output stream, and vice-versa + // else { uint8_t rest = 8 - off; - uint8_t left, right, old = bsw->bytes[fill]; - uint64_t i; + uint8_t mask = (1 << rest) - 1; + uint8_t l, m = bsw->bytes[fill]; + uint64_t i; for ( i = 0; i < len; i++ ) { - left = (byt[i] & ((1 << rest) - 1)) << off; - right = (byt[i] >> rest) & ((1 << off) - 1); - - bsw->bytes[fill++] = old ^ left; - old = right; + l = byt[i] & mask; + bsw->bytes[fill++] = m ^ (l << off); + m = byt[i] >> rest; } - bsw->bytes[fill] = old; + bsw->bytes[fill] = m; } bsw->fill = fill; From 572a0d2c91c30788c67071e56eb011e3374fff5f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 17 Aug 2020 20:35:22 -0700 Subject: [PATCH 178/933] ur: adds ur_bsw32() --- pkg/urbit/include/ur/hashcons.h | 5 ++ pkg/urbit/tests/ur_tests.c | 34 +++++++++++++ pkg/urbit/ur/hashcons.c | 90 +++++++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+) diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index 1f492168d2..9ca5e6479c 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -195,6 +195,11 @@ ur_bsw8(ur_bsw_t *bsw, uint8_t len, uint8_t byt); void ur_bsw8_slow(ur_bsw_t *bsw, uint8_t len, uint8_t byt); +void +ur_bsw32(ur_bsw_t *bsw, uint8_t len, uint32_t val); +void +ur_bsw32_slow(ur_bsw_t *bsw, uint8_t len, uint32_t val); + void ur_bsw64(ur_bsw_t *bsw, uint8_t len_bit, uint64_t val); void diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index c32f616d6f..c2182bfcb6 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -251,6 +251,39 @@ _test_bsw8(void) & _test_bsw8_loop("bsw bits alt 2", 0x55); } +static int +_test_bsw32_loop(const char* cap, uint32_t val) +{ + int ret = 1; + ur_bsw_t a = {0}; + ur_bsw_t b = {0}; + uint8_t i, j; + + for ( i = 0; i < 8; i++) { + for ( j = 0; j <= 32; j++ ) { + _bsw_init(&a, 1, 1); + _bsw_init(&b, 1, 1); + a.off = a.bits = b.off = b.bits = i; + + ur_bsw32_slow(&a, j, val); + ur_bsw32(&b, j, val); + + ret &= _bsw_cmp_check(cap, val, i, j, &a, &b); + } + } + + return ret; +} + +static int +_test_bsw32(void) +{ + return _test_bsw32_loop("bsw 32 ones", 0xffffffff) + & _test_bsw32_loop("bsw 32 zeros", 0x0) + & _test_bsw32_loop("bsw 32 alt 1", 0xaaaaaaaa) + & _test_bsw32_loop("bsw 32 alt 2", 0x55555555); +} + static int _test_bsw64_loop(const char* cap, uint64_t val) { @@ -331,6 +364,7 @@ _test_bsw(void) { return _test_bsw_bit() & _test_bsw8() + & _test_bsw32() & _test_bsw64() & _test_bsw_bytes(); } diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 3786dde19c..10681d14d0 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -991,6 +991,96 @@ ur_bsw8_slow(ur_bsw_t *bsw, uint8_t len, uint8_t byt) } } +static inline void +_bsw32_unsafe(ur_bsw_t *bsw, uint8_t len, uint32_t val) +{ + uint64_t fill = bsw->fill; + uint8_t off = bsw->off; + uint8_t *bytes = bsw->bytes; + + bsw->bits += len; + + if ( off ) { + uint8_t rest = 8 - off; + + if ( len < rest ) { + bytes[fill] ^= (val & ((1 << len) - 1)) << off; + bsw->off = off + len; + return; + } + + bytes[fill++] ^= (val & ((1 << rest) - 1)) << off; + val >>= rest; + len -= rest; + } + + switch ( len >> 3 ) { + case 4: { + bytes[fill++] = ur_mask_8(val); + bytes[fill++] = ur_mask_8(val >> 8); + bytes[fill++] = ur_mask_8(val >> 16); + bytes[fill++] = ur_mask_8(val >> 24); + + // no offset is possible here + // + bsw->fill = fill; + bsw->off = 0; + return; + } + + case 3: { + bytes[fill++] = ur_mask_8(val); + bytes[fill++] = ur_mask_8(val >> 8); + bytes[fill++] = ur_mask_8(val >> 16); + val >>= 24; + } break; + + case 2: { + bytes[fill++] = ur_mask_8(val); + bytes[fill++] = ur_mask_8(val >> 8); + val >>= 16; + } break; + + case 1: { + bytes[fill++] = ur_mask_8(val); + val >>= 8; + } break; + } + + off = ur_mask_3(len); + + if ( off ) { + bytes[fill] = (uint8_t)(val & ((1 << off) - 1)); + } + + bsw->fill = fill; + bsw->off = off; +} + +void +ur_bsw32(ur_bsw_t *bsw, uint8_t len, uint32_t val) +{ + uint8_t bits = bsw->off + len; + + if ( bsw->fill + (bits >> 3) + !!ur_mask_3(bits) >= bsw->size ) { + ur_bsw_grow(bsw); + } + + _bsw32_unsafe(bsw, (len > 32) ? 32 : len, val); +} + +void +ur_bsw32_slow(ur_bsw_t *bsw, uint8_t len, uint32_t val) +{ + len = (len > 32) ? 32 : len; + + while ( len ) { + ur_bsw_bit(bsw, val & 0xff); + val >>= 1; + len--; + } +} + static inline void _bsw64_unsafe(ur_bsw_t *bsw, uint8_t len, uint64_t val) { From 5662a085d5894683779b8b64ae040f98dbbe36a5 Mon Sep 17 00:00:00 2001 From: Jared Tobin Date: Tue, 18 Aug 2020 13:48:05 -0230 Subject: [PATCH 179/933] urbit-king: update urbit-hob to v0.3.3 v0.3.2 fixed an important bug that should be pulled in here. --- pkg/hs/stack.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/hs/stack.yaml b/pkg/hs/stack.yaml index 74bad3fe51..e1fbe99b4e 100644 --- a/pkg/hs/stack.yaml +++ b/pkg/hs/stack.yaml @@ -17,8 +17,8 @@ extra-deps: - flat-0.3.4@sha256:002a0e0ae656ea8cc02a772d0bcb6ea7dbd7f2e79070959cc748ad1e7138eb38 - base58-bytestring-0.1.0@sha256:a1da72ee89d5450bac1c792d9fcbe95ed7154ab7246f2172b57bd4fd9b5eab79 - lock-file-0.7.0.0@sha256:3ad84b5e454145e1d928063b56abb96db24a99a21b493989520e58fa0ab37b00 - - urbit-hob-0.3.1@sha256:afbdc7ad071eefc6ca85f5b598b6c62ed49079d15d1840dac27438a3b3150303 - para-1.1@sha256:a90eebb063ad70271e6e2a7f00a93e8e8f8b77273f100f39852fbf8301926f81 + - urbit-hob-0.3.3@sha256:ff8dae3844881cd979fee96bcb3ab3d5ea95f7c3ad2302dbc4b2dc417ff6595b # This allows building on NixOS. nix: From dca4344a45699321a01a7a6f8afda7e1851d49f7 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 18 Aug 2020 12:22:45 -0400 Subject: [PATCH 180/933] natpmp: By default, only try to talk to the router on private ips. Since startup hangs for seconds when you are not behind a router, but still attempt to ask one to open ports for you, by default, only try to contact the router if the local ip is 192.168.*.* or 10.*.*.*. Also make port forwarding force on/off. --- pkg/hs/urbit-king/lib/Urbit/King/CLI.hs | 19 +++++++++++++---- pkg/hs/urbit-king/lib/Urbit/King/Main.hs | 9 +++++--- pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs | 25 +++++++++++++++++++++-- 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs index d5fe8d34cd..e5b0d832ca 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs @@ -19,7 +19,7 @@ import System.Environment (getProgName) data Host = Host { hSharedHttpPort :: Maybe Word16 , hSharedHttpsPort :: Maybe Word16 - , hUseNatPmp :: Bool + , hUseNatPmp :: Maybe NatSetting } deriving (Show) @@ -71,6 +71,11 @@ data PillSource | PillSourceURL String deriving (Show) +data NatSetting + = NatSettingAlways + | NatSettingWhenPrivateNetwork + deriving (Show) + data New = New { nPillSource :: PillSource , nPierPath :: Maybe FilePath -- Derived from ship name if not specified. @@ -427,11 +432,17 @@ host = do <> hidden hUseNatPmp <- - fmap not - $ switch - $ long "no-port-forwarding" + ( flag' (Just NatSettingAlways) + $ long "port-forwarding" + <> help "Always try to search for a router to forward ames ports" + <> hidden + ) <|> + ( flag' Nothing + $ long "no-port-forwarding" <> help "Disable trying to ask the router to forward ames ports" <> hidden + ) <|> + (pure $ Just NatSettingWhenPrivateNetwork) pure (Host{..}) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs index af7e57d38e..39cf6db17c 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs @@ -590,12 +590,15 @@ runShip (CLI.Run pierPath) opts daemon = do mStart -buildPortHandler :: HasLogFunc e => Bool -> RIO e PortControlApi -buildPortHandler False = pure buildInactivePorts +buildPortHandler :: HasLogFunc e => Maybe CLI.NatSetting -> RIO e PortControlApi +buildPortHandler Nothing = pure buildInactivePorts -- TODO: Figure out what to do about logging here. The "port: " messages are -- the sort of thing that should be put on the muxed terminal log, but we don't -- have that at this layer. -buildPortHandler True = buildNatPorts (io . hPutStrLn stderr . unpack) +buildPortHandler (Just CLI.NatSettingAlways) = + buildNatPorts TryNatAlways (io . hPutStrLn stderr . unpack) +buildPortHandler (Just CLI.NatSettingWhenPrivateNetwork) = + buildNatPorts TryNatWhenPrivate (io . hPutStrLn stderr . unpack) startBrowser :: HasLogFunc e => FilePath -> RIO e () startBrowser pierPath = runRAcquire $ do diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs index adf3382e2e..7c31ddf680 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs @@ -1,5 +1,6 @@ module Urbit.Vere.Ports (HasPortControlApi(..), PortControlApi, + TryNat(..), buildInactivePorts, buildNatPorts, requestPortAccess) where @@ -30,12 +31,24 @@ buildInactivePorts = PortControlApi noop noop where noop x = pure () +data TryNat + = TryNatAlways + | TryNatWhenPrivate + -- | Builds a PortControlApi struct which tries to hole-punch by talking to the -- NAT gateway over NAT-PMP. buildNatPorts :: (HasLogFunc e) - => (Text -> RIO e ()) + => TryNat + -> (Text -> RIO e ()) -> RIO e PortControlApi -buildNatPorts stderr = do + +buildNatPorts TryNatWhenPrivate stderr = do + behind <- likelyBehindRouter + if behind + then buildNatPorts TryNatAlways stderr + else pure buildInactivePorts + +buildNatPorts TryNatAlways stderr = do q <- newTQueueIO async $ portThread q stderr @@ -222,6 +235,14 @@ likelyIPAddress = liftIO do SockAddrInet _ addr -> pure $ Just $ hostAddressToTuple addr _ -> pure $ Nothing +likelyBehindRouter :: MonadIO m => m Bool +likelyBehindRouter = do + likelyIPAddress >>= \case + Just ip@(192, 168, _, _) -> pure True + Just ip@(10, _, _, _) -> pure True + _ -> pure False + + -- Acquire a port for the duration of the RAcquire. requestPortAccess :: forall e. (HasPortControlApi e) => Word16 -> RAcquire e () requestPortAccess port = do From 60e2ae02a210490c1b4a54bb3d85ca3c5d46841b Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 18 Aug 2020 15:43:31 -0400 Subject: [PATCH 181/933] natpmp: cleanup by using a tristate --- pkg/hs/urbit-king/lib/Urbit/King/CLI.hs | 21 ++++++++++++------ pkg/hs/urbit-king/lib/Urbit/King/Main.hs | 11 +++++---- pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs | 27 +++++++++++------------ 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs index e5b0d832ca..4f91709a2f 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs @@ -19,7 +19,7 @@ import System.Environment (getProgName) data Host = Host { hSharedHttpPort :: Maybe Word16 , hSharedHttpsPort :: Maybe Word16 - , hUseNatPmp :: Maybe NatSetting + , hUseNatPmp :: Nat } deriving (Show) @@ -71,9 +71,10 @@ data PillSource | PillSourceURL String deriving (Show) -data NatSetting - = NatSettingAlways - | NatSettingWhenPrivateNetwork +data Nat + = NatAlways + | NatWhenPrivateNetwork + | NatNever deriving (Show) data New = New @@ -432,17 +433,23 @@ host = do <> hidden hUseNatPmp <- - ( flag' (Just NatSettingAlways) + ( flag' NatAlways $ long "port-forwarding" <> help "Always try to search for a router to forward ames ports" <> hidden ) <|> - ( flag' Nothing + ( flag' NatNever $ long "no-port-forwarding" <> help "Disable trying to ask the router to forward ames ports" <> hidden ) <|> - (pure $ Just NatSettingWhenPrivateNetwork) + ( flag' NatWhenPrivateNetwork + $ long "port-forwarding-when-internal" + <> help ("Try asking the router to forward when ip is 192.168.0.0/24 or" <> + "10.0.0.0/8 (default).") + <> hidden + ) <|> + (pure $ NatWhenPrivateNetwork) pure (Host{..}) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs index 39cf6db17c..7f8b9aaf3c 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs @@ -590,15 +590,14 @@ runShip (CLI.Run pierPath) opts daemon = do mStart -buildPortHandler :: HasLogFunc e => Maybe CLI.NatSetting -> RIO e PortControlApi -buildPortHandler Nothing = pure buildInactivePorts +buildPortHandler :: HasLogFunc e => CLI.Nat -> RIO e PortControlApi +buildPortHandler CLI.NatNever = pure buildInactivePorts -- TODO: Figure out what to do about logging here. The "port: " messages are -- the sort of thing that should be put on the muxed terminal log, but we don't -- have that at this layer. -buildPortHandler (Just CLI.NatSettingAlways) = - buildNatPorts TryNatAlways (io . hPutStrLn stderr . unpack) -buildPortHandler (Just CLI.NatSettingWhenPrivateNetwork) = - buildNatPorts TryNatWhenPrivate (io . hPutStrLn stderr . unpack) +buildPortHandler CLI.NatAlways = buildNatPorts (io . hPutStrLn stderr . unpack) +buildPortHandler CLI.NatWhenPrivateNetwork = + buildNatPortsWhenPrivate (io . hPutStrLn stderr . unpack) startBrowser :: HasLogFunc e => FilePath -> RIO e () startBrowser pierPath = runRAcquire $ do diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs index 7c31ddf680..78ec7c7788 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs @@ -1,7 +1,7 @@ module Urbit.Vere.Ports (HasPortControlApi(..), PortControlApi, - TryNat(..), buildInactivePorts, + buildNatPortsWhenPrivate, buildNatPorts, requestPortAccess) where @@ -31,24 +31,23 @@ buildInactivePorts = PortControlApi noop noop where noop x = pure () -data TryNat - = TryNatAlways - | TryNatWhenPrivate +-- | Builds a PortControlApi struct which tries to hole-punch by talking to the +-- NAT gateway over NAT-PMP iff we are on a private network ip. +buildNatPortsWhenPrivate :: (HasLogFunc e) + => (Text -> RIO e ()) + -> RIO e PortControlApi +buildNatPortsWhenPrivate stderr = do + behind <- likelyBehindRouter + if behind + then buildNatPorts stderr + else pure buildInactivePorts -- | Builds a PortControlApi struct which tries to hole-punch by talking to the -- NAT gateway over NAT-PMP. buildNatPorts :: (HasLogFunc e) - => TryNat - -> (Text -> RIO e ()) + => (Text -> RIO e ()) -> RIO e PortControlApi - -buildNatPorts TryNatWhenPrivate stderr = do - behind <- likelyBehindRouter - if behind - then buildNatPorts TryNatAlways stderr - else pure buildInactivePorts - -buildNatPorts TryNatAlways stderr = do +buildNatPorts stderr = do q <- newTQueueIO async $ portThread q stderr From 5c7f846d719dafb65ef3d72e0b33fe52681d1323 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 19 Aug 2020 12:05:13 -0400 Subject: [PATCH 182/933] natpmp: change the library's timeout system to not wait 4 minutes. --- pkg/hs/natpmp-static/cbits/natpmp.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/hs/natpmp-static/cbits/natpmp.c b/pkg/hs/natpmp-static/cbits/natpmp.c index 3a49812921..289c36445c 100644 --- a/pkg/hs/natpmp-static/cbits/natpmp.c +++ b/pkg/hs/natpmp-static/cbits/natpmp.c @@ -282,11 +282,19 @@ int readnatpmpresponseorretry(natpmp_t * p, natpmpresp_t * response) gettimeofday(&now, NULL); // check errors ! if(timercmp(&now, &p->retry_time, >=)) { int delay, r; - if(p->try_number >= 9) { + // NOTE: This used to be 9, and was changed for the haskell + // bindings to be 5. + if(p->try_number >= 5) { return NATPMP_ERR_NOGATEWAYSUPPORT; } /*printf("retry! %d\n", p->try_number);*/ - delay = 250 * (1<try_number); // ms + + // NOTE: Changed how delays are calculated. Waiting up to four + // minutes for a packet that might never get a response is not + // a good user experience. Instead, retry up to 2 seconds. + // + // delay = 250 * (1<try_number); // ms + delay = 250 * p->try_number; // ms /*for(i=0; itry_number; i++) delay += delay;*/ p->retry_time.tv_sec += (delay / 1000); From 1401d7bc5ce7550aac3f9a54d5a3e9bfb086d38a Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 19 Aug 2020 12:53:59 -0400 Subject: [PATCH 183/933] natpmp: fix error handling and don't die on errors in getpubliaddress This fixes a case where the natpmp async could pure () instead of recursing, which would lock ames. This also adds some more error handling on the haskell side of things and disables the raw fprintfs in the c bindings layer. --- pkg/hs/natpmp-static/cbits/binding.c | 20 ++++++++++---------- pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs | 9 ++++++++- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/pkg/hs/natpmp-static/cbits/binding.c b/pkg/hs/natpmp-static/cbits/binding.c index d15b57be47..50f3d4f097 100644 --- a/pkg/hs/natpmp-static/cbits/binding.c +++ b/pkg/hs/natpmp-static/cbits/binding.c @@ -55,22 +55,22 @@ int readNatResponseSynchronously(natpmp_t* natpmp, natpmpresp_t * response) r = select(FD_SETSIZE, &fds, NULL, NULL, &timeout); sav_errno = errno; if(r<0) { - fprintf(stderr, "select(): errno=%d '%s'\n", - sav_errno, strerror(sav_errno)); + /* fprintf(stderr, "select(): errno=%d '%s'\n", */ + /* sav_errno, strerror(sav_errno)); */ return 1; } r = readnatpmpresponseorretry(natpmp, response); sav_errno = errno; /* printf("readnatpmpresponseorretry returned %d (%s)\n", */ /* r, r==0?"OK":(r==NATPMP_TRYAGAIN?"TRY AGAIN":"FAILED")); */ - if(r<0 && r!=NATPMP_TRYAGAIN) { -#ifdef ENABLE_STRNATPMPERR - fprintf(stderr, "readnatpmpresponseorretry() failed : %s\n", - strnatpmperr(r)); -#endif - fprintf(stderr, " errno=%d '%s'\n", - sav_errno, strerror(sav_errno)); - } +/* if(r<0 && r!=NATPMP_TRYAGAIN) { */ +/* #ifdef ENABLE_STRNATPMPERR */ +/* fprintf(stderr, "readnatpmpresponseorretry() failed : %s\n", */ +/* strnatpmperr(r)); */ +/* #endif */ +/* fprintf(stderr, " errno=%d '%s'\n", */ +/* sav_errno, strerror(sav_errno)); */ +/* } */ } while(r==NATPMP_TRYAGAIN); return r; diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs index 78ec7c7788..bfb0ae61e9 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs @@ -99,6 +99,8 @@ portThread :: forall e. (HasLogFunc e) -> RIO e () portThread q stderr = do initNatPmp >>= \case + Left ErrCannotGetGateway -> do + assumeOnPublicInternet Left err -> do likelyIPAddress >>= \case Just ip@(192, 168, _, _) -> warnBehindRouterAndErr ip err @@ -123,7 +125,12 @@ portThread q stderr = do foundRouter :: NatPmpHandle -> RIO e () foundRouter pmp = do getPublicAddress pmp >>= \case - Left _ -> pure () + Left ErrCannotGetGateway -> assumeOnPublicInternet + Left ErrNoGatewaySupport -> assumeOnPublicInternet + Left err -> do + stderr $ "port: received error when asking router for public ip: " ++ + (tshow err) + loopErr q Right addr -> do let (a, b, c, d) = hostAddressToTuple addr stderr $ "port: router reports that our public IP is " ++ (tshow a) ++ From d4522adb0c33248b484933fe4aa6a1979583e601 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 19 Aug 2020 10:18:58 -0700 Subject: [PATCH 184/933] ur: moves slow8/32/64 write functions into tests --- pkg/urbit/include/ur/hashcons.h | 6 ----- pkg/urbit/tests/ur_tests.c | 44 ++++++++++++++++++++++++++++++--- pkg/urbit/ur/hashcons.c | 34 ------------------------- 3 files changed, 40 insertions(+), 44 deletions(-) diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index 9ca5e6479c..10c243e5ab 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -192,18 +192,12 @@ ur_bsw_bit(ur_bsw_t *bsw, uint8_t bit); void ur_bsw8(ur_bsw_t *bsw, uint8_t len, uint8_t byt); -void -ur_bsw8_slow(ur_bsw_t *bsw, uint8_t len, uint8_t byt); void ur_bsw32(ur_bsw_t *bsw, uint8_t len, uint32_t val); -void -ur_bsw32_slow(ur_bsw_t *bsw, uint8_t len, uint32_t val); void ur_bsw64(ur_bsw_t *bsw, uint8_t len_bit, uint64_t val); -void -ur_bsw64_slow(ur_bsw_t *bsw, uint8_t len, uint64_t val); void ur_bsw_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt); diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index c2182bfcb6..70e55af026 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -218,6 +218,18 @@ _bsw_cmp_check(const char* cap, uint8_t val, uint8_t off, uint8_t len, ur_bsw_t return ret; } +static void +_bsw8_slow(ur_bsw_t *bsw, uint8_t len, uint8_t byt) +{ + len = (len > 8) ? 8 : len; + + while ( len ) { + ur_bsw_bit(bsw, byt); + byt >>= 1; + len--; + } +} + static int _test_bsw8_loop(const char* cap, uint8_t val) { @@ -232,7 +244,7 @@ _test_bsw8_loop(const char* cap, uint8_t val) _bsw_init(&b, 1, 1); a.off = a.bits = b.off = b.bits = i; - ur_bsw8_slow(&a, j, val); + _bsw8_slow(&a, j, val); ur_bsw8(&b, j, val); ret &= _bsw_cmp_check(cap, val, i, j, &a, &b); @@ -251,6 +263,18 @@ _test_bsw8(void) & _test_bsw8_loop("bsw bits alt 2", 0x55); } +static void +_bsw32_slow(ur_bsw_t *bsw, uint8_t len, uint32_t val) +{ + len = (len > 32) ? 32 : len; + + while ( len ) { + ur_bsw_bit(bsw, val & 0xff); + val >>= 1; + len--; + } +} + static int _test_bsw32_loop(const char* cap, uint32_t val) { @@ -265,7 +289,7 @@ _test_bsw32_loop(const char* cap, uint32_t val) _bsw_init(&b, 1, 1); a.off = a.bits = b.off = b.bits = i; - ur_bsw32_slow(&a, j, val); + _bsw32_slow(&a, j, val); ur_bsw32(&b, j, val); ret &= _bsw_cmp_check(cap, val, i, j, &a, &b); @@ -284,6 +308,18 @@ _test_bsw32(void) & _test_bsw32_loop("bsw 32 alt 2", 0x55555555); } +static void +_bsw64_slow(ur_bsw_t *bsw, uint8_t len, uint64_t val) +{ + len = (len > 64) ? 64 : len; + + while ( len ) { + ur_bsw_bit(bsw, val & 0xff); + val >>= 1; + len--; + } +} + static int _test_bsw64_loop(const char* cap, uint64_t val) { @@ -298,7 +334,7 @@ _test_bsw64_loop(const char* cap, uint64_t val) _bsw_init(&b, 1, 1); a.off = a.bits = b.off = b.bits = i; - ur_bsw64_slow(&a, j, val); + _bsw64_slow(&a, j, val); ur_bsw64(&b, j, val); ret &= _bsw_cmp_check(cap, val, i, j, &a, &b); @@ -332,7 +368,7 @@ _test_bsw_bytes_loop(const char* cap, uint64_t len, uint8_t val) byt = malloc(len); for ( j = 0; j < len; j++ ) { - ur_bsw8_slow(&a, 8, val); + _bsw8_slow(&a, 8, val); byt[j] = val; } diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 10681d14d0..d9ff000f90 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -981,16 +981,6 @@ ur_bsw8(ur_bsw_t *bsw, uint8_t len, uint8_t byt) _bsw8_unsafe(bsw, (len > 8) ? 8 : len, byt); } -void -ur_bsw8_slow(ur_bsw_t *bsw, uint8_t len, uint8_t byt) -{ - while ( len ) { - ur_bsw_bit(bsw, byt); - byt >>= 1; - len--; - } -} - static inline void _bsw32_unsafe(ur_bsw_t *bsw, uint8_t len, uint32_t val) { @@ -1069,18 +1059,6 @@ ur_bsw32(ur_bsw_t *bsw, uint8_t len, uint32_t val) _bsw32_unsafe(bsw, (len > 32) ? 32 : len, val); } -void -ur_bsw32_slow(ur_bsw_t *bsw, uint8_t len, uint32_t val) -{ - len = (len > 32) ? 32 : len; - - while ( len ) { - ur_bsw_bit(bsw, val & 0xff); - val >>= 1; - len--; - } -} - static inline void _bsw64_unsafe(ur_bsw_t *bsw, uint8_t len, uint64_t val) { @@ -1201,18 +1179,6 @@ ur_bsw64(ur_bsw_t *bsw, uint8_t len, uint64_t val) _bsw64_unsafe(bsw, (len > 64) ? 64 : len, val); } -void -ur_bsw64_slow(ur_bsw_t *bsw, uint8_t len, uint64_t val) -{ - len = (len > 64) ? 64 : len; - - while ( len ) { - ur_bsw_bit(bsw, val & 0xff); - val >>= 1; - len--; - } -} - static inline void _bsw_bytes_unsafe(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) { From 0f3731a40c0b6b8aea32ad3e82fbc9a145eb9149 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 19 Aug 2020 00:44:21 -0700 Subject: [PATCH 185/933] ur: adds initial tests for bitstream-read functions (ur_bsr*) --- pkg/urbit/include/ur/hashcons.h | 30 +- pkg/urbit/tests/ur_tests.c | 684 ++++++++++++++++++++++++++++++++ pkg/urbit/ur/hashcons.c | 308 +++++++++++++- 3 files changed, 1010 insertions(+), 12 deletions(-) diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index 10c243e5ab..51bfab0759 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -202,14 +202,40 @@ ur_bsw64(ur_bsw_t *bsw, uint8_t len_bit, uint64_t val); void ur_bsw_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt); -uint64_t -ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt); + +typedef struct ur_bsr_s { + uint64_t left; + uint64_t bits; + uint8_t off; + const uint8_t *bytes; +} ur_bsr_t; typedef enum { ur_cue_good = 0, ur_cue_gone = 1 } ur_cue_res_e; +ur_bool_t +ur_bsr_sane(ur_bsr_t *bsr); + +ur_cue_res_e +ur_bsr_bit(ur_bsr_t *bsr, uint8_t *out); + +uint8_t +ur_bsr_bit_any(ur_bsr_t *bsr); + +uint8_t +ur_bsr8_any(ur_bsr_t *bsr, uint8_t len); + +uint32_t +ur_bsr32_any(ur_bsr_t *bsr, uint8_t len); + +uint64_t +ur_bsr64_any(ur_bsr_t *bsr, uint8_t len); + +uint64_t +ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt); + typedef enum { ur_jam_atom = 0, ur_jam_cell = 1, diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index 70e55af026..3c6fd6265f 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -405,6 +405,685 @@ _test_bsw(void) & _test_bsw_bytes(); } +static int +_bsr_bit_check(const char *cap, + ur_bsr_t *bsr, + uint8_t off, + uint64_t bits, + uint8_t exp, + uint8_t val, + ur_cue_res_e ser, + ur_cue_res_e res) +{ + int ret = 1; + + if ( !ur_bsr_sane(bsr) ) { + fprintf(stderr, "%s: insane off=%u left=%" PRIu64 " bits=%" PRIu64 "\r\n", + cap, bsr->off, bsr->left, bsr->bits); + ret = 0; + } + + if ( ser != res ) { + fprintf(stderr, "%s: val not equal (%s, %s) off=%u left=%" PRIu64 " byte=%02x bits=%" PRIu64 "\r\n", + cap, (ur_cue_good == ser) ? "good" : "gone", + (ur_cue_good == res) ? "good" : "gone", + bsr->off, bsr->left, bsr->left ? bsr->bytes[0] : 0, bsr->bits); + ret = 0; + } + + if ( (ur_cue_good == res) && (exp != val) ) { + fprintf(stderr, "%s: res not equal (%02x, %02x) off=%u left=%" PRIu64 " byte=%02x bits=%" PRIu64 "\r\n", + cap, exp, val, bsr->off, bsr->left, bsr->left ? bsr->bytes[0] : 0, bsr->bits); + ret = 0; + } + + if ( off != bsr->off ) { + fprintf(stderr, "%s: offset fail (%u, %u)\r\n", cap, off, bsr->off); + ret = 0; + } + + if ( bits != bsr->bits ) { + fprintf(stderr, "%s: bits fail (%" PRIu64 ", %" PRIu64 ")\r\n", cap, bits, bsr->bits); + ret = 0; + } + + return ret; +} + +static int +_test_bsr_bit_ones(void) +{ + int ret = 1; + uint8_t ones[1] = { 0xff }; + ur_bsr_t bsr = { .left = sizeof(ones), .bytes = ones }; + uint8_t out; + ur_cue_res_e res; + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 1", &bsr, 1, 1, ur_cue_good, res, 1, out); + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 2", &bsr, 2, 2, ur_cue_good, res, 1, out); + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 3", &bsr, 3, 3, ur_cue_good, res, 1, out); + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 4", &bsr, 4, 4, ur_cue_good, res, 1, out); + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 5", &bsr, 5, 5, ur_cue_good, res, 1, out); + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 6", &bsr, 6, 6, ur_cue_good, res, 1, out); + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 7", &bsr, 7, 7, ur_cue_good, res, 1, out); + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 8", &bsr, 0, 8, ur_cue_good, res, 1, out); + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 9", &bsr, 0, 8, ur_cue_gone, res, 0, 0); + + return ret; +} + +static int +_test_bsr_bit_zeros(void) +{ + int ret = 1; + uint8_t ones[1] = { 0x0 }; + ur_bsr_t bsr = { .left = sizeof(ones), .bytes = ones }; + uint8_t out; + ur_cue_res_e res; + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 1", &bsr, 1, 1, ur_cue_good, res, 0, out); + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 2", &bsr, 2, 2, ur_cue_good, res, 0, out); + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 3", &bsr, 3, 3, ur_cue_good, res, 0, out); + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 4", &bsr, 4, 4, ur_cue_good, res, 0, out); + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 5", &bsr, 5, 5, ur_cue_good, res, 0, out); + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 6", &bsr, 6, 6, ur_cue_good, res, 0, out); + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 7", &bsr, 7, 7, ur_cue_good, res, 0, out); + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 8", &bsr, 0, 8, ur_cue_good, res, 0, out); + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 9", &bsr, 0, 8, ur_cue_gone, res, 0, 0); + + return ret; +} + +static int +_test_bsr_bit_alt(void) +{ + int ret = 1; + uint8_t ones[1] = { 0xaa }; + ur_bsr_t bsr = { .left = sizeof(ones), .bytes = ones }; + uint8_t out; + ur_cue_res_e res; + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 1", &bsr, 1, 1, ur_cue_good, res, 0, out); + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 2", &bsr, 2, 2, ur_cue_good, res, 1, out); + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 3", &bsr, 3, 3, ur_cue_good, res, 0, out); + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 4", &bsr, 4, 4, ur_cue_good, res, 1, out); + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 5", &bsr, 5, 5, ur_cue_good, res, 0, out); + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 6", &bsr, 6, 6, ur_cue_good, res, 1, out); + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 7", &bsr, 7, 7, ur_cue_good, res, 0, out); + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 8", &bsr, 0, 8, ur_cue_good, res, 1, out); + + res = ur_bsr_bit(&bsr, &out); + ret &= _bsr_bit_check("bsr bit ones 9", &bsr, 0, 8, ur_cue_gone, res, 0, 0); + + return ret; +} + +static int +_test_bsr_bit(void) +{ + return _test_bsr_bit_ones() + & _test_bsr_bit_zeros() + & _test_bsr_bit_alt(); +} + +static int +_bsr_bit_any_check(const char* cap, ur_bsr_t *bsr, uint8_t off, uint64_t bits, uint8_t exp, uint8_t val) +{ + int ret = 1; + + if ( !ur_bsr_sane(bsr) ) { + fprintf(stderr, "%s: insane off=%u left=%" PRIu64 " bits=%" PRIu64 "\r\n", + cap, bsr->off, bsr->left, bsr->bits); + ret = 0; + } + + if ( exp != val ) { + fprintf(stderr, "%s: not equal (%02x, %02x) off=%u left=%" PRIu64 " byte=%02x bits=%" PRIu64 "\r\n", + cap, exp, val, bsr->off, bsr->left, bsr->left ? bsr->bytes[0] : 0, bsr->bits); + ret = 0; + } + + if ( off != bsr->off ) { + fprintf(stderr, "%s: offset fail (%u, %u)\r\n", cap, off, bsr->off); + ret = 0; + } + + if ( bits != bsr->bits ) { + fprintf(stderr, "%s: bits fail (%" PRIu64 ", %" PRIu64 ")\r\n", cap, bits, bsr->bits); + ret = 0; + } + + return ret; +} + +static int +_test_bsr_bit_any_ones(void) +{ + int ret = 1; + uint8_t ones[1] = { 0xff }; + ur_bsr_t bsr = { .left = sizeof(ones), .bytes = ones }; + uint8_t out; + + ret &= _bsr_bit_any_check("bsr bit-any ones init", &bsr, 0, 0, 0, 0); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any ones 1", &bsr, 1, 1, 1, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any ones 2", &bsr, 2, 2, 1, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any ones 3", &bsr, 3, 3, 1, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any ones 4", &bsr, 4, 4, 1, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any ones 5", &bsr, 5, 5, 1, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any ones 6", &bsr, 6, 6, 1, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any ones 7", &bsr, 7, 7, 1, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any ones 8", &bsr, 0, 8, 1, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any ones off 9", &bsr, 0, 9, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any ones off 10", &bsr, 0, 10, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any ones off 11", &bsr, 0, 11, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any ones off 12", &bsr, 0, 12, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any ones off 13", &bsr, 0, 13, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any ones off 14", &bsr, 0, 14, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any ones off 15", &bsr, 0, 15, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any ones off 16", &bsr, 0, 16, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any ones off 17", &bsr, 0, 17, 0, out); + + return ret; +} + +static int +_test_bsr_bit_any_zeros(void) +{ + int ret = 1; + uint8_t ones[1] = { 0x0 }; + ur_bsr_t bsr = { .left = sizeof(ones), .bytes = ones }; + uint8_t out; + + ret &= _bsr_bit_any_check("bsr bit-any zeros init", &bsr, 0, 0, 0, 0); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any zeros 1", &bsr, 1, 1, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any zeros 2", &bsr, 2, 2, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any zeros 3", &bsr, 3, 3, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any zeros 4", &bsr, 4, 4, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any zeros 5", &bsr, 5, 5, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any zeros 6", &bsr, 6, 6, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any zeros 7", &bsr, 7, 7, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any zeros 8", &bsr, 0, 8, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any zeros off 9", &bsr, 0, 9, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any zeros off 10", &bsr, 0, 10, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any zeros off 11", &bsr, 0, 11, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any zeros off 12", &bsr, 0, 12, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any zeros off 13", &bsr, 0, 13, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any zeros off 14", &bsr, 0, 14, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any zeros off 15", &bsr, 0, 15, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any zeros off 16", &bsr, 0, 16, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any zeros off 17", &bsr, 0, 17, 0, out); + + return ret; +} + +static int +_test_bsr_bit_any_alt(void) +{ + int ret = 1; + uint8_t ones[1] = { 0xaa }; + ur_bsr_t bsr = { .left = sizeof(ones), .bytes = ones }; + uint8_t out; + + ret &= _bsr_bit_any_check("bsr bit-any alt init", &bsr, 0, 0, 0, 0); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any alt 1", &bsr, 1, 1, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any alt 2", &bsr, 2, 2, 1, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any alt 3", &bsr, 3, 3, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any alt 4", &bsr, 4, 4, 1, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any alt 5", &bsr, 5, 5, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any alt 6", &bsr, 6, 6, 1, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any alt 7", &bsr, 7, 7, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any alt 8", &bsr, 0, 8, 1, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any alt off 9", &bsr, 0, 9, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any alt off 10", &bsr, 0, 10, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any alt off 11", &bsr, 0, 11, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any alt off 12", &bsr, 0, 12, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any alt off 13", &bsr, 0, 13, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any alt off 14", &bsr, 0, 14, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any alt off 15", &bsr, 0, 15, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any alt off 16", &bsr, 0, 16, 0, out); + + out = ur_bsr_bit_any(&bsr); + ret &= _bsr_bit_any_check("bsr bit-any alt off 17", &bsr, 0, 17, 0, out); + + return ret; +} + +static int +_test_bsr_bit_any(void) +{ + return _test_bsr_bit_any_ones() + & _test_bsr_bit_any_zeros() + & _test_bsr_bit_any_alt(); +} + +static int +_bsr_cmp_any_check(const char* cap, uint8_t off, uint8_t len, ur_bsr_t *a, ur_bsr_t *b) +{ + int ret = 1; + + if ( !ur_bsr_sane(a) ) { + fprintf(stderr, "%s: off %u, len %u a insane off=%u left=%" PRIu64 " bits=%" PRIu64 "\r\n", + cap, off, len, a->off, a->left, a->bits); + ret = 0; + } + + if ( !ur_bsr_sane(b) ) { + fprintf(stderr, "%s: off %u, len %u a insane off=%u left=%" PRIu64 " bits=%" PRIu64 "\r\n", + cap, off, len, b->off, b->left, b->bits); + ret = 0; + } + + if ( a->off != b->off ) { + fprintf(stderr, "%s: off %u len %u: offset fail (%u, %u)\r\n", + cap, off, len, a->off, b->off); + ret = 0; + } + + if ( a->left != b->left ) { + fprintf(stderr, "%s: off %u len %u: left fail (%" PRIu64 ", %" PRIu64 ")\r\n", + cap, off, len, a->left, b->left); + ret = 0; + } + + if ( a->bits != b->bits ) { + fprintf(stderr, "%s: off %u len %u: bits fail (%" PRIu64 ", %" PRIu64 ")\r\n", + cap, off, len, a->bits, b->bits); + ret = 0; + } + + return ret; +} + +static uint8_t +_bsr8_any_slow(ur_bsr_t *bsr, uint8_t len) +{ + uint8_t i, out = 0; + + len = (len > 8) ? 8 : len; + + for ( i = 0; i < len; i++ ) { + out ^= ur_bsr_bit_any(bsr) << i; + } + + return out; +} + +static int +_test_bsr8_loop(const char *cap, uint8_t len, uint8_t val) +{ + int ret = 1; + uint8_t *bytes; + ur_bsr_t a, b; + uint8_t c, d, i, j, k; + + for ( i = 0; i < 8; i++) { + for ( j = 0; j <= 8; j++ ) { + bytes = malloc(len); + + for ( k = 0; k < len; k++ ) { + bytes[k] = val; + } + + a.left = b.left = len; + a.bytes = b.bytes = bytes; + a.off = a.bits = b.off = b.bits = i; + + c = _bsr8_any_slow(&a, j); + d = ur_bsr8_any(&b, j); + + ret &= _bsr_cmp_any_check(cap, i, j, &a, &b); + + if ( c != d ) { + fprintf(stderr, "%s: off %u, len %u not equal (%02x, %02x) off=%u left=%" PRIu64 " byte=%02x bits=%" PRIu64 "\r\n", + cap, i, j, c, d, b.off, b.left, b.left ? b.bytes[0] : 0, b.bits); + ret = 0; + } + + free(bytes); + } + } + + return ret; +} + +static int +_test_bsr8(void) +{ + return _test_bsr8_loop("bsr8 ones 1", 1, 0xff) + & _test_bsr8_loop("bsr8 ones 2", 2, 0xff) + & _test_bsr8_loop("bsr8 zeros 1", 1, 0x0) + & _test_bsr8_loop("bsr8 zeros 2", 2, 0x0) + & _test_bsr8_loop("bsr8 alt-1 1", 1, 0xaa) + & _test_bsr8_loop("bsr8 alt-1 2", 2, 0xaa) + & _test_bsr8_loop("bsr8 alt-2 1", 1, 0x55) + & _test_bsr8_loop("bsr8 alt-2 2", 2, 0x55); +} + +static uint32_t +_bsr32_any_slow(ur_bsr_t *bsr, uint8_t len) +{ + uint32_t out = 0; + uint8_t i; + + len = (len > 32) ? 32 : len; + + for ( i = 0; i < len; i++ ) { + out ^= (uint32_t)ur_bsr_bit_any(bsr) << i; + } + + return out; +} + +static int +_test_bsr32_loop(const char *cap, uint8_t len, uint8_t val) +{ + int ret = 1; + uint8_t *bytes; + ur_bsr_t a, b; + uint32_t c, d; + uint8_t i, j, k; + + for ( i = 0; i < 8; i++) { + for ( j = 0; j <= 32; j++ ) { + bytes = malloc(len); + + for ( k = 0; k < len; k++ ) { + bytes[k] = val; + } + + a.left = b.left = len; + a.bytes = b.bytes = bytes; + a.off = a.bits = b.off = b.bits = i; + + c = _bsr32_any_slow(&a, j); + d = ur_bsr32_any(&b, j); + + ret &= _bsr_cmp_any_check(cap, i, j, &a, &b); + + if ( c != d ) { + fprintf(stderr, "%s: off %u, len %u not equal (%08x, %08x) off=%u left=%" PRIu64 " byte=%02x bits=%" PRIu64 "\r\n", + cap, i, j, c, d, b.off, b.left, b.left ? b.bytes[0] : 0, b.bits); + ret = 0; + } + + free(bytes); + } + } + + return ret; +} + +static int +_test_bsr32(void) +{ + return _test_bsr32_loop("bsr32 ones 1", 1, 0xff) + & _test_bsr32_loop("bsr32 ones 2", 2, 0xff) + & _test_bsr32_loop("bsr32 ones 3", 3, 0xff) + & _test_bsr32_loop("bsr32 ones 4", 4, 0xff) + & _test_bsr32_loop("bsr32 zeros 1", 1, 0x0) + & _test_bsr32_loop("bsr32 zeros 2", 2, 0x0) + & _test_bsr32_loop("bsr32 zeros 3", 3, 0x0) + & _test_bsr32_loop("bsr32 zeros 4", 4, 0x0) + & _test_bsr32_loop("bsr32 alt-1 1", 1, 0xaa) + & _test_bsr32_loop("bsr32 alt-1 2", 2, 0xaa) + & _test_bsr32_loop("bsr32 alt-1 3", 3, 0xaa) + & _test_bsr32_loop("bsr32 alt-1 4", 4, 0xaa) + & _test_bsr32_loop("bsr32 alt-2 1", 1, 0x55) + & _test_bsr32_loop("bsr32 alt-2 2", 2, 0x55) + & _test_bsr32_loop("bsr32 alt-2 3", 3, 0x55) + & _test_bsr32_loop("bsr32 alt-2 4", 4, 0x55); +} + +static uint64_t +_bsr64_any_slow(ur_bsr_t *bsr, uint8_t len) +{ + uint64_t out = 0; + uint8_t i; + + len = (len > 64) ? 64 : len; + + for ( i = 0; i < len; i++ ) { + out ^= (uint64_t)ur_bsr_bit_any(bsr) << i; + } + + return out; +} + +static int +_test_bsr64_loop(const char *cap, uint8_t len, uint8_t val) +{ + int ret = 1; + uint8_t *bytes; + ur_bsr_t a, b; + uint64_t c, d; + uint8_t i, j, k; + + for ( i = 0; i < 8; i++) { + for ( j = 0; j <= 64; j++ ) { + bytes = malloc(len); + + for ( k = 0; k < len; k++ ) { + bytes[k] = val; + } + + a.left = b.left = len; + a.bytes = b.bytes = bytes; + a.off = a.bits = b.off = b.bits = i; + + c = _bsr64_any_slow(&a, j); + d = ur_bsr64_any(&b, j); + + ret &= _bsr_cmp_any_check(cap, i, j, &a, &b); + + if ( c != d ) { + fprintf(stderr, "%s: off %u, len %u not equal (%016" PRIx64", %016" PRIx64") off=%u left=%" PRIu64 " byte=%02x bits=%" PRIu64 "\r\n", + cap, i, j, c, d, b.off, b.left, b.left ? b.bytes[0] : 0, b.bits); + ret = 0; + } + + free(bytes); + } + } + + return ret; +} + +static int +_test_bsr64(void) +{ + return _test_bsr64_loop("bsr64 ones 1", 1, 0xff) + & _test_bsr64_loop("bsr64 ones 2", 2, 0xff) + & _test_bsr64_loop("bsr64 ones 3", 3, 0xff) + & _test_bsr64_loop("bsr64 ones 4", 4, 0xff) + & _test_bsr64_loop("bsr64 ones 5", 5, 0xff) + & _test_bsr64_loop("bsr64 ones 6", 6, 0xff) + & _test_bsr64_loop("bsr64 ones 7", 7, 0xff) + & _test_bsr64_loop("bsr64 ones 8", 8, 0xff) + & _test_bsr64_loop("bsr64 zeros 1", 1, 0x0) + & _test_bsr64_loop("bsr64 zeros 2", 2, 0x0) + & _test_bsr64_loop("bsr64 zeros 3", 3, 0x0) + & _test_bsr64_loop("bsr64 zeros 4", 4, 0x0) + & _test_bsr64_loop("bsr64 zeros 5", 5, 0x0) + & _test_bsr64_loop("bsr64 zeros 6", 6, 0x0) + & _test_bsr64_loop("bsr64 zeros 7", 7, 0x0) + & _test_bsr64_loop("bsr64 zeros 8", 8, 0x0) + & _test_bsr64_loop("bsr64 alt-1 1", 1, 0xaa) + & _test_bsr64_loop("bsr64 alt-1 2", 2, 0xaa) + & _test_bsr64_loop("bsr64 alt-1 3", 3, 0xaa) + & _test_bsr64_loop("bsr64 alt-1 4", 4, 0xaa) + & _test_bsr64_loop("bsr64 alt-1 5", 5, 0xaa) + & _test_bsr64_loop("bsr64 alt-1 6", 6, 0xaa) + & _test_bsr64_loop("bsr64 alt-1 7", 7, 0xaa) + & _test_bsr64_loop("bsr64 alt-1 8", 8, 0xaa) + & _test_bsr64_loop("bsr64 alt-2 1", 1, 0x55) + & _test_bsr64_loop("bsr64 alt-2 2", 2, 0x55) + & _test_bsr64_loop("bsr64 alt-2 3", 3, 0x55) + & _test_bsr64_loop("bsr64 alt-2 4", 4, 0x55) + & _test_bsr64_loop("bsr64 alt-2 5", 5, 0x55) + & _test_bsr64_loop("bsr64 alt-2 6", 6, 0x55) + & _test_bsr64_loop("bsr64 alt-2 7", 7, 0x55) + & _test_bsr64_loop("bsr64 alt-2 8", 8, 0x55); +} + +static int +_test_bsr(void) +{ + return _test_bsr_bit() + & _test_bsr_bit_any() + & _test_bsr8() + & _test_bsr32() + & _test_bsr64(); +} + static int _test_jam_spec(const char *cap, ur_root_t *r, @@ -566,6 +1245,11 @@ _test_ur(void) ret = 0; } + if ( !_test_bsr() ) { + fprintf(stderr, "ur test bsr failed\r\n"); + ret = 0; + } + if ( !_test_jam_cue() ) { fprintf(stderr, "ur test jam/cue failed\r\n"); ret = 0; diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index d9ff000f90..f618dd4e95 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -1312,17 +1312,20 @@ ur_bsw_mat_bytes(ur_bsw_t *bsw, uint64_t len_bit, uint64_t len, uint8_t *byt) } } -typedef struct ur_bsr_s { - uint64_t left; - uint64_t bits; - uint8_t off; - const uint8_t *bytes; -} ur_bsr_t; +ur_bool_t +ur_bsr_sane(ur_bsr_t *bsr) +{ + if ( !bsr->left ) { + return !bsr->off && !bsr->bytes; + } -static inline ur_cue_res_e + return 1; +} + +ur_cue_res_e ur_bsr_bit(ur_bsr_t *bsr, uint8_t *out) { - uint8_t left = bsr->left; + uint64_t left = bsr->left; if ( !left ) { return ur_cue_gone; @@ -1358,6 +1361,292 @@ ur_bsr_bit(ur_bsr_t *bsr, uint8_t *out) } } +uint8_t +ur_bsr_bit_any(ur_bsr_t *bsr) +{ + uint64_t left = bsr->left; + + bsr->bits++; + + if ( !left ) { + return 0; + } + else { + uint8_t byt = bsr->bytes[0]; + uint8_t off = bsr->off; + uint8_t bit = (byt >> off) & 1; + + if ( 7 == off ) { + left--; + + if ( left ) { + bsr->bytes++; + bsr->left = left; + } + else { + bsr->bytes = 0; + bsr->left = 0; + } + + bsr->off = 0; + } + else { + bsr->off = 1 + off; + } + + return bit; + } +} + +uint8_t +ur_bsr8_any(ur_bsr_t *bsr, uint8_t len) +{ + uint64_t left = bsr->left; + + len = ( len > 8 ) ? 8 : len; + + bsr->bits += len; + + if ( !left ) { + return 0; + } + else { + uint8_t off = bsr->off; + uint8_t rest = 8 - off; + const uint8_t *bytes = bsr->bytes; + uint8_t m = bytes[0] >> off; + + if ( len < rest ) { + bsr->off = off + len; + return m & ((1 << len) - 1); + } + else if ( 1 == left ) { + bsr->off = 0; + bsr->left = 0; + bsr->bytes = 0; + return m; + } + else { + off = len - rest; + + bsr->off = off; + bsr->left--; + bsr->bytes++; + + { + uint8_t l = bytes[1] & ((1 << off) - 1); + return m ^ (l << rest); + } + } + } +} + +uint32_t +ur_bsr32_any(ur_bsr_t *bsr, uint8_t len) +{ + uint64_t left = bsr->left; + + len = ( len > 32 ) ? 32 : len; + + bsr->bits += len; + + if ( !left ) { + return 0; + } + else { + uint8_t off = bsr->off; + uint8_t rest = 8 - off; + const uint8_t *b = bsr->bytes; + uint32_t m = b[0] >> off; + + if ( len < rest ) { + bsr->off = off + len; + return m & ((1 << len) - 1); + } + else { + uint8_t mask, len_byt; + uint32_t l; + + len -= rest; + left--; + bsr->bytes++; + + len_byt = len >> 3; + + if ( len_byt >= left ) { + len_byt = left; + bsr->off = off = 0; + bsr->left = 0; + bsr->bytes = 0; + } + else { + bsr->off = off = ur_mask_3(len); + bsr->left = left - len_byt; + bsr->bytes += len_byt; + } + + mask = (1 << off) - 1; + + switch ( len_byt ) { + case 4: { + l = (uint32_t)b[1] + ^ (uint32_t)b[2] << 8 + ^ (uint32_t)b[3] << 16 + ^ (uint32_t)b[4] << 24; + } break; + + case 3: { + l = (uint32_t)b[1] + ^ (uint32_t)b[2] << 8 + ^ (uint32_t)b[3] << 16 + ^ (uint32_t)(b[4] & mask) << 24; + } break; + + case 2: { + l = (uint32_t)b[1] + ^ (uint32_t)b[2] << 8 + ^ (uint32_t)(b[3] & mask) << 16; + } break; + + case 1: { + l = (uint32_t)b[1] + ^ (uint32_t)(b[2] & mask) << 8; + } break; + + case 0: { + l = (uint32_t)(b[1] & mask); + } break; + } + + return m ^ (l << rest); + } + } +} + +uint64_t +ur_bsr64_any(ur_bsr_t *bsr, uint8_t len) +{ + uint64_t left = bsr->left; + + len = ( len > 64 ) ? 64 : len; + + bsr->bits += len; + + if ( !left ) { + return 0; + } + else { + uint8_t off = bsr->off; + uint8_t rest = 8 - off; + const uint8_t *b = bsr->bytes; + uint64_t m = b[0] >> off; + + if ( len < rest ) { + bsr->off = off + len; + return m & ((1 << len) - 1); + } + else { + uint8_t mask, len_byt; + uint64_t l; + + len -= rest; + left--; + bsr->bytes++; + + len_byt = len >> 3; + + if ( len_byt >= left ) { + len_byt = left; + bsr->off = off = 0; + bsr->left = 0; + bsr->bytes = 0; + } + else { + bsr->off = off = ur_mask_3(len); + bsr->left = left - len_byt; + bsr->bytes += len_byt; + } + + mask = (1 << off) - 1; + + switch ( len_byt ) { + case 8: { + l = (uint64_t)b[1] + ^ (uint64_t)b[2] << 8 + ^ (uint64_t)b[3] << 16 + ^ (uint64_t)b[4] << 24 + ^ (uint64_t)b[5] << 32 + ^ (uint64_t)b[6] << 40 + ^ (uint64_t)b[7] << 48 + ^ (uint64_t)b[8] << 56; + } break; + + case 7: { + l = (uint64_t)b[1] + ^ (uint64_t)b[2] << 8 + ^ (uint64_t)b[3] << 16 + ^ (uint64_t)b[4] << 24 + ^ (uint64_t)b[5] << 32 + ^ (uint64_t)b[6] << 40 + ^ (uint64_t)b[7] << 48 + ^ (uint64_t)(b[8] & mask) << 56; + } break; + + case 6: { + l = (uint64_t)b[1] + ^ (uint64_t)b[2] << 8 + ^ (uint64_t)b[3] << 16 + ^ (uint64_t)b[4] << 24 + ^ (uint64_t)b[5] << 32 + ^ (uint64_t)b[6] << 40 + ^ (uint64_t)(b[7] & mask) << 48; + } break; + + case 5: { + l = (uint64_t)b[1] + ^ (uint64_t)b[2] << 8 + ^ (uint64_t)b[3] << 16 + ^ (uint64_t)b[4] << 24 + ^ (uint64_t)b[5] << 32 + ^ (uint64_t)(b[6] & mask) << 40; + } break; + + case 4: { + l = (uint64_t)b[1] + ^ (uint64_t)b[2] << 8 + ^ (uint64_t)b[3] << 16 + ^ (uint64_t)b[4] << 24 + ^ (uint64_t)(b[5] & mask) << 32; + } break; + + case 3: { + l = (uint64_t)b[1] + ^ (uint64_t)b[2] << 8 + ^ (uint64_t)b[3] << 16 + ^ (uint64_t)(b[4] & mask) << 24; + } break; + + case 2: { + l = (uint64_t)b[1] + ^ (uint64_t)b[2] << 8 + ^ (uint64_t)(b[3] & mask) << 16; + } break; + + case 1: { + l = (uint64_t)b[1] + ^ (uint64_t)(b[2] & mask) << 8; + } break; + + case 0: { + l = (uint64_t)(b[1] & mask); + } break; + } + + return m ^ (l << rest); + } + } +} + static inline ur_cue_res_e ur_bsr_tag(ur_bsr_t *bsr, ur_cue_tag_e *out) { @@ -1408,7 +1697,6 @@ ur_bsr64(ur_bsr_t *bsr, uint8_t len) for ( i = 0; i < len; i++ ) { if ( ur_cue_good != ur_bsr_bit(bsr, &bit) ) { bsr->bits += len - i; - bsr->bytes = 0; return acc; } @@ -1421,7 +1709,7 @@ ur_bsr64(ur_bsr_t *bsr, uint8_t len) static inline void ur_bsr_bytes(ur_bsr_t *bsr, uint64_t len, uint8_t *out) { - uint8_t left = bsr->left; + uint64_t left = bsr->left; uint8_t off = bsr->off; ur_bool_t end = len >= left; From 88428961dd061b1d1ff444ade4f4bda554289af5 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 19 Aug 2020 14:02:03 -0400 Subject: [PATCH 186/933] natpmp: also detect 172.16.0/0/12 ips as private. --- pkg/hs/urbit-king/lib/Urbit/King/CLI.hs | 4 ++-- pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs index 4f91709a2f..5657ce8c8c 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs @@ -445,8 +445,8 @@ host = do ) <|> ( flag' NatWhenPrivateNetwork $ long "port-forwarding-when-internal" - <> help ("Try asking the router to forward when ip is 192.168.0.0/24 or" <> - "10.0.0.0/8 (default).") + <> help ("Try asking the router to forward when ip is 192.168.0.0/16, " <> + "172.16.0.0/12 or 10.0.0.0/8 (default).") <> hidden ) <|> (pure $ NatWhenPrivateNetwork) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs index bfb0ae61e9..18493b342b 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs @@ -104,6 +104,8 @@ portThread q stderr = do Left err -> do likelyIPAddress >>= \case Just ip@(192, 168, _, _) -> warnBehindRouterAndErr ip err + Just ip@(172, x, _, _) + | (x >= 16 && x <= 31) -> warnBehindRouterAndErr ip err Just ip@(10, _, _, _) -> warnBehindRouterAndErr ip err _ -> assumeOnPublicInternet Right pmp -> foundRouter pmp @@ -245,6 +247,8 @@ likelyBehindRouter :: MonadIO m => m Bool likelyBehindRouter = do likelyIPAddress >>= \case Just ip@(192, 168, _, _) -> pure True + Just ip@(172, x, _, _) + | (x >= 16 && x <= 31) -> pure True Just ip@(10, _, _, _) -> pure True _ -> pure False From 4aa1dbe4a2cecedac699253b00b2142dd1fa1832 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 19 Aug 2020 11:51:47 -0700 Subject: [PATCH 187/933] ur: adds ur_bsw_bex() and tests --- pkg/urbit/include/ur/hashcons.h | 3 ++ pkg/urbit/tests/ur_tests.c | 39 +++++++++++++++++++- pkg/urbit/ur/hashcons.c | 63 +++++++++++++++++++++++++++------ 3 files changed, 94 insertions(+), 11 deletions(-) diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index 51bfab0759..b8127314c7 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -202,6 +202,9 @@ ur_bsw64(ur_bsw_t *bsw, uint8_t len_bit, uint64_t val); void ur_bsw_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt); +void +ur_bsw_bex(ur_bsw_t *bsw, uint8_t n); + typedef struct ur_bsr_s { uint64_t left; diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index 3c6fd6265f..0526633fb4 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -395,6 +395,42 @@ _test_bsw_bytes(void) & _test_bsw_bytes_loop("bsw bytes alt 2 odd", 10, 0x55); } +static void +_bsw_bex_slow(ur_bsw_t *bsw, uint8_t n) +{ + while ( n >= 64 ) { + _bsw64_slow(bsw, 64, 0); + n -= 64; + } + + _bsw64_slow(bsw, n + 1, 1ULL << n); +} + +static int +_test_bsw_bex() +{ + int ret = 1; + ur_bsw_t a = {0}; + ur_bsw_t b = {0}; + uint8_t i, l; + uint32_t j, k; + + for ( i = 0; i < 8; i++) { + for ( j = 0; j < 256; j++ ) { + _bsw_init(&a, 1, 1); + _bsw_init(&b, 1, 1); + a.off = a.bits = b.off = b.bits = i; + + _bsw_bex_slow(&a, j); + ur_bsw_bex(&b, j); + + ret &= _bsw_cmp_check("bsw bex", j, i, j + 1, &a, &b); + } + } + + return ret; +} + static int _test_bsw(void) { @@ -402,7 +438,8 @@ _test_bsw(void) & _test_bsw8() & _test_bsw32() & _test_bsw64() - & _test_bsw_bytes(); + & _test_bsw_bytes() + & _test_bsw_bex(); } static int diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index f618dd4e95..321b02190e 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -1230,14 +1230,58 @@ ur_bsw_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) } static inline void -_bsw_mat64_unsafe(ur_bsw_t *bsw, uint8_t len_len, uint8_t len, uint64_t val) +_bsw_bex_unsafe(ur_bsw_t *bsw, uint8_t n) { - if ( 0 == val ) { + uint64_t fill = bsw->fill; + uint8_t off = bsw->off; + uint32_t bits = n + off; + + fill += bits >> 3; + off = ur_mask_3(bits); + + bsw->bytes[fill] ^= 1 << off; + + if ( 7 == off ) { + bsw->off = 0; + bsw->fill = 1 + fill; + } + else { + bsw->off = 1 + off; + bsw->fill = fill; + } + + bsw->bits += 1 + n; +} + +void +ur_bsw_bex(ur_bsw_t *bsw, uint8_t n) +{ + uint32_t bits = 1 + n + bsw->off; + uint8_t need = (bits >> 3) + !!ur_mask_3(bits); + + if ( bsw->fill + need >= bsw->size ) { + if ( need > bsw->prev ) { + bsw->prev = need; + } + ur_bsw_grow(bsw); + } + + _bsw_bex_unsafe(bsw, n); +} + +static inline void +_bsw_mat64_unsafe(ur_bsw_t *bsw, uint8_t len, uint64_t val) +{ + if ( 0 == len ) { _bsw_bit_unsafe(bsw, 1); } else { - _bsw64_unsafe(bsw, len_len + 1, 1ULL << len_len); - _bsw64_unsafe(bsw, len_len - 1, len); + { + uint8_t nel = ur_met0_64(len); + _bsw_bex_unsafe(bsw, nel); + _bsw64_unsafe(bsw, nel - 1, len); + } + _bsw64_unsafe(bsw, len, val); } } @@ -1248,16 +1292,15 @@ ur_bsw_mat64(ur_bsw_t *bsw, uint8_t len, uint64_t val) len = ( len > 64 ) ? 64 : len; { - uint8_t len_len = ur_met0_64(len); - uint8_t next = ( 0 == val ) ? 1 : len + (2 * len_len); - uint8_t bits = bsw->off + next; + uint8_t next = ( 0 == val ) ? 1 : len + (2 * ur_met0_64(len)); + uint8_t bits = bsw->off + next; if ( bsw->fill + (bits >> 3) + !!ur_mask_3(bits) >= bsw->size ) { ur_bsw_grow(bsw); } - - _bsw_mat64_unsafe(bsw, len_len, len, val); } + + _bsw_mat64_unsafe(bsw, len, val); } static inline void @@ -1265,7 +1308,7 @@ _bsw_mat_bytes_unsafe(ur_bsw_t *bsw, uint8_t len_len, uint64_t len_bit, uint64_t { // write run-length // - _bsw64_unsafe(bsw, len_len + 1, 1ULL << len_len); + _bsw_bex_unsafe(bsw, len_len); _bsw64_unsafe(bsw, len_len - 1, len_bit); // write bytes From 79363d66a8a994680a2bbb1dc0968f4dc2648e5c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 19 Aug 2020 12:04:12 -0700 Subject: [PATCH 188/933] ur: refactors bit-stream bounds-enforcement and growth --- pkg/urbit/include/ur/hashcons.h | 5 +- pkg/urbit/tests/ur_tests.c | 12 ++--- pkg/urbit/ur/hashcons.c | 88 +++++++++++++++------------------ 3 files changed, 50 insertions(+), 55 deletions(-) diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index b8127314c7..e5f578cca3 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -4,6 +4,9 @@ typedef uint8_t ur_bool_t; +#define ur_min(a, b) ( ((a) < (b)) ? (a) : (b) ) +#define ur_max(a, b) ( ((a) > (b)) ? (a) : (b) ) + #if (32 == (CHAR_BIT * __SIZEOF_INT__)) # define ur_lz32 __builtin_clz #elif (32 == (CHAR_BIT * __SIZEOF_LONG__)) @@ -182,7 +185,7 @@ typedef struct ur_bsw_s { } ur_bsw_t; void -ur_bsw_grow(ur_bsw_t *bsw); +ur_bsw_grow(ur_bsw_t *bsw, uint64_t need); ur_bool_t ur_bsw_sane(ur_bsw_t *bsw); diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index 0526633fb4..02ade55f72 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -221,7 +221,7 @@ _bsw_cmp_check(const char* cap, uint8_t val, uint8_t off, uint8_t len, ur_bsw_t static void _bsw8_slow(ur_bsw_t *bsw, uint8_t len, uint8_t byt) { - len = (len > 8) ? 8 : len; + len = ur_min(8, len); while ( len ) { ur_bsw_bit(bsw, byt); @@ -266,7 +266,7 @@ _test_bsw8(void) static void _bsw32_slow(ur_bsw_t *bsw, uint8_t len, uint32_t val) { - len = (len > 32) ? 32 : len; + len = ur_min(32, len); while ( len ) { ur_bsw_bit(bsw, val & 0xff); @@ -311,7 +311,7 @@ _test_bsw32(void) static void _bsw64_slow(ur_bsw_t *bsw, uint8_t len, uint64_t val) { - len = (len > 64) ? 64 : len; + len = ur_min(64, len); while ( len ) { ur_bsw_bit(bsw, val & 0xff); @@ -885,7 +885,7 @@ _bsr8_any_slow(ur_bsr_t *bsr, uint8_t len) { uint8_t i, out = 0; - len = (len > 8) ? 8 : len; + len = ur_min(8, len); for ( i = 0; i < len; i++ ) { out ^= ur_bsr_bit_any(bsr) << i; @@ -951,7 +951,7 @@ _bsr32_any_slow(ur_bsr_t *bsr, uint8_t len) uint32_t out = 0; uint8_t i; - len = (len > 32) ? 32 : len; + len = ur_min(32, len); for ( i = 0; i < len; i++ ) { out ^= (uint32_t)ur_bsr_bit_any(bsr) << i; @@ -1026,7 +1026,7 @@ _bsr64_any_slow(ur_bsr_t *bsr, uint8_t len) uint64_t out = 0; uint8_t i; - len = (len > 64) ? 64 : len; + len = ur_min(64, len); for ( i = 0; i < len; i++ ) { out ^= (uint64_t)ur_bsr_bit_any(bsr) << i; diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 321b02190e..3d55ea1b75 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -885,15 +885,14 @@ ur_walk_fore(ur_root_t *r, } void -ur_bsw_grow(ur_bsw_t *bsw) +ur_bsw_grow(ur_bsw_t *bsw, uint64_t step) { - uint64_t prev = bsw->prev; uint64_t size = bsw->size; - uint64_t next = prev + size; + uint64_t next = size + step; bsw->bytes = realloc(bsw->bytes, next); assert(bsw->bytes); - memset(bsw->bytes + size, 0, prev); + memset(bsw->bytes + size, 0, step); bsw->prev = size; bsw->size = next; @@ -931,7 +930,7 @@ ur_bsw_bit(ur_bsw_t *bsw, uint8_t bit) if ( (7 == bsw->off) && ((1 + bsw->fill) == bsw->size) ) { - ur_bsw_grow(bsw); + ur_bsw_grow(bsw, bsw->prev); } _bsw_bit_unsafe(bsw, bit); @@ -974,11 +973,13 @@ _bsw8_unsafe(ur_bsw_t *bsw, uint8_t len, uint8_t byt) void ur_bsw8(ur_bsw_t *bsw, uint8_t len, uint8_t byt) { + len = ur_min(8, len); + if ( bsw->fill + !!((bsw->off + len) >> 3) >= bsw->size ) { - ur_bsw_grow(bsw); + ur_bsw_grow(bsw, bsw->prev); } - _bsw8_unsafe(bsw, (len > 8) ? 8 : len, byt); + _bsw8_unsafe(bsw, len, byt); } static inline void @@ -1050,13 +1051,17 @@ _bsw32_unsafe(ur_bsw_t *bsw, uint8_t len, uint32_t val) void ur_bsw32(ur_bsw_t *bsw, uint8_t len, uint32_t val) { - uint8_t bits = bsw->off + len; + uint8_t bits, need; - if ( bsw->fill + (bits >> 3) + !!ur_mask_3(bits) >= bsw->size ) { - ur_bsw_grow(bsw); + len = ur_min(32, len); + bits = bsw->off + len; + need = (bits >> 3) + !!ur_mask_3(bits); + + if ( bsw->fill + need >= bsw->size ) { + ur_bsw_grow(bsw, ur_max(need, bsw->prev)); } - _bsw32_unsafe(bsw, (len > 32) ? 32 : len, val); + _bsw32_unsafe(bsw, len, val); } static inline void @@ -1170,13 +1175,17 @@ _bsw64_unsafe(ur_bsw_t *bsw, uint8_t len, uint64_t val) void ur_bsw64(ur_bsw_t *bsw, uint8_t len, uint64_t val) { - uint8_t bits = bsw->off + len; + uint8_t bits, need; - if ( bsw->fill + (bits >> 3) + !!ur_mask_3(bits) >= bsw->size ) { - ur_bsw_grow(bsw); + len = ur_min(64, len); + bits = bsw->off + len; + need = (bits >> 3) + !!ur_mask_3(bits); + + if ( bsw->fill + need >= bsw->size ) { + ur_bsw_grow(bsw, ur_max(need, bsw->prev)); } - _bsw64_unsafe(bsw, (len > 64) ? 64 : len, val); + _bsw64_unsafe(bsw, len, val); } static inline void @@ -1214,16 +1223,10 @@ _bsw_bytes_unsafe(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) void ur_bsw_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) { - if ( (bsw->fill + len + !!bsw->off) >= bsw->size ) { - uint64_t prev = bsw->prev; + uint64_t need = len + !!bsw->off; - // be sure to grow sufficiently - // - if ( len > prev ) { - bsw->prev = len; - } - - ur_bsw_grow(bsw); + if ( bsw->fill + need >= bsw->size ) { + ur_bsw_grow(bsw, ur_max(need, bsw->prev)); } _bsw_bytes_unsafe(bsw, len, byt); @@ -1260,10 +1263,7 @@ ur_bsw_bex(ur_bsw_t *bsw, uint8_t n) uint8_t need = (bits >> 3) + !!ur_mask_3(bits); if ( bsw->fill + need >= bsw->size ) { - if ( need > bsw->prev ) { - bsw->prev = need; - } - ur_bsw_grow(bsw); + ur_bsw_grow(bsw, ur_max(need, bsw->prev)); } _bsw_bex_unsafe(bsw, n); @@ -1289,15 +1289,15 @@ _bsw_mat64_unsafe(ur_bsw_t *bsw, uint8_t len, uint64_t val) void ur_bsw_mat64(ur_bsw_t *bsw, uint8_t len, uint64_t val) { - len = ( len > 64 ) ? 64 : len; + uint8_t next, bits, need; - { - uint8_t next = ( 0 == val ) ? 1 : len + (2 * ur_met0_64(len)); - uint8_t bits = bsw->off + next; + len = ur_min(64, len); + next = ( 0 == len ) ? 1 : len + (2 * ur_met0_64(len)); + bits = bsw->off + next; + need = (bits >> 3) + !!ur_mask_3(bits); - if ( bsw->fill + (bits >> 3) + !!ur_mask_3(bits) >= bsw->size ) { - ur_bsw_grow(bsw); - } + if ( bsw->fill + need >= bsw->size ) { + ur_bsw_grow(bsw, ur_max(need, bsw->prev)); } _bsw_mat64_unsafe(bsw, len, val); @@ -1339,16 +1339,8 @@ ur_bsw_mat_bytes(ur_bsw_t *bsw, uint64_t len_bit, uint64_t len, uint8_t *byt) uint8_t bits = bsw->off + (2 * len_len); uint64_t need = len + (bits >> 3) + !!ur_mask_3(bits); - if ( (bsw->fill + need) >= bsw->size ) { - uint64_t prev = bsw->prev; - - // be sure to grow sufficiently - // - if ( need > prev ) { - bsw->prev = need; - } - - ur_bsw_grow(bsw); + if ( bsw->fill + need >= bsw->size ) { + ur_bsw_grow(bsw, ur_max(need, bsw->prev)); } _bsw_mat_bytes_unsafe(bsw, len_len, len_bit, len, byt); @@ -1446,7 +1438,7 @@ ur_bsr8_any(ur_bsr_t *bsr, uint8_t len) { uint64_t left = bsr->left; - len = ( len > 8 ) ? 8 : len; + len = ur_min(8, len); bsr->bits += len; @@ -1489,7 +1481,7 @@ ur_bsr32_any(ur_bsr_t *bsr, uint8_t len) { uint64_t left = bsr->left; - len = ( len > 32 ) ? 32 : len; + len = ur_min(32, len); bsr->bits += len; @@ -1571,7 +1563,7 @@ ur_bsr64_any(ur_bsr_t *bsr, uint8_t len) { uint64_t left = bsr->left; - len = ( len > 64 ) ? 64 : len; + len = ur_min(64, len); bsr->bits += len; From c5bbe9e441ca1360e87c0a8ed54b479fdc342d50 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 19 Aug 2020 17:17:15 -0700 Subject: [PATCH 189/933] ur: rewrites ur_bsw_bytes to be bit-indexed --- pkg/urbit/tests/ur_tests.c | 39 +++++++++----- pkg/urbit/ur/hashcons.c | 103 ++++++++++++++++++++----------------- 2 files changed, 84 insertions(+), 58 deletions(-) diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index 02ade55f72..8856d45bed 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -353,6 +353,19 @@ _test_bsw64(void) & _test_bsw64_loop("bsw 64 alt 2", 0x5555555555555555ULL); } +static void +_bsw_bytes_slow(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) +{ + uint64_t i, len_byt = len >> 3; + + for ( i = 0; i < len_byt; i++ ) { + _bsw8_slow(bsw, 8, byt[i]); + len -= 8; + } + + _bsw8_slow(bsw, len, byt[len_byt]); +} + static int _test_bsw_bytes_loop(const char* cap, uint64_t len, uint8_t val) { @@ -360,24 +373,26 @@ _test_bsw_bytes_loop(const char* cap, uint64_t len, uint8_t val) ur_bsw_t a = {0}; ur_bsw_t b = {0}; uint8_t i, j, *byt; + uint64_t len_bit = len << 3; + + byt = malloc(len); + memset(byt, val, len); for ( i = 0; i < 8; i++) { - _bsw_init(&a, 1, 1); - _bsw_init(&b, 1, 1); - a.off = a.bits = b.off = b.bits = i; - byt = malloc(len); + for ( j = 0; j < len_bit; j++ ) { + _bsw_init(&a, 1, 1); + _bsw_init(&b, 1, 1); + a.off = a.bits = b.off = b.bits = i; - for ( j = 0; j < len; j++ ) { - _bsw8_slow(&a, 8, val); - byt[j] = val; + _bsw_bytes_slow(&a, j, byt); + ur_bsw_bytes(&b, j, byt); + + ret &= _bsw_cmp_check(cap, val, i, j, &a, &b); } - - ur_bsw_bytes(&b, len, byt); - free(byt); - - ret &= _bsw_cmp_check(cap, val, 8, i, &a, &b); } + free(byt); + return ret; } diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 3d55ea1b75..b514fb173d 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -1191,12 +1191,19 @@ ur_bsw64(ur_bsw_t *bsw, uint8_t len, uint64_t val) static inline void _bsw_bytes_unsafe(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) { - uint64_t fill = bsw->fill; - uint8_t off = bsw->off; + uint64_t len_byt = len >> 3; + uint8_t len_bit = ur_mask_3(len); + uint64_t fill = bsw->fill; + uint8_t off = bsw->off; if ( !off ) { - memcpy(bsw->bytes + fill, byt, len); - fill += len; + memcpy(bsw->bytes + fill, byt, len_byt); + fill += len_byt; + off = len_bit; + + if ( off ) { + bsw->bytes[fill] = byt[len_byt] & ((1 << off) - 1); + } } // the least-significant bits of the input become the // most-significant bits of a byte in the output stream, and vice-versa @@ -1207,23 +1214,38 @@ _bsw_bytes_unsafe(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) uint8_t l, m = bsw->bytes[fill]; uint64_t i; - for ( i = 0; i < len; i++ ) { + for ( i = 0; i < len_byt; i++ ) { l = byt[i] & mask; bsw->bytes[fill++] = m ^ (l << off); m = byt[i] >> rest; } - bsw->bytes[fill] = m; + if ( len_bit < rest ) { + l = byt[len_byt] & ((1 << len_bit) - 1); + bsw->bytes[fill] = m ^ (l << off); + off += len_bit; + } + else { + l = byt[len_byt] & mask; + bsw->bytes[fill++] = m ^ (l << off); + + m = byt[len_byt] >> rest; + + off = len_bit - rest; + bsw->bytes[fill] = m & ((1 << off) - 1); + } } + bsw->off = off; bsw->fill = fill; - bsw->bits += len << 3; + bsw->bits += len; } void ur_bsw_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) { - uint64_t need = len + !!bsw->off; + uint8_t bits = len + bsw->off; + uint64_t need = (bits >> 3) + !!ur_mask_3(bits); if ( bsw->fill + need >= bsw->size ) { ur_bsw_grow(bsw, ur_max(need, bsw->prev)); @@ -1304,47 +1326,36 @@ ur_bsw_mat64(ur_bsw_t *bsw, uint8_t len, uint64_t val) } static inline void -_bsw_mat_bytes_unsafe(ur_bsw_t *bsw, uint8_t len_len, uint64_t len_bit, uint64_t len, uint8_t *byt) +_bsw_mat_bytes_unsafe(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) { - // write run-length - // - _bsw_bex_unsafe(bsw, len_len); - _bsw64_unsafe(bsw, len_len - 1, len_bit); - - // write bytes - // - { - uint8_t low = ur_mask_3(len_bit); - - if ( !low ) { - _bsw_bytes_unsafe(bsw, len, byt); - } - else { - len--; - _bsw_bytes_unsafe(bsw, len, byt); - _bsw8_unsafe(bsw, low, byt[len]); + if ( 0 == len ) { + _bsw_bit_unsafe(bsw, 1); + } + else { + // write run-length + // + { + uint8_t nel = ur_met0_64(len); + _bsw_bex_unsafe(bsw, nel); + _bsw64_unsafe(bsw, nel - 1, len); } + + _bsw_bytes_unsafe(bsw, len, byt); } } void -ur_bsw_mat_bytes(ur_bsw_t *bsw, uint64_t len_bit, uint64_t len, uint8_t *byt) +ur_bsw_mat_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) { - uint8_t len_len = ur_met0_64(len_bit); + uint64_t next = ( 0 == len ) ? 1 : len + (2 * ur_met0_64(len)); + uint64_t bits = bsw->off + next; + uint64_t need = (bits >> 3) + !!ur_mask_3(bits); - // XX - assert( 64 > len_len ); - - { - uint8_t bits = bsw->off + (2 * len_len); - uint64_t need = len + (bits >> 3) + !!ur_mask_3(bits); - - if ( bsw->fill + need >= bsw->size ) { - ur_bsw_grow(bsw, ur_max(need, bsw->prev)); - } - - _bsw_mat_bytes_unsafe(bsw, len_len, len_bit, len, byt); + if ( bsw->fill + need >= bsw->size ) { + ur_bsw_grow(bsw, ur_max(need, bsw->prev)); } + + _bsw_mat_bytes_unsafe(bsw, len, byt); } ur_bool_t @@ -1822,20 +1833,20 @@ ur_bsr_mat(ur_bsr_t *bsr, uint64_t *out) } static inline void -_jam_mat(ur_root_t *r, ur_nref ref, ur_bsw_t *bsw, uint64_t len_bit) +_jam_mat(ur_root_t *r, ur_nref ref, ur_bsw_t *bsw, uint64_t len) { switch ( ur_nref_tag(ref) ) { default: assert(0); case ur_direct: { - ur_bsw_mat64(bsw, len_bit, ref); + ur_bsw_mat64(bsw, len, ref); } break; case ur_iatom: { - uint64_t len; - uint8_t *byt; - ur_bytes(r, ref, &byt, &len); - ur_bsw_mat_bytes(bsw, len_bit, len, byt); + uint64_t len_byt; + uint8_t *byt; + ur_bytes(r, ref, &byt, &len_byt); + ur_bsw_mat_bytes(bsw, len, byt); } break; } } From b117ca25a6f1f9a17d916320090a815bc845006b Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 19 Aug 2020 18:35:10 -0700 Subject: [PATCH 190/933] ur: fills out bistream-write (ur_bsw*) interface --- pkg/urbit/include/ur/hashcons.h | 22 +++++- pkg/urbit/ur/hashcons.c | 121 ++++++++++++++++++++++++-------- 2 files changed, 111 insertions(+), 32 deletions(-) diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index e5f578cca3..42c3b078ff 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -185,7 +185,7 @@ typedef struct ur_bsw_s { } ur_bsw_t; void -ur_bsw_grow(ur_bsw_t *bsw, uint64_t need); +ur_bsw_grow(ur_bsw_t *bsw, uint64_t step); ur_bool_t ur_bsw_sane(ur_bsw_t *bsw); @@ -200,7 +200,7 @@ void ur_bsw32(ur_bsw_t *bsw, uint8_t len, uint32_t val); void -ur_bsw64(ur_bsw_t *bsw, uint8_t len_bit, uint64_t val); +ur_bsw64(ur_bsw_t *bsw, uint8_t len, uint64_t val); void ur_bsw_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt); @@ -208,6 +208,24 @@ ur_bsw_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt); void ur_bsw_bex(ur_bsw_t *bsw, uint8_t n); +void +ur_bsw_mat64(ur_bsw_t *bsw, uint8_t len, uint64_t val); + +void +ur_bsw_mat_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt); + +void +ur_bsw_back64(ur_bsw_t *bsw, uint8_t len, uint64_t val); + +void +ur_bsw_atom64(ur_bsw_t *bsw, uint8_t len, uint64_t val); + +void +ur_bsw_atom_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt); + +void +ur_bsw_cell(ur_bsw_t *bsw); + typedef struct ur_bsr_s { uint64_t left; diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index b514fb173d..182f7a16cb 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -1358,6 +1358,82 @@ ur_bsw_mat_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) _bsw_mat_bytes_unsafe(bsw, len, byt); } +static inline void +_bsw_back64(ur_bsw_t *bsw, uint8_t len, uint64_t val) +{ + _bsw8_unsafe(bsw, 2, 3); + _bsw_mat64_unsafe(bsw, len, val); +} + +void +ur_bsw_back64(ur_bsw_t *bsw, uint8_t len, uint64_t val) +{ + uint64_t next = ( 0 == len ) ? 1 : len + (2 * ur_met0_64(len)); + uint64_t bits = 2 + bsw->off + next; + uint64_t need = (bits >> 3) + !!ur_mask_3(bits); + + if ( bsw->fill + need >= bsw->size ) { + ur_bsw_grow(bsw, ur_max(need, bsw->prev)); + } + + _bsw_back64(bsw, len, val); +} + +static inline void +_bsw_atom64(ur_bsw_t *bsw, uint8_t len, uint64_t val) +{ + _bsw_bit_unsafe(bsw, 0); + _bsw_mat64_unsafe(bsw, len, val); +} + +void +ur_bsw_atom64(ur_bsw_t *bsw, uint8_t len, uint64_t val) +{ + uint64_t next = ( 0 == len ) ? 1 : len + (2 * ur_met0_64(len)); + uint64_t bits = 1 + bsw->off + next; + uint64_t need = (bits >> 3) + !!ur_mask_3(bits); + + if ( bsw->fill + need >= bsw->size ) { + ur_bsw_grow(bsw, ur_max(need, bsw->prev)); + } + + _bsw_atom64(bsw, len, val); +} + +static inline void +_bsw_atom_bytes_unsafe(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) +{ + _bsw_bit_unsafe(bsw, 0); + _bsw_mat_bytes_unsafe(bsw, len, byt); +} + +void +ur_bsw_atom_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) +{ + uint64_t next = ( 0 == len ) ? 1 : len + (2 * ur_met0_64(len)); + uint64_t bits = 1 + bsw->off + next; + uint64_t need = (bits >> 3) + !!ur_mask_3(bits); + + if ( bsw->fill + need >= bsw->size ) { + ur_bsw_grow(bsw, ur_max(need, bsw->prev)); + } + + _bsw_atom_bytes_unsafe(bsw, len, byt); +} + +void +ur_bsw_cell(ur_bsw_t *bsw) +{ + uint8_t bits = 2 + bsw->off; + uint8_t need = (bits >> 3) + !!ur_mask_3(bits); + + if ( bsw->fill + need >= bsw->size ) { + ur_bsw_grow(bsw, ur_max(need, bsw->prev)); + } + + _bsw8_unsafe(bsw, 2, 1); +} + ur_bool_t ur_bsr_sane(ur_bsr_t *bsr) { @@ -1833,21 +1909,17 @@ ur_bsr_mat(ur_bsr_t *bsr, uint64_t *out) } static inline void -_jam_mat(ur_root_t *r, ur_nref ref, ur_bsw_t *bsw, uint64_t len) +_bsw_atom(ur_root_t *r, ur_nref ref, ur_bsw_t *bsw, uint64_t len) { switch ( ur_nref_tag(ref) ) { default: assert(0); - case ur_direct: { - ur_bsw_mat64(bsw, len, ref); - } break; + case ur_direct: return ur_bsw_atom64(bsw, len, ref); case ur_iatom: { - uint64_t len_byt; - uint8_t *byt; - ur_bytes(r, ref, &byt, &len_byt); - ur_bsw_mat_bytes(bsw, len, byt); - } break; + uint8_t *byt = r->atoms.bytes[ur_nref_idx(ref)]; + return ur_bsw_atom_bytes(bsw, len, byt); + } } } @@ -1862,27 +1934,21 @@ _jam_atom(ur_root_t *r, ur_nref ref, void *ptr) _jam_t *j = ptr; ur_dict64_t *dict = &(j->dict); ur_bsw_t *bsw = &j->bsw; - uint64_t bak, len_bit; - - len_bit = ur_met(r, 0, ref); + uint64_t bak, len = ur_met(r, 0, ref); if ( !ur_dict64_get(r, dict, ref, &bak) ) { ur_dict64_put(r, dict, ref, bsw->bits); - ur_bsw_bit(bsw, 0); - _jam_mat(r, ref, bsw, len_bit); + _bsw_atom(r, ref, bsw, len); } else { - uint64_t bak_bit = ur_met0_64(bak); + uint64_t len_bak = ur_met0_64(bak); - if ( len_bit <= bak_bit ) { - ur_bsw_bit(bsw, 0); - _jam_mat(r, ref, bsw, len_bit); + if ( len <= len_bak ) { + _bsw_atom(r, ref, bsw, len); } else { - ur_bsw_bit(bsw, 1); - ur_bsw_bit(bsw, 1); - ur_bsw_mat64(bsw, bak_bit, bak); + ur_bsw_back64(bsw, len_bak, bak); } } } @@ -1898,17 +1964,12 @@ _jam_cell(ur_root_t *r, ur_nref ref, void *ptr) if ( !ur_dict64_get(r, dict, ref, &bak) ) { ur_dict64_put(r, dict, ref, bsw->bits); - ur_bsw_bit(bsw, 1); - ur_bsw_bit(bsw, 0); - - return 1; // true + ur_bsw_cell(bsw); + return 1; } else { - ur_bsw_bit(bsw, 1); - ur_bsw_bit(bsw, 1); - ur_bsw_mat64(bsw, ur_met0_64(bak), bak); - - return 0; // false + ur_bsw_back64(bsw, ur_met0_64(bak), bak); + return 0; } } From e3cafdd464c3e254bc0c3ae5b3ce7d7ebae97fa9 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 20 Aug 2020 11:58:08 -0700 Subject: [PATCH 191/933] roll/reel with while loops --- pkg/urbit/jets/b/reel.c | 59 +++++++++++++++++++++++++---------------- pkg/urbit/jets/b/roll.c | 33 +++++++++-------------- 2 files changed, 49 insertions(+), 43 deletions(-) diff --git a/pkg/urbit/jets/b/reel.c b/pkg/urbit/jets/b/reel.c index 5cdd9c918e..186cd47ce4 100644 --- a/pkg/urbit/jets/b/reel.c +++ b/pkg/urbit/jets/b/reel.c @@ -3,35 +3,48 @@ */ #include "all.h" - static u3_noun - _reel_in(u3j_site* sit_u, u3_noun a, u3_noun b) - { - if ( 0 == a ) { - return b; - } - else if ( c3n == u3du(a) ) { - return u3m_bail(c3__exit); - } - else { - u3_noun gim = u3k(u3h(a)); - u3_noun hur = _reel_in(sit_u, u3t(a), b); - - return u3j_gate_slam(sit_u, u3nc(gim, hur)); - } - } - /* functions */ u3_noun u3qb_reel(u3_noun a, u3_noun b) { - u3_noun pro; - u3j_site sit_u; - u3j_gate_prep(&sit_u, u3k(b)); - pro = _reel_in(&sit_u, a, u3k(u3x_at(u3x_sam_3, b))); - u3j_gate_lose(&sit_u); - return pro; + u3_noun pro = u3k(u3x_at(u3x_sam_3, b)); + if ( u3_nul == a ) { + return pro; + } + else { + u3j_site sit_u; + u3_noun i, t = a; + c3_w j_w, len_w = 0, all_w = 89, pre_w = 55; + u3_noun* vec = u3a_malloc(all_w); + + // stuff list into an array + do { + if ( c3n == u3r_cell(t, &i, &t) ) { + u3a_free(vec); + return u3m_bail(c3__exit); + } + else { + if ( len_w == all_w ) { + // grow vec fib-wise + all_w += pre_w; + pre_w = len_w; + vec = u3a_realloc(vec, all_w); + } + vec[len_w++] = i; + } + } while ( u3_nul != t ); + + // now we can iterate backwards + u3j_gate_prep(&sit_u, u3k(b)); + for ( j_w = len_w; j_w > 0; ) { + pro = u3j_gate_slam(&sit_u, u3nc(u3k(vec[--j_w]), pro)); + } + u3j_gate_lose(&sit_u); + u3a_free(vec); + return pro; + } } u3_noun u3wb_reel(u3_noun cor) diff --git a/pkg/urbit/jets/b/roll.c b/pkg/urbit/jets/b/roll.c index a88d4fc1d2..72f334f55b 100644 --- a/pkg/urbit/jets/b/roll.c +++ b/pkg/urbit/jets/b/roll.c @@ -3,32 +3,25 @@ */ #include "all.h" - static u3_noun - _roll_in(u3j_site* sit_u, u3_noun a, u3_noun b) - { - if ( 0 == a ) { - return b; - } - else if ( c3n == u3du(a) ) { - return u3m_bail(c3__exit); - } - else { - b = u3j_gate_slam(sit_u, u3nc(u3k(u3h(a)), b)); - return _roll_in(sit_u, u3t(a), b); - } - } - /* functions */ u3_noun u3qb_roll(u3_noun a, u3_noun b) { - u3_noun pro; - u3j_site sit_u; - u3j_gate_prep(&sit_u, u3k(b)); - pro = _roll_in(&sit_u, a, u3k(u3x_at(u3x_sam_3, b))); - u3j_gate_lose(&sit_u); + u3_noun pro = u3k(u3x_at(u3x_sam_3, b)); + + if ( u3_nul != a ) { + u3j_site sit_u; + u3_noun i, t = a; + u3j_gate_prep(&sit_u, u3k(b)); + do { + u3x_cell(t, &i, &t); + pro = u3j_gate_slam(&sit_u, u3nc(u3k(i), pro)); + } while ( u3_nul != t ); + u3j_gate_lose(&sit_u); + } + return pro; } u3_noun From 15f0df81f1e614d16f9fa14d66215df9e67de6c4 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 18 Aug 2020 11:22:28 -0400 Subject: [PATCH 192/933] natpmp: when reopening laptop, reestablish a connection to the router. --- pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs | 44 ++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs index 18493b342b..6d6c8b7a69 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs @@ -69,6 +69,14 @@ portLeaseLifetime = 15 * 60 portRenewalTime :: Word32 portRenewalTime = portLeaseLifetime - 60 +-- Number of retries before we give up on performing nat operations. +maxRetries :: Int +maxRetries = 3 + +-- How long to wait between retries. +networkRetryDelay :: Int +networkRetryDelay = 5 * 1000000 + -- Messages sent from the main thread to the port mapping communication thread. data PortThreadMsg = PTMOpen Word16 (STM ()) @@ -163,6 +171,8 @@ portThread q stderr = do logInfo $ displayShow ("port: sending initial request to NAT-PMP for port ", p) setPortMapping pmp PTUdp p p portLeaseLifetime >>= \case + Left err | isResetAndRetry err -> do + attemptReestablishNatPmpThen (\pmp -> handlePTM pmp msg nextRenew) Left err -> do logError $ displayShow ("port: failed to request NAT-PMP for port ", p, @@ -197,10 +207,12 @@ portThread q stderr = do displayShow ("port: sending renewing request to NAT-PMP for port ", p) setPortMapping pmp PTUdp p p portLeaseLifetime >>= \case + Left err | isResetAndRetry err -> do + attemptReestablishNatPmpThen (\pmp -> handleRenew pmp nextRenew) Left err -> do logError $ displayShow ("port: failed to request NAT-PMP for port ", p, - ":", err, ", disabling NAT-PMP") + ":", err, ". disabling NAT-PMP") loopErr q Right _ -> do -- We don't need to filter the port because we just did. @@ -210,6 +222,29 @@ portThread q stderr = do rest loop pmp withRenew + -- If the internal natpmp socket is closed (laptop lid closed, network + -- change, etc), attempt to reestablish a connection. + attemptReestablishNatPmpThen :: (NatPmpHandle -> RIO e ()) + -> RIO e () + attemptReestablishNatPmpThen andThen = do + logInfo $ + displayShow ("port: network changed. Attempting NAT reconnect"); + loop 0 + where + loop :: Int -> RIO e () + loop tryNum = do + initNatPmp >>= \case + Left err -> do + if tryNum == maxRetries + then do + stderr $ "port: failed to reestablish a connection to your router" + loopErr q + else do + threadDelay networkRetryDelay + loop (tryNum + 1) + Right pmp -> do + andThen pmp + filterPort :: Word16 -> DH.MinPrioHeap POSIXTime RenewAction -> DH.MinPrioHeap POSIXTime RenewAction @@ -252,6 +287,13 @@ likelyBehindRouter = do Just ip@(10, _, _, _) -> pure True _ -> pure False +-- Some of the errors that we encounter happen when the underlying sockets have +-- closed out from under us. When this happens, we want to wait a short time +-- and reset the system. +isResetAndRetry :: Error -> Bool +isResetAndRetry ErrRecvFrom = True +isResetAndRetry ErrSendErr = True +isResetAndRetry _ = False -- Acquire a port for the duration of the RAcquire. requestPortAccess :: forall e. (HasPortControlApi e) => Word16 -> RAcquire e () From 6125ac4fe43b9a70c5d3208c7936d2207bd21cb3 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 20 Aug 2020 12:54:27 -0700 Subject: [PATCH 193/933] fix vector allocation in reel --- pkg/urbit/jets/b/reel.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pkg/urbit/jets/b/reel.c b/pkg/urbit/jets/b/reel.c index 186cd47ce4..fcf3b3a2d4 100644 --- a/pkg/urbit/jets/b/reel.c +++ b/pkg/urbit/jets/b/reel.c @@ -10,14 +10,11 @@ u3_noun b) { u3_noun pro = u3k(u3x_at(u3x_sam_3, b)); - if ( u3_nul == a ) { - return pro; - } - else { + if ( u3_nul != a ) { u3j_site sit_u; u3_noun i, t = a; c3_w j_w, len_w = 0, all_w = 89, pre_w = 55; - u3_noun* vec = u3a_malloc(all_w); + u3_noun* vec = u3a_malloc(all_w * sizeof(u3_noun)); // stuff list into an array do { @@ -30,7 +27,7 @@ // grow vec fib-wise all_w += pre_w; pre_w = len_w; - vec = u3a_realloc(vec, all_w); + vec = u3a_realloc(vec, all_w * sizeof(u3_noun)); } vec[len_w++] = i; } @@ -43,8 +40,8 @@ } u3j_gate_lose(&sit_u); u3a_free(vec); - return pro; } + return pro; } u3_noun u3wb_reel(u3_noun cor) From 8255fc0e8c90973da467bc81bd78779268217cab Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 20 Aug 2020 20:23:25 -0400 Subject: [PATCH 194/933] natpmp: formatting and cleanup old pmp handle --- pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs index 6d6c8b7a69..024bd391f3 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ports.hs @@ -75,7 +75,7 @@ maxRetries = 3 -- How long to wait between retries. networkRetryDelay :: Int -networkRetryDelay = 5 * 1000000 +networkRetryDelay = 5 * 1_000_000 -- Messages sent from the main thread to the port mapping communication thread. data PortThreadMsg @@ -172,6 +172,7 @@ portThread q stderr = do displayShow ("port: sending initial request to NAT-PMP for port ", p) setPortMapping pmp PTUdp p p portLeaseLifetime >>= \case Left err | isResetAndRetry err -> do + closeNatPmp pmp attemptReestablishNatPmpThen (\pmp -> handlePTM pmp msg nextRenew) Left err -> do logError $ @@ -208,6 +209,7 @@ portThread q stderr = do p) setPortMapping pmp PTUdp p p portLeaseLifetime >>= \case Left err | isResetAndRetry err -> do + closeNatPmp pmp attemptReestablishNatPmpThen (\pmp -> handleRenew pmp nextRenew) Left err -> do logError $ From 4d1bb97f3608a374508d22deffe9240776ad015e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 20 Aug 2020 12:38:58 -0700 Subject: [PATCH 195/933] ur: adds ur_bsr_bytes_any(), for bit-indexed byte reads --- pkg/urbit/include/ur/hashcons.h | 3 + pkg/urbit/tests/ur_tests.c | 77 +++++++++++++++++++++++++ pkg/urbit/ur/hashcons.c | 99 +++++++++++++++++++++++++++++++++ 3 files changed, 179 insertions(+) diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index 42c3b078ff..fcd1776dd9 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -257,6 +257,9 @@ ur_bsr32_any(ur_bsr_t *bsr, uint8_t len); uint64_t ur_bsr64_any(ur_bsr_t *bsr, uint8_t len); +void +ur_bsr_bytes_any(ur_bsr_t *bsr, uint64_t len, uint8_t *out); + uint64_t ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt); diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index 8856d45bed..f0d2b961ad 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -1126,11 +1126,88 @@ _test_bsr64(void) & _test_bsr64_loop("bsr64 alt-2 8", 8, 0x55); } +static void +_bsr_bytes_any_slow(ur_bsr_t *bsr, uint64_t len, uint8_t *out) +{ + uint64_t i, len_byt = len >> 3; + + for ( i = 0; i < len_byt; i++ ) { + out[i] = _bsr8_any_slow(bsr, 8); + } + + out[len_byt] = _bsr8_any_slow(bsr, ur_mask_3(len)); +} + +static int +_test_bsr_bytes_any_loop(const char *cap, uint8_t len, uint8_t val) +{ + int ret = 1; + uint64_t len_bit = len << 3; + ur_bsr_t a, b; + uint8_t *bytes, *c, *d; + uint8_t i, j, k; + + c = malloc(len); + d = malloc(len); + bytes = malloc(len); + memset(bytes, val, len); + + for ( i = 0; i < 8; i++) { + for ( j = 1; j <= len_bit; j++ ) { + a.left = b.left = len; + a.bytes = b.bytes = bytes; + a.off = a.bits = b.off = b.bits = i; + memset(c, 0x0, len); + memset(d, 0x0, len); + + _bsr_bytes_any_slow(&a, j, c); + ur_bsr_bytes_any(&b, j, d); + + ret &= _bsr_cmp_any_check(cap, i, j, &a, &b); + + if ( memcmp(c, d, len) ) { + fprintf(stderr, "%s: off %u, len %u not equal off=%u left=%" PRIu64 " bits=%" PRIu64 "\r\n", + cap, i, j, b.off, b.left, b.bits); + fprintf(stderr, " a: { "); + for ( k = 0; k < len; k++ ) { + fprintf(stderr, "%02x, ", c[k]); + } + fprintf(stderr, "}\r\n"); + fprintf(stderr, " b: { "); + for ( k = 0; k < len; k++ ) { + fprintf(stderr, "%02x, ", d[k]); + } + fprintf(stderr, "}\r\n"); + ret = 0; + } + } + } + + free(bytes); + + return ret; +} + +static int +_test_bsr_bytes_any(void) +{ + return _test_bsr_bytes_any_loop("bsr bytes nought", 0, 0x0) + & _test_bsr_bytes_any_loop("bsr bytes ones odd", 3, 0xff) + & _test_bsr_bytes_any_loop("bsr bytes ones even", 4, 0xff) + & _test_bsr_bytes_any_loop("bsr bytes zeros odd", 5, 0x0) + & _test_bsr_bytes_any_loop("bsr bytes zeros even", 6, 0x0) + & _test_bsr_bytes_any_loop("bsr bytes alt 1 odd", 7, 0xaa) + & _test_bsr_bytes_any_loop("bsr bytes alt 1 even", 8, 0xaa) + & _test_bsr_bytes_any_loop("bsr bytes alt 2 odd", 9, 0x55) + & _test_bsr_bytes_any_loop("bsr bytes alt 2 odd", 10, 0x55); +} + static int _test_bsr(void) { return _test_bsr_bit() & _test_bsr_bit_any() + & _test_bsr_bytes_any() & _test_bsr8() & _test_bsr32() & _test_bsr64(); diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 182f7a16cb..6d3aad0ef2 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -1769,6 +1769,105 @@ ur_bsr64_any(ur_bsr_t *bsr, uint8_t len) } } +void +ur_bsr_bytes_any(ur_bsr_t *bsr, uint64_t len, uint8_t *out) +{ + uint64_t left = bsr->left; + + if ( !left ) { + return; + } + else { + const uint8_t *b = bsr->bytes; + uint8_t off = bsr->off; + uint64_t len_byt = len >> 3; + uint8_t len_bit = ur_mask_3(len); + + if ( !off ) { + uint8_t bits = off + len_bit; + uint64_t need = len_byt + (bits >> 3) + !!ur_mask_3(bits); + + if ( need > left ) { + memcpy(out, b, left); + bsr->bytes = 0; + bsr->left = 0; + } + else { + memcpy(out, b, len_byt); + off = len_bit; + left -= len_byt; + + if ( !left ) { + bsr->bytes = 0; + } + else { + bsr->bytes += len_byt; + } + + bsr->left = left; + + if ( off ) { + out[len_byt] = b[len_byt] & ((1 << off) - 1); + } + } + } + // the most-significant bits from a byte in the stream + // become the least-significant bits of an output byte, and vice-versa + // + else { + uint64_t need = len_byt + (len_bit >> 3) + !!ur_mask_3(len_bit); + ur_bool_t end = need >= left; + uint64_t max = end ? (left - 1) : len_byt; + uint8_t rest = 8 - off; + uint8_t mask = (1 << off) - 1; + uint8_t byt = b[0]; + uint8_t l, m = byt >> off; + uint64_t i; + + for ( i = 0; i < max; i++ ) { + byt = b[1ULL + i]; + l = byt & mask; + out[i] = m ^ (l << rest); + m = byt >> off; + } + + if ( end ) { + if ( len_bit && len_bit < rest ) { + out[max] = m & ((1 << len_bit) - 1); + bsr->bytes += max; + left -= max; + off += len_bit; + } + else { + out[max] = m; + bsr->bytes = 0; + left = 0; + off = 0; + } + } + else { + uint8_t bits = off + len_bit; + + bsr->bytes += max; + left -= max + !!(bits >> 3); + off = ur_mask_3(bits); + + if ( len_bit <= rest ) { + out[max] = m & ((1 << len_bit) - 1); + } + else { + l = b[1ULL + max] & ((1 << off) - 1);; + out[max] = m ^ (l << rest); + } + } + } + + bsr->off = off; + bsr->left = left; + bsr->bits += len; + } +} + static inline ur_cue_res_e ur_bsr_tag(ur_bsr_t *bsr, ur_cue_tag_e *out) { From a7ac76d5e7cc4a0d62f501aea45fc2e59a3d6a0b Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 20 Aug 2020 12:39:22 -0700 Subject: [PATCH 196/933] ur: cleans up ur_bsrN_any tests --- pkg/urbit/tests/ur_tests.c | 45 +++++++++++++++----------------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index f0d2b961ad..9f1ea4f01a 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -915,16 +915,13 @@ _test_bsr8_loop(const char *cap, uint8_t len, uint8_t val) int ret = 1; uint8_t *bytes; ur_bsr_t a, b; - uint8_t c, d, i, j, k; + uint8_t c, d, i, j; + + bytes = malloc(len); + memset(bytes, val, len); for ( i = 0; i < 8; i++) { for ( j = 0; j <= 8; j++ ) { - bytes = malloc(len); - - for ( k = 0; k < len; k++ ) { - bytes[k] = val; - } - a.left = b.left = len; a.bytes = b.bytes = bytes; a.off = a.bits = b.off = b.bits = i; @@ -939,11 +936,11 @@ _test_bsr8_loop(const char *cap, uint8_t len, uint8_t val) cap, i, j, c, d, b.off, b.left, b.left ? b.bytes[0] : 0, b.bits); ret = 0; } - - free(bytes); } } + free(bytes); + return ret; } @@ -982,16 +979,13 @@ _test_bsr32_loop(const char *cap, uint8_t len, uint8_t val) uint8_t *bytes; ur_bsr_t a, b; uint32_t c, d; - uint8_t i, j, k; + uint8_t i, j; + + bytes = malloc(len); + memset(bytes, val, len); for ( i = 0; i < 8; i++) { for ( j = 0; j <= 32; j++ ) { - bytes = malloc(len); - - for ( k = 0; k < len; k++ ) { - bytes[k] = val; - } - a.left = b.left = len; a.bytes = b.bytes = bytes; a.off = a.bits = b.off = b.bits = i; @@ -1006,11 +1000,11 @@ _test_bsr32_loop(const char *cap, uint8_t len, uint8_t val) cap, i, j, c, d, b.off, b.left, b.left ? b.bytes[0] : 0, b.bits); ret = 0; } - - free(bytes); } } + free(bytes); + return ret; } @@ -1057,16 +1051,13 @@ _test_bsr64_loop(const char *cap, uint8_t len, uint8_t val) uint8_t *bytes; ur_bsr_t a, b; uint64_t c, d; - uint8_t i, j, k; + uint8_t i, j; + + bytes = malloc(len); + memset(bytes, val, len); for ( i = 0; i < 8; i++) { for ( j = 0; j <= 64; j++ ) { - bytes = malloc(len); - - for ( k = 0; k < len; k++ ) { - bytes[k] = val; - } - a.left = b.left = len; a.bytes = b.bytes = bytes; a.off = a.bits = b.off = b.bits = i; @@ -1081,11 +1072,11 @@ _test_bsr64_loop(const char *cap, uint8_t len, uint8_t val) cap, i, j, c, d, b.off, b.left, b.left ? b.bytes[0] : 0, b.bits); ret = 0; } - - free(bytes); } } + free(bytes); + return ret; } From 5a8043f62036cc63c2f524668668596db1ef0807 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 20 Aug 2020 15:49:02 -0700 Subject: [PATCH 197/933] ur: clean up ur_bsr8_any() --- pkg/urbit/ur/hashcons.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 6d3aad0ef2..5637c23a77 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -1533,10 +1533,10 @@ ur_bsr8_any(ur_bsr_t *bsr, uint8_t len) return 0; } else { - uint8_t off = bsr->off; - uint8_t rest = 8 - off; - const uint8_t *bytes = bsr->bytes; - uint8_t m = bytes[0] >> off; + uint8_t off = bsr->off; + uint8_t rest = 8 - off; + const uint8_t *b = bsr->bytes; + uint8_t m = b[0] >> off; if ( len < rest ) { bsr->off = off + len; @@ -1556,7 +1556,7 @@ ur_bsr8_any(ur_bsr_t *bsr, uint8_t len) bsr->bytes++; { - uint8_t l = bytes[1] & ((1 << off) - 1); + uint8_t l = b[1] & ((1 << off) - 1); return m ^ (l << rest); } } From b3c644930a486899a1d224670dce5a508d1eca0f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 20 Aug 2020 15:58:35 -0700 Subject: [PATCH 198/933] ur: use new ur_bsr*_any functions in ur_cue() --- pkg/urbit/ur/hashcons.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 5637c23a77..bf4597d9d2 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -2001,7 +2001,7 @@ ur_bsr_mat(ur_bsr_t *bsr, uint64_t *out) } else { len--; - *out = ur_bsr64(bsr, len) ^ (1ULL << len); + *out = ur_bsr64_any(bsr, len) ^ (1ULL << len); } return ur_cue_good; @@ -2112,19 +2112,20 @@ _cue_atom(ur_root_t *r, _cue_t *c, ur_nref *out) } if ( 62 >= len ) { - *out = (ur_nref)ur_bsr64(bsr, len); + *out = (ur_nref)ur_bsr64_any(bsr, len); } else { - uint8_t *byt = calloc(len, 1); - ur_bsr_bytes(bsr, len, byt); + uint64_t len_byt = (len >> 3) + !!ur_mask_3(len); + uint8_t *byt = calloc(len_byt, 1); + ur_bsr_bytes_any(bsr, len, byt); // strip trailing zeroes // - while ( len && !byt[len - 1] ) { - len--; + while ( len_byt && !byt[len_byt - 1] ) { + len_byt--; } - *out = _coin_bytes_unsafe(r, byt, len); + *out = _coin_bytes_unsafe(r, byt, len_byt); } return ur_cue_good; @@ -2143,7 +2144,7 @@ _cue_back(ur_bsr_t *bsr, uint64_t *out) // XX assert( 62 >= len ); - *out = ur_bsr64(bsr, len); + *out = ur_bsr64_any(bsr, len); return ur_cue_good; } From e09ba7e8ee773006a58671a3781dcea6ee75a3dd Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 20 Aug 2020 23:38:29 -0700 Subject: [PATCH 199/933] ur: fixes typos in tests --- pkg/urbit/tests/ur_tests.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index 9f1ea4f01a..8cc667ecab 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -407,7 +407,7 @@ _test_bsw_bytes(void) & _test_bsw_bytes_loop("bsw bytes alt 1 odd", 7, 0xaa) & _test_bsw_bytes_loop("bsw bytes alt 1 even", 8, 0xaa) & _test_bsw_bytes_loop("bsw bytes alt 2 odd", 9, 0x55) - & _test_bsw_bytes_loop("bsw bytes alt 2 odd", 10, 0x55); + & _test_bsw_bytes_loop("bsw bytes alt 2 even", 10, 0x55); } static void @@ -476,7 +476,7 @@ _bsr_bit_check(const char *cap, } if ( ser != res ) { - fprintf(stderr, "%s: val not equal (%s, %s) off=%u left=%" PRIu64 " byte=%02x bits=%" PRIu64 "\r\n", + fprintf(stderr, "%s: res not equal (%s, %s) off=%u left=%" PRIu64 " byte=%02x bits=%" PRIu64 "\r\n", cap, (ur_cue_good == ser) ? "good" : "gone", (ur_cue_good == res) ? "good" : "gone", bsr->off, bsr->left, bsr->left ? bsr->bytes[0] : 0, bsr->bits); @@ -484,7 +484,7 @@ _bsr_bit_check(const char *cap, } if ( (ur_cue_good == res) && (exp != val) ) { - fprintf(stderr, "%s: res not equal (%02x, %02x) off=%u left=%" PRIu64 " byte=%02x bits=%" PRIu64 "\r\n", + fprintf(stderr, "%s: val not equal (%02x, %02x) off=%u left=%" PRIu64 " byte=%02x bits=%" PRIu64 "\r\n", cap, exp, val, bsr->off, bsr->left, bsr->left ? bsr->bytes[0] : 0, bsr->bits); ret = 0; } @@ -1190,7 +1190,7 @@ _test_bsr_bytes_any(void) & _test_bsr_bytes_any_loop("bsr bytes alt 1 odd", 7, 0xaa) & _test_bsr_bytes_any_loop("bsr bytes alt 1 even", 8, 0xaa) & _test_bsr_bytes_any_loop("bsr bytes alt 2 odd", 9, 0x55) - & _test_bsr_bytes_any_loop("bsr bytes alt 2 odd", 10, 0x55); + & _test_bsr_bytes_any_loop("bsr bytes alt 2 even", 10, 0x55); } static int From 1a89c71e96fbdc80e67ec879ee4a97b02cf51bde Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 20 Aug 2020 15:48:40 -0700 Subject: [PATCH 200/933] ur: adds ur_bsr_rub_log and tests, fixes ur_bsr_zeros() --- pkg/urbit/include/ur/hashcons.h | 11 +++ pkg/urbit/tests/ur_tests.c | 127 +++++++++++++++++++++++++++++++- pkg/urbit/ur/hashcons.c | 94 ++++++++++++++++++++--- 3 files changed, 220 insertions(+), 12 deletions(-) diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index fcd1776dd9..976a8cc2b8 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -9,21 +9,26 @@ typedef uint8_t ur_bool_t; #if (32 == (CHAR_BIT * __SIZEOF_INT__)) # define ur_lz32 __builtin_clz +# define ur_tz32 __builtin_ctz #elif (32 == (CHAR_BIT * __SIZEOF_LONG__)) # define ur_lz32 __builtin_clzl +# define ur_tz32 __builtin_ctzl #else # error "port me" #endif #if (64 == (CHAR_BIT * __SIZEOF_LONG__)) # define ur_lz64 __builtin_clzl +# define ur_tz64 __builtin_ctzl #elif (64 == (CHAR_BIT * __SIZEOF_LONG_LONG__)) # define ur_lz64 __builtin_clzll +# define ur_tz64 __builtin_ctzll #else # error "port me" #endif #define ur_lz8(a) ( ur_lz32(a) - 24 ) +#define ur_tz8 ur_tz32 #define ur_mask_3(a) (a & 0x7) #define ur_mask_8(a) (a & 0xff) @@ -260,6 +265,12 @@ ur_bsr64_any(ur_bsr_t *bsr, uint8_t len); void ur_bsr_bytes_any(ur_bsr_t *bsr, uint64_t len, uint8_t *out); +ur_cue_res_e +ur_bsr_rub_log(ur_bsr_t *bsr, uint8_t *out); + +ur_cue_res_e +ur_bsr_zeros(ur_bsr_t *bsr, uint8_t *out); + uint64_t ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt); diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index 8cc667ecab..4a19c04395 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -1193,6 +1193,130 @@ _test_bsr_bytes_any(void) & _test_bsr_bytes_any_loop("bsr bytes alt 2 even", 10, 0x55); } +static int +_bsr_cmp_check(const char* cap, + uint8_t off, + uint8_t len, + ur_bsr_t *a, + ur_bsr_t *b, + uint8_t c, + uint8_t d, + ur_cue_res_e e, + ur_cue_res_e f) +{ + int ret = 1; + + if ( !ur_bsr_sane(a) ) { + fprintf(stderr, "%s: off %u, len %u a insane off=%u left=%" PRIu64 " bits=%" PRIu64 "\r\n", + cap, off, len, a->off, a->left, a->bits); + ret = 0; + } + + if ( !ur_bsr_sane(b) ) { + fprintf(stderr, "%s: off %u, len %u a insane off=%u left=%" PRIu64 " bits=%" PRIu64 "\r\n", + cap, off, len, b->off, b->left, b->bits); + ret = 0; + } + + if ( e != f ) { + fprintf(stderr, "%s: off %u, len %u ret not equal (%s, %s) off=%u left=%" PRIu64 " bits=%" PRIu64 "\r\n", + cap, off, len, + (ur_cue_good == e) ? "good" : "gone", + (ur_cue_good == f) ? "good" : "gone", + b->off, b->left, b->bits); + ret = 0; + } + + if ( (ur_cue_good == e) && (c != d) ) { + fprintf(stderr, "%s: off %u, len %u val not equal (%02x, %02x) off=%u left=%" PRIu64 " bits=%" PRIu64 "\r\n", + cap, off, len, c, d, b->off, b->left, b->bits); + ret = 0; + } + + if ( a->off != b->off ) { + fprintf(stderr, "%s: off %u len %u: offset fail (%u, %u)\r\n", + cap, off, len, a->off, b->off); + ret = 0; + } + + if ( a->left != b->left ) { + fprintf(stderr, "%s: off %u len %u: left fail (%" PRIu64 ", %" PRIu64 ")\r\n", + cap, off, len, a->left, b->left); + ret = 0; + } + + if ( a->bits != b->bits ) { + fprintf(stderr, "%s: off %u len %u: bits fail (%" PRIu64 ", %" PRIu64 ")\r\n", + cap, off, len, a->bits, b->bits); + ret = 0; + } + + + return ret; +} + +static int +_test_bsr_rub_log_loop(const char *cap, uint8_t len, uint8_t val) +{ + int ret = 1; + ur_bsr_t a, b; + uint8_t *bytes, c, d; + uint8_t i, j, k; + ur_cue_res_e e, f; + + bytes = malloc(len); + + for ( i = 0; i < 8; i++) { + for ( j = 0; j < len; j++ ) { + a.left = b.left = len; + a.bytes = b.bytes = bytes; + a.off = a.bits = b.off = b.bits = i; + + memset(bytes, 0x0, j); + memset(bytes + j, val, len - j); + + e = ur_bsr_zeros(&a, &c); + f = ur_bsr_rub_log(&b, &d); + + ret &= _bsr_cmp_check(cap, i, j, &a, &b, c, d, e, f); + } + } + + free(bytes); + + return ret; +} + +static int +_test_bsr_rub_log(void) +{ + int ret = _test_bsr_rub_log_loop("bsr rub_log nought", 0, 0x0) + & _test_bsr_rub_log_loop("bsr rub_log ones odd", 3, 0xff) + & _test_bsr_rub_log_loop("bsr rub_log ones even", 4, 0xff) + & _test_bsr_rub_log_loop("bsr rub_log ones big", 50, 0xff) + & _test_bsr_rub_log_loop("bsr rub_log zeros odd", 5, 0x0) + & _test_bsr_rub_log_loop("bsr rub_log zeros even", 6, 0x0) + & _test_bsr_rub_log_loop("bsr rub_log zeros big", 50, 0x0); + + { + uint8_t i, j = 5; + char cap[1024]; + + for ( i = 0; i < 8; i++ ) { + snprintf(cap, 1000, "bsr rub_log 1<<%u odd", i); + ret &= _test_bsr_rub_log_loop((const char*)cap, j++, 0x1 << i); + + snprintf(cap, 1000, "bsr rub_log 1<<%u even", i); + ret &= _test_bsr_rub_log_loop((const char*)cap, j++, 0x1 << i); + + snprintf(cap, 1000, "bsr rub_log 1<<%u big", i); + ret &= _test_bsr_rub_log_loop((const char*)cap, 50, 0x1 << i); + } + } + + return ret; +} + static int _test_bsr(void) { @@ -1201,7 +1325,8 @@ _test_bsr(void) & _test_bsr_bytes_any() & _test_bsr8() & _test_bsr32() - & _test_bsr64(); + & _test_bsr64() + & _test_bsr_rub_log(); } static int diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index bf4597d9d2..bb9e4326e5 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -1868,6 +1868,75 @@ ur_bsr_bytes_any(ur_bsr_t *bsr, uint64_t len, uint8_t *out) } } +static inline ur_cue_res_e +_bsr_rub_log_meme(ur_bsr_t *bsr) +{ + bsr->bits += 256; + bsr->bytes += 32; + bsr->left -= 32; + + // XX distinguish meme status + // + return ur_cue_gone; +} + +ur_cue_res_e +ur_bsr_rub_log(ur_bsr_t *bsr, uint8_t *out) +{ + uint64_t left = bsr->left; + + if ( !left ) { + return ur_cue_gone; + } + else { + uint8_t off = bsr->off; + uint8_t rest = 8 - off; + const uint8_t *b = bsr->bytes; + uint8_t byt = b[0] >> off; + uint8_t skip = 0; + + while ( !byt ) { + if ( 32 == skip ) { + return _bsr_rub_log_meme(bsr); + } + + skip++; + + if ( skip == left ) { + bsr->bits += (skip << 3) - off; + bsr->bytes = 0; + bsr->left = 0; + bsr->off = 0; + return ur_cue_gone; + } + + byt = b[skip]; + } + + { + uint32_t zeros = ur_tz8(byt) + (skip ? ((skip << 3) - off) : 0); + + if ( 255 < zeros ) { + return _bsr_rub_log_meme(bsr); + } + else { + uint32_t bits = off + 1 + zeros; + uint8_t bytes = bits >> 3; + + left -= bytes; + + bsr->bytes = left ? (b + bytes) : 0; + bsr->bits += 1 + zeros; + bsr->left = left; + bsr->off = ur_mask_3(bits); + + *out = zeros; + return ur_cue_good; + } + } + } +} + static inline ur_cue_res_e ur_bsr_tag(ur_bsr_t *bsr, ur_cue_tag_e *out) { @@ -1889,23 +1958,26 @@ ur_bsr_tag(ur_bsr_t *bsr, ur_cue_tag_e *out) return ur_cue_good; } -static inline ur_cue_res_e +ur_cue_res_e ur_bsr_zeros(ur_bsr_t *bsr, uint8_t *out) { ur_cue_res_e res; - uint8_t bit, len = 0; + uint8_t bit, i = 0; - while ( (ur_cue_good == (res = ur_bsr_bit(bsr, &bit))) && (0 == bit) ) { - len++; + do { + if ( ur_cue_good != (res = ur_bsr_bit(bsr, &bit)) ) { + return res; + } + else if ( bit ) { + *out = i; + return ur_cue_good; + } } + while ( ++i ); - if ( ur_cue_good != res ) { - return res; - } - else { - *out = len; - return ur_cue_good; - } + // XX distinguish meme + // + return ur_cue_gone; } static inline uint64_t From d130633732035905536da89b7fdaf9b2b3da5ad3 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 20 Aug 2020 15:45:57 -0700 Subject: [PATCH 201/933] ur: uses ur_bsr_rub_log() in ur_bsr_mat, moves ur_bsr_zeros() into tests --- pkg/urbit/include/ur/hashcons.h | 3 --- pkg/urbit/tests/ur_tests.c | 24 +++++++++++++++++++++++- pkg/urbit/ur/hashcons.c | 29 ++++------------------------- 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index 976a8cc2b8..8ccb183a39 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -268,9 +268,6 @@ ur_bsr_bytes_any(ur_bsr_t *bsr, uint64_t len, uint8_t *out); ur_cue_res_e ur_bsr_rub_log(ur_bsr_t *bsr, uint8_t *out); -ur_cue_res_e -ur_bsr_zeros(ur_bsr_t *bsr, uint8_t *out); - uint64_t ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt); diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index 4a19c04395..4de14f9861 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -1255,6 +1255,28 @@ _bsr_cmp_check(const char* cap, return ret; } +static ur_cue_res_e +_bsr_rub_log_slow(ur_bsr_t *bsr, uint8_t *out) +{ + ur_cue_res_e res; + uint8_t bit, i = 0; + + do { + if ( ur_cue_good != (res = ur_bsr_bit(bsr, &bit)) ) { + return res; + } + else if ( bit ) { + *out = i; + return ur_cue_good; + } + } + while ( ++i ); + + // XX distinguish meme + // + return ur_cue_gone; +} + static int _test_bsr_rub_log_loop(const char *cap, uint8_t len, uint8_t val) { @@ -1275,7 +1297,7 @@ _test_bsr_rub_log_loop(const char *cap, uint8_t len, uint8_t val) memset(bytes, 0x0, j); memset(bytes + j, val, len - j); - e = ur_bsr_zeros(&a, &c); + e = _bsr_rub_log_slow(&a, &c); f = ur_bsr_rub_log(&b, &d); ret &= _bsr_cmp_check(cap, i, j, &a, &b, c, d, e, f); diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index bb9e4326e5..e02a29b845 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -1958,28 +1958,6 @@ ur_bsr_tag(ur_bsr_t *bsr, ur_cue_tag_e *out) return ur_cue_good; } -ur_cue_res_e -ur_bsr_zeros(ur_bsr_t *bsr, uint8_t *out) -{ - ur_cue_res_e res; - uint8_t bit, i = 0; - - do { - if ( ur_cue_good != (res = ur_bsr_bit(bsr, &bit)) ) { - return res; - } - else if ( bit ) { - *out = i; - return ur_cue_good; - } - } - while ( ++i ); - - // XX distinguish meme - // - return ur_cue_gone; -} - static inline uint64_t ur_bsr64(ur_bsr_t *bsr, uint8_t len) { @@ -2059,10 +2037,11 @@ ur_bsr_bytes(ur_bsr_t *bsr, uint64_t len, uint8_t *out) static inline ur_cue_res_e ur_bsr_mat(ur_bsr_t *bsr, uint64_t *out) { - uint8_t len; + ur_cue_res_e res; + uint8_t len; - if ( ur_cue_gone == ur_bsr_zeros(bsr, &len) ) { - return ur_cue_gone; + if ( ur_cue_good != (res = ur_bsr_rub_log(bsr, &len)) ) { + return res; } // XX From 4a7ad95e14e2f252bb7dc70bae52c1bc294e9cf9 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 21 Aug 2020 14:26:10 -0700 Subject: [PATCH 202/933] ur: rewrites ur_bsr_tag(), adds tests --- pkg/urbit/include/ur/hashcons.h | 15 +++--- pkg/urbit/tests/ur_tests.c | 71 ++++++++++++++++++++++++- pkg/urbit/ur/hashcons.c | 94 ++++++++++++++++++++++++--------- 3 files changed, 147 insertions(+), 33 deletions(-) diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index 8ccb183a39..ef3f2af74e 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -244,6 +244,12 @@ typedef enum { ur_cue_gone = 1 } ur_cue_res_e; +typedef enum { + ur_jam_atom = 0, + ur_jam_cell = 1, + ur_jam_back = 2 +} ur_cue_tag_e; + ur_bool_t ur_bsr_sane(ur_bsr_t *bsr); @@ -265,17 +271,14 @@ ur_bsr64_any(ur_bsr_t *bsr, uint8_t len); void ur_bsr_bytes_any(ur_bsr_t *bsr, uint64_t len, uint8_t *out); +ur_cue_res_e +ur_bsr_tag(ur_bsr_t *bsr, ur_cue_tag_e *out); + ur_cue_res_e ur_bsr_rub_log(ur_bsr_t *bsr, uint8_t *out); uint64_t ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt); -typedef enum { - ur_jam_atom = 0, - ur_jam_cell = 1, - ur_jam_back = 2 -} ur_cue_tag_e; - ur_cue_res_e ur_cue(ur_root_t *r, uint64_t len, const uint8_t *byt, ur_nref *out); diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index 4de14f9861..f14b8258c2 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -1339,6 +1339,74 @@ _test_bsr_rub_log(void) return ret; } +static ur_cue_res_e +_bsr_tag_slow(ur_bsr_t *bsr, ur_cue_tag_e *out) +{ + ur_cue_res_e res; + uint8_t bit; + + if ( ur_cue_good != (res = ur_bsr_bit(bsr, &bit)) ) { + return res; + } + else if ( 0 == bit ) { + *out = ur_jam_atom; + return ur_cue_good; + } + else if ( ur_cue_good != (res = ur_bsr_bit(bsr, &bit)) ) { + return res; + } + + *out = ( 0 == bit ) ? ur_jam_cell : ur_jam_back; + return ur_cue_good; +} + +static int +_test_bsr_tag_loop(const char *cap, uint8_t len, uint8_t val) +{ + int ret = 1; + ur_bsr_t a, b; + uint8_t *bytes; + ur_cue_tag_e c, d; + uint8_t i, j, k; + ur_cue_res_e e, f; + + bytes = malloc(len); + + for ( i = 0; i < 8; i++) { + for ( j = 0; j < len; j++ ) { + a.left = b.left = len; + a.bytes = b.bytes = bytes; + a.off = a.bits = b.off = b.bits = i; + + memset(bytes, 0x0, j); + memset(bytes + j, val, len - j); + + e = _bsr_tag_slow(&a, &c); + f = ur_bsr_tag(&b, &d); + + ret &= _bsr_cmp_check(cap, i, j, &a, &b, c, d, e, f); + } + } + + free(bytes); + + return ret; +} + +static int +_test_bsr_tag(void) +{ + return _test_bsr_tag_loop("bsr tag nought", 0, 0x0) + & _test_bsr_tag_loop("bsr tag ones 1", 1, 0xff) + & _test_bsr_tag_loop("bsr tag ones 2", 2, 0xff) + & _test_bsr_tag_loop("bsr tag zeros 1", 1, 0x0) + & _test_bsr_tag_loop("bsr tag zeros 2", 2, 0x0) + & _test_bsr_tag_loop("bsr tag alt-1 1", 1, 0xaa) + & _test_bsr_tag_loop("bsr tag alt-1 2", 2, 0xaa) + & _test_bsr_tag_loop("bsr tag alt-2 1", 1, 0x55) + & _test_bsr_tag_loop("bsr tag alt-2 2", 2, 0x55); +} + static int _test_bsr(void) { @@ -1348,7 +1416,8 @@ _test_bsr(void) & _test_bsr8() & _test_bsr32() & _test_bsr64() - & _test_bsr_rub_log(); + & _test_bsr_rub_log() + & _test_bsr_tag(); } static int diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index e02a29b845..e583477530 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -1868,6 +1868,73 @@ ur_bsr_bytes_any(ur_bsr_t *bsr, uint64_t len, uint8_t *out) } } +static inline ur_cue_res_e +_bsr_set_gone(ur_bsr_t *bsr, uint8_t bits) +{ + bsr->bits += bits; + bsr->bytes = 0; + bsr->left = 0; + bsr->off = 0; + return ur_cue_gone; +} + +ur_cue_res_e +ur_bsr_tag(ur_bsr_t *bsr, ur_cue_tag_e *out) +{ + uint64_t left = bsr->left; + + if ( !left ) { + return ur_cue_gone; + } + else { + const uint8_t *b = bsr->bytes; + uint8_t off = bsr->off; + uint8_t bit = (b[0] >> off) & 1; + uint8_t len = 1; + + if ( 0 == bit ) { + *out = ur_jam_atom; + } + else { + if ( 7 == off ) { + if ( 1 == left ) { + return _bsr_set_gone(bsr, 1); + } + + bit = b[1] & 1; + } + else { + bit = (b[0] >> (off + 1)) & 1; + } + + len++; + *out = ( 0 == bit ) ? ur_jam_cell : ur_jam_back; + } + + { + uint8_t bits = off + len; + uint8_t bytes = bits >> 3; + + left -= bytes; + + if ( !left ) { + bsr->bytes = 0; + bsr->left = 0; + bsr->off = 0; + } + else { + bsr->bytes += bytes; + bsr->left = left; + bsr->off = ur_mask_3(bits); + } + + bsr->bits += len; + + return ur_cue_good; + } + } +} + static inline ur_cue_res_e _bsr_rub_log_meme(ur_bsr_t *bsr) { @@ -1903,11 +1970,7 @@ ur_bsr_rub_log(ur_bsr_t *bsr, uint8_t *out) skip++; if ( skip == left ) { - bsr->bits += (skip << 3) - off; - bsr->bytes = 0; - bsr->left = 0; - bsr->off = 0; - return ur_cue_gone; + return _bsr_set_gone(bsr, (skip << 3) - off); } byt = b[skip]; @@ -1937,27 +2000,6 @@ ur_bsr_rub_log(ur_bsr_t *bsr, uint8_t *out) } } -static inline ur_cue_res_e -ur_bsr_tag(ur_bsr_t *bsr, ur_cue_tag_e *out) -{ - ur_cue_res_e res; - uint8_t bit; - - if ( ur_cue_good != (res = ur_bsr_bit(bsr, &bit)) ) { - return res; - } - else if ( 0 == bit ) { - *out = ur_jam_atom; - return ur_cue_good; - } - else if ( ur_cue_good != (res = ur_bsr_bit(bsr, &bit)) ) { - return res; - } - - *out = ( 0 == bit ) ? ur_jam_cell : ur_jam_back; - return ur_cue_good; -} - static inline uint64_t ur_bsr64(ur_bsr_t *bsr, uint8_t len) { From 6e3dade9a6db39ac2a2bd1d5e9785fad4b11f98b Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 21 Aug 2020 14:26:26 -0700 Subject: [PATCH 203/933] ur: improves ur_bsr_sane() --- pkg/urbit/ur/hashcons.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index e583477530..cd0cfd5d1c 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -1437,11 +1437,13 @@ ur_bsw_cell(ur_bsw_t *bsw) ur_bool_t ur_bsr_sane(ur_bsr_t *bsr) { + ur_bool_t ret = 8 > bsr->off; + if ( !bsr->left ) { - return !bsr->off && !bsr->bytes; + ret = ret && (!bsr->off && !bsr->bytes); } - return 1; + return ret; } ur_cue_res_e From 66970a01e129638d9e20e1c89e6add8e7858265c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 21 Aug 2020 14:26:38 -0700 Subject: [PATCH 204/933] ur: refactors ur_bsr_bit* functions --- pkg/urbit/ur/hashcons.c | 47 ++++++++++++----------------------------- 1 file changed, 14 insertions(+), 33 deletions(-) diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index cd0cfd5d1c..2a4e0fa29f 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -1455,32 +1455,22 @@ ur_bsr_bit(ur_bsr_t *bsr, uint8_t *out) return ur_cue_gone; } else { - uint8_t byt = bsr->bytes[0]; - uint8_t off = bsr->off; - uint8_t bit = (byt >> off) & 1; + const uint8_t *b = bsr->bytes; + uint8_t off = bsr->off; + uint8_t bit = (b[0] >> off) & 1; if ( 7 == off ) { - left--; - - if ( left ) { - bsr->bytes++; - bsr->left = left; - } - else { - bsr->bytes = 0; - bsr->left = 0; - } - - bsr->off = 0; + bsr->bytes = ( --left ) ? (b + 1) : 0; + bsr->left = left; + bsr->off = 0; } else { - bsr->off = 1 + off; + bsr->off = 1 + off; } bsr->bits++; *out = bit; - return ur_cue_good; } } @@ -1496,26 +1486,17 @@ ur_bsr_bit_any(ur_bsr_t *bsr) return 0; } else { - uint8_t byt = bsr->bytes[0]; - uint8_t off = bsr->off; - uint8_t bit = (byt >> off) & 1; + const uint8_t *b = bsr->bytes; + uint8_t off = bsr->off; + uint8_t bit = (b[0] >> off) & 1; if ( 7 == off ) { - left--; - - if ( left ) { - bsr->bytes++; - bsr->left = left; - } - else { - bsr->bytes = 0; - bsr->left = 0; - } - - bsr->off = 0; + bsr->bytes = ( --left ) ? (b + 1) : 0; + bsr->left = left; + bsr->off = 0; } else { - bsr->off = 1 + off; + bsr->off = 1 + off; } return bit; From 753a3ea9a57c86b662326b142b5395b357e1662f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 21 Aug 2020 14:28:09 -0700 Subject: [PATCH 205/933] ur: removes superceded functions: ur_bsr64 and ur_bsr_bytes --- pkg/urbit/ur/hashcons.c | 76 ----------------------------------------- 1 file changed, 76 deletions(-) diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 2a4e0fa29f..681d7611eb 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -1983,82 +1983,6 @@ ur_bsr_rub_log(ur_bsr_t *bsr, uint8_t *out) } } -static inline uint64_t -ur_bsr64(ur_bsr_t *bsr, uint8_t len) -{ - uint64_t acc = 0; - uint64_t i; - uint8_t bit; - - for ( i = 0; i < len; i++ ) { - if ( ur_cue_good != ur_bsr_bit(bsr, &bit) ) { - bsr->bits += len - i; - return acc; - } - - acc ^= (uint64_t)bit << i; - } - - return acc; -} - -static inline void -ur_bsr_bytes(ur_bsr_t *bsr, uint64_t len, uint8_t *out) -{ - uint64_t left = bsr->left; - uint8_t off = bsr->off; - ur_bool_t end = len >= left; - - if ( !left ) { - return; - } - - if ( !off ) { - if ( end ) { - memcpy(out, bsr->bytes, left); - bsr->bytes = 0; - left = 0; - } - else { - memcpy(out, bsr->bytes, len); - bsr->bytes += len; - left -= len; - } - } - // the most-significant bits from a byte in the stream - // become the least-significant bits of an output byte, and vice-versa - // - else { - uint8_t rest = 8 - off; - const uint8_t *bytes = bsr->bytes; - uint8_t byt = bytes[0]; - uint8_t l, m; - uint64_t max = end ? (left - 1) : len; - uint64_t i; - - for ( i = 0; i < max; i++ ) { - m = byt >> off; - byt = bytes[1 + i]; - l = byt & ((1 << off) - 1); - out[i] = m ^ (l << rest); - } - - if ( end ) { - out[max] = bytes[max] >> off; - - bsr->bytes = 0; - left = 0; - } - else { - bsr->bytes += max; - left -= max; - } - } - - bsr->left = left; - bsr->bits += len << 3; -} - static inline ur_cue_res_e ur_bsr_mat(ur_bsr_t *bsr, uint64_t *out) { From 096677a3c3b43d90100eab96e721912590769c79 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 21 Aug 2020 15:27:04 -0700 Subject: [PATCH 206/933] ur: distinguish "meme" (exceeds memory repr) errors in ur_bsr* and ur_cue* functions --- pkg/urbit/include/ur/hashcons.h | 6 ++++- pkg/urbit/tests/ur_tests.c | 4 +-- pkg/urbit/ur/hashcons.c | 44 ++++++++++++++++++--------------- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index ef3f2af74e..d842e4f09b 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -241,7 +241,8 @@ typedef struct ur_bsr_s { typedef enum { ur_cue_good = 0, - ur_cue_gone = 1 + ur_cue_gone = 1, + ur_cue_meme = 2 } ur_cue_res_e; typedef enum { @@ -277,6 +278,9 @@ ur_bsr_tag(ur_bsr_t *bsr, ur_cue_tag_e *out); ur_cue_res_e ur_bsr_rub_log(ur_bsr_t *bsr, uint8_t *out); +ur_cue_res_e +ur_bsr_rub_len(ur_bsr_t *bsr, uint64_t *out); + uint64_t ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt); diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index f14b8258c2..fc8b663860 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -1272,9 +1272,7 @@ _bsr_rub_log_slow(ur_bsr_t *bsr, uint8_t *out) } while ( ++i ); - // XX distinguish meme - // - return ur_cue_gone; + return ur_cue_meme; } static int diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 681d7611eb..8888919ea7 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -1924,10 +1924,7 @@ _bsr_rub_log_meme(ur_bsr_t *bsr) bsr->bits += 256; bsr->bytes += 32; bsr->left -= 32; - - // XX distinguish meme status - // - return ur_cue_gone; + return ur_cue_meme; } ur_cue_res_e @@ -1983,8 +1980,8 @@ ur_bsr_rub_log(ur_bsr_t *bsr, uint8_t *out) } } -static inline ur_cue_res_e -ur_bsr_mat(ur_bsr_t *bsr, uint64_t *out) +ur_cue_res_e +ur_bsr_rub_len(ur_bsr_t *bsr, uint64_t *out) { ur_cue_res_e res; uint8_t len; @@ -1992,16 +1989,23 @@ ur_bsr_mat(ur_bsr_t *bsr, uint64_t *out) if ( ur_cue_good != (res = ur_bsr_rub_log(bsr, &len)) ) { return res; } - - // XX - assert( 64 > len ); - - if ( !len ) { - *out = 0; + else if ( 64 <= len ) { + return ur_cue_meme; } - else { - len--; - *out = ur_bsr64_any(bsr, len) ^ (1ULL << len); + + switch ( len ) { + case 0: { + *out = 0; + } break; + + case 1: { + *out = 1; + } break; + + default: { + len--; + *out = ur_bsr64_any(bsr, len) ^ (1ULL << len); + } break; } return ur_cue_good; @@ -2107,7 +2111,7 @@ _cue_atom(ur_root_t *r, _cue_t *c, ur_nref *out) ur_cue_res_e res; uint64_t len; - if ( ur_cue_good != (res = ur_bsr_mat(bsr, &len)) ) { + if ( ur_cue_good != (res = ur_bsr_rub_len(bsr, &len)) ) { return res; } @@ -2137,12 +2141,12 @@ _cue_back(ur_bsr_t *bsr, uint64_t *out) ur_cue_res_e res; uint64_t len; - if ( ur_cue_good != (res = ur_bsr_mat(bsr, &len)) ) { + if ( ur_cue_good != (res = ur_bsr_rub_len(bsr, &len)) ) { return res; } - - // XX - assert( 62 >= len ); + else if ( 62 < len ) { + return ur_cue_meme; + } *out = ur_bsr64_any(bsr, len); return ur_cue_good; From 8bc148acc3a6bc6a03a8de21e74404d4e69c176c Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 24 Aug 2020 15:01:02 -0700 Subject: [PATCH 207/933] use road stack instead of heap vector in reel --- pkg/urbit/jets/b/reel.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/pkg/urbit/jets/b/reel.c b/pkg/urbit/jets/b/reel.c index fcf3b3a2d4..dd3e2103ac 100644 --- a/pkg/urbit/jets/b/reel.c +++ b/pkg/urbit/jets/b/reel.c @@ -12,34 +12,25 @@ u3_noun pro = u3k(u3x_at(u3x_sam_3, b)); if ( u3_nul != a ) { u3j_site sit_u; + u3_noun* top; u3_noun i, t = a; - c3_w j_w, len_w = 0, all_w = 89, pre_w = 55; - u3_noun* vec = u3a_malloc(all_w * sizeof(u3_noun)); + c3_w len_w = 0; - // stuff list into an array + // push list onto road stack do { - if ( c3n == u3r_cell(t, &i, &t) ) { - u3a_free(vec); - return u3m_bail(c3__exit); - } - else { - if ( len_w == all_w ) { - // grow vec fib-wise - all_w += pre_w; - pre_w = len_w; - vec = u3a_realloc(vec, all_w * sizeof(u3_noun)); - } - vec[len_w++] = i; - } + u3x_cell(t, &i, &t); + top = (c3_w*) u3a_push(sizeof(u3_noun)); + *top = i; + ++len_w; } while ( u3_nul != t ); - // now we can iterate backwards u3j_gate_prep(&sit_u, u3k(b)); - for ( j_w = len_w; j_w > 0; ) { - pro = u3j_gate_slam(&sit_u, u3nc(u3k(vec[--j_w]), pro)); + while ( len_w-- > 0 ) { + top = u3a_peek(sizeof(u3_noun)); + u3a_pop(sizeof(u3_noun)); + pro = u3j_gate_slam(&sit_u, u3nc(u3k(*top), pro)); } u3j_gate_lose(&sit_u); - u3a_free(vec); } return pro; } From 8a3b2fc0617a316ced6e4cae2dd95014ecc898ef Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 21 Aug 2020 15:54:56 -0700 Subject: [PATCH 208/933] ur: refactors ur "library" into separate modules --- pkg/urbit/include/ur/bitstream.h | 106 +++ pkg/urbit/include/ur/defs.h | 66 ++ pkg/urbit/include/ur/hashcons.h | 167 +--- pkg/urbit/include/ur/serial.h | 13 + pkg/urbit/include/ur/ur.h | 9 + pkg/urbit/tests/ur_tests.c | 2 +- pkg/urbit/ur/bitstream.c | 1133 +++++++++++++++++++++++ pkg/urbit/ur/hashcons.c | 1449 +----------------------------- pkg/urbit/ur/serial.c | 299 ++++++ 9 files changed, 1651 insertions(+), 1593 deletions(-) create mode 100644 pkg/urbit/include/ur/bitstream.h create mode 100644 pkg/urbit/include/ur/defs.h create mode 100644 pkg/urbit/include/ur/serial.h create mode 100644 pkg/urbit/include/ur/ur.h create mode 100644 pkg/urbit/ur/bitstream.c create mode 100644 pkg/urbit/ur/serial.c diff --git a/pkg/urbit/include/ur/bitstream.h b/pkg/urbit/include/ur/bitstream.h new file mode 100644 index 0000000000..785866857f --- /dev/null +++ b/pkg/urbit/include/ur/bitstream.h @@ -0,0 +1,106 @@ +#ifndef UR_BITSTREAM_H +#define UR_BITSTREAM_H + +#include + +typedef enum { + ur_cue_good = 0, + ur_cue_gone = 1, + ur_cue_meme = 2 +} ur_cue_res_e; + +typedef enum { + ur_jam_atom = 0, + ur_jam_cell = 1, + ur_jam_back = 2 +} ur_cue_tag_e; + +typedef struct ur_bsr_s { + uint64_t left; + uint64_t bits; + uint8_t off; + const uint8_t *bytes; +} ur_bsr_t; + +typedef struct ur_bsw_s { + uint64_t prev; + uint64_t size; + uint64_t fill; + uint64_t bits; + uint8_t off; + uint8_t *bytes; +} ur_bsw_t; + +ur_bool_t +ur_bsr_sane(ur_bsr_t *bsr); + +ur_cue_res_e +ur_bsr_bit(ur_bsr_t *bsr, uint8_t *out); + +uint8_t +ur_bsr_bit_any(ur_bsr_t *bsr); + +uint8_t +ur_bsr8_any(ur_bsr_t *bsr, uint8_t len); + +uint32_t +ur_bsr32_any(ur_bsr_t *bsr, uint8_t len); + +uint64_t +ur_bsr64_any(ur_bsr_t *bsr, uint8_t len); + +void +ur_bsr_bytes_any(ur_bsr_t *bsr, uint64_t len, uint8_t *out); + +ur_cue_res_e +ur_bsr_tag(ur_bsr_t *bsr, ur_cue_tag_e *out); + +ur_cue_res_e +ur_bsr_rub_log(ur_bsr_t *bsr, uint8_t *out); + +ur_cue_res_e +ur_bsr_rub_len(ur_bsr_t *bsr, uint64_t *out); + +void +ur_bsw_grow(ur_bsw_t *bsw, uint64_t step); + +ur_bool_t +ur_bsw_sane(ur_bsw_t *bsw); + +void +ur_bsw_bit(ur_bsw_t *bsw, uint8_t bit); + +void +ur_bsw8(ur_bsw_t *bsw, uint8_t len, uint8_t byt); + +void +ur_bsw32(ur_bsw_t *bsw, uint8_t len, uint32_t val); + +void +ur_bsw64(ur_bsw_t *bsw, uint8_t len, uint64_t val); + +void +ur_bsw_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt); + +void +ur_bsw_bex(ur_bsw_t *bsw, uint8_t n); + +void +ur_bsw_mat64(ur_bsw_t *bsw, uint8_t len, uint64_t val); + +void +ur_bsw_mat_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt); + +void +ur_bsw_back64(ur_bsw_t *bsw, uint8_t len, uint64_t val); + +void +ur_bsw_atom64(ur_bsw_t *bsw, uint8_t len, uint64_t val); + +void +ur_bsw_atom_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt); + +void +ur_bsw_cell(ur_bsw_t *bsw); + +#endif diff --git a/pkg/urbit/include/ur/defs.h b/pkg/urbit/include/ur/defs.h new file mode 100644 index 0000000000..51f9064cc3 --- /dev/null +++ b/pkg/urbit/include/ur/defs.h @@ -0,0 +1,66 @@ +#ifndef UR_DEFS_H +#define UR_DEFS_H + +#include +#include +#include + +typedef uint8_t ur_bool_t; + +#define ur_min(a, b) ( ((a) < (b)) ? (a) : (b) ) +#define ur_max(a, b) ( ((a) > (b)) ? (a) : (b) ) + +#if (32 == (CHAR_BIT * __SIZEOF_INT__)) +# define ur_lz32 __builtin_clz +# define ur_tz32 __builtin_ctz +#elif (32 == (CHAR_BIT * __SIZEOF_LONG__)) +# define ur_lz32 __builtin_clzl +# define ur_tz32 __builtin_ctzl +#else +# error "port me" +#endif + +#if (64 == (CHAR_BIT * __SIZEOF_LONG__)) +# define ur_lz64 __builtin_clzl +# define ur_tz64 __builtin_ctzl +#elif (64 == (CHAR_BIT * __SIZEOF_LONG_LONG__)) +# define ur_lz64 __builtin_clzll +# define ur_tz64 __builtin_ctzll +#else +# error "port me" +#endif + +#define ur_lz8(a) ( ur_lz32(a) - 24 ) +#define ur_tz8 ur_tz32 + +#define ur_mask_3(a) (a & 0x7) +#define ur_mask_8(a) (a & 0xff) +#define ur_mask_31(a) (a & 0x7fffffff) +#define ur_mask_62(a) (a & 0x3fffffffffffffffULL) + +#define ur_met0_8(a) ( (a) ? 8 - ur_lz8(a) : 0 ) +#define ur_met0_32(a) ( (a) ? 32 - ur_lz32(a) : 0 ) +#define ur_met0_64(a) ( (a) ? 64 - ur_lz64(a) : 0 ) + +inline uint64_t +ur_met0_bytes(uint8_t *byt, uint64_t len) +{ + // XX requires no trailing null bytes + // + uint64_t last = len - 1; + return (last << 3) + ur_met0_8(byt[last]); +} + +#define ur_met3_8(a) \ + ({ uint8_t _a = ur_met0_8(a); \ + ( (_a >> 3) + !!ur_mask_3(_a) ); }) + +#define ur_met3_32(a) \ + ({ uint8_t _a = ur_met0_32(a); \ + ( (_a >> 3) + !!ur_mask_3(_a) ); }) + +#define ur_met3_64(a) \ + ({ uint8_t _a = ur_met0_64(a); \ + ( (_a >> 3) + !!ur_mask_3(_a) ); }) + +#endif diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index d842e4f09b..73601c174f 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -1,55 +1,12 @@ +#ifndef UR_HASHCONS_H +#define UR_HASHCONS_H + #include #include #include +#include -typedef uint8_t ur_bool_t; - -#define ur_min(a, b) ( ((a) < (b)) ? (a) : (b) ) -#define ur_max(a, b) ( ((a) > (b)) ? (a) : (b) ) - -#if (32 == (CHAR_BIT * __SIZEOF_INT__)) -# define ur_lz32 __builtin_clz -# define ur_tz32 __builtin_ctz -#elif (32 == (CHAR_BIT * __SIZEOF_LONG__)) -# define ur_lz32 __builtin_clzl -# define ur_tz32 __builtin_ctzl -#else -# error "port me" -#endif - -#if (64 == (CHAR_BIT * __SIZEOF_LONG__)) -# define ur_lz64 __builtin_clzl -# define ur_tz64 __builtin_ctzl -#elif (64 == (CHAR_BIT * __SIZEOF_LONG_LONG__)) -# define ur_lz64 __builtin_clzll -# define ur_tz64 __builtin_ctzll -#else -# error "port me" -#endif - -#define ur_lz8(a) ( ur_lz32(a) - 24 ) -#define ur_tz8 ur_tz32 - -#define ur_mask_3(a) (a & 0x7) -#define ur_mask_8(a) (a & 0xff) -#define ur_mask_31(a) (a & 0x7fffffff) -#define ur_mask_62(a) (a & 0x3fffffffffffffffULL) - -#define ur_met0_8(a) ( (a) ? 8 - ur_lz8(a) : 0 ) -#define ur_met0_32(a) ( (a) ? 32 - ur_lz32(a) : 0 ) -#define ur_met0_64(a) ( (a) ? 64 - ur_lz64(a) : 0 ) - -#define ur_met3_8(a) \ - ({ uint8_t _a = ur_met0_8(a); \ - ( (_a >> 3) + !!ur_mask_3(_a) ); }) \ - -#define ur_met3_32(a) \ - ({ uint8_t _a = ur_met0_32(a); \ - ( (_a >> 3) + !!ur_mask_3(_a) ); }) \ - -#define ur_met3_64(a) \ - ({ uint8_t _a = ur_met0_64(a); \ - ( (_a >> 3) + !!ur_mask_3(_a) ); }) \ +#include "ur/defs.h" #define ur_nref_tag(ref) ( ref >> 62 ) #define ur_nref_idx(ref) ur_mask_62(ref) @@ -127,6 +84,9 @@ typedef struct ur_root_s { ur_atoms_t atoms; } ur_root_t; +uint64_t +ur_met(ur_root_t *r, uint8_t bloq, ur_nref ref); + void ur_dict32_grow(ur_root_t *r, ur_dict32_t *dict, uint64_t prev, uint64_t size); @@ -148,6 +108,9 @@ ur_dict64_get(ur_root_t *r, ur_dict64_t *dict, ur_nref ref, uint64_t *out); void ur_dict64_put(ur_root_t *r, ur_dict64_t *dict, ur_nref ref, uint64_t val); +ur_nref +ur_coin_bytes_unsafe(ur_root_t *r, uint8_t *byt, uint64_t len); + ur_nref ur_coin_bytes(ur_root_t *r, uint8_t *byt, uint64_t len); @@ -179,110 +142,4 @@ ur_walk_fore(ur_root_t *r, void (*atom)(ur_root_t*, ur_nref, void*), ur_bool_t (*cell)(ur_root_t*, ur_nref, void*)); - -typedef struct ur_bsw_s { - uint64_t prev; - uint64_t size; - uint64_t fill; - uint64_t bits; - uint8_t off; - uint8_t *bytes; -} ur_bsw_t; - -void -ur_bsw_grow(ur_bsw_t *bsw, uint64_t step); - -ur_bool_t -ur_bsw_sane(ur_bsw_t *bsw); - -void -ur_bsw_bit(ur_bsw_t *bsw, uint8_t bit); - -void -ur_bsw8(ur_bsw_t *bsw, uint8_t len, uint8_t byt); - -void -ur_bsw32(ur_bsw_t *bsw, uint8_t len, uint32_t val); - -void -ur_bsw64(ur_bsw_t *bsw, uint8_t len, uint64_t val); - -void -ur_bsw_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt); - -void -ur_bsw_bex(ur_bsw_t *bsw, uint8_t n); - -void -ur_bsw_mat64(ur_bsw_t *bsw, uint8_t len, uint64_t val); - -void -ur_bsw_mat_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt); - -void -ur_bsw_back64(ur_bsw_t *bsw, uint8_t len, uint64_t val); - -void -ur_bsw_atom64(ur_bsw_t *bsw, uint8_t len, uint64_t val); - -void -ur_bsw_atom_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt); - -void -ur_bsw_cell(ur_bsw_t *bsw); - - -typedef struct ur_bsr_s { - uint64_t left; - uint64_t bits; - uint8_t off; - const uint8_t *bytes; -} ur_bsr_t; - -typedef enum { - ur_cue_good = 0, - ur_cue_gone = 1, - ur_cue_meme = 2 -} ur_cue_res_e; - -typedef enum { - ur_jam_atom = 0, - ur_jam_cell = 1, - ur_jam_back = 2 -} ur_cue_tag_e; - -ur_bool_t -ur_bsr_sane(ur_bsr_t *bsr); - -ur_cue_res_e -ur_bsr_bit(ur_bsr_t *bsr, uint8_t *out); - -uint8_t -ur_bsr_bit_any(ur_bsr_t *bsr); - -uint8_t -ur_bsr8_any(ur_bsr_t *bsr, uint8_t len); - -uint32_t -ur_bsr32_any(ur_bsr_t *bsr, uint8_t len); - -uint64_t -ur_bsr64_any(ur_bsr_t *bsr, uint8_t len); - -void -ur_bsr_bytes_any(ur_bsr_t *bsr, uint64_t len, uint8_t *out); - -ur_cue_res_e -ur_bsr_tag(ur_bsr_t *bsr, ur_cue_tag_e *out); - -ur_cue_res_e -ur_bsr_rub_log(ur_bsr_t *bsr, uint8_t *out); - -ur_cue_res_e -ur_bsr_rub_len(ur_bsr_t *bsr, uint64_t *out); - -uint64_t -ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt); - -ur_cue_res_e -ur_cue(ur_root_t *r, uint64_t len, const uint8_t *byt, ur_nref *out); +#endif \ No newline at end of file diff --git a/pkg/urbit/include/ur/serial.h b/pkg/urbit/include/ur/serial.h new file mode 100644 index 0000000000..2a8d98b86e --- /dev/null +++ b/pkg/urbit/include/ur/serial.h @@ -0,0 +1,13 @@ +#ifndef UR_SERIAL_H +#define UR_SERIAL_H + +#include +#include + +uint64_t +ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt); + +ur_cue_res_e +ur_cue(ur_root_t *r, uint64_t len, const uint8_t *byt, ur_nref *out); + +#endif diff --git a/pkg/urbit/include/ur/ur.h b/pkg/urbit/include/ur/ur.h new file mode 100644 index 0000000000..5b1bb222eb --- /dev/null +++ b/pkg/urbit/include/ur/ur.h @@ -0,0 +1,9 @@ +#ifndef UR_UR_H +#define UR_UR_H + +#include "ur/defs.h" +#include "ur/bitstream.h" +#include "ur/hashcons.h" +#include "ur/serial.h" + +#endif diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index fc8b663860..66a145559f 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -5,7 +5,7 @@ #include #include -#include "ur/hashcons.h" +#include "ur/ur.h" static void _bsw_init(ur_bsw_t *bsw, uint64_t prev, uint64_t size) diff --git a/pkg/urbit/ur/bitstream.c b/pkg/urbit/ur/bitstream.c new file mode 100644 index 0000000000..476cf40d89 --- /dev/null +++ b/pkg/urbit/ur/bitstream.c @@ -0,0 +1,1133 @@ +#include +#include +#include + +#include "ur/defs.h" +#include "ur/bitstream.h" + +ur_bool_t +ur_bsr_sane(ur_bsr_t *bsr) +{ + ur_bool_t ret = 8 > bsr->off; + + if ( !bsr->left ) { + ret = ret && (!bsr->off && !bsr->bytes); + } + + return ret; +} + +ur_cue_res_e +ur_bsr_bit(ur_bsr_t *bsr, uint8_t *out) +{ + uint64_t left = bsr->left; + + if ( !left ) { + return ur_cue_gone; + } + else { + const uint8_t *b = bsr->bytes; + uint8_t off = bsr->off; + uint8_t bit = (b[0] >> off) & 1; + + if ( 7 == off ) { + bsr->bytes = ( --left ) ? (b + 1) : 0; + bsr->left = left; + bsr->off = 0; + } + else { + bsr->off = 1 + off; + } + + bsr->bits++; + + *out = bit; + return ur_cue_good; + } +} + +uint8_t +ur_bsr_bit_any(ur_bsr_t *bsr) +{ + uint64_t left = bsr->left; + + bsr->bits++; + + if ( !left ) { + return 0; + } + else { + const uint8_t *b = bsr->bytes; + uint8_t off = bsr->off; + uint8_t bit = (b[0] >> off) & 1; + + if ( 7 == off ) { + bsr->bytes = ( --left ) ? (b + 1) : 0; + bsr->left = left; + bsr->off = 0; + } + else { + bsr->off = 1 + off; + } + + return bit; + } +} + +uint8_t +ur_bsr8_any(ur_bsr_t *bsr, uint8_t len) +{ + uint64_t left = bsr->left; + + len = ur_min(8, len); + + bsr->bits += len; + + if ( !left ) { + return 0; + } + else { + uint8_t off = bsr->off; + uint8_t rest = 8 - off; + const uint8_t *b = bsr->bytes; + uint8_t m = b[0] >> off; + + if ( len < rest ) { + bsr->off = off + len; + return m & ((1 << len) - 1); + } + else if ( 1 == left ) { + bsr->off = 0; + bsr->left = 0; + bsr->bytes = 0; + return m; + } + else { + off = len - rest; + + bsr->off = off; + bsr->left--; + bsr->bytes++; + + { + uint8_t l = b[1] & ((1 << off) - 1); + return m ^ (l << rest); + } + } + } +} + +uint32_t +ur_bsr32_any(ur_bsr_t *bsr, uint8_t len) +{ + uint64_t left = bsr->left; + + len = ur_min(32, len); + + bsr->bits += len; + + if ( !left ) { + return 0; + } + else { + uint8_t off = bsr->off; + uint8_t rest = 8 - off; + const uint8_t *b = bsr->bytes; + uint32_t m = b[0] >> off; + + if ( len < rest ) { + bsr->off = off + len; + return m & ((1 << len) - 1); + } + else { + uint8_t mask, len_byt; + uint32_t l; + + len -= rest; + left--; + bsr->bytes++; + + len_byt = len >> 3; + + if ( len_byt >= left ) { + len_byt = left; + bsr->off = off = 0; + bsr->left = 0; + bsr->bytes = 0; + } + else { + bsr->off = off = ur_mask_3(len); + bsr->left = left - len_byt; + bsr->bytes += len_byt; + } + + mask = (1 << off) - 1; + + switch ( len_byt ) { + case 4: { + l = (uint32_t)b[1] + ^ (uint32_t)b[2] << 8 + ^ (uint32_t)b[3] << 16 + ^ (uint32_t)b[4] << 24; + } break; + + case 3: { + l = (uint32_t)b[1] + ^ (uint32_t)b[2] << 8 + ^ (uint32_t)b[3] << 16 + ^ (uint32_t)(b[4] & mask) << 24; + } break; + + case 2: { + l = (uint32_t)b[1] + ^ (uint32_t)b[2] << 8 + ^ (uint32_t)(b[3] & mask) << 16; + } break; + + case 1: { + l = (uint32_t)b[1] + ^ (uint32_t)(b[2] & mask) << 8; + } break; + + case 0: { + l = (uint32_t)(b[1] & mask); + } break; + } + + return m ^ (l << rest); + } + } +} + +uint64_t +ur_bsr64_any(ur_bsr_t *bsr, uint8_t len) +{ + uint64_t left = bsr->left; + + len = ur_min(64, len); + + bsr->bits += len; + + if ( !left ) { + return 0; + } + else { + uint8_t off = bsr->off; + uint8_t rest = 8 - off; + const uint8_t *b = bsr->bytes; + uint64_t m = b[0] >> off; + + if ( len < rest ) { + bsr->off = off + len; + return m & ((1 << len) - 1); + } + else { + uint8_t mask, len_byt; + uint64_t l; + + len -= rest; + left--; + bsr->bytes++; + + len_byt = len >> 3; + + if ( len_byt >= left ) { + len_byt = left; + bsr->off = off = 0; + bsr->left = 0; + bsr->bytes = 0; + } + else { + bsr->off = off = ur_mask_3(len); + bsr->left = left - len_byt; + bsr->bytes += len_byt; + } + + mask = (1 << off) - 1; + + switch ( len_byt ) { + case 8: { + l = (uint64_t)b[1] + ^ (uint64_t)b[2] << 8 + ^ (uint64_t)b[3] << 16 + ^ (uint64_t)b[4] << 24 + ^ (uint64_t)b[5] << 32 + ^ (uint64_t)b[6] << 40 + ^ (uint64_t)b[7] << 48 + ^ (uint64_t)b[8] << 56; + } break; + + case 7: { + l = (uint64_t)b[1] + ^ (uint64_t)b[2] << 8 + ^ (uint64_t)b[3] << 16 + ^ (uint64_t)b[4] << 24 + ^ (uint64_t)b[5] << 32 + ^ (uint64_t)b[6] << 40 + ^ (uint64_t)b[7] << 48 + ^ (uint64_t)(b[8] & mask) << 56; + } break; + + case 6: { + l = (uint64_t)b[1] + ^ (uint64_t)b[2] << 8 + ^ (uint64_t)b[3] << 16 + ^ (uint64_t)b[4] << 24 + ^ (uint64_t)b[5] << 32 + ^ (uint64_t)b[6] << 40 + ^ (uint64_t)(b[7] & mask) << 48; + } break; + + case 5: { + l = (uint64_t)b[1] + ^ (uint64_t)b[2] << 8 + ^ (uint64_t)b[3] << 16 + ^ (uint64_t)b[4] << 24 + ^ (uint64_t)b[5] << 32 + ^ (uint64_t)(b[6] & mask) << 40; + } break; + + case 4: { + l = (uint64_t)b[1] + ^ (uint64_t)b[2] << 8 + ^ (uint64_t)b[3] << 16 + ^ (uint64_t)b[4] << 24 + ^ (uint64_t)(b[5] & mask) << 32; + } break; + + case 3: { + l = (uint64_t)b[1] + ^ (uint64_t)b[2] << 8 + ^ (uint64_t)b[3] << 16 + ^ (uint64_t)(b[4] & mask) << 24; + } break; + + case 2: { + l = (uint64_t)b[1] + ^ (uint64_t)b[2] << 8 + ^ (uint64_t)(b[3] & mask) << 16; + } break; + + case 1: { + l = (uint64_t)b[1] + ^ (uint64_t)(b[2] & mask) << 8; + } break; + + case 0: { + l = (uint64_t)(b[1] & mask); + } break; + } + + return m ^ (l << rest); + } + } +} + +void +ur_bsr_bytes_any(ur_bsr_t *bsr, uint64_t len, uint8_t *out) +{ + uint64_t left = bsr->left; + + if ( !left ) { + return; + } + else { + const uint8_t *b = bsr->bytes; + uint8_t off = bsr->off; + uint64_t len_byt = len >> 3; + uint8_t len_bit = ur_mask_3(len); + + if ( !off ) { + uint8_t bits = off + len_bit; + uint64_t need = len_byt + (bits >> 3) + !!ur_mask_3(bits); + + if ( need > left ) { + memcpy(out, b, left); + bsr->bytes = 0; + bsr->left = 0; + } + else { + memcpy(out, b, len_byt); + off = len_bit; + left -= len_byt; + + if ( !left ) { + bsr->bytes = 0; + } + else { + bsr->bytes += len_byt; + } + + bsr->left = left; + + if ( off ) { + out[len_byt] = b[len_byt] & ((1 << off) - 1); + } + } + } + // the most-significant bits from a byte in the stream + // become the least-significant bits of an output byte, and vice-versa + // + else { + uint64_t need = len_byt + (len_bit >> 3) + !!ur_mask_3(len_bit); + ur_bool_t end = need >= left; + uint64_t max = end ? (left - 1) : len_byt; + uint8_t rest = 8 - off; + uint8_t mask = (1 << off) - 1; + uint8_t byt = b[0]; + uint8_t l, m = byt >> off; + uint64_t i; + + for ( i = 0; i < max; i++ ) { + byt = b[1ULL + i]; + l = byt & mask; + out[i] = m ^ (l << rest); + m = byt >> off; + } + + if ( end ) { + if ( len_bit && len_bit < rest ) { + out[max] = m & ((1 << len_bit) - 1); + bsr->bytes += max; + left -= max; + off += len_bit; + } + else { + out[max] = m; + bsr->bytes = 0; + left = 0; + off = 0; + } + } + else { + uint8_t bits = off + len_bit; + + bsr->bytes += max; + left -= max + !!(bits >> 3); + off = ur_mask_3(bits); + + if ( len_bit <= rest ) { + out[max] = m & ((1 << len_bit) - 1); + } + else { + l = b[1ULL + max] & ((1 << off) - 1);; + out[max] = m ^ (l << rest); + } + } + } + + bsr->off = off; + bsr->left = left; + bsr->bits += len; + } +} + +static inline ur_cue_res_e +_bsr_set_gone(ur_bsr_t *bsr, uint8_t bits) +{ + bsr->bits += bits; + bsr->bytes = 0; + bsr->left = 0; + bsr->off = 0; + return ur_cue_gone; +} + +ur_cue_res_e +ur_bsr_tag(ur_bsr_t *bsr, ur_cue_tag_e *out) +{ + uint64_t left = bsr->left; + + if ( !left ) { + return ur_cue_gone; + } + else { + const uint8_t *b = bsr->bytes; + uint8_t off = bsr->off; + uint8_t bit = (b[0] >> off) & 1; + uint8_t len = 1; + + if ( 0 == bit ) { + *out = ur_jam_atom; + } + else { + if ( 7 == off ) { + if ( 1 == left ) { + return _bsr_set_gone(bsr, 1); + } + + bit = b[1] & 1; + } + else { + bit = (b[0] >> (off + 1)) & 1; + } + + len++; + *out = ( 0 == bit ) ? ur_jam_cell : ur_jam_back; + } + + { + uint8_t bits = off + len; + uint8_t bytes = bits >> 3; + + left -= bytes; + + if ( !left ) { + bsr->bytes = 0; + bsr->left = 0; + bsr->off = 0; + } + else { + bsr->bytes += bytes; + bsr->left = left; + bsr->off = ur_mask_3(bits); + } + + bsr->bits += len; + + return ur_cue_good; + } + } +} + +static inline ur_cue_res_e +_bsr_rub_log_meme(ur_bsr_t *bsr) +{ + bsr->bits += 256; + bsr->bytes += 32; + bsr->left -= 32; + return ur_cue_meme; +} + +ur_cue_res_e +ur_bsr_rub_log(ur_bsr_t *bsr, uint8_t *out) +{ + uint64_t left = bsr->left; + + if ( !left ) { + return ur_cue_gone; + } + else { + uint8_t off = bsr->off; + uint8_t rest = 8 - off; + const uint8_t *b = bsr->bytes; + uint8_t byt = b[0] >> off; + uint8_t skip = 0; + + while ( !byt ) { + if ( 32 == skip ) { + return _bsr_rub_log_meme(bsr); + } + + skip++; + + if ( skip == left ) { + return _bsr_set_gone(bsr, (skip << 3) - off); + } + + byt = b[skip]; + } + + { + uint32_t zeros = ur_tz8(byt) + (skip ? ((skip << 3) - off) : 0); + + if ( 255 < zeros ) { + return _bsr_rub_log_meme(bsr); + } + else { + uint32_t bits = off + 1 + zeros; + uint8_t bytes = bits >> 3; + + left -= bytes; + + bsr->bytes = left ? (b + bytes) : 0; + bsr->bits += 1 + zeros; + bsr->left = left; + bsr->off = ur_mask_3(bits); + + *out = zeros; + return ur_cue_good; + } + } + } +} + +ur_cue_res_e +ur_bsr_rub_len(ur_bsr_t *bsr, uint64_t *out) +{ + ur_cue_res_e res; + uint8_t len; + + if ( ur_cue_good != (res = ur_bsr_rub_log(bsr, &len)) ) { + return res; + } + else if ( 64 <= len ) { + return ur_cue_meme; + } + + switch ( len ) { + case 0: { + *out = 0; + } break; + + case 1: { + *out = 1; + } break; + + default: { + len--; + *out = ur_bsr64_any(bsr, len) ^ (1ULL << len); + } break; + } + + return ur_cue_good; +} + +void +ur_bsw_grow(ur_bsw_t *bsw, uint64_t step) +{ + uint64_t size = bsw->size; + uint64_t next = size + step; + + bsw->bytes = realloc(bsw->bytes, next); + assert(bsw->bytes); + memset(bsw->bytes + size, 0, step); + + bsw->prev = size; + bsw->size = next; +} + +ur_bool_t +ur_bsw_sane(ur_bsw_t *bsw) +{ + return ( (8 > bsw->off) + && ((bsw->fill << 3) + bsw->off == bsw->bits) ); +} + +static inline void +_bsw_bit_unsafe(ur_bsw_t *bsw, uint8_t bit) +{ + uint64_t fill = bsw->fill; + uint8_t off = bsw->off; + + bsw->bytes[fill] ^= (bit & 1) << off; + + if ( 7 == off ) { + bsw->fill = 1 + fill; + bsw->off = 0; + } + else { + bsw->off = 1 + off; + } + + bsw->bits++; +} + +void +ur_bsw_bit(ur_bsw_t *bsw, uint8_t bit) +{ + if ( (7 == bsw->off) + && ((1 + bsw->fill) == bsw->size) ) + { + ur_bsw_grow(bsw, bsw->prev); + } + + _bsw_bit_unsafe(bsw, bit); +} + +static inline void +_bsw8_unsafe(ur_bsw_t *bsw, uint8_t len, uint8_t byt) +{ + uint64_t fill = bsw->fill; + uint8_t off = bsw->off; + uint8_t rest = 8 - off; + uint8_t l, m; + + // the least-significant bits of the input become the + // most-significant bits of a byte in the output stream + // + if ( len < rest ) { + l = byt & ((1 << len) - 1); + + bsw->bytes[fill] ^= l << off; + bsw->off = off + len; + } + // and vice-versa + // + else { + l = byt & ((1 << rest) - 1); + m = byt >> rest; + + bsw->bytes[fill++] ^= l << off; + off = len - rest; + bsw->bytes[fill] = m & ((1 << off) - 1); + + bsw->fill = fill; + bsw->off = off; + } + + bsw->bits += len; +} + +void +ur_bsw8(ur_bsw_t *bsw, uint8_t len, uint8_t byt) +{ + len = ur_min(8, len); + + if ( bsw->fill + !!((bsw->off + len) >> 3) >= bsw->size ) { + ur_bsw_grow(bsw, bsw->prev); + } + + _bsw8_unsafe(bsw, len, byt); +} + +static inline void +_bsw32_unsafe(ur_bsw_t *bsw, uint8_t len, uint32_t val) +{ + uint64_t fill = bsw->fill; + uint8_t off = bsw->off; + uint8_t *bytes = bsw->bytes; + + bsw->bits += len; + + if ( off ) { + uint8_t rest = 8 - off; + + if ( len < rest ) { + bytes[fill] ^= (val & ((1 << len) - 1)) << off; + bsw->off = off + len; + return; + } + + bytes[fill++] ^= (val & ((1 << rest) - 1)) << off; + val >>= rest; + len -= rest; + } + + switch ( len >> 3 ) { + case 4: { + bytes[fill++] = ur_mask_8(val); + bytes[fill++] = ur_mask_8(val >> 8); + bytes[fill++] = ur_mask_8(val >> 16); + bytes[fill++] = ur_mask_8(val >> 24); + + // no offset is possible here + // + bsw->fill = fill; + bsw->off = 0; + return; + } + + case 3: { + bytes[fill++] = ur_mask_8(val); + bytes[fill++] = ur_mask_8(val >> 8); + bytes[fill++] = ur_mask_8(val >> 16); + val >>= 24; + } break; + + case 2: { + bytes[fill++] = ur_mask_8(val); + bytes[fill++] = ur_mask_8(val >> 8); + val >>= 16; + } break; + + case 1: { + bytes[fill++] = ur_mask_8(val); + val >>= 8; + } break; + } + + off = ur_mask_3(len); + + if ( off ) { + bytes[fill] = (uint8_t)(val & ((1 << off) - 1)); + } + + bsw->fill = fill; + bsw->off = off; +} + +void +ur_bsw32(ur_bsw_t *bsw, uint8_t len, uint32_t val) +{ + uint8_t bits, need; + + len = ur_min(32, len); + bits = bsw->off + len; + need = (bits >> 3) + !!ur_mask_3(bits); + + if ( bsw->fill + need >= bsw->size ) { + ur_bsw_grow(bsw, ur_max(need, bsw->prev)); + } + + _bsw32_unsafe(bsw, len, val); +} + +static inline void +_bsw64_unsafe(ur_bsw_t *bsw, uint8_t len, uint64_t val) +{ + uint64_t fill = bsw->fill; + uint8_t off = bsw->off; + uint8_t *bytes = bsw->bytes; + + bsw->bits += len; + + if ( off ) { + uint8_t rest = 8 - off; + + if ( len < rest ) { + bytes[fill] ^= (val & ((1 << len) - 1)) << off; + bsw->off = off + len; + return; + } + + bytes[fill++] ^= (val & ((1 << rest) - 1)) << off; + val >>= rest; + len -= rest; + } + + switch ( len >> 3 ) { + case 8: { + bytes[fill++] = ur_mask_8(val); + bytes[fill++] = ur_mask_8(val >> 8); + bytes[fill++] = ur_mask_8(val >> 16); + bytes[fill++] = ur_mask_8(val >> 24); + bytes[fill++] = ur_mask_8(val >> 32); + bytes[fill++] = ur_mask_8(val >> 40); + bytes[fill++] = ur_mask_8(val >> 48); + bytes[fill++] = ur_mask_8(val >> 56); + + // no offset is possible here + // + bsw->fill = fill; + bsw->off = 0; + return; + } + + case 7: { + bytes[fill++] = ur_mask_8(val); + bytes[fill++] = ur_mask_8(val >> 8); + bytes[fill++] = ur_mask_8(val >> 16); + bytes[fill++] = ur_mask_8(val >> 24); + bytes[fill++] = ur_mask_8(val >> 32); + bytes[fill++] = ur_mask_8(val >> 40); + bytes[fill++] = ur_mask_8(val >> 48); + val >>= 56; + } break; + + case 6: { + bytes[fill++] = ur_mask_8(val); + bytes[fill++] = ur_mask_8(val >> 8); + bytes[fill++] = ur_mask_8(val >> 16); + bytes[fill++] = ur_mask_8(val >> 24); + bytes[fill++] = ur_mask_8(val >> 32); + bytes[fill++] = ur_mask_8(val >> 40); + val >>= 48; + } break; + + case 5: { + bytes[fill++] = ur_mask_8(val); + bytes[fill++] = ur_mask_8(val >> 8); + bytes[fill++] = ur_mask_8(val >> 16); + bytes[fill++] = ur_mask_8(val >> 24); + bytes[fill++] = ur_mask_8(val >> 32); + val >>= 40; + } break; + + case 4: { + bytes[fill++] = ur_mask_8(val); + bytes[fill++] = ur_mask_8(val >> 8); + bytes[fill++] = ur_mask_8(val >> 16); + bytes[fill++] = ur_mask_8(val >> 24); + val >>= 32; + } break; + + case 3: { + bytes[fill++] = ur_mask_8(val); + bytes[fill++] = ur_mask_8(val >> 8); + bytes[fill++] = ur_mask_8(val >> 16); + val >>= 24; + } break; + + case 2: { + bytes[fill++] = ur_mask_8(val); + bytes[fill++] = ur_mask_8(val >> 8); + val >>= 16; + } break; + + case 1: { + bytes[fill++] = ur_mask_8(val); + val >>= 8; + } break; + } + + off = ur_mask_3(len); + + if ( off ) { + bytes[fill] = (uint8_t)(val & ((1 << off) - 1)); + } + + bsw->fill = fill; + bsw->off = off; +} + +void +ur_bsw64(ur_bsw_t *bsw, uint8_t len, uint64_t val) +{ + uint8_t bits, need; + + len = ur_min(64, len); + bits = bsw->off + len; + need = (bits >> 3) + !!ur_mask_3(bits); + + if ( bsw->fill + need >= bsw->size ) { + ur_bsw_grow(bsw, ur_max(need, bsw->prev)); + } + + _bsw64_unsafe(bsw, len, val); +} + +static inline void +_bsw_bytes_unsafe(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) +{ + uint64_t len_byt = len >> 3; + uint8_t len_bit = ur_mask_3(len); + uint64_t fill = bsw->fill; + uint8_t off = bsw->off; + + if ( !off ) { + memcpy(bsw->bytes + fill, byt, len_byt); + fill += len_byt; + off = len_bit; + + if ( off ) { + bsw->bytes[fill] = byt[len_byt] & ((1 << off) - 1); + } + } + // the least-significant bits of the input become the + // most-significant bits of a byte in the output stream, and vice-versa + // + else { + uint8_t rest = 8 - off; + uint8_t mask = (1 << rest) - 1; + uint8_t l, m = bsw->bytes[fill]; + uint64_t i; + + for ( i = 0; i < len_byt; i++ ) { + l = byt[i] & mask; + bsw->bytes[fill++] = m ^ (l << off); + m = byt[i] >> rest; + } + + if ( len_bit < rest ) { + l = byt[len_byt] & ((1 << len_bit) - 1); + bsw->bytes[fill] = m ^ (l << off); + off += len_bit; + } + else { + l = byt[len_byt] & mask; + bsw->bytes[fill++] = m ^ (l << off); + + m = byt[len_byt] >> rest; + + off = len_bit - rest; + bsw->bytes[fill] = m & ((1 << off) - 1); + } + } + + bsw->off = off; + bsw->fill = fill; + bsw->bits += len; +} + +void +ur_bsw_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) +{ + uint8_t bits = len + bsw->off; + uint64_t need = (bits >> 3) + !!ur_mask_3(bits); + + if ( bsw->fill + need >= bsw->size ) { + ur_bsw_grow(bsw, ur_max(need, bsw->prev)); + } + + _bsw_bytes_unsafe(bsw, len, byt); +} + +static inline void +_bsw_bex_unsafe(ur_bsw_t *bsw, uint8_t n) +{ + uint64_t fill = bsw->fill; + uint8_t off = bsw->off; + uint32_t bits = n + off; + + fill += bits >> 3; + off = ur_mask_3(bits); + + bsw->bytes[fill] ^= 1 << off; + + if ( 7 == off ) { + bsw->off = 0; + bsw->fill = 1 + fill; + } + else { + bsw->off = 1 + off; + bsw->fill = fill; + } + + bsw->bits += 1 + n; +} + +void +ur_bsw_bex(ur_bsw_t *bsw, uint8_t n) +{ + uint32_t bits = 1 + n + bsw->off; + uint8_t need = (bits >> 3) + !!ur_mask_3(bits); + + if ( bsw->fill + need >= bsw->size ) { + ur_bsw_grow(bsw, ur_max(need, bsw->prev)); + } + + _bsw_bex_unsafe(bsw, n); +} + +static inline void +_bsw_mat64_unsafe(ur_bsw_t *bsw, uint8_t len, uint64_t val) +{ + if ( 0 == len ) { + _bsw_bit_unsafe(bsw, 1); + } + else { + { + uint8_t nel = ur_met0_64(len); + _bsw_bex_unsafe(bsw, nel); + _bsw64_unsafe(bsw, nel - 1, len); + } + + _bsw64_unsafe(bsw, len, val); + } +} + +void +ur_bsw_mat64(ur_bsw_t *bsw, uint8_t len, uint64_t val) +{ + uint8_t next, bits, need; + + len = ur_min(64, len); + next = ( 0 == len ) ? 1 : len + (2 * ur_met0_64(len)); + bits = bsw->off + next; + need = (bits >> 3) + !!ur_mask_3(bits); + + if ( bsw->fill + need >= bsw->size ) { + ur_bsw_grow(bsw, ur_max(need, bsw->prev)); + } + + _bsw_mat64_unsafe(bsw, len, val); +} + +static inline void +_bsw_mat_bytes_unsafe(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) +{ + if ( 0 == len ) { + _bsw_bit_unsafe(bsw, 1); + } + else { + // write run-length + // + { + uint8_t nel = ur_met0_64(len); + _bsw_bex_unsafe(bsw, nel); + _bsw64_unsafe(bsw, nel - 1, len); + } + + _bsw_bytes_unsafe(bsw, len, byt); + } +} + +void +ur_bsw_mat_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) +{ + uint64_t next = ( 0 == len ) ? 1 : len + (2 * ur_met0_64(len)); + uint64_t bits = bsw->off + next; + uint64_t need = (bits >> 3) + !!ur_mask_3(bits); + + if ( bsw->fill + need >= bsw->size ) { + ur_bsw_grow(bsw, ur_max(need, bsw->prev)); + } + + _bsw_mat_bytes_unsafe(bsw, len, byt); +} + +static inline void +_bsw_back64(ur_bsw_t *bsw, uint8_t len, uint64_t val) +{ + _bsw8_unsafe(bsw, 2, 3); + _bsw_mat64_unsafe(bsw, len, val); +} + +void +ur_bsw_back64(ur_bsw_t *bsw, uint8_t len, uint64_t val) +{ + uint64_t next = ( 0 == len ) ? 1 : len + (2 * ur_met0_64(len)); + uint64_t bits = 2 + bsw->off + next; + uint64_t need = (bits >> 3) + !!ur_mask_3(bits); + + if ( bsw->fill + need >= bsw->size ) { + ur_bsw_grow(bsw, ur_max(need, bsw->prev)); + } + + _bsw_back64(bsw, len, val); +} + +static inline void +_bsw_atom64(ur_bsw_t *bsw, uint8_t len, uint64_t val) +{ + _bsw_bit_unsafe(bsw, 0); + _bsw_mat64_unsafe(bsw, len, val); +} + +void +ur_bsw_atom64(ur_bsw_t *bsw, uint8_t len, uint64_t val) +{ + uint64_t next = ( 0 == len ) ? 1 : len + (2 * ur_met0_64(len)); + uint64_t bits = 1 + bsw->off + next; + uint64_t need = (bits >> 3) + !!ur_mask_3(bits); + + if ( bsw->fill + need >= bsw->size ) { + ur_bsw_grow(bsw, ur_max(need, bsw->prev)); + } + + _bsw_atom64(bsw, len, val); +} + +static inline void +_bsw_atom_bytes_unsafe(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) +{ + _bsw_bit_unsafe(bsw, 0); + _bsw_mat_bytes_unsafe(bsw, len, byt); +} + +void +ur_bsw_atom_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) +{ + uint64_t next = ( 0 == len ) ? 1 : len + (2 * ur_met0_64(len)); + uint64_t bits = 1 + bsw->off + next; + uint64_t need = (bits >> 3) + !!ur_mask_3(bits); + + if ( bsw->fill + need >= bsw->size ) { + ur_bsw_grow(bsw, ur_max(need, bsw->prev)); + } + + _bsw_atom_bytes_unsafe(bsw, len, byt); +} + +void +ur_bsw_cell(ur_bsw_t *bsw) +{ + uint8_t bits = 2 + bsw->off; + uint8_t need = (bits >> 3) + !!ur_mask_3(bits); + + if ( bsw->fill + need >= bsw->size ) { + ur_bsw_grow(bsw, ur_max(need, bsw->prev)); + } + + _bsw8_unsafe(bsw, 2, 1); +} diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 8888919ea7..a10579c7cb 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -9,8 +9,14 @@ #include +#include "ur/defs.h" #include "ur/hashcons.h" +// declarations of inline functions +// +uint64_t +ur_met0_bytes(uint8_t *byt, uint64_t len); + ur_mug ur_mug_bytes(const uint8_t *byt, uint64_t len) { @@ -402,15 +408,6 @@ ur_bytes(ur_root_t *r, ur_nref ref, uint8_t **byt, uint64_t *len) } } -static inline uint64_t -_met0_bytes(uint8_t *byt, uint64_t len) -{ - // XX requires no trailing null bytes - // - uint64_t last = len - 1; - return (last << 3) + ur_met0_8(byt[last]); -} - uint64_t ur_met(ur_root_t *r, uint8_t bloq, ur_nref ref) { @@ -452,7 +449,7 @@ ur_met(ur_root_t *r, uint8_t bloq, ur_nref ref) uint64_t len = r->atoms.lens[idx]; uint8_t *byt = r->atoms.bytes[idx]; - m_bit = _met0_bytes(byt, len); + m_bit = ur_met0_bytes(byt, len); } switch ( bloq ) { @@ -514,8 +511,8 @@ _cons_unsafe(ur_cells_t *cells, ur_mug mug, ur_nref hed, ur_nref tal) return cel; } -static ur_nref -_coin_bytes_unsafe(ur_root_t *r, uint8_t *byt, uint64_t len) +ur_nref +ur_coin_bytes_unsafe(ur_root_t *r, uint8_t *byt, uint64_t len) { ur_atoms_t *atoms = &(r->atoms); ur_dict_t *dict = &(atoms->dict); @@ -570,7 +567,7 @@ ur_coin_bytes(ur_root_t *r, uint8_t *byt, uint64_t len) // produce a direct atom if possible // - if ( 62 >= _met0_bytes(byt, len) ) { + if ( 62 >= ur_met0_bytes(byt, len) ) { uint64_t i, direct = 0; for ( i = 0; i < len; i++ ) { @@ -584,7 +581,7 @@ ur_coin_bytes(ur_root_t *r, uint8_t *byt, uint64_t len) assert( copy ); memcpy(copy, byt, len); - return _coin_bytes_unsafe(r, copy, len); + return ur_coin_bytes_unsafe(r, copy, len); } } @@ -608,7 +605,7 @@ ur_coin64(ur_root_t *r, uint64_t n) byt[6] = ur_mask_8(n >> 48); byt[7] = ur_mask_8(n >> 56); - return _coin_bytes_unsafe(r, byt, 8); + return ur_coin_bytes_unsafe(r, byt, 8); } } @@ -883,1425 +880,3 @@ ur_walk_fore(ur_root_t *r, free(don); } - -void -ur_bsw_grow(ur_bsw_t *bsw, uint64_t step) -{ - uint64_t size = bsw->size; - uint64_t next = size + step; - - bsw->bytes = realloc(bsw->bytes, next); - assert(bsw->bytes); - memset(bsw->bytes + size, 0, step); - - bsw->prev = size; - bsw->size = next; -} - -ur_bool_t -ur_bsw_sane(ur_bsw_t *bsw) -{ - return ( (8 > bsw->off) - && ((bsw->fill << 3) + bsw->off == bsw->bits) ); -} - -static inline void -_bsw_bit_unsafe(ur_bsw_t *bsw, uint8_t bit) -{ - uint64_t fill = bsw->fill; - uint8_t off = bsw->off; - - bsw->bytes[fill] ^= (bit & 1) << off; - - if ( 7 == off ) { - bsw->fill = 1 + fill; - bsw->off = 0; - } - else { - bsw->off = 1 + off; - } - - bsw->bits++; -} - -void -ur_bsw_bit(ur_bsw_t *bsw, uint8_t bit) -{ - if ( (7 == bsw->off) - && ((1 + bsw->fill) == bsw->size) ) - { - ur_bsw_grow(bsw, bsw->prev); - } - - _bsw_bit_unsafe(bsw, bit); -} - -static inline void -_bsw8_unsafe(ur_bsw_t *bsw, uint8_t len, uint8_t byt) -{ - uint64_t fill = bsw->fill; - uint8_t off = bsw->off; - uint8_t rest = 8 - off; - uint8_t l, m; - - // the least-significant bits of the input become the - // most-significant bits of a byte in the output stream - // - if ( len < rest ) { - l = byt & ((1 << len) - 1); - - bsw->bytes[fill] ^= l << off; - bsw->off = off + len; - } - // and vice-versa - // - else { - l = byt & ((1 << rest) - 1); - m = byt >> rest; - - bsw->bytes[fill++] ^= l << off; - off = len - rest; - bsw->bytes[fill] = m & ((1 << off) - 1); - - bsw->fill = fill; - bsw->off = off; - } - - bsw->bits += len; -} - -void -ur_bsw8(ur_bsw_t *bsw, uint8_t len, uint8_t byt) -{ - len = ur_min(8, len); - - if ( bsw->fill + !!((bsw->off + len) >> 3) >= bsw->size ) { - ur_bsw_grow(bsw, bsw->prev); - } - - _bsw8_unsafe(bsw, len, byt); -} - -static inline void -_bsw32_unsafe(ur_bsw_t *bsw, uint8_t len, uint32_t val) -{ - uint64_t fill = bsw->fill; - uint8_t off = bsw->off; - uint8_t *bytes = bsw->bytes; - - bsw->bits += len; - - if ( off ) { - uint8_t rest = 8 - off; - - if ( len < rest ) { - bytes[fill] ^= (val & ((1 << len) - 1)) << off; - bsw->off = off + len; - return; - } - - bytes[fill++] ^= (val & ((1 << rest) - 1)) << off; - val >>= rest; - len -= rest; - } - - switch ( len >> 3 ) { - case 4: { - bytes[fill++] = ur_mask_8(val); - bytes[fill++] = ur_mask_8(val >> 8); - bytes[fill++] = ur_mask_8(val >> 16); - bytes[fill++] = ur_mask_8(val >> 24); - - // no offset is possible here - // - bsw->fill = fill; - bsw->off = 0; - return; - } - - case 3: { - bytes[fill++] = ur_mask_8(val); - bytes[fill++] = ur_mask_8(val >> 8); - bytes[fill++] = ur_mask_8(val >> 16); - val >>= 24; - } break; - - case 2: { - bytes[fill++] = ur_mask_8(val); - bytes[fill++] = ur_mask_8(val >> 8); - val >>= 16; - } break; - - case 1: { - bytes[fill++] = ur_mask_8(val); - val >>= 8; - } break; - } - - off = ur_mask_3(len); - - if ( off ) { - bytes[fill] = (uint8_t)(val & ((1 << off) - 1)); - } - - bsw->fill = fill; - bsw->off = off; -} - -void -ur_bsw32(ur_bsw_t *bsw, uint8_t len, uint32_t val) -{ - uint8_t bits, need; - - len = ur_min(32, len); - bits = bsw->off + len; - need = (bits >> 3) + !!ur_mask_3(bits); - - if ( bsw->fill + need >= bsw->size ) { - ur_bsw_grow(bsw, ur_max(need, bsw->prev)); - } - - _bsw32_unsafe(bsw, len, val); -} - -static inline void -_bsw64_unsafe(ur_bsw_t *bsw, uint8_t len, uint64_t val) -{ - uint64_t fill = bsw->fill; - uint8_t off = bsw->off; - uint8_t *bytes = bsw->bytes; - - bsw->bits += len; - - if ( off ) { - uint8_t rest = 8 - off; - - if ( len < rest ) { - bytes[fill] ^= (val & ((1 << len) - 1)) << off; - bsw->off = off + len; - return; - } - - bytes[fill++] ^= (val & ((1 << rest) - 1)) << off; - val >>= rest; - len -= rest; - } - - switch ( len >> 3 ) { - case 8: { - bytes[fill++] = ur_mask_8(val); - bytes[fill++] = ur_mask_8(val >> 8); - bytes[fill++] = ur_mask_8(val >> 16); - bytes[fill++] = ur_mask_8(val >> 24); - bytes[fill++] = ur_mask_8(val >> 32); - bytes[fill++] = ur_mask_8(val >> 40); - bytes[fill++] = ur_mask_8(val >> 48); - bytes[fill++] = ur_mask_8(val >> 56); - - // no offset is possible here - // - bsw->fill = fill; - bsw->off = 0; - return; - } - - case 7: { - bytes[fill++] = ur_mask_8(val); - bytes[fill++] = ur_mask_8(val >> 8); - bytes[fill++] = ur_mask_8(val >> 16); - bytes[fill++] = ur_mask_8(val >> 24); - bytes[fill++] = ur_mask_8(val >> 32); - bytes[fill++] = ur_mask_8(val >> 40); - bytes[fill++] = ur_mask_8(val >> 48); - val >>= 56; - } break; - - case 6: { - bytes[fill++] = ur_mask_8(val); - bytes[fill++] = ur_mask_8(val >> 8); - bytes[fill++] = ur_mask_8(val >> 16); - bytes[fill++] = ur_mask_8(val >> 24); - bytes[fill++] = ur_mask_8(val >> 32); - bytes[fill++] = ur_mask_8(val >> 40); - val >>= 48; - } break; - - case 5: { - bytes[fill++] = ur_mask_8(val); - bytes[fill++] = ur_mask_8(val >> 8); - bytes[fill++] = ur_mask_8(val >> 16); - bytes[fill++] = ur_mask_8(val >> 24); - bytes[fill++] = ur_mask_8(val >> 32); - val >>= 40; - } break; - - case 4: { - bytes[fill++] = ur_mask_8(val); - bytes[fill++] = ur_mask_8(val >> 8); - bytes[fill++] = ur_mask_8(val >> 16); - bytes[fill++] = ur_mask_8(val >> 24); - val >>= 32; - } break; - - case 3: { - bytes[fill++] = ur_mask_8(val); - bytes[fill++] = ur_mask_8(val >> 8); - bytes[fill++] = ur_mask_8(val >> 16); - val >>= 24; - } break; - - case 2: { - bytes[fill++] = ur_mask_8(val); - bytes[fill++] = ur_mask_8(val >> 8); - val >>= 16; - } break; - - case 1: { - bytes[fill++] = ur_mask_8(val); - val >>= 8; - } break; - } - - off = ur_mask_3(len); - - if ( off ) { - bytes[fill] = (uint8_t)(val & ((1 << off) - 1)); - } - - bsw->fill = fill; - bsw->off = off; -} - -void -ur_bsw64(ur_bsw_t *bsw, uint8_t len, uint64_t val) -{ - uint8_t bits, need; - - len = ur_min(64, len); - bits = bsw->off + len; - need = (bits >> 3) + !!ur_mask_3(bits); - - if ( bsw->fill + need >= bsw->size ) { - ur_bsw_grow(bsw, ur_max(need, bsw->prev)); - } - - _bsw64_unsafe(bsw, len, val); -} - -static inline void -_bsw_bytes_unsafe(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) -{ - uint64_t len_byt = len >> 3; - uint8_t len_bit = ur_mask_3(len); - uint64_t fill = bsw->fill; - uint8_t off = bsw->off; - - if ( !off ) { - memcpy(bsw->bytes + fill, byt, len_byt); - fill += len_byt; - off = len_bit; - - if ( off ) { - bsw->bytes[fill] = byt[len_byt] & ((1 << off) - 1); - } - } - // the least-significant bits of the input become the - // most-significant bits of a byte in the output stream, and vice-versa - // - else { - uint8_t rest = 8 - off; - uint8_t mask = (1 << rest) - 1; - uint8_t l, m = bsw->bytes[fill]; - uint64_t i; - - for ( i = 0; i < len_byt; i++ ) { - l = byt[i] & mask; - bsw->bytes[fill++] = m ^ (l << off); - m = byt[i] >> rest; - } - - if ( len_bit < rest ) { - l = byt[len_byt] & ((1 << len_bit) - 1); - bsw->bytes[fill] = m ^ (l << off); - off += len_bit; - } - else { - l = byt[len_byt] & mask; - bsw->bytes[fill++] = m ^ (l << off); - - m = byt[len_byt] >> rest; - - off = len_bit - rest; - bsw->bytes[fill] = m & ((1 << off) - 1); - } - } - - bsw->off = off; - bsw->fill = fill; - bsw->bits += len; -} - -void -ur_bsw_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) -{ - uint8_t bits = len + bsw->off; - uint64_t need = (bits >> 3) + !!ur_mask_3(bits); - - if ( bsw->fill + need >= bsw->size ) { - ur_bsw_grow(bsw, ur_max(need, bsw->prev)); - } - - _bsw_bytes_unsafe(bsw, len, byt); -} - -static inline void -_bsw_bex_unsafe(ur_bsw_t *bsw, uint8_t n) -{ - uint64_t fill = bsw->fill; - uint8_t off = bsw->off; - uint32_t bits = n + off; - - fill += bits >> 3; - off = ur_mask_3(bits); - - bsw->bytes[fill] ^= 1 << off; - - if ( 7 == off ) { - bsw->off = 0; - bsw->fill = 1 + fill; - } - else { - bsw->off = 1 + off; - bsw->fill = fill; - } - - bsw->bits += 1 + n; -} - -void -ur_bsw_bex(ur_bsw_t *bsw, uint8_t n) -{ - uint32_t bits = 1 + n + bsw->off; - uint8_t need = (bits >> 3) + !!ur_mask_3(bits); - - if ( bsw->fill + need >= bsw->size ) { - ur_bsw_grow(bsw, ur_max(need, bsw->prev)); - } - - _bsw_bex_unsafe(bsw, n); -} - -static inline void -_bsw_mat64_unsafe(ur_bsw_t *bsw, uint8_t len, uint64_t val) -{ - if ( 0 == len ) { - _bsw_bit_unsafe(bsw, 1); - } - else { - { - uint8_t nel = ur_met0_64(len); - _bsw_bex_unsafe(bsw, nel); - _bsw64_unsafe(bsw, nel - 1, len); - } - - _bsw64_unsafe(bsw, len, val); - } -} - -void -ur_bsw_mat64(ur_bsw_t *bsw, uint8_t len, uint64_t val) -{ - uint8_t next, bits, need; - - len = ur_min(64, len); - next = ( 0 == len ) ? 1 : len + (2 * ur_met0_64(len)); - bits = bsw->off + next; - need = (bits >> 3) + !!ur_mask_3(bits); - - if ( bsw->fill + need >= bsw->size ) { - ur_bsw_grow(bsw, ur_max(need, bsw->prev)); - } - - _bsw_mat64_unsafe(bsw, len, val); -} - -static inline void -_bsw_mat_bytes_unsafe(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) -{ - if ( 0 == len ) { - _bsw_bit_unsafe(bsw, 1); - } - else { - // write run-length - // - { - uint8_t nel = ur_met0_64(len); - _bsw_bex_unsafe(bsw, nel); - _bsw64_unsafe(bsw, nel - 1, len); - } - - _bsw_bytes_unsafe(bsw, len, byt); - } -} - -void -ur_bsw_mat_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) -{ - uint64_t next = ( 0 == len ) ? 1 : len + (2 * ur_met0_64(len)); - uint64_t bits = bsw->off + next; - uint64_t need = (bits >> 3) + !!ur_mask_3(bits); - - if ( bsw->fill + need >= bsw->size ) { - ur_bsw_grow(bsw, ur_max(need, bsw->prev)); - } - - _bsw_mat_bytes_unsafe(bsw, len, byt); -} - -static inline void -_bsw_back64(ur_bsw_t *bsw, uint8_t len, uint64_t val) -{ - _bsw8_unsafe(bsw, 2, 3); - _bsw_mat64_unsafe(bsw, len, val); -} - -void -ur_bsw_back64(ur_bsw_t *bsw, uint8_t len, uint64_t val) -{ - uint64_t next = ( 0 == len ) ? 1 : len + (2 * ur_met0_64(len)); - uint64_t bits = 2 + bsw->off + next; - uint64_t need = (bits >> 3) + !!ur_mask_3(bits); - - if ( bsw->fill + need >= bsw->size ) { - ur_bsw_grow(bsw, ur_max(need, bsw->prev)); - } - - _bsw_back64(bsw, len, val); -} - -static inline void -_bsw_atom64(ur_bsw_t *bsw, uint8_t len, uint64_t val) -{ - _bsw_bit_unsafe(bsw, 0); - _bsw_mat64_unsafe(bsw, len, val); -} - -void -ur_bsw_atom64(ur_bsw_t *bsw, uint8_t len, uint64_t val) -{ - uint64_t next = ( 0 == len ) ? 1 : len + (2 * ur_met0_64(len)); - uint64_t bits = 1 + bsw->off + next; - uint64_t need = (bits >> 3) + !!ur_mask_3(bits); - - if ( bsw->fill + need >= bsw->size ) { - ur_bsw_grow(bsw, ur_max(need, bsw->prev)); - } - - _bsw_atom64(bsw, len, val); -} - -static inline void -_bsw_atom_bytes_unsafe(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) -{ - _bsw_bit_unsafe(bsw, 0); - _bsw_mat_bytes_unsafe(bsw, len, byt); -} - -void -ur_bsw_atom_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) -{ - uint64_t next = ( 0 == len ) ? 1 : len + (2 * ur_met0_64(len)); - uint64_t bits = 1 + bsw->off + next; - uint64_t need = (bits >> 3) + !!ur_mask_3(bits); - - if ( bsw->fill + need >= bsw->size ) { - ur_bsw_grow(bsw, ur_max(need, bsw->prev)); - } - - _bsw_atom_bytes_unsafe(bsw, len, byt); -} - -void -ur_bsw_cell(ur_bsw_t *bsw) -{ - uint8_t bits = 2 + bsw->off; - uint8_t need = (bits >> 3) + !!ur_mask_3(bits); - - if ( bsw->fill + need >= bsw->size ) { - ur_bsw_grow(bsw, ur_max(need, bsw->prev)); - } - - _bsw8_unsafe(bsw, 2, 1); -} - -ur_bool_t -ur_bsr_sane(ur_bsr_t *bsr) -{ - ur_bool_t ret = 8 > bsr->off; - - if ( !bsr->left ) { - ret = ret && (!bsr->off && !bsr->bytes); - } - - return ret; -} - -ur_cue_res_e -ur_bsr_bit(ur_bsr_t *bsr, uint8_t *out) -{ - uint64_t left = bsr->left; - - if ( !left ) { - return ur_cue_gone; - } - else { - const uint8_t *b = bsr->bytes; - uint8_t off = bsr->off; - uint8_t bit = (b[0] >> off) & 1; - - if ( 7 == off ) { - bsr->bytes = ( --left ) ? (b + 1) : 0; - bsr->left = left; - bsr->off = 0; - } - else { - bsr->off = 1 + off; - } - - bsr->bits++; - - *out = bit; - return ur_cue_good; - } -} - -uint8_t -ur_bsr_bit_any(ur_bsr_t *bsr) -{ - uint64_t left = bsr->left; - - bsr->bits++; - - if ( !left ) { - return 0; - } - else { - const uint8_t *b = bsr->bytes; - uint8_t off = bsr->off; - uint8_t bit = (b[0] >> off) & 1; - - if ( 7 == off ) { - bsr->bytes = ( --left ) ? (b + 1) : 0; - bsr->left = left; - bsr->off = 0; - } - else { - bsr->off = 1 + off; - } - - return bit; - } -} - -uint8_t -ur_bsr8_any(ur_bsr_t *bsr, uint8_t len) -{ - uint64_t left = bsr->left; - - len = ur_min(8, len); - - bsr->bits += len; - - if ( !left ) { - return 0; - } - else { - uint8_t off = bsr->off; - uint8_t rest = 8 - off; - const uint8_t *b = bsr->bytes; - uint8_t m = b[0] >> off; - - if ( len < rest ) { - bsr->off = off + len; - return m & ((1 << len) - 1); - } - else if ( 1 == left ) { - bsr->off = 0; - bsr->left = 0; - bsr->bytes = 0; - return m; - } - else { - off = len - rest; - - bsr->off = off; - bsr->left--; - bsr->bytes++; - - { - uint8_t l = b[1] & ((1 << off) - 1); - return m ^ (l << rest); - } - } - } -} - -uint32_t -ur_bsr32_any(ur_bsr_t *bsr, uint8_t len) -{ - uint64_t left = bsr->left; - - len = ur_min(32, len); - - bsr->bits += len; - - if ( !left ) { - return 0; - } - else { - uint8_t off = bsr->off; - uint8_t rest = 8 - off; - const uint8_t *b = bsr->bytes; - uint32_t m = b[0] >> off; - - if ( len < rest ) { - bsr->off = off + len; - return m & ((1 << len) - 1); - } - else { - uint8_t mask, len_byt; - uint32_t l; - - len -= rest; - left--; - bsr->bytes++; - - len_byt = len >> 3; - - if ( len_byt >= left ) { - len_byt = left; - bsr->off = off = 0; - bsr->left = 0; - bsr->bytes = 0; - } - else { - bsr->off = off = ur_mask_3(len); - bsr->left = left - len_byt; - bsr->bytes += len_byt; - } - - mask = (1 << off) - 1; - - switch ( len_byt ) { - case 4: { - l = (uint32_t)b[1] - ^ (uint32_t)b[2] << 8 - ^ (uint32_t)b[3] << 16 - ^ (uint32_t)b[4] << 24; - } break; - - case 3: { - l = (uint32_t)b[1] - ^ (uint32_t)b[2] << 8 - ^ (uint32_t)b[3] << 16 - ^ (uint32_t)(b[4] & mask) << 24; - } break; - - case 2: { - l = (uint32_t)b[1] - ^ (uint32_t)b[2] << 8 - ^ (uint32_t)(b[3] & mask) << 16; - } break; - - case 1: { - l = (uint32_t)b[1] - ^ (uint32_t)(b[2] & mask) << 8; - } break; - - case 0: { - l = (uint32_t)(b[1] & mask); - } break; - } - - return m ^ (l << rest); - } - } -} - -uint64_t -ur_bsr64_any(ur_bsr_t *bsr, uint8_t len) -{ - uint64_t left = bsr->left; - - len = ur_min(64, len); - - bsr->bits += len; - - if ( !left ) { - return 0; - } - else { - uint8_t off = bsr->off; - uint8_t rest = 8 - off; - const uint8_t *b = bsr->bytes; - uint64_t m = b[0] >> off; - - if ( len < rest ) { - bsr->off = off + len; - return m & ((1 << len) - 1); - } - else { - uint8_t mask, len_byt; - uint64_t l; - - len -= rest; - left--; - bsr->bytes++; - - len_byt = len >> 3; - - if ( len_byt >= left ) { - len_byt = left; - bsr->off = off = 0; - bsr->left = 0; - bsr->bytes = 0; - } - else { - bsr->off = off = ur_mask_3(len); - bsr->left = left - len_byt; - bsr->bytes += len_byt; - } - - mask = (1 << off) - 1; - - switch ( len_byt ) { - case 8: { - l = (uint64_t)b[1] - ^ (uint64_t)b[2] << 8 - ^ (uint64_t)b[3] << 16 - ^ (uint64_t)b[4] << 24 - ^ (uint64_t)b[5] << 32 - ^ (uint64_t)b[6] << 40 - ^ (uint64_t)b[7] << 48 - ^ (uint64_t)b[8] << 56; - } break; - - case 7: { - l = (uint64_t)b[1] - ^ (uint64_t)b[2] << 8 - ^ (uint64_t)b[3] << 16 - ^ (uint64_t)b[4] << 24 - ^ (uint64_t)b[5] << 32 - ^ (uint64_t)b[6] << 40 - ^ (uint64_t)b[7] << 48 - ^ (uint64_t)(b[8] & mask) << 56; - } break; - - case 6: { - l = (uint64_t)b[1] - ^ (uint64_t)b[2] << 8 - ^ (uint64_t)b[3] << 16 - ^ (uint64_t)b[4] << 24 - ^ (uint64_t)b[5] << 32 - ^ (uint64_t)b[6] << 40 - ^ (uint64_t)(b[7] & mask) << 48; - } break; - - case 5: { - l = (uint64_t)b[1] - ^ (uint64_t)b[2] << 8 - ^ (uint64_t)b[3] << 16 - ^ (uint64_t)b[4] << 24 - ^ (uint64_t)b[5] << 32 - ^ (uint64_t)(b[6] & mask) << 40; - } break; - - case 4: { - l = (uint64_t)b[1] - ^ (uint64_t)b[2] << 8 - ^ (uint64_t)b[3] << 16 - ^ (uint64_t)b[4] << 24 - ^ (uint64_t)(b[5] & mask) << 32; - } break; - - case 3: { - l = (uint64_t)b[1] - ^ (uint64_t)b[2] << 8 - ^ (uint64_t)b[3] << 16 - ^ (uint64_t)(b[4] & mask) << 24; - } break; - - case 2: { - l = (uint64_t)b[1] - ^ (uint64_t)b[2] << 8 - ^ (uint64_t)(b[3] & mask) << 16; - } break; - - case 1: { - l = (uint64_t)b[1] - ^ (uint64_t)(b[2] & mask) << 8; - } break; - - case 0: { - l = (uint64_t)(b[1] & mask); - } break; - } - - return m ^ (l << rest); - } - } -} - -void -ur_bsr_bytes_any(ur_bsr_t *bsr, uint64_t len, uint8_t *out) -{ - uint64_t left = bsr->left; - - if ( !left ) { - return; - } - else { - const uint8_t *b = bsr->bytes; - uint8_t off = bsr->off; - uint64_t len_byt = len >> 3; - uint8_t len_bit = ur_mask_3(len); - - if ( !off ) { - uint8_t bits = off + len_bit; - uint64_t need = len_byt + (bits >> 3) + !!ur_mask_3(bits); - - if ( need > left ) { - memcpy(out, b, left); - bsr->bytes = 0; - bsr->left = 0; - } - else { - memcpy(out, b, len_byt); - off = len_bit; - left -= len_byt; - - if ( !left ) { - bsr->bytes = 0; - } - else { - bsr->bytes += len_byt; - } - - bsr->left = left; - - if ( off ) { - out[len_byt] = b[len_byt] & ((1 << off) - 1); - } - } - } - // the most-significant bits from a byte in the stream - // become the least-significant bits of an output byte, and vice-versa - // - else { - uint64_t need = len_byt + (len_bit >> 3) + !!ur_mask_3(len_bit); - ur_bool_t end = need >= left; - uint64_t max = end ? (left - 1) : len_byt; - uint8_t rest = 8 - off; - uint8_t mask = (1 << off) - 1; - uint8_t byt = b[0]; - uint8_t l, m = byt >> off; - uint64_t i; - - for ( i = 0; i < max; i++ ) { - byt = b[1ULL + i]; - l = byt & mask; - out[i] = m ^ (l << rest); - m = byt >> off; - } - - if ( end ) { - if ( len_bit && len_bit < rest ) { - out[max] = m & ((1 << len_bit) - 1); - bsr->bytes += max; - left -= max; - off += len_bit; - } - else { - out[max] = m; - bsr->bytes = 0; - left = 0; - off = 0; - } - } - else { - uint8_t bits = off + len_bit; - - bsr->bytes += max; - left -= max + !!(bits >> 3); - off = ur_mask_3(bits); - - if ( len_bit <= rest ) { - out[max] = m & ((1 << len_bit) - 1); - } - else { - l = b[1ULL + max] & ((1 << off) - 1);; - out[max] = m ^ (l << rest); - } - } - } - - bsr->off = off; - bsr->left = left; - bsr->bits += len; - } -} - -static inline ur_cue_res_e -_bsr_set_gone(ur_bsr_t *bsr, uint8_t bits) -{ - bsr->bits += bits; - bsr->bytes = 0; - bsr->left = 0; - bsr->off = 0; - return ur_cue_gone; -} - -ur_cue_res_e -ur_bsr_tag(ur_bsr_t *bsr, ur_cue_tag_e *out) -{ - uint64_t left = bsr->left; - - if ( !left ) { - return ur_cue_gone; - } - else { - const uint8_t *b = bsr->bytes; - uint8_t off = bsr->off; - uint8_t bit = (b[0] >> off) & 1; - uint8_t len = 1; - - if ( 0 == bit ) { - *out = ur_jam_atom; - } - else { - if ( 7 == off ) { - if ( 1 == left ) { - return _bsr_set_gone(bsr, 1); - } - - bit = b[1] & 1; - } - else { - bit = (b[0] >> (off + 1)) & 1; - } - - len++; - *out = ( 0 == bit ) ? ur_jam_cell : ur_jam_back; - } - - { - uint8_t bits = off + len; - uint8_t bytes = bits >> 3; - - left -= bytes; - - if ( !left ) { - bsr->bytes = 0; - bsr->left = 0; - bsr->off = 0; - } - else { - bsr->bytes += bytes; - bsr->left = left; - bsr->off = ur_mask_3(bits); - } - - bsr->bits += len; - - return ur_cue_good; - } - } -} - -static inline ur_cue_res_e -_bsr_rub_log_meme(ur_bsr_t *bsr) -{ - bsr->bits += 256; - bsr->bytes += 32; - bsr->left -= 32; - return ur_cue_meme; -} - -ur_cue_res_e -ur_bsr_rub_log(ur_bsr_t *bsr, uint8_t *out) -{ - uint64_t left = bsr->left; - - if ( !left ) { - return ur_cue_gone; - } - else { - uint8_t off = bsr->off; - uint8_t rest = 8 - off; - const uint8_t *b = bsr->bytes; - uint8_t byt = b[0] >> off; - uint8_t skip = 0; - - while ( !byt ) { - if ( 32 == skip ) { - return _bsr_rub_log_meme(bsr); - } - - skip++; - - if ( skip == left ) { - return _bsr_set_gone(bsr, (skip << 3) - off); - } - - byt = b[skip]; - } - - { - uint32_t zeros = ur_tz8(byt) + (skip ? ((skip << 3) - off) : 0); - - if ( 255 < zeros ) { - return _bsr_rub_log_meme(bsr); - } - else { - uint32_t bits = off + 1 + zeros; - uint8_t bytes = bits >> 3; - - left -= bytes; - - bsr->bytes = left ? (b + bytes) : 0; - bsr->bits += 1 + zeros; - bsr->left = left; - bsr->off = ur_mask_3(bits); - - *out = zeros; - return ur_cue_good; - } - } - } -} - -ur_cue_res_e -ur_bsr_rub_len(ur_bsr_t *bsr, uint64_t *out) -{ - ur_cue_res_e res; - uint8_t len; - - if ( ur_cue_good != (res = ur_bsr_rub_log(bsr, &len)) ) { - return res; - } - else if ( 64 <= len ) { - return ur_cue_meme; - } - - switch ( len ) { - case 0: { - *out = 0; - } break; - - case 1: { - *out = 1; - } break; - - default: { - len--; - *out = ur_bsr64_any(bsr, len) ^ (1ULL << len); - } break; - } - - return ur_cue_good; -} - -static inline void -_bsw_atom(ur_root_t *r, ur_nref ref, ur_bsw_t *bsw, uint64_t len) -{ - switch ( ur_nref_tag(ref) ) { - default: assert(0); - - case ur_direct: return ur_bsw_atom64(bsw, len, ref); - - case ur_iatom: { - uint8_t *byt = r->atoms.bytes[ur_nref_idx(ref)]; - return ur_bsw_atom_bytes(bsw, len, byt); - } - } -} - -typedef struct _jam_s { - ur_dict64_t dict; - ur_bsw_t bsw; -} _jam_t; - -static void -_jam_atom(ur_root_t *r, ur_nref ref, void *ptr) -{ - _jam_t *j = ptr; - ur_dict64_t *dict = &(j->dict); - ur_bsw_t *bsw = &j->bsw; - uint64_t bak, len = ur_met(r, 0, ref); - - if ( !ur_dict64_get(r, dict, ref, &bak) ) { - ur_dict64_put(r, dict, ref, bsw->bits); - - _bsw_atom(r, ref, bsw, len); - } - else { - uint64_t len_bak = ur_met0_64(bak); - - if ( len <= len_bak ) { - _bsw_atom(r, ref, bsw, len); - } - else { - ur_bsw_back64(bsw, len_bak, bak); - } - } -} - -static ur_bool_t -_jam_cell(ur_root_t *r, ur_nref ref, void *ptr) -{ - _jam_t *j = ptr; - ur_dict64_t *dict = &(j->dict); - ur_bsw_t *bsw = &j->bsw; - uint64_t bak; - - if ( !ur_dict64_get(r, dict, ref, &bak) ) { - ur_dict64_put(r, dict, ref, bsw->bits); - - ur_bsw_cell(bsw); - return 1; - } - else { - ur_bsw_back64(bsw, ur_met0_64(bak), bak); - return 0; - } -} - -uint64_t -ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt) -{ - _jam_t j = {0}; - { - uint64_t fib11 = 89, fib12 = 144; - - j.bsw.prev = fib11; - j.bsw.size = fib12; - j.bsw.bytes = calloc(j.bsw.size, 1); - - ur_dict64_grow(r, &j.dict, fib11, fib12); - } - - ur_walk_fore(r, ref, &j, _jam_atom, _jam_cell); - ur_dict_free((ur_dict_t*)&j.dict); - - *len = j.bsw.fill + !!j.bsw.off; - *byt = j.bsw.bytes; - - return j.bsw.bits; -} - -typedef struct _cue_s { - ur_dict64_t dict; - ur_bsr_t bsr; -} _cue_t; - -static inline ur_cue_res_e -_cue_atom(ur_root_t *r, _cue_t *c, ur_nref *out) -{ - ur_bsr_t *bsr = &c->bsr; - ur_cue_res_e res; - uint64_t len; - - if ( ur_cue_good != (res = ur_bsr_rub_len(bsr, &len)) ) { - return res; - } - - if ( 62 >= len ) { - *out = (ur_nref)ur_bsr64_any(bsr, len); - } - else { - uint64_t len_byt = (len >> 3) + !!ur_mask_3(len); - uint8_t *byt = calloc(len_byt, 1); - ur_bsr_bytes_any(bsr, len, byt); - - // strip trailing zeroes - // - while ( len_byt && !byt[len_byt - 1] ) { - len_byt--; - } - - *out = _coin_bytes_unsafe(r, byt, len_byt); - } - - return ur_cue_good; -} - -static inline ur_cue_res_e -_cue_back(ur_bsr_t *bsr, uint64_t *out) -{ - ur_cue_res_e res; - uint64_t len; - - if ( ur_cue_good != (res = ur_bsr_rub_len(bsr, &len)) ) { - return res; - } - else if ( 62 < len ) { - return ur_cue_meme; - } - - *out = ur_bsr64_any(bsr, len); - return ur_cue_good; -} - -#define STACK_ROOT 0 -#define STACK_HEAD 1 -#define STACK_TAIL 2 - -// stack frame for recording head vs tail iteration -// -// In Hoon, this structure would be as follows: -// -// $% [%root ~] -// [%head cursor=@] -// [%tail cursor=@ hed-ref=*] -// == -// -typedef struct _cue_frame_s { - uint8_t tag; - uint64_t bits; - ur_nref ref; -} _cue_frame_t; - -typedef struct _cue_stack_s { - uint32_t prev; - uint32_t size; - uint32_t fill; - _cue_frame_t* f; -} _cue_stack_t; - -static inline void -_cue_stack_push(_cue_stack_t *s, uint8_t tag, uint64_t bits, ur_nref ref) -{ - if ( s->fill == s->size ) { - uint32_t next = s->prev + s->size; - s->f = realloc(s->f, next * sizeof(*s->f)); - s->prev = s->size; - s->size = next; - } - - _cue_frame_t* f = &(s->f[s->fill++]); - f->tag = tag; - f->bits = bits; - f->ref = ref; -} - -ur_cue_res_e -ur_cue(ur_root_t *r, uint64_t len, const uint8_t *byt, ur_nref *out) -{ - ur_cue_res_e res; - ur_nref ref; - _cue_t c = {0}; - _cue_stack_t s = { .prev = 89, .size = 144, .fill = 0, .f = 0 }; - - // init bitstream-reader - // - c.bsr.left = len; - c.bsr.bytes = byt; - - // init dictionary - // - { - uint64_t fib11 = 89, fib12 = 144; - ur_dict64_grow(r, &c.dict, fib11, fib12); - } - - // setup stack - // - s.f = malloc(s.size * sizeof(*s.f)); - _cue_stack_push(&s, STACK_ROOT, 0, 0); - - // advance into buffer - // - advance: { - uint64_t bits = c.bsr.bits; - ur_cue_tag_e tag; - - if ( ur_cue_good != (res = ur_bsr_tag(&c.bsr, &tag)) ) { - goto perfect; - } - - switch ( tag ) { - default: assert(0); - - case ur_jam_atom: { - if ( ur_cue_good != (res = _cue_atom(r, &c, &ref)) ) { - goto perfect; - } - else { - ur_dict64_put(r, &c.dict, bits, (uint64_t)ref); - goto retreat; - } - } - - case ur_jam_back: { - uint64_t bak, val; - - if ( ur_cue_good != (res = _cue_back(&c.bsr, &bak)) ) { - goto perfect; - } - else if ( !ur_dict64_get(r, &c.dict, bak, &val) ) { - // XX distinguish bad backref? - // - res = ur_cue_gone; - goto perfect; - } - - ref = (ur_nref)val; - goto retreat; - } - - case ur_jam_cell: { - _cue_stack_push(&s, STACK_HEAD, bits, 0); - goto advance; - } - } - } - - // retreat down the stack - // - retreat: { - _cue_frame_t f = s.f[--s.fill]; - - switch ( f.tag ) { - default: assert(0); - - case STACK_ROOT: { - res = ur_cue_good; - goto perfect; - } - - case STACK_HEAD: { - _cue_stack_push(&s, STACK_TAIL, f.bits, ref); - goto advance; - } - - case STACK_TAIL: { - ref = ur_cons(r, f.ref, ref); - ur_dict64_put(r, &c.dict, f.bits, (uint64_t)ref); - goto retreat; - } - } - } - - // we done - // - perfect: { - ur_dict_free((ur_dict_t*)&c.dict); - free(s.f); - - if ( ur_cue_good == res ) { - *out = ref; - } - - return res; - } -} diff --git a/pkg/urbit/ur/serial.c b/pkg/urbit/ur/serial.c new file mode 100644 index 0000000000..bfcc859914 --- /dev/null +++ b/pkg/urbit/ur/serial.c @@ -0,0 +1,299 @@ +#include +#include + +#include "ur/ur.h" + +static inline void +_bsw_atom(ur_root_t *r, ur_nref ref, ur_bsw_t *bsw, uint64_t len) +{ + switch ( ur_nref_tag(ref) ) { + default: assert(0); + + case ur_direct: return ur_bsw_atom64(bsw, len, ref); + + case ur_iatom: { + uint8_t *byt = r->atoms.bytes[ur_nref_idx(ref)]; + return ur_bsw_atom_bytes(bsw, len, byt); + } + } +} + +typedef struct _jam_s { + ur_dict64_t dict; + ur_bsw_t bsw; +} _jam_t; + +static void +_jam_atom(ur_root_t *r, ur_nref ref, void *ptr) +{ + _jam_t *j = ptr; + ur_dict64_t *dict = &(j->dict); + ur_bsw_t *bsw = &j->bsw; + uint64_t bak, len = ur_met(r, 0, ref); + + if ( !ur_dict64_get(r, dict, ref, &bak) ) { + ur_dict64_put(r, dict, ref, bsw->bits); + + _bsw_atom(r, ref, bsw, len); + } + else { + uint64_t len_bak = ur_met0_64(bak); + + if ( len <= len_bak ) { + _bsw_atom(r, ref, bsw, len); + } + else { + ur_bsw_back64(bsw, len_bak, bak); + } + } +} + +static ur_bool_t +_jam_cell(ur_root_t *r, ur_nref ref, void *ptr) +{ + _jam_t *j = ptr; + ur_dict64_t *dict = &(j->dict); + ur_bsw_t *bsw = &j->bsw; + uint64_t bak; + + if ( !ur_dict64_get(r, dict, ref, &bak) ) { + ur_dict64_put(r, dict, ref, bsw->bits); + + ur_bsw_cell(bsw); + return 1; + } + else { + ur_bsw_back64(bsw, ur_met0_64(bak), bak); + return 0; + } +} + +uint64_t +ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt) +{ + _jam_t j = {0}; + { + uint64_t fib11 = 89, fib12 = 144; + + j.bsw.prev = fib11; + j.bsw.size = fib12; + j.bsw.bytes = calloc(j.bsw.size, 1); + + ur_dict64_grow(r, &j.dict, fib11, fib12); + } + + ur_walk_fore(r, ref, &j, _jam_atom, _jam_cell); + ur_dict_free((ur_dict_t*)&j.dict); + + *len = j.bsw.fill + !!j.bsw.off; + *byt = j.bsw.bytes; + + return j.bsw.bits; +} + +typedef struct _cue_s { + ur_dict64_t dict; + ur_bsr_t bsr; +} _cue_t; + +static inline ur_cue_res_e +_cue_atom(ur_root_t *r, _cue_t *c, ur_nref *out) +{ + ur_bsr_t *bsr = &c->bsr; + ur_cue_res_e res; + uint64_t len; + + if ( ur_cue_good != (res = ur_bsr_rub_len(bsr, &len)) ) { + return res; + } + + if ( 62 >= len ) { + *out = (ur_nref)ur_bsr64_any(bsr, len); + } + else { + uint64_t len_byt = (len >> 3) + !!ur_mask_3(len); + uint8_t *byt = calloc(len_byt, 1); + ur_bsr_bytes_any(bsr, len, byt); + + // strip trailing zeroes + // + while ( len_byt && !byt[len_byt - 1] ) { + len_byt--; + } + + *out = ur_coin_bytes_unsafe(r, byt, len_byt); + } + + return ur_cue_good; +} + +static inline ur_cue_res_e +_cue_back(ur_bsr_t *bsr, uint64_t *out) +{ + ur_cue_res_e res; + uint64_t len; + + if ( ur_cue_good != (res = ur_bsr_rub_len(bsr, &len)) ) { + return res; + } + else if ( 62 < len ) { + return ur_cue_meme; + } + + *out = ur_bsr64_any(bsr, len); + return ur_cue_good; +} + +#define STACK_ROOT 0 +#define STACK_HEAD 1 +#define STACK_TAIL 2 + +// stack frame for recording head vs tail iteration +// +// In Hoon, this structure would be as follows: +// +// $% [%root ~] +// [%head cursor=@] +// [%tail cursor=@ hed-ref=*] +// == +// +typedef struct _cue_frame_s { + uint8_t tag; + uint64_t bits; + ur_nref ref; +} _cue_frame_t; + +typedef struct _cue_stack_s { + uint32_t prev; + uint32_t size; + uint32_t fill; + _cue_frame_t* f; +} _cue_stack_t; + +static inline void +_cue_stack_push(_cue_stack_t *s, uint8_t tag, uint64_t bits, ur_nref ref) +{ + if ( s->fill == s->size ) { + uint32_t next = s->prev + s->size; + s->f = realloc(s->f, next * sizeof(*s->f)); + s->prev = s->size; + s->size = next; + } + + _cue_frame_t* f = &(s->f[s->fill++]); + f->tag = tag; + f->bits = bits; + f->ref = ref; +} + +ur_cue_res_e +ur_cue(ur_root_t *r, uint64_t len, const uint8_t *byt, ur_nref *out) +{ + ur_cue_res_e res; + ur_nref ref; + _cue_t c = {0}; + _cue_stack_t s = { .prev = 89, .size = 144, .fill = 0, .f = 0 }; + + // init bitstream-reader + // + c.bsr.left = len; + c.bsr.bytes = byt; + + // init dictionary + // + { + uint64_t fib11 = 89, fib12 = 144; + ur_dict64_grow(r, &c.dict, fib11, fib12); + } + + // setup stack + // + s.f = malloc(s.size * sizeof(*s.f)); + _cue_stack_push(&s, STACK_ROOT, 0, 0); + + // advance into buffer + // + advance: { + uint64_t bits = c.bsr.bits; + ur_cue_tag_e tag; + + if ( ur_cue_good != (res = ur_bsr_tag(&c.bsr, &tag)) ) { + goto perfect; + } + + switch ( tag ) { + default: assert(0); + + case ur_jam_atom: { + if ( ur_cue_good != (res = _cue_atom(r, &c, &ref)) ) { + goto perfect; + } + else { + ur_dict64_put(r, &c.dict, bits, (uint64_t)ref); + goto retreat; + } + } + + case ur_jam_back: { + uint64_t bak, val; + + if ( ur_cue_good != (res = _cue_back(&c.bsr, &bak)) ) { + goto perfect; + } + else if ( !ur_dict64_get(r, &c.dict, bak, &val) ) { + // XX distinguish bad backref? + // + res = ur_cue_gone; + goto perfect; + } + + ref = (ur_nref)val; + goto retreat; + } + + case ur_jam_cell: { + _cue_stack_push(&s, STACK_HEAD, bits, 0); + goto advance; + } + } + } + + // retreat down the stack + // + retreat: { + _cue_frame_t f = s.f[--s.fill]; + + switch ( f.tag ) { + default: assert(0); + + case STACK_ROOT: { + res = ur_cue_good; + goto perfect; + } + + case STACK_HEAD: { + _cue_stack_push(&s, STACK_TAIL, f.bits, ref); + goto advance; + } + + case STACK_TAIL: { + ref = ur_cons(r, f.ref, ref); + ur_dict64_put(r, &c.dict, f.bits, (uint64_t)ref); + goto retreat; + } + } + } + + // we done + // + perfect: { + ur_dict_free((ur_dict_t*)&c.dict); + free(s.f); + + if ( ur_cue_good == res ) { + *out = ref; + } + + return res; + } +} From 9c008c269b6e57ee6e8c08dbee98131c62a88883 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 24 Aug 2020 13:28:22 -0700 Subject: [PATCH 209/933] u3: refactors u3u_uniq() --- pkg/urbit/include/noun/events.h | 11 +++ pkg/urbit/noun/events.c | 22 +++++ pkg/urbit/noun/urth.c | 150 ++++++++++++++++++++------------ 3 files changed, 126 insertions(+), 57 deletions(-) diff --git a/pkg/urbit/include/noun/events.h b/pkg/urbit/include/noun/events.h index 965548a1fb..67729118f8 100644 --- a/pkg/urbit/include/noun/events.h +++ b/pkg/urbit/include/noun/events.h @@ -97,3 +97,14 @@ */ c3_o u3e_wipe(void); + + + /* u3e_yolo(): disable dirty page tracking, read/write whole loom. + */ + c3_o + u3e_yolo(void); + + /* u3e_foul(): dirty all the pages of the loom. + */ + void + u3e_foul(void); diff --git a/pkg/urbit/noun/events.c b/pkg/urbit/noun/events.c index 289c30d399..1e1fa6b815 100644 --- a/pkg/urbit/noun/events.c +++ b/pkg/urbit/noun/events.c @@ -995,3 +995,25 @@ u3e_wipe(void) return c3y; } + +/* u3e_yolo(): disable dirty page tracking, read/write whole loom. +*/ +c3_o +u3e_yolo(void) +{ + // NB: u3e_save() will reinstate protection flags + // + if ( 0 != mprotect((void *)u3_Loom, u3a_bytes, (PROT_READ | PROT_WRITE)) ) { + return c3n; + } + + return c3y; +} + +/* u3e_foul(): dirty all the pages of the loom. +*/ +void +u3e_foul(void) +{ + memset((void*)u3P.dit_w, 0xff, u3a_pages >> 3); +} diff --git a/pkg/urbit/noun/urth.c b/pkg/urbit/noun/urth.c index aa3557bd12..142d5a0467 100644 --- a/pkg/urbit/noun/urth.c +++ b/pkg/urbit/noun/urth.c @@ -221,6 +221,23 @@ _cu_hamt_walk(u3_noun kev, void* ptr) vec_u->refs[vec_u->fill++] = _cu_from_loom(rot_u, kev); } +/* _cu_all_from_loom(): reallocate essential persistent state off-loom. +** +** NB: destroys the loom. +*/ +static ur_nref +_cu_all_from_loom(ur_root_t* rot_u, ur_nvec_t* cod_u) +{ + ur_nref ken = _cu_from_loom(rot_u, u3A->roc); + c3_w cod_w = u3h_wyt(u3R->jed.cod_p); + _cu_vec dat_u = { .vec_u = cod_u, .rot_u = rot_u }; + + ur_nvec_init(cod_u, cod_w); + u3h_walk_with(u3R->jed.cod_p, _cu_hamt_walk, &dat_u); + + return ken; +} + typedef struct _cu_loom_s { ur_dict32_t map_u; // direct->indirect mapping u3_atom *vat; // indirect atoms @@ -312,43 +329,72 @@ _cu_cells_to_loom(ur_root_t* rot_u, _cu_loom* lom_u) } } -/* u3u_uniq(): hash-cons roots off-loom, reallocate on loom. +/* _cu_all_to_loom(): reallocate all of [rot_u] on the loom, restore roots. */ -void -u3u_uniq(void) +static void +_cu_all_to_loom(ur_root_t* rot_u, ur_nref ken, ur_nvec_t* cod_u) { - c3_assert( &(u3H->rod_u) == u3R ); + _cu_loom lom_u = {0}; + ur_dict32_grow(0, &lom_u.map_u, 89, 144); - // allow read/write on the whole loom, bypassing page tracking + _cu_atoms_to_loom(rot_u, &lom_u); + _cu_cells_to_loom(rot_u, &lom_u); + + // restore kernel reference (always a cell) // - // NB: u3e_save() will reinstate protection flags + u3A->roc = lom_u.cel[ur_nref_idx(ken)]; + + // restore cold jet state (always cells) // - if ( 0 != mprotect((void *)u3_Loom, u3a_bytes, (PROT_READ | PROT_WRITE)) ) { - c3_assert(0); + { + c3_d max_d = cod_u->fill; + c3_d i_d; + ur_nref ref; + u3_noun kev; + + for ( i_d = 0; i_d < max_d; i_d++) { + ref = cod_u->refs[i_d]; + kev = lom_u.cel[ur_nref_idx(ref)]; + u3h_put(u3R->jed.cod_p, u3h(kev), u3k(u3t(kev))); + u3z(kev); + } + } + + _cu_loom_free(&lom_u); +} + +/* _cu_realloc(): hash-cons roots off-loom, reallocate on loom. +*/ +static ur_nref +_cu_realloc(FILE* fil_u, ur_root_t** tor_u, ur_nvec_t* doc_u) +{ + // bypassing page tracking as an optimization + // + // NB: u3e_yolo() will mark all as dirty, and + // u3e_save() will reinstate protection flags + // + if ( c3n == u3e_yolo() ) { + if ( fil_u ) { + fprintf(fil_u, "uniq: unable to bypass page tracking, continuing\r\n"); + } } // stash event number // c3_d eve_d = u3A->ent_d; - // reallocate kernel and cold jet state // ur_root_t* rot_u = ur_hcon_init(); - ur_nref ken = _cu_from_loom(rot_u, u3A->roc); - - ur_nvec_t cod_u; - { - c3_w cod_w = u3h_wyt(u3R->jed.cod_p); - _cu_vec dat_u = { .vec_u = &cod_u, .rot_u = rot_u }; - ur_nvec_init(&cod_u, cod_w); - u3h_walk_with(u3R->jed.cod_p, _cu_hamt_walk, &dat_u); - } + ur_nvec_t cod_u; + ur_nref ken = _cu_all_from_loom(rot_u, &cod_u); // print [rot_u] measurements // - ur_hcon_info(stderr, rot_u); - fprintf(stderr, "\r\n"); + if ( fil_u ) { + ur_hcon_info(fil_u, rot_u); + fprintf(stderr, "\r\n"); + } // reinitialize loom // @@ -356,43 +402,9 @@ u3u_uniq(void) // u3m_pave(c3y, c3n); - { - // reallocate all nouns on the loom - // - _cu_loom lom_u = {0}; - - ur_dict32_grow(0, &lom_u.map_u, 89, 144); - - _cu_atoms_to_loom(rot_u, &lom_u); - _cu_cells_to_loom(rot_u, &lom_u); - - // restore kernel reference (always a cell) - // - u3A->roc = lom_u.cel[ur_nref_idx(ken)]; - - // restore cold jet state (always cells) - // - { - c3_d max_d = cod_u.fill; - c3_d i_d; - ur_nref ref; - u3_noun kev; - - for ( i_d = 0; i_d < max_d; i_d++) { - ref = cod_u.refs[i_d]; - kev = lom_u.cel[ur_nref_idx(ref)]; - u3h_put(u3R->jed.cod_p, u3h(kev), u3k(u3t(kev))); - u3z(kev); - } - } - - _cu_loom_free(&lom_u); - } - - // dispose off-loom structures + // reallocate all nouns on the loom // - ur_nvec_free(&cod_u); - ur_hcon_free(rot_u); + _cu_all_to_loom(rot_u, ken, &cod_u); // allocate new hot jet state; re-establish warm // @@ -405,5 +417,29 @@ u3u_uniq(void) // mark all pages dirty // - memset((void*)u3P.dit_w, 0xff, u3a_pages >> 3); + u3e_foul(); + + *tor_u = rot_u; + *doc_u = cod_u; + + return ken; +} + +/* u3u_uniq(): hash-cons roots off-loom, reallocate on loom. +*/ +void +u3u_uniq(void) +{ + ur_root_t* rot_u; + ur_nvec_t cod_u; + ur_nref ken; + + c3_assert( &(u3H->rod_u) == u3R ); + + ken = _cu_realloc(stderr, &rot_u, &cod_u); + + // dispose off-loom structures + // + ur_nvec_free(&cod_u); + ur_hcon_free(rot_u); } From 5dca7bd62070bf4d113766b789b8d821fad2c6b9 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 24 Aug 2020 16:59:12 -0700 Subject: [PATCH 210/933] u3: implements u3u_cram() --- pkg/urbit/include/noun/urth.h | 5 + pkg/urbit/noun/urth.c | 172 +++++++++++++++++++++++++++++++++- pkg/urbit/worker/main.c | 15 ++- 3 files changed, 188 insertions(+), 4 deletions(-) diff --git a/pkg/urbit/include/noun/urth.h b/pkg/urbit/include/noun/urth.h index d777debc5e..988920e602 100644 --- a/pkg/urbit/include/noun/urth.h +++ b/pkg/urbit/include/noun/urth.h @@ -6,3 +6,8 @@ */ void u3u_uniq(void); + + /* u3u_cram(): globably deduplicate memory, and write a rock to disk. + */ + c3_o + u3u_cram(c3_c* dir_c, c3_d eve_d); diff --git a/pkg/urbit/noun/urth.c b/pkg/urbit/noun/urth.c index 142d5a0467..adfd8c7dc1 100644 --- a/pkg/urbit/noun/urth.c +++ b/pkg/urbit/noun/urth.c @@ -7,7 +7,7 @@ #include #include "all.h" -#include "ur/hashcons.h" +#include "ur/ur.h" /* _cu_met_3(): atom bytewidth a la u3r_met(3, ...) */ @@ -443,3 +443,173 @@ u3u_uniq(void) ur_nvec_free(&cod_u); ur_hcon_free(rot_u); } + +static c3_o +_cu_rock_save(c3_c* dir_c, c3_d eve_d, c3_d len_d, c3_y* byt_y) +{ + c3_i fid_i; + + // open rock file, creating the containing directory if necessary + // + { + c3_w nam_w = 1 + snprintf(0, 0, "%s/.urb/roc/%" PRIu64 ".jam", dir_c, eve_d); + c3_c* nam_c = c3_malloc(nam_w); + c3_i ret_i; + + // create $pier/.urb/roc, if it doesn't exist + // + // NB, $pier/.urb is guaranteed to already exist + // + { + ret_i = snprintf(nam_c, nam_w, "%s/.urb/roc", dir_c); + + if ( ret_i < 0 ) { + fprintf(stderr, "rock: path format failed (%s, %" PRIu64 "): %s\r\n", + dir_c, eve_d, strerror(errno)); + c3_free(nam_c); + return c3n; + } + else if ( ret_i >= nam_w ) { + fprintf(stderr, "rock: path format failed (%s, %" PRIu64 "): truncated\r\n", + dir_c, eve_d); + c3_free(nam_c); + return c3n; + } + + if ( mkdir(nam_c, 0700) + && (EEXIST != errno) ) + { + fprintf(stderr, "rock: directory create failed (%s, %" PRIu64 "): %s\r\n", + dir_c, eve_d, strerror(errno)); + c3_free(nam_c); + return c3n; + } + } + + ret_i = snprintf(nam_c, nam_w, "%s/.urb/roc/%" PRIu64 ".jam", dir_c, eve_d); + + if ( ret_i < 0 ) { + fprintf(stderr, "rock: path format failed (%s, %" PRIu64 "): %s\r\n", + dir_c, eve_d, strerror(errno)); + c3_free(nam_c); + return c3n; + } + else if ( ret_i >= nam_w ) { + fprintf(stderr, "rock: path format failed (%s, %" PRIu64 "): truncated\r\n", + dir_c, eve_d); + c3_free(nam_c); + return c3n; + } + + if ( -1 == (fid_i = open(nam_c, O_RDWR | O_CREAT | O_TRUNC, 0644)) ) { + fprintf(stderr, "rock: open failed (%s, %" PRIu64 "): %s\r\n", + dir_c, eve_d, strerror(errno)); + c3_free(nam_c); + return c3n; + } + + c3_free(nam_c); + } + + // write jam-buffer into [fid_i] + // + // XX deduplicate with _write() wrapper in term.c + // + { + ssize_t ret_i; + + while ( len_d > 0 ) { + c3_w lop_w = 0; + // retry interrupt/async errors + // + do { + // abort pathological retry loop + // + if ( 100 == ++lop_w ) { + fprintf(stderr, "rock: write loop: %s\r\n", strerror(errno)); + close(fid_i); + // XX unlink file? + // + return c3n; + } + + ret_i = write(fid_i, byt_y, len_d); + } + while ( (ret_i < 0) + && ( (errno == EINTR) + || (errno == EAGAIN) + || (errno == EWOULDBLOCK) )); + + // assert on true errors + // + // NB: can't call u3l_log here or we would re-enter _write() + // + if ( ret_i < 0 ) { + fprintf(stderr, "rock: write failed %s\r\n", strerror(errno)); + close(fid_i); + // XX unlink file? + // + return c3n; + } + // continue partial writes + // + else { + len_d -= ret_i; + byt_y += ret_i; + } + } + } + + close(fid_i); + + return c3y; +} + +/* u3u_cram(): globably deduplicate memory, and write a rock to disk. +*/ +c3_o +u3u_cram(c3_c* dir_c, c3_d eve_d) +{ + c3_o ret_o = c3y; + c3_d len_d; + c3_y* byt_y; + + c3_assert( &(u3H->rod_u) == u3R ); + + { + ur_root_t* rot_u; + ur_nvec_t cod_u; + ur_nref ken = _cu_realloc(stderr, &rot_u, &cod_u); + + { + ur_nref roc = u3_nul; + c3_d max_d = cod_u.fill; + c3_d i_d; + + // cons vector of cold jet-state entries onto a list + // + for ( i_d = 0; i_d < max_d; i_d++) { + roc = ur_cons(rot_u, cod_u.refs[i_d], roc); + } + + roc = ur_cons(rot_u, ur_coin64(rot_u, c3__fast), ur_cons(rot_u, ken, roc)); + + ur_jam(rot_u, roc, &len_d, &byt_y); + } + + // dispose off-loom structures + // + ur_nvec_free(&cod_u); + ur_hcon_free(rot_u); + } + + // write jam-buffer into pier + // + if ( c3n == _cu_rock_save(dir_c, eve_d, len_d, byt_y) ) { + ret_o = c3n; + } + + c3_free(byt_y); + + return ret_o; +} diff --git a/pkg/urbit/worker/main.c b/pkg/urbit/worker/main.c index 76eba3004e..8cd196a0ac 100644 --- a/pkg/urbit/worker/main.c +++ b/pkg/urbit/worker/main.c @@ -251,15 +251,24 @@ _cw_cram(c3_i argc, c3_c* argv[]) c3_c* dir_c = argv[2]; c3_d eve_d = u3m_boot(dir_c); + c3_o ret_o; fprintf(stderr, "urbit-worker: cram: preparing\r\n"); - if ( c3n == u3m_rock_stay(dir_c, eve_d) ) { + if ( c3n == (ret_o = u3u_cram(dir_c, eve_d)) ) { fprintf(stderr, "urbit-worker: cram: unable to jam state\r\n"); - exit(1); + } + else { + fprintf(stderr, "urbit-worker: cram: rock saved at event %" PRIu64 "\r\n", eve_d); } - fprintf(stderr, "urbit-worker: cram: rock saved at event %" PRIu64 "\r\n", eve_d); + // save even on failure, as we just did all the work of deduplication + // + u3e_save(); + + if ( c3n == ret_o ) { + exit(1); + } } /* _cw_queu(); cue rock, save, and exit. From 8d5adc8bc1cc373b780118cafbc0ca19388c102b Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 25 Aug 2020 13:04:52 -0700 Subject: [PATCH 211/933] ur: refactors ur_cue() into higher-order traversal --- pkg/urbit/include/ur/defs.h | 4 + pkg/urbit/ur/serial.c | 353 +++++++++++++++++------------------- 2 files changed, 167 insertions(+), 190 deletions(-) diff --git a/pkg/urbit/include/ur/defs.h b/pkg/urbit/include/ur/defs.h index 51f9064cc3..c20f379502 100644 --- a/pkg/urbit/include/ur/defs.h +++ b/pkg/urbit/include/ur/defs.h @@ -5,6 +5,10 @@ #include #include +#define ur_fib10 55 +#define ur_fib11 89 +#define ur_fib12 144 + typedef uint8_t ur_bool_t; #define ur_min(a, b) ( ((a) < (b)) ? (a) : (b) ) diff --git a/pkg/urbit/ur/serial.c b/pkg/urbit/ur/serial.c index bfcc859914..245eac50ca 100644 --- a/pkg/urbit/ur/serial.c +++ b/pkg/urbit/ur/serial.c @@ -72,15 +72,11 @@ uint64_t ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt) { _jam_t j = {0}; - { - uint64_t fib11 = 89, fib12 = 144; - j.bsw.prev = fib11; - j.bsw.size = fib12; - j.bsw.bytes = calloc(j.bsw.size, 1); - - ur_dict64_grow(r, &j.dict, fib11, fib12); - } + j.bsw.prev = ur_fib11; + j.bsw.size = ur_fib12; + j.bsw.bytes = calloc(j.bsw.size, 1); + ur_dict64_grow(r, &j.dict, ur_fib11, ur_fib12); ur_walk_fore(r, ref, &j, _jam_atom, _jam_cell); ur_dict_free((ur_dict_t*)&j.dict); @@ -91,24 +87,168 @@ ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt) return j.bsw.bits; } -typedef struct _cue_s { - ur_dict64_t dict; - ur_bsr_t bsr; -} _cue_t; +#define CUE_HEAD64 0xffffffffffffffffULL -static inline ur_cue_res_e -_cue_atom(ur_root_t *r, _cue_t *c, ur_nref *out) +/* +** stack frame for recording head vs tail iteration +** +** $? [CUE_HEAD64 bits=@] +** [hed=* bits=@] +*/ +typedef struct _cue64_frame_s { + uint64_t ref; + uint64_t bits; +} _cue64_frame_t; + +typedef struct _cue64_stack_s { + uint32_t prev; + uint32_t size; + uint32_t fill; + _cue64_frame_t* f; +} _cue64_stack_t; + +static inline void +_cue64_stack_push(_cue64_stack_t *s, uint64_t ref, uint64_t bits) { - ur_bsr_t *bsr = &c->bsr; - ur_cue_res_e res; - uint64_t len; - - if ( ur_cue_good != (res = ur_bsr_rub_len(bsr, &len)) ) { - return res; + if ( s->fill == s->size ) { + uint32_t next = s->prev + s->size; + s->f = realloc(s->f, next * sizeof(*s->f)); + s->prev = s->size; + s->size = next; } + _cue64_frame_t* f = &(s->f[s->fill++]); + f->ref = ref; + f->bits = bits; +} + +static inline ur_cue_res_e +_cue_walk64_advance(ur_root_t *r, + _cue64_stack_t *s, + ur_bsr_t *bsr, + ur_dict64_t *dict, + uint64_t (*coin)(ur_root_t*, ur_bsr_t*, uint64_t), + uint64_t *out) +{ + while ( 1 ) { + uint64_t len, bits = bsr->bits; + ur_cue_tag_e tag; + ur_cue_res_e res; + + if ( ur_cue_good != (res = ur_bsr_tag(bsr, &tag)) ) { + return res; + } + + switch ( tag ) { + default: assert(0); + + case ur_jam_atom: { + if ( ur_cue_good != (res = ur_bsr_rub_len(bsr, &len)) ) { + return res; + } + + *out = coin(r, bsr, len); + ur_dict64_put(r, dict, bits, *out); + return ur_cue_good; + } + + case ur_jam_back: { + if ( ur_cue_good != (res = ur_bsr_rub_len(bsr, &len)) ) { + return res; + } + else if ( 62 < len ) { + return ur_cue_meme; + } + else { + uint64_t bak = ur_bsr64_any(bsr, len); + + if ( !ur_dict64_get(r, dict, bak, out) ) { + // XX distinguish bad backref? + // + return ur_cue_gone; + } + + return ur_cue_good; + } + } + + case ur_jam_cell: { + _cue64_stack_push(s, CUE_HEAD64, bits); + continue; + } + } + } +} + +ur_cue_res_e +ur_cue_walk64(ur_root_t *r, + uint64_t len, + const uint8_t *byt, + uint64_t *out, + uint64_t (*coin)(ur_root_t*, ur_bsr_t*, uint64_t), + uint64_t (*cons)(ur_root_t*, uint64_t, uint64_t)) +{ + ur_cue_res_e res; + uint64_t ref; + ur_dict64_t dict = {0}; + ur_bsr_t bsr = {0}; + _cue64_stack_t s = {0}; + + // init dictionary + // + ur_dict64_grow(r, &dict, ur_fib11, ur_fib12); + + // init bitstream-reader + // + bsr.left = len; + bsr.bytes = byt; + + // setup stack + // + s.prev = ur_fib10; + s.size = ur_fib11; + s.f = malloc(s.size * sizeof(*s.f)); + + // advance into stream + // + res = _cue_walk64_advance(r, &s, &bsr, &dict, coin, &ref); + + // retreat down the stack + // + while ( s.fill && (ur_cue_good == res) ) { + _cue64_frame_t f = s.f[--s.fill]; + + // f is a head-frame + // + if ( CUE_HEAD64 == f.ref ) { + _cue64_stack_push(&s, ref, f.bits); + res = _cue_walk64_advance(r, &s, &bsr, &dict, coin, &ref); + } + // f is a tail-frame + // + else { + ref = cons(r, f.ref, ref); + ur_dict64_put(r, &dict, f.bits, ref); + } + } + + // finalize result + // + ur_dict_free((ur_dict_t*)&dict); + free(s.f); + + if ( ur_cue_good == res ) { + *out = ref; + } + + return res; +} + +static inline uint64_t +_cue_coin(ur_root_t *r, ur_bsr_t *bsr, uint64_t len) +{ if ( 62 >= len ) { - *out = (ur_nref)ur_bsr64_any(bsr, len); + return ur_bsr64_any(bsr, len); } else { uint64_t len_byt = (len >> 3) + !!ur_mask_3(len); @@ -121,179 +261,12 @@ _cue_atom(ur_root_t *r, _cue_t *c, ur_nref *out) len_byt--; } - *out = ur_coin_bytes_unsafe(r, byt, len_byt); + return (uint64_t)ur_coin_bytes_unsafe(r, byt, len_byt); } - - return ur_cue_good; -} - -static inline ur_cue_res_e -_cue_back(ur_bsr_t *bsr, uint64_t *out) -{ - ur_cue_res_e res; - uint64_t len; - - if ( ur_cue_good != (res = ur_bsr_rub_len(bsr, &len)) ) { - return res; - } - else if ( 62 < len ) { - return ur_cue_meme; - } - - *out = ur_bsr64_any(bsr, len); - return ur_cue_good; -} - -#define STACK_ROOT 0 -#define STACK_HEAD 1 -#define STACK_TAIL 2 - -// stack frame for recording head vs tail iteration -// -// In Hoon, this structure would be as follows: -// -// $% [%root ~] -// [%head cursor=@] -// [%tail cursor=@ hed-ref=*] -// == -// -typedef struct _cue_frame_s { - uint8_t tag; - uint64_t bits; - ur_nref ref; -} _cue_frame_t; - -typedef struct _cue_stack_s { - uint32_t prev; - uint32_t size; - uint32_t fill; - _cue_frame_t* f; -} _cue_stack_t; - -static inline void -_cue_stack_push(_cue_stack_t *s, uint8_t tag, uint64_t bits, ur_nref ref) -{ - if ( s->fill == s->size ) { - uint32_t next = s->prev + s->size; - s->f = realloc(s->f, next * sizeof(*s->f)); - s->prev = s->size; - s->size = next; - } - - _cue_frame_t* f = &(s->f[s->fill++]); - f->tag = tag; - f->bits = bits; - f->ref = ref; } ur_cue_res_e ur_cue(ur_root_t *r, uint64_t len, const uint8_t *byt, ur_nref *out) { - ur_cue_res_e res; - ur_nref ref; - _cue_t c = {0}; - _cue_stack_t s = { .prev = 89, .size = 144, .fill = 0, .f = 0 }; - - // init bitstream-reader - // - c.bsr.left = len; - c.bsr.bytes = byt; - - // init dictionary - // - { - uint64_t fib11 = 89, fib12 = 144; - ur_dict64_grow(r, &c.dict, fib11, fib12); - } - - // setup stack - // - s.f = malloc(s.size * sizeof(*s.f)); - _cue_stack_push(&s, STACK_ROOT, 0, 0); - - // advance into buffer - // - advance: { - uint64_t bits = c.bsr.bits; - ur_cue_tag_e tag; - - if ( ur_cue_good != (res = ur_bsr_tag(&c.bsr, &tag)) ) { - goto perfect; - } - - switch ( tag ) { - default: assert(0); - - case ur_jam_atom: { - if ( ur_cue_good != (res = _cue_atom(r, &c, &ref)) ) { - goto perfect; - } - else { - ur_dict64_put(r, &c.dict, bits, (uint64_t)ref); - goto retreat; - } - } - - case ur_jam_back: { - uint64_t bak, val; - - if ( ur_cue_good != (res = _cue_back(&c.bsr, &bak)) ) { - goto perfect; - } - else if ( !ur_dict64_get(r, &c.dict, bak, &val) ) { - // XX distinguish bad backref? - // - res = ur_cue_gone; - goto perfect; - } - - ref = (ur_nref)val; - goto retreat; - } - - case ur_jam_cell: { - _cue_stack_push(&s, STACK_HEAD, bits, 0); - goto advance; - } - } - } - - // retreat down the stack - // - retreat: { - _cue_frame_t f = s.f[--s.fill]; - - switch ( f.tag ) { - default: assert(0); - - case STACK_ROOT: { - res = ur_cue_good; - goto perfect; - } - - case STACK_HEAD: { - _cue_stack_push(&s, STACK_TAIL, f.bits, ref); - goto advance; - } - - case STACK_TAIL: { - ref = ur_cons(r, f.ref, ref); - ur_dict64_put(r, &c.dict, f.bits, (uint64_t)ref); - goto retreat; - } - } - } - - // we done - // - perfect: { - ur_dict_free((ur_dict_t*)&c.dict); - free(s.f); - - if ( ur_cue_good == res ) { - *out = ref; - } - - return res; - } + return ur_cue_walk64(r, len, byt, (uint64_t*)out, _cue_coin, ur_cons); } From 63d36b4e754d5952dd1e8d015d0c07620d6482a6 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 25 Aug 2020 15:50:26 -0700 Subject: [PATCH 212/933] ur: fixes bug in ur_bsr_bytes_any pointer math, adds tests --- pkg/urbit/tests/ur_tests.c | 12 ++++++++++++ pkg/urbit/ur/bitstream.c | 7 ++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index 66a145559f..4d9670a6cb 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -892,6 +892,12 @@ _bsr_cmp_any_check(const char* cap, uint8_t off, uint8_t len, ur_bsr_t *a, ur_bs ret = 0; } + if ( a->bytes != b->bytes ) { + fprintf(stderr, "%s: off %u len %u: bytes fail (%p, %p)\r\n", + cap, off, len, a->bytes, b->bytes); + ret = 0; + } + return ret; } @@ -1251,6 +1257,12 @@ _bsr_cmp_check(const char* cap, ret = 0; } + if ( a->bytes != b->bytes ) { + fprintf(stderr, "%s: off %u len %u: bytes fail (%p, %p)\r\n", + cap, off, len, a->bytes, b->bytes); + ret = 0; + } + return ret; } diff --git a/pkg/urbit/ur/bitstream.c b/pkg/urbit/ur/bitstream.c index 476cf40d89..eea2202543 100644 --- a/pkg/urbit/ur/bitstream.c +++ b/pkg/urbit/ur/bitstream.c @@ -400,10 +400,11 @@ ur_bsr_bytes_any(ur_bsr_t *bsr, uint64_t len, uint8_t *out) } } else { - uint8_t bits = off + len_bit; + uint8_t bits = off + len_bit; + uint64_t step = max + !!(bits >> 3); - bsr->bytes += max; - left -= max + !!(bits >> 3); + bsr->bytes += step; + left -= step; off = ur_mask_3(bits); if ( len_bit <= rest ) { From 177432f914bb89522c6dceadf12af2bf5800299f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 25 Aug 2020 16:56:05 -0700 Subject: [PATCH 213/933] ur: adds 32-bit ur_cue traversal, ur_cue_test validator --- pkg/urbit/include/ur/serial.h | 55 +++++ pkg/urbit/tests/ur_tests.c | 20 +- pkg/urbit/ur/serial.c | 372 ++++++++++++++++++++++++++++------ 3 files changed, 373 insertions(+), 74 deletions(-) diff --git a/pkg/urbit/include/ur/serial.h b/pkg/urbit/include/ur/serial.h index 2a8d98b86e..0fe634108b 100644 --- a/pkg/urbit/include/ur/serial.h +++ b/pkg/urbit/include/ur/serial.h @@ -7,7 +7,62 @@ uint64_t ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt); +typedef uint32_t (*ur_coin32_f)(ur_root_t*, ur_bsr_t*, uint64_t); +typedef uint32_t (*ur_cons32_f)(ur_root_t*, uint32_t, uint32_t); + +typedef uint64_t (*ur_coin64_f)(ur_root_t*, ur_bsr_t*, uint64_t); +typedef uint64_t (*ur_cons64_f)(ur_root_t*, uint64_t, uint64_t); + +ur_cue_res_e +ur_cue_walk32_unsafe(ur_root_t *r, + ur_dict32_t *dict, + uint64_t len, + const uint8_t *byt, + uint32_t *out, + ur_coin32_f coin, + ur_cons32_f cons); + +ur_cue_res_e +ur_cue_walk32(ur_root_t *r, + uint64_t len, + const uint8_t *byt, + uint32_t *out, + ur_coin32_f coin, + ur_cons32_f cons); + +ur_cue_res_e +ur_cue_walk64_unsafe(ur_root_t *r, + ur_dict64_t *dict, + uint64_t len, + const uint8_t *byt, + uint64_t *out, + ur_coin64_f coin, + ur_cons64_f cons); + +ur_cue_res_e +ur_cue_walk64(ur_root_t *r, + uint64_t len, + const uint8_t *byt, + uint64_t *out, + ur_coin64_f coin, + ur_cons64_f cons); + +ur_cue_res_e +ur_cue_unsafe(ur_root_t *r, + ur_dict64_t *dict, + uint64_t len, + const uint8_t *byt, + ur_nref *out); + ur_cue_res_e ur_cue(ur_root_t *r, uint64_t len, const uint8_t *byt, ur_nref *out); +ur_bool_t +ur_cue_test_unsafe(ur_dict32_t *dict, + uint64_t len, + const uint8_t *byt); + +ur_bool_t +ur_cue_test(uint64_t len, const uint8_t *byt); + #endif diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index 4d9670a6cb..b2d5b9b36e 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -1475,18 +1475,24 @@ _test_cue_spec(const char *cap, size_t len, const uint8_t *res) { + int ret = 1; ur_nref out; - if ( ur_cue_good != ur_cue(r, len, res, &out) ) { + if ( !ur_cue_test(len, res) ) { fprintf(stderr, "\033[31mcue %s fail 1\033[0m\r\n", cap); - return 0; - } - else if ( ref != out ) { - fprintf(stderr, "\033[31mcue %s fail 2 ref=%" PRIu64 " out=%" PRIu64 " \033[0m\r\n", cap, ref, out); - return 0; + ret = 0; } - return 1; + if ( ur_cue_good != ur_cue(r, len, res, &out) ) { + fprintf(stderr, "\033[31mcue %s fail 2\033[0m\r\n", cap); + ret = 0; + } + else if ( ref != out ) { + fprintf(stderr, "\033[31mcue %s fail 3 ref=%" PRIu64 " out=%" PRIu64 " \033[0m\r\n", cap, ref, out); + ret = 0; + } + + return ret; } static int diff --git a/pkg/urbit/ur/serial.c b/pkg/urbit/ur/serial.c index 245eac50ca..c6cb02efc3 100644 --- a/pkg/urbit/ur/serial.c +++ b/pkg/urbit/ur/serial.c @@ -87,19 +87,32 @@ ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt) return j.bsw.bits; } +#define CUE_HEAD32 0xffffffff #define CUE_HEAD64 0xffffffffffffffffULL /* ** stack frame for recording head vs tail iteration ** -** $? [CUE_HEAD64 bits=@] +** $? [CUE_HEAD_NN bits=@] ** [hed=* bits=@] */ +typedef struct _cue32_frame_s { + uint32_t ref; + uint64_t bits; +} _cue32_frame_t; + typedef struct _cue64_frame_s { uint64_t ref; uint64_t bits; } _cue64_frame_t; +typedef struct _cue32_stack_s { + uint32_t prev; + uint32_t size; + uint32_t fill; + _cue32_frame_t* f; +} _cue32_stack_t; + typedef struct _cue64_stack_s { uint32_t prev; uint32_t size; @@ -107,28 +120,13 @@ typedef struct _cue64_stack_s { _cue64_frame_t* f; } _cue64_stack_t; -static inline void -_cue64_stack_push(_cue64_stack_t *s, uint64_t ref, uint64_t bits) -{ - if ( s->fill == s->size ) { - uint32_t next = s->prev + s->size; - s->f = realloc(s->f, next * sizeof(*s->f)); - s->prev = s->size; - s->size = next; - } - - _cue64_frame_t* f = &(s->f[s->fill++]); - f->ref = ref; - f->bits = bits; -} - static inline ur_cue_res_e -_cue_walk64_advance(ur_root_t *r, - _cue64_stack_t *s, - ur_bsr_t *bsr, - ur_dict64_t *dict, - uint64_t (*coin)(ur_root_t*, ur_bsr_t*, uint64_t), - uint64_t *out) +_cue_walk32_next(ur_root_t *r, + _cue32_stack_t *s, + ur_bsr_t *bsr, + ur_dict32_t *dict, + ur_coin32_f coin, + uint32_t *out) { while ( 1 ) { uint64_t len, bits = bsr->bits; @@ -142,14 +140,24 @@ _cue_walk64_advance(ur_root_t *r, switch ( tag ) { default: assert(0); - case ur_jam_atom: { - if ( ur_cue_good != (res = ur_bsr_rub_len(bsr, &len)) ) { - return res; + case ur_jam_cell: { + // reallocate the stack if full + // + if ( s->fill == s->size ) { + uint32_t next = s->prev + s->size; + s->f = realloc(s->f, next * sizeof(*s->f)); + s->prev = s->size; + s->size = next; } - *out = coin(r, bsr, len); - ur_dict64_put(r, dict, bits, *out); - return ur_cue_good; + // save a head-frame and read the head from the stream + // + { + _cue32_frame_t* f = &(s->f[s->fill++]); + f->ref = CUE_HEAD32; + f->bits = bits; + } + continue; } case ur_jam_back: { @@ -162,41 +170,40 @@ _cue_walk64_advance(ur_root_t *r, else { uint64_t bak = ur_bsr64_any(bsr, len); - if ( !ur_dict64_get(r, dict, bak, out) ) { - // XX distinguish bad backref? - // - return ur_cue_gone; - } - - return ur_cue_good; + // XX distinguish bad backref? + // + return ur_dict32_get(r, dict, bak, out) + ? ur_cue_good + : ur_cue_gone; } } - case ur_jam_cell: { - _cue64_stack_push(s, CUE_HEAD64, bits); - continue; + case ur_jam_atom: { + if ( ur_cue_good != (res = ur_bsr_rub_len(bsr, &len)) ) { + return res; + } + + *out = coin(r, bsr, len); + ur_dict32_put(r, dict, bits, *out); + return ur_cue_good; } } } } ur_cue_res_e -ur_cue_walk64(ur_root_t *r, - uint64_t len, - const uint8_t *byt, - uint64_t *out, - uint64_t (*coin)(ur_root_t*, ur_bsr_t*, uint64_t), - uint64_t (*cons)(ur_root_t*, uint64_t, uint64_t)) +ur_cue_walk32_unsafe(ur_root_t *r, + ur_dict32_t *dict, + uint64_t len, + const uint8_t *byt, + uint32_t *out, + ur_coin32_f coin, + ur_cons32_f cons) { ur_cue_res_e res; - uint64_t ref; - ur_dict64_t dict = {0}; + uint32_t ref; ur_bsr_t bsr = {0}; - _cue64_stack_t s = {0}; - - // init dictionary - // - ur_dict64_grow(r, &dict, ur_fib11, ur_fib12); + _cue32_stack_t s = {0}; // init bitstream-reader // @@ -211,36 +218,200 @@ ur_cue_walk64(ur_root_t *r, // advance into stream // - res = _cue_walk64_advance(r, &s, &bsr, &dict, coin, &ref); + res = _cue_walk32_next(r, &s, &bsr, dict, coin, &ref); - // retreat down the stack + // process result // while ( s.fill && (ur_cue_good == res) ) { - _cue64_frame_t f = s.f[--s.fill]; - - // f is a head-frame + // peek at the top of the stack // - if ( CUE_HEAD64 == f.ref ) { - _cue64_stack_push(&s, ref, f.bits); - res = _cue_walk64_advance(r, &s, &bsr, &dict, coin, &ref); + _cue32_frame_t *f = &(s.f[s.fill - 1]); + + // f is a head-frame; stash result and read the tail from the stream + // + if ( CUE_HEAD32 == f->ref ) { + f->ref = ref; + res = _cue_walk32_next(r, &s, &bsr, dict, coin, &ref); } - // f is a tail-frame + // f is a tail-frame; pop the stack and continue // else { - ref = cons(r, f.ref, ref); - ur_dict64_put(r, &dict, f.bits, ref); + ref = cons(r, f->ref, ref); + ur_dict32_put(r, dict, f->bits, ref); + s.fill--; } } - // finalize result - // - ur_dict_free((ur_dict_t*)&dict); free(s.f); if ( ur_cue_good == res ) { *out = ref; } + return res; +} +ur_cue_res_e +ur_cue_walk32(ur_root_t *r, + uint64_t len, + const uint8_t *byt, + uint32_t *out, + ur_coin32_f coin, + ur_cons32_f cons) +{ + ur_dict32_t dict = {0}; + ur_dict32_grow(r, &dict, ur_fib11, ur_fib12); + ur_cue_res_e res = ur_cue_walk32_unsafe(r, &dict, len, + byt, out, coin, cons); + + ur_dict_free((ur_dict_t*)&dict); + return res; +} + +static inline ur_cue_res_e +_cue_walk64_next(ur_root_t *r, + _cue64_stack_t *s, + ur_bsr_t *bsr, + ur_dict64_t *dict, + ur_coin64_f coin, + uint64_t *out) +{ + while ( 1 ) { + uint64_t len, bits = bsr->bits; + ur_cue_tag_e tag; + ur_cue_res_e res; + + if ( ur_cue_good != (res = ur_bsr_tag(bsr, &tag)) ) { + return res; + } + + switch ( tag ) { + default: assert(0); + + case ur_jam_cell: { + // reallocate the stack if full + // + if ( s->fill == s->size ) { + uint32_t next = s->prev + s->size; + s->f = realloc(s->f, next * sizeof(*s->f)); + s->prev = s->size; + s->size = next; + } + + // save a head-frame and read the head from the stream + // + { + _cue64_frame_t* f = &(s->f[s->fill++]); + f->ref = CUE_HEAD64; + f->bits = bits; + } + continue; + } + + case ur_jam_back: { + if ( ur_cue_good != (res = ur_bsr_rub_len(bsr, &len)) ) { + return res; + } + else if ( 62 < len ) { + return ur_cue_meme; + } + else { + uint64_t bak = ur_bsr64_any(bsr, len); + + // XX distinguish bad backref? + // + return ur_dict64_get(r, dict, bak, out) + ? ur_cue_good + : ur_cue_gone; + } + } + + case ur_jam_atom: { + if ( ur_cue_good != (res = ur_bsr_rub_len(bsr, &len)) ) { + return res; + } + + *out = coin(r, bsr, len); + ur_dict64_put(r, dict, bits, *out); + return ur_cue_good; + } + } + } +} + +ur_cue_res_e +ur_cue_walk64_unsafe(ur_root_t *r, + ur_dict64_t *dict, + uint64_t len, + const uint8_t *byt, + uint64_t *out, + ur_coin64_f coin, + ur_cons64_f cons) +{ + ur_cue_res_e res; + uint64_t ref; + ur_bsr_t bsr = {0}; + _cue64_stack_t s = {0}; + + // init bitstream-reader + // + bsr.left = len; + bsr.bytes = byt; + + // setup stack + // + s.prev = ur_fib10; + s.size = ur_fib11; + s.f = malloc(s.size * sizeof(*s.f)); + + // advance into stream + // + res = _cue_walk64_next(r, &s, &bsr, dict, coin, &ref); + + // process result + // + while ( s.fill && (ur_cue_good == res) ) { + // peek at the top of the stack + // + _cue64_frame_t *f = &(s.f[s.fill - 1]); + + // f is a head-frame; stash result and read the tail from the stream + // + if ( CUE_HEAD64 == f->ref ) { + f->ref = ref; + res = _cue_walk64_next(r, &s, &bsr, dict, coin, &ref); + } + // f is a tail-frame; pop the stack and continue + // + else { + ref = cons(r, f->ref, ref); + ur_dict64_put(r, dict, f->bits, ref); + s.fill--; + } + } + + free(s.f); + + if ( ur_cue_good == res ) { + *out = ref; + } + return res; +} + +ur_cue_res_e +ur_cue_walk64(ur_root_t *r, + uint64_t len, + const uint8_t *byt, + uint64_t *out, + ur_coin64_f coin, + ur_cons64_f cons) +{ + ur_dict64_t dict = {0}; + ur_dict64_grow(r, &dict, ur_fib11, ur_fib12); + + ur_cue_res_e res = ur_cue_walk64_unsafe(r, &dict, len, + byt, out, coin, cons); + + ur_dict_free((ur_dict_t*)&dict); return res; } @@ -266,7 +437,74 @@ _cue_coin(ur_root_t *r, ur_bsr_t *bsr, uint64_t len) } ur_cue_res_e -ur_cue(ur_root_t *r, uint64_t len, const uint8_t *byt, ur_nref *out) +ur_cue_unsafe(ur_root_t *r, + ur_dict64_t *dict, + uint64_t len, + const uint8_t *byt, + ur_nref *out) { - return ur_cue_walk64(r, len, byt, (uint64_t*)out, _cue_coin, ur_cons); + return ur_cue_walk64_unsafe(r, dict, len, byt, + (uint64_t*)out, _cue_coin, ur_cons); +} + +ur_cue_res_e +ur_cue(ur_root_t *r, + uint64_t len, + const uint8_t *byt, + ur_nref *out) +{ + return ur_cue_walk64(r, len, byt, + (uint64_t*)out, _cue_coin, ur_cons); +} + +static inline uint32_t +_cue_test_coin(ur_root_t *r, ur_bsr_t *bsr, uint64_t len) +{ + // XX need a ur_bsr_skip() + // + { + uint64_t len_byt = (len >> 3) + !!ur_mask_3(len); + uint8_t *byt = calloc(len_byt, 1); + ur_bsr_bytes_any(bsr, len, byt); + + free(byt); + } + + return 0; +} + +static inline uint32_t +_cue_test_cons(ur_root_t *r, uint32_t hed, uint32_t tal) +{ + return 0; +} + +ur_bool_t +ur_cue_test_unsafe(ur_dict32_t *dict, + uint64_t len, + const uint8_t *byt) +{ + // NB, the root argument is unused, as all dict keys are + // backreferences, limited to 62-bit direct atoms + // + ur_root_t *r = 0; + uint32_t out; + ur_cue_res_e res = ur_cue_walk32_unsafe(r, dict, len, + byt, &out, + _cue_test_coin, + _cue_test_cons); + return ur_cue_good == res; +} + +ur_bool_t +ur_cue_test(uint64_t len, const uint8_t *byt) +{ + ur_root_t *r = 0; + ur_dict32_t dict = {0}; + ur_dict32_grow(r, &dict, ur_fib11, ur_fib12); + + ur_bool_t ret = ur_cue_test_unsafe(&dict, len, byt); + + ur_dict_free((ur_dict_t*)&dict); + return ret; } From 88f58d3f017ae9fda59448a49a759cc1645f0b4e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 26 Aug 2020 13:17:34 -0700 Subject: [PATCH 214/933] ur: fixes serial.h includes --- pkg/urbit/include/ur/serial.h | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/urbit/include/ur/serial.h b/pkg/urbit/include/ur/serial.h index 0fe634108b..904bcc3f38 100644 --- a/pkg/urbit/include/ur/serial.h +++ b/pkg/urbit/include/ur/serial.h @@ -2,6 +2,7 @@ #define UR_SERIAL_H #include +#include #include uint64_t From 0420bf9aa52d08847749d3709b5706e8746f2ad5 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 26 Aug 2020 13:20:16 -0700 Subject: [PATCH 215/933] ur: adds additional fibonacci constants --- pkg/urbit/include/ur/defs.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/urbit/include/ur/defs.h b/pkg/urbit/include/ur/defs.h index c20f379502..605193b1d3 100644 --- a/pkg/urbit/include/ur/defs.h +++ b/pkg/urbit/include/ur/defs.h @@ -8,6 +8,8 @@ #define ur_fib10 55 #define ur_fib11 89 #define ur_fib12 144 +#define ur_fib33 3524578 +#define ur_fib34 5702887 typedef uint8_t ur_bool_t; From 6f93ec3aa5027ecb096e552e2c834cfccb61b536 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 25 Aug 2020 17:55:49 -0700 Subject: [PATCH 216/933] ur: implements ur_dict_get/put, cleans up ur_dict*_t handling --- pkg/urbit/include/ur/hashcons.h | 24 ++++++++--- pkg/urbit/ur/hashcons.c | 70 +++++++++++++++++++++++++++++---- 2 files changed, 82 insertions(+), 12 deletions(-) diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index 73601c174f..9cfd9d2da2 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -11,6 +11,8 @@ #define ur_nref_tag(ref) ( ref >> 62 ) #define ur_nref_idx(ref) ur_mask_62(ref) +#define ur_pail_max 10 + typedef uint32_t ur_mug; typedef uint64_t ur_nref; typedef enum { @@ -26,8 +28,8 @@ typedef struct ur_nvec_s { typedef struct ur_pail32_s { uint8_t fill; - ur_nref refs[10]; - uint32_t vals[10]; + ur_nref refs[ur_pail_max]; + uint32_t vals[ur_pail_max]; } ur_pail32_t; typedef struct ur_dict32_s { @@ -38,8 +40,8 @@ typedef struct ur_dict32_s { typedef struct ur_pail64_s { uint8_t fill; - ur_nref refs[10]; - uint64_t vals[10]; + ur_nref refs[ur_pail_max]; + uint64_t vals[ur_pail_max]; } ur_pail64_t; typedef struct ur_dict64_s { @@ -50,7 +52,7 @@ typedef struct ur_dict64_s { typedef struct ur_pail_s { uint8_t fill; - ur_nref refs[10]; + ur_nref refs[ur_pail_max]; } ur_pail_t; typedef struct ur_dict_s { @@ -99,9 +101,21 @@ ur_dict32_put(ur_root_t *r, ur_dict32_t *dict, ur_nref ref, uint32_t val); void ur_dict64_grow(ur_root_t *r, ur_dict64_t *dict, uint64_t prev, uint64_t size); +void +ur_dict_grow(ur_root_t *r, ur_dict_t *dict, uint64_t prev, uint64_t size); + +ur_bool_t +ur_dict_get(ur_root_t *r, ur_dict_t *dict, ur_nref ref); + +void +ur_dict_put(ur_root_t *r, ur_dict_t *dict, ur_nref ref); + void ur_dict_free(ur_dict_t *dict); +void +ur_dict_wipe(ur_dict_t *dict); + ur_bool_t ur_dict64_get(ur_root_t *r, ur_dict64_t *dict, ur_nref ref, uint64_t *out); diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index a10579c7cb..7ad97c3a9a 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -128,7 +128,7 @@ ur_dict32_grow(ur_root_t *r, ur_dict32_t *dict, uint64_t prev, uint64_t size) ur_pail32_t *bucket = &(buckets[idx]); uint8_t new_fill = bucket->fill; - if ( 10 == new_fill ) { + if ( ur_pail_max == new_fill ) { free(buckets); return ur_dict32_grow(r, dict, size, next); } @@ -182,7 +182,7 @@ ur_dict32_put(ur_root_t *r, ur_dict32_t *dict, ur_nref ref, uint32_t val) } } - if ( 10 == fill ) { + if ( ur_pail_max == fill ) { ur_dict32_grow(r, dict, dict->prev, dict->size); continue; } @@ -216,7 +216,7 @@ ur_dict64_grow(ur_root_t *r, ur_dict64_t *dict, uint64_t prev, uint64_t size) ur_pail64_t *bucket = &(buckets[idx]); uint8_t new_fill = bucket->fill; - if ( 10 == new_fill ) { + if ( ur_pail_max == new_fill ) { free(buckets); return ur_dict64_grow(r, dict, size, next); } @@ -270,7 +270,7 @@ ur_dict64_put(ur_root_t *r, ur_dict64_t *dict, ur_nref ref, uint64_t val) } } - if ( 10 == fill ) { + if ( ur_pail_max == fill ) { ur_dict64_grow(r, dict, dict->prev, dict->size); continue; } @@ -303,7 +303,7 @@ ur_dict_grow(ur_root_t *r, ur_dict_t *dict, uint64_t prev, uint64_t size) ur_pail_t *bucket = &(buckets[idx]); uint8_t new_fill = bucket->fill; - if ( 10 == new_fill ) { + if ( ur_pail_max == new_fill ) { free(buckets); return ur_dict_grow(r, dict, size, next); } @@ -320,12 +320,68 @@ ur_dict_grow(ur_root_t *r, ur_dict_t *dict, uint64_t prev, uint64_t size) dict->buckets = buckets; } +ur_bool_t +ur_dict_get(ur_root_t *r, ur_dict_t *dict, ur_nref ref) +{ + ur_mug mug = ur_nref_mug(r, ref); + uint64_t idx = ( mug % dict->size ); + + ur_pail_t *bucket = &(dict->buckets[idx]); + uint8_t i, fill = bucket->fill; + + for ( i = 0; i < fill; i++ ) { + if ( ref == bucket->refs[i] ) { + return 1; + } + } + + return 0; +} + +void +ur_dict_put(ur_root_t *r, ur_dict_t *dict, ur_nref ref) +{ + ur_mug mug = ur_nref_mug(r, ref); + + while ( 1 ) { + uint64_t idx = ( mug % dict->size ); + ur_pail_t *bucket = &(dict->buckets[idx]); + uint8_t i, fill = bucket->fill; + + for ( i = 0; i < fill; i++ ) { + if ( ref == bucket->refs[i] ) { + return; + } + } + + if ( ur_pail_max == fill ) { + ur_dict_grow(r, dict, dict->prev, dict->size); + continue; + } + + bucket->refs[fill] = ref; + bucket->fill = 1 + fill; + break; + } +} + void ur_dict_free(ur_dict_t *dict) { free(dict->buckets); } +void +ur_dict_wipe(ur_dict_t *dict) +{ + ur_pail_t *buckets = dict->buckets; + uint64_t i, size = dict->size; + + for ( i = 0; i < size; i++ ) { + buckets[i].fill = 0; + } +} + void ur_atoms_grow(ur_atoms_t *atoms) { @@ -538,7 +594,7 @@ ur_coin_bytes_unsafe(ur_root_t *r, uint8_t *byt, uint64_t len) } } - if ( 10 == b_fill ) { + if ( ur_pail_max == b_fill ) { ur_dict_grow(r, dict, dict->prev, dict->size); continue; } @@ -633,7 +689,7 @@ ur_cons(ur_root_t *r, ur_nref hed, ur_nref tal) } } - if ( 10 == b_fill ) { + if ( ur_pail_max == b_fill ) { ur_dict_grow(r, dict, dict->prev, dict->size); continue; } From 43bd092476c7cc4ea47c5ab8fba51bc7b1e6daad Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 26 Aug 2020 15:11:41 -0700 Subject: [PATCH 217/933] ur: reimplements ur_cue_test() directly --- pkg/urbit/include/ur/serial.h | 4 +- pkg/urbit/ur/serial.c | 167 +++++++++++++++++++++++++++------- 2 files changed, 135 insertions(+), 36 deletions(-) diff --git a/pkg/urbit/include/ur/serial.h b/pkg/urbit/include/ur/serial.h index 904bcc3f38..68ad17750d 100644 --- a/pkg/urbit/include/ur/serial.h +++ b/pkg/urbit/include/ur/serial.h @@ -58,8 +58,8 @@ ur_cue_unsafe(ur_root_t *r, ur_cue_res_e ur_cue(ur_root_t *r, uint64_t len, const uint8_t *byt, ur_nref *out); -ur_bool_t -ur_cue_test_unsafe(ur_dict32_t *dict, +ur_cue_res_e +ur_cue_test_unsafe(ur_dict_t *dict, uint64_t len, const uint8_t *byt); diff --git a/pkg/urbit/ur/serial.c b/pkg/urbit/ur/serial.c index c6cb02efc3..3453449e19 100644 --- a/pkg/urbit/ur/serial.c +++ b/pkg/urbit/ur/serial.c @@ -457,54 +457,153 @@ ur_cue(ur_root_t *r, (uint64_t*)out, _cue_coin, ur_cons); } -static inline uint32_t -_cue_test_coin(ur_root_t *r, ur_bsr_t *bsr, uint64_t len) -{ - // XX need a ur_bsr_skip() - // - { - uint64_t len_byt = (len >> 3) + !!ur_mask_3(len); - uint8_t *byt = calloc(len_byt, 1); - ur_bsr_bytes_any(bsr, len, byt); +typedef struct _cue_test_frame_s { + ur_bool_t tal; + uint64_t bits; +} _cue_test_frame_t; - free(byt); +typedef struct _cue_test_stack_s { + uint32_t prev; + uint32_t size; + uint32_t fill; + _cue_test_frame_t* f; +} _cue_test_stack_t; + +static inline ur_cue_res_e +_cue_test_next(_cue_test_stack_t *s, + ur_bsr_t *bsr, + ur_dict_t *dict) +{ + while ( 1 ) { + uint64_t len, bits = bsr->bits; + ur_cue_tag_e tag; + ur_cue_res_e res; + + if ( ur_cue_good != (res = ur_bsr_tag(bsr, &tag)) ) { + return res; + } + + switch ( tag ) { + default: assert(0); + + case ur_jam_cell: { + // reallocate the stack if full + // + if ( s->fill == s->size ) { + uint32_t next = s->prev + s->size; + s->f = realloc(s->f, next * sizeof(*s->f)); + s->prev = s->size; + s->size = next; + } + + // save a head-frame and read the head from the stream + // + { + _cue_test_frame_t* f = &(s->f[s->fill++]); + f->tal = 0; + f->bits = bits; + } + continue; + } + + case ur_jam_back: { + if ( ur_cue_good != (res = ur_bsr_rub_len(bsr, &len)) ) { + return res; + } + else if ( 62 < len ) { + return ur_cue_meme; + } + else { + uint64_t bak = ur_bsr64_any(bsr, len); + + // XX distinguish bad backref? + // + return ur_dict_get((ur_root_t*)0, dict, bak) + ? ur_cue_good + : ur_cue_gone; + } + } + + case ur_jam_atom: { + if ( ur_cue_good != (res = ur_bsr_rub_len(bsr, &len)) ) { + return res; + } + + // XX need a ur_bsr_skip() + // + { + uint64_t len_byt = (len >> 3) + !!ur_mask_3(len); + uint8_t *byt = calloc(len_byt, 1); + ur_bsr_bytes_any(bsr, len, byt); + + free(byt); + } + + ur_dict_put((ur_root_t*)0, dict, bits); + return ur_cue_good; + } + } } - - return 0; } -static inline uint32_t -_cue_test_cons(ur_root_t *r, uint32_t hed, uint32_t tal) -{ - return 0; -} - -ur_bool_t -ur_cue_test_unsafe(ur_dict32_t *dict, +ur_cue_res_e +ur_cue_test_unsafe(ur_dict_t *dict, uint64_t len, const uint8_t *byt) { - // NB, the root argument is unused, as all dict keys are - // backreferences, limited to 62-bit direct atoms + ur_bsr_t bsr = {0}; + _cue_test_stack_t s = {0}; + ur_cue_res_e res; + + // init bitstream-reader // - ur_root_t *r = 0; - uint32_t out; - ur_cue_res_e res = ur_cue_walk32_unsafe(r, dict, len, - byt, &out, - _cue_test_coin, - _cue_test_cons); - return ur_cue_good == res; + bsr.left = len; + bsr.bytes = byt; + + // setup stack + // + s.prev = ur_fib10; + s.size = ur_fib11; + s.f = malloc(s.size * sizeof(*s.f)); + + // advance into stream + // + res = _cue_test_next(&s, &bsr, dict); + + // process result + // + while ( s.fill && (ur_cue_good == res) ) { + // peek at the top of the stack + // + _cue_test_frame_t *f = &(s.f[s.fill - 1]); + + // f is a head-frame; stash result and read the tail from the stream + // + if ( !f->tal ) { + f->tal = 1; + res = _cue_test_next(&s, &bsr, dict); + } + // f is a tail-frame; pop the stack and continue + // + else { + ur_dict_put((ur_root_t*)0, dict, f->bits); + s.fill--; + } + } + + free(s.f); + + return res; } ur_bool_t ur_cue_test(uint64_t len, const uint8_t *byt) { - ur_root_t *r = 0; - ur_dict32_t dict = {0}; - ur_dict32_grow(r, &dict, ur_fib11, ur_fib12); + ur_dict_t dict = {0}; + ur_dict_grow((ur_root_t*)0, &dict, ur_fib11, ur_fib12); - ur_bool_t ret = ur_cue_test_unsafe(&dict, len, byt); + ur_bool_t ret = ur_cue_good == ur_cue_test_unsafe(&dict, len, byt); - ur_dict_free((ur_dict_t*)&dict); + ur_dict_free(&dict); return ret; } From e964e4a1fb0c2c8239bc5ddc9202466065ce0e1a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 26 Aug 2020 16:12:03 -0700 Subject: [PATCH 218/933] ur: reimplements ur_cue/_unsafe directly --- pkg/urbit/ur/serial.c | 154 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 136 insertions(+), 18 deletions(-) diff --git a/pkg/urbit/ur/serial.c b/pkg/urbit/ur/serial.c index 3453449e19..398f0082a7 100644 --- a/pkg/urbit/ur/serial.c +++ b/pkg/urbit/ur/serial.c @@ -415,24 +415,91 @@ ur_cue_walk64(ur_root_t *r, return res; } -static inline uint64_t -_cue_coin(ur_root_t *r, ur_bsr_t *bsr, uint64_t len) +static inline ur_cue_res_e +_cue_next(ur_root_t *r, + _cue64_stack_t *s, + ur_bsr_t *bsr, + ur_dict64_t *dict, + ur_nref *out) { - if ( 62 >= len ) { - return ur_bsr64_any(bsr, len); - } - else { - uint64_t len_byt = (len >> 3) + !!ur_mask_3(len); - uint8_t *byt = calloc(len_byt, 1); - ur_bsr_bytes_any(bsr, len, byt); + while ( 1 ) { + uint64_t len, bits = bsr->bits; + ur_cue_tag_e tag; + ur_cue_res_e res; - // strip trailing zeroes - // - while ( len_byt && !byt[len_byt - 1] ) { - len_byt--; + if ( ur_cue_good != (res = ur_bsr_tag(bsr, &tag)) ) { + return res; } - return (uint64_t)ur_coin_bytes_unsafe(r, byt, len_byt); + switch ( tag ) { + default: assert(0); + + case ur_jam_cell: { + // reallocate the stack if full + // + if ( s->fill == s->size ) { + uint32_t next = s->prev + s->size; + s->f = realloc(s->f, next * sizeof(*s->f)); + s->prev = s->size; + s->size = next; + } + + // save a head-frame and read the head from the stream + // + { + _cue64_frame_t* f = &(s->f[s->fill++]); + f->ref = CUE_HEAD64; + f->bits = bits; + } + continue; + } + + case ur_jam_back: { + if ( ur_cue_good != (res = ur_bsr_rub_len(bsr, &len)) ) { + return res; + } + else if ( 62 < len ) { + return ur_cue_meme; + } + else { + uint64_t val, bak = ur_bsr64_any(bsr, len); + + // XX distinguish bad backref? + // + if ( !ur_dict64_get(r, dict, bak, &val) ) { + return ur_cue_gone; + } + + *out = (ur_nref)val; + return ur_cue_good; + } + } + + case ur_jam_atom: { + if ( ur_cue_good != (res = ur_bsr_rub_len(bsr, &len)) ) { + return res; + } + else if ( 62 >= len ) { + *out = (ur_nref)ur_bsr64_any(bsr, len); + } + else { + uint64_t len_byt = (len >> 3) + !!ur_mask_3(len); + uint8_t *byt = calloc(len_byt, 1); + ur_bsr_bytes_any(bsr, len, byt); + + // strip trailing zeroes + // + while ( len_byt && !byt[len_byt - 1] ) { + len_byt--; + } + + *out = ur_coin_bytes_unsafe(r, byt, len_byt); + } + + ur_dict64_put(r, dict, bits, (uint64_t)*out); + return ur_cue_good; + } + } } } @@ -443,8 +510,54 @@ ur_cue_unsafe(ur_root_t *r, const uint8_t *byt, ur_nref *out) { - return ur_cue_walk64_unsafe(r, dict, len, byt, - (uint64_t*)out, _cue_coin, ur_cons); + ur_bsr_t bsr = {0}; + _cue64_stack_t s = {0}; + ur_cue_res_e res; + ur_nref ref; + + // init bitstream-reader + // + bsr.left = len; + bsr.bytes = byt; + + // setup stack + // + s.prev = ur_fib10; + s.size = ur_fib11; + s.f = malloc(s.size * sizeof(*s.f)); + + // advance into stream + // + res = _cue_next(r, &s, &bsr, dict, &ref); + + // process result + // + while ( s.fill && (ur_cue_good == res) ) { + // peek at the top of the stack + // + _cue64_frame_t *f = &(s.f[s.fill - 1]); + + // f is a head-frame; stash result and read the tail from the stream + // + if ( CUE_HEAD64 == f->ref ) { + f->ref = ref; + res = _cue_next(r, &s, &bsr, dict, &ref); + } + // f is a tail-frame; pop the stack and continue + // + else { + ref = ur_cons(r, f->ref, ref); + ur_dict64_put(r, dict, f->bits, (uint64_t)ref); + s.fill--; + } + } + + free(s.f); + + if ( ur_cue_good == res ) { + *out = ref; + } + return res; } ur_cue_res_e @@ -453,8 +566,13 @@ ur_cue(ur_root_t *r, const uint8_t *byt, ur_nref *out) { - return ur_cue_walk64(r, len, byt, - (uint64_t*)out, _cue_coin, ur_cons); + ur_dict64_t dict = {0}; + ur_dict64_grow(r, &dict, ur_fib11, ur_fib12); + + ur_cue_res_e res = ur_cue_unsafe(r, &dict, len, byt, out); + + ur_dict_free((ur_dict_t*)&dict); + return res; } typedef struct _cue_test_frame_s { From 1da0c6d3531fd7cb2f3251723f9708775f41254d Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 26 Aug 2020 16:18:18 -0700 Subject: [PATCH 219/933] ur: removes higher-ordered cue traversals --- pkg/urbit/include/ur/serial.h | 40 ---- pkg/urbit/ur/serial.c | 348 +++------------------------------- 2 files changed, 24 insertions(+), 364 deletions(-) diff --git a/pkg/urbit/include/ur/serial.h b/pkg/urbit/include/ur/serial.h index 68ad17750d..afac9e6a0d 100644 --- a/pkg/urbit/include/ur/serial.h +++ b/pkg/urbit/include/ur/serial.h @@ -8,46 +8,6 @@ uint64_t ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt); -typedef uint32_t (*ur_coin32_f)(ur_root_t*, ur_bsr_t*, uint64_t); -typedef uint32_t (*ur_cons32_f)(ur_root_t*, uint32_t, uint32_t); - -typedef uint64_t (*ur_coin64_f)(ur_root_t*, ur_bsr_t*, uint64_t); -typedef uint64_t (*ur_cons64_f)(ur_root_t*, uint64_t, uint64_t); - -ur_cue_res_e -ur_cue_walk32_unsafe(ur_root_t *r, - ur_dict32_t *dict, - uint64_t len, - const uint8_t *byt, - uint32_t *out, - ur_coin32_f coin, - ur_cons32_f cons); - -ur_cue_res_e -ur_cue_walk32(ur_root_t *r, - uint64_t len, - const uint8_t *byt, - uint32_t *out, - ur_coin32_f coin, - ur_cons32_f cons); - -ur_cue_res_e -ur_cue_walk64_unsafe(ur_root_t *r, - ur_dict64_t *dict, - uint64_t len, - const uint8_t *byt, - uint64_t *out, - ur_coin64_f coin, - ur_cons64_f cons); - -ur_cue_res_e -ur_cue_walk64(ur_root_t *r, - uint64_t len, - const uint8_t *byt, - uint64_t *out, - ur_coin64_f coin, - ur_cons64_f cons); - ur_cue_res_e ur_cue_unsafe(ur_root_t *r, ur_dict64_t *dict, diff --git a/pkg/urbit/ur/serial.c b/pkg/urbit/ur/serial.c index 398f0082a7..b32973a6ff 100644 --- a/pkg/urbit/ur/serial.c +++ b/pkg/urbit/ur/serial.c @@ -87,337 +87,30 @@ ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt) return j.bsw.bits; } -#define CUE_HEAD32 0xffffffff -#define CUE_HEAD64 0xffffffffffffffffULL - /* ** stack frame for recording head vs tail iteration ** -** $? [CUE_HEAD_NN bits=@] +** $? [CUE_HEAD bits=@] ** [hed=* bits=@] */ -typedef struct _cue32_frame_s { - uint32_t ref; - uint64_t bits; -} _cue32_frame_t; -typedef struct _cue64_frame_s { +#define CUE_HEAD 0xffffffffffffffffULL + +typedef struct _cue_frame_s { uint64_t ref; uint64_t bits; -} _cue64_frame_t; +} _cue_frame_t; -typedef struct _cue32_stack_s { - uint32_t prev; - uint32_t size; - uint32_t fill; - _cue32_frame_t* f; -} _cue32_stack_t; - -typedef struct _cue64_stack_s { - uint32_t prev; - uint32_t size; - uint32_t fill; - _cue64_frame_t* f; -} _cue64_stack_t; - -static inline ur_cue_res_e -_cue_walk32_next(ur_root_t *r, - _cue32_stack_t *s, - ur_bsr_t *bsr, - ur_dict32_t *dict, - ur_coin32_f coin, - uint32_t *out) -{ - while ( 1 ) { - uint64_t len, bits = bsr->bits; - ur_cue_tag_e tag; - ur_cue_res_e res; - - if ( ur_cue_good != (res = ur_bsr_tag(bsr, &tag)) ) { - return res; - } - - switch ( tag ) { - default: assert(0); - - case ur_jam_cell: { - // reallocate the stack if full - // - if ( s->fill == s->size ) { - uint32_t next = s->prev + s->size; - s->f = realloc(s->f, next * sizeof(*s->f)); - s->prev = s->size; - s->size = next; - } - - // save a head-frame and read the head from the stream - // - { - _cue32_frame_t* f = &(s->f[s->fill++]); - f->ref = CUE_HEAD32; - f->bits = bits; - } - continue; - } - - case ur_jam_back: { - if ( ur_cue_good != (res = ur_bsr_rub_len(bsr, &len)) ) { - return res; - } - else if ( 62 < len ) { - return ur_cue_meme; - } - else { - uint64_t bak = ur_bsr64_any(bsr, len); - - // XX distinguish bad backref? - // - return ur_dict32_get(r, dict, bak, out) - ? ur_cue_good - : ur_cue_gone; - } - } - - case ur_jam_atom: { - if ( ur_cue_good != (res = ur_bsr_rub_len(bsr, &len)) ) { - return res; - } - - *out = coin(r, bsr, len); - ur_dict32_put(r, dict, bits, *out); - return ur_cue_good; - } - } - } -} - -ur_cue_res_e -ur_cue_walk32_unsafe(ur_root_t *r, - ur_dict32_t *dict, - uint64_t len, - const uint8_t *byt, - uint32_t *out, - ur_coin32_f coin, - ur_cons32_f cons) -{ - ur_cue_res_e res; - uint32_t ref; - ur_bsr_t bsr = {0}; - _cue32_stack_t s = {0}; - - // init bitstream-reader - // - bsr.left = len; - bsr.bytes = byt; - - // setup stack - // - s.prev = ur_fib10; - s.size = ur_fib11; - s.f = malloc(s.size * sizeof(*s.f)); - - // advance into stream - // - res = _cue_walk32_next(r, &s, &bsr, dict, coin, &ref); - - // process result - // - while ( s.fill && (ur_cue_good == res) ) { - // peek at the top of the stack - // - _cue32_frame_t *f = &(s.f[s.fill - 1]); - - // f is a head-frame; stash result and read the tail from the stream - // - if ( CUE_HEAD32 == f->ref ) { - f->ref = ref; - res = _cue_walk32_next(r, &s, &bsr, dict, coin, &ref); - } - // f is a tail-frame; pop the stack and continue - // - else { - ref = cons(r, f->ref, ref); - ur_dict32_put(r, dict, f->bits, ref); - s.fill--; - } - } - - free(s.f); - - if ( ur_cue_good == res ) { - *out = ref; - } - return res; -} - -ur_cue_res_e -ur_cue_walk32(ur_root_t *r, - uint64_t len, - const uint8_t *byt, - uint32_t *out, - ur_coin32_f coin, - ur_cons32_f cons) -{ - ur_dict32_t dict = {0}; - ur_dict32_grow(r, &dict, ur_fib11, ur_fib12); - ur_cue_res_e res = ur_cue_walk32_unsafe(r, &dict, len, - byt, out, coin, cons); - - ur_dict_free((ur_dict_t*)&dict); - return res; -} - -static inline ur_cue_res_e -_cue_walk64_next(ur_root_t *r, - _cue64_stack_t *s, - ur_bsr_t *bsr, - ur_dict64_t *dict, - ur_coin64_f coin, - uint64_t *out) -{ - while ( 1 ) { - uint64_t len, bits = bsr->bits; - ur_cue_tag_e tag; - ur_cue_res_e res; - - if ( ur_cue_good != (res = ur_bsr_tag(bsr, &tag)) ) { - return res; - } - - switch ( tag ) { - default: assert(0); - - case ur_jam_cell: { - // reallocate the stack if full - // - if ( s->fill == s->size ) { - uint32_t next = s->prev + s->size; - s->f = realloc(s->f, next * sizeof(*s->f)); - s->prev = s->size; - s->size = next; - } - - // save a head-frame and read the head from the stream - // - { - _cue64_frame_t* f = &(s->f[s->fill++]); - f->ref = CUE_HEAD64; - f->bits = bits; - } - continue; - } - - case ur_jam_back: { - if ( ur_cue_good != (res = ur_bsr_rub_len(bsr, &len)) ) { - return res; - } - else if ( 62 < len ) { - return ur_cue_meme; - } - else { - uint64_t bak = ur_bsr64_any(bsr, len); - - // XX distinguish bad backref? - // - return ur_dict64_get(r, dict, bak, out) - ? ur_cue_good - : ur_cue_gone; - } - } - - case ur_jam_atom: { - if ( ur_cue_good != (res = ur_bsr_rub_len(bsr, &len)) ) { - return res; - } - - *out = coin(r, bsr, len); - ur_dict64_put(r, dict, bits, *out); - return ur_cue_good; - } - } - } -} - -ur_cue_res_e -ur_cue_walk64_unsafe(ur_root_t *r, - ur_dict64_t *dict, - uint64_t len, - const uint8_t *byt, - uint64_t *out, - ur_coin64_f coin, - ur_cons64_f cons) -{ - ur_cue_res_e res; - uint64_t ref; - ur_bsr_t bsr = {0}; - _cue64_stack_t s = {0}; - - // init bitstream-reader - // - bsr.left = len; - bsr.bytes = byt; - - // setup stack - // - s.prev = ur_fib10; - s.size = ur_fib11; - s.f = malloc(s.size * sizeof(*s.f)); - - // advance into stream - // - res = _cue_walk64_next(r, &s, &bsr, dict, coin, &ref); - - // process result - // - while ( s.fill && (ur_cue_good == res) ) { - // peek at the top of the stack - // - _cue64_frame_t *f = &(s.f[s.fill - 1]); - - // f is a head-frame; stash result and read the tail from the stream - // - if ( CUE_HEAD64 == f->ref ) { - f->ref = ref; - res = _cue_walk64_next(r, &s, &bsr, dict, coin, &ref); - } - // f is a tail-frame; pop the stack and continue - // - else { - ref = cons(r, f->ref, ref); - ur_dict64_put(r, dict, f->bits, ref); - s.fill--; - } - } - - free(s.f); - - if ( ur_cue_good == res ) { - *out = ref; - } - return res; -} - -ur_cue_res_e -ur_cue_walk64(ur_root_t *r, - uint64_t len, - const uint8_t *byt, - uint64_t *out, - ur_coin64_f coin, - ur_cons64_f cons) -{ - ur_dict64_t dict = {0}; - ur_dict64_grow(r, &dict, ur_fib11, ur_fib12); - - ur_cue_res_e res = ur_cue_walk64_unsafe(r, &dict, len, - byt, out, coin, cons); - - ur_dict_free((ur_dict_t*)&dict); - return res; -} +typedef struct _cue_stack_s { + uint32_t prev; + uint32_t size; + uint32_t fill; + _cue_frame_t* f; +} _cue_stack_t; static inline ur_cue_res_e _cue_next(ur_root_t *r, - _cue64_stack_t *s, + _cue_stack_t *s, ur_bsr_t *bsr, ur_dict64_t *dict, ur_nref *out) @@ -447,8 +140,8 @@ _cue_next(ur_root_t *r, // save a head-frame and read the head from the stream // { - _cue64_frame_t* f = &(s->f[s->fill++]); - f->ref = CUE_HEAD64; + _cue_frame_t* f = &(s->f[s->fill++]); + f->ref = CUE_HEAD; f->bits = bits; } continue; @@ -511,7 +204,7 @@ ur_cue_unsafe(ur_root_t *r, ur_nref *out) { ur_bsr_t bsr = {0}; - _cue64_stack_t s = {0}; + _cue_stack_t s = {0}; ur_cue_res_e res; ur_nref ref; @@ -535,11 +228,11 @@ ur_cue_unsafe(ur_root_t *r, while ( s.fill && (ur_cue_good == res) ) { // peek at the top of the stack // - _cue64_frame_t *f = &(s.f[s.fill - 1]); + _cue_frame_t *f = &(s.f[s.fill - 1]); // f is a head-frame; stash result and read the tail from the stream // - if ( CUE_HEAD64 == f->ref ) { + if ( CUE_HEAD == f->ref ) { f->ref = ref; res = _cue_next(r, &s, &bsr, dict, &ref); } @@ -575,6 +268,13 @@ ur_cue(ur_root_t *r, return res; } +/* +** stack frame for recording head vs tail iteration +** +** [hed=? bits=@] +** +*/ + typedef struct _cue_test_frame_s { ur_bool_t tal; uint64_t bits; From 11e7afdefcd05301a5b296c177c6278c8803b613 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 26 Aug 2020 13:17:18 -0700 Subject: [PATCH 220/933] u3: adds u3s_cue_xeno() --- pkg/urbit/include/noun/serial.h | 5 + pkg/urbit/noun/serial.c | 206 ++++++++++++++++++++++++++++++++ 2 files changed, 211 insertions(+) diff --git a/pkg/urbit/include/noun/serial.h b/pkg/urbit/include/noun/serial.h index c81e95d6db..2e07378a4e 100644 --- a/pkg/urbit/include/noun/serial.h +++ b/pkg/urbit/include/noun/serial.h @@ -34,3 +34,8 @@ */ u3_noun u3s_cue(u3_atom a); + + /* u3s_cue_xeno(): cue onto the loom, bookkeeping off the loom. + */ + u3_noun + u3s_cue_xeno(c3_d len_d, const c3_y* byt_y); diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index 9accdf733d..589fd0bfc5 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -6,6 +6,7 @@ #include #include "all.h" +#include "ur/ur.h" /* _cs_met0_w(): safe bitwidth for any c3_w */ @@ -726,3 +727,208 @@ u3s_cue(u3_atom a) return pro; } + +/* +** stack frame for recording head vs tail iteration +** +** $? [u3_none bits=@] +** [hed=* bits=@] +*/ +typedef struct _cue_frame_s { + u3_weak ref; + c3_d bit_d; +} _cue_frame_t; + +typedef struct _cue_stack_s { + c3_w pre_w; + c3_w siz_w; + c3_w fil_w; + _cue_frame_t* fam_u; +} _cue_stack_t; + +/* _cs_cue_xeno_next(): read next value from bitstream, bookkeeping off-loom. +*/ +static inline ur_cue_res_e +_cs_cue_xeno_next(_cue_stack_t* tac_u, + ur_bsr_t* red_u, + ur_dict32_t* dic_u, + u3_noun* out) +{ + ur_root_t* rot_u = 0; + + while ( 1 ) { + c3_d len_d, bit_d = red_u->bits; + ur_cue_tag_e tag_e; + ur_cue_res_e res_e; + + if ( ur_cue_good != (res_e = ur_bsr_tag(red_u, &tag_e)) ) { + return res_e; + } + + switch ( tag_e ) { + default: c3_assert(0); + + case ur_jam_cell: { + // reallocate the stack if full + // + if ( tac_u->fil_w == tac_u->siz_w ) { + c3_w nex_w = tac_u->pre_w + tac_u->siz_w; + tac_u->fam_u = c3_realloc(tac_u->fam_u, nex_w * sizeof(*tac_u->fam_u)); + tac_u->pre_w = tac_u->siz_w; + tac_u->siz_w = nex_w; + } + + // save a head-frame and read the head from the stream + // + { + _cue_frame_t* fam_u = &(tac_u->fam_u[tac_u->fil_w++]); + fam_u->ref = u3_none; + fam_u->bit_d = bit_d; + } + continue; + } + + case ur_jam_back: { + if ( ur_cue_good != (res_e = ur_bsr_rub_len(red_u, &len_d)) ) { + return res_e; + } + else if ( 62 < len_d ) { + return ur_cue_meme; + } + else { + c3_d bak_d = ur_bsr64_any(red_u, len_d); + c3_w bak_w; + + if ( !ur_dict32_get(rot_u, dic_u, bak_d, &bak_w) ) { + // XX distinguish bad backref? + // + return ur_cue_gone; + } + else { + *out = u3k((u3_noun)bak_w); + return ur_cue_good; + } + } + } + + case ur_jam_atom: { + if ( ur_cue_good != (res_e = ur_bsr_rub_len(red_u, &len_d)) ) { + return res_e; + } + + if ( 31 >= len_d ) { + *out = (u3_noun)ur_bsr32_any(red_u, len_d); + } + // XX need a ur_bsr_words_any() + // + else { + c3_d byt_d = (len_d >> 3) + !!ur_mask_3(len_d); + c3_y* byt_y; + + // XX check that byt_d fits in a c3_w; + + byt_y = c3_calloc(byt_d); + ur_bsr_bytes_any(red_u, len_d, byt_y); + + *out = u3i_bytes(byt_d, byt_y); + + c3_free(byt_y); + } + + ur_dict32_put(rot_u, dic_u, bit_d, *out); + return ur_cue_good; + } + } + } +} + +/* _cs_cue_xeno_unsafe(): cue onto the loom, all bookkeeping off-loom. +*/ +static ur_cue_res_e +_cs_cue_xeno_unsafe(ur_dict32_t* dic_u, + c3_d len_d, + const c3_y* byt_y, + u3_noun* out) +{ + ur_bsr_t red_u = {0}; + _cue_stack_t tac_u = {0}; + ur_cue_res_e res_e; + u3_noun ref; + + // init bitstream-reader + // + red_u.left = len_d; + red_u.bytes = byt_y; + + // setup stack + // + tac_u.pre_w = ur_fib10; + tac_u.siz_w = ur_fib11; + tac_u.fam_u = c3_malloc(tac_u.siz_w * sizeof(*tac_u.fam_u)); + + // advance into stream + // + res_e = _cs_cue_xeno_next(&tac_u, &red_u, dic_u, &ref); + + // process result + // + while ( tac_u.fil_w && (ur_cue_good == res_e) ) { + // peek at the top of the stack + // + _cue_frame_t* fam_u = &(tac_u.fam_u[tac_u.fil_w - 1]); + + // f is a head-frame; stash result and read the tail from the stream + // + if ( u3_none == fam_u->ref ) { + fam_u->ref = ref; + res_e = _cs_cue_xeno_next(&tac_u, &red_u, dic_u, &ref); + } + // f is a tail-frame; pop the stack and continue + // + else { + ur_root_t* rot_u = 0; + + ref = u3nc(fam_u->ref, ref); + ur_dict32_put(rot_u, dic_u, fam_u->bit_d, ref); + tac_u.fil_w--; + } + } + + c3_free(tac_u.fam_u); + + if ( ur_cue_good == res_e ) { + *out = ref; + } + return res_e; +} + +/* u3s_cue_xeno(): cue onto the loom, bookkeeping off the loom. +*/ +u3_noun +u3s_cue_xeno(c3_d len_d, const c3_y* byt_y) +{ + ur_dict32_t dic_u = {0}; + ur_cue_res_e res_e; + u3_noun pro; + + c3_assert( &(u3H->rod_u) == u3R ); + + // XX tune the initial dictionary size for less reallocation + // + { + ur_root_t* rot_u = 0; + ur_dict32_grow(rot_u, &dic_u, ur_fib33, ur_fib34); + } + + // errors are fatal + // + if ( ur_cue_good != + (res_e = _cs_cue_xeno_unsafe(&dic_u, len_d, byt_y, &pro)) ) + { + fprintf(stderr, "cue xeno: failed\r\n"); + exit(1); + } + + ur_dict_free((ur_dict_t*)&dic_u); + return pro; +} From 24b91af8885159cbd53db481392b043fcd4ad393 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 25 Aug 2020 17:43:36 -0700 Subject: [PATCH 221/933] u3: refactors _cu_rock_save(), splitting out path/directory format/creation --- pkg/urbit/noun/urth.c | 91 +++++++++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 38 deletions(-) diff --git a/pkg/urbit/noun/urth.c b/pkg/urbit/noun/urth.c index adfd8c7dc1..14c1885f69 100644 --- a/pkg/urbit/noun/urth.c +++ b/pkg/urbit/noun/urth.c @@ -444,49 +444,21 @@ u3u_uniq(void) ur_hcon_free(rot_u); } +/* _cu_rock_path_make(): format rock path, creating directory if necessary.. +*/ static c3_o -_cu_rock_save(c3_c* dir_c, c3_d eve_d, c3_d len_d, c3_y* byt_y) +_cu_rock_path_make(c3_c* dir_c, c3_d eve_d, c3_c** out_c) { - c3_i fid_i; + c3_w nam_w = 1 + snprintf(0, 0, "%s/.urb/roc/%" PRIu64 ".jam", dir_c, eve_d); + c3_c* nam_c = c3_malloc(nam_w); + c3_i ret_i; - // open rock file, creating the containing directory if necessary + // create $pier/.urb/roc, if it doesn't exist + // + // NB, $pier/.urb is guaranteed to already exist // { - c3_w nam_w = 1 + snprintf(0, 0, "%s/.urb/roc/%" PRIu64 ".jam", dir_c, eve_d); - c3_c* nam_c = c3_malloc(nam_w); - c3_i ret_i; - - // create $pier/.urb/roc, if it doesn't exist - // - // NB, $pier/.urb is guaranteed to already exist - // - { - ret_i = snprintf(nam_c, nam_w, "%s/.urb/roc", dir_c); - - if ( ret_i < 0 ) { - fprintf(stderr, "rock: path format failed (%s, %" PRIu64 "): %s\r\n", - dir_c, eve_d, strerror(errno)); - c3_free(nam_c); - return c3n; - } - else if ( ret_i >= nam_w ) { - fprintf(stderr, "rock: path format failed (%s, %" PRIu64 "): truncated\r\n", - dir_c, eve_d); - c3_free(nam_c); - return c3n; - } - - if ( mkdir(nam_c, 0700) - && (EEXIST != errno) ) - { - fprintf(stderr, "rock: directory create failed (%s, %" PRIu64 "): %s\r\n", - dir_c, eve_d, strerror(errno)); - c3_free(nam_c); - return c3n; - } - } - - ret_i = snprintf(nam_c, nam_w, "%s/.urb/roc/%" PRIu64 ".jam", dir_c, eve_d); + ret_i = snprintf(nam_c, nam_w, "%s/.urb/roc", dir_c); if ( ret_i < 0 ) { fprintf(stderr, "rock: path format failed (%s, %" PRIu64 "): %s\r\n", @@ -501,6 +473,49 @@ _cu_rock_save(c3_c* dir_c, c3_d eve_d, c3_d len_d, c3_y* byt_y) return c3n; } + if ( mkdir(nam_c, 0700) + && (EEXIST != errno) ) + { + fprintf(stderr, "rock: directory create failed (%s, %" PRIu64 "): %s\r\n", + dir_c, eve_d, strerror(errno)); + c3_free(nam_c); + return c3n; + } + } + + ret_i = snprintf(nam_c, nam_w, "%s/.urb/roc/%" PRIu64 ".jam", dir_c, eve_d); + + if ( ret_i < 0 ) { + fprintf(stderr, "rock: path format failed (%s, %" PRIu64 "): %s\r\n", + dir_c, eve_d, strerror(errno)); + c3_free(nam_c); + return c3n; + } + else if ( ret_i >= nam_w ) { + fprintf(stderr, "rock: path format failed (%s, %" PRIu64 "): truncated\r\n", + dir_c, eve_d); + c3_free(nam_c); + return c3n; + } + + *out_c = nam_c; + return c3y; +} + +static c3_o +_cu_rock_save(c3_c* dir_c, c3_d eve_d, c3_d len_d, c3_y* byt_y) +{ + c3_i fid_i; + + // open rock file, creating the containing directory if necessary + // + { + c3_c* nam_c; + + if ( c3n == _cu_rock_path_make(dir_c, eve_d, &nam_c) ) { + return c3n; + } + if ( -1 == (fid_i = open(nam_c, O_RDWR | O_CREAT | O_TRUNC, 0644)) ) { fprintf(stderr, "rock: open failed (%s, %" PRIu64 "): %s\r\n", dir_c, eve_d, strerror(errno)); From dd8a74cea255ecd00b1c6155427ec097e225eeb8 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 25 Aug 2020 17:45:17 -0700 Subject: [PATCH 222/933] u3: replaces u3_serf_uncram with u3u_uncram() --- pkg/urbit/include/noun/urth.h | 4 + pkg/urbit/include/vere/serf.h | 5 -- pkg/urbit/noun/urth.c | 161 ++++++++++++++++++++++++++++++++++ pkg/urbit/worker/main.c | 14 ++- pkg/urbit/worker/serf.c | 91 ++----------------- 5 files changed, 185 insertions(+), 90 deletions(-) diff --git a/pkg/urbit/include/noun/urth.h b/pkg/urbit/include/noun/urth.h index 988920e602..7320d3b329 100644 --- a/pkg/urbit/include/noun/urth.h +++ b/pkg/urbit/include/noun/urth.h @@ -11,3 +11,7 @@ */ c3_o u3u_cram(c3_c* dir_c, c3_d eve_d); + /* u3u_uncram(): restore persistent state from a rock. + */ + c3_o + u3u_uncram(c3_c* dir_c, c3_d eve_d); diff --git a/pkg/urbit/include/vere/serf.h b/pkg/urbit/include/vere/serf.h index 12647dbb6a..004e297511 100644 --- a/pkg/urbit/include/vere/serf.h +++ b/pkg/urbit/include/vere/serf.h @@ -24,11 +24,6 @@ u3_noun u3_serf_init(u3_serf* sef_u); - /* u3_serf_uncram(): initialize from rock at [eve_d]. - */ - void - u3_serf_uncram(u3_serf* sef_u, c3_d eve_d); - /* u3_serf_writ(): apply writ [wit], producing plea [*pel] on c3y. */ c3_o diff --git a/pkg/urbit/noun/urth.c b/pkg/urbit/noun/urth.c index 14c1885f69..442d15587a 100644 --- a/pkg/urbit/noun/urth.c +++ b/pkg/urbit/noun/urth.c @@ -444,6 +444,34 @@ u3u_uniq(void) ur_hcon_free(rot_u); } +/* _cu_rock_path(): format rock path. +*/ +static c3_o +_cu_rock_path(c3_c* dir_c, c3_d eve_d, c3_c** out_c) +{ + c3_w nam_w = 1 + snprintf(0, 0, "%s/.urb/roc/%" PRIu64 ".jam", dir_c, eve_d); + c3_c* nam_c = c3_malloc(nam_w); + c3_i ret_i; + + ret_i = snprintf(nam_c, nam_w, "%s/.urb/roc/%" PRIu64 ".jam", dir_c, eve_d); + + if ( ret_i < 0 ) { + fprintf(stderr, "rock: path format failed (%s, %" PRIu64 "): %s\r\n", + dir_c, eve_d, strerror(errno)); + c3_free(nam_c); + return c3n; + } + else if ( ret_i >= nam_w ) { + fprintf(stderr, "rock: path format failed (%s, %" PRIu64 "): truncated\r\n", + dir_c, eve_d); + c3_free(nam_c); + return c3n; + } + + *out_c = nam_c; + return c3y; +} + /* _cu_rock_path_make(): format rock path, creating directory if necessary.. */ static c3_o @@ -628,3 +656,136 @@ u3u_cram(c3_c* dir_c, c3_d eve_d) return ret_o; } + +/* _cu_rock_load(): load a rock into a byte buffer. +*/ +static c3_o +_cu_rock_load(c3_c* dir_c, c3_d eve_d, c3_d* out_d, c3_y** out_y) +{ + c3_i fid_i; + c3_d len_d; + + // open rock file + // + { + c3_c* nam_c; + + if ( c3n == _cu_rock_path(dir_c, eve_d, &nam_c) ) { + return c3n; + } + + if ( -1 == (fid_i = open(nam_c, O_RDONLY, 0644)) ) { + fprintf(stderr, "rock: open failed (%s, %" PRIu64 "): %s\r\n", + dir_c, eve_d, strerror(errno)); + c3_free(nam_c); + return c3n; + } + + c3_free(nam_c); + } + + // measure rock file + // + { + struct stat buf_b; + + if ( -1 == fstat(fid_i, &buf_b) ) { + fprintf(stderr, "rock: stat failed (%s, %" PRIu64 "): %s\r\n", + dir_c, eve_d, strerror(errno)); + close(fid_i); + return c3n; + } + + len_d = buf_b.st_size; + } + + // mmap rock file + // + { + void* ptr_v; + + if ( MAP_FAILED == (ptr_v = mmap(0, len_d, PROT_READ, MAP_SHARED, fid_i, 0)) ) { + fprintf(stderr, "rock: mmap failed (%s, %" PRIu64 "): %s\r\n", + dir_c, eve_d, strerror(errno)); + close(fid_i); + return c3n; + } + + *out_d = len_d; + *out_y = (c3_y*)ptr_v; + } + + close(fid_i); + + return c3y; +} + +/* u3u_uncram(): restore persistent state from a rock. +*/ +c3_o +u3u_uncram(c3_c* dir_c, c3_d eve_d) +{ + c3_d len_d; + c3_y* byt_y; + + // load rock file into buffer + // + if ( c3n == _cu_rock_load(dir_c, eve_d, &len_d, &byt_y) ) { + return c3n; + } + + // bypassing page tracking as an optimization + // + // NB: u3e_yolo() will mark all as dirty, and + // u3e_save() will reinstate protection flags + // + if ( c3n == u3e_yolo() ) { + fprintf(stderr, "uncram: unable to bypass page tracking, continuing\r\n"); + } + + // reinitialize loom + // + // NB: hot jet state is not yet re-established + // + u3m_pave(c3y, c3n); + + // cue rock, restore persistent state + // + // XX errors are fatal, barring a full "u3m_reboot"-type operation. + // + { + u3_noun roc, cod, ref = u3s_cue_xeno(len_d, byt_y); + + if ( u3r_pq(ref, c3__fast, &roc, &cod) ) { + u3z(ref); + fprintf(stderr, "uncram: failed: invalid rock format\r\n"); + exit(1); + } + + u3A->roc = u3k(roc); + u3j_load(u3k(cod)); + + u3z(ref); + } + + // allocate new hot jet state; re-establish warm + // + u3j_boot(c3y); + u3j_ream(); + + // restore event number + // + u3A->ent_d = eve_d; + + // mark all pages dirty + // + u3e_foul(); + + // leave rocks on disk + // + // if ( c3n == u3m_rock_drop(dir_c, eve_d) ) { + // u3l_log("serf: warning: orphaned state file\r\n"); + // } + + return c3y; +} diff --git a/pkg/urbit/worker/main.c b/pkg/urbit/worker/main.c index 8cd196a0ac..d7060d6b44 100644 --- a/pkg/urbit/worker/main.c +++ b/pkg/urbit/worker/main.c @@ -189,7 +189,12 @@ _cw_serf_commence(c3_i argc, c3_c* argv[]) u3V.sen_d = u3V.dun_d = u3m_boot(dir_c); if ( eve_d ) { - u3_serf_uncram(&u3V, eve_d); + // XX need not be fatal, need a u3m_reboot equivalent + // + if ( c3n == u3u_uncram(u3V.dir_c, eve_d) ) { + fprintf(stderr, "serf (%" PRIu64 "): rock load failed\r\n", eve_d); + exit(1); + } } } @@ -292,7 +297,12 @@ _cw_queu(c3_i argc, c3_c* argv[]) memset(&u3V, 0, sizeof(u3V)); u3V.dir_c = strdup(dir_c); u3V.sen_d = u3V.dun_d = u3m_boot(dir_c); - u3_serf_uncram(&u3V, eve_d); + + if ( c3n == u3u_uncram(dir_c, eve_d) ) { + fprintf(stderr, "urbit-worker: queu: failed\r\n"); + exit(1); + } + u3e_save(); fprintf(stderr, "urbit-worker: queu: rock loaded at event %" PRIu64 "\r\n", eve_d); diff --git a/pkg/urbit/worker/serf.c b/pkg/urbit/worker/serf.c index 8ddc30e48e..98215b979c 100644 --- a/pkg/urbit/worker/serf.c +++ b/pkg/urbit/worker/serf.c @@ -277,27 +277,6 @@ u3_serf_grab(void) fflush(stderr); } -/* _serf_cram(): deduplicate and compact memory. ORPHANED -*/ -static void -_serf_cram(u3_serf* sef_u) -{ - u3_serf_grab(); - - u3l_log("serf (%" PRIu64 "): compacting loom\r\n", sef_u->dun_d); - - if ( c3n == u3m_rock_stay(sef_u->dir_c, sef_u->dun_d) ) { - u3l_log("serf: unable to jam state\r\n"); - return; - } - - u3_serf_uncram(sef_u, sef_u->dun_d); - - u3l_log("serf (%" PRIu64 "): compacted loom\r\n", sef_u->dun_d); - - u3_serf_grab(); -} - /* u3_serf_post(): update serf state post-writ. */ void @@ -971,11 +950,18 @@ u3_serf_live(u3_serf* sef_u, u3_noun com, u3_noun* ret) u3l_log("serf (%" PRIu64 "): saving rock\r\n", sef_u->dun_d); - if ( c3n == u3m_rock_stay(sef_u->dir_c, eve_d) ) { + if ( c3n == u3u_cram(sef_u->dir_c, eve_d) ) { fprintf(stderr, "serf (%" PRIu64 "): unable to jam state\r\n", eve_d); return c3n; } + if ( u3r_mug(u3A->roc) != sef_u->mug_l ) { + fprintf(stderr, "serf (%" PRIu64 "): mug mismatch 0x%08x 0x%08x\r\n", + eve_d, sef_u->mug_l, u3r_mug(u3A->roc)); + return c3n; + } + + u3e_save(); u3_serf_grab(); *ret = u3nc(c3__live, u3_nul); @@ -1120,67 +1106,6 @@ _serf_ripe(u3_serf* sef_u) return u3nc(u3i_chubs(1, &sef_u->dun_d), sef_u->mug_l); } -/* u3_serf_uncram(): initialize from rock at [eve_d]. -*/ -void -u3_serf_uncram(u3_serf* sef_u, c3_d eve_d) -{ - c3_o roc_o; - c3_c nam_c[8193]; - snprintf(nam_c, 8192, "%s/.urb/roc/%" PRIu64 ".jam", sef_u->dir_c, eve_d); - - struct stat buf_b; - c3_i fid_i = open(nam_c, O_RDONLY, 0644); - - if ( (fid_i < 0) || (fstat(fid_i, &buf_b) < 0) ) { - fprintf(stderr, "serf: rock: %s not found\r\n", nam_c); - roc_o = c3n; - } - else { - fprintf(stderr, "serf: rock: %s found\r\n", nam_c); - roc_o = c3y; - } - - close(fid_i); - - - if ( c3y == roc_o ) { - if ( c3n == u3e_hold() ) { - fprintf(stderr, "serf: unable to backup checkpoint\r\n"); - } - else { - u3m_wipe(); - - if ( c3n == u3m_rock_load(sef_u->dir_c, eve_d) ) { - fprintf(stderr, "serf: compaction failed, restoring checkpoint\r\n"); - - if ( c3n == u3e_fall() ) { - fprintf(stderr, "serf: unable to restore checkpoint\r\n"); - c3_assert(0); - } - } - - if ( c3n == u3e_drop() ) { - fprintf(stderr, "serf: warning: orphaned backup checkpoint file\r\n"); - } - - // leave rocks on disk - // - // if ( c3n == u3m_rock_drop(sef_u->dir_c, sef_u->dun_d) ) { - // u3l_log("serf: warning: orphaned state file\r\n"); - // } - - fprintf(stderr, "serf (%" PRIu64 "): compacted loom\r\n", eve_d); - - sef_u->sen_d = sef_u->dun_d = eve_d; - - // save now for flexibility - // - u3e_save(); - } - } -} - /* u3_serf_init(): init or restore, producing status. */ u3_noun From ac7d0731f66499e40e657491fa354bcbb31775d0 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 27 Aug 2020 12:46:55 -0700 Subject: [PATCH 223/933] u3: adds u3s_cue_smol/full/bytes/atom --- pkg/urbit/include/noun/serial.h | 20 ++ pkg/urbit/noun/serial.c | 368 +++++++++++++++++++++++++++++++- 2 files changed, 387 insertions(+), 1 deletion(-) diff --git a/pkg/urbit/include/noun/serial.h b/pkg/urbit/include/noun/serial.h index 2e07378a4e..53883e95a6 100644 --- a/pkg/urbit/include/noun/serial.h +++ b/pkg/urbit/include/noun/serial.h @@ -39,3 +39,23 @@ */ u3_noun u3s_cue_xeno(c3_d len_d, const c3_y* byt_y); + + /* u3s_cue_smol(): cue onto the loom, bitwidth fits in a direct atom. + */ + u3_noun + u3s_cue_smol(c3_w len_w, const c3_y* byt_y); + + /* u3s_cue_full(): cue onto the loom. + */ + u3_noun + u3s_cue_full(c3_d len_d, const c3_y* byt_y); + + /* u3s_cue_bytes(): cue bytes. + */ + u3_noun + u3s_cue_bytes(c3_d len_d, const c3_y* byt_y); + + /* u3s_cue_atom(): cue atom. + */ + u3_noun + u3s_cue_atom(u3_atom a); diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index 589fd0bfc5..be51e314e9 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -826,7 +826,7 @@ _cs_cue_xeno_next(_cue_stack_t* tac_u, c3_y* byt_y; // XX check that byt_d fits in a c3_w; - + // byt_y = c3_calloc(byt_d); ur_bsr_bytes_any(red_u, len_d, byt_y); @@ -932,3 +932,369 @@ u3s_cue_xeno(c3_d len_d, const c3_y* byt_y) ur_dict_free((ur_dict_t*)&dic_u); return pro; } + +/* _cs_cue_need(): bail on ur_cue_* read failures. +*/ +static inline void +_cs_cue_need(ur_cue_res_e res_e) +{ + if ( ur_cue_good == res_e ) { + return; + } + else { + c3_m mot_m = (ur_cue_meme == res_e) ? c3__meme : c3__exit; + u3m_bail(mot_m); + } +} + +/* _cs_cue_smol_next(): read next value from bitstream, direct-atom cursors. +*/ +static inline u3_noun +_cs_cue_smol_next(c3_ys mov, + c3_ys off, + u3p(u3h_root) har_p, + ur_bsr_t* red_u) +{ + while ( 1 ) { + c3_d len_d, bit_d = red_u->bits; + ur_cue_tag_e tag_e; + + _cs_cue_need(ur_bsr_tag(red_u, &tag_e)); + + switch ( tag_e ) { + default: c3_assert(0); + + case ur_jam_cell: { + // wind the stack + // + u3R->cap_p += mov; + + // ensure we haven't overflowed (ie, run into the heap) + // (off==0 means we're on a north road) + // + if ( 0 == off ) { + if( !(u3R->cap_p > u3R->hat_p) ) { + u3m_bail(c3__meme); + } + } + else { + if( !(u3R->cap_p < u3R->hat_p) ) { + u3m_bail(c3__meme); + } + } + + // save a head-frame and read the head from the stream + // + { + _cue_frame_t* fam_u = u3to(_cue_frame_t, u3R->cap_p + off); + fam_u->ref = u3_none; + fam_u->bit_d = bit_d; + } + continue; + } + + case ur_jam_back: { + _cs_cue_need(ur_bsr_rub_len(red_u, &len_d)); + + // XX review, s/b deterministic error + // + c3_assert( 32 > len_d ); + + { + c3_w bak_w = ur_bsr32_any(red_u, len_d); + u3_weak bak = u3h_get(har_p, (u3_noun)bak_w); + return u3x_good(bak); + } + } + + case ur_jam_atom: { + u3_atom vat; + + _cs_cue_need(ur_bsr_rub_len(red_u, &len_d)); + + if ( 31 >= len_d ) { + vat = (u3_noun)ur_bsr32_any(red_u, len_d); + } + else { + c3_w byt_w = (len_d >> 3) + !!ur_mask_3(len_d); + c3_w* wor_w = u3a_slaq(3, byt_w); + // XX assumes little-endian + // XX need a ur_bsr_words_any() + // + c3_y* byt_y = (c3_y*)wor_w; + + ur_bsr_bytes_any(red_u, len_d, byt_y); + vat = u3a_malt(wor_w); + } + + u3h_put(har_p, (u3_noun)(c3_w)bit_d, u3k(vat)); + + return vat; + } + } + } +} + +/* u3s_cue_smol(): cue onto the loom, bitwidth fits in a direct atom. +*/ +u3_noun +u3s_cue_smol(c3_w len_w, const c3_y* byt_y) +{ + ur_bsr_t red_u = {0}; + u3_noun ref; + + c3_assert( 0x10000000 >= len_w ); + + // initialize a hash table for dereferencing backrefs + // + u3p(u3h_root) har_p = u3h_new(); + const u3_post top_p = u3R->cap_p; + + // initialize signed stack offsets (relative to north/south road) + // + c3_ys mov, off; + { + c3_o nor_o = u3a_is_north(u3R); + c3_y wis_y = c3_wiseof(_cue_frame_t); + mov = ( c3y == nor_o ? -wis_y : wis_y ); + off = ( c3y == nor_o ? 0 : -wis_y ); + } + + // init bitstream-reader + // + red_u.left = len_w; + red_u.bytes = byt_y; + + // advance into stream + // + ref = _cs_cue_smol_next(mov, off, har_p, &red_u); + + // process result + // + while ( top_p != u3R->cap_p ) { + // peek at the top of the stack + // + _cue_frame_t* fam_u = u3to(_cue_frame_t, u3R->cap_p + off); + + // f is a head-frame; stash result and read the tail from the stream + // + if ( u3_none == fam_u->ref ) { + fam_u->ref = ref; + ref = _cs_cue_smol_next(mov, off, har_p, &red_u); + } + // f is a tail-frame; pop the stack and continue + // + else { + ref = u3nc(fam_u->ref, ref); + u3h_put(har_p, (u3_noun)(c3_w)fam_u->bit_d, u3k(ref)); + u3R->cap_p -= mov; + } + } + + u3h_free(har_p); + + return ref; +} + +/* _cs_cue_get(): u3h_get wrapper handling allocation and refcounts. +*/ +static inline u3_weak +_cs_cue_get(u3p(u3h_root) har_p, c3_d key_d) +{ + u3_atom key = u3i_chubs(1, &key_d); + u3_weak pro = u3h_get(har_p, key); + u3z(key); + return pro; +} + +/* _cs_cue_put(): u3h_put wrapper handling allocation and refcounts. +*/ +static inline u3_noun +_cs_cue_put(u3p(u3h_root) har_p, c3_d key_d, u3_noun val) +{ + u3_atom key = u3i_chubs(1, &key_d); + u3h_put(har_p, key, u3k(val)); + u3z(key); + return val; +} + +/* _cs_cue_full_next(): read next value from bitstream. +*/ +static inline u3_noun +_cs_cue_full_next(c3_ys mov, + c3_ys off, + u3p(u3h_root) har_p, + ur_bsr_t* red_u) +{ + while ( 1 ) { + c3_d len_d, bit_d = red_u->bits; + ur_cue_tag_e tag_e; + + _cs_cue_need(ur_bsr_tag(red_u, &tag_e)); + + switch ( tag_e ) { + default: c3_assert(0); + + case ur_jam_cell: { + // wind the stack + // + u3R->cap_p += mov; + + // ensure we haven't overflowed (ie, run into the heap) + // (off==0 means we're on a north road) + // + if ( 0 == off ) { + if( !(u3R->cap_p > u3R->hat_p) ) { + u3m_bail(c3__meme); + } + } + else { + if( !(u3R->cap_p < u3R->hat_p) ) { + u3m_bail(c3__meme); + } + } + + // save a head-frame and read the head from the stream + // + { + _cue_frame_t* fam_u = u3to(_cue_frame_t, u3R->cap_p + off); + fam_u->ref = u3_none; + fam_u->bit_d = bit_d; + } + continue; + } + + case ur_jam_back: { + _cs_cue_need(ur_bsr_rub_len(red_u, &len_d)); + + if ( 62 < len_d ) { + return u3m_bail(c3__meme); + } + else { + c3_d bak_d = ur_bsr64_any(red_u, len_d); + u3_weak bak = _cs_cue_get(har_p, bak_d); + return u3x_good(bak); + } + } + + case ur_jam_atom: { + u3_atom vat; + + _cs_cue_need(ur_bsr_rub_len(red_u, &len_d)); + + if ( 31 >= len_d ) { + vat = (u3_noun)ur_bsr32_any(red_u, len_d); + } + // XX need a ur_bsr_words_any() + // + else { + // XX check that byt_d fits in a c3_w; + // + c3_d byt_d = (len_d >> 3) + !!ur_mask_3(len_d); + c3_w* wor_w = u3a_slaq(3, byt_d); + // XX assumes little-endian + // + c3_y* byt_y = (c3_y*)wor_w; + + ur_bsr_bytes_any(red_u, len_d, byt_y); + + vat = u3a_malt(wor_w); + } + + return _cs_cue_put(har_p, bit_d, vat); + } + } + } +} + +/* u3s_cue_full(): cue onto the loom. +*/ +u3_noun +u3s_cue_full(c3_d len_d, const c3_y* byt_y) +{ + ur_bsr_t red_u = {0}; + u3_noun ref; + + // initialize a hash table for dereferencing backrefs + // + u3p(u3h_root) har_p = u3h_new(); + const u3_post top_p = u3R->cap_p; + + // initialize signed stack offsets (relative to north/south road) + // + c3_ys mov, off; + { + c3_o nor_o = u3a_is_north(u3R); + c3_y wis_y = c3_wiseof(_cue_frame_t); + mov = ( c3y == nor_o ? -wis_y : wis_y ); + off = ( c3y == nor_o ? 0 : -wis_y ); + } + + // init bitstream-reader + // + red_u.left = len_d; + red_u.bytes = byt_y; + + // advance into stream + // + ref = _cs_cue_full_next(mov, off, har_p, &red_u); + + // process result + // + while ( top_p != u3R->cap_p ) { + // peek at the top of the stack + // + _cue_frame_t* fam_u = u3to(_cue_frame_t, u3R->cap_p + off); + + // f is a head-frame; stash result and read the tail from the stream + // + if ( u3_none == fam_u->ref ) { + fam_u->ref = ref; + ref = _cs_cue_full_next(mov, off, har_p, &red_u); + } + // f is a tail-frame; pop the stack and continue + // + else { + ref = u3nc(fam_u->ref, ref); + _cs_cue_put(har_p, fam_u->bit_d, ref); + u3R->cap_p -= mov; + } + } + + u3h_free(har_p); + + return ref; +} + +/* u3s_cue_bytes(): cue bytes. +*/ +u3_noun +u3s_cue_bytes(c3_d len_d, const c3_y* byt_y) +{ + // check if we can bitwise-index [len_d] bytes in a direct atom + // + return ( 0x10000000ULL >= len_d ) + ? u3s_cue_smol(len_d, byt_y) + : u3s_cue_full(len_d, byt_y); +} + +/* u3s_cue_atom(): cue atom. +*/ +u3_noun +u3s_cue_atom(u3_atom a) +{ + c3_w len_w = u3r_met(3, a); + c3_y* byt_y; + + // XX assumes little-endian + // + if ( c3y == u3a_is_cat(a) ) { + byt_y = (c3_y*)&a; + } + else { + u3a_atom* vat_u = u3a_to_ptr(a); + byt_y = (c3_y*)vat_u->buf_w; + } + + return u3s_cue_bytes((c3_d)len_w, byt_y); +} From baf8b884faa4303e696691ee23a8e0723b98bf8c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 27 Aug 2020 13:51:30 -0700 Subject: [PATCH 224/933] u3: adds u3s_jam_xeno() --- pkg/urbit/include/noun/serial.h | 5 ++ pkg/urbit/noun/serial.c | 127 +++++++++++++++++++++++++++++++- 2 files changed, 130 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/include/noun/serial.h b/pkg/urbit/include/noun/serial.h index 53883e95a6..96a39bcd84 100644 --- a/pkg/urbit/include/noun/serial.h +++ b/pkg/urbit/include/noun/serial.h @@ -30,6 +30,11 @@ c3_o u3s_jam_file(u3_noun a, c3_c* pas_c); + /* u3s_jam_xeno(): jam with off-loom buffer (re-)allocation. + */ + c3_d + u3s_jam_xeno(u3_noun a, c3_d* len_d, c3_y** byt_y); + /* u3s_cue(): cue [a] */ u3_noun diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index be51e314e9..26cd330af9 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -502,6 +502,129 @@ u3s_jam_file(u3_noun a, c3_c* pas_c) } } +typedef struct _jam_xeno_s { + u3p(u3h_root) har_p; + ur_bsw_t rit_u; +} _jam_xeno_t; + +/* _cs_coin_chub(): shortcircuit u3i_chubs(). +*/ +static inline u3_atom +_cs_coin_chub(c3_d a_d) +{ + return ( 0x7fffffffULL >= a_d ) ? a_d : u3i_chubs(1, &a_d); +} + +/* _cs_jam_xeno_atom(): encode in/direct atom in bitstream. +*/ +static inline void +_cs_jam_bsw_atom(ur_bsw_t* rit_u, c3_w met_w, u3_atom a) +{ + if ( c3y == u3a_is_cat(a) ) { + // XX need a ur_bsw_atom32() + // + ur_bsw_atom64(rit_u, (c3_y)met_w, (c3_d)a); + } + else { + u3a_atom* vat_u = u3a_to_ptr(a); + // XX assumes little-endian + // XX need a ur_bsw_atom_words() + // + c3_y* byt_y = (c3_y*)vat_u->buf_w; + ur_bsw_atom_bytes(rit_u, (c3_d)met_w, byt_y); + } +} + +/* _cs_jam_bsw_back(): encode in/direct backref in bitstream. +*/ +static inline void +_cs_jam_bsw_back(ur_bsw_t* rit_u, c3_w met_w, u3_atom a) +{ + c3_d bak_d = ( c3y == u3a_is_cat(a) ) + ? (c3_d)a + : u3r_chub(0, a); + + // XX need a ur_bsw_back32() + // + ur_bsw_back64(rit_u, (c3_y)met_w, bak_d); +} + +/* _cs_jam_xeno_atom(): encode atom or backref in bitstream. +*/ +static void +_cs_jam_xeno_atom(u3_atom a, void* ptr_v) +{ + _jam_xeno_t* jam_u = ptr_v; + ur_bsw_t* rit_u = &(jam_u->rit_u); + u3_weak bak = u3h_git(jam_u->har_p, a); + c3_w met_w = u3r_met(0, a); + + if ( u3_none == bak ) { + u3h_put(jam_u->har_p, a, _cs_coin_chub(rit_u->bits)); + _cs_jam_bsw_atom(rit_u, met_w, a); + } + else { + c3_w bak_w = u3r_met(0, bak); + + if ( met_w <= bak_w ) { + _cs_jam_bsw_atom(rit_u, met_w, a); + } + else { + _cs_jam_bsw_back(rit_u, bak_w, bak); + } + } +} + +/* _cs_jam_xeno_cell(): encode cell or backref in bitstream. +*/ +static c3_o +_cs_jam_xeno_cell(u3_noun a, void* ptr_v) +{ + _jam_xeno_t* jam_u = ptr_v; + ur_bsw_t* rit_u = &(jam_u->rit_u); + u3_weak bak = u3h_git(jam_u->har_p, a); + + if ( u3_none == bak ) { + u3h_put(jam_u->har_p, a, _cs_coin_chub(rit_u->bits)); + ur_bsw_cell(rit_u); + return c3y; + } + else { + _cs_jam_bsw_back(rit_u, u3r_met(0, bak), bak); + return c3n; + } +} + +/* u3s_jam_xeno(): jam with off-loom buffer (re-)allocation. +*/ +c3_d +u3s_jam_xeno(u3_noun a, c3_d* len_d, c3_y** byt_y) +{ + _jam_xeno_t jam_u = {0}; + + c3_assert( &(u3H->rod_u) == u3R ); + + jam_u.har_p = u3h_new(); + + jam_u.rit_u.prev = ur_fib11; + jam_u.rit_u.size = ur_fib12; + jam_u.rit_u.bytes = c3_calloc(jam_u.rit_u.size); + + // as this is a hot path, we unsafely elide overflow checks + // + // a page-fault overflow detection system is urgently needed ... + // + u3a_walk_fore_unsafe(a, &jam_u, _cs_jam_xeno_atom, + _cs_jam_xeno_cell); + + *len_d = jam_u.rit_u.fill + !!jam_u.rit_u.off; + *byt_y = jam_u.rit_u.bytes; + + u3h_free(jam_u.har_p); + + return jam_u.rit_u.bits; +} + #define CUE_ROOT 0 #define CUE_HEAD 1 #define CUE_TAIL 2 @@ -1101,7 +1224,7 @@ u3s_cue_smol(c3_w len_w, const c3_y* byt_y) static inline u3_weak _cs_cue_get(u3p(u3h_root) har_p, c3_d key_d) { - u3_atom key = u3i_chubs(1, &key_d); + u3_atom key = _cs_coin_chub(key_d); u3_weak pro = u3h_get(har_p, key); u3z(key); return pro; @@ -1112,7 +1235,7 @@ _cs_cue_get(u3p(u3h_root) har_p, c3_d key_d) static inline u3_noun _cs_cue_put(u3p(u3h_root) har_p, c3_d key_d, u3_noun val) { - u3_atom key = u3i_chubs(1, &key_d); + u3_atom key = _cs_coin_chub(key_d); u3h_put(har_p, key, u3k(val)); u3z(key); return val; From 9addb545c0f83f3511d8fc821b9a470e89aea27c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 27 Aug 2020 15:01:43 -0700 Subject: [PATCH 225/933] u3: refactors jam_tests to run all and capture results --- pkg/urbit/tests/jam_tests.c | 124 ++++++++++++++++++++++++------------ 1 file changed, 82 insertions(+), 42 deletions(-) diff --git a/pkg/urbit/tests/jam_tests.c b/pkg/urbit/tests/jam_tests.c index bc557c8572..b49f17827c 100644 --- a/pkg/urbit/tests/jam_tests.c +++ b/pkg/urbit/tests/jam_tests.c @@ -9,19 +9,21 @@ _setup(void) u3m_pave(c3y, c3n); } -/* _test_jam(): spot check jam/cue +/* _test_jam_spot_a(): spot check jam/cue */ -static void -_test_jam(void) +static c3_i +_test_jam_spot_a(void) { + c3_i ret_i = 1; + if ( 0xc != u3qe_jam(1) ) { fprintf(stderr, "jam: fail (a)\r\n"); - exit(1); + ret_i = 0; } if ( 1 != u3ke_cue(u3qe_jam(1)) ) { fprintf(stderr, "jam: fail (b)\r\n"); - exit(1); + ret_i = 0; } { @@ -29,12 +31,12 @@ _test_jam(void) if ( 0x1231 != u3qe_jam(a) ) { fprintf(stderr, "jam: fail (c)\r\n"); - exit(1); + ret_i = 0; } if ( c3y != u3r_sing(a, u3ke_cue(u3qe_jam(a))) ) { fprintf(stderr, "jam: fail (d)\r\n"); - exit(1); + ret_i = 0; } } @@ -43,28 +45,26 @@ _test_jam(void) if ( 0x344871 != u3qe_jam(a) ) { fprintf(stderr, "jam: fail (e)\r\n"); - exit(1); + ret_i = 0; } if ( c3y != u3r_sing(a, u3ke_cue(u3qe_jam(a))) ) { fprintf(stderr, "jam: fail (f)\r\n"); - exit(1); + ret_i = 0; } } { u3_noun a = u3nc(u3nc(1, 2), 3); - // fprintf(stderr, "%x\n", u3qe_jam(a)); - if ( 0x3448c5 != u3qe_jam(a) ) { fprintf(stderr, "jam: fail (g)\r\n"); - exit(1); + ret_i = 0; } if ( c3y != u3r_sing(a, u3ke_cue(u3qe_jam(a))) ) { fprintf(stderr, "jam: fail (h)\r\n"); - exit(1); + ret_i = 0; } } @@ -74,7 +74,7 @@ _test_jam(void) if ( c3y != u3r_sing(a, u3ke_cue(u3qe_jam(a))) ) { fprintf(stderr, "jam: fail (j)\r\n"); - exit(1); + ret_i = 0; } } @@ -84,7 +84,7 @@ _test_jam(void) if ( c3y != u3r_sing(a, u3ke_cue(u3qe_jam(a))) ) { fprintf(stderr, "jam: fail (k)\r\n"); - exit(1); + ret_i = 0; } } @@ -93,16 +93,20 @@ _test_jam(void) if ( c3y != u3r_sing(a, u3ke_cue(u3qe_jam(a))) ) { fprintf(stderr, "jam: fail (l)\r\n"); - exit(1); + ret_i = 0; } } + + return ret_i; } -/* _test_cue_jam(): more jam/cue spot-checking, ported from the 64-bit effort +/* _test_jam_spot_b(): more jam/cue spot-checking, ported from the 64-bit effort */ -static void -_test_cue_jam() +static c3_i +_test_jam_spot_b() { + c3_i ret_i = 1; + // the boot msg from the worker { u3_noun dat = u3_nul; @@ -114,13 +118,14 @@ _test_cue_jam() u3_noun tail_out = u3t(out_1); if (c3__play != head_out){ - printf("*** cue_jam 0 out head \n"); + fprintf(stderr, "*** cue_jam 0 out head\r\n"); + ret_i = 0; } if (u3_nul != tail_out){ - printf("*** cue_jam 0 out tail \n"); + fprintf(stderr, "*** cue_jam 0 out tail\r\n"); + ret_i = 0; } - } // the boot msg from the worker, again, @@ -144,7 +149,8 @@ _test_cue_jam() u3_noun jam_2 = u3i_bytes(len_w, buf_y); if ( c3n == u3r_sing(jam_1, jam_2) ) { - printf("*** error in 6 byte message\n"); + fprintf(stderr, "*** error in 6 byte message\r\n"); + ret_i = 0; } u3_noun out_1 = u3ke_cue(jam_2); @@ -153,13 +159,14 @@ _test_cue_jam() u3_noun tail_out = u3t(out_1); if (c3__play != head_out){ - printf("*** cue_jam 0 out head \n"); + fprintf(stderr, "*** cue_jam 0 out head\r\n"); + ret_i = 0; } if (u3_nul != tail_out){ - printf("*** cue_jam 0 out tail \n"); + fprintf(stderr, "*** cue_jam 0 out tail\r\n"); + ret_i = 0; } - } // 1 @@ -169,13 +176,15 @@ _test_cue_jam() u3_atom jam_1 = u3ke_jam(in_1); if (12 != jam_1){ - printf("*** cue_jam 1a \n"); + fprintf(stderr, "*** cue_jam 1a\r\n"); + ret_i = 0; } u3_noun out_1 = u3ke_cue(jam_1); if (1 != out_1){ - printf("*** cue_jam 1b \n"); + fprintf(stderr, "*** cue_jam 1b\r\n"); + ret_i = 0; } } @@ -186,7 +195,8 @@ _test_cue_jam() u3_atom jam_1 = u3ke_jam(in_1); if (817 != jam_1){ - printf("*** cue_jam 2 in \n"); + fprintf(stderr, "*** cue_jam 2 in\r\n"); + ret_i = 0; } u3_noun out_1 = u3ke_cue(jam_1); @@ -196,11 +206,13 @@ _test_cue_jam() u3_noun tail_out = u3t(out_1); if (1 != head_out){ - printf("*** cue_jam 2 out head \n"); + fprintf(stderr, "*** cue_jam 2 out head\r\n"); + ret_i = 0; } if (1 != tail_out){ - printf("*** cue_jam 2 out tail \n"); + fprintf(stderr, "*** cue_jam 2 out tail\r\n"); + ret_i = 0; } } @@ -211,7 +223,8 @@ _test_cue_jam() u3_atom jam_1 = u3ke_jam(in_1); if (4657 != jam_1){ - printf("*** cue_jam 2 in \n"); + fprintf(stderr, "*** cue_jam 2 in\r\n"); + ret_i = 0; } u3_noun out_1 = u3ke_cue(jam_1); @@ -220,11 +233,13 @@ _test_cue_jam() u3_noun tail_out = u3t(out_1); if (1 != head_out){ - printf("*** cue_jam 2 out head \n"); + fprintf(stderr, "*** cue_jam 2 out head\r\n"); + ret_i = 0; } if (2 != tail_out){ - printf("*** cue_jam 2 out tail \n"); + fprintf(stderr, "*** cue_jam 2 out tail\r\n"); + ret_i = 0; } } @@ -252,25 +267,49 @@ _test_cue_jam() u3_noun a2 = u3h(out_1); u3_noun r2 = u3t(out_1); if (a2 != a){ - printf("*** _cue_jam: complicated a\n"); + fprintf(stderr, "*** _cue_jam: complicated a\r\n"); + ret_i = 0; } u3_noun b2 = u3h(r2); u3_noun s2 = u3t(r2); if (b2 != b){ - printf("*** _cue_jam: complicated b\n"); + fprintf(stderr, "*** _cue_jam: complicated b\r\n"); + ret_i = 0; } u3_noun c2 = u3h(s2); u3_noun d2 = u3t(s2); if (c2 != c){ - printf("*** _cue_jam: complicated c\n"); + fprintf(stderr, "*** _cue_jam: complicated c\r\n"); + ret_i = 0; } if (d2 != d){ - printf("*** _cue_jam: complicated d\n"); + fprintf(stderr, "*** _cue_jam: complicated d\r\n"); + ret_i = 0; } } + + return 1; +} + +static c3_i +_test_jam(void) +{ + c3_i ret_i = 1; + + if ( !_test_jam_spot_a() ) { + fprintf(stderr, "test jam: spot a: failed\r\n"); + ret_i = 0; + } + + if ( !_test_jam_spot_b() ) { + fprintf(stderr, "test jam: spot b: failed\r\n"); + ret_i = 0; + } + + return ret_i; } /* main(): run all test cases. @@ -280,10 +319,11 @@ main(int argc, char* argv[]) { _setup(); - _test_jam(); - _test_cue_jam(); - - fprintf(stderr, "test_jam: ok\n"); + if ( !_test_jam() ) { + fprintf(stderr, "test jam: failed\r\n"); + exit(1); + } + fprintf(stderr, "test jam: ok\r\n"); return 0; } From 5b9c48c3fd629895ca486feae0179a1340b581dd Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 27 Aug 2020 15:12:57 -0700 Subject: [PATCH 226/933] u3: adds jam/cue roundtrip tests of new implementations --- pkg/urbit/noun/serial.c | 8 +- pkg/urbit/tests/jam_tests.c | 230 ++++++++++++++++++++++++++++++++++++ 2 files changed, 234 insertions(+), 4 deletions(-) diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index 26cd330af9..db04067a02 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -965,10 +965,10 @@ _cs_cue_xeno_next(_cue_stack_t* tac_u, } } -/* _cs_cue_xeno_unsafe(): cue onto the loom, all bookkeeping off-loom. +/* u3s_cue_xeno_unsafe(): cue onto the loom, all bookkeeping off-loom. */ -static ur_cue_res_e -_cs_cue_xeno_unsafe(ur_dict32_t* dic_u, +ur_cue_res_e +u3s_cue_xeno_unsafe(ur_dict32_t* dic_u, c3_d len_d, const c3_y* byt_y, u3_noun* out) @@ -1046,7 +1046,7 @@ u3s_cue_xeno(c3_d len_d, const c3_y* byt_y) // errors are fatal // if ( ur_cue_good != - (res_e = _cs_cue_xeno_unsafe(&dic_u, len_d, byt_y, &pro)) ) + (res_e = u3s_cue_xeno_unsafe(&dic_u, len_d, byt_y, &pro)) ) { fprintf(stderr, "cue xeno: failed\r\n"); exit(1); diff --git a/pkg/urbit/tests/jam_tests.c b/pkg/urbit/tests/jam_tests.c index b49f17827c..420ee3da0b 100644 --- a/pkg/urbit/tests/jam_tests.c +++ b/pkg/urbit/tests/jam_tests.c @@ -1,4 +1,13 @@ #include "all.h" +#include "ur/ur.h" + +// XX not declared in serial.h due to presence of ur_* types +// +ur_cue_res_e +u3s_cue_xeno_unsafe(ur_dict32_t* dic_u, + c3_d len_d, + const c3_y* byt_y, + u3_noun* out); /* _setup(): prepare for tests. */ @@ -294,6 +303,222 @@ _test_jam_spot_b() return 1; } +static void +_byte_print(c3_d out_d, + c3_y* out_y, + c3_w len_w, + const c3_y* byt_y) +{ + c3_d i_d; + + fprintf(stderr, " actual: { "); + for ( i_d = 0; i_d < out_d; i_d++ ) { + fprintf(stderr, "0x%x, ", out_y[i_d]); + } + fprintf(stderr, "}\r\n"); + fprintf(stderr, " expect: { "); + for ( i_d = 0; i_d < len_w; i_d++ ) { + fprintf(stderr, "0x%x, ", byt_y[i_d]); + } + fprintf(stderr, "}\r\n"); +} + +static c3_i +_test_jam_spec(const c3_c* cap_c, + u3_noun ref, + c3_w len_w, + const c3_y* byt_y) +{ + c3_i ret_i = 1; + c3_d out_d; + c3_y* out_y; + + { + u3s_jam_xeno(ref, &out_d, &out_y); + + if ( 0 != memcmp(out_y, byt_y, len_w) ) { + fprintf(stderr, "\033[31mjam xeno %s fail\033[0m\r\n", cap_c); + _byte_print(out_d, out_y, len_w, byt_y); + ret_i = 0; + } + + free(out_y); + } + + { + c3_w bit_w; + c3_w* wor_w = u3s_jam_fib(ref, &bit_w); + + out_d = (bit_w >> 3) + !!ur_mask_3(bit_w); + // XX assumes little-endian + // + out_y = (c3_y*)wor_w; + + if ( 0 != memcmp(out_y, byt_y, len_w) ) { + fprintf(stderr, "\033[31mjam fib %s fail\033[0m\r\n", cap_c); + _byte_print(out_d, out_y, len_w, byt_y); + ret_i = 0; + } + + u3a_wfree(wor_w); + } + + return ret_i; +} + +static c3_i +_test_cue_spec(const c3_c* cap_c, + u3_noun ref, + c3_w len_w, + const c3_y* byt_y) +{ + c3_i ret_i = 1; + + { + ur_dict32_t dic_u = {0}; + u3_noun out; + + ur_dict32_grow((ur_root_t*)0, &dic_u, ur_fib10, ur_fib11); + + if ( ur_cue_good != u3s_cue_xeno_unsafe(&dic_u, len_w, byt_y, &out) ) { + fprintf(stderr, "\033[31mcue %s fail 1\033[0m\r\n", cap_c); + ret_i = 0; + } + else if ( c3n == u3r_sing(ref, out) ) { + fprintf(stderr, "\033[31mcue %s fail 2\033[0m\r\n", cap_c); + u3m_p("ref", ref); + u3m_p("out", out); + ret_i = 0; + } + + u3z(out); + ur_dict_free((ur_dict_t*)&dic_u); + } + + { + u3_noun pro = u3m_soft(0, u3s_cue_atom, u3i_bytes(len_w, byt_y)); + u3_noun tag, out; + + u3x_cell(pro, &tag, &out); + + if ( u3_blip != tag ) { + fprintf(stderr, "\033[31mcue %s fail 3\033[0m\r\n", cap_c); + ret_i = 0; + } + else if ( c3n == u3r_sing(ref, out) ) { + fprintf(stderr, "\033[31mcue %s fail 4\033[0m\r\n", cap_c); + u3m_p("ref", ref); + u3m_p("out", out); + ret_i = 0; + } + + u3z(pro); + } + + // if we haven't failed yet, run u3s_cue_full w/out virtualization + // + if ( ret_i ) { + u3_noun out = u3s_cue_full(len_w, byt_y); + + if ( c3n == u3r_sing(ref, out) ) { + fprintf(stderr, "\033[31mcue %s fail 5\033[0m\r\n", cap_c); + u3m_p("ref", ref); + u3m_p("out", out); + ret_i = 0; + } + + u3z(out); + } + + return ret_i; +} + +static c3_i +_test_jam_roundtrip(void) +{ + c3_i ret_i = 1; + +# define TEST_CASE(a, b) \ + const c3_c* cap_c = a; \ + u3_noun ref = b; \ + ret_i &= _test_jam_spec(cap_c, ref, sizeof(res_y), res_y); \ + ret_i &= _test_cue_spec(cap_c, ref, sizeof(res_y), res_y); \ + u3z(ref); + + { + c3_y res_y[1] = { 0x2 }; + TEST_CASE("0", 0); + } + + { + c3_y res_y[1] = { 0xc }; + TEST_CASE("1", 1); + } + + { + c3_y res_y[1] = { 0x48 }; + TEST_CASE("2", 2); + } + + { + c3_y res_y[6] = { 0xc0, 0x37, 0xb, 0x9b, 0xa3, 0x3 }; + TEST_CASE("%fast", c3__fast); + } + + { + c3_y res_y[6] = { 0xc0, 0x37, 0xab, 0x63, 0x63, 0x3 }; + TEST_CASE("%full", c3__full); + } + + { + c3_y res_y[1] = { 0x29 }; + TEST_CASE("[0 0]", u3nc(0, 0)); + } + + { + c3_y res_y[2] = { 0x31, 0x3 }; + TEST_CASE("[1 1]", u3nc(1, 1)); + } + + { + c3_y res_y[2] = { 0x21, 0xd1 }; + TEST_CASE("[2 3]", u3nc(2, 3)); + } + + { + c3_y res_y[11] = { 0x1, 0xdf, 0x2c, 0x6c, 0x8e, 0xe, 0x7c, 0xb3, 0x3a, 0x36, 0x36 }; + TEST_CASE("[%fast %full]", u3nc(c3__fast, c3__full)); + } + + { + c3_y res_y[2] = { 0x71, 0xcc }; + TEST_CASE("[1 1 1]", u3nc(1, u3nc(1, 1))); + } + + { + c3_y res_y[12] = { 0x1, 0xdf, 0x2c, 0x6c, 0x8e, 0x1e, 0xf0, 0xcd, 0xea, 0xd8, 0xd8, 0x93 }; + TEST_CASE("[%fast %full %fast]", u3nc(c3__fast, u3nc(c3__full, c3__fast))); + } + + { + c3_y res_y[6] = { 0xa5, 0x35, 0x19, 0xf3, 0x18, 0x5 }; + TEST_CASE("[[0 0] [[0 0] 1 1] 1 1]", u3nc(u3nc(0, 0), u3nc(u3nc(u3nc(0, 0), u3nc(1, 1)), u3nc(1, 1)))); + } + + { + c3_y res_y[14] = { 0x15, 0x17, 0xb2, 0xd0, 0x85, 0x59, 0xb8, 0x61, 0x87, 0x5f, 0x10, 0x54, 0x55, 0x5 }; + TEST_CASE("deep", u3nc(u3nc(u3nc(1, u3nc(u3nc(2, u3nc(u3nc(3, u3nc(u3nc(4, u3nc(u3nt(5, 6, u3nc(7, u3nc(u3nc(8, 0), 0))), 0)), 0)), 0)), 0)), 0), 0)); + } + + { + c3_y inp_y[33] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + c3_y res_y[35] = { 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8 }; + TEST_CASE("wide", u3i_bytes(sizeof(inp_y), inp_y)); + } + + return ret_i; +} + static c3_i _test_jam(void) { @@ -309,6 +534,11 @@ _test_jam(void) ret_i = 0; } + if ( !_test_jam_roundtrip() ) { + fprintf(stderr, "test jam: roundtrip: failed\r\n"); + ret_i = 0; + } + return ret_i; } From aee89f6a6434ac6f51beed050d39d99ebc105430 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 27 Aug 2020 15:13:54 -0700 Subject: [PATCH 227/933] ur: removes trailing whitespace in tests --- pkg/urbit/tests/ur_tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index b2d5b9b36e..95e84e89f4 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -1522,7 +1522,7 @@ _test_jam_cue(void) uint8_t res[1] = { 0xc }; TEST_CASE("1", 1); } - + { uint8_t res[1] = { 0x48 }; TEST_CASE("2", 2); @@ -1554,7 +1554,7 @@ _test_jam_cue(void) } { - uint8_t res[11] = { 0x1, 0xdf, 0x2c, 0x6c, 0x8e, 0xe, 0x7c, 0xb3, 0x3a, 0x36, 0x36 }; + uint8_t res[11] = { 0x1, 0xdf, 0x2c, 0x6c, 0x8e, 0xe, 0x7c, 0xb3, 0x3a, 0x36, 0x36 }; TEST_CASE("[%fast %full]", NC(FAST, FULL)); } From 899f4312842e8b16e3fa4ef4ed441c6e1926b427 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 27 Aug 2020 22:22:18 -0700 Subject: [PATCH 228/933] ur: cleans up hashtable grow, adds consistent wipe operations --- pkg/urbit/include/ur/hashcons.h | 18 ++-- pkg/urbit/ur/hashcons.c | 143 +++++++++++++++++++------------- 2 files changed, 98 insertions(+), 63 deletions(-) diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index 9cfd9d2da2..797ab74cfc 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -98,9 +98,21 @@ ur_dict32_get(ur_root_t *r, ur_dict32_t *dict, ur_nref ref, uint32_t *out); void ur_dict32_put(ur_root_t *r, ur_dict32_t *dict, ur_nref ref, uint32_t val); +void +ur_dict32_wipe(ur_dict32_t *dict); + void ur_dict64_grow(ur_root_t *r, ur_dict64_t *dict, uint64_t prev, uint64_t size); +ur_bool_t +ur_dict64_get(ur_root_t *r, ur_dict64_t *dict, ur_nref ref, uint64_t *out); + +void +ur_dict64_put(ur_root_t *r, ur_dict64_t *dict, ur_nref ref, uint64_t val); + +void +ur_dict64_wipe(ur_dict64_t *dict); + void ur_dict_grow(ur_root_t *r, ur_dict_t *dict, uint64_t prev, uint64_t size); @@ -116,12 +128,6 @@ ur_dict_free(ur_dict_t *dict); void ur_dict_wipe(ur_dict_t *dict); -ur_bool_t -ur_dict64_get(ur_root_t *r, ur_dict64_t *dict, ur_nref ref, uint64_t *out); - -void -ur_dict64_put(ur_root_t *r, ur_dict64_t *dict, ur_nref ref, uint64_t val); - ur_nref ur_coin_bytes_unsafe(ur_root_t *r, uint8_t *byt, uint64_t len); diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 7ad97c3a9a..a4aca7d8b5 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -115,31 +115,33 @@ ur_dict32_grow(ur_root_t *r, ur_dict32_t *dict, uint64_t prev, uint64_t size) buckets = calloc(next, sizeof(*buckets)); - for ( i = 0; i < old_size; i++ ) { - ur_pail32_t *old_bucket = &(old_buckets[i]); - uint8_t j, old_fill = old_bucket->fill; + if ( old_buckets ) { + for ( i = 0; i < old_size; i++ ) { + ur_pail32_t *old_bucket = &(old_buckets[i]); + uint8_t j, old_fill = old_bucket->fill; - for ( j = 0; j < old_fill; j++ ) { - uint32_t val = old_bucket->vals[j]; - ur_nref ref = old_bucket->refs[j]; - ur_mug mug = ur_nref_mug(r, ref); + for ( j = 0; j < old_fill; j++ ) { + uint32_t val = old_bucket->vals[j]; + ur_nref ref = old_bucket->refs[j]; + ur_mug mug = ur_nref_mug(r, ref); - uint64_t idx = ( mug % next ); - ur_pail32_t *bucket = &(buckets[idx]); - uint8_t new_fill = bucket->fill; + uint64_t idx = ( mug % next ); + ur_pail32_t *bucket = &(buckets[idx]); + uint8_t new_fill = bucket->fill; - if ( ur_pail_max == new_fill ) { - free(buckets); - return ur_dict32_grow(r, dict, size, next); + if ( ur_pail_max == new_fill ) { + free(buckets); + return ur_dict32_grow(r, dict, size, next); + } + + bucket->refs[new_fill] = ref; + bucket->vals[new_fill] = val; + bucket->fill = 1 + new_fill; } - - bucket->refs[new_fill] = ref; - bucket->vals[new_fill] = val; - bucket->fill = 1 + new_fill; } - } - free(old_buckets); + free(old_buckets); + } dict->prev = size; dict->size = next; @@ -194,6 +196,17 @@ ur_dict32_put(ur_root_t *r, ur_dict32_t *dict, ur_nref ref, uint32_t val) } } +void +ur_dict32_wipe(ur_dict32_t *dict) +{ + ur_pail32_t *buckets = dict->buckets; + uint64_t i, size = dict->size; + + for ( i = 0; i < size; i++ ) { + buckets[i].fill = 0; + } +} + void ur_dict64_grow(ur_root_t *r, ur_dict64_t *dict, uint64_t prev, uint64_t size) { @@ -203,31 +216,33 @@ ur_dict64_grow(ur_root_t *r, ur_dict64_t *dict, uint64_t prev, uint64_t size) buckets = calloc(next, sizeof(*buckets)); - for ( i = 0; i < old_size; i++ ) { - ur_pail64_t *old_bucket = &(old_buckets[i]); - uint8_t j, old_fill = old_bucket->fill; + if ( old_buckets ) { + for ( i = 0; i < old_size; i++ ) { + ur_pail64_t *old_bucket = &(old_buckets[i]); + uint8_t j, old_fill = old_bucket->fill; - for ( j = 0; j < old_fill; j++ ) { - uint64_t val = old_bucket->vals[j]; - ur_nref ref = old_bucket->refs[j]; - ur_mug mug = ur_nref_mug(r, ref); + for ( j = 0; j < old_fill; j++ ) { + uint64_t val = old_bucket->vals[j]; + ur_nref ref = old_bucket->refs[j]; + ur_mug mug = ur_nref_mug(r, ref); - uint64_t idx = ( mug % next ); - ur_pail64_t *bucket = &(buckets[idx]); - uint8_t new_fill = bucket->fill; + uint64_t idx = ( mug % next ); + ur_pail64_t *bucket = &(buckets[idx]); + uint8_t new_fill = bucket->fill; - if ( ur_pail_max == new_fill ) { - free(buckets); - return ur_dict64_grow(r, dict, size, next); + if ( ur_pail_max == new_fill ) { + free(buckets); + return ur_dict64_grow(r, dict, size, next); + } + + bucket->refs[new_fill] = ref; + bucket->vals[new_fill] = val; + bucket->fill = 1 + new_fill; } - - bucket->refs[new_fill] = ref; - bucket->vals[new_fill] = val; - bucket->fill = 1 + new_fill; } - } - free(old_buckets); + free(old_buckets); + } dict->prev = size; dict->size = next; @@ -282,6 +297,17 @@ ur_dict64_put(ur_root_t *r, ur_dict64_t *dict, ur_nref ref, uint64_t val) } } +void +ur_dict64_wipe(ur_dict64_t *dict) +{ + ur_pail64_t *buckets = dict->buckets; + uint64_t i, size = dict->size; + + for ( i = 0; i < size; i++ ) { + buckets[i].fill = 0; + } +} + void ur_dict_grow(ur_root_t *r, ur_dict_t *dict, uint64_t prev, uint64_t size) { @@ -291,29 +317,31 @@ ur_dict_grow(ur_root_t *r, ur_dict_t *dict, uint64_t prev, uint64_t size) buckets = calloc(next, sizeof(*buckets)); - for ( i = 0; i < old_size; i++ ) { - ur_pail_t *old_bucket = &(old_buckets[i]); - uint8_t j, old_fill = old_bucket->fill; + if ( old_buckets ) { + for ( i = 0; i < old_size; i++ ) { + ur_pail_t *old_bucket = &(old_buckets[i]); + uint8_t j, old_fill = old_bucket->fill; - for ( j = 0; j < old_fill; j++ ) { - ur_nref ref = old_bucket->refs[j]; - ur_mug mug = ur_nref_mug(r, ref); - - uint64_t idx = ( mug % next ); - ur_pail_t *bucket = &(buckets[idx]); - uint8_t new_fill = bucket->fill; + for ( j = 0; j < old_fill; j++ ) { + ur_nref ref = old_bucket->refs[j]; + ur_mug mug = ur_nref_mug(r, ref); - if ( ur_pail_max == new_fill ) { - free(buckets); - return ur_dict_grow(r, dict, size, next); + uint64_t idx = ( mug % next ); + ur_pail_t *bucket = &(buckets[idx]); + uint8_t new_fill = bucket->fill; + + if ( ur_pail_max == new_fill ) { + free(buckets); + return ur_dict_grow(r, dict, size, next); + } + + bucket->refs[new_fill] = ref; + bucket->fill = 1 + new_fill; } - - bucket->refs[new_fill] = ref; - bucket->fill = 1 + new_fill; } - } - free(old_buckets); + free(old_buckets); + } dict->prev = size; dict->size = next; @@ -369,6 +397,7 @@ void ur_dict_free(ur_dict_t *dict) { free(dict->buckets); + dict->buckets = 0; } void @@ -604,7 +633,7 @@ ur_coin_bytes_unsafe(ur_root_t *r, uint8_t *byt, uint64_t len) } tom = _coin_unsafe(atoms, mug, byt, len); - + bucket->refs[b_fill] = tom; bucket->fill = 1 + b_fill; From 851f03294d6ab96c462ba49605bc60f6f869ee4e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 27 Aug 2020 22:26:14 -0700 Subject: [PATCH 229/933] build: adds jam/cue microbenchmarks (make bench) --- pkg/urbit/Makefile | 14 +- pkg/urbit/bench/ur_bench.c | 316 +++++++++++++++++++++++++++++++++++++ 2 files changed, 328 insertions(+), 2 deletions(-) create mode 100644 pkg/urbit/bench/ur_bench.c diff --git a/pkg/urbit/Makefile b/pkg/urbit/Makefile index 76e65e89e3..872c5eb1d3 100644 --- a/pkg/urbit/Makefile +++ b/pkg/urbit/Makefile @@ -7,6 +7,7 @@ vere = $(wildcard vere/*.c) $(wildcard vere/*/*.c) daemon = $(wildcard daemon/*.c) worker = $(wildcard worker/*.c) tests = $(wildcard tests/*.c) +bench = $(wildcard bench/*.c) common = $(jets) $(noun) $(ur) $(vere) headers = $(shell find include -type f) @@ -18,8 +19,9 @@ worker_objs = $(shell echo $(worker) | sed 's/\.c/.o/g') all_objs = $(common_objs) $(daemon_objs) $(worker_objs) all_srcs = $(common) $(daemon) $(worker) -test_exes = $(shell echo $(tests) | sed 's/tests\//.\/build\//g' | sed 's/\.c//g') -all_exes = $(test_exes) ./build/urbit ./build/urbit-worker +test_exes = $(shell echo $(tests) | sed 's/tests\//.\/build\//g' | sed 's/\.c//g') +bench_exes = $(shell echo $(bench) | sed 's/bench\//.\/build\//g' | sed 's/\.c//g') +all_exes = $(test_exes) $(bench_exes) ./build/urbit ./build/urbit-worker # -Werror promotes all warnings that are enabled into errors (this is on) # -Wall issues all types of errors. This is off (for now) @@ -41,6 +43,9 @@ test: $(test_exes) done; \ if [ $$FAIL != 0 ]; then echo "\n" && exit 1; fi; +bench: $(bench_exes) + build/ur_bench + clean: rm -f ./tags $(all_objs) $(all_exes) @@ -49,6 +54,11 @@ mrproper: clean ################################################################################ +build/ur_bench: $(common_objs) bench/ur_bench.o + @echo CC -o $@ + @mkdir -p ./build + @$(CC) $^ $(LDFLAGS) -o $@ + build/%_tests: $(common_objs) tests/%_tests.o @echo CC -o $@ @mkdir -p ./build diff --git a/pkg/urbit/bench/ur_bench.c b/pkg/urbit/bench/ur_bench.c new file mode 100644 index 0000000000..16a08d15e0 --- /dev/null +++ b/pkg/urbit/bench/ur_bench.c @@ -0,0 +1,316 @@ +#include "all.h" +#include "vere/vere.h" +#include "ur/ur.h" + +// XX not declared in serial.h due to presence of ur_* types +// +ur_cue_res_e +u3s_cue_xeno_unsafe(ur_dict32_t* dic_u, + c3_d len_d, + const c3_y* byt_y, + u3_noun* out); + +/* _setup(): prepare for tests. +*/ +static void +_setup(void) +{ + u3m_init(); + u3m_pave(c3y, c3n); +} + +/* _ames_writ_ex(): |hi packet from fake ~zod to fake ~nec +*/ +static u3_noun +_ames_writ_ex(void) +{ + c3_y bod_y[63] = { + 0x30, 0x90, 0x2d, 0x0, 0x0, 0x0, 0x1, 0x0, 0x9, 0xc0, 0xd0, + 0x0, 0x4, 0x40, 0x30, 0xf4, 0xa, 0x3d, 0x45, 0x86, 0x66, 0x2c, + 0x2, 0x38, 0xf8, 0x72, 0xa3, 0x9, 0xf6, 0x6, 0xf3, 0x0, 0xbe, + 0x67, 0x61, 0x49, 0x50, 0x4, 0x3c, 0x13, 0xb2, 0x96, 0x42, 0x1b, + 0x62, 0xac, 0x97, 0xff, 0x24, 0xeb, 0x69, 0x1b, 0xb2, 0x60, 0x72, + 0xa, 0x53, 0xdf, 0xe8, 0x8a, 0x9c, 0x6f, 0xb3 + }; + u3_noun lan = u3nc(0, 1); + u3_noun cad = u3nt(c3__send, lan, u3i_bytes(sizeof(bod_y), bod_y)); + u3_noun wir = u3nt(c3__newt, 0x1234, u3_nul); + u3_noun ovo = u3nc(u3nc(u3_blip, wir), cad); + u3_noun wen; + + { + struct timeval tim_u; + gettimeofday(&tim_u, 0); + wen = u3_time_in_tv(&tim_u); + } + + return u3nt(c3__work, 0, u3nc(wen, ovo)); +} + +static void +_jam_bench(void) +{ + struct timeval b4, f2, d0; + c3_w mil_w, i_w, max_w = 10000; + u3_noun wit = _ames_writ_ex(); + + fprintf(stderr, "\r\njam microbenchmark:\r\n"); + + { + gettimeofday(&b4, 0); + + { + c3_w* wor_w, bit_w; + + for ( i_w = 0; i_w < max_w; i_w++ ) { + wor_w = u3s_jam_fib(wit, &bit_w); + u3a_wfree(wor_w); + } + } + + gettimeofday(&f2, 0); + timersub(&f2, &b4, &d0); + mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); + fprintf(stderr, " jam og: %u ms\r\n", mil_w); + } + + { + gettimeofday(&b4, 0); + + { + c3_d len_d; + c3_y* byt_y; + + for ( i_w = 0; i_w < max_w; i_w++ ) { + u3s_jam_xeno(wit, &len_d, &byt_y); + c3_free(byt_y); + } + } + + gettimeofday(&f2, 0); + timersub(&f2, &b4, &d0); + mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); + fprintf(stderr, " jam xeno: %u ms\r\n", mil_w); + } + + while ( 1 ) { + ur_root_t* rot_u = ur_hcon_init(); + c3_d len_d; + c3_y* byt_y; + ur_nref ref; + + u3s_jam_xeno(wit, &len_d, &byt_y); + if ( ur_cue_good != ur_cue(rot_u, len_d, byt_y, &ref) ) { + fprintf(stderr, " jam bench: cue failed wtf\r\n"); + break; + } + + c3_free(byt_y); + + { + gettimeofday(&b4, 0); + + for ( i_w = 0; i_w < max_w; i_w++ ) { + ur_jam(rot_u, ref, &len_d, &byt_y); + c3_free(byt_y); + } + + gettimeofday(&f2, 0); + timersub(&f2, &b4, &d0); + mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); + fprintf(stderr, " jam cons: %u ms\r\n", mil_w); + } + + ur_hcon_free(rot_u); + break; + } + + u3z(wit); +} + +static void +_cue_bench(void) +{ + struct timeval b4, f2, d0; + c3_w mil_w, i_w, max_w = 20000; + u3_atom vat = u3ke_jam(_ames_writ_ex()); + + fprintf(stderr, "\r\ncue microbenchmark:\r\n"); + + { + gettimeofday(&b4, 0); + + for ( i_w = 0; i_w < max_w; i_w++ ) { + u3z(u3s_cue(vat)); + } + + gettimeofday(&f2, 0); + timersub(&f2, &b4, &d0); + mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); + fprintf(stderr, " cue og: %u ms\r\n", mil_w); + } + + // XX "loom: corrupt" assertion failure + // + // { + // gettimeofday(&b4, 0); + + // // for ( i_w = 0; i_w < max_w; i_w++ ) { + // u3z(u3s_cue_atom(vat)); + // // } + + // gettimeofday(&f2, 0); + // timersub(&f2, &b4, &d0); + // mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); + // fprintf(stderr, " cue_atom: %u ms\r\n", mil_w); + // } + + // NB: runs 1/8th the number of times + // + { + gettimeofday(&b4, 0); + + { + c3_w len_w = u3r_met(3, vat); + // XX assumes little-endian + // + c3_y* byt_y = ( c3y == u3a_is_cat(vat) ) + ? (c3_y*)&vat + : (c3_y*)((u3a_atom*)u3a_to_ptr(vat))->buf_w; + + for ( i_w = 0; i_w < max_w / 8; i_w++ ) { + u3z(u3s_cue_xeno(len_w, byt_y)); + } + } + + gettimeofday(&f2, 0); + timersub(&f2, &b4, &d0); + mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); + fprintf(stderr, " cue xeno: %u ms (estimated)\r\n", mil_w * 8); + } + + // NB: runs 1/8th the number of times + // + { + gettimeofday(&b4, 0); + + { + ur_dict32_t dic_u = {0}; + u3_noun out; + + c3_w len_w = u3r_met(3, vat); + // XX assumes little-endian + // + c3_y* byt_y = ( c3y == u3a_is_cat(vat) ) + ? (c3_y*)&vat + : (c3_y*)((u3a_atom*)u3a_to_ptr(vat))->buf_w; + + ur_dict32_grow((ur_root_t*)0, &dic_u, ur_fib10, ur_fib11); + + for ( i_w = 0; i_w < max_w / 8; i_w++ ) { + u3z(u3s_cue_xeno(len_w, byt_y)); + ur_dict32_wipe(&dic_u); + } + + ur_dict_free((ur_dict_t*)&dic_u); + } + + gettimeofday(&f2, 0); + timersub(&f2, &b4, &d0); + mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); + fprintf(stderr, " cue xeno unsafe: %u ms (estimated)\r\n", mil_w * 8); + } + + { + gettimeofday(&b4, 0); + + { + c3_w len_w = u3r_met(3, vat); + // XX assumes little-endian + // + c3_y* byt_y = ( c3y == u3a_is_cat(vat) ) + ? (c3_y*)&vat + : (c3_y*)((u3a_atom*)u3a_to_ptr(vat))->buf_w; + + for ( i_w = 0; i_w < max_w; i_w++ ) { + ur_cue_test(len_w, byt_y); + } + } + + gettimeofday(&f2, 0); + timersub(&f2, &b4, &d0); + mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); + fprintf(stderr, " cue test: %u ms\r\n", mil_w); + } + + { + gettimeofday(&b4, 0); + + { + ur_root_t* rot_u = ur_hcon_init(); + ur_nref ref; + c3_w len_w = u3r_met(3, vat); + // XX assumes little-endian + // + c3_y* byt_y = ( c3y == u3a_is_cat(vat) ) + ? (c3_y*)&vat + : (c3_y*)((u3a_atom*)u3a_to_ptr(vat))->buf_w; + + for ( i_w = 0; i_w < max_w; i_w++ ) { + ur_cue(rot_u, len_w, byt_y, &ref); + } + + ur_hcon_free(rot_u); + } + + gettimeofday(&f2, 0); + timersub(&f2, &b4, &d0); + mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); + fprintf(stderr, " cue cons: %u ms\r\n", mil_w); + } + + { + gettimeofday(&b4, 0); + + { + ur_root_t* rot_u; + ur_nref ref; + c3_w len_w = u3r_met(3, vat); + // XX assumes little-endian + // + c3_y* byt_y = ( c3y == u3a_is_cat(vat) ) + ? (c3_y*)&vat + : (c3_y*)((u3a_atom*)u3a_to_ptr(vat))->buf_w; + + for ( i_w = 0; i_w < max_w; i_w++ ) { + rot_u = ur_hcon_init(); + ur_cue(rot_u, len_w, byt_y, &ref); + ur_hcon_free(rot_u); + } + } + + gettimeofday(&f2, 0); + timersub(&f2, &b4, &d0); + mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); + fprintf(stderr, " cue re-cons: %u ms\r\n", mil_w); + } + + u3z(vat); +} + +/* main(): run all benchmarks +*/ +int +main(int argc, char* argv[]) +{ + _setup(); + + _jam_bench(); + _cue_bench(); + + // GC + // + u3m_grab(u3_none); + + return 0; +} From 4eb3e1217ea9f39a83f4bf6171c69f4ed04b1aea Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 27 Aug 2020 23:37:59 -0700 Subject: [PATCH 230/933] u3: fixes indirect-atom allocation bug in u3s_cue_smol/full --- pkg/urbit/bench/ur_bench.c | 44 +++++++++++++++++++++++++++----------- pkg/urbit/noun/serial.c | 23 +++++++++++--------- 2 files changed, 45 insertions(+), 22 deletions(-) diff --git a/pkg/urbit/bench/ur_bench.c b/pkg/urbit/bench/ur_bench.c index 16a08d15e0..3f8ce37d88 100644 --- a/pkg/urbit/bench/ur_bench.c +++ b/pkg/urbit/bench/ur_bench.c @@ -150,20 +150,40 @@ _cue_bench(void) fprintf(stderr, " cue og: %u ms\r\n", mil_w); } - // XX "loom: corrupt" assertion failure - // - // { - // gettimeofday(&b4, 0); + { + gettimeofday(&b4, 0); - // // for ( i_w = 0; i_w < max_w; i_w++ ) { - // u3z(u3s_cue_atom(vat)); - // // } + for ( i_w = 0; i_w < max_w; i_w++ ) { + u3z(u3s_cue_atom(vat)); + } - // gettimeofday(&f2, 0); - // timersub(&f2, &b4, &d0); - // mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); - // fprintf(stderr, " cue_atom: %u ms\r\n", mil_w); - // } + gettimeofday(&f2, 0); + timersub(&f2, &b4, &d0); + mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); + fprintf(stderr, " cue atom: %u ms\r\n", mil_w); + } + + { + gettimeofday(&b4, 0); + + { + c3_w len_w = u3r_met(3, vat); + // XX assumes little-endian + // + c3_y* byt_y = ( c3y == u3a_is_cat(vat) ) + ? (c3_y*)&vat + : (c3_y*)((u3a_atom*)u3a_to_ptr(vat))->buf_w; + + for ( i_w = 0; i_w < max_w; i_w++ ) { + u3z(u3s_cue_full(len_w, byt_y)); + } + } + + gettimeofday(&f2, 0); + timersub(&f2, &b4, &d0); + mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); + fprintf(stderr, " cue full: %u ms\r\n", mil_w); + } // NB: runs 1/8th the number of times // diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index db04067a02..6a335fe024 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -1140,14 +1140,12 @@ _cs_cue_smol_next(c3_ys mov, } else { c3_w byt_w = (len_d >> 3) + !!ur_mask_3(len_d); - c3_w* wor_w = u3a_slaq(3, byt_w); - // XX assumes little-endian - // XX need a ur_bsr_words_any() - // - c3_y* byt_y = (c3_y*)wor_w; + c3_y* byt_y = u3a_calloc(1, byt_w); ur_bsr_bytes_any(red_u, len_d, byt_y); - vat = u3a_malt(wor_w); + + vat = u3i_bytes(byt_w, byt_y); + u3a_free(byt_y); } u3h_put(har_p, (u3_noun)(c3_w)bit_d, u3k(vat)); @@ -1314,14 +1312,19 @@ _cs_cue_full_next(c3_ys mov, // XX check that byt_d fits in a c3_w; // c3_d byt_d = (len_d >> 3) + !!ur_mask_3(len_d); - c3_w* wor_w = u3a_slaq(3, byt_d); - // XX assumes little-endian + // XX the following (little-endian cheat) corrupts the loom // - c3_y* byt_y = (c3_y*)wor_w; + // c3_w* wor_w = u3a_slaq(3, byt_d); + // c3_y* byt_y = (c3_y*)wor_w; + // // copy bytes + // vat = u3a_malt(wor_w); + // + c3_y* byt_y = u3a_calloc(1, byt_d); ur_bsr_bytes_any(red_u, len_d, byt_y); - vat = u3a_malt(wor_w); + vat = u3i_bytes(byt_d, byt_y); + u3a_free(byt_y); } return _cs_cue_put(har_p, bit_d, vat); From b9fd36e47bc3a9a569e2ee839487d17137365a98 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 27 Aug 2020 23:40:43 -0700 Subject: [PATCH 231/933] u3: removes u3s_cue_smol, hoped-for performance never materialized --- pkg/urbit/bench/ur_bench.c | 22 ----- pkg/urbit/include/noun/serial.h | 12 +-- pkg/urbit/noun/serial.c | 163 +------------------------------- pkg/urbit/tests/jam_tests.c | 15 --- 4 files changed, 3 insertions(+), 209 deletions(-) diff --git a/pkg/urbit/bench/ur_bench.c b/pkg/urbit/bench/ur_bench.c index 3f8ce37d88..35b101ad7d 100644 --- a/pkg/urbit/bench/ur_bench.c +++ b/pkg/urbit/bench/ur_bench.c @@ -163,28 +163,6 @@ _cue_bench(void) fprintf(stderr, " cue atom: %u ms\r\n", mil_w); } - { - gettimeofday(&b4, 0); - - { - c3_w len_w = u3r_met(3, vat); - // XX assumes little-endian - // - c3_y* byt_y = ( c3y == u3a_is_cat(vat) ) - ? (c3_y*)&vat - : (c3_y*)((u3a_atom*)u3a_to_ptr(vat))->buf_w; - - for ( i_w = 0; i_w < max_w; i_w++ ) { - u3z(u3s_cue_full(len_w, byt_y)); - } - } - - gettimeofday(&f2, 0); - timersub(&f2, &b4, &d0); - mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); - fprintf(stderr, " cue full: %u ms\r\n", mil_w); - } - // NB: runs 1/8th the number of times // { diff --git a/pkg/urbit/include/noun/serial.h b/pkg/urbit/include/noun/serial.h index 96a39bcd84..1ecfdd5112 100644 --- a/pkg/urbit/include/noun/serial.h +++ b/pkg/urbit/include/noun/serial.h @@ -45,17 +45,7 @@ u3_noun u3s_cue_xeno(c3_d len_d, const c3_y* byt_y); - /* u3s_cue_smol(): cue onto the loom, bitwidth fits in a direct atom. - */ - u3_noun - u3s_cue_smol(c3_w len_w, const c3_y* byt_y); - - /* u3s_cue_full(): cue onto the loom. - */ - u3_noun - u3s_cue_full(c3_d len_d, const c3_y* byt_y); - - /* u3s_cue_bytes(): cue bytes. + /* u3s_cue_bytes(): cue bytes onto the loom. */ u3_noun u3s_cue_bytes(c3_d len_d, const c3_y* byt_y); diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index 6a335fe024..165ecd2e29 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -1070,153 +1070,6 @@ _cs_cue_need(ur_cue_res_e res_e) } } -/* _cs_cue_smol_next(): read next value from bitstream, direct-atom cursors. -*/ -static inline u3_noun -_cs_cue_smol_next(c3_ys mov, - c3_ys off, - u3p(u3h_root) har_p, - ur_bsr_t* red_u) -{ - while ( 1 ) { - c3_d len_d, bit_d = red_u->bits; - ur_cue_tag_e tag_e; - - _cs_cue_need(ur_bsr_tag(red_u, &tag_e)); - - switch ( tag_e ) { - default: c3_assert(0); - - case ur_jam_cell: { - // wind the stack - // - u3R->cap_p += mov; - - // ensure we haven't overflowed (ie, run into the heap) - // (off==0 means we're on a north road) - // - if ( 0 == off ) { - if( !(u3R->cap_p > u3R->hat_p) ) { - u3m_bail(c3__meme); - } - } - else { - if( !(u3R->cap_p < u3R->hat_p) ) { - u3m_bail(c3__meme); - } - } - - // save a head-frame and read the head from the stream - // - { - _cue_frame_t* fam_u = u3to(_cue_frame_t, u3R->cap_p + off); - fam_u->ref = u3_none; - fam_u->bit_d = bit_d; - } - continue; - } - - case ur_jam_back: { - _cs_cue_need(ur_bsr_rub_len(red_u, &len_d)); - - // XX review, s/b deterministic error - // - c3_assert( 32 > len_d ); - - { - c3_w bak_w = ur_bsr32_any(red_u, len_d); - u3_weak bak = u3h_get(har_p, (u3_noun)bak_w); - return u3x_good(bak); - } - } - - case ur_jam_atom: { - u3_atom vat; - - _cs_cue_need(ur_bsr_rub_len(red_u, &len_d)); - - if ( 31 >= len_d ) { - vat = (u3_noun)ur_bsr32_any(red_u, len_d); - } - else { - c3_w byt_w = (len_d >> 3) + !!ur_mask_3(len_d); - c3_y* byt_y = u3a_calloc(1, byt_w); - - ur_bsr_bytes_any(red_u, len_d, byt_y); - - vat = u3i_bytes(byt_w, byt_y); - u3a_free(byt_y); - } - - u3h_put(har_p, (u3_noun)(c3_w)bit_d, u3k(vat)); - - return vat; - } - } - } -} - -/* u3s_cue_smol(): cue onto the loom, bitwidth fits in a direct atom. -*/ -u3_noun -u3s_cue_smol(c3_w len_w, const c3_y* byt_y) -{ - ur_bsr_t red_u = {0}; - u3_noun ref; - - c3_assert( 0x10000000 >= len_w ); - - // initialize a hash table for dereferencing backrefs - // - u3p(u3h_root) har_p = u3h_new(); - const u3_post top_p = u3R->cap_p; - - // initialize signed stack offsets (relative to north/south road) - // - c3_ys mov, off; - { - c3_o nor_o = u3a_is_north(u3R); - c3_y wis_y = c3_wiseof(_cue_frame_t); - mov = ( c3y == nor_o ? -wis_y : wis_y ); - off = ( c3y == nor_o ? 0 : -wis_y ); - } - - // init bitstream-reader - // - red_u.left = len_w; - red_u.bytes = byt_y; - - // advance into stream - // - ref = _cs_cue_smol_next(mov, off, har_p, &red_u); - - // process result - // - while ( top_p != u3R->cap_p ) { - // peek at the top of the stack - // - _cue_frame_t* fam_u = u3to(_cue_frame_t, u3R->cap_p + off); - - // f is a head-frame; stash result and read the tail from the stream - // - if ( u3_none == fam_u->ref ) { - fam_u->ref = ref; - ref = _cs_cue_smol_next(mov, off, har_p, &red_u); - } - // f is a tail-frame; pop the stack and continue - // - else { - ref = u3nc(fam_u->ref, ref); - u3h_put(har_p, (u3_noun)(c3_w)fam_u->bit_d, u3k(ref)); - u3R->cap_p -= mov; - } - } - - u3h_free(har_p); - - return ref; -} - /* _cs_cue_get(): u3h_get wrapper handling allocation and refcounts. */ static inline u3_weak @@ -1333,10 +1186,10 @@ _cs_cue_full_next(c3_ys mov, } } -/* u3s_cue_full(): cue onto the loom. +/* u3s_cue_bytes(): cue bytes onto the loom. */ u3_noun -u3s_cue_full(c3_d len_d, const c3_y* byt_y) +u3s_cue_bytes(c3_d len_d, const c3_y* byt_y) { ur_bsr_t red_u = {0}; u3_noun ref; @@ -1392,18 +1245,6 @@ u3s_cue_full(c3_d len_d, const c3_y* byt_y) return ref; } -/* u3s_cue_bytes(): cue bytes. -*/ -u3_noun -u3s_cue_bytes(c3_d len_d, const c3_y* byt_y) -{ - // check if we can bitwise-index [len_d] bytes in a direct atom - // - return ( 0x10000000ULL >= len_d ) - ? u3s_cue_smol(len_d, byt_y) - : u3s_cue_full(len_d, byt_y); -} - /* u3s_cue_atom(): cue atom. */ u3_noun diff --git a/pkg/urbit/tests/jam_tests.c b/pkg/urbit/tests/jam_tests.c index 420ee3da0b..f759d89345 100644 --- a/pkg/urbit/tests/jam_tests.c +++ b/pkg/urbit/tests/jam_tests.c @@ -415,21 +415,6 @@ _test_cue_spec(const c3_c* cap_c, u3z(pro); } - // if we haven't failed yet, run u3s_cue_full w/out virtualization - // - if ( ret_i ) { - u3_noun out = u3s_cue_full(len_w, byt_y); - - if ( c3n == u3r_sing(ref, out) ) { - fprintf(stderr, "\033[31mcue %s fail 5\033[0m\r\n", cap_c); - u3m_p("ref", ref); - u3m_p("out", out); - ret_i = 0; - } - - u3z(out); - } - return ret_i; } From d76a5e9077a504cf8f0331ce91591edc11d51786 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 27 Aug 2020 23:47:02 +0200 Subject: [PATCH 232/933] vere: properly clean up dropped laneless packets Previously, if ames told us there was no lane for a target, we would drop the packet, but fail to register this in the queue, or even reclaim the memory it was using. Now, we do all the required book-keeping when dropping packets in the "no lane for this" case. --- pkg/urbit/vere/io/ames.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 4922832d5a..a3783cf541 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -655,20 +655,25 @@ _ames_lane_scry_cb(void* vod_p, u3_noun nun) // if scry fails, remember we can't scry, and just inject the packet // if (u3_none == las) { - pac_u->sam_u->foq_d--; u3l_log("ames: giving up scry\n"); pac_u->sam_u->see_o = c3n; _ames_put_packet(pac_u->sam_u, _ames_serialize_packet(pac_u, c3n), pac_u->ore_u); + pac_u->sam_u->foq_d--; + _ames_panc_free(pac_u); + } + // if there is no lane, drop the packet + // + else if (u3_nul == las) { + pac_u->sam_u->foq_d--; _ames_panc_free(pac_u); } // if there is a lane, forward the packet on it // - else if (u3_nul != las) { + else { _ames_forward(pac_u, u3k(las)); } - // if there is no lane, drop the packet u3z(nun); } From 024c16cd9764286856ee06fa7fc737048de9e74d Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 28 Aug 2020 15:34:19 +0200 Subject: [PATCH 233/933] vere: give up ames scry after successive failures Instead of giving up on scrying at the first sight of a u3_none result, keep trying for a little bit. If five scries fail in direct succession, consider scrying not worth the effort, and stop trying as before. --- pkg/urbit/vere/io/ames.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index a3783cf541..81f5635fc4 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -42,6 +42,7 @@ time_t imp_t[256]; // imperial IP timestamps c3_o imp_o[256]; // imperial print status c3_o see_o; // can scry + c3_d saw_d; // successive scry failures c3_o fit_o; // filtering active c3_y ver_y; // protocol version c3_d vet_d; // version mismatches filtered @@ -655,24 +656,31 @@ _ames_lane_scry_cb(void* vod_p, u3_noun nun) // if scry fails, remember we can't scry, and just inject the packet // if (u3_none == las) { - u3l_log("ames: giving up scry\n"); - pac_u->sam_u->see_o = c3n; + if (5 < ++pac_u->sam_u->saw_d) { + u3l_log("ames: giving up scry\n"); + pac_u->sam_u->see_o = c3n; + } _ames_put_packet(pac_u->sam_u, _ames_serialize_packet(pac_u, c3n), pac_u->ore_u); pac_u->sam_u->foq_d--; _ames_panc_free(pac_u); } - // if there is no lane, drop the packet - // - else if (u3_nul == las) { - pac_u->sam_u->foq_d--; - _ames_panc_free(pac_u); - } - // if there is a lane, forward the packet on it - // else { - _ames_forward(pac_u, u3k(las)); + if (0 < pac_u->sam_u->saw_d) { + pac_u->sam_u->saw_d--; + } + // if there is no lane, drop the packet + // + if (u3_nul == las) { + pac_u->sam_u->foq_d--; + _ames_panc_free(pac_u); + } + // if there is a lane, forward the packet on it + // + else { + _ames_forward(pac_u, u3k(las)); + } } u3z(nun); From daf463c4be6a97153d33286e4fcd4e5b738124da Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 28 Aug 2020 11:17:22 -0700 Subject: [PATCH 234/933] ur: fixes a buffer over-write in ur_bsr_bytes_any() --- pkg/urbit/ur/bitstream.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/pkg/urbit/ur/bitstream.c b/pkg/urbit/ur/bitstream.c index eea2202543..fabc15adbc 100644 --- a/pkg/urbit/ur/bitstream.c +++ b/pkg/urbit/ur/bitstream.c @@ -369,14 +369,18 @@ ur_bsr_bytes_any(ur_bsr_t *bsr, uint64_t len, uint8_t *out) // become the least-significant bits of an output byte, and vice-versa // else { - uint64_t need = len_byt + (len_bit >> 3) + !!ur_mask_3(len_bit); - ur_bool_t end = need >= left; - uint64_t max = end ? (left - 1) : len_byt; - uint8_t rest = 8 - off; - uint8_t mask = (1 << off) - 1; - uint8_t byt = b[0]; - uint8_t l, m = byt >> off; - uint64_t i; + uint8_t rest = 8 - off; + uint8_t mask = (1 << off) - 1; + uint8_t byt = b[0]; + uint8_t l, m = byt >> off; + ur_bool_t end; + uint64_t i, max; + + { + uint64_t need = len_byt + !!len_bit; + end = need >= left; + max = end ? (left - 1) : len_byt; + } for ( i = 0; i < max; i++ ) { byt = b[1ULL + i]; @@ -407,12 +411,14 @@ ur_bsr_bytes_any(ur_bsr_t *bsr, uint64_t len, uint8_t *out) left -= step; off = ur_mask_3(bits); - if ( len_bit <= rest ) { - out[max] = m & ((1 << len_bit) - 1); - } - else { - l = b[1ULL + max] & ((1 << off) - 1);; - out[max] = m ^ (l << rest); + if ( len_bit ) { + if ( len_bit <= rest ) { + out[max] = m & ((1 << len_bit) - 1); + } + else { + l = b[1ULL + max] & ((1 << off) - 1);; + out[max] = m ^ (l << rest); + } } } } From f6042e440fbb721c07751b16a90bdfc89fc4eb7c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 28 Aug 2020 11:18:01 -0700 Subject: [PATCH 235/933] u3: removes double atom allocation in u3s_cue_bytes() --- pkg/urbit/noun/serial.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index 165ecd2e29..8924162bb5 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -1162,22 +1162,24 @@ _cs_cue_full_next(c3_ys mov, // XX need a ur_bsr_words_any() // else { - // XX check that byt_d fits in a c3_w; - // - c3_d byt_d = (len_d >> 3) + !!ur_mask_3(len_d); - // XX the following (little-endian cheat) corrupts the loom - // - // c3_w* wor_w = u3a_slaq(3, byt_d); - // c3_y* byt_y = (c3_y*)wor_w; - // // copy bytes - // vat = u3a_malt(wor_w); - // - c3_y* byt_y = u3a_calloc(1, byt_d); + c3_w* wor_w; + c3_y* byt_y; + + { + c3_d byt_d = (len_d >> 3) + !!ur_mask_3(len_d); + + if ( 0xffffffffULL < byt_d) { + return u3m_bail(c3__meme); + } + + // XX assumes little-endian + // + wor_w = u3a_slaq(3, byt_d); + byt_y = (c3_y*)wor_w; + } ur_bsr_bytes_any(red_u, len_d, byt_y); - - vat = u3i_bytes(byt_d, byt_y); - u3a_free(byt_y); + vat = u3a_malt(wor_w); } return _cs_cue_put(har_p, bit_d, vat); From 1ea8e7310453ed9fdc5a3a06555fff579d71c15d Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 28 Aug 2020 11:18:35 -0700 Subject: [PATCH 236/933] build: adds microbenchmark for virtualized cue --- pkg/urbit/bench/ur_bench.c | 59 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/pkg/urbit/bench/ur_bench.c b/pkg/urbit/bench/ur_bench.c index 35b101ad7d..9b257966f6 100644 --- a/pkg/urbit/bench/ur_bench.c +++ b/pkg/urbit/bench/ur_bench.c @@ -296,6 +296,64 @@ _cue_bench(void) u3z(vat); } +static u3_noun +_cue_loop(u3_atom a) +{ + c3_w i_w, max_w = 20000; + + for ( i_w = 0; i_w < max_w; i_w++ ) { + u3z(u3s_cue(a)); + } + + return u3_blip; +} + +static u3_noun +_cue_atom_loop(u3_atom a) +{ + c3_w i_w, max_w = 20000; + + for ( i_w = 0; i_w < max_w; i_w++ ) { + u3z(u3s_cue_atom(a)); + } + + return u3_blip; +} + +static void +_cue_soft_bench(void) +{ + struct timeval b4, f2, d0; + u3_atom vat = u3ke_jam(_ames_writ_ex()); + c3_w mil_w; + + fprintf(stderr, "\r\ncue virtual microbenchmark:\r\n"); + + { + gettimeofday(&b4, 0); + + u3z(u3m_soft(0, _cue_loop, u3k(vat))); + + gettimeofday(&f2, 0); + timersub(&f2, &b4, &d0); + mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); + fprintf(stderr, " cue virtual og: %u ms\r\n", mil_w); + } + + { + gettimeofday(&b4, 0); + + u3z(u3m_soft(0, _cue_atom_loop, u3k(vat))); + + gettimeofday(&f2, 0); + timersub(&f2, &b4, &d0); + mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); + fprintf(stderr, " cue virtual atom: %u ms\r\n", mil_w); + } + + u3z(vat); +} + /* main(): run all benchmarks */ int @@ -305,6 +363,7 @@ main(int argc, char* argv[]) _jam_bench(); _cue_bench(); + _cue_soft_bench(); // GC // From 7b42f540b40706647676c76734277499cbacd79d Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 28 Aug 2020 14:45:51 -0700 Subject: [PATCH 237/933] ur: fixes buffer over-read bugs in bitstream in tests --- pkg/urbit/tests/ur_tests.c | 6 +- pkg/urbit/ur/bitstream.c | 200 ++++++++++++++++++++++--------------- 2 files changed, 121 insertions(+), 85 deletions(-) diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index 95e84e89f4..9ec4fecb52 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -1126,13 +1126,15 @@ _test_bsr64(void) static void _bsr_bytes_any_slow(ur_bsr_t *bsr, uint64_t len, uint8_t *out) { - uint64_t i, len_byt = len >> 3; + uint64_t i, len_byt = len >> 3, len_bit = ur_mask_3(len); for ( i = 0; i < len_byt; i++ ) { out[i] = _bsr8_any_slow(bsr, 8); } - out[len_byt] = _bsr8_any_slow(bsr, ur_mask_3(len)); + if ( len_bit ) { + out[len_byt] = _bsr8_any_slow(bsr, len_bit); + } } static int diff --git a/pkg/urbit/ur/bitstream.c b/pkg/urbit/ur/bitstream.c index fabc15adbc..d5ff9642df 100644 --- a/pkg/urbit/ur/bitstream.c +++ b/pkg/urbit/ur/bitstream.c @@ -130,22 +130,22 @@ ur_bsr32_any(ur_bsr_t *bsr, uint8_t len) return 0; } else { - uint8_t off = bsr->off; - uint8_t rest = 8 - off; - const uint8_t *b = bsr->bytes; - uint32_t m = b[0] >> off; + uint8_t off = bsr->off; + uint8_t rest = 8 - off; + uint32_t m = bsr->bytes[0] >> off; if ( len < rest ) { bsr->off = off + len; return m & ((1 << len) - 1); } else { - uint8_t mask, len_byt; - uint32_t l; + const uint8_t *b; + uint8_t mask, len_byt; + uint32_t l; len -= rest; left--; - bsr->bytes++; + b = ++bsr->bytes; len_byt = len >> 3; @@ -164,33 +164,44 @@ ur_bsr32_any(ur_bsr_t *bsr, uint8_t len) mask = (1 << off) - 1; switch ( len_byt ) { + default: assert(0); + case 4: { - l = (uint32_t)b[1] - ^ (uint32_t)b[2] << 8 - ^ (uint32_t)b[3] << 16 - ^ (uint32_t)b[4] << 24; + l = (uint32_t)b[0] + ^ (uint32_t)b[1] << 8 + ^ (uint32_t)b[2] << 16 + ^ (uint32_t)b[3] << 24; } break; case 3: { - l = (uint32_t)b[1] - ^ (uint32_t)b[2] << 8 - ^ (uint32_t)b[3] << 16 - ^ (uint32_t)(b[4] & mask) << 24; + l = (uint32_t)b[0] + ^ (uint32_t)b[1] << 8 + ^ (uint32_t)b[2] << 16; + + if ( mask ) { + l ^= (uint32_t)(b[3] & mask) << 24; + } } break; case 2: { - l = (uint32_t)b[1] - ^ (uint32_t)b[2] << 8 - ^ (uint32_t)(b[3] & mask) << 16; + l = (uint32_t)b[0] + ^ (uint32_t)b[1] << 8; + + if ( mask ) { + l ^= (uint32_t)(b[2] & mask) << 16; + } } break; case 1: { - l = (uint32_t)b[1] - ^ (uint32_t)(b[2] & mask) << 8; + l = (uint32_t)b[0]; + + if ( mask ) { + l ^= (uint32_t)(b[1] & mask) << 8; + } } break; case 0: { - l = (uint32_t)(b[1] & mask); + l = ( mask ) ? (uint32_t)(b[0] & mask) : 0; } break; } @@ -212,22 +223,22 @@ ur_bsr64_any(ur_bsr_t *bsr, uint8_t len) return 0; } else { - uint8_t off = bsr->off; - uint8_t rest = 8 - off; - const uint8_t *b = bsr->bytes; - uint64_t m = b[0] >> off; + uint8_t off = bsr->off; + uint8_t rest = 8 - off; + uint64_t m = bsr->bytes[0] >> off; if ( len < rest ) { bsr->off = off + len; return m & ((1 << len) - 1); } else { - uint8_t mask, len_byt; - uint64_t l; + const uint8_t *b; + uint8_t mask, len_byt; + uint64_t l; len -= rest; left--; - bsr->bytes++; + b = ++bsr->bytes; len_byt = len >> 3; @@ -247,74 +258,95 @@ ur_bsr64_any(ur_bsr_t *bsr, uint8_t len) switch ( len_byt ) { case 8: { - l = (uint64_t)b[1] - ^ (uint64_t)b[2] << 8 - ^ (uint64_t)b[3] << 16 - ^ (uint64_t)b[4] << 24 - ^ (uint64_t)b[5] << 32 - ^ (uint64_t)b[6] << 40 - ^ (uint64_t)b[7] << 48 - ^ (uint64_t)b[8] << 56; + l = (uint64_t)b[0] + ^ (uint64_t)b[1] << 8 + ^ (uint64_t)b[2] << 16 + ^ (uint64_t)b[3] << 24 + ^ (uint64_t)b[4] << 32 + ^ (uint64_t)b[5] << 40 + ^ (uint64_t)b[6] << 48 + ^ (uint64_t)b[7] << 56; } break; case 7: { - l = (uint64_t)b[1] - ^ (uint64_t)b[2] << 8 - ^ (uint64_t)b[3] << 16 - ^ (uint64_t)b[4] << 24 - ^ (uint64_t)b[5] << 32 - ^ (uint64_t)b[6] << 40 - ^ (uint64_t)b[7] << 48 - ^ (uint64_t)(b[8] & mask) << 56; + l = (uint64_t)b[0] + ^ (uint64_t)b[1] << 8 + ^ (uint64_t)b[2] << 16 + ^ (uint64_t)b[3] << 24 + ^ (uint64_t)b[4] << 32 + ^ (uint64_t)b[5] << 40 + ^ (uint64_t)b[6] << 48; + + if ( mask ) { + l ^= (uint64_t)(b[7] & mask) << 56; + } } break; case 6: { - l = (uint64_t)b[1] - ^ (uint64_t)b[2] << 8 - ^ (uint64_t)b[3] << 16 - ^ (uint64_t)b[4] << 24 - ^ (uint64_t)b[5] << 32 - ^ (uint64_t)b[6] << 40 - ^ (uint64_t)(b[7] & mask) << 48; + l = (uint64_t)b[0] + ^ (uint64_t)b[1] << 8 + ^ (uint64_t)b[2] << 16 + ^ (uint64_t)b[3] << 24 + ^ (uint64_t)b[4] << 32 + ^ (uint64_t)b[5] << 40; + + if ( mask ) { + l ^= (uint64_t)(b[6] & mask) << 48; + } } break; case 5: { - l = (uint64_t)b[1] - ^ (uint64_t)b[2] << 8 - ^ (uint64_t)b[3] << 16 - ^ (uint64_t)b[4] << 24 - ^ (uint64_t)b[5] << 32 - ^ (uint64_t)(b[6] & mask) << 40; + l = (uint64_t)b[0] + ^ (uint64_t)b[1] << 8 + ^ (uint64_t)b[2] << 16 + ^ (uint64_t)b[3] << 24 + ^ (uint64_t)b[4] << 32; + + if ( mask ) { + l ^= (uint64_t)(b[5] & mask) << 40; + } } break; case 4: { - l = (uint64_t)b[1] - ^ (uint64_t)b[2] << 8 - ^ (uint64_t)b[3] << 16 - ^ (uint64_t)b[4] << 24 - ^ (uint64_t)(b[5] & mask) << 32; + l = (uint64_t)b[0] + ^ (uint64_t)b[1] << 8 + ^ (uint64_t)b[2] << 16 + ^ (uint64_t)b[3] << 24; + + if ( mask ) { + l ^= (uint64_t)(b[4] & mask) << 32; + } } break; case 3: { - l = (uint64_t)b[1] - ^ (uint64_t)b[2] << 8 - ^ (uint64_t)b[3] << 16 - ^ (uint64_t)(b[4] & mask) << 24; + l = (uint64_t)b[0] + ^ (uint64_t)b[1] << 8 + ^ (uint64_t)b[2] << 16; + + if ( mask ) { + l ^= (uint64_t)(b[3] & mask) << 24; + } } break; case 2: { - l = (uint64_t)b[1] - ^ (uint64_t)b[2] << 8 - ^ (uint64_t)(b[3] & mask) << 16; + l = (uint64_t)b[0] + ^ (uint64_t)b[1] << 8; + + if ( mask ) { + l ^= (uint64_t)(b[2] & mask) << 16; + } } break; case 1: { - l = (uint64_t)b[1] - ^ (uint64_t)(b[2] & mask) << 8; + l = (uint64_t)b[0]; + + if ( mask ) { + l ^= (uint64_t)(b[1] & mask) << 8; + } } break; case 0: { - l = (uint64_t)(b[1] & mask); + l = ( mask ) ? (uint64_t)(b[0] & mask) : 0; } break; } @@ -925,19 +957,21 @@ _bsw_bytes_unsafe(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) m = byt[i] >> rest; } - if ( len_bit < rest ) { - l = byt[len_byt] & ((1 << len_bit) - 1); - bsw->bytes[fill] = m ^ (l << off); - off += len_bit; - } - else { - l = byt[len_byt] & mask; - bsw->bytes[fill++] = m ^ (l << off); + if ( len_bit ) { + if ( len_bit < rest ) { + l = byt[len_byt] & ((1 << len_bit) - 1); + bsw->bytes[fill] = m ^ (l << off); + off += len_bit; + } + else { + l = byt[len_byt] & mask; + bsw->bytes[fill++] = m ^ (l << off); - m = byt[len_byt] >> rest; + m = byt[len_byt] >> rest; - off = len_bit - rest; - bsw->bytes[fill] = m & ((1 << off) - 1); + off = len_bit - rest; + bsw->bytes[fill] = m & ((1 << off) - 1); + } } } From 6f3d83f4dca0a36e8569b2615ee7b07964a35500 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 28 Aug 2020 14:52:51 -0700 Subject: [PATCH 238/933] ur: adds ur_jam_unsafe() --- pkg/urbit/include/ur/serial.h | 7 +++++++ pkg/urbit/ur/serial.c | 31 ++++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/pkg/urbit/include/ur/serial.h b/pkg/urbit/include/ur/serial.h index afac9e6a0d..13d8fae511 100644 --- a/pkg/urbit/include/ur/serial.h +++ b/pkg/urbit/include/ur/serial.h @@ -5,6 +5,13 @@ #include #include +uint64_t +ur_jam_unsafe(ur_root_t *r, + ur_nref ref, + ur_dict64_t *dict, + uint64_t *len, + uint8_t **byt); + uint64_t ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt); diff --git a/pkg/urbit/ur/serial.c b/pkg/urbit/ur/serial.c index b32973a6ff..b7964ee9af 100644 --- a/pkg/urbit/ur/serial.c +++ b/pkg/urbit/ur/serial.c @@ -19,15 +19,15 @@ _bsw_atom(ur_root_t *r, ur_nref ref, ur_bsw_t *bsw, uint64_t len) } typedef struct _jam_s { - ur_dict64_t dict; - ur_bsw_t bsw; + ur_dict64_t *dict; + ur_bsw_t bsw; } _jam_t; static void _jam_atom(ur_root_t *r, ur_nref ref, void *ptr) { _jam_t *j = ptr; - ur_dict64_t *dict = &(j->dict); + ur_dict64_t *dict = j->dict; ur_bsw_t *bsw = &j->bsw; uint64_t bak, len = ur_met(r, 0, ref); @@ -52,7 +52,7 @@ static ur_bool_t _jam_cell(ur_root_t *r, ur_nref ref, void *ptr) { _jam_t *j = ptr; - ur_dict64_t *dict = &(j->dict); + ur_dict64_t *dict = j->dict; ur_bsw_t *bsw = &j->bsw; uint64_t bak; @@ -69,17 +69,21 @@ _jam_cell(ur_root_t *r, ur_nref ref, void *ptr) } uint64_t -ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt) +ur_jam_unsafe(ur_root_t *r, + ur_nref ref, + ur_dict64_t *dict, + uint64_t *len, + uint8_t **byt) { _jam_t j = {0}; + j.dict = dict; + j.bsw.prev = ur_fib11; j.bsw.size = ur_fib12; j.bsw.bytes = calloc(j.bsw.size, 1); - ur_dict64_grow(r, &j.dict, ur_fib11, ur_fib12); ur_walk_fore(r, ref, &j, _jam_atom, _jam_cell); - ur_dict_free((ur_dict_t*)&j.dict); *len = j.bsw.fill + !!j.bsw.off; *byt = j.bsw.bytes; @@ -87,6 +91,19 @@ ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt) return j.bsw.bits; } +uint64_t +ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt) +{ + ur_dict64_t dict = {0}; + ur_dict64_grow(r, &dict, ur_fib11, ur_fib12); + + { + uint64_t bits = ur_jam_unsafe(r, ref, &dict, len, byt); + ur_dict_free((ur_dict_t*)&dict); + return bits; + } +} + /* ** stack frame for recording head vs tail iteration ** From 7fa6499e3725387468d143ee477eb7aca3d5dfb4 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 28 Aug 2020 14:59:30 -0700 Subject: [PATCH 239/933] build: updates benchmarks --- pkg/urbit/bench/ur_bench.c | 64 +++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 5 deletions(-) diff --git a/pkg/urbit/bench/ur_bench.c b/pkg/urbit/bench/ur_bench.c index 9b257966f6..7b6283fefd 100644 --- a/pkg/urbit/bench/ur_bench.c +++ b/pkg/urbit/bench/ur_bench.c @@ -121,6 +121,31 @@ _jam_bench(void) fprintf(stderr, " jam cons: %u ms\r\n", mil_w); } + { + gettimeofday(&b4, 0); + + { + ur_dict64_t dic_u = {0}; + c3_d len_d; + c3_y* byt_y; + + ur_dict64_grow((ur_root_t*)0, &dic_u, ur_fib10, ur_fib11); + + for ( i_w = 0; i_w < max_w; i_w++ ) { + ur_jam_unsafe(rot_u, ref, &dic_u, &len_d, &byt_y); + c3_free(byt_y); + ur_dict64_wipe(&dic_u); + } + + ur_dict_free((ur_dict_t*)&dic_u); + } + + gettimeofday(&f2, 0); + timersub(&f2, &b4, &d0); + mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); + fprintf(stderr, " jam cons unsafe: %u ms\r\n", mil_w); + } + ur_hcon_free(rot_u); break; } @@ -187,8 +212,6 @@ _cue_bench(void) fprintf(stderr, " cue xeno: %u ms (estimated)\r\n", mil_w * 8); } - // NB: runs 1/8th the number of times - // { gettimeofday(&b4, 0); @@ -205,8 +228,9 @@ _cue_bench(void) ur_dict32_grow((ur_root_t*)0, &dic_u, ur_fib10, ur_fib11); - for ( i_w = 0; i_w < max_w / 8; i_w++ ) { - u3z(u3s_cue_xeno(len_w, byt_y)); + for ( i_w = 0; i_w < max_w; i_w++ ) { + u3s_cue_xeno_unsafe(&dic_u, len_w, byt_y, &out); + u3z(out); ur_dict32_wipe(&dic_u); } @@ -216,7 +240,7 @@ _cue_bench(void) gettimeofday(&f2, 0); timersub(&f2, &b4, &d0); mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); - fprintf(stderr, " cue xeno unsafe: %u ms (estimated)\r\n", mil_w * 8); + fprintf(stderr, " cue xeno unsafe: %u ms\r\n", mil_w); } { @@ -241,6 +265,36 @@ _cue_bench(void) fprintf(stderr, " cue test: %u ms\r\n", mil_w); } + { + gettimeofday(&b4, 0); + + { + ur_dict_t dic_u = {0}; + u3_noun out; + + c3_w len_w = u3r_met(3, vat); + // XX assumes little-endian + // + c3_y* byt_y = ( c3y == u3a_is_cat(vat) ) + ? (c3_y*)&vat + : (c3_y*)((u3a_atom*)u3a_to_ptr(vat))->buf_w; + + ur_dict_grow((ur_root_t*)0, &dic_u, ur_fib10, ur_fib11); + + for ( i_w = 0; i_w < max_w; i_w++ ) { + ur_cue_test_unsafe(&dic_u, len_w, byt_y); + ur_dict_wipe(&dic_u); + } + + ur_dict_free(&dic_u); + } + + gettimeofday(&f2, 0); + timersub(&f2, &b4, &d0); + mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); + fprintf(stderr, " cue test unsafe: %u ms\r\n", mil_w); + } + { gettimeofday(&b4, 0); From 5f77200d0d31291ca9a25430e96a75ad012478c8 Mon Sep 17 00:00:00 2001 From: Fang Date: Sat, 29 Aug 2020 17:17:45 +0200 Subject: [PATCH 240/933] vere: cache lanes for stateless forwarding While stateless forwarding doesn't need to touch disk, there's still overhead in needing to communicate with the serf over IPC. By caching lanes, we get to skip the IPC pipeline, and can respond to forwarding requests synchronously. We include timestamps alongside the entries in the cache, and consider entries older than two minutes as stale. The cache is capped at around ~100mb of memory use. Further commentary is provided inline. Previously, ~nus would drop 3 forward requests, for every one it fulfilled. Now, it seems able to keep up with demand, only dropping forwards shortly after boot, while the cache isn't primed yet. --- pkg/urbit/vere/io/ames.c | 100 +++++++++++++++++++++++++++++++++++---- 1 file changed, 91 insertions(+), 9 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 81f5635fc4..7dbd7efe34 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -45,6 +45,7 @@ c3_d saw_d; // successive scry failures c3_o fit_o; // filtering active c3_y ver_y; // protocol version + u3p(u3h_root) lax_p; // lane scry cache c3_d vet_d; // version mismatches filtered c3_d mut_d; // invalid mugs filtered struct _u3_panc* pac_u; // packets pending forwards @@ -309,6 +310,43 @@ _ames_lane_from_sockaddr(struct sockaddr_in* add_u) return lan_u; } +/* _ames_lane_into_cache(): put las for who into cache, including timestamp +*/ +void +_ames_lane_into_cache(u3p(u3h_root) lax_p, u3_noun who, u3_noun las) { + struct timeval tim_tv; + gettimeofday(&tim_tv, 0); + u3_noun now = u3_time_in_tv(&tim_tv); + u3_noun val = u3nc(las, now); + u3h_put(lax_p, who, val); + u3z(who); +} + +/* _ames_lane_from_cache(): retrieve lane for who from cache, if any & fresh +*/ +u3_weak +_ames_lane_from_cache(u3p(u3h_root) lax_p, u3_noun who) { + u3_weak lac = u3h_git(lax_p, who); + + if (u3_none != lac) { + struct timeval tim_tv; + gettimeofday(&tim_tv, 0); + u3_noun now = u3_time_in_tv(&tim_tv); + u3_noun den = u3t(lac); + + // consider entries older than 2 minutes stale, ignore them + // + if (120000 > u3_time_gap_ms(u3k(den), now)) { + lac = u3k(u3h(lac)); + } else { + lac = u3_none; + } + } + + u3z(who); + return lac; +} + /* _ames_serialize_packet(): u3_panc to atom, updating the origin lane if dop_o ** (retains pac_u) */ @@ -627,7 +665,7 @@ static void _ames_forward(u3_panc* pac_u, u3_noun las) { pac_u->sam_u->fow_d++; - if ( 0 == (pac_u->sam_u->fow_d % 10000) ) { + if ( 0 == (pac_u->sam_u->fow_d % 1000000) ) { u3l_log("ames: forwarded %" PRIu64 " total\n", pac_u->sam_u->fow_d); } @@ -670,6 +708,13 @@ _ames_lane_scry_cb(void* vod_p, u3_noun nun) if (0 < pac_u->sam_u->saw_d) { pac_u->sam_u->saw_d--; } + + // cache the scry result for later use + // + _ames_lane_into_cache(pac_u->sam_u->lax_p, + u3i_chubs(2, pac_u->bod_u.rec_d), + u3k(las)); + // if there is no lane, drop the packet // if (u3_nul == las) { @@ -784,7 +829,19 @@ _ames_recv_cb(uv_udp_t* wax_u, { pas_o = c3n; - // if the queue is full, and we can't forward synchronously, + u3_weak lac; + // if the recipient is a galaxy, their lane is always &+~gax + // + if ( (rec_d[1] == 0) && (256 > rec_d[0]) ) { + lac = u3nc(c3y, (c3_y)rec_d[0]); + } + // otherwise, try to get the lane from cache + // + else { + lac = _ames_lane_from_cache(sam_u->lax_p, u3i_chubs(2, rec_d)); + } + + // if we don't know the lane, and the scry queue is full, // just drop the packet // //TODO drop oldest item in forward queue in favor of this one. @@ -792,16 +849,21 @@ _ames_recv_cb(uv_udp_t* wax_u, // so can't pluck these out of the event queue like it does in // _ames_cap_queue. as such, blocked on u3_lord_peek_cancel or w/e. // - if ( (1000 < sam_u->foq_d) - && !(rec_d[1] == 0 && (256 > rec_d[0])) ) + if ( (u3_none == lac) && (1000 < sam_u->foq_d) ) { c3_free(con_y); sam_u->fod_d++; - if ( 0 == (sam_u->fod_d % 100000) ) { + if ( 0 == (sam_u->fod_d % 10000) ) { u3l_log("ames: dropped %" PRIu64 " forwards total\n", sam_u->fod_d); } } + // if we know there's no lane, drop the packet + // + else if (u3_nul == lac) { + c3_free(con_y); + u3z(lac); + } // otherwise, proceed with forwarding // else { @@ -826,12 +888,12 @@ _ames_recv_cb(uv_udp_t* wax_u, } sam_u->pac_u = pac_u; - // if the recipient is a galaxy, their lane is always &+~gax + // if we already know the lane, just forward // - if ( (rec_d[1] == 0) && (256 > rec_d[0]) ) { - _ames_forward(pac_u, u3nc(u3nc(c3y, (c3_y)rec_d[0]), u3_nul)); + if (u3_none != lac) { + _ames_forward(pac_u, lac); } - // otherwise, if there's space in the queue, scry the lane out of ames + // otherwise, there's space in the scry queue; scry the lane out of ames // else { u3_noun pax = u3nq(u3i_string("peers"), @@ -1106,6 +1168,8 @@ _ames_exit_cb(uv_handle_t* had_u) pac_u = nex_u; } + u3h_free(sam_u->lax_p); + c3_free(sam_u); } @@ -1131,6 +1195,7 @@ _ames_io_info(u3_auto* car_u) u3l_log(" filtered (ver): %" PRIu64 "\n", sam_u->vet_d); u3l_log(" filtered (mug): %" PRIu64 "\n", sam_u->mut_d); u3l_log(" crashed: %" PRIu64 "\n", sam_u->fal_d); + u3l_log(" cached lanes: %u\n", u3to(u3h_root, sam_u->lax_p)->use_w); } /* u3_ames_io_init(): initialize ames I/O. @@ -1145,6 +1210,23 @@ u3_ames_io_init(u3_pier* pir_u) sam_u->fit_o = c3n; sam_u->foq_d = 0; + //NOTE some numbers on memory usage for the lane cache + // + // assuming we store: + // a (list lane) with 1 item, 1+8 + 1 + (6*2) = 22 words + // and a @da as timestamp, 5 words + // consed together, 6 words + // with worst-case (128-bit) @p keys, 8 words + // and an additional cell for the k-v pair, 6 words + // that makes for a per-entry memory use of 47 words => 188 bytes + // + // the 500k entries below would take about 94mb (in the worst case, but + // not accounting for hashtable overhead). + // we could afford more, but 500k entries is more than we'll likely use + // in the near future. + // + sam_u->lax_p = u3h_new_cache(500000); + c3_assert( !uv_udp_init(u3L, &sam_u->wax_u) ); sam_u->wax_u.data = sam_u; From 585fb248ec9ac8ed7dc6ba17529e22d81c625b59 Mon Sep 17 00:00:00 2001 From: Fang Date: Sat, 29 Aug 2020 17:33:31 +0200 Subject: [PATCH 241/933] vere: only touch forward queue counter if scrying Slightly simplify the logic around changing the queue size counter by only modifying it when we're _actually_ scrying, instead of synchronously processing the forward. --- pkg/urbit/vere/io/ames.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 7dbd7efe34..8c56ca1506 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -679,7 +679,6 @@ _ames_forward(u3_panc* pac_u, u3_noun las) u3z(los); u3z(pac); } - pac_u->sam_u->foq_d--; _ames_panc_free(pac_u); } @@ -691,6 +690,8 @@ _ames_lane_scry_cb(void* vod_p, u3_noun nun) u3_panc* pac_u = vod_p; u3_weak las = u3r_at(7, nun); + pac_u->sam_u->foq_d--; + // if scry fails, remember we can't scry, and just inject the packet // if (u3_none == las) { @@ -701,7 +702,6 @@ _ames_lane_scry_cb(void* vod_p, u3_noun nun) _ames_put_packet(pac_u->sam_u, _ames_serialize_packet(pac_u, c3n), pac_u->ore_u); - pac_u->sam_u->foq_d--; _ames_panc_free(pac_u); } else { @@ -718,7 +718,6 @@ _ames_lane_scry_cb(void* vod_p, u3_noun nun) // if there is no lane, drop the packet // if (u3_nul == las) { - pac_u->sam_u->foq_d--; _ames_panc_free(pac_u); } // if there is a lane, forward the packet on it @@ -867,8 +866,6 @@ _ames_recv_cb(uv_udp_t* wax_u, // otherwise, proceed with forwarding // else { - sam_u->foq_d++; - // store the packet details for later processing // u3_panc* pac_u = c3_calloc(sizeof(*pac_u)); @@ -896,6 +893,7 @@ _ames_recv_cb(uv_udp_t* wax_u, // otherwise, there's space in the scry queue; scry the lane out of ames // else { + sam_u->foq_d++; u3_noun pax = u3nq(u3i_string("peers"), u3dc("scot", 'p', u3i_chubs(2, rec_d)), u3i_string("forward-lane"), From 7aa452b2fa73452321cb49bcc04e6a9e9a7dc3be Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 31 Aug 2020 22:34:10 +0200 Subject: [PATCH 242/933] vere: ames.c stylistic improvements Primarily, be consistent about parenthesis spacing around conditionals. --- pkg/urbit/vere/io/ames.c | 45 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 8c56ca1506..eb758a0e5d 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -113,10 +113,10 @@ _ames_pact_free(u3_pact* pac_u) */ static void _ames_panc_free(u3_panc* pac_u) { - if (0 != pac_u->nex_u) { + if ( 0 != pac_u->nex_u ) { pac_u->nex_u->pre_u = pac_u->pre_u; } - if (0 != pac_u->pre_u) { + if ( 0 != pac_u->pre_u ) { pac_u->pre_u->nex_u = pac_u->nex_u; } else { c3_assert(pac_u == pac_u->sam_u->pac_u); @@ -312,7 +312,7 @@ _ames_lane_from_sockaddr(struct sockaddr_in* add_u) /* _ames_lane_into_cache(): put las for who into cache, including timestamp */ -void +static void _ames_lane_into_cache(u3p(u3h_root) lax_p, u3_noun who, u3_noun las) { struct timeval tim_tv; gettimeofday(&tim_tv, 0); @@ -324,11 +324,11 @@ _ames_lane_into_cache(u3p(u3h_root) lax_p, u3_noun who, u3_noun las) { /* _ames_lane_from_cache(): retrieve lane for who from cache, if any & fresh */ -u3_weak +static u3_weak _ames_lane_from_cache(u3p(u3h_root) lax_p, u3_noun who) { u3_weak lac = u3h_git(lax_p, who); - if (u3_none != lac) { + if ( u3_none != lac ) { struct timeval tim_tv; gettimeofday(&tim_tv, 0); u3_noun now = u3_time_in_tv(&tim_tv); @@ -336,7 +336,7 @@ _ames_lane_from_cache(u3p(u3h_root) lax_p, u3_noun who) { // consider entries older than 2 minutes stale, ignore them // - if (120000 > u3_time_gap_ms(u3k(den), now)) { + if ( 120000 > u3_time_gap_ms(u3k(den), now) ) { lac = u3k(u3h(lac)); } else { lac = u3_none; @@ -359,7 +359,7 @@ _ames_serialize_packet(u3_panc* pac_u, c3_o dop_o) // update the body's lane, if desired // - if (c3y == dop_o) { + if ( c3y == dop_o ) { // unpack (jam [(unit lane) body]) // u3_noun lon, bod; @@ -377,7 +377,7 @@ _ames_serialize_packet(u3_panc* pac_u, c3_o dop_o) // but that doesn't matter: ames.hoon ignores origin in that case, // always using the appropriate galaxy lane instead. // - if (u3_nul == lon) { + if ( u3_nul == lon ) { u3z(lon); lon = u3nt(u3_nul, c3n, u3_ames_encode_lane(pac_u->ore_u)); nal_o = c3y; @@ -413,7 +413,7 @@ _ames_serialize_packet(u3_panc* pac_u, c3_o dop_o) // if we updated the origin lane, we need to update the mug too // - if (c3y == nal_o) { + if ( c3y == nal_o ) { pac_u->hed_u.mug_l = _ca_mug_body(sen_y + rec_y + bod_u->con_w, pac_y + 4); } @@ -672,7 +672,7 @@ _ames_forward(u3_panc* pac_u, u3_noun las) { u3_noun los = las; u3_noun pac = _ames_serialize_packet(pac_u, c3y); - while (u3_nul != las) { + while ( u3_nul != las ) { _ames_ef_send(pac_u->sam_u, u3k(u3h(las)), u3k(pac)); las = u3t(las); } @@ -694,8 +694,8 @@ _ames_lane_scry_cb(void* vod_p, u3_noun nun) // if scry fails, remember we can't scry, and just inject the packet // - if (u3_none == las) { - if (5 < ++pac_u->sam_u->saw_d) { + if ( u3_none == las ) { + if ( 5 < ++pac_u->sam_u->saw_d ) { u3l_log("ames: giving up scry\n"); pac_u->sam_u->see_o = c3n; } @@ -705,7 +705,7 @@ _ames_lane_scry_cb(void* vod_p, u3_noun nun) _ames_panc_free(pac_u); } else { - if (0 < pac_u->sam_u->saw_d) { + if ( 0 < pac_u->sam_u->saw_d ) { pac_u->sam_u->saw_d--; } @@ -717,7 +717,7 @@ _ames_lane_scry_cb(void* vod_p, u3_noun nun) // if there is no lane, drop the packet // - if (u3_nul == las) { + if ( u3_nul == las ) { _ames_panc_free(pac_u); } // if there is a lane, forward the packet on it @@ -747,7 +747,7 @@ _ames_recv_cb(uv_udp_t* wax_u, // ensure a sane message size // - if (4 >= nrd_i) { + if ( 4 >= nrd_i ) { pas_o = c3n; } // unpack the packet header @@ -800,7 +800,7 @@ _ames_recv_cb(uv_udp_t* wax_u, c3_d rec_d[2]; c3_w con_w = nrd_i - 4 - sen_y - rec_y; c3_y* con_y = NULL; - if (c3y == pas_o) { + if ( c3y == pas_o ) { u3_noun sen = u3i_bytes(sen_y, bod_y); u3_noun rec = u3i_bytes(rec_y, bod_y + sen_y); u3r_chubs(0, 2, rec_d, rec); @@ -848,8 +848,7 @@ _ames_recv_cb(uv_udp_t* wax_u, // so can't pluck these out of the event queue like it does in // _ames_cap_queue. as such, blocked on u3_lord_peek_cancel or w/e. // - if ( (u3_none == lac) && (1000 < sam_u->foq_d) ) - { + if ( (u3_none == lac) && (1000 < sam_u->foq_d) ) { c3_free(con_y); sam_u->fod_d++; @@ -859,7 +858,7 @@ _ames_recv_cb(uv_udp_t* wax_u, } // if we know there's no lane, drop the packet // - else if (u3_nul == lac) { + else if ( u3_nul == lac ) { c3_free(con_y); u3z(lac); } @@ -879,7 +878,7 @@ _ames_recv_cb(uv_udp_t* wax_u, pac_u->bod_u.con_y = con_y; pac_u->ore_u = _ames_lane_from_sockaddr((struct sockaddr_in *)adr_u); - if (0 != sam_u->pac_u) { + if ( 0 != sam_u->pac_u ) { pac_u->nex_u = sam_u->pac_u; sam_u->pac_u->pre_u = pac_u; } @@ -887,7 +886,7 @@ _ames_recv_cb(uv_udp_t* wax_u, // if we already know the lane, just forward // - if (u3_none != lac) { + if ( u3_none != lac ) { _ames_forward(pac_u, lac); } // otherwise, there's space in the scry queue; scry the lane out of ames @@ -906,7 +905,7 @@ _ames_recv_cb(uv_udp_t* wax_u, // if we passed the filter, inject the packet // - if (c3y == pas_o) { + if ( c3y == pas_o ) { c3_free(con_y); u3_lane ore_u = _ames_lane_from_sockaddr((struct sockaddr_in *)adr_u); u3_noun msg = u3i_bytes((c3_w)nrd_i, (c3_y*)buf_u->base); @@ -1026,7 +1025,7 @@ _ames_prot_scry_cb(void* vod_p, u3_noun nun) u3_ames* sam_u = vod_p; u3_weak ver = u3r_at(7, nun); - if (u3_none == ver) { + if ( u3_none == ver ) { // assume protocol version 0 // sam_u->ver_y = 0; From e90258627f7b06da10be023f282c71a695a088b6 Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 31 Aug 2020 22:36:32 +0200 Subject: [PATCH 243/933] vere: reset instead of decrement scry fail counter If scries succeed, they work. No need to make this smarter. --- pkg/urbit/vere/io/ames.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index eb758a0e5d..db20cdbfa4 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -705,9 +705,7 @@ _ames_lane_scry_cb(void* vod_p, u3_noun nun) _ames_panc_free(pac_u); } else { - if ( 0 < pac_u->sam_u->saw_d ) { - pac_u->sam_u->saw_d--; - } + pac_u->sam_u->saw_d = 0; // cache the scry result for later use // From 45ad5adbfddc7ee5fe7c0d4e4fb177818490c862 Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 31 Aug 2020 22:37:52 +0200 Subject: [PATCH 244/933] vere: more correct lane cache commentary @da are 128 bits, just like the worst-case @p. --- pkg/urbit/vere/io/ames.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index db20cdbfa4..796c088138 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -1209,13 +1209,13 @@ u3_ames_io_init(u3_pier* pir_u) // // assuming we store: // a (list lane) with 1 item, 1+8 + 1 + (6*2) = 22 words - // and a @da as timestamp, 5 words + // and a @da as timestamp, 8 words // consed together, 6 words // with worst-case (128-bit) @p keys, 8 words // and an additional cell for the k-v pair, 6 words - // that makes for a per-entry memory use of 47 words => 188 bytes + // that makes for a per-entry memory use of 50 words => 200 bytes // - // the 500k entries below would take about 94mb (in the worst case, but + // the 500k entries below would take about 100mb (in the worst case, but // not accounting for hashtable overhead). // we could afford more, but 500k entries is more than we'll likely use // in the near future. From bb136b7981c6529619c17104fc2af9846ea4a647 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 31 Aug 2020 15:55:45 -0700 Subject: [PATCH 245/933] ur: updates ur_bsr_bytes_any() test (failing) to cover off-the-end edge-cases --- pkg/urbit/tests/ur_tests.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index 9ec4fecb52..511ebe0ff1 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -1140,22 +1140,23 @@ _bsr_bytes_any_slow(ur_bsr_t *bsr, uint64_t len, uint8_t *out) static int _test_bsr_bytes_any_loop(const char *cap, uint8_t len, uint8_t val) { - int ret = 1; - uint64_t len_bit = len << 3; - ur_bsr_t a, b; - uint8_t *bytes, *c, *d; - uint8_t i, j, k; + int ret = 1; + uint64_t max = (len << 3) + 7; + ur_bsr_t a, b; + uint8_t *bytes, *c, *d; + uint8_t i, j, k; - c = malloc(len); - d = malloc(len); + c = malloc(1 + len); + d = malloc(1 + len); bytes = malloc(len); memset(bytes, val, len); for ( i = 0; i < 8; i++) { - for ( j = 1; j <= len_bit; j++ ) { + for ( j = 1; j <= max; j++ ) { a.left = b.left = len; - a.bytes = b.bytes = bytes; - a.off = a.bits = b.off = b.bits = i; + a.bytes = b.bytes = len ? bytes : 0; + a.off = b.off = len ? i : 0; + a.bits = b.bits = i; memset(c, 0x0, len); memset(d, 0x0, len); From c123e9413a5c8e9ea070907c01f0df1c9407e400 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 31 Aug 2020 15:56:55 -0700 Subject: [PATCH 246/933] ur: refactors ur_bsr_bytes_any(), fixes edge-case bugs --- pkg/urbit/tests/ur_tests.c | 2 + pkg/urbit/ur/bitstream.c | 91 ++++++++++++++++++++------------------ 2 files changed, 49 insertions(+), 44 deletions(-) diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index 511ebe0ff1..4eae9ac614 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -1184,6 +1184,8 @@ _test_bsr_bytes_any_loop(const char *cap, uint8_t len, uint8_t val) } free(bytes); + free(d); + free(c); return ret; } diff --git a/pkg/urbit/ur/bitstream.c b/pkg/urbit/ur/bitstream.c index d5ff9642df..04910f36a0 100644 --- a/pkg/urbit/ur/bitstream.c +++ b/pkg/urbit/ur/bitstream.c @@ -360,6 +360,8 @@ ur_bsr_bytes_any(ur_bsr_t *bsr, uint64_t len, uint8_t *out) { uint64_t left = bsr->left; + bsr->bits += len; + if ( !left ) { return; } @@ -368,33 +370,24 @@ ur_bsr_bytes_any(ur_bsr_t *bsr, uint64_t len, uint8_t *out) uint8_t off = bsr->off; uint64_t len_byt = len >> 3; uint8_t len_bit = ur_mask_3(len); + uint64_t need = len_byt + !!len_bit; if ( !off ) { - uint8_t bits = off + len_bit; - uint64_t need = len_byt + (bits >> 3) + !!ur_mask_3(bits); - if ( need > left ) { memcpy(out, b, left); + left = 0; bsr->bytes = 0; - bsr->left = 0; } else { memcpy(out, b, len_byt); - off = len_bit; - left -= len_byt; - - if ( !left ) { - bsr->bytes = 0; - } - else { - bsr->bytes += len_byt; - } - - bsr->left = left; + off = len_bit; if ( off ) { out[len_byt] = b[len_byt] & ((1 << off) - 1); } + + left -= len_byt; + bsr->bytes = ( left ) ? b + len_byt : 0; } } // the most-significant bits from a byte in the stream @@ -403,61 +396,71 @@ ur_bsr_bytes_any(ur_bsr_t *bsr, uint64_t len, uint8_t *out) else { uint8_t rest = 8 - off; uint8_t mask = (1 << off) - 1; - uint8_t byt = b[0]; - uint8_t l, m = byt >> off; - ur_bool_t end; - uint64_t i, max; + uint8_t byt, l, m = *b >> off; + uint64_t last = left - 1; + // loop over all the bytes we need (or all that remain) + // + // [l] holds [off] bits + // [m] holds [rest] bits + // { - uint64_t need = len_byt + !!len_bit; - end = need >= left; - max = end ? (left - 1) : len_byt; + uint64_t max = ur_min(last, len_byt); + uint64_t i; + + for ( i = 0; i < max; i++ ) { + byt = *++b; + l = byt & mask; + out[i] = m ^ (l << rest); + m = byt >> off; + } } - for ( i = 0; i < max; i++ ) { - byt = b[1ULL + i]; - l = byt & mask; - out[i] = m ^ (l << rest); - m = byt >> off; - } + // we're reading into or beyond the last byte [bsr] + // + // [m] holds all the remaining bits in [bsr], + // but we might not need all of it + // + if ( need >= left ) { + uint8_t bits = len - (last << 3); - if ( end ) { - if ( len_bit && len_bit < rest ) { - out[max] = m & ((1 << len_bit) - 1); - bsr->bytes += max; - left -= max; + if ( bits < rest ) { + out[last] = m & ((1 << bits) - 1); + bsr->bytes = b; + left = 1; off += len_bit; } else { - out[max] = m; + out[last] = m; bsr->bytes = 0; left = 0; off = 0; } } + // we need less than a byte, but it might span multiple bytes + // else { - uint8_t bits = off + len_bit; - uint64_t step = max + !!(bits >> 3); + uint8_t bits = off + len_bit; + uint8_t step = !!(bits >> 3); - bsr->bytes += step; - left -= step; + bsr->bytes = b + step; + left -= len_byt + step; off = ur_mask_3(bits); if ( len_bit ) { if ( len_bit <= rest ) { - out[max] = m & ((1 << len_bit) - 1); + out[len_byt] = m & ((1 << len_bit) - 1); } else { - l = b[1ULL + max] & ((1 << off) - 1);; - out[max] = m ^ (l << rest); + l = *++b & ((1 << off) - 1); + out[len_byt] = m ^ (l << rest); } } } } - bsr->off = off; - bsr->left = left; - bsr->bits += len; + bsr->off = off; + bsr->left = left; } } From 4387c3e2d826d51b4897ee49288567ce9e607ee6 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 31 Aug 2020 16:51:39 -0700 Subject: [PATCH 247/933] ur: adds ur_bsr_skip_any() and tests, uses in ur_cue_test() --- pkg/urbit/include/ur/bitstream.h | 3 ++ pkg/urbit/tests/ur_tests.c | 49 ++++++++++++++++++++++++++++++++ pkg/urbit/ur/bitstream.c | 49 ++++++++++++++++++++++++++++++++ pkg/urbit/ur/serial.c | 11 +------ 4 files changed, 102 insertions(+), 10 deletions(-) diff --git a/pkg/urbit/include/ur/bitstream.h b/pkg/urbit/include/ur/bitstream.h index 785866857f..0207853806 100644 --- a/pkg/urbit/include/ur/bitstream.h +++ b/pkg/urbit/include/ur/bitstream.h @@ -52,6 +52,9 @@ ur_bsr64_any(ur_bsr_t *bsr, uint8_t len); void ur_bsr_bytes_any(ur_bsr_t *bsr, uint64_t len, uint8_t *out); +void +ur_bsr_skip_any(ur_bsr_t *bsr, uint64_t len); + ur_cue_res_e ur_bsr_tag(ur_bsr_t *bsr, ur_cue_tag_e *out); diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index 4eae9ac614..2470ef5a7e 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -1204,6 +1204,54 @@ _test_bsr_bytes_any(void) & _test_bsr_bytes_any_loop("bsr bytes alt 2 even", 10, 0x55); } +static int +_test_bsr_skip_any_loop(const char *cap, uint8_t len, uint8_t val) +{ + int ret = 1; + uint64_t max = (len << 3) + 7; + ur_bsr_t a, b; + uint8_t *bytes, *c; + uint8_t i, j, k; + + c = malloc(1 + len); + bytes = malloc(len); + memset(bytes, val, len); + + for ( i = 0; i < 8; i++) { + for ( j = 1; j <= max; j++ ) { + a.left = b.left = len; + a.bytes = b.bytes = len ? bytes : 0; + a.off = b.off = len ? i : 0; + a.bits = b.bits = i; + memset(c, 0x0, len); + + _bsr_bytes_any_slow(&a, j, c); + ur_bsr_skip_any(&b, j); + + ret &= _bsr_cmp_any_check(cap, i, j, &a, &b); + } + } + + free(bytes); + free(c); + + return ret; +} + +static int +_test_bsr_skip_any(void) +{ + return _test_bsr_skip_any_loop("bsr skip nought", 0, 0x0) + & _test_bsr_skip_any_loop("bsr skip ones odd", 3, 0xff) + & _test_bsr_skip_any_loop("bsr skip ones even", 4, 0xff) + & _test_bsr_skip_any_loop("bsr skip zeros odd", 5, 0x0) + & _test_bsr_skip_any_loop("bsr skip zeros even", 6, 0x0) + & _test_bsr_skip_any_loop("bsr skip alt 1 odd", 7, 0xaa) + & _test_bsr_skip_any_loop("bsr skip alt 1 even", 8, 0xaa) + & _test_bsr_skip_any_loop("bsr skip alt 2 odd", 9, 0x55) + & _test_bsr_skip_any_loop("bsr skip alt 2 even", 10, 0x55); +} + static int _bsr_cmp_check(const char* cap, uint8_t off, @@ -1428,6 +1476,7 @@ _test_bsr(void) return _test_bsr_bit() & _test_bsr_bit_any() & _test_bsr_bytes_any() + & _test_bsr_skip_any() & _test_bsr8() & _test_bsr32() & _test_bsr64() diff --git a/pkg/urbit/ur/bitstream.c b/pkg/urbit/ur/bitstream.c index 04910f36a0..b9dbc34dd8 100644 --- a/pkg/urbit/ur/bitstream.c +++ b/pkg/urbit/ur/bitstream.c @@ -464,6 +464,55 @@ ur_bsr_bytes_any(ur_bsr_t *bsr, uint64_t len, uint8_t *out) } } +void +ur_bsr_skip_any(ur_bsr_t *bsr, uint64_t len) +{ + uint64_t left = bsr->left; + + bsr->bits += len; + + if ( !left ) { + return; + } + else { + const uint8_t *b = bsr->bytes; + uint8_t off = bsr->off; + uint64_t len_byt = len >> 3; + uint8_t len_bit = ur_mask_3(len); + uint64_t need = len_byt + !!len_bit; + uint8_t rest = 8 - off; + uint64_t last = left - 1; + + b += ur_min(last, len_byt) + 1; + + if ( need >= left ) { + uint8_t bits = len - (last << 3); + + if ( bits < rest ) { + bsr->bytes = b - 1; + left = 1; + off += len_bit; + } + else { + bsr->bytes = 0; + left = 0; + off = 0; + } + } + else { + uint8_t bits = off + len_bit; + uint8_t step = !!(bits >> 3); + + bsr->bytes = b - (1 - step); + left -= len_byt + step; + off = ur_mask_3(bits); + } + + bsr->off = off; + bsr->left = left; + } +} + static inline ur_cue_res_e _bsr_set_gone(ur_bsr_t *bsr, uint8_t bits) { diff --git a/pkg/urbit/ur/serial.c b/pkg/urbit/ur/serial.c index b7964ee9af..8f48b3d8ba 100644 --- a/pkg/urbit/ur/serial.c +++ b/pkg/urbit/ur/serial.c @@ -364,16 +364,7 @@ _cue_test_next(_cue_test_stack_t *s, return res; } - // XX need a ur_bsr_skip() - // - { - uint64_t len_byt = (len >> 3) + !!ur_mask_3(len); - uint8_t *byt = calloc(len_byt, 1); - ur_bsr_bytes_any(bsr, len, byt); - - free(byt); - } - + ur_bsr_skip_any(bsr, len); ur_dict_put((ur_root_t*)0, dict, bits); return ur_cue_good; } From 4128b19d91a08c8fd69d9f8ee02859c833322904 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 31 Aug 2020 17:05:10 -0700 Subject: [PATCH 248/933] ur: adds ur_bsr_init() to check 64-bit bitwise-addressing overflow --- pkg/urbit/include/ur/bitstream.h | 14 ++++++++++++++ pkg/urbit/ur/bitstream.c | 15 +++++++++++++++ pkg/urbit/ur/serial.c | 10 ++++++---- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/pkg/urbit/include/ur/bitstream.h b/pkg/urbit/include/ur/bitstream.h index 0207853806..7ca513352c 100644 --- a/pkg/urbit/include/ur/bitstream.h +++ b/pkg/urbit/include/ur/bitstream.h @@ -15,6 +15,14 @@ typedef enum { ur_jam_back = 2 } ur_cue_tag_e; +/* +** stateful bitstream reader, backed by a byte-buffer, +** supporting a variety of read sizes/patterns. +** +** NB: ur_bsr*_any() functions behave as if the stream were infinite, +** subject to overall limit of a 64-bit bit-cursor. +** +*/ typedef struct ur_bsr_s { uint64_t left; uint64_t bits; @@ -31,6 +39,12 @@ typedef struct ur_bsw_s { uint8_t *bytes; } ur_bsw_t; +/* +** initialize bitstream and check for 64-bit bit-cursor overflow. +*/ +ur_cue_res_e +ur_bsr_init(ur_bsr_t *bsr, uint64_t len, const uint8_t *bytes); + ur_bool_t ur_bsr_sane(ur_bsr_t *bsr); diff --git a/pkg/urbit/ur/bitstream.c b/pkg/urbit/ur/bitstream.c index b9dbc34dd8..b91a107eef 100644 --- a/pkg/urbit/ur/bitstream.c +++ b/pkg/urbit/ur/bitstream.c @@ -5,6 +5,21 @@ #include "ur/defs.h" #include "ur/bitstream.h" +ur_cue_res_e +ur_bsr_init(ur_bsr_t *bsr, uint64_t len, const uint8_t *bytes) +{ + // check for overflow + // + if ( (len << 3) < len ) { + return ur_cue_meme; + } + + bsr->left = len; + bsr->bytes = bytes; + + return ur_cue_good; +} + ur_bool_t ur_bsr_sane(ur_bsr_t *bsr) { diff --git a/pkg/urbit/ur/serial.c b/pkg/urbit/ur/serial.c index 8f48b3d8ba..a4aa5e74a4 100644 --- a/pkg/urbit/ur/serial.c +++ b/pkg/urbit/ur/serial.c @@ -227,8 +227,9 @@ ur_cue_unsafe(ur_root_t *r, // init bitstream-reader // - bsr.left = len; - bsr.bytes = byt; + if ( ur_cue_good != (res = ur_bsr_init(&bsr, len, byt)) ) { + return res; + } // setup stack // @@ -383,8 +384,9 @@ ur_cue_test_unsafe(ur_dict_t *dict, // init bitstream-reader // - bsr.left = len; - bsr.bytes = byt; + if ( ur_cue_good != (res = ur_bsr_init(&bsr, len, byt)) ) { + return res; + } // setup stack // From 612df9541fd23767bc56a7244b79226ae1d17a17 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 31 Aug 2020 17:48:32 -0700 Subject: [PATCH 249/933] ur: documents jam/cue invariants, enforces cue --- pkg/urbit/include/ur/serial.h | 20 ++++++++++++++++++++ pkg/urbit/ur/serial.c | 10 ++++++++++ 2 files changed, 30 insertions(+) diff --git a/pkg/urbit/include/ur/serial.h b/pkg/urbit/include/ur/serial.h index 13d8fae511..9a05115a04 100644 --- a/pkg/urbit/include/ur/serial.h +++ b/pkg/urbit/include/ur/serial.h @@ -5,6 +5,15 @@ #include #include +/* +** bit-wise serialize a noun of arbitrary into a byte-buffer. +** supports up to 64-bits of bit-addressed output (nearly 2 EiB). +** as this is an impractical volume data, cursor overflow is not checked. +** +** unsafe variant is unsafe wrt its [dict] parameter, which must be empty, +** but can be passed in order to skip reallocation inside hot loops. +** +*/ uint64_t ur_jam_unsafe(ur_root_t *r, ur_nref ref, @@ -15,6 +24,17 @@ ur_jam_unsafe(ur_root_t *r, uint64_t ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt); +/* +** bitwise deserialization of an arbitrary byte-buffer into a noun. +** supports up to 62-bits of bit-addressed input (511 PiB). +** return will be [ur_cue_good] upon success. +** +** unsafe variant is unsafe wrt its [dict] parameter, which must be empty, +** but can be passed in order to skip reallocation inside hot loops. +** +** test variant does not allocate nouns, but merely parses the input. +** +*/ ur_cue_res_e ur_cue_unsafe(ur_root_t *r, ur_dict64_t *dict, diff --git a/pkg/urbit/ur/serial.c b/pkg/urbit/ur/serial.c index a4aa5e74a4..71b14222ed 100644 --- a/pkg/urbit/ur/serial.c +++ b/pkg/urbit/ur/serial.c @@ -230,6 +230,11 @@ ur_cue_unsafe(ur_root_t *r, if ( ur_cue_good != (res = ur_bsr_init(&bsr, len, byt)) ) { return res; } + // bit-cursor (and backreferences) must fit in 62-bit direct atoms + // + else if ( 0x7ffffffffffffffULL < len ) { + return ur_cue_meme; + } // setup stack // @@ -387,6 +392,11 @@ ur_cue_test_unsafe(ur_dict_t *dict, if ( ur_cue_good != (res = ur_bsr_init(&bsr, len, byt)) ) { return res; } + // bit-cursor (and backreferences) must fit in 62-bit direct atoms + // + else if ( 0x7ffffffffffffffULL < len ) { + return ur_cue_meme; + } // setup stack // From fd5edcb6b64f8fcba60d0f9c40cf9dc5f06e8212 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 31 Aug 2020 17:51:39 -0700 Subject: [PATCH 250/933] ur: distinguish bad backreferences from other failures in cue --- pkg/urbit/include/ur/bitstream.h | 5 +++-- pkg/urbit/ur/serial.c | 9 ++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/pkg/urbit/include/ur/bitstream.h b/pkg/urbit/include/ur/bitstream.h index 7ca513352c..5a6d5239cd 100644 --- a/pkg/urbit/include/ur/bitstream.h +++ b/pkg/urbit/include/ur/bitstream.h @@ -5,8 +5,9 @@ typedef enum { ur_cue_good = 0, - ur_cue_gone = 1, - ur_cue_meme = 2 + ur_cue_back = 1, + ur_cue_gone = 2, + ur_cue_meme = 3 } ur_cue_res_e; typedef enum { diff --git a/pkg/urbit/ur/serial.c b/pkg/urbit/ur/serial.c index 71b14222ed..5a945072df 100644 --- a/pkg/urbit/ur/serial.c +++ b/pkg/urbit/ur/serial.c @@ -174,10 +174,8 @@ _cue_next(ur_root_t *r, else { uint64_t val, bak = ur_bsr64_any(bsr, len); - // XX distinguish bad backref? - // if ( !ur_dict64_get(r, dict, bak, &val) ) { - return ur_cue_gone; + return ur_cue_back; } *out = (ur_nref)val; @@ -356,12 +354,9 @@ _cue_test_next(_cue_test_stack_t *s, } else { uint64_t bak = ur_bsr64_any(bsr, len); - - // XX distinguish bad backref? - // return ur_dict_get((ur_root_t*)0, dict, bak) ? ur_cue_good - : ur_cue_gone; + : ur_cue_back; } } From b01d57eb3037b1d4a607a72d0474e1aa9ff00f43 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 31 Aug 2020 17:53:32 -0700 Subject: [PATCH 251/933] u3: distinguish bad backreferences, enforce 62-bit cursors in cue --- pkg/urbit/noun/serial.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index 8924162bb5..688026a698 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -923,14 +923,11 @@ _cs_cue_xeno_next(_cue_stack_t* tac_u, c3_w bak_w; if ( !ur_dict32_get(rot_u, dic_u, bak_d, &bak_w) ) { - // XX distinguish bad backref? - // - return ur_cue_gone; - } - else { - *out = u3k((u3_noun)bak_w); - return ur_cue_good; + return ur_cue_back; } + + *out = u3k((u3_noun)bak_w); + return ur_cue_good; } } @@ -980,8 +977,14 @@ u3s_cue_xeno_unsafe(ur_dict32_t* dic_u, // init bitstream-reader // - red_u.left = len_d; - red_u.bytes = byt_y; + if ( ur_cue_good != (res_e = ur_bsr_init(&red_u, len_d, byt_y)) ) { + return res_e; + } + // bit-cursor (and backreferences) must fit in 62-bit direct atoms + // + else if ( 0x7ffffffffffffffULL < len_d ) { + return ur_cue_meme; + } // setup stack // @@ -1213,8 +1216,13 @@ u3s_cue_bytes(c3_d len_d, const c3_y* byt_y) // init bitstream-reader // - red_u.left = len_d; - red_u.bytes = byt_y; + _cs_cue_need(ur_bsr_init(&red_u, len_d, byt_y)); + + // bit-cursor (and backreferences) must fit in 62-bit direct atoms + // + if ( 0x7ffffffffffffffULL < len_d ) { + return u3m_bail(c3__meme); + } // advance into stream // From 626c4671da5a4eee7bb6d0df4c0e39a567597ab9 Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 1 Sep 2020 14:30:42 +0200 Subject: [PATCH 252/933] vere: v0.10.9-rc1 --- pkg/urbit/configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/urbit/configure b/pkg/urbit/configure index e7c2def8c9..313d11a10e 100755 --- a/pkg/urbit/configure +++ b/pkg/urbit/configure @@ -2,7 +2,7 @@ set -e -URBIT_VERSION="0.10.8" +URBIT_VERSION="0.10.9-rc1" deps=" \ curl gmp sigsegv argon2 ed25519 ent h2o scrypt uv murmur3 secp256k1 \ From f0dd6dc7a6ca5ba5274b53e08cb850b3e6347047 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 31 Aug 2020 19:40:32 -0700 Subject: [PATCH 253/933] u3: refactors u3s_cue_xeno, declares u3s_cue_xeno_unsafe() --- pkg/urbit/bench/ur_bench.c | 18 ++++-------- pkg/urbit/include/noun/serial.h | 18 ++++++++++-- pkg/urbit/noun/serial.c | 51 ++++++++++++++++++--------------- pkg/urbit/noun/urth.c | 21 +++++++++++--- pkg/urbit/tests/jam_tests.c | 10 +------ 5 files changed, 67 insertions(+), 51 deletions(-) diff --git a/pkg/urbit/bench/ur_bench.c b/pkg/urbit/bench/ur_bench.c index 7b6283fefd..af99346ffc 100644 --- a/pkg/urbit/bench/ur_bench.c +++ b/pkg/urbit/bench/ur_bench.c @@ -2,14 +2,6 @@ #include "vere/vere.h" #include "ur/ur.h" -// XX not declared in serial.h due to presence of ur_* types -// -ur_cue_res_e -u3s_cue_xeno_unsafe(ur_dict32_t* dic_u, - c3_d len_d, - const c3_y* byt_y, - u3_noun* out); - /* _setup(): prepare for tests. */ static void @@ -188,12 +180,11 @@ _cue_bench(void) fprintf(stderr, " cue atom: %u ms\r\n", mil_w); } - // NB: runs 1/8th the number of times - // { gettimeofday(&b4, 0); { + u3_noun out; c3_w len_w = u3r_met(3, vat); // XX assumes little-endian // @@ -201,15 +192,16 @@ _cue_bench(void) ? (c3_y*)&vat : (c3_y*)((u3a_atom*)u3a_to_ptr(vat))->buf_w; - for ( i_w = 0; i_w < max_w / 8; i_w++ ) { - u3z(u3s_cue_xeno(len_w, byt_y)); + for ( i_w = 0; i_w < max_w; i_w++ ) { + u3s_cue_xeno(len_w, byt_y, &out); + u3z(out); } } gettimeofday(&f2, 0); timersub(&f2, &b4, &d0); mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); - fprintf(stderr, " cue xeno: %u ms (estimated)\r\n", mil_w * 8); + fprintf(stderr, " cue xeno: %u ms\r\n", mil_w); } { diff --git a/pkg/urbit/include/noun/serial.h b/pkg/urbit/include/noun/serial.h index 1ecfdd5112..8d82e3de80 100644 --- a/pkg/urbit/include/noun/serial.h +++ b/pkg/urbit/include/noun/serial.h @@ -1,6 +1,12 @@ /* i/n/serial.h ** */ + /* forward declarations + */ + /* ur_dict32_s: off-loom 32-bit dictionary. + */ + struct ur_dict32_s; + /* Noun serialization. All noun arguments RETAINED. */ @@ -40,10 +46,18 @@ u3_noun u3s_cue(u3_atom a); + /* u3s_cue_xeno_unsafe(): cue onto the loom, all bookkeeping off-loom. + */ + c3_o + u3s_cue_xeno_unsafe(struct ur_dict32_s* dic_u, + c3_d len_d, + const c3_y* byt_y, + u3_noun* out); + /* u3s_cue_xeno(): cue onto the loom, bookkeeping off the loom. */ - u3_noun - u3s_cue_xeno(c3_d len_d, const c3_y* byt_y); + c3_o + u3s_cue_xeno(c3_d len_d, const c3_y* byt_y, u3_noun* out); /* u3s_cue_bytes(): cue bytes onto the loom. */ diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index 688026a698..7c48cb58a5 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -963,8 +963,10 @@ _cs_cue_xeno_next(_cue_stack_t* tac_u, } /* u3s_cue_xeno_unsafe(): cue onto the loom, all bookkeeping off-loom. +** +** NB: unsafe wrt to [dic_u], which must be empty. */ -ur_cue_res_e +c3_o u3s_cue_xeno_unsafe(ur_dict32_t* dic_u, c3_d len_d, const c3_y* byt_y, @@ -978,12 +980,12 @@ u3s_cue_xeno_unsafe(ur_dict32_t* dic_u, // init bitstream-reader // if ( ur_cue_good != (res_e = ur_bsr_init(&red_u, len_d, byt_y)) ) { - return res_e; + return c3n; } // bit-cursor (and backreferences) must fit in 62-bit direct atoms // else if ( 0x7ffffffffffffffULL < len_d ) { - return ur_cue_meme; + return c3n; } // setup stack @@ -1020,43 +1022,46 @@ u3s_cue_xeno_unsafe(ur_dict32_t* dic_u, } } - c3_free(tac_u.fam_u); - if ( ur_cue_good == res_e ) { *out = ref; + c3_free(tac_u.fam_u); + return c3y; + } + else { + // unwind the stack, disposing intermediate nouns + // + while ( tac_u.fil_w ) { + _cue_frame_t* fam_u = &(tac_u.fam_u[--tac_u.fil_w]); + + if ( u3_none != fam_u->ref ) { + u3z(fam_u->ref); + } + } + + c3_free(tac_u.fam_u); + return c3n; } - return res_e; } /* u3s_cue_xeno(): cue onto the loom, bookkeeping off the loom. */ -u3_noun -u3s_cue_xeno(c3_d len_d, const c3_y* byt_y) +c3_o +u3s_cue_xeno(c3_d len_d, const c3_y* byt_y, u3_noun* out) { ur_dict32_t dic_u = {0}; - ur_cue_res_e res_e; - u3_noun pro; + c3_o ret_o; c3_assert( &(u3H->rod_u) == u3R ); // XX tune the initial dictionary size for less reallocation // - { - ur_root_t* rot_u = 0; - ur_dict32_grow(rot_u, &dic_u, ur_fib33, ur_fib34); - } + ur_dict32_grow((ur_root_t*)0, &dic_u, ur_fib10, ur_fib11); - // errors are fatal - // - if ( ur_cue_good != - (res_e = u3s_cue_xeno_unsafe(&dic_u, len_d, byt_y, &pro)) ) - { - fprintf(stderr, "cue xeno: failed\r\n"); - exit(1); - } + ret_o = u3s_cue_xeno_unsafe(&dic_u, len_d, byt_y, out); ur_dict_free((ur_dict_t*)&dic_u); - return pro; + + return ret_o; } /* _cs_cue_need(): bail on ur_cue_* read failures. diff --git a/pkg/urbit/noun/urth.c b/pkg/urbit/noun/urth.c index 442d15587a..16dcd66a06 100644 --- a/pkg/urbit/noun/urth.c +++ b/pkg/urbit/noun/urth.c @@ -754,12 +754,25 @@ u3u_uncram(c3_c* dir_c, c3_d eve_d) // XX errors are fatal, barring a full "u3m_reboot"-type operation. // { - u3_noun roc, cod, ref = u3s_cue_xeno(len_d, byt_y); + ur_dict32_t dic_u = {0}; + u3_noun roc, cod, ref; - if ( u3r_pq(ref, c3__fast, &roc, &cod) ) { - u3z(ref); + // XX tune the initial dictionary size for less reallocation + // + ur_dict32_grow((ur_root_t*)0, &dic_u, ur_fib33, ur_fib34); + + if ( c3n == u3s_cue_xeno_unsafe(&dic_u, len_d, byt_y, &ref) ) { + fprintf(stderr, "uncram: failed to cue rock\r\n"); + ur_dict_free((ur_dict_t*)&dic_u); + return c3n; + } + + ur_dict_free((ur_dict_t*)&dic_u); + + if ( c3n == u3r_pq(ref, c3__fast, &roc, &cod) ) { fprintf(stderr, "uncram: failed: invalid rock format\r\n"); - exit(1); + u3z(ref); + return c3n; } u3A->roc = u3k(roc); diff --git a/pkg/urbit/tests/jam_tests.c b/pkg/urbit/tests/jam_tests.c index f759d89345..da8fc914ae 100644 --- a/pkg/urbit/tests/jam_tests.c +++ b/pkg/urbit/tests/jam_tests.c @@ -1,14 +1,6 @@ #include "all.h" #include "ur/ur.h" -// XX not declared in serial.h due to presence of ur_* types -// -ur_cue_res_e -u3s_cue_xeno_unsafe(ur_dict32_t* dic_u, - c3_d len_d, - const c3_y* byt_y, - u3_noun* out); - /* _setup(): prepare for tests. */ static void @@ -380,7 +372,7 @@ _test_cue_spec(const c3_c* cap_c, ur_dict32_grow((ur_root_t*)0, &dic_u, ur_fib10, ur_fib11); - if ( ur_cue_good != u3s_cue_xeno_unsafe(&dic_u, len_w, byt_y, &out) ) { + if ( c3n == u3s_cue_xeno_unsafe(&dic_u, len_w, byt_y, &out) ) { fprintf(stderr, "\033[31mcue %s fail 1\033[0m\r\n", cap_c); ret_i = 0; } From 7d541b5a1f984fb2f11ac333e853da014d715330 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 1 Sep 2020 12:07:21 -0700 Subject: [PATCH 254/933] u3: refactors mmap read/write patterns in urth.c --- pkg/urbit/include/noun/urth.h | 20 +++++ pkg/urbit/noun/urth.c | 136 +++++++++++++++++++++++++++------- 2 files changed, 128 insertions(+), 28 deletions(-) diff --git a/pkg/urbit/include/noun/urth.h b/pkg/urbit/include/noun/urth.h index 7320d3b329..c8dd98a96b 100644 --- a/pkg/urbit/include/noun/urth.h +++ b/pkg/urbit/include/noun/urth.h @@ -15,3 +15,23 @@ */ c3_o u3u_uncram(c3_c* dir_c, c3_d eve_d); + + /* u3u_mmap_read(): open and mmap the file at [pat_c] for reading. + */ + c3_o + u3u_mmap_read(c3_c* cap_c, c3_c* pat_c, c3_d* out_d, c3_y** out_y); + + /* u3u_mmap(): open/create file-backed mmap at [pat_c] for read/write. + */ + c3_o + u3u_mmap(c3_c* cap_c, c3_c* pat_c, c3_d len_d, c3_y** out_y); + + /* u3u_mmap_save(): sync file-backed mmap. + */ + c3_o + u3u_mmap_save(c3_c* cap_c, c3_c* pat_c, c3_d len_d, c3_y* byt_y); + + /* u3u_munmap(): unmap the region at [byt_y]. + */ + c3_o + u3u_munmap(c3_d len_d, c3_y* byt_y); diff --git a/pkg/urbit/noun/urth.c b/pkg/urbit/noun/urth.c index 16dcd66a06..a791a3f65c 100644 --- a/pkg/urbit/noun/urth.c +++ b/pkg/urbit/noun/urth.c @@ -657,41 +657,30 @@ u3u_cram(c3_c* dir_c, c3_d eve_d) return ret_o; } -/* _cu_rock_load(): load a rock into a byte buffer. +/* u3u_mmap_read(): open and mmap the file at [pat_c] for reading. */ -static c3_o -_cu_rock_load(c3_c* dir_c, c3_d eve_d, c3_d* out_d, c3_y** out_y) +c3_o +u3u_mmap_read(c3_c* cap_c, c3_c* pat_c, c3_d* out_d, c3_y** out_y) { c3_i fid_i; c3_d len_d; - // open rock file + // open file // - { - c3_c* nam_c; - - if ( c3n == _cu_rock_path(dir_c, eve_d, &nam_c) ) { - return c3n; - } - - if ( -1 == (fid_i = open(nam_c, O_RDONLY, 0644)) ) { - fprintf(stderr, "rock: open failed (%s, %" PRIu64 "): %s\r\n", - dir_c, eve_d, strerror(errno)); - c3_free(nam_c); - return c3n; - } - - c3_free(nam_c); + if ( -1 == (fid_i = open(pat_c, O_RDONLY, 0644)) ) { + fprintf(stderr, "%s: open failed (%s): %s\r\n", + cap_c, pat_c, strerror(errno)); + return c3n; } - // measure rock file + // measure file // { struct stat buf_b; if ( -1 == fstat(fid_i, &buf_b) ) { - fprintf(stderr, "rock: stat failed (%s, %" PRIu64 "): %s\r\n", - dir_c, eve_d, strerror(errno)); + fprintf(stderr, "%s: stat failed (%s): %s\r\n", + cap_c, pat_c, strerror(errno)); close(fid_i); return c3n; } @@ -699,14 +688,14 @@ _cu_rock_load(c3_c* dir_c, c3_d eve_d, c3_d* out_d, c3_y** out_y) len_d = buf_b.st_size; } - // mmap rock file + // mmap file // { void* ptr_v; if ( MAP_FAILED == (ptr_v = mmap(0, len_d, PROT_READ, MAP_SHARED, fid_i, 0)) ) { - fprintf(stderr, "rock: mmap failed (%s, %" PRIu64 "): %s\r\n", - dir_c, eve_d, strerror(errno)); + fprintf(stderr, "%s: mmap failed (%s): %s\r\n", + cap_c, pat_c, strerror(errno)); close(fid_i); return c3n; } @@ -715,22 +704,104 @@ _cu_rock_load(c3_c* dir_c, c3_d eve_d, c3_d* out_d, c3_y** out_y) *out_y = (c3_y*)ptr_v; } + // close file + // close(fid_i); return c3y; } +/* u3u_mmap(): open/create file-backed mmap at [pat_c] for read/write. +*/ +c3_o +u3u_mmap(c3_c* cap_c, c3_c* pat_c, c3_d len_d, c3_y** out_y) +{ + c3_i fid_i; + + // open file + // + if ( -1 == (fid_i = open(pat_c, O_RDWR | O_CREAT | O_TRUNC, 0644)) ) { + fprintf(stderr, "%s: open failed (%s): %s\r\n", + cap_c, pat_c, strerror(errno)); + return c3n; + } + + // grow [fid_i] to [len_w] + // + // XX build with _FILE_OFFSET_BITS == 64 ? + // + if ( 0 != ftruncate(fid_i, len_d) ) { + fprintf(stderr, "%s: ftruncate grow %s: %s\r\n", + cap_c, pat_c, strerror(errno)); + close(fid_i); + return c3n; + } + + // mmap file + // + { + void* ptr_v; + + if ( MAP_FAILED == (ptr_v = mmap(0, len_d, PROT_READ|PROT_WRITE, MAP_SHARED, fid_i, 0)) ) { + fprintf(stderr, "%s: mmap failed (%s): %s\r\n", + cap_c, pat_c, strerror(errno)); + close(fid_i); + return c3n; + } + + *out_y = (c3_y*)ptr_v; + } + + // close file + // + close(fid_i); + + return c3y; +} + +/* u3u_mmap_save(): sync file-backed mmap. +*/ +c3_o +u3u_mmap_save(c3_c* cap_c, c3_c* pat_c, c3_d len_d, c3_y* byt_y) +{ + if ( 0 != msync(byt_y, len_d, MS_SYNC) ) { + fprintf(stderr, "%s: msync %s: %s\r\n", cap_c, pat_c, strerror(errno)); + return c3n; + } + + return c3y; +} + +/* u3u_munmap(): unmap the region at [byt_y]. +*/ +c3_o +u3u_munmap(c3_d len_d, c3_y* byt_y) +{ + if ( 0 != munmap(byt_y, len_d) ) { + return c3n; + } + + return c3y; +} + /* u3u_uncram(): restore persistent state from a rock. */ c3_o u3u_uncram(c3_c* dir_c, c3_d eve_d) { + c3_c* nam_c; c3_d len_d; c3_y* byt_y; // load rock file into buffer // - if ( c3n == _cu_rock_load(dir_c, eve_d, &len_d, &byt_y) ) { + if ( c3n == _cu_rock_path(dir_c, eve_d, &nam_c) ) { + fprintf(stderr, "uncram: failed to make rock path (%s, %" PRIu64 ")\r\n", + dir_c, eve_d); + return c3n; + } + else if ( c3n == u3u_mmap_read("rock", nam_c, &len_d, &byt_y) ) { + c3_free(nam_c); return c3n; } @@ -764,6 +835,7 @@ u3u_uncram(c3_c* dir_c, c3_d eve_d) if ( c3n == u3s_cue_xeno_unsafe(&dic_u, len_d, byt_y, &ref) ) { fprintf(stderr, "uncram: failed to cue rock\r\n"); ur_dict_free((ur_dict_t*)&dic_u); + c3_free(nam_c); return c3n; } @@ -772,6 +844,7 @@ u3u_uncram(c3_c* dir_c, c3_d eve_d) if ( c3n == u3r_pq(ref, c3__fast, &roc, &cod) ) { fprintf(stderr, "uncram: failed: invalid rock format\r\n"); u3z(ref); + c3_free(nam_c); return c3n; } @@ -781,6 +854,8 @@ u3u_uncram(c3_c* dir_c, c3_d eve_d) u3z(ref); } + u3u_munmap(len_d, byt_y); + // allocate new hot jet state; re-establish warm // u3j_boot(c3y); @@ -796,9 +871,14 @@ u3u_uncram(c3_c* dir_c, c3_d eve_d) // leave rocks on disk // - // if ( c3n == u3m_rock_drop(dir_c, eve_d) ) { - // u3l_log("serf: warning: orphaned state file\r\n"); + // if ( 0 != unlink(nam_c) ) { + // fprintf(stderr, "uncram: failed to delete rock (%s, %" PRIu64 "): %s\r\n", + // dir_c, eve_d, strerror(errno)); + // c3_free(nam_c); + // return c3n; // } + c3_free(nam_c); + return c3y; } From 2897feeea39ada1945dbde567dbf8411c625086b Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 1 Sep 2020 13:59:20 -0700 Subject: [PATCH 255/933] u3: removes obsolete portable snapshot implementation --- pkg/urbit/include/noun/events.h | 21 --- pkg/urbit/include/noun/manage.h | 20 -- pkg/urbit/include/noun/serial.h | 18 -- pkg/urbit/noun/events.c | 114 ------------ pkg/urbit/noun/manage.c | 115 ------------ pkg/urbit/noun/serial.c | 311 -------------------------------- 6 files changed, 599 deletions(-) diff --git a/pkg/urbit/include/noun/events.h b/pkg/urbit/include/noun/events.h index 67729118f8..16b706f535 100644 --- a/pkg/urbit/include/noun/events.h +++ b/pkg/urbit/include/noun/events.h @@ -78,27 +78,6 @@ c3_w u3e_dirty(void); - /* u3e_hold(): backup memory images - */ - c3_o - u3e_hold(void); - - /* u3e_drop(): remove backed-up memory images - */ - c3_o - u3e_drop(void); - - /* u3e_fall(): restore memory images - */ - c3_o - u3e_fall(void); - - /* u3e_wipe(): discard memory images - */ - c3_o - u3e_wipe(void); - - /* u3e_yolo(): disable dirty page tracking, read/write whole loom. */ c3_o diff --git a/pkg/urbit/include/noun/manage.h b/pkg/urbit/include/noun/manage.h index a05ce78714..fec47392ec 100644 --- a/pkg/urbit/include/noun/manage.h +++ b/pkg/urbit/include/noun/manage.h @@ -145,23 +145,3 @@ */ c3_w u3m_pack(void); - - /* u3m_rock_stay(): jam state into [dir_c] at [evt_d] - */ - c3_o - u3m_rock_stay(c3_c* dir_c, c3_d evt_d); - - /* u3m_rock_load(): load state from [dir_c] at [evt_d] - */ - c3_o - u3m_rock_load(c3_c* dir_c, c3_d evt_d); - - /* u3m_rock_drop(): delete saved state from [dir_c] at [evt_d] - */ - c3_o - u3m_rock_drop(c3_c* dir_c, c3_d evt_d); - - /* u3m_wipe(): purge and reinitialize loom, with checkpointing - */ - void - u3m_wipe(void); diff --git a/pkg/urbit/include/noun/serial.h b/pkg/urbit/include/noun/serial.h index 8d82e3de80..f7a06aa4aa 100644 --- a/pkg/urbit/include/noun/serial.h +++ b/pkg/urbit/include/noun/serial.h @@ -18,24 +18,6 @@ c3_w* u3s_jam_fib(u3_noun a, c3_w* bit_w); - /* u3s_jam_met(): measure a noun for jam, calculating backrefs - */ - c3_d - u3s_jam_met(u3_noun a, u3p(u3h_root)* bak_p); - - /* u3s_jam_buf(): jam [a] into [buf_w], without allocation - ** - ** using backrefs in [bak_p], as computed by u3s_jam_met - ** can only encode up to c3_w bits - */ - void - u3s_jam_buf(u3_noun a, u3p(u3h_root) bak_p, c3_w* buf_w); - - /* u3s_jam_file(): jam [a] into a file, overwriting - */ - c3_o - u3s_jam_file(u3_noun a, c3_c* pas_c); - /* u3s_jam_xeno(): jam with off-loom buffer (re-)allocation. */ c3_d diff --git a/pkg/urbit/noun/events.c b/pkg/urbit/noun/events.c index 1e1fa6b815..da34120c72 100644 --- a/pkg/urbit/noun/events.c +++ b/pkg/urbit/noun/events.c @@ -882,120 +882,6 @@ u3e_live(c3_o nuu_o, c3_c* dir_c) return nuu_o; } -static c3_o -_ce_image_move(u3e_image* img_u, c3_o bak_o) -{ - c3_c old_c[8193]; - c3_c new_c[8197]; - snprintf(old_c, 8193, "%s/.urb/chk/%s.bin", u3P.dir_c, img_u->nam_c); - snprintf(new_c, 8197, "%s.bak", old_c); - - c3_i ret_i; - - if ( c3y == bak_o ) { - ret_i = rename(old_c, new_c); - } - else { - ret_i = rename(new_c, old_c); - } - - if ( 0 != ret_i ) { - u3l_log("loom: %s %s failed: %s\r\n", ( c3y == bak_o ) ? "hold" : "fall", - img_u->nam_c, strerror(errno)); - return c3n; - } - - return c3y; -} - -/* u3e_hold(): backup memory images -*/ -c3_o -u3e_hold(void) -{ - if ( (c3n == _ce_image_move(&u3P.nor_u, c3y)) || - (c3n == _ce_image_move(&u3P.sou_u, c3y)) ) - { - return c3n; - } - - // XX sync directory - - return c3y; -} - -static c3_o -_ce_image_drop(u3e_image* img_u) -{ - c3_c pat_c[8193]; - snprintf(pat_c, 8192, "%s/.urb/chk/%s.bin.bak", u3P.dir_c, img_u->nam_c); - - if ( 0 != unlink(pat_c) ) { - u3l_log("loom: drop %s failed: %s\r\n", img_u->nam_c, strerror(errno)); - return c3n; - } - - return c3y; -} - -/* u3e_drop(): remove backed-up memory images -*/ -c3_o -u3e_drop(void) -{ - if ( (c3n == _ce_image_drop(&u3P.nor_u)) || - (c3n == _ce_image_drop(&u3P.sou_u)) ) - { - return c3n; - } - - return c3y; -} - -/* u3e_fall(): restore memory images -*/ -c3_o -u3e_fall(void) -{ - if ( (c3n == _ce_image_move(&u3P.nor_u, c3n)) || - (c3n == _ce_image_move(&u3P.sou_u, c3n)) ) - { - return c3n; - } - - // XX sync directory - - return c3y; -} - -/* u3e_wipe(): discard memory images -*/ -c3_o -u3e_wipe(void) -{ - // XX ensure no patch files are present - - if ( 0 != ftruncate(u3P.nor_u.fid_i, 0) ) { - u3l_log("loom: wipe %s failed: %s\r\n", u3P.nor_u.nam_c, strerror(errno)); - return c3n; - } - - if ( 0 != ftruncate(u3P.sou_u.fid_i, 0) ) { - u3l_log("loom: wipe %s failed: %s\r\n", u3P.sou_u.nam_c, strerror(errno)); - return c3n; - } - - c3_sync(u3P.nor_u.fid_i); - c3_sync(u3P.sou_u.fid_i); - - close(u3P.nor_u.fid_i); - close(u3P.sou_u.fid_i); - - // XX sync directory - - return c3y; -} - /* u3e_yolo(): disable dirty page tracking, read/write whole loom. */ c3_o diff --git a/pkg/urbit/noun/manage.c b/pkg/urbit/noun/manage.c index c83d006055..2a1c36c7d1 100644 --- a/pkg/urbit/noun/manage.c +++ b/pkg/urbit/noun/manage.c @@ -1729,121 +1729,6 @@ u3m_boot_lite(void) return 0; } -/* u3m_rock_stay(): jam state into [dir_c] at [evt_d] -*/ -c3_o -u3m_rock_stay(c3_c* dir_c, c3_d evt_d) -{ - c3_c nam_c[8193]; - - snprintf(nam_c, 8192, "%s", dir_c); - mkdir(nam_c, 0700); - - snprintf(nam_c, 8192, "%s/.urb", dir_c); - mkdir(nam_c, 0700); - - snprintf(nam_c, 8192, "%s/.urb/roc", dir_c); - mkdir(nam_c, 0700); - - snprintf(nam_c, 8192, "%s/.urb/roc/%" PRIu64 ".jam", dir_c, evt_d); - - { - u3_noun dat = u3nt(c3__fast, u3k(u3A->roc), u3j_stay()); - c3_o ret_o = u3s_jam_file(dat, nam_c); - u3z(dat); - return ret_o; - } -} - -/* u3m_rock_load(): load state from [dir_c] at [evt_d] -*/ -c3_o -u3m_rock_load(c3_c* dir_c, c3_d evt_d) -{ - c3_c nam_c[8193]; - snprintf(nam_c, 8192, "%s/.urb/roc/%" PRIu64 ".jam", dir_c, evt_d); - - { - u3_noun dat; - - { - // XX u3m_file bails, but we'd prefer to return errors - // - u3_noun fil = u3m_file(nam_c); - u3a_print_memory(stderr, "rock: load", u3r_met(5, fil)); - - u3_noun pro = u3m_soft(0, u3ke_cue, fil); - - if ( u3_blip != u3h(pro) ) { - fprintf(stderr, "rock: unable to cue %s\r\n", nam_c); - u3z(pro); - return c3n; - } - else { - dat = u3k(u3t(pro)); - u3z(pro); - } - } - - { - u3_noun roc, rel; - - if ( u3r_pq(dat, c3__fast, &roc, &rel) ) { - u3z(dat); - return c3n; - } - - u3A->roc = u3k(roc); - u3j_load(u3k(rel)); - } - - u3z(dat); - } - - u3A->ent_d = evt_d; - u3j_ream(); - u3n_ream(); - - return c3y; -} - -/* u3m_rock_drop(): delete saved state from [dir_c] at [evt_d] -*/ -c3_o -u3m_rock_drop(c3_c* dir_c, c3_d evt_d) -{ - c3_c nam_c[8193]; - snprintf(nam_c, 8192, "%s/.urb/roc/%" PRIu64 ".jam", dir_c, evt_d); - - if ( 0 != unlink(nam_c) ) { - u3l_log("rock: drop %s failed: %s\r\n", nam_c, strerror(errno)); - return c3n; - } - - return c3y; -} - -/* u3m_wipe(): purge and reinitialize loom, with checkpointing -*/ -void -u3m_wipe(void) -{ - // clear page flags - // - memset((void*)u3P.dit_w, 0, u3a_pages >> 3); - // reinitialize checkpoint system - // - // NB: callers must first u3e_hold() or u3e_wipe() - // - u3e_live(c3n, u3P.dir_c); - // reinitialize loom - // - u3m_pave(c3y, c3n); - // reinitialize jets - // - u3j_boot(c3y); -} - /* u3m_reclaim: clear persistent caches to reclaim memory */ void diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index 7c48cb58a5..7e6ecb2cec 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -191,317 +191,6 @@ u3s_jam_fib(u3_noun a, c3_w* bit_w) return fib_u.buf_w; } -/* _cs_jam_met_mat(): the jam bitwidth of an atom of bitwidth [wid_w] -** -** equivalent to (head (rub a)) -*/ -static c3_d -_cs_jam_met_mat(c3_w wid_w) -{ - return ( 0 == wid_w ) ? 1ULL : - (c3_d)wid_w + (2ULL * (c3_d)_cs_met0_w(wid_w)); -} - -/* _cs_jam_met: struct for tracking the jam bitwidth of a noun -*/ -struct _cs_jam_met { - u3p(u3h_root) har_p; - u3p(u3h_root) bak_p; - c3_d len_d; -}; - -/* _cs_jam_met_atom_cb(): bitwidth of atom or backref encoding for [a] -*/ -static void -_cs_jam_met_atom_cb(u3_atom a, void* ptr_v) -{ - struct _cs_jam_met* met_u = ptr_v; - c3_w a_w = u3r_met(0, a); - u3_weak b = u3h_git(met_u->har_p, a); - - // if we haven't haven't seen [a], put cursor into [har_p] - // - if ( u3_none == b ) { - u3h_put(met_u->har_p, a, u3i_chubs(1, &(met_u->len_d))); - met_u->len_d += 1ULL + _cs_jam_met_mat(a_w); - } - else { - c3_w b_w = u3r_met(0, b); - - // if [a] is smaller than a backref, use directly - // - if ( a_w <= b_w ) { - met_u->len_d += 1ULL + _cs_jam_met_mat(a_w); - } - // otherwise, save backref - // - else { - u3h_put(met_u->bak_p, a, u3k(b)); - met_u->len_d += 2ULL + _cs_jam_met_mat(b_w); - } - } -} - -/* _cs_jam_met_cell_cb(): bitwidth of cell or backref encoding for [a] -*/ -static c3_o -_cs_jam_met_cell_cb(u3_noun a, void* ptr_v) -{ - struct _cs_jam_met* met_u = ptr_v; - u3_weak b = u3h_git(met_u->har_p, a); - - // if we haven't haven't seen [a], put cursor into [har_p] - // - if ( u3_none == b ) { - u3h_put(met_u->har_p, a, u3i_chubs(1, &(met_u->len_d))); - met_u->len_d += 2ULL; - return c3y; - } - // otherwise, save backref and shortcircuit traversal - // - else { - c3_w b_w = u3r_met(0, b); - u3h_put(met_u->bak_p, a, u3k(b)); - met_u->len_d += 2ULL + _cs_jam_met_mat(b_w); - return c3n; - } -} - -/* u3s_jam_met(): measure a noun for jam, calculating backrefs -*/ -c3_d -u3s_jam_met(u3_noun a, u3p(u3h_root)* bak_p) -{ - struct _cs_jam_met met_u; - met_u.har_p = u3h_new(); - met_u.bak_p = u3h_new(); - met_u.len_d = 0ULL; - - u3a_walk_fore(a, &met_u, _cs_jam_met_atom_cb, - _cs_jam_met_cell_cb); - u3h_free(met_u.har_p); - *bak_p = met_u.bak_p; - - return met_u.len_d; -} - -/* _cs_jam_buf: struct for tracking the pre-measured jam of a noun -*/ -struct _cs_jam_buf { - u3p(u3h_root) bak_p; - c3_w bit_w; - c3_w* buf_w; -}; - -/* _cs_jam_buf_chop(): chop [met_w] bits of [a] into [buf_u] -*/ -static void -_cs_jam_buf_chop(struct _cs_jam_buf* buf_u, c3_w met_w, u3_noun a) -{ - u3r_chop(0, 0, met_w, buf_u->bit_w, buf_u->buf_w, a); - buf_u->bit_w += met_w; -} - -/* _cs_jam_buf_mat(): length-prefixed encode (mat) [a] into [buf_u] -*/ -static void -_cs_jam_buf_mat(struct _cs_jam_buf* buf_u, u3_atom a) -{ - if ( 0 == a ) { - _cs_jam_buf_chop(buf_u, 1, 1); - } - else { - c3_w a_w = u3r_met(0, a); - c3_w b_w = _cs_met0_w(a_w); - - _cs_jam_buf_chop(buf_u, b_w+1, 1 << b_w); - _cs_jam_buf_chop(buf_u, b_w-1, a_w & ((1 << (b_w-1)) - 1)); - _cs_jam_buf_chop(buf_u, a_w, a); - } -} - -/* _cs_jam_buf_atom_cb(): encode atom or backref -*/ -static void -_cs_jam_buf_atom_cb(u3_atom a, void* ptr_v) -{ - struct _cs_jam_buf* buf_u = ptr_v; - u3_weak b = u3h_git(buf_u->bak_p, a); - - // if [a] has no backref (or this is the referent), encode atom - // - if ( (u3_none == b) || - (u3r_word(0, b) == buf_u->bit_w) ) - { - _cs_jam_buf_chop(buf_u, 1, 0); - _cs_jam_buf_mat(buf_u, a); - } - else { - c3_w a_w = u3r_met(0, a); - c3_w b_w = u3r_met(0, b); - - // if [a] is smaller than the backref, encode atom - // - if ( a_w <= b_w ) { - _cs_jam_buf_chop(buf_u, 1, 0); - _cs_jam_buf_mat(buf_u, a); - } - // otherwise, encode backref - // - else { - _cs_jam_buf_chop(buf_u, 2, 3); - _cs_jam_buf_mat(buf_u, b); - } - } -} - -/* _cs_jam_buf_cell_cb(): encode cell or backref -*/ -static c3_o -_cs_jam_buf_cell_cb(u3_noun a, void* ptr_v) -{ - struct _cs_jam_buf* buf_u = ptr_v; - u3_weak b = u3h_git(buf_u->bak_p, a); - - // if [a] has no backref (or this is the referent), encode cell - // - if ( (u3_none == b) || - (u3r_word(0, b) == buf_u->bit_w) ) - { - _cs_jam_buf_chop(buf_u, 2, 1); - return c3y; - } - // otherwise, encode backref and shortcircuit traversal - // - else { - _cs_jam_buf_chop(buf_u, 2, 3); - _cs_jam_buf_mat(buf_u, b); - return c3n; - } -} - -/* u3s_jam_buf(): jam [a] into pre-allocated [buf_w], without allocation -** -** using backrefs in [bak_p], as computed by u3s_jam_met() -** NB [buf_w] must be pre-allocated with sufficient space -** -** XX can only encode up to c3_w bits, due to use of chop -*/ -void -u3s_jam_buf(u3_noun a, u3p(u3h_root) bak_p, c3_w* buf_w) -{ - struct _cs_jam_buf buf_u; - buf_u.bak_p = bak_p; - buf_u.buf_w = buf_w; - buf_u.bit_w = 0; - - // this is in fact safe under normal usage, as - // the stack will have been checked in u3s_jam_met() - // - u3a_walk_fore_unsafe(a, &buf_u, _cs_jam_buf_atom_cb, - _cs_jam_buf_cell_cb); -} - -/* u3s_jam_file(): jam [a] into a file, overwriting -*/ -c3_o -u3s_jam_file(u3_noun a, c3_c* pas_c) -{ - u3p(u3h_root) bak_p; - c3_i fid_i = open(pas_c, O_RDWR | O_CREAT | O_TRUNC, 0644); - c3_w byt_w, wor_w, len_w; - - if ( fid_i < 0 ) { - fprintf(stderr, "jam: open %s: %s\r\n", pas_c, strerror(errno)); - return c3n; - } - - { - c3_d len_d = u3s_jam_met(a, &bak_p); - - if ( len_d > 0xffffffffULL ) { - fprintf(stderr, "jam: overflow c3_w: %" PRIu64 "\r\n", len_d); - u3h_free(bak_p); - return c3n; - } - - // length in bytes a la u3i_bytes - // - byt_w = (c3_w)(len_d >> 3ULL); - if ( len_d > (c3_d)(byt_w << 3) ) { - byt_w++; - } - - // length in words - // - wor_w = (c3_w)(len_d >> 5ULL); - if ( len_d > (c3_d)(wor_w << 5) ) { - wor_w++; - } - - // byte-length of word-length - // - len_w = 4 * wor_w; - } - - // grow [fid_i] to [len_w] - // - if ( 0 != ftruncate(fid_i, len_w) ) { - fprintf(stderr, "jam: ftruncate grow %s: %s\r\n", pas_c, strerror(errno)); - goto error; - } - - // mmap [fid_i], jam into it, sync, and unmap - // - { - c3_w* buf_w; - void* ptr_v = mmap(0, len_w, PROT_READ|PROT_WRITE, MAP_SHARED, fid_i, 0); - - if ( MAP_FAILED == ptr_v ) { - fprintf(stderr, "jam: mmap %s: %s\r\n", pas_c, strerror(errno)); - goto error; - } - - buf_w = ptr_v; - u3s_jam_buf(a, bak_p, buf_w); - - if ( 0 != msync(ptr_v, len_w, MS_SYNC) ) { - fprintf(stderr, "jam: msync %s: %s\r\n", pas_c, strerror(errno)); - // XX ignore return? - // - munmap(ptr_v, len_w); - goto error; - } - - if ( 0 != munmap(ptr_v, len_w) ) { - fprintf(stderr, "jam: munmap %s: %s\r\n", pas_c, strerror(errno)); - // XX fatal error? - // - goto error; - } - } - - // shrink [fid_i] to [byt_w] - // - if ( 0 != ftruncate(fid_i, byt_w) ) { - fprintf(stderr, "jam: ftruncate shrink %s: %s\r\n", pas_c, strerror(errno)); - goto error; - } - - { - close(fid_i); - u3h_free(bak_p); - return c3y; - } - - error: { - close(fid_i); - unlink(pas_c); - u3h_free(bak_p); - return c3n; - } -} - typedef struct _jam_xeno_s { u3p(u3h_root) har_p; ur_bsw_t rit_u; From 1839384d52a65f52bdb59700081786f42f4f16ff Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 1 Sep 2020 14:17:26 -0700 Subject: [PATCH 256/933] u3: refactors ivory-pill boot --- pkg/urbit/noun/vortex.c | 11 ++++----- pkg/urbit/vere/king.c | 52 +++++++++++++++++++++++++++++------------ 2 files changed, 42 insertions(+), 21 deletions(-) diff --git a/pkg/urbit/noun/vortex.c b/pkg/urbit/noun/vortex.c index 75351185db..8288baf03d 100644 --- a/pkg/urbit/noun/vortex.c +++ b/pkg/urbit/noun/vortex.c @@ -50,30 +50,29 @@ u3v_boot(u3_noun eve) static u3_noun _cv_lite(u3_noun pil) { - u3_noun arv = u3ke_cue(pil); u3_noun eve, pro; - u3x_trel(arv, &eve, 0, 0); + u3x_trel(pil, &eve, 0, 0); - u3l_log("lite: arvo formula %x\r\n", u3r_mug(arv)); + u3l_log("lite: arvo formula %x\r\n", u3r_mug(pil)); pro = u3v_life(u3k(eve)); u3l_log("lite: core %x\r\n", u3r_mug(pro)); - u3z(arv); + u3z(pil); return pro; } /* u3v_boot_lite(): light bootstrap sequence, just making a kernel. */ c3_o -u3v_boot_lite(u3_atom lit) +u3v_boot_lite(u3_noun pil) { // ensure zero-initialized kernel // u3A->roc = 0; { - u3_noun pro = u3m_soft(0, _cv_lite, lit); + u3_noun pro = u3m_soft(0, _cv_lite, pil); if ( u3_blip != u3h(pro) ) { u3z(pro); diff --git a/pkg/urbit/vere/king.c b/pkg/urbit/vere/king.c index c0df14592a..60f8a2c76f 100644 --- a/pkg/urbit/vere/king.c +++ b/pkg/urbit/vere/king.c @@ -692,6 +692,42 @@ _king_loop_exit() unlink(u3K.certs_c); } +static void +_king_boot_ivory(void) +{ + c3_d len_d; + c3_y* byt_y; + + if ( u3_Host.ops_u.lit_c ) { + if ( c3n == u3u_mmap_read("lite", u3_Host.ops_u.lit_c, &len_d, &byt_y) ) { + u3l_log("lite: unable to load ivory pill at %s\n", + u3_Host.ops_u.lit_c); + exit(1); + } + } + else { + len_d = u3_Ivory_pill_len; + byt_y = u3_Ivory_pill; + } + + { + u3_noun pil = u3ke_cue(u3i_bytes(len_d, byt_y)); + + if ( c3n == u3v_boot_lite(pil)) { + u3l_log("lite: boot failed\r\n"); + exit(1); + } + } + + if ( u3_Host.ops_u.lit_c ) { + if ( c3n == u3u_munmap(len_d, byt_y) ) { + u3l_log("lite: unable to unmap ivory pill at %s\n", + u3_Host.ops_u.lit_c); + exit(1); + } + } +} + /* u3_king_commence(): start the daemon */ void @@ -726,21 +762,7 @@ u3_king_commence() // boot the ivory pill // - { - u3_noun lit; - - if ( 0 != u3_Host.ops_u.lit_c ) { - lit = u3m_file(u3_Host.ops_u.lit_c); - } - else { - lit = u3i_bytes(u3_Ivory_pill_len, u3_Ivory_pill); - } - - if ( c3n == u3v_boot_lite(lit)) { - u3l_log("lite: boot failed\r\n"); - exit(1); - } - } + _king_boot_ivory(); // disable core dumps (due to lmdb size) // From d676d034cc0ee31512eb5ff6460f44930d72ab97 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 1 Sep 2020 14:38:49 -0700 Subject: [PATCH 257/933] vere: refactors ipc-framing api (newt.c) --- pkg/urbit/include/vere/vere.h | 7 +-- pkg/urbit/vere/lord.c | 106 ++++++++++++++++++---------------- pkg/urbit/vere/newt.c | 43 +++++++------- pkg/urbit/worker/main.c | 15 +++-- 4 files changed, 92 insertions(+), 79 deletions(-) diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index de8379d3ba..b47dd50d09 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -40,7 +40,7 @@ /* u3_moor_poke: poke callback function. */ - typedef void (*u3_moor_poke)(void*, u3_atom); + typedef void (*u3_moor_poke)(void*, c3_d, c3_y*); /* u3_moor_bail: bailout callback function. */ @@ -407,7 +407,6 @@ */ typedef struct _u3_writ { struct timeval tim_u; // time enqueued - u3_atom mat; // serialized struct _u3_writ* nex_u; // next in queue u3_writ_type typ_e; // type-tagged union { // @@ -1169,10 +1168,10 @@ void u3_newt_decode(u3_moat* mot_u, c3_y* buf_y, c3_d len_d); - /* u3_newt_write(): write atom to stream; free atom. + /* u3_newt_send(): write buffer to stream. */ void - u3_newt_write(u3_mojo* moj_u, u3_atom mat); + u3_newt_send(u3_mojo* moj_u, c3_d len_d, c3_y* byt_y); /* u3_newt_read_sync(): start reading; multiple msgs synchronous. */ diff --git a/pkg/urbit/vere/lord.c b/pkg/urbit/vere/lord.c index fef5584c5d..2fc2762ba1 100644 --- a/pkg/urbit/vere/lord.c +++ b/pkg/urbit/vere/lord.c @@ -652,14 +652,12 @@ _lord_plea_work(u3_lord* god_u, u3_noun dat) /* _lord_on_plea(): handle plea from serf. */ static void -_lord_on_plea(void* ptr_v, u3_noun mat) +_lord_on_plea(void* ptr_v, c3_d len_d, c3_y* byt_y) { u3_lord* god_u = ptr_v; - u3_noun jar = u3ke_cue(mat); - u3_noun tag, dat; + u3_noun tag, dat, jar = u3ke_cue(u3i_bytes(len_d, byt_y)); if ( c3n == u3r_cell(jar, &tag, &dat) ) { - u3m_p("jar", jar); return _lord_plea_foul(god_u, 0, jar); } @@ -706,64 +704,62 @@ _lord_writ_new(u3_lord* god_u) return wit_u; } -/* _lord_writ_jam(): serialize writ. +/* _lord_writ_make(): cons writ. */ -static void -_lord_writ_jam(u3_lord* god_u, u3_writ* wit_u) +static u3_noun +_lord_writ_make(u3_lord* god_u, u3_writ* wit_u) { - if ( 0 == wit_u->mat ) { - u3_noun msg; + u3_noun msg; - switch ( wit_u->typ_e ) { - default: c3_assert(0); + switch ( wit_u->typ_e ) { + default: c3_assert(0); - case u3_writ_work: { - u3_noun mil = u3i_words(1, &wit_u->wok_u.egg_u->mil_w); - msg = u3nt(c3__work, mil, u3k(wit_u->wok_u.job)); - } break; + case u3_writ_work: { + u3_noun mil = u3i_words(1, &wit_u->wok_u.egg_u->mil_w); + msg = u3nt(c3__work, mil, u3k(wit_u->wok_u.job)); + } break; - case u3_writ_peek: { - msg = u3nc(c3__peek, u3nq(0, // XX support timeouts - u3k(wit_u->pek_u->now), - u3k(wit_u->pek_u->gan), - u3k(wit_u->pek_u->ful))); - } break; + case u3_writ_peek: { + msg = u3nc(c3__peek, u3nq(0, // XX support timeouts + u3k(wit_u->pek_u->now), + u3k(wit_u->pek_u->gan), + u3k(wit_u->pek_u->ful))); + } break; - case u3_writ_play: { - u3_fact* tac_u = wit_u->fon_u.ext_u; - c3_d eve_d = tac_u->eve_d; - u3_noun lit = u3_nul; + case u3_writ_play: { + u3_fact* tac_u = wit_u->fon_u.ext_u; + c3_d eve_d = tac_u->eve_d; + u3_noun lit = u3_nul; - while ( tac_u ) { - lit = u3nc(u3k(tac_u->job), lit); - tac_u = tac_u->nex_u; - } + while ( tac_u ) { + lit = u3nc(u3k(tac_u->job), lit); + tac_u = tac_u->nex_u; + } - msg = u3nt(c3__play, u3i_chubs(1, &eve_d), u3kb_flop(lit)); + msg = u3nt(c3__play, u3i_chubs(1, &eve_d), u3kb_flop(lit)); - } break; + } break; - case u3_writ_save: { - msg = u3nt(c3__live, c3__save, u3i_chubs(1, &god_u->eve_d)); - } break; + case u3_writ_save: { + msg = u3nt(c3__live, c3__save, u3i_chubs(1, &god_u->eve_d)); + } break; - case u3_writ_cram: { - msg = u3nt(c3__live, c3__cram, u3i_chubs(1, &god_u->eve_d)); - } break; + case u3_writ_cram: { + msg = u3nt(c3__live, c3__cram, u3i_chubs(1, &god_u->eve_d)); + } break; - case u3_writ_pack: { - msg = u3nt(c3__live, c3__pack, u3_nul); - } break; + case u3_writ_pack: { + msg = u3nt(c3__live, c3__pack, u3_nul); + } break; - case u3_writ_exit: { - // requested exit code is always 0 - // - msg = u3nt(c3__live, c3__exit, 0); - } break; - } - - wit_u->mat = u3ke_jam(msg); + case u3_writ_exit: { + // requested exit code is always 0 + // + msg = u3nt(c3__live, c3__exit, 0); + } break; } + + return msg; } /* _lord_writ_send(): send writ to serf. @@ -778,9 +774,17 @@ _lord_writ_send(u3_lord* god_u, u3_writ* wit_u) god_u->inn_u.bal_f = _lord_bail_noop; } - _lord_writ_jam(god_u, wit_u); - u3_newt_write(&god_u->inn_u, wit_u->mat); - wit_u->mat = 0; + { + u3_noun jar = _lord_writ_make(god_u, wit_u); + u3_noun mat = u3ke_jam(jar); + c3_w len_w = u3r_met(3, mat); + c3_y* byt_y = c3_malloc(len_w); + + u3r_bytes(0, len_w, byt_y, mat); + u3_newt_send(&god_u->inn_u, len_w, byt_y); + + u3z(mat); + } } /* _lord_writ_plan(): enqueue a writ and send. diff --git a/pkg/urbit/vere/newt.c b/pkg/urbit/vere/newt.c index e7cfe2be50..3b349a46cd 100644 --- a/pkg/urbit/vere/newt.c +++ b/pkg/urbit/vere/newt.c @@ -70,8 +70,7 @@ _newt_meat_plan(u3_moat* mot_u, u3_meat* met_u) static void _newt_meat_poke(u3_moat* mot_u, u3_meat* met_u) { - u3_noun mat = u3i_bytes((c3_w)met_u->len_d, met_u->hun_y); - mot_u->pok_f(mot_u->ptr_v, mat); + mot_u->pok_f(mot_u->ptr_v, met_u->len_d, met_u->hun_y); c3_free(met_u); } @@ -388,7 +387,8 @@ u3_newt_moat_info(u3_moat* mot_u) typedef struct _n_req { uv_write_t wri_u; u3_mojo* moj_u; - c3_y buf_y[0]; + c3_y* buf_y; + c3_y len_y[8]; } n_req; /* _newt_write_cb(): generic write callback. @@ -399,6 +399,7 @@ _newt_write_cb(uv_write_t* wri_u, c3_i sas_i) n_req* req_u = (n_req*)wri_u; u3_mojo* moj_u = req_u->moj_u; + c3_free(req_u->buf_y); c3_free(req_u); if ( 0 != sas_i ) { @@ -435,35 +436,37 @@ u3_newt_mojo_stop(u3_mojo* moj_u, u3_moor_bail bal_f) uv_close((uv_handle_t*)&moj_u->pyp_u, _mojo_stop_cb); } -/* u3_newt_write(): write atom to stream; free atom. +/* u3_newt_send(): write buffer to stream. */ void -u3_newt_write(u3_mojo* moj_u, u3_atom mat) +u3_newt_send(u3_mojo* moj_u, c3_d len_d, c3_y* byt_y) { - c3_w len_w = u3r_met(3, mat); - n_req* req_u = c3_malloc(8 + len_w + sizeof(*req_u)); + n_req* req_u = c3_malloc(sizeof(*req_u)); req_u->moj_u = moj_u; + req_u->buf_y = byt_y; - // write header; c3_d is futureproofing + // write header // - req_u->buf_y[0] = ((len_w >> 0) & 0xff); - req_u->buf_y[1] = ((len_w >> 8) & 0xff); - req_u->buf_y[2] = ((len_w >> 16) & 0xff); - req_u->buf_y[3] = ((len_w >> 24) & 0xff); - req_u->buf_y[4] = req_u->buf_y[5] = req_u->buf_y[6] = req_u->buf_y[7] = 0; - - // write payload - // - u3r_bytes(0, len_w, req_u->buf_y + 8, mat); - u3z(mat); + req_u->len_y[0] = ( len_d & 0xff); + req_u->len_y[1] = ((len_d >> 8) & 0xff); + req_u->len_y[2] = ((len_d >> 16) & 0xff); + req_u->len_y[3] = ((len_d >> 24) & 0xff); + req_u->len_y[4] = ((len_d >> 32) & 0xff); + req_u->len_y[5] = ((len_d >> 40) & 0xff); + req_u->len_y[6] = ((len_d >> 48) & 0xff); + req_u->len_y[7] = ((len_d >> 56) & 0xff); { - uv_buf_t buf_u = uv_buf_init((c3_c*)req_u->buf_y, 8 + len_w); + uv_buf_t buf_u[2] = { + uv_buf_init((c3_c*)req_u->len_y, 8), + uv_buf_init((c3_c*)req_u->buf_y, len_d) + }; + c3_i sas_i; if ( 0 != (sas_i = uv_write(&req_u->wri_u, (uv_stream_t*)&moj_u->pyp_u, - &buf_u, 1, + buf_u, 2, _newt_write_cb)) ) { c3_free(req_u); diff --git a/pkg/urbit/worker/main.c b/pkg/urbit/worker/main.c index d7060d6b44..84baa65e47 100644 --- a/pkg/urbit/worker/main.c +++ b/pkg/urbit/worker/main.c @@ -42,7 +42,14 @@ _cw_serf_fail(void* vod_p, const c3_c* wut_c) static void _cw_serf_send(u3_noun pel) { - u3_newt_write(&out_u, u3ke_jam(pel)); + u3_noun mat = u3ke_jam(pel); + c3_d len_w = u3r_met(3, mat); + c3_y* byt_y = c3_malloc(len_w); + + u3r_bytes(0, len_w, byt_y, mat); + u3_newt_send(&out_u, len_w, byt_y); + + u3z(mat); } /* _cw_serf_send_slog(): send hint output (hod is [priority tank]). @@ -64,11 +71,11 @@ _cw_serf_send_stdr(c3_c* str_c) /* _cw_serf_writ(): */ static void -_cw_serf_writ(void* vod_p, u3_noun mat) +_cw_serf_writ(void* vod_p, c3_d len_d, c3_y* byt_y) { - u3_noun ret; + u3_noun ret, jar = u3ke_cue(u3i_bytes(len_d, byt_y)); - if ( c3n == u3_serf_writ(&u3V, u3ke_cue(mat), &ret) ) { + if ( c3n == u3_serf_writ(&u3V, jar, &ret) ) { _cw_serf_fail(0, "bad jar"); } else { From f6bd14c7c6248a348c7835a20321fa4f997611a0 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 1 Sep 2020 14:46:33 -0700 Subject: [PATCH 258/933] ur: cleans up and comments defs.h --- pkg/urbit/include/ur/defs.h | 41 ++++++++++++++++++++++++------------- pkg/urbit/ur/hashcons.c | 6 +++--- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/pkg/urbit/include/ur/defs.h b/pkg/urbit/include/ur/defs.h index 605193b1d3..d3b1c6ebfa 100644 --- a/pkg/urbit/include/ur/defs.h +++ b/pkg/urbit/include/ur/defs.h @@ -5,17 +5,34 @@ #include #include -#define ur_fib10 55 -#define ur_fib11 89 -#define ur_fib12 144 -#define ur_fib33 3524578 -#define ur_fib34 5702887 - typedef uint8_t ur_bool_t; #define ur_min(a, b) ( ((a) < (b)) ? (a) : (b) ) #define ur_max(a, b) ( ((a) > (b)) ? (a) : (b) ) +/* +** fibonacci constants, for convenient initialization of +** objects intended to be reallocated with fibonacci growth +*/ +#define ur_fib10 55 +#define ur_fib11 89 +#define ur_fib12 144 +#define ur_fib27 196418 +#define ur_fib28 317811 +#define ur_fib33 3524578 +#define ur_fib34 5702887 + +/* +** bit-masking helpers +*/ +#define ur_mask_3(a) (a & 0x7) +#define ur_mask_8(a) (a & 0xff) +#define ur_mask_31(a) (a & 0x7fffffff) +#define ur_mask_62(a) (a & 0x3fffffffffffffffULL) + +/* +** atom measurement +*/ #if (32 == (CHAR_BIT * __SIZEOF_INT__)) # define ur_lz32 __builtin_clz # define ur_tz32 __builtin_ctz @@ -39,20 +56,16 @@ typedef uint8_t ur_bool_t; #define ur_lz8(a) ( ur_lz32(a) - 24 ) #define ur_tz8 ur_tz32 -#define ur_mask_3(a) (a & 0x7) -#define ur_mask_8(a) (a & 0xff) -#define ur_mask_31(a) (a & 0x7fffffff) -#define ur_mask_62(a) (a & 0x3fffffffffffffffULL) - #define ur_met0_8(a) ( (a) ? 8 - ur_lz8(a) : 0 ) #define ur_met0_32(a) ( (a) ? 32 - ur_lz32(a) : 0 ) #define ur_met0_64(a) ( (a) ? 64 - ur_lz64(a) : 0 ) +/* +** unsafe wrt trailing null bytes, which are invalid +*/ inline uint64_t -ur_met0_bytes(uint8_t *byt, uint64_t len) +ur_met0_bytes_unsafe(uint8_t *byt, uint64_t len) { - // XX requires no trailing null bytes - // uint64_t last = len - 1; return (last << 3) + ur_met0_8(byt[last]); } diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index a4aca7d8b5..514fed6675 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -15,7 +15,7 @@ // declarations of inline functions // uint64_t -ur_met0_bytes(uint8_t *byt, uint64_t len); +ur_met0_bytes_unsafe(uint8_t *byt, uint64_t len); ur_mug ur_mug_bytes(const uint8_t *byt, uint64_t len) @@ -534,7 +534,7 @@ ur_met(ur_root_t *r, uint8_t bloq, ur_nref ref) uint64_t len = r->atoms.lens[idx]; uint8_t *byt = r->atoms.bytes[idx]; - m_bit = ur_met0_bytes(byt, len); + m_bit = ur_met0_bytes_unsafe(byt, len); } switch ( bloq ) { @@ -652,7 +652,7 @@ ur_coin_bytes(ur_root_t *r, uint8_t *byt, uint64_t len) // produce a direct atom if possible // - if ( 62 >= ur_met0_bytes(byt, len) ) { + if ( 62 >= ur_met0_bytes_unsafe(byt, len) ) { uint64_t i, direct = 0; for ( i = 0; i < len; i++ ) { From f49963ffcfbb7370aea56d52f42a34dfbe58615e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 2 Sep 2020 16:42:05 -0700 Subject: [PATCH 259/933] ur: refactors and adds comments to bitstream.h --- pkg/urbit/include/ur/bitstream.h | 133 +++++++++++++++++++++++++++---- pkg/urbit/tests/ur_tests.c | 38 ++++----- pkg/urbit/ur/bitstream.c | 23 ++++-- 3 files changed, 153 insertions(+), 41 deletions(-) diff --git a/pkg/urbit/include/ur/bitstream.h b/pkg/urbit/include/ur/bitstream.h index 5a6d5239cd..66781f569e 100644 --- a/pkg/urbit/include/ur/bitstream.h +++ b/pkg/urbit/include/ur/bitstream.h @@ -3,25 +3,13 @@ #include -typedef enum { - ur_cue_good = 0, - ur_cue_back = 1, - ur_cue_gone = 2, - ur_cue_meme = 3 -} ur_cue_res_e; - -typedef enum { - ur_jam_atom = 0, - ur_jam_cell = 1, - ur_jam_back = 2 -} ur_cue_tag_e; - /* ** stateful bitstream reader, backed by a byte-buffer, -** supporting a variety of read sizes/patterns. +** maintaing a 64-bit bit-cursor, and supporting a variety +** of read sizes and patterns. ** ** NB: ur_bsr*_any() functions behave as if the stream were infinite, -** subject to overall limit of a 64-bit bit-cursor. +** subject to the overall limit of the bit-cursor. ** */ typedef struct ur_bsr_s { @@ -31,6 +19,31 @@ typedef struct ur_bsr_s { const uint8_t *bytes; } ur_bsr_t; +/* +** generalized bitstream-reader/cue response enum +*/ +typedef enum { + ur_cue_good = 0, // successful read + ur_cue_back = 1, // missing backreference + ur_cue_gone = 2, // read off the end of the stream + ur_cue_meme = 3 // exceeded memory representation +} ur_cue_res_e; + +/* +** jam/cue type tag enumeration +*/ +typedef enum { + ur_jam_atom = 0, + ur_jam_cell = 1, + ur_jam_back = 2 +} ur_cue_tag_e; + +/* +** stateful bitstream writer, backed by a byte-buffer automatically +** reallocated with fibonacc growth, maintaing a 64-bit bit-cursor, +** and supporting a variety of write sizes and patterns. +** +*/ typedef struct ur_bsw_s { uint64_t prev; uint64_t size; @@ -41,83 +54,169 @@ typedef struct ur_bsw_s { } ur_bsw_t; /* -** initialize bitstream and check for 64-bit bit-cursor overflow. +** initialize bitstream-reader and check for 64-bit bit-cursor overflow. */ ur_cue_res_e ur_bsr_init(ur_bsr_t *bsr, uint64_t len, const uint8_t *bytes); +/* +** validate bitstream-reader invariants. +*/ ur_bool_t ur_bsr_sane(ur_bsr_t *bsr); +/* +** read a bit, failing at EOS +*/ ur_cue_res_e ur_bsr_bit(ur_bsr_t *bsr, uint8_t *out); +/* +** read a bit +*/ uint8_t ur_bsr_bit_any(ur_bsr_t *bsr); +/* +** read N (up to 8) bits into a uint8. +*/ uint8_t ur_bsr8_any(ur_bsr_t *bsr, uint8_t len); +/* +** read N (up to 32) bits into a uint32. +*/ uint32_t ur_bsr32_any(ur_bsr_t *bsr, uint8_t len); +/* +** read N (up to 64) bits into a uint64. +*/ uint64_t ur_bsr64_any(ur_bsr_t *bsr, uint8_t len); +/* +** read N bits into a zero-initialized byte array. +*/ void ur_bsr_bytes_any(ur_bsr_t *bsr, uint64_t len, uint8_t *out); +/* +** advance the bitstream cursor as if we had read N bits. +*/ void ur_bsr_skip_any(ur_bsr_t *bsr, uint64_t len); +/* +** read a jam/cue type tag. +*/ ur_cue_res_e ur_bsr_tag(ur_bsr_t *bsr, ur_cue_tag_e *out); +/* +** read a binary exponent, producing the binary log. +** +** read N (up to 255) zero bits followed by a 1, produce N. +*/ ur_cue_res_e -ur_bsr_rub_log(ur_bsr_t *bsr, uint8_t *out); +ur_bsr_log(ur_bsr_t *bsr, uint8_t *out); +/* +** read an atomic run-length (a la +rub). +** +** read a binary log N, then read N (up to 64) bits, +** produce (N-bits ^ (1 << N)) +*/ ur_cue_res_e ur_bsr_rub_len(ur_bsr_t *bsr, uint64_t *out); +/* +** reallocate bitstream write buffer with max(fibonacci, step) growth. +*/ void ur_bsw_grow(ur_bsw_t *bsw, uint64_t step); +/* +** validate bitstream-writer invariants. +*/ ur_bool_t ur_bsw_sane(ur_bsw_t *bsw); +/* +** write a bit +*/ void ur_bsw_bit(ur_bsw_t *bsw, uint8_t bit); +/* +** write N (up to 8) bits of a uint8. +*/ void ur_bsw8(ur_bsw_t *bsw, uint8_t len, uint8_t byt); +/* +** write N (up to 32) bits of a uint32. +*/ void ur_bsw32(ur_bsw_t *bsw, uint8_t len, uint32_t val); +/* +** write N (up to 64) bits of a uint64. +*/ void ur_bsw64(ur_bsw_t *bsw, uint8_t len, uint64_t val); +/* +** write N bits of a byte array. +** +** NB: [byt] must contain at least N bits. +*/ void ur_bsw_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt); +/* +** write a binary exponent (N zero bits, followed by a 1). +*/ void ur_bsw_bex(ur_bsw_t *bsw, uint8_t n); +/* +** write N (up to 64) run-length prefixed bits (a la +mat). +*/ void ur_bsw_mat64(ur_bsw_t *bsw, uint8_t len, uint64_t val); +/* +** write N run-length prefixed bits (a la +mat). +** +** NB: [byt] must contain at least N bits. +*/ void ur_bsw_mat_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt); +/* +** write a backref tag (1, 1) and N (up to 64) run-length prefixed bits. +*/ void ur_bsw_back64(ur_bsw_t *bsw, uint8_t len, uint64_t val); +/* +** write an atom tag (0) and N (up to 64) run-length prefixed bits. +*/ void ur_bsw_atom64(ur_bsw_t *bsw, uint8_t len, uint64_t val); +/* +** write an atom tag (0) and N run-length prefixed bits. +** +** NB: [byt] must contain at least N bits. +*/ void ur_bsw_atom_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt); +/* +** write a cell tag (1, 0) +*/ void ur_bsw_cell(ur_bsw_t *bsw); diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index 2470ef5a7e..f65a1fd4a2 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -1321,7 +1321,7 @@ _bsr_cmp_check(const char* cap, } static ur_cue_res_e -_bsr_rub_log_slow(ur_bsr_t *bsr, uint8_t *out) +_bsr_log_slow(ur_bsr_t *bsr, uint8_t *out) { ur_cue_res_e res; uint8_t bit, i = 0; @@ -1341,7 +1341,7 @@ _bsr_rub_log_slow(ur_bsr_t *bsr, uint8_t *out) } static int -_test_bsr_rub_log_loop(const char *cap, uint8_t len, uint8_t val) +_test_bsr_log_loop(const char *cap, uint8_t len, uint8_t val) { int ret = 1; ur_bsr_t a, b; @@ -1360,8 +1360,8 @@ _test_bsr_rub_log_loop(const char *cap, uint8_t len, uint8_t val) memset(bytes, 0x0, j); memset(bytes + j, val, len - j); - e = _bsr_rub_log_slow(&a, &c); - f = ur_bsr_rub_log(&b, &d); + e = _bsr_log_slow(&a, &c); + f = ur_bsr_log(&b, &d); ret &= _bsr_cmp_check(cap, i, j, &a, &b, c, d, e, f); } @@ -1373,29 +1373,29 @@ _test_bsr_rub_log_loop(const char *cap, uint8_t len, uint8_t val) } static int -_test_bsr_rub_log(void) +_test_bsr_log(void) { - int ret = _test_bsr_rub_log_loop("bsr rub_log nought", 0, 0x0) - & _test_bsr_rub_log_loop("bsr rub_log ones odd", 3, 0xff) - & _test_bsr_rub_log_loop("bsr rub_log ones even", 4, 0xff) - & _test_bsr_rub_log_loop("bsr rub_log ones big", 50, 0xff) - & _test_bsr_rub_log_loop("bsr rub_log zeros odd", 5, 0x0) - & _test_bsr_rub_log_loop("bsr rub_log zeros even", 6, 0x0) - & _test_bsr_rub_log_loop("bsr rub_log zeros big", 50, 0x0); + int ret = _test_bsr_log_loop("bsr log nought", 0, 0x0) + & _test_bsr_log_loop("bsr log ones odd", 3, 0xff) + & _test_bsr_log_loop("bsr log ones even", 4, 0xff) + & _test_bsr_log_loop("bsr log ones big", 50, 0xff) + & _test_bsr_log_loop("bsr log zeros odd", 5, 0x0) + & _test_bsr_log_loop("bsr log zeros even", 6, 0x0) + & _test_bsr_log_loop("bsr log zeros big", 50, 0x0); { uint8_t i, j = 5; char cap[1024]; for ( i = 0; i < 8; i++ ) { - snprintf(cap, 1000, "bsr rub_log 1<<%u odd", i); - ret &= _test_bsr_rub_log_loop((const char*)cap, j++, 0x1 << i); + snprintf(cap, 1000, "bsr log 1<<%u odd", i); + ret &= _test_bsr_log_loop((const char*)cap, j++, 0x1 << i); - snprintf(cap, 1000, "bsr rub_log 1<<%u even", i); - ret &= _test_bsr_rub_log_loop((const char*)cap, j++, 0x1 << i); + snprintf(cap, 1000, "bsr log 1<<%u even", i); + ret &= _test_bsr_log_loop((const char*)cap, j++, 0x1 << i); - snprintf(cap, 1000, "bsr rub_log 1<<%u big", i); - ret &= _test_bsr_rub_log_loop((const char*)cap, 50, 0x1 << i); + snprintf(cap, 1000, "bsr log 1<<%u big", i); + ret &= _test_bsr_log_loop((const char*)cap, 50, 0x1 << i); } } @@ -1480,7 +1480,7 @@ _test_bsr(void) & _test_bsr8() & _test_bsr32() & _test_bsr64() - & _test_bsr_rub_log() + & _test_bsr_log() & _test_bsr_tag(); } diff --git a/pkg/urbit/ur/bitstream.c b/pkg/urbit/ur/bitstream.c index b91a107eef..d72548257d 100644 --- a/pkg/urbit/ur/bitstream.c +++ b/pkg/urbit/ur/bitstream.c @@ -596,7 +596,7 @@ ur_bsr_tag(ur_bsr_t *bsr, ur_cue_tag_e *out) } static inline ur_cue_res_e -_bsr_rub_log_meme(ur_bsr_t *bsr) +_bsr_log_meme(ur_bsr_t *bsr) { bsr->bits += 256; bsr->bytes += 32; @@ -605,7 +605,7 @@ _bsr_rub_log_meme(ur_bsr_t *bsr) } ur_cue_res_e -ur_bsr_rub_log(ur_bsr_t *bsr, uint8_t *out) +ur_bsr_log(ur_bsr_t *bsr, uint8_t *out) { uint64_t left = bsr->left; @@ -621,7 +621,7 @@ ur_bsr_rub_log(ur_bsr_t *bsr, uint8_t *out) while ( !byt ) { if ( 32 == skip ) { - return _bsr_rub_log_meme(bsr); + return _bsr_log_meme(bsr); } skip++; @@ -637,7 +637,7 @@ ur_bsr_rub_log(ur_bsr_t *bsr, uint8_t *out) uint32_t zeros = ur_tz8(byt) + (skip ? ((skip << 3) - off) : 0); if ( 255 < zeros ) { - return _bsr_rub_log_meme(bsr); + return _bsr_log_meme(bsr); } else { uint32_t bits = off + 1 + zeros; @@ -663,7 +663,7 @@ ur_bsr_rub_len(ur_bsr_t *bsr, uint64_t *out) ur_cue_res_e res; uint8_t len; - if ( ur_cue_good != (res = ur_bsr_rub_log(bsr, &len)) ) { + if ( ur_cue_good != (res = ur_bsr_log(bsr, &len)) ) { return res; } else if ( 64 <= len ) { @@ -688,6 +688,19 @@ ur_bsr_rub_len(ur_bsr_t *bsr, uint64_t *out) return ur_cue_good; } +/* +** bitstream-writer operations follow a pattern of an unsafe (inline) +** implementation, unsafe wrt to buffer size and reallocation, +** wrapped in a public function with buffer size checks. +** +** higher-level operations made up of multiple discrete writes check +** the buffer size once for all involved writes. +** +** this pattern should be easily adaptable to an alternate bitstream-writer +** implementation that flushes accumulated output periodically instead +** of reallocating the output buffer. +*/ + void ur_bsw_grow(ur_bsw_t *bsw, uint64_t step) { From f45dfaed367348ea907fbda6db0157430ddae2d6 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 2 Sep 2020 17:24:22 -0700 Subject: [PATCH 260/933] ur: refactors and adds comments to hashcons.h --- pkg/urbit/bench/ur_bench.c | 12 +- pkg/urbit/include/ur/hashcons.h | 119 +++++++++++++++---- pkg/urbit/noun/urth.c | 8 +- pkg/urbit/tests/ur_tests.c | 4 +- pkg/urbit/ur/hashcons.c | 199 ++++++++++++++++---------------- 5 files changed, 208 insertions(+), 134 deletions(-) diff --git a/pkg/urbit/bench/ur_bench.c b/pkg/urbit/bench/ur_bench.c index af99346ffc..8a29de65a2 100644 --- a/pkg/urbit/bench/ur_bench.c +++ b/pkg/urbit/bench/ur_bench.c @@ -86,7 +86,7 @@ _jam_bench(void) } while ( 1 ) { - ur_root_t* rot_u = ur_hcon_init(); + ur_root_t* rot_u = ur_root_init(); c3_d len_d; c3_y* byt_y; ur_nref ref; @@ -138,7 +138,7 @@ _jam_bench(void) fprintf(stderr, " jam cons unsafe: %u ms\r\n", mil_w); } - ur_hcon_free(rot_u); + ur_root_free(rot_u); break; } @@ -291,7 +291,7 @@ _cue_bench(void) gettimeofday(&b4, 0); { - ur_root_t* rot_u = ur_hcon_init(); + ur_root_t* rot_u = ur_root_init(); ur_nref ref; c3_w len_w = u3r_met(3, vat); // XX assumes little-endian @@ -304,7 +304,7 @@ _cue_bench(void) ur_cue(rot_u, len_w, byt_y, &ref); } - ur_hcon_free(rot_u); + ur_root_free(rot_u); } gettimeofday(&f2, 0); @@ -327,9 +327,9 @@ _cue_bench(void) : (c3_y*)((u3a_atom*)u3a_to_ptr(vat))->buf_w; for ( i_w = 0; i_w < max_w; i_w++ ) { - rot_u = ur_hcon_init(); + rot_u = ur_root_init(); ur_cue(rot_u, len_w, byt_y, &ref); - ur_hcon_free(rot_u); + ur_root_free(rot_u); } } diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index 797ab74cfc..3851d47ac9 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -8,23 +8,37 @@ #include "ur/defs.h" -#define ur_nref_tag(ref) ( ref >> 62 ) -#define ur_nref_idx(ref) ur_mask_62(ref) - -#define ur_pail_max 10 - -typedef uint32_t ur_mug; +/* +** noun references are representated by 64-bits, with the top 2 bits +** reserved for discriminable tags. +*/ typedef uint64_t ur_nref; + typedef enum { ur_direct = 0, ur_iatom = 1, ur_icell = 2, } ur_tag; -typedef struct ur_nvec_s { - uint64_t fill; - ur_nref* refs; -} ur_nvec_t; +#define ur_nref_tag(ref) ( ref >> 62 ) +#define ur_nref_idx(ref) ur_mask_62(ref) + +/* +** 31-bit, non-zero, murmur3-based noun hash. +*/ +typedef uint32_t ur_mug; + +/* +** associative structures (dictionaries) of noun references, +** distributed by mug across fixed-size buckets (pails), +** reallocated with fibonacci growth once a bucket is full. +** +** - ur_dict_t: set of noun references +** - ur_dict32_t: map from noun reference to uint32 +** - ur_dict32_t: map from noun reference to uint64 +*/ + +#define ur_pail_max 10 typedef struct ur_pail32_s { uint8_t fill; @@ -61,6 +75,10 @@ typedef struct ur_dict_s { ur_pail_t *buckets; } ur_dict_t; +/* +** cells are hash-consed, atoms are deduplicated (byte-array comparison), +** mug hashes are stored, and noun references are unique within a root. +*/ typedef struct ur_cells_s { ur_dict_t dict; uint64_t prev; @@ -86,9 +104,22 @@ typedef struct ur_root_s { ur_atoms_t atoms; } ur_root_t; -uint64_t -ur_met(ur_root_t *r, uint8_t bloq, ur_nref ref); +/* +** a vector of noun references. +*/ +typedef struct ur_nvec_s { + uint64_t fill; + ur_nref* refs; +} ur_nvec_t; +/* +** type-specific dictionary operations. +** +** NB: [r] is only used to retrieve the stored mug of cells and +** indirect atoms. If all references are direct atoms (62-bits or less), +** [r] can be null. This option is used extensively in cue (de-serialization) +** implementations, where the dictionary keys are bit-cursors. +*/ void ur_dict32_grow(ur_root_t *r, ur_dict32_t *dict, uint64_t prev, uint64_t size); @@ -122,12 +153,27 @@ ur_dict_get(ur_root_t *r, ur_dict_t *dict, ur_nref ref); void ur_dict_put(ur_root_t *r, ur_dict_t *dict, ur_nref ref); -void -ur_dict_free(ur_dict_t *dict); - void ur_dict_wipe(ur_dict_t *dict); +/* +** free the buckets of any dictionary (cast to ur_dict_t*). +*/ +void +ur_dict_free(ur_dict_t *dict); + +/* +** measure the bloq (binary-exponent) length of an atom in [r] +*/ +uint64_t +ur_met(ur_root_t *r, uint8_t bloq, ur_nref ref); + +/* +** find or allocate an atom in [r] +** +** unsafe variant is unsafe wrt allocation (byte arrays must be +** allocated with system malloc) and trailing null bytes (not allowed). +*/ ur_nref ur_coin_bytes_unsafe(ur_root_t *r, uint8_t *byt, uint64_t len); @@ -137,24 +183,49 @@ ur_coin_bytes(ur_root_t *r, uint8_t *byt, uint64_t len); ur_nref ur_coin64(ur_root_t *r, uint64_t n); +/* +** find or construct a cell in [r] +*/ ur_nref ur_cons(ur_root_t *r, ur_nref hed, ur_nref tal); -void -ur_hcon_info(FILE *f, ur_root_t *r); - -void -ur_hcon_free(ur_root_t *r); +/* +** calculate the mug of [ref], or produce the stored value in [r]. +*/ +ur_mug +ur_nref_mug(ur_root_t *r, ur_nref ref); +/* +** initialize a noun arena (root). +*/ ur_root_t* -ur_hcon_init(void); +ur_root_init(void); + +/* +** print root details to [f] +*/ +void +ur_root_info(FILE *f, ur_root_t *r); + +/* +** dispose all allocations in [r] +*/ +void +ur_root_free(ur_root_t *r); + +/* +** initialize or dispose a vector of noun references +*/ +void +ur_nvec_init(ur_nvec_t *v, uint64_t size); void ur_nvec_free(ur_nvec_t *v); -void -ur_nvec_init(ur_nvec_t *v, uint64_t size); - +/* +** abitrary depth-first, pre-order noun traversal, where +** cells can optionally short-circuit. +*/ void ur_walk_fore(ur_root_t *r, ur_nref ref, diff --git a/pkg/urbit/noun/urth.c b/pkg/urbit/noun/urth.c index a791a3f65c..bf42d75823 100644 --- a/pkg/urbit/noun/urth.c +++ b/pkg/urbit/noun/urth.c @@ -385,14 +385,14 @@ _cu_realloc(FILE* fil_u, ur_root_t** tor_u, ur_nvec_t* doc_u) // reallocate kernel and cold jet state // - ur_root_t* rot_u = ur_hcon_init(); + ur_root_t* rot_u = ur_root_init(); ur_nvec_t cod_u; ur_nref ken = _cu_all_from_loom(rot_u, &cod_u); // print [rot_u] measurements // if ( fil_u ) { - ur_hcon_info(fil_u, rot_u); + ur_root_info(fil_u, rot_u); fprintf(stderr, "\r\n"); } @@ -441,7 +441,7 @@ u3u_uniq(void) // dispose off-loom structures // ur_nvec_free(&cod_u); - ur_hcon_free(rot_u); + ur_root_free(rot_u); } /* _cu_rock_path(): format rock path. @@ -643,7 +643,7 @@ u3u_cram(c3_c* dir_c, c3_d eve_d) // dispose off-loom structures // ur_nvec_free(&cod_u); - ur_hcon_free(rot_u); + ur_root_free(rot_u); } // write jam-buffer into pier diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index f65a1fd4a2..aa4a83c69d 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -1552,7 +1552,7 @@ _test_cue_spec(const char *cap, static int _test_jam_cue(void) { - ur_root_t *r = ur_hcon_init(); + ur_root_t *r = ur_root_init(); int ret = 1; # define NC(a, b) ur_cons(r, a, b) @@ -1638,6 +1638,8 @@ _test_jam_cue(void) TEST_CASE("wide", ur_coin_bytes(r, inp, sizeof(inp))); } + ur_root_free(r); + return ret; } diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 514fed6675..b4b4c65209 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -17,95 +17,6 @@ uint64_t ur_met0_bytes_unsafe(uint8_t *byt, uint64_t len); -ur_mug -ur_mug_bytes(const uint8_t *byt, uint64_t len) -{ - uint32_t seed = 0xcafebabe; - ur_mug mug; - - while ( 1 ) { - uint32_t raw; - MurmurHash3_x86_32(byt, len, seed, &raw); - mug = (raw >> 31) ^ ( ur_mask_31(raw) ); - - if ( 0 == mug ) { - seed++; - } - else { - return mug; - } - } -} - -ur_mug -ur_mug32(uint32_t x) -{ - uint8_t byt[4] = { - ur_mask_8(x >> 0), - ur_mask_8(x >> 8), - ur_mask_8(x >> 16), - ur_mask_8(x >> 24) - }; - - return ur_mug_bytes(byt, ur_met3_32(x)); -} - -ur_mug -ur_mug64(uint64_t x) -{ - uint8_t byt[8] = { - ur_mask_8(x >> 0), - ur_mask_8(x >> 8), - ur_mask_8(x >> 16), - ur_mask_8(x >> 24), - ur_mask_8(x >> 32), - ur_mask_8(x >> 40), - ur_mask_8(x >> 48), - ur_mask_8(x >> 56) - }; - - return ur_mug_bytes(byt, ur_met3_64(x)); -} - -ur_mug -ur_mug_both(ur_mug hed, ur_mug tal) -{ - // XX not correct per u3r_mug, but necessary to avoid collisions - // - return ur_mug32(hed ^ (0x7fffffff ^ ur_mug32(tal))); -} - -ur_mug -ur_nref_mug(ur_root_t *r, ur_nref ref) -{ - switch ( ur_nref_tag(ref) ) { - default: assert(0); - - case ur_direct: return ur_mug64(ref); - case ur_iatom: return r->atoms.mugs[ur_nref_idx(ref)]; - case ur_icell: return r->cells.mugs[ur_nref_idx(ref)]; - } -} - -ur_bool_t -ur_deep(ur_nref ref) -{ - return ur_icell == ur_nref_tag(ref); -} - -ur_nref -ur_head(ur_root_t *r, ur_nref ref) -{ - assert( ur_deep(ref) ); - return r->cells.heads[ur_nref_idx(ref)]; -} - -ur_nref -ur_tail(ur_root_t *r, ur_nref ref) -{ - assert( ur_deep(ref) ); - return r->cells.tails[ur_nref_idx(ref)]; -} void ur_dict32_grow(ur_root_t *r, ur_dict32_t *dict, uint64_t prev, uint64_t size) { @@ -393,13 +304,6 @@ ur_dict_put(ur_root_t *r, ur_dict_t *dict, ur_nref ref) } } -void -ur_dict_free(ur_dict_t *dict) -{ - free(dict->buckets); - dict->buckets = 0; -} - void ur_dict_wipe(ur_dict_t *dict) { @@ -411,6 +315,103 @@ ur_dict_wipe(ur_dict_t *dict) } } +void +ur_dict_free(ur_dict_t *dict) +{ + free(dict->buckets); + dict->buckets = 0; +} + +ur_mug +ur_mug_bytes(const uint8_t *byt, uint64_t len) +{ + uint32_t seed = 0xcafebabe; + ur_mug mug; + + while ( 1 ) { + uint32_t raw; + MurmurHash3_x86_32(byt, len, seed, &raw); + mug = (raw >> 31) ^ ( ur_mask_31(raw) ); + + if ( 0 == mug ) { + seed++; + } + else { + return mug; + } + } +} + +ur_mug +ur_mug32(uint32_t x) +{ + uint8_t byt[4] = { + ur_mask_8(x >> 0), + ur_mask_8(x >> 8), + ur_mask_8(x >> 16), + ur_mask_8(x >> 24) + }; + + return ur_mug_bytes(byt, ur_met3_32(x)); +} + +ur_mug +ur_mug64(uint64_t x) +{ + uint8_t byt[8] = { + ur_mask_8(x >> 0), + ur_mask_8(x >> 8), + ur_mask_8(x >> 16), + ur_mask_8(x >> 24), + ur_mask_8(x >> 32), + ur_mask_8(x >> 40), + ur_mask_8(x >> 48), + ur_mask_8(x >> 56) + }; + + return ur_mug_bytes(byt, ur_met3_64(x)); +} + +ur_mug +ur_mug_both(ur_mug hed, ur_mug tal) +{ + // XX not correct per u3r_mug, but necessary to avoid collisions + // + return ur_mug32(hed ^ (0x7fffffff ^ ur_mug32(tal))); +} + +ur_mug +ur_nref_mug(ur_root_t *r, ur_nref ref) +{ + switch ( ur_nref_tag(ref) ) { + default: assert(0); + + case ur_direct: return ur_mug64(ref); + case ur_iatom: return r->atoms.mugs[ur_nref_idx(ref)]; + case ur_icell: return r->cells.mugs[ur_nref_idx(ref)]; + } +} + +ur_bool_t +ur_deep(ur_nref ref) +{ + return ur_icell == ur_nref_tag(ref); +} + +ur_nref +ur_head(ur_root_t *r, ur_nref ref) +{ + assert( ur_deep(ref) ); + return r->cells.heads[ur_nref_idx(ref)]; +} + +ur_nref +ur_tail(ur_root_t *r, ur_nref ref) +{ + assert( ur_deep(ref) ); + return r->cells.tails[ur_nref_idx(ref)]; +} + void ur_atoms_grow(ur_atoms_t *atoms) { @@ -819,7 +820,7 @@ _cells_info(FILE *f, ur_cells_t *cells) } void -ur_hcon_info(FILE *f, ur_root_t *r) +ur_root_info(FILE *f, ur_root_t *r) { uint64_t total = 0; @@ -859,7 +860,7 @@ _cells_free(ur_cells_t *cells) } void -ur_hcon_free(ur_root_t *r) +ur_root_free(ur_root_t *r) { _atoms_free(&(r->atoms)); _cells_free(&(r->cells)); @@ -867,7 +868,7 @@ ur_hcon_free(ur_root_t *r) } ur_root_t* -ur_hcon_init(void) +ur_root_init(void) { ur_root_t *r = calloc(1, sizeof(*r)); assert( r ); From 8eb8a142a6a3e689f7d0051a5f283dc36ed366b9 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 2 Sep 2020 18:45:34 -0700 Subject: [PATCH 261/933] ur: adds explanatory comments to ur_tests.c --- pkg/urbit/tests/ur_tests.c | 161 +++++++++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index aa4a83c69d..1aeece955b 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -7,6 +7,9 @@ #include "ur/ur.h" +/* +** initialize helper for bitstream-writer tests. +*/ static void _bsw_init(ur_bsw_t *bsw, uint64_t prev, uint64_t size) { @@ -20,6 +23,9 @@ _bsw_init(ur_bsw_t *bsw, uint64_t prev, uint64_t size) bsw->bytes = calloc(size, 1); } +/* +** check bitstream-writer test invariants. +*/ static int _bsw_bit_check(const char* cap, ur_bsw_t *bsw, uint8_t byt, uint8_t off) { @@ -44,6 +50,9 @@ _bsw_bit_check(const char* cap, ur_bsw_t *bsw, uint8_t byt, uint8_t off) return ret; } +/* +** test 8 sequential writes of a set bit. +*/ static int _test_bsw_bit_ones(void) { @@ -87,6 +96,9 @@ _test_bsw_bit_ones(void) return ret; } +/* +** test 8 sequential writes of 1 null bit. +*/ static int _test_bsw_bit_zeros(void) { @@ -130,6 +142,9 @@ _test_bsw_bit_zeros(void) return ret; } +/* +** test 8 sequential writes of alternating bits. +*/ static int _test_bsw_bit_alt(void) { @@ -181,6 +196,16 @@ _test_bsw_bit(void) & _test_bsw_bit_alt(); } +/* +** subsequents bitstream-writer tests assume the correctnesss of +** ur_bsw_bit(), and compare the output of a bit-at-a-time +** "golden master" with that of the relevant, higher-level operation. +** +** XX the "golden" master implementations shouldn't be in bitstream module, +** as we don't intend to run them, but it's kind of weird implement them +** in the test itself. +** +*/ static int _bsw_cmp_check(const char* cap, uint8_t val, uint8_t off, uint8_t len, ur_bsw_t *a, ur_bsw_t *b) { @@ -218,6 +243,9 @@ _bsw_cmp_check(const char* cap, uint8_t val, uint8_t off, uint8_t len, ur_bsw_t return ret; } +/* +** ur_bsw8 golden master +*/ static void _bsw8_slow(ur_bsw_t *bsw, uint8_t len, uint8_t byt) { @@ -230,6 +258,10 @@ _bsw8_slow(ur_bsw_t *bsw, uint8_t len, uint8_t byt) } } +/* +** at varying offsets, write varying numbers of bits via +** ur_bsw8 and master, comparing the result each time. +*/ static int _test_bsw8_loop(const char* cap, uint8_t val) { @@ -263,6 +295,9 @@ _test_bsw8(void) & _test_bsw8_loop("bsw bits alt 2", 0x55); } +/* +** ur_bsw32 golden master +*/ static void _bsw32_slow(ur_bsw_t *bsw, uint8_t len, uint32_t val) { @@ -275,6 +310,10 @@ _bsw32_slow(ur_bsw_t *bsw, uint8_t len, uint32_t val) } } +/* +** at varying offsets, write varying numbers of bits via +** ur_bsw32 and master, comparing the result each time. +*/ static int _test_bsw32_loop(const char* cap, uint32_t val) { @@ -308,6 +347,9 @@ _test_bsw32(void) & _test_bsw32_loop("bsw 32 alt 2", 0x55555555); } +/* +** ur_bsw64 golden master +*/ static void _bsw64_slow(ur_bsw_t *bsw, uint8_t len, uint64_t val) { @@ -320,6 +362,10 @@ _bsw64_slow(ur_bsw_t *bsw, uint8_t len, uint64_t val) } } +/* +** at varying offsets, write varying numbers of bits via +** ur_bsw64 and master, comparing the result each time. +*/ static int _test_bsw64_loop(const char* cap, uint64_t val) { @@ -353,6 +399,9 @@ _test_bsw64(void) & _test_bsw64_loop("bsw 64 alt 2", 0x5555555555555555ULL); } +/* +** ur_bsw_bytes() golden master +*/ static void _bsw_bytes_slow(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) { @@ -366,6 +415,10 @@ _bsw_bytes_slow(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) _bsw8_slow(bsw, len, byt[len_byt]); } +/* +** at varying offsets, write varying numbers of bits via +** ur_bsw_bytes and master, comparing the result each time. +*/ static int _test_bsw_bytes_loop(const char* cap, uint64_t len, uint8_t val) { @@ -410,6 +463,9 @@ _test_bsw_bytes(void) & _test_bsw_bytes_loop("bsw bytes alt 2 even", 10, 0x55); } +/* +** ur_bsw_bex golden master +*/ static void _bsw_bex_slow(ur_bsw_t *bsw, uint8_t n) { @@ -421,6 +477,10 @@ _bsw_bex_slow(ur_bsw_t *bsw, uint8_t n) _bsw64_slow(bsw, n + 1, 1ULL << n); } +/* +** at varying offsets, write varying numbers of bits via +** ur_bsw_bex and master, comparing the result each time. +*/ static int _test_bsw_bex() { @@ -457,6 +517,9 @@ _test_bsw(void) & _test_bsw_bex(); } +/* +** check bitstream-reader test invariants. +*/ static int _bsr_bit_check(const char *cap, ur_bsr_t *bsr, @@ -502,6 +565,10 @@ _bsr_bit_check(const char *cap, return ret; } +/* +** read a bit 8 times from a bitstream initialized to all ones, +** checking invariants and result after each read. +*/ static int _test_bsr_bit_ones(void) { @@ -541,6 +608,10 @@ _test_bsr_bit_ones(void) return ret; } +/* +** read a bit 8 times from a bitstream initialized to all zeros, +** checking invariants and result after each read. +*/ static int _test_bsr_bit_zeros(void) { @@ -580,6 +651,10 @@ _test_bsr_bit_zeros(void) return ret; } +/* +** read a bit 8 times from a bitstream initialized to alternating zeros and ones, +** checking invariants and result after each read. +*/ static int _test_bsr_bit_alt(void) { @@ -627,6 +702,10 @@ _test_bsr_bit(void) & _test_bsr_bit_alt(); } +/* +** check bitstream-reader test invariants, after (maybe) reading +** of the end of the stream. +*/ static int _bsr_bit_any_check(const char* cap, ur_bsr_t *bsr, uint8_t off, uint64_t bits, uint8_t exp, uint8_t val) { @@ -657,6 +736,10 @@ _bsr_bit_any_check(const char* cap, ur_bsr_t *bsr, uint8_t off, uint64_t bits, u return ret; } +/* +** read a bit 17 times from a bitstream initialized to 8 ones, +** checking invariants and result after each read. +*/ static int _test_bsr_bit_any_ones(void) { @@ -721,6 +804,10 @@ _test_bsr_bit_any_ones(void) return ret; } +/* +** read a bit 17 times from a bitstream initialized to 8 zeros, +** checking invariants and result after each read. +*/ static int _test_bsr_bit_any_zeros(void) { @@ -785,6 +872,10 @@ _test_bsr_bit_any_zeros(void) return ret; } +/* +** read a bit 17 times from a bitstream initialized to 8 bits of alternating, +** ones and zeros, checking invariants and result after each read. +*/ static int _test_bsr_bit_any_alt(void) { @@ -857,6 +948,16 @@ _test_bsr_bit_any(void) & _test_bsr_bit_any_alt(); } +/* +** subsequents bitstream-reader tests assume the correctnesss of +** ur_bsr_bit_any(), and compare the output of a bit-at-a-time +** "golden master" with that of the relevant, higher-level operation. +** +** XX the "golden" master implementations shouldn't be in bitstream module, +** as we don't intend to run them, but it's kind of weird implement them +** in the test itself. +** +*/ static int _bsr_cmp_any_check(const char* cap, uint8_t off, uint8_t len, ur_bsr_t *a, ur_bsr_t *b) { @@ -901,6 +1002,9 @@ _bsr_cmp_any_check(const char* cap, uint8_t off, uint8_t len, ur_bsr_t *a, ur_bs return ret; } +/* +** ur_bsr8_any golden master +*/ static uint8_t _bsr8_any_slow(ur_bsr_t *bsr, uint8_t len) { @@ -915,6 +1019,11 @@ _bsr8_any_slow(ur_bsr_t *bsr, uint8_t len) return out; } +/* +** from a bitstream-reader initialized with varying values/lengths/offsets, +** read a varying numbers of bits via ur_bsr8_any and master, comparing +** the results and respective states each time. +*/ static int _test_bsr8_loop(const char *cap, uint8_t len, uint8_t val) { @@ -963,6 +1072,9 @@ _test_bsr8(void) & _test_bsr8_loop("bsr8 alt-2 2", 2, 0x55); } +/* +** ur_bsr32_any golden master +*/ static uint32_t _bsr32_any_slow(ur_bsr_t *bsr, uint8_t len) { @@ -978,6 +1090,11 @@ _bsr32_any_slow(ur_bsr_t *bsr, uint8_t len) return out; } +/* +** from a bitstream-reader initialized with varying values/lengths/offsets, +** read a varying numbers of bits via ur_bsr32_any and master, comparing +** the results and respective states each time. +*/ static int _test_bsr32_loop(const char *cap, uint8_t len, uint8_t val) { @@ -1035,6 +1152,9 @@ _test_bsr32(void) & _test_bsr32_loop("bsr32 alt-2 4", 4, 0x55); } +/* +** ur_bsr64_any golden master +*/ static uint64_t _bsr64_any_slow(ur_bsr_t *bsr, uint8_t len) { @@ -1050,6 +1170,11 @@ _bsr64_any_slow(ur_bsr_t *bsr, uint8_t len) return out; } +/* +** from a bitstream-reader initialized with varying values/lengths/offsets, +** read a varying numbers of bits via ur_bsr64_any and master, comparing +** the results and respective states each time. +*/ static int _test_bsr64_loop(const char *cap, uint8_t len, uint8_t val) { @@ -1123,6 +1248,9 @@ _test_bsr64(void) & _test_bsr64_loop("bsr64 alt-2 8", 8, 0x55); } +/* +** ur_bsr_bytes_any golden master +*/ static void _bsr_bytes_any_slow(ur_bsr_t *bsr, uint64_t len, uint8_t *out) { @@ -1137,6 +1265,11 @@ _bsr_bytes_any_slow(ur_bsr_t *bsr, uint64_t len, uint8_t *out) } } +/* +** from a bitstream-reader initialized with varying values/lengths/offsets, +** read a varying numbers of bits via ur_bsr_bytes_any and master, comparing +** the results and respective states each time. +*/ static int _test_bsr_bytes_any_loop(const char *cap, uint8_t len, uint8_t val) { @@ -1204,6 +1337,11 @@ _test_bsr_bytes_any(void) & _test_bsr_bytes_any_loop("bsr bytes alt 2 even", 10, 0x55); } +/* +** from a bitstream-reader initialized with varying values/lengths/offsets, +** skip a varying numbers of bits via ur_bsr_skip_any and read the same via +** ur_bsr_bytes_any master, comparing the respective states each time. +*/ static int _test_bsr_skip_any_loop(const char *cap, uint8_t len, uint8_t val) { @@ -1252,6 +1390,10 @@ _test_bsr_skip_any(void) & _test_bsr_skip_any_loop("bsr skip alt 2 even", 10, 0x55); } +/* +** compare the result and state of two reads (that were not permitted +** to read past the end of the stream). +*/ static int _bsr_cmp_check(const char* cap, uint8_t off, @@ -1320,6 +1462,9 @@ _bsr_cmp_check(const char* cap, return ret; } +/* +** ur_bsr_log golden master +*/ static ur_cue_res_e _bsr_log_slow(ur_bsr_t *bsr, uint8_t *out) { @@ -1340,6 +1485,11 @@ _bsr_log_slow(ur_bsr_t *bsr, uint8_t *out) return ur_cue_meme; } +/* +** from a bitstream-reader initialized with varying values/lengths/offsets, +** read a varying numbers of bits via ur_bsr_log and master, comparing +** the results and respective states each time. +*/ static int _test_bsr_log_loop(const char *cap, uint8_t len, uint8_t val) { @@ -1402,6 +1552,9 @@ _test_bsr_log(void) return ret; } +/* +** ur_bsr_tag golden master +*/ static ur_cue_res_e _bsr_tag_slow(ur_bsr_t *bsr, ur_cue_tag_e *out) { @@ -1423,6 +1576,11 @@ _bsr_tag_slow(ur_bsr_t *bsr, ur_cue_tag_e *out) return ur_cue_good; } +/* +** from a bitstream-reader initialized with varying values/lengths/offsets, +** read a jam type tag via ur_bsr_tag and master, comparing the results and +** respective states each time. +*/ static int _test_bsr_tag_loop(const char *cap, uint8_t len, uint8_t val) { @@ -1549,6 +1707,9 @@ _test_cue_spec(const char *cap, return ret; } +/* +** test jam/cue correctness and roundtrips across a variety of inputs +*/ static int _test_jam_cue(void) { From 9ef5e096a767cd70dc964f4dcd41b0a1e056e70d Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 1 Sep 2020 14:45:21 -0700 Subject: [PATCH 262/933] TMP: adds ivory-pill boot-timing printfs --- pkg/urbit/vere/king.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/urbit/vere/king.c b/pkg/urbit/vere/king.c index 60f8a2c76f..aa2ae96016 100644 --- a/pkg/urbit/vere/king.c +++ b/pkg/urbit/vere/king.c @@ -762,7 +762,16 @@ u3_king_commence() // boot the ivory pill // - _king_boot_ivory(); + { + struct timeval b4, f2, d0; + gettimeofday(&b4, 0); + + _king_boot_ivory(); + + gettimeofday(&f2, 0); + timersub(&f2, &b4, &d0); + fprintf(stderr, "lite: boot %lu ms\r\n", (d0.tv_sec * 1000) + (d0.tv_usec / 1000)); + } // disable core dumps (due to lmdb size) // From 0709edb84a400e3ece9298b2e3ff547c50a8d147 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 1 Sep 2020 14:46:54 -0700 Subject: [PATCH 263/933] vere: swaps out cue implementation in ivory pill boot --- pkg/urbit/vere/king.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkg/urbit/vere/king.c b/pkg/urbit/vere/king.c index aa2ae96016..dd0d39b9a1 100644 --- a/pkg/urbit/vere/king.c +++ b/pkg/urbit/vere/king.c @@ -5,8 +5,10 @@ #include #include #include + #include "all.h" #include "vere/vere.h" +#include "ur/ur.h" #include "ivory.h" @@ -711,7 +713,17 @@ _king_boot_ivory(void) } { - u3_noun pil = u3ke_cue(u3i_bytes(len_d, byt_y)); + ur_dict32_t dic_u = {0}; + u3_noun pil; + + ur_dict32_grow((ur_root_t*)0, &dic_u, ur_fib27, ur_fib28); + + if ( c3n == u3s_cue_xeno_unsafe(&dic_u, len_d, byt_y, &pil) ) { + u3l_log("lite: unable to cue ivory pill\r\n"); + exit(1); + } + + ur_dict_free((ur_dict_t*)&dic_u); if ( c3n == u3v_boot_lite(pil)) { u3l_log("lite: boot failed\r\n"); From 2bd460214357f7138a0a2883a8435d8c57655a6e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 1 Sep 2020 14:47:41 -0700 Subject: [PATCH 264/933] Revert "TMP: adds ivory-pill boot-timing printfs" This reverts commit e7df5cedc1ff24b8cf9f07484278a9fc9d647ff4. --- pkg/urbit/vere/king.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/pkg/urbit/vere/king.c b/pkg/urbit/vere/king.c index dd0d39b9a1..5528041360 100644 --- a/pkg/urbit/vere/king.c +++ b/pkg/urbit/vere/king.c @@ -774,16 +774,7 @@ u3_king_commence() // boot the ivory pill // - { - struct timeval b4, f2, d0; - gettimeofday(&b4, 0); - - _king_boot_ivory(); - - gettimeofday(&f2, 0); - timersub(&f2, &b4, &d0); - fprintf(stderr, "lite: boot %lu ms\r\n", (d0.tv_sec * 1000) + (d0.tv_usec / 1000)); - } + _king_boot_ivory(); // disable core dumps (due to lmdb size) // From b9409693dcf4aae4a5e3c001908991a85663dc9a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 2 Sep 2020 16:07:07 -0700 Subject: [PATCH 265/933] serf: refactors event tracing, adds jam/cue tracing --- pkg/urbit/include/vere/serf.h | 19 +++++----- pkg/urbit/worker/main.c | 69 ++++++++++++++++++++++++++++++++--- pkg/urbit/worker/serf.c | 26 +++---------- 3 files changed, 78 insertions(+), 36 deletions(-) diff --git a/pkg/urbit/include/vere/serf.h b/pkg/urbit/include/vere/serf.h index 004e297511..4ed63f5ea0 100644 --- a/pkg/urbit/include/vere/serf.h +++ b/pkg/urbit/include/vere/serf.h @@ -6,15 +6,16 @@ /* u3_serf: worker-process state */ typedef struct _u3_serf { - c3_d key_d[4]; // disk key - c3_c* dir_c; // execution directory (pier) - c3_d sen_d; // last event requested - c3_d dun_d; // last event processed - c3_l mug_l; // hash of state - c3_o pac_o; // pack kernel - c3_o rec_o; // reclaim cache - c3_o mut_o; // mutated kerne - u3_noun sac; // space measurementl + c3_d key_d[4]; // disk key + c3_c* dir_c; // execution directory (pier) + c3_d sen_d; // last event requested + c3_d dun_d; // last event processed + c3_l mug_l; // hash of state + c3_o pac_o; // pack kernel + c3_o rec_o; // reclaim cache + c3_o mut_o; // mutated kerne + u3_noun sac; // space measurementl + void (*xit_f)(void); // exit callback } u3_serf; /** Functions. diff --git a/pkg/urbit/worker/main.c b/pkg/urbit/worker/main.c index 84baa65e47..e429636d7f 100644 --- a/pkg/urbit/worker/main.c +++ b/pkg/urbit/worker/main.c @@ -28,6 +28,9 @@ static u3_serf u3V; // one serf per process static u3_moat inn_u; // input stream static u3_mojo out_u; // output stream +#undef SERF_TRACE_JAM +#undef SERF_TRACE_CUE + /* _cw_serf_fail(): failure stub. */ static void @@ -42,13 +45,24 @@ _cw_serf_fail(void* vod_p, const c3_c* wut_c) static void _cw_serf_send(u3_noun pel) { - u3_noun mat = u3ke_jam(pel); - c3_d len_w = u3r_met(3, mat); - c3_y* byt_y = c3_malloc(len_w); + u3_noun mat; + c3_w len_w; + c3_y* byt_y; +#ifdef SERF_TRACE_JAM + u3t_event_trace("serf ipc jam", 'B'); +#endif + + mat = u3ke_jam(pel); + len_w = u3r_met(3, mat); + byt_y = c3_malloc(len_w); u3r_bytes(0, len_w, byt_y, mat); - u3_newt_send(&out_u, len_w, byt_y); +#ifdef SERF_TRACE_JAM + u3t_event_trace("serf ipc jam", 'E'); +#endif + + u3_newt_send(&out_u, len_w, byt_y); u3z(mat); } @@ -68,12 +82,41 @@ _cw_serf_send_stdr(c3_c* str_c) _cw_serf_send_slog(u3nc(0, u3i_string(str_c))); } -/* _cw_serf_writ(): + +/* _cw_serf_step_trace(): initialize or rotate trace file. +*/ +static void +_cw_serf_step_trace(void) +{ + if ( u3C.wag_w & u3o_trace ) { + if ( u3_Host.tra_u.con_w == 0 && u3_Host.tra_u.fun_w == 0 ) { + u3t_trace_open(u3V.dir_c); + } + else if ( u3_Host.tra_u.con_w >= 100000 ) { + u3t_trace_close(); + u3t_trace_open(u3V.dir_c); + } + } +} + +/* _cw_serf_writ(): process a command from the king. */ static void _cw_serf_writ(void* vod_p, c3_d len_d, c3_y* byt_y) { - u3_noun ret, jar = u3ke_cue(u3i_bytes(len_d, byt_y)); + u3_noun ret, jar; + + _cw_serf_step_trace(); + +#ifdef SERF_TRACE_CUE + u3t_event_trace("serf ipc cue", 'B'); +#endif + + jar = u3ke_cue(u3i_bytes(len_d, byt_y)); + +#ifdef SERF_TRACE_CUE + u3t_event_trace("serf ipc cue", 'E'); +#endif if ( c3n == u3_serf_writ(&u3V, jar, &ret) ) { _cw_serf_fail(0, "bad jar"); @@ -108,6 +151,14 @@ _cw_serf_stdio(c3_i* inn_i, c3_i* out_i) close(nul_i); } +/* _cw_serf_stdio(): cleanup on serf exit. +*/ +static void +_cw_serf_exit(void) +{ + u3t_trace_close(); +} + /* _cw_serf_commence(); initialize and run serf */ static void @@ -214,6 +265,12 @@ _cw_serf_commence(c3_i argc, c3_c* argv[]) u3C.slog_f = _cw_serf_send_slog; } + u3V.xit_f = _cw_serf_exit; + +#if defined(SERF_TRACE_JAM) || defined(SERF_TRACE_CUE) + u3t_trace_open(u3V.dir_c); +#endif + // start serf // { diff --git a/pkg/urbit/worker/serf.c b/pkg/urbit/worker/serf.c index 98215b979c..79023fe252 100644 --- a/pkg/urbit/worker/serf.c +++ b/pkg/urbit/worker/serf.c @@ -587,7 +587,7 @@ _serf_work(u3_serf* sef_u, c3_w mil_w, u3_noun job) u3_noun u3_serf_work(u3_serf* sef_u, c3_w mil_w, u3_noun job) { - c3_t tac_t = ( 0 != u3_Host.tra_u.fil_u ); + c3_t tac_t = ( u3C.wag_w & u3o_trace ); c3_c lab_c[2056]; u3_noun pro; @@ -838,7 +838,7 @@ u3_serf_peek(u3_serf* sef_u, c3_w mil_w, u3_noun sam) /* _serf_writ_live_exit(): exit on command. */ static void -_serf_writ_live_exit(c3_w cod_w) +_serf_writ_live_exit(u3_serf* sef_u, c3_w cod_w) { if ( u3C.wag_w & u3o_debug_cpu ) { FILE* fil_u; @@ -875,6 +875,8 @@ _serf_writ_live_exit(c3_w cod_w) // c3_free(u3D.ray_u); + sef_u->xit_f(); + exit(cod_w); } @@ -924,7 +926,7 @@ u3_serf_live(u3_serf* sef_u, u3_noun com, u3_noun* ret) u3z(com); // NB, doesn't return // - _serf_writ_live_exit(cod_y); + _serf_writ_live_exit(sef_u, cod_y); *ret = u3nc(c3__live, u3_nul); return c3y; } @@ -997,22 +999,6 @@ u3_serf_live(u3_serf* sef_u, u3_noun com, u3_noun* ret) } } -/* _serf_step_trace(): initialize or rotate trace file. -*/ -static void -_serf_step_trace(u3_serf* sef_u) -{ - if ( u3C.wag_w & u3o_trace ) { - if ( u3_Host.tra_u.con_w == 0 && u3_Host.tra_u.fun_w == 0 ) { - u3t_trace_open(sef_u->dir_c); - } - else if ( u3_Host.tra_u.con_w >= 100000 ) { - u3t_trace_close(); - u3t_trace_open(sef_u->dir_c); - } - } -} - /* u3_serf_writ(): apply writ [wit], producing plea [*pel] on c3y. */ c3_o @@ -1025,8 +1011,6 @@ u3_serf_writ(u3_serf* sef_u, u3_noun wit, u3_noun* pel) ret_o = c3n; } else { - _serf_step_trace(sef_u); - switch ( tag ) { default: { ret_o = c3n; From 313c5f6050ab3828af4de395659eee5bb895a010 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 2 Sep 2020 22:56:59 -0700 Subject: [PATCH 266/933] serf: use off-loom jam for ipc $plea --- pkg/urbit/noun/serial.c | 2 -- pkg/urbit/worker/main.c | 12 ++++-------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index 7e6ecb2cec..46ba7866bb 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -291,8 +291,6 @@ u3s_jam_xeno(u3_noun a, c3_d* len_d, c3_y** byt_y) { _jam_xeno_t jam_u = {0}; - c3_assert( &(u3H->rod_u) == u3R ); - jam_u.har_p = u3h_new(); jam_u.rit_u.prev = ur_fib11; diff --git a/pkg/urbit/worker/main.c b/pkg/urbit/worker/main.c index e429636d7f..8801a93e82 100644 --- a/pkg/urbit/worker/main.c +++ b/pkg/urbit/worker/main.c @@ -45,25 +45,21 @@ _cw_serf_fail(void* vod_p, const c3_c* wut_c) static void _cw_serf_send(u3_noun pel) { - u3_noun mat; - c3_w len_w; + c3_d len_d; c3_y* byt_y; #ifdef SERF_TRACE_JAM u3t_event_trace("serf ipc jam", 'B'); #endif - mat = u3ke_jam(pel); - len_w = u3r_met(3, mat); - byt_y = c3_malloc(len_w); - u3r_bytes(0, len_w, byt_y, mat); + u3s_jam_xeno(pel, &len_d, &byt_y); #ifdef SERF_TRACE_JAM u3t_event_trace("serf ipc jam", 'E'); #endif - u3_newt_send(&out_u, len_w, byt_y); - u3z(mat); + u3_newt_send(&out_u, len_d, byt_y); + u3z(pel); } /* _cw_serf_send_slog(): send hint output (hod is [priority tank]). From 9159a7a318afb405deb97580123bfa36c0542a89 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 2 Sep 2020 23:02:55 -0700 Subject: [PATCH 267/933] serf: use off-loom cue for ipc $writ --- pkg/urbit/worker/main.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/pkg/urbit/worker/main.c b/pkg/urbit/worker/main.c index 8801a93e82..9e8bcadf41 100644 --- a/pkg/urbit/worker/main.c +++ b/pkg/urbit/worker/main.c @@ -24,9 +24,10 @@ #include "ur/hashcons.h" -static u3_serf u3V; // one serf per process -static u3_moat inn_u; // input stream -static u3_mojo out_u; // output stream +static u3_serf u3V; // one serf per process +static u3_moat inn_u; // input stream +static u3_mojo out_u; // output stream +static ur_dict32_t dic_u; // cue dictionary #undef SERF_TRACE_JAM #undef SERF_TRACE_CUE @@ -101,6 +102,7 @@ static void _cw_serf_writ(void* vod_p, c3_d len_d, c3_y* byt_y) { u3_noun ret, jar; + c3_o ret_o; _cw_serf_step_trace(); @@ -108,13 +110,18 @@ _cw_serf_writ(void* vod_p, c3_d len_d, c3_y* byt_y) u3t_event_trace("serf ipc cue", 'B'); #endif - jar = u3ke_cue(u3i_bytes(len_d, byt_y)); + ret_o = u3s_cue_xeno_unsafe(&dic_u, len_d, byt_y, &jar); + // XX check if the dictionary grew too much and shrink? + // + ur_dict32_wipe(&dic_u); #ifdef SERF_TRACE_CUE u3t_event_trace("serf ipc cue", 'E'); #endif - if ( c3n == u3_serf_writ(&u3V, jar, &ret) ) { + if ( (c3n == ret_o) + || (c3n == u3_serf_writ(&u3V, jar, &ret)) ) + { _cw_serf_fail(0, "bad jar"); } else { @@ -152,6 +159,7 @@ _cw_serf_stdio(c3_i* inn_i, c3_i* out_i) static void _cw_serf_exit(void) { + ur_dict_free((ur_dict_t*)&dic_u); u3t_trace_close(); } @@ -225,6 +233,8 @@ _cw_serf_commence(c3_i argc, c3_c* argv[]) uv_stream_set_blocking((uv_stream_t*)&out_u.pyp_u, 1); } + ur_dict32_grow((ur_root_t*)0, &dic_u, ur_fib10, ur_fib11); + // set up writing // out_u.ptr_v = &u3V; From 91f5c50befc19cd23a367f4d266a54dac94261a1 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 2 Sep 2020 15:43:16 -0700 Subject: [PATCH 268/933] vere: adds jam/cue tracing to ipc and disk layers --- pkg/urbit/vere/disk.c | 48 +++++++++++++++++++++++++++++++++++-------- pkg/urbit/vere/lord.c | 42 ++++++++++++++++++++++++++++++++----- 2 files changed, 76 insertions(+), 14 deletions(-) diff --git a/pkg/urbit/vere/disk.c b/pkg/urbit/vere/disk.c index feea9697f1..7bfdd338b9 100644 --- a/pkg/urbit/vere/disk.c +++ b/pkg/urbit/vere/disk.c @@ -39,6 +39,8 @@ struct _cd_save { }; #undef VERBOSE_DISK +#undef DISK_TRACE_JAM +#undef DISK_TRACE_CUE static void _disk_commit(u3_disk* log_u); @@ -168,11 +170,23 @@ _disk_commit_start(struct _cd_save* req_u) static c3_w _disk_serialize_v0(u3_fact* tac_u, c3_y** dat_y) { - u3_atom mat = u3ke_jam(u3nc(tac_u->bug_l, u3k(tac_u->job))); - c3_w len_w = u3r_met(3, mat); + u3_noun val = u3nc(tac_u->bug_l, u3k(tac_u->job)); + u3_atom mat; + c3_w len_w; + +#ifdef DISK_TRACE_JAM + u3t_event_trace("king disk jam", 'B'); +#endif + + mat = u3ke_jam(val); + len_w = u3r_met(3, mat); *dat_y = c3_malloc(len_w); u3r_bytes(0, len_w, *dat_y, mat); +#ifdef DISK_TRACE_JAM + u3t_event_trace("king disk jam", 'E'); +#endif + u3z(mat); return len_w; @@ -368,19 +382,27 @@ _disk_read_one_cb(void* ptr_v, c3_d eve_d, size_t val_i, void* val_p) u3_fact* tac_u; { - // XX u3m_soft? - // - u3_noun dat = u3ke_cue(u3i_bytes(val_i, val_p)); - u3_noun mug, job; + u3_noun val, mug, job; c3_l bug_l; +#ifdef DISK_TRACE_CUE + u3t_event_trace("king disk cue", 'B'); +#endif - if ( (c3n == u3r_cell(dat, &mug, &job)) + // XX u3m_soft? + // + val = u3ke_cue(u3i_bytes(val_i, val_p)); + +#ifdef DISK_TRACE_CUE + u3t_event_trace("king disk cue", 'E'); +#endif + + if ( (c3n == u3r_cell(val, &mug, &job)) || (c3n == u3r_safe_word(mug, &bug_l)) ) // XX { // failure here triggers cleanup in _disk_read_start_cb() // - u3z(dat); + u3z(val); return c3n; } @@ -389,7 +411,7 @@ _disk_read_one_cb(void* ptr_v, c3_d eve_d, size_t val_i, void* val_p) tac_u = u3_fact_init(eve_d, 0, u3k(job)); tac_u->bug_l = bug_l; - u3z(dat); + u3z(val); } if ( !red_u->ent_u ) { @@ -643,6 +665,10 @@ u3_disk_exit(u3_disk* log_u) u3_dire_free(log_u->com_u); c3_free(log_u); + +#if defined(DISK_TRACE_JAM) || defined(DISK_TRACE_CUE) + u3t_trace_close(); +#endif } /* u3_disk_info(): print status info. @@ -782,5 +808,9 @@ u3_disk_init(c3_c* pax_c, u3_disk_cb cb_u) log_u->liv_o = c3y; +#if defined(DISK_TRACE_JAM) || defined(DISK_TRACE_CUE) + u3t_trace_open(pax_c); +#endif + return log_u; } diff --git a/pkg/urbit/vere/lord.c b/pkg/urbit/vere/lord.c index 2fc2762ba1..e435261b48 100644 --- a/pkg/urbit/vere/lord.c +++ b/pkg/urbit/vere/lord.c @@ -19,6 +19,9 @@ #include "all.h" #include "vere/vere.h" +#undef LORD_TRACE_JAM +#undef LORD_TRACE_CUE + /* |% :: +writ: from king to serf @@ -150,6 +153,10 @@ _lord_stop(u3_lord* god_u) u3_newt_mojo_stop(&god_u->inn_u, _lord_bail_noop); uv_close((uv_handle_t*)&god_u->cub_u, 0); + +#if defined(LORD_TRACE_JAM) || defined(LORD_TRACE_CUE) + u3t_trace_close(); +#endif } /* _lord_bail(): serf/lord error. @@ -655,7 +662,17 @@ static void _lord_on_plea(void* ptr_v, c3_d len_d, c3_y* byt_y) { u3_lord* god_u = ptr_v; - u3_noun tag, dat, jar = u3ke_cue(u3i_bytes(len_d, byt_y)); + u3_noun tag, dat, jar; + +#ifdef LORD_TRACE_CUE + u3t_event_trace("king ipc cue", 'B'); +#endif + + jar = u3ke_cue(u3i_bytes(len_d, byt_y)); + +#ifdef LORD_TRACE_CUE + u3t_event_trace("king ipc cue", 'E'); +#endif if ( c3n == u3r_cell(jar, &tag, &dat) ) { return _lord_plea_foul(god_u, 0, jar); @@ -776,13 +793,24 @@ _lord_writ_send(u3_lord* god_u, u3_writ* wit_u) { u3_noun jar = _lord_writ_make(god_u, wit_u); - u3_noun mat = u3ke_jam(jar); - c3_w len_w = u3r_met(3, mat); - c3_y* byt_y = c3_malloc(len_w); + u3_noun mat; + c3_w len_w; + c3_y* byt_y; +#ifdef LORD_TRACE_JAM + u3t_event_trace("king ipc jam", 'B'); +#endif + + mat = u3ke_jam(jar); + len_w = u3r_met(3, mat); + byt_y = c3_malloc(len_w); u3r_bytes(0, len_w, byt_y, mat); - u3_newt_send(&god_u->inn_u, len_w, byt_y); +#ifdef LORD_TRACE_JAM + u3t_event_trace("king ipc jam", 'E'); +#endif + + u3_newt_send(&god_u->inn_u, len_w, byt_y); u3z(mat); } } @@ -1131,6 +1159,10 @@ u3_lord_init(c3_c* pax_c, c3_w wag_w, c3_d key_d[4], u3_lord_cb cb_u) } } +#if defined(LORD_TRACE_JAM) || defined(LORD_TRACE_CUE) + u3t_trace_open(god_u->pax_c); +#endif + // start reading from proc // { From 4a7e1b2009e88ef1b10758da767d836e350f6ccd Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 28 Aug 2020 16:17:46 -0400 Subject: [PATCH 269/933] king dawn: replace web3 usage with hand rolled jsonrpc messages. This replaces the autogenerated bindings to the Azimuth contracts which use Network.Web3 with hand rolled json messages. Booting a ship involved 256 individual galaxy point lookups using web3, while Vere batched all of that into one JSONRPC message. With this patch, we also batch everything at each phase into one JSONRPC batch. --- pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs | 439 ++++++++++++++++------- pkg/hs/urbit-king/package.yaml | 3 +- 2 files changed, 308 insertions(+), 134 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs index 9091539a6d..a9de21a277 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs @@ -1,3 +1,5 @@ +{-# OPTIONS_GHC -Wno-deprecations #-} + {-| Use etherium to access PKI information. -} @@ -6,51 +8,45 @@ module Urbit.Vere.Dawn where import Urbit.Arvo.Common import Urbit.Arvo.Event hiding (Address) -import Urbit.Prelude hiding (Call, rights, to) +import Urbit.Prelude hiding (Call, rights, to, (.=)) import Data.Bits (xor) import Data.List (nub) import Data.Text (splitOn) -import Network.Ethereum.Account -import Network.Ethereum.Api.Eth -import Network.Ethereum.Api.Provider -import Network.Ethereum.Api.Types hiding (blockNumber) -import Network.Ethereum.Web3 -import Network.HTTP.Client.TLS - -import Data.Solidity.Prim.Address (fromHexString) +import Data.Aeson +import Data.HexString +import Numeric (showHex) import qualified Crypto.Hash.SHA256 as SHA256 import qualified Crypto.Hash.SHA512 as SHA512 import qualified Crypto.Sign.Ed25519 as Ed import qualified Data.Binary as B -import qualified Data.ByteArray as BA import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as C --- import qualified Network.Ethereum.Ens as Ens import qualified Network.HTTP.Client as C -import qualified Urbit.Azimuth as AZ import qualified Urbit.Ob as Ob +import qualified Network.HTTP.Client.TLS as TLS +import qualified Network.HTTP.Types as HT + -- During boot, use the infura provider -provider = HttpProvider "http://eth-mainnet.urbit.org:8545" +provider = "http://eth-mainnet.urbit.org:8545" + +-- The address of the azimuth contract as a string. +azimuthAddr = "0x223c067f8cf28ae173ee5cafea60ca44c335fecb" :: Text -- Conversion Utilities -------------------------------------------------------- --- Takes the web3's bytes representation and changes the endianness. -bytes32ToBS :: BytesN 32 -> ByteString -bytes32ToBS = reverse . BA.pack . BA.unpack - -toBloq :: Quantity -> Bloq -toBloq = fromIntegral . unQuantity - -passFromEth :: BytesN 32 -> BytesN 32 -> UIntN 32 -> Pass -passFromEth enc aut sut | sut /= 1 = +passFromBS :: ByteString -> ByteString -> ByteString -> Pass +passFromBS enc aut sut | bytesAtom sut /= 1 = Pass (Ed.PublicKey mempty) (Ed.PublicKey mempty) -passFromEth enc aut sut = +passFromBS enc aut sut = Pass (decode aut) (decode enc) where - decode = Ed.PublicKey . bytes32ToBS + decode = Ed.PublicKey + +bsToBool :: ByteString -> Bool +bsToBool bs = bytesAtom bs == 1 clanFromShip :: Ship -> Ob.Class clanFromShip = Ob.clan . Ob.patp . fromIntegral @@ -61,6 +57,11 @@ shipSein = Ship . fromIntegral . Ob.fromPatp . Ob.sein . Ob.patp . fromIntegral renderShip :: Ship -> Text renderShip = Ob.renderPatp . Ob.patp . fromIntegral + +hexStrToAtom :: Text -> Atom +hexStrToAtom = + bytesAtom . reverse . toBytes . hexString . removePrefix . encodeUtf8 + -- Data Validation ------------------------------------------------------------- -- Derive public key structure from the key derivation seed structure @@ -74,85 +75,262 @@ ringToPass Ring{..} = Pass{..} Nothing -> error "Invalid seed passed to createKeypairFromSeed" Just x -> x +-- JSONRPC Functions ----------------------------------------------------------- + +-- The big problem here is that we can't really use the generated web3 wrappers +-- around the azimuth contracts, especially for the galaxy table request. They +-- make multiple rpc invocations per galaxy request (which aren't even +-- batched!), while Vere built a single batched rpc call to fetch the entire +-- galaxy table. +-- +-- The included Network.JsonRpc.TinyClient that Network.Web3 embeds can't do +-- batches, so calling that directly is out. +-- +-- Network.JSONRPC appears to not like something about the JSON that Infura +-- returns; it's just hanging? Also no documentation. +-- +-- So, like with Vere, we roll our own. + +dawnSendHTTP endpoint requestData = liftIO do + manager <- C.newManager TLS.tlsManagerSettings + + initialRequest <- C.parseRequest endpoint + let request = initialRequest + { C.method = "POST" + , C.requestBody = C.RequestBodyLBS $ requestData + , C.requestHeaders = [("Accept", "applciation/json"), + ("Content-Type", "application/json"), + ("Charsets", "utf-8")] + } + + response <- C.httpLbs request manager + + -- Return body if 200. + let code = HT.statusCode $ C.responseStatus response + case code of + 200 -> pure $ Right $ C.responseBody response + x -> pure $ Left x + +class RequestMethod m where + getRequestMethod :: m -> Text + +data RawResponse = RawResponse + { rrId :: Int + , rrResult :: Text + } + deriving (Show) + +instance FromJSON RawResponse where + parseJSON = withObject "Response" $ \v -> do + rrId <- v .: "id" + rrResult <- v .: "result" + pure RawResponse{..} + + +-- Given a list of methods and parameters, return a list of decoded responses. +dawnPostRequests :: forall req e resp + . (ToJSON req, RequestMethod req) + => String + -> (req -> Text -> resp) + -> [req] + -> RIO e [resp] +dawnPostRequests endpoint responseBuilder requests = do + -- Encode our input requests + let requestPayload = + encode $ Array $ fromList $ map toFullRequest $ zip [0..] requests + + -- Send to the server + responses <- dawnSendHTTP endpoint requestPayload >>= \case + Left err -> error $ "error fetching " ++ provider ++ ": HTTP " ++ (show err) + Right x -> pure x + + -- Get a list of the result texts in the order of the submitted requests + rawSorted <- case decode responses of + Nothing -> error $ "couldn't decode json" + Just x -> pure $ map rrResult $ sortOn rrId x + + -- Build the final result structure by calling the passed in builder with the + -- request (some outputs need data from the request sturcture, eitherwise, + -- we'd lean on FromJSON). + let results = map (uncurry responseBuilder) (zip requests rawSorted) + pure results + + where + toFullRequest :: (Int, req) -> Value + toFullRequest (id, req) = object [ "jsonrpc" .= ("2.0" :: Text) + , "method" .= getRequestMethod req + , "params" .= req + , "id" .= id + ] + +-- Azimuth JSON Requests ------------------------------------------------------- + +-- Simple packing a block number to the text format. +blockNumToStr :: Int -> Text +blockNumToStr bn = pack $ "0x" <> (showHex bn "") + +-- Not a full implementation of the Ethereum ABI, but just the ability to call +-- a method by encoded id (like 0x63fa9a87 for `points(uint32)`), and a single +-- UIntN 32 parameter. +encodeCall :: Text -> Int -> Text +encodeCall method idx = method <> leadingZeroes <> renderedNumber + where + renderedNumber = pack $ showHex idx "" + leadingZeroes = replicate (64 - length renderedNumber) '0' + +data BlockRequest = BlockRequest + deriving (Show, Eq) + +instance RequestMethod BlockRequest where + getRequestMethod BlockRequest = "eth_blockNumber" + +instance ToJSON BlockRequest where + toJSON BlockRequest = Array $ fromList [] + +-- No need to parse, it's already in the format we'll pass as an argument to +-- eth calls which take a block number. +parseBlockRequest :: BlockRequest -> Text -> TextBlockNum +parseBlockRequest br txt = txt + +type TextBlockNum = Text + +data PointRequest = PointRequest + { grqHexBlockNum :: TextBlockNum + , grqPointId :: Int + } deriving (Show, Eq) + +instance RequestMethod PointRequest where + getRequestMethod PointRequest{..} = "eth_call" + +instance ToJSON PointRequest where + toJSON PointRequest{..} = + Array $ fromList [object [ "to" .= azimuthAddr + , "data" .= encodeCall "0x63fa9a87" grqPointId], + String grqHexBlockNum + ] + +parseAndChunkResultToBS :: Text -> [ByteString] +parseAndChunkResultToBS result = + map reverse $ + chunkBytestring 32 $ + toBytes $ + hexString $ + removePrefix $ + encodeUtf8 result + +-- The incoming result is a text bytestring. We need to take that text, and +-- spit out the parsed data. +-- +-- We're sort of lucky here. After removing the front "0x", we can just chop +-- the incoming text string into 10 different 64 character chunks and then +-- parse them as numbers. +parseEthPoint :: PointRequest -> Text -> EthPoint +parseEthPoint PointRequest{..} result = EthPoint{..} + where + [rawEncryptionKey, + rawAuthenticationKey, + rawHasSponsor, + rawActive, + rawEscapeRequested, + rawSponsor, + rawEscapeTo, + rawCryptoSuite, + rawKeyRevision, + rawContinuityNum] = parseAndChunkResultToBS result + + escapeState = if bsToBool rawEscapeRequested + then Just $ Ship $ fromIntegral $ bytesAtom rawEscapeTo + else Nothing + + -- Vere doesn't set ownership information, neither did the old Dawn.hs + -- implementation. + epOwn = (0, 0, 0, 0) + + epNet = if not $ bsToBool rawActive + then Nothing + else Just + ( fromIntegral $ bytesAtom rawKeyRevision + , passFromBS rawEncryptionKey rawAuthenticationKey rawCryptoSuite + , fromIntegral $ bytesAtom rawContinuityNum + , (bsToBool rawHasSponsor, + Ship (fromIntegral $ bytesAtom rawSponsor)) + , escapeState + ) + + -- I don't know what this is supposed to be, other than the old Dawn.hs and + -- dawn.c do the same thing. + epKid = case clanFromShip (Ship $ fromIntegral grqPointId) of + Ob.Galaxy -> Just (0, setToHoonSet mempty) + Ob.Star -> Just (0, setToHoonSet mempty) + _ -> Nothing + +-- Preprocess data from a point request into the form used in the galaxy table. +parseGalaxyTableEntry :: PointRequest -> Text -> (Ship, (Rift, Life, Pass)) +parseGalaxyTableEntry PointRequest{..} result = (ship, (rift, life, pass)) + where + [rawEncryptionKey, + rawAuthenticationKey, + _, _, _, _, _, + rawCryptoSuite, + rawKeyRevision, + rawContinuityNum] = parseAndChunkResultToBS result + + ship = Ship $ fromIntegral grqPointId + rift = fromIntegral $ bytesAtom rawContinuityNum + life = fromIntegral $ bytesAtom rawKeyRevision + pass = passFromBS rawEncryptionKey rawAuthenticationKey rawCryptoSuite + +removePrefix :: ByteString -> ByteString +removePrefix withOhEx + | prefix == "0x" = suffix + | otherwise = error "not prefixed with 0x" + where + (prefix, suffix) = splitAt 2 withOhEx + +chunkBytestring :: Int -> ByteString -> [ByteString] +chunkBytestring size bs + | null rest = [cur] + | otherwise = (cur : chunkBytestring size rest) + where + (cur, rest) = splitAt size bs + +data TurfRequest = TurfRequest + { trqHexBlockNum :: TextBlockNum + , trqTurfId :: Int + } deriving (Show, Eq) + +instance RequestMethod TurfRequest where + getRequestMethod TurfRequest{..} = "eth_call" + +instance ToJSON TurfRequest where + toJSON TurfRequest{..} = + Array $ fromList [object [ "to" .= azimuthAddr + , "data" .= encodeCall "0xeccc8ff1" trqTurfId], + String trqHexBlockNum + ] + +-- This is another hack instead of a full Ethereum ABI resposne. +parseTurfResponse :: TurfRequest -> Text -> Turf +parseTurfResponse a raw = turf + where + without0x = removePrefix $ encodeUtf8 raw + (_, blRest) = splitAt 64 without0x + (utfLenStr, utfStr) = splitAt 64 blRest + utfLen = fromIntegral $ bytesAtom $ reverse $ toBytes $ hexString utfLenStr + dnsStr = decodeUtf8 $ (BS.take utfLen) $ toBytes $ hexString utfStr + turf = Turf $ fmap Cord $ reverse $ splitOn "." dnsStr + -- Azimuth Functions ----------------------------------------------------------- --- Perform a request to azimuth at a certain block number -withAzimuth :: Quantity - -> Address - -> DefaultAccount Web3 a - -> Web3 a -withAzimuth bloq azimuth action = - withAccount () $ - withParam (to .~ azimuth) $ - withParam (block .~ BlockWithNumber bloq) - action +retrievePoint :: String -> TextBlockNum -> Ship -> RIO e EthPoint +retrievePoint endpoint block ship = + dawnPostRequests provider parseEthPoint + [(PointRequest block (fromIntegral ship))] >>= \case + [x] -> pure x + _ -> error "JSON server returned multiple return values." --- Retrieves the EthPoint information for an individual point. -retrievePoint :: Quantity -> Address -> Ship -> Web3 EthPoint -retrievePoint bloq azimuth ship = - withAzimuth bloq azimuth $ do - (encryptionKey, - authenticationKey, - hasSponsor, - active, - escapeRequested, - sponsor, - escapeTo, - cryptoSuite, - keyRevision, - continuityNum) <- AZ.points (fromIntegral ship) - - let escapeState = if escapeRequested - then Just $ Ship $ fromIntegral escapeTo - else Nothing - - -- The hoon version also sets this to all 0s and then does nothing with it. - let epOwn = (0, 0, 0, 0) - - let epNet = if not active - then Nothing - else Just - ( fromIntegral keyRevision - , passFromEth encryptionKey authenticationKey cryptoSuite - , fromIntegral continuityNum - , (hasSponsor, Ship (fromIntegral sponsor)) - , escapeState - ) - - -- TODO: wtf? - let epKid = case clanFromShip ship of - Ob.Galaxy -> Just (0, setToHoonSet mempty) - Ob.Star -> Just (0, setToHoonSet mempty) - _ -> Nothing - - pure EthPoint{..} - --- Retrieves information about all the galaxies from Ethereum. -retrieveGalaxyTable :: Quantity -> Address -> Web3 (Map Ship (Rift, Life, Pass)) -retrieveGalaxyTable bloq azimuth = - withAzimuth bloq azimuth $ mapFromList <$> mapM getRow [0..255] - where - getRow idx = do - (encryptionKey, authenticationKey, _, _, _, _, _, cryptoSuite, - keyRev, continuity) <- AZ.points idx - pure ( fromIntegral idx - , ( fromIntegral continuity - , fromIntegral keyRev - , passFromEth encryptionKey authenticationKey cryptoSuite - ) - ) - --- Reads the three Ames domains from Ethereum, removing duplicates -readAmesDomains :: Quantity -> Address -> Web3 [Turf] -readAmesDomains bloq azimuth = - withAzimuth bloq azimuth $ nub <$> mapM getTurf [0..2] - where - getTurf idx = - Turf . fmap Cord . reverse . splitOn "." <$> AZ.dnsDomains idx - - -validateShipAndGetImmediateSponsor :: Quantity -> Address -> Seed -> Web3 Ship -validateShipAndGetImmediateSponsor block azimuth (Seed ship life ring oaf) = +validateShipAndGetSponsor :: String -> TextBlockNum -> Seed -> RIO e Ship +validateShipAndGetSponsor endpoint block (Seed ship life ring oaf) = case clanFromShip ship of Ob.Comet -> validateComet Ob.Moon -> validateMoon @@ -177,7 +355,7 @@ validateShipAndGetImmediateSponsor block azimuth (Seed ship life ring oaf) = validateRest = do putStrLn ("boot: retrieving " ++ renderShip ship ++ "'s public keys") - whoP <- retrievePoint block azimuth ship + whoP <- retrievePoint endpoint block ship case epNet whoP of Nothing -> fail "ship not keyed" Just (netLife, pass, contNum, (hasSponsor, who), _) -> do @@ -194,12 +372,12 @@ validateShipAndGetImmediateSponsor block azimuth (Seed ship life ring oaf) = -- Walk through the sponsorship chain retrieving the actual sponsorship chain -- as it exists on Ethereum. -getSponsorshipChain :: Quantity -> Address -> Ship -> Web3 [(Ship,EthPoint)] -getSponsorshipChain block azimuth = loop +getSponsorshipChain :: String -> TextBlockNum -> Ship -> RIO e [(Ship,EthPoint)] +getSponsorshipChain endpoint block = loop where loop ship = do putStrLn ("boot: retrieving keys for sponsor " ++ renderShip ship) - ethPoint <- retrievePoint block azimuth ship + ethPoint <- retrievePoint endpoint block ship case (clanFromShip ship, epNet ethPoint) of (Ob.Comet, _) -> fail "Comets cannot be sponsors" @@ -217,47 +395,44 @@ getSponsorshipChain block azimuth = loop chain <- loop sponsor pure $ chain ++ [(ship, ethPoint)] - -- Produces either an error or a validated boot event structure. -dawnVent :: Seed -> RIO e (Either Text Dawn) +dawnVent :: HasLogFunc e => Seed -> RIO e (Either Text Dawn) dawnVent dSeed@(Seed ship life ring oaf) = do - ret <- runWeb3' provider $ do - block <- blockNumber - putStrLn ("boot: ethereum block #" ++ tshow block) + blockResponses + <- dawnPostRequests provider parseBlockRequest [BlockRequest] - -- TODO: Eventually look up the contract from ENS. Right now, our infura - -- node is filtering everything except for a very small set of contracts, - -- so just hard code the address. - -- - -- putStrLn "boot: retrieving azimuth contract" - -- azimuth <- withAccount () $ Ens.resolve "azimuth.eth" - let azimuthAddr = "0x223c067f8cf28ae173ee5cafea60ca44c335fecb" - let azimuth = case fromHexString azimuthAddr of - Left _ -> error "Impossible" - Right x -> x + hexStrBlock <- case blockResponses of + [num] -> pure num + x -> error "Unexpected multiple returns from block # request" - immediateSponsor <- validateShipAndGetImmediateSponsor block azimuth dSeed - dSponsor <- getSponsorshipChain block azimuth immediateSponsor + let dBloq = hexStrToAtom hexStrBlock + putStrLn ("boot: ethereum block #" ++ tshow dBloq) - putStrLn "boot: retrieving galaxy table" - dCzar <- mapToHoonMap <$> retrieveGalaxyTable block azimuth + immediateSponsor <- validateShipAndGetSponsor provider hexStrBlock dSeed + dSponsor <- getSponsorshipChain provider hexStrBlock immediateSponsor - putStrLn "boot: retrieving network domains" - dTurf <- readAmesDomains block azimuth + putStrLn "boot: retrieving galaxy table" + dCzar <- (mapToHoonMap . mapFromList) <$> + (dawnPostRequests provider parseGalaxyTableEntry $ + map (PointRequest hexStrBlock) [0..255]) - let dBloq = toBloq block - let dNode = Nothing - pure $ MkDawn{..} + putStrLn "boot: retrieving network domains" + dTurf <- nub <$> (dawnPostRequests provider parseTurfResponse $ + map (TurfRequest hexStrBlock) [0..2]) - case ret of - Left x -> pure $ Left $ tshow x - Right y -> pure $ Right y + let dNode = Nothing + -- TODO: Figure out exception handling now. We don't want all the `error` + -- statements in ehre to literally kill the program. + pure $ Right $ MkDawn{..} + + +-- Comet List ------------------------------------------------------------------ dawnCometList :: RIO e [Ship] dawnCometList = do -- Get the jamfile with the list of stars accepting comets right now. - manager <- io $ C.newManager tlsManagerSettings + manager <- io $ C.newManager TLS.tlsManagerSettings request <- io $ C.parseRequest "https://bootstrap.urbit.org/comet-stars.jam" response <- io $ C.httpLbs (C.setRequestCheckStatus request) manager let body = toStrict $ C.responseBody response diff --git a/pkg/hs/urbit-king/package.yaml b/pkg/hs/urbit-king/package.yaml index 8ad6ca2311..583cd6b6cd 100644 --- a/pkg/hs/urbit-king/package.yaml +++ b/pkg/hs/urbit-king/package.yaml @@ -51,6 +51,7 @@ dependencies: - hashable - hashtables - heap + - hexstring - http-client - http-client-tls - http-types @@ -101,7 +102,6 @@ dependencies: - unliftio-core - unordered-containers - urbit-atom - - urbit-azimuth - urbit-eventlog-lmdb - urbit-hob - urbit-noun @@ -114,7 +114,6 @@ dependencies: - wai-websockets - warp - warp-tls - - web3 - websockets default-extensions: From 0569bd9e3d4db4910d55c845a1aece4f05d9943b Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 3 Sep 2020 14:26:29 -0700 Subject: [PATCH 270/933] ur: adds failing jam test case --- pkg/urbit/tests/ur_tests.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index 1aeece955b..dee9ca5e6c 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -1799,6 +1799,12 @@ _test_jam_cue(void) TEST_CASE("wide", ur_coin_bytes(r, inp, sizeof(inp))); } + { + uint8_t inp[16] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc, 0xa8, 0xab, 0x60, 0xef, 0x2d, 0xd, 0x0, 0x0, 0x80 }; + uint8_t res[19] = { 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x18, 0x50, 0x57, 0xc1, 0xde, 0x5b, 0x1a, 0x0, 0x0, 0x0, 0x1 }; + TEST_CASE("date", ur_coin_bytes(r, inp, sizeof(inp))); + } + ur_root_free(r); return ret; From 9c593636800fbf38ceb9c16e7e89ffb80770cb8d Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 3 Sep 2020 14:19:35 -0700 Subject: [PATCH 271/933] ur: updates ur_bsw_t comparison tests to memcmp() buffers (failing) --- pkg/urbit/tests/ur_tests.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index dee9ca5e6c..8859966ee2 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -222,12 +222,6 @@ _bsw_cmp_check(const char* cap, uint8_t val, uint8_t off, uint8_t len, ur_bsw_t ret = 0; } - if ( a->bytes[0] != b->bytes[0] ) { - fprintf(stderr, "%s: val 0x%02x off %u len %u: bytes fail (0x%02x, 0x%02x)\r\n", - cap, val, off, len, a->bytes[0], b->bytes[0]); - ret = 0; - } - if ( a->off != b->off ) { fprintf(stderr, "%s: val 0x%02x off %u len %u: offset fail (%u, %u)\r\n", cap, val, off, len, a->off, b->off); @@ -240,6 +234,26 @@ _bsw_cmp_check(const char* cap, uint8_t val, uint8_t off, uint8_t len, ur_bsw_t ret = 0; } + { + uint64_t k, len_byt = a->fill + !!a->off; + + if ( memcmp(a->bytes, b->bytes, len_byt) ) { + fprintf(stderr, "%s: val 0x%02x off %u, len %u not equal off=%u fill=%" PRIu64 "\r\n", + cap, val, off, len, b->off, b->fill); + fprintf(stderr, " a: { "); + for ( k = 0; k < len_byt; k++ ) { + fprintf(stderr, "%02x, ", a->bytes[k]); + } + fprintf(stderr, "}\r\n"); + fprintf(stderr, " b: { "); + for ( k = 0; k < len_byt; k++ ) { + fprintf(stderr, "%02x, ", b->bytes[k]); + } + fprintf(stderr, "}\r\n"); + ret = 0; + } + } + return ret; } From c469ccb04350bdc76f92d76a4fdd299ea35e764e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 3 Sep 2020 14:24:29 -0700 Subject: [PATCH 272/933] ur: fixes a bug in ur_bsw_bytes() which was introduced by an earlier fix for a buffer over-read --- pkg/urbit/ur/bitstream.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/pkg/urbit/ur/bitstream.c b/pkg/urbit/ur/bitstream.c index d72548257d..14b841ba40 100644 --- a/pkg/urbit/ur/bitstream.c +++ b/pkg/urbit/ur/bitstream.c @@ -1037,21 +1037,31 @@ _bsw_bytes_unsafe(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) m = byt[i] >> rest; } - if ( len_bit ) { - if ( len_bit < rest ) { - l = byt[len_byt] & ((1 << len_bit) - 1); - bsw->bytes[fill] = m ^ (l << off); - off += len_bit; - } - else { - l = byt[len_byt] & mask; - bsw->bytes[fill++] = m ^ (l << off); + // no trailing bits; we need only write the rest of the last byte. + // + // NB: while semantically equivalent to the subsequent block, + // this case must be separate to avoid reading off the end of [byt] + // + if ( !len_bit ) { + bsw->bytes[fill] = m; + } + // trailing bits fit into the current output byte. + // + else if ( len_bit < rest ) { + l = byt[len_byt] & ((1 << len_bit) - 1); + bsw->bytes[fill] = m ^ (l << off); + off += len_bit; + } + // trailing bits extend into the next output byte. + // + else { + l = byt[len_byt] & mask; + bsw->bytes[fill++] = m ^ (l << off); - m = byt[len_byt] >> rest; + m = byt[len_byt] >> rest; - off = len_bit - rest; - bsw->bytes[fill] = m & ((1 << off) - 1); - } + off = len_bit - rest; + bsw->bytes[fill] = m & ((1 << off) - 1); } } From 33b6a8b924c8ce70f2dd934989a8ace20b8b7180 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 3 Sep 2020 14:26:50 -0700 Subject: [PATCH 273/933] u3: ports (formerly) failing jam test case from ur_tests --- pkg/urbit/tests/jam_tests.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/urbit/tests/jam_tests.c b/pkg/urbit/tests/jam_tests.c index da8fc914ae..41e5d767b2 100644 --- a/pkg/urbit/tests/jam_tests.c +++ b/pkg/urbit/tests/jam_tests.c @@ -493,6 +493,12 @@ _test_jam_roundtrip(void) TEST_CASE("wide", u3i_bytes(sizeof(inp_y), inp_y)); } + { + c3_y inp_y[16] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc, 0xa8, 0xab, 0x60, 0xef, 0x2d, 0xd, 0x0, 0x0, 0x80 }; + c3_y res_y[19] = { 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x18, 0x50, 0x57, 0xc1, 0xde, 0x5b, 0x1a, 0x0, 0x0, 0x0, 0x1 }; + TEST_CASE("date", u3i_bytes(sizeof(inp_y), inp_y)); + } + return ret_i; } From 466f342e7b95ddc72c0dae2f75c181d435965493 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 3 Sep 2020 14:48:58 -0700 Subject: [PATCH 274/933] vere: use off-loom jam for ipc $writ --- pkg/urbit/vere/lord.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/pkg/urbit/vere/lord.c b/pkg/urbit/vere/lord.c index e435261b48..9d94f66e4c 100644 --- a/pkg/urbit/vere/lord.c +++ b/pkg/urbit/vere/lord.c @@ -793,25 +793,21 @@ _lord_writ_send(u3_lord* god_u, u3_writ* wit_u) { u3_noun jar = _lord_writ_make(god_u, wit_u); - u3_noun mat; - c3_w len_w; + c3_d len_d; c3_y* byt_y; #ifdef LORD_TRACE_JAM u3t_event_trace("king ipc jam", 'B'); #endif - mat = u3ke_jam(jar); - len_w = u3r_met(3, mat); - byt_y = c3_malloc(len_w); - u3r_bytes(0, len_w, byt_y, mat); + u3s_jam_xeno(jar, &len_d, &byt_y); #ifdef LORD_TRACE_JAM u3t_event_trace("king ipc jam", 'E'); #endif - u3_newt_send(&god_u->inn_u, len_w, byt_y); - u3z(mat); + u3_newt_send(&god_u->inn_u, len_d, byt_y); + u3z(jar); } } From f42e4360552c764c7ed2106952afeb25b990344d Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 3 Sep 2020 15:00:17 -0700 Subject: [PATCH 275/933] vere: use off-loom cue for ipc $plea --- pkg/urbit/include/vere/vere.h | 1 + pkg/urbit/vere/lord.c | 23 +++++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index b47dd50d09..cf84b868a2 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -444,6 +444,7 @@ uv_process_t cub_u; // process handle uv_process_options_t ops_u; // process configuration uv_stdio_container_t cod_u[3]; // process options + void* dic_u; // cue dictionary time_t wen_t; // process creation time u3_mojo inn_u; // client's stdin u3_moat out_u; // client's stdout diff --git a/pkg/urbit/vere/lord.c b/pkg/urbit/vere/lord.c index 9d94f66e4c..52fa4ee7bf 100644 --- a/pkg/urbit/vere/lord.c +++ b/pkg/urbit/vere/lord.c @@ -18,6 +18,7 @@ #include "all.h" #include "vere/vere.h" +#include "ur/hashcons.h" #undef LORD_TRACE_JAM #undef LORD_TRACE_CUE @@ -71,6 +72,7 @@ _lord_stop_cb(void* ptr_v, void (*exit_f)(void*) = god_u->cb_u.exit_f; void* exit_v = god_u->cb_u.ptr_v; + ur_dict_free((ur_dict_t*)god_u->dic_u); c3_free(god_u); if ( exit_f ) { @@ -661,20 +663,27 @@ _lord_plea_work(u3_lord* god_u, u3_noun dat) static void _lord_on_plea(void* ptr_v, c3_d len_d, c3_y* byt_y) { - u3_lord* god_u = ptr_v; - u3_noun tag, dat, jar; + u3_lord* god_u = ptr_v; + ur_dict32_t* dic_u = god_u->dic_u; + u3_noun tag, dat, jar = u3_blip; + c3_o ret_o; #ifdef LORD_TRACE_CUE u3t_event_trace("king ipc cue", 'B'); #endif - jar = u3ke_cue(u3i_bytes(len_d, byt_y)); + ret_o = u3s_cue_xeno_unsafe(dic_u, len_d, byt_y, &jar); + // XX check if the dictionary grew too much and shrink? + // + ur_dict32_wipe(dic_u); #ifdef LORD_TRACE_CUE u3t_event_trace("king ipc cue", 'E'); #endif - if ( c3n == u3r_cell(jar, &tag, &dat) ) { + if ( (c3n == ret_o) + || (c3n == u3r_cell(jar, &tag, &dat)) ) + { return _lord_plea_foul(god_u, 0, jar); } @@ -1159,6 +1168,12 @@ u3_lord_init(c3_c* pax_c, c3_w wag_w, c3_d key_d[4], u3_lord_cb cb_u) u3t_trace_open(god_u->pax_c); #endif + { + ur_dict32_t* dic_u = c3_calloc(sizeof(*dic_u)); + ur_dict32_grow((ur_root_t*)0, dic_u, ur_fib10, ur_fib11); + god_u->dic_u = dic_u; + } + // start reading from proc // { From 51b85dc5a8a5b04f5199be66ed87e4edc7ebc876 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 3 Sep 2020 15:38:27 -0700 Subject: [PATCH 276/933] u3: removes redundant byte-array allocation in u3s_cue_xeno --- pkg/urbit/noun/serial.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index 46ba7866bb..79208801a0 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -629,17 +629,24 @@ _cs_cue_xeno_next(_cue_stack_t* tac_u, // XX need a ur_bsr_words_any() // else { - c3_d byt_d = (len_d >> 3) + !!ur_mask_3(len_d); + c3_w* wor_w; c3_y* byt_y; - // XX check that byt_d fits in a c3_w; - // - byt_y = c3_calloc(byt_d); + { + c3_d byt_d = (len_d >> 3) + !!ur_mask_3(len_d); + + if ( 0xffffffffULL < byt_d) { + return u3m_bail(c3__meme); + } + + // XX assumes little-endian + // + wor_w = u3a_slaq(3, byt_d); + byt_y = (c3_y*)wor_w; + } + ur_bsr_bytes_any(red_u, len_d, byt_y); - - *out = u3i_bytes(byt_d, byt_y); - - c3_free(byt_y); + *out = u3a_malt(wor_w); } ur_dict32_put(rot_u, dic_u, bit_d, *out); From e9d4b7b7624dfe0c80911b6fc2a2d41008767a3d Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 3 Sep 2020 15:50:58 -0700 Subject: [PATCH 277/933] ur: cleans up header comments --- pkg/urbit/include/ur/hashcons.h | 8 +++----- pkg/urbit/include/ur/serial.h | 10 +++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index 3851d47ac9..045d5055af 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -9,8 +9,7 @@ #include "ur/defs.h" /* -** noun references are representated by 64-bits, with the top 2 bits -** reserved for discriminable tags. +** 64-bit noun references, with the top 2 bits reserved for type tags. */ typedef uint64_t ur_nref; @@ -223,8 +222,7 @@ void ur_nvec_free(ur_nvec_t *v); /* -** abitrary depth-first, pre-order noun traversal, where -** cells can optionally short-circuit. +** depth-first, pre-order noun traversal, cells can short-circuit. */ void ur_walk_fore(ur_root_t *r, @@ -233,4 +231,4 @@ ur_walk_fore(ur_root_t *r, void (*atom)(ur_root_t*, ur_nref, void*), ur_bool_t (*cell)(ur_root_t*, ur_nref, void*)); -#endif \ No newline at end of file +#endif diff --git a/pkg/urbit/include/ur/serial.h b/pkg/urbit/include/ur/serial.h index 9a05115a04..dde11ee67b 100644 --- a/pkg/urbit/include/ur/serial.h +++ b/pkg/urbit/include/ur/serial.h @@ -6,9 +6,9 @@ #include /* -** bit-wise serialize a noun of arbitrary into a byte-buffer. +** bit-wise serialization of a noun into a byte-buffer. ** supports up to 64-bits of bit-addressed output (nearly 2 EiB). -** as this is an impractical volume data, cursor overflow is not checked. +** (as this is an impractical volume data, cursor overflow is not checked.) ** ** unsafe variant is unsafe wrt its [dict] parameter, which must be empty, ** but can be passed in order to skip reallocation inside hot loops. @@ -25,12 +25,12 @@ uint64_t ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt); /* -** bitwise deserialization of an arbitrary byte-buffer into a noun. +** bitwise deserialization of a byte-buffer into a noun. ** supports up to 62-bits of bit-addressed input (511 PiB). -** return will be [ur_cue_good] upon success. +** returns [ur_cue_good] on success. ** ** unsafe variant is unsafe wrt its [dict] parameter, which must be empty, -** but can be passed in order to skip reallocation inside hot loops. +** (present in order to skip reallocation inside hot loops). ** ** test variant does not allocate nouns, but merely parses the input. ** From 4d86e3595cc43247a897182446b4c7481170d5ad Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 3 Sep 2020 16:00:19 -0700 Subject: [PATCH 278/933] u3: switches +cue jet to use new implementation --- pkg/urbit/jets/e/cue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/urbit/jets/e/cue.c b/pkg/urbit/jets/e/cue.c index a26cecfac4..eab7ac0310 100644 --- a/pkg/urbit/jets/e/cue.c +++ b/pkg/urbit/jets/e/cue.c @@ -6,7 +6,7 @@ u3_noun u3qe_cue(u3_atom a) { - return u3s_cue(a); + return u3s_cue_atom(a); } u3_noun From b47047b8692ea558245648f1eb448861ffe7e7a7 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 3 Sep 2020 22:07:55 -0700 Subject: [PATCH 279/933] u3: renames global deduplication to %meld, adds to $writ --- pkg/urbit/include/noun/urth.h | 4 ++-- pkg/urbit/noun/urth.c | 4 ++-- pkg/urbit/worker/main.c | 10 +++++----- pkg/urbit/worker/serf.c | 14 ++++++++++++++ 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/pkg/urbit/include/noun/urth.h b/pkg/urbit/include/noun/urth.h index c8dd98a96b..d837a72291 100644 --- a/pkg/urbit/include/noun/urth.h +++ b/pkg/urbit/include/noun/urth.h @@ -2,10 +2,10 @@ */ /** Functions. **/ - /* u3u_uniq(): hash-cons roots off-loom, reallocate on loom. + /* u3u_meld(): globally deduplicate memory. */ void - u3u_uniq(void); + u3u_meld(void); /* u3u_cram(): globably deduplicate memory, and write a rock to disk. */ diff --git a/pkg/urbit/noun/urth.c b/pkg/urbit/noun/urth.c index bf42d75823..33c9bf2c95 100644 --- a/pkg/urbit/noun/urth.c +++ b/pkg/urbit/noun/urth.c @@ -425,10 +425,10 @@ _cu_realloc(FILE* fil_u, ur_root_t** tor_u, ur_nvec_t* doc_u) return ken; } -/* u3u_uniq(): hash-cons roots off-loom, reallocate on loom. +/* u3u_meld(): globally deduplicate memory. */ void -u3u_uniq(void) +u3u_meld(void) { ur_root_t* rot_u; ur_nvec_t cod_u; diff --git a/pkg/urbit/worker/main.c b/pkg/urbit/worker/main.c index 9e8bcadf41..a9d48e840c 100644 --- a/pkg/urbit/worker/main.c +++ b/pkg/urbit/worker/main.c @@ -382,7 +382,7 @@ _cw_queu(c3_i argc, c3_c* argv[]) /* _cw_uniq(); deduplicate persistent nouns */ static void -_cw_uniq(c3_i argc, c3_c* argv[]) +_cw_meld(c3_i argc, c3_c* argv[]) { c3_assert( 3 <= argc ); @@ -392,7 +392,7 @@ _cw_uniq(c3_i argc, c3_c* argv[]) u3_serf_grab(); - u3u_uniq(); + u3u_meld(); u3_serf_grab(); @@ -428,7 +428,7 @@ _cw_usage(c3_i argc, c3_c* argv[]) " compact persistent state:\n" " %s pack \n\n" " deduplicate persistent state:\n" - " %s uniq \n\n" + " %s meld \n\n" " jam persistent state:\n" " %s cram \n\n" " cue persistent state:\n" @@ -475,8 +475,8 @@ main(c3_i argc, c3_c* argv[]) else if ( 0 == strcmp("queu", argv[1]) ) { _cw_queu(argc, argv); } - else if ( 0 == strcmp("uniq", argv[1]) ) { - _cw_uniq(argc, argv); + else if ( 0 == strcmp("meld", argv[1]) ) { + _cw_meld(argc, argv); } else if ( 0 == strcmp("pack", argv[1]) ) { _cw_pack(argc, argv); diff --git a/pkg/urbit/worker/serf.c b/pkg/urbit/worker/serf.c index 79023fe252..cea2e8dcad 100644 --- a/pkg/urbit/worker/serf.c +++ b/pkg/urbit/worker/serf.c @@ -34,6 +34,7 @@ $% [%cram eve=@] [%exit cod=@] [%save eve=@] + [%meld ~] [%pack ~] == == [%peek mil=@ now=@da lyc=gang pat=path] @@ -983,6 +984,19 @@ u3_serf_live(u3_serf* sef_u, u3_noun com, u3_noun* ret) } } + case c3__meld: { + if ( u3_nul != dat ) { + u3z(com); + return c3n; + } + else { + u3z(com); + u3u_meld(); + *ret = u3nc(c3__live, u3_nul); + return c3y; + } + } + case c3__save: { c3_d eve_d; From 81aa0e30037219eb5b124e2de818c8c3ef65b616 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 3 Sep 2020 22:14:07 -0700 Subject: [PATCH 280/933] vere: adds missing function comments in pier.c --- pkg/urbit/vere/pier.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index 9c66b5315a..333a22e213 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -1435,6 +1435,8 @@ u3_pier_boot(c3_w wag_w, // config flags return pir_u; } +/* _pier_save_cb(): save snapshot upon serf/disk synchronization. +*/ static void _pier_save_cb(void* ptr_v, c3_d eve_d) { @@ -1468,6 +1470,8 @@ u3_pier_save(u3_pier* pir_u) return c3n; } +/* _pier_cram_cb(): save snapshot upon serf/disk synchronization. +*/ static void _pier_cram_cb(void* ptr_v, c3_d eve_d) { @@ -1502,6 +1506,8 @@ u3_pier_cram(u3_pier* pir_u) return c3n; } +/* _pier_work_close_cb(): dispose u3_work after closing handles. +*/ static void _pier_work_close_cb(uv_handle_t* idl_u) { @@ -1509,6 +1515,8 @@ _pier_work_close_cb(uv_handle_t* idl_u) c3_free(wok_u); } +/* _pier_work_close(): close drivers/handles in the u3_psat_work state. +*/ static void _pier_work_close(u3_work* wok_u) { From 844ed22a2e10fb251fb10fc95b12075513c3124e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 3 Sep 2020 22:22:38 -0700 Subject: [PATCH 281/933] vere: moves |pack initiation to king, handles future |meld --- pkg/urbit/include/vere/vere.h | 25 +++++++++++++++++++++++-- pkg/urbit/vere/io/term.c | 11 ++++++----- pkg/urbit/vere/lord.c | 31 +++++++++++++++++++++++++++++++ pkg/urbit/vere/pier.c | 24 ++++++++++++++++++++++++ pkg/urbit/worker/serf.c | 9 +++------ 5 files changed, 87 insertions(+), 13 deletions(-) diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index cf84b868a2..5ee6b79708 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -399,8 +399,9 @@ u3_writ_play = 2, u3_writ_save = 3, u3_writ_cram = 4, - u3_writ_pack = 5, - u3_writ_exit = 6 + u3_writ_meld = 5, + u3_writ_pack = 6, + u3_writ_exit = 7 } u3_writ_type; /* u3_writ: ipc message from king to serf @@ -948,6 +949,16 @@ c3_o u3_lord_cram(u3_lord* god_u); + /* u3_lord_meld(): globally deduplicate persistent state. + */ + void + u3_lord_meld(u3_lord* god_u); + + /* u3_lord_pack(): defragment persistent state. + */ + void + u3_lord_pack(u3_lord* god_u); + /* u3_lord_work(): attempt work. */ void @@ -1221,6 +1232,16 @@ c3_o u3_pier_cram(u3_pier* pir_u); + /* u3_pier_meld(): globally deduplicate persistent state. + */ + void + u3_pier_meld(u3_pier* pir_u); + + /* u3_pier_pack(): defragment persistent state. + */ + void + u3_pier_pack(u3_pier* pir_u); + /* u3_pier_info(): print status info. */ void diff --git a/pkg/urbit/vere/io/term.c b/pkg/urbit/vere/io/term.c index 3eb24050cd..2da13a87b1 100644 --- a/pkg/urbit/vere/io/term.c +++ b/pkg/urbit/vere/io/term.c @@ -1413,13 +1413,14 @@ _term_io_kick(u3_auto* car_u, u3_noun wir, u3_noun cad) // uv_timer_start(&u3K.tim_u, (uv_timer_cb)u3_king_grab, 0, 0); } break; - // ignore pack (processed in worker) - // + case c3__meld: { + ret_o = c3y; + u3_pier_meld(car_u->pir_u); + } break; + case c3__pack: { ret_o = c3y; - // XX would be - // - // u3_assure(u3_pier_pack(car_u->pir_u)); + u3_pier_pack(car_u->pir_u); } break; } } diff --git a/pkg/urbit/vere/lord.c b/pkg/urbit/vere/lord.c index 52fa4ee7bf..a216ce1389 100644 --- a/pkg/urbit/vere/lord.c +++ b/pkg/urbit/vere/lord.c @@ -32,6 +32,7 @@ $% [%cram eve=@] [%exit cod=@] [%save eve=@] + [%meld ~] [%pack ~] == == [%peek mil=@ now=@da lyc=gang pat=path] @@ -274,6 +275,12 @@ _lord_plea_live(u3_lord* god_u, u3_noun dat) god_u->cb_u.cram_f(god_u->cb_u.ptr_v); } break; + case u3_writ_meld: { + // XX wire into cb + // + u3l_log("pier: meld complete\n"); + } break; + case u3_writ_pack: { // XX wire into cb // @@ -774,6 +781,10 @@ _lord_writ_make(u3_lord* god_u, u3_writ* wit_u) msg = u3nt(c3__live, c3__cram, u3i_chubs(1, &god_u->eve_d)); } break; + case u3_writ_meld: { + msg = u3nt(c3__live, c3__meld, u3_nul); + } break; + case u3_writ_pack: { msg = u3nt(c3__live, c3__pack, u3_nul); } break; @@ -1004,6 +1015,26 @@ u3_lord_cram(u3_lord* god_u) } } +/* u3_lord_meld(): globally deduplicate persistent state. +*/ +void +u3_lord_meld(u3_lord* god_u) +{ + u3_writ* wit_u = _lord_writ_new(god_u); + wit_u->typ_e = u3_writ_meld; + _lord_writ_plan(god_u, wit_u); +} + +/* u3_lord_pack(): defragment persistent state. +*/ +void +u3_lord_pack(u3_lord* god_u) +{ + u3_writ* wit_u = _lord_writ_new(god_u); + wit_u->typ_e = u3_writ_pack; + _lord_writ_plan(god_u, wit_u); +} + /* u3_lord_exit(): shutdown gracefully. */ void diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index 333a22e213..6ea699eac8 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -1506,6 +1506,30 @@ u3_pier_cram(u3_pier* pir_u) return c3n; } +/* u3_pier_meld(): globally deduplicate persistent state. +*/ +void +u3_pier_meld(u3_pier* pir_u) +{ +#ifdef VERBOSE_PIER + fprintf(stderr, "pier: (%" PRIu64 "): meld: plan\r\n", pir_u->god_u->eve_d); +#endif + + u3_lord_meld(pir_u->god_u); +} + +/* u3_pier_pack(): defragment persistent state. +*/ +void +u3_pier_pack(u3_pier* pir_u) +{ +#ifdef VERBOSE_PIER + fprintf(stderr, "pier: (%" PRIu64 "): meld: plan\r\n", pir_u->god_u->eve_d); +#endif + + u3_lord_pack(pir_u->god_u); +} + /* _pier_work_close_cb(): dispose u3_work after closing handles. */ static void diff --git a/pkg/urbit/worker/serf.c b/pkg/urbit/worker/serf.c index cea2e8dcad..71460db93a 100644 --- a/pkg/urbit/worker/serf.c +++ b/pkg/urbit/worker/serf.c @@ -343,12 +343,6 @@ _serf_sure_feck(u3_serf* sef_u, c3_w pre_w, u3_noun vir) rec_o = c3y; } - // pack memory on |pack - // - if ( c3__pack == u3h(fec) ) { - pac_o = c3y; - } - riv = u3t(riv); i_w++; } @@ -367,6 +361,9 @@ _serf_sure_feck(u3_serf* sef_u, c3_w pre_w, u3_noun vir) // low-priority: 2^27 contiguous words remaining (~536 MB) // XX maybe use 2^23 (~16 MB) and 2^26 (~268 MB? // + // XX these thresholds should trigger notifications sent to the king + // instead of directly triggering these remedial actions. + // { u3_noun pri = u3_none; c3_w pos_w = u3a_open(u3R); From 4bd0882e7d13eab8d924a0b7889e09b160a243c0 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 4 Sep 2020 10:54:31 -0400 Subject: [PATCH 282/933] king dawn: instead of crashing, return an error --- pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs | 47 +++++++++++++----------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs index a9de21a277..de0cde16a7 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs @@ -57,11 +57,14 @@ shipSein = Ship . fromIntegral . Ob.fromPatp . Ob.sein . Ob.patp . fromIntegral renderShip :: Ship -> Text renderShip = Ob.renderPatp . Ob.patp . fromIntegral - hexStrToAtom :: Text -> Atom hexStrToAtom = bytesAtom . reverse . toBytes . hexString . removePrefix . encodeUtf8 +onLeft :: (a -> b) -> Either a c -> Either b c +onLeft fun (Left a) = Left $ fun a +onLeft fun (Right c) = Right c + -- Data Validation ------------------------------------------------------------- -- Derive public key structure from the key derivation seed structure @@ -397,34 +400,34 @@ getSponsorshipChain endpoint block = loop -- Produces either an error or a validated boot event structure. dawnVent :: HasLogFunc e => Seed -> RIO e (Either Text Dawn) -dawnVent dSeed@(Seed ship life ring oaf) = do - blockResponses - <- dawnPostRequests provider parseBlockRequest [BlockRequest] +dawnVent dSeed@(Seed ship life ring oaf) = + -- The type checker can't figure this out on its own. + (onLeft tshow :: Either SomeException Dawn -> Either Text Dawn) <$> try do + blockResponses + <- dawnPostRequests provider parseBlockRequest [BlockRequest] - hexStrBlock <- case blockResponses of - [num] -> pure num - x -> error "Unexpected multiple returns from block # request" + hexStrBlock <- case blockResponses of + [num] -> pure num + x -> error "Unexpected multiple returns from block # request" - let dBloq = hexStrToAtom hexStrBlock - putStrLn ("boot: ethereum block #" ++ tshow dBloq) + let dBloq = hexStrToAtom hexStrBlock + putStrLn ("boot: ethereum block #" ++ tshow dBloq) - immediateSponsor <- validateShipAndGetSponsor provider hexStrBlock dSeed - dSponsor <- getSponsorshipChain provider hexStrBlock immediateSponsor + immediateSponsor <- validateShipAndGetSponsor provider hexStrBlock dSeed + dSponsor <- getSponsorshipChain provider hexStrBlock immediateSponsor - putStrLn "boot: retrieving galaxy table" - dCzar <- (mapToHoonMap . mapFromList) <$> - (dawnPostRequests provider parseGalaxyTableEntry $ - map (PointRequest hexStrBlock) [0..255]) + putStrLn "boot: retrieving galaxy table" + dCzar <- (mapToHoonMap . mapFromList) <$> + (dawnPostRequests provider parseGalaxyTableEntry $ + map (PointRequest hexStrBlock) [0..255]) - putStrLn "boot: retrieving network domains" - dTurf <- nub <$> (dawnPostRequests provider parseTurfResponse $ - map (TurfRequest hexStrBlock) [0..2]) + putStrLn "boot: retrieving network domains" + dTurf <- nub <$> (dawnPostRequests provider parseTurfResponse $ + map (TurfRequest hexStrBlock) [0..2]) - let dNode = Nothing + let dNode = Nothing - -- TODO: Figure out exception handling now. We don't want all the `error` - -- statements in ehre to literally kill the program. - pure $ Right $ MkDawn{..} + pure $ MkDawn{..} -- Comet List ------------------------------------------------------------------ From 07089a1c9367ff851d2b06b76bef7f05b5c9a269 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 4 Sep 2020 11:01:47 -0400 Subject: [PATCH 283/933] king dawn: remove stray marks --- pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs index de0cde16a7..165a865a50 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs @@ -1,5 +1,3 @@ -{-# OPTIONS_GHC -Wno-deprecations #-} - {-| Use etherium to access PKI information. -} From 74b40e0e52a0429afea21c9da5d1f0580aa28126 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 4 Sep 2020 14:44:26 -0400 Subject: [PATCH 284/933] king dawn: nits --- pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs | 77 ++++++++++++------------ 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs index 165a865a50..8c38797c2a 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs @@ -2,12 +2,17 @@ Use etherium to access PKI information. -} -module Urbit.Vere.Dawn where +module Urbit.Vere.Dawn ( dawnVent + , dawnCometList + , renderShip + , mineComet + ) where import Urbit.Arvo.Common import Urbit.Arvo.Event hiding (Address) import Urbit.Prelude hiding (Call, rights, to, (.=)) +import Data.Bifunctor (bimap) import Data.Bits (xor) import Data.List (nub) import Data.Text (splitOn) @@ -21,6 +26,7 @@ import qualified Crypto.Sign.Ed25519 as Ed import qualified Data.Binary as B import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as C +import qualified Data.ByteString.Lazy as L import qualified Network.HTTP.Client as C import qualified Urbit.Ob as Ob @@ -28,20 +34,19 @@ import qualified Network.HTTP.Client.TLS as TLS import qualified Network.HTTP.Types as HT -- During boot, use the infura provider +provider :: String provider = "http://eth-mainnet.urbit.org:8545" -- The address of the azimuth contract as a string. -azimuthAddr = "0x223c067f8cf28ae173ee5cafea60ca44c335fecb" :: Text +azimuthAddr :: Text +azimuthAddr = "0x223c067f8cf28ae173ee5cafea60ca44c335fecb" -- Conversion Utilities -------------------------------------------------------- passFromBS :: ByteString -> ByteString -> ByteString -> Pass -passFromBS enc aut sut | bytesAtom sut /= 1 = - Pass (Ed.PublicKey mempty) (Ed.PublicKey mempty) -passFromBS enc aut sut = - Pass (decode aut) (decode enc) - where - decode = Ed.PublicKey +passFromBS enc aut sut + | bytesAtom sut /= 1 = Pass (Ed.PublicKey mempty) (Ed.PublicKey mempty) + | otherwise = Pass (Ed.PublicKey aut) (Ed.PublicKey enc) bsToBool :: ByteString -> Bool bsToBool bs = bytesAtom bs == 1 @@ -60,8 +65,7 @@ hexStrToAtom = bytesAtom . reverse . toBytes . hexString . removePrefix . encodeUtf8 onLeft :: (a -> b) -> Either a c -> Either b c -onLeft fun (Left a) = Left $ fun a -onLeft fun (Right c) = Right c +onLeft fun = bimap fun id -- Data Validation ------------------------------------------------------------- @@ -92,6 +96,7 @@ ringToPass Ring{..} = Pass{..} -- -- So, like with Vere, we roll our own. +dawnSendHTTP :: String -> L.ByteString -> RIO e (Either Int L.ByteString) dawnSendHTTP endpoint requestData = liftIO do manager <- C.newManager TLS.tlsManagerSettings @@ -99,7 +104,7 @@ dawnSendHTTP endpoint requestData = liftIO do let request = initialRequest { C.method = "POST" , C.requestBody = C.RequestBodyLBS $ requestData - , C.requestHeaders = [("Accept", "applciation/json"), + , C.requestHeaders = [("Accept", "application/json"), ("Content-Type", "application/json"), ("Charsets", "utf-8")] } @@ -110,7 +115,7 @@ dawnSendHTTP endpoint requestData = liftIO do let code = HT.statusCode $ C.responseStatus response case code of 200 -> pure $ Right $ C.responseBody response - x -> pure $ Left x + _ -> pure $ Left code class RequestMethod m where getRequestMethod :: m -> Text @@ -138,11 +143,11 @@ dawnPostRequests :: forall req e resp dawnPostRequests endpoint responseBuilder requests = do -- Encode our input requests let requestPayload = - encode $ Array $ fromList $ map toFullRequest $ zip [0..] requests + encode $ Array $ fromList $ fmap toFullRequest $ zip [0..] requests -- Send to the server responses <- dawnSendHTTP endpoint requestPayload >>= \case - Left err -> error $ "error fetching " ++ provider ++ ": HTTP " ++ (show err) + Left err -> error $ "error fetching " <> provider <> ": HTTP " <> (show err) Right x -> pure x -- Get a list of the result texts in the order of the submitted requests @@ -151,25 +156,21 @@ dawnPostRequests endpoint responseBuilder requests = do Just x -> pure $ map rrResult $ sortOn rrId x -- Build the final result structure by calling the passed in builder with the - -- request (some outputs need data from the request sturcture, eitherwise, + -- request (some outputs need data from the request structure, eitherwise, -- we'd lean on FromJSON). let results = map (uncurry responseBuilder) (zip requests rawSorted) pure results where toFullRequest :: (Int, req) -> Value - toFullRequest (id, req) = object [ "jsonrpc" .= ("2.0" :: Text) - , "method" .= getRequestMethod req - , "params" .= req - , "id" .= id - ] + toFullRequest (rid, req) = object [ "jsonrpc" .= ("2.0" :: Text) + , "method" .= getRequestMethod req + , "params" .= req + , "id" .= rid + ] -- Azimuth JSON Requests ------------------------------------------------------- --- Simple packing a block number to the text format. -blockNumToStr :: Int -> Text -blockNumToStr bn = pack $ "0x" <> (showHex bn "") - -- Not a full implementation of the Ethereum ABI, but just the ability to call -- a method by encoded id (like 0x63fa9a87 for `points(uint32)`), and a single -- UIntN 32 parameter. @@ -191,7 +192,7 @@ instance ToJSON BlockRequest where -- No need to parse, it's already in the format we'll pass as an argument to -- eth calls which take a block number. parseBlockRequest :: BlockRequest -> Text -> TextBlockNum -parseBlockRequest br txt = txt +parseBlockRequest _ txt = txt type TextBlockNum = Text @@ -204,6 +205,7 @@ instance RequestMethod PointRequest where getRequestMethod PointRequest{..} = "eth_call" instance ToJSON PointRequest where + -- 0x63fa9a87 is the points(uint32) call. toJSON PointRequest{..} = Array $ fromList [object [ "to" .= azimuthAddr , "data" .= encodeCall "0x63fa9a87" grqPointId], @@ -304,13 +306,14 @@ instance RequestMethod TurfRequest where getRequestMethod TurfRequest{..} = "eth_call" instance ToJSON TurfRequest where + -- 0xeccc8ff1 is the dnsDomains(uint32) call. toJSON TurfRequest{..} = Array $ fromList [object [ "to" .= azimuthAddr , "data" .= encodeCall "0xeccc8ff1" trqTurfId], String trqHexBlockNum ] --- This is another hack instead of a full Ethereum ABI resposne. +-- This is another hack instead of a full Ethereum ABI response. parseTurfResponse :: TurfRequest -> Text -> Turf parseTurfResponse a raw = turf where @@ -318,7 +321,7 @@ parseTurfResponse a raw = turf (_, blRest) = splitAt 64 without0x (utfLenStr, utfStr) = splitAt 64 blRest utfLen = fromIntegral $ bytesAtom $ reverse $ toBytes $ hexString utfLenStr - dnsStr = decodeUtf8 $ (BS.take utfLen) $ toBytes $ hexString utfStr + dnsStr = decodeUtf8 $ BS.take utfLen $ toBytes $ hexString utfStr turf = Turf $ fmap Cord $ reverse $ splitOn "." dnsStr -- Azimuth Functions ----------------------------------------------------------- @@ -326,7 +329,7 @@ parseTurfResponse a raw = turf retrievePoint :: String -> TextBlockNum -> Ship -> RIO e EthPoint retrievePoint endpoint block ship = dawnPostRequests provider parseEthPoint - [(PointRequest block (fromIntegral ship))] >>= \case + [PointRequest block (fromIntegral ship)] >>= \case [x] -> pure x _ -> error "JSON server returned multiple return values." @@ -341,7 +344,7 @@ validateShipAndGetSponsor endpoint block (Seed ship life ring oaf) = -- A comet address is the fingerprint of the keypair let shipFromPass = cometFingerprint $ ringToPass ring when (ship /= shipFromPass) $ - fail ("comet name doesn't match fingerprint " ++ show ship ++ " vs " ++ + fail ("comet name doesn't match fingerprint " <> show ship <> " vs " <> show shipFromPass) when (life /= 1) $ fail ("comet can never be re-keyed") @@ -354,15 +357,15 @@ validateShipAndGetSponsor endpoint block (Seed ship life ring oaf) = pure $ shipSein ship validateRest = do - putStrLn ("boot: retrieving " ++ renderShip ship ++ "'s public keys") + putStrLn ("boot: retrieving " <> renderShip ship <> "'s public keys") whoP <- retrievePoint endpoint block ship case epNet whoP of Nothing -> fail "ship not keyed" Just (netLife, pass, contNum, (hasSponsor, who), _) -> do when (netLife /= life) $ - fail ("keyfile life mismatch; keyfile claims life " ++ - show life ++ ", but Azimuth claims life " ++ + fail ("keyfile life mismatch; keyfile claims life " <> + show life <> ", but Azimuth claims life " <> show netLife) when ((ringToPass ring) /= pass) $ fail "keyfile does not match blockchain" @@ -377,7 +380,7 @@ getSponsorshipChain :: String -> TextBlockNum -> Ship -> RIO e [(Ship,EthPoint)] getSponsorshipChain endpoint block = loop where loop ship = do - putStrLn ("boot: retrieving keys for sponsor " ++ renderShip ship) + putStrLn ("boot: retrieving keys for sponsor " <> renderShip ship) ethPoint <- retrievePoint endpoint block ship case (clanFromShip ship, epNet ethPoint) of @@ -385,16 +388,16 @@ getSponsorshipChain endpoint block = loop (Ob.Moon, _) -> fail "Moons cannot be sponsors" (_, Nothing) -> - fail $ unpack ("Ship " ++ renderShip ship ++ " not booted") + fail $ unpack ("Ship " <> renderShip ship <> " not booted") (Ob.Galaxy, Just _) -> pure [(ship, ethPoint)] (_, Just (_, _, _, (False, _), _)) -> - fail $ unpack ("Ship " ++ renderShip ship ++ " has no sponsor") + fail $ unpack ("Ship " <> renderShip ship <> " has no sponsor") (_, Just (_, _, _, (True, sponsor), _)) -> do chain <- loop sponsor - pure $ chain ++ [(ship, ethPoint)] + pure $ chain <> [(ship, ethPoint)] -- Produces either an error or a validated boot event structure. dawnVent :: HasLogFunc e => Seed -> RIO e (Either Text Dawn) @@ -409,7 +412,7 @@ dawnVent dSeed@(Seed ship life ring oaf) = x -> error "Unexpected multiple returns from block # request" let dBloq = hexStrToAtom hexStrBlock - putStrLn ("boot: ethereum block #" ++ tshow dBloq) + putStrLn ("boot: ethereum block #" <> tshow dBloq) immediateSponsor <- validateShipAndGetSponsor provider hexStrBlock dSeed dSponsor <- getSponsorshipChain provider hexStrBlock immediateSponsor From 8e1468b2e027b09f0f2726e2b6cd1c5cca08ef09 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 4 Sep 2020 11:34:29 -0700 Subject: [PATCH 285/933] u3: rewrites +stir to use loops (constant stack space) --- pkg/urbit/jets/e/parse.c | 77 ++++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 30 deletions(-) diff --git a/pkg/urbit/jets/e/parse.c b/pkg/urbit/jets/e/parse.c index 290275c38a..a8a817aa39 100644 --- a/pkg/urbit/jets/e/parse.c +++ b/pkg/urbit/jets/e/parse.c @@ -918,42 +918,59 @@ u3_noun fel, u3_noun tub) { - u3_noun vex = u3x_good(u3n_slam_on(u3k(fel), u3k(tub))); - u3_noun p_vex, q_vex; - u3_noun ret; + // lef: list of successful [fel] parse results + // wag: initial accumulator + // + u3_noun wag, lef = u3_nul; - u3x_cell(vex, &p_vex, &q_vex); - if ( c3n == u3du(q_vex) ) { - ret = u3nq(u3k(p_vex), - u3_nul, - u3k(rud), - u3k(tub)); - } - else { - u3_noun uq_vex = u3t(q_vex); - u3_noun puq_vex, quq_vex; - u3_noun wag, p_wag, q_wag, uq_wag, puq_wag, quq_wag; + { + u3_noun vex, p_vex, q_vex; + u3j_site fel_u; + u3j_gate_prep(&fel_u, u3k(fel)); - u3x_cell(uq_vex, &puq_vex, &quq_vex); - wag = _cqe_stir_fun(rud, raq, fel, quq_vex); + vex = u3j_gate_slam(&fel_u, u3k(tub)); + u3x_cell(vex, &p_vex, &q_vex); - u3x_cell(wag, &p_wag, &q_wag); - if ( c3n == u3du(q_wag) ) { - return u3m_bail(c3__fail); + while ( u3_nul != q_vex ) { + lef = u3nc(vex, lef); + tub = u3x_at(7, q_vex); // q.u.q.vex + + vex = u3j_gate_slam(&fel_u, u3k(tub)); + u3x_cell(vex, &p_vex, &q_vex); } - uq_wag = u3t(q_wag); - u3x_cell(uq_wag, &puq_wag, &quq_wag); - ret = u3nq(_last(p_vex, p_wag), - u3_nul, - u3x_good(u3n_slam_on(u3k(raq), - u3nc(u3k(puq_vex), - u3k(puq_wag)))), - u3k(quq_wag)); - u3z(wag); + wag = u3nq(u3k(p_vex), u3_nul, u3k(rud), u3k(tub)); + u3z(vex); + u3j_gate_lose(&fel_u); } - u3z(vex); - return ret; + + // fold [lef] into [wag] by way of [raq] + // + if ( u3_nul != lef ) { + u3_noun p_vex, puq_vex, gaw, p_wag, puq_wag, quq_wag; + u3_noun i, t = lef; + u3j_site raq_u; + u3j_gate_prep(&raq_u, u3k(raq)); + + do { + u3x_cell(t, &i, &t); + u3x_qual(i, &p_vex, 0, &puq_vex, 0); + u3x_qual(wag, &p_wag, 0, &puq_wag, &quq_wag); + + gaw = u3nq(_last(p_vex, p_wag), + u3_nul, + u3j_gate_slam(&raq_u, + u3nc(u3k(puq_vex), u3k(puq_wag))), + u3k(quq_wag)); + u3z(wag); + wag = gaw; + } while ( u3_nul != t ); + + u3z(lef); + u3j_gate_lose(&raq_u); + } + + return wag; } u3_noun From 836715ff31231201d450d929e1fc51811a532a64 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 4 Sep 2020 11:57:15 -0700 Subject: [PATCH 286/933] u3: optimizes +stir jet, reducing incremental allocations in fold --- pkg/urbit/jets/e/parse.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/pkg/urbit/jets/e/parse.c b/pkg/urbit/jets/e/parse.c index a8a817aa39..a45fe78bf7 100644 --- a/pkg/urbit/jets/e/parse.c +++ b/pkg/urbit/jets/e/parse.c @@ -919,9 +919,10 @@ u3_noun tub) { // lef: list of successful [fel] parse results - // wag: initial accumulator + // wag: initial accumulator (deconstructed) // - u3_noun wag, lef = u3_nul; + u3_noun lef = u3_nul; + u3_noun p_wag, puq_wag, quq_wag; { u3_noun vex, p_vex, q_vex; @@ -939,7 +940,9 @@ u3x_cell(vex, &p_vex, &q_vex); } - wag = u3nq(u3k(p_vex), u3_nul, u3k(rud), u3k(tub)); + p_wag = u3k(p_vex); + puq_wag = u3k(rud); + quq_wag = u3k(tub); u3z(vex); u3j_gate_lose(&fel_u); } @@ -947,7 +950,7 @@ // fold [lef] into [wag] by way of [raq] // if ( u3_nul != lef ) { - u3_noun p_vex, puq_vex, gaw, p_wag, puq_wag, quq_wag; + u3_noun p_vex, puq_vex; u3_noun i, t = lef; u3j_site raq_u; u3j_gate_prep(&raq_u, u3k(raq)); @@ -955,22 +958,21 @@ do { u3x_cell(t, &i, &t); u3x_qual(i, &p_vex, 0, &puq_vex, 0); - u3x_qual(wag, &p_wag, 0, &puq_wag, &quq_wag); - gaw = u3nq(_last(p_vex, p_wag), - u3_nul, - u3j_gate_slam(&raq_u, - u3nc(u3k(puq_vex), u3k(puq_wag))), - u3k(quq_wag)); - u3z(wag); - wag = gaw; + { + u3_noun p_gaw = _last(p_vex, p_wag); + u3z(p_wag); + p_wag = p_gaw; + } + + puq_wag = u3j_gate_slam(&raq_u, u3nc(u3k(puq_vex), puq_wag)); } while ( u3_nul != t ); u3z(lef); u3j_gate_lose(&raq_u); } - return wag; + return u3nq(p_wag, u3_nul, puq_wag, quq_wag); } u3_noun From 89f833365cc67b09f75d773f95dd5b745a8ce330 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 4 Sep 2020 13:07:19 -0700 Subject: [PATCH 287/933] u3: optimizes +stir jet, pushes incremental results onto the road stack --- pkg/urbit/jets/e/parse.c | 56 +++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/pkg/urbit/jets/e/parse.c b/pkg/urbit/jets/e/parse.c index a45fe78bf7..0b32740dc8 100644 --- a/pkg/urbit/jets/e/parse.c +++ b/pkg/urbit/jets/e/parse.c @@ -918,57 +918,77 @@ u3_noun fel, u3_noun tub) { - // lef: list of successful [fel] parse results - // wag: initial accumulator (deconstructed) + // wag: initial accumulator (deconstructed) + // top: stack pointer + // len_w: number of result pairs on the stack // - u3_noun lef = u3_nul; u3_noun p_wag, puq_wag, quq_wag; + u3_noun* top; + c3_w len_w = 0; + // push incremental, successful [fel] parse results onto road stack + // { - u3_noun vex, p_vex, q_vex; + u3_noun vex, p_vex, q_vex, puq_vex, quq_vex; u3j_site fel_u; u3j_gate_prep(&fel_u, u3k(fel)); vex = u3j_gate_slam(&fel_u, u3k(tub)); u3x_cell(vex, &p_vex, &q_vex); - while ( u3_nul != q_vex ) { - lef = u3nc(vex, lef); - tub = u3x_at(7, q_vex); // q.u.q.vex + u3k(tub); + while ( u3_nul != q_vex ) { + u3x_trel(q_vex, 0, &puq_vex, &quq_vex); + + top = u3a_push(sizeof(u3_noun)); + *top = u3k(puq_vex); + + top = u3a_push(sizeof(u3_noun)); + *top = u3k(p_vex); + ++len_w; + + u3z(tub); + tub = u3k(quq_vex); + + u3z(vex); vex = u3j_gate_slam(&fel_u, u3k(tub)); u3x_cell(vex, &p_vex, &q_vex); } p_wag = u3k(p_vex); puq_wag = u3k(rud); - quq_wag = u3k(tub); + quq_wag = tub; + u3z(vex); u3j_gate_lose(&fel_u); } - // fold [lef] into [wag] by way of [raq] + // unwind the stack, folding parse results into [wag] by way of [raq] // - if ( u3_nul != lef ) { + if ( len_w ) { u3_noun p_vex, puq_vex; - u3_noun i, t = lef; u3j_site raq_u; u3j_gate_prep(&raq_u, u3k(raq)); - do { - u3x_cell(t, &i, &t); - u3x_qual(i, &p_vex, 0, &puq_vex, 0); + while ( len_w-- > 0 ) { + top = u3a_peek(sizeof(u3_noun)); + p_vex = *top; + u3a_pop(sizeof(u3_noun)); + + top = u3a_peek(sizeof(u3_noun)); + puq_vex = *top; + u3a_pop(sizeof(u3_noun)); { u3_noun p_gaw = _last(p_vex, p_wag); - u3z(p_wag); + u3z(p_vex); u3z(p_wag); p_wag = p_gaw; } - puq_wag = u3j_gate_slam(&raq_u, u3nc(u3k(puq_vex), puq_wag)); - } while ( u3_nul != t ); + puq_wag = u3j_gate_slam(&raq_u, u3nc(puq_vex, puq_wag)); + } - u3z(lef); u3j_gate_lose(&raq_u); } From a42c90db9c3170656eae8b41f38839efaa4971dd Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 4 Sep 2020 17:02:11 -0400 Subject: [PATCH 288/933] king dawn: export functions used in tests --- pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs index 8c38797c2a..7c3ffc7c64 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs @@ -6,6 +6,12 @@ module Urbit.Vere.Dawn ( dawnVent , dawnCometList , renderShip , mineComet + -- Used only in testing + , mix + , shas + , shaf + , cometFingerprintBS + , cometFingerprint ) where import Urbit.Arvo.Common From ecbcdf7d0064922c2449a93c925e2a34fe9cbe40 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Sat, 5 Sep 2020 21:49:23 -0400 Subject: [PATCH 289/933] king: change logging from tracing to info in Wai.hs I noticed that the king's text log file kept filling up, and it's mostly 'sending chunk "\n"' from eyre. This changes the log level of every partial send over an active eyre channel to info, instead of always. --- pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Wai.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Wai.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Wai.hs index 3815e1ca95..1a7057bb61 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Wai.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Wai.hs @@ -179,7 +179,7 @@ streamBlocks env init getAct = send init >> loop send "" = pure () send c = do - runRIO env (logTrace (display ("sending chunk " <> tshow c))) + runRIO env (logInfo (display ("sending chunk " <> tshow c))) yield $ Chunk $ fromByteString c yield Flush From 40dabb3bac3f4fb07a2dcab331b3b8e680f11c60 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 8 Sep 2020 13:11:29 -0700 Subject: [PATCH 290/933] u3: tweaks +stir jet for refcount clarity --- pkg/urbit/jets/e/parse.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pkg/urbit/jets/e/parse.c b/pkg/urbit/jets/e/parse.c index 0b32740dc8..1ca166d138 100644 --- a/pkg/urbit/jets/e/parse.c +++ b/pkg/urbit/jets/e/parse.c @@ -52,6 +52,14 @@ } } + static u3_noun + _last_k(u3_noun zyc, u3_noun naz) + { + u3_noun pro = _last(zyc, naz); + u3z(zyc); u3z(naz); + return pro; + } + static u3_noun _next(u3_noun tub) { @@ -972,20 +980,15 @@ u3j_gate_prep(&raq_u, u3k(raq)); while ( len_w-- > 0 ) { - top = u3a_peek(sizeof(u3_noun)); - p_vex = *top; + top = u3a_peek(sizeof(u3_noun)); + p_vex = *top; u3a_pop(sizeof(u3_noun)); top = u3a_peek(sizeof(u3_noun)); puq_vex = *top; u3a_pop(sizeof(u3_noun)); - { - u3_noun p_gaw = _last(p_vex, p_wag); - u3z(p_vex); u3z(p_wag); - p_wag = p_gaw; - } - + p_wag = _last_k(p_vex, p_wag); puq_wag = u3j_gate_slam(&raq_u, u3nc(puq_vex, puq_wag)); } From 562548440b2c57138b72e5936e38da89f0726143 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 8 Sep 2020 13:20:43 -0700 Subject: [PATCH 291/933] ur: assert not-null after all allocations --- pkg/urbit/ur/hashcons.c | 14 ++++++++++---- pkg/urbit/ur/serial.c | 7 +++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index b4b4c65209..04c2b735a4 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -25,6 +25,7 @@ ur_dict32_grow(ur_root_t *r, ur_dict32_t *dict, uint64_t prev, uint64_t size) uint64_t i, next = prev + size; buckets = calloc(next, sizeof(*buckets)); + assert( buckets ); if ( old_buckets ) { for ( i = 0; i < old_size; i++ ) { @@ -126,6 +127,7 @@ ur_dict64_grow(ur_root_t *r, ur_dict64_t *dict, uint64_t prev, uint64_t size) uint64_t i, next = prev + size; buckets = calloc(next, sizeof(*buckets)); + assert( buckets ); if ( old_buckets ) { for ( i = 0; i < old_size; i++ ) { @@ -227,6 +229,7 @@ ur_dict_grow(ur_root_t *r, ur_dict_t *dict, uint64_t prev, uint64_t size) uint64_t i, next = prev + size; buckets = calloc(next, sizeof(*buckets)); + assert( buckets ); if ( old_buckets ) { for ( i = 0; i < old_size; i++ ) { @@ -425,11 +428,11 @@ ur_atoms_grow(ur_atoms_t *atoms) atoms->bytes = malloc(next * ( sizeof(*atoms->bytes) + sizeof(*atoms->lens) + sizeof(*atoms->mugs) )); + assert( atoms->bytes ); + atoms->lens = (void*)((char*)atoms->bytes + (next * sizeof(*atoms->bytes))); atoms->mugs = (void*)((char*)atoms->lens + (next * sizeof(*atoms->lens))); - assert( atoms->bytes ); - if ( bytes ) { memcpy(atoms->bytes, bytes, size * (sizeof(*bytes))); memcpy(atoms->lens, lens, size * (sizeof(*lens))); @@ -455,11 +458,11 @@ ur_cells_grow(ur_cells_t *cells) cells->heads = malloc(next * ( sizeof(*cells->heads) + sizeof(*cells->heads) + sizeof(*cells->mugs) )); + assert( cells->heads ); + cells->tails = (void*)((char*)cells->heads + (next * sizeof(*cells->heads))); cells->mugs = (void*)((char*)cells->tails + (next * sizeof(*cells->tails))); - assert( cells->heads ); - if ( heads ) { memcpy(cells->heads, heads, size * (sizeof(*heads))); memcpy(cells->tails, tails, size * (sizeof(*tails))); @@ -914,6 +917,7 @@ ur_nvec_init(ur_nvec_t *v, uint64_t size) { v->fill = 0; v->refs = calloc(size, sizeof(ur_nref)); + assert( v->refs ); } void @@ -927,6 +931,7 @@ ur_walk_fore(ur_root_t *r, ur_nref *top, *don; don = malloc(size * sizeof(*don)); + assert( don ); top = don + ++fill; *top = ref; @@ -952,6 +957,7 @@ ur_walk_fore(ur_root_t *r, if ( size == fill ) { uint64_t next = prev + size; don = realloc(don, next * sizeof(*don)); + assert( don ); top = don + fill; prev = size; size = next; diff --git a/pkg/urbit/ur/serial.c b/pkg/urbit/ur/serial.c index 5a945072df..e30c8d9123 100644 --- a/pkg/urbit/ur/serial.c +++ b/pkg/urbit/ur/serial.c @@ -82,6 +82,7 @@ ur_jam_unsafe(ur_root_t *r, j.bsw.prev = ur_fib11; j.bsw.size = ur_fib12; j.bsw.bytes = calloc(j.bsw.size, 1); + assert( j.bsw.bytes ); ur_walk_fore(r, ref, &j, _jam_atom, _jam_cell); @@ -150,6 +151,7 @@ _cue_next(ur_root_t *r, if ( s->fill == s->size ) { uint32_t next = s->prev + s->size; s->f = realloc(s->f, next * sizeof(*s->f)); + assert( s->f ); s->prev = s->size; s->size = next; } @@ -193,6 +195,8 @@ _cue_next(ur_root_t *r, else { uint64_t len_byt = (len >> 3) + !!ur_mask_3(len); uint8_t *byt = calloc(len_byt, 1); + assert( byt ); + ur_bsr_bytes_any(bsr, len, byt); // strip trailing zeroes @@ -239,6 +243,7 @@ ur_cue_unsafe(ur_root_t *r, s.prev = ur_fib10; s.size = ur_fib11; s.f = malloc(s.size * sizeof(*s.f)); + assert( s.f ); // advance into stream // @@ -331,6 +336,7 @@ _cue_test_next(_cue_test_stack_t *s, if ( s->fill == s->size ) { uint32_t next = s->prev + s->size; s->f = realloc(s->f, next * sizeof(*s->f)); + assert( s->f ); s->prev = s->size; s->size = next; } @@ -398,6 +404,7 @@ ur_cue_test_unsafe(ur_dict_t *dict, s.prev = ur_fib10; s.size = ur_fib11; s.f = malloc(s.size * sizeof(*s.f)); + assert( s.f ); // advance into stream // From 82e91811d4bee5612c89f5f401d6afd798c8da51 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 8 Sep 2020 22:25:24 -0700 Subject: [PATCH 292/933] ur: replaces allocation-failure assertions with error printfs/abort() --- pkg/urbit/ur/bitstream.c | 9 ++++++- pkg/urbit/ur/hashcons.c | 57 ++++++++++++++++++++-------------------- pkg/urbit/ur/serial.c | 30 ++++++++++++--------- 3 files changed, 55 insertions(+), 41 deletions(-) diff --git a/pkg/urbit/ur/bitstream.c b/pkg/urbit/ur/bitstream.c index 14b841ba40..f525f31b56 100644 --- a/pkg/urbit/ur/bitstream.c +++ b/pkg/urbit/ur/bitstream.c @@ -1,4 +1,5 @@ #include +#include #include #include @@ -708,7 +709,13 @@ ur_bsw_grow(ur_bsw_t *bsw, uint64_t step) uint64_t next = size + step; bsw->bytes = realloc(bsw->bytes, next); - assert(bsw->bytes); + + if ( !bsw->bytes ) { + fprintf(stderr, + "ur: bitstream-write allocation failed, out of memory\r\n"); + abort(); + } + memset(bsw->bytes + size, 0, step); bsw->prev = size; diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 04c2b735a4..38a8abbf5f 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -17,6 +17,18 @@ uint64_t ur_met0_bytes_unsafe(uint8_t *byt, uint64_t len); +static void* +_oom(const char* cap, void* v) +{ + if ( !v ) { + fprintf(stderr, + "ur: hashcons: %s: allocation failed, out of memory\r\n", cap); + abort(); + } + + return v; +} + void ur_dict32_grow(ur_root_t *r, ur_dict32_t *dict, uint64_t prev, uint64_t size) { @@ -24,8 +36,7 @@ ur_dict32_grow(ur_root_t *r, ur_dict32_t *dict, uint64_t prev, uint64_t size) uint64_t old_size = dict->size; uint64_t i, next = prev + size; - buckets = calloc(next, sizeof(*buckets)); - assert( buckets ); + buckets = _oom("dict32_grow", calloc(next, sizeof(*buckets))); if ( old_buckets ) { for ( i = 0; i < old_size; i++ ) { @@ -126,8 +137,7 @@ ur_dict64_grow(ur_root_t *r, ur_dict64_t *dict, uint64_t prev, uint64_t size) uint64_t old_size = dict->size; uint64_t i, next = prev + size; - buckets = calloc(next, sizeof(*buckets)); - assert( buckets ); + buckets = _oom("dict64_grow", calloc(next, sizeof(*buckets))); if ( old_buckets ) { for ( i = 0; i < old_size; i++ ) { @@ -228,8 +238,7 @@ ur_dict_grow(ur_root_t *r, ur_dict_t *dict, uint64_t prev, uint64_t size) uint64_t old_size = dict->size; uint64_t i, next = prev + size; - buckets = calloc(next, sizeof(*buckets)); - assert( buckets ); + buckets = _oom("dict_grow", calloc(next, sizeof(*buckets))); if ( old_buckets ) { for ( i = 0; i < old_size; i++ ) { @@ -425,11 +434,9 @@ ur_atoms_grow(ur_atoms_t *atoms) uint64_t *lens = atoms->lens; ur_mug *mugs = atoms->mugs; - atoms->bytes = malloc(next * ( sizeof(*atoms->bytes) - + sizeof(*atoms->lens) - + sizeof(*atoms->mugs) )); - assert( atoms->bytes ); - + atoms->bytes = _oom("atoms_grow", malloc(next * ( sizeof(*atoms->bytes) + + sizeof(*atoms->lens) + + sizeof(*atoms->mugs) ))); atoms->lens = (void*)((char*)atoms->bytes + (next * sizeof(*atoms->bytes))); atoms->mugs = (void*)((char*)atoms->lens + (next * sizeof(*atoms->lens))); @@ -455,11 +462,9 @@ ur_cells_grow(ur_cells_t *cells) ur_nref *tails = cells->tails; ur_mug *mugs = cells->mugs; - cells->heads = malloc(next * ( sizeof(*cells->heads) - + sizeof(*cells->heads) - + sizeof(*cells->mugs) )); - assert( cells->heads ); - + cells->heads = _oom("cells_grow", malloc(next * ( sizeof(*cells->heads) + + sizeof(*cells->heads) + + sizeof(*cells->mugs) ))); cells->tails = (void*)((char*)cells->heads + (next * sizeof(*cells->heads))); cells->mugs = (void*)((char*)cells->tails + (next * sizeof(*cells->tails))); @@ -666,8 +671,7 @@ ur_coin_bytes(ur_root_t *r, uint8_t *byt, uint64_t len) return (ur_nref)direct; } else { - uint8_t *copy = malloc(len); - assert( copy ); + uint8_t *copy = _oom("coin_bytes", malloc(len)); memcpy(copy, byt, len); return ur_coin_bytes_unsafe(r, copy, len); @@ -681,10 +685,11 @@ ur_coin64(ur_root_t *r, uint64_t n) return n; } else { - uint8_t *byt = malloc(8); - assert( byt ); + uint8_t *byt; assert( 8 == ur_met3_64(n) ); + byt = _oom("coin64", malloc(8)); + byt[0] = ur_mask_8(n); byt[1] = ur_mask_8(n >> 8); byt[2] = ur_mask_8(n >> 16); @@ -873,8 +878,7 @@ ur_root_free(ur_root_t *r) ur_root_t* ur_root_init(void) { - ur_root_t *r = calloc(1, sizeof(*r)); - assert( r ); + ur_root_t *r = _oom("root_init", calloc(1, sizeof(*r))); { ur_dict_t *dict; @@ -916,8 +920,7 @@ void ur_nvec_init(ur_nvec_t *v, uint64_t size) { v->fill = 0; - v->refs = calloc(size, sizeof(ur_nref)); - assert( v->refs ); + v->refs = _oom("nvec_init", calloc(size, sizeof(ur_nref))); } void @@ -930,8 +933,7 @@ ur_walk_fore(ur_root_t *r, uint64_t prev = 89, size = 144, fill = 0; ur_nref *top, *don; - don = malloc(size * sizeof(*don)); - assert( don ); + don = _oom("walk_fore", malloc(size * sizeof(*don))); top = don + ++fill; *top = ref; @@ -956,8 +958,7 @@ ur_walk_fore(ur_root_t *r, // if ( size == fill ) { uint64_t next = prev + size; - don = realloc(don, next * sizeof(*don)); - assert( don ); + don = _oom("walk_fore", realloc(don, next * sizeof(*don))); top = don + fill; prev = size; size = next; diff --git a/pkg/urbit/ur/serial.c b/pkg/urbit/ur/serial.c index e30c8d9123..83610c12bf 100644 --- a/pkg/urbit/ur/serial.c +++ b/pkg/urbit/ur/serial.c @@ -3,6 +3,18 @@ #include "ur/ur.h" +static void* +_oom(const char* cap, void* v) +{ + if ( !v ) { + fprintf(stderr, + "ur: hashcons: %s: allocation failed, out of memory\r\n", cap); + abort(); + } + + return v; +} + static inline void _bsw_atom(ur_root_t *r, ur_nref ref, ur_bsw_t *bsw, uint64_t len) { @@ -81,8 +93,7 @@ ur_jam_unsafe(ur_root_t *r, j.bsw.prev = ur_fib11; j.bsw.size = ur_fib12; - j.bsw.bytes = calloc(j.bsw.size, 1); - assert( j.bsw.bytes ); + j.bsw.bytes = _oom("jam", calloc(j.bsw.size, 1)); ur_walk_fore(r, ref, &j, _jam_atom, _jam_cell); @@ -150,8 +161,7 @@ _cue_next(ur_root_t *r, // if ( s->fill == s->size ) { uint32_t next = s->prev + s->size; - s->f = realloc(s->f, next * sizeof(*s->f)); - assert( s->f ); + s->f = _oom("cue_next stack", realloc(s->f, next * sizeof(*s->f))); s->prev = s->size; s->size = next; } @@ -194,8 +204,7 @@ _cue_next(ur_root_t *r, } else { uint64_t len_byt = (len >> 3) + !!ur_mask_3(len); - uint8_t *byt = calloc(len_byt, 1); - assert( byt ); + uint8_t *byt = _oom("cue_next bytes", calloc(len_byt, 1)); ur_bsr_bytes_any(bsr, len, byt); @@ -242,8 +251,7 @@ ur_cue_unsafe(ur_root_t *r, // s.prev = ur_fib10; s.size = ur_fib11; - s.f = malloc(s.size * sizeof(*s.f)); - assert( s.f ); + s.f = _oom("cue stack", malloc(s.size * sizeof(*s.f))); // advance into stream // @@ -335,8 +343,7 @@ _cue_test_next(_cue_test_stack_t *s, // if ( s->fill == s->size ) { uint32_t next = s->prev + s->size; - s->f = realloc(s->f, next * sizeof(*s->f)); - assert( s->f ); + s->f = _oom("cue_test", realloc(s->f, next * sizeof(*s->f))); s->prev = s->size; s->size = next; } @@ -403,8 +410,7 @@ ur_cue_test_unsafe(ur_dict_t *dict, // s.prev = ur_fib10; s.size = ur_fib11; - s.f = malloc(s.size * sizeof(*s.f)); - assert( s.f ); + s.f = _oom("cue_test", malloc(s.size * sizeof(*s.f))); // advance into stream // From 6cb5df513eb6bf8f7a23691d10950525ce58464c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 8 Sep 2020 22:30:34 -0700 Subject: [PATCH 293/933] u3: refactors off-loom re-allocation in _cu_from_loom() --- pkg/urbit/noun/urth.c | 194 ++++++++++++++++++++++-------------------- 1 file changed, 104 insertions(+), 90 deletions(-) diff --git a/pkg/urbit/noun/urth.c b/pkg/urbit/noun/urth.c index 33c9bf2c95..6d802ed579 100644 --- a/pkg/urbit/noun/urth.c +++ b/pkg/urbit/noun/urth.c @@ -29,29 +29,38 @@ _cu_met_3(u3a_atom* vat_u) } } +/* _cu_atom_to_ref(): allocate indirect atom off-loom. +*/ static inline ur_nref -_cu_atom_to_ref(u3a_atom* vat_u, ur_root_t *r) +_cu_atom_to_ref(ur_root_t* rot_u, u3a_atom* vat_u) { ur_nref ref; + c3_d val_d; switch ( vat_u->len_w ) { case 2: { - ref = ur_coin64(r, ( ((c3_d)vat_u->buf_w[1]) << 32 - | ((c3_d)vat_u->buf_w[0]) )); + val_d = ((c3_d)vat_u->buf_w[1]) << 32 + | ((c3_d)vat_u->buf_w[0]); + ref = ur_coin64(rot_u, val_d); } break; case 1: { - ref = ur_coin64(r, (c3_d)vat_u->buf_w[0]); + val_d = (c3_d)vat_u->buf_w[0]; + ref = ur_coin64(rot_u, val_d); } break; - default: { - c3_assert( vat_u->len_w ); - + // XX assumes little-endian + // c3_y* byt_y = (c3_y*)vat_u->buf_w; - c3_w len_w = _cu_met_3(vat_u); + c3_d len_d = ((c3_d)vat_u->len_w) << 2; - ref = ur_coin_bytes(r, byt_y, (c3_d)len_w); + c3_assert( len_d ); + + // NB: this call will accounts for any trailing null bytes + // caused by an overestimate in [len_d] + // + ref = ur_coin_bytes(rot_u, byt_y, len_d); } break; } @@ -90,25 +99,19 @@ _cu_box_stash(u3a_noun* som_u, ur_nref ref) box_w[2] = ref >> 32; } -// stack frame for recording head vs tail iteration -// -// In Hoon, this structure would be as follows: -// -// $% [%root ~] -// [%head loom-cell=^] -// [%tail loom-cell=^ off-loom-head=*] -// == -// +/* +** stack frame for recording head vs tail iteration +** +** $? [LOM_HEAD cell=*] +** [ref=* cell=*] +*/ -#define STACK_ROOT 0 -#define STACK_HEAD 1 -#define STACK_TAIL 2 +#define LOM_HEAD 0xffffffffffffffffULL typedef struct _cu_frame_s { - c3_y tag_y; - u3a_cell* cel_u; ur_nref ref; + u3a_cell* cel_u; } _cu_frame; typedef struct _cu_stack_s @@ -119,91 +122,103 @@ typedef struct _cu_stack_s _cu_frame* fam_u; } _cu_stack; -/* _cu_stack_push(): push a "stack" frame. +/* _cu_from_loom_next(): advance off-loom reallocation traversal. */ -static inline void -_cu_stack_push(_cu_stack *s, c3_y tag_y, u3a_cell* cel_u, ur_nref ref) +static inline ur_nref +_cu_from_loom_next(_cu_stack* tac_u, ur_root_t* rot_u, u3_noun a) { - if ( s->fil_w == s->siz_w ) { - c3_w nex_w = s->pre_w + s->siz_w; - s->fam_u = c3_realloc(s->fam_u, nex_w * sizeof(*s->fam_u)); - s->pre_w = s->siz_w; - s->siz_w = nex_w; - } + while ( 1 ) { + // u3 direct == ur direct + // + if ( c3y == u3a_is_cat(a) ) { + return (ur_nref)a; + } + else { + u3a_noun* som_u = u3a_to_ptr(a); + ur_nref ref; - _cu_frame* fam_u = &(s->fam_u[s->fil_w++]); - fam_u->tag_y = tag_y; - fam_u->cel_u = cel_u; - fam_u->ref = ref; + // check for relocation pointers + // + if ( c3y == _cu_box_check(som_u, &ref) ) { + return ref; + } + // reallocate indirect atoms, stashing relocation pointers + // + else if ( c3y == u3a_is_atom(a) ) { + ref = _cu_atom_to_ref(rot_u, (u3a_atom*)som_u); + _cu_box_stash(som_u, ref); + return ref; + } + else { + u3a_cell* cel_u = (u3a_cell*)som_u; + + // reallocate the stack if full + // + if ( tac_u->fil_w == tac_u->siz_w ) { + c3_w nex_w = tac_u->pre_w + tac_u->siz_w; + tac_u->fam_u = c3_realloc(tac_u->fam_u, nex_w * sizeof(*tac_u->fam_u)); + tac_u->pre_w = tac_u->siz_w; + tac_u->siz_w = nex_w; + } + + // push a head-frame and continue into the head + // + { + _cu_frame* fam_u = &(tac_u->fam_u[tac_u->fil_w++]); + fam_u->ref = LOM_HEAD; + fam_u->cel_u = cel_u; + } + + a = cel_u->hed; + continue; + } + } + } } /* _cu_from_loom(): reallocate [a] off loom, in [r]. */ static ur_nref -_cu_from_loom(ur_root_t *r, u3_noun a) +_cu_from_loom(ur_root_t* rot_u, u3_noun a) { - ur_nref ref; + _cu_stack tac_u = {0}; + ur_nref ref; - _cu_stack s = { .pre_w = 89, .siz_w = 144, .fil_w = 0, .fam_u = 0 }; - s.fam_u = c3_malloc((s.pre_w + s.siz_w) * sizeof(*s.fam_u)); - _cu_stack_push(&s, STACK_ROOT, 0, 0); + tac_u.pre_w = ur_fib10; + tac_u.siz_w = ur_fib11; + tac_u.fam_u = c3_malloc(tac_u.siz_w * sizeof(*tac_u.fam_u)); - advance: { - // u3 direct == ur direct + ref = _cu_from_loom_next(&tac_u, rot_u, a); + + // incorporate reallocated ref, accounting for cells + // + while ( tac_u.fil_w ) { + // peek at the top of the stack // - if ( c3y == u3a_is_cat(a) ) { - ref = (ur_nref)a; - goto retreat; + _cu_frame* fam_u = &(tac_u.fam_u[tac_u.fil_w - 1]); + + // [fam_u] is a head-frame; stash ref and continue into the tail + // + if ( LOM_HEAD == fam_u->ref ) { + fam_u->ref = ref; + ref = _cu_from_loom_next(&tac_u, rot_u, fam_u->cel_u->tel); } + // [fam_u] is a tail-frame; cons refs and pop the stack + // else { - u3a_noun* som_u = u3a_to_ptr(a); - - // all bits set == already reallocated - // - if ( c3y == _cu_box_check(som_u, &ref) ) { - goto retreat; - } - else if ( c3y == u3a_is_atom(a) ) { - ref = _cu_atom_to_ref((u3a_atom*)som_u, r); - _cu_box_stash(som_u, ref); - goto retreat; - } - else { - u3a_cell* cel_u = (u3a_cell*)som_u; - _cu_stack_push(&s, STACK_HEAD, cel_u, 0); - a = cel_u->hed; - goto advance; - } + ref = ur_cons(rot_u, fam_u->ref, ref); + _cu_box_stash((u3a_noun*)fam_u->cel_u, ref); + tac_u.fil_w--; } } - retreat: { - _cu_frame fam_u = s.fam_u[--s.fil_w]; - - switch ( fam_u.tag_y ) { - default: c3_assert(0); - case STACK_ROOT: break; - - case STACK_HEAD: { - _cu_stack_push(&s, STACK_TAIL, fam_u.cel_u, ref); - a = fam_u.cel_u->tel; - goto advance; - } - - case STACK_TAIL: { - u3a_cell* cel_u = fam_u.cel_u; - ref = ur_cons(r, fam_u.ref, ref); - _cu_box_stash((u3a_noun*)cel_u, ref); - goto retreat; - } - } - } - - free(s.fam_u); + c3_free(tac_u.fam_u); return ref; } +/* _cu_vec: parameters for cold-state hamt walk. +*/ typedef struct _cu_vec_s { ur_nvec_t* vec_u; ur_root_t* rot_u; @@ -393,7 +408,7 @@ _cu_realloc(FILE* fil_u, ur_root_t** tor_u, ur_nvec_t* doc_u) // if ( fil_u ) { ur_root_info(fil_u, rot_u); - fprintf(stderr, "\r\n"); + fprintf(fil_u, "\r\n"); } // reinitialize loom @@ -432,11 +447,10 @@ u3u_meld(void) { ur_root_t* rot_u; ur_nvec_t cod_u; - ur_nref ken; c3_assert( &(u3H->rod_u) == u3R ); - ken = _cu_realloc(stderr, &rot_u, &cod_u); + _cu_realloc(stderr, &rot_u, &cod_u); // dispose off-loom structures // From 467d8d239bde4ea23574fcb703ba40f34dc70292 Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 4 Sep 2020 15:02:32 +0200 Subject: [PATCH 294/933] vere: support rendering +stub as ansi escape codes Adds support to term.c for a %klr blit, containing a +stub describing styled text. Dill will start making use of this in a separate commit, for release cutting reasons. --- pkg/urbit/include/c/motes.h | 3 + pkg/urbit/include/vere/vere.h | 1 + pkg/urbit/vere/io/term.c | 184 +++++++++++++++++++++++++++++++++- 3 files changed, 183 insertions(+), 5 deletions(-) diff --git a/pkg/urbit/include/c/motes.h b/pkg/urbit/include/c/motes.h index 40fcedc688..af29527feb 100644 --- a/pkg/urbit/include/c/motes.h +++ b/pkg/urbit/include/c/motes.h @@ -76,6 +76,7 @@ # define c3__bink c3_s4('b','i','n','k') # define c3__bird c3_s4('b','i','r','d') # define c3__bit c3_s3('b','i','t') +# define c3__bl c3_s2('b','l') # define c3__blan c3_s4('b','l','a','n') # define c3__blap c3_s4('b','l','a','p') # define c3__bleb c3_s4('b','l','e','b') @@ -112,6 +113,7 @@ # define c3__born c3_s4('b','o','r','n') # define c3__both c3_s4('b','o','t','h') # define c3__box c3_s3('b','o','x') +# define c3__br c3_s2('b','r') # define c3__bran c3_s4('b','r','a','n') # define c3__brax c3_s4('b','r','a','x') # define c3__brbn c3_s4('b','r','b','n') @@ -602,6 +604,7 @@ # define c3__kick c3_s4('k','i','c','k') # define c3__king c3_s4('k','i','n','g') # define c3__kit c3_s3('k','i','t') +# define c3__klr c3_s3('k','l','r') # define c3__knit c3_s4('k','n','i','t') # define c3__kno c3_s3('k','n','o') # define c3__ktbc c3_s4('k','t','b','c') diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index e84aa31106..b86fdf2dd0 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -155,6 +155,7 @@ struct { c3_w* lin_w; // current line (utf32) c3_w len_w; // length of current line + c3_w sap_w; // escape chars in current line c3_w cus_w; // cursor position } mir; diff --git a/pkg/urbit/vere/io/term.c b/pkg/urbit/vere/io/term.c index 3eb24050cd..d1da4c966f 100644 --- a/pkg/urbit/vere/io/term.c +++ b/pkg/urbit/vere/io/term.c @@ -468,6 +468,10 @@ _term_it_show_blank(u3_utty* uty_u) static void _term_it_show_cursor(u3_utty* uty_u, c3_w cur_w) { + //NOTE assumes all styled text precedes the cursor. drum enforces this. + // + cur_w = cur_w + uty_u->tat_u.mir.sap_w; + if ( cur_w < uty_u->tat_u.mir.cus_w ) { c3_w dif_w = (uty_u->tat_u.mir.cus_w - cur_w); @@ -488,7 +492,7 @@ _term_it_show_cursor(u3_utty* uty_u, c3_w cur_w) /* _term_it_show_line(): set current line */ static void -_term_it_show_line(u3_utty* uty_u, c3_w* lin_w, c3_w len_w) +_term_it_show_line(u3_utty* uty_u, c3_w* lin_w, c3_w len_w, c3_w sap_w) { _term_it_show_wide(uty_u, len_w, lin_w); @@ -499,6 +503,7 @@ _term_it_show_line(u3_utty* uty_u, c3_w* lin_w, c3_w len_w) uty_u->tat_u.mir.lin_w = lin_w; } uty_u->tat_u.mir.len_w = len_w; + uty_u->tat_u.mir.sap_w = sap_w; } /* _term_it_refresh_line(): refresh current line. @@ -507,10 +512,11 @@ static void _term_it_refresh_line(u3_utty* uty_u) { c3_w len_w = uty_u->tat_u.mir.len_w; + c3_w sap_w = uty_u->tat_u.mir.sap_w; c3_w cus_w = uty_u->tat_u.mir.cus_w; _term_it_show_clear(uty_u); - _term_it_show_line(uty_u, uty_u->tat_u.mir.lin_w, len_w); + _term_it_show_line(uty_u, uty_u->tat_u.mir.lin_w, len_w, sap_w); _term_it_show_cursor(uty_u, cus_w); } @@ -1036,6 +1042,167 @@ u3_term_ef_ctlc(void) _term_it_refresh_line(uty_u); } +/* _term_it_put_tint(): put ansi color id on lin_w. RETAINS col. +*/ +static void +_term_it_put_tint(c3_w* lin_w, + u3_noun col) +{ + switch ( col ) { + default: + case u3_nul: *lin_w = '9'; break; + case 'k': *lin_w = '0'; break; + case 'r': *lin_w = '1'; break; + case 'g': *lin_w = '2'; break; + case 'y': *lin_w = '3'; break; + case 'b': *lin_w = '4'; break; + case 'm': *lin_w = '5'; break; + case 'c': *lin_w = '6'; break; + case 'w': *lin_w = '7'; break; + } +} + +/* _term_it_put_deco(): put ansi sgr code on lin_w. RETAINS dec. +*/ +static void +_term_it_put_deco(c3_w* lin_w, + u3_noun dec) +{ + switch ( dec ) { + default: + case u3_nul: *lin_w = '0'; break; + case c3__br: *lin_w = '1'; break; + case c3__un: *lin_w = '4'; break; + case c3__bl: *lin_w = '5'; break; + } +} + +/* _term_it_show_stub(): send styled text to terminal as ansi escape sequences +*/ +static void +_term_it_show_stub(u3_utty* uty_u, + u3_noun tub) +{ + c3_w tuc_w = u3qb_lent(tub); + + // count the amount of characters across all stubs + // + c3_w lec_w = 0; + { + u3_noun nub = tub; + while ( u3_nul != nub ) { + u3_noun nib = u3t(u3h(nub)); + lec_w = lec_w + u3qb_lent(nib); + nub = u3t(nub); + } + } + + // allocate enough memory for every display character, plus styles + // + //NOTE we use max 20 characters per styl for escape codes: + // 3 for opening, 4 for decorations, 4 for colors, 4 for closing, + // and 5 as separators between decorations and colors. + // + c3_w* lin_w = c3_malloc( sizeof(c3_w) * (lec_w + (20 * tuc_w)) ); + + // write the contents to the buffer, + // tracking total and escape characters written + // + c3_w i_w = 0; + c3_w sap_w = 0; + { + u3_noun nub = tub; + while ( u3_nul != nub ) { + u3_noun tyl, nib, dec, bag, fog; + u3x_cell(u3h(nub), &tyl, &nib); + u3x_trel(tyl, &dec, &bag, &fog); + + c3_o tyl_o = c3n; + if ( (u3_nul != dec) || (u3_nul != bag) || (u3_nul != fog) ) { + tyl_o = c3y; + } + + // write style escape sequences + // + if ( c3y == tyl_o ) { + c3_o mor_o = c3n; + lin_w[i_w++] = 27; + lin_w[i_w++] = '['; + sap_w += 2; + + // text decorations + // + { + u3_noun dos = u3qdi_tap(dec); + u3_noun des = dos; + while ( u3_nul != des ) { + if ( c3y == mor_o ) { + lin_w[i_w++] = ';'; + sap_w++; + } + _term_it_put_deco(&lin_w[i_w++], u3h(des)); + sap_w++; + mor_o = c3y; + des = u3t(des); + } + u3z(dos); + } + + // background color + // + if ( u3_nul != bag ) { + if ( c3y == mor_o ) { + lin_w[i_w++] = ';'; + sap_w++; + } + lin_w[i_w++] = '4'; + _term_it_put_tint(&lin_w[i_w++], bag); + sap_w += 2; + mor_o = c3y; + } + + // foreground color + // + if ( u3_nul != fog ) { + if ( c3y == mor_o ) { + lin_w[i_w++] = ';'; + sap_w++; + } + lin_w[i_w++] = '3'; + _term_it_put_tint(&lin_w[i_w++], fog); + sap_w += 2; + mor_o = c3y; + } + + lin_w[i_w++] = 'm'; + sap_w++; + } + + // write the text itself + // + for ( i_w = i_w; u3_nul != nib; i_w++, nib = u3t(nib) ) { + lin_w[i_w] = u3r_word(0, u3h(nib)); + } + + // if we applied any styles, toggle them off + // + if ( c3y == tyl_o ) { + lin_w[i_w++] = 27; + lin_w[i_w++] = '['; + lin_w[i_w++] = '0'; + lin_w[i_w++] = 'm'; + sap_w += 4; + } + + nub = u3t(nub); + } + } + + _term_it_show_line(uty_u, lin_w, i_w, sap_w); + + u3z(tub); +} + /* _term_ef_blit(): send blit to terminal. */ static void @@ -1064,10 +1231,17 @@ _term_ef_blit(u3_utty* uty_u, } } break; + case c3__klr: { + if ( c3n == u3_Host.ops_u.tem ) { + _term_it_show_clear(uty_u); + } + _term_it_show_stub(uty_u, u3k(u3t(blt))); + } break; + case c3__lin: { u3_noun lin = u3t(blt); c3_w len_w = u3kb_lent(u3k(lin)); - c3_w* lin_w = c3_malloc(4 * len_w); + c3_w* lin_w = c3_malloc( sizeof(c3_w) * len_w ); { c3_w i_w; @@ -1079,9 +1253,9 @@ _term_ef_blit(u3_utty* uty_u, if ( c3n == u3_Host.ops_u.tem ) { _term_it_show_clear(uty_u); - _term_it_show_line(uty_u, lin_w, len_w); + _term_it_show_line(uty_u, lin_w, len_w, 0); } else { - _term_it_show_line(uty_u, lin_w, len_w); + _term_it_show_line(uty_u, lin_w, len_w, 0); } } break; From c20385a212041dacd834c9bacf4581c5701ced58 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 9 Sep 2020 13:12:27 -0700 Subject: [PATCH 295/933] u3: refactors on-loom re-allocation in _cu_all_to_loom() --- pkg/urbit/noun/urth.c | 144 +++++++++++++++++++++--------------------- 1 file changed, 72 insertions(+), 72 deletions(-) diff --git a/pkg/urbit/noun/urth.c b/pkg/urbit/noun/urth.c index 6d802ed579..8a58000ecd 100644 --- a/pkg/urbit/noun/urth.c +++ b/pkg/urbit/noun/urth.c @@ -259,101 +259,93 @@ typedef struct _cu_loom_s { u3_noun *cel; // cells } _cu_loom; -/* _cu_loom_free(): dispose loom relocation pointers -*/ -static void -_cu_loom_free(_cu_loom* lom_u) -{ - ur_dict_free((ur_dict_t*)&(lom_u->map_u)); - free(lom_u->vat); - free(lom_u->cel); -} - -/* _cu_atoms_to_loom(): allocate all indirect atoms on the loom. -*/ -static void -_cu_atoms_to_loom(ur_root_t* rot_u, _cu_loom* lom_u) -{ - c3_d* len_d = rot_u->atoms.lens; - c3_y** byt_y = rot_u->atoms.bytes; - c3_d fil_d = rot_u->atoms.fill; - u3_atom* vat = lom_u->vat = calloc(fil_d, sizeof(u3_atom)); - c3_d i_d; - - for ( i_d = 0; i_d < fil_d; i_d++ ) { - vat[i_d] = u3i_bytes(len_d[i_d], byt_y[i_d]); - } -} - /* _cu_ref_to_noun(): lookup/allocate [ref] on the loom. */ static u3_noun -_cu_ref_to_noun(ur_nref ref, _cu_loom* lom_u) +_cu_ref_to_noun(ur_root_t* rot_u, ur_nref ref, _cu_loom* lom_u) { switch ( ur_nref_tag(ref) ) { - default: assert(0); + default: c3_assert(0); + // all ur indirect atoms have been pre-reallocated on the loom. + // + case ur_iatom: return lom_u->vat[ur_nref_idx(ref)]; + + + // cells were allocated off-loom in cons-order, and are traversed + // in the same order: we've already relocated any one we could need here. + // + case ur_icell: return lom_u->cel[ur_nref_idx(ref)]; + + // u3 direct atoms are 31-bit, while ur direct atoms are 62-bit; + // we use a hashtable to deduplicate the non-overlapping space + // case ur_direct: { + u3_atom vat; + if ( 0x7fffffffULL >= ref ) { return (u3_atom)ref; } + else if ( ur_dict32_get(rot_u, &lom_u->map_u, ref, (c3_w*)&vat) ) { + return vat; + } else { - c3_w val_w; - - // XX the ur_root_t argument here is only used to dereference a mug, - // but these atoms are all direct, so it'll never be used - // - if ( ur_dict32_get(0, &lom_u->map_u, ref, &val_w) ) { - return (u3_atom)val_w; + { + c3_w wor_w[2] = { ref & 0xffffffff, ref >> 32 }; + vat = (c3_w)u3i_words(2, wor_w); } - else { - u3_atom vat; - { - c3_w wor_w[2] = { ref & 0xffffffff, ref >> 32 }; - vat = val_w = u3i_words(2, wor_w); - } - ur_dict32_put(0, &lom_u->map_u, ref, val_w); - - return vat; - } + ur_dict32_put(0, &lom_u->map_u, ref, (c3_w)vat); + return vat; } } break; - - case ur_iatom: return lom_u->vat[ur_nref_idx(ref)]; - - case ur_icell: return lom_u->cel[ur_nref_idx(ref)]; - } -} - -/* _cu_cells_to_loom(): allocate all cells on the loom. -*/ -static void -_cu_cells_to_loom(ur_root_t* rot_u, _cu_loom* lom_u) -{ - ur_nref* hed = rot_u->cells.heads; - ur_nref* tal = rot_u->cells.tails; - c3_d fil_d = rot_u->cells.fill; - u3_noun* cel = lom_u->cel = calloc(fil_d, sizeof(u3_noun)); - c3_d i_d; - - for ( i_d = 0; i_d < fil_d; i_d++ ) { - cel[i_d] = u3nc(_cu_ref_to_noun(hed[i_d], lom_u), - _cu_ref_to_noun(tal[i_d], lom_u)); - // XX mug? } } /* _cu_all_to_loom(): reallocate all of [rot_u] on the loom, restore roots. +** NB: requires all roots to be cells +** does *not* track refcounts, which must be +** subsequently reconstructed via tracing. */ static void _cu_all_to_loom(ur_root_t* rot_u, ur_nref ken, ur_nvec_t* cod_u) { - _cu_loom lom_u = {0}; - ur_dict32_grow(0, &lom_u.map_u, 89, 144); + _cu_loom lom_u = {0}; + c3_d i_d, fil_d; - _cu_atoms_to_loom(rot_u, &lom_u); - _cu_cells_to_loom(rot_u, &lom_u); + ur_dict32_grow(0, &lom_u.map_u, ur_fib11, ur_fib12); + + // allocate all atoms on the loom. + // + { + c3_d* len_d = rot_u->atoms.lens; + c3_y** byt_y = rot_u->atoms.bytes; + + fil_d = rot_u->atoms.fill; + lom_u.vat = calloc(fil_d, sizeof(u3_atom)); + + for ( i_d = 0; i_d < fil_d; i_d++ ) { + lom_u.vat[i_d] = u3i_bytes(len_d[i_d], byt_y[i_d]); + } + } + + // allocate all cells on the loom. + // + { + ur_nref* hed = rot_u->cells.heads; + ur_nref* tal = rot_u->cells.tails; + u3_noun cel; + + fil_d = rot_u->cells.fill; + lom_u.cel = c3_calloc(fil_d * sizeof(u3_noun)); + + for ( i_d = 0; i_d < fil_d; i_d++ ) { + cel = u3nc(_cu_ref_to_noun(rot_u, hed[i_d], &lom_u), + _cu_ref_to_noun(rot_u, tal[i_d], &lom_u)); + lom_u.cel[i_d] = cel; + u3r_mug(cel); + } + } // restore kernel reference (always a cell) // @@ -375,7 +367,11 @@ _cu_all_to_loom(ur_root_t* rot_u, ur_nref ken, ur_nvec_t* cod_u) } } - _cu_loom_free(&lom_u); + // dispose of relocation pointers + // + c3_free(lom_u.cel); + c3_free(lom_u.vat); + ur_dict_free((ur_dict_t*)&lom_u.map_u); } /* _cu_realloc(): hash-cons roots off-loom, reallocate on loom. @@ -421,6 +417,10 @@ _cu_realloc(FILE* fil_u, ur_root_t** tor_u, ur_nvec_t* doc_u) // _cu_all_to_loom(rot_u, ken, &cod_u); + // establish correct refcounts via tracing + // + u3m_grab(u3_none); + // allocate new hot jet state; re-establish warm // u3j_boot(c3y); From ba79aa713aefa8764e12f2c80699d09a1531c7e9 Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Wed, 9 Sep 2020 18:20:21 -0700 Subject: [PATCH 296/933] king: move most things from debug log level to info --- pkg/hs/urbit-king/lib/Urbit/King/Main.hs | 70 +++++++++---------- pkg/hs/urbit-king/lib/Urbit/Vere/Ames/DNS.hs | 6 +- pkg/hs/urbit-king/lib/Urbit/Vere/Ames/UDP.hs | 18 ++--- pkg/hs/urbit-king/lib/Urbit/Vere/Clay.hs | 16 ++--- pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs | 22 +++--- .../urbit-king/lib/Urbit/Vere/Eyre/Multi.hs | 6 +- pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs | 10 +-- .../urbit-king/lib/Urbit/Vere/Eyre/Service.hs | 8 +-- pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Wai.hs | 2 +- .../urbit-king/lib/Urbit/Vere/Http/Client.hs | 2 +- pkg/hs/urbit-king/lib/Urbit/Vere/LMDB.hs | 2 +- pkg/hs/urbit-king/lib/Urbit/Vere/NounServ.hs | 10 +-- pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs | 30 ++++---- pkg/hs/urbit-king/lib/Urbit/Vere/Serf.hs | 10 +-- pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs | 2 +- 15 files changed, 107 insertions(+), 107 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs index 7f8b9aaf3c..66092ffb69 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs @@ -194,9 +194,9 @@ tryBootFromPill oExit pill lite ship boot = do where bootedPier vSlog = do view pierPathL >>= lockFile - rio $ logDebug "Starting boot" + rio $ logInfo "Starting boot" sls <- Pier.booted vSlog pill lite ship boot - rio $ logDebug "Completed boot" + rio $ logInfo "Completed boot" pure sls runOrExitImmediately @@ -210,9 +210,9 @@ runOrExitImmediately vSlog getPier oExit mStart = do where shutdownImmediately :: (Serf, Log.EventLog) -> RIO PierEnv () shutdownImmediately (serf, log) = do - logDebug "Sending shutdown signal" + logInfo "Sending shutdown signal" Serf.stop serf - logDebug "Shutdown!" + logInfo "Shutdown!" runPier :: (Serf, Log.EventLog) -> RIO PierEnv () runPier serfLog = do @@ -231,9 +231,9 @@ tryPlayShip exitImmediately fullReplay playFrom mStart = do where wipeSnapshot = do shipPath <- view pierPathL - logDebug "wipeSnapshot" - logDebug $ display $ pack @Text ("Wiping " <> north shipPath) - logDebug $ display $ pack @Text ("Wiping " <> south shipPath) + logInfo "wipeSnapshot" + logInfo $ display $ pack @Text ("Wiping " <> north shipPath) + logInfo $ display $ pack @Text ("Wiping " <> south shipPath) removeFileIfExists (north shipPath) removeFileIfExists (south shipPath) @@ -243,9 +243,9 @@ tryPlayShip exitImmediately fullReplay playFrom mStart = do resumeShip :: TVar (Text -> IO ()) -> RAcquire PierEnv (Serf, Log.EventLog) resumeShip vSlog = do view pierPathL >>= lockFile - rio $ logDebug "RESUMING SHIP" + rio $ logInfo "RESUMING SHIP" sls <- Pier.resumed vSlog playFrom - rio $ logDebug "SHIP RESUMED" + rio $ logInfo "SHIP RESUMED" pure sls runRAcquire :: (MonadUnliftIO (m e), MonadIO (m e), MonadReader e (m e)) @@ -260,7 +260,7 @@ checkEvs pierPath first last = do rwith (Log.existing logPath) $ \log -> do let ident = Log.identity log let pbSty = PB.defStyle { PB.stylePostfix = PB.exact } - logDebug (displayShow ident) + logInfo (displayShow ident) last <- atomically $ Log.lastEv log <&> \lastReal -> min last lastReal @@ -285,7 +285,7 @@ checkEvs pierPath first last = do showEvents pb eId cycle = await >>= \case Nothing -> do lift $ PB.killProgressBar pb - lift $ logDebug "Everything checks out." + lift $ logInfo "Everything checks out." Just bs -> do lift $ PB.incProgress pb 1 lift $ do @@ -314,10 +314,10 @@ collectAllFx = error "TODO" -} collectAllFx :: FilePath -> RIO KingEnv () collectAllFx top = do - logDebug $ display $ pack @Text top + logInfo $ display $ pack @Text top vSlog <- logSlogs rwith (collectedFX vSlog) $ \() -> - logDebug "Done collecting effects!" + logInfo "Done collecting effects!" where tmpDir :: FilePath tmpDir = top ".tmpdir" @@ -338,10 +338,10 @@ collectAllFx top = do replayPartEvs :: FilePath -> Word64 -> RIO KingEnv () replayPartEvs top last = do - logDebug $ display $ pack @Text top + logInfo $ display $ pack @Text top fetchSnapshot rwith replayedEvs $ \() -> - logDebug "Done replaying events!" + logInfo "Done replaying events!" where fetchSnapshot :: RIO KingEnv () fetchSnapshot = do @@ -384,57 +384,57 @@ replayPartEvs top last = do -} testPill :: HasLogFunc e => FilePath -> Bool -> Bool -> RIO e () testPill pax showPil showSeq = do - logDebug "Reading pill file." + logInfo "Reading pill file." pillBytes <- readFile pax - logDebug "Cueing pill file." + logInfo "Cueing pill file." pillNoun <- io $ cueBS pillBytes & either throwIO pure - logDebug "Parsing pill file." + logInfo "Parsing pill file." pill <- fromNounErr pillNoun & either (throwIO . uncurry ParseErr) pure - logDebug "Using pill to generate boot sequence." + logInfo "Using pill to generate boot sequence." bootSeq <- genBootSeq (Ship 0) pill False (Fake (Ship 0)) - logDebug "Validate jam/cue and toNoun/fromNoun on pill value" + logInfo "Validate jam/cue and toNoun/fromNoun on pill value" reJam <- validateNounVal pill - logDebug "Checking if round-trip matches input file:" + logInfo "Checking if round-trip matches input file:" unless (reJam == pillBytes) $ do - logDebug " Our jam does not match the file...\n" - logDebug " This is surprising, but it is probably okay." + logInfo " Our jam does not match the file...\n" + logInfo " This is surprising, but it is probably okay." when showPil $ do - logDebug "\n\n== Pill ==\n" + logInfo "\n\n== Pill ==\n" io $ pPrint pill when showSeq $ do - logDebug "\n\n== Boot Sequence ==\n" + logInfo "\n\n== Boot Sequence ==\n" io $ pPrint bootSeq validateNounVal :: (HasLogFunc e, Eq a, ToNoun a, FromNoun a) => a -> RIO e ByteString validateNounVal inpVal = do - logDebug " jam" + logInfo " jam" inpByt <- evaluate $ jamBS $ toNoun inpVal - logDebug " cue" + logInfo " cue" outNon <- cueBS inpByt & either throwIO pure - logDebug " fromNoun" + logInfo " fromNoun" outVal <- fromNounErr outNon & either (throwIO . uncurry ParseErr) pure - logDebug " toNoun" + logInfo " toNoun" outNon <- evaluate (toNoun outVal) - logDebug " jam" + logInfo " jam" outByt <- evaluate $ jamBS outNon - logDebug "Checking if: x == cue (jam x)" + logInfo "Checking if: x == cue (jam x)" unless (inpVal == outVal) $ error "Value fails test: x == cue (jam x)" - logDebug "Checking if: jam x == jam (cue (jam x))" + logInfo "Checking if: jam x == jam (cue (jam x))" unless (inpByt == outByt) $ error "Value fails test: jam x == jam (cue (jam x))" @@ -446,11 +446,11 @@ validateNounVal inpVal = do pillFrom :: CLI.PillSource -> RIO HostEnv Pill pillFrom = \case CLI.PillSourceFile pillPath -> do - logDebug $ display $ "boot: reading pill from " ++ (pack pillPath :: Text) + logInfo $ display $ "boot: reading pill from " ++ (pack pillPath :: Text) io (loadFile pillPath >>= either throwIO pure) CLI.PillSourceURL url -> do - logDebug $ display $ "boot: retrieving pill from " ++ (pack url :: Text) + logInfo $ display $ "boot: retrieving pill from " ++ (pack url :: Text) -- Get the jamfile with the list of stars accepting comets right now. manager <- io $ C.newManager tlsManagerSettings request <- io $ C.parseRequest url @@ -729,7 +729,7 @@ runShipRestarting r o = do logTrace $ display (pier <> " shutdown requested") race_ (wait tid) $ do threadDelay 5_000_000 - logDebug $ display (pier <> " not down after 5s, killing with fire.") + logInfo $ display (pier <> " not down after 5s, killing with fire.") cancel tid logTrace $ display ("Ship terminated: " <> pier) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/DNS.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/DNS.hs index f16f6a55a8..25eccdc4bc 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/DNS.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/DNS.hs @@ -131,11 +131,11 @@ doResolv gal (prevWen, prevIP) turfs stderr = do io (resolv gal turfs) >>= \case Nothing -> do stderr $ "ames: czar at " ++ galStr ++ ": not found" - logDebug $ displayShow ("(ames) Failed to lookup IP for ", gal) + logInfo $ displayShow ("(ames) Failed to lookup IP for ", gal) pure (prevIP, tim) Just (turf, host, port, addr) -> do when (Just addr /= prevIP) (printCzar addr) - logDebug $ displayShow ("(ames) Looked up ", host, port, turf, addr) + logInfo $ displayShow ("(ames) Looked up ", host, port, turf, addr) pure (Just addr, tim) where galStr = renderGalaxy gal @@ -155,7 +155,7 @@ resolvWorker resolvWorker gal vTurfs vLast waitMsg send stderr = async (forever go) where logDrop = - logDebug $ displayShow ("(ames) Dropping packet; no ip for galaxy ", gal) + logInfo $ displayShow ("(ames) Dropping packet; no ip for galaxy ", gal) go :: RIO e () go = do diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/UDP.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/UDP.hs index 0dc758b46b..75014dd0d0 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/UDP.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/UDP.hs @@ -80,14 +80,14 @@ forceBind :: HasLogFunc e => PortNumber -> HostAddress -> RIO e Socket forceBind por hos = go where go = do - logDebug (display ("AMES: UDP: Opening socket on port " <> tshow por)) + logInfo (display ("AMES: UDP: Opening socket on port " <> tshow por)) io (doBind por hos) >>= \case Right sk -> do - logDebug (display ("AMES: UDP: Opened socket on port " <> tshow por)) + logInfo (display ("AMES: UDP: Opened socket on port " <> tshow por)) pure sk Left err -> do - logDebug (display ("AMES: UDP: " <> tshow err)) - logDebug ("AMES: UDP: Failed to open UDP socket. Waiting") + logInfo (display ("AMES: UDP: " <> tshow err)) + logInfo ("AMES: UDP: Failed to open UDP socket. Waiting") threadDelay 250_000 go @@ -138,7 +138,7 @@ recvPacket sok = do -} fakeUdpServ :: HasLogFunc e => RIO e UdpServ fakeUdpServ = do - logDebug $ displayShow ("AMES", "UDP", "\"Starting\" fake UDP server.") + logInfo $ displayShow ("AMES", "UDP", "\"Starting\" fake UDP server.") pure UdpServ { .. } where usSend = \_ _ -> pure () @@ -158,7 +158,7 @@ realUdpServ -> HostAddress -> RIO e UdpServ realUdpServ por hos = do - logDebug $ displayShow ("AMES", "UDP", "Starting real UDP server.") + logInfo $ displayShow ("AMES", "UDP", "Starting real UDP server.") env <- ask @@ -178,7 +178,7 @@ realUdpServ por hos = do -} let signalBrokenSocket :: Socket -> RIO e () signalBrokenSocket sock = do - logDebug $ displayShow ("AMES", "UDP" + logInfo $ displayShow ("AMES", "UDP" , "Socket broken. Requesting new socket" ) atomically $ do @@ -242,11 +242,11 @@ realUdpServ por hos = do enqueueRecvPacket p a b let shutdown = do - logDebug "AMES: UDP: Shutting down. (killing threads)" + logInfo "AMES: UDP: Shutting down. (killing threads)" cancel tOpen cancel tSend cancel tRecv - logDebug "AMES: UDP: Shutting down. (closing socket)" + logInfo "AMES: UDP: Shutting down. (closing socket)" io $ join $ atomically $ do res <- readTVar vSock <&> maybe (pure ()) close writeTVar vSock Nothing diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Clay.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Clay.hs index 6b8272266c..ae626ed08c 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Clay.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Clay.hs @@ -163,7 +163,7 @@ clay env plan = handleEffect :: ClayDrv -> SyncEf -> IO () handleEffect cd = runRIO env . \case SyncEfHill _ mountPoints -> do - logDebug $ displayShow ("(clay) known mount points:", mountPoints) + logInfo $ displayShow ("(clay) known mount points:", mountPoints) pierPath <- view pierPathL mountPairs <- flip mapM mountPoints $ \desk -> do ss <- takeFilesystemSnapshot (pierPath (deskToPath desk)) @@ -171,14 +171,14 @@ clay env plan = atomically $ writeTVar (cdMountPoints cd) (M.fromList mountPairs) SyncEfDirk p desk -> do - logDebug $ displayShow ("(clay) dirk:", p, desk) + logInfo $ displayShow ("(clay) dirk:", p, desk) m <- atomically $ readTVar (cdMountPoints cd) let snapshot = M.findWithDefault M.empty desk m pierPath <- view pierPathL let dir = pierPath deskToPath desk actions <- buildActionListFromDifferences dir snapshot - logDebug $ displayShow ("(clay) dirk actions: ", actions) + logInfo $ displayShow ("(clay) dirk actions: ", actions) let !intoList = map (actionsToInto dir) actions @@ -196,7 +196,7 @@ clay env plan = (applyActionsToMountPoints desk actions) SyncEfErgo p desk actions -> do - logDebug $ displayShow ("(clay) ergo:", p, desk, actions) + logInfo $ displayShow ("(clay) ergo:", p, desk, actions) m <- atomically $ readTVar (cdMountPoints cd) let mountPoint = M.findWithDefault M.empty desk m @@ -211,7 +211,7 @@ clay env plan = (applyActionsToMountPoints desk hashedActions) SyncEfOgre p desk -> do - logDebug $ displayShow ("(clay) ogre:", p, desk) + logInfo $ displayShow ("(clay) ogre:", p, desk) pierPath <- view pierPathL removeDirectoryRecursive $ pierPath deskToPath desk atomically $ modifyTVar (cdMountPoints cd) (M.delete desk) @@ -229,13 +229,13 @@ clay env plan = performAction :: (Map FilePath Int) -> (FilePath, Maybe (Mime, Int)) -> RIO e () performAction m (fp, Nothing) = do - logDebug $ displayShow ("(clay) deleting file ", fp) + logInfo $ displayShow ("(clay) deleting file ", fp) removeFile fp performAction m (fp, Just ((Mime _ (File (Octs bs)), hash))) - | skip = logDebug $ + | skip = logInfo $ displayShow ("(clay) skipping unchanged file update " , fp) | otherwise = do - logDebug $ displayShow ("(clay) updating file " , fp) + logInfo $ displayShow ("(clay) updating file " , fp) createDirectoryIfMissing True $ takeDirectory fp writeFile fp bs where diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs index 3d97651a00..ee6d616eb4 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs @@ -178,7 +178,7 @@ startServ -> (Text -> RIO e ()) -> RIO e Serv startServ who isFake conf plan stderr = do - logDebug (displayShow ("EYRE", "startServ")) + logInfo (displayShow ("EYRE", "startServ")) multi <- view multiEyreApiL @@ -221,11 +221,11 @@ startServ who isFake conf plan stderr = do let onKilReq :: Ship -> Word64 -> STM () onKilReq _ship = plan . cancelEv srvId . fromIntegral - logDebug (displayShow ("EYRE", "joinMultiEyre", who, mTls, mCre)) + logInfo (displayShow ("EYRE", "joinMultiEyre", who, mTls, mCre)) atomically (joinMultiEyre multi who mCre onReq onKilReq) - logDebug $ displayShow ("EYRE", "Starting loopback server") + logInfo $ displayShow ("EYRE", "Starting loopback server") lop <- serv vLive $ ServConf { scHost = soHost (pttLop ptt) , scPort = soWhich (pttLop ptt) @@ -237,7 +237,7 @@ startServ who isFake conf plan stderr = do } } - logDebug $ displayShow ("EYRE", "Starting insecure server") + logInfo $ displayShow ("EYRE", "Starting insecure server") ins <- serv vLive $ ServConf { scHost = soHost (pttIns ptt) , scPort = soWhich (pttIns ptt) @@ -250,7 +250,7 @@ startServ who isFake conf plan stderr = do } mSec <- for mTls $ \tls -> do - logDebug "Starting secure server" + logInfo "Starting secure server" serv vLive $ ServConf { scHost = soHost (pttSec ptt) , scPort = soWhich (pttSec ptt) @@ -271,7 +271,7 @@ startServ who isFake conf plan stderr = do let por = Ports secPor insPor lopPor fil = pierPath <> "/.http.ports" - logDebug $ displayShow ("EYRE", "All Servers Started.", srvId, por, fil) + logInfo $ displayShow ("EYRE", "All Servers Started.", srvId, por, fil) for secPor $ \p -> stderr ("http: secure web interface live on https://localhost:" <> tshow p) stderr ("http: web interface live on http://localhost:" <> tshow insPor) @@ -351,10 +351,10 @@ eyre env who plan isFake stderr = (initialEvents, runHttpServer) restart :: Drv -> HttpServerConf -> RIO e Serv restart (Drv var) conf = do - logDebug "Restarting http server" + logInfo "Restarting http server" let startAct = startServ who isFake conf plan stderr res <- fromEither =<< restartService var startAct kill - logDebug "Done restating http server" + logInfo "Done restating http server" pure res liveFailed _ = pure () @@ -362,11 +362,11 @@ eyre env who plan isFake stderr = (initialEvents, runHttpServer) handleEf :: Drv -> HttpServerEf -> IO () handleEf drv = runRIO env . \case HSESetConfig (i, ()) conf -> do - logDebug (displayShow ("EYRE", "%set-config")) + logInfo (displayShow ("EYRE", "%set-config")) Serv {..} <- restart drv conf - logDebug (displayShow ("EYRE", "%set-config", "Sending %live")) + logInfo (displayShow ("EYRE", "%set-config", "Sending %live")) atomically $ plan (EvErr (liveEv sServId sPorts) liveFailed) - logDebug "Write ports file" + logInfo "Write ports file" io (writePortsFile sPortsFile sPorts) HSEResponse (i, req, _seq, ()) ev -> do logDebug (displayShow ("EYRE", "%response")) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Multi.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Multi.hs index 706afb8f3d..73a0c5c559 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Multi.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Multi.hs @@ -72,7 +72,7 @@ leaveMultiEyre MultiEyreApi {..} who = do multiEyre :: HasLogFunc e => MultiEyreConf -> RIO e MultiEyreApi multiEyre conf@MultiEyreConf {..} = do - logDebug (displayShow ("EYRE", "MULTI", conf)) + logInfo (displayShow ("EYRE", "MULTI", conf)) vLive <- io emptyLiveReqs >>= newTVarIO vPlan <- newTVarIO mempty @@ -96,7 +96,7 @@ multiEyre conf@MultiEyreConf {..} = do Just cb -> cb who reqId mIns <- for mecHttpPort $ \por -> do - logDebug (displayShow ("EYRE", "MULTI", "HTTP", por)) + logInfo (displayShow ("EYRE", "MULTI", "HTTP", por)) serv vLive $ ServConf { scHost = host , scPort = SPChoices $ singleton $ fromIntegral por @@ -109,7 +109,7 @@ multiEyre conf@MultiEyreConf {..} = do } mSec <- for mecHttpsPort $ \por -> do - logDebug (displayShow ("EYRE", "MULTI", "HTTPS", por)) + logInfo (displayShow ("EYRE", "MULTI", "HTTPS", por)) serv vLive $ ServConf { scHost = host , scPort = SPChoices $ singleton $ fromIntegral por diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs index e007d6331a..0fdab349b6 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs @@ -164,7 +164,7 @@ tryOpenChoices tryOpenChoices hos = go where go (p :| ps) = do - logDebug (displayShow ("EYRE", "Trying to open port.", p)) + logInfo (displayShow ("EYRE", "Trying to open port.", p)) io (tryOpen hos p) >>= \case Left err -> do logError (displayShow ("EYRE", "Failed to open port.", p)) @@ -185,7 +185,7 @@ tryOpenAny hos = do pure (Right (p, s)) logDbg :: (HasLogFunc e, Show a) => [Text] -> a -> RIO e () -logDbg ctx msg = logDebug (prefix <> suffix) +logDbg ctx msg = logInfo (prefix <> suffix) where prefix = display (concat $ fmap (<> ": ") ctx) suffix = displayShow msg @@ -312,7 +312,7 @@ configCreds TlsConfig {..} = fakeServ :: HasLogFunc e => ServConf -> RIO e ServApi fakeServ conf = do let por = fakePort (scPort conf) - logDebug (displayShow ("EYRE", "SERV", "Running Fake Server", por)) + logInfo (displayShow ("EYRE", "SERV", "Running Fake Server", por)) pure $ ServApi { saKil = pure () , saPor = pure por @@ -331,7 +331,7 @@ getFirstTlsConfig (MTC var) = do realServ :: HasLogFunc e => TVar E.LiveReqs -> ServConf -> RIO e ServApi realServ vLive conf@ServConf {..} = do - logDebug (displayShow ("EYRE", "SERV", "Running Real Server")) + logInfo (displayShow ("EYRE", "SERV", "Running Real Server")) kil <- newEmptyTMVarIO por <- newEmptyTMVarIO @@ -344,7 +344,7 @@ realServ vLive conf@ServConf {..} = do } where runServ vPort = do - logDebug (displayShow ("EYRE", "SERV", "runServ")) + logInfo (displayShow ("EYRE", "SERV", "runServ")) rwith (forceOpenSocket scHost scPort) $ \(por, sok) -> do atomically (putTMVar vPort por) startServer scType scHost por sok scRedi vLive diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Service.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Service.hs index ce3bc01a93..af571afc93 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Service.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Service.hs @@ -31,21 +31,21 @@ restartService -> (s -> RIO e ()) -> RIO e (Either SomeException s) restartService vServ sstart kkill = do - logDebug "restartService" + logInfo "restartService" modifyMVar vServ $ \case Nothing -> doStart Just sv -> doRestart sv where doRestart :: s -> RIO e (Maybe s, Either SomeException s) doRestart serv = do - logDebug "doStart" + logInfo "doStart" try (kkill serv) >>= \case Left exn -> pure (Nothing, Left exn) Right () -> doStart doStart :: RIO e (Maybe s, Either SomeException s) doStart = do - logDebug "doStart" + logInfo "doStart" try sstart <&> \case Right s -> (Just s, Right s) Left exn -> (Nothing, Left exn) @@ -59,7 +59,7 @@ stopService -> (s -> RIO e ()) -> RIO e (Either SomeException ()) stopService vServ kkill = do - logDebug "stopService" + logInfo "stopService" modifyMVar vServ $ \case Nothing -> pure (Nothing, Right ()) Just sv -> do diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Wai.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Wai.hs index 1a7057bb61..147c3bd939 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Wai.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Wai.hs @@ -179,7 +179,7 @@ streamBlocks env init getAct = send init >> loop send "" = pure () send c = do - runRIO env (logInfo (display ("sending chunk " <> tshow c))) + runRIO env (logDebug (display ("sending chunk " <> tshow c))) yield $ Chunk $ fromByteString c yield Flush diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Http/Client.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Http/Client.hs index 011ce86acd..92e36145b2 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Http/Client.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Http/Client.hs @@ -140,7 +140,7 @@ client env plan = (initialEvents, runHttpClient) runReq HttpClientDrv{..} id req = async $ case cvtReq req of Nothing -> do - logDebug $ displayShow ("(malformed http client request)", id, req) + logInfo $ displayShow ("(malformed http client request)", id, req) planEvent id (Cancel ()) Just r -> do logDebug $ displayShow ("(http client request)", id, req) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/LMDB.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/LMDB.hs index 8e544647b6..691e25e5c0 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/LMDB.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/LMDB.hs @@ -226,7 +226,7 @@ readRowsBatch :: ∀e. HasLogFunc e readRowsBatch env dbi first = readRows where readRows = do - logDebug $ display ("(readRowsBatch) From: " <> tshow first) + logInfo $ display ("(readRowsBatch) From: " <> tshow first) withWordPtr first $ \pIdx -> withKVPtrs' (MDB_val 8 (castPtr pIdx)) nullVal $ \pKey pVal -> rwith (readTxn env) $ \txn -> diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/NounServ.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/NounServ.hs index f23f82aa33..bc31c32e96 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/NounServ.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/NounServ.hs @@ -82,7 +82,7 @@ wsConn pre inp out wsc = do flip finally cleanup $ do res <- atomically (waitCatchSTM writer <|> waitCatchSTM reader) - logDebug $ displayShow (res :: Either SomeException ()) + logInfo $ displayShow (res :: Either SomeException ()) -------------------------------------------------------------------------------- @@ -95,7 +95,7 @@ wsClient pax por = do out <- io $ newTBMChanIO 5 con <- pure (mkConn inp out) - logDebug "NOUNSERV (wsClie) Trying to connect" + logInfo "NOUNSERV (wsClie) Trying to connect" tid <- io $ async $ WS.runClient "127.0.0.1" por (unpack pax) @@ -111,7 +111,7 @@ wsServApp :: (HasLogFunc e, ToNoun o, FromNoun i, Show i, Show o) -> WS.PendingConnection -> RIO e () wsServApp cb pen = do - logDebug "NOUNSERV (wsServer) Got connection!" + logInfo "NOUNSERV (wsServer) Got connection!" wsc <- io $ WS.acceptRequest pen inp <- io $ newTBMChanIO 5 out <- io $ newTBMChanIO 5 @@ -125,10 +125,10 @@ wsServer = do tid <- async $ do env <- ask - logDebug "NOUNSERV (wsServer) Starting server" + logInfo "NOUNSERV (wsServer) Starting server" io $ WS.runServer "127.0.0.1" 9999 $ runRIO env . wsServApp (writeTBMChan con) - logDebug "NOUNSERV (wsServer) Server died" + logInfo "NOUNSERV (wsServer) Server died" atomically $ closeTBMChan con pure $ Server (readTBMChan con) tid 9999 diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs index 37b38a7d1f..82da7d0df9 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs @@ -178,21 +178,21 @@ bootNewShip -> RIO e () bootNewShip pill lite ship bootEv = do seq@(BootSeq ident x y) <- genBootSeq ship pill lite bootEv - logDebug "BootSeq Computed" + logInfo "BootSeq Computed" pierPath <- view pierPathL rio (setupPierDirectory pierPath) - logDebug "Directory setup." + logInfo "Directory setup." let logPath = (pierPath ".urb/log") rwith (Log.new logPath ident) $ \log -> do - logDebug "Event log onitialized." + logInfo "Event log onitialized." jobs <- (\now -> bootSeqJobs now seq) <$> io Time.now writeJobs log (fromList jobs) - logDebug "Finsihed populating event log with boot sequence" + logInfo "Finsihed populating event log with boot sequence" -- Resume an existing ship. ---------------------------------------------------- @@ -216,16 +216,16 @@ resumed vSlog replayUntil = do serf <- runSerf vSlog tap rio $ do - logDebug "Replaying events" + logInfo "Replaying events" Serf.execReplay serf log replayUntil >>= \case Left err -> error (show err) Right 0 -> do - logDebug "No work during replay so no snapshot" + logInfo "No work during replay so no snapshot" pure () Right _ -> do - logDebug "Taking snapshot" + logInfo "Taking snapshot" io (Serf.snapshot serf) - logDebug "SNAPSHOT TAKEN" + logInfo "SNAPSHOT TAKEN" pure (serf, log) @@ -251,14 +251,14 @@ acquireWorker :: HasLogFunc e => Text -> RIO e () -> RAcquire e (Async ()) acquireWorker nam act = mkRAcquire (async act) kill where kill tid = do - logDebug ("Killing worker thread: " <> display nam) + logInfo ("Killing worker thread: " <> display nam) cancel tid acquireWorkerBound :: HasLogFunc e => Text -> RIO e () -> RAcquire e (Async ()) acquireWorkerBound nam act = mkRAcquire (asyncBound act) kill where kill tid = do - logDebug ("Killing worker thread: " <> display nam) + logInfo ("Killing worker thread: " <> display nam) cancel tid @@ -293,11 +293,11 @@ pier (serf, log) vSlog startedSig = do pure (res, Term.useDemux res) void $ acquireWorker "TERMSERV Listener" $ forever $ do - logDebug "TERMSERV Waiting for external terminal." + logInfo "TERMSERV Waiting for external terminal." atomically $ do ext <- Term.connClient <$> readTQueue termApiQ Term.addDemux ext demux - logDebug "TERMSERV External terminal connected." + logInfo "TERMSERV External terminal connected." -- Slogs go to both stderr and to the terminal. env <- ask @@ -377,7 +377,7 @@ pier (serf, log) vSlog startedSig = do threadDelay 15_000_000 wen <- io Time.now let kal = \mTermNoun -> runRIO env $ do - logDebug $ displayShow ("scry result: ", mTermNoun) + logInfo $ displayShow ("scry result: ", mTermNoun) let nkt = MkKnot $ tshow $ Time.MkDate wen let pax = Path ["j", "~zod", "life", nkt, "~zod"] atomically $ putTMVar scrySig (wen, Nothing, pax, kal) @@ -501,7 +501,7 @@ router slog waitFx Drivers {..} = do logEvent :: HasLogFunc e => Ev -> RIO e () logEvent ev = do - logInfo $ "<- " <> display (summarizeEvent ev) + --logInfo $ "<- " <> display (summarizeEvent ev) logDebug $ "[EVENT]\n" <> display pretty where pretty :: Text @@ -509,7 +509,7 @@ logEvent ev = do logEffect :: HasLogFunc e => Lenient Ef -> RIO e () logEffect ef = do - logInfo $ " -> " <> display (summarizeEffect ef) + --logInfo $ " -> " <> display (summarizeEffect ef) logDebug $ display $ "[EFFECT]\n" <> pretty ef where pretty :: Lenient Ef -> Text diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Serf.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Serf.hs index e03512883e..6a65f2d238 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Serf.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Serf.hs @@ -40,7 +40,7 @@ withSerf config = mkRAcquire startup kill where startup = do (serf, st) <- io $ start config - logDebug (displayShow ("serf state", st)) + logInfo (displayShow ("serf state", st)) pure serf kill serf = do void $ rio $ stop serf @@ -58,7 +58,7 @@ execReplay serf log last = do where doBoot :: RIO e (Either PlayBail Word) doBoot = do - logDebug "Beginning boot sequence" + logInfo "Beginning boot sequence" let bootSeqLen = lifecycleLen (Log.identity log) @@ -72,14 +72,14 @@ execReplay serf log last = do when (numEvs /= bootSeqLen) $ do throwIO (MissingBootEventsInEventLog numEvs bootSeqLen) - logDebug $ display ("Sending " <> tshow numEvs <> " boot events to serf") + logInfo $ display ("Sending " <> tshow numEvs <> " boot events to serf") io (boot serf evs) >>= \case Just err -> do - logDebug "Error on replay, exiting" + logInfo "Error on replay, exiting" pure (Left err) Nothing -> do - logDebug "Finished boot events, moving on to more events from log." + logInfo "Finished boot events, moving on to more events from log." doReplay <&> \case Left err -> Left err Right num -> Right (num + numEvs) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs index 06082c142d..eea980a7fc 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs @@ -472,7 +472,7 @@ localClient doneSignal = fst <$> mkRAcquire start stop loop rd else if w == 3 then do -- ETX (^C) - logDebug $ displayShow "Ctrl-c interrupt" + logInfo $ displayShow "Ctrl-c interrupt" atomically $ do writeTQueue wq [Term.Trace "interrupt\r\n"] writeTQueue rq $ Ctl $ Cord "c" From efe1f7ce3944a9a482a92c200b4e670f21b3aeeb Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 9 Sep 2020 22:30:20 -0700 Subject: [PATCH 297/933] u3: disables meld and cram under U3_MEMORY_DEEBUG --- pkg/urbit/noun/urth.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pkg/urbit/noun/urth.c b/pkg/urbit/noun/urth.c index 8a58000ecd..82f052d1d7 100644 --- a/pkg/urbit/noun/urth.c +++ b/pkg/urbit/noun/urth.c @@ -379,6 +379,10 @@ _cu_all_to_loom(ur_root_t* rot_u, ur_nref ken, ur_nvec_t* cod_u) static ur_nref _cu_realloc(FILE* fil_u, ur_root_t** tor_u, ur_nvec_t* doc_u) { +#ifdef U3_MEMORY_DEBUG + c3_assert(0); +#endif + // bypassing page tracking as an optimization // // NB: u3e_yolo() will mark all as dirty, and @@ -442,6 +446,13 @@ _cu_realloc(FILE* fil_u, ur_root_t** tor_u, ur_nvec_t* doc_u) /* u3u_meld(): globally deduplicate memory. */ +#ifdef U3_MEMORY_DEBUG +void +u3u_meld(void) +{ + fprintf(stderr, "u3: unable to meld under U3_MEMORY_DEBUG\r\n"); +} +#else void u3u_meld(void) { @@ -457,6 +468,7 @@ u3u_meld(void) ur_nvec_free(&cod_u); ur_root_free(rot_u); } +#endif /* _cu_rock_path(): format rock path. */ @@ -624,6 +636,14 @@ _cu_rock_save(c3_c* dir_c, c3_d eve_d, c3_d len_d, c3_y* byt_y) /* u3u_cram(): globably deduplicate memory, and write a rock to disk. */ +#ifdef U3_MEMORY_DEBUG +c3_o +u3u_cram(c3_c* dir_c, c3_d eve_d) +{ + fprintf(stderr, "u3: unable to cram under U3_MEMORY_DEBUG\r\n"); + return c3n; +} +#else c3_o u3u_cram(c3_c* dir_c, c3_d eve_d) { @@ -670,6 +690,7 @@ u3u_cram(c3_c* dir_c, c3_d eve_d) return ret_o; } +#endif /* u3u_mmap_read(): open and mmap the file at [pat_c] for reading. */ From cda7a7edb0f9d4c8117bad6462d4b284f8f51785 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 9 Sep 2020 22:33:44 -0700 Subject: [PATCH 298/933] ur: consistently use fibonacci constants --- pkg/urbit/ur/hashcons.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 38a8abbf5f..a08de03110 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -882,29 +882,28 @@ ur_root_init(void) { ur_dict_t *dict; - uint64_t fib11 = 89, fib12 = 144; // allocate atom storage // - r->atoms.prev = fib11; - r->atoms.size = fib12; + r->atoms.prev = ur_fib11; + r->atoms.size = ur_fib12; ur_atoms_grow(&(r->atoms)); // allocate atom hashtable // dict = &(r->atoms.dict); - ur_dict_grow(r, dict, fib11, fib12); + ur_dict_grow(r, dict, ur_fib11, ur_fib12); // allocate cell storage // - r->cells.prev = fib11; - r->cells.size = fib12; + r->cells.prev = ur_fib11; + r->cells.size = ur_fib12; ur_cells_grow(&(r->cells)); // allocate cell hashtable // dict = &(r->cells.dict); - ur_dict_grow(r, dict, fib11, fib12); + ur_dict_grow(r, dict, ur_fib11, ur_fib12); } return r; @@ -930,7 +929,7 @@ ur_walk_fore(ur_root_t *r, void (*atom)(ur_root_t*, ur_nref, void*), ur_bool_t (*cell)(ur_root_t*, ur_nref, void*)) { - uint64_t prev = 89, size = 144, fill = 0; + uint64_t prev = ur_fib11, size = ur_fib12, fill = 0; ur_nref *top, *don; don = _oom("walk_fore", malloc(size * sizeof(*don))); From a3531799086b2aefcde819b368c2ef8f01d963d4 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 9 Sep 2020 22:35:52 -0700 Subject: [PATCH 299/933] vere: consistently handle %meld $writ in king --- pkg/urbit/vere/lord.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/urbit/vere/lord.c b/pkg/urbit/vere/lord.c index a216ce1389..05e55e27d0 100644 --- a/pkg/urbit/vere/lord.c +++ b/pkg/urbit/vere/lord.c @@ -116,6 +116,7 @@ _lord_writ_free(u3_writ* wit_u) case u3_writ_save: case u3_writ_cram: + case u3_writ_meld: case u3_writ_pack: case u3_writ_exit: { } break; @@ -209,6 +210,7 @@ _lord_writ_str(u3_writ_type typ_e) case u3_writ_play: return "play"; case u3_writ_save: return "save"; case u3_writ_cram: return "cram"; + case u3_writ_meld: return "meld"; case u3_writ_pack: return "pack"; case u3_writ_exit: return "exit"; } From 06417698750c134c27ab6eef4c25cc17b5433427 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 9 Sep 2020 22:39:39 -0700 Subject: [PATCH 300/933] vere: fix crash on u3_pier_bail() --- pkg/urbit/vere/pier.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index 1b4e23638a..295b459538 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -1792,8 +1792,7 @@ u3_pier_exit(u3_pier* pir_u) void u3_pier_bail(u3_pier* pir_u) { - pir_u->sat_e = u3_psat_done; - + // halt serf // if ( pir_u->god_u ) { u3_lord_halt(pir_u->god_u); @@ -1816,6 +1815,8 @@ u3_pier_bail(u3_pier* pir_u) pir_u->log_u = 0; } + pir_u->sat_e = u3_psat_done; + _pier_done(pir_u); } From 3eb51b13d6bb3dd2b165ea3a678e197a0267ae14 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 9 Sep 2020 22:40:46 -0700 Subject: [PATCH 301/933] vere: fixes %trim effect handler --- pkg/urbit/vere/io/hind.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/vere/io/hind.c b/pkg/urbit/vere/io/hind.c index be83a9f66e..37d090399e 100644 --- a/pkg/urbit/vere/io/hind.c +++ b/pkg/urbit/vere/io/hind.c @@ -45,8 +45,9 @@ _hind_io_kick(u3_auto* car_u, u3_noun wir, u3_noun cad) // case c3__trim: { ret_o = c3y; - u3_auto_plan(car_u, u3_ovum_init(0, u3_blip, u3k(wir), u3k(cad))); - } + u3_auto_plan(car_u, u3_ovum_init(0, u3_blip, + u3nc(c3__arvo, u3_nul), u3k(cad))); + } break; case c3__vega: { ret_o = c3y; From 0699f6f3f11e797b12aedf66b8f41224e66901d6 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 9 Sep 2020 22:42:53 -0700 Subject: [PATCH 302/933] vere: improves error messages on ipc EOF --- pkg/urbit/include/vere/vere.h | 2 +- pkg/urbit/vere/lord.c | 12 +++++++++++- pkg/urbit/vere/newt.c | 12 ++++++------ pkg/urbit/worker/main.c | 12 +++++++++--- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index b86fdf2dd0..dca2a4d8bb 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -44,7 +44,7 @@ /* u3_moor_bail: bailout callback function. */ - typedef void (*u3_moor_bail)(void*, const c3_c* err_c); + typedef void (*u3_moor_bail)(void*, ssize_t err_i, const c3_c* err_c); /* u3_meat: blob message block. */ diff --git a/pkg/urbit/vere/lord.c b/pkg/urbit/vere/lord.c index 3b3d806a09..2cf8e1ce12 100644 --- a/pkg/urbit/vere/lord.c +++ b/pkg/urbit/vere/lord.c @@ -61,6 +61,7 @@ */ static void _lord_stop_cb(void* ptr_v, + ssize_t err_i, const c3_c* err_c) { u3_lord* god_u = ptr_v; @@ -122,6 +123,7 @@ _lord_writ_free(u3_writ* wit_u) */ static void _lord_bail_noop(void* ptr_v, + ssize_t err_i, const c3_c* err_c) { } @@ -986,10 +988,18 @@ _lord_on_serf_exit(uv_process_t* req_u, */ static void _lord_on_serf_bail(void* ptr_v, + ssize_t err_i, const c3_c* err_c) { u3_lord* god_u = ptr_v; - u3l_log("pier: serf error: %s\r\n", err_c); + + if ( UV_EOF == err_i ) { + u3l_log("pier: serf unexpectedly shut down\r\n"); + } + else { + u3l_log("pier: serf error: %s\r\n", err_c); + } + _lord_bail(god_u); } diff --git a/pkg/urbit/vere/newt.c b/pkg/urbit/vere/newt.c index e7cfe2be50..a65aa900fe 100644 --- a/pkg/urbit/vere/newt.c +++ b/pkg/urbit/vere/newt.c @@ -217,7 +217,7 @@ _newt_read(u3_moat* mot_u, fprintf(stderr, "newt: read failed %s\r\n", uv_strerror(len_i)); } - mot_u->bal_f(mot_u->ptr_v, uv_strerror(len_i)); + mot_u->bal_f(mot_u->ptr_v, len_i, uv_strerror(len_i)); return c3n; } // EAGAIN/EWOULDBLOCK @@ -299,7 +299,7 @@ _newt_read_init(u3_moat* mot_u, uv_read_cb read_cb_f) read_cb_f)) ) { fprintf(stderr, "newt: read failed %s\r\n", uv_strerror(sas_i)); - mot_u->bal_f(mot_u->ptr_v, uv_strerror(sas_i)); + mot_u->bal_f(mot_u->ptr_v, sas_i, uv_strerror(sas_i)); } } } @@ -310,7 +310,7 @@ static void _moat_stop_cb(uv_handle_t* han_u) { u3_moat* mot_u = han_u->data; - mot_u->bal_f(mot_u->ptr_v, ""); + mot_u->bal_f(mot_u->ptr_v, -1, ""); } /* u3_newt_moat_stop(); newt stop/close input stream. @@ -407,7 +407,7 @@ _newt_write_cb(uv_write_t* wri_u, c3_i sas_i) } else { fprintf(stderr, "newt: write failed %s\r\n", uv_strerror(sas_i)); - moj_u->bal_f(moj_u->ptr_v, uv_strerror(sas_i)); + moj_u->bal_f(moj_u->ptr_v, sas_i, uv_strerror(sas_i)); } } } @@ -418,7 +418,7 @@ static void _mojo_stop_cb(uv_handle_t* han_u) { u3_mojo* moj_u = han_u->data; - moj_u->bal_f(moj_u->ptr_v, ""); + moj_u->bal_f(moj_u->ptr_v, -1, ""); } /* u3_newt_mojo_stop(); newt stop/close output stream. @@ -468,7 +468,7 @@ u3_newt_write(u3_mojo* moj_u, u3_atom mat) { c3_free(req_u); fprintf(stderr, "newt: write failed %s\r\n", uv_strerror(sas_i)); - moj_u->bal_f(moj_u->ptr_v, uv_strerror(sas_i)); + moj_u->bal_f(moj_u->ptr_v, sas_i, uv_strerror(sas_i)); } } } diff --git a/pkg/urbit/worker/main.c b/pkg/urbit/worker/main.c index 7bc494e269..0ed19d0d80 100644 --- a/pkg/urbit/worker/main.c +++ b/pkg/urbit/worker/main.c @@ -29,9 +29,15 @@ static u3_mojo out_u; // output stream /* _cw_serf_fail(): failure stub. */ static void -_cw_serf_fail(void* vod_p, const c3_c* wut_c) +_cw_serf_fail(void* ptr_v, ssize_t err_i, const c3_c* err_c) { - fprintf(stderr, "serf: fail: %s\r\n", wut_c); + if ( UV_EOF == err_i ) { + fprintf(stderr, "serf: pier unexpectedly shut down\r\n"); + } + else { + fprintf(stderr, "serf: pier error: %s\r\n", err_c); + } + exit(1); } @@ -67,7 +73,7 @@ _cw_serf_writ(void* vod_p, u3_noun mat) u3_noun ret; if ( c3n == u3_serf_writ(&u3V, u3ke_cue(mat), &ret) ) { - _cw_serf_fail(0, "bad jar"); + _cw_serf_fail(0, -1, "bad jar"); } else { _cw_serf_send(ret); From f4c58ff256dcb3a72b9d82aafbf2bd9cb5d69258 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 9 Sep 2020 22:43:28 -0700 Subject: [PATCH 303/933] u3: improves error output on c3_assert() --- pkg/urbit/include/c/defs.h | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/urbit/include/c/defs.h b/pkg/urbit/include/c/defs.h index 8eee3998cd..01a07909c7 100644 --- a/pkg/urbit/include/c/defs.h +++ b/pkg/urbit/include/c/defs.h @@ -30,6 +30,7 @@ # define c3_assert(x) \ do { \ if (!(x)) { \ + fflush(stderr); \ fprintf(stderr, "\rAssertion '%s' " \ "failed in %s:%d\n", \ #x, __FILE__, __LINE__); \ From ce236f17ee44be2a3dad38b3f49fe46184cab6e8 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 10 Sep 2020 15:01:46 -0700 Subject: [PATCH 304/933] term: refactors spinner, avoiding (most) unnecessary measurement --- pkg/urbit/vere/io/term.c | 92 ++++++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 36 deletions(-) diff --git a/pkg/urbit/vere/io/term.c b/pkg/urbit/vere/io/term.c index d1da4c966f..336519e5b6 100644 --- a/pkg/urbit/vere/io/term.c +++ b/pkg/urbit/vere/io/term.c @@ -800,17 +800,18 @@ _term_read_cb(uv_stream_t* tcp_u, c3_free(buf_u->base); } -/* _term_spin_write_str(): write null-terminated string +/* _term_spin_dump(): write static vector to terminal FD. */ static void -_term_spin_write_str(u3_utty* uty_u, - const c3_c* str_c) +_term_spin_dump(u3_utty* uty_u, + c3_w len_w, + const c3_c* str_c) { - // c3_i fid_i = uv_fileno(&uty_u->pop_u); - c3_i fid_i = uty_u->pop_u.io_watcher.fd; // XX old libuv - c3_w len_w = strlen(str_c); + c3_i fid_i; - if ( len_w != write(fid_i, str_c, len_w) ) { + if ( !uv_fileno((uv_handle_t*)&uty_u->pop_u, &fid_i) + && (len_w != write(fid_i, str_c, len_w)) ) + { // ignore, we just tryin } } @@ -820,7 +821,8 @@ _term_spin_write_str(u3_utty* uty_u, static void _term_spin_move_left(u3_utty* uty_u) { - _term_spin_write_str(uty_u, (const c3_c*)uty_u->ufo_u.out.cub1_y); + const c3_c* str_c = (const c3_c*)uty_u->ufo_u.out.cub1_y; + _term_spin_dump(uty_u, strlen(str_c), str_c); } /* _term_spin_timer_cb(): render spinner @@ -830,57 +832,75 @@ _term_spin_timer_cb(uv_timer_t* tim_u) { u3_utty* uty_u = tim_u->data; u3_utat* tat_u = &uty_u->tat_u; + c3_w bac_w; - c3_w cus_w = tat_u->mir.cus_w; - c3_l col_l = tat_u->siz.col_l; + // calculate backoff from end of line, or bail out + // + { + c3_w cus_w = tat_u->mir.cus_w; + c3_l col_l = tat_u->siz.col_l; - if ( cus_w >= col_l ) { // shenanigans! - return; + if ( cus_w >= col_l ) { // shenanigans! + return; + } + + bac_w = col_l - 1 - cus_w; } - c3_w bac_w = col_l - 1 - cus_w; // backoff from end of line - c3_d lag_d = tat_u->sun_u.eve_d++; - + c3_d lag_d = tat_u->sun_u.eve_d++; const c3_c daz_c[] = "|/-\\"; - const c3_c dal_c[] = "\xc2\xab"; - const c3_c dar_c[] = "\xc2\xbb"; + // | + « + why + » + \0 + c3_c buf_c[1 + 2 + 4 + 2 + 1]; + c3_c* cur_c = buf_c; + c3_w sol_w = 1; // spinner length (utf-32) - c3_c buf_c[1 + 2 + 4 + 2 + 1]; - // | + « + why + » + \0 - - c3_c* cur_c = buf_c; - - *cur_c++ = daz_c[lag_d % strlen(daz_c)]; - c3_w sol_w = 1; // spinner length (utf-32) + *cur_c++ = daz_c[lag_d % (sizeof(daz_c) - 1)]; if ( tat_u->sun_u.why_c[0] ) { - strncpy(cur_c, dal_c, 2); - cur_c += 2; - sol_w += 1; // length of dal_c (utf-32) + { + const c3_c dal_c[] = "\xc2\xab"; + *cur_c++ = dal_c[0]; + *cur_c++ = dal_c[1]; + sol_w++; // length of dal_c (utf-32) + } - strncpy(cur_c, tat_u->sun_u.why_c, 4); - cur_c += 4; - sol_w += 4; // XX assumed utf-8 + { + c3_c* why_c = tat_u->sun_u.why_c; + *cur_c++ = *why_c++; + *cur_c++ = *why_c++; + *cur_c++ = *why_c++; + *cur_c++ = *why_c++; + sol_w += 4; // XX assumed utf-8 + } - strncpy(cur_c, dar_c, 2); - cur_c += 2; - sol_w += 1; // length of dar_c (utf-32) + { + const c3_c dar_c[] = "\xc2\xbb"; + *cur_c++ = dar_c[0]; + *cur_c++ = dar_c[1]; + sol_w++; // length of dar_c (utf-32) + } } *cur_c = '\0'; - // One-time cursor backoff. + // One-time cursor backoff. + // if ( c3n == tat_u->sun_u.diz_o ) { c3_w i_w; for ( i_w = bac_w; i_w < sol_w; i_w++ ) { _term_spin_move_left(uty_u); } + + tat_u->sun_u.diz_o = c3y; } - _term_spin_write_str(uty_u, buf_c); - tat_u->sun_u.diz_o = c3y; + { + c3_w len_w = cur_c - buf_c; + _term_spin_dump(uty_u, len_w, buf_c); + } // Cursor stays on spinner. + // while ( sol_w-- ) { _term_spin_move_left(uty_u); } From bf28ff571f10cedbf2823356fd823d612e89f4c6 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 10 Sep 2020 15:37:01 -0700 Subject: [PATCH 305/933] vere: refactors term write codepaths, avoiding reallocation --- pkg/urbit/include/vere/vere.h | 39 +++--- pkg/urbit/vere/io/term.c | 241 +++++++++++++++------------------- 2 files changed, 122 insertions(+), 158 deletions(-) diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index dca2a4d8bb..3f6d9a04ae 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -136,14 +136,6 @@ c3_w pid_w; // pid of checkpoint process } u3_save; - /* u3_ubuf: unix tty i/o buffer. - */ - typedef struct _u3_ubuf { - struct _u3_ubuf* nex_u; - c3_w len_w; - c3_y hun_y[0]; // bytes to send - } u3_ubuf; - /* u3_utat: unix terminal state. */ typedef struct { @@ -191,24 +183,23 @@ */ typedef struct { struct { - const c3_y* kcuu1_y; // key_up - const c3_y* kcud1_y; // key_down - const c3_y* kcub1_y; // key_back - const c3_y* kcuf1_y; // key_forward - c3_w max_w; // maximum input sequence length + uv_buf_t kcuu1_u; // key_up + uv_buf_t kcud1_u; // key_down + uv_buf_t kcub1_u; // key_back + uv_buf_t kcuf1_u; // key_forward } inn; struct { - const c3_y* clear_y; // clear_screen - const c3_y* el_y; // clr_bol clear to beginning - // const c3_y* el1_y; // clr_eol clear to end - const c3_y* ed_y; // clear to end of screen - const c3_y* bel_y; // bel sound bell - const c3_y* cub1_y; // parm_left - const c3_y* cuf1_y; // parm_right - const c3_y* cuu1_y; // parm_up - const c3_y* cud1_y; // parm_down - // const c3_y* cub_y; // parm_left_cursor #num - // const c3_y* cuf_y; // parm_right_cursor #num + uv_buf_t clear_u; // clear_screen + uv_buf_t el_u; // clr_bol clear to beginning + // uv_buf_t el1_u; // clr_eol clear to end + uv_buf_t ed_u; // clear to end of screen + uv_buf_t bel_u; // bel sound bell + uv_buf_t cub1_u; // parm_left + uv_buf_t cuf1_u; // parm_right + uv_buf_t cuu1_u; // parm_up + uv_buf_t cud1_u; // parm_down + // uv_buf_t cub_u; // parm_left_cursor #num + // uv_buf_t cuf_u; // parm_right_cursor #num } out; } u3_utfo; diff --git a/pkg/urbit/vere/io/term.c b/pkg/urbit/vere/io/term.c index 336519e5b6..6120922ab8 100644 --- a/pkg/urbit/vere/io/term.c +++ b/pkg/urbit/vere/io/term.c @@ -13,6 +13,11 @@ #include "all.h" #include "vere/vere.h" +// macros for string literal args/buffers +// +#define TERM_LIT(s) sizeof(s) - 1, (const c3_y*)(s) +#define TERM_LIT_BUF(s) uv_buf_init(s, sizeof(s) - 1) + static u3_utty* _term_main(); static void _term_read_cb(uv_stream_t* tcp_u, ssize_t siz_i, @@ -143,60 +148,33 @@ u3_term_log_init(void) uv_pipe_open(&(uty_u->pop_u), uty_u->fid_i); } - // Load terminfo strings. + // configure output escape sequences + // + // (as reported by the terminfo database we bundled) // { - c3_w len_w; + uty_u->ufo_u.out.clear_u = TERM_LIT_BUF("\033[H\033[2J"); + uty_u->ufo_u.out.el_u = TERM_LIT_BUF("\033[K"); + // uty_u->ufo_u.out.el1_u = TERM_LIT_BUF("\033[1K"); + uty_u->ufo_u.out.ed_u = TERM_LIT_BUF("\033[J"); + uty_u->ufo_u.out.bel_u = TERM_LIT_BUF("\x7"); + uty_u->ufo_u.out.cub1_u = TERM_LIT_BUF("\x8"); + uty_u->ufo_u.out.cuf1_u = TERM_LIT_BUF("\033[C"); + uty_u->ufo_u.out.cuu1_u = TERM_LIT_BUF("\033[A"); + uty_u->ufo_u.out.cud1_u = TERM_LIT_BUF("\xa"); + // uty_u->ufo_u.out.cub_u = TERM_LIT_BUF("\033[%p1%dD"); + // uty_u->ufo_u.out.cuf_u = TERM_LIT_BUF("\033[%p1%dC"); + } - uty_u->ufo_u.inn.max_w = 0; - - // escape sequences we use - // (as reported by the terminfo database we bundled) - // - { - uty_u->ufo_u.out.clear_y = (const c3_y*)"\033[H\033[2J"; - uty_u->ufo_u.out.el_y = (const c3_y*)"\033[K"; - // uty_u->ufo_u.out.el1_y = (const c3_y*)"\033[1K"; - uty_u->ufo_u.out.ed_y = (const c3_y*)"\033[J"; - uty_u->ufo_u.out.bel_y = (const c3_y*)"\x7"; - uty_u->ufo_u.out.cub1_y = (const c3_y*)"\x8"; - uty_u->ufo_u.out.cuf1_y = (const c3_y*)"\033[C"; - uty_u->ufo_u.out.cuu1_y = (const c3_y*)"\033[A"; - uty_u->ufo_u.out.cud1_y = (const c3_y*)"\xa"; - // uty_u->ufo_u.out.cub_y = (const c3_y*)"\033[%p1%dD"; - // uty_u->ufo_u.out.cuf_y = (const c3_y*)"\033[%p1%dC"; - } - - // NB: terminfo reports the wrong sequence for arrow keys on xterms. - // - { - uty_u->ufo_u.inn.kcuu1_y = (const c3_y*)"\033[A"; // terminfo reports "\033OA" - uty_u->ufo_u.inn.kcud1_y = (const c3_y*)"\033[B"; // terminfo reports "\033OB" - uty_u->ufo_u.inn.kcuf1_y = (const c3_y*)"\033[C"; // terminfo reports "\033OC" - uty_u->ufo_u.inn.kcub1_y = (const c3_y*)"\033[D"; // terminfo reports "\033OD" - } - - uty_u->ufo_u.inn.max_w = 0; - if ( (len_w = strlen((c3_c*)uty_u->ufo_u.inn.kcuu1_y)) > - uty_u->ufo_u.inn.max_w ) - { - uty_u->ufo_u.inn.max_w = len_w; - } - if ( (len_w = strlen((c3_c*)uty_u->ufo_u.inn.kcud1_y)) > - uty_u->ufo_u.inn.max_w ) - { - uty_u->ufo_u.inn.max_w = len_w; - } - if ( (len_w = strlen((c3_c*)uty_u->ufo_u.inn.kcub1_y)) > - uty_u->ufo_u.inn.max_w ) - { - uty_u->ufo_u.inn.max_w = len_w; - } - if ( (len_w = strlen((c3_c*)uty_u->ufo_u.inn.kcuf1_y)) > - uty_u->ufo_u.inn.max_w ) - { - uty_u->ufo_u.inn.max_w = len_w; - } + // configure input escape sequences + // + // NB: terminfo reports the wrong sequence for arrow keys on xterms. + // + { + uty_u->ufo_u.inn.kcuu1_u = TERM_LIT_BUF("\033[A"); // terminfo reports "\033OA" + uty_u->ufo_u.inn.kcud1_u = TERM_LIT_BUF("\033[B"); // terminfo reports "\033OB" + uty_u->ufo_u.inn.kcuf1_u = TERM_LIT_BUF("\033[C"); // terminfo reports "\033OC" + uty_u->ufo_u.inn.kcub1_u = TERM_LIT_BUF("\033[D"); // terminfo reports "\033OD" } // Load old terminal state to restore. @@ -331,20 +309,6 @@ _term_tcsetattr(c3_i fil_i, c3_i act_i, const struct termios* tms_u) return ret_i; } -/* _term_it_buf(): create a data buffer. -*/ -static u3_ubuf* -_term_it_buf(c3_w len_w, const c3_y* hun_y) -{ - u3_ubuf* buf_u = c3_malloc(len_w + sizeof(*buf_u)); - - buf_u->len_w = len_w; - memcpy(buf_u->hun_y, hun_y, len_w); - - buf_u->nex_u = 0; - return buf_u; -} - /* _term_write_cb(): general write callback. */ static void @@ -358,71 +322,71 @@ _term_write_cb(uv_write_t* wri_u, c3_i sas_i) c3_free(wri_u); } -/* _term_it_write_buf(): write buffer uv style. +/* _term_it_write(): write libuv buffer, freeing pointer. */ static void -_term_it_write_buf(u3_utty* uty_u, uv_buf_t buf_u) +_term_it_write(u3_utty* uty_u, + uv_buf_t* buf_u, + void* ptr_v) { - uv_write_t* wri_u = c3_malloc(sizeof(uv_write_t)); - wri_u->data = buf_u.base; + uv_write_t* wri_u = c3_malloc(sizeof(*wri_u)); + c3_w ret_w; - c3_w ret_w; - if ( 0 != (ret_w = uv_write(wri_u, - (uv_stream_t*)&(uty_u->pop_u), - &buf_u, 1, - _term_write_cb)) ) + wri_u->data = ptr_v; + + if ( (ret_w = uv_write(wri_u, + (uv_stream_t*)&(uty_u->pop_u), + buf_u, 1, + _term_write_cb)) ) { u3l_log("term: write: %s\n", uv_strerror(ret_w)); } } -/* _term_it_write_old(): write buffer, transferring pointer. +/* _term_it_dump(): write static vector. */ static void -_term_it_write_old(u3_utty* uty_u, - u3_ubuf* old_u) +_term_it_dump(u3_utty* uty_u, + c3_w len_w, + const c3_y* hun_y) { - uv_buf_t buf_u; - - // XX extra copy here due to old code. Use hbod as base directly. - // - { - c3_y* buf_y = c3_malloc(old_u->len_w); - - memcpy(buf_y, old_u->hun_y, old_u->len_w); - buf_u = uv_buf_init((c3_c*)buf_y, old_u->len_w); - - c3_free(old_u); - } - _term_it_write_buf(uty_u, buf_u); + uv_buf_t buf_u = uv_buf_init((c3_c*)hun_y, len_w); + _term_it_write(uty_u, &buf_u, 0); } -/* _term_it_write_bytes(): write bytes, retaining pointer. +/* _term_it_dump_buf(): write static buffer. */ static void -_term_it_write_bytes(u3_utty* uty_u, - c3_w len_w, - const c3_y* hun_y) +_term_it_dump_buf(u3_utty* uty_u, + uv_buf_t* buf_u) { - _term_it_write_old(uty_u, _term_it_buf(len_w, hun_y)); + _term_it_write(uty_u, buf_u, 0); } -/* _term_it_write_txt(): write null-terminated string, retaining pointer. +/* _term_it_send(): write dynamic vector, freeing pointer. */ static void -_term_it_write_txt(u3_utty* uty_u, - const c3_y* hun_y) +_term_it_send(u3_utty* uty_u, + c3_w len_w, + const c3_y* hun_y) { - _term_it_write_bytes(uty_u, strlen((const c3_c*)hun_y), hun_y); + uv_buf_t buf_u = uv_buf_init((c3_c*)hun_y, len_w); + _term_it_write(uty_u, &buf_u, (void*)hun_y); } -/* _term_it_write_str(): write null-terminated string, retaining pointer. +/* _term_it_send_cord(): write a cord. */ static void -_term_it_write_str(u3_utty* uty_u, - const c3_c* str_c) +_term_it_send_cord(u3_utty* uty_u, + u3_atom txt) { - _term_it_write_txt(uty_u, (const c3_y*) str_c); + c3_w len_w = u3r_met(3, txt); + c3_y* hun_y = c3_malloc(len_w); + u3r_bytes(0, len_w, hun_y, txt); + + _term_it_send(uty_u, len_w, hun_y); + + u3z(txt); } /* _term_it_show_wide(): show wide text, retaining. @@ -430,15 +394,19 @@ _term_it_write_str(u3_utty* uty_u, static void _term_it_show_wide(u3_utty* uty_u, c3_w len_w, c3_w* txt_w) { - u3_noun wad = u3i_words(len_w, txt_w); - u3_noun txt = u3do("tuft", wad); - c3_c* txt_c = u3r_string(txt); + u3_noun txt = u3do("tuft", u3i_words(len_w, txt_w)); - _term_it_write_str(uty_u, txt_c); - c3_free(txt_c); - u3z(txt); + { + c3_w byt_w = u3r_met(3, txt); + c3_y* byt_y = c3_malloc(byt_w); + u3r_bytes(0, byt_w, byt_y, txt); + + _term_it_send(uty_u, byt_w, byt_y); + } uty_u->tat_u.mir.cus_w += len_w; + + u3z(txt); } /* _term_it_show_clear(): clear to the beginning of the current line. @@ -447,8 +415,8 @@ static void _term_it_show_clear(u3_utty* uty_u) { if ( uty_u->tat_u.siz.col_l ) { - _term_it_write_str(uty_u, "\r"); - _term_it_write_txt(uty_u, uty_u->ufo_u.out.el_y); + _term_it_dump(uty_u, TERM_LIT("\r")); + _term_it_dump_buf(uty_u, &uty_u->ufo_u.out.el_u); uty_u->tat_u.mir.len_w = 0; uty_u->tat_u.mir.cus_w = 0; @@ -460,7 +428,7 @@ _term_it_show_clear(u3_utty* uty_u) static void _term_it_show_blank(u3_utty* uty_u) { - _term_it_write_txt(uty_u, uty_u->ufo_u.out.clear_y); + _term_it_dump_buf(uty_u, &uty_u->ufo_u.out.clear_u); } /* _term_it_show_cursor(): set current line, transferring pointer. @@ -476,14 +444,14 @@ _term_it_show_cursor(u3_utty* uty_u, c3_w cur_w) c3_w dif_w = (uty_u->tat_u.mir.cus_w - cur_w); while ( dif_w-- ) { - _term_it_write_txt(uty_u, uty_u->ufo_u.out.cub1_y); + _term_it_dump_buf(uty_u, &uty_u->ufo_u.out.cub1_u); } } else if ( cur_w > uty_u->tat_u.mir.cus_w ) { c3_w dif_w = (cur_w - uty_u->tat_u.mir.cus_w); while ( dif_w-- ) { - _term_it_write_txt(uty_u, uty_u->ufo_u.out.cuf1_y); + _term_it_dump_buf(uty_u, &uty_u->ufo_u.out.cuf1_u); } } uty_u->tat_u.mir.cus_w = cur_w; @@ -526,10 +494,12 @@ static void _term_it_show_more(u3_utty* uty_u) { if ( c3y == u3_Host.ops_u.tem ) { - _term_it_write_str(uty_u, "\n"); - } else { - _term_it_write_str(uty_u, "\r\n"); + _term_it_dump(uty_u, TERM_LIT("\n")); } + else { + _term_it_dump(uty_u, TERM_LIT("\r\n")); + } + uty_u->tat_u.mir.cus_w = 0; } @@ -658,7 +628,7 @@ _term_io_suck_char(u3_utty* uty_u, c3_y cay_y) if ( c3y == tat_u->esc.bra ) { switch ( cay_y ) { default: { - _term_it_write_txt(uty_u, uty_u->ufo_u.out.bel_y); + _term_it_dump_buf(uty_u, &uty_u->ufo_u.out.bel_u); break; } case 'A': _term_io_belt(uty_u, u3nc(c3__aro, 'u')); break; @@ -687,7 +657,7 @@ _term_io_suck_char(u3_utty* uty_u, c3_y cay_y) else { tat_u->esc.ape = c3n; - _term_it_write_txt(uty_u, uty_u->ufo_u.out.bel_y); + _term_it_dump_buf(uty_u, &uty_u->ufo_u.out.bel_u); } } } @@ -712,7 +682,7 @@ _term_io_suck_char(u3_utty* uty_u, c3_y cay_y) _term_io_belt(uty_u, u3nt(c3__txt, cay_y, u3_nul)); } else if ( 0 == cay_y ) { - _term_it_write_txt(uty_u, uty_u->ufo_u.out.bel_y); + _term_it_dump_buf(uty_u, &uty_u->ufo_u.out.bel_u); } else if ( 8 == cay_y || 127 == cay_y ) { _term_io_belt(uty_u, u3nc(c3__bac, u3_nul)); @@ -821,8 +791,8 @@ _term_spin_dump(u3_utty* uty_u, static void _term_spin_move_left(u3_utty* uty_u) { - const c3_c* str_c = (const c3_c*)uty_u->ufo_u.out.cub1_y; - _term_spin_dump(uty_u, strlen(str_c), str_c); + uv_buf_t* buf_u = &uty_u->ufo_u.out.cub1_u; + _term_spin_dump(uty_u, buf_u->len, buf_u->base); } /* _term_spin_timer_cb(): render spinner @@ -1234,7 +1204,7 @@ _term_ef_blit(u3_utty* uty_u, case c3__bel: { if ( c3n == u3_Host.ops_u.tem ) { - _term_it_write_txt(uty_u, uty_u->ufo_u.out.bel_y); + _term_it_dump_buf(uty_u, &uty_u->ufo_u.out.bel_u); } } break; @@ -1297,23 +1267,24 @@ _term_ef_blit(u3_utty* uty_u, } break; case c3__url: { - if ( c3n == u3ud(u3t(blt)) ) { - break; - } else { - c3_c* txt_c = u3r_string(u3t(blt)); + u3_noun txt = u3t(blt); + // XX check u3_Host.ops_u.tem ? + // XX this looks to be broken, + // multiple calls to _show_clear will discard the mirror state + // + if ( c3y == u3a_is_atom(txt) ) { _term_it_show_clear(uty_u); - _term_it_write_str(uty_u, txt_c); - c3_free(txt_c); + + _term_it_send_cord(uty_u, u3k(txt)); _term_it_show_more(uty_u); _term_it_refresh_line(uty_u); } - } + } break; } - u3z(blt); - return; + u3z(blt); } /* u3_term_io_hija(): hijack console for fprintf, returning FILE*. @@ -1349,8 +1320,10 @@ u3_term_io_hija(void) c3_assert(!"hija-fcntl"); } _write(uty_u->fid_i, "\r", 1); - _write(uty_u->fid_i, uty_u->ufo_u.out.el_y, - strlen((c3_c*) uty_u->ufo_u.out.el_y)); + { + uv_buf_t* buf_u = &uty_u->ufo_u.out.el_u; + _write(uty_u->fid_i, buf_u->base, buf_u->len); + } } return stdout; } From 41238a55494cd8ab0c4d90a6038d56c1b5440a35 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 10 Sep 2020 18:35:29 -0700 Subject: [PATCH 306/933] vere: further refactors the terminal spinner --- pkg/urbit/vere/io/term.c | 117 ++++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 57 deletions(-) diff --git a/pkg/urbit/vere/io/term.c b/pkg/urbit/vere/io/term.c index 6120922ab8..a96923660a 100644 --- a/pkg/urbit/vere/io/term.c +++ b/pkg/urbit/vere/io/term.c @@ -770,37 +770,11 @@ _term_read_cb(uv_stream_t* tcp_u, c3_free(buf_u->base); } -/* _term_spin_dump(): write static vector to terminal FD. +/* _term_spin_step(): advance spinner state and (re-)render. */ static void -_term_spin_dump(u3_utty* uty_u, - c3_w len_w, - const c3_c* str_c) +_term_spin_step(u3_utty* uty_u) { - c3_i fid_i; - - if ( !uv_fileno((uv_handle_t*)&uty_u->pop_u, &fid_i) - && (len_w != write(fid_i, str_c, len_w)) ) - { - // ignore, we just tryin - } -} - -/* _term_spin_move_left(): move the cursor left -*/ -static void -_term_spin_move_left(u3_utty* uty_u) -{ - uv_buf_t* buf_u = &uty_u->ufo_u.out.cub1_u; - _term_spin_dump(uty_u, buf_u->len, buf_u->base); -} - -/* _term_spin_timer_cb(): render spinner -*/ -static void -_term_spin_timer_cb(uv_timer_t* tim_u) -{ - u3_utty* uty_u = tim_u->data; u3_utat* tat_u = &uty_u->tat_u; c3_w bac_w; @@ -824,58 +798,87 @@ _term_spin_timer_cb(uv_timer_t* tim_u) c3_c* cur_c = buf_c; c3_w sol_w = 1; // spinner length (utf-32) + // set spinner char + // *cur_c++ = daz_c[lag_d % (sizeof(daz_c) - 1)]; + // if we have a spinner, add it between brackets + // if ( tat_u->sun_u.why_c[0] ) { - { - const c3_c dal_c[] = "\xc2\xab"; - *cur_c++ = dal_c[0]; - *cur_c++ = dal_c[1]; - sol_w++; // length of dal_c (utf-32) - } + *cur_c++ = '\xc2'; + *cur_c++ = '\xab'; + sol_w++; { c3_c* why_c = tat_u->sun_u.why_c; *cur_c++ = *why_c++; *cur_c++ = *why_c++; *cur_c++ = *why_c++; - *cur_c++ = *why_c++; - sol_w += 4; // XX assumed utf-8 + *cur_c++ = *why_c; + // XX assumes one glyph per char + // + sol_w += 4; } - { - const c3_c dar_c[] = "\xc2\xbb"; - *cur_c++ = dar_c[0]; - *cur_c++ = dar_c[1]; - sol_w++; // length of dar_c (utf-32) - } + *cur_c++ = '\xc2'; + *cur_c++ = '\xbb'; + sol_w++; } *cur_c = '\0'; - // One-time cursor backoff. + // write spinner, adjusting cursor as needed // - if ( c3n == tat_u->sun_u.diz_o ) { - c3_w i_w; - for ( i_w = bac_w; i_w < sol_w; i_w++ ) { - _term_spin_move_left(uty_u); + // NB: we simply bail out if anything goes wrong + // + { + uv_buf_t lef_u = uty_u->ufo_u.out.cub1_u; + c3_i fid_i; + + if ( uv_fileno((uv_handle_t*)&uty_u->pop_u, &fid_i) ) { + return; } - tat_u->sun_u.diz_o = c3y; - } + // One-time cursor backoff. + // + if ( c3n == tat_u->sun_u.diz_o ) { + c3_w i_w; - { - c3_w len_w = cur_c - buf_c; - _term_spin_dump(uty_u, len_w, buf_c); - } + for ( i_w = bac_w; i_w < sol_w; i_w++ ) { + if ( lef_u.len != write(fid_i, lef_u.base, lef_u.len) ) { + return; + } + } - // Cursor stays on spinner. - // - while ( sol_w-- ) { - _term_spin_move_left(uty_u); + tat_u->sun_u.diz_o = c3y; + } + + { + c3_w len_w = cur_c - buf_c; + if ( len_w != write(fid_i, buf_c, len_w) ) { + return; + } + } + + // Cursor stays on spinner. + // + while ( sol_w-- ) { + if ( lef_u.len != write(fid_i, lef_u.base, lef_u.len) ) { + return; + } + } } } +/* _term_spin_timer_cb(): render spinner +*/ +static void +_term_spin_timer_cb(uv_timer_t* tim_u) +{ + u3_utty* uty_u = tim_u->data; + _term_spin_step(uty_u); +} + #define _SPIN_COOL_US 500UL // spinner activation delay when cool #define _SPIN_WARM_US 50UL // spinner activation delay when warm #define _SPIN_RATE_US 250UL // spinner rate (ms/frame) From db54ac108485ad6e774c7ac7ad6ca2ae396ec447 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 10 Sep 2020 22:43:37 -0700 Subject: [PATCH 307/933] vere: zero-initialize terminal mirror style offset --- pkg/urbit/vere/io/term.c | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/urbit/vere/io/term.c b/pkg/urbit/vere/io/term.c index a96923660a..232188d7d8 100644 --- a/pkg/urbit/vere/io/term.c +++ b/pkg/urbit/vere/io/term.c @@ -209,6 +209,7 @@ u3_term_log_init(void) { uty_u->tat_u.mir.lin_w = 0; uty_u->tat_u.mir.len_w = 0; + uty_u->tat_u.mir.sap_w = 0; uty_u->tat_u.mir.cus_w = 0; uty_u->tat_u.esc.ape = c3n; From f3299796e6952680b96d05cd73ab7f32c6e4e8e3 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 10 Sep 2020 22:44:07 -0700 Subject: [PATCH 308/933] vere: check for null before closing terminal pipe --- pkg/urbit/vere/io/term.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/urbit/vere/io/term.c b/pkg/urbit/vere/io/term.c index 232188d7d8..7abadfbb70 100644 --- a/pkg/urbit/vere/io/term.c +++ b/pkg/urbit/vere/io/term.c @@ -286,7 +286,9 @@ u3_term_log_exit(void) } } - uv_close((uv_handle_t*)&u3_Host.uty_u->pop_u, 0); + if ( u3_Host.uty_u ) { + uv_close((uv_handle_t*)&u3_Host.uty_u->pop_u, 0); + } } /* _term_tcsetattr(): tcsetattr w/retry on EINTR. From 1e5e4e5001f448eb589cef21557d4d3bc677eb16 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 10 Sep 2020 22:44:35 -0700 Subject: [PATCH 309/933] vere: refactors _term_it_show_cursor() --- pkg/urbit/vere/io/term.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/urbit/vere/io/term.c b/pkg/urbit/vere/io/term.c index 7abadfbb70..42b520fd8f 100644 --- a/pkg/urbit/vere/io/term.c +++ b/pkg/urbit/vere/io/term.c @@ -439,24 +439,28 @@ _term_it_show_blank(u3_utty* uty_u) static void _term_it_show_cursor(u3_utty* uty_u, c3_w cur_w) { + c3_w cus_w = uty_u->tat_u.mir.cus_w; + c3_w dif_w; + //NOTE assumes all styled text precedes the cursor. drum enforces this. // - cur_w = cur_w + uty_u->tat_u.mir.sap_w; + cur_w += uty_u->tat_u.mir.sap_w; - if ( cur_w < uty_u->tat_u.mir.cus_w ) { - c3_w dif_w = (uty_u->tat_u.mir.cus_w - cur_w); + if ( cur_w < cus_w ) { + dif_w = cus_w - cur_w; while ( dif_w-- ) { _term_it_dump_buf(uty_u, &uty_u->ufo_u.out.cub1_u); } } - else if ( cur_w > uty_u->tat_u.mir.cus_w ) { - c3_w dif_w = (cur_w - uty_u->tat_u.mir.cus_w); + else if ( cur_w > cus_w ) { + dif_w = cur_w - cus_w; while ( dif_w-- ) { _term_it_dump_buf(uty_u, &uty_u->ufo_u.out.cuf1_u); } } + uty_u->tat_u.mir.cus_w = cur_w; } From ccc77d627dac1dbb97536be78827d3d7285346bb Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 10 Sep 2020 22:44:48 -0700 Subject: [PATCH 310/933] vere: refactors %lin blit handling in term.c --- pkg/urbit/vere/io/term.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/pkg/urbit/vere/io/term.c b/pkg/urbit/vere/io/term.c index 42b520fd8f..caa97a50f8 100644 --- a/pkg/urbit/vere/io/term.c +++ b/pkg/urbit/vere/io/term.c @@ -1081,7 +1081,7 @@ _term_it_put_deco(c3_w* lin_w, */ static void _term_it_show_stub(u3_utty* uty_u, - u3_noun tub) + u3_noun tub) { c3_w tuc_w = u3qb_lent(tub); @@ -1203,6 +1203,28 @@ _term_it_show_stub(u3_utty* uty_u, u3z(tub); } +/* _term_it_show_tour(): send utf32 to terminal. +*/ +static void +_term_it_show_tour(u3_utty* uty_u, + u3_noun lin) +{ + c3_w len_w = u3qb_lent(lin); + c3_w* lin_w = c3_malloc( sizeof(c3_w) * len_w ); + + { + c3_w i_w; + + for ( i_w = 0; u3_nul != lin; i_w++, lin = u3t(lin) ) { + lin_w[i_w] = u3r_word(0, u3h(lin)); + } + } + + _term_it_show_line(uty_u, lin_w, len_w, 0); + + u3z(lin); +} + /* _term_ef_blit(): send blit to terminal. */ static void @@ -1239,24 +1261,10 @@ _term_ef_blit(u3_utty* uty_u, } break; case c3__lin: { - u3_noun lin = u3t(blt); - c3_w len_w = u3kb_lent(u3k(lin)); - c3_w* lin_w = c3_malloc( sizeof(c3_w) * len_w ); - - { - c3_w i_w; - - for ( i_w = 0; u3_nul != lin; i_w++, lin = u3t(lin) ) { - lin_w[i_w] = u3r_word(0, u3h(lin)); - } - } - if ( c3n == u3_Host.ops_u.tem ) { _term_it_show_clear(uty_u); - _term_it_show_line(uty_u, lin_w, len_w, 0); - } else { - _term_it_show_line(uty_u, lin_w, len_w, 0); } + _term_it_show_tour(uty_u, u3k(u3t(blt))); } break; case c3__mor: { From 27ebfcfbdf10336ca5b5256ec361b6477dbb9d21 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 10 Sep 2020 23:29:56 -0700 Subject: [PATCH 311/933] vere: refactors terminal jam-file blits --- pkg/urbit/vere/io/term.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/urbit/vere/io/term.c b/pkg/urbit/vere/io/term.c index caa97a50f8..7779bb8d38 100644 --- a/pkg/urbit/vere/io/term.c +++ b/pkg/urbit/vere/io/term.c @@ -1272,16 +1272,17 @@ _term_ef_blit(u3_utty* uty_u, } break; case c3__sav: { - _term_it_save(u3k(u3h(u3t(blt))), u3k(u3t(u3t(blt)))); + u3_noun pax, dat; + u3x_cell(u3t(blt), &pax, &dat); + + _term_it_save(u3k(pax), u3k(dat)); } break; case c3__sag: { - u3_noun pib = u3k(u3t(u3t(blt))); - u3_noun jam; + u3_noun pax, dat; + u3x_cell(u3t(blt), &pax, &dat); - jam = u3ke_jam(pib); - - _term_it_save(u3k(u3h(u3t(blt))), jam); + _term_it_save(u3k(pax), u3qe_jam(dat)); } break; case c3__url: { From 49210f49f37d97bc83cbd6a4143f28ee8ccafbf3 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 11 Sep 2020 00:06:12 -0700 Subject: [PATCH 312/933] vere: refactors terminal rendering to limit utf-32->utf-8 conversions --- pkg/urbit/include/vere/vere.h | 7 +-- pkg/urbit/vere/io/term.c | 87 +++++++++++++++++++---------------- 2 files changed, 51 insertions(+), 43 deletions(-) diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index 3f6d9a04ae..a8875ee952 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -145,9 +145,10 @@ } siz; struct { - c3_w* lin_w; // current line (utf32) - c3_w len_w; // length of current line - c3_w sap_w; // escape chars in current line + c3_y* lin_y; // current line (utf8) + c3_w byt_w; // utf8 line-length + c3_w wor_w; // utf32 line-length + c3_w sap_w; // escape chars in line c3_w cus_w; // cursor position } mir; diff --git a/pkg/urbit/vere/io/term.c b/pkg/urbit/vere/io/term.c index 7779bb8d38..ef49f3eda5 100644 --- a/pkg/urbit/vere/io/term.c +++ b/pkg/urbit/vere/io/term.c @@ -207,8 +207,9 @@ u3_term_log_init(void) // Initialize mirror and accumulator state. // { - uty_u->tat_u.mir.lin_w = 0; - uty_u->tat_u.mir.len_w = 0; + uty_u->tat_u.mir.lin_y = 0; + uty_u->tat_u.mir.byt_w = 0; + uty_u->tat_u.mir.wor_w = 0; uty_u->tat_u.mir.sap_w = 0; uty_u->tat_u.mir.cus_w = 0; @@ -392,26 +393,6 @@ _term_it_send_cord(u3_utty* uty_u, u3z(txt); } -/* _term_it_show_wide(): show wide text, retaining. -*/ -static void -_term_it_show_wide(u3_utty* uty_u, c3_w len_w, c3_w* txt_w) -{ - u3_noun txt = u3do("tuft", u3i_words(len_w, txt_w)); - - { - c3_w byt_w = u3r_met(3, txt); - c3_y* byt_y = c3_malloc(byt_w); - u3r_bytes(0, byt_w, byt_y, txt); - - _term_it_send(uty_u, byt_w, byt_y); - } - - uty_u->tat_u.mir.cus_w += len_w; - - u3z(txt); -} - /* _term_it_show_clear(): clear to the beginning of the current line. */ static void @@ -421,7 +402,7 @@ _term_it_show_clear(u3_utty* uty_u) _term_it_dump(uty_u, TERM_LIT("\r")); _term_it_dump_buf(uty_u, &uty_u->ufo_u.out.el_u); - uty_u->tat_u.mir.len_w = 0; + uty_u->tat_u.mir.wor_w = 0; uty_u->tat_u.mir.cus_w = 0; } } @@ -464,21 +445,20 @@ _term_it_show_cursor(u3_utty* uty_u, c3_w cur_w) uty_u->tat_u.mir.cus_w = cur_w; } -/* _term_it_show_line(): set current line +/* _term_it_show_line(): render current line. */ static void -_term_it_show_line(u3_utty* uty_u, c3_w* lin_w, c3_w len_w, c3_w sap_w) +_term_it_show_line(u3_utty* uty_u, c3_w wor_w, c3_w sap_w) { - _term_it_show_wide(uty_u, len_w, lin_w); + u3_utat* tat_u = &uty_u->tat_u; - if ( lin_w != uty_u->tat_u.mir.lin_w ) { - if ( uty_u->tat_u.mir.lin_w ) { - c3_free(uty_u->tat_u.mir.lin_w); - } - uty_u->tat_u.mir.lin_w = lin_w; - } - uty_u->tat_u.mir.len_w = len_w; - uty_u->tat_u.mir.sap_w = sap_w; + _term_it_dump(uty_u, tat_u->mir.byt_w, tat_u->mir.lin_y); + + // XX refactor to avoid updating state + // + tat_u->mir.cus_w += wor_w; + tat_u->mir.wor_w = wor_w; + tat_u->mir.sap_w = sap_w; } /* _term_it_refresh_line(): refresh current line. @@ -486,15 +466,42 @@ _term_it_show_line(u3_utty* uty_u, c3_w* lin_w, c3_w len_w, c3_w sap_w) static void _term_it_refresh_line(u3_utty* uty_u) { - c3_w len_w = uty_u->tat_u.mir.len_w; - c3_w sap_w = uty_u->tat_u.mir.sap_w; - c3_w cus_w = uty_u->tat_u.mir.cus_w; + u3_utat* tat_u = &uty_u->tat_u; + c3_w wor_w = tat_u->mir.wor_w; + c3_w sap_w = tat_u->mir.sap_w; + c3_w cus_w = tat_u->mir.cus_w; _term_it_show_clear(uty_u); - _term_it_show_line(uty_u, uty_u->tat_u.mir.lin_w, len_w, sap_w); + _term_it_show_line(uty_u, wor_w, sap_w); _term_it_show_cursor(uty_u, cus_w); } +/* _term_it_set_line(): set current line. +*/ +static void +_term_it_set_line(u3_utty* uty_u, + c3_w* lin_w, + c3_w wor_w, + c3_w sap_w) +{ + u3_utat* tat_u = &uty_u->tat_u; + u3_noun txt = u3do("tuft", u3i_words(wor_w, lin_w)); + c3_w byt_w = u3r_met(3, txt); + c3_y* hun_y = (c3_y*)lin_w; + + u3r_bytes(0, byt_w, hun_y, txt); + + c3_free(tat_u->mir.lin_y); + tat_u->mir.lin_y = hun_y; + tat_u->mir.byt_w = byt_w; + tat_u->mir.wor_w = wor_w; + tat_u->mir.sap_w = sap_w; + + _term_it_show_line(uty_u, wor_w, sap_w); + + u3z(txt); +} + /* _term_it_show_more(): new current line. */ static void @@ -1198,7 +1205,7 @@ _term_it_show_stub(u3_utty* uty_u, } } - _term_it_show_line(uty_u, lin_w, i_w, sap_w); + _term_it_set_line(uty_u, lin_w, i_w, sap_w); u3z(tub); } @@ -1220,7 +1227,7 @@ _term_it_show_tour(u3_utty* uty_u, } } - _term_it_show_line(uty_u, lin_w, len_w, 0); + _term_it_set_line(uty_u, lin_w, len_w, 0); u3z(lin); } From 4eaffc87b294742ba802d47b3db899fb73301dd0 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 11 Sep 2020 00:22:47 -0700 Subject: [PATCH 313/933] vere: directly implements utf-32 to utf-8 conversion --- pkg/urbit/vere/io/term.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/pkg/urbit/vere/io/term.c b/pkg/urbit/vere/io/term.c index ef49f3eda5..f54b68ab00 100644 --- a/pkg/urbit/vere/io/term.c +++ b/pkg/urbit/vere/io/term.c @@ -485,11 +485,39 @@ _term_it_set_line(u3_utty* uty_u, c3_w sap_w) { u3_utat* tat_u = &uty_u->tat_u; - u3_noun txt = u3do("tuft", u3i_words(wor_w, lin_w)); - c3_w byt_w = u3r_met(3, txt); c3_y* hun_y = (c3_y*)lin_w; + c3_w byt_w = 0; - u3r_bytes(0, byt_w, hun_y, txt); + // convert lin_w in-place from utf-32 to utf-8 + // + // (this is just a hand-translation of +tuft) + // + { + c3_w car_w, i_w; + + for ( i_w = 0; i_w < wor_w; i_w++ ) { + car_w = lin_w[i_w]; + + if ( 0x7f >= car_w ) { + hun_y[byt_w++] = car_w; + } + else if ( 0x7ff >= car_w ) { + hun_y[byt_w++] = 0xc0 ^ ((car_w >> 6) & 0x1f); + hun_y[byt_w++] = 0x80 ^ (car_w & 0x3f); + } + else if ( 0xffff >= car_w ) { + hun_y[byt_w++] = 0xe0 ^ ((car_w >> 12) & 0xf); + hun_y[byt_w++] = 0x80 ^ ((car_w >> 6) & 0x3f); + hun_y[byt_w++] = 0x80 ^ (car_w & 0x3f); + } + else { + hun_y[byt_w++] = 0xf0 ^ ((car_w >> 18) & 0x7); + hun_y[byt_w++] = 0x80 ^ ((car_w >> 12) & 0x3f); + hun_y[byt_w++] = 0x80 ^ ((car_w >> 6) & 0x3f); + hun_y[byt_w++] = 0x80 ^ (car_w & 0x3f); + } + } + } c3_free(tat_u->mir.lin_y); tat_u->mir.lin_y = hun_y; @@ -498,8 +526,6 @@ _term_it_set_line(u3_utty* uty_u, tat_u->mir.sap_w = sap_w; _term_it_show_line(uty_u, wor_w, sap_w); - - u3z(txt); } /* _term_it_show_more(): new current line. From 00a691dfe26819053a38038c8fd147b12307efc0 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 11 Sep 2020 00:29:58 -0700 Subject: [PATCH 314/933] vere: comments-out unused ansi input sequences --- pkg/urbit/include/vere/vere.h | 14 ++++++++------ pkg/urbit/vere/io/term.c | 14 +++++++------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index a8875ee952..bf1a5cf976 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -183,12 +183,14 @@ /* u2_utfo: unix terminfo strings. */ typedef struct { - struct { - uv_buf_t kcuu1_u; // key_up - uv_buf_t kcud1_u; // key_down - uv_buf_t kcub1_u; // key_back - uv_buf_t kcuf1_u; // key_forward - } inn; + // disabled, currently unused + // + // struct { + // uv_buf_t kcuu1_u; // key_up + // uv_buf_t kcud1_u; // key_down + // uv_buf_t kcub1_u; // key_back + // uv_buf_t kcuf1_u; // key_forward + // } inn; struct { uv_buf_t clear_u; // clear_screen uv_buf_t el_u; // clr_bol clear to beginning diff --git a/pkg/urbit/vere/io/term.c b/pkg/urbit/vere/io/term.c index f54b68ab00..e948a2b847 100644 --- a/pkg/urbit/vere/io/term.c +++ b/pkg/urbit/vere/io/term.c @@ -169,13 +169,13 @@ u3_term_log_init(void) // configure input escape sequences // // NB: terminfo reports the wrong sequence for arrow keys on xterms. - // - { - uty_u->ufo_u.inn.kcuu1_u = TERM_LIT_BUF("\033[A"); // terminfo reports "\033OA" - uty_u->ufo_u.inn.kcud1_u = TERM_LIT_BUF("\033[B"); // terminfo reports "\033OB" - uty_u->ufo_u.inn.kcuf1_u = TERM_LIT_BUF("\033[C"); // terminfo reports "\033OC" - uty_u->ufo_u.inn.kcub1_u = TERM_LIT_BUF("\033[D"); // terminfo reports "\033OD" - } + // disabled, currently unused + // { + // uty_u->ufo_u.inn.kcuu1_u = TERM_LIT_BUF("\033[A"); // terminfo reports "\033OA" + // uty_u->ufo_u.inn.kcud1_u = TERM_LIT_BUF("\033[B"); // terminfo reports "\033OB" + // uty_u->ufo_u.inn.kcuf1_u = TERM_LIT_BUF("\033[C"); // terminfo reports "\033OC" + // uty_u->ufo_u.inn.kcub1_u = TERM_LIT_BUF("\033[D"); // terminfo reports "\033OD" + // } // Load old terminal state to restore. // From 67dc15efca5f29e06f3d524744e9f3a2c167a123 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 10 Sep 2020 16:21:33 -0700 Subject: [PATCH 315/933] vere: avoids allocations by attempting synchronous terminal writes --- pkg/urbit/vere/io/term.c | 55 ++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/pkg/urbit/vere/io/term.c b/pkg/urbit/vere/io/term.c index e948a2b847..a3cfedd2bd 100644 --- a/pkg/urbit/vere/io/term.c +++ b/pkg/urbit/vere/io/term.c @@ -313,11 +313,13 @@ _term_tcsetattr(c3_i fil_i, c3_i act_i, const struct termios* tms_u) return ret_i; } -/* _term_write_cb(): general write callback. +/* _term_it_write_cb(): general write callback. */ static void -_term_write_cb(uv_write_t* wri_u, c3_i sas_i) +_term_it_write_cb(uv_write_t* wri_u, c3_i sas_i) { + // write failure is logged, but otherwise ignored. + // if ( 0 != sas_i ) { u3l_log("term: write: %s\n", uv_strerror(sas_i)); } @@ -333,17 +335,48 @@ _term_it_write(u3_utty* uty_u, uv_buf_t* buf_u, void* ptr_v) { - uv_write_t* wri_u = c3_malloc(sizeof(*wri_u)); - c3_w ret_w; + // work off a local copy of the buffer, in case we need + // to manipulate the length/pointer + // + uv_buf_t fub_u = { .base = buf_u->base, .len = buf_u->len }; + uv_stream_t* han_u = (uv_stream_t*)&(uty_u->pop_u); + c3_i ret_i; - wri_u->data = ptr_v; + // try to write synchronously + // + while ( 1 ) { + ret_i = uv_try_write(han_u, &fub_u, 1); - if ( (ret_w = uv_write(wri_u, - (uv_stream_t*)&(uty_u->pop_u), - buf_u, 1, - _term_write_cb)) ) - { - u3l_log("term: write: %s\n", uv_strerror(ret_w)); + if ( (ret_i > 0) && (ret_i < fub_u.len) ) { + fub_u.len -= ret_i; + fub_u.base += ret_i; + continue; + } + else { + break; + } + } + + // cue an async write if necessary + // + if ( UV_EAGAIN == ret_i ) { + uv_write_t* wri_u = c3_malloc(sizeof(*wri_u)); + wri_u->data = ptr_v; + + // invoke callback manually on error + // + if ( (ret_i = uv_write(wri_u, han_u, &fub_u, 1, _term_it_write_cb)) ) { + _term_it_write_cb(wri_u, ret_i); + } + } + else { + // synchronous write failure is logged, but otherwise ignored + // + if ( ret_i < 0 ) { + u3l_log("term: write: %s\n", uv_strerror(ret_i)); + } + + c3_free(ptr_v); } } From faaaa9415d25d06137b0b08cab55ccac89b50a87 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 11 Sep 2020 11:44:18 -0700 Subject: [PATCH 316/933] vere: incorporate term.c review feedback, updates comments --- pkg/urbit/vere/io/term.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/pkg/urbit/vere/io/term.c b/pkg/urbit/vere/io/term.c index a3cfedd2bd..decd77ca0e 100644 --- a/pkg/urbit/vere/io/term.c +++ b/pkg/urbit/vere/io/term.c @@ -15,6 +15,9 @@ // macros for string literal args/buffers // +// since (sizeof(s) - 1) is used for vector length, parameters +// must be appropriately typed. use with care! +// #define TERM_LIT(s) sizeof(s) - 1, (const c3_y*)(s) #define TERM_LIT_BUF(s) uv_buf_init(s, sizeof(s) - 1) @@ -150,7 +153,8 @@ u3_term_log_init(void) // configure output escape sequences // - // (as reported by the terminfo database we bundled) + // our requirements are minimal here, so we bypass terminfo + // and simply use constant sequences. // { uty_u->ufo_u.out.clear_u = TERM_LIT_BUF("\033[H\033[2J"); @@ -380,6 +384,15 @@ _term_it_write(u3_utty* uty_u, } } +/* _term_it_dump_buf(): write static buffer. +*/ +static void +_term_it_dump_buf(u3_utty* uty_u, + uv_buf_t* buf_u) +{ + _term_it_write(uty_u, buf_u, 0); +} + /* _term_it_dump(): write static vector. */ static void @@ -388,16 +401,7 @@ _term_it_dump(u3_utty* uty_u, const c3_y* hun_y) { uv_buf_t buf_u = uv_buf_init((c3_c*)hun_y, len_w); - _term_it_write(uty_u, &buf_u, 0); -} - -/* _term_it_dump_buf(): write static buffer. -*/ -static void -_term_it_dump_buf(u3_utty* uty_u, - uv_buf_t* buf_u) -{ - _term_it_write(uty_u, buf_u, 0); + _term_it_dump_buf(uty_u, &buf_u); } /* _term_it_send(): write dynamic vector, freeing pointer. @@ -524,6 +528,7 @@ _term_it_set_line(u3_utty* uty_u, // convert lin_w in-place from utf-32 to utf-8 // // (this is just a hand-translation of +tuft) + // XX refactor for use here and in a jet // { c3_w car_w, i_w; @@ -741,10 +746,9 @@ _term_io_suck_char(u3_utty* uty_u, c3_y cay_y) u3_noun huv = u3i_bytes(tat_u->fut.wid_w, tat_u->fut.syb_y); u3_noun wug; - // u3l_log("muck-utf8 len %d\n", tat_u->fut.len_w); - // u3l_log("muck-utf8 %x\n", huv); + // XX implement directly here and jet + // wug = u3do("taft", huv); - // u3l_log("muck-utf32 %x\n", tat_u->fut.len_w); tat_u->fut.len_w = tat_u->fut.wid_w = 0; _term_io_belt(uty_u, u3nt(c3__txt, wug, u3_nul)); From b719a738f4e3031fc8ad8f11aaed226698d67ecb Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 11 Sep 2020 13:38:04 -0700 Subject: [PATCH 317/933] u3: refactors road stack api, limiting overflow checks --- pkg/urbit/include/noun/allocate.h | 56 ++++++++++++++--- pkg/urbit/jets/b/reel.c | 23 +++++-- pkg/urbit/jets/e/parse.c | 27 +++++--- pkg/urbit/noun/allocate.c | 100 ++++++++++++++---------------- 4 files changed, 128 insertions(+), 78 deletions(-) diff --git a/pkg/urbit/include/noun/allocate.h b/pkg/urbit/include/noun/allocate.h index ee95cc31e1..b16219aa75 100644 --- a/pkg/urbit/include/noun/allocate.h +++ b/pkg/urbit/include/noun/allocate.h @@ -168,6 +168,13 @@ u3a_flag_sand = 0x1, // bump allocation (XX not impl) }; + /* u3_pile: stack control, abstracted over road direction. + */ + typedef struct _u3a_pile { + u3_post top_p; + c3_ws mov_ws; + c3_ws off_ws; + } u3a_pile; /** Macros. Should be better commented. **/ @@ -302,6 +309,35 @@ # define u3_Loom ((c3_w *)(void *)U3_OS_LoomBase) + /** inline functions. + **/ + /** road stack. + **/ + /* u3a_peek(): examine the top of the road stack + */ + inline void* + u3a_peek(u3a_pile* pil_u) + { + return u3to(void, (u3R->cap_p + pil_u->off_ws)); + } + + /* u3a_pop(): deallocate space on the road stack + */ + inline void + u3a_pop(u3a_pile* pil_u) + { + u3R->cap_p -= pil_u->mov_ws; + } + + /* u3a_push(): allocate space on the road stack + */ + inline void* + u3a_push(u3a_pile* pil_u) + { + u3R->cap_p += pil_u->mov_ws; + return u3a_peek(pil_u); + } + /** Functions. **/ /** Allocation. @@ -328,20 +364,20 @@ void* u3a_wealloc(void* lag_v, c3_w len_w); - /* u3a_push(): allocate space on the road stack - */ - void* - u3a_push(c3_w len_w); - - /* u3a_pop(): deallocate space on the road stack + /* u3a_pile_prep(): initialize stack control. */ void - u3a_pop(c3_w len_w); + u3a_pile_prep(u3a_pile* pil_u, c3_w len_w); - /* u3a_peek(): examine the top of the road stack + /* u3a_pile_sane(): bail on invalid road stack state. */ - void* - u3a_peek(c3_w len_w); + void + u3a_pile_sane(u3a_pile* pil_u); + + /* u3a_pile_done(): assert valid upon completion. + */ + void + u3a_pile_done(u3a_pile* pil_u); /* C-style aligned allocation - *not* compatible with above. diff --git a/pkg/urbit/jets/b/reel.c b/pkg/urbit/jets/b/reel.c index dd3e2103ac..38d3c30d1b 100644 --- a/pkg/urbit/jets/b/reel.c +++ b/pkg/urbit/jets/b/reel.c @@ -10,28 +10,39 @@ u3_noun b) { u3_noun pro = u3k(u3x_at(u3x_sam_3, b)); + if ( u3_nul != a ) { + u3a_pile pil_u; u3j_site sit_u; - u3_noun* top; - u3_noun i, t = a; + u3_noun* top; + u3_noun i, t = a; c3_w len_w = 0; - // push list onto road stack + u3a_pile_prep(&pil_u, sizeof(u3_noun)); + + // push list onto road stack + // do { u3x_cell(t, &i, &t); - top = (c3_w*) u3a_push(sizeof(u3_noun)); + top = u3a_push(&pil_u); *top = i; ++len_w; } while ( u3_nul != t ); + u3a_pile_sane(&pil_u); u3j_gate_prep(&sit_u, u3k(b)); + while ( len_w-- > 0 ) { - top = u3a_peek(sizeof(u3_noun)); - u3a_pop(sizeof(u3_noun)); + top = u3a_peek(&pil_u); + u3a_pop(&pil_u); + pro = u3j_gate_slam(&sit_u, u3nc(u3k(*top), pro)); } + u3j_gate_lose(&sit_u); + u3a_pile_done(&pil_u); } + return pro; } u3_noun diff --git a/pkg/urbit/jets/e/parse.c b/pkg/urbit/jets/e/parse.c index 1ca166d138..01cc03ae59 100644 --- a/pkg/urbit/jets/e/parse.c +++ b/pkg/urbit/jets/e/parse.c @@ -930,9 +930,12 @@ // top: stack pointer // len_w: number of result pairs on the stack // - u3_noun p_wag, puq_wag, quq_wag; - u3_noun* top; - c3_w len_w = 0; + u3_noun p_wag, puq_wag, quq_wag; + u3_noun* top; + u3a_pile pil_u; + c3_w len_w = 0; + + u3a_pile_prep(&pil_u, sizeof(u3_noun)); // push incremental, successful [fel] parse results onto road stack // @@ -949,10 +952,10 @@ while ( u3_nul != q_vex ) { u3x_trel(q_vex, 0, &puq_vex, &quq_vex); - top = u3a_push(sizeof(u3_noun)); + top = u3a_push(&pil_u); *top = u3k(puq_vex); - top = u3a_push(sizeof(u3_noun)); + top = u3a_push(&pil_u); *top = u3k(p_vex); ++len_w; @@ -972,6 +975,10 @@ u3j_gate_lose(&fel_u); } + // check for stack overflow + // + u3a_pile_sane(&pil_u); + // unwind the stack, folding parse results into [wag] by way of [raq] // if ( len_w ) { @@ -980,13 +987,13 @@ u3j_gate_prep(&raq_u, u3k(raq)); while ( len_w-- > 0 ) { - top = u3a_peek(sizeof(u3_noun)); + top = u3a_peek(&pil_u); p_vex = *top; - u3a_pop(sizeof(u3_noun)); + u3a_pop(&pil_u); - top = u3a_peek(sizeof(u3_noun)); + top = u3a_peek(&pil_u); puq_vex = *top; - u3a_pop(sizeof(u3_noun)); + u3a_pop(&pil_u); p_wag = _last_k(p_vex, p_wag); puq_wag = u3j_gate_slam(&raq_u, u3nc(puq_vex, puq_wag)); @@ -995,6 +1002,8 @@ u3j_gate_lose(&raq_u); } + u3a_pile_done(&pil_u); + return u3nq(p_wag, u3_nul, puq_wag, quq_wag); } diff --git a/pkg/urbit/noun/allocate.c b/pkg/urbit/noun/allocate.c index 48aeb47716..0501409592 100644 --- a/pkg/urbit/noun/allocate.c +++ b/pkg/urbit/noun/allocate.c @@ -3,6 +3,15 @@ */ #include "all.h" +// declarations of inline functions +// +void* +u3a_peek(u3a_pile* pil_u); +void +u3a_pop(u3a_pile* pil_u); +void* +u3a_push(u3a_pile* pil_u); + /* _box_count(): adjust memory count. */ #ifdef U3_CPU_DEBUG @@ -589,67 +598,52 @@ u3a_wealloc(void* lag_v, c3_w len_w) } } } -/* u3a_push(): allocate space on the road stack -*/ -void* -u3a_push(c3_w len_w) -{ - void *cur, *top = u3to(void, u3R->cap_p); - if ( c3y == u3a_is_north(u3R) ) { - top -= len_w; - cur = top; - u3p(void) cap_p = u3R->cap_p = u3of(void, top); - if( !( cap_p < u3R->mat_p && - cap_p > u3R->hat_p ) ) - { - u3m_bail(c3__meme); - } - - return cur; - } - else { - cur = top; - top += len_w; - u3R->cap_p = u3of(void, top); - u3p(void) cap_p = u3R->cap_p = u3of(void, top); - - if( !( cap_p > u3R->mat_p && - cap_p < u3R->hat_p ) ) - { - u3m_bail(c3__meme); - } - - return cur; - } -} - -/* u3a_pop(): deallocate space on the road stack +/* u3a_pile_prep(): initialize stack control. */ void -u3a_pop(c3_w len_w) +u3a_pile_prep(u3a_pile* pil_u, c3_w len_w) { - void* top = u3to(void, u3R->cap_p); - if ( c3y == u3a_is_north(u3R) ) { - top += len_w; - u3p(void) cap_p = u3R->cap_p = u3of(void, top); - c3_assert(cap_p <= u3R->mat_p); - c3_assert(cap_p > u3R->hat_p); - } - else { - top -= len_w; - u3p(void) cap_p = u3R->cap_p = u3of(void, top); - c3_assert(cap_p >= u3R->mat_p); - c3_assert(cap_p < u3R->hat_p); - } + // frame size, in words + // + c3_w wor_w = (len_w + 3) >> 2; + c3_o nor_o = u3a_is_north(u3R); + + pil_u->top_p = u3R->cap_p; + pil_u->mov_ws = (c3y == nor_o) ? -wor_w : wor_w; + pil_u->off_ws = (c3y == nor_o) ? 0 : -wor_w; } -/* u3a_peek(): examine the top of the road stack +/* u3a_pile_sane(): bail on invalid road stack state. */ -void* -u3a_peek(c3_w len_w) +void +u3a_pile_sane(u3a_pile* pil_u) { - return u3to(void, u3R->cap_p) - (c3y == u3a_is_north(u3R) ? 0 : len_w); + // !off means we're on a north road + // + if ( !pil_u->off_ws ) { + if( !(u3R->cap_p > u3R->hat_p) ) { + u3m_bail(c3__meme); + } + c3_assert( pil_u->top_p >= u3R->cap_p ); + } + else { + if( !(u3R->cap_p < u3R->hat_p) ) { + u3m_bail(c3__meme); + } + c3_assert( pil_u->top_p <= u3R->cap_p ); + } + + // XX also stash road pointer in [pil_u] and assert same road? + // +} + +/* u3a_pile_done(): assert valid upon completion. +*/ +void +u3a_pile_done(u3a_pile* pil_u) +{ + c3_assert( pil_u->top_p == u3R->cap_p ); } /* u3a_wfree(): free storage. From a78b303bb4a145f50d8ef64aed1a172db7d67c26 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 11 Sep 2020 14:54:49 -0700 Subject: [PATCH 318/933] u3: adds further improvements to road-stack api --- pkg/urbit/include/noun/allocate.h | 115 ++++++++++++++++++++---------- pkg/urbit/jets/b/reel.c | 8 +-- pkg/urbit/jets/e/parse.c | 13 ++-- pkg/urbit/noun/allocate.c | 44 +++--------- 4 files changed, 100 insertions(+), 80 deletions(-) diff --git a/pkg/urbit/include/noun/allocate.h b/pkg/urbit/include/noun/allocate.h index b16219aa75..f563f624b7 100644 --- a/pkg/urbit/include/noun/allocate.h +++ b/pkg/urbit/include/noun/allocate.h @@ -171,9 +171,12 @@ /* u3_pile: stack control, abstracted over road direction. */ typedef struct _u3a_pile { - u3_post top_p; - c3_ws mov_ws; - c3_ws off_ws; + c3_ws mov_ws; + c3_ws off_ws; + u3_post top_p; +#ifdef U3_MEMORY_DEBUG + u3a_road* rod_u; +#endif } u3a_pile; /** Macros. Should be better commented. @@ -313,30 +316,81 @@ **/ /** road stack. **/ - /* u3a_peek(): examine the top of the road stack - */ - inline void* - u3a_peek(u3a_pile* pil_u) - { - return u3to(void, (u3R->cap_p + pil_u->off_ws)); - } + /* u3a_drop(): drop a roac stack frame per [pil_u]. + */ + inline void + u3a_drop(u3a_pile* pil_u) + { + u3R->cap_p -= pil_u->mov_ws; + } - /* u3a_pop(): deallocate space on the road stack - */ - inline void - u3a_pop(u3a_pile* pil_u) - { - u3R->cap_p -= pil_u->mov_ws; - } + /* u3a_peek(): examine the top of the road stack. + */ + inline void* + u3a_peek(u3a_pile* pil_u) + { + return u3to(void, (u3R->cap_p + pil_u->off_ws)); + } - /* u3a_push(): allocate space on the road stack - */ - inline void* - u3a_push(u3a_pile* pil_u) - { - u3R->cap_p += pil_u->mov_ws; - return u3a_peek(pil_u); - } + /* u3a_pop(): drop a stack frame, peek at the new top; + */ + inline void* + u3a_pop(u3a_pile* pil_u) + { + u3a_drop(pil_u); + return u3a_peek(pil_u); + } + + /* u3a_push(): push a frame onto the road stack, per [pil_u]. + */ + inline void* + u3a_push(u3a_pile* pil_u) + { + u3R->cap_p += pil_u->mov_ws; + return u3a_peek(pil_u); + } + + // XX unfortunate forward declaration + // + c3_i + u3m_bail(c3_m how_m) __attribute__((noreturn)); + + /* u3a_pile_sane(): bail on invalid road stack state. + */ + inline void + u3a_pile_sane(u3a_pile* pil_u) + { + // !off means we're on a north road + // + if ( !pil_u->off_ws ) { + if( !(u3R->cap_p > u3R->hat_p) ) { + u3m_bail(c3__meme); + } +#ifdef U3_MEMORY_DEBUG + c3_assert( pil_u->top_p >= u3R->cap_p ); +#endif + } + else { + if( !(u3R->cap_p < u3R->hat_p) ) { + u3m_bail(c3__meme); + } +#ifdef U3_MEMORY_DEBUG + c3_assert( pil_u->top_p <= u3R->cap_p ); +#endif + } + +#ifdef U3_MEMORY_DEBUG + c3_assert( pil_u->rod_u == u3R ); +#endif + } + + /* u3a_pile_done(): assert valid upon completion. + */ + inline c3_o + u3a_pile_done(u3a_pile* pil_u) + { + return (pil_u->top_p == u3R->cap_p) ? c3y : c3n; + } /** Functions. **/ @@ -369,17 +423,6 @@ void u3a_pile_prep(u3a_pile* pil_u, c3_w len_w); - /* u3a_pile_sane(): bail on invalid road stack state. - */ - void - u3a_pile_sane(u3a_pile* pil_u); - - /* u3a_pile_done(): assert valid upon completion. - */ - void - u3a_pile_done(u3a_pile* pil_u); - - /* C-style aligned allocation - *not* compatible with above. */ /* u3a_malloc(): aligned storage measured in bytes. diff --git a/pkg/urbit/jets/b/reel.c b/pkg/urbit/jets/b/reel.c index 38d3c30d1b..582df0ac45 100644 --- a/pkg/urbit/jets/b/reel.c +++ b/pkg/urbit/jets/b/reel.c @@ -32,15 +32,15 @@ u3a_pile_sane(&pil_u); u3j_gate_prep(&sit_u, u3k(b)); - while ( len_w-- > 0 ) { - top = u3a_peek(&pil_u); - u3a_pop(&pil_u); + top = u3a_peek(&pil_u); + while ( len_w-- > 0 ) { pro = u3j_gate_slam(&sit_u, u3nc(u3k(*top), pro)); + top = u3a_pop(&pil_u); } u3j_gate_lose(&sit_u); - u3a_pile_done(&pil_u); + c3_assert( c3y == u3a_pile_done(&pil_u) ); } return pro; diff --git a/pkg/urbit/jets/e/parse.c b/pkg/urbit/jets/e/parse.c index 01cc03ae59..95327572fb 100644 --- a/pkg/urbit/jets/e/parse.c +++ b/pkg/urbit/jets/e/parse.c @@ -986,14 +986,13 @@ u3j_site raq_u; u3j_gate_prep(&raq_u, u3k(raq)); - while ( len_w-- > 0 ) { - top = u3a_peek(&pil_u); - p_vex = *top; - u3a_pop(&pil_u); + top = u3a_peek(&pil_u); - top = u3a_peek(&pil_u); + while ( len_w-- > 0 ) { + p_vex = *top; + top = u3a_pop(&pil_u); puq_vex = *top; - u3a_pop(&pil_u); + top = u3a_pop(&pil_u); p_wag = _last_k(p_vex, p_wag); puq_wag = u3j_gate_slam(&raq_u, u3nc(puq_vex, puq_wag)); @@ -1002,7 +1001,7 @@ u3j_gate_lose(&raq_u); } - u3a_pile_done(&pil_u); + c3_assert( c3y == u3a_pile_done(&pil_u) ); return u3nq(p_wag, u3_nul, puq_wag, quq_wag); } diff --git a/pkg/urbit/noun/allocate.c b/pkg/urbit/noun/allocate.c index 0501409592..961fd79d07 100644 --- a/pkg/urbit/noun/allocate.c +++ b/pkg/urbit/noun/allocate.c @@ -5,12 +5,18 @@ // declarations of inline functions // +void +u3a_drop(u3a_pile* pil_u); void* u3a_peek(u3a_pile* pil_u); -void +void* u3a_pop(u3a_pile* pil_u); void* u3a_push(u3a_pile* pil_u); +void +u3a_pile_sane(u3a_pile* pil_u); +c3_o +u3a_pile_done(u3a_pile* pil_u); /* _box_count(): adjust memory count. */ @@ -609,41 +615,13 @@ u3a_pile_prep(u3a_pile* pil_u, c3_w len_w) c3_w wor_w = (len_w + 3) >> 2; c3_o nor_o = u3a_is_north(u3R); - pil_u->top_p = u3R->cap_p; pil_u->mov_ws = (c3y == nor_o) ? -wor_w : wor_w; pil_u->off_ws = (c3y == nor_o) ? 0 : -wor_w; -} + pil_u->top_p = u3R->cap_p; -/* u3a_pile_sane(): bail on invalid road stack state. -*/ -void -u3a_pile_sane(u3a_pile* pil_u) -{ - // !off means we're on a north road - // - if ( !pil_u->off_ws ) { - if( !(u3R->cap_p > u3R->hat_p) ) { - u3m_bail(c3__meme); - } - c3_assert( pil_u->top_p >= u3R->cap_p ); - } - else { - if( !(u3R->cap_p < u3R->hat_p) ) { - u3m_bail(c3__meme); - } - c3_assert( pil_u->top_p <= u3R->cap_p ); - } - - // XX also stash road pointer in [pil_u] and assert same road? - // -} - -/* u3a_pile_done(): assert valid upon completion. -*/ -void -u3a_pile_done(u3a_pile* pil_u) -{ - c3_assert( pil_u->top_p == u3R->cap_p ); +#ifdef U3_MEMORY_DEBUG + pil_u->rod_u = u3R; +#endif } /* u3a_wfree(): free storage. From 2e8d84c1730f174497fc4e1611fd147ab057abfd Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 11 Sep 2020 14:57:57 -0700 Subject: [PATCH 319/933] u3: removes redundant stack reads from +reel and +stir jets --- pkg/urbit/jets/b/reel.c | 2 -- pkg/urbit/jets/e/parse.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/pkg/urbit/jets/b/reel.c b/pkg/urbit/jets/b/reel.c index 582df0ac45..d750ecad0c 100644 --- a/pkg/urbit/jets/b/reel.c +++ b/pkg/urbit/jets/b/reel.c @@ -32,8 +32,6 @@ u3a_pile_sane(&pil_u); u3j_gate_prep(&sit_u, u3k(b)); - top = u3a_peek(&pil_u); - while ( len_w-- > 0 ) { pro = u3j_gate_slam(&sit_u, u3nc(u3k(*top), pro)); top = u3a_pop(&pil_u); diff --git a/pkg/urbit/jets/e/parse.c b/pkg/urbit/jets/e/parse.c index 95327572fb..c59d496de0 100644 --- a/pkg/urbit/jets/e/parse.c +++ b/pkg/urbit/jets/e/parse.c @@ -986,8 +986,6 @@ u3j_site raq_u; u3j_gate_prep(&raq_u, u3k(raq)); - top = u3a_peek(&pil_u); - while ( len_w-- > 0 ) { p_vex = *top; top = u3a_pop(&pil_u); From 8db9a4d39410480b179dd6f0a5227facf728c70c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 11 Sep 2020 15:10:49 -0700 Subject: [PATCH 320/933] u3: only perform road stack checks in +stir jet if necessary --- pkg/urbit/jets/e/parse.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/urbit/jets/e/parse.c b/pkg/urbit/jets/e/parse.c index c59d496de0..67293dc413 100644 --- a/pkg/urbit/jets/e/parse.c +++ b/pkg/urbit/jets/e/parse.c @@ -975,10 +975,6 @@ u3j_gate_lose(&fel_u); } - // check for stack overflow - // - u3a_pile_sane(&pil_u); - // unwind the stack, folding parse results into [wag] by way of [raq] // if ( len_w ) { @@ -986,6 +982,10 @@ u3j_site raq_u; u3j_gate_prep(&raq_u, u3k(raq)); + // check for stack overflow + // + u3a_pile_sane(&pil_u); + while ( len_w-- > 0 ) { p_vex = *top; top = u3a_pop(&pil_u); @@ -996,11 +996,11 @@ puq_wag = u3j_gate_slam(&raq_u, u3nc(puq_vex, puq_wag)); } + c3_assert( c3y == u3a_pile_done(&pil_u) ); + u3j_gate_lose(&raq_u); } - c3_assert( c3y == u3a_pile_done(&pil_u) ); - return u3nq(p_wag, u3_nul, puq_wag, quq_wag); } From 047481667a2f43c8eb2933d0f7120cf16689adf6 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 11 Sep 2020 15:12:46 -0700 Subject: [PATCH 321/933] u3: clarifies forward-declaration comment in allocate.h --- pkg/urbit/include/noun/allocate.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/urbit/include/noun/allocate.h b/pkg/urbit/include/noun/allocate.h index f563f624b7..f5b7e90b2f 100644 --- a/pkg/urbit/include/noun/allocate.h +++ b/pkg/urbit/include/noun/allocate.h @@ -350,7 +350,8 @@ return u3a_peek(pil_u); } - // XX unfortunate forward declaration + // we have to forward-declare u3m_bail() here, as our + // headers don't have the necessary guards. // c3_i u3m_bail(c3_m how_m) __attribute__((noreturn)); From ad4d6368da667fd003cc90ae0a37cb84134b06a1 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 11 Sep 2020 15:38:55 -0700 Subject: [PATCH 322/933] vere: restores a necessary layer of reallocation --- pkg/urbit/vere/io/term.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/urbit/vere/io/term.c b/pkg/urbit/vere/io/term.c index decd77ca0e..53dd794590 100644 --- a/pkg/urbit/vere/io/term.c +++ b/pkg/urbit/vere/io/term.c @@ -489,7 +489,17 @@ _term_it_show_line(u3_utty* uty_u, c3_w wor_w, c3_w sap_w) { u3_utat* tat_u = &uty_u->tat_u; - _term_it_dump(uty_u, tat_u->mir.byt_w, tat_u->mir.lin_y); + // we have to reallocate the current line on write, + // or we have a data race if a) the write is async, + // and b) a new output line arrives before the write completes. + // + { + c3_w len_w = tat_u->mir.byt_w; + c3_y* hun_y = c3_malloc(len_w); + memcpy(hun_y, tat_u->mir.lin_y, len_w); + + _term_it_send(uty_u, len_w, hun_y); + } // XX refactor to avoid updating state // From 0eb63131b898a426e70dd4355adc7843dd37cbc3 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 11 Sep 2020 15:56:07 -0700 Subject: [PATCH 323/933] u3: const-qualifies u3_pile pointer in road-stack api (where appropriate) --- pkg/urbit/include/noun/allocate.h | 12 ++++++------ pkg/urbit/noun/allocate.c | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/urbit/include/noun/allocate.h b/pkg/urbit/include/noun/allocate.h index f5b7e90b2f..dee9a414ce 100644 --- a/pkg/urbit/include/noun/allocate.h +++ b/pkg/urbit/include/noun/allocate.h @@ -319,7 +319,7 @@ /* u3a_drop(): drop a roac stack frame per [pil_u]. */ inline void - u3a_drop(u3a_pile* pil_u) + u3a_drop(const u3a_pile* pil_u) { u3R->cap_p -= pil_u->mov_ws; } @@ -327,7 +327,7 @@ /* u3a_peek(): examine the top of the road stack. */ inline void* - u3a_peek(u3a_pile* pil_u) + u3a_peek(const u3a_pile* pil_u) { return u3to(void, (u3R->cap_p + pil_u->off_ws)); } @@ -335,7 +335,7 @@ /* u3a_pop(): drop a stack frame, peek at the new top; */ inline void* - u3a_pop(u3a_pile* pil_u) + u3a_pop(const u3a_pile* pil_u) { u3a_drop(pil_u); return u3a_peek(pil_u); @@ -344,7 +344,7 @@ /* u3a_push(): push a frame onto the road stack, per [pil_u]. */ inline void* - u3a_push(u3a_pile* pil_u) + u3a_push(const u3a_pile* pil_u) { u3R->cap_p += pil_u->mov_ws; return u3a_peek(pil_u); @@ -359,7 +359,7 @@ /* u3a_pile_sane(): bail on invalid road stack state. */ inline void - u3a_pile_sane(u3a_pile* pil_u) + u3a_pile_sane(const u3a_pile* pil_u) { // !off means we're on a north road // @@ -388,7 +388,7 @@ /* u3a_pile_done(): assert valid upon completion. */ inline c3_o - u3a_pile_done(u3a_pile* pil_u) + u3a_pile_done(const u3a_pile* pil_u) { return (pil_u->top_p == u3R->cap_p) ? c3y : c3n; } diff --git a/pkg/urbit/noun/allocate.c b/pkg/urbit/noun/allocate.c index 961fd79d07..6ab0317886 100644 --- a/pkg/urbit/noun/allocate.c +++ b/pkg/urbit/noun/allocate.c @@ -6,17 +6,17 @@ // declarations of inline functions // void -u3a_drop(u3a_pile* pil_u); +u3a_drop(const u3a_pile* pil_u); void* -u3a_peek(u3a_pile* pil_u); +u3a_peek(const u3a_pile* pil_u); void* -u3a_pop(u3a_pile* pil_u); +u3a_pop(const u3a_pile* pil_u); void* -u3a_push(u3a_pile* pil_u); +u3a_push(const u3a_pile* pil_u); void -u3a_pile_sane(u3a_pile* pil_u); +u3a_pile_sane(const u3a_pile* pil_u); c3_o -u3a_pile_done(u3a_pile* pil_u); +u3a_pile_done(const u3a_pile* pil_u); /* _box_count(): adjust memory count. */ From b43fca453940f9823713ed3b5b5400952e5739a1 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 11 Sep 2020 15:56:48 -0700 Subject: [PATCH 324/933] u3: refactors +reel and +stir jets, removing obsolete stack bookkeeping --- pkg/urbit/jets/b/reel.c | 5 +---- pkg/urbit/jets/e/parse.c | 46 ++++++++++++++++++---------------------- 2 files changed, 22 insertions(+), 29 deletions(-) diff --git a/pkg/urbit/jets/b/reel.c b/pkg/urbit/jets/b/reel.c index d750ecad0c..2292db1a98 100644 --- a/pkg/urbit/jets/b/reel.c +++ b/pkg/urbit/jets/b/reel.c @@ -16,7 +16,6 @@ u3j_site sit_u; u3_noun* top; u3_noun i, t = a; - c3_w len_w = 0; u3a_pile_prep(&pil_u, sizeof(u3_noun)); @@ -26,19 +25,17 @@ u3x_cell(t, &i, &t); top = u3a_push(&pil_u); *top = i; - ++len_w; } while ( u3_nul != t ); u3a_pile_sane(&pil_u); u3j_gate_prep(&sit_u, u3k(b)); - while ( len_w-- > 0 ) { + while ( c3n == u3a_pile_done(&pil_u) ) { pro = u3j_gate_slam(&sit_u, u3nc(u3k(*top), pro)); top = u3a_pop(&pil_u); } u3j_gate_lose(&sit_u); - c3_assert( c3y == u3a_pile_done(&pil_u) ); } return pro; diff --git a/pkg/urbit/jets/e/parse.c b/pkg/urbit/jets/e/parse.c index 67293dc413..8befe6a804 100644 --- a/pkg/urbit/jets/e/parse.c +++ b/pkg/urbit/jets/e/parse.c @@ -918,6 +918,13 @@ } } +/* _stir_pair(): stack frame recording intermediate parse results +*/ + typedef struct { + u3_noun har; // hair, p_vex + u3_noun res; // parse-result, puq_vex + } _stir_pair; + /* stir */ static u3_noun @@ -926,16 +933,15 @@ u3_noun fel, u3_noun tub) { + // pil_u: stack control structure + // par_u: frame pointer // wag: initial accumulator (deconstructed) - // top: stack pointer - // len_w: number of result pairs on the stack // - u3_noun p_wag, puq_wag, quq_wag; - u3_noun* top; - u3a_pile pil_u; - c3_w len_w = 0; + u3a_pile pil_u; + _stir_pair* par_u; + u3_noun p_wag, puq_wag, quq_wag; - u3a_pile_prep(&pil_u, sizeof(u3_noun)); + u3a_pile_prep(&pil_u, sizeof(*par_u)); // push incremental, successful [fel] parse results onto road stack // @@ -952,12 +958,9 @@ while ( u3_nul != q_vex ) { u3x_trel(q_vex, 0, &puq_vex, &quq_vex); - top = u3a_push(&pil_u); - *top = u3k(puq_vex); - - top = u3a_push(&pil_u); - *top = u3k(p_vex); - ++len_w; + par_u = u3a_push(&pil_u); + par_u->har = u3k(p_vex); + par_u->res = u3k(puq_vex); u3z(tub); tub = u3k(quq_vex); @@ -977,8 +980,7 @@ // unwind the stack, folding parse results into [wag] by way of [raq] // - if ( len_w ) { - u3_noun p_vex, puq_vex; + if ( c3n == u3a_pile_done(&pil_u) ) { u3j_site raq_u; u3j_gate_prep(&raq_u, u3k(raq)); @@ -986,18 +988,12 @@ // u3a_pile_sane(&pil_u); - while ( len_w-- > 0 ) { - p_vex = *top; - top = u3a_pop(&pil_u); - puq_vex = *top; - top = u3a_pop(&pil_u); - - p_wag = _last_k(p_vex, p_wag); - puq_wag = u3j_gate_slam(&raq_u, u3nc(puq_vex, puq_wag)); + while ( c3n == u3a_pile_done(&pil_u) ) { + p_wag = _last_k(par_u->har, p_wag); + puq_wag = u3j_gate_slam(&raq_u, u3nc(par_u->res, puq_wag)); + par_u = u3a_pop(&pil_u); } - c3_assert( c3y == u3a_pile_done(&pil_u) ); - u3j_gate_lose(&raq_u); } From 707a8343979c30c1fffe5b4ae27ac9dc3b306d03 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sat, 12 Sep 2020 22:33:31 -0700 Subject: [PATCH 325/933] u3: corrects comments in allocate.h --- pkg/urbit/include/noun/allocate.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/urbit/include/noun/allocate.h b/pkg/urbit/include/noun/allocate.h index dee9a414ce..d6325ff662 100644 --- a/pkg/urbit/include/noun/allocate.h +++ b/pkg/urbit/include/noun/allocate.h @@ -168,7 +168,7 @@ u3a_flag_sand = 0x1, // bump allocation (XX not impl) }; - /* u3_pile: stack control, abstracted over road direction. + /* u3a_pile: stack control, abstracted over road direction. */ typedef struct _u3a_pile { c3_ws mov_ws; @@ -316,7 +316,7 @@ **/ /** road stack. **/ - /* u3a_drop(): drop a roac stack frame per [pil_u]. + /* u3a_drop(): drop a road stack frame per [pil_u]. */ inline void u3a_drop(const u3a_pile* pil_u) @@ -332,7 +332,7 @@ return u3to(void, (u3R->cap_p + pil_u->off_ws)); } - /* u3a_pop(): drop a stack frame, peek at the new top; + /* u3a_pop(): drop a road stack frame, peek at the new top. */ inline void* u3a_pop(const u3a_pile* pil_u) From 10a674b0a5f386d8f4685c066f6137bc1f376e1e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 11 Sep 2020 17:31:28 -0700 Subject: [PATCH 326/933] u3: rewrites u3r_mug for clarity --- pkg/urbit/include/noun/retrieve.h | 4 +- pkg/urbit/noun/retrieve.c | 217 +++++++++++------------------- 2 files changed, 79 insertions(+), 142 deletions(-) diff --git a/pkg/urbit/include/noun/retrieve.h b/pkg/urbit/include/noun/retrieve.h index eed2bcc916..64b5ed67f6 100644 --- a/pkg/urbit/include/noun/retrieve.h +++ b/pkg/urbit/include/noun/retrieve.h @@ -81,9 +81,9 @@ u3_noun c, u3_noun d); - /* u3r_mug(): MurmurHash3 on a noun. + /* u3r_mug(): statefully mug a noun with 31-bit murmur3. */ - c3_w + c3_l u3r_mug(u3_noun veb); /* u3r_fing(): diff --git a/pkg/urbit/noun/retrieve.c b/pkg/urbit/noun/retrieve.c index 63589ab1e1..3c3ec0a14d 100644 --- a/pkg/urbit/noun/retrieve.c +++ b/pkg/urbit/noun/retrieve.c @@ -1455,101 +1455,24 @@ u3r_mug_cell(u3_noun hed, return u3r_mug_both(lus_w, biq_w); } -#define MUG_ROOT 0 -#define MUG_HEAD 1 -#define MUG_TAIL 2 +/* _cr_mug: stack frame for recording cell travesal +** !mug == head-frame +*/ +typedef struct { + c3_l mug_l; + u3_cell cel; +} _cr_mugf; -// stack frame for recording head vs tail iteration -// -// In Hoon, this structure would be as follows: -// -// $% [%root ~] -// [%head cell=^] -// [%tail cell=^ hed-mug=@] -// == -// -typedef struct mugframe +/* _cr_mug_next(): advance mug calculation, pushing cells onto the stack. +*/ +static inline c3_l +_cr_mug_next(u3a_pile* pil_u, u3_noun veb) { - c3_y tag_y; - u3a_cell* cel_u; - c3_w mug_w; -} mugframe; - -static inline void -_mug_push(c3_ys mov, - c3_ys off, - c3_y tag_y, - u3a_cell* cel_u, - c3_w mug_w) -{ - u3R->cap_p += mov; - - // ensure we haven't overflowed the stack - // (off==0 means we're on a north road) - // - if ( 0 == off ) { - if( !(u3R->cap_p > u3R->hat_p) ) { - u3m_bail(c3__meme); - } - } - else { - if( !(u3R->cap_p < u3R->hat_p) ) { - u3m_bail(c3__meme); - } - } - - mugframe* fam_u = u3to(mugframe, u3R->cap_p + off); - fam_u->tag_y = tag_y; - fam_u->cel_u = cel_u; - fam_u->mug_w = mug_w; -} - -static inline mugframe -_mug_pop(c3_ys mov, c3_ys off) -{ - mugframe* fam_u = u3to(mugframe, u3R->cap_p + off); - u3R->cap_p -= mov; - - return *fam_u; -} - -// u3r_mug(): statefully mug a noun using a 31-bit MurmurHash3 -// -c3_w -u3r_mug(u3_noun veb) -{ - // sanity check (makes a clear error message) - // - c3_assert( u3_none != veb ); - - // initialize signed stack offsets (relative to north/south road) - // - c3_ys mov, off; - { - c3_y wis_y = c3_wiseof(mugframe); - c3_o nor_o = u3a_is_north(u3R); - mov = ( c3y == nor_o ? -wis_y : wis_y ); - off = ( c3y == nor_o ? 0 : -wis_y ); - } - - // stash the current stack post - // - u3p(mugframe) cap_p = u3R->cap_p; - - // push the (only) ROOT stack frame (our termination condition) - // - _mug_push(mov, off, MUG_ROOT, 0, 0); - - c3_w mug_w; - - // read from the current noun .veb - // - advance: { + while ( 1 ) { // veb is a direct atom, mug is not memoized // - if ( _(u3a_is_cat(veb)) ) { - mug_w = u3r_mug_words(&veb, 1); - goto retreat; + if ( c3y == u3a_is_cat(veb) ) { + return (c3_l)u3r_mug_words(&veb, 1); } // veb is indirect, a pointer into the loom // @@ -1558,72 +1481,86 @@ u3r_mug(u3_noun veb) // veb has already been mugged, return memoized value // - if ( 0 != veb_u->mug_w ) { - mug_w = veb_u->mug_w; - goto retreat; + // XX debug mode, assert 31-bit? + // + if ( veb_u->mug_w ) { + return (c3_l)veb_u->mug_w; } // veb is an indirect atom, mug its bytes and memoize // - else if ( _(u3a_is_atom(veb)) ) { + else if ( c3y == u3a_is_atom(veb) ) { u3a_atom* vat_u = (u3a_atom*)veb_u; - mug_w = u3r_mug_words(vat_u->buf_w, vat_u->len_w); - vat_u->mug_w = mug_w; - goto retreat; + c3_l mug_l = u3r_mug_words(vat_u->buf_w, vat_u->len_w); + vat_u->mug_w = mug_l; + return mug_l; } // veb is a cell, push a stack frame to mark head-recursion // and read the head // else { u3a_cell* cel_u = (u3a_cell*)veb_u; - _mug_push(mov, off, MUG_HEAD, cel_u, 0); + _cr_mugf* fam_u = u3a_push(pil_u); + + // check for overflow + // + u3a_pile_sane(pil_u); + + fam_u->mug_l = 0; + fam_u->cel = veb; + veb = cel_u->hed; - goto advance; + continue; } } } +} - // consume the popped stack frame and mug from above - // - retreat: { - mugframe fam_u = _mug_pop(mov, off); - - switch ( fam_u.tag_y ) { - default: { - c3_assert(0); - } - - // we done - // - case MUG_ROOT: { - break; - } - - // mug_w is the mug of the head of cel_u - // push a stack frame to mark tail recursion, - // record the mug of the head, and read the tail - // - case MUG_HEAD: { - _mug_push(mov, off, MUG_TAIL, fam_u.cel_u, mug_w); - - veb = fam_u.cel_u->tel; - goto advance; - } - - // mug_w is the mug of the tail of cel_u - // combine the mugs, memoize the value, and recur - // - case MUG_TAIL: { - u3a_cell* cel_u = fam_u.cel_u; - mug_w = u3r_mug_both(fam_u.mug_w, mug_w); - cel_u->mug_w = mug_w; - goto retreat; - } - } - } +/* u3r_mug(): statefully mug a noun with 31-bit murmur3. +*/ +c3_l +u3r_mug(u3_noun veb) +{ + u3a_pile pil_u; + _cr_mugf* fam_u; + c3_l mug_l; // sanity check // - c3_assert( u3R->cap_p == cap_p ); + c3_assert( u3_none != veb ); - return mug_w; + u3a_pile_prep(&pil_u, sizeof(*fam_u)); + + // commence mugging + // + mug_l = _cr_mug_next(&pil_u, veb); + + // process cell results + // + if ( c3n == u3a_pile_done(&pil_u) ) { + fam_u = u3a_peek(&pil_u); + + do { + // fam_u is a head-frame: stash mug and continue into the tail + // + if ( !fam_u->mug_l ) { + u3a_cell* cel_u = u3a_to_ptr(fam_u->cel); + + fam_u->mug_l = mug_l; + mug_l = _cr_mug_next(&pil_u, cel_u->tel); + fam_u = u3a_peek(&pil_u); + } + // fam_u is a tail-frame: calculate/memoize cell mug and pop the stack + // + else { + u3a_cell* cel_u = u3a_to_ptr(fam_u->cel); + + mug_l = u3r_mug_both(fam_u->mug_l, mug_l); + cel_u->mug_w = mug_l; + fam_u = u3a_pop(&pil_u); + } + } + while ( c3n == u3a_pile_done(&pil_u) ); + } + + return mug_l; } From 6f39faeb7d75af7818e7fdc7f8e72769b3e9474e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 14 Sep 2020 15:20:42 -0700 Subject: [PATCH 327/933] u3: refactors u3a_walk_fore/unsafe(), using road stack api --- pkg/urbit/noun/allocate.c | 91 +++++++++++---------------------------- 1 file changed, 26 insertions(+), 65 deletions(-) diff --git a/pkg/urbit/noun/allocate.c b/pkg/urbit/noun/allocate.c index 6ab0317886..939b9e7987 100644 --- a/pkg/urbit/noun/allocate.c +++ b/pkg/urbit/noun/allocate.c @@ -2668,59 +2668,33 @@ u3a_walk_fore(u3_noun a, void (*pat_f)(u3_atom, void*), c3_o (*cel_f)(u3_noun, void*)) { - // initialize signed stack offsets (relative to N or S road) - // - c3_o nor_o = u3a_is_north(u3R); - c3_ys mov_ys, off_ys; - { - c3_y wis_y = c3_wiseof(u3_noun); - mov_ys = ( c3y == nor_o ? -wis_y : wis_y ); - off_ys = ( c3y == nor_o ? 0 : -wis_y ); - } + u3_noun* top; + u3a_pile pil_u; - // set stack root, push argument + // initialize stack control; push argument // - u3_noun *top, *don; - { - don = u3to(u3_noun, u3R->cap_p + off_ys); - u3R->cap_p += mov_ys; - top = u3to(u3_noun, u3R->cap_p + off_ys); - *top = a; - } + u3a_pile_prep(&pil_u, sizeof(u3_noun)); + top = u3a_push(&pil_u); + *top = a; - while ( top != don ) { + while ( c3n == u3a_pile_done(&pil_u) ) { // visit an atom, then pop the stack // if ( c3y == u3a_is_atom(a) ) { pat_f(a, ptr_v); - u3R->cap_p -= mov_ys; - top = u3to(u3_noun, u3R->cap_p + off_ys); + top = u3a_pop(&pil_u); } // vist a cell, if c3n, pop the stack // else if ( c3n == cel_f(a, ptr_v) ) { - u3R->cap_p -= mov_ys; - top = u3to(u3_noun, u3R->cap_p + off_ys); - + top = u3a_pop(&pil_u); } // otherwise, push the tail and continue into the head // else { - *top = u3t(a); - u3R->cap_p += mov_ys; - - if ( c3y == nor_o ) { - if( !(u3R->cap_p > u3R->hat_p) ) { - u3m_bail(c3__meme); - } - } - else { - if( !(u3R->cap_p < u3R->hat_p) ) { - u3m_bail(c3__meme); - } - } - - top = u3to(u3_noun, u3R->cap_p + off_ys); + *top = u3t(a); + top = u3a_push(&pil_u); + u3a_pile_sane(&pil_u); *top = u3h(a); } @@ -2736,48 +2710,35 @@ u3a_walk_fore_unsafe(u3_noun a, void (*pat_f)(u3_atom, void*), c3_o (*cel_f)(u3_noun, void*)) { - // initialize signed stack offsets (relative to N or S road) - // - c3_ys mov_ys, off_ys; - { - c3_y wis_y = c3_wiseof(u3_noun); - c3_o nor_o = u3a_is_north(u3R); - mov_ys = ( c3y == nor_o ? -wis_y : wis_y ); - off_ys = ( c3y == nor_o ? 0 : -wis_y ); - } + u3_noun* top; + u3a_pile pil_u; - // set stack root, push argument + // initialize stack control; push argument // - u3_noun *top, *don; - { - don = u3to(u3_noun, u3R->cap_p + off_ys); - u3R->cap_p += mov_ys; - top = u3to(u3_noun, u3R->cap_p + off_ys); - *top = a; - } + u3a_pile_prep(&pil_u, sizeof(u3_noun)); + top = u3a_push(&pil_u); + *top = a; - while ( top != don ) { + while ( c3n == u3a_pile_done(&pil_u) ) { // visit an atom, then pop the stack // if ( c3y == u3a_is_atom(a) ) { pat_f(a, ptr_v); - u3R->cap_p -= mov_ys; - top = u3to(u3_noun, u3R->cap_p + off_ys); + top = u3a_pop(&pil_u); } // vist a cell, if c3n, pop the stack // else if ( c3n == cel_f(a, ptr_v) ) { - u3R->cap_p -= mov_ys; - top = u3to(u3_noun, u3R->cap_p + off_ys); - + top = u3a_pop(&pil_u); } // otherwise, push the tail and continue into the head // else { - *top = u3t(a); - u3R->cap_p += mov_ys; - top = u3to(u3_noun, u3R->cap_p + off_ys); - *top = u3h(a); + *top = u3t(a); + // NB: overflow check elided here + // + top = u3a_push(&pil_u); + *top = u3h(a); } a = *top; From 00ed9b1c1c526729d6f8cb0fd3941900815d91b8 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sat, 12 Sep 2020 23:19:18 -0700 Subject: [PATCH 328/933] u3: refactors atom reallocation in u3a_take() --- pkg/urbit/noun/allocate.c | 69 ++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/pkg/urbit/noun/allocate.c b/pkg/urbit/noun/allocate.c index 939b9e7987..345e4a50ba 100644 --- a/pkg/urbit/noun/allocate.c +++ b/pkg/urbit/noun/allocate.c @@ -1026,12 +1026,48 @@ _me_gain_use(u3_noun dog) } } +#undef VERBOSE_TAKE + +/* _ca_take_atom(): reallocate an indirect atom off the stack. +*/ +static inline u3_atom +_ca_take_atom(u3a_atom* old_u) +{ + c3_w* new_w = u3a_walloc(old_u->len_w + c3_wiseof(u3a_atom)); + u3a_atom* new_u = (u3a_atom*)(void *)new_w; + u3_noun new = u3a_to_pug(u3a_outa(new_u)); + +#ifdef VERBOSE_TAKE + u3l_log("%s: atom %p to %p\r\n", ( c3y == u3a_is_north(u3R) ) + ? "north" + : "south", + old_u, + new_u); +#endif + + // XX use memcpy? + // + new_u->mug_w = old_u->mug_w; + new_u->len_w = old_u->len_w; + { + c3_w i_w; + + for ( i_w=0; i_w < old_u->len_w; i_w++ ) { + new_u->buf_w[i_w] = old_u->buf_w[i_w]; + } + } + + // borrow mug slot to record new destination in [old_u] + // + old_u->mug_w = new; + + return new; +} + #define TAKE_ROOT 0 #define TAKE_HEAD 1 #define TAKE_TAIL 2 -#undef VERBOSE_TAKE - // stack frame for recording head vs tail iteration // // In Hoon, this structure would be as follows: @@ -1177,34 +1213,7 @@ u3a_take(u3_noun veb) } else { if ( c3y == u3a_is_atom(veb) ) { - u3a_atom* old_u = u3a_to_ptr(veb); - c3_w* new_w = u3a_walloc(old_u->len_w + c3_wiseof(u3a_atom)); - u3a_atom* new_u = (u3a_atom*)(void *)new_w; - u3_noun new = u3a_to_pug(u3a_outa(new_u)); - -#ifdef VERBOSE_TAKE - u3l_log("%s: atom %p to %p\r\n", ( c3y == nor_o ) - ? "north" - : "south", - old_u, - new_u); -#endif - - new_u->mug_w = old_u->mug_w; - new_u->len_w = old_u->len_w; - { - c3_w i_w; - - for ( i_w=0; i_w < old_u->len_w; i_w++ ) { - new_u->buf_w[i_w] = old_u->buf_w[i_w]; - } - } - - // Borrow mug slot to record new destination in .old_u. - // - old_u->mug_w = new; - - pro = new; + pro = _ca_take_atom((u3a_atom*)veb_u); goto retreat; } else { From a0621f2bbf0ac32a2cace38b89d0b9e000928a5d Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sat, 12 Sep 2020 23:31:00 -0700 Subject: [PATCH 329/933] u3: refactors cell reallocation, stack struct in u3a_take() --- pkg/urbit/noun/allocate.c | 101 +++++++++++++++++++++----------------- 1 file changed, 55 insertions(+), 46 deletions(-) diff --git a/pkg/urbit/noun/allocate.c b/pkg/urbit/noun/allocate.c index 345e4a50ba..fde57e023a 100644 --- a/pkg/urbit/noun/allocate.c +++ b/pkg/urbit/noun/allocate.c @@ -1064,6 +1064,36 @@ _ca_take_atom(u3a_atom* old_u) return new; } +/* _ca_take_cell(): reallocate a cell atom off the stack. +*/ +static inline u3_cell +_ca_take_cell(u3a_cell* old_u, u3_noun hed, u3_noun tel) +{ + // XX use u3a_celloc? + // + c3_w* new_w = u3a_walloc(c3_wiseof(u3a_cell)); + u3a_cell* new_u = (u3a_cell*)(void *)new_w; + u3_cell new = u3a_to_pom(u3a_outa(new_u)); + +#ifdef VERBOSE_TAKE + u3l_log("%s: cell %p to %p\r\n", ( c3y == u3a_is_north(u3R) ) + ? "north" + : "south", + old_u, + new_u); +#endif + + new_u->mug_w = old_u->mug_w; + new_u->hed = hed; + new_u->tel = tel; + + // borrow mug slot to record new destination in [old_u] + // + old_u->mug_w = new; + + return new; +} + #define TAKE_ROOT 0 #define TAKE_HEAD 1 #define TAKE_TAIL 2 @@ -1073,23 +1103,23 @@ _ca_take_atom(u3a_atom* old_u) // In Hoon, this structure would be as follows: // // $% [%root ~] -// [%head old=* new=*] -// [%tail old=* new=*] +// [%head old=^] +// [%tail old=^ hed=*] // == // typedef struct takeframe { - c3_y tag_y; - u3a_cell* old_u; - u3a_cell* new_u; + c3_y tag_y; + u3_cell old; + u3_noun hed; } takeframe; static inline void -_ca_take_push(c3_ys mov, - c3_ys off, - c3_y tag_y, - u3a_cell* old_u, - u3a_cell* new_u) +_ca_take_push(c3_ys mov, + c3_ys off, + c3_y tag_y, + u3_cell old, + u3_cell hed) { u3R->cap_p += mov; @@ -1109,8 +1139,8 @@ _ca_take_push(c3_ys mov, takeframe* fam_u = u3to(takeframe, u3R->cap_p + off); fam_u->tag_y = tag_y; - fam_u->old_u = old_u; - fam_u->new_u = new_u; + fam_u->old = old; + fam_u->hed = hed; } static inline takeframe @@ -1211,32 +1241,15 @@ u3a_take(u3_noun veb) pro = nov; goto retreat; } + else if ( c3y == u3a_is_atom(veb) ) { + pro = _ca_take_atom((u3a_atom*)veb_u); + goto retreat; + } else { - if ( c3y == u3a_is_atom(veb) ) { - pro = _ca_take_atom((u3a_atom*)veb_u); - goto retreat; - } - else { - u3a_cell* old_u = u3a_to_ptr(veb); - // XX use u3a_celloc? - // - c3_w* new_w = u3a_walloc(c3_wiseof(u3a_cell)); - u3a_cell* new_u = (u3a_cell*)(void *)new_w; - -#ifdef VERBOSE_TAKE - u3l_log("%s: cell %p to %p\r\n", ( c3y == nor_o ) - ? "north" - : "south", - old_u, - new_u); -#endif - - new_u->mug_w = old_u->mug_w; - - veb = old_u->hed; - _ca_take_push(mov, off, TAKE_HEAD, old_u, new_u); - goto advance; - } + u3a_cell* old_u = (u3a_cell*)veb_u; + _ca_take_push(mov, off, TAKE_HEAD, veb, 0); + veb = old_u->hed; + goto advance; } } } @@ -1261,10 +1274,10 @@ u3a_take(u3_noun veb) // and advance to copy the tail // case TAKE_HEAD: { - fam_u.new_u->hed = pro; + u3a_cell* old_u = u3a_to_ptr(fam_u.old); - veb = fam_u.old_u->tel; - _ca_take_push(mov, off, TAKE_TAIL, fam_u.old_u, fam_u.new_u); + _ca_take_push(mov, off, TAKE_TAIL, fam_u.old, pro); + veb = old_u->tel; goto advance; } @@ -1272,13 +1285,9 @@ u3a_take(u3_noun veb) // and produce the whole copied cell (as if it were a read from above). // case TAKE_TAIL: { - fam_u.new_u->tel = pro; - pro = u3a_to_pom(u3a_outa(fam_u.new_u)); - - // Borrow mug slot to record new destination in old_u. - // - fam_u.old_u->mug_w = pro; + u3a_cell* old_u = u3a_to_ptr(fam_u.old); + pro = _ca_take_cell(old_u, fam_u.hed, pro); goto retreat; } } From 8b08a8b5c8da4e6ac5b00eddcded65c775b592d5 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 14 Sep 2020 15:44:11 -0700 Subject: [PATCH 330/933] u3: refactors u3a_take() to use road stack api --- pkg/urbit/noun/allocate.c | 97 +++++++++++++-------------------------- 1 file changed, 31 insertions(+), 66 deletions(-) diff --git a/pkg/urbit/noun/allocate.c b/pkg/urbit/noun/allocate.c index fde57e023a..21e960f1d3 100644 --- a/pkg/urbit/noun/allocate.c +++ b/pkg/urbit/noun/allocate.c @@ -1114,75 +1114,28 @@ typedef struct takeframe u3_noun hed; } takeframe; -static inline void -_ca_take_push(c3_ys mov, - c3_ys off, - c3_y tag_y, - u3_cell old, - u3_cell hed) -{ - u3R->cap_p += mov; - - // ensure we haven't overflowed the stack - // (off==0 means we're on a north road) - // - if ( 0 == off ) { - if( !(u3R->cap_p > u3R->hat_p) ) { - u3m_bail(c3__meme); - } - } - else { - if( !(u3R->cap_p < u3R->hat_p) ) { - u3m_bail(c3__meme); - } - } - - takeframe* fam_u = u3to(takeframe, u3R->cap_p + off); - fam_u->tag_y = tag_y; - fam_u->old = old; - fam_u->hed = hed; -} - -static inline takeframe -_ca_take_pop(c3_ys mov, c3_ys off) -{ - takeframe* fam_u = u3to(takeframe, u3R->cap_p + off); - u3R->cap_p -= mov; - - return *fam_u; -} - /* u3a_take(): gain, copying juniors. */ u3_noun u3a_take(u3_noun veb) { - c3_assert(u3_none != veb); + u3a_pile pil_u; + u3_noun pro; + c3_o nor_o = u3a_is_north(u3R); u3t_on(coy_o); - // initialize signed stack offsets (relative to north/south road) + c3_assert(u3_none != veb); + + u3a_pile_prep(&pil_u, sizeof(takeframe)); + + // push the ROOT stack frame (our termination condition) // - c3_o nor_o = u3a_is_north(u3R); - c3_ys mov, off; { - c3_y wis_y = c3_wiseof(takeframe); - mov = ( c3y == nor_o ? -wis_y : wis_y ); - off = ( c3y == nor_o ? 0 : -wis_y ); + takeframe* fam_u = u3a_push(&pil_u); + fam_u->tag_y = TAKE_ROOT; } - // stash the current stack post - // - u3p(takeframe) cap_p = u3R->cap_p; - - // push the (only) ROOT stack frame (our termination condition) - // - _ca_take_push(mov, off, TAKE_ROOT, 0, 0); - - // the finished copy of our current noun .veb - // - u3_noun pro; - // read from the current noun .veb // advance: { @@ -1246,8 +1199,16 @@ u3a_take(u3_noun veb) goto retreat; } else { - u3a_cell* old_u = (u3a_cell*)veb_u; - _ca_take_push(mov, off, TAKE_HEAD, veb, 0); + u3a_cell* old_u = (u3a_cell*)veb_u; + + { + takeframe* fam_u = u3a_push(&pil_u); + u3a_pile_sane(&pil_u); + + fam_u->tag_y = TAKE_HEAD; + fam_u->old = veb; + } + veb = old_u->hed; goto advance; } @@ -1257,9 +1218,9 @@ u3a_take(u3_noun veb) // consume: popped stack frame, and .pro from above // retreat: { - takeframe fam_u = _ca_take_pop(mov, off); + takeframe* fam_u = u3a_peek(&pil_u); - switch ( fam_u.tag_y ) { + switch ( fam_u->tag_y ) { default: { c3_assert(0); } @@ -1267,6 +1228,7 @@ u3a_take(u3_noun veb) // .fam_u is our stack root, we're done. // case TAKE_ROOT: { + u3a_pop(&pil_u); break; } @@ -1274,9 +1236,11 @@ u3a_take(u3_noun veb) // and advance to copy the tail // case TAKE_HEAD: { - u3a_cell* old_u = u3a_to_ptr(fam_u.old); + u3a_cell* old_u = u3a_to_ptr(fam_u->old); + + fam_u->tag_y = TAKE_TAIL; + fam_u->hed = pro; - _ca_take_push(mov, off, TAKE_TAIL, fam_u.old, pro); veb = old_u->tel; goto advance; } @@ -1285,9 +1249,10 @@ u3a_take(u3_noun veb) // and produce the whole copied cell (as if it were a read from above). // case TAKE_TAIL: { - u3a_cell* old_u = u3a_to_ptr(fam_u.old); + u3a_cell* old_u = u3a_to_ptr(fam_u->old); - pro = _ca_take_cell(old_u, fam_u.hed, pro); + pro = _ca_take_cell(old_u, fam_u->hed, pro); + u3a_pop(&pil_u); goto retreat; } } @@ -1295,7 +1260,7 @@ u3a_take(u3_noun veb) // sanity check // - c3_assert( u3R->cap_p == cap_p ); + c3_assert( c3y == u3a_pile_done(&pil_u) ); u3t_off(coy_o); From c591eb220d7e9a22c37eb36dcade393a32f648a6 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 14 Sep 2020 15:52:51 -0700 Subject: [PATCH 331/933] u3: factors out "advance" block of u3a_take() --- pkg/urbit/noun/allocate.c | 88 +++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 41 deletions(-) diff --git a/pkg/urbit/noun/allocate.c b/pkg/urbit/noun/allocate.c index 21e960f1d3..05e2cc92e1 100644 --- a/pkg/urbit/noun/allocate.c +++ b/pkg/urbit/noun/allocate.c @@ -1111,37 +1111,17 @@ typedef struct takeframe { c3_y tag_y; u3_cell old; - u3_noun hed; + u3_weak hed; } takeframe; -/* u3a_take(): gain, copying juniors. -*/ -u3_noun -u3a_take(u3_noun veb) +static inline u3_noun +_ca_take_next(u3a_pile* pil_u, u3_noun veb) { - u3a_pile pil_u; - u3_noun pro; - c3_o nor_o = u3a_is_north(u3R); + c3_o nor_o = u3a_is_north(u3R); - u3t_on(coy_o); - - c3_assert(u3_none != veb); - - u3a_pile_prep(&pil_u, sizeof(takeframe)); - - // push the ROOT stack frame (our termination condition) - // - { - takeframe* fam_u = u3a_push(&pil_u); - fam_u->tag_y = TAKE_ROOT; - } - - // read from the current noun .veb - // - advance: { + while (1) { if ( c3y == u3a_is_cat(veb) ) { - pro = veb; - goto retreat; + return veb; } // senior pointers are not refcounted // @@ -1149,8 +1129,7 @@ u3a_take(u3_noun veb) ? u3a_north_is_senior(u3R, veb) : u3a_south_is_senior(u3R, veb)) ) { - pro = veb; - goto retreat; + return veb; } // not junior; a normal pointer in our road -- refcounted // @@ -1161,10 +1140,7 @@ u3a_take(u3_noun veb) // bypass normal road checks in u3k // _me_gain_use(veb); - pro = veb; - goto retreat; - - + return veb; } // junior pointers are copied // @@ -1191,29 +1167,55 @@ u3a_take(u3_noun veb) // bypass normal road checks in u3k // _me_gain_use(nov); - pro = nov; - goto retreat; + return nov; } else if ( c3y == u3a_is_atom(veb) ) { - pro = _ca_take_atom((u3a_atom*)veb_u); - goto retreat; + return _ca_take_atom((u3a_atom*)veb_u); } else { u3a_cell* old_u = (u3a_cell*)veb_u; { - takeframe* fam_u = u3a_push(&pil_u); - u3a_pile_sane(&pil_u); + takeframe* fam_u = u3a_push(pil_u); + u3a_pile_sane(pil_u); fam_u->tag_y = TAKE_HEAD; fam_u->old = veb; + fam_u->hed = u3_none; } veb = old_u->hed; - goto advance; + continue; } } } +} + +/* u3a_take(): gain, copying juniors. +*/ +u3_noun +u3a_take(u3_noun veb) +{ + u3a_pile pil_u; + u3_noun pro; + c3_o nor_o = u3a_is_north(u3R); + + u3t_on(coy_o); + + c3_assert(u3_none != veb); + + u3a_pile_prep(&pil_u, sizeof(takeframe)); + + // push the ROOT stack frame (our termination condition) + // + { + takeframe* fam_u = u3a_push(&pil_u); + fam_u->tag_y = TAKE_ROOT; + } + + // read from the current noun .veb + // + pro = _ca_take_next(&pil_u, veb); // consume: popped stack frame, and .pro from above // @@ -1237,12 +1239,15 @@ u3a_take(u3_noun veb) // case TAKE_HEAD: { u3a_cell* old_u = u3a_to_ptr(fam_u->old); + c3_assert( u3_none == fam_u->hed ); fam_u->tag_y = TAKE_TAIL; fam_u->hed = pro; - veb = old_u->tel; - goto advance; + // veb = old_u->tel; + // goto advance; + pro = _ca_take_next(&pil_u, old_u->tel); + goto retreat; } // .pro is the copied tail of a cell; save a pointer to it in .new_u, @@ -1250,6 +1255,7 @@ u3a_take(u3_noun veb) // case TAKE_TAIL: { u3a_cell* old_u = u3a_to_ptr(fam_u->old); + c3_assert( u3_none != fam_u->hed ); pro = _ca_take_cell(old_u, fam_u->hed, pro); u3a_pop(&pil_u); From fae8980660465cae3a42fdb88e7d6e3d40d46e83 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 14 Sep 2020 16:03:13 -0700 Subject: [PATCH 332/933] u3: refactors "retreat" block of u3a_take in to do/while loop --- pkg/urbit/noun/allocate.c | 102 ++++++++++---------------------------- 1 file changed, 27 insertions(+), 75 deletions(-) diff --git a/pkg/urbit/noun/allocate.c b/pkg/urbit/noun/allocate.c index 05e2cc92e1..ba9d8bbd11 100644 --- a/pkg/urbit/noun/allocate.c +++ b/pkg/urbit/noun/allocate.c @@ -1094,25 +1094,11 @@ _ca_take_cell(u3a_cell* old_u, u3_noun hed, u3_noun tel) return new; } -#define TAKE_ROOT 0 -#define TAKE_HEAD 1 -#define TAKE_TAIL 2 - -// stack frame for recording head vs tail iteration -// -// In Hoon, this structure would be as follows: -// -// $% [%root ~] -// [%head old=^] -// [%tail old=^ hed=*] -// == -// -typedef struct takeframe +typedef struct _ca_take { - c3_y tag_y; - u3_cell old; - u3_weak hed; -} takeframe; + u3_weak hed; // taken head + u3_cell old; // old cell +} _ca_take; static inline u3_noun _ca_take_next(u3a_pile* pil_u, u3_noun veb) @@ -1176,12 +1162,11 @@ _ca_take_next(u3a_pile* pil_u, u3_noun veb) u3a_cell* old_u = (u3a_cell*)veb_u; { - takeframe* fam_u = u3a_push(pil_u); + _ca_take* fam_u = u3a_push(pil_u); u3a_pile_sane(pil_u); - fam_u->tag_y = TAKE_HEAD; - fam_u->old = veb; - fam_u->hed = u3_none; + fam_u->hed = u3_none; + fam_u->old = veb; } veb = old_u->hed; @@ -1196,78 +1181,45 @@ _ca_take_next(u3a_pile* pil_u, u3_noun veb) u3_noun u3a_take(u3_noun veb) { - u3a_pile pil_u; - u3_noun pro; - c3_o nor_o = u3a_is_north(u3R); + u3a_pile pil_u; + _ca_take* fam_u; + u3_noun pro; + c3_o nor_o = u3a_is_north(u3R); u3t_on(coy_o); c3_assert(u3_none != veb); - u3a_pile_prep(&pil_u, sizeof(takeframe)); + u3a_pile_prep(&pil_u, sizeof(*fam_u)); - // push the ROOT stack frame (our termination condition) - // - { - takeframe* fam_u = u3a_push(&pil_u); - fam_u->tag_y = TAKE_ROOT; - } - - // read from the current noun .veb + // commence taking // pro = _ca_take_next(&pil_u, veb); - // consume: popped stack frame, and .pro from above + // process cell results // - retreat: { - takeframe* fam_u = u3a_peek(&pil_u); + if ( c3n == u3a_pile_done(&pil_u) ) { + fam_u = u3a_peek(&pil_u); - switch ( fam_u->tag_y ) { - default: { - c3_assert(0); - } - - // .fam_u is our stack root, we're done. + do { + // fam_u is a head-frame: stash copy and continue into the tail // - case TAKE_ROOT: { - u3a_pop(&pil_u); - break; - } - - // .pro is the copied head of a cell; save a pointer to it in .new_u - // and advance to copy the tail - // - case TAKE_HEAD: { + if ( u3_none == fam_u->hed ) { u3a_cell* old_u = u3a_to_ptr(fam_u->old); - c3_assert( u3_none == fam_u->hed ); - - fam_u->tag_y = TAKE_TAIL; - fam_u->hed = pro; - - // veb = old_u->tel; - // goto advance; - pro = _ca_take_next(&pil_u, old_u->tel); - goto retreat; + fam_u->hed = pro; + pro = _ca_take_next(&pil_u, old_u->tel); + fam_u = u3a_peek(&pil_u); } - - // .pro is the copied tail of a cell; save a pointer to it in .new_u, - // and produce the whole copied cell (as if it were a read from above). + // fam_u is a tail-frame: copy cell and pop the stack // - case TAKE_TAIL: { + else { u3a_cell* old_u = u3a_to_ptr(fam_u->old); - c3_assert( u3_none != fam_u->hed ); - - pro = _ca_take_cell(old_u, fam_u->hed, pro); - u3a_pop(&pil_u); - goto retreat; + pro = _ca_take_cell(old_u, fam_u->hed, pro); + fam_u = u3a_pop(&pil_u); } - } + } while ( c3n == u3a_pile_done(&pil_u) ); } - // sanity check - // - c3_assert( c3y == u3a_pile_done(&pil_u) ); - u3t_off(coy_o); return pro; From 740c0bbf81d212889d363b824b01011d5bb05344 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 14 Sep 2020 16:29:54 -0700 Subject: [PATCH 333/933] u3: splits u3a_take into north/south implementations --- pkg/urbit/noun/allocate.c | 194 +++++++++++++++++++++++++++----------- 1 file changed, 140 insertions(+), 54 deletions(-) diff --git a/pkg/urbit/noun/allocate.c b/pkg/urbit/noun/allocate.c index ba9d8bbd11..68892b1af2 100644 --- a/pkg/urbit/noun/allocate.c +++ b/pkg/urbit/noun/allocate.c @@ -1100,74 +1100,54 @@ typedef struct _ca_take u3_cell old; // old cell } _ca_take; +/* _ca_take_next_south: take next noun, pushing cells on stack. +*/ static inline u3_noun -_ca_take_next(u3a_pile* pil_u, u3_noun veb) +_ca_take_next_north(u3a_pile* pil_u, u3_noun veb) { - c3_o nor_o = u3a_is_north(u3R); - - while (1) { - if ( c3y == u3a_is_cat(veb) ) { - return veb; - } - // senior pointers are not refcounted + while ( 1 ) { + // direct atoms and senior refs are not counted. // - else if ( c3y == (( c3y == nor_o ) - ? u3a_north_is_senior(u3R, veb) - : u3a_south_is_senior(u3R, veb)) ) + if ( (c3y == u3a_is_cat(veb)) + || (c3y == u3a_north_is_senior(u3R, veb)) ) { return veb; } - // not junior; a normal pointer in our road -- refcounted + // not junior; normal (heap) refs on our road are counted. // - else if ( c3n == (( c3y == nor_o ) - ? u3a_north_is_junior(u3R, veb) - : u3a_south_is_junior(u3R, veb)) ) - { - // bypass normal road checks in u3k - // - _me_gain_use(veb); + else if ( c3n == u3a_north_is_junior(u3R, veb) ) { + _me_gain_use(veb); // bypass branches in u3k() return veb; } - // junior pointers are copied + // junior (stack) refs are copied. // else { u3a_noun* veb_u = u3a_to_ptr(veb); - // 32-bit mug_w: already copied .veb and .mug_w is the pointer + // 32-bit mug_w: already copied [veb] and [mug_w] is the new ref. // if ( veb_u->mug_w >> 31 ) { u3_noun nov = (u3_noun)veb_u->mug_w; - c3_assert( c3y == (( c3y == nor_o) - ? u3a_north_is_normal(u3R, nov) - : u3a_south_is_normal(u3R, nov)) ); + c3_assert( c3y == u3a_north_is_normal(u3R, nov) ); #ifdef VERBOSE_TAKE - u3l_log("%s: %p is already %p\r\n", ( c3y == nor_o ) - ? "north" - : "south", - veb_u, - u3a_to_ptr(nov)); + u3l_log("north: %p is already %p\r\n", veb_u, u3a_to_ptr(nov)); #endif - // bypass normal road checks in u3k - // - _me_gain_use(nov); + _me_gain_use(nov); // bypass branches in u3k() return nov; } else if ( c3y == u3a_is_atom(veb) ) { return _ca_take_atom((u3a_atom*)veb_u); } else { - u3a_cell* old_u = (u3a_cell*)veb_u; + u3a_cell* old_u = (u3a_cell*)veb_u; + _ca_take* fam_u = u3a_push(pil_u); + u3a_pile_sane(pil_u); - { - _ca_take* fam_u = u3a_push(pil_u); - u3a_pile_sane(pil_u); - - fam_u->hed = u3_none; - fam_u->old = veb; - } + fam_u->hed = u3_none; + fam_u->old = veb; veb = old_u->hed; continue; @@ -1176,25 +1156,75 @@ _ca_take_next(u3a_pile* pil_u, u3_noun veb) } } -/* u3a_take(): gain, copying juniors. +/* _ca_take_next_south: take next noun, pushing cells on stack. */ -u3_noun -u3a_take(u3_noun veb) +static inline u3_noun +_ca_take_next_south(u3a_pile* pil_u, u3_noun veb) +{ + while ( 1 ) { + // direct atoms and senior refs are not counted. + // + if ( (c3y == u3a_is_cat(veb)) + || (c3y == u3a_south_is_senior(u3R, veb)) ) + { + return veb; + } + // not junior; a normal pointer in our road -- refcounted + // + else if ( c3n == u3a_south_is_junior(u3R, veb) ) { + _me_gain_use(veb); // bypass branches in u3k() + return veb; + } + // junior (stack) refs are copied. + // + else { + u3a_noun* veb_u = u3a_to_ptr(veb); + + // 32-bit mug_w: already copied [veb] and [mug_w] is the new ref. + // + if ( veb_u->mug_w >> 31 ) { + u3_noun nov = (u3_noun)veb_u->mug_w; + + c3_assert( c3y == u3a_south_is_normal(u3R, nov) ); + +#ifdef VERBOSE_TAKE + u3l_log("south: %p is already %p\r\n", veb_u, u3a_to_ptr(nov)); +#endif + + _me_gain_use(nov); // bypass branches in u3k() + return nov; + } + else if ( c3y == u3a_is_atom(veb) ) { + return _ca_take_atom((u3a_atom*)veb_u); + } + else { + u3a_cell* old_u = (u3a_cell*)veb_u; + _ca_take* fam_u = u3a_push(pil_u); + u3a_pile_sane(pil_u); + + fam_u->hed = u3_none; + fam_u->old = veb; + + veb = old_u->hed; + continue; + } + } + } +} + +/* _ca_take_north(): in a north road, gain, copying juniors (from stack). +*/ +static u3_noun +_ca_take_north(u3_noun veb) { - u3a_pile pil_u; - _ca_take* fam_u; u3_noun pro; - c3_o nor_o = u3a_is_north(u3R); - - u3t_on(coy_o); - - c3_assert(u3_none != veb); - + _ca_take* fam_u; + u3a_pile pil_u; u3a_pile_prep(&pil_u, sizeof(*fam_u)); // commence taking // - pro = _ca_take_next(&pil_u, veb); + pro = _ca_take_next_north(&pil_u, veb); // process cell results // @@ -1207,7 +1237,7 @@ u3a_take(u3_noun veb) if ( u3_none == fam_u->hed ) { u3a_cell* old_u = u3a_to_ptr(fam_u->old); fam_u->hed = pro; - pro = _ca_take_next(&pil_u, old_u->tel); + pro = _ca_take_next_north(&pil_u, old_u->tel); fam_u = u3a_peek(&pil_u); } // fam_u is a tail-frame: copy cell and pop the stack @@ -1220,8 +1250,64 @@ u3a_take(u3_noun veb) } while ( c3n == u3a_pile_done(&pil_u) ); } - u3t_off(coy_o); + return pro; +} +/* _ca_take_south(): in a south road, gain, copying juniors (from stack). +*/ +static u3_noun +_ca_take_south(u3_noun veb) +{ + u3_noun pro; + _ca_take* fam_u; + u3a_pile pil_u; + u3a_pile_prep(&pil_u, sizeof(*fam_u)); + // commence taking + // + pro = _ca_take_next_south(&pil_u, veb); + + // process cell results + // + if ( c3n == u3a_pile_done(&pil_u) ) { + fam_u = u3a_peek(&pil_u); + + do { + // fam_u is a head-frame: stash copy and continue into the tail + // + if ( u3_none == fam_u->hed ) { + u3a_cell* old_u = u3a_to_ptr(fam_u->old); + fam_u->hed = pro; + pro = _ca_take_next_south(&pil_u, old_u->tel); + fam_u = u3a_peek(&pil_u); + } + // fam_u is a tail-frame: copy cell and pop the stack + // + else { + u3a_cell* old_u = u3a_to_ptr(fam_u->old); + pro = _ca_take_cell(old_u, fam_u->hed, pro); + fam_u = u3a_pop(&pil_u); + } + } while ( c3n == u3a_pile_done(&pil_u) ); + } + + return pro; +} + +/* u3a_take(): gain, copying juniors. +*/ +u3_noun +u3a_take(u3_noun veb) +{ + u3_noun pro; + u3t_on(coy_o); + + c3_assert(u3_none != veb); + + pro = ( c3y == u3a_is_north(u3R) ) + ? _ca_take_north(veb) + : _ca_take_south(veb); + + u3t_off(coy_o); return pro; } From c1d22949afdc45105f18b059654fc60517ba3701 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 14 Sep 2020 17:56:45 -0700 Subject: [PATCH 334/933] u3: rewrites u3s_cue to use road stack api --- pkg/urbit/noun/serial.c | 251 ++++++++++++++-------------------------- 1 file changed, 89 insertions(+), 162 deletions(-) diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index 9accdf733d..9fcb766ec7 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -501,111 +501,35 @@ u3s_jam_file(u3_noun a, c3_c* pas_c) } } -#define CUE_ROOT 0 -#define CUE_HEAD 1 -#define CUE_TAIL 2 - -// stack frame for recording head vs tail iteration -// -// In Hoon, this structure would be as follows: -// -// $% [%root ~] -// [%head cell-cursor=@] -// [%tail cell-cursor=@ hed-width=@ hed-value=*] -// == -// -typedef struct _cs_cue_frame -{ - c3_y tag_y; - u3_atom cur; - u3_atom wid; - u3_noun hed; -} cueframe; - -/* _cs_cue_push(): construct a cueframe and push it onto the road stack. +/* _cs_cue: stack frame for tracking intermediate cell results */ -static inline void -_cs_cue_push(c3_ys mov, - c3_ys off, - c3_y tag_y, - u3_atom cur, - u3_atom wid, - u3_noun hed) +typedef struct _cs_cue { + u3_weak hed; // head of a cell or u3_none + u3_atom wid; // bitwidth of [hed] or 0 + u3_atom cur; // bit-cursor position +} _cs_cue; + +/* _cs_rub: rub, TRANSFER [cur], RETAIN [a] +*/ +static inline u3_noun +_cs_rub(u3_atom cur, u3_atom a) { - u3R->cap_p += mov; - - // ensure we haven't overflowed the stack - // (off==0 means we're on a north road) - // - if ( 0 == off ) { - if( !(u3R->cap_p > u3R->hat_p) ) { - u3m_bail(c3__meme); - } - } - else { - if( !(u3R->cap_p < u3R->hat_p) ) { - u3m_bail(c3__meme); - } - } - - cueframe* fam_u = u3to(cueframe, u3R->cap_p + off); - fam_u->tag_y = tag_y; - fam_u->cur = cur; - fam_u->wid = wid; - fam_u->hed = hed; + u3_noun pro = u3qe_rub(cur, a); + u3z(cur); + return pro; } -/* _cs_cue_pop(): pop a cueframe off the road stack and return it. +/* _cs_cue_next(): advance into [a], reading next value +** TRANSFER [cur], RETAIN [a] */ -static inline cueframe -_cs_cue_pop(c3_ys mov, c3_ys off) +static inline u3_noun +_cs_cue_next(u3a_pile* pil_u, + u3p(u3h_root) har_p, + u3_atom cur, + u3_atom a, + u3_atom* wid) { - cueframe* fam_u = u3to(cueframe, u3R->cap_p + off); - u3R->cap_p -= mov; - - return *fam_u; -} - -/* u3s_cue(): cue [a] -*/ -u3_noun -u3s_cue(u3_atom a) -{ - // initialize signed stack offsets (relative to north/south road) - // - c3_ys mov, off; - { - c3_y wis_y = c3_wiseof(cueframe); - c3_o nor_o = u3a_is_north(u3R); - mov = ( c3y == nor_o ? -wis_y : wis_y ); - off = ( c3y == nor_o ? 0 : -wis_y ); - } - - // initialize a hash table for dereferencing backrefs - // - u3p(u3h_root) har_p = u3h_new(); - - // stash the current stack post - // - u3p(cueframe) cap_p = u3R->cap_p; - - // push the (only) ROOT stack frame (our termination condition) - // - _cs_cue_push(mov, off, CUE_ROOT, 0, 0, 0); - - // initialize cursor to bit-position 0 - // - u3_atom cur = 0; - - // the bitwidth and product from reading at cursor - // - u3_atom wid, pro; - - // read from atom at cursor - // - // TRANSFER .cur - // - advance: { + while ( 1 ) { // read tag bit at cur // c3_y tag_y = u3qc_cut(0, cur, 1, a); @@ -615,19 +539,14 @@ u3s_cue(u3_atom a) // produce atom and the width we read // if ( 0 == tag_y ) { - u3_noun bur; - { - u3_noun x = u3qa_inc(cur); - bur = u3qe_rub(x, a); - u3z(x); - } + u3_noun bur = _cs_rub(u3i_vint(cur), a); + u3_noun pro = u3k(u3t(bur)); - pro = u3k(u3t(bur)); u3h_put(har_p, cur, u3k(pro)); - wid = u3qa_inc(u3h(bur)); + *wid = u3qa_inc(u3h(bur)); u3z(bur); - goto retreat; + return pro; } else { // read tag bit at (1 + cur) @@ -643,86 +562,94 @@ u3s_cue(u3_atom a) // produce referenced value and the width we read // if ( 1 == tag_y ) { - u3_noun bur; - { - u3_noun x = u3ka_add(2, cur); - bur = u3qe_rub(x, a); - u3z(x); - } + u3_noun bur = _cs_rub(u3ka_add(2, cur), a); + u3_noun pro = u3x_good(u3h_get(har_p, u3t(bur))); - pro = u3h_get(har_p, u3k(u3t(bur))); - - if ( u3_none == pro ) { - return u3m_bail(c3__exit); - } - - wid = u3qa_add(2, u3h(bur)); + *wid = u3qa_add(2, u3h(bur)); u3z(bur); - goto retreat; + return pro; } // next bit unset, (2 + cur) points to the head of a cell // - // push a frame to mark HEAD recursion and read the head + // push a head-frame onto the road stack and read the head // else { - _cs_cue_push(mov, off, CUE_HEAD, cur, 0, 0); + _cs_cue* fam_u = u3a_push(pil_u); + u3a_pile_sane(pil_u); + + // NB: fam_u->wid unused in head-frame + // + fam_u->hed = u3_none; + fam_u->cur = cur; cur = u3qa_add(2, cur); - goto advance; + continue; } } } +} - // consume: popped stack frame, .wid and .pro from above. +u3_noun +u3s_cue(u3_atom a) +{ + // pro: cue'd noun product + // wid: bitwidth read to produce [pro] + // fam_u: stack frame + // har_p: backreference table + // pil_u: stack control structur // - // TRANSFER .wid, .pro, and contents of .fam_u - // (.cur is in scope, but we have already lost our reference to it) + u3_noun pro; + u3_atom wid, cur = 0; + _cs_cue* fam_u; + u3p(u3h_root) har_p = u3h_new(); + u3a_pile pil_u; + + // initialize stack control // - retreat: { - cueframe fam_u = _cs_cue_pop(mov, off); + u3a_pile_prep(&pil_u, sizeof(*fam_u)); - switch ( fam_u.tag_y ) { - default: { - c3_assert(0); - } + // commence cueing at bit-position 0 + // + pro = _cs_cue_next(&pil_u, har_p, 0, a, &wid); - // fam_u is our stack root, we're done. + // process cell results + // + if ( c3n == u3a_pile_done(&pil_u) ) { + fam_u = u3a_peek(&pil_u); + + do { + // fam_u is a head-frame: stash [pro] and [wid]; continue into the tail // - case CUE_ROOT: { - break; - } + if ( u3_none == fam_u->hed ) { + // NB: fam_u->wid unused in head-frame + // + fam_u->hed = pro; + fam_u->wid = wid; - // .wid and .pro are the head of the cell at fam_u.cur. - // save them (and the cell cursor) in a TAIL frame, - // set the cursor to the tail and read there. + // continue reading at the bit-position after [pro] + { + u3_noun cur = u3ka_add(2, u3qa_add(wid, fam_u->cur)); + pro = _cs_cue_next(&pil_u, har_p, cur, a, &wid); + } + + fam_u = u3a_peek(&pil_u); + } + // fam_u is a tail-frame: cons cell and save for backrefs, + // recalculate [wid], and pop the stack // - case CUE_HEAD: { - _cs_cue_push(mov, off, CUE_TAIL, fam_u.cur, wid, pro); - - cur = u3ka_add(2, u3qa_add(wid, fam_u.cur)); - goto advance; + else { + pro = u3nc(fam_u->hed, pro); + u3h_put(har_p, fam_u->cur, u3k(pro)); + u3z(fam_u->cur); + wid = u3ka_add(2, u3ka_add(wid, fam_u->wid)); + fam_u = u3a_pop(&pil_u); } - - // .wid and .pro are the tail of the cell at fam_u.cur, - // construct the cell, memoize it, and produce it along with - // its total width (as if it were a read from above). - // - case CUE_TAIL: { - pro = u3nc(fam_u.hed, pro); - u3h_put(har_p, fam_u.cur, u3k(pro)); - wid = u3ka_add(2, u3ka_add(wid, fam_u.wid)); - goto retreat; - } - } + } while ( c3n == u3a_pile_done(&pil_u) ); } u3z(wid); u3h_free(har_p); - // sanity check - // - c3_assert( u3R->cap_p == cap_p ); - return pro; } From e014baacac31da04f18e96e3201ddb96873e70ef Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 14 Sep 2020 23:04:18 -0700 Subject: [PATCH 335/933] u3: refactors u3r_sing internals to use road stack api --- pkg/urbit/noun/retrieve.c | 103 ++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 54 deletions(-) diff --git a/pkg/urbit/noun/retrieve.c b/pkg/urbit/noun/retrieve.c index 3c3ec0a14d..79724ffe58 100644 --- a/pkg/urbit/noun/retrieve.c +++ b/pkg/urbit/noun/retrieve.c @@ -230,21 +230,13 @@ typedef struct { } eqframe; static inline eqframe* -_eq_push(c3_ys mov, c3_ys off, u3_noun a, u3_noun b) +_eq_push(u3a_pile* pil_u, u3_noun a, u3_noun b) { - u3R->cap_p += mov; - eqframe* cur = u3to(eqframe, u3R->cap_p + off); - cur->sat_y = SONG_NONE; - cur->a = a; - cur->b = b; - return cur; -} - -static inline eqframe* -_eq_pop(c3_ys mov, c3_ys off) -{ - u3R->cap_p -= mov; - return u3to(eqframe, u3R->cap_p + off); + eqframe* fam_u = u3a_push(pil_u); + fam_u->sat_y = SONG_NONE; + fam_u->a = a; + fam_u->b = b; + return fam_u; } /* _song_atom(): check if atom [a] is indirect and equal to noun [b] @@ -296,19 +288,19 @@ _song_atom(u3_atom a, u3_noun b) * (tightly coupled to _song_x) */ static c3_o -_song_x_cape(c3_ys mov, c3_ys off, - eqframe* fam, eqframe* don, - u3p(u3h_root) har_p) +_song_x_cape(u3a_pile* pil_u, u3p(u3h_root) har_p) { - u3_noun a, b, key; - u3_weak got; + eqframe* fam_u = u3a_peek(pil_u); + u3_noun a, b, key; + u3_weak got; u3a_cell* a_u; u3a_cell* b_u; - while ( don != fam ) { - a = fam->a; - b = fam->b; - switch ( fam->sat_y ) { + while ( c3n == u3a_pile_done(pil_u) ) { + a = fam_u->a; + b = fam_u->b; + + switch ( fam_u->sat_y ) { case SONG_NONE: if ( a == b ) { break; @@ -340,12 +332,14 @@ _song_x_cape(c3_ys mov, c3_ys off, got = u3h_get(har_p, key); u3t_on(euq_o); u3z(key); + if ( u3_none != got ) { - fam = _eq_pop(mov, off); - continue; + fam_u = u3a_pop(pil_u); + } + else { + fam_u->sat_y = SONG_HEAD; + fam_u = _eq_push(pil_u, a_u->hed, b_u->hed); } - fam->sat_y = SONG_HEAD; - fam = _eq_push(mov, off, a_u->hed, b_u->hed); continue; } } @@ -354,8 +348,9 @@ _song_x_cape(c3_ys mov, c3_ys off, a_u = u3a_to_ptr(a); b_u = u3a_to_ptr(b); u3a_wed(&(a_u->hed), &(b_u->hed)); - fam->sat_y = SONG_TAIL; - fam = _eq_push(mov, off, a_u->tel, b_u->tel); + + fam_u->sat_y = SONG_TAIL; + fam_u = _eq_push(pil_u, a_u->tel, b_u->tel); continue; case SONG_TAIL: @@ -380,7 +375,8 @@ _song_x_cape(c3_ys mov, c3_ys off, u3t_on(euq_o); u3z(key); } - fam = _eq_pop(mov, off); + + fam_u = u3a_pop(pil_u); } return c3y; @@ -391,30 +387,27 @@ _song_x_cape(c3_ys mov, c3_ys off, static c3_o _song_x(u3_noun a, u3_noun b) { - u3p(eqframe) empty = u3R->cap_p; + c3_s ovr_s = 0; + u3a_cell* a_u; + u3a_cell* b_u; + eqframe* fam_u; + u3a_pile pil_u; - c3_y wis_y = c3_wiseof(eqframe); - c3_o nor_o = u3a_is_north(u3R); - c3_ys mov = ( c3y == nor_o ? -wis_y : wis_y ); - c3_ys off = ( c3y == nor_o ? 0 : -wis_y ); - c3_s ovr_s = 0; - eqframe* fam = _eq_push(mov, off, a, b); - eqframe* don = u3to(eqframe, empty + off); + u3a_pile_prep(&pil_u, sizeof(eqframe)); + fam_u = _eq_push(&pil_u, a, b); - u3a_cell* a_u; - u3a_cell* b_u; + while ( c3n == u3a_pile_done(&pil_u) ) { + a = fam_u->a; + b = fam_u->b; - while ( don != fam ) { - a = fam->a; - b = fam->b; - switch ( fam->sat_y ) { + switch ( fam_u->sat_y ) { case SONG_NONE: if ( a == b ) { break; } else if ( c3y == u3a_is_atom(a) ) { if ( c3n == _song_atom(a, b) ) { - u3R->cap_p = empty; + u3R->cap_p = pil_u.top_p; return c3n; } else { @@ -422,7 +415,7 @@ _song_x(u3_noun a, u3_noun b) } } else if ( c3y == u3a_is_atom(b) ) { - u3R->cap_p = empty; + u3R->cap_p = pil_u.top_p; return c3n; } else { @@ -433,12 +426,12 @@ _song_x(u3_noun a, u3_noun b) (0 != b_u->mug_w) && (a_u->mug_w != b_u->mug_w) ) { - u3R->cap_p = empty; + u3R->cap_p = pil_u.top_p; return c3n; } else { - fam->sat_y = SONG_HEAD; - fam = _eq_push(mov, off, a_u->hed, b_u->hed); + fam_u->sat_y = SONG_HEAD; + fam_u = _eq_push(&pil_u, a_u->hed, b_u->hed); continue; } } @@ -447,8 +440,9 @@ _song_x(u3_noun a, u3_noun b) a_u = u3a_to_ptr(a); b_u = u3a_to_ptr(b); u3a_wed(&(a_u->hed), &(b_u->hed)); - fam->sat_y = SONG_TAIL; - fam = _eq_push(mov, off, a_u->tel, b_u->tel); + + fam_u->sat_y = SONG_TAIL; + fam_u = _eq_push(&pil_u, a_u->tel, b_u->tel); continue; case SONG_TAIL: @@ -467,12 +461,13 @@ _song_x(u3_noun a, u3_noun b) // if ( 0 == ++ovr_s ) { u3p(u3h_root) har_p = u3h_new(); - c3_o ret_o = _song_x_cape(mov, off, fam, don, har_p); + c3_o ret_o = _song_x_cape(&pil_u, har_p); u3h_free(har_p); - u3R->cap_p = empty; + u3R->cap_p = pil_u.top_p; return ret_o; } - fam = _eq_pop(mov, off); + + fam_u = u3a_pop(&pil_u); } return c3y; From e389220d1889e80a20c5cb2e8f9bd5cf279629c9 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 14 Sep 2020 23:42:40 -0700 Subject: [PATCH 336/933] u3: refactors u3r_sing internals, adding comments --- pkg/urbit/noun/retrieve.c | 251 ++++++++++++++++++++++++++------------ 1 file changed, 172 insertions(+), 79 deletions(-) diff --git a/pkg/urbit/noun/retrieve.c b/pkg/urbit/noun/retrieve.c index 79724ffe58..cd8826e6f6 100644 --- a/pkg/urbit/noun/retrieve.c +++ b/pkg/urbit/noun/retrieve.c @@ -219,9 +219,25 @@ u3r_mean(u3_noun som, ...) return ret_o; } -#define SONG_NONE 0 -#define SONG_HEAD 1 -#define SONG_TAIL 2 +// stack frame for tracking noun comparison and unification +// +// We're always comparing arbitrary nouns in a %none frame. +// When we comparing two cells, we change the none frame to +// a head-frame and push a new %none frame for the heads. +// If the heads were equal, the head-frame has the context to +// unify their head pointers. We then repeat with the tails, +// mutatis mutandis. +// +// In Hoon, this structure would be as follows: +// +// $% [%none a=* b=*] +// [%head a=^ b=^] +// [%tail a=^ b=^] +// == +// +#define SING_NONE 0 +#define SING_HEAD 1 +#define SING_TAIL 2 typedef struct { c3_y sat_y; @@ -229,26 +245,43 @@ typedef struct { u3_noun b; } eqframe; +/* _cr_sing_push(): push a new stack frame, initialized as SING_NONE. +*/ static inline eqframe* -_eq_push(u3a_pile* pil_u, u3_noun a, u3_noun b) +_cr_sing_push(u3a_pile* pil_u, u3_noun a, u3_noun b) { eqframe* fam_u = u3a_push(pil_u); - fam_u->sat_y = SONG_NONE; + fam_u->sat_y = SING_NONE; fam_u->a = a; fam_u->b = b; return fam_u; } -/* _song_atom(): check if atom [a] is indirect and equal to noun [b] +/* _cr_sing_mug(): short-circuit comparison if mugs are present and not equal. */ static inline c3_o -_song_atom(u3_atom a, u3_noun b) +_cr_sing_mug(u3a_noun* a_u, u3a_noun* b_u) +{ + // XX debug assertions that both mugs are 31-bit + // (ie, not u3a_take() relocation references) + // + if ( a_u->mug_w && b_u->mug_w && (a_u->mug_w != b_u->mug_w) ) { + return c3n; + } + + return c3y; +} + +/* _cr_sing_atom(): check if atom [a] is indirect and equal to noun [b] +*/ +static inline c3_o +_cr_sing_atom(u3_atom a, u3_noun b) { // [a] is an atom, not pointer-equal to noun [b]. // if they're not both indirect atoms, they can't be equal. // - if ( (c3n == u3a_is_pug(a)) || - (c3n == u3a_is_pug(b)) ) + if ( (c3n == u3a_is_pug(a)) + || (c3n == u3a_is_pug(b)) ) { return c3n; } @@ -256,23 +289,26 @@ _song_atom(u3_atom a, u3_noun b) u3a_atom* a_u = u3a_to_ptr(a); u3a_atom* b_u = u3a_to_ptr(b); - if ( (0 != a_u->mug_w) && - (0 != b_u->mug_w) && - (a_u->mug_w != b_u->mug_w) ) - { + // [a] and [b] are not equal if their mugs are present and not equal. + // + if ( c3n == _cr_sing_mug((u3a_noun*)a_u, (u3a_noun*)b_u) ) { return c3n; } else { - c3_w w_rez = a_u->len_w; - c3_w w_mox = b_u->len_w; + c3_w a_w = a_u->len_w; + c3_w b_w = b_u->len_w; - if ( w_rez != w_mox ) { + // [a] and [b] are not equal if their lengths are not equal + // + if ( a_w != b_w ) { return c3n; } else { c3_w i_w; - for ( i_w = 0; i_w < w_rez; i_w++ ) { + // XX memcmp + // + for ( i_w = 0; i_w < a_w; i_w++ ) { if ( a_u->buf_w[i_w] != b_u->buf_w[i_w] ) { return c3n; } @@ -284,11 +320,45 @@ _song_atom(u3_atom a, u3_noun b) return c3y; } -/* _song_x_cape(): unifying equality with comparison deduplication - * (tightly coupled to _song_x) +/* _cr_sing_cape_test(): check for previous comparison of [a] and [b]. +*/ +static inline c3_o +_cr_sing_cape_test(u3p(u3h_root) har_p, u3_noun a, u3_noun b) +{ + u3_noun key = u3nc(u3a_to_off(a), u3a_to_off(b)); + u3_noun val; + + u3t_off(euq_o); + val = u3h_git(har_p, key); + u3t_on(euq_o); + + u3z(key); + return ( u3_none == val ) ? c3y : c3n; +} + +/* _cr_sing_cape_keep(): store [a] and [b] to short-circuit subsequent tests. +** NB: [a] and [b] (which MUST be equal nouns) +** are cons'd as offsets (direct atoms) to avoid refcount churn. +*/ +static inline void +_cr_sing_cape_keep(u3p(u3h_root) har_p, u3_noun a, u3_noun b) +{ + // only store if [a] and [b] are copies of each other + // + if ( a != b ) { + u3_noun key = u3nc(u3a_to_off(a), u3a_to_off(b)); + u3t_off(euq_o); + u3h_put(har_p, key, c3y); + u3t_on(euq_o); + u3z(key); + } +} + +/* _cr_sing_cape(): unifying equality with comparison deduplication + * (tightly coupled to _cr_sing) */ static c3_o -_song_x_cape(u3a_pile* pil_u, u3p(u3h_root) har_p) +_cr_sing_cape(u3a_pile* pil_u, u3p(u3h_root) har_p) { eqframe* fam_u = u3a_peek(pil_u); u3_noun a, b, key; @@ -296,17 +366,22 @@ _song_x_cape(u3a_pile* pil_u, u3p(u3h_root) har_p) u3a_cell* a_u; u3a_cell* b_u; - while ( c3n == u3a_pile_done(pil_u) ) { + // loop while arguments remain on the stack + // + do { a = fam_u->a; b = fam_u->b; switch ( fam_u->sat_y ) { - case SONG_NONE: + + // [a] and [b] are arbitrary nouns + // + case SING_NONE: { if ( a == b ) { break; } else if ( c3y == u3a_is_atom(a) ) { - if ( c3n == _song_atom(a, b) ) { + if ( c3n == _cr_sing_atom(a, b) ) { return c3n; } else { @@ -316,76 +391,75 @@ _song_x_cape(u3a_pile* pil_u, u3p(u3h_root) har_p) else if ( c3y == u3a_is_atom(b) ) { return c3n; } + // [a] and [b] are cells + // else { a_u = u3a_to_ptr(a); b_u = u3a_to_ptr(b); - if ( (0 != a_u->mug_w) && - (0 != b_u->mug_w) && - (a_u->mug_w != b_u->mug_w) ) - { + // short-circuiting mug check + // + if ( c3n == _cr_sing_mug((u3a_noun*)a_u, (u3a_noun*)b_u) ) { return c3n; } + // short-circuiting re-comparison check + // + else if ( c3y == _cr_sing_cape_test(har_p, a, b) ) { + fam_u = u3a_pop(pil_u); + continue; + } + // upgrade none-frame to head-frame, check heads + // else { - key = u3nc(u3a_to_off(a), u3a_to_off(b)); - u3t_off(euq_o); - got = u3h_get(har_p, key); - u3t_on(euq_o); - u3z(key); - - if ( u3_none != got ) { - fam_u = u3a_pop(pil_u); - } - else { - fam_u->sat_y = SONG_HEAD; - fam_u = _eq_push(pil_u, a_u->hed, b_u->hed); - } + fam_u->sat_y = SING_HEAD; + fam_u = _cr_sing_push(pil_u, a_u->hed, b_u->hed); continue; } } + } break; - case SONG_HEAD: + // cells [a] and [b] have equal heads + // + case SING_HEAD: { a_u = u3a_to_ptr(a); b_u = u3a_to_ptr(b); u3a_wed(&(a_u->hed), &(b_u->hed)); - fam_u->sat_y = SONG_TAIL; - fam_u = _eq_push(pil_u, a_u->tel, b_u->tel); + // upgrade head-frame to tail-frame, check tails + // + fam_u->sat_y = SING_TAIL; + fam_u = _cr_sing_push(pil_u, a_u->tel, b_u->tel); continue; + } - case SONG_TAIL: + // cells [a] and [b] are equal + // + case SING_TAIL: { a_u = u3a_to_ptr(a); b_u = u3a_to_ptr(b); u3a_wed(&(a_u->tel), &(b_u->tel)); - break; + } break; - default: + default: { c3_assert(0); - break; + } break; } - // [har_p] is effectively a set of equal pairs. - // we cons [a] and [b] as posts so that we don't - // touch their reference counts. + // track equal pairs to short-circuit possible (re-)comparison // - if ( a != b ) { - key = u3nc(u3a_to_off(a), u3a_to_off(b)); - u3t_off(euq_o); - u3h_put(har_p, key, c3y); - u3t_on(euq_o); - u3z(key); - } + _cr_sing_cape_keep(har_p, a, b); fam_u = u3a_pop(pil_u); } + while ( c3n == u3a_pile_done(pil_u) ); return c3y; } -/* _song_x(): yes if a and b are the same noun, use uni to unify +/* _cr_sing(): yes if a and b are the same noun, use uni to unify */ static c3_o -_song_x(u3_noun a, u3_noun b) +_cr_sing(u3_noun a, u3_noun b) { c3_s ovr_s = 0; u3a_cell* a_u; @@ -393,20 +467,27 @@ _song_x(u3_noun a, u3_noun b) eqframe* fam_u; u3a_pile pil_u; + // initialize stack control, push arguments onto the stack (none-frame) + // u3a_pile_prep(&pil_u, sizeof(eqframe)); - fam_u = _eq_push(&pil_u, a, b); + fam_u = _cr_sing_push(&pil_u, a, b); + // loop while arguments are on the stack + // while ( c3n == u3a_pile_done(&pil_u) ) { a = fam_u->a; b = fam_u->b; switch ( fam_u->sat_y ) { - case SONG_NONE: + + // [a] and [b] are arbitrary nouns + // + case SING_NONE: { if ( a == b ) { break; } else if ( c3y == u3a_is_atom(a) ) { - if ( c3n == _song_atom(a, b) ) { + if ( c3n == _cr_sing_atom(a, b) ) { u3R->cap_p = pil_u.top_p; return c3n; } @@ -418,50 +499,62 @@ _song_x(u3_noun a, u3_noun b) u3R->cap_p = pil_u.top_p; return c3n; } + // [a] and [b] are cells + // else { a_u = u3a_to_ptr(a); b_u = u3a_to_ptr(b); - if ( (0 != a_u->mug_w) && - (0 != b_u->mug_w) && - (a_u->mug_w != b_u->mug_w) ) - { + // short-circuiting mug check + // + if ( c3n == _cr_sing_mug((u3a_noun*)a_u, (u3a_noun*)b_u) ) { u3R->cap_p = pil_u.top_p; return c3n; } + // upgrade none-frame to head-frame, check heads + // else { - fam_u->sat_y = SONG_HEAD; - fam_u = _eq_push(&pil_u, a_u->hed, b_u->hed); + fam_u->sat_y = SING_HEAD; + fam_u = _cr_sing_push(&pil_u, a_u->hed, b_u->hed); continue; } } + } break; - case SONG_HEAD: + // cells [a] and [b] have equal heads + // + case SING_HEAD: { a_u = u3a_to_ptr(a); b_u = u3a_to_ptr(b); u3a_wed(&(a_u->hed), &(b_u->hed)); - fam_u->sat_y = SONG_TAIL; - fam_u = _eq_push(&pil_u, a_u->tel, b_u->tel); + // upgrade head-frame to tail-frame, check tails + // + fam_u->sat_y = SING_TAIL; + fam_u = _cr_sing_push(&pil_u, a_u->tel, b_u->tel); continue; + } - case SONG_TAIL: + // cells [a] and [b] are equal + // + case SING_TAIL: { a_u = u3a_to_ptr(a); b_u = u3a_to_ptr(b); u3a_wed(&(a_u->tel), &(b_u->tel)); - break; + } break; - default: + default: { c3_assert(0); - break; + } break; } - // [ovr_s] counts iterations. when it overflows, we know we've hit a - // pathological case and MUST start de-duplicating comparisons. + // [ovr_s] counts comparisons, if it overflows, we've likely hit + // a pathological case (highly duplicated tree), so we de-duplicate + // subsequent comparisons by maintaing a set of equal pairs. // if ( 0 == ++ovr_s ) { u3p(u3h_root) har_p = u3h_new(); - c3_o ret_o = _song_x_cape(&pil_u, har_p); + c3_o ret_o = _cr_sing_cape(&pil_u, har_p); u3h_free(har_p); u3R->cap_p = pil_u.top_p; return ret_o; @@ -480,7 +573,7 @@ u3r_sing(u3_noun a, u3_noun b) { c3_o ret_o; u3t_on(euq_o); - ret_o = _song_x(a, b); + ret_o = _cr_sing(a, b); u3t_off(euq_o); return ret_o; } From 7cb15d77f24981d571e4221a9e56abc6a87b37f5 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 14 Sep 2020 13:16:02 -0700 Subject: [PATCH 337/933] u3: fixes -P profiling by moving alloc hints in imprison.c broken by yours truly, in 406a823ddd7827598f6bbaaadd75a3fc91572c5e --- pkg/urbit/noun/imprison.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/urbit/noun/imprison.c b/pkg/urbit/noun/imprison.c index 6eb533c436..c4c81b952a 100644 --- a/pkg/urbit/noun/imprison.c +++ b/pkg/urbit/noun/imprison.c @@ -10,7 +10,6 @@ u3i_bytes(c3_w a_w, const c3_y* b_y) { u3_noun pro; - u3t_on(mal_o); // Strip trailing zeroes. // @@ -40,6 +39,7 @@ u3i_bytes(c3_w a_w, // Allocate, fill, return. // + u3t_on(mal_o); { c3_w len_w = (a_w + 3) >> 2; c3_w* nov_w = u3a_walloc((len_w + c3_wiseof(u3a_atom))); @@ -70,8 +70,8 @@ u3i_bytes(c3_w a_w, pro = u3a_to_pug(u3a_outa(nov_w)); } - u3t_off(mal_o); + return pro; } @@ -82,7 +82,6 @@ u3i_words(c3_w a_w, const c3_w* b_w) { u3_noun pro; - u3t_on(mal_o); // Strip trailing zeroes. // @@ -101,6 +100,7 @@ u3i_words(c3_w a_w, // Allocate, fill, return. // + u3t_on(mal_o); { c3_w* nov_w = u3a_walloc(a_w + c3_wiseof(u3a_atom)); u3a_atom* nov_u = (void*)nov_w; @@ -120,8 +120,8 @@ u3i_words(c3_w a_w, pro = u3a_to_pug(u3a_outa(nov_w)); } - u3t_off(mal_o); + return pro; } @@ -132,7 +132,6 @@ u3i_chubs(c3_w a_w, const c3_d* b_d) { u3_noun pro; - u3t_on(mal_o); // Strip trailing zeroes. // @@ -151,6 +150,7 @@ u3i_chubs(c3_w a_w, // Allocate, fill, return. // + u3t_on(mal_o); { c3_w len_w = 2 * a_w; @@ -192,8 +192,8 @@ u3i_chubs(c3_w a_w, pro = u3a_to_pug(u3a_outa(nov_w)); } - u3t_off(mal_o); + return pro; } From ab6002543856d686f7799b95ee765cfafc3cf90d Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 14 Sep 2020 13:17:24 -0700 Subject: [PATCH 338/933] vere: disables sample profiling in the king --- pkg/urbit/vere/king.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/urbit/vere/king.c b/pkg/urbit/vere/king.c index c0df14592a..4549ccbcef 100644 --- a/pkg/urbit/vere/king.c +++ b/pkg/urbit/vere/king.c @@ -704,10 +704,11 @@ u3_king_commence() uv_timer_init(u3L, &u3K.tim_u); // start up a "fast-compile" arvo for internal use only - // (with hashboard always disabled) + // (with hashboard and sample-profiling always disabled) // sag_w = u3C.wag_w; u3C.wag_w |= u3o_hashless; + u3C.wag_w &= ~u3o_debug_cpu; u3m_boot_lite(); From dd3112985e6fd54d99499fdd1705d05be365fe89 Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 15 Sep 2020 16:40:28 +0200 Subject: [PATCH 339/933] kh: support rendering +stub as ansi escape codes Adds support to term.hs for a %klr blit, containing a +stub describing styled text. Dill will start making use of this in a separate commit, for release cutting reasons. --- pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs | 75 ++++++++++++++++++++++ pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs | 52 +++++++++++++++ 2 files changed, 127 insertions(+) diff --git a/pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs b/pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs index 606539907a..d77b25051c 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs @@ -112,6 +112,7 @@ data Blit = Bel () | Clr () | Hop Word64 + | Klr Stub | Lin [Char] | Mor () | Sag Path Noun @@ -119,12 +120,84 @@ data Blit | Url Cord deriving (Eq, Ord) +data Deco + = DecoBl + | DecoBr + | DecoUn + | DecoNull + deriving (Eq, Ord, Show) + +data Tint + = TintR + | TintG + | TintB + | TintC + | TintM + | TintY + | TintK + | TintW + | TintNull + deriving (Eq, Ord, Show) + +data Stye = Stye + { deco :: (HoonSet Deco) + , back :: Tint + , fore :: Tint + } + deriving (Eq, Ord, Show) + +newtype Stub = Stub [(Stye, [Char])] + deriving (Eq, Ord, Show) + +instance ToNoun Deco where + toNoun = \case + DecoBl -> toNoun $ Cord "bl" + DecoBr -> toNoun $ Cord "br" + DecoUn -> toNoun $ Cord "un" + DecoNull -> Atom 0 + +instance FromNoun Deco where + parseNoun = named "Deco" . \case + Atom 0 -> pure DecoNull + n -> parseNoun @Cord n <&> unCord >>= \case + "bl" -> pure DecoBl + "br" -> pure DecoBr + "un" -> pure DecoUn + t -> fail ("invalid: " <> unpack t) + +instance ToNoun Tint where + toNoun = \case + TintR -> toNoun $ Cord "r" + TintG -> toNoun $ Cord "g" + TintB -> toNoun $ Cord "b" + TintC -> toNoun $ Cord "c" + TintM -> toNoun $ Cord "m" + TintY -> toNoun $ Cord "y" + TintK -> toNoun $ Cord "k" + TintW -> toNoun $ Cord "w" + TintNull -> Atom 0 + +instance FromNoun Tint where + parseNoun = named "Tint" . \case + Atom 0 -> pure TintNull + n -> parseNoun @Cord n <&> unCord >>= \case + "r" -> pure TintR + "g" -> pure TintG + "b" -> pure TintB + "c" -> pure TintC + "m" -> pure TintM + "y" -> pure TintY + "k" -> pure TintK + "w" -> pure TintW + t -> fail ("invalid: " <> unpack t) + -- Manual instance to not save the noun/atom in Sag/Sav, because these can be -- megabytes and makes king hang. instance Show Blit where show (Bel ()) = "Bel ()" show (Clr ()) = "Clr ()" show (Hop x) = "Hop " ++ (show x) + show (Klr s) = "Klr " ++ (show s) show (Lin c) = "Lin " ++ (show c) show (Mor ()) = "Mor ()" show (Sag path _) = "Sag " ++ (show path) @@ -144,6 +217,8 @@ data TermEf | TermEfMass Path Noun -- Irrelevant deriving (Eq, Ord, Show) +deriveNoun ''Stye +deriveNoun ''Stub deriveNoun ''Blit deriveNoun ''TermEf diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs index eea980a7fc..e4b5bf0cd4 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs @@ -30,6 +30,7 @@ import Urbit.King.API (readPortsFile) import Urbit.TermSize (TermSize(TermSize)) import Urbit.Vere.Term.API (Client(Client)) +import qualified Data.Set as S import qualified Data.ByteString.Internal as BS import qualified Data.ByteString.UTF8 as BS import qualified System.Console.ANSI as ANSI @@ -342,6 +343,8 @@ localClient doneSignal = fst <$> mkRAcquire start stop Clr () -> do T.clearScreen termRefreshLine ls Hop w -> termShowCursor ls (fromIntegral w) + Klr s -> do ls2 <- termShowClear ls + termShowStub ls2 s Lin c -> do ls2 <- termShowClear ls termShowLine ls2 (pack c) Mor () -> termShowMore ls @@ -349,6 +352,55 @@ localClient doneSignal = fst <$> mkRAcquire start stop Sav path atom -> pure ls Url url -> pure ls + termRenderDeco :: Deco -> Char + termRenderDeco = \case + DecoBr -> '1' + DecoUn -> '4' + DecoBl -> '5' + DecoNull -> '0' + + termRenderTint :: Tint -> Char + termRenderTint = \case + TintK -> '0' + TintR -> '1' + TintG -> '2' + TintY -> '3' + TintB -> '4' + TintM -> '5' + TintC -> '6' + TintW -> '7' + TintNull -> '9' + + -- Wraps the appropriate escape sequence around a piece of styled text + termRenderStubSegment :: Stye -> [Char] -> [Char] + termRenderStubSegment Stye {..} tape = + case (S.null decoset, back, fore) of + (True, TintNull, TintNull) -> tape + _ -> styled + where + decoset = setFromHoonSet deco + escape = [chr 27, '['] + + styles = intercalate ";" $ filter (not . null) + [ intersperse ';' $ fmap termRenderDeco $ toList decoset + , case back of + TintNull -> [] + tint -> ['4', termRenderTint tint] + , case fore of + TintNull -> [] + tint -> ['3', termRenderTint tint] + ] + + styled = mconcat [escape, styles, "m", tape, escape, "0m"] + + -- Displays and sets styled text as the current line + termShowStub :: LineState -> Stub -> RIO e LineState + termShowStub ls (Stub s) = do + let visualLength = sum $ fmap (length . snd) s + let outText = pack $ mconcat $ fmap (uncurry termRenderStubSegment) s + putStr outText + pure ls { lsLine = outText, lsCurPos = visualLength } + -- Moves the cursor to the requested position termShowCursor :: LineState -> Int -> RIO e LineState termShowCursor ls@LineState{..} {-line pos)-} newPos = do From 39a82fe66d8e97e3517077387499515924ebdc83 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 15 Sep 2020 13:50:22 -0700 Subject: [PATCH 340/933] ur: updates api to consistently use (len, bytes) for vectors --- pkg/urbit/include/ur/defs.h | 2 +- pkg/urbit/include/ur/hashcons.h | 4 ++-- pkg/urbit/noun/urth.c | 4 ++-- pkg/urbit/tests/ur_tests.c | 4 ++-- pkg/urbit/ur/hashcons.c | 18 +++++++++--------- pkg/urbit/ur/serial.c | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/pkg/urbit/include/ur/defs.h b/pkg/urbit/include/ur/defs.h index d3b1c6ebfa..c5cf411c1f 100644 --- a/pkg/urbit/include/ur/defs.h +++ b/pkg/urbit/include/ur/defs.h @@ -64,7 +64,7 @@ typedef uint8_t ur_bool_t; ** unsafe wrt trailing null bytes, which are invalid */ inline uint64_t -ur_met0_bytes_unsafe(uint8_t *byt, uint64_t len) +ur_met0_bytes_unsafe(uint64_t len, uint8_t *byt) { uint64_t last = len - 1; return (last << 3) + ur_met0_8(byt[last]); diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index 045d5055af..c8a8e4ba50 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -174,10 +174,10 @@ ur_met(ur_root_t *r, uint8_t bloq, ur_nref ref); ** allocated with system malloc) and trailing null bytes (not allowed). */ ur_nref -ur_coin_bytes_unsafe(ur_root_t *r, uint8_t *byt, uint64_t len); +ur_coin_bytes_unsafe(ur_root_t *r, uint64_t len, uint8_t *byt); ur_nref -ur_coin_bytes(ur_root_t *r, uint8_t *byt, uint64_t len); +ur_coin_bytes(ur_root_t *r, uint64_t len, uint8_t *byt); ur_nref ur_coin64(ur_root_t *r, uint64_t n); diff --git a/pkg/urbit/noun/urth.c b/pkg/urbit/noun/urth.c index 82f052d1d7..876e2d5dc1 100644 --- a/pkg/urbit/noun/urth.c +++ b/pkg/urbit/noun/urth.c @@ -57,10 +57,10 @@ _cu_atom_to_ref(ur_root_t* rot_u, u3a_atom* vat_u) c3_assert( len_d ); - // NB: this call will accounts for any trailing null bytes + // NB: this call will account for any trailing null bytes // caused by an overestimate in [len_d] // - ref = ur_coin_bytes(rot_u, byt_y, len_d); + ref = ur_coin_bytes(rot_u, len_d, byt_y); } break; } diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index 8859966ee2..56e8f2dc17 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -1810,13 +1810,13 @@ _test_jam_cue(void) { uint8_t inp[33] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; uint8_t res[35] = { 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8 }; - TEST_CASE("wide", ur_coin_bytes(r, inp, sizeof(inp))); + TEST_CASE("wide", ur_coin_bytes(r, sizeof(inp), inp)); } { uint8_t inp[16] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc, 0xa8, 0xab, 0x60, 0xef, 0x2d, 0xd, 0x0, 0x0, 0x80 }; uint8_t res[19] = { 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x18, 0x50, 0x57, 0xc1, 0xde, 0x5b, 0x1a, 0x0, 0x0, 0x0, 0x1 }; - TEST_CASE("date", ur_coin_bytes(r, inp, sizeof(inp))); + TEST_CASE("date", ur_coin_bytes(r, sizeof(inp), inp)); } ur_root_free(r); diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index a08de03110..756c92f6df 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -15,7 +15,7 @@ // declarations of inline functions // uint64_t -ur_met0_bytes_unsafe(uint8_t *byt, uint64_t len); +ur_met0_bytes_unsafe(uint64_t len, uint8_t *byt); static void* _oom(const char* cap, void* v) @@ -543,7 +543,7 @@ ur_met(ur_root_t *r, uint8_t bloq, ur_nref ref) uint64_t len = r->atoms.lens[idx]; uint8_t *byt = r->atoms.bytes[idx]; - m_bit = ur_met0_bytes_unsafe(byt, len); + m_bit = ur_met0_bytes_unsafe(len, byt); } switch ( bloq ) { @@ -568,7 +568,7 @@ ur_met(ur_root_t *r, uint8_t bloq, ur_nref ref) } static ur_nref -_coin_unsafe(ur_atoms_t *atoms, ur_mug mug, uint8_t *byt, uint64_t len) +_coin_unsafe(ur_atoms_t *atoms, ur_mug mug, uint64_t len, uint8_t *byt) { uint64_t fill = atoms->fill; ur_tag tag = ur_iatom; @@ -606,7 +606,7 @@ _cons_unsafe(ur_cells_t *cells, ur_mug mug, ur_nref hed, ur_nref tal) } ur_nref -ur_coin_bytes_unsafe(ur_root_t *r, uint8_t *byt, uint64_t len) +ur_coin_bytes_unsafe(ur_root_t *r, uint64_t len, uint8_t *byt) { ur_atoms_t *atoms = &(r->atoms); ur_dict_t *dict = &(atoms->dict); @@ -641,7 +641,7 @@ ur_coin_bytes_unsafe(ur_root_t *r, uint8_t *byt, uint64_t len) ur_atoms_grow(atoms); } - tom = _coin_unsafe(atoms, mug, byt, len); + tom = _coin_unsafe(atoms, mug, len, byt); bucket->refs[b_fill] = tom; bucket->fill = 1 + b_fill; @@ -651,7 +651,7 @@ ur_coin_bytes_unsafe(ur_root_t *r, uint8_t *byt, uint64_t len) } ur_nref -ur_coin_bytes(ur_root_t *r, uint8_t *byt, uint64_t len) +ur_coin_bytes(ur_root_t *r, uint64_t len, uint8_t *byt) { // strip trailing zeroes // @@ -661,7 +661,7 @@ ur_coin_bytes(ur_root_t *r, uint8_t *byt, uint64_t len) // produce a direct atom if possible // - if ( 62 >= ur_met0_bytes_unsafe(byt, len) ) { + if ( 62 >= ur_met0_bytes_unsafe(len, byt) ) { uint64_t i, direct = 0; for ( i = 0; i < len; i++ ) { @@ -674,7 +674,7 @@ ur_coin_bytes(ur_root_t *r, uint8_t *byt, uint64_t len) uint8_t *copy = _oom("coin_bytes", malloc(len)); memcpy(copy, byt, len); - return ur_coin_bytes_unsafe(r, copy, len); + return ur_coin_bytes_unsafe(r, len, copy); } } @@ -699,7 +699,7 @@ ur_coin64(ur_root_t *r, uint64_t n) byt[6] = ur_mask_8(n >> 48); byt[7] = ur_mask_8(n >> 56); - return ur_coin_bytes_unsafe(r, byt, 8); + return ur_coin_bytes_unsafe(r, 8, byt); } } diff --git a/pkg/urbit/ur/serial.c b/pkg/urbit/ur/serial.c index 83610c12bf..a2d111e91e 100644 --- a/pkg/urbit/ur/serial.c +++ b/pkg/urbit/ur/serial.c @@ -214,7 +214,7 @@ _cue_next(ur_root_t *r, len_byt--; } - *out = ur_coin_bytes_unsafe(r, byt, len_byt); + *out = ur_coin_bytes_unsafe(r, len_byt, byt); } ur_dict64_put(r, dict, bits, (uint64_t)*out); From 76f1b782187fa50e8b6008b8f9b167589aa15fd2 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 15 Sep 2020 14:01:34 -0700 Subject: [PATCH 341/933] ur: refactors scalar/direct-atom measurement macros --- pkg/urbit/include/ur/defs.h | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/pkg/urbit/include/ur/defs.h b/pkg/urbit/include/ur/defs.h index c5cf411c1f..c16a7e153e 100644 --- a/pkg/urbit/include/ur/defs.h +++ b/pkg/urbit/include/ur/defs.h @@ -30,6 +30,13 @@ typedef uint8_t ur_bool_t; #define ur_mask_31(a) (a & 0x7fffffff) #define ur_mask_62(a) (a & 0x3fffffffffffffffULL) +/* +** bloq (binary exponent) conversions +*/ +#define ur_bloq_up1(a) ( (a + 0x1) >> 1 ) +#define ur_bloq_up2(a) ( (a + 0x3) >> 2 ) +#define ur_bloq_up3(a) ( (a + 0x7) >> 3 ) + /* ** atom measurement */ @@ -70,16 +77,8 @@ ur_met0_bytes_unsafe(uint64_t len, uint8_t *byt) return (last << 3) + ur_met0_8(byt[last]); } -#define ur_met3_8(a) \ - ({ uint8_t _a = ur_met0_8(a); \ - ( (_a >> 3) + !!ur_mask_3(_a) ); }) - -#define ur_met3_32(a) \ - ({ uint8_t _a = ur_met0_32(a); \ - ( (_a >> 3) + !!ur_mask_3(_a) ); }) - -#define ur_met3_64(a) \ - ({ uint8_t _a = ur_met0_64(a); \ - ( (_a >> 3) + !!ur_mask_3(_a) ); }) +#define ur_met3_8(a) ur_bloq_up3(ur_met0_8(a)) +#define ur_met3_32(a) ur_bloq_up3(ur_met0_32(a)) +#define ur_met3_64(a) ur_bloq_up3(ur_met0_64(a)) #endif From 6477f6304532002613e8c684972de0e50b4d1aec Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 15 Sep 2020 14:06:46 -0700 Subject: [PATCH 342/933] ur: refactors ur_met, deduplicating and using bloq-conversion macros --- pkg/urbit/ur/hashcons.c | 76 +++++++++++++---------------------------- 1 file changed, 24 insertions(+), 52 deletions(-) diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 756c92f6df..f00a8be5a7 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -505,65 +505,37 @@ ur_bytes(ur_root_t *r, ur_nref ref, uint8_t **byt, uint64_t *len) uint64_t ur_met(ur_root_t *r, uint8_t bloq, ur_nref ref) { + uint64_t m_bit; + + // XX return bool for cells, length in out parameter + // assert( !ur_deep(ref) ); - // these cases are the same, except for the - // bit-width calculation and the width of their operands - // - switch ( ur_nref_tag(ref) ) { - default: assert(0); + if ( ur_direct == ur_nref_tag(ref) ) { + m_bit = ur_met0_64(ref); + } + else { + uint64_t idx = ur_nref_idx(ref); + uint64_t len = r->atoms.lens[idx]; + uint8_t *byt = r->atoms.bytes[idx]; - case ur_direct: { - uint8_t m_bit = ur_met0_64(ref); + m_bit = ur_met0_bytes_unsafe(len, byt); + } - switch ( bloq ) { - case 0: return m_bit; - case 1: return (m_bit + 1) >> 1; - case 2: return (m_bit + 3) >> 2; + switch ( bloq ) { + case 0: return m_bit; + case 1: return ur_bloq_up1(m_bit); + case 2: return ur_bloq_up2(m_bit); - { - // hand-inline of ur_met3_64 - // - uint8_t m_byt = (m_bit >> 3) + !!ur_mask_3(m_bit); + { + uint64_t m_byt = ur_bloq_up3(m_bit); - case 3: return m_byt; - default: { - uint8_t off = (bloq - 3); - return (m_byt + ((1 << off) - 1)) >> off; - } - } + case 3: return m_byt; + default: { + uint8_t off = (bloq - 3); + return (m_byt + ((1ULL << off) - 1)) >> off; } - } break; - - case ur_iatom: { - uint64_t m_bit; - - { - uint64_t idx = ur_nref_idx(ref); - uint64_t len = r->atoms.lens[idx]; - uint8_t *byt = r->atoms.bytes[idx]; - - m_bit = ur_met0_bytes_unsafe(len, byt); - } - - switch ( bloq ) { - case 0: return m_bit; - case 1: return (m_bit + 1) >> 1; - case 2: return (m_bit + 3) >> 2; - - { - // hand-inline of ur_met3_64 - // - uint64_t m_byt = (m_bit >> 3) + !!ur_mask_3(m_bit); - - case 3: return m_byt; - default: { - uint8_t off = (bloq - 3); - return (m_byt + ((1ULL << off) - 1)) >> off; - } - } - } - } break; + } } } From 0064271e7d85f679f1cbabea7b6d7f9b2197758f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 15 Sep 2020 15:09:17 -0700 Subject: [PATCH 343/933] ur: refactors bitstream length calculatings, using bloq-conversion macros --- pkg/urbit/ur/bitstream.c | 52 +++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/pkg/urbit/ur/bitstream.c b/pkg/urbit/ur/bitstream.c index f525f31b56..31f485b853 100644 --- a/pkg/urbit/ur/bitstream.c +++ b/pkg/urbit/ur/bitstream.c @@ -875,11 +875,10 @@ _bsw32_unsafe(ur_bsw_t *bsw, uint8_t len, uint32_t val) void ur_bsw32(ur_bsw_t *bsw, uint8_t len, uint32_t val) { - uint8_t bits, need; + uint8_t need; len = ur_min(32, len); - bits = bsw->off + len; - need = (bits >> 3) + !!ur_mask_3(bits); + need = ur_bloq_up3( bsw->off + len ); if ( bsw->fill + need >= bsw->size ) { ur_bsw_grow(bsw, ur_max(need, bsw->prev)); @@ -999,11 +998,10 @@ _bsw64_unsafe(ur_bsw_t *bsw, uint8_t len, uint64_t val) void ur_bsw64(ur_bsw_t *bsw, uint8_t len, uint64_t val) { - uint8_t bits, need; + uint8_t need; len = ur_min(64, len); - bits = bsw->off + len; - need = (bits >> 3) + !!ur_mask_3(bits); + need = ur_bloq_up3( bsw->off + len ); if ( bsw->fill + need >= bsw->size ) { ur_bsw_grow(bsw, ur_max(need, bsw->prev)); @@ -1080,8 +1078,7 @@ _bsw_bytes_unsafe(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) void ur_bsw_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) { - uint8_t bits = len + bsw->off; - uint64_t need = (bits >> 3) + !!ur_mask_3(bits); + uint64_t need = ur_bloq_up3(len + bsw->off); if ( bsw->fill + need >= bsw->size ) { ur_bsw_grow(bsw, ur_max(need, bsw->prev)); @@ -1117,8 +1114,7 @@ _bsw_bex_unsafe(ur_bsw_t *bsw, uint8_t n) void ur_bsw_bex(ur_bsw_t *bsw, uint8_t n) { - uint32_t bits = 1 + n + bsw->off; - uint8_t need = (bits >> 3) + !!ur_mask_3(bits); + uint64_t need = ur_bloq_up3(1 + n + bsw->off); if ( bsw->fill + need >= bsw->size ) { ur_bsw_grow(bsw, ur_max(need, bsw->prev)); @@ -1144,15 +1140,18 @@ _bsw_mat64_unsafe(ur_bsw_t *bsw, uint8_t len, uint64_t val) } } +/* +* the length of a "mat" run-length encoded atom of [len] bits +*/ +#define MAT_LEN(len) ( ( 0 == len ) ? 1 : len + (2 * ur_met0_64((uint64_t)len)) ) + void ur_bsw_mat64(ur_bsw_t *bsw, uint8_t len, uint64_t val) { - uint8_t next, bits, need; + uint8_t need; len = ur_min(64, len); - next = ( 0 == len ) ? 1 : len + (2 * ur_met0_64(len)); - bits = bsw->off + next; - need = (bits >> 3) + !!ur_mask_3(bits); + need = ur_bloq_up3( bsw->off + MAT_LEN(len) ); if ( bsw->fill + need >= bsw->size ) { ur_bsw_grow(bsw, ur_max(need, bsw->prev)); @@ -1183,9 +1182,7 @@ _bsw_mat_bytes_unsafe(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) void ur_bsw_mat_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) { - uint64_t next = ( 0 == len ) ? 1 : len + (2 * ur_met0_64(len)); - uint64_t bits = bsw->off + next; - uint64_t need = (bits >> 3) + !!ur_mask_3(bits); + uint64_t need = ur_bloq_up3( bsw->off + MAT_LEN(len) ); if ( bsw->fill + need >= bsw->size ) { ur_bsw_grow(bsw, ur_max(need, bsw->prev)); @@ -1204,9 +1201,10 @@ _bsw_back64(ur_bsw_t *bsw, uint8_t len, uint64_t val) void ur_bsw_back64(ur_bsw_t *bsw, uint8_t len, uint64_t val) { - uint64_t next = ( 0 == len ) ? 1 : len + (2 * ur_met0_64(len)); - uint64_t bits = 2 + bsw->off + next; - uint64_t need = (bits >> 3) + !!ur_mask_3(bits); + uint8_t need; + + len = ur_min(64, len); + need = ur_bloq_up3( 2 + bsw->off + MAT_LEN(len) ); if ( bsw->fill + need >= bsw->size ) { ur_bsw_grow(bsw, ur_max(need, bsw->prev)); @@ -1225,9 +1223,10 @@ _bsw_atom64(ur_bsw_t *bsw, uint8_t len, uint64_t val) void ur_bsw_atom64(ur_bsw_t *bsw, uint8_t len, uint64_t val) { - uint64_t next = ( 0 == len ) ? 1 : len + (2 * ur_met0_64(len)); - uint64_t bits = 1 + bsw->off + next; - uint64_t need = (bits >> 3) + !!ur_mask_3(bits); + uint8_t need; + + len = ur_min(64, len); + need = ur_bloq_up3( 1 + bsw->off + MAT_LEN(len) ); if ( bsw->fill + need >= bsw->size ) { ur_bsw_grow(bsw, ur_max(need, bsw->prev)); @@ -1246,9 +1245,7 @@ _bsw_atom_bytes_unsafe(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) void ur_bsw_atom_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) { - uint64_t next = ( 0 == len ) ? 1 : len + (2 * ur_met0_64(len)); - uint64_t bits = 1 + bsw->off + next; - uint64_t need = (bits >> 3) + !!ur_mask_3(bits); + uint64_t need = ur_bloq_up3( 1 + bsw->off + MAT_LEN(len) ); if ( bsw->fill + need >= bsw->size ) { ur_bsw_grow(bsw, ur_max(need, bsw->prev)); @@ -1260,8 +1257,7 @@ ur_bsw_atom_bytes(ur_bsw_t *bsw, uint64_t len, uint8_t *byt) void ur_bsw_cell(ur_bsw_t *bsw) { - uint8_t bits = 2 + bsw->off; - uint8_t need = (bits >> 3) + !!ur_mask_3(bits); + uint8_t need = ur_bloq_up3( 2 + bsw->off ); if ( bsw->fill + need >= bsw->size ) { ur_bsw_grow(bsw, ur_max(need, bsw->prev)); From a6a7b557a95cd246430ce68809d8188d40ae28f4 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 15 Sep 2020 15:12:14 -0700 Subject: [PATCH 344/933] serf: adds comments re: unnecessary failure-mode of %uncram --- pkg/urbit/worker/main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/urbit/worker/main.c b/pkg/urbit/worker/main.c index a9d48e840c..dabd2ae182 100644 --- a/pkg/urbit/worker/main.c +++ b/pkg/urbit/worker/main.c @@ -254,6 +254,9 @@ _cw_serf_commence(c3_i argc, c3_c* argv[]) if ( eve_d ) { // XX need not be fatal, need a u3m_reboot equivalent + // XX can spuriously fail do to corrupt memory-image checkpoint, + // need a u3m_half_boot equivalent + // workaround is to delete/move the checkpoint in case of corruption // if ( c3n == u3u_uncram(u3V.dir_c, eve_d) ) { fprintf(stderr, "serf (%" PRIu64 "): rock load failed\r\n", eve_d); @@ -368,6 +371,10 @@ _cw_queu(c3_i argc, c3_c* argv[]) u3V.dir_c = strdup(dir_c); u3V.sen_d = u3V.dun_d = u3m_boot(dir_c); + // XX can spuriously fail do to corrupt memory-image checkpoint, + // need a u3m_half_boot equivalent + // workaround is to delete/move the checkpoint in case of corruption + // if ( c3n == u3u_uncram(dir_c, eve_d) ) { fprintf(stderr, "urbit-worker: queu: failed\r\n"); exit(1); From bd0432f84e1dc83dbe1bd3e2b2d07d021eda8074 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 17 Sep 2020 11:54:57 -0700 Subject: [PATCH 345/933] ur: adds initialization/finalization to bitstream-write api --- pkg/urbit/include/ur/bitstream.h | 12 ++++++++++++ pkg/urbit/noun/serial.c | 10 ++-------- pkg/urbit/ur/bitstream.c | 27 +++++++++++++++++++++++++++ pkg/urbit/ur/serial.c | 14 +++----------- 4 files changed, 44 insertions(+), 19 deletions(-) diff --git a/pkg/urbit/include/ur/bitstream.h b/pkg/urbit/include/ur/bitstream.h index 66781f569e..8e7ae7f941 100644 --- a/pkg/urbit/include/ur/bitstream.h +++ b/pkg/urbit/include/ur/bitstream.h @@ -130,6 +130,12 @@ ur_bsr_log(ur_bsr_t *bsr, uint8_t *out); ur_cue_res_e ur_bsr_rub_len(ur_bsr_t *bsr, uint64_t *out); +/* +** initialize bitstream-writer with prev/size for fibonacci growth. +*/ +void +ur_bsw_init(ur_bsw_t *bsw, uint64_t prev, uint64_t size); + /* ** reallocate bitstream write buffer with max(fibonacci, step) growth. */ @@ -142,6 +148,12 @@ ur_bsw_grow(ur_bsw_t *bsw, uint64_t step); ur_bool_t ur_bsw_sane(ur_bsw_t *bsw); +/* +** return bit-length, produce byte-buffer. +*/ +uint64_t +ur_bsw_done(ur_bsw_t *bsw, uint64_t *len, uint8_t **byt); + /* ** write a bit */ diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index 79208801a0..15c946699a 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -290,13 +290,10 @@ c3_d u3s_jam_xeno(u3_noun a, c3_d* len_d, c3_y** byt_y) { _jam_xeno_t jam_u = {0}; + ur_bsw_init(&jam_u.rit_u, ur_fib11, ur_fib12); jam_u.har_p = u3h_new(); - jam_u.rit_u.prev = ur_fib11; - jam_u.rit_u.size = ur_fib12; - jam_u.rit_u.bytes = c3_calloc(jam_u.rit_u.size); - // as this is a hot path, we unsafely elide overflow checks // // a page-fault overflow detection system is urgently needed ... @@ -304,12 +301,9 @@ u3s_jam_xeno(u3_noun a, c3_d* len_d, c3_y** byt_y) u3a_walk_fore_unsafe(a, &jam_u, _cs_jam_xeno_atom, _cs_jam_xeno_cell); - *len_d = jam_u.rit_u.fill + !!jam_u.rit_u.off; - *byt_y = jam_u.rit_u.bytes; - u3h_free(jam_u.har_p); - return jam_u.rit_u.bits; + return ur_bsw_done(&jam_u.rit_u, len_d, byt_y); } #define CUE_ROOT 0 diff --git a/pkg/urbit/ur/bitstream.c b/pkg/urbit/ur/bitstream.c index 31f485b853..146f5e33d9 100644 --- a/pkg/urbit/ur/bitstream.c +++ b/pkg/urbit/ur/bitstream.c @@ -702,6 +702,20 @@ ur_bsr_rub_len(ur_bsr_t *bsr, uint64_t *out) ** of reallocating the output buffer. */ +void +ur_bsw_init(ur_bsw_t *bsw, uint64_t prev, uint64_t size) +{ + bsw->prev = prev; + bsw->size = size; + bsw->bytes = calloc(size, 1); + + if ( !bsw->bytes ) { + fprintf(stderr, + "ur: bitstream-init allocation failed, out of memory\r\n"); + abort(); + } +} + void ur_bsw_grow(ur_bsw_t *bsw, uint64_t step) { @@ -729,6 +743,19 @@ ur_bsw_sane(ur_bsw_t *bsw) && ((bsw->fill << 3) + bsw->off == bsw->bits) ); } +uint64_t +ur_bsw_done(ur_bsw_t *bsw, uint64_t *len, uint8_t **byt) +{ + uint64_t bits = bsw->bits; + + *len = bsw->fill + !!bsw->off; + *byt = bsw->bytes; + + memset(bsw, 0, sizeof(*bsw)); + + return bits; +} + static inline void _bsw_bit_unsafe(ur_bsw_t *bsw, uint8_t bit) { diff --git a/pkg/urbit/ur/serial.c b/pkg/urbit/ur/serial.c index a2d111e91e..7f922f5394 100644 --- a/pkg/urbit/ur/serial.c +++ b/pkg/urbit/ur/serial.c @@ -87,20 +87,12 @@ ur_jam_unsafe(ur_root_t *r, uint64_t *len, uint8_t **byt) { - _jam_t j = {0}; - - j.dict = dict; - - j.bsw.prev = ur_fib11; - j.bsw.size = ur_fib12; - j.bsw.bytes = _oom("jam", calloc(j.bsw.size, 1)); + _jam_t j = { .dict = dict }; + ur_bsw_init(&j.bsw, ur_fib11, ur_fib12); ur_walk_fore(r, ref, &j, _jam_atom, _jam_cell); - *len = j.bsw.fill + !!j.bsw.off; - *byt = j.bsw.bytes; - - return j.bsw.bits; + return ur_bsw_done(&j.bsw, len, byt); } uint64_t From 06cf6386aadf16c73c5bac027c472df3583d2aff Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 17 Sep 2020 11:55:31 -0700 Subject: [PATCH 346/933] ur: renames bitstream-write reinit test helper for clarity --- pkg/urbit/tests/ur_tests.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index 56e8f2dc17..f8d6ae1e09 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -11,7 +11,7 @@ ** initialize helper for bitstream-writer tests. */ static void -_bsw_init(ur_bsw_t *bsw, uint64_t prev, uint64_t size) +_bsw_reinit(ur_bsw_t *bsw, uint64_t prev, uint64_t size) { bsw->prev = prev; bsw->size = size; @@ -58,7 +58,7 @@ _test_bsw_bit_ones(void) { int ret = 1; ur_bsw_t bsw = {0}; - _bsw_init(&bsw, 1, 1); + _bsw_reinit(&bsw, 1, 1); ret &= _bsw_bit_check("bsw ones init", &bsw, 0x0, 0); @@ -104,7 +104,7 @@ _test_bsw_bit_zeros(void) { int ret = 1; ur_bsw_t bsw = {0}; - _bsw_init(&bsw, 1, 1); + _bsw_reinit(&bsw, 1, 1); ret &= _bsw_bit_check("bsw zeros init", &bsw, 0x0, 0); @@ -150,7 +150,7 @@ _test_bsw_bit_alt(void) { int ret = 1; ur_bsw_t bsw = {0}; - _bsw_init(&bsw, 1, 1); + _bsw_reinit(&bsw, 1, 1); ret &= _bsw_bit_check("bsw alt init", &bsw, 0x0, 0); @@ -286,8 +286,8 @@ _test_bsw8_loop(const char* cap, uint8_t val) for ( i = 0; i < 8; i++) { for ( j = 0; j <= 8; j++ ) { - _bsw_init(&a, 1, 1); - _bsw_init(&b, 1, 1); + _bsw_reinit(&a, 1, 1); + _bsw_reinit(&b, 1, 1); a.off = a.bits = b.off = b.bits = i; _bsw8_slow(&a, j, val); @@ -338,8 +338,8 @@ _test_bsw32_loop(const char* cap, uint32_t val) for ( i = 0; i < 8; i++) { for ( j = 0; j <= 32; j++ ) { - _bsw_init(&a, 1, 1); - _bsw_init(&b, 1, 1); + _bsw_reinit(&a, 1, 1); + _bsw_reinit(&b, 1, 1); a.off = a.bits = b.off = b.bits = i; _bsw32_slow(&a, j, val); @@ -390,8 +390,8 @@ _test_bsw64_loop(const char* cap, uint64_t val) for ( i = 0; i < 8; i++) { for ( j = 0; j <= 64; j++ ) { - _bsw_init(&a, 1, 1); - _bsw_init(&b, 1, 1); + _bsw_reinit(&a, 1, 1); + _bsw_reinit(&b, 1, 1); a.off = a.bits = b.off = b.bits = i; _bsw64_slow(&a, j, val); @@ -447,8 +447,8 @@ _test_bsw_bytes_loop(const char* cap, uint64_t len, uint8_t val) for ( i = 0; i < 8; i++) { for ( j = 0; j < len_bit; j++ ) { - _bsw_init(&a, 1, 1); - _bsw_init(&b, 1, 1); + _bsw_reinit(&a, 1, 1); + _bsw_reinit(&b, 1, 1); a.off = a.bits = b.off = b.bits = i; _bsw_bytes_slow(&a, j, byt); @@ -506,8 +506,8 @@ _test_bsw_bex() for ( i = 0; i < 8; i++) { for ( j = 0; j < 256; j++ ) { - _bsw_init(&a, 1, 1); - _bsw_init(&b, 1, 1); + _bsw_reinit(&a, 1, 1); + _bsw_reinit(&b, 1, 1); a.off = a.bits = b.off = b.bits = i; _bsw_bex_slow(&a, j); From efe4479f23769584a0e3f1bd1cfe5fecd090dd31 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 17 Sep 2020 15:12:30 -0700 Subject: [PATCH 347/933] ur: refactors unsafe cue variants into a handle-based api --- pkg/urbit/bench/ur_bench.c | 12 +- pkg/urbit/include/ur/serial.h | 54 +++++++-- pkg/urbit/ur/serial.c | 199 +++++++++++++++++++++++++--------- 3 files changed, 194 insertions(+), 71 deletions(-) diff --git a/pkg/urbit/bench/ur_bench.c b/pkg/urbit/bench/ur_bench.c index 8a29de65a2..36be84cecd 100644 --- a/pkg/urbit/bench/ur_bench.c +++ b/pkg/urbit/bench/ur_bench.c @@ -261,8 +261,7 @@ _cue_bench(void) gettimeofday(&b4, 0); { - ur_dict_t dic_u = {0}; - u3_noun out; + ur_cue_test_t *t = ur_cue_test_init(); c3_w len_w = u3r_met(3, vat); // XX assumes little-endian @@ -271,20 +270,17 @@ _cue_bench(void) ? (c3_y*)&vat : (c3_y*)((u3a_atom*)u3a_to_ptr(vat))->buf_w; - ur_dict_grow((ur_root_t*)0, &dic_u, ur_fib10, ur_fib11); - for ( i_w = 0; i_w < max_w; i_w++ ) { - ur_cue_test_unsafe(&dic_u, len_w, byt_y); - ur_dict_wipe(&dic_u); + ur_cue_test_with(t, len_w, byt_y); } - ur_dict_free(&dic_u); + ur_cue_test_done(t); } gettimeofday(&f2, 0); timersub(&f2, &b4, &d0); mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); - fprintf(stderr, " cue test unsafe: %u ms\r\n", mil_w); + fprintf(stderr, " cue test with: %u ms\r\n", mil_w); } { diff --git a/pkg/urbit/include/ur/serial.h b/pkg/urbit/include/ur/serial.h index dde11ee67b..677851f8a6 100644 --- a/pkg/urbit/include/ur/serial.h +++ b/pkg/urbit/include/ur/serial.h @@ -29,28 +29,58 @@ ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt); ** supports up to 62-bits of bit-addressed input (511 PiB). ** returns [ur_cue_good] on success. ** -** unsafe variant is unsafe wrt its [dict] parameter, which must be empty, -** (present in order to skip reallocation inside hot loops). +** cue_with factors out stack/dict (re)allocation, +** for better performance of hot loops. ** -** test variant does not allocate nouns, but merely parses the input. +** cue_test does not allocate nouns, but merely parses the input; +** cue_test_with* api factors out stack/dict (re)allocation, +** for better performance of repeated tests. ** */ -ur_cue_res_e -ur_cue_unsafe(ur_root_t *r, - ur_dict64_t *dict, - uint64_t len, - const uint8_t *byt, - ur_nref *out); + +typedef struct ur_cue_test_s ur_cue_test_t; +typedef struct ur_cue_s ur_cue_t; ur_cue_res_e ur_cue(ur_root_t *r, uint64_t len, const uint8_t *byt, ur_nref *out); +ur_cue_t* +ur_cue_init_with(ur_root_t *r, + uint64_t d_prev, + uint64_t d_size, + uint32_t s_prev, + uint32_t s_size); + +ur_cue_t* +ur_cue_init(ur_root_t *r); + ur_cue_res_e -ur_cue_test_unsafe(ur_dict_t *dict, - uint64_t len, - const uint8_t *byt); +ur_cue_with(ur_cue_t *c, + uint64_t len, + const uint8_t *byt, + ur_nref *out); + +void +ur_cue_done(ur_cue_t *c); ur_bool_t ur_cue_test(uint64_t len, const uint8_t *byt); +ur_cue_test_t* +ur_cue_test_init_with(uint64_t d_prev, + uint64_t d_size, + uint32_t s_prev, + uint32_t s_size); + +ur_cue_test_t* +ur_cue_test_init(void); + +ur_bool_t +ur_cue_test_with(ur_cue_test_t *t, + uint64_t len, + const uint8_t *byt); + +void +ur_cue_test_done(ur_cue_test_t *t); + #endif diff --git a/pkg/urbit/ur/serial.c b/pkg/urbit/ur/serial.c index 7f922f5394..dfe5dcb250 100644 --- a/pkg/urbit/ur/serial.c +++ b/pkg/urbit/ur/serial.c @@ -216,15 +216,25 @@ _cue_next(ur_root_t *r, } } -ur_cue_res_e -ur_cue_unsafe(ur_root_t *r, - ur_dict64_t *dict, - uint64_t len, - const uint8_t *byt, - ur_nref *out) +/* +** define opaque struct ur_cue_s (ie, ur_cue_t) +*/ +struct ur_cue_s { + ur_root_t *r; + _cue_stack_t s; + ur_dict64_t dict; +}; + +static ur_cue_res_e +_cue(ur_cue_t *c, + uint64_t len, + const uint8_t *byt, + ur_nref *out) { - ur_bsr_t bsr = {0}; - _cue_stack_t s = {0}; + ur_bsr_t bsr = {0}; + ur_root_t *r = c->r; + _cue_stack_t *s = &c->s; + ur_dict64_t *dict = &c->dict; ur_cue_res_e res; ur_nref ref; @@ -239,58 +249,99 @@ ur_cue_unsafe(ur_root_t *r, return ur_cue_meme; } - // setup stack - // - s.prev = ur_fib10; - s.size = ur_fib11; - s.f = _oom("cue stack", malloc(s.size * sizeof(*s.f))); - // advance into stream // - res = _cue_next(r, &s, &bsr, dict, &ref); + res = _cue_next(r, s, &bsr, dict, &ref); // process result // - while ( s.fill && (ur_cue_good == res) ) { + while ( s->fill && (ur_cue_good == res) ) { // peek at the top of the stack // - _cue_frame_t *f = &(s.f[s.fill - 1]); + _cue_frame_t *f = &(s->f[s->fill - 1]); // f is a head-frame; stash result and read the tail from the stream // if ( CUE_HEAD == f->ref ) { f->ref = ref; - res = _cue_next(r, &s, &bsr, dict, &ref); + res = _cue_next(r, s, &bsr, dict, &ref); } // f is a tail-frame; pop the stack and continue // else { ref = ur_cons(r, f->ref, ref); ur_dict64_put(r, dict, f->bits, (uint64_t)ref); - s.fill--; + s->fill--; } } - free(s.f); - if ( ur_cue_good == res ) { *out = ref; } return res; } +ur_cue_t* +ur_cue_init_with(ur_root_t *r, + uint64_t d_prev, + uint64_t d_size, + uint32_t s_prev, + uint32_t s_size) +{ + ur_cue_t* c = _oom("cue_init", calloc(sizeof(*c), 1)); + c->r = r; + + ur_dict64_grow(r, &c->dict, d_prev, d_size); + + c->s.prev = s_prev; + c->s.size = s_size; + c->s.f = _oom("cue_test_init", malloc(s_size * sizeof(*c->s.f))); + + return c; +} + +ur_cue_t* +ur_cue_init(ur_root_t *r) +{ + return ur_cue_init_with(r, ur_fib11, ur_fib12, // dict sizes + ur_fib10, ur_fib11); // stack sizes +} + +ur_cue_res_e +ur_cue_with(ur_cue_t *c, + uint64_t len, + const uint8_t *byt, + ur_nref *out) +{ + ur_cue_res_e res = _cue(c, len, byt, out); + + // XX check size, shrink if above threshold + // + ur_dict64_wipe(&c->dict); + c->s.fill = 0; + + return res; +} + +void +ur_cue_done(ur_cue_t *c) +{ + + ur_dict_free((ur_dict_t*)&c->dict); + free(c->s.f); + free(c); +} + ur_cue_res_e ur_cue(ur_root_t *r, uint64_t len, const uint8_t *byt, ur_nref *out) { - ur_dict64_t dict = {0}; - ur_dict64_grow(r, &dict, ur_fib11, ur_fib12); + ur_cue_t *c = ur_cue_init(r); + ur_cue_res_e res = _cue(c, len, byt, out); - ur_cue_res_e res = ur_cue_unsafe(r, &dict, len, byt, out); - - ur_dict_free((ur_dict_t*)&dict); + ur_cue_done(c); return res; } @@ -378,14 +429,23 @@ _cue_test_next(_cue_test_stack_t *s, } } -ur_cue_res_e -ur_cue_test_unsafe(ur_dict_t *dict, - uint64_t len, - const uint8_t *byt) +/* +** define opaque struct ur_cue_test_s (ie, ur_cue_test_t) +*/ +struct ur_cue_test_s { + _cue_test_stack_t s; + ur_dict_t dict; +}; + +static ur_cue_res_e +_cue_test(ur_cue_test_t *t, + uint64_t len, + const uint8_t *byt) { - ur_bsr_t bsr = {0}; - _cue_test_stack_t s = {0}; - ur_cue_res_e res; + ur_bsr_t bsr = {0}; + _cue_test_stack_t *s = &t->s; + ur_dict_t *dict = &t->dict; + ur_cue_res_e res; // init bitstream-reader // @@ -398,50 +458,87 @@ ur_cue_test_unsafe(ur_dict_t *dict, return ur_cue_meme; } - // setup stack - // - s.prev = ur_fib10; - s.size = ur_fib11; - s.f = _oom("cue_test", malloc(s.size * sizeof(*s.f))); - // advance into stream // - res = _cue_test_next(&s, &bsr, dict); + res = _cue_test_next(s, &bsr, dict); // process result // - while ( s.fill && (ur_cue_good == res) ) { + while ( s->fill && (ur_cue_good == res) ) { // peek at the top of the stack // - _cue_test_frame_t *f = &(s.f[s.fill - 1]); + _cue_test_frame_t *f = &(s->f[s->fill - 1]); // f is a head-frame; stash result and read the tail from the stream // if ( !f->tal ) { f->tal = 1; - res = _cue_test_next(&s, &bsr, dict); + res = _cue_test_next(s, &bsr, dict); } // f is a tail-frame; pop the stack and continue // else { ur_dict_put((ur_root_t*)0, dict, f->bits); - s.fill--; + s->fill--; } } - free(s.f); - return res; } +ur_cue_test_t* +ur_cue_test_init_with(uint64_t d_prev, + uint64_t d_size, + uint32_t s_prev, + uint32_t s_size) +{ + ur_cue_test_t* t = _oom("cue_test_init", calloc(sizeof(*t), 1)); + + ur_dict_grow((ur_root_t*)0, &t->dict, d_prev, d_size); + + t->s.prev = s_prev; + t->s.size = s_size; + t->s.f = _oom("cue_test_init", malloc(s_size * sizeof(*t->s.f))); + + return t; +} + +ur_cue_test_t* +ur_cue_test_init(void) +{ + return ur_cue_test_init_with(ur_fib11, ur_fib12, // dict sizes + ur_fib10, ur_fib11); // stack sizes +} + +ur_bool_t +ur_cue_test_with(ur_cue_test_t *t, + uint64_t len, + const uint8_t *byt) +{ + ur_bool_t ret = ur_cue_good == _cue_test(t, len, byt); + + // XX check size, shrink if above threshold + // + ur_dict_wipe(&t->dict); + t->s.fill = 0; + + return ret; +} + +void +ur_cue_test_done(ur_cue_test_t *t) +{ + ur_dict_free(&t->dict); + free(t->s.f); + free(t); +} + ur_bool_t ur_cue_test(uint64_t len, const uint8_t *byt) { - ur_dict_t dict = {0}; - ur_dict_grow((ur_root_t*)0, &dict, ur_fib11, ur_fib12); + ur_cue_test_t *t = ur_cue_test_init(); + ur_bool_t ret = ur_cue_good == _cue_test(t, len, byt); - ur_bool_t ret = ur_cue_good == ur_cue_test_unsafe(&dict, len, byt); - - ur_dict_free(&dict); + ur_cue_test_done(t); return ret; } From 6b10dd0f7e6b3ca2238f002d11e480c62ef850f0 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 17 Sep 2020 15:59:18 -0700 Subject: [PATCH 348/933] ur: adds walk_fore variant with a handle-based api for repeated traversal --- pkg/urbit/include/ur/hashcons.h | 29 ++++++- pkg/urbit/ur/hashcons.c | 132 ++++++++++++++++++++++---------- 2 files changed, 116 insertions(+), 45 deletions(-) diff --git a/pkg/urbit/include/ur/hashcons.h b/pkg/urbit/include/ur/hashcons.h index c8a8e4ba50..ea047e13f1 100644 --- a/pkg/urbit/include/ur/hashcons.h +++ b/pkg/urbit/include/ur/hashcons.h @@ -111,6 +111,11 @@ typedef struct ur_nvec_s { ur_nref* refs; } ur_nvec_t; +/* +** opaque handle for repeated traversal. +*/ +typedef struct ur_walk_fore_s ur_walk_fore_t; + /* ** type-specific dictionary operations. ** @@ -225,10 +230,28 @@ ur_nvec_free(ur_nvec_t *v); ** depth-first, pre-order noun traversal, cells can short-circuit. */ void -ur_walk_fore(ur_root_t *r, - ur_nref ref, - void *v, +ur_walk_fore(ur_root_t *r, + ur_nref ref, + void *v, void (*atom)(ur_root_t*, ur_nref, void*), ur_bool_t (*cell)(ur_root_t*, ur_nref, void*)); +ur_walk_fore_t* +ur_walk_fore_init_with(ur_root_t *r, + uint32_t s_prev, + uint32_t s_size); + +ur_walk_fore_t* +ur_walk_fore_init(ur_root_t *r); + +void +ur_walk_fore_with(ur_walk_fore_t *w, + ur_nref ref, + void *v, + void (*atom)(ur_root_t*, ur_nref, void*), + ur_bool_t (*cell)(ur_root_t*, ur_nref, void*)); + +void +ur_walk_fore_done(ur_walk_fore_t *w); + #endif diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index f00a8be5a7..3360ed3e95 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -894,6 +894,93 @@ ur_nvec_init(ur_nvec_t *v, uint64_t size) v->refs = _oom("nvec_init", calloc(size, sizeof(ur_nref))); } +/* +** define opaque struct ur_walk_fore_s (ie, ur_walk_fore_t) +*/ +struct ur_walk_fore_s { + ur_root_t *r; + uint32_t prev; + uint32_t size; + uint32_t fill; + ur_nref *top; +}; + +ur_walk_fore_t* +ur_walk_fore_init_with(ur_root_t *r, + uint32_t s_prev, + uint32_t s_size) +{ + ur_walk_fore_t *w = _oom("walk_fore", malloc(sizeof(*w))); + w->top = _oom("walk_fore", malloc(s_size * sizeof(*w->top))); + w->prev = s_prev; + w->size = s_size; + w->fill = 0; + w->r = r; + + return w; +} + +ur_walk_fore_t* +ur_walk_fore_init(ur_root_t *r) +{ + return ur_walk_fore_init_with(r, ur_fib10, ur_fib11); +} + +void +ur_walk_fore_with(ur_walk_fore_t *w, + ur_nref ref, + void *v, + void (*atom)(ur_root_t*, ur_nref, void*), + ur_bool_t (*cell)(ur_root_t*, ur_nref, void*)) +{ + ur_root_t *r = w->r; + ur_nref *don = w->top; + + w->top += ++w->fill; + *w->top = ref; + + while ( w->top != don ) { + // visit atom, pop stack + // + if ( !ur_deep(ref) ) { + atom(r, ref, v); + w->top--; w->fill--; + } + // visit cell, pop stack if false + // + else if ( !cell(r, ref, v) ) { + w->top--; w->fill--; + } + // push the tail, continue into the head + // + else { + *w->top = ur_tail(r, ref); + + // reallocate "stack" if full + // + if ( w->size == w->fill ) { + uint32_t next = w->prev + w->size; + don = _oom("walk_fore", realloc(don, next * sizeof(*don))); + w->top = don + w->fill; + w->prev = w->size; + w->size = next; + } + + w->top++; w->fill++; + *w->top = ur_head(r, ref); + } + + ref = *w->top; + } +} + +void +ur_walk_fore_done(ur_walk_fore_t *w) +{ + free(w->top); + free(w); +} + void ur_walk_fore(ur_root_t *r, ur_nref ref, @@ -901,46 +988,7 @@ ur_walk_fore(ur_root_t *r, void (*atom)(ur_root_t*, ur_nref, void*), ur_bool_t (*cell)(ur_root_t*, ur_nref, void*)) { - uint64_t prev = ur_fib11, size = ur_fib12, fill = 0; - ur_nref *top, *don; - - don = _oom("walk_fore", malloc(size * sizeof(*don))); - top = don + ++fill; - *top = ref; - - while ( top != don ) { - // visit atom, pop stack - // - if ( !ur_deep(ref) ) { - atom(r, ref, v); - top--; fill--; - } - // visit cell, pop stack if false - // - else if ( !cell(r, ref, v) ) { - top--; fill--; - } - // push the tail, continue into the head - // - else { - *top = ur_tail(r, ref); - - // reallocate "stack" if full - // - if ( size == fill ) { - uint64_t next = prev + size; - don = _oom("walk_fore", realloc(don, next * sizeof(*don))); - top = don + fill; - prev = size; - size = next; - } - - top++; fill++; - *top = ur_head(r, ref); - } - - ref = *top; - } - - free(don); + ur_walk_fore_t *w = ur_walk_fore_init(r); + ur_walk_fore_with(w, ref, v, atom, cell); + ur_walk_fore_done(w); } From 8b5bc77565f729087cf121c25c69a869760921d0 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 17 Sep 2020 16:17:00 -0700 Subject: [PATCH 349/933] ur: refactors unsafe jam into a handle-based api --- pkg/urbit/bench/ur_bench.c | 15 +++--- pkg/urbit/include/ur/serial.h | 30 ++++++++++-- pkg/urbit/ur/serial.c | 92 +++++++++++++++++++++++++---------- 3 files changed, 100 insertions(+), 37 deletions(-) diff --git a/pkg/urbit/bench/ur_bench.c b/pkg/urbit/bench/ur_bench.c index 36be84cecd..a0cb7a4333 100644 --- a/pkg/urbit/bench/ur_bench.c +++ b/pkg/urbit/bench/ur_bench.c @@ -117,25 +117,22 @@ _jam_bench(void) gettimeofday(&b4, 0); { - ur_dict64_t dic_u = {0}; - c3_d len_d; - c3_y* byt_y; - - ur_dict64_grow((ur_root_t*)0, &dic_u, ur_fib10, ur_fib11); + ur_jam_t *jam_u = ur_jam_init(rot_u); + c3_d len_d; + c3_y* byt_y; for ( i_w = 0; i_w < max_w; i_w++ ) { - ur_jam_unsafe(rot_u, ref, &dic_u, &len_d, &byt_y); + ur_jam_with(jam_u, ref, &len_d, &byt_y); c3_free(byt_y); - ur_dict64_wipe(&dic_u); } - ur_dict_free((ur_dict_t*)&dic_u); + ur_jam_done(jam_u); } gettimeofday(&f2, 0); timersub(&f2, &b4, &d0); mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); - fprintf(stderr, " jam cons unsafe: %u ms\r\n", mil_w); + fprintf(stderr, " jam cons with: %u ms\r\n", mil_w); } ur_root_free(rot_u); diff --git a/pkg/urbit/include/ur/serial.h b/pkg/urbit/include/ur/serial.h index 677851f8a6..61e91daf9f 100644 --- a/pkg/urbit/include/ur/serial.h +++ b/pkg/urbit/include/ur/serial.h @@ -10,10 +10,13 @@ ** supports up to 64-bits of bit-addressed output (nearly 2 EiB). ** (as this is an impractical volume data, cursor overflow is not checked.) ** -** unsafe variant is unsafe wrt its [dict] parameter, which must be empty, -** but can be passed in order to skip reallocation inside hot loops. +** jam_with* api factors out stack/dict (re)allocation, +** for better performance inside hot loops. ** */ + +typedef struct ur_jam_s ur_jam_t; + uint64_t ur_jam_unsafe(ur_root_t *r, ur_nref ref, @@ -22,7 +25,28 @@ ur_jam_unsafe(ur_root_t *r, uint8_t **byt); uint64_t -ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt); +ur_jam(ur_root_t *r, + ur_nref ref, + uint64_t *len, + uint8_t **byt); + +ur_jam_t* +ur_jam_init_with(ur_root_t *r, + uint64_t d_prev, + uint64_t d_size, + uint32_t s_prev, + uint32_t s_size); + +ur_jam_t* +ur_jam_init(ur_root_t *r); + +uint64_t +ur_jam_with(ur_jam_t *j, + ur_nref ref, + uint64_t *len, + uint8_t **byt); +void +ur_jam_done(ur_jam_t *j); /* ** bitwise deserialization of a byte-buffer into a noun. diff --git a/pkg/urbit/ur/serial.c b/pkg/urbit/ur/serial.c index dfe5dcb250..61eeca39c7 100644 --- a/pkg/urbit/ur/serial.c +++ b/pkg/urbit/ur/serial.c @@ -30,16 +30,21 @@ _bsw_atom(ur_root_t *r, ur_nref ref, ur_bsw_t *bsw, uint64_t len) } } -typedef struct _jam_s { - ur_dict64_t *dict; +/* +** define opaque struct ur_jam_s (ie, ur_jam_t) +*/ +struct ur_jam_s { + ur_root_t *r; + ur_walk_fore_t *w; + ur_dict64_t dict; ur_bsw_t bsw; -} _jam_t; +}; static void _jam_atom(ur_root_t *r, ur_nref ref, void *ptr) { - _jam_t *j = ptr; - ur_dict64_t *dict = j->dict; + ur_jam_t *j = ptr; + ur_dict64_t *dict = &j->dict; ur_bsw_t *bsw = &j->bsw; uint64_t bak, len = ur_met(r, 0, ref); @@ -63,8 +68,8 @@ _jam_atom(ur_root_t *r, ur_nref ref, void *ptr) static ur_bool_t _jam_cell(ur_root_t *r, ur_nref ref, void *ptr) { - _jam_t *j = ptr; - ur_dict64_t *dict = j->dict; + ur_jam_t *j = ptr; + ur_dict64_t *dict = &j->dict; ur_bsw_t *bsw = &j->bsw; uint64_t bak; @@ -80,32 +85,69 @@ _jam_cell(ur_root_t *r, ur_nref ref, void *ptr) } } -uint64_t -ur_jam_unsafe(ur_root_t *r, - ur_nref ref, - ur_dict64_t *dict, - uint64_t *len, - uint8_t **byt) +static uint64_t +_jam(ur_jam_t *j, + ur_nref ref, + uint64_t *len, + uint8_t **byt) { - _jam_t j = { .dict = dict }; - ur_bsw_init(&j.bsw, ur_fib11, ur_fib12); + ur_bsw_init(&j->bsw, ur_fib11, ur_fib12); + ur_walk_fore_with(j->w, ref, j, _jam_atom, _jam_cell); + return ur_bsw_done(&j->bsw, len, byt); +} - ur_walk_fore(r, ref, &j, _jam_atom, _jam_cell); +ur_jam_t* +ur_jam_init_with(ur_root_t *r, + uint64_t d_prev, + uint64_t d_size, + uint32_t s_prev, + uint32_t s_size) +{ + ur_jam_t *j = _oom("jam_init", calloc(sizeof(*j), 1)); + j->w = ur_walk_fore_init_with(r, s_prev, s_size); + j->r = r; - return ur_bsw_done(&j.bsw, len, byt); + ur_dict64_grow(r, &j->dict, d_prev, d_size); + + return j; +} + +ur_jam_t* +ur_jam_init(ur_root_t *r) +{ + return ur_jam_init_with(r, ur_fib11, ur_fib12, // dict sizes + ur_fib10, ur_fib11); // stack sizes } uint64_t -ur_jam(ur_root_t *r, ur_nref ref, uint64_t *len, uint8_t **byt) +ur_jam_with(ur_jam_t *j, + ur_nref ref, + uint64_t *len, + uint8_t **byt) { - ur_dict64_t dict = {0}; - ur_dict64_grow(r, &dict, ur_fib11, ur_fib12); + uint64_t bits = _jam(j, ref, len, byt); + ur_dict64_wipe(&j->dict); + return bits; +} - { - uint64_t bits = ur_jam_unsafe(r, ref, &dict, len, byt); - ur_dict_free((ur_dict_t*)&dict); - return bits; - } +void +ur_jam_done(ur_jam_t *j) +{ + ur_dict_free((ur_dict_t*)&j->dict); + free(j->w); + free(j); +} + +uint64_t +ur_jam(ur_root_t *r, + ur_nref ref, + uint64_t *len, + uint8_t **byt) +{ + ur_jam_t *j = ur_jam_init(r); + uint64_t bits = _jam(j, ref, len, byt); + ur_jam_done(j); + return bits; } /* From bf20b93e4da8d3e2501368e10d833b1e7591db1b Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 17 Sep 2020 22:01:41 -0700 Subject: [PATCH 350/933] ur: cleans up ur_met(), atom measurement --- pkg/urbit/ur/hashcons.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 3360ed3e95..71f2568f9a 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -526,15 +526,12 @@ ur_met(ur_root_t *r, uint8_t bloq, ur_nref ref) case 0: return m_bit; case 1: return ur_bloq_up1(m_bit); case 2: return ur_bloq_up2(m_bit); + case 3: return ur_bloq_up3(m_bit); - { + default: { uint64_t m_byt = ur_bloq_up3(m_bit); - - case 3: return m_byt; - default: { - uint8_t off = (bloq - 3); - return (m_byt + ((1ULL << off) - 1)) >> off; - } + uint8_t off = (bloq - 3); + return (m_byt + ((1ULL << off) - 1)) >> off; } } } From bc3c1eb0c7d4aa0d149f0ac32577824e946775c3 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 17 Sep 2020 22:44:13 -0700 Subject: [PATCH 351/933] ur: cleans up ur_bsr_log() --- pkg/urbit/ur/bitstream.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/pkg/urbit/ur/bitstream.c b/pkg/urbit/ur/bitstream.c index 146f5e33d9..dfc42393b7 100644 --- a/pkg/urbit/ur/bitstream.c +++ b/pkg/urbit/ur/bitstream.c @@ -615,7 +615,6 @@ ur_bsr_log(ur_bsr_t *bsr, uint8_t *out) } else { uint8_t off = bsr->off; - uint8_t rest = 8 - off; const uint8_t *b = bsr->bytes; uint8_t byt = b[0] >> off; uint8_t skip = 0; @@ -625,13 +624,11 @@ ur_bsr_log(ur_bsr_t *bsr, uint8_t *out) return _bsr_log_meme(bsr); } - skip++; + byt = b[++skip]; if ( skip == left ) { return _bsr_set_gone(bsr, (skip << 3) - off); } - - byt = b[skip]; } { @@ -646,10 +643,10 @@ ur_bsr_log(ur_bsr_t *bsr, uint8_t *out) left -= bytes; - bsr->bytes = left ? (b + bytes) : 0; - bsr->bits += 1 + zeros; - bsr->left = left; - bsr->off = ur_mask_3(bits); + bsr->bytes = left ? (b + bytes) : 0; + bsr->bits += 1 + zeros; + bsr->left = left; + bsr->off = ur_mask_3(bits); *out = zeros; return ur_cue_good; From 6ef6acbddcb7f6a8af0ba9d044be3a3bf5f1d7f3 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 17 Sep 2020 22:44:40 -0700 Subject: [PATCH 352/933] ur: removes unused variables in tests --- pkg/urbit/tests/ur_tests.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/urbit/tests/ur_tests.c b/pkg/urbit/tests/ur_tests.c index f8d6ae1e09..1e590e572d 100644 --- a/pkg/urbit/tests/ur_tests.c +++ b/pkg/urbit/tests/ur_tests.c @@ -501,8 +501,8 @@ _test_bsw_bex() int ret = 1; ur_bsw_t a = {0}; ur_bsw_t b = {0}; - uint8_t i, l; - uint32_t j, k; + uint8_t i; + uint32_t j; for ( i = 0; i < 8; i++) { for ( j = 0; j < 256; j++ ) { @@ -1363,7 +1363,7 @@ _test_bsr_skip_any_loop(const char *cap, uint8_t len, uint8_t val) uint64_t max = (len << 3) + 7; ur_bsr_t a, b; uint8_t *bytes, *c; - uint8_t i, j, k; + uint8_t i, j; c = malloc(1 + len); bytes = malloc(len); @@ -1510,7 +1510,7 @@ _test_bsr_log_loop(const char *cap, uint8_t len, uint8_t val) int ret = 1; ur_bsr_t a, b; uint8_t *bytes, c, d; - uint8_t i, j, k; + uint8_t i, j; ur_cue_res_e e, f; bytes = malloc(len); @@ -1602,7 +1602,7 @@ _test_bsr_tag_loop(const char *cap, uint8_t len, uint8_t val) ur_bsr_t a, b; uint8_t *bytes; ur_cue_tag_e c, d; - uint8_t i, j, k; + uint8_t i, j; ur_cue_res_e e, f; bytes = malloc(len); From 81e38c7b72bb166e0c7ba732c33599f144a79e8f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 17 Sep 2020 16:30:42 -0700 Subject: [PATCH 353/933] u3: refactors u3s_cue_bytes() to use road-stack api --- pkg/urbit/noun/serial.c | 99 ++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 61 deletions(-) diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index 15c946699a..d22ca29d06 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -788,13 +788,12 @@ _cs_cue_put(u3p(u3h_root) har_p, c3_d key_d, u3_noun val) return val; } -/* _cs_cue_full_next(): read next value from bitstream. +/* _cs_cue_bytes_next(): read next value from bitstream. */ static inline u3_noun -_cs_cue_full_next(c3_ys mov, - c3_ys off, - u3p(u3h_root) har_p, - ur_bsr_t* red_u) +_cs_cue_bytes_next(u3a_pile* pil_u, + u3p(u3h_root) har_p, + ur_bsr_t* red_u) { while ( 1 ) { c3_d len_d, bit_d = red_u->bits; @@ -806,31 +805,11 @@ _cs_cue_full_next(c3_ys mov, default: c3_assert(0); case ur_jam_cell: { - // wind the stack - // - u3R->cap_p += mov; + _cue_frame_t* fam_u = u3a_push(pil_u); + u3a_pile_sane(pil_u); - // ensure we haven't overflowed (ie, run into the heap) - // (off==0 means we're on a north road) - // - if ( 0 == off ) { - if( !(u3R->cap_p > u3R->hat_p) ) { - u3m_bail(c3__meme); - } - } - else { - if( !(u3R->cap_p < u3R->hat_p) ) { - u3m_bail(c3__meme); - } - } - - // save a head-frame and read the head from the stream - // - { - _cue_frame_t* fam_u = u3to(_cue_frame_t, u3R->cap_p + off); - fam_u->ref = u3_none; - fam_u->bit_d = bit_d; - } + fam_u->ref = u3_none; + fam_u->bit_d = bit_d; continue; } @@ -889,23 +868,19 @@ _cs_cue_full_next(c3_ys mov, u3_noun u3s_cue_bytes(c3_d len_d, const c3_y* byt_y) { - ur_bsr_t red_u = {0}; - u3_noun ref; + ur_bsr_t red_u = {0}; + u3a_pile pil_u; + _cue_frame_t* fam_u; + u3p(u3h_root) har_p; + u3_noun ref; + + // initialize stack control + // + u3a_pile_prep(&pil_u, sizeof(*fam_u)); // initialize a hash table for dereferencing backrefs // - u3p(u3h_root) har_p = u3h_new(); - const u3_post top_p = u3R->cap_p; - - // initialize signed stack offsets (relative to north/south road) - // - c3_ys mov, off; - { - c3_o nor_o = u3a_is_north(u3R); - c3_y wis_y = c3_wiseof(_cue_frame_t); - mov = ( c3y == nor_o ? -wis_y : wis_y ); - off = ( c3y == nor_o ? 0 : -wis_y ); - } + har_p = u3h_new(); // init bitstream-reader // @@ -919,28 +894,30 @@ u3s_cue_bytes(c3_d len_d, const c3_y* byt_y) // advance into stream // - ref = _cs_cue_full_next(mov, off, har_p, &red_u); + ref = _cs_cue_bytes_next(&pil_u, har_p, &red_u); - // process result + // process cell results // - while ( top_p != u3R->cap_p ) { - // peek at the top of the stack - // - _cue_frame_t* fam_u = u3to(_cue_frame_t, u3R->cap_p + off); + if ( c3n == u3a_pile_done(&pil_u) ) { + fam_u = u3a_peek(&pil_u); - // f is a head-frame; stash result and read the tail from the stream - // - if ( u3_none == fam_u->ref ) { - fam_u->ref = ref; - ref = _cs_cue_full_next(mov, off, har_p, &red_u); - } - // f is a tail-frame; pop the stack and continue - // - else { - ref = u3nc(fam_u->ref, ref); - _cs_cue_put(har_p, fam_u->bit_d, ref); - u3R->cap_p -= mov; + do { + // f is a head-frame; stash result and read the tail from the stream + // + if ( u3_none == fam_u->ref ) { + fam_u->ref = ref; + ref = _cs_cue_bytes_next(&pil_u, har_p, &red_u); + fam_u = u3a_peek(&pil_u); + } + // f is a tail-frame; pop the stack and continue + // + else { + ref = u3nc(fam_u->ref, ref); + _cs_cue_put(har_p, fam_u->bit_d, ref); + fam_u = u3a_pop(&pil_u); + } } + while ( c3n == u3a_pile_done(&pil_u) ); } u3h_free(har_p); From 55c4fa2079f5b18272fe1bb41da41ee5e4c37415 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 17 Sep 2020 18:07:34 -0700 Subject: [PATCH 354/933] u3: factors atoms/backrefs out of u3s_cue_xeno --- pkg/urbit/noun/serial.c | 133 ++++++++++++++++++++++++---------------- 1 file changed, 81 insertions(+), 52 deletions(-) diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index d22ca29d06..e6210ba4b5 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -532,6 +532,82 @@ u3s_cue(u3_atom a) return pro; } +/* _cs_cue_xeno_back(): cue a backref, off-loom dictionary. +*/ +static inline ur_cue_res_e +_cs_cue_xeno_back(ur_bsr_t* red_u, + ur_dict32_t* dic_u, + u3_noun* out) +{ + ur_root_t* rot_u = 0; + ur_cue_res_e res_e; + c3_d len_d; + + if ( ur_cue_good != (res_e = ur_bsr_rub_len(red_u, &len_d)) ) { + return res_e; + } + else if ( 62 < len_d ) { + return ur_cue_meme; + } + else { + c3_d bak_d = ur_bsr64_any(red_u, len_d); + c3_w bak_w; + + if ( !ur_dict32_get(rot_u, dic_u, bak_d, &bak_w) ) { + return ur_cue_back; + } + + *out = u3k((u3_noun)bak_w); + return ur_cue_good; + } +} + +/* _cs_cue_xeno_atom(): cue an atom, off-loom dictionary. +*/ +static inline ur_cue_res_e +_cs_cue_xeno_atom(ur_bsr_t* red_u, + ur_dict32_t* dic_u, + c3_d bit_d, + u3_noun* out) +{ + ur_root_t* rot_u = 0; + ur_cue_res_e res_e; + c3_d len_d; + + if ( ur_cue_good != (res_e = ur_bsr_rub_len(red_u, &len_d)) ) { + return res_e; + } + + if ( 31 >= len_d ) { + *out = (u3_noun)ur_bsr32_any(red_u, len_d); + } + // XX need a ur_bsr_words_any() + // + else { + c3_w* wor_w; + c3_y* byt_y; + + { + c3_d byt_d = (len_d >> 3) + !!ur_mask_3(len_d); + + if ( 0xffffffffULL < byt_d) { + return u3m_bail(c3__meme); + } + + // XX assumes little-endian + // + wor_w = u3a_slaq(3, byt_d); + byt_y = (c3_y*)wor_w; + } + + ur_bsr_bytes_any(red_u, len_d, byt_y); + *out = u3a_malt(wor_w); + } + + ur_dict32_put(rot_u, dic_u, bit_d, *out); + return ur_cue_good; +} + /* ** stack frame for recording head vs tail iteration ** @@ -543,6 +619,8 @@ typedef struct _cue_frame_s { c3_d bit_d; } _cue_frame_t; +/* _cue_stack_t: heap-allocated struct, used to bypass the road stack. +*/ typedef struct _cue_stack_s { c3_w pre_w; c3_w siz_w; @@ -558,10 +636,8 @@ _cs_cue_xeno_next(_cue_stack_t* tac_u, ur_dict32_t* dic_u, u3_noun* out) { - ur_root_t* rot_u = 0; - while ( 1 ) { - c3_d len_d, bit_d = red_u->bits; + c3_d bit_d = red_u->bits; ur_cue_tag_e tag_e; ur_cue_res_e res_e; @@ -593,58 +669,11 @@ _cs_cue_xeno_next(_cue_stack_t* tac_u, } case ur_jam_back: { - if ( ur_cue_good != (res_e = ur_bsr_rub_len(red_u, &len_d)) ) { - return res_e; - } - else if ( 62 < len_d ) { - return ur_cue_meme; - } - else { - c3_d bak_d = ur_bsr64_any(red_u, len_d); - c3_w bak_w; - - if ( !ur_dict32_get(rot_u, dic_u, bak_d, &bak_w) ) { - return ur_cue_back; - } - - *out = u3k((u3_noun)bak_w); - return ur_cue_good; - } + return _cs_cue_xeno_back(red_u, dic_u, out); } case ur_jam_atom: { - if ( ur_cue_good != (res_e = ur_bsr_rub_len(red_u, &len_d)) ) { - return res_e; - } - - if ( 31 >= len_d ) { - *out = (u3_noun)ur_bsr32_any(red_u, len_d); - } - // XX need a ur_bsr_words_any() - // - else { - c3_w* wor_w; - c3_y* byt_y; - - { - c3_d byt_d = (len_d >> 3) + !!ur_mask_3(len_d); - - if ( 0xffffffffULL < byt_d) { - return u3m_bail(c3__meme); - } - - // XX assumes little-endian - // - wor_w = u3a_slaq(3, byt_d); - byt_y = (c3_y*)wor_w; - } - - ur_bsr_bytes_any(red_u, len_d, byt_y); - *out = u3a_malt(wor_w); - } - - ur_dict32_put(rot_u, dic_u, bit_d, *out); - return ur_cue_good; + return _cs_cue_xeno_atom(red_u, dic_u, bit_d, out); } } } From bf117f63a8845be7727578734e2ceecca81f1185 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 17 Sep 2020 22:00:42 -0700 Subject: [PATCH 355/933] u3: adds u3s_cue_fill and handle-based api --- pkg/urbit/bench/ur_bench.c | 48 ++++++++ pkg/urbit/include/noun/serial.h | 34 ++++++ pkg/urbit/noun/serial.c | 202 +++++++++++++++++++++++++++++++- pkg/urbit/tests/jam_tests.c | 17 +++ 4 files changed, 295 insertions(+), 6 deletions(-) diff --git a/pkg/urbit/bench/ur_bench.c b/pkg/urbit/bench/ur_bench.c index a0cb7a4333..c97fecfc1c 100644 --- a/pkg/urbit/bench/ur_bench.c +++ b/pkg/urbit/bench/ur_bench.c @@ -177,6 +177,54 @@ _cue_bench(void) fprintf(stderr, " cue atom: %u ms\r\n", mil_w); } + { + gettimeofday(&b4, 0); + + { + c3_w len_w = u3r_met(3, vat); + // XX assumes little-endian + // + c3_y* byt_y = ( c3y == u3a_is_cat(vat) ) + ? (c3_y*)&vat + : (c3_y*)((u3a_atom*)u3a_to_ptr(vat))->buf_w; + + for ( i_w = 0; i_w < max_w; i_w++ ) { + u3z(u3s_cue_sill(len_w, byt_y)); + } + } + + gettimeofday(&f2, 0); + timersub(&f2, &b4, &d0); + mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); + fprintf(stderr, " cue sill: %u ms\r\n", mil_w); + } + + { + gettimeofday(&b4, 0); + + { + u3_cue_sill* sil_u = u3s_cue_sill_init(); + + c3_w len_w = u3r_met(3, vat); + // XX assumes little-endian + // + c3_y* byt_y = ( c3y == u3a_is_cat(vat) ) + ? (c3_y*)&vat + : (c3_y*)((u3a_atom*)u3a_to_ptr(vat))->buf_w; + + for ( i_w = 0; i_w < max_w; i_w++ ) { + u3z(u3s_cue_sill_with(sil_u, len_w, byt_y)); + } + + u3s_cue_sill_done(sil_u); + } + + gettimeofday(&f2, 0); + timersub(&f2, &b4, &d0); + mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); + fprintf(stderr, " cue sill with: %u ms\r\n", mil_w); + } + { gettimeofday(&b4, 0); diff --git a/pkg/urbit/include/noun/serial.h b/pkg/urbit/include/noun/serial.h index f7a06aa4aa..b721d9c5a8 100644 --- a/pkg/urbit/include/noun/serial.h +++ b/pkg/urbit/include/noun/serial.h @@ -1,6 +1,12 @@ /* i/n/serial.h ** */ + /* opaque handles + */ + /* u3_cue_sill: handle for cue-ing with an off-loom dictionary. + */ + typedef struct _u3_cue_sill u3_cue_sill; + /* forward declarations */ /* ur_dict32_s: off-loom 32-bit dictionary. @@ -28,6 +34,34 @@ u3_noun u3s_cue(u3_atom a); + /* u3s_cue_sill_init_with(): initialize a cue_sill handle as specified. + */ + u3_cue_sill* + u3s_cue_sill_init_with(c3_d pre_d, c3_d siz_d); + + /* u3s_cue_sill_init(): initialize a cue_sill handle. + */ + u3_cue_sill* + u3s_cue_sill_init(void); + + /* u3s_cue_sill_init(): cue on-loom, with off-loom dictionary in handle. + */ + u3_weak + u3s_cue_sill_with(u3_cue_sill* sil_u, + c3_d len_d, + const c3_y* byt_y); + + /* u3s_cue_sill_init(): dispose cue_sill handle. + */ + void + u3s_cue_sill_done(u3_cue_sill* sil_u); + + /* u3s_cue_sill(): cue on-loom, with off-loom dictionary. + */ + u3_weak + u3s_cue_sill(c3_d len_d, + const c3_y* byt_y); + /* u3s_cue_xeno_unsafe(): cue onto the loom, all bookkeeping off-loom. */ c3_o diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index e6210ba4b5..8bde730ab2 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -532,10 +532,10 @@ u3s_cue(u3_atom a) return pro; } -/* _cs_cue_xeno_back(): cue a backref, off-loom dictionary. +/* _cs_cue_sill_back(): cue a backref, off-loom dictionary. */ static inline ur_cue_res_e -_cs_cue_xeno_back(ur_bsr_t* red_u, +_cs_cue_sill_back(ur_bsr_t* red_u, ur_dict32_t* dic_u, u3_noun* out) { @@ -562,10 +562,10 @@ _cs_cue_xeno_back(ur_bsr_t* red_u, } } -/* _cs_cue_xeno_atom(): cue an atom, off-loom dictionary. +/* _cs_cue_sill_atom(): cue an atom, off-loom dictionary. */ static inline ur_cue_res_e -_cs_cue_xeno_atom(ur_bsr_t* red_u, +_cs_cue_sill_atom(ur_bsr_t* red_u, ur_dict32_t* dic_u, c3_d bit_d, u3_noun* out) @@ -619,6 +619,196 @@ typedef struct _cue_frame_s { c3_d bit_d; } _cue_frame_t; +/* _cs_cue_sill_next(): read next value from bitstream, dictionary off-loom. +** NB: this is _cs_cue_xeno_next, using the road stack. +*/ +static inline ur_cue_res_e +_cs_cue_sill_next(u3a_pile* pil_u, + ur_bsr_t* red_u, + ur_dict32_t* dic_u, + u3_noun* out) +{ + while ( 1 ) { + c3_d bit_d = red_u->bits; + ur_cue_tag_e tag_e; + ur_cue_res_e res_e; + + if ( ur_cue_good != (res_e = ur_bsr_tag(red_u, &tag_e)) ) { + return res_e; + } + + switch ( tag_e ) { + default: c3_assert(0); + + case ur_jam_cell: { + _cue_frame_t* fam_u = u3a_push(pil_u); + u3a_pile_sane(pil_u); + + fam_u->ref = u3_none; + fam_u->bit_d = bit_d; + continue; + } + + case ur_jam_back: { + return _cs_cue_sill_back(red_u, dic_u, out); + } + + case ur_jam_atom: { + return _cs_cue_sill_atom(red_u, dic_u, bit_d, out); + } + } + } +} + +struct _u3_cue_sill { + ur_dict32_t dic_u; +}; + +/* _cs_cue_sill(): cue on-loom, with off-loom dictionary in handle. +*/ +static u3_weak +_cs_cue_sill(u3_cue_sill* sil_u, + c3_d len_d, + const c3_y* byt_y) +{ + ur_bsr_t red_u = {0}; + ur_dict32_t* dic_u = &sil_u->dic_u; + u3a_pile pil_u; + _cue_frame_t* fam_u; + ur_cue_res_e res_e; + u3_noun ref; + + // initialize stack control + // + u3a_pile_prep(&pil_u, sizeof(*fam_u)); + + // init bitstream-reader + // + if ( ur_cue_good != (res_e = ur_bsr_init(&red_u, len_d, byt_y)) ) { + return c3n; + } + // bit-cursor (and backreferences) must fit in 62-bit direct atoms + // + else if ( 0x7ffffffffffffffULL < len_d ) { + return c3n; + } + + // advance into stream + // + res_e = _cs_cue_sill_next(&pil_u, &red_u, dic_u, &ref); + + // process cell results + // + if ( (c3n == u3a_pile_done(&pil_u)) + && (ur_cue_good == res_e) ) + { + fam_u = u3a_peek(&pil_u); + + do { + // f is a head-frame; stash result and read the tail from the stream + // + if ( u3_none == fam_u->ref ) { + fam_u->ref = ref; + res_e = _cs_cue_sill_next(&pil_u, &red_u, dic_u, &ref); + fam_u = u3a_peek(&pil_u); + } + // f is a tail-frame; pop the stack and continue + // + else { + ur_root_t* rot_u = 0; + + ref = u3nc(fam_u->ref, ref); + ur_dict32_put(rot_u, dic_u, fam_u->bit_d, ref); + fam_u = u3a_pop(&pil_u); + } + } + while ( (c3n == u3a_pile_done(&pil_u)) + && (ur_cue_good == res_e) ); + } + + if ( ur_cue_good == res_e ) { + return ref; + } + // on failure, unwind the stack and dispose of intermediate nouns + // + else if ( c3n == u3a_pile_done(&pil_u) ) { + do { + if ( u3_none != fam_u->ref ) { + u3z(fam_u->ref); + } + fam_u = u3a_pop(&pil_u); + } + while ( c3n == u3a_pile_done(&pil_u) ); + } + + return u3_none; +} + +/* u3s_cue_sill_init_with(): initialize a cue_sill handle as specified. +*/ +u3_cue_sill* +u3s_cue_sill_init_with(c3_d pre_d, c3_d siz_d) +{ + u3_cue_sill* sil_u; + + c3_assert( &(u3H->rod_u) == u3R ); + + sil_u = c3_calloc(sizeof(*sil_u)); + ur_dict32_grow((ur_root_t*)0, &sil_u->dic_u, pre_d, siz_d); + + return sil_u; +} + +/* u3s_cue_sill_init(): initialize a cue_sill handle. +*/ +u3_cue_sill* +u3s_cue_sill_init(void) +{ + return u3s_cue_sill_init_with(ur_fib10, ur_fib11); +} + +/* u3s_cue_sill_init(): cue on-loom, with off-loom dictionary in handle. +*/ +u3_weak +u3s_cue_sill_with(u3_cue_sill* sil_u, + c3_d len_d, + const c3_y* byt_y) +{ + u3_weak som; + + c3_assert( &(u3H->rod_u) == u3R ); + + som = _cs_cue_sill(sil_u, len_d, byt_y); + ur_dict32_wipe(&sil_u->dic_u); + return som; +} + +/* u3s_cue_sill_init(): dispose cue_sill handle. +*/ +void +u3s_cue_sill_done(u3_cue_sill* sil_u) +{ + ur_dict_free((ur_dict_t*)&sil_u->dic_u); + c3_free(sil_u); +} + +/* u3s_cue_sill(): cue on-loom, with off-loom dictionary. +*/ +u3_weak +u3s_cue_sill(c3_d len_d, + const c3_y* byt_y) +{ + u3_cue_sill* sil_u; + u3_weak som; + + c3_assert( &(u3H->rod_u) == u3R ); + + sil_u = u3s_cue_sill_init(); + som = _cs_cue_sill(sil_u, len_d, byt_y); + u3s_cue_sill_done(sil_u); + return som; +} + /* _cue_stack_t: heap-allocated struct, used to bypass the road stack. */ typedef struct _cue_stack_s { @@ -669,11 +859,11 @@ _cs_cue_xeno_next(_cue_stack_t* tac_u, } case ur_jam_back: { - return _cs_cue_xeno_back(red_u, dic_u, out); + return _cs_cue_sill_back(red_u, dic_u, out); } case ur_jam_atom: { - return _cs_cue_xeno_atom(red_u, dic_u, bit_d, out); + return _cs_cue_sill_atom(red_u, dic_u, bit_d, out); } } } diff --git a/pkg/urbit/tests/jam_tests.c b/pkg/urbit/tests/jam_tests.c index 41e5d767b2..842c0d8930 100644 --- a/pkg/urbit/tests/jam_tests.c +++ b/pkg/urbit/tests/jam_tests.c @@ -407,6 +407,23 @@ _test_cue_spec(const c3_c* cap_c, u3z(pro); } + { + u3_noun out; + + if ( u3_none == (out = u3s_cue_sill(len_w, byt_y)) ) { + fprintf(stderr, "\033[31mcue %s fail 5\033[0m\r\n", cap_c); + ret_i = 0; + } + else if ( c3n == u3r_sing(ref, out) ) { + fprintf(stderr, "\033[31mcue %s fail 6\033[0m\r\n", cap_c); + u3m_p("ref", ref); + u3m_p("out", out); + ret_i = 0; + } + + u3z(out); + } + return ret_i; } From fe0169559421cb91706a2a52ebbe61384fec0b76 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 18 Sep 2020 11:22:36 -0700 Subject: [PATCH 356/933] u3: use u3s_cue_sill_with() in u3u_uncram() --- pkg/urbit/noun/urth.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/pkg/urbit/noun/urth.c b/pkg/urbit/noun/urth.c index 876e2d5dc1..04b84bc445 100644 --- a/pkg/urbit/noun/urth.c +++ b/pkg/urbit/noun/urth.c @@ -860,23 +860,20 @@ u3u_uncram(c3_c* dir_c, c3_d eve_d) // XX errors are fatal, barring a full "u3m_reboot"-type operation. // { - ur_dict32_t dic_u = {0}; - u3_noun roc, cod, ref; - // XX tune the initial dictionary size for less reallocation // - ur_dict32_grow((ur_root_t*)0, &dic_u, ur_fib33, ur_fib34); + u3_cue_sill* sil_u = u3s_cue_sill_init_with(ur_fib33, ur_fib34); + u3_weak ref = u3s_cue_sill_with(sil_u, len_d, byt_y); + u3_noun roc, cod; - if ( c3n == u3s_cue_xeno_unsafe(&dic_u, len_d, byt_y, &ref) ) { + u3s_cue_sill_done(sil_u); + + if ( u3_none == ref ) { fprintf(stderr, "uncram: failed to cue rock\r\n"); - ur_dict_free((ur_dict_t*)&dic_u); c3_free(nam_c); return c3n; } - - ur_dict_free((ur_dict_t*)&dic_u); - - if ( c3n == u3r_pq(ref, c3__fast, &roc, &cod) ) { + else if ( c3n == u3r_pq(ref, c3__fast, &roc, &cod) ) { fprintf(stderr, "uncram: failed: invalid rock format\r\n"); u3z(ref); c3_free(nam_c); From a79a0e943733a57bfd69d7345ba4c1766bd336e8 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 18 Sep 2020 11:23:12 -0700 Subject: [PATCH 357/933] serf: use u3s_cue_sill() for ipc $writ's --- pkg/urbit/worker/main.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/pkg/urbit/worker/main.c b/pkg/urbit/worker/main.c index 536e46342a..fe8bdaf4ce 100644 --- a/pkg/urbit/worker/main.c +++ b/pkg/urbit/worker/main.c @@ -24,10 +24,10 @@ #include "ur/hashcons.h" -static u3_serf u3V; // one serf per process -static u3_moat inn_u; // input stream -static u3_mojo out_u; // output stream -static ur_dict32_t dic_u; // cue dictionary +static u3_serf u3V; // one serf per process +static u3_moat inn_u; // input stream +static u3_mojo out_u; // output stream +static u3_cue_sill* sil_u; // cue handle #undef SERF_TRACE_JAM #undef SERF_TRACE_CUE @@ -107,8 +107,8 @@ _cw_serf_step_trace(void) static void _cw_serf_writ(void* vod_p, c3_d len_d, c3_y* byt_y) { - u3_noun ret, jar; - c3_o ret_o; + u3_weak jar; + u3_noun ret; _cw_serf_step_trace(); @@ -116,16 +116,13 @@ _cw_serf_writ(void* vod_p, c3_d len_d, c3_y* byt_y) u3t_event_trace("serf ipc cue", 'B'); #endif - ret_o = u3s_cue_xeno_unsafe(&dic_u, len_d, byt_y, &jar); - // XX check if the dictionary grew too much and shrink? - // - ur_dict32_wipe(&dic_u); + jar = u3s_cue_sill_with(sil_u, len_d, byt_y); #ifdef SERF_TRACE_CUE u3t_event_trace("serf ipc cue", 'E'); #endif - if ( (c3n == ret_o) + if ( (u3_none == jar) || (c3n == u3_serf_writ(&u3V, jar, &ret)) ) { _cw_serf_fail(0, -1, "bad jar"); @@ -165,7 +162,7 @@ _cw_serf_stdio(c3_i* inn_i, c3_i* out_i) static void _cw_serf_exit(void) { - ur_dict_free((ur_dict_t*)&dic_u); + u3s_cue_sill_done(sil_u); u3t_trace_close(); } @@ -239,7 +236,7 @@ _cw_serf_commence(c3_i argc, c3_c* argv[]) uv_stream_set_blocking((uv_stream_t*)&out_u.pyp_u, 1); } - ur_dict32_grow((ur_root_t*)0, &dic_u, ur_fib10, ur_fib11); + sil_u = u3s_cue_sill_init(); // set up writing // From 830df0d86ead4056c9e4ef320b8d7169c113ead5 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 18 Sep 2020 11:24:02 -0700 Subject: [PATCH 358/933] vere: use u3s_cue_sill for ipc $plea's --- pkg/urbit/include/vere/vere.h | 2 +- pkg/urbit/vere/lord.c | 25 ++++++++++--------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index 516a1319bc..e92a74044b 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -470,7 +470,7 @@ uv_process_t cub_u; // process handle uv_process_options_t ops_u; // process configuration uv_stdio_container_t cod_u[3]; // process options - void* dic_u; // cue dictionary + u3_cue_sill* sil_u; // cue handle time_t wen_t; // process creation time u3_mojo inn_u; // client's stdin u3_moat out_u; // client's stdout diff --git a/pkg/urbit/vere/lord.c b/pkg/urbit/vere/lord.c index 9d5f5c37c4..dd7b3224ed 100644 --- a/pkg/urbit/vere/lord.c +++ b/pkg/urbit/vere/lord.c @@ -74,7 +74,7 @@ _lord_stop_cb(void* ptr_v, void (*exit_f)(void*) = god_u->cb_u.exit_f; void* exit_v = god_u->cb_u.ptr_v; - ur_dict_free((ur_dict_t*)god_u->dic_u); + u3s_cue_sill_done(god_u->sil_u); c3_free(god_u); if ( exit_f ) { @@ -674,27 +674,24 @@ _lord_plea_work(u3_lord* god_u, u3_noun dat) static void _lord_on_plea(void* ptr_v, c3_d len_d, c3_y* byt_y) { - u3_lord* god_u = ptr_v; - ur_dict32_t* dic_u = god_u->dic_u; - u3_noun tag, dat, jar = u3_blip; - c3_o ret_o; + u3_lord* god_u = ptr_v; + u3_noun tag, dat; + u3_weak jar; #ifdef LORD_TRACE_CUE u3t_event_trace("king ipc cue", 'B'); #endif - ret_o = u3s_cue_xeno_unsafe(dic_u, len_d, byt_y, &jar); - // XX check if the dictionary grew too much and shrink? - // - ur_dict32_wipe(dic_u); + jar = u3s_cue_sill_with(god_u->sil_u, len_d, byt_y); #ifdef LORD_TRACE_CUE u3t_event_trace("king ipc cue", 'E'); #endif - if ( (c3n == ret_o) - || (c3n == u3r_cell(jar, &tag, &dat)) ) - { + if ( u3_none == jar ) { + return _lord_plea_foul(god_u, 0, u3_blip); + } + else if ( c3n == u3r_cell(jar, &tag, &dat) ) { return _lord_plea_foul(god_u, 0, jar); } @@ -1172,9 +1169,7 @@ u3_lord_init(c3_c* pax_c, c3_w wag_w, c3_d key_d[4], u3_lord_cb cb_u) #endif { - ur_dict32_t* dic_u = c3_calloc(sizeof(*dic_u)); - ur_dict32_grow((ur_root_t*)0, dic_u, ur_fib10, ur_fib11); - god_u->dic_u = dic_u; + god_u->sil_u = u3s_cue_sill_init(); } // start reading from proc From e4e8c4e9e83c394a1d8df591a6e5eefc6aa41233 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 18 Sep 2020 11:24:20 -0700 Subject: [PATCH 359/933] vere: use u3s_cue_sill() for ivory pill --- pkg/urbit/vere/king.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pkg/urbit/vere/king.c b/pkg/urbit/vere/king.c index 9a7a113d9f..dfa24e174d 100644 --- a/pkg/urbit/vere/king.c +++ b/pkg/urbit/vere/king.c @@ -713,17 +713,15 @@ _king_boot_ivory(void) } { - ur_dict32_t dic_u = {0}; - u3_noun pil; + u3_cue_sill* sil_u = u3s_cue_sill_init_with(ur_fib27, ur_fib28); + u3_weak pil; - ur_dict32_grow((ur_root_t*)0, &dic_u, ur_fib27, ur_fib28); - - if ( c3n == u3s_cue_xeno_unsafe(&dic_u, len_d, byt_y, &pil) ) { + if ( u3_none == (pil = u3s_cue_sill_with(sil_u, len_d, byt_y)) ) { u3l_log("lite: unable to cue ivory pill\r\n"); exit(1); } - ur_dict_free((ur_dict_t*)&dic_u); + u3s_cue_sill_done(sil_u); if ( c3n == u3v_boot_lite(pil)) { u3l_log("lite: boot failed\r\n"); From 77754c974ceeb4080af42cf2e797b6ea00aad387 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 18 Sep 2020 11:35:36 -0700 Subject: [PATCH 360/933] u3: removes unused atom measurement function in urth.c --- pkg/urbit/noun/urth.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/pkg/urbit/noun/urth.c b/pkg/urbit/noun/urth.c index 04b84bc445..2124f20df1 100644 --- a/pkg/urbit/noun/urth.c +++ b/pkg/urbit/noun/urth.c @@ -9,26 +9,6 @@ #include "all.h" #include "ur/ur.h" -/* _cu_met_3(): atom bytewidth a la u3r_met(3, ...) -*/ -static inline c3_w -_cu_met_3(u3a_atom* vat_u) -{ - c3_w len_w = vat_u->len_w; - c3_w* buf_w = vat_u->buf_w; - - if ( !len_w ) { - return 0; - } - else { - c3_w gal_w = len_w - 1; - c3_w daz_w = buf_w[gal_w]; - - return (gal_w << 2) - + ((daz_w >> 24) ? 4 : (daz_w >> 16) ? 3 : (daz_w >> 8) ? 2 : 1); - } -} - /* _cu_atom_to_ref(): allocate indirect atom off-loom. */ static inline ur_nref From 5f8dcecbe332367c09d78ce23810ad355486978a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 18 Sep 2020 12:02:38 -0700 Subject: [PATCH 361/933] u3: removes u3s_cue_xeno() --- pkg/urbit/bench/ur_bench.c | 55 ----------- pkg/urbit/include/noun/serial.h | 13 --- pkg/urbit/noun/serial.c | 162 -------------------------------- pkg/urbit/tests/jam_tests.c | 29 +----- 4 files changed, 4 insertions(+), 255 deletions(-) diff --git a/pkg/urbit/bench/ur_bench.c b/pkg/urbit/bench/ur_bench.c index c97fecfc1c..1d82affa35 100644 --- a/pkg/urbit/bench/ur_bench.c +++ b/pkg/urbit/bench/ur_bench.c @@ -225,61 +225,6 @@ _cue_bench(void) fprintf(stderr, " cue sill with: %u ms\r\n", mil_w); } - { - gettimeofday(&b4, 0); - - { - u3_noun out; - c3_w len_w = u3r_met(3, vat); - // XX assumes little-endian - // - c3_y* byt_y = ( c3y == u3a_is_cat(vat) ) - ? (c3_y*)&vat - : (c3_y*)((u3a_atom*)u3a_to_ptr(vat))->buf_w; - - for ( i_w = 0; i_w < max_w; i_w++ ) { - u3s_cue_xeno(len_w, byt_y, &out); - u3z(out); - } - } - - gettimeofday(&f2, 0); - timersub(&f2, &b4, &d0); - mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); - fprintf(stderr, " cue xeno: %u ms\r\n", mil_w); - } - - { - gettimeofday(&b4, 0); - - { - ur_dict32_t dic_u = {0}; - u3_noun out; - - c3_w len_w = u3r_met(3, vat); - // XX assumes little-endian - // - c3_y* byt_y = ( c3y == u3a_is_cat(vat) ) - ? (c3_y*)&vat - : (c3_y*)((u3a_atom*)u3a_to_ptr(vat))->buf_w; - - ur_dict32_grow((ur_root_t*)0, &dic_u, ur_fib10, ur_fib11); - - for ( i_w = 0; i_w < max_w; i_w++ ) { - u3s_cue_xeno_unsafe(&dic_u, len_w, byt_y, &out); - u3z(out); - ur_dict32_wipe(&dic_u); - } - - ur_dict_free((ur_dict_t*)&dic_u); - } - - gettimeofday(&f2, 0); - timersub(&f2, &b4, &d0); - mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); - fprintf(stderr, " cue xeno unsafe: %u ms\r\n", mil_w); - } - { gettimeofday(&b4, 0); diff --git a/pkg/urbit/include/noun/serial.h b/pkg/urbit/include/noun/serial.h index b721d9c5a8..bededd9e26 100644 --- a/pkg/urbit/include/noun/serial.h +++ b/pkg/urbit/include/noun/serial.h @@ -62,19 +62,6 @@ u3s_cue_sill(c3_d len_d, const c3_y* byt_y); - /* u3s_cue_xeno_unsafe(): cue onto the loom, all bookkeeping off-loom. - */ - c3_o - u3s_cue_xeno_unsafe(struct ur_dict32_s* dic_u, - c3_d len_d, - const c3_y* byt_y, - u3_noun* out); - - /* u3s_cue_xeno(): cue onto the loom, bookkeeping off the loom. - */ - c3_o - u3s_cue_xeno(c3_d len_d, const c3_y* byt_y, u3_noun* out); - /* u3s_cue_bytes(): cue bytes onto the loom. */ u3_noun diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index 8bde730ab2..601488493e 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -809,168 +809,6 @@ u3s_cue_sill(c3_d len_d, return som; } -/* _cue_stack_t: heap-allocated struct, used to bypass the road stack. -*/ -typedef struct _cue_stack_s { - c3_w pre_w; - c3_w siz_w; - c3_w fil_w; - _cue_frame_t* fam_u; -} _cue_stack_t; - -/* _cs_cue_xeno_next(): read next value from bitstream, bookkeeping off-loom. -*/ -static inline ur_cue_res_e -_cs_cue_xeno_next(_cue_stack_t* tac_u, - ur_bsr_t* red_u, - ur_dict32_t* dic_u, - u3_noun* out) -{ - while ( 1 ) { - c3_d bit_d = red_u->bits; - ur_cue_tag_e tag_e; - ur_cue_res_e res_e; - - if ( ur_cue_good != (res_e = ur_bsr_tag(red_u, &tag_e)) ) { - return res_e; - } - - switch ( tag_e ) { - default: c3_assert(0); - - case ur_jam_cell: { - // reallocate the stack if full - // - if ( tac_u->fil_w == tac_u->siz_w ) { - c3_w nex_w = tac_u->pre_w + tac_u->siz_w; - tac_u->fam_u = c3_realloc(tac_u->fam_u, nex_w * sizeof(*tac_u->fam_u)); - tac_u->pre_w = tac_u->siz_w; - tac_u->siz_w = nex_w; - } - - // save a head-frame and read the head from the stream - // - { - _cue_frame_t* fam_u = &(tac_u->fam_u[tac_u->fil_w++]); - fam_u->ref = u3_none; - fam_u->bit_d = bit_d; - } - continue; - } - - case ur_jam_back: { - return _cs_cue_sill_back(red_u, dic_u, out); - } - - case ur_jam_atom: { - return _cs_cue_sill_atom(red_u, dic_u, bit_d, out); - } - } - } -} - -/* u3s_cue_xeno_unsafe(): cue onto the loom, all bookkeeping off-loom. -** -** NB: unsafe wrt to [dic_u], which must be empty. -*/ -c3_o -u3s_cue_xeno_unsafe(ur_dict32_t* dic_u, - c3_d len_d, - const c3_y* byt_y, - u3_noun* out) -{ - ur_bsr_t red_u = {0}; - _cue_stack_t tac_u = {0}; - ur_cue_res_e res_e; - u3_noun ref; - - // init bitstream-reader - // - if ( ur_cue_good != (res_e = ur_bsr_init(&red_u, len_d, byt_y)) ) { - return c3n; - } - // bit-cursor (and backreferences) must fit in 62-bit direct atoms - // - else if ( 0x7ffffffffffffffULL < len_d ) { - return c3n; - } - - // setup stack - // - tac_u.pre_w = ur_fib10; - tac_u.siz_w = ur_fib11; - tac_u.fam_u = c3_malloc(tac_u.siz_w * sizeof(*tac_u.fam_u)); - - // advance into stream - // - res_e = _cs_cue_xeno_next(&tac_u, &red_u, dic_u, &ref); - - // process result - // - while ( tac_u.fil_w && (ur_cue_good == res_e) ) { - // peek at the top of the stack - // - _cue_frame_t* fam_u = &(tac_u.fam_u[tac_u.fil_w - 1]); - - // f is a head-frame; stash result and read the tail from the stream - // - if ( u3_none == fam_u->ref ) { - fam_u->ref = ref; - res_e = _cs_cue_xeno_next(&tac_u, &red_u, dic_u, &ref); - } - // f is a tail-frame; pop the stack and continue - // - else { - ur_root_t* rot_u = 0; - - ref = u3nc(fam_u->ref, ref); - ur_dict32_put(rot_u, dic_u, fam_u->bit_d, ref); - tac_u.fil_w--; - } - } - - if ( ur_cue_good == res_e ) { - *out = ref; - c3_free(tac_u.fam_u); - return c3y; - } - else { - // unwind the stack, disposing intermediate nouns - // - while ( tac_u.fil_w ) { - _cue_frame_t* fam_u = &(tac_u.fam_u[--tac_u.fil_w]); - - if ( u3_none != fam_u->ref ) { - u3z(fam_u->ref); - } - } - - c3_free(tac_u.fam_u); - return c3n; - } -} - -/* u3s_cue_xeno(): cue onto the loom, bookkeeping off the loom. -*/ -c3_o -u3s_cue_xeno(c3_d len_d, const c3_y* byt_y, u3_noun* out) -{ - ur_dict32_t dic_u = {0}; - c3_o ret_o; - - c3_assert( &(u3H->rod_u) == u3R ); - - // XX tune the initial dictionary size for less reallocation - // - ur_dict32_grow((ur_root_t*)0, &dic_u, ur_fib10, ur_fib11); - - ret_o = u3s_cue_xeno_unsafe(&dic_u, len_d, byt_y, out); - - ur_dict_free((ur_dict_t*)&dic_u); - - return ret_o; -} - /* _cs_cue_need(): bail on ur_cue_* read failures. */ static inline void diff --git a/pkg/urbit/tests/jam_tests.c b/pkg/urbit/tests/jam_tests.c index 842c0d8930..8c03df3377 100644 --- a/pkg/urbit/tests/jam_tests.c +++ b/pkg/urbit/tests/jam_tests.c @@ -366,27 +366,6 @@ _test_cue_spec(const c3_c* cap_c, { c3_i ret_i = 1; - { - ur_dict32_t dic_u = {0}; - u3_noun out; - - ur_dict32_grow((ur_root_t*)0, &dic_u, ur_fib10, ur_fib11); - - if ( c3n == u3s_cue_xeno_unsafe(&dic_u, len_w, byt_y, &out) ) { - fprintf(stderr, "\033[31mcue %s fail 1\033[0m\r\n", cap_c); - ret_i = 0; - } - else if ( c3n == u3r_sing(ref, out) ) { - fprintf(stderr, "\033[31mcue %s fail 2\033[0m\r\n", cap_c); - u3m_p("ref", ref); - u3m_p("out", out); - ret_i = 0; - } - - u3z(out); - ur_dict_free((ur_dict_t*)&dic_u); - } - { u3_noun pro = u3m_soft(0, u3s_cue_atom, u3i_bytes(len_w, byt_y)); u3_noun tag, out; @@ -394,11 +373,11 @@ _test_cue_spec(const c3_c* cap_c, u3x_cell(pro, &tag, &out); if ( u3_blip != tag ) { - fprintf(stderr, "\033[31mcue %s fail 3\033[0m\r\n", cap_c); + fprintf(stderr, "\033[31mcue %s fail 1\033[0m\r\n", cap_c); ret_i = 0; } else if ( c3n == u3r_sing(ref, out) ) { - fprintf(stderr, "\033[31mcue %s fail 4\033[0m\r\n", cap_c); + fprintf(stderr, "\033[31mcue %s fail 2\033[0m\r\n", cap_c); u3m_p("ref", ref); u3m_p("out", out); ret_i = 0; @@ -411,11 +390,11 @@ _test_cue_spec(const c3_c* cap_c, u3_noun out; if ( u3_none == (out = u3s_cue_sill(len_w, byt_y)) ) { - fprintf(stderr, "\033[31mcue %s fail 5\033[0m\r\n", cap_c); + fprintf(stderr, "\033[31mcue %s fail 3\033[0m\r\n", cap_c); ret_i = 0; } else if ( c3n == u3r_sing(ref, out) ) { - fprintf(stderr, "\033[31mcue %s fail 6\033[0m\r\n", cap_c); + fprintf(stderr, "\033[31mcue %s fail 4\033[0m\r\n", cap_c); u3m_p("ref", ref); u3m_p("out", out); ret_i = 0; From c3a854363e497d4a77dbf78c64f0c4d2da7811ce Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 18 Sep 2020 12:04:04 -0700 Subject: [PATCH 362/933] u3: renames u3s_cue_sill* to u3s_cue_xeno* --- pkg/urbit/bench/ur_bench.c | 12 +++--- pkg/urbit/include/noun/serial.h | 34 +++++++---------- pkg/urbit/include/vere/vere.h | 2 +- pkg/urbit/noun/serial.c | 65 ++++++++++++++++----------------- pkg/urbit/noun/urth.c | 6 +-- pkg/urbit/tests/jam_tests.c | 2 +- pkg/urbit/vere/king.c | 6 +-- pkg/urbit/vere/lord.c | 6 +-- pkg/urbit/worker/main.c | 8 ++-- 9 files changed, 67 insertions(+), 74 deletions(-) diff --git a/pkg/urbit/bench/ur_bench.c b/pkg/urbit/bench/ur_bench.c index 1d82affa35..706d3ec9a1 100644 --- a/pkg/urbit/bench/ur_bench.c +++ b/pkg/urbit/bench/ur_bench.c @@ -189,21 +189,21 @@ _cue_bench(void) : (c3_y*)((u3a_atom*)u3a_to_ptr(vat))->buf_w; for ( i_w = 0; i_w < max_w; i_w++ ) { - u3z(u3s_cue_sill(len_w, byt_y)); + u3z(u3s_cue_xeno(len_w, byt_y)); } } gettimeofday(&f2, 0); timersub(&f2, &b4, &d0); mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); - fprintf(stderr, " cue sill: %u ms\r\n", mil_w); + fprintf(stderr, " cue xeno: %u ms\r\n", mil_w); } { gettimeofday(&b4, 0); { - u3_cue_sill* sil_u = u3s_cue_sill_init(); + u3_cue_xeno* sil_u = u3s_cue_xeno_init(); c3_w len_w = u3r_met(3, vat); // XX assumes little-endian @@ -213,16 +213,16 @@ _cue_bench(void) : (c3_y*)((u3a_atom*)u3a_to_ptr(vat))->buf_w; for ( i_w = 0; i_w < max_w; i_w++ ) { - u3z(u3s_cue_sill_with(sil_u, len_w, byt_y)); + u3z(u3s_cue_xeno_with(sil_u, len_w, byt_y)); } - u3s_cue_sill_done(sil_u); + u3s_cue_xeno_done(sil_u); } gettimeofday(&f2, 0); timersub(&f2, &b4, &d0); mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000); - fprintf(stderr, " cue sill with: %u ms\r\n", mil_w); + fprintf(stderr, " cue xeno with: %u ms\r\n", mil_w); } { diff --git a/pkg/urbit/include/noun/serial.h b/pkg/urbit/include/noun/serial.h index bededd9e26..a2af308c0a 100644 --- a/pkg/urbit/include/noun/serial.h +++ b/pkg/urbit/include/noun/serial.h @@ -3,15 +3,9 @@ */ /* opaque handles */ - /* u3_cue_sill: handle for cue-ing with an off-loom dictionary. + /* u3_cue_xeno: handle for cue-ing with an off-loom dictionary. */ - typedef struct _u3_cue_sill u3_cue_sill; - - /* forward declarations - */ - /* ur_dict32_s: off-loom 32-bit dictionary. - */ - struct ur_dict32_s; + typedef struct _u3_cue_xeno u3_cue_xeno; /* Noun serialization. All noun arguments RETAINED. */ @@ -34,32 +28,32 @@ u3_noun u3s_cue(u3_atom a); - /* u3s_cue_sill_init_with(): initialize a cue_sill handle as specified. + /* u3s_cue_xeno_init_with(): initialize a cue_xeno handle as specified. */ - u3_cue_sill* - u3s_cue_sill_init_with(c3_d pre_d, c3_d siz_d); + u3_cue_xeno* + u3s_cue_xeno_init_with(c3_d pre_d, c3_d siz_d); - /* u3s_cue_sill_init(): initialize a cue_sill handle. + /* u3s_cue_xeno_init(): initialize a cue_xeno handle. */ - u3_cue_sill* - u3s_cue_sill_init(void); + u3_cue_xeno* + u3s_cue_xeno_init(void); - /* u3s_cue_sill_init(): cue on-loom, with off-loom dictionary in handle. + /* u3s_cue_xeno_init(): cue on-loom, with off-loom dictionary in handle. */ u3_weak - u3s_cue_sill_with(u3_cue_sill* sil_u, + u3s_cue_xeno_with(u3_cue_xeno* sil_u, c3_d len_d, const c3_y* byt_y); - /* u3s_cue_sill_init(): dispose cue_sill handle. + /* u3s_cue_xeno_init(): dispose cue_xeno handle. */ void - u3s_cue_sill_done(u3_cue_sill* sil_u); + u3s_cue_xeno_done(u3_cue_xeno* sil_u); - /* u3s_cue_sill(): cue on-loom, with off-loom dictionary. + /* u3s_cue_xeno(): cue on-loom, with off-loom dictionary. */ u3_weak - u3s_cue_sill(c3_d len_d, + u3s_cue_xeno(c3_d len_d, const c3_y* byt_y); /* u3s_cue_bytes(): cue bytes onto the loom. diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index e92a74044b..e3e3e5d7a1 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -470,7 +470,7 @@ uv_process_t cub_u; // process handle uv_process_options_t ops_u; // process configuration uv_stdio_container_t cod_u[3]; // process options - u3_cue_sill* sil_u; // cue handle + u3_cue_xeno* sil_u; // cue handle time_t wen_t; // process creation time u3_mojo inn_u; // client's stdin u3_moat out_u; // client's stdout diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index 601488493e..a3f6576a93 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -532,10 +532,10 @@ u3s_cue(u3_atom a) return pro; } -/* _cs_cue_sill_back(): cue a backref, off-loom dictionary. +/* _cs_cue_xeno_back(): cue a backref, off-loom dictionary. */ static inline ur_cue_res_e -_cs_cue_sill_back(ur_bsr_t* red_u, +_cs_cue_xeno_back(ur_bsr_t* red_u, ur_dict32_t* dic_u, u3_noun* out) { @@ -562,10 +562,10 @@ _cs_cue_sill_back(ur_bsr_t* red_u, } } -/* _cs_cue_sill_atom(): cue an atom, off-loom dictionary. +/* _cs_cue_xeno_atom(): cue an atom, off-loom dictionary. */ static inline ur_cue_res_e -_cs_cue_sill_atom(ur_bsr_t* red_u, +_cs_cue_xeno_atom(ur_bsr_t* red_u, ur_dict32_t* dic_u, c3_d bit_d, u3_noun* out) @@ -619,11 +619,10 @@ typedef struct _cue_frame_s { c3_d bit_d; } _cue_frame_t; -/* _cs_cue_sill_next(): read next value from bitstream, dictionary off-loom. -** NB: this is _cs_cue_xeno_next, using the road stack. +/* _cs_cue_xeno_next(): read next value from bitstream, dictionary off-loom. */ static inline ur_cue_res_e -_cs_cue_sill_next(u3a_pile* pil_u, +_cs_cue_xeno_next(u3a_pile* pil_u, ur_bsr_t* red_u, ur_dict32_t* dic_u, u3_noun* out) @@ -650,24 +649,24 @@ _cs_cue_sill_next(u3a_pile* pil_u, } case ur_jam_back: { - return _cs_cue_sill_back(red_u, dic_u, out); + return _cs_cue_xeno_back(red_u, dic_u, out); } case ur_jam_atom: { - return _cs_cue_sill_atom(red_u, dic_u, bit_d, out); + return _cs_cue_xeno_atom(red_u, dic_u, bit_d, out); } } } } -struct _u3_cue_sill { +struct _u3_cue_xeno { ur_dict32_t dic_u; }; -/* _cs_cue_sill(): cue on-loom, with off-loom dictionary in handle. +/* _cs_cue_xeno(): cue on-loom, with off-loom dictionary in handle. */ static u3_weak -_cs_cue_sill(u3_cue_sill* sil_u, +_cs_cue_xeno(u3_cue_xeno* sil_u, c3_d len_d, const c3_y* byt_y) { @@ -695,7 +694,7 @@ _cs_cue_sill(u3_cue_sill* sil_u, // advance into stream // - res_e = _cs_cue_sill_next(&pil_u, &red_u, dic_u, &ref); + res_e = _cs_cue_xeno_next(&pil_u, &red_u, dic_u, &ref); // process cell results // @@ -709,7 +708,7 @@ _cs_cue_sill(u3_cue_sill* sil_u, // if ( u3_none == fam_u->ref ) { fam_u->ref = ref; - res_e = _cs_cue_sill_next(&pil_u, &red_u, dic_u, &ref); + res_e = _cs_cue_xeno_next(&pil_u, &red_u, dic_u, &ref); fam_u = u3a_peek(&pil_u); } // f is a tail-frame; pop the stack and continue @@ -744,12 +743,12 @@ _cs_cue_sill(u3_cue_sill* sil_u, return u3_none; } -/* u3s_cue_sill_init_with(): initialize a cue_sill handle as specified. +/* u3s_cue_xeno_init_with(): initialize a cue_xeno handle as specified. */ -u3_cue_sill* -u3s_cue_sill_init_with(c3_d pre_d, c3_d siz_d) +u3_cue_xeno* +u3s_cue_xeno_init_with(c3_d pre_d, c3_d siz_d) { - u3_cue_sill* sil_u; + u3_cue_xeno* sil_u; c3_assert( &(u3H->rod_u) == u3R ); @@ -759,18 +758,18 @@ u3s_cue_sill_init_with(c3_d pre_d, c3_d siz_d) return sil_u; } -/* u3s_cue_sill_init(): initialize a cue_sill handle. +/* u3s_cue_xeno_init(): initialize a cue_xeno handle. */ -u3_cue_sill* -u3s_cue_sill_init(void) +u3_cue_xeno* +u3s_cue_xeno_init(void) { - return u3s_cue_sill_init_with(ur_fib10, ur_fib11); + return u3s_cue_xeno_init_with(ur_fib10, ur_fib11); } -/* u3s_cue_sill_init(): cue on-loom, with off-loom dictionary in handle. +/* u3s_cue_xeno_init(): cue on-loom, with off-loom dictionary in handle. */ u3_weak -u3s_cue_sill_with(u3_cue_sill* sil_u, +u3s_cue_xeno_with(u3_cue_xeno* sil_u, c3_d len_d, const c3_y* byt_y) { @@ -778,34 +777,34 @@ u3s_cue_sill_with(u3_cue_sill* sil_u, c3_assert( &(u3H->rod_u) == u3R ); - som = _cs_cue_sill(sil_u, len_d, byt_y); + som = _cs_cue_xeno(sil_u, len_d, byt_y); ur_dict32_wipe(&sil_u->dic_u); return som; } -/* u3s_cue_sill_init(): dispose cue_sill handle. +/* u3s_cue_xeno_init(): dispose cue_xeno handle. */ void -u3s_cue_sill_done(u3_cue_sill* sil_u) +u3s_cue_xeno_done(u3_cue_xeno* sil_u) { ur_dict_free((ur_dict_t*)&sil_u->dic_u); c3_free(sil_u); } -/* u3s_cue_sill(): cue on-loom, with off-loom dictionary. +/* u3s_cue_xeno(): cue on-loom, with off-loom dictionary. */ u3_weak -u3s_cue_sill(c3_d len_d, +u3s_cue_xeno(c3_d len_d, const c3_y* byt_y) { - u3_cue_sill* sil_u; + u3_cue_xeno* sil_u; u3_weak som; c3_assert( &(u3H->rod_u) == u3R ); - sil_u = u3s_cue_sill_init(); - som = _cs_cue_sill(sil_u, len_d, byt_y); - u3s_cue_sill_done(sil_u); + sil_u = u3s_cue_xeno_init(); + som = _cs_cue_xeno(sil_u, len_d, byt_y); + u3s_cue_xeno_done(sil_u); return som; } diff --git a/pkg/urbit/noun/urth.c b/pkg/urbit/noun/urth.c index 2124f20df1..89b9185ece 100644 --- a/pkg/urbit/noun/urth.c +++ b/pkg/urbit/noun/urth.c @@ -842,11 +842,11 @@ u3u_uncram(c3_c* dir_c, c3_d eve_d) { // XX tune the initial dictionary size for less reallocation // - u3_cue_sill* sil_u = u3s_cue_sill_init_with(ur_fib33, ur_fib34); - u3_weak ref = u3s_cue_sill_with(sil_u, len_d, byt_y); + u3_cue_xeno* sil_u = u3s_cue_xeno_init_with(ur_fib33, ur_fib34); + u3_weak ref = u3s_cue_xeno_with(sil_u, len_d, byt_y); u3_noun roc, cod; - u3s_cue_sill_done(sil_u); + u3s_cue_xeno_done(sil_u); if ( u3_none == ref ) { fprintf(stderr, "uncram: failed to cue rock\r\n"); diff --git a/pkg/urbit/tests/jam_tests.c b/pkg/urbit/tests/jam_tests.c index 8c03df3377..aac870ec38 100644 --- a/pkg/urbit/tests/jam_tests.c +++ b/pkg/urbit/tests/jam_tests.c @@ -389,7 +389,7 @@ _test_cue_spec(const c3_c* cap_c, { u3_noun out; - if ( u3_none == (out = u3s_cue_sill(len_w, byt_y)) ) { + if ( u3_none == (out = u3s_cue_xeno(len_w, byt_y)) ) { fprintf(stderr, "\033[31mcue %s fail 3\033[0m\r\n", cap_c); ret_i = 0; } diff --git a/pkg/urbit/vere/king.c b/pkg/urbit/vere/king.c index dfa24e174d..40f58f910c 100644 --- a/pkg/urbit/vere/king.c +++ b/pkg/urbit/vere/king.c @@ -713,15 +713,15 @@ _king_boot_ivory(void) } { - u3_cue_sill* sil_u = u3s_cue_sill_init_with(ur_fib27, ur_fib28); + u3_cue_xeno* sil_u = u3s_cue_xeno_init_with(ur_fib27, ur_fib28); u3_weak pil; - if ( u3_none == (pil = u3s_cue_sill_with(sil_u, len_d, byt_y)) ) { + if ( u3_none == (pil = u3s_cue_xeno_with(sil_u, len_d, byt_y)) ) { u3l_log("lite: unable to cue ivory pill\r\n"); exit(1); } - u3s_cue_sill_done(sil_u); + u3s_cue_xeno_done(sil_u); if ( c3n == u3v_boot_lite(pil)) { u3l_log("lite: boot failed\r\n"); diff --git a/pkg/urbit/vere/lord.c b/pkg/urbit/vere/lord.c index dd7b3224ed..f148f1c690 100644 --- a/pkg/urbit/vere/lord.c +++ b/pkg/urbit/vere/lord.c @@ -74,7 +74,7 @@ _lord_stop_cb(void* ptr_v, void (*exit_f)(void*) = god_u->cb_u.exit_f; void* exit_v = god_u->cb_u.ptr_v; - u3s_cue_sill_done(god_u->sil_u); + u3s_cue_xeno_done(god_u->sil_u); c3_free(god_u); if ( exit_f ) { @@ -682,7 +682,7 @@ _lord_on_plea(void* ptr_v, c3_d len_d, c3_y* byt_y) u3t_event_trace("king ipc cue", 'B'); #endif - jar = u3s_cue_sill_with(god_u->sil_u, len_d, byt_y); + jar = u3s_cue_xeno_with(god_u->sil_u, len_d, byt_y); #ifdef LORD_TRACE_CUE u3t_event_trace("king ipc cue", 'E'); @@ -1169,7 +1169,7 @@ u3_lord_init(c3_c* pax_c, c3_w wag_w, c3_d key_d[4], u3_lord_cb cb_u) #endif { - god_u->sil_u = u3s_cue_sill_init(); + god_u->sil_u = u3s_cue_xeno_init(); } // start reading from proc diff --git a/pkg/urbit/worker/main.c b/pkg/urbit/worker/main.c index fe8bdaf4ce..8fe291522b 100644 --- a/pkg/urbit/worker/main.c +++ b/pkg/urbit/worker/main.c @@ -27,7 +27,7 @@ static u3_serf u3V; // one serf per process static u3_moat inn_u; // input stream static u3_mojo out_u; // output stream -static u3_cue_sill* sil_u; // cue handle +static u3_cue_xeno* sil_u; // cue handle #undef SERF_TRACE_JAM #undef SERF_TRACE_CUE @@ -116,7 +116,7 @@ _cw_serf_writ(void* vod_p, c3_d len_d, c3_y* byt_y) u3t_event_trace("serf ipc cue", 'B'); #endif - jar = u3s_cue_sill_with(sil_u, len_d, byt_y); + jar = u3s_cue_xeno_with(sil_u, len_d, byt_y); #ifdef SERF_TRACE_CUE u3t_event_trace("serf ipc cue", 'E'); @@ -162,7 +162,7 @@ _cw_serf_stdio(c3_i* inn_i, c3_i* out_i) static void _cw_serf_exit(void) { - u3s_cue_sill_done(sil_u); + u3s_cue_xeno_done(sil_u); u3t_trace_close(); } @@ -236,7 +236,7 @@ _cw_serf_commence(c3_i argc, c3_c* argv[]) uv_stream_set_blocking((uv_stream_t*)&out_u.pyp_u, 1); } - sil_u = u3s_cue_sill_init(); + sil_u = u3s_cue_xeno_init(); // set up writing // From 00df76c2145b04aa5e657a5505aac06a019f5f7d Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 18 Sep 2020 12:24:34 -0700 Subject: [PATCH 363/933] u3: factors atoms/backrefs back into u3s_cue_xeno() --- pkg/urbit/noun/serial.c | 131 ++++++++++++++++------------------------ 1 file changed, 52 insertions(+), 79 deletions(-) diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index a3f6576a93..cff41ab783 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -532,82 +532,6 @@ u3s_cue(u3_atom a) return pro; } -/* _cs_cue_xeno_back(): cue a backref, off-loom dictionary. -*/ -static inline ur_cue_res_e -_cs_cue_xeno_back(ur_bsr_t* red_u, - ur_dict32_t* dic_u, - u3_noun* out) -{ - ur_root_t* rot_u = 0; - ur_cue_res_e res_e; - c3_d len_d; - - if ( ur_cue_good != (res_e = ur_bsr_rub_len(red_u, &len_d)) ) { - return res_e; - } - else if ( 62 < len_d ) { - return ur_cue_meme; - } - else { - c3_d bak_d = ur_bsr64_any(red_u, len_d); - c3_w bak_w; - - if ( !ur_dict32_get(rot_u, dic_u, bak_d, &bak_w) ) { - return ur_cue_back; - } - - *out = u3k((u3_noun)bak_w); - return ur_cue_good; - } -} - -/* _cs_cue_xeno_atom(): cue an atom, off-loom dictionary. -*/ -static inline ur_cue_res_e -_cs_cue_xeno_atom(ur_bsr_t* red_u, - ur_dict32_t* dic_u, - c3_d bit_d, - u3_noun* out) -{ - ur_root_t* rot_u = 0; - ur_cue_res_e res_e; - c3_d len_d; - - if ( ur_cue_good != (res_e = ur_bsr_rub_len(red_u, &len_d)) ) { - return res_e; - } - - if ( 31 >= len_d ) { - *out = (u3_noun)ur_bsr32_any(red_u, len_d); - } - // XX need a ur_bsr_words_any() - // - else { - c3_w* wor_w; - c3_y* byt_y; - - { - c3_d byt_d = (len_d >> 3) + !!ur_mask_3(len_d); - - if ( 0xffffffffULL < byt_d) { - return u3m_bail(c3__meme); - } - - // XX assumes little-endian - // - wor_w = u3a_slaq(3, byt_d); - byt_y = (c3_y*)wor_w; - } - - ur_bsr_bytes_any(red_u, len_d, byt_y); - *out = u3a_malt(wor_w); - } - - ur_dict32_put(rot_u, dic_u, bit_d, *out); - return ur_cue_good; -} - /* ** stack frame for recording head vs tail iteration ** @@ -627,8 +551,10 @@ _cs_cue_xeno_next(u3a_pile* pil_u, ur_dict32_t* dic_u, u3_noun* out) { + ur_root_t* rot_u = 0; + while ( 1 ) { - c3_d bit_d = red_u->bits; + c3_d len_d, bit_d = red_u->bits; ur_cue_tag_e tag_e; ur_cue_res_e res_e; @@ -649,11 +575,58 @@ _cs_cue_xeno_next(u3a_pile* pil_u, } case ur_jam_back: { - return _cs_cue_xeno_back(red_u, dic_u, out); + if ( ur_cue_good != (res_e = ur_bsr_rub_len(red_u, &len_d)) ) { + return res_e; + } + else if ( 62 < len_d ) { + return ur_cue_meme; + } + else { + c3_d bak_d = ur_bsr64_any(red_u, len_d); + c3_w bak_w; + + if ( !ur_dict32_get(rot_u, dic_u, bak_d, &bak_w) ) { + return ur_cue_back; + } + + *out = u3k((u3_noun)bak_w); + return ur_cue_good; + } } case ur_jam_atom: { - return _cs_cue_xeno_atom(red_u, dic_u, bit_d, out); + if ( ur_cue_good != (res_e = ur_bsr_rub_len(red_u, &len_d)) ) { + return res_e; + } + + if ( 31 >= len_d ) { + *out = (u3_noun)ur_bsr32_any(red_u, len_d); + } + // XX need a ur_bsr_words_any() + // + else { + c3_w* wor_w; + c3_y* byt_y; + + { + c3_d byt_d = (len_d >> 3) + !!ur_mask_3(len_d); + + if ( 0xffffffffULL < byt_d) { + return u3m_bail(c3__meme); + } + + // XX assumes little-endian + // + wor_w = u3a_slaq(3, byt_d); + byt_y = (c3_y*)wor_w; + } + + ur_bsr_bytes_any(red_u, len_d, byt_y); + *out = u3a_malt(wor_w); + } + + ur_dict32_put(rot_u, dic_u, bit_d, *out); + return ur_cue_good; } } } From d2047862d82f255d9acb9ede924437cd40e544a6 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 18 Sep 2020 12:25:47 -0700 Subject: [PATCH 364/933] u3: updates u3s_cue_xeno() to return error, not bail on oversized atoms --- pkg/urbit/noun/serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index cff41ab783..7cffa82102 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -612,7 +612,7 @@ _cs_cue_xeno_next(u3a_pile* pil_u, c3_d byt_d = (len_d >> 3) + !!ur_mask_3(len_d); if ( 0xffffffffULL < byt_d) { - return u3m_bail(c3__meme); + return ur_cue_meme; } // XX assumes little-endian From 0917a89d1e8f8d3786bf5617b76434c8cc809d05 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 18 Sep 2020 13:56:25 -0700 Subject: [PATCH 365/933] vere: fix typo in secp reco jet ecdsa-raw-recover had an erroneous jet. This commit fixes the critical error so that the jet returns the right result according to the secp secp256k1 spec, although it still does not match the hoon. The hoon is subtly wrong, and will be addressed in a future commit. --- pkg/urbit/jets/e/secp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/urbit/jets/e/secp.c b/pkg/urbit/jets/e/secp.c index 746d3b2552..61efda4810 100644 --- a/pkg/urbit/jets/e/secp.c +++ b/pkg/urbit/jets/e/secp.c @@ -207,7 +207,7 @@ u3qe_reco(u3_atom has, ret = secp256k1_ecdsa_recover(ctx_u, /* IN: context */ & puk_u, /* OUT: pub key */ & sig_u, /* IN: signature */ - (const c3_y *) & has); /* IN: message has */ + has_y); /* IN: message has */ if (1 != ret) { u3l_log("\rsecp jet: crypto package error\n"); From 9be3318ae98d4d46b1f9ece5fc088d58c61639f5 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 18 Sep 2020 14:47:22 -0700 Subject: [PATCH 366/933] zuse: add refactored secp core (unjetted) The secp core had some flaws: in particular, the logic for signing/recovery did not match libsecbp256k1 w.r.t. the enigmatic "recid" (v) value. The jet hints were also subtly wrong, in that the curve parameters were in a sample (not an arm) and thus not matched by the jet matching scheme. Consequently, the jets would be used (but incorrect) for other curve parameters. Tests were also added to exercise the recovery id cases thoroughly. --- pkg/arvo/sys/zuse.hoon | 274 ++++++++++++++++++ pkg/arvo/tests/sys/zuse/crypto/secp256k1.hoon | 119 ++++++++ 2 files changed, 393 insertions(+) create mode 100644 pkg/arvo/tests/sys/zuse/crypto/secp256k1.hoon diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index 74a2f79902..ce735a1750 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -4180,6 +4180,280 @@ :: :: :::: ++secp:crypto :: (2b9) secp family :: :::: + ++ new-secp !. + :: TODO: as-octs and hmc are outside of jet parent + => :+ hmc=hmac-sha256l:hmac:crypto + as-octs=as-octs:mimes:html + ..is + ~% %secp ..is ~ + |% + += jacobian [x=@ y=@ z=@] :: jacobian point + += point [x=@ y=@] :: curve point + += domain + $: p=@ :: prime modulo + a=@ :: y^2=x^3+ax+b + b=@ :: + g=point :: base point + n=@ :: prime order of g + == + ++ secp + |_ [bytes=@ =domain] + ++ field-p ~(. fo p.domain) + ++ field-n ~(. fo n.domain) + ++ compress-point + |= =point + ^- @ + %+ can 3 + :~ [bytes x.point] + [1 (add 2 (cut 0 [0 1] y.point))] + == + :: + ++ serialize-point + |= =point + ^- @ + %+ can 3 + :~ [bytes y.point] + [bytes x.point] + [1 4] + == + :: + ++ decompress-point + |= compressed=@ + ^- point + =/ x=@ (end 3 bytes compressed) + ?> =(3 (mod p.domain 4)) + =/ fop field-p + =+ [fadd fmul fpow]=[sum.fop pro.fop exp.fop] + =/ y=@ %+ fpow (rsh 0 2 +(p.domain)) + %+ fadd b.domain + %+ fadd (fpow 3 x) + (fmul a.domain x) + =/ s=@ (rsh 3 bytes compressed) + ~| [`@ux`s `@ux`compressed] + ?> |(=(2 s) =(3 s)) + :: check parity + :: + =? y !=((sub s 2) (mod y 2)) + (sub p.domain y) + [x y] + :: + ++ jc :: jacobian math + |% + ++ from + |= a=jacobian + ^- point + =/ fop field-p + =+ [fmul fpow finv]=[pro.fop exp.fop inv.fop] + =/ z (finv z.a) + :- (fmul x.a (fpow 2 z)) + (fmul y.a (fpow 3 z)) + :: + ++ into + |= point + ^- jacobian + [x y 1] + :: + ++ double + |= jacobian + ^- jacobian + ?: =(0 y) [0 0 0] + =/ fop field-p + =+ [fadd fsub fmul fpow]=[sum.fop dif.fop pro.fop exp.fop] + =/ s :(fmul 4 x (fpow 2 y)) + =/ m %+ fadd + (fmul 3 (fpow 2 x)) + (fmul a.domain (fpow 4 z)) + =/ nx %+ fsub + (fpow 2 m) + (fmul 2 s) + =/ ny %+ fsub + (fmul m (fsub s nx)) + (fmul 8 (fpow 4 y)) + =/ nz :(fmul 2 y z) + [nx ny nz] + :: + ++ add + |= [a=jacobian b=jacobian] + ^- jacobian + ?: =(0 y.a) b + ?: =(0 y.b) a + =/ fop field-p + =+ [fadd fsub fmul fpow]=[sum.fop dif.fop pro.fop exp.fop] + =/ u1 :(fmul x.a z.b z.b) + =/ u2 :(fmul x.b z.a z.a) + =/ s1 :(fmul y.a z.b z.b z.b) + =/ s2 :(fmul y.b z.a z.a z.a) + ?: =(u1 u2) + ?. =(s1 s2) + [0 0 1] + (double a) + =/ h (fsub u2 u1) + =/ r (fsub s2 s1) + =/ h2 (fmul h h) + =/ h3 (fmul h2 h) + =/ u1h2 (fmul u1 h2) + =/ nx %+ fsub + (fmul r r) + :(fadd h3 u1h2 u1h2) + =/ ny %+ fsub + (fmul r (fsub u1h2 nx)) + (fmul s1 h3) + =/ nz :(fmul h z.a z.b) + [nx ny nz] + :: + ++ mul + |= [a=jacobian scalar=@] + ^- jacobian + ?: =(0 y.a) + [0 0 1] + ?: =(0 scalar) + [0 0 1] + ?: =(1 scalar) + a + ?: (gte scalar n.domain) + $(scalar (mod scalar n.domain)) + ?: =(0 (mod scalar 2)) + (double $(scalar (rsh 0 1 scalar))) + (add a (double $(scalar (rsh 0 1 scalar)))) + -- + ++ mul-point-scalar + |= [p=point scalar=@] + ^- point + =/ j jc + %- from.j + %+ mul.j + (into.j p) + scalar + :: + ++ in-order + |= i=@ + ?& (gth i 0) + (lth i n.domain) + == + ++ priv-to-pub + |= private-key=@ + ^- point + ?> (in-order private-key) + (mul-point-scalar g.domain private-key) + :: + ++ make-k + |= [hash=@ private-key=@] + ^- @ + ?> (in-order private-key) + :: hash is truncated to bytes + =/ v (fil 3 bytes 1) + =/ k 0 + =. k %+ hmc [bytes k] + %- as-octs + %+ can 3 + :~ [bytes hash] + [bytes private-key] + [1 0] + [bytes v] + == + =. v (hmc bytes^k bytes^v) + =. k %+ hmc [bytes k] + %- as-octs + %+ can 3 + :~ [bytes hash] + [bytes private-key] + [1 1] + [bytes v] + == + =. v (hmc bytes^k bytes^v) + (hmc bytes^k bytes^v) + :: + ++ ecdsa-raw-sign + |= [hash=@ private-key=@] + ^- [r=@ s=@ y=@] + =/ k (make-k hash private-key) + =/ rp (priv-to-pub k) + =* r x.rp + ?< =(0 r) + =/ fon field-n + =+ [fadd fmul finv]=[sum.fon pro.fon inv.fon] + =/ s %+ fmul (finv k) + %+ fadd hash + %+ fmul r + private-key + ?< =(0 s) + [r s y.rp] + :: general recovery omitted, but possible + -- + ++ secp256k1 + ~% %secp256k1 + ~ + |% + ++ t :: in the battery for jet matching + ^- domain + :* 0xffff.ffff.ffff.ffff.ffff.ffff.ffff.ffff. + ffff.ffff.ffff.ffff.ffff.fffe.ffff.fc2f + 0 + 7 + :- 0x79be.667e.f9dc.bbac.55a0.6295.ce87.0b07. + 029b.fcdb.2dce.28d9.59f2.815b.16f8.1798 + 0x483a.da77.26a3.c465.5da4.fbfc.0e11.08a8. + fd17.b448.a685.5419.9c47.d08f.fb10.d4b8 + 0xffff.ffff.ffff.ffff.ffff.ffff.ffff.fffe. + baae.dce6.af48.a03b.bfd2.5e8c.d036.4141 + == + :: + ++ curve ~(. secp 32 t) + ++ make-k + ~/ %make + |= [hash=@uvI private-key=@] + (make-k:curve hash private-key) + ++ priv-to-pub + |= private-key=@ + (priv-to-pub:curve private-key) + :: + ++ ecdsa-raw-sign + ~/ %sign + |= [hash=@uvI private-key=@] + ^- [v=@ r=@ s=@] + =/ c curve + =+ (ecdsa-raw-sign.c hash private-key) + =/ rp=point [r y] + =/ s-high (gte (mul 2 s) n.domain.c) + =? s s-high + (sub n.domain.c s) + =? rp s-high + [x.rp (sub p.domain.c y.rp)] + =/ v (end 0 1 y.rp) + =? v (gte x.rp n.domain.c) + (add v 2) + [v x.rp s] + :: + ++ ecdsa-raw-recover + ~/ %reco + |= [hash=@ sig=[v=@ r=@ s=@]] + ^- point + ?> (lte v.sig 3) + =/ c curve + ?> (in-order.c hash) + ?> (in-order.c r.sig) + ?> (in-order.c s.sig) + =/ x ?: (gte v.sig 2) + (add r.sig n.domain.c) + r.sig + =/ fop field-p.c + =+ [fadd fmul fpow]=[sum.fop pro.fop exp.fop] + =/ ysq (fadd (fpow 3 x) b.domain.c) + =/ beta (fpow (rsh 0 2 +(p.domain.c)) ysq) + =/ y ?: =((end 0 1 v.sig) (end 0 1 beta)) + beta + (sub p.domain.c beta) + ?> =(0 (dif.fop ysq (fmul y y))) + =/ nz (sub n.domain.c hash) + =/ j jc.c + =/ gz (mul.j (into.j g.domain.c) nz) + =/ xy (mul.j (into.j x y) s.sig) + =/ qr (add.j gz xy) + =/ qj (mul.j qr (inv:field-n.c x)) + =/ pub (from.j qj) + ?< =([0 0] pub) + pub + -- + -- ++ secp ~% %secp ..is ~ |% diff --git a/pkg/arvo/tests/sys/zuse/crypto/secp256k1.hoon b/pkg/arvo/tests/sys/zuse/crypto/secp256k1.hoon new file mode 100644 index 0000000000..eb01c04bed --- /dev/null +++ b/pkg/arvo/tests/sys/zuse/crypto/secp256k1.hoon @@ -0,0 +1,119 @@ +:: tests for secp256k1 elliptic curve cryptography +:: +/+ *test +=/ ecc secp256k1:new-secp:crypto +|% +:: from libsecp256k1 src/modules/recovery/tests_impl.h +:: there are more tests there, ports would be welcome +++ test-ecdsa-recovery-end-to-end + =/ util + =/ eny=@ 'ecdsa recovery test "entropy"' + =/ rnd ~(. og eny) + =/ dom t.ecc + |% + ++ random-scalar-order + =* core . + =^ z rnd (rads:rnd (dec n.dom)) + [`@`.+(z) core] + -- + :: generate a random key and message + %+ category "random" + %- zing + =| [i=@ out=(list tang)] + |- ^+ out + ?: =(i 64) out + =^ message util random-scalar-order:util + =^ privkey util random-scalar-order:util + =/ pubkey (priv-to-pub.ecc privkey) + =/ msghash (shax (shax message)) + =/ sig (ecdsa-raw-sign.ecc msghash privkey) + =/ reckey (ecdsa-raw-recover.ecc msghash sig) + %= $ + i .+(i) + out :_ out + %+ expect-eq + !> pubkey + !> reckey + == + :: +++ test-ecdsa-recovery-edge-cases + =< %+ category "edge cases" + (zing ~[t1 t2 t3 t4 t5]) + =/ msg32=@ '...egassem terces yrev a si sihT' + =/ r=@ux 0x67cb.285f.9cd1.94e8. + 40d6.2939.7af5.5696. + 62fd.e446.4999.5963. + 179a.7dd1.7bd2.3532 + =/ s=@ux 0x4b1b.7df3.4ce1.f68e. + 694f.f6f1.1ac7.51dd. + 7dd7.3e38.7ee4.fc86. + 6e1b.e8ec.c7dd.9557 + =/ r %+ turn (gulf 0 3) + |= v=@ + (mule |.((ecdsa-raw-recover.ecc msg32 v r s))) + =/ t1 %+ expect-eq + !> %.n + !> -.&1.r + =/ t3 %+ expect-eq + !> %.n + !> -.&3.r + =/ t4 %+ expect-eq + !> %.n + !> -.&4.r + =/ t2 %+ expect-eq + !> :+ %.y + 0x8687.4a6b.24a7.5462. + 7116.560e.7ae1.5cd6. + 9eb3.3e73.b4d8.c810. + 33b2.7c2f.a9cf.5d1c + 0xe13f.19fa.8dea.0d1a. + e3e8.4c91.146c.3386. + 8f87.730e.31bb.486e. + b370.05d1.40cc.7a55 + !> &2.r + :: (4,4) should recover with all 4 recids + :_ . + ^= t5 + %- expect-eq :_ + !> %+ turn (gulf 0 3) + |= v=@ + (mule |.((ecdsa-raw-recover.ecc msg32 v 4 4))) + !> + :~ :+ %.y + 0x8a3d.70c0.4104.68e4. + 5739.39af.01b9.9ea7. + b206.4910.6d55.acf9. + f558.eba2.8ed5.9a2e + 0x77eb.58dd.36ed.385b. + 3dcf.e7d3.62c8.16f3. + 7d3b.ef3e.4a34.94b8. + 6fcc.8357.5184.9329 + :+ %.y + 0x3e99.0254.a50d.6599. + 26c9.28ef.8b54.181e. + e67e.27ff.bf63.eb69. + 294b.9ab6.d27b.a225 + 0xa898.847e.931e.9b10. + 2c0f.9b0f.9597.07ba. + f9b8.5e93.6425.fc72. + e80c.a868.e535.dfb4 + :+ %.y + 0x7e15.24fa.06ba.fd6e. + b9c0.2f27.9e13.1314. + be93.0570.0fc6.9e80. + d54d.29ab.3606.3f23 + 0x3f86.a967.33e7.723d. + fdde.4e03.382d.8c45. + 3493.fa88.9050.5ba5. + cfc4.0a8b.226b.1b00 + :+ %.y + 0xb337.c9b7.4ca9.9ea9. + 63c6.560d.2558.cdf0. + 9c73.0120.8409.649a. + 8a6d.1fb1.0e1c.b946 + 0x11df.5391.ee11.6de0. + a722.bc0f.be5f.6575. + 3d07.03a9.9925.0581. + f7de.cd5e.f0f4.f809 + == +-- From d4a87735af7f1ffc99fe1834dd1ab9ee165dcafd Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 18 Sep 2020 15:12:58 -0700 Subject: [PATCH 367/933] update solid pill --- bin/solid.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index 693b79266a..794055e16a 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:06808af2c089441d2cb497fc95e3292b6229b3dfa034272d46c7c41f34eb6a3b -size 6268465 +oid sha256:3a528385ae211229e195dd5dc393a18d9a8fbcac41d0b9c8be8c5066c922e99b +size 6279613 From cd7c3039082c660aad7b754c0de08c154febbfb9 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 24 Jul 2020 14:03:08 -0700 Subject: [PATCH 368/933] vere: accept embedded nulls in leer-jet (to-wain:format) Prior to this commit, there was a jet mismatch in to-wain (formerly called lore, and still jetted under that name). 0 bytes in the middle of a cord caused the jet to crash, whereas the hoon simply treated them as the end of cord and truncated the output. The history of this behavior is fraught with controversy. This commit rectifies the current mess with the following rationale: Null bytes are valid ASCII/UTF-8, and \n\n in the input will cause null list items in the output, so nulls are (for the purposes of to-wain) allowed in cords. Trailing nulls cannot be represented because of the nature of atoms, but that is outside the scope of to-wain's concern. Therefore to-wain should simply measure the cord and split on newlines, and do nothing fancy at all with nulls. The old jet is left wired up under %lore, and should be removed when support for the old, unupgraded zuse is no longer necessary. A new jet with matching null handling has been wired up under the name %leer. --- pkg/urbit/include/jets/q.h | 1 + pkg/urbit/include/jets/w.h | 1 + pkg/urbit/jets/e/lore.c | 79 ++++++++++++++++++++++++++++++++------ pkg/urbit/jets/tree.c | 5 +++ 4 files changed, 74 insertions(+), 12 deletions(-) diff --git a/pkg/urbit/include/jets/q.h b/pkg/urbit/include/jets/q.h index 68f9466036..c392e24798 100644 --- a/pkg/urbit/include/jets/q.h +++ b/pkg/urbit/include/jets/q.h @@ -98,6 +98,7 @@ u3_noun u3qe_jam(u3_atom); u3_noun u3qe_mat(u3_atom); u3_noun u3qe_rub(u3_atom, u3_atom); + u3_noun u3qe_leer(u3_atom); u3_noun u3qe_lore(u3_atom); u3_noun u3qe_loss(u3_noun, u3_noun); u3_noun u3qe_lune(u3_atom); diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index 0e579bac8f..fe1fd73b37 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -107,6 +107,7 @@ u3_noun u3we_jam(u3_noun); u3_noun u3we_mat(u3_noun); u3_noun u3we_rub(u3_noun); + u3_noun u3we_leer(u3_noun); u3_noun u3we_lore(u3_noun); u3_noun u3we_loss(u3_noun); u3_noun u3we_lune(u3_noun); diff --git a/pkg/urbit/jets/e/lore.c b/pkg/urbit/jets/e/lore.c index 9d62644d04..64819622e5 100644 --- a/pkg/urbit/jets/e/lore.c +++ b/pkg/urbit/jets/e/lore.c @@ -3,6 +3,30 @@ */ #include "all.h" + static u3_noun + _lore_cut(c3_w pos_w, c3_w len_w, u3_noun src) + { + if ( 0 == len_w ) { + return 0; + } + else { + // as an optimization, we alloc small lines on the stack + // (only small to prevent stack overflow) + c3_t big_t = len_w > 255; + c3_y* buf_y = big_t ? u3a_malloc(len_w) : alloca(len_w); + u3_noun red; + + u3r_bytes(pos_w, len_w, buf_y, src); + red = u3i_bytes(len_w, buf_y); + if ( big_t ) { + u3a_free(buf_y); + } + return red; + } + } + + // Leaving the lore jet in place for backwards compatibility. + // TODO: remove u3[qw]e_lore (also from jet tree) u3_noun u3qe_lore(u3_atom lub) @@ -34,21 +58,14 @@ return u3m_bail(c3__exit); } - { - c3_y* byts_y = 0; - - if ( 0 != meg_w ) { - byts_y = alloca(meg_w); - u3r_bytes(pos_w, meg_w, byts_y, lub); - } - + if ( !_(end_y) && pos_w >= len_w ) { + return u3kb_flop(tez); + } + else { + tez = u3nc(_lore_cut(pos_w, meg_w, lub), tez); if ( _(end_y) ) { - return u3kb_flop(u3nc(u3i_bytes(meg_w, byts_y), tez)); - } - if ( pos_w >= len_w ) { return u3kb_flop(tez); } - tez = u3nc(u3i_bytes(meg_w, byts_y), tez); pos_w += (meg_w + 1); } } @@ -67,3 +84,41 @@ return u3qe_lore(lub); } } + + u3_noun + u3qe_leer(u3_atom txt) + { + c3_w pos_w, i_w = 0, len_w = u3r_met(3, txt); + u3_noun out = u3_nul; + + while ( 1 ) { + // scan till end or newline + for ( pos_w = i_w; i_w < len_w; ++i_w ) { + if ( 10 == u3r_byte(i_w, txt) ) { + break; + } + } + // append to list + out = u3nc(_lore_cut(pos_w, i_w - pos_w, txt), out); + // finish or advance + if ( i_w++ == len_w ) { + break; + } + } + + return u3kb_flop(out); + } + + u3_noun + u3we_leer(u3_noun cor) + { + u3_noun txt; + + if ( (u3_none == (txt = u3r_at(u3x_sam, cor))) || + (c3n == u3ud(txt)) ) + { + return u3m_bail(c3__fail); + } else { + return u3qe_leer(txt); + } + } diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index f92ca5a483..bd916be95a 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -203,6 +203,10 @@ static c3_c* _141_hex_aes_ha[] = { 0 }; +static u3j_harm _141_hex_leer_a[] = {{".2", u3we_leer}, {}}; +static c3_c* _141_hex_leer_ha[] = { + 0 +}; static u3j_harm _141_hex_lore_a[] = {{".2", u3we_lore}, {}}; static c3_c* _141_hex_lore_ha[] = { "19b13cfea49fd14aafbb20b8b888ba454f809c3f50a7cfeebd43f87336fe052d", @@ -386,6 +390,7 @@ static c3_c* _141_hex_ripe_ha[] = { static u3j_core _141_hex_d[] = { { "lore", 63, _141_hex_lore_a, 0, _141_hex_lore_ha }, + { "leer", 63, _141_hex_leer_a, 0, _141_hex_leer_ha }, { "loss", 63, _141_hex_loss_a, 0, _141_hex_loss_ha }, { "lune", 127, _141_hex_lune_a, 0, _141_hex_lune_ha }, From d6c14eea35bd737d87d8213e6a9c54f09e22f152 Mon Sep 17 00:00:00 2001 From: Fang Date: Sat, 19 Sep 2020 00:41:06 +0200 Subject: [PATCH 369/933] term: don't print styles in non-interactive mode --- pkg/urbit/vere/io/term.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/urbit/vere/io/term.c b/pkg/urbit/vere/io/term.c index 53dd794590..c2ce4497c4 100644 --- a/pkg/urbit/vere/io/term.c +++ b/pkg/urbit/vere/io/term.c @@ -1198,7 +1198,8 @@ _term_it_show_stub(u3_utty* uty_u, u3x_trel(tyl, &dec, &bag, &fog); c3_o tyl_o = c3n; - if ( (u3_nul != dec) || (u3_nul != bag) || (u3_nul != fog) ) { + if ( ( c3n == u3_Host.ops_u.tem ) && + ( (u3_nul != dec) || (u3_nul != bag) || (u3_nul != fog) ) ) { tyl_o = c3y; } From 44b7d5de6b19a728f3333e00d3512e53cf55e85e Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 18 Sep 2020 15:58:42 -0700 Subject: [PATCH 370/933] zuse: make it clear where the secp jet should make explicit size checks Well-behaved secp jets can now plausibly exit if they are given inputs of the wrong size/range. Previously this was either not checked or the inputs were silently truncated. --- pkg/arvo/sys/zuse.hoon | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index ce735a1750..f58468cad8 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -4325,6 +4325,10 @@ (into.j p) scalar :: + ++ valid-hash + |= has=@ + (lte (met 3 has) bytes) + :: ++ in-order |= i=@ ?& (gth i 0) @@ -4340,7 +4344,7 @@ |= [hash=@ private-key=@] ^- @ ?> (in-order private-key) - :: hash is truncated to bytes + ?> (valid-hash hash) =/ v (fil 3 bytes 1) =/ k 0 =. k %+ hmc [bytes k] @@ -4366,6 +4370,7 @@ ++ ecdsa-raw-sign |= [hash=@ private-key=@] ^- [r=@ s=@ y=@] + :: make-k and priv-to pub will validate inputs =/ k (make-k hash private-key) =/ rp (priv-to-pub k) =* r x.rp @@ -4401,9 +4406,11 @@ ++ make-k ~/ %make |= [hash=@uvI private-key=@] + :: checks sizes (make-k:curve hash private-key) ++ priv-to-pub |= private-key=@ + :: checks sizes (priv-to-pub:curve private-key) :: ++ ecdsa-raw-sign @@ -4411,6 +4418,7 @@ |= [hash=@uvI private-key=@] ^- [v=@ r=@ s=@] =/ c curve + :: raw-sign checks sizes =+ (ecdsa-raw-sign.c hash private-key) =/ rp=point [r y] =/ s-high (gte (mul 2 s) n.domain.c) @@ -4429,7 +4437,7 @@ ^- point ?> (lte v.sig 3) =/ c curve - ?> (in-order.c hash) + ?> (valid-hash.c hash) ?> (in-order.c r.sig) ?> (in-order.c s.sig) =/ x ?: (gte v.sig 2) From a675bf322a93e3a3bc4efd95d1d9b6d75f8e33dd Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 18 Sep 2020 17:16:10 -0700 Subject: [PATCH 371/933] vere: wire up jets for new secp --- pkg/arvo/sys/zuse.hoon | 8 +++---- pkg/urbit/jets/tree.c | 53 ++++++++++++------------------------------ 2 files changed, 19 insertions(+), 42 deletions(-) diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index f58468cad8..ae82807c5e 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -4182,10 +4182,10 @@ :: :::: ++ new-secp !. :: TODO: as-octs and hmc are outside of jet parent - => :+ hmc=hmac-sha256l:hmac:crypto - as-octs=as-octs:mimes:html - ..is - ~% %secp ..is ~ + => :+ ..is + hmc=hmac-sha256l:hmac:crypto + as-octs=as-octs:mimes:html + ~% %secp +< ~ |% += jacobian [x=@ y=@ z=@] :: jacobian point += point [x=@ y=@] :: curve point diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index f92ca5a483..4a24c40c06 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -311,49 +311,26 @@ static c3_c* _141_hex_argon_ha[] = { 0 }; - static u3j_harm _141_hex_secp_make_a[] = {{".2", u3we_make, c3y}, {}}; - static c3_c* _141_hex_secp_make_ha[] = { - "171cae298e8f73b6b77c72f957d9d7afd495ed1ca7d78fe9d5f869ea2203bada", - 0 - }; - static u3j_harm _141_hex_secp_sign_a[] = {{".2", u3we_sign, c3y}, {}}; - static c3_c* _141_hex_secp_sign_ha[] = { - "aac58cd537481d41fc4d941a7a0ed247552d64af6c9dce71e0d74c39384e2d60", - 0 - }; - static u3j_harm _141_hex_secp_reco_a[] = {{".2", u3we_reco, c3y}, {}}; - static c3_c* _141_hex_secp_reco_ha[] = { - "390d4cd3a04817b6436035a6fa77fe3008008afa164db732c8f4d5c52954fbee", - 0 - }; -static u3j_core _141_hex_secp_secp_helper_d[] = - { { "make-k", 7, _141_hex_secp_make_a, 0, _141_hex_secp_make_ha }, - { "ecdsa-raw-sign", 7, _141_hex_secp_sign_a, 0, _141_hex_secp_sign_ha }, - { "ecdsa-raw-recover", 7, _141_hex_secp_reco_a, 0, _141_hex_secp_reco_ha }, +static c3_c* _141_hex_secp_secp256k1_make_ha[] = { 0 }; +static u3j_harm _141_hex_secp_secp256k1_make_a[] = {{".2", u3we_make, c3y}, {}}; +static c3_c* _141_hex_secp_secp256k1_sign_ha[] = { 0 }; +static u3j_harm _141_hex_secp_secp256k1_sign_a[] = {{".2", u3we_sign, c3y}, {}}; +static c3_c* _141_hex_secp_secp256k1_reco_ha[] = { 0 }; +static u3j_harm _141_hex_secp_secp256k1_reco_a[] = {{".2", u3we_reco, c3y}, {}}; + +static c3_c* _141_hex_secp_secp256k1_ha[] = { 0 }; +static u3j_core _141_hex_secp_secp256k1_d[] = + { { "make", 7, _141_hex_secp_secp256k1_make_a, 0, _141_hex_secp_secp256k1_make_ha }, + { "sign", 7, _141_hex_secp_secp256k1_sign_a, 0, _141_hex_secp_secp256k1_sign_ha }, + { "reco", 7, _141_hex_secp_secp256k1_reco_a, 0, _141_hex_secp_secp256k1_reco_ha }, {} }; -static c3_c* _141_hex_secp_secp_helper_ha[] = { - "24175b141f1efc2e2de00c39a2b70cf3491f2b82371e0e15f63dfb6d2d86eac5", - 0 -}; - -static u3j_core _141_hex_secp_secp_d[] = - { { "helper", 15, 0, _141_hex_secp_secp_helper_d, _141_hex_secp_secp_helper_ha }, - {} - }; -static c3_c* _141_hex_secp_secp_ha[] = { - "42f57966a293fdadbce8b0cc2108039f1f7fafe0b12f1fec52b2d1937a8347d7", - 0 -}; +static c3_c* _141_hex_secp_ha[] = { 0 }; static u3j_core _141_hex_secp_d[] = - { { "secp", 7, 0, _141_hex_secp_secp_d, _141_hex_secp_secp_ha }, + { { "secp256k1", 3, 0, _141_hex_secp_secp256k1_d, _141_hex_secp_secp256k1_ha }, {} }; -static c3_c* _141_hex_secp_ha[] = { - "e153a8c88f04bfed03dc882f560f912eaf3f5e3911f55dbb054519c2e1b4d778", - 0 -}; static u3j_harm _141_hex_blake2b_a[] = {{".2", u3we_blake, c3y}, {}}; static c3_c* _141_hex_blake2b_ha[] = { @@ -396,7 +373,7 @@ static u3j_core _141_hex_d[] = { "argon", 31, 0, _141_hex_argon_d, _141_hex_argon_ha }, { "blake", 31, 0, _141_hex_blake_d, _141_hex_blake_ha }, { "ripemd", 31, 0, _141_hex_ripe_d, _141_hex_ripe_ha }, - { "secp", 31, 0, _141_hex_secp_d, _141_hex_secp_ha }, + { "secp", 6, 0, _141_hex_secp_d, _141_hex_secp_ha }, {} }; static c3_c* _141_hex_ha[] = { From 513c0e92d8a9711ad1b1fcdf547837d8e4597987 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 18 Sep 2020 17:43:15 -0700 Subject: [PATCH 372/933] hoon: ensure lib/bip32 is working with new secp, remove old secp --- pkg/arvo/lib/bip32.hoon | 8 +- pkg/arvo/sys/zuse.hoon | 195 +++------------------------------------- 2 files changed, 16 insertions(+), 187 deletions(-) diff --git a/pkg/arvo/lib/bip32.hoon b/pkg/arvo/lib/bip32.hoon index 1d4722d4e6..36837bed9d 100644 --- a/pkg/arvo/lib/bip32.hoon +++ b/pkg/arvo/lib/bip32.hoon @@ -16,7 +16,7 @@ :: dep: depth in chain :: ind: index at depth :: pif: parent fingerprint (4 bytes) -|_ [prv=@ pub=pont cad=@ dep=@ud ind=@ud pif=@] +|_ [prv=@ pub=point.ecc cad=@ dep=@ud ind=@ud pif=@] :: += keyc [key=@ cai=@] :: prv/pub key + chain code :: @@ -26,7 +26,7 @@ :: ++ ser-p compress-point.ecc :: -++ n ^n:ecc +++ n n:t.ecc :: :: core initialization :: @@ -46,7 +46,7 @@ +>(pub (decompress-point.ecc key), cad cai) :: ++ from-public-point - |= [pon=pont cai=@] + |= [pon=point.ecc cai=@] +>(pub pon, cad cai) :: ++ from-extended @@ -150,7 +150,7 @@ :: rare exception, invalid key, go to the next one ?: (gte left n) $(i +(i)) ::TODO or child key is "point at infinity" %_ +>.$ - pub (jc-add.ecc (point left) pub) + pub (add-points.ecc (point left) pub) cad right dep +(dep) ind i diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index ae82807c5e..0bcf04dd9c 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -4180,7 +4180,7 @@ :: :: :::: ++secp:crypto :: (2b9) secp family :: :::: - ++ new-secp !. + ++ secp !. :: TODO: as-octs and hmc are outside of jet parent => :+ ..is hmc=hmac-sha256l:hmac:crypto @@ -4316,6 +4316,11 @@ (double $(scalar (rsh 0 1 scalar))) (add a (double $(scalar (rsh 0 1 scalar)))) -- + ++ add-points + |= [a=point b=point] + ^- point + =/ j jc + (from.j (add.j (into.j a) (into.j b))) ++ mul-point-scalar |= [p=point scalar=@] ^- point @@ -4402,7 +4407,12 @@ baae.dce6.af48.a03b.bfd2.5e8c.d036.4141 == :: - ++ curve ~(. secp 32 t) + ++ curve ~(. secp 32 t) + ++ serialize-point serialize-point:curve + ++ compress-point compress-point:curve + ++ decompress-point decompress-point:curve + ++ add-points add-points:curve + ++ mul-point-scalar mul-point-scalar:curve ++ make-k ~/ %make |= [hash=@uvI private-key=@] @@ -4462,187 +4472,6 @@ pub -- -- - ++ secp - ~% %secp ..is ~ - |% - += jaco [x=@ y=@ z=@] :: jacobian point - += pont [x=@ y=@] :: curve point - :: - ++ secp256k1 - %+ secp 32 - :* p=0xffff.ffff.ffff.ffff.ffff.ffff.ffff.ffff. :: modulo - ffff.ffff.ffff.ffff.ffff.fffe.ffff.fc2f - a=0 :: y^2=x^3+ax+b - b=7 - ^= g :: "prime" point - :* x=0x79be.667e.f9dc.bbac.55a0.6295.ce87.0b07. - 029b.fcdb.2dce.28d9.59f2.815b.16f8.1798 - y=0x483a.da77.26a3.c465.5da4.fbfc.0e11.08a8. - fd17.b448.a685.5419.9c47.d08f.fb10.d4b8 - == - n=0xffff.ffff.ffff.ffff.ffff.ffff.ffff.fffe. :: prime order of g - baae.dce6.af48.a03b.bfd2.5e8c.d036.4141 - == - :: - ++ secp - ~/ %secp - |= [w=@ p=@ a=@ b=@ g=pont n=@] :: being passed in from above - =/ p ~(. fo p) - =/ n ~(. fo n) - ~% %helper ..$ ~ - |% - ++ compress-point - ~/ %compress-point - |= pont - ^- @ - (can 3 ~[w^x 1^(add 0x2 (cut 0 [0 1] y))]) - :: - ++ serialize-point - ~/ %serialize-point - |= pont - ^- @ - (can 3 ~[w^y w^x 1^0x4]) - :: - ++ decompress-point - ~/ %decompress-point - |= dat=@ - ^- pont - =+ x=(end 3 w a) - =+ y=:(add (pow x 3) (mul a x) b) - =+ s=(rsh 3 32 dat) - :- x - ?: =(0x2 s) y - ?: =(0x3 s) y - ~| [`@ux`s `@ux`dat] - !! - :: - ++ priv-to-pub :: get pub from priv - ~/ %priv-to-pub - |= prv=@ - ^- pont - (jc-mul g prv) - :: - ++ make-k :: deterministic nonce - ~/ %make-k - =, mimes:html - |= [has=@uvI prv=@] - ^- @ - =* hmc hmac-sha256l:hmac - =/ v (fil 3 w 1) - =/ k 0 - =. k (hmc w^k (as-octs (can 3 [w has] [w prv] [1 0x0] [w v] ~))) - =. v (hmc w^k w^v) - =. k (hmc w^k (as-octs (can 3 [w has] [w prv] [1 0x1] [w v] ~))) - =. v (hmc w^k w^v) - (hmc w^k w^v) - :: - ++ ecdsa-raw-sign :: generate signature - ~/ %ecdsa-raw-sign - |= [has=@uvI prv=@] - ^- [v=@ r=@ s=@] - =/ z has - =/ k (make-k has prv) - =+ [r y]=(jc-mul g k) - =/ s (pro.n `@`(inv.n k) `@`(sum.n z (mul r prv))) - =/ big-s (gte (mul 2 s) ^n) - :* v=(mix (end 0 1 y) ?:(big-s 1 0)) - r=r - s=?.(big-s s (sub ^n s)) - == - :: - ++ ecdsa-raw-recover :: get pubkey from sig - ~/ %ecdsa-raw-recover - |= [has=@uvI sig=[v=@ r=@ s=@]] - ^- pont - ?> (lte v.sig 7) - =/ x r.sig - =/ ysq (sum.p b (exp.p 3 x)) :: omits A=0 - =/ bet (exp.p (div +(^p) 4) ysq) - =/ y ?:(=(1 (end 0 1 (mix v.sig bet))) bet (dif.p 0 bet)) - ?> =(0 (dif.p ysq (pro.p y y))) - ?< =(0 (sit.n r.sig)) - ?< =(0 (sit.n s.sig)) - =/ gz (mul:jc [x y 1]:g (dif.n 0 has)) - =/ xy (mul:jc [x y 1] s.sig) - =/ qr (add:jc gz xy) - (from:jc (mul:jc qr (inv.n r.sig))) - :: - ++ jc-mul :: point x scalar - |= [a=pont n=@] - ^- pont - (from:jc (mul:jc (into:jc a) n)) - :: - ++ jc-add :: add points - |= [a=pont b=pont] - ^- pont - (from:jc (add:jc (into:jc a) (into:jc b))) - :: - ++ jc :: jacobian core - |% - ++ add :: addition - |= [a=jaco b=jaco] - ^- jaco - ?: =(0 y.a) b - ?: =(0 y.b) a - =/ u1 :(pro.p x.a z.b z.b) - =/ u2 :(pro.p x.b z.a z.a) - =/ s1 :(pro.p y.a z.b z.b z.b) - =/ s2 :(pro.p y.b z.a z.a z.a) - ?: =(u1 u2) - ?. =(s1 s2) - [0 0 1] - (dub a) - =/ h (dif.p u2 u1) - =/ r (dif.p s2 s1) - =/ h2 (pro.p h h) - =/ h3 (pro.p h2 h) - =/ u1h2 (pro.p u1 h2) - =/ nx (dif.p (pro.p r r) :(sum.p h3 u1h2 u1h2)) - =/ ny (dif.p (pro.p r (dif.p u1h2 nx)) (pro.p s1 h3)) - =/ nz :(pro.p h z.a z.b) - [nx ny nz] - :: - ++ dub :: double - |= a=jaco - ^- jaco - ?: =(0 y.a) - [0 0 0] - =/ ysq (pro.p y.a y.a) - =/ s :(pro.p 4 x.a ysq) - =/ m :(pro.p 3 x.a x.a) :: omits A=0 - =/ nx (dif.p (pro.p m m) (sum.p s s)) - =/ ny (dif.p (pro.p m (dif.p s nx)) :(pro.p 8 ysq ysq)) - =/ nz :(pro.p 2 y.a z.a) - [nx ny nz] - :: - ++ mul :: jaco x scalar - |= [a=jaco n=@] - ^- jaco - ?: =(0 y.a) - [0 0 1] - ?: =(0 n) - [0 0 1] - ?: =(1 n) - a - ?: (gte n ^^n) - $(n (mod n ^^n)) - ?: =(0 (mod n 2)) - (dub $(n (div n 2))) - (add a (dub $(n (div n 2)))) - :: - ++ from :: jaco -> point - |= a=jaco - ^- pont - =/ z (inv.p z.a) - [:(pro.p x.a z z) :(pro.p y.a z z z)] - :: - ++ into :: point -> jaco - |= pont - ^- jaco - [x y z=1] - -- - -- - -- :: ++ blake ~% %blake ..is ~ From 5068a4156c5e9d940a853329a6bf6b9d64a4da9e Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 21 Sep 2020 11:40:29 -0700 Subject: [PATCH 373/933] fix secp test (new-secp staging name is gone) --- pkg/arvo/tests/sys/zuse/crypto/secp256k1.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/arvo/tests/sys/zuse/crypto/secp256k1.hoon b/pkg/arvo/tests/sys/zuse/crypto/secp256k1.hoon index eb01c04bed..ee27c2ef88 100644 --- a/pkg/arvo/tests/sys/zuse/crypto/secp256k1.hoon +++ b/pkg/arvo/tests/sys/zuse/crypto/secp256k1.hoon @@ -1,7 +1,7 @@ :: tests for secp256k1 elliptic curve cryptography :: /+ *test -=/ ecc secp256k1:new-secp:crypto +=/ ecc secp256k1:secp:crypto |% :: from libsecp256k1 src/modules/recovery/tests_impl.h :: there are more tests there, ports would be welcome From 7b4b542301c55f2b4f49679a8f449bd470f9dee3 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 21 Sep 2020 12:17:00 -0700 Subject: [PATCH 374/933] update solid pill --- bin/solid.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index 794055e16a..900a536cfe 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3a528385ae211229e195dd5dc393a18d9a8fbcac41d0b9c8be8c5066c922e99b -size 6279613 +oid sha256:270136cee93188fd0f27ddc74fb6aa827f4026410651d6d13270454e0243ba0d +size 6268618 From 7493f98480d21b3107e66d7caae6f6af7b2fb506 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 22 Sep 2020 11:42:28 -0700 Subject: [PATCH 375/933] ur: adds missing serial.h include --- pkg/urbit/include/ur/serial.h | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/urbit/include/ur/serial.h b/pkg/urbit/include/ur/serial.h index 61e91daf9f..e1cf9e39f4 100644 --- a/pkg/urbit/include/ur/serial.h +++ b/pkg/urbit/include/ur/serial.h @@ -4,6 +4,7 @@ #include #include #include +#include /* ** bit-wise serialization of a noun into a byte-buffer. From 592b61fa86a899ce0d582bf6fe906a9a48e1eacf Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 22 Sep 2020 11:55:57 -0700 Subject: [PATCH 376/933] vere: use cue/test handles for repeated packet parsing --- pkg/urbit/vere/io/ames.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 796c088138..64771cfbb4 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -12,6 +12,7 @@ #include "all.h" #include "vere/vere.h" +#include "ur/serial.h" /* u3_pact: ames packet, coming or going. */ @@ -35,6 +36,8 @@ uv_udp_t wax_u; // uv_handle_t had_u; // }; // + ur_cue_test_t* tes_u; // cue-test handle + u3_cue_xeno* sil_u; // cue handle c3_c* dns_c; // domain XX multiple/fallback c3_d dop_d; // drop count c3_d fal_d; // crash count @@ -365,8 +368,11 @@ _ames_serialize_packet(u3_panc* pac_u, c3_o dop_o) u3_noun lon, bod; { //NOTE we checked for cue safety in _ames_recv_cb - u3_noun old = u3ke_cue(u3i_bytes(pac_u->bod_u.con_w, pac_u->bod_u.con_y)); - u3x_cell(old, &lon, &bod); + // + u3_weak old = u3s_cue_xeno_with(pac_u->sam_u->sil_u, + pac_u->bod_u.con_w, + pac_u->bod_u.con_y); + u3x_cell(u3x_good(old), &lon, &bod); u3k(lon); u3k(bod); u3z(old); } @@ -798,6 +804,7 @@ _ames_recv_cb(uv_udp_t* wax_u, c3_d rec_d[2]; c3_w con_w = nrd_i - 4 - sen_y - rec_y; c3_y* con_y = NULL; + if ( c3y == pas_o ) { u3_noun sen = u3i_bytes(sen_y, bod_y); u3_noun rec = u3i_bytes(rec_y, bod_y + sen_y); @@ -810,9 +817,7 @@ _ames_recv_cb(uv_udp_t* wax_u, // ensure the content is cue-able // - u3_noun pro = u3m_soft(0, u3ke_cue, u3i_bytes(con_w, con_y)); - pas_o = (u3_blip == u3h(pro)) ? c3y : c3n; - u3z(pro); + pas_o = ur_cue_test_with(sam_u->tes_u, con_w, con_y) ? c3y : c3n; } // if we can scry, @@ -1165,6 +1170,9 @@ _ames_exit_cb(uv_handle_t* had_u) u3h_free(sam_u->lax_p); + u3s_cue_xeno_done(sam_u->sil_u); + ur_cue_test_done(sam_u->tes_u); + c3_free(sam_u); } @@ -1225,6 +1233,9 @@ u3_ames_io_init(u3_pier* pir_u) c3_assert( !uv_udp_init(u3L, &sam_u->wax_u) ); sam_u->wax_u.data = sam_u; + sam_u->sil_u = u3s_cue_xeno_init(); + sam_u->tes_u = ur_cue_test_init(); + // Disable networking for fake ships // if ( c3y == sam_u->pir_u->fak_o ) { From bf2aa9d2e61bdc9a72652735c8cbbabb84acca88 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 22 Sep 2020 12:07:41 -0400 Subject: [PATCH 377/933] king: remove dead code in noun conversion. --- .../urbit-noun-core/lib/Urbit/Noun/Convert.hs | 72 ------------------- 1 file changed, 72 deletions(-) diff --git a/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Convert.hs b/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Convert.hs index f72a465dfd..97df9e085c 100644 --- a/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Convert.hs +++ b/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Convert.hs @@ -22,78 +22,6 @@ import qualified Control.Monad.Fail as Fail type ParseStack = [Text] --- IResult --------------------------------------------------------------------- - -data IResult a = IError ParseStack String | ISuccess a - deriving (Eq, Show, Typeable, Functor, Foldable, Traversable) - -instance Applicative IResult where - pure = ISuccess - (<*>) = ap - -instance Fail.MonadFail IResult where - fail err = IError [] err - -instance Monad IResult where - return = pure - fail = Fail.fail - ISuccess a >>= k = k a - IError path err >>= _ = IError path err - -instance MonadPlus IResult where - mzero = fail "mzero" - mplus a@(ISuccess _) _ = a - mplus _ b = b - -instance Alternative IResult where - empty = mzero - (<|>) = mplus - -instance Semigroup (IResult a) where - (<>) = mplus - -instance Monoid (IResult a) where - mempty = fail "mempty" - mappend = (<>) - - --- Result ---------------------------------------------------------------------- - -data Result a = Error String | Success a - deriving (Eq, Show, Typeable, Functor, Foldable, Traversable) - -instance Applicative Result where - pure = Success - (<*>) = ap - -instance Fail.MonadFail Result where - fail err = Error err - -instance Monad Result where - return = pure - fail = Fail.fail - - Success a >>= k = k a - Error err >>= _ = Error err - -instance MonadPlus Result where - mzero = fail "mzero" - mplus a@(Success _) _ = a - mplus _ b = b - -instance Alternative Result where - empty = mzero - (<|>) = mplus - -instance Semigroup (Result a) where - (<>) = mplus - {-# INLINE (<>) #-} - -instance Monoid (Result a) where - mempty = fail "mempty" - mappend = (<>) - - -- "Parser" -------------------------------------------------------------------- type Failure f r = ParseStack -> String -> f r From c4a2088bff2d28c7a8a43eacbcbcaff0def62513 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 24 Sep 2020 17:07:12 +0200 Subject: [PATCH 378/933] vere: add /~/slog http endpoint Acts as a SSE endpoint for streaming slogs emitted by the runtime. Takes care of tank rendering, emitting the lines resulting from printing the tank at whatever the current terminal width is. Adds siginfo logic to http.c, showing how many connections to that endpoint are open. --- pkg/urbit/include/vere/vere.h | 2 + pkg/urbit/vere/io/http.c | 225 ++++++++++++++++++++++++++++++++-- pkg/urbit/vere/pier.c | 6 +- 3 files changed, 222 insertions(+), 11 deletions(-) diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index 516a1319bc..e8f3dcd45e 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -633,6 +633,8 @@ u3_pico* ent_u; u3_pico* ext_u; } pec_u; + void* sop_p; // slog stream data + void (*sog_f)(void*, c3_w, u3_noun); // slog stream callback // XX remove c3_s por_s; // UDP port u3_save* sav_u; // autosave diff --git a/pkg/urbit/vere/io/http.c b/pkg/urbit/vere/io/http.c index bcd356221e..1e7ee68b5e 100644 --- a/pkg/urbit/vere/io/http.c +++ b/pkg/urbit/vere/io/http.c @@ -90,8 +90,7 @@ typedef struct _u3_h2o_serv { */ typedef struct _u3_hfig { u3_form* for_u; // config from %eyre - struct _u3_warc* cli_u; // rev proxy clients - struct _u3_pcon* con_u; // cli_u connections + struct _u3_hreq* seq_u; // open slog requests } u3_hfig; /* u3_httd: general http device @@ -361,6 +360,44 @@ _http_req_unlink(u3_hreq* req_u) } } +/* _http_seq_link(): store slog stream request in state +*/ +static void +_http_seq_link(u3_hcon* hon_u, u3_hreq* req_u) +{ + u3_hfig* fig_u = &hon_u->htp_u->htd_u->fig_u; + req_u->hon_u = hon_u; + req_u->seq_l = hon_u->seq_l++; + req_u->nex_u = fig_u->seq_u; + + if ( 0 != req_u->nex_u ) { + req_u->nex_u->pre_u = req_u; + } + fig_u->seq_u = req_u; +} + +/* _http_seq_unlink(): remove slog stream request from state +*/ +static void +_http_seq_unlink(u3_hreq* req_u) +{ + u3_hfig* fig_u = &req_u->hon_u->htp_u->htd_u->fig_u; + if ( 0 != req_u->pre_u ) { + req_u->pre_u->nex_u = req_u->nex_u; + + if ( 0 != req_u->nex_u ) { + req_u->nex_u->pre_u = req_u->pre_u; + } + } + else { + fig_u->seq_u = req_u->nex_u; + + if ( 0 != req_u->nex_u ) { + req_u->nex_u->pre_u = 0; + } + } +} + /* _http_req_to_duct(): translate srv/con/req to duct */ static u3_noun @@ -395,13 +432,11 @@ typedef struct _u3_hgen { u3_hreq* req_u; // originating request } u3_hgen; -/* _http_req_done(): request finished, deallocation callback +/* _http_req_close(): clean up & deallocate request */ static void -_http_req_done(void* ptr_v) +_http_req_close(u3_hreq* req_u) { - u3_hreq* req_u = (u3_hreq*)ptr_v; - // client canceled request before response // if ( u3_rsat_plan == req_u->sat_e ) { @@ -412,10 +447,28 @@ _http_req_done(void* ptr_v) uv_close((uv_handle_t*)req_u->tim_u, _http_close_cb); req_u->tim_u = 0; } +} +/* _http_req_done(): request finished, deallocation callback +*/ +static void +_http_req_done(void* ptr_v) +{ + u3_hreq* req_u = (u3_hreq*)ptr_v; + _http_req_close(req_u); _http_req_unlink(req_u); } +/* _http_seq_done(): slog stream request finished, deallocation callback +*/ +static void +_http_seq_done(void* ptr_v) +{ + u3_hreq* seq_u = (u3_hreq*)ptr_v; + _http_req_close(seq_u); + _http_seq_unlink(seq_u); +} + /* _http_req_timer_cb(): request timeout callback */ static void @@ -432,7 +485,7 @@ _http_req_timer_cb(uv_timer_t* tim_u) } } -/* _http_req_new(): receive http request. +/* _http_req_new(): receive standard http request. */ static u3_hreq* _http_req_new(u3_hcon* hon_u, h2o_req_t* rec_u) @@ -450,6 +503,24 @@ _http_req_new(u3_hcon* hon_u, h2o_req_t* rec_u) return req_u; } +/* _http_seq_new(): receive slog stream http request. +*/ +static u3_hreq* +_http_seq_new(u3_hcon* hon_u, h2o_req_t* rec_u) +{ + u3_hreq* req_u = h2o_mem_alloc_shared(&rec_u->pool, sizeof(*req_u), + _http_seq_done); + req_u->rec_u = rec_u; + req_u->sat_e = u3_rsat_plan; + req_u->tim_u = 0; + req_u->gen_u = 0; + req_u->pre_u = 0; + + _http_seq_link(hon_u, req_u); + + return req_u; +} + /* _http_req_dispatch(): dispatch http request to %eyre */ static void @@ -728,6 +799,47 @@ typedef struct _h2o_uv_sock { // see private st_h2o_uv_socket_t uv_stream_t* han_u; // client stream handler (u3_hcon) } h2o_uv_sock; +/* _http_seq_accept(): handle incoming http request on slogstream endpoint +*/ +static int +_http_seq_accept(h2o_handler_t* han_u, h2o_req_t* rec_u) +{ + // store the request in state + // + u3_hreq* seq_u; + { + h2o_uv_sock* suv_u = (h2o_uv_sock*)rec_u->conn-> + callbacks->get_socket(rec_u->conn); + u3_hcon* hon_u = (u3_hcon*)suv_u->han_u; + + // sanity check + c3_assert( hon_u->sok_u == &suv_u->sok_u ); + + seq_u = _http_seq_new(hon_u, rec_u); + + seq_u->tim_u = c3_malloc(sizeof(*seq_u->tim_u)); + seq_u->tim_u->data = seq_u; + uv_timer_init(u3L, seq_u->tim_u); + uv_timer_start(seq_u->tim_u, _http_req_timer_cb, 600 * 1000, 0); + } + + // send the initial response + // + { + u3_noun hed = u3nl(u3nc(u3i_string("Content-Type"), + u3i_string("text/event-stream")), + u3nc(u3i_string("Cache-Control"), + u3i_string("no-cache")), + u3nc(u3i_string("Connection"), + u3i_string("keep-alive")), + u3_none); + + _http_start_respond(seq_u, 200, hed, u3_nul, c3n); + } + + return 0; +} + /* _http_rec_accept(); handle incoming http request from h2o. */ static c3_i @@ -1240,6 +1352,12 @@ _http_serv_init_h2o(SSL_CTX* tls_u, c3_o log, c3_o red) h2o_u->han_u->on_req = _http_rec_accept; } + // register slog stream endpoint + // + h2o_pathconf_t* pac_u = h2o_config_register_path(h2o_u->hos_u, "/~/slog", 0); + h2o_handler_t* han_u = h2o_create_handler(pac_u, sizeof(*han_u)); + han_u->on_req = _http_seq_accept; + if ( c3y == log ) { // XX move this to post serv_start and put the port in the name #if 0 @@ -1732,6 +1850,67 @@ _http_ef_http_server(u3_httd* htd_u, u3z(dat); } +/* _http_stream_slog(): emit slog to open connections +*/ +static void +_http_stream_slog(void* vop_p, c3_w pri_w, u3_noun tan) +{ + u3_httd* htd_u = (u3_httd*)vop_p; + u3_hreq* seq_u = htd_u->fig_u.seq_u; + + // only do the work if there are open slog streams + // + if ( 0 != seq_u ) { + u3_weak data = u3_none; + + if ( c3y == u3a_is_atom(tan) ) { + data = u3nt(u3_nul, u3r_met(3, tan), u3k(tan)); + } + else { + u3_weak wol = u3_none; + + // if we have no arvo kernel and can't evaluate nock, + // only send %leaf tanks + // + if ( 0 == u3A->roc ) { + if ( c3__leaf == u3h(tan) ) { + wol = u3nc(u3k(u3t(tan)), u3_nul); + } + } + else { + u3_noun blu = u3_term_get_blew(0); + c3_l col_l = u3h(blu); + wol = u3dc("wash", u3nc(0, col_l), u3k(tan)); + u3z(blu); + } + + if ( u3_none != wol ) { + u3_noun low = wol; + u3_atom txt = u3_nul; + while ( u3_nul != low ) { + u3_atom lin = u3qc_cat(3, u3qc_rap(3, u3k(u3h(low))), c3_s2('\n', '\n')); + txt = u3qc_cat(3, txt, u3qc_cat(3, u3i_string("data:"), lin)); + low = u3t(low); + } + data = u3nt(u3_nul, u3r_met(3, txt), txt); + } + + u3z(wol); + } + + if ( u3_none != data ) { + while ( 0 != seq_u ) { + _http_continue_respond(seq_u, u3k(data), c3n); + seq_u = seq_u->nex_u; + } + } + + u3z(data); + } + + u3z(tan); +} + /* _reck_mole(): parse simple atomic mole. */ static u3_noun @@ -1800,7 +1979,7 @@ _http_io_kick(u3_auto* car_u, u3_noun wir, u3_noun cad) u3_noun p_pud, t_pud, tt_pud, q_pud, r_pud, s_pud; c3_l sev_l, coq_l, seq_l; - + if ( (c3n == u3r_cell(pud, &p_pud, &t_pud)) || (c3n == _reck_lily(c3__uv, u3k(p_pud), &sev_l)) ) { @@ -1857,11 +2036,34 @@ _http_io_exit(u3_auto* car_u) // _http_serv_close(htp_u); // } - // XX close u3_Host.fig_u.cli_u and con_u + { + u3_noun dat = u3nt(u3_nul, 25, u3i_string("data:urbit shutting down\n\n")); + u3_hreq* seq_u = htd_u->fig_u.seq_u; + while ( 0 != seq_u ) { + _http_continue_respond(seq_u, u3k(dat), c3y); + seq_u = seq_u->nex_u; + } + u3z(dat); + } _http_release_ports_file(u3_Host.dir_c); } +/* _http_io_info(): print status info. +*/ +static void +_http_io_info(u3_auto* car_u) +{ + u3_httd* htd_u = (u3_httd*)car_u; + c3_y sec_y = 0; + u3_hreq* seq_u = htd_u->fig_u.seq_u; + while ( 0 != seq_u ) { + sec_y++; + seq_u = seq_u->nex_u; + } + u3l_log(" open slogstreams: %d\n", sec_y); +} + /* u3_http_io_init(): initialize http I/O. */ u3_auto* @@ -1873,8 +2075,13 @@ u3_http_io_init(u3_pier* pir_u) car_u->nam_m = c3__http; car_u->liv_o = c3n; car_u->io.talk_f = _http_io_talk; + car_u->io.info_f = _http_io_info; car_u->io.kick_f = _http_io_kick; car_u->io.exit_f = _http_io_exit; + + pir_u->sop_p = htd_u; + pir_u->sog_f = _http_stream_slog; + // XX retry up to N? // // car_u->ev.bail_f = ...; diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index bc2d2d0d72..cc330e28b4 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -971,10 +971,12 @@ _pier_on_lord_slog(void* ptr_v, c3_w pri_w, u3_noun tan) c3_c* tan_c = u3r_string(tan); u3C.stderr_log_f(tan_c); c3_free(tan_c); - u3z(tan); + + pir_u->sog_f(pir_u->sop_p, pri_w, tan); } else { - u3_pier_tank(0, pri_w, tan); + u3_pier_tank(0, pri_w, u3k(tan)); + pir_u->sog_f(pir_u->sop_p, pri_w, tan); } } From a6af03553294b25d68c3f8051bb67a18cbabcdba Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 24 Sep 2020 23:30:42 +0200 Subject: [PATCH 379/933] vere: add heartbeat to slog endpoint Because ISPs might close connections that have no data going over them. --- pkg/urbit/vere/io/http.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/pkg/urbit/vere/io/http.c b/pkg/urbit/vere/io/http.c index 1e7ee68b5e..b146f3968b 100644 --- a/pkg/urbit/vere/io/http.c +++ b/pkg/urbit/vere/io/http.c @@ -91,6 +91,7 @@ typedef struct _u3_h2o_serv { typedef struct _u3_hfig { u3_form* for_u; // config from %eyre struct _u3_hreq* seq_u; // open slog requests + uv_timer_t* sit_u; // slog stream heartbeat } u3_hfig; /* u3_httd: general http device @@ -107,6 +108,7 @@ static void _http_serv_start_all(u3_httd* htd_u); static void _http_form_free(u3_httd* htd_u); static const c3_i TCP_BACKLOG = 16; +static const c3_w HEARTBEAT_TIMEOUT = 20 * 1000; /* _http_close_cb(): uv_close_cb that just free's handle */ @@ -1911,6 +1913,27 @@ _http_stream_slog(void* vop_p, c3_w pri_w, u3_noun tan) u3z(tan); } +/* _http_seq_heartbeat_cb(): send heartbeat to slog streams and restart timer +*/ +static void +_http_seq_heartbeat_cb(uv_timer_t* tim_u) +{ + u3_httd* htd_u = tim_u->data; + u3_hreq* seq_u = htd_u->fig_u.seq_u; + + if ( 0 != seq_u ) { + u3_noun dat = u3nt(u3_nul, 1, c3_s1('\n')); + while ( 0 != seq_u ) { + _http_continue_respond(seq_u, u3k(dat), c3y); + seq_u = seq_u->nex_u; + } + u3z(dat); + } + + uv_timer_start(htd_u->fig_u.sit_u, _http_seq_heartbeat_cb, + HEARTBEAT_TIMEOUT, 0); +} + /* _reck_mole(): parse simple atomic mole. */ static u3_noun @@ -2082,6 +2105,12 @@ u3_http_io_init(u3_pier* pir_u) pir_u->sop_p = htd_u; pir_u->sog_f = _http_stream_slog; + uv_timer_t* sit_u = c3_malloc(sizeof(*sit_u)); + sit_u->data = htd_u; + uv_timer_init(u3L, sit_u); + uv_timer_start(sit_u, _http_seq_heartbeat_cb, HEARTBEAT_TIMEOUT, 0); + htd_u->fig_u.sit_u = sit_u; + // XX retry up to N? // // car_u->ev.bail_f = ...; From 6659c859f1c938c10a4a452718d3b7b81454e0bf Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 25 Sep 2020 01:43:03 +0200 Subject: [PATCH 380/933] kh: abolish unicode syntax in favor of ascii --- pkg/hs/proto/lib/Untyped/Parser.hs | 128 ++++++++--------- .../lib/Urbit/EventLog/LMDB.hs | 4 +- pkg/hs/urbit-king/lib/Urbit/King/Main.hs | 2 +- pkg/hs/urbit-king/lib/Urbit/Vere/LMDB.hs | 4 +- pkg/hs/urbit-king/lib/Urbit/Vere/NounServ.hs | 6 +- pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs | 8 +- .../urbit-king/lib/Urbit/Vere/Term/Render.hs | 10 +- pkg/hs/urbit-king/test/HoonMapSetTests.hs | 2 +- pkg/hs/urbit-noun-core/lib/Urbit/Noun/Jam.hs | 2 +- pkg/hs/urbit-noun/lib/Urbit/Noun.hs | 2 +- pkg/hs/urbit-noun/lib/Urbit/Noun/Tree.hs | 134 +++++++++--------- 11 files changed, 151 insertions(+), 151 deletions(-) diff --git a/pkg/hs/proto/lib/Untyped/Parser.hs b/pkg/hs/proto/lib/Untyped/Parser.hs index 14eb4db6bc..be32011cdb 100644 --- a/pkg/hs/proto/lib/Untyped/Parser.hs +++ b/pkg/hs/proto/lib/Untyped/Parser.hs @@ -79,61 +79,61 @@ data Mode = Wide | Tall type Parser = StateT Mode (Parsec Void Text) -withLocalState ∷ Monad m => s → StateT s m a → StateT s m a +withLocalState :: Monad m => s -> StateT s m a -> StateT s m a withLocalState val x = do { old <- get; put val; x <* put old } -inWideMode ∷ Parser a → Parser a +inWideMode :: Parser a -> Parser a inWideMode = withLocalState Wide -ace, pal, par ∷ Parser () +ace, pal, par :: Parser () ace = void (char ' ') pal = void (char '(') par = void (char ')') -- Simple Lexers --------------------------------------------------------------- -gap ∷ Parser () +gap :: Parser () gap = choice [ char ' ' >> void (some spaceChar) , newline >> void (many spaceChar) ] -whitespace ∷ Parser () +whitespace :: Parser () whitespace = ace <|> void gap -- Literals -------------------------------------------------------------------- -alpha ∷ Parser Char +alpha :: Parser Char alpha = oneOf (['a'..'z'] ++ ['A'..'Z']) -sym ∷ Parser Sym +sym :: Parser Sym sym = bucSym <|> pack <$> some alpha where bucSym = char '$' *> pure "" -atom ∷ Parser Nat +atom :: Parser Nat atom = do - init ← some digitChar - rest ← many (char '.' *> some digitChar) + init <- some digitChar + rest <- many (char '.' *> some digitChar) guard True -- TODO Validate '.'s pure (Prelude.read $ concat $ init:rest) -nat ∷ Parser Nat +nat :: Parser Nat nat = Prelude.read <$> some digitChar -tape ∷ Parser Text +tape :: Parser Text tape = do between (char '"') (char '"') $ pack <$> many (label "tape char" (anySingleBut '"')) -cord ∷ Parser Text +cord :: Parser Text cord = do between (char '\'') (char '\'') $ pack <$> many (label "cord char" (anySingleBut '\'')) -tag ∷ Parser Text +tag :: Parser Text tag = try (char '%' >> sym) -literal ∷ Parser CST +literal :: Parser CST literal = choice [ Yes <$ string "%.y" , No <$ string "%.n" @@ -156,48 +156,48 @@ literal = choice - accept the `tall` form or: - swich to `Wide` mode and then accept the wide form. -} -parseRune ∷ Parser a → Parser a → Parser a +parseRune :: Parser a -> Parser a -> Parser a parseRune tall wide = get >>= \case - Wide → wide - Tall → tall <|> inWideMode wide + Wide -> wide + Tall -> tall <|> inWideMode wide -rune0 ∷ a → Parser a +rune0 :: a -> Parser a rune0 = pure -rune1 ∷ (a→b) → Parser a → Parser b +rune1 :: (a->b) -> Parser a -> Parser b rune1 node x = parseRune tall wide - where tall = do gap; p←x; pure (node p) - wide = do pal; p←x; par; pure (node p) + where tall = do gap; p<-x; pure (node p) + wide = do pal; p<-x; par; pure (node p) -rune2 ∷ (a→b→c) → Parser a → Parser b → Parser c +rune2 :: (a->b->c) -> Parser a -> Parser b -> Parser c rune2 node x y = parseRune tall wide - where tall = do gap; p←x; gap; q←y; pure (node p q) - wide = do pal; p←x; ace; q←y; par; pure (node p q) + where tall = do gap; p<-x; gap; q<-y; pure (node p q) + wide = do pal; p<-x; ace; q<-y; par; pure (node p q) -rune3 ∷ (a→b→c→d) → Parser a → Parser b → Parser c → Parser d +rune3 :: (a->b->c->d) -> Parser a -> Parser b -> Parser c -> Parser d rune3 node x y z = parseRune tall wide - where tall = do gap; p←x; gap; q←y; gap; r←z; pure (node p q r) - wide = do pal; p←x; ace; q←y; ace; r←z; par; pure (node p q r) + where tall = do gap; p<-x; gap; q<-y; gap; r<-z; pure (node p q r) + wide = do pal; p<-x; ace; q<-y; ace; r<-z; par; pure (node p q r) -rune4 ∷ (a→b→c→d→e) → Parser a → Parser b → Parser c → Parser d → Parser e +rune4 :: (a->b->c->d->e) -> Parser a -> Parser b -> Parser c -> Parser d -> Parser e rune4 node x y z g = parseRune tall wide - where tall = do gap; p←x; gap; q←y; gap; r←z; gap; s←g; pure (node p q r s) - wide = do pal; p←x; ace; q←y; ace; r←z; ace; s←g; pure (node p q r s) + where tall = do gap; p<-x; gap; q<-y; gap; r<-z; gap; s<-g; pure (node p q r s) + wide = do pal; p<-x; ace; q<-y; ace; r<-z; ace; s<-g; pure (node p q r s) -runeN ∷ ([a]→b) → Parser a → Parser b +runeN :: ([a]->b) -> Parser a -> Parser b runeN node elem = node <$> parseRune tall wide where tall = gap >> elems where elems = term <|> elemAnd - elemAnd = do x ← elem; gap; xs ← elems; pure (x:xs) + elemAnd = do x <- elem; gap; xs <- elems; pure (x:xs) term = string "==" *> pure [] wide = pal *> option [] elems <* par where elems = (:) <$> elem <*> many (ace >> elem) -runeNE ∷ (NonEmpty a → b) → Parser a → Parser b +runeNE :: (NonEmpty a -> b) -> Parser a -> Parser b runeNE node elem = node <$> parseRune tall wide where tall = do let elems = term <|> elemAnd - elemAnd = do x ← elem; gap; xs ← elems; pure (x:xs) + elemAnd = do x <- elem; gap; xs <- elems; pure (x:xs) term = string "==" *> pure [] fst <- gap *> elem rst <- gap *> elems @@ -206,36 +206,36 @@ runeNE node elem = node <$> parseRune tall wide -- Irregular Syntax ------------------------------------------------------------ -inc ∷ Parser CST -- +(3) +inc :: Parser CST -- +(3) inc = do string "+(" - h ← cst + h <- cst char ')' pure h -equals ∷ Parser (CST, CST) -- =(3 4) +equals :: Parser (CST, CST) -- =(3 4) equals = do string "=(" - x ← cst + x <- cst ace - y ← cst + y <- cst char ')' pure (x, y) -tuple ∷ ∀a. Parser a → Parser [a] +tuple :: forall a. Parser a -> Parser [a] tuple p = char '[' >> elems where - xs ∷ Parser [a] - xs = do { x ← p; (x:) <$> tail } + xs :: Parser [a] + xs = do { x <- p; (x:) <$> tail } - tail ∷ Parser [a] + tail :: Parser [a] tail = (pure [] <* char ']') <|> (ace >> elems) - elems ∷ Parser [a] + elems :: Parser [a] elems = (pure [] <* char ']') <|> xs -appIrr ∷ Parser CST +appIrr :: Parser CST appIrr = do char '(' x <- cst @@ -244,7 +244,7 @@ appIrr = do char ')' pure (AppIrr x y) -irregular ∷ Parser CST +irregular :: Parser CST irregular = inWideMode $ choice [ Tupl <$> tuple cst @@ -255,14 +255,14 @@ irregular = -- Runes ----------------------------------------------------------------------- -pat ∷ Parser Pat +pat :: Parser Pat pat = choice [ PatTag <$> tag , char '*' $> PatTar ] -cases ∷ Parser [(Pat, CST)] +cases :: Parser [(Pat, CST)] cases = do - mode ← get + mode <- get guard (mode == Tall) end <|> lop where @@ -270,9 +270,9 @@ cases = do end = string "==" $> [] lop = do { p <- pat; gap; b <- cst; gap; ((p,b):) <$> goo } -wutHep ∷ Parser CST +wutHep :: Parser CST wutHep = do - mode ← get + mode <- get guard (mode == Tall) gap ex <- cst @@ -280,15 +280,15 @@ wutHep = do cs <- cases pure (WutHep ex cs) -barCen ∷ Parser CST +barCen :: Parser CST barCen = do - mode ← get + mode <- get guard (mode == Tall) gap cs <- cases pure (BarCen cs) -rune ∷ Parser CST +rune :: Parser CST rune = runeSwitch [ ("|=", rune2 BarTis sym cst) , ("|-", rune4 BarHep sym sym cst cst) , (":-", rune2 ColHep cst cst) @@ -313,13 +313,13 @@ rune = runeSwitch [ ("|=", rune2 BarTis sym cst) , ("~/", rune2 SigFas cst cst) ] -runeSwitch ∷ [(Text, Parser a)] → Parser a -runeSwitch = choice . fmap (\(s, p) → string s *> p) +runeSwitch :: [(Text, Parser a)] -> Parser a +runeSwitch = choice . fmap (\(s, p) -> string s *> p) -- CST Parser ------------------------------------------------------------------ -cst ∷ Parser CST +cst :: Parser CST cst = irregular <|> rune <|> literal @@ -327,19 +327,19 @@ cst = irregular <|> rune <|> literal hoonFile = do option () whitespace - h ← cst + h <- cst option () whitespace eof pure h -parse ∷ Text → Either Text CST +parse :: Text -> Either Text CST parse txt = runParser (evalStateT hoonFile Tall) "stdin" txt & \case - Left e → Left (pack $ errorBundlePretty e) - Right x → pure x + Left e -> Left (pack $ errorBundlePretty e) + Right x -> pure x -parseHoonTest ∷ Text → IO () +parseHoonTest :: Text -> IO () parseHoonTest = parseTest (evalStateT hoonFile Tall) -main ∷ IO () +main :: IO () main = (head <$> getArgs) >>= parseHoonTest diff --git a/pkg/hs/urbit-eventlog-lmdb/lib/Urbit/EventLog/LMDB.hs b/pkg/hs/urbit-eventlog-lmdb/lib/Urbit/EventLog/LMDB.hs index ed53db19c3..0cb44beaa9 100644 --- a/pkg/hs/urbit-eventlog-lmdb/lib/Urbit/EventLog/LMDB.hs +++ b/pkg/hs/urbit-eventlog-lmdb/lib/Urbit/EventLog/LMDB.hs @@ -300,7 +300,7 @@ streamEvents log first = do for_ batch yield streamEvents log (first + word (length batch)) -streamEffectsRows :: ∀e. HasLogFunc e +streamEffectsRows :: forall e. HasLogFunc e => EventLog -> Word64 -> ConduitT () (Word64, ByteString) (RIO e) () streamEffectsRows log = go @@ -352,7 +352,7 @@ readBatch log first = start {-| Read 1000 rows from the database, starting from key `first`. -} -readRowsBatch :: ∀e. HasLogFunc e +readRowsBatch :: forall e. HasLogFunc e => Env -> Dbi -> Word64 -> RIO e (V.Vector (Word64, ByteString)) readRowsBatch env dbi first = readRows where diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs index 66092ffb69..c8b653cc98 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs @@ -835,7 +835,7 @@ runMultipleShips ships = do -------------------------------------------------------------------------------- -connTerm :: ∀e. HasLogFunc e => FilePath -> RIO e () +connTerm :: forall e. HasLogFunc e => FilePath -> RIO e () connTerm = Term.runTerminalClient diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/LMDB.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/LMDB.hs index 691e25e5c0..8e32246dfe 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/LMDB.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/LMDB.hs @@ -169,7 +169,7 @@ streamEvents log first = do for_ batch yield streamEvents log (first + word (length batch)) -streamEffectsRows :: ∀e. HasLogFunc e +streamEffectsRows :: forall e. HasLogFunc e => EventLog -> EventId -> ConduitT () (Word64, ByteString) (RIO e) () streamEffectsRows log = go @@ -221,7 +221,7 @@ readBatch log first = start {- Read 1000 rows from the database, starting from key `first`. -} -readRowsBatch :: ∀e. HasLogFunc e +readRowsBatch :: forall e. HasLogFunc e => Env -> Dbi -> Word64 -> RIO e (V.Vector (Word64, ByteString)) readRowsBatch env dbi first = readRows where diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/NounServ.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/NounServ.hs index bc31c32e96..4f60929ac3 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/NounServ.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/NounServ.hs @@ -44,7 +44,7 @@ data Server i o a = Server -------------------------------------------------------------------------------- -withRIOThread ∷ RIO e a → RIO e (Async a) +withRIOThread :: RIO e a -> RIO e (Async a) withRIOThread act = do env <- ask io $ async $ runRIO env $ act @@ -87,7 +87,7 @@ wsConn pre inp out wsc = do -------------------------------------------------------------------------------- -wsClient :: ∀i o e. (ToNoun o, FromNoun i, Show o, Show i, HasLogFunc e) +wsClient :: forall i o e. (ToNoun o, FromNoun i, Show o, Show i, HasLogFunc e) => Text -> W.Port -> RIO e (Client i o) wsClient pax por = do env <- ask @@ -118,7 +118,7 @@ wsServApp cb pen = do atomically $ cb (mkConn inp out) wsConn "NOUNSERV (wsServ) " inp out wsc -wsServer :: ∀i o e. (ToNoun o, FromNoun i, Show i, Show o, HasLogFunc e) +wsServer :: forall i o e. (ToNoun o, FromNoun i, Show i, Show o, HasLogFunc e) => RIO e (Server i o W.Port) wsServer = do con <- io $ newTBMChanIO 5 diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs index e4b5bf0cd4..be919c721f 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs @@ -104,7 +104,7 @@ connClient c = Client , take = Serv.cRecv c } -connectToRemote :: ∀e. HasLogFunc e +connectToRemote :: forall e. HasLogFunc e => Port -> Client -> RAcquire e (Async (), Async ()) @@ -130,7 +130,7 @@ data HackConfigDir = HCD { _hcdPax :: FilePath } makeLenses ''HackConfigDir instance HasPierPath HackConfigDir where pierPathL = hcdPax -runTerminalClient :: ∀e. HasLogFunc e => FilePath -> RIO e () +runTerminalClient :: forall e. HasLogFunc e => FilePath -> RIO e () runTerminalClient pier = runRAcquire $ do mPort <- runRIO (HCD pier) readPortsFile port <- maybe (error "Can't connect") pure mPort @@ -173,7 +173,7 @@ _spin_idle_us = 500000 {-| Initializes the generalized input/output parts of the terminal. -} -localClient :: ∀e. HasLogFunc e +localClient :: forall e. HasLogFunc e => STM () -> RAcquire e (TermSize, Client) localClient doneSignal = fst <$> mkRAcquire start stop @@ -415,7 +415,7 @@ localClient doneSignal = fst <$> mkRAcquire start stop -- Moves the cursor left without any mutation of the LineState. Used only -- in cursor spinning. - _termSpinnerMoveLeft :: Int → RIO e () + _termSpinnerMoveLeft :: Int -> RIO e () _termSpinnerMoveLeft = T.cursorLeft -- Displays and sets the current line diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Term/Render.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Term/Render.hs index a7751a005f..3765f9cb25 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Term/Render.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Term/Render.hs @@ -16,17 +16,17 @@ import qualified System.Console.ANSI as ANSI -- Types ----------------------------------------------------------------------- -clearScreen ∷ MonadIO m ⇒ m () +clearScreen :: MonadIO m => m () clearScreen = liftIO $ ANSI.clearScreen -clearLine ∷ MonadIO m ⇒ m () +clearLine :: MonadIO m => m () clearLine = liftIO $ ANSI.clearLine -soundBell ∷ MonadIO m ⇒ m () +soundBell :: MonadIO m => m () soundBell = liftIO $ putStr "\a" -cursorLeft ∷ MonadIO m ⇒ Int → m () +cursorLeft :: MonadIO m => Int -> m () cursorLeft = liftIO . ANSI.cursorBackward -cursorRight ∷ MonadIO m ⇒ Int → m () +cursorRight :: MonadIO m => Int -> m () cursorRight = liftIO . ANSI.cursorForward diff --git a/pkg/hs/urbit-king/test/HoonMapSetTests.hs b/pkg/hs/urbit-king/test/HoonMapSetTests.hs index f5b797a9a2..9cb8deaf9e 100644 --- a/pkg/hs/urbit-king/test/HoonMapSetTests.hs +++ b/pkg/hs/urbit-king/test/HoonMapSetTests.hs @@ -38,7 +38,7 @@ type TreeTests = [TreeTest] -- Utils ----------------------------------------------------------------------- -roundTrip :: ∀a. Eq a => (a -> a) -> a -> Bool +roundTrip :: forall a. Eq a => (a -> a) -> a -> Bool roundTrip f x = f x == x diff --git a/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Jam.hs b/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Jam.hs index 3b5d02f44f..e9f2a64c26 100644 --- a/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Jam.hs +++ b/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Jam.hs @@ -1,7 +1,7 @@ {-# OPTIONS_GHC -O2 #-} {-| - Fast implementation of Jam (Noun → Atom). + Fast implementation of Jam (Noun -> Atom). This is based on the implementation of `flat`. -} diff --git a/pkg/hs/urbit-noun/lib/Urbit/Noun.hs b/pkg/hs/urbit-noun/lib/Urbit/Noun.hs index 7e443992a3..ac62f5c3fc 100644 --- a/pkg/hs/urbit-noun/lib/Urbit/Noun.hs +++ b/pkg/hs/urbit-noun/lib/Urbit/Noun.hs @@ -49,7 +49,7 @@ data LoadErr instance Exception LoadErr -loadFile :: ∀a. FromNoun a => FilePath -> IO (Either LoadErr a) +loadFile :: forall a. FromNoun a => FilePath -> IO (Either LoadErr a) loadFile pax = try $ do byt <- try (readFile pax) >>= either (throwIO . FileErr) pure non <- cueBS byt & either (throwIO . CueErr) pure diff --git a/pkg/hs/urbit-noun/lib/Urbit/Noun/Tree.hs b/pkg/hs/urbit-noun/lib/Urbit/Noun/Tree.hs index 61751cca57..876148e3d1 100644 --- a/pkg/hs/urbit-noun/lib/Urbit/Noun/Tree.hs +++ b/pkg/hs/urbit-noun/lib/Urbit/Noun/Tree.hs @@ -27,14 +27,14 @@ import GHC.Natural (Natural) -- Types ----------------------------------------------------------------------- data NounVal a = NounVal - { non ∷ Noun - , val ∷ !a + { non :: Noun + , val :: !a } data HoonTreeNode a = NTN - { n ∷ NounVal a - , l ∷ HoonTree a - , r ∷ HoonTree a + { n :: NounVal a + , l :: HoonTree a + , r :: HoonTree a } deriving (Eq, Ord, Show) @@ -43,10 +43,10 @@ data HoonTree a = E | Node (HoonTreeNode a) pattern N n l r = Node (NTN n l r) -newtype HoonSet a = HoonSet { unHoonSet ∷ HoonTree a } +newtype HoonSet a = HoonSet { unHoonSet :: HoonTree a } deriving newtype (Eq, Ord, Show, FromNoun, ToNoun) -newtype HoonMap k v = HoonMap { unHoonMap ∷ HoonTree (k, v) } +newtype HoonMap k v = HoonMap { unHoonMap :: HoonTree (k, v) } deriving newtype (Eq, Ord, Show, FromNoun, ToNoun) @@ -61,17 +61,17 @@ instance Ord (NounVal a) where instance ToNoun (NounVal a) where toNoun = non -instance Show a ⇒ Show (NounVal a) where +instance Show a => Show (NounVal a) where show = show . val -instance FromNoun a ⇒ FromNoun (NounVal a) where +instance FromNoun a => FromNoun (NounVal a) where parseNoun x = NounVal x <$> parseNoun x -instance ToNoun a ⇒ ToNoun (HoonTree a) where +instance ToNoun a => ToNoun (HoonTree a) where toNoun E = A 0 toNoun (Node n) = toNoun n -instance FromNoun a ⇒ FromNoun (HoonTree a) where +instance FromNoun a => FromNoun (HoonTree a) where parseNoun (A 0) = pure E parseNoun n = Node <$> parseNoun n @@ -82,60 +82,60 @@ deriveNoun ''HoonTreeNode type Nat = Natural -slowMug ∷ Noun → Nat +slowMug :: Noun -> Nat slowMug = trim 0xcafe_babe . \case - A a → a - C h t → mix (slowMug h) $ mix 0x7fff_ffff (slowMug t) + A a -> a + C h t -> mix (slowMug h) $ mix 0x7fff_ffff (slowMug t) where - trim ∷ Nat → Nat → Nat + trim :: Nat -> Nat -> Nat trim syd key = if 0/=ham then ham else trim (succ syd) key where haz = muk syd (met 3 key) key ham = mix (rsh 0 31 haz) (end 0 31 haz) -mix ∷ Nat → Nat → Nat +mix :: Nat -> Nat -> Nat mix = xor -- Murmur3 -muk ∷ Nat → Nat → Nat → Nat +muk :: Nat -> Nat -> Nat -> Nat muk seed len = fromIntegral . murmur3 (word32 seed) . resize . atomBytes where - resize ∷ ByteString → ByteString + resize :: ByteString -> ByteString resize buf = case compare (length buf) (int len) of - EQ → buf - LT → error "bad-muk" - GT → error "bad-muk" --- LT → buf <> replicate (len - length buf) 0 --- GT → take len buf + EQ -> buf + LT -> error "bad-muk" + GT -> error "bad-muk" +-- LT -> buf <> replicate (len - length buf) 0 +-- GT -> take len buf -int ∷ Integral i ⇒ i → Int +int :: Integral i => i -> Int int = fromIntegral -word32 ∷ Integral i ⇒ i → Word32 +word32 :: Integral i => i -> Word32 word32 = fromIntegral -bex ∷ Nat → Nat +bex :: Nat -> Nat bex = (2^) -end ∷ Nat → Nat → Nat → Nat +end :: Nat -> Nat -> Nat -> Nat end blockSize blocks n = n `mod` (bex (bex blockSize * blocks)) -rsh ∷ Nat → Nat → Nat → Nat +rsh :: Nat -> Nat -> Nat -> Nat rsh blockSize blocks n = shiftR n $ fromIntegral $ (bex blockSize * blocks) -met ∷ Nat → Nat → Nat +met :: Nat -> Nat -> Nat met bloq = go 0 where go c 0 = c go c n = go (succ c) (rsh bloq 1 n) -- XX TODO -mug ∷ Noun → Nat +mug :: Noun -> Nat mug = slowMug @@ -144,7 +144,7 @@ mug = slowMug {- Orders in ascending double mug hash order, collisions fall back to dor. -} -mor ∷ Noun → Noun → Bool +mor :: Noun -> Noun -> Bool mor a b = if c == d then dor a b else c < d where c = mug $ A $ mug a @@ -153,7 +153,7 @@ mor a b = if c == d then dor a b else c < d {- Orders in ascending tree depth. -} -dor ∷ Noun → Noun → Bool +dor :: Noun -> Noun -> Bool dor a b | a == b = True dor (A a) (C _ _) = True dor (C x y) (A b) = False @@ -166,80 +166,80 @@ dor (C x y) (C p q) = dor x p Collisions fall back to dor. -} -gor ∷ Noun → Noun → Bool +gor :: Noun -> Noun -> Bool gor a b = if c==d then dor a b else c NounVal a -> Bool morVal = on mor non gorVal = on gor non -------------------------------------------------------------------------------- -nounVal ∷ ToNoun a ⇒ Iso' a (NounVal a) +nounVal :: ToNoun a => Iso' a (NounVal a) nounVal = iso to val where to x = NounVal (toNoun x) x -treeToList ∷ ∀a. HoonTree a → [a] +treeToList :: forall a. HoonTree a -> [a] treeToList = go [] where - go ∷ [a] → HoonTree a → [a] + go :: [a] -> HoonTree a -> [a] go acc = \case - E → acc - Node (NTN v l r) → go (go (val v : acc) l) r + E -> acc + Node (NTN v l r) -> go (go (val v : acc) l) r -setFromHoonSet ∷ Ord a ⇒ HoonSet a → Set a +setFromHoonSet :: Ord a => HoonSet a -> Set a setFromHoonSet = setFromList . treeToList . unHoonSet -mapFromHoonMap ∷ Ord k ⇒ HoonMap k v → Map k v +mapFromHoonMap :: Ord k => HoonMap k v -> Map k v mapFromHoonMap = mapFromList . treeToList . unHoonMap -setToHoonSet ∷ ∀a. (Ord a, ToNoun a) ⇒ Set a → HoonSet a +setToHoonSet :: forall a. (Ord a, ToNoun a) => Set a -> HoonSet a setToHoonSet = HoonSet . foldr put E . fmap (view nounVal) . setToList where put x = \case - E → N x E E - Node a | x == n a → Node a - Node a | gorVal x (n a) → lef x a - Node a → rit x a + E -> N x E E + Node a | x == n a -> Node a + Node a | gorVal x (n a) -> lef x a + Node a -> rit x a rit x a = put x (r a) & \case - E → error "bad-put-set" - Node c | morVal (n a) (n c) → N (n a) (l a) (Node c) - Node c → N (n c) (N (n a) (l a) (l c)) (r c) + E -> error "bad-put-set" + Node c | morVal (n a) (n c) -> N (n a) (l a) (Node c) + Node c -> N (n c) (N (n a) (l a) (l c)) (r c) lef x a = put x (l a) & \case - E → error "bad-put-set" - Node c | morVal (n a) (n c) → N (n a) (Node c) (r a) - Node c → N (n c) (l c) (N (n a) (r c) (r a)) + E -> error "bad-put-set" + Node c | morVal (n a) (n c) -> N (n a) (Node c) (r a) + Node c -> N (n c) (l c) (N (n a) (r c) (r a)) -p ∷ (ToNoun a, ToNoun b) ⇒ NounVal (a,b) → NounVal a +p :: (ToNoun a, ToNoun b) => NounVal (a,b) -> NounVal a p = view (from nounVal . to fst . nounVal) -pq ∷ (ToNoun a, ToNoun b) ⇒ NounVal (a,b) → (NounVal a, NounVal b) +pq :: (ToNoun a, ToNoun b) => NounVal (a,b) -> (NounVal a, NounVal b) pq = boof . view (from nounVal) where boof (x, y) = (x ^. nounVal, y ^. nounVal) -mapToHoonMap ∷ ∀k v. (ToNoun k, ToNoun v, Ord k, Ord v) ⇒ Map k v → HoonMap k v +mapToHoonMap :: forall k v. (ToNoun k, ToNoun v, Ord k, Ord v) => Map k v -> HoonMap k v mapToHoonMap = HoonMap . foldr put E . fmap (view nounVal) . mapToList where - put ∷ NounVal (k, v) → HoonTree (k, v) → HoonTree (k, v) + put :: NounVal (k, v) -> HoonTree (k, v) -> HoonTree (k, v) put kv@(pq -> (b, c)) = \case - E → N kv E E - Node a | kv == n a → Node a - Node a | b == p (n a) → N kv (l a) (r a) - Node a | gorVal b (p $ n a) → lef kv a - Node a → rit kv a + E -> N kv E E + Node a | kv == n a -> Node a + Node a | b == p (n a) -> N kv (l a) (r a) + Node a | gorVal b (p $ n a) -> lef kv a + Node a -> rit kv a lef kv@(pq -> (b, c)) a = put kv (l a) & \case - E → error "bad-put-map" - Node d | morVal (p $ n a) (p $ n d) → N (n a) (Node d) (r a) - Node d → N (n d) (l d) (N (n a) (r d) (r a)) + E -> error "bad-put-map" + Node d | morVal (p $ n a) (p $ n d) -> N (n a) (Node d) (r a) + Node d -> N (n d) (l d) (N (n a) (r d) (r a)) rit kv@(pq -> (b, c)) a = put kv (r a) & \case - E → error "bad-put-map" - Node d | morVal (p $ n a) (p $ n d) → N (n a) (l a) (Node d) - Node d → N (n d) (N (n a) (l a) (l d)) (r d) + E -> error "bad-put-map" + Node d | morVal (p $ n a) (p $ n d) -> N (n a) (l a) (Node d) + Node d -> N (n d) (N (n a) (l a) (l d)) (r d) From a5c51aed0b7f50f81d0a5b012d33dced4e0aac8b Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 24 Sep 2020 19:59:53 -0700 Subject: [PATCH 381/933] vere: adds jets for en/decoding base16 --- pkg/urbit/include/jets/q.h | 3 + pkg/urbit/include/jets/w.h | 3 + pkg/urbit/include/noun/retrieve.h | 8 ++ pkg/urbit/include/noun/xtract.h | 5 ++ pkg/urbit/jets/e/base.c | 128 ++++++++++++++++++++++++++++++ pkg/urbit/jets/tree.c | 28 +++++++ pkg/urbit/noun/retrieve.c | 33 ++++++++ 7 files changed, 208 insertions(+) create mode 100644 pkg/urbit/jets/e/base.c diff --git a/pkg/urbit/include/jets/q.h b/pkg/urbit/include/jets/q.h index 68f9466036..3c59427ca6 100644 --- a/pkg/urbit/include/jets/q.h +++ b/pkg/urbit/include/jets/q.h @@ -152,6 +152,9 @@ u3_noun u3qe_reco(u3_atom has, u3_atom sig_v, u3_atom sig_r, u3_atom sig_s); u3_noun u3qe_sign(u3_atom has, u3_atom prv); + u3_noun u3qe_en_base16(u3_noun cot); + u3_noun u3qe_de_base16(u3_atom inp); + u3_noun u3qeo_raw(u3_atom, u3_atom); u3_noun u3qef_drg(u3_noun, u3_atom); diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index 0e579bac8f..39957288af 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -181,6 +181,9 @@ u3_noun u3we_sign(u3_noun); u3_noun u3we_reco(u3_noun); + u3_noun u3we_en_base16(u3_noun); + u3_noun u3we_de_base16(u3_noun); + u3_noun u3we_bend_fun(u3_noun); u3_noun u3we_cold_fun(u3_noun); u3_noun u3we_cook_fun(u3_noun); diff --git a/pkg/urbit/include/noun/retrieve.h b/pkg/urbit/include/noun/retrieve.h index eed2bcc916..73fed0ccb6 100644 --- a/pkg/urbit/include/noun/retrieve.h +++ b/pkg/urbit/include/noun/retrieve.h @@ -368,6 +368,14 @@ u3r_mp(mpz_t a_mp, u3_atom b); + /* u3r_short(): + ** + ** Return short (a_w) of (b). + */ + c3_s + u3r_short(c3_w a_w, + u3_atom b); + /* u3r_word(): ** ** Return word (a_w) of (b). diff --git a/pkg/urbit/include/noun/xtract.h b/pkg/urbit/include/noun/xtract.h index 334f670e18..593ac7aa6f 100644 --- a/pkg/urbit/include/noun/xtract.h +++ b/pkg/urbit/include/noun/xtract.h @@ -57,6 +57,11 @@ # define u3x_peg(a_w, b_w) \ ( (a_w << u3x_dep(b_w)) | (b_w &~ (1 << u3x_dep(b_w))) ) + /* u3x_atom(): atom or exit. + */ +# define u3x_atom(a) \ + ( (c3y == u3a_is_cell(a)) ? u3m_bail(c3__exit) : a ) + /** Functions. **/ /** u3x_*: read, but bail with c3__exit on a crash. diff --git a/pkg/urbit/jets/e/base.c b/pkg/urbit/jets/e/base.c new file mode 100644 index 0000000000..62a4d66a6a --- /dev/null +++ b/pkg/urbit/jets/e/base.c @@ -0,0 +1,128 @@ +/* j/5/base.c +** +*/ +#include "all.h" + +const c3_y hex_y[16] = { '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; + +u3_noun +u3qe_en_base16(u3_noun cot) +{ + c3_w len_w, byt_w; + u3_atom len, dat; + u3x_cell(cot, &len, &dat); + u3x_atom(len); u3x_atom(dat); + + if ( c3n == u3a_is_cat(len) ) { + return u3m_bail(c3__fail); + } + else { + len_w = (c3_w)len; + byt_w = len_w * 2; + + if ( (byt_w / 2) != len_w ) { + return u3m_bail(c3__fail); + } + else { + c3_y* buf_y = u3a_malloc(byt_w); + c3_y* dat_y = buf_y; + c3_y inp_y; + + while ( len_w-- ) { + inp_y = u3r_byte(len_w, dat); + + *buf_y++ = hex_y[inp_y >> 4]; + *buf_y++ = hex_y[inp_y & 0xf]; + } + + { + u3_noun pro = u3i_bytes(byt_w, dat_y); + u3a_free(dat_y); + return pro; + } + } + } +} + +static inline c3_o +_of_hex_digit(c3_y inp_y, c3_y* out_y) +{ + if ( inp_y >= '0' && inp_y <= '9' ) { + *out_y = inp_y - '0'; + return c3y; + } + else if ( inp_y >= 'a' && inp_y <= 'f' ) { + *out_y = inp_y - 87; + return c3y; + } + else if ( inp_y >= 'A' && inp_y <= 'F' ) { + *out_y = inp_y - 55; + return c3y; + } + + return c3n; +} + +u3_noun +u3qe_de_base16(u3_atom inp) +{ + c3_w sor_w = u3r_met(4, inp); + c3_w len_w = sor_w; + c3_y* buf_y = u3a_malloc(len_w); + c3_y* dat_y = buf_y; + + // handle odd-numbered input lengths + // + { + c3_w byt_w = u3r_met(3, inp); + + if ( byt_w & 1 ) { + c3_y inp_y = u3r_byte(byt_w - 1, inp); + c3_y dit_y; + + if ( c3n == _of_hex_digit(inp_y, &dit_y) ) { + u3a_free(dat_y); + return u3_nul; + } + else { + *buf_y++ = dit_y & 0xf; + len_w--; + } + } + } + + while ( len_w-- ) { + c3_s inp_s = u3r_short(len_w, inp); + c3_y low_y, hig_y; + + if ( (c3n == _of_hex_digit(inp_s & 0xff, &low_y)) + || (c3n == _of_hex_digit(inp_s >> 8, &hig_y)) ) + { + u3a_free(dat_y); + return u3_nul; + } + else { + *buf_y++ = (hig_y & 0xf) ^ (low_y << 4); + } + } + + { + u3_noun dat = u3i_bytes(sor_w, dat_y); + u3a_free(dat_y); + return u3nt(u3_nul, u3i_words(1, &sor_w), dat); + } +} + +u3_noun +u3we_en_base16(u3_noun cor) +{ + return u3qe_en_base16(u3x_at(u3x_sam, cor)); +} + +u3_noun +u3we_de_base16(u3_noun cor) +{ + u3_noun sam = u3x_at(u3x_sam, cor); + return u3qe_de_base16(u3x_atom(sam)); +} diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index f92ca5a483..30f7ea5c15 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -15,6 +15,33 @@ #include "all.h" +static u3j_harm _141_hex_mimes_base16_en_a[] = {{".2", u3we_en_base16}, {}}; +static c3_c* _141_hex_mimes_base16_en_ha[] = { + 0 +}; + +static u3j_harm _141_hex_mimes_base16_de_a[] = {{".2", u3we_de_base16}, {}}; +static c3_c* _141_hex_mimes_base16_de_ha[] = { + 0 +}; + +static u3j_core _141_hex_mimes_base16_d[] = + { { "en", 7, _141_hex_mimes_base16_en_a, 0, _141_hex_mimes_base16_en_ha }, + { "de", 7, _141_hex_mimes_base16_de_a, 0, _141_hex_mimes_base16_de_ha }, + {} + }; +static c3_c* _141_hex_mimes_base16_ha[] = { + 0 +}; + +static u3j_core _141_hex_mimes_d[] = + { { "base16", 3, 0, _141_hex_mimes_base16_d, _141_hex_mimes_base16_ha }, + {} + }; +static c3_c* _141_hex_mimes_ha[] = { + 0 +}; + static u3j_harm _141_hex_aes_ecba_en_a[] = {{".2", u3wea_ecba_en}, {}}; static c3_c* _141_hex_aes_ecba_en_ha[] = { "a4eaaead7ffeb213cf8d611f20d7be4786b34f31a27f41c77538125992107c2d", @@ -397,6 +424,7 @@ static u3j_core _141_hex_d[] = { "blake", 31, 0, _141_hex_blake_d, _141_hex_blake_ha }, { "ripemd", 31, 0, _141_hex_ripe_d, _141_hex_ripe_ha }, { "secp", 31, 0, _141_hex_secp_d, _141_hex_secp_ha }, + { "mimes", 31, 0, _141_hex_mimes_d, _141_hex_mimes_ha }, {} }; static c3_c* _141_hex_ha[] = { diff --git a/pkg/urbit/noun/retrieve.c b/pkg/urbit/noun/retrieve.c index 63589ab1e1..340180817e 100644 --- a/pkg/urbit/noun/retrieve.c +++ b/pkg/urbit/noun/retrieve.c @@ -1107,6 +1107,39 @@ u3r_mp(mpz_t a_mp, } } +/* u3r_short(): +** +** Return short (a_w) of (b). +*/ +c3_s +u3r_short(c3_w a_w, + u3_atom b) +{ + c3_assert( u3_none != b ); + c3_assert( c3y == u3a_is_atom(b) ); + + if ( c3y == u3a_is_cat(b) ) { + switch ( a_w ) { + case 0: return b & 0xffff; + case 1: return b >> 16; + default: return 0; + } + } + else { + u3a_atom* b_u = u3a_to_ptr(b); + c3_w nix_w = a_w >> 1; + + if ( nix_w >= b_u->len_w ) { + return 0; + } + else { + c3_w wor_w = b_u->buf_w[nix_w]; + + return ( a_w & 1 ) ? (wor_w >> 16) : (wor_w & 0xffff); + } + } +} + /* u3r_word(): ** ** Return word (a_w) of (b). From 2541ccbbec00ff64552ad27d2266fc8e040d0f8a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 24 Sep 2020 23:27:38 -0700 Subject: [PATCH 382/933] vere: refactors u3qe_de_base16() to properly handle odd lengths --- pkg/urbit/jets/e/base.c | 99 +++++++++++++++++++++++++++-------------- 1 file changed, 66 insertions(+), 33 deletions(-) diff --git a/pkg/urbit/jets/e/base.c b/pkg/urbit/jets/e/base.c index 62a4d66a6a..9c02a69bcb 100644 --- a/pkg/urbit/jets/e/base.c +++ b/pkg/urbit/jets/e/base.c @@ -64,53 +64,86 @@ _of_hex_digit(c3_y inp_y, c3_y* out_y) return c3n; } +static inline c3_o +_of_hex_odd(u3_atom inp, c3_w len_w, c3_w byt_w, c3_y* buf_y) +{ + c3_y low_y, hig_y, lit_y, hit_y; + + hig_y = u3r_byte(--byt_w, inp); + + while ( --len_w ) { + low_y = u3r_byte(--byt_w, inp); + + if ( (c3n == _of_hex_digit(low_y, &lit_y)) + || (c3n == _of_hex_digit(hig_y, &hit_y)) ) + { + return c3n; + } + else { + *buf_y++ = (hit_y & 0xf) ^ (lit_y << 4); + } + + hig_y = u3r_byte(--byt_w, inp); + } + + if ( c3n == _of_hex_digit(hig_y, &hit_y) ) { + return c3n; + } + else { + *buf_y = hit_y & 0xf; + } + + return c3y; +} + +static inline c3_o +_of_hex_even(u3_atom inp, c3_w len_w, c3_y* buf_y) +{ + c3_y lit_y, hit_y; + c3_s inp_s; + + while ( len_w-- ) { + inp_s = u3r_short(len_w, inp); + + if ( (c3n == _of_hex_digit(inp_s & 0xff, &lit_y)) + || (c3n == _of_hex_digit(inp_s >> 8, &hit_y)) ) + { + return c3n; + } + else { + *buf_y++ = (hit_y & 0xf) ^ (lit_y << 4); + } + } + + return c3y; +} + u3_noun u3qe_de_base16(u3_atom inp) { - c3_w sor_w = u3r_met(4, inp); - c3_w len_w = sor_w; + c3_w len_w = u3r_met(4, inp); c3_y* buf_y = u3a_malloc(len_w); - c3_y* dat_y = buf_y; + c3_o ret_o; - // handle odd-numbered input lengths - // { c3_w byt_w = u3r_met(3, inp); if ( byt_w & 1 ) { - c3_y inp_y = u3r_byte(byt_w - 1, inp); - c3_y dit_y; - - if ( c3n == _of_hex_digit(inp_y, &dit_y) ) { - u3a_free(dat_y); - return u3_nul; - } - else { - *buf_y++ = dit_y & 0xf; - len_w--; - } - } - } - - while ( len_w-- ) { - c3_s inp_s = u3r_short(len_w, inp); - c3_y low_y, hig_y; - - if ( (c3n == _of_hex_digit(inp_s & 0xff, &low_y)) - || (c3n == _of_hex_digit(inp_s >> 8, &hig_y)) ) - { - u3a_free(dat_y); - return u3_nul; + ret_o = _of_hex_odd(inp, len_w, byt_w, buf_y); } else { - *buf_y++ = (hig_y & 0xf) ^ (low_y << 4); + ret_o = _of_hex_even(inp, len_w, buf_y); } } - { - u3_noun dat = u3i_bytes(sor_w, dat_y); - u3a_free(dat_y); - return u3nt(u3_nul, u3i_words(1, &sor_w), dat); + if ( c3n == ret_o ) { + u3a_free(buf_y); + return u3_nul; + } + else { + u3_noun dat = u3i_bytes(len_w, buf_y); + u3a_free(buf_y); + return u3nt(u3_nul, u3i_words(1, &len_w), dat); } } From e9f09e32c173e6f5162cd2af55dc4b1c05e4ac12 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 18 Sep 2020 13:46:43 -0400 Subject: [PATCH 383/933] king: put slogs in the muxed scrollback If you connect to an urbit using the remote terminal code, slogs would not be printed to them since they were hard coded to be printed to stderr. This threads slog printing to the terminal driver, and puts them in scrollback. (It does not actually fix slogs being printed on one line.) --- pkg/hs/urbit-king/lib/Urbit/King/Main.hs | 9 +++--- pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs | 28 +++++++---------- pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs | 22 ++++++++++--- pkg/hs/urbit-king/lib/Urbit/Vere/Term/API.hs | 12 ++++++- .../urbit-king/lib/Urbit/Vere/Term/Logic.hs | 31 +++++++++++++++---- pkg/hs/urbit-noun/lib/Urbit/Noun/Tank.hs | 6 ++++ 6 files changed, 77 insertions(+), 31 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs index 66092ffb69..9b1449d6b4 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs @@ -175,10 +175,10 @@ logStderr action = do logFunc <- view stderrLogFuncL runRIO logFunc action -logSlogs :: HasStderrLogFunc e => RIO e (TVar (Text -> IO ())) +logSlogs :: HasStderrLogFunc e => RIO e (TVar ((Atom, Tank) -> IO ())) logSlogs = logStderr $ do env <- ask - newTVarIO (runRIO env . logOther "serf" . display . T.strip) + newTVarIO (runRIO env . logOther "serf" . display . T.strip . tankToText . snd) tryBootFromPill :: Bool @@ -200,7 +200,7 @@ tryBootFromPill oExit pill lite ship boot = do pure sls runOrExitImmediately - :: TVar (Text -> IO ()) + :: TVar ((Atom, Tank) -> IO ()) -> RAcquire PierEnv (Serf, Log.EventLog) -> Bool -> MVar () @@ -240,7 +240,8 @@ tryPlayShip exitImmediately fullReplay playFrom mStart = do north shipPath = shipPath <> "/.urb/chk/north.bin" south shipPath = shipPath <> "/.urb/chk/south.bin" - resumeShip :: TVar (Text -> IO ()) -> RAcquire PierEnv (Serf, Log.EventLog) + resumeShip :: TVar ((Atom, Tank) -> IO ()) + -> RAcquire PierEnv (Serf, Log.EventLog) resumeShip vSlog = do view pierPathL >>= lockFile rio $ logInfo "RESUMING SHIP" diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs index 82da7d0df9..181b180243 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs @@ -111,14 +111,9 @@ writeJobs log !jobs = do -- Acquire a running serf. ----------------------------------------------------- -printTank :: (Text -> IO ()) -> Atom -> Tank -> IO () -printTank f _priority = f . unlines . fmap unTape . wash (WashCfg 0 80) . tankTree - where - tankTree (Tank t) = t - runSerf :: HasPierEnv e - => TVar (Text -> IO ()) + => TVar ((Atom, Tank) -> IO ()) -> FilePath -> RAcquire e Serf runSerf vSlog pax = do @@ -126,13 +121,13 @@ runSerf vSlog pax = do serfProg <- io getSerfProg Serf.withSerf (config env serfProg) where - slog txt = atomically (readTVar vSlog) >>= (\f -> f txt) + slog s = atomically (readTVar vSlog) >>= (\f -> f s) config env serfProg = Serf.Config { scSerf = env ^. pierConfigL . pcSerfExe . to (maybe serfProg unpack) , scPier = pax , scFlag = env ^. pierConfigL . pcSerfFlags - , scSlog = \(pri, tank) -> printTank slog pri tank - , scStdr = \txt -> slog (txt <> "\r\n") + , scSlog = slog -- printTank slog pri tank + , scStdr = \txt -> slog (0, (textToTank txt)) , scDead = pure () -- TODO: What can be done? } getSerfProg :: IO FilePath @@ -147,7 +142,7 @@ runSerf vSlog pax = do -- Boot a new ship. ------------------------------------------------------------ booted - :: TVar (Text -> IO ()) + :: TVar ((Atom, Tank) -> IO ()) -> Pill -> Bool -> Ship @@ -198,7 +193,7 @@ bootNewShip pill lite ship bootEv = do -- Resume an existing ship. ---------------------------------------------------- resumed - :: TVar (Text -> IO ()) + :: TVar ((Atom, Tank) -> IO ()) -> Maybe Word64 -> RAcquire PierEnv (Serf, EventLog) resumed vSlog replayUntil = do @@ -267,7 +262,7 @@ acquireWorkerBound nam act = mkRAcquire (asyncBound act) kill pier :: (Serf, EventLog) - -> TVar (Text -> IO ()) + -> TVar ((Atom, Tank) -> IO ()) -> MVar () -> RAcquire PierEnv () pier (serf, log) vSlog startedSig = do @@ -301,9 +296,9 @@ pier (serf, log) vSlog startedSig = do -- Slogs go to both stderr and to the terminal. env <- ask - atomically $ writeTVar vSlog $ \txt -> runRIO env $ do - atomically $ Term.trace muxed txt - logOther "serf" (display $ T.strip txt) + atomically $ writeTVar vSlog $ \s@(_, tank) -> runRIO env $ do + atomically $ Term.slog muxed s + logOther "serf" (display $ T.strip $ tankToText tank) -- Our call above to set the logging function which echos errors from the -- Serf doesn't have the appended \r\n because those \r\n s are added in @@ -356,8 +351,9 @@ pier (serf, log) vSlog startedSig = do let slog :: Text -> IO () slog txt = do + -- TODO: What is this and is it right? fn <- atomically (readTVar vSlog) - fn txt + fn (0, textToTank txt) drivz <- startDrivers tExec <- acquireWorker "Effects" (router slog (readTQueue executeQ) drivz) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs index e4b5bf0cd4..2f51ca0688 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs @@ -182,7 +182,9 @@ localClient doneSignal = fst <$> mkRAcquire start stop start = do tsWriteQueue <- newTQueueIO :: RIO e (TQueue [Term.Ev]) spinnerMVar <- newEmptyTMVarIO :: RIO e (TMVar ()) - pWriterThread <- asyncBound (writeTerminal tsWriteQueue spinnerMVar) + tsizeTVar <- io $ T.termSize >>= newTVarIO + pWriterThread <- asyncBound + (writeTerminal tsWriteQueue spinnerMVar tsizeTVar) pPreviousConfiguration <- io $ getTerminalAttributes stdInput @@ -203,7 +205,7 @@ localClient doneSignal = fst <$> mkRAcquire start stop , give = writeTQueue tsWriteQueue } - tsize <- io $ T.termSize + tsize <- io $ T.liveTermSize (\ts -> atomically $ writeTVar tsizeTVar ts) pure ((tsize, client), Private{..}) @@ -245,8 +247,8 @@ localClient doneSignal = fst <$> mkRAcquire start stop -- Writes data to the terminal. Both the terminal reading, normal logging, -- and effect handling can all emit bytes which go to the terminal. - writeTerminal :: TQueue [Term.Ev] -> TMVar () -> RIO e () - writeTerminal q spinner = do + writeTerminal :: TQueue [Term.Ev] -> TMVar () -> TVar TermSize -> RIO e () + writeTerminal q spinner termSizeVar = do currentTime <- io $ now loop (LineState "" 0 Nothing Nothing True 0 currentTime) where @@ -260,6 +262,17 @@ localClient doneSignal = fst <$> mkRAcquire start stop putStr p termRefreshLine ls + writeSlog :: LineState -> (Atom, Tank) -> RIO e LineState + writeSlog ls slog = do + putStr "\r" + T.clearLine + TermSize width _ <- atomically $ readTVar termSizeVar + -- TODO: Ignoring priority for now. + putStr (tshow width <> "\r\n") + let lines = fmap unTape $ wash (WashCfg 0 width) $ tankTree $ snd slog + forM lines $ \line -> putStr (line <> "\r\n") + termRefreshLine ls + {- Figure out how long to wait to show the spinner. When we don't have a vane name to display, we assume its a user @@ -310,6 +323,7 @@ localClient doneSignal = fst <$> mkRAcquire start stop execEv ls = \case Term.Blits bs -> foldM writeBlit ls bs Term.Trace p -> writeTrace ls (unCord p) + Term.Slog s -> writeSlog ls s Term.Blank -> writeBlank ls Term.Spinr (Just txt) -> doSpin ls (unCord <$> txt) Term.Spinr Nothing -> unspin ls diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Term/API.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Term/API.hs index 0d38b8ffd3..270ee1a7da 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Term/API.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Term/API.hs @@ -1,7 +1,12 @@ {-| Interface Terminal API. -} -module Urbit.Vere.Term.API (Ev(..), Client(..), trace, spin, stopSpin) where +module Urbit.Vere.Term.API (Ev(..), + Client(..), + trace, + slog, + spin, + stopSpin) where import Urbit.Prelude hiding (trace) @@ -15,11 +20,13 @@ import Urbit.Arvo (Belt, Blit) %blits -- list of blits from arvo. %trace -- stderr line from runtime. + %slog -- nock worker logging with priority %blank -- print a blank line %spinr -- Start or stop the spinner -} data Ev = Blits [Blit] | Trace Cord + | Slog (Atom, Tank) | Blank | Spinr (Maybe (Maybe Cord)) deriving (Show) @@ -37,6 +44,9 @@ deriveNoun ''Ev trace :: Client -> Text -> STM () trace ts = give ts . singleton . Trace . Cord +slog :: Client -> (Atom, Tank) -> STM () +slog ts = give ts . singleton . Slog + spin :: Client -> Maybe Text -> STM () spin ts = give ts . singleton . Spinr . Just . fmap Cord diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Term/Logic.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Term/Logic.hs index 8e739b88ae..b4f26d4977 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Term/Logic.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Term/Logic.hs @@ -37,6 +37,7 @@ type SpinnerState = Maybe SpinnerCause -} data Ev = EvLine Text + | EvSlog (Atom, Tank) | EvSpin SpinnerState | EvMove Word | EvBell @@ -53,8 +54,13 @@ data Ef | EfSpin SpinnerState deriving (Show) +data History + = HistoryText Text + | HistorySlog (Atom, Tank) + deriving (Show) + data St = St - { sHistory :: Seq Text + { sHistory :: Seq History , sLine :: Text , sCurPos :: Word , sSpinner :: SpinnerState @@ -74,19 +80,27 @@ init = St mempty "" 0 Nothing -} step :: St -> Ev -> St step st@St{..} = \case - EvLine t -> st & record t + EvLine t -> st & recordText t + EvSlog s -> st & recordSlog s EvSpin s -> st { sSpinner = s } EvMove w -> st { sCurPos = min w (word $ length sLine) } EvEdit t -> st { sLine = t, sCurPos = word (length t) } - EvMore -> st { sLine = "", sCurPos = 0 } & record (sLine <> "\n") + EvMore -> st { sLine = "", sCurPos = 0 } & recordText (sLine <> "\n") EvBell -> st EvDraw -> st where word :: Integral i => i -> Word word = fromIntegral - record :: Text -> St -> St - record t st@St{..} = st { sHistory = trim (sHistory |> t) } + recordText :: Text -> St -> St + recordText t st@St{..} = st { + sHistory = trim (sHistory |> (HistoryText t)) + } + + recordSlog :: (Atom, Tank) -> St -> St + recordSlog t st@St{..} = st { + sHistory = trim (sHistory |> (HistorySlog t)) + } trim :: Seq a -> Seq a trim s | length s < 20 = s @@ -96,11 +110,14 @@ step st@St{..} = \case drawState :: St -> [Ev] drawState St{..} = hist <> out <> cur <> spin where - hist = EvLine <$> toList sHistory + hist = fmap drawHistory $ toList sHistory out = if null sLine then [] else [EvEdit sLine] cur = if 0 == sCurPos then [] else [EvMove $ fromIntegral $ sCurPos] spin = maybe [] (singleton . EvSpin . Just) sSpinner + drawHistory (HistoryText t) = EvLine t + drawHistory (HistorySlog s) = EvSlog s + -- Conversion ------------------------------------------------------------------ @@ -127,11 +144,13 @@ fromTermEv = \case Term.Trace t -> [EvLine $ unCord t] Term.Blank -> [EvLine ""] Term.Spinr s -> [EvSpin $ toCause <$> s] + Term.Slog s -> [EvSlog s] toTermEv :: Ev -> Term.Ev toTermEv = \case EvLine "" -> Term.Blank EvLine t -> Term.Trace (Cord t) + EvSlog s -> Term.Slog s EvSpin s -> Term.Spinr (fromCause <$> s) EvMove w -> Term.Blits [Arvo.Hop $ fromIntegral w] EvBell -> Term.Blits [Arvo.Bel ()] diff --git a/pkg/hs/urbit-noun/lib/Urbit/Noun/Tank.hs b/pkg/hs/urbit-noun/lib/Urbit/Noun/Tank.hs index bfba684c7d..9dbbdf2f96 100644 --- a/pkg/hs/urbit-noun/lib/Urbit/Noun/Tank.hs +++ b/pkg/hs/urbit-noun/lib/Urbit/Noun/Tank.hs @@ -85,6 +85,12 @@ ram = \case loop [x] = ram x <> r loop (x:xs) = ram x <> p <> loop xs +tankToText :: Tank -> Text +tankToText (Tank t) = unlines $ fmap unTape $ wash (WashCfg 0 80) t + +textToTank :: Text -> Tank +textToTank = Tank . Leaf . Tape + {- ++ win |= {tab/@ edg/@} From 20a6c0331c2c7977884a7abfc5fef1c29bdb9e8a Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 25 Sep 2020 11:32:17 -0400 Subject: [PATCH 384/933] king: set initial terminal size and react to resizes This changes startup so we get the size of the current terminal to send to Urbit on startup. We then subscribe to terminal size change notifications and send those to your Urbit via the terminal muxing system. In the case where there are multiple terminal connections to your Urbit, set the terminal size to the minimum of the widths. --- pkg/hs/urbit-king/lib/Urbit/King/API.hs | 3 +- pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs | 8 ++- pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs | 50 +++++++++----- pkg/hs/urbit-king/lib/Urbit/Vere/Term/API.hs | 27 +++++++- .../urbit-king/lib/Urbit/Vere/Term/Demux.hs | 66 +++++++++++++++---- pkg/hs/urbit-termsize/lib/Urbit/TermSize.hs | 4 +- 6 files changed, 122 insertions(+), 36 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/API.hs b/pkg/hs/urbit-king/lib/Urbit/King/API.hs index adba475509..61bf31dfe7 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/API.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/API.hs @@ -18,7 +18,6 @@ import Urbit.Prelude import Network.Socket (Socket) import Prelude (read) -import Urbit.Arvo (Belt) import Urbit.King.App (HasPierPath(..)) import qualified Network.HTTP.Types as H @@ -32,7 +31,7 @@ import qualified Urbit.Vere.Term.API as Term -- Types ----------------------------------------------------------------------- -type TermConn = NounServ.Conn Belt [Term.Ev] +type TermConn = NounServ.Conn Term.ClientTake [Term.Ev] type TermConnAPI = TVar (Maybe (TermConn -> STM ())) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs index 181b180243..86dbb8934f 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs @@ -31,7 +31,7 @@ import System.Posix.Files (ownerModes, setFileMode) import Urbit.EventLog.LMDB (EventLog) import Urbit.King.API (TermConn) import Urbit.Noun.Time (Wen) -import Urbit.TermSize (TermSize(..)) +import Urbit.TermSize (TermSize(..), termSize) import Urbit.Vere.Serf (Serf) import qualified Data.Text as T @@ -283,8 +283,10 @@ pier (serf, log) vSlog startedSig = do writeTVar (King.kTermConn kingApi) (Just $ writeTQueue q) pure q + initialTermSize <- io $ termSize + (demux :: Term.Demux, muxed :: Term.Client) <- atomically $ do - res <- Term.mkDemux + res <- Term.mkDemux initialTermSize pure (res, Term.useDemux res) void $ acquireWorker "TERMSERV Listener" $ forever $ do @@ -312,7 +314,7 @@ pier (serf, log) vSlog startedSig = do (bootEvents, startDrivers) <- do env <- ask let err = atomically . Term.trace muxed . (<> "\r\n") - let siz = TermSize { tsWide = 80, tsTall = 24 } + siz <- atomically $ Term.curDemuxSize demux let fak = isFake logId drivers env ship fak compute (siz, muxed) err sigint diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs index 2f51ca0688..a26f9abb0d 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs @@ -28,7 +28,7 @@ import Data.List ((!!)) import RIO.Directory (createDirectoryIfMissing) import Urbit.King.API (readPortsFile) import Urbit.TermSize (TermSize(TermSize)) -import Urbit.Vere.Term.API (Client(Client)) +import Urbit.Vere.Term.API (Client(Client), ClientTake(..)) import qualified Data.Set as S import qualified Data.ByteString.Internal as BS @@ -71,7 +71,7 @@ data Private = Private -- Utils ----------------------------------------------------------------------- -initialBlew w h = EvBlip $ BlipEvTerm $ TermEvBlew (UD 1, ()) w h +blewEvent w h = EvBlip $ BlipEvTerm $ TermEvBlew (UD 1, ()) w h initialHail = EvBlip $ BlipEvTerm $ TermEvHail (UD 1, ()) () @@ -98,7 +98,7 @@ isTerminalBlit _ = True -------------------------------------------------------------------------------- -connClient :: Serv.Conn Belt [Term.Ev] -> Client +connClient :: Serv.Conn ClientTake [Term.Ev] -> Client connClient c = Client { give = Serv.cSend c , take = Serv.cRecv c @@ -135,7 +135,7 @@ runTerminalClient pier = runRAcquire $ do mPort <- runRIO (HCD pier) readPortsFile port <- maybe (error "Can't connect") pure mPort mExit <- io newEmptyTMVarIO - (siz, cli) <- localClient (putTMVar mExit ()) + cli <- localClient (putTMVar mExit ()) (tid, sid) <- connectToRemote (Port $ fromIntegral port) cli atomically $ waitSTM tid <|> waitSTM sid <|> takeTMVar mExit @@ -175,14 +175,28 @@ _spin_idle_us = 500000 -} localClient :: ∀e. HasLogFunc e => STM () - -> RAcquire e (TermSize, Client) + -> RAcquire e Client localClient doneSignal = fst <$> mkRAcquire start stop where - start :: HasLogFunc e => RIO e ((TermSize, Client), Private) + start :: HasLogFunc e => RIO e (Client, Private) start = do tsWriteQueue <- newTQueueIO :: RIO e (TQueue [Term.Ev]) spinnerMVar <- newEmptyTMVarIO :: RIO e (TMVar ()) - tsizeTVar <- io $ T.termSize >>= newTVarIO + + -- Track the terminal size, keeping track of the size of the local + -- terminal for our own printing, as well as putting size changes into an + -- event queue so we can send changes to the terminal muxing system. + tsizeTVar <- newTVarIO (TermSize 80 24) -- Value doesn't matter. + tsSizeChangeQueue <- newTQueueIO + io $ T.liveTermSize (\ts -> atomically $ do + -- We keep track of the console's local size for + -- our own tank washing. + writeTVar tsizeTVar ts + + -- We queue up changes so we can broadcast them + -- to the muxing client. + writeTQueue tsSizeChangeQueue ts) + pWriterThread <- asyncBound (writeTerminal tsWriteQueue spinnerMVar tsizeTVar) @@ -201,17 +215,18 @@ localClient doneSignal = fst <$> mkRAcquire start stop pReaderThread <- asyncBound (readTerminal tsReadQueue tsWriteQueue (bell tsWriteQueue)) - let client = Client { take = Just <$> readTQueue tsReadQueue + let client = Client { take = Just <$> asum [ + readTQueue tsReadQueue <&> ClientTakeBelt, + readTQueue tsSizeChangeQueue <&> ClientTakeSize + ] , give = writeTQueue tsWriteQueue } - tsize <- io $ T.liveTermSize (\ts -> atomically $ writeTVar tsizeTVar ts) - - pure ((tsize, client), Private{..}) + pure (client, Private{..}) stop :: HasLogFunc e - => ((TermSize, Client), Private) -> RIO e () - stop ((_, Client{..}), Private{..}) = do + => (Client, Private) -> RIO e () + stop (Client{..}, Private{..}) = do -- Note that we don't `cancel pReaderThread` here. This is a deliberate -- decision because fdRead calls into a native function which the runtime -- can't kill. If we were to cancel here, the internal `waitCatch` would @@ -583,7 +598,7 @@ term' -> RIO e ([Ev], RAcquire e (DriverApi TermEf)) term' (tsize, client) serfSIGINT = do let TermSize wi hi = tsize - initEv = [initialBlew wi hi, initialHail] + initEv = [blewEvent wi hi, initialHail] pure (initEv, runDriver) where @@ -619,13 +634,16 @@ term env (tsize, Client{..}) plan serfSIGINT = runTerm readLoop :: RIO e () readLoop = forever $ do atomically take >>= \case - Nothing -> pure () - Just b -> do + Nothing -> pure () + Just (ClientTakeBelt b) -> do when (b == Ctl (Cord "c")) $ do io serfSIGINT let beltEv = EvBlip $ BlipEvTerm $ TermEvBelt (UD 1, ()) $ b let beltFailed _ = pure () atomically $ plan (EvErr beltEv beltFailed) + Just (ClientTakeSize ts@(TermSize w h)) -> do + let blewFailed _ = pure () + atomically $ plan (EvErr (blewEvent w h) blewFailed) handleEffect :: TermEf -> RIO e () handleEffect = \case diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Term/API.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Term/API.hs index 270ee1a7da..381ae51113 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Term/API.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Term/API.hs @@ -3,6 +3,7 @@ -} module Urbit.Vere.Term.API (Ev(..), Client(..), + ClientTake(..), trace, slog, spin, @@ -12,6 +13,7 @@ import Urbit.Prelude hiding (trace) import Urbit.Arvo (Belt, Blit) +import Urbit.TermSize -- External Types -------------------------------------------------------------- @@ -31,8 +33,31 @@ data Ev = Blits [Blit] | Spinr (Maybe (Maybe Cord)) deriving (Show) +data ClientTake + = ClientTakeBelt Belt + | ClientTakeSize TermSize + deriving (Show) + +instance ToNoun ClientTake where + toNoun = \case + ClientTakeBelt b -> toNoun $ (Cord "belt", b) + ClientTakeSize (TermSize w h) -> toNoun $ (Cord "size", (w, h)) + +instance FromNoun ClientTake where + parseNoun n = named "ClientTake" $ do + (Cord name, rest) <- parseNoun n + case name of + "belt" -> do + b <- parseNoun rest + pure (ClientTakeBelt b) + "size" -> do + (w, h) <- parseNoun rest + pure (ClientTakeSize (TermSize w h)) + _ -> fail "weird client take" + + data Client = Client - { take :: STM (Maybe Belt) + { take :: STM (Maybe ClientTake) , give :: [Ev] -> STM () } diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Term/Demux.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Term/Demux.hs index 5a7bd23e29..c4e98ced7d 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Term/Demux.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Term/Demux.hs @@ -4,12 +4,15 @@ given full event history since the creation of the demuxer. -} -module Urbit.Vere.Term.Demux (Demux, mkDemux, addDemux, useDemux) where +module Urbit.Vere.Term.Demux (Demux, + mkDemux, + addDemux, + useDemux, + curDemuxSize) where import Urbit.Prelude - -import Urbit.Arvo (Belt) -import Urbit.Vere.Term.API (Client(Client)) +import Urbit.TermSize +import Urbit.Vere.Term.API (Client(Client), ClientTake(..)) import qualified Urbit.Vere.Term.API as Term import qualified Urbit.Vere.Term.Logic as Logic @@ -42,11 +45,17 @@ ksDelete k (KeyedSet t n) = KeyedSet (deleteMap k t) n data Demux = Demux { dConns :: TVar (KeyedSet Client) + , dSizes :: TVar (IntMap TermSize) , dStash :: TVar Logic.St + , dMinSize :: TVar TermSize } -mkDemux :: STM Demux -mkDemux = Demux <$> newTVar mempty <*> newTVar Logic.init +mkDemux :: TermSize -> STM Demux +mkDemux ts = Demux <$> + newTVar mempty <*> + newTVar mempty <*> + newTVar Logic.init <*> + newTVar ts addDemux :: Client -> Demux -> STM () addDemux conn Demux{..} = do @@ -57,6 +66,8 @@ addDemux conn Demux{..} = do useDemux :: Demux -> Client useDemux d = Client { give = dGive d, take = dTake d } +curDemuxSize :: Demux -> STM TermSize +curDemuxSize Demux{..} = readTVar dMinSize -- Internal -------------------------------------------------------------------- @@ -77,16 +88,45 @@ dGive Demux{..} evs = do If there are no attached clients, this will not return until one is attached. -} -dTake :: Demux -> STM (Maybe Belt) +dTake :: Demux -> STM (Maybe ClientTake) dTake Demux{..} = do conns <- readTVar dConns - waitForBelt conns >>= \case - (_, Just b ) -> pure (Just b) - (k, Nothing) -> do writeTVar dConns (ksDelete k conns) - pure Nothing + waitForTake conns >>= \case + (_, Just (ClientTakeBelt b)) -> pure (Just (ClientTakeBelt b)) + + (k, Just (ClientTakeSize s)) -> do + newSizeTree <- modifyAndReturnTVar dSizes (insertMap k s) + maybeUpdateTerminalSize newSizeTree + + (k, Nothing) -> do + writeTVar dConns (ksDelete k conns) + newSizeTree <- modifyAndReturnTVar dSizes (deleteMap k) + maybeUpdateTerminalSize newSizeTree + where - waitForBelt :: KeyedSet Client -> STM (Int, Maybe Belt) - waitForBelt ks = asum + waitForTake :: KeyedSet Client -> STM (Int, Maybe ClientTake) + waitForTake ks = asum $ fmap (\(k,c) -> (k,) <$> Term.take c) $ mapToList $ _ksTable ks + + maybeUpdateTerminalSize :: IntMap TermSize -> STM (Maybe ClientTake) + maybeUpdateTerminalSize newSizeTree = do + let termSize = foldr minTermSize (TermSize 1024 1024) newSizeTree + curSize <- readTVar dMinSize + if curSize == termSize + then pure Nothing + else do + writeTVar dMinSize termSize + pure $ Just (ClientTakeSize termSize) + + modifyAndReturnTVar :: TVar a -> (a -> a) -> STM a + modifyAndReturnTVar var fun = do + pre <- readTVar var + let post = fun pre + writeTVar var post + pure post + + minTermSize :: TermSize -> TermSize -> TermSize + minTermSize (TermSize wa ha) (TermSize wb hb) = + TermSize (min wa wb) (min ha hb) diff --git a/pkg/hs/urbit-termsize/lib/Urbit/TermSize.hs b/pkg/hs/urbit-termsize/lib/Urbit/TermSize.hs index 33f2d78cf6..af4e1f0b0f 100644 --- a/pkg/hs/urbit-termsize/lib/Urbit/TermSize.hs +++ b/pkg/hs/urbit-termsize/lib/Urbit/TermSize.hs @@ -37,4 +37,6 @@ termSize = size <&> \case liveTermSize :: (TermSize -> IO ()) -> IO TermSize liveTermSize cb = do Sys.installHandler Sys.sigWINCH (Sys.Catch (termSize >>= cb)) Nothing - termSize + ts <- termSize + cb ts + pure ts From 5ea372be128dd2d10eeb6b6b21ec0c34b0e8eac1 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 25 Sep 2020 10:51:35 -0700 Subject: [PATCH 385/933] vere: adds basic tests for base16 jets --- pkg/urbit/include/jets/q.h | 2 +- pkg/urbit/jets/e/base.c | 9 +- pkg/urbit/tests/jet_tests.c | 279 ++++++++++++++++++++++++++++++++++++ 3 files changed, 284 insertions(+), 6 deletions(-) create mode 100644 pkg/urbit/tests/jet_tests.c diff --git a/pkg/urbit/include/jets/q.h b/pkg/urbit/include/jets/q.h index 3c59427ca6..9af222dac6 100644 --- a/pkg/urbit/include/jets/q.h +++ b/pkg/urbit/include/jets/q.h @@ -152,7 +152,7 @@ u3_noun u3qe_reco(u3_atom has, u3_atom sig_v, u3_atom sig_r, u3_atom sig_s); u3_noun u3qe_sign(u3_atom has, u3_atom prv); - u3_noun u3qe_en_base16(u3_noun cot); + u3_noun u3qe_en_base16(u3_atom len, u3_atom dat); u3_noun u3qe_de_base16(u3_atom inp); u3_noun u3qeo_raw(u3_atom, u3_atom); diff --git a/pkg/urbit/jets/e/base.c b/pkg/urbit/jets/e/base.c index 9c02a69bcb..409cc659d3 100644 --- a/pkg/urbit/jets/e/base.c +++ b/pkg/urbit/jets/e/base.c @@ -7,12 +7,9 @@ const c3_y hex_y[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; u3_noun -u3qe_en_base16(u3_noun cot) +u3qe_en_base16(u3_atom len, u3_atom dat) { c3_w len_w, byt_w; - u3_atom len, dat; - u3x_cell(cot, &len, &dat); - u3x_atom(len); u3x_atom(dat); if ( c3n == u3a_is_cat(len) ) { return u3m_bail(c3__fail); @@ -150,7 +147,9 @@ u3qe_de_base16(u3_atom inp) u3_noun u3we_en_base16(u3_noun cor) { - return u3qe_en_base16(u3x_at(u3x_sam, cor)); + u3_noun a, b; + u3x_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0); + return u3qe_en_base16(u3x_atom(a), u3x_atom(b)); } u3_noun diff --git a/pkg/urbit/tests/jet_tests.c b/pkg/urbit/tests/jet_tests.c new file mode 100644 index 0000000000..23ccfddb98 --- /dev/null +++ b/pkg/urbit/tests/jet_tests.c @@ -0,0 +1,279 @@ +#include "all.h" + +/* _setup(): prepare for tests. +*/ +static void +_setup(void) +{ + u3m_init(); + u3m_pave(c3y, c3n); +} + +static c3_i +_test_en_base16(void) +{ + c3_i ret_i = 1; + + { + u3_atom dat = 0xaa; + u3_atom pro = u3qe_en_base16(u3r_met(3, dat), dat); + + if ( c3n == u3r_sing_c("aa", pro) ) { + fprintf(stderr, "en_base16: fail (a)\r\n"); + ret_i = 0; + } + + u3z(pro); + } + + { + u3_atom dat = 0x1234; + u3_atom pro = u3qe_en_base16(u3r_met(3, dat), dat); + + if ( c3n == u3r_sing_c("1234", pro) ) { + fprintf(stderr, "en_base16: fail (b)\r\n"); + ret_i = 0; + } + + u3z(pro); + } + + { + u3_atom dat = 0xf012; + u3_atom pro = u3qe_en_base16(u3r_met(3, dat), dat); + + if ( c3n == u3r_sing_c("f012", pro) ) { + fprintf(stderr, "en_base16: fail (c)\r\n"); + ret_i = 0; + } + + u3z(pro); + } + + { + u3_atom dat = 0x10b; + u3_atom pro = u3qe_en_base16(u3r_met(3, dat), dat); + + if ( c3n == u3r_sing_c("010b", pro) ) { + fprintf(stderr, "en_base16: fail (d)\r\n"); + ret_i = 0; + } + + u3z(pro); + } + + { + u3_atom pro = u3qe_en_base16(3, 0x1234); + + if ( c3n == u3r_sing_c("001234", pro) ) { + fprintf(stderr, "en_base16: fail (e)\r\n"); + ret_i = 0; + } + + u3z(pro); + } + + { + u3_atom pro = u3qe_en_base16(1, 0x1234); + + if ( c3n == u3r_sing_c("34", pro) ) { + fprintf(stderr, "en_base16: fail (f)\r\n"); + ret_i = 0; + } + + u3z(pro); + } + + return ret_i; +} + + +static c3_i +_test_de_base16(void) +{ + c3_i ret_i = 1; + + { + u3_noun inp = u3i_string("aa"); + u3_noun pro = u3qe_de_base16(inp); + u3_atom len, dat; + + if ( c3n == u3r_pq(pro, u3_nul, &len, &dat) ) { + fprintf(stderr, "de_base16: fail cell (a)\r\n"); + ret_i = 0; + } + + if ( 1 != len ) { + fprintf(stderr, "de_base16: fail len (a)\r\n"); + ret_i = 0; + } + + if ( 0xaa != dat ) { + fprintf(stderr, "de_base16: fail dat (a)\r\n"); + ret_i = 0; + } + + u3z(inp); u3z(pro); + } + + { + u3_noun inp = u3i_string("1234"); + u3_noun pro = u3qe_de_base16(inp); + u3_atom len, dat; + + if ( c3n == u3r_pq(pro, u3_nul, &len, &dat) ) { + fprintf(stderr, "de_base16: fail cell (b)\r\n"); + ret_i = 0; + } + + if ( 2 != len ) { + fprintf(stderr, "de_base16: fail len (b)\r\n"); + ret_i = 0; + } + + if ( 0x1234 != dat ) { + fprintf(stderr, "de_base16: fail dat (b)\r\n"); + ret_i = 0; + } + + u3z(inp); u3z(pro); + } + + { + u3_noun inp = u3i_string("f012"); + u3_noun pro = u3qe_de_base16(inp); + u3_atom len, dat; + + if ( c3n == u3r_pq(pro, u3_nul, &len, &dat) ) { + fprintf(stderr, "de_base16: fail cell (c)\r\n"); + ret_i = 0; + } + + if ( 2 != len ) { + fprintf(stderr, "de_base16: fail len (c)\r\n"); + ret_i = 0; + } + + if ( 0xf012 != dat ) { + fprintf(stderr, "de_base16: fail dat (c)\r\n"); + ret_i = 0; + } + + u3z(inp); u3z(pro); + } + + { + u3_noun inp = u3i_string("010b"); + u3_noun pro = u3qe_de_base16(inp); + u3_atom len, dat; + + if ( c3n == u3r_pq(pro, u3_nul, &len, &dat) ) { + fprintf(stderr, "de_base16: fail cell (d)\r\n"); + ret_i = 0; + } + + if ( 2 != len ) { + fprintf(stderr, "de_base16: fail len (d)\r\n"); + ret_i = 0; + } + + if ( 0x10b != dat ) { + fprintf(stderr, "de_base16: fail dat (d)\r\n"); + ret_i = 0; + } + + u3z(inp); u3z(pro); + } + + { + u3_noun inp = u3i_string("10b"); + u3_noun pro = u3qe_de_base16(inp); + u3_atom len, dat; + + if ( c3n == u3r_pq(pro, u3_nul, &len, &dat) ) { + fprintf(stderr, "de_base16: fail cell (e)\r\n"); + ret_i = 0; + } + + if ( 2 != len ) { + fprintf(stderr, "de_base16: fail len (e)\r\n"); + ret_i = 0; + } + + if ( 0x10b != dat ) { + fprintf(stderr, "de_base16: fail dat (e)\r\n"); + ret_i = 0; + } + + u3z(inp); u3z(pro); + } + + { + u3_noun inp = u3i_string("001234"); + u3_noun pro = u3qe_de_base16(inp); + u3_atom len, dat; + + if ( c3n == u3r_pq(pro, u3_nul, &len, &dat) ) { + fprintf(stderr, "de_base16: fail cell (f)\r\n"); + ret_i = 0; + } + + if ( 3 != len ) { + fprintf(stderr, "de_base16: fail len (f)\r\n"); + ret_i = 0; + } + + if ( 0x1234 != dat ) { + fprintf(stderr, "de_base16: fail dat (f)\r\n"); + ret_i = 0; + } + + u3z(inp); u3z(pro); + } + + return ret_i; +} + +static c3_i +_test_base16(void) +{ + c3_i ret_i = 1; + + ret_i &= _test_en_base16(); + ret_i &= _test_de_base16(); + + return ret_i; +} + +static c3_i +_test_jets(void) +{ + c3_i ret_i = 1; + + if ( !_test_base16() ) { + fprintf(stderr, "test jets: base16: failed\r\n"); + ret_i = 0; + } + + return ret_i; +} + +/* main(): run all test cases. +*/ +int +main(int argc, char* argv[]) +{ + _setup(); + + if ( !_test_jets() ) { + fprintf(stderr, "test jets: failed\r\n"); + exit(1); + } + + // GC + // + u3m_grab(u3_none); + + fprintf(stderr, "test jets: ok\r\n"); + return 0; +} From 4ce4ce1974615d89a65b245d45fb630dc836ceb0 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 25 Sep 2020 17:18:17 -0700 Subject: [PATCH 386/933] u3: adds new bigatom allocation/builder api --- pkg/urbit/include/noun/allocate.h | 59 ++++++ pkg/urbit/noun/allocate.c | 298 ++++++++++++++++++++++++++++++ 2 files changed, 357 insertions(+) diff --git a/pkg/urbit/include/noun/allocate.h b/pkg/urbit/include/noun/allocate.h index d6325ff662..6eb006e5d2 100644 --- a/pkg/urbit/include/noun/allocate.h +++ b/pkg/urbit/include/noun/allocate.h @@ -179,6 +179,21 @@ #endif } u3a_pile; + /* u3a_slab_new: atom builder. + */ + typedef struct _u3a_slab_new { + struct { // internals + u3a_atom* _vat_u; // heap atom (nullable) + c3_w _sat_w; // static storage + } _; // + union { // + c3_y* buf_y; // bytes + c3_w* buf_w; // words + }; // + c3_d byt_d; // byte len + c3_w wor_w; // word len + } u3a_slab_new; + /** Macros. Should be better commented. **/ /* In and out of the box. @@ -645,6 +660,50 @@ /* Atoms from proto-atoms. */ + /* u3a_slab_init(); configure and initialize a slab of bloq-length. + */ + void + u3a_slab_init(u3a_slab_new* sab_u, c3_g met_g, c3_w len_w); + + /* u3a_slab_bare(); configure a slab of bloq-length, with uninitialized memory. + */ + void + u3a_slab_bare(u3a_slab_new* sab_u, c3_g met_g, c3_w len_w); + + /* u3a_slab_grow(); resize a slab, reallocating as necessary + */ + void + u3a_slab_grow(u3a_slab_new* sab_u, c3_g met_g, c3_w len_w); + + /* u3a_slab_free(); dispose of a slab. + */ + void + u3a_slab_free(u3a_slab_new* sab_u); + + // XX assumes little-endian + // + #define u3a_slab_moot_bytes u3a_slab_moot + + /* u3a_slab_mint(); produce atom from slab, trimming. + */ + u3_atom + u3a_slab_mint(u3a_slab_new* sab_u); + + /* u3a_slab_moot(); produce atom from slab, no trimming. + */ + u3_atom + u3a_slab_moot(u3a_slab_new* sab_u); + + /* u3a_slab_mint_bytes(); produce atom from byte-slab, trimming. + ** XX assumes little-endian, implement swap to support big-endian + */ +# define u3a_slab_mint_bytes u3a_slab_mint + + /* u3a_slab_moot_bytes(); produce atom from byte-slab, no trimming. + ** XX assumes little-endian, implement swap to support big-endian + */ +# define u3a_slab_moot_bytes u3a_slab_moot + /* u3a_slab(): create a length-bounded proto-atom. */ c3_w* diff --git a/pkg/urbit/noun/allocate.c b/pkg/urbit/noun/allocate.c index 6ab0317886..57a3d71708 100644 --- a/pkg/urbit/noun/allocate.c +++ b/pkg/urbit/noun/allocate.c @@ -2457,6 +2457,304 @@ u3a_rewrite_noun(u3_noun som) cel->tel = u3a_rewritten_noun(cel->tel); } +/* _ca_slab_size(): calculate slab bloq-size, checking for overflow. +*/ +static c3_w +_ca_slab_size(c3_g met_g, c3_w len_w, c3_d* out_d) +{ + c3_d bit_d = (c3_d)len_w << met_g; + c3_d byt_d = (bit_d + 0x7) >> 3; + c3_d wor_d = (byt_d + 0x3) >> 2; + c3_w wor_w = (c3_d)wor_d; + + if ( (wor_w != wor_d) + || (len_w != (bit_d >> met_g)) ) + { + return u3m_bail(c3__fail); + } + else { + *out_d = byt_d; + return wor_w; + } +} + +/* _ca_slab_init(): initialize slab with heap allocation. +** NB: [len_w] must be >0 +*/ +static void +_ca_slab_init(u3a_slab_new* sab_u, c3_w len_w) +{ + c3_w* nov_w = u3a_walloc(len_w + c3_wiseof(u3a_atom)); + u3a_atom* vat_u = (void *)nov_w; + + vat_u->mug_w = 0; + vat_u->len_w = len_w; + + sab_u->_._vat_u = vat_u; + sab_u->buf_w = vat_u->buf_w; + sab_u->wor_w = len_w; +} + +/* _ca_slab_grow(): update slab with heap reallocation. +*/ +static void +_ca_slab_grow(u3a_slab_new* sab_u, c3_w len_w) +{ + c3_w* old_w = (void*)sab_u->_._vat_u; + // XX implement a more efficient u3a_wealloc() + // + c3_w* nov_w = u3a_wealloc(old_w, len_w); + u3a_atom* vat_u = (void *)nov_w; + + vat_u->len_w = len_w; + + sab_u->_._vat_u = vat_u; + sab_u->buf_w = vat_u->buf_w; + sab_u->wor_w = len_w; +} + +/* _ca_atom_one(): c3_w -> u3_atom, ie, u3i_word() +*/ +static u3_atom +_ca_atom_one(c3_w dat_w) +{ + if ( c3y == u3a_is_cat(dat_w) ) { + return (u3_atom)dat_w; + } + else { + c3_w* nov_w = u3a_walloc(1 + c3_wiseof(u3a_atom)); + u3a_atom* vat_u = (void *)nov_w; + + vat_u->mug_w = 0; + vat_u->len_w = 1; + vat_u->buf_w[0] = dat_w; + + return u3a_to_pug(u3a_outa(nov_w)); + } +} + +/* _ca_atom_mint(): finalize a heap-allocated atom at specified length. +*/ +static u3_atom +_ca_atom_mint(u3a_atom* vat_u, c3_w len_w) +{ + c3_w* nov_w = (void*)vat_u; + + if ( 0 == len_w ) { + u3a_wfree(nov_w); + return (u3_atom)0; + } + else if ( 1 == len_w ) { + c3_w dat_w = *vat_u->buf_w; + + if ( c3y == u3a_is_cat(dat_w) ) { + u3a_wfree(nov_w); + return (u3_atom)dat_w; + } + } + + // try to strip a block off the end + // + { + c3_w old_w = vat_u->len_w; + c3_w dif_w = old_w - len_w; + + if ( dif_w >= u3a_minimum ) { + c3_w* box_w = (void *)u3a_botox(nov_w); + c3_w* end_w = (nov_w + c3_wiseof(u3a_atom) + len_w + 1); + c3_w asz_w = (end_w - box_w); + c3_w bsz_w = box_w[0] - asz_w; + + _box_attach(_box_make(end_w, bsz_w, 0)); + + box_w[0] = asz_w; + box_w[asz_w - 1] = asz_w; + } + } + + vat_u->len_w = len_w; + + return u3a_to_pug(u3a_outa(nov_w)); +} + +/* u3a_slab_init(); configure and initialize a slab of bloq-length. +*/ +void +u3a_slab_init(u3a_slab_new* sab_u, c3_g met_g, c3_w len_w) +{ + u3t_on(mal_o); + { + c3_d byt_d; + c3_w wor_w = _ca_slab_size(met_g, len_w, &byt_d); + + // if we only need one word, use the static storage in [sab_u] + // + if ( 1 == wor_w ) { + sab_u->_._vat_u = 0; + sab_u->buf_w = &sab_u->_._sat_w; + sab_u->wor_w = 1; + sab_u->byt_d = byt_d; + } + // allocate an indirect atom + // + else { + _ca_slab_init(sab_u, wor_w); + sab_u->byt_d = byt_d; + } + + // XX refactor + // + memset(sab_u->buf_y, 0, (size_t)wor_w * 4); + } + u3t_off(mal_o); +} + +/* u3a_slab_bare(); configure a slab of bloq-length, with uninitialized memory. +*/ +void +u3a_slab_bare(u3a_slab_new* sab_u, c3_g met_g, c3_w len_w) +{ + u3t_on(mal_o); + { + c3_d byt_d; + c3_w wor_w = _ca_slab_size(met_g, len_w, &byt_d); + + // if we only need one word, use the static storage in [sab_u] + // + if ( 1 == wor_w ) { + sab_u->_._vat_u = 0; + sab_u->buf_w = &sab_u->_._sat_w; + sab_u->wor_w = 1; + sab_u->byt_d = byt_d; + } + // allocate an indirect atom + // + else { + _ca_slab_init(sab_u, wor_w); + sab_u->byt_d = byt_d; + } + } + u3t_off(mal_o); +} + +/* u3a_slab_grow(); resize a slab, reallocating as necessary +*/ +void +u3a_slab_grow(u3a_slab_new* sab_u, c3_g met_g, c3_w len_w) +{ + u3t_on(mal_o); + { + c3_d byt_d; + c3_w wor_w = _ca_slab_size(met_g, len_w, &byt_d); + + // XX actually shrink? + // + if ( wor_w <= sab_u->wor_w ) { + sab_u->wor_w = wor_w; + sab_u->byt_d = byt_d; + } + // upgrade from static storage + // + else if ( 1 == sab_u->wor_w ) { + c3_w dat_w = *sab_u->buf_w; + + _ca_slab_init(sab_u, wor_w); + sab_u->buf_w[0] = dat_w; + sab_u->byt_d = byt_d; + } + // reallocate + // + else { + _ca_slab_grow(sab_u, wor_w); + sab_u->byt_d = byt_d; + } + } + u3t_off(mal_o); +} + +/* u3a_slab_free(); dispose of a slab. +*/ +void +u3a_slab_free(u3a_slab_new* sab_u) +{ + u3t_on(mal_o); + if ( 1 == sab_u->wor_w ) { + c3_assert( !sab_u->_._vat_u ); + } + else { + u3a_atom* vat_u = sab_u->_._vat_u; + + c3_assert( (sab_u->buf_w - c3_wiseof(u3a_atom)) == (c3_w*)vat_u ); + + u3a_wfree(vat_u); + } + u3t_off(mal_o); +} + +/* u3a_slab_mint(); produce atom from slab, trimming. +*/ +u3_atom +u3a_slab_mint(u3a_slab_new* sab_u) +{ + u3_atom pro; + + u3t_on(mal_o); + + if ( 1 == sab_u->wor_w ) { + c3_w dat_w = *sab_u->buf_w; + + c3_assert( !sab_u->_._vat_u ); + + pro = _ca_atom_one(dat_w); + } + else { + u3a_atom* vat_u = sab_u->_._vat_u; + c3_w len_w = sab_u->wor_w; + + c3_assert( (sab_u->buf_w - c3_wiseof(u3a_atom)) == (c3_w*)vat_u ); + + while ( len_w && !(sab_u->buf_w[len_w - 1]) ) { + len_w--; + } + + pro = _ca_atom_mint(vat_u, len_w); + } + + u3t_off(mal_o); + + return pro; +} + +/* u3a_slab_moot(); produce atom from slab, no trimming. +*/ +u3_atom +u3a_slab_moot(u3a_slab_new* sab_u) +{ + u3_atom pro; + + u3t_on(mal_o); + + if ( 1 == sab_u->wor_w ) { + c3_w dat_w = *sab_u->buf_w; + + c3_assert( !sab_u->_._vat_u ); + + pro = _ca_atom_one(dat_w); + } + else { + u3a_atom* vat_u = sab_u->_._vat_u; + c3_w len_w = sab_u->wor_w; + + c3_assert( (sab_u->buf_w - c3_wiseof(u3a_atom)) == (c3_w*)vat_u ); + + pro = _ca_atom_mint(vat_u, len_w); + } + + u3t_off(mal_o); + + return pro; +} + /* u3a_slab(): create a length-bounded proto-atom. */ c3_w* From 012991310bb80c25ecf290a52aac3aebf0326055 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 25 Sep 2020 19:21:18 -0700 Subject: [PATCH 387/933] u3: adds u3a_wtrim(), for shrinking word-aligned allocations --- pkg/urbit/include/noun/allocate.h | 5 +++++ pkg/urbit/noun/allocate.c | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/pkg/urbit/include/noun/allocate.h b/pkg/urbit/include/noun/allocate.h index 6eb006e5d2..489413677f 100644 --- a/pkg/urbit/include/noun/allocate.h +++ b/pkg/urbit/include/noun/allocate.h @@ -429,6 +429,11 @@ void u3a_wfree(void* lag_v); + /* u3a_wtrim(): trim storage. + */ + void + u3a_wtrim(void* tox_v, c3_w old_w, c3_w len_w); + /* u3a_wealloc(): word realloc. */ void* diff --git a/pkg/urbit/noun/allocate.c b/pkg/urbit/noun/allocate.c index 57a3d71708..5951b426ef 100644 --- a/pkg/urbit/noun/allocate.c +++ b/pkg/urbit/noun/allocate.c @@ -632,6 +632,28 @@ u3a_wfree(void* tox_v) _box_free(u3a_botox(tox_v)); } +/* u3a_wtrim(): trim storage. +*/ +void +u3a_wtrim(void* tox_v, c3_w old_w, c3_w len_w) +{ + c3_w* nov_w = tox_v; + + if ( (old_w > len_w) + && ((old_w - len_w) >= u3a_minimum) ) + { + c3_w* box_w = (void *)u3a_botox(nov_w); + c3_w* end_w = (nov_w + len_w + 1); + c3_w asz_w = (end_w - box_w); + c3_w bsz_w = box_w[0] - asz_w; + + _box_attach(_box_make(end_w, bsz_w, 0)); + + box_w[0] = asz_w; + box_w[asz_w - 1] = asz_w; + } +} + /* u3a_calloc(): allocate and zero-initialize array */ void* From 52b917ee7176bf8df76204db6d41685ff1e28e34 Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Sat, 26 Sep 2020 15:55:10 -0700 Subject: [PATCH 388/933] king: stateless forwarding --- pkg/hs/urbit-king/lib/Urbit/King/App.hs | 6 +- pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs | 151 ++++++++++++++---- .../lib/Urbit/Vere/Ames/LaneCache.hs | 34 ++++ .../urbit-king/lib/Urbit/Vere/Ames/Packet.hs | 102 ++++++++++++ pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs | 29 ++-- pkg/hs/urbit-king/package.yaml | 3 + .../urbit-noun/lib/Urbit/Noun/Conversions.hs | 23 ++- pkg/hs/urbit-noun/package.yaml | 1 + 8 files changed, 293 insertions(+), 56 deletions(-) create mode 100644 pkg/hs/urbit-king/lib/Urbit/Vere/Ames/LaneCache.hs create mode 100644 pkg/hs/urbit-king/lib/Urbit/Vere/Ames/Packet.hs diff --git a/pkg/hs/urbit-king/lib/Urbit/King/App.hs b/pkg/hs/urbit-king/lib/Urbit/King/App.hs index 107708d16a..6be577a653 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/App.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/App.hs @@ -190,9 +190,9 @@ runHostEnv multi ports action = do king <- ask let hostEnv = HostEnv { _hostEnvKingEnv = king - , _hostEnvMultiEyreApi = multi - , _hostEnvPortControlApi = ports - } + , _hostEnvMultiEyreApi = multi + , _hostEnvPortControlApi = ports + } io (runRIO hostEnv action) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs index 5065cb4ace..b71551e027 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs @@ -9,14 +9,19 @@ import Urbit.Prelude import Network.Socket hiding (recvFrom, sendTo) import Urbit.Arvo hiding (Fake) import Urbit.King.Config +import Urbit.Vere.Ames.LaneCache +import Urbit.Vere.Ames.Packet import Urbit.Vere.Pier.Types import Urbit.Vere.Ports +import Data.Serialize (decode, encode) import Urbit.King.App (HasKingId(..), HasPierEnv(..)) import Urbit.Vere.Ames.DNS (NetworkMode(..), ResolvServ(..)) import Urbit.Vere.Ames.DNS (galaxyPort, resolvServ) import Urbit.Vere.Ames.UDP (UdpServ(..), fakeUdpServ, realUdpServ) +import qualified Urbit.Noun.Time as Time + -- Constants ------------------------------------------------------------------- @@ -33,11 +38,15 @@ packetsDroppedPerComplaint = 1000 -- Types ----------------------------------------------------------------------- +type Version = Word8 + data AmesDrv = AmesDrv { aTurfs :: TVar (Maybe [Turf]) , aDropped :: TVar Word + , aVersion :: TVar (Maybe Version) , aUdpServ :: UdpServ , aResolvr :: ResolvServ + , aVersTid :: Async () , aRecvTid :: Async () } @@ -82,9 +91,10 @@ bornEv inst = EvBlip $ BlipEvNewt $ NewtEvBorn (fromIntegral inst, ()) () hearEv :: PortNumber -> HostAddress -> ByteString -> Ev hearEv p a bs = - EvBlip $ BlipEvAmes $ AmesEvHear () dest (MkBytes bs) - where - dest = EachNo $ Jammed $ AAIpv4 (Ipv4 a) (fromIntegral p) + EvBlip $ BlipEvAmes $ AmesEvHear () (ipDest p a) (MkBytes bs) + +ipDest :: PortNumber -> HostAddress -> AmesDest +ipDest p a = EachNo $ Jammed $ AAIpv4 (Ipv4 a) (fromIntegral p) -------------------------------------------------------------------------------- @@ -125,9 +135,10 @@ ames' :: HasPierEnv e => Ship -> Bool + -> (Time.Wen -> Gang -> Path -> (Maybe (Term, Noun) -> IO ()) -> STM ()) -> (Text -> RIO e ()) -> RIO e ([Ev], RAcquire e (DriverApi NewtEf)) -ames' who isFake stderr = do +ames' who isFake scry stderr = do -- Unfortunately, we cannot use TBQueue because the only behavior -- provided for when full is to block the writer. The implementation -- below uses materially the same data structures as TBQueue, however. @@ -151,7 +162,7 @@ ames' who isFake stderr = do pure pM env <- ask - let (bornEvs, startDriver) = ames env who isFake enqueuePacket stderr + let (bornEvs, startDriver) = ames env who isFake scry enqueuePacket stderr let runDriver = do diOnEffect <- startDriver @@ -178,10 +189,11 @@ ames => e -> Ship -> Bool + -> (Time.Wen -> Gang -> Path -> (Maybe (Term, Noun) -> IO ()) -> STM ()) -> (EvErr -> STM PacketOutcome) -> (Text -> RIO e ()) -> ([Ev], RAcquire e (NewtEf -> IO ())) -ames env who isFake enqueueEv stderr = (initialEvents, runAmes) +ames env who isFake scry enqueueEv stderr = (initialEvents, runAmes) where king = fromIntegral (env ^. kingIdL) @@ -194,36 +206,85 @@ ames env who isFake enqueueEv stderr = (initialEvents, runAmes) drv <- mkRAcquire start stop pure (handleEffect drv mode) - start :: HasLogFunc e => RIO e AmesDrv + start :: RIO e AmesDrv start = do + mode <- rio (netMode isFake) + cache <- laneCache scryLane + aTurfs <- newTVarIO Nothing aDropped <- newTVarIO 0 + aVersion <- newTVarIO Nothing + aVersTid <- trackVersionThread aVersion aUdpServ <- udpServ isFake who - aRecvTid <- queuePacketsThread aDropped aUdpServ aResolvr <- resolvServ aTurfs (usSend aUdpServ) stderr + aRecvTid <- queuePacketsThread + aDropped + aVersion + (byCache cache) + (send aUdpServ aResolvr mode) + aUdpServ + pure (AmesDrv { .. }) hearFailed _ = pure () - queuePacketsThread :: HasLogFunc e => TVar Word -> UdpServ -> RIO e (Async ()) - queuePacketsThread dropCtr UdpServ {..} = async $ forever $ do - outcome <- atomically $ do - (p, a, b) <- usRecv - enqueueEv (EvErr (hearEv p a b) hearFailed) - case outcome of - Intake -> pure () - Ouster -> do - d <- atomically $ do - d <- readTVar dropCtr - writeTVar dropCtr (d + 1) - pure d - when (d `rem` packetsDroppedPerComplaint == 0) $ - logWarn "ames: queue full; dropping inbound packets" + trackVersionThread :: HasLogFunc e => TVar (Maybe Version) -> RIO e (Async ()) + trackVersionThread versSlot = async $ forever do + env <- ask - stop :: AmesDrv -> RIO e () + scryVersion \v -> do + v0 <- readTVarIO versSlot + atomically $ writeTVar versSlot (Just v) + if (v0 == Just v) + then logInfo $ displayShow ("ames: proto version unchanged at", v) + else stderr ("ames: protocol version now " <> tshow v) + + threadDelay (10 * 60 * 1_000_000) -- 10m + + queuePacketsThread :: HasLogFunc e + => TVar Word + -> TVar (Maybe Version) + -> (Ship -> (Maybe [AmesDest] -> RIO e ()) -> RIO e ()) + -> (AmesDest -> ByteString -> RIO e ()) + -> UdpServ + -> RIO e (Async ()) + queuePacketsThread dropCtr vers lan forward UdpServ{..} = async $ forever $ do + -- port number, host address, bytestring + (p, a, b) <- atomically usRecv + ver <- readTVarIO vers + + case decode b of + Right (pkt@Packet {..}) | ver == Nothing || ver == Just pktVersion -> do + logDebug $ displayShow ("ames: bon packet", pkt, showUD $ bytesAtom b) + + if pktRcvr == who + then serf'sUp p a b + else lan pktRcvr $ \case + Just (dest:_) -> forward dest $ encode pkt + { pktOrigin = pktOrigin <|> Just (ipDest p a) } + _ -> logInfo $ displayShow ("ames: dropping unroutable", pkt) + + Right pkt -> logInfo $ displayShow ("ames: dropping ill-versed", pkt, ver) + + Left e -> logInfo $ displayShow ("ames: dropping malformed", e) + + where + serf'sUp p a b = + atomically (enqueueEv (EvErr (hearEv p a b) hearFailed)) >>= \case + Intake -> pure () + Ouster -> do + d <- atomically $ do + d <- readTVar dropCtr + writeTVar dropCtr (d + 1) + pure d + when (d `rem` packetsDroppedPerComplaint == 0) $ + logWarn "ames: queue full; dropping inbound packets" + + stop :: forall e. AmesDrv -> RIO e () stop AmesDrv {..} = io $ do usKill aUdpServ rsKill aResolvr + cancel aVersTid cancel aRecvTid handleEffect :: AmesDrv -> NetworkMode -> NewtEf -> IO () @@ -234,19 +295,53 @@ ames env who isFake enqueueEv stderr = (initialEvents, runAmes) NewtEfSend (_id, ()) dest (MkBytes bs) -> do atomically (readTVar aTurfs) >>= \case Nothing -> stderr "ames: send before turfs" >> pure () - Just turfs -> sendPacket drv mode dest bs + Just turfs -> send aUdpServ aResolvr mode dest bs - sendPacket :: AmesDrv -> NetworkMode -> AmesDest -> ByteString -> RIO e () - sendPacket AmesDrv {..} mode dest byt = do - let to adr = io (usSend aUdpServ adr byt) + send :: UdpServ + -> ResolvServ + -> NetworkMode + -> AmesDest + -> ByteString + -> RIO e () + send udpServ resolvr mode dest byt = do + let to adr = io (usSend udpServ adr byt) case (mode, dest) of (NoNetwork, _ ) -> pure () (Fake , _ ) -> when (okFakeAddr dest) $ to (localAddr Fake dest) (Localhost, _ ) -> to (localAddr Localhost dest) (Real , ra) -> ra & \case - EachYes gala -> io (rsSend aResolvr gala byt) + EachYes gala -> io (rsSend resolvr gala byt) EachNo addr -> to (ipv4Addr addr) + scryVersion :: HasLogFunc e => (Version -> RIO e ()) -> RIO e () + scryVersion = scry' ["protocol", "version"] + . maybe (logError "ames: could not scry for version") + + scryLane :: HasLogFunc e + => Ship + -> (Maybe [AmesDest] -> RIO e ()) + -> RIO e () + scryLane ship = scry' ["peers", MkKnot $ tshow ship, "forward-lane"] + + scry' :: forall e n + . (HasLogFunc e, FromNoun n) + => [Knot] + -> (Maybe n -> RIO e ()) + -> RIO e () + scry' p k = do + env <- ask + wen <- io Time.now + let nkt = MkKnot $ tshow $ Time.MkDate wen + let pax = Path $ "ax" : MkKnot (tshow who) : "" : nkt : p + putStrLn ("scrying for " <> tshow pax) + let kon = runRIO env . \case + Just (_, fromNoun @n -> Just v) -> k (Just v) + Just (_, n) -> do + logError $ displayShow ("ames: uncanny scry result", pax, n) + k Nothing + Nothing -> k Nothing + atomically $ scry wen Nothing pax kon + ipv4Addr (Jammed (AAVoid v )) = absurd v ipv4Addr (Jammed (AAIpv4 a p)) = SockAddrInet (fromIntegral p) (unIpv4 a) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/LaneCache.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/LaneCache.hs new file mode 100644 index 0000000000..8c8e235c4c --- /dev/null +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/LaneCache.hs @@ -0,0 +1,34 @@ +module Urbit.Vere.Ames.LaneCache (LaneCache, laneCache, byCache) where + +import Urbit.Prelude + +import Urbit.Noun.Time + +expiry :: Gap +expiry = (2 * 60) ^. from secs + +data LaneCache m a b = LaneCache + { lcCache :: TVar (Map a (Wen, b)) + , lcAction :: a -> (b -> m ()) -> m () + } + +laneCache :: (Ord a, MonadIO n) + => (a -> (b -> m ()) -> m ()) + -> n (LaneCache m a b) +laneCache act = LaneCache <$> newTVarIO mempty <*> pure act + +byCache :: (Ord a, MonadIO m) + => LaneCache m a b + -> a -> (b -> m ()) -> m () +byCache LaneCache {..} x f = lookup x <$> readTVarIO lcCache >>= \case + Nothing -> go + Just (t, v) -> do + t' <- io now + if gap t' t > expiry + then go + else f v + where + go = lcAction x $ \v -> do + t <- io now + atomically $ modifyTVar' lcCache (insertMap x (t, v)) + f v diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/Packet.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/Packet.hs new file mode 100644 index 0000000000..9566e10599 --- /dev/null +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/Packet.hs @@ -0,0 +1,102 @@ +{-| + Parsing of Ames packets +-} + +module Urbit.Vere.Ames.Packet where + +import Urbit.Prelude + +import Data.Bits +import Data.LargeWord +import Data.Serialize + +import Urbit.Arvo (AmesDest) +import Urbit.Noun.Tree (mug) + +data Packet = Packet + { pktVersion :: Word8 + , pktEncrypted :: Bool + -- + , pktSndr :: Ship + , pktRcvr :: Ship + , pktOrigin :: Maybe AmesDest + , pktContent :: Bytes + } + +instance Show Packet where + show Packet {..} + = "Packet {pktVersion = " + <> show pktVersion + <> ", pktEncrypted = " + <> show pktEncrypted + <> ", pktSndr = " + <> show pktSndr + <> ", pktRcvr = " + <> show pktRcvr + <> ", pktOrigin = " + <> show pktOrigin + <> ", pktContent = " + <> showUD (bytesAtom $ unBytes pktContent) + <> "}" + +instance Serialize Packet where + get = do + -- header + head <- getWord32le + let pktVersion = head .&. 0b111 & fromIntegral + let checksum = shiftR head 3 .&. (2 ^ 20 - 1) + let sndrRank = shiftR head 23 .&. 0b11 + let rcvrRank = shiftR head 25 .&. 0b11 + let pktEncrypted = testBit head 27 & not -- loobean + -- verify checksum + lookAhead $ do + len <- remaining + body <- getBytes len + -- XX mug (marked "TODO") is implemented as "slowMug" in U.N.Tree. Ominous + -- Also, toNoun will copy the bytes into an atom. We probably want a mugBS + let chk = fromIntegral (mug $ toNoun $ MkBytes body) .&. (2 ^ 20 - 1) + when (checksum /= chk) $ + fail ("checksum mismatch: expected " <> show checksum + <> "; got " <> show chk) + -- body + pktSndr <- getShip sndrRank + pktRcvr <- getShip rcvrRank + len <- remaining + payload <- getBytes len + -- data ("payload") + (pktOrigin, pktContent) <- case cueBS payload of + Left e -> fail (show e) + Right n -> case fromNounErr n of + Left e -> fail (show e) + Right c -> pure c + pure Packet {..} + where + getShip = fmap Ship . \case + 0 -> fromIntegral <$> getWord16le -- galaxy / star + 1 -> fromIntegral <$> getWord32le -- planet + 2 -> fromIntegral <$> getWord64le -- moon + 3 -> LargeKey <$> getWord64le <*> getWord64le -- comet + _ -> fail "impossibiru" + + put Packet {..} = do + let load = jamBS $ toNoun (pktOrigin, pktContent) + let (sndR, putSndr) = putShipGetRank pktSndr + let (rcvR, putRcvr) = putShipGetRank pktRcvr + let body = runPut (putSndr <> putRcvr <> putByteString load) + -- XX again maybe mug can be made better here + let chek = fromIntegral (mug $ toNoun $ MkBytes body) .&. (2 ^ 20 - 1) + let encr = pktEncrypted + let vers = fromIntegral pktVersion .&. 0b111 + let head = vers + .|. shiftL chek 3 + .|. shiftL sndR 23 + .|. shiftL rcvR 25 + .|. if encr then 0 else bit 27 + putWord32le head + putByteString body -- XX can we avoid copy? + where + putShipGetRank s@(Ship (LargeKey p q)) = case () of + _ | s < 2 ^ 16 -> (0, putWord16le $ fromIntegral s) -- gar + | s < 2 ^ 32 -> (1, putWord32le $ fromIntegral s) -- pan + | s < 2 ^ 64 -> (2, putWord64le $ fromIntegral s) -- mon + | otherwise -> (3, putWord64le p >> putWord64le q) -- com diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs index 82da7d0df9..997e37ce26 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs @@ -305,6 +305,9 @@ pier (serf, log) vSlog startedSig = do atomically $ Term.trace muxed txt logOther "serf" (display $ T.strip txt) + scrySig <- newEmptyTMVarIO + onKill <- view onKillPierSigL + -- Our call above to set the logging function which echos errors from the -- Serf doesn't have the appended \r\n because those \r\n s are added in -- the c serf code. Logging output from our haskell process must manually @@ -312,6 +315,7 @@ pier (serf, log) vSlog startedSig = do let compute = putTMVar computeQ let execute = writeTQueue executeQ let persist = writeTQueue persistQ + let scry = \w b g k -> putTMVar scrySig (w, b, g, k) let sigint = Serf.sendSIGINT serf (bootEvents, startDrivers) <- do @@ -319,10 +323,7 @@ pier (serf, log) vSlog startedSig = do let err = atomically . Term.trace muxed . (<> "\r\n") let siz = TermSize { tsWide = 80, tsTall = 24 } let fak = isFake logId - drivers env ship fak compute (siz, muxed) err sigint - - scrySig <- newEmptyTMVarIO - onKill <- view onKillPierSigL + drivers env ship fak compute scry (siz, muxed) err sigint let computeConfig = ComputeConfig { ccOnWork = takeTMVar computeQ , ccOnKill = onKill @@ -369,19 +370,6 @@ pier (serf, log) vSlog startedSig = do threadDelay (snapshotEverySecs * 1_000_000) void $ atomically $ tryPutTMVar saveSig () - -- TODO bullshit scry tester - when False $ do - void $ acquireWorker "bullshit scry tester" $ do - env <- ask - forever $ do - threadDelay 15_000_000 - wen <- io Time.now - let kal = \mTermNoun -> runRIO env $ do - logInfo $ displayShow ("scry result: ", mTermNoun) - let nkt = MkKnot $ tshow $ Time.MkDate wen - let pax = Path ["j", "~zod", "life", nkt, "~zod"] - atomically $ putTMVar scrySig (wen, Nothing, pax, kal) - putMVar startedSig () -- Wait for something to die. @@ -423,18 +411,21 @@ drivers -> Ship -> Bool -> (RunReq -> STM ()) + -> (Wen -> Gang -> Path -> (Maybe (Term, Noun) -> IO ()) -> STM ()) -> (TermSize, Term.Client) -> (Text -> RIO e ()) -> IO () -> RAcquire e ([Ev], RAcquire e Drivers) -drivers env who isFake plan termSys stderr serfSIGINT = do +drivers env who isFake plan scry termSys stderr serfSIGINT = do (behnBorn, runBehn) <- rio Behn.behn' (termBorn, runTerm) <- rio (Term.term' termSys serfSIGINT) - (amesBorn, runAmes) <- rio (Ames.ames' who isFake stderr) + (amesBorn, runAmes) <- rio (Ames.ames' who isFake scry stderr) (httpBorn, runEyre) <- rio (Eyre.eyre' who isFake stderr) (clayBorn, runClay) <- rio Clay.clay' (irisBorn, runIris) <- rio Iris.client' + putStrLn ("ship is " <> tshow who) + let initialEvents = mconcat [behnBorn,clayBorn,amesBorn,httpBorn,irisBorn,termBorn] let runDrivers = do diff --git a/pkg/hs/urbit-king/package.yaml b/pkg/hs/urbit-king/package.yaml index 583cd6b6cd..e309fd73cf 100644 --- a/pkg/hs/urbit-king/package.yaml +++ b/pkg/hs/urbit-king/package.yaml @@ -31,6 +31,7 @@ dependencies: - binary - bytestring - case-insensitive + - cereal - classy-prelude - conduit - containers @@ -119,6 +120,7 @@ dependencies: default-extensions: - ApplicativeDo - BangPatterns + - BinaryLiterals - BlockArguments - ConstraintKinds - DataKinds @@ -145,6 +147,7 @@ default-extensions: - OverloadedStrings - PackageImports - PartialTypeSignatures + - PatternGuards - PatternSynonyms - QuasiQuotes - Rank2Types diff --git a/pkg/hs/urbit-noun/lib/Urbit/Noun/Conversions.hs b/pkg/hs/urbit-noun/lib/Urbit/Noun/Conversions.hs index 6a8b5fddfe..d1f1f94dac 100644 --- a/pkg/hs/urbit-noun/lib/Urbit/Noun/Conversions.hs +++ b/pkg/hs/urbit-noun/lib/Urbit/Noun/Conversions.hs @@ -12,6 +12,7 @@ module Urbit.Noun.Conversions , UD(..), UV(..), UW(..), cordToUW , Mug(..), Path(..), EvilPath(..), Ship(..) , Lenient(..), pathToFilePath, filePathToPath + , showUD, tshowUD ) where import ClassyPrelude hiding (hash) @@ -36,6 +37,7 @@ import RIO.FilePath (joinPath, splitDirectories, takeBaseName, takeDirectory, takeExtension, (<.>)) import Urbit.Noun.Cue (cue) import Urbit.Noun.Jam (jam) +import Urbit.Ob (patp) import qualified Data.Char as C import qualified Data.Text.Encoding as T @@ -97,22 +99,28 @@ instance FromNoun UD where Nothing -> fail ("invalid decimal atom: " <> unpack (filter (/= '.') t)) Just vl -> pure (UD vl) +showUD :: (Show i, Integral i) => i -> String +showUD = uTypeAddDots 3 . show + +tshowUD :: (Show i, Integral i) => i -> Text +tshowUD = pack . uTypeAddDots 3 . show + -------------------------------------------------------------------------------- -uTypeAddDots :: String -> String -uTypeAddDots = reverse . go . reverse +uTypeAddDots :: Int -> String -> String +uTypeAddDots n = reverse . go . reverse where go s = if null tel then hed else hed <> "." <> go tel where - hed = take 5 s - tel = drop 5 s + hed = take n s + tel = drop n s convertToU :: [Char] -> [Char] -> Atom -> String convertToU baseMap prefix = go [] where - go acc 0 = "0" <> prefix <> uTypeAddDots acc + go acc 0 = "0" <> prefix <> uTypeAddDots 5 acc go acc n = go (char n : acc) (n `div` len) char n = baseMap !! (fromIntegral (n `mod` len)) @@ -571,7 +579,10 @@ instance FromNoun Term where -- XX TODO -- Ship ------------------------------------------------------------------------ newtype Ship = Ship Word128 -- @p - deriving newtype (Eq, Ord, Show, Enum, Real, Integral, Num, ToNoun, FromNoun) + deriving newtype (Eq, Ord, Enum, Real, Integral, Num, ToNoun, FromNoun) + +instance Show Ship where + show = show . patp . fromIntegral -- Path ------------------------------------------------------------------------ diff --git a/pkg/hs/urbit-noun/package.yaml b/pkg/hs/urbit-noun/package.yaml index d94be31f67..74dfe2dddb 100644 --- a/pkg/hs/urbit-noun/package.yaml +++ b/pkg/hs/urbit-noun/package.yaml @@ -25,6 +25,7 @@ dependencies: - text - time - urbit-atom + - urbit-hob - urbit-noun-core default-extensions: From dd18bf6f0f5aa229b97a6d54700278a1743c0b59 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 28 Sep 2020 10:56:51 -0400 Subject: [PATCH 389/933] king: review comments --- pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs | 3 +-- pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs index 86dbb8934f..6e920685c4 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs @@ -126,7 +126,7 @@ runSerf vSlog pax = do { scSerf = env ^. pierConfigL . pcSerfExe . to (maybe serfProg unpack) , scPier = pax , scFlag = env ^. pierConfigL . pcSerfFlags - , scSlog = slog -- printTank slog pri tank + , scSlog = slog , scStdr = \txt -> slog (0, (textToTank txt)) , scDead = pure () -- TODO: What can be done? } @@ -353,7 +353,6 @@ pier (serf, log) vSlog startedSig = do let slog :: Text -> IO () slog txt = do - -- TODO: What is this and is it right? fn <- atomically (readTVar vSlog) fn (0, textToTank txt) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs index a26f9abb0d..61554dbf04 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs @@ -282,8 +282,8 @@ localClient doneSignal = fst <$> mkRAcquire start stop putStr "\r" T.clearLine TermSize width _ <- atomically $ readTVar termSizeVar - -- TODO: Ignoring priority for now. - putStr (tshow width <> "\r\n") + -- TODO: Ignoring priority for now. Priority changes the color of, + -- and adds a prefix of '>' to, the output. let lines = fmap unTape $ wash (WashCfg 0 width) $ tankTree $ snd slog forM lines $ \line -> putStr (line <> "\r\n") termRefreshLine ls From c01134bf10b7f34c6ce6e4c92090d36fde1a4023 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 25 Sep 2020 19:21:53 -0700 Subject: [PATCH 390/933] u3: moves slab atom-builder to "imprison" module, refactors --- pkg/urbit/include/noun/allocate.h | 59 ------ pkg/urbit/include/noun/imprison.h | 65 +++++++ pkg/urbit/noun/allocate.c | 298 ----------------------------- pkg/urbit/noun/imprison.c | 301 ++++++++++++++++++++++++++++++ 4 files changed, 366 insertions(+), 357 deletions(-) diff --git a/pkg/urbit/include/noun/allocate.h b/pkg/urbit/include/noun/allocate.h index 489413677f..1b6f71bc54 100644 --- a/pkg/urbit/include/noun/allocate.h +++ b/pkg/urbit/include/noun/allocate.h @@ -179,21 +179,6 @@ #endif } u3a_pile; - /* u3a_slab_new: atom builder. - */ - typedef struct _u3a_slab_new { - struct { // internals - u3a_atom* _vat_u; // heap atom (nullable) - c3_w _sat_w; // static storage - } _; // - union { // - c3_y* buf_y; // bytes - c3_w* buf_w; // words - }; // - c3_d byt_d; // byte len - c3_w wor_w; // word len - } u3a_slab_new; - /** Macros. Should be better commented. **/ /* In and out of the box. @@ -665,50 +650,6 @@ /* Atoms from proto-atoms. */ - /* u3a_slab_init(); configure and initialize a slab of bloq-length. - */ - void - u3a_slab_init(u3a_slab_new* sab_u, c3_g met_g, c3_w len_w); - - /* u3a_slab_bare(); configure a slab of bloq-length, with uninitialized memory. - */ - void - u3a_slab_bare(u3a_slab_new* sab_u, c3_g met_g, c3_w len_w); - - /* u3a_slab_grow(); resize a slab, reallocating as necessary - */ - void - u3a_slab_grow(u3a_slab_new* sab_u, c3_g met_g, c3_w len_w); - - /* u3a_slab_free(); dispose of a slab. - */ - void - u3a_slab_free(u3a_slab_new* sab_u); - - // XX assumes little-endian - // - #define u3a_slab_moot_bytes u3a_slab_moot - - /* u3a_slab_mint(); produce atom from slab, trimming. - */ - u3_atom - u3a_slab_mint(u3a_slab_new* sab_u); - - /* u3a_slab_moot(); produce atom from slab, no trimming. - */ - u3_atom - u3a_slab_moot(u3a_slab_new* sab_u); - - /* u3a_slab_mint_bytes(); produce atom from byte-slab, trimming. - ** XX assumes little-endian, implement swap to support big-endian - */ -# define u3a_slab_mint_bytes u3a_slab_mint - - /* u3a_slab_moot_bytes(); produce atom from byte-slab, no trimming. - ** XX assumes little-endian, implement swap to support big-endian - */ -# define u3a_slab_moot_bytes u3a_slab_moot - /* u3a_slab(): create a length-bounded proto-atom. */ c3_w* diff --git a/pkg/urbit/include/noun/imprison.h b/pkg/urbit/include/noun/imprison.h index 714bf15c6c..d15adae461 100644 --- a/pkg/urbit/include/noun/imprison.h +++ b/pkg/urbit/include/noun/imprison.h @@ -2,8 +2,73 @@ ** ** This file is in the public domain. */ + + /** Structures. + **/ + /* u3i_slab: atom builder. + */ + typedef struct _u3i_slab { + struct { // internals + u3a_atom* _vat_u; // heap atom (nullable) + c3_w _sat_w; // static storage + } _; // + union { // + c3_y* buf_y; // bytes + c3_w* buf_w; // words + }; // + c3_d byt_d; // byte len + c3_w wor_w; // word len + } u3i_slab; + + /* staged atom-building api + */ + /* u3i_slab_init(): configure bloq-length slab, zero-initialize. + */ + void + u3i_slab_init(u3i_slab* sab_u, c3_g met_g, c3_w len_w); + + /* u3i_slab_bare(): configure bloq-length slab, uninitialized. + */ + void + u3i_slab_bare(u3i_slab* sab_u, c3_g met_g, c3_w len_w); + + /* u3i_slab_grow(): resize slab, reallocating as necessary. + */ + void + u3i_slab_grow(u3i_slab* sab_u, c3_g met_g, c3_w len_w); + + /* u3i_slab_free(): dispose memory backing slab. + */ + void + u3i_slab_free(u3i_slab* sab_u); + + /* u3i_slab_mint(): produce atom from slab, trimming. + */ + u3_atom + u3i_slab_mint(u3i_slab* sab_u); + + /* u3i_slab_moot(): produce atom from slab, no trimming. + */ + u3_atom + u3i_slab_moot(u3i_slab* sab_u); + + /* u3i_slab_mint_bytes(): produce atom from byte-slab, trimming. + ** XX assumes little-endian, implement swap to support big-endian + */ +# define u3i_slab_mint_bytes u3i_slab_mint + + /* u3i_slab_moot_bytes(): produce atom from byte-slab, no trimming. + ** XX assumes little-endian, implement swap to support big-endian + */ +# define u3i_slab_moot_bytes u3i_slab_moot + /* General constructors. */ + /* u3i_word(): construct u3_atom from c3_w. + */ + u3_atom + u3i_word(c3_w dat_w); + /* u3i_bytes(): Copy [a] bytes from [b] to an LSB first atom. */ u3_noun diff --git a/pkg/urbit/noun/allocate.c b/pkg/urbit/noun/allocate.c index 5951b426ef..9749152368 100644 --- a/pkg/urbit/noun/allocate.c +++ b/pkg/urbit/noun/allocate.c @@ -2479,304 +2479,6 @@ u3a_rewrite_noun(u3_noun som) cel->tel = u3a_rewritten_noun(cel->tel); } -/* _ca_slab_size(): calculate slab bloq-size, checking for overflow. -*/ -static c3_w -_ca_slab_size(c3_g met_g, c3_w len_w, c3_d* out_d) -{ - c3_d bit_d = (c3_d)len_w << met_g; - c3_d byt_d = (bit_d + 0x7) >> 3; - c3_d wor_d = (byt_d + 0x3) >> 2; - c3_w wor_w = (c3_d)wor_d; - - if ( (wor_w != wor_d) - || (len_w != (bit_d >> met_g)) ) - { - return u3m_bail(c3__fail); - } - else { - *out_d = byt_d; - return wor_w; - } -} - -/* _ca_slab_init(): initialize slab with heap allocation. -** NB: [len_w] must be >0 -*/ -static void -_ca_slab_init(u3a_slab_new* sab_u, c3_w len_w) -{ - c3_w* nov_w = u3a_walloc(len_w + c3_wiseof(u3a_atom)); - u3a_atom* vat_u = (void *)nov_w; - - vat_u->mug_w = 0; - vat_u->len_w = len_w; - - sab_u->_._vat_u = vat_u; - sab_u->buf_w = vat_u->buf_w; - sab_u->wor_w = len_w; -} - -/* _ca_slab_grow(): update slab with heap reallocation. -*/ -static void -_ca_slab_grow(u3a_slab_new* sab_u, c3_w len_w) -{ - c3_w* old_w = (void*)sab_u->_._vat_u; - // XX implement a more efficient u3a_wealloc() - // - c3_w* nov_w = u3a_wealloc(old_w, len_w); - u3a_atom* vat_u = (void *)nov_w; - - vat_u->len_w = len_w; - - sab_u->_._vat_u = vat_u; - sab_u->buf_w = vat_u->buf_w; - sab_u->wor_w = len_w; -} - -/* _ca_atom_one(): c3_w -> u3_atom, ie, u3i_word() -*/ -static u3_atom -_ca_atom_one(c3_w dat_w) -{ - if ( c3y == u3a_is_cat(dat_w) ) { - return (u3_atom)dat_w; - } - else { - c3_w* nov_w = u3a_walloc(1 + c3_wiseof(u3a_atom)); - u3a_atom* vat_u = (void *)nov_w; - - vat_u->mug_w = 0; - vat_u->len_w = 1; - vat_u->buf_w[0] = dat_w; - - return u3a_to_pug(u3a_outa(nov_w)); - } -} - -/* _ca_atom_mint(): finalize a heap-allocated atom at specified length. -*/ -static u3_atom -_ca_atom_mint(u3a_atom* vat_u, c3_w len_w) -{ - c3_w* nov_w = (void*)vat_u; - - if ( 0 == len_w ) { - u3a_wfree(nov_w); - return (u3_atom)0; - } - else if ( 1 == len_w ) { - c3_w dat_w = *vat_u->buf_w; - - if ( c3y == u3a_is_cat(dat_w) ) { - u3a_wfree(nov_w); - return (u3_atom)dat_w; - } - } - - // try to strip a block off the end - // - { - c3_w old_w = vat_u->len_w; - c3_w dif_w = old_w - len_w; - - if ( dif_w >= u3a_minimum ) { - c3_w* box_w = (void *)u3a_botox(nov_w); - c3_w* end_w = (nov_w + c3_wiseof(u3a_atom) + len_w + 1); - c3_w asz_w = (end_w - box_w); - c3_w bsz_w = box_w[0] - asz_w; - - _box_attach(_box_make(end_w, bsz_w, 0)); - - box_w[0] = asz_w; - box_w[asz_w - 1] = asz_w; - } - } - - vat_u->len_w = len_w; - - return u3a_to_pug(u3a_outa(nov_w)); -} - -/* u3a_slab_init(); configure and initialize a slab of bloq-length. -*/ -void -u3a_slab_init(u3a_slab_new* sab_u, c3_g met_g, c3_w len_w) -{ - u3t_on(mal_o); - { - c3_d byt_d; - c3_w wor_w = _ca_slab_size(met_g, len_w, &byt_d); - - // if we only need one word, use the static storage in [sab_u] - // - if ( 1 == wor_w ) { - sab_u->_._vat_u = 0; - sab_u->buf_w = &sab_u->_._sat_w; - sab_u->wor_w = 1; - sab_u->byt_d = byt_d; - } - // allocate an indirect atom - // - else { - _ca_slab_init(sab_u, wor_w); - sab_u->byt_d = byt_d; - } - - // XX refactor - // - memset(sab_u->buf_y, 0, (size_t)wor_w * 4); - } - u3t_off(mal_o); -} - -/* u3a_slab_bare(); configure a slab of bloq-length, with uninitialized memory. -*/ -void -u3a_slab_bare(u3a_slab_new* sab_u, c3_g met_g, c3_w len_w) -{ - u3t_on(mal_o); - { - c3_d byt_d; - c3_w wor_w = _ca_slab_size(met_g, len_w, &byt_d); - - // if we only need one word, use the static storage in [sab_u] - // - if ( 1 == wor_w ) { - sab_u->_._vat_u = 0; - sab_u->buf_w = &sab_u->_._sat_w; - sab_u->wor_w = 1; - sab_u->byt_d = byt_d; - } - // allocate an indirect atom - // - else { - _ca_slab_init(sab_u, wor_w); - sab_u->byt_d = byt_d; - } - } - u3t_off(mal_o); -} - -/* u3a_slab_grow(); resize a slab, reallocating as necessary -*/ -void -u3a_slab_grow(u3a_slab_new* sab_u, c3_g met_g, c3_w len_w) -{ - u3t_on(mal_o); - { - c3_d byt_d; - c3_w wor_w = _ca_slab_size(met_g, len_w, &byt_d); - - // XX actually shrink? - // - if ( wor_w <= sab_u->wor_w ) { - sab_u->wor_w = wor_w; - sab_u->byt_d = byt_d; - } - // upgrade from static storage - // - else if ( 1 == sab_u->wor_w ) { - c3_w dat_w = *sab_u->buf_w; - - _ca_slab_init(sab_u, wor_w); - sab_u->buf_w[0] = dat_w; - sab_u->byt_d = byt_d; - } - // reallocate - // - else { - _ca_slab_grow(sab_u, wor_w); - sab_u->byt_d = byt_d; - } - } - u3t_off(mal_o); -} - -/* u3a_slab_free(); dispose of a slab. -*/ -void -u3a_slab_free(u3a_slab_new* sab_u) -{ - u3t_on(mal_o); - if ( 1 == sab_u->wor_w ) { - c3_assert( !sab_u->_._vat_u ); - } - else { - u3a_atom* vat_u = sab_u->_._vat_u; - - c3_assert( (sab_u->buf_w - c3_wiseof(u3a_atom)) == (c3_w*)vat_u ); - - u3a_wfree(vat_u); - } - u3t_off(mal_o); -} - -/* u3a_slab_mint(); produce atom from slab, trimming. -*/ -u3_atom -u3a_slab_mint(u3a_slab_new* sab_u) -{ - u3_atom pro; - - u3t_on(mal_o); - - if ( 1 == sab_u->wor_w ) { - c3_w dat_w = *sab_u->buf_w; - - c3_assert( !sab_u->_._vat_u ); - - pro = _ca_atom_one(dat_w); - } - else { - u3a_atom* vat_u = sab_u->_._vat_u; - c3_w len_w = sab_u->wor_w; - - c3_assert( (sab_u->buf_w - c3_wiseof(u3a_atom)) == (c3_w*)vat_u ); - - while ( len_w && !(sab_u->buf_w[len_w - 1]) ) { - len_w--; - } - - pro = _ca_atom_mint(vat_u, len_w); - } - - u3t_off(mal_o); - - return pro; -} - -/* u3a_slab_moot(); produce atom from slab, no trimming. -*/ -u3_atom -u3a_slab_moot(u3a_slab_new* sab_u) -{ - u3_atom pro; - - u3t_on(mal_o); - - if ( 1 == sab_u->wor_w ) { - c3_w dat_w = *sab_u->buf_w; - - c3_assert( !sab_u->_._vat_u ); - - pro = _ca_atom_one(dat_w); - } - else { - u3a_atom* vat_u = sab_u->_._vat_u; - c3_w len_w = sab_u->wor_w; - - c3_assert( (sab_u->buf_w - c3_wiseof(u3a_atom)) == (c3_w*)vat_u ); - - pro = _ca_atom_mint(vat_u, len_w); - } - - u3t_off(mal_o); - - return pro; -} - /* u3a_slab(): create a length-bounded proto-atom. */ c3_w* diff --git a/pkg/urbit/noun/imprison.c b/pkg/urbit/noun/imprison.c index c4c81b952a..928d57901d 100644 --- a/pkg/urbit/noun/imprison.c +++ b/pkg/urbit/noun/imprison.c @@ -3,6 +3,307 @@ */ #include "all.h" +/* _ci_slab_size(): calculate slab bloq-size, checking for overflow. +*/ +static c3_w +_ci_slab_size(c3_g met_g, c3_w len_w, c3_d* out_d) +{ + c3_d bit_d = (c3_d)len_w << met_g; + c3_d byt_d = (bit_d + 0x7) >> 3; + c3_d wor_d = (byt_d + 0x3) >> 2; + c3_w wor_w = (c3_d)wor_d; + + if ( (wor_w != wor_d) + || (len_w != (bit_d >> met_g)) ) + { + return (c3_w)u3m_bail(c3__fail); + } + else { + *out_d = byt_d; + return wor_w; + } +} + +/* _ci_slab_init(): initialize slab with heap allocation. +** NB: [len_w] must be >0 +*/ +static void +_ci_slab_init(u3i_slab* sab_u, c3_w len_w) +{ + c3_w* nov_w = u3a_walloc(len_w + c3_wiseof(u3a_atom)); + u3a_atom* vat_u = (void *)nov_w; + + vat_u->mug_w = 0; + vat_u->len_w = len_w; + + sab_u->_._vat_u = vat_u; + sab_u->buf_w = vat_u->buf_w; + sab_u->wor_w = len_w; +} + +/* _ci_slab_grow(): update slab with heap reallocation. +*/ +static void +_ci_slab_grow(u3i_slab* sab_u, c3_w len_w) +{ + c3_w* old_w = (void*)sab_u->_._vat_u; + // XX implement a more efficient u3a_wealloc() + // + c3_w* nov_w = u3a_wealloc(old_w, len_w); + u3a_atom* vat_u = (void *)nov_w; + + vat_u->len_w = len_w; + + sab_u->_._vat_u = vat_u; + sab_u->buf_w = vat_u->buf_w; + sab_u->wor_w = len_w; +} + +/* _ci_atom_mint(): finalize a heap-allocated atom at specified length. +*/ +static u3_atom +_ci_atom_mint(u3a_atom* vat_u, c3_w len_w) +{ + c3_w* nov_w = (void*)vat_u; + + if ( 0 == len_w ) { + u3a_wfree(nov_w); + return (u3_atom)0; + } + else if ( 1 == len_w ) { + c3_w dat_w = *vat_u->buf_w; + + if ( c3y == u3a_is_cat(dat_w) ) { + u3a_wfree(nov_w); + return (u3_atom)dat_w; + } + } + + // try to strip a block off the end + // + { + c3_w old_w = vat_u->len_w; + + if ( old_w > len_w ) { + c3_y wiz_y = c3_wiseof(u3a_atom); + u3a_wtrim(nov_w, old_w + wiz_y, len_w + wiz_y); + } + } + + vat_u->len_w = len_w; + + return u3a_to_pug(u3a_outa(nov_w)); +} + +/* u3i_slab_init(): configure bloq-length slab, zero-initialize. +*/ +void +u3i_slab_init(u3i_slab* sab_u, c3_g met_g, c3_w len_w) +{ + u3t_on(mal_o); + { + c3_d byt_d; + c3_w wor_w = _ci_slab_size(met_g, len_w, &byt_d); + + // if we only need one word, use the static storage in [sab_u] + // + if ( 1 == wor_w ) { + sab_u->_._vat_u = 0; + sab_u->buf_w = &sab_u->_._sat_w; + sab_u->wor_w = 1; + } + // allocate an indirect atom + // + else { + _ci_slab_init(sab_u, wor_w); + } + + sab_u->byt_d = byt_d; + + // XX refactor + // + memset(sab_u->buf_y, 0, (size_t)wor_w * 4); + } + u3t_off(mal_o); +} + +/* u3i_slab_bare(): configure bloq-length slab, uninitialized. +*/ +void +u3i_slab_bare(u3i_slab* sab_u, c3_g met_g, c3_w len_w) +{ + u3t_on(mal_o); + { + c3_d byt_d; + c3_w wor_w = _ci_slab_size(met_g, len_w, &byt_d); + + // if we only need one word, use the static storage in [sab_u] + // + if ( 1 == wor_w ) { + sab_u->_._vat_u = 0; + sab_u->buf_w = &sab_u->_._sat_w; + sab_u->wor_w = 1; + } + // allocate an indirect atom + // + else { + _ci_slab_init(sab_u, wor_w); + } + + sab_u->byt_d = byt_d; + } + u3t_off(mal_o); +} + +/* u3i_slab_grow(): resize slab, reallocating as necessary. +*/ +void +u3i_slab_grow(u3i_slab* sab_u, c3_g met_g, c3_w len_w) +{ + u3t_on(mal_o); + { + c3_d byt_d; + c3_w wor_w = _ci_slab_size(met_g, len_w, &byt_d); + + // XX actually shrink? + // + if ( wor_w <= sab_u->wor_w ) { + sab_u->wor_w = wor_w; + } + // upgrade from static storage + // + else if ( 1 == sab_u->wor_w ) { + c3_w dat_w = *sab_u->buf_w; + + _ci_slab_init(sab_u, wor_w); + sab_u->buf_w[0] = dat_w; + } + // reallocate + // + else { + _ci_slab_grow(sab_u, wor_w); + } + + sab_u->byt_d = byt_d; + } + u3t_off(mal_o); +} + +/* u3i_slab_free(): dispose memory backing slab. +*/ +void +u3i_slab_free(u3i_slab* sab_u) +{ + u3t_on(mal_o); + if ( 1 == sab_u->wor_w ) { + c3_assert( !sab_u->_._vat_u ); + } + else { + u3a_atom* vat_u = sab_u->_._vat_u; + + c3_assert( (sab_u->buf_w - c3_wiseof(u3a_atom)) == (c3_w*)vat_u ); + + u3a_wfree(vat_u); + } + u3t_off(mal_o); +} + +/* u3i_slab_mint(): produce atom from slab, trimming. +*/ +u3_atom +u3i_slab_mint(u3i_slab* sab_u) +{ + u3_atom pro; + + u3t_on(mal_o); + + if ( 1 == sab_u->wor_w ) { + c3_w dat_w = *sab_u->buf_w; + + c3_assert( !sab_u->_._vat_u ); + + u3t_off(mal_o); + pro = u3i_word(dat_w); + u3t_on(mal_o); + } + else { + u3a_atom* vat_u = sab_u->_._vat_u; + c3_w len_w = sab_u->wor_w; + + c3_assert( (sab_u->buf_w - c3_wiseof(u3a_atom)) == (c3_w*)vat_u ); + + while ( len_w && !(sab_u->buf_w[len_w - 1]) ) { + len_w--; + } + + pro = _ci_atom_mint(vat_u, len_w); + } + + u3t_off(mal_o); + + return pro; +} + +/* u3i_slab_moot(): produce atom from slab, no trimming. +*/ +u3_atom +u3i_slab_moot(u3i_slab* sab_u) +{ + u3_atom pro; + + u3t_on(mal_o); + + if ( 1 == sab_u->wor_w ) { + c3_w dat_w = *sab_u->buf_w; + + c3_assert( !sab_u->_._vat_u ); + + u3t_off(mal_o); + pro = u3i_word(dat_w); + u3t_on(mal_o); + } + else { + u3a_atom* vat_u = sab_u->_._vat_u; + c3_w len_w = sab_u->wor_w; + + c3_assert( (sab_u->buf_w - c3_wiseof(u3a_atom)) == (c3_w*)vat_u ); + + pro = _ci_atom_mint(vat_u, len_w); + } + + u3t_off(mal_o); + + return pro; +} + +/* u3i_word(): construct u3_atom from c3_w. +*/ +u3_atom +u3i_word(c3_w dat_w) +{ + u3_atom pro; + + u3t_on(mal_o); + + if ( c3y == u3a_is_cat(dat_w) ) { + pro = (u3_atom)dat_w; + } + else { + c3_w* nov_w = u3a_walloc(1 + c3_wiseof(u3a_atom)); + u3a_atom* vat_u = (void *)nov_w; + + vat_u->mug_w = 0; + vat_u->len_w = 1; + vat_u->buf_w[0] = dat_w; + + pro = u3a_to_pug(u3a_outa(nov_w)); + } + + u3t_off(mal_o); + + return pro; +} + /* u3i_bytes(): Copy [a] bytes from [b] to an LSB first atom. */ u3_noun From 5f75ad0055ecf0afb8fb8036f18c6b932c5b6268 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sat, 26 Sep 2020 00:12:05 -0700 Subject: [PATCH 391/933] u3: moves all use of u3a_slab/slaq to new u3i_slab api --- pkg/urbit/jets/c/can.c | 17 +++++++------- pkg/urbit/jets/c/cat.c | 19 +++++++--------- pkg/urbit/jets/c/con.c | 27 ++++++++++------------ pkg/urbit/jets/c/cut.c | 10 ++++---- pkg/urbit/jets/c/dis.c | 26 ++++++++++----------- pkg/urbit/jets/c/end.c | 10 ++++---- pkg/urbit/jets/c/lsh.c | 11 ++++----- pkg/urbit/jets/c/mix.c | 26 ++++++++++----------- pkg/urbit/jets/c/rap.c | 20 ++++++++-------- pkg/urbit/jets/c/rep.c | 20 ++++++++-------- pkg/urbit/jets/c/rip.c | 22 ++++++++---------- pkg/urbit/jets/c/rsh.c | 11 ++++----- pkg/urbit/jets/e/jam.c | 18 +++++++-------- pkg/urbit/noun/imprison.c | 9 ++++---- pkg/urbit/noun/serial.c | 48 +++++++++++++++------------------------ 15 files changed, 130 insertions(+), 164 deletions(-) diff --git a/pkg/urbit/jets/c/can.c b/pkg/urbit/jets/c/can.c index 8e1cbd464d..7ee8aef45c 100644 --- a/pkg/urbit/jets/c/can.c +++ b/pkg/urbit/jets/c/can.c @@ -14,9 +14,9 @@ return u3m_bail(c3__fail); } else { - c3_g a_g = a; - c3_w tot_w = 0; - c3_w* sal_w; + c3_g a_g = a; + c3_w tot_w = 0; + u3i_slab sab_u; /* Measure and validate the slab required. */ @@ -41,12 +41,12 @@ tot_w += pi_cab; cab = u3t(cab); } + if ( 0 == tot_w ) { return 0; } - if ( 0 == (sal_w = u3a_slaq(a_g, tot_w)) ) { - return u3m_bail(c3__fail); - } + + u3i_slab_init(&sab_u, a_g, tot_w); } /* Chop the list atoms in. @@ -60,12 +60,13 @@ u3_atom pi_cab = u3h(i_cab); u3_atom qi_cab = u3t(i_cab); - u3r_chop(a_g, 0, pi_cab, pos_w, sal_w, qi_cab); + u3r_chop(a_g, 0, pi_cab, pos_w, sab_u.buf_w, qi_cab); pos_w += pi_cab; cab = u3t(cab); } } - return u3a_malt(sal_w); + + return u3i_slab_mint(&sab_u); } } u3_noun diff --git a/pkg/urbit/jets/c/cat.c b/pkg/urbit/jets/c/cat.c index ea7ea30a28..0851ddc7c1 100644 --- a/pkg/urbit/jets/c/cat.c +++ b/pkg/urbit/jets/c/cat.c @@ -22,18 +22,15 @@ if ( 0 == all_w ) { return 0; - } else { - c3_w* sal_w = u3a_slaq(a_g, all_w); + } + else { + u3i_slab sab_u; + u3i_slab_init(&sab_u, a_g, all_w); - if ( 0 == sal_w ) { - return u3m_bail(c3__fail); - } - else { - u3r_chop(a_g, 0, lew_w, 0, sal_w, b); - u3r_chop(a_g, 0, ler_w, lew_w, sal_w, c); - } - // return u3a_moot(sal_w); - return u3a_malt(sal_w); + u3r_chop(a_g, 0, lew_w, 0, sab_u.buf_w, b); + u3r_chop(a_g, 0, ler_w, lew_w, sab_u.buf_w, c); + + return u3i_slab_mint(&sab_u); } } } diff --git a/pkg/urbit/jets/c/con.c b/pkg/urbit/jets/c/con.c index cf25e4033c..09db8cbc46 100644 --- a/pkg/urbit/jets/c/con.c +++ b/pkg/urbit/jets/c/con.c @@ -15,24 +15,21 @@ if ( (lna_w == 0) && (lnb_w == 0) ) { return 0; - } else { - c3_w len_w = c3_max(lna_w, lnb_w); - c3_w* sal_w = u3a_slab(len_w); + } + else { + c3_w len_w = c3_max(lna_w, lnb_w); + c3_w i_w; + u3i_slab sab_u; - if ( 0 == sal_w ) { - return u3m_bail(c3__fail); + u3i_slab_init(&sab_u, 5, len_w); + + u3r_chop(5, 0, lna_w, 0, sab_u.buf_w, a); + + for ( i_w = 0; i_w < lnb_w; i_w++ ) { + sab_u.buf_w[i_w] |= u3r_word(i_w, b); } - else { - c3_w i_w; - u3r_chop(5, 0, lna_w, 0, sal_w, a); - - for ( i_w = 0; i_w < lnb_w; i_w++ ) { - sal_w[i_w] |= u3r_word(i_w, b); - } - // return u3a_moot(sal_w); - return u3a_malt(sal_w); - } + return u3i_slab_mint(&sab_u); } } u3_noun diff --git a/pkg/urbit/jets/c/cut.c b/pkg/urbit/jets/c/cut.c index 2cb37f3ce1..08b7d55e58 100644 --- a/pkg/urbit/jets/c/cut.c +++ b/pkg/urbit/jets/c/cut.c @@ -38,14 +38,12 @@ return u3k(d); } else { - c3_w* sal_w = u3a_slaq(a_g, c_w); + u3i_slab sab_u; + u3i_slab_init(&sab_u, a_g, c_w); - if ( 0 == sal_w ) { - return u3m_bail(c3__fail); - } - u3r_chop(a_g, b_w, c_w, 0, sal_w, d); + u3r_chop(a_g, b_w, c_w, 0, sab_u.buf_w, d); - return u3a_malt(sal_w); + return u3i_slab_mint(&sab_u); } } } diff --git a/pkg/urbit/jets/c/dis.c b/pkg/urbit/jets/c/dis.c index d54ef13b1c..cdeae3dd29 100644 --- a/pkg/urbit/jets/c/dis.c +++ b/pkg/urbit/jets/c/dis.c @@ -15,23 +15,21 @@ if ( (lna_w == 0) && (lnb_w == 0) ) { return 0; - } else { - c3_w len_w = c3_max(lna_w, lnb_w); - c3_w* sal_w = u3a_slab(len_w); + } + else { + c3_w len_w = c3_max(lna_w, lnb_w); + c3_w i_w; + u3i_slab sab_u; - if ( 0 == sal_w ) { - return u3m_bail(c3__fail); + u3i_slab_init(&sab_u, 5, len_w); + + u3r_chop(5, 0, lna_w, 0, sab_u.buf_w, a); + + for ( i_w = 0; i_w < len_w; i_w++ ) { + sab_u.buf_w[i_w] &= (i_w >= lnb_w) ? 0 : u3r_word(i_w, b); } - else { - c3_w i_w; - u3r_chop(5, 0, lna_w, 0, sal_w, a); - - for ( i_w = 0; i_w < len_w; i_w++ ) { - sal_w[i_w] &= (i_w >= lnb_w) ? 0 : u3r_word(i_w, b); - } - return u3a_malt(sal_w); - } + return u3i_slab_mint(&sab_u); } } u3_noun diff --git a/pkg/urbit/jets/c/end.c b/pkg/urbit/jets/c/end.c index 15bc09f534..dfa30fb214 100644 --- a/pkg/urbit/jets/c/end.c +++ b/pkg/urbit/jets/c/end.c @@ -29,14 +29,12 @@ return u3k(c); } else { - c3_w* sal_w = u3a_slaq(a_g, b_w); + u3i_slab sab_u; + u3i_slab_init(&sab_u, a_g, b_w); - if ( 0 == sal_w ) { - return u3m_bail(c3__fail); - } - u3r_chop(a_g, 0, b_w, 0, sal_w, c); + u3r_chop(a_g, 0, b_w, 0, sab_u.buf_w, c); - return u3a_malt(sal_w); + return u3i_slab_mint(&sab_u); } } } diff --git a/pkg/urbit/jets/c/lsh.c b/pkg/urbit/jets/c/lsh.c index 87f286a33c..d6789144c3 100644 --- a/pkg/urbit/jets/c/lsh.c +++ b/pkg/urbit/jets/c/lsh.c @@ -29,15 +29,12 @@ return u3m_bail(c3__exit); } else { - c3_w* sal_w = u3a_slaq(a_g, (b_w + len_w)); + u3i_slab sab_u; + u3i_slab_init(&sab_u, a_g, (b_w + len_w)); - if ( 0 == sal_w ) { - return u3m_bail(c3__fail); - } - u3r_chop(a_g, 0, len_w, b_w, sal_w, c); + u3r_chop(a_g, 0, len_w, b_w, sab_u.buf_w, c); - // return u3a_moot(sal_w); - return u3a_malt(sal_w); + return u3i_slab_mint(&sab_u); } } } diff --git a/pkg/urbit/jets/c/mix.c b/pkg/urbit/jets/c/mix.c index 6c734f703b..bc013dabce 100644 --- a/pkg/urbit/jets/c/mix.c +++ b/pkg/urbit/jets/c/mix.c @@ -15,23 +15,21 @@ if ( (lna_w == 0) && (lnb_w == 0) ) { return 0; - } else { - c3_w len_w = c3_max(lna_w, lnb_w); - c3_w* sal_w = u3a_slab(len_w); + } + else { + c3_w len_w = c3_max(lna_w, lnb_w); + c3_w i_w; + u3i_slab sab_u; - if ( 0 == sal_w ) { - return u3m_bail(c3__fail); + u3i_slab_init(&sab_u, 5, len_w); + + u3r_chop(5, 0, lna_w, 0, sab_u.buf_w, a); + + for ( i_w = 0; i_w < lnb_w; i_w++ ) { + sab_u.buf_w[i_w] ^= u3r_word(i_w, b); } - else { - c3_w i_w; - u3r_chop(5, 0, lna_w, 0, sal_w, a); - - for ( i_w = 0; i_w < lnb_w; i_w++ ) { - sal_w[i_w] ^= u3r_word(i_w, b); - } - return u3a_malt(sal_w); - } + return u3i_slab_mint(&sab_u); } } u3_noun diff --git a/pkg/urbit/jets/c/rap.c b/pkg/urbit/jets/c/rap.c index 336572582f..dbdf6f29fd 100644 --- a/pkg/urbit/jets/c/rap.c +++ b/pkg/urbit/jets/c/rap.c @@ -14,9 +14,9 @@ return u3m_bail(c3__exit); } else { - c3_g a_g = a; - c3_w tot_w = 0; - c3_w* sal_w; + c3_g a_g = a; + c3_w tot_w = 0; + u3i_slab sab_u; /* Measure and validate the slab required. */ @@ -42,31 +42,31 @@ tot_w += len_w; cab = u3t(cab); } + if ( 0 == tot_w ) { return 0; } - if ( 0 == (sal_w = u3a_slaq(a_g, tot_w)) ) { - return u3m_bail(c3__fail); - } + + u3i_slab_init(&sab_u, a_g, tot_w); } /* Chop the list atoms in. */ { u3_noun cab = b; - c3_w pos_w = 0; + c3_w pos_w = 0; while ( 0 != cab ) { u3_noun h_cab = u3h(cab); c3_w len_w = u3r_met(a_g, h_cab); - u3r_chop(a_g, 0, len_w, pos_w, sal_w, h_cab); + u3r_chop(a_g, 0, len_w, pos_w, sab_u.buf_w, h_cab); pos_w += len_w; cab = u3t(cab); } } - // return u3a_moot(sal_w); - return u3a_malt(sal_w); + + return u3i_slab_mint(&sab_u); } } u3_noun diff --git a/pkg/urbit/jets/c/rep.c b/pkg/urbit/jets/c/rep.c index 24e331f65a..7e34b8faa8 100644 --- a/pkg/urbit/jets/c/rep.c +++ b/pkg/urbit/jets/c/rep.c @@ -14,9 +14,9 @@ return u3m_bail(c3__exit); } else { - c3_g a_g = a; - c3_w tot_w = 0; - c3_w* sal_w; + c3_g a_g = a; + c3_w tot_w = 0; + u3i_slab sab_u; /* Measure and validate the slab required. */ @@ -42,30 +42,30 @@ tot_w++; cab = u3t(cab); } + if ( 0 == tot_w ) { return 0; } - if ( 0 == (sal_w = u3a_slaq(a_g, tot_w)) ) { - return u3m_bail(c3__fail); - } + + u3i_slab_init(&sab_u, a_g, tot_w); } /* Chop the list atoms in. */ { u3_noun cab = b; - c3_w pos_w = 0; + c3_w pos_w = 0; while ( 0 != cab ) { u3_noun h_cab = u3h(cab); - u3r_chop(a_g, 0, 1, pos_w, sal_w, h_cab); + u3r_chop(a_g, 0, 1, pos_w, sab_u.buf_w, h_cab); pos_w++; cab = u3t(cab); } } - // return u3a_moot(sal_w); - return u3a_malt(sal_w); + + return u3i_slab_mint(&sab_u); } } u3_noun diff --git a/pkg/urbit/jets/c/rip.c b/pkg/urbit/jets/c/rip.c index 3f05c01eb0..cf23140eb5 100644 --- a/pkg/urbit/jets/c/rip.c +++ b/pkg/urbit/jets/c/rip.c @@ -42,23 +42,19 @@ u3_noun u3qc_rip(u3_atom bloq, u3_atom b) { c3_w tub_w = ((dif_w == 0) ? san_w : (san_w - dif_w)); for ( c3_w i_w = 0; i_w < met_w; i_w++ ) { - c3_w pat_w = (met_w - (i_w + 1)); - c3_w wut_w = (pat_w << san_g); - c3_w sap_w = ((0 == i_w) ? tub_w : san_w); - c3_w* sal_w = u3a_slab(sap_w); - - if ( 0 == sal_w ) { - return u3m_bail(c3__fail); - } - - c3_w j_w; - u3_atom rip; + c3_w pat_w = (met_w - (i_w + 1)); + c3_w wut_w = (pat_w << san_g); + c3_w sap_w = ((0 == i_w) ? tub_w : san_w); + c3_w j_w; + u3_atom rip; + u3i_slab sab_u; + u3i_slab_init(&sab_u, 5, sap_w); for ( j_w = 0; j_w < sap_w; j_w++ ) { - sal_w[j_w] = u3r_word(wut_w + j_w, b); + sab_u.buf_w[j_w] = u3r_word(wut_w + j_w, b); } - rip = u3a_malt(sal_w); + rip = u3i_slab_mint(&sab_u); acc = u3nc(rip, acc); len_w -= san_w; } diff --git a/pkg/urbit/jets/c/rsh.c b/pkg/urbit/jets/c/rsh.c index 4ecdf138e3..1919ce3eac 100644 --- a/pkg/urbit/jets/c/rsh.c +++ b/pkg/urbit/jets/c/rsh.c @@ -26,15 +26,12 @@ return 0; } else { - c3_w* sal_w = u3a_slaq(a_g, (len_w - b_w)); + u3i_slab sab_u; + u3i_slab_init(&sab_u, a_g, (len_w - b_w)); - if ( 0 == sal_w ) { - return u3m_bail(c3__fail); - } - u3r_chop(a_g, b_w, (len_w - b_w), 0, sal_w, c); + u3r_chop(a_g, b_w, (len_w - b_w), 0, sab_u.buf_w, c); - // return u3a_moot(sal_w); - return u3a_malt(sal_w); + return u3i_slab_mint(&sab_u); } } } diff --git a/pkg/urbit/jets/e/jam.c b/pkg/urbit/jets/e/jam.c index 9b0502d0dc..8195eaf4ef 100644 --- a/pkg/urbit/jets/e/jam.c +++ b/pkg/urbit/jets/e/jam.c @@ -37,16 +37,16 @@ u3qe_jam(u3_atom a) } #endif - c3_w bit_w, *sal_w; - c3_w* wor_w = u3s_jam_fib(a, &bit_w); - c3_w len_w = bit_w >> 5; - if ( (len_w << 5) != bit_w ) { - ++len_w; - } - sal_w = u3a_slab(len_w); - memcpy(sal_w, wor_w, len_w*sizeof(c3_w)); + c3_w bit_w; + c3_w* wor_w = u3s_jam_fib(a, &bit_w); + c3_w len_w = (bit_w + 0x1f) >> 5; + u3i_slab sab_u; + u3i_slab_init(&sab_u, 5, len_w); + + memcpy(sab_u.buf_y, wor_w, len_w * sizeof(c3_w)); u3a_wfree(wor_w); - return u3a_moot(sal_w); + + return u3i_slab_moot(&sab_u); } u3_noun diff --git a/pkg/urbit/noun/imprison.c b/pkg/urbit/noun/imprison.c index 928d57901d..2166ac63f2 100644 --- a/pkg/urbit/noun/imprison.c +++ b/pkg/urbit/noun/imprison.c @@ -503,13 +503,14 @@ u3i_chubs(c3_w a_w, u3_noun u3i_mp(mpz_t a_mp) { - c3_w pyg_w = mpz_size(a_mp) * ((sizeof(mp_limb_t)) / 4); - c3_w* buz_w = u3a_slab(4 * pyg_w); + c3_w pyg_w = mpz_size(a_mp) * (sizeof(mp_limb_t) / sizeof(c3_w)); + u3i_slab sab_u; + u3i_slab_init(&sab_u, 5, sizeof(c3_w) * pyg_w); - mpz_export(buz_w, 0, -1, sizeof(c3_w), 0, 0, a_mp); + mpz_export(sab_u.buf_w, 0, -1, sizeof(c3_w), 0, 0, a_mp); mpz_clear(a_mp); - return u3a_malt(buz_w); + return u3i_slab_mint(&sab_u); } /* u3i_vint(): increment [a]. diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index 79208801a0..76337ada68 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -629,24 +629,18 @@ _cs_cue_xeno_next(_cue_stack_t* tac_u, // XX need a ur_bsr_words_any() // else { - c3_w* wor_w; - c3_y* byt_y; + c3_d byt_d = (len_d + 0x7) >> 3; - { - c3_d byt_d = (len_d >> 3) + !!ur_mask_3(len_d); - - if ( 0xffffffffULL < byt_d) { - return u3m_bail(c3__meme); - } - - // XX assumes little-endian - // - wor_w = u3a_slaq(3, byt_d); - byt_y = (c3_y*)wor_w; + if ( 0xffffffffULL < byt_d) { + return u3m_bail(c3__meme); } + else { + u3i_slab sab_u; + u3i_slab_init(&sab_u, 3, (c3_w)byt_d); - ur_bsr_bytes_any(red_u, len_d, byt_y); - *out = u3a_malt(wor_w); + ur_bsr_bytes_any(red_u, len_d, sab_u.buf_y); + *out = u3i_slab_mint_bytes(&sab_u); + } } ur_dict32_put(rot_u, dic_u, bit_d, *out); @@ -864,24 +858,18 @@ _cs_cue_full_next(c3_ys mov, // XX need a ur_bsr_words_any() // else { - c3_w* wor_w; - c3_y* byt_y; + c3_d byt_d = (len_d + 0x7) >> 3; - { - c3_d byt_d = (len_d >> 3) + !!ur_mask_3(len_d); - - if ( 0xffffffffULL < byt_d) { - return u3m_bail(c3__meme); - } - - // XX assumes little-endian - // - wor_w = u3a_slaq(3, byt_d); - byt_y = (c3_y*)wor_w; + if ( 0xffffffffULL < byt_d) { + return u3m_bail(c3__meme); } + else { + u3i_slab sab_u; + u3i_slab_init(&sab_u, 3, (c3_w)byt_d); - ur_bsr_bytes_any(red_u, len_d, byt_y); - vat = u3a_malt(wor_w); + ur_bsr_bytes_any(red_u, len_d, sab_u.buf_y); + vat = u3i_slab_mint_bytes(&sab_u); + } } return _cs_cue_put(har_p, bit_d, vat); From 58267092fa0ba2ce8f0dd01cedb6d54612fd9e79 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sat, 26 Sep 2020 00:34:22 -0700 Subject: [PATCH 392/933] u3: refactors u3i_* atom functions using u3i_slab api --- pkg/urbit/include/noun/imprison.h | 8 +- pkg/urbit/noun/imprison.c | 191 ++++++------------------------ 2 files changed, 43 insertions(+), 156 deletions(-) diff --git a/pkg/urbit/include/noun/imprison.h b/pkg/urbit/include/noun/imprison.h index d15adae461..7c5e55c0b7 100644 --- a/pkg/urbit/include/noun/imprison.h +++ b/pkg/urbit/include/noun/imprison.h @@ -71,13 +71,13 @@ /* u3i_bytes(): Copy [a] bytes from [b] to an LSB first atom. */ - u3_noun + u3_atom u3i_bytes(c3_w a_w, const c3_y* b_y); /* u3i_words(): Copy [a] words from [b] into an atom. */ - u3_noun + u3_atom u3i_words(c3_w a_w, const c3_w* b_w); @@ -89,12 +89,12 @@ /* u3i_mp(): Copy the GMP integer [a] into an atom, and clear it. */ - u3_noun + u3_atom u3i_mp(mpz_t a_mp); /* u3i_vint(): increment [a]. */ - u3_noun + u3_atom u3i_vint(u3_noun a); /* u3i_cell(): Produce the cell `[a b]`. diff --git a/pkg/urbit/noun/imprison.c b/pkg/urbit/noun/imprison.c index 2166ac63f2..2ae4dd70ee 100644 --- a/pkg/urbit/noun/imprison.c +++ b/pkg/urbit/noun/imprison.c @@ -306,124 +306,62 @@ u3i_word(c3_w dat_w) /* u3i_bytes(): Copy [a] bytes from [b] to an LSB first atom. */ -u3_noun +u3_atom u3i_bytes(c3_w a_w, const c3_y* b_y) { - u3_noun pro; - - // Strip trailing zeroes. + // strip trailing zeroes. // while ( a_w && !b_y[a_w - 1] ) { a_w--; } - // Check for cat. - // - if ( a_w <= 4 ) { - if ( !a_w ) { - return 0; - } - else if ( a_w == 1 ) { - return b_y[0]; - } - else if ( a_w == 2 ) { - return (b_y[0] | (b_y[1] << 8)); - } - else if ( a_w == 3 ) { - return (b_y[0] | (b_y[1] << 8) | (b_y[2] << 16)); - } - else if ( (b_y[3] <= 0x7f) ) { - return (b_y[0] | (b_y[1] << 8) | (b_y[2] << 16) | (b_y[3] << 24)); - } + if ( !a_w ) { + return (u3_atom)0; } + else { + u3i_slab sab_u; - // Allocate, fill, return. - // - u3t_on(mal_o); - { - c3_w len_w = (a_w + 3) >> 2; - c3_w* nov_w = u3a_walloc((len_w + c3_wiseof(u3a_atom))); - u3a_atom* nov_u = (void*)nov_w; + u3i_slab_bare(&sab_u, 3, a_w); - nov_u->mug_w = 0; - nov_u->len_w = len_w; - - // Clear the words. - // + u3t_on(mal_o); { - c3_w i_w; - - for ( i_w=0; i_w < len_w; i_w++ ) { - nov_u->buf_w[i_w] = 0; - } + // zero-initialize last word + // + sab_u.buf_w[sab_u.wor_w - 1] = 0; + memcpy(sab_u.buf_y, b_y, a_w); } + u3t_off(mal_o); - // Fill the bytes. - // - { - c3_w i_w; - - for ( i_w=0; i_w < a_w; i_w++ ) { - nov_u->buf_w[i_w >> 2] |= (b_y[i_w] << ((i_w & 3) * 8)); - } - } - - pro = u3a_to_pug(u3a_outa(nov_w)); + return u3i_slab_moot_bytes(&sab_u); } - u3t_off(mal_o); - - return pro; } /* u3i_words(): Copy [a] words from [b] into an atom. */ -u3_noun +u3_atom u3i_words(c3_w a_w, const c3_w* b_w) { - u3_noun pro; - - // Strip trailing zeroes. + // strip trailing zeroes. // while ( a_w && !b_w[a_w - 1] ) { a_w--; } - // Check for cat. - // if ( !a_w ) { - return 0; + return (u3_atom)0; } - else if ( (a_w == 1) && !(b_w[0] >> 31) ) { - return b_w[0]; + else { + u3i_slab sab_u; + u3i_slab_bare(&sab_u, 5, a_w); + + u3t_on(mal_o); + memcpy(sab_u.buf_w, b_w, (size_t)4 * a_w); + u3t_off(mal_o); + + return u3i_slab_moot(&sab_u); } - - // Allocate, fill, return. - // - u3t_on(mal_o); - { - c3_w* nov_w = u3a_walloc(a_w + c3_wiseof(u3a_atom)); - u3a_atom* nov_u = (void*)nov_w; - - nov_u->mug_w = 0; - nov_u->len_w = a_w; - - // Fill the words. - // - { - c3_w i_w; - - for ( i_w=0; i_w < a_w; i_w++ ) { - nov_u->buf_w[i_w] = b_w[i_w]; - } - } - - pro = u3a_to_pug(u3a_outa(nov_w)); - } - u3t_off(mal_o); - - return pro; } /* u3i_chubs(): Copy [a] chubs from [b] into an atom. @@ -432,75 +370,29 @@ u3_atom u3i_chubs(c3_w a_w, const c3_d* b_d) { - u3_noun pro; + u3i_slab sab_u; + u3i_slab_bare(&sab_u, 6, a_w); - // Strip trailing zeroes. - // - while ( a_w && !b_d[a_w - 1] ) { - a_w--; - } - - // Check for cat. - // - if ( !a_w ) { - return 0; - } - else if ( (1 == a_w) && !(b_d[0] >> 31) ) { - return (c3_w)b_d[0]; - } - - // Allocate, fill, return. - // u3t_on(mal_o); { - c3_w len_w = 2 * a_w; + c3_w* buf_w = sab_u.buf_w; + c3_w i_w; + c3_d i_d; - if ( !(b_d[a_w - 1] >> 32) ) { - len_w--; + for ( i_w = 0; i_w < a_w; i_w++ ) { + i_d = b_d[i_w]; + *buf_w++ = i_d & 0xffffffffULL; + *buf_w++ = i_d >> 32; } - - c3_w* nov_w = u3a_walloc(len_w + c3_wiseof(u3a_atom)); - u3a_atom* nov_u = (void*)nov_w; - - nov_u->mug_w = 0; - nov_u->len_w = len_w; - - // Fill the words. - // - { - c3_w i_w, x_w, max_w = a_w - 1; - c3_d i_d; - - for ( i_w = 0; i_w < max_w; i_w++ ) { - i_d = b_d[i_w]; - x_w = 2 * i_w; - nov_u->buf_w[x_w] = i_d & 0xffffffffULL; - x_w++; - nov_u->buf_w[x_w] = i_d >> 32; - } - - { - i_d = b_d[i_w]; - x_w = 2 * i_w; - nov_u->buf_w[x_w] = i_d & 0xffffffffULL; - x_w++; - } - - if ( x_w < len_w ) { - nov_u->buf_w[x_w] = i_d >> 32; - } - } - - pro = u3a_to_pug(u3a_outa(nov_w)); } u3t_off(mal_o); - return pro; + return u3i_slab_mint(&sab_u); } /* u3i_mp(): Copy the GMP integer [a] into an atom, and clear it. */ -u3_noun +u3_atom u3i_mp(mpz_t a_mp) { c3_w pyg_w = mpz_size(a_mp) * (sizeof(mp_limb_t) / sizeof(c3_w)); @@ -515,18 +407,13 @@ u3i_mp(mpz_t a_mp) /* u3i_vint(): increment [a]. */ -u3_noun +u3_atom u3i_vint(u3_noun a) { c3_assert(u3_none != a); if ( _(u3a_is_cat(a)) ) { - c3_w vin_w = (a + 1); - - if ( a == 0x7fffffff ) { - return u3i_words(1, &vin_w); - } - else return vin_w; + return ( a == 0x7fffffff ) ? u3i_word(a + 1) : (a + 1); } else if ( _(u3a_is_cell(a)) ) { return u3m_bail(c3__exit); From 1116652b2aca2b2b05c317d11ab043aae8decdcb Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sat, 26 Sep 2020 00:38:46 -0700 Subject: [PATCH 393/933] u3: refactors +repn jet using u3i_slab api --- pkg/urbit/jets/c/repn.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/pkg/urbit/jets/c/repn.c b/pkg/urbit/jets/c/repn.c index ee6b713d20..4b9c694357 100644 --- a/pkg/urbit/jets/c/repn.c +++ b/pkg/urbit/jets/c/repn.c @@ -28,19 +28,8 @@ u3qc_repn(u3_atom bits, u3_noun blox) c3_w num_blox_w = u3qb_lent(blox); c3_w bit_widt_w = num_blox_w * bits; c3_w wor_widt_w = DIVCEIL(bit_widt_w, 32); - - // - // Allocate a proto-atom. This is u3a_slab without initialization. - // - c3_w* buf_w; - { - c3_w* nov_w = u3a_walloc(wor_widt_w + c3_wiseof(u3a_atom)); - u3a_atom* pug_u = (void *)nov_w; - - pug_u->mug_w = 0; - pug_u->len_w = wor_widt_w; - buf_w = pug_u->buf_w; - } + u3i_slab sab_u; + u3i_slab_bare(&sab_u, 5, wor_widt_w); // // Fill the atom buffer with bits from each block. @@ -53,7 +42,7 @@ u3qc_repn(u3_atom bits, u3_noun blox) // cur_w next buffer word to flush into. // { - c3_w acc_w=0, use_w=0, *cur_w=buf_w; + c3_w acc_w=0, use_w=0, *cur_w=sab_u.buf_w; # define FLUSH() *cur_w++=acc_w; acc_w=use_w=0 # define SLICE(sz,off,val) TAKEBITS(sz, val) << off @@ -98,7 +87,7 @@ u3qc_repn(u3_atom bits, u3_noun blox) } } - return u3a_malt(buf_w); + return u3i_slab_mint(&sab_u); } u3_noun From ea9328a4db0fb76b0dca6fdb1fe63ded50609c3c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sat, 26 Sep 2020 00:39:15 -0700 Subject: [PATCH 394/933] u3: removes u3a_slab and friends --- pkg/urbit/include/noun/allocate.h | 27 ------- pkg/urbit/noun/allocate.c | 118 ------------------------------ 2 files changed, 145 deletions(-) diff --git a/pkg/urbit/include/noun/allocate.h b/pkg/urbit/include/noun/allocate.h index 1b6f71bc54..602077f5c6 100644 --- a/pkg/urbit/include/noun/allocate.h +++ b/pkg/urbit/include/noun/allocate.h @@ -648,33 +648,6 @@ void u3a_deadbeef(void); - /* Atoms from proto-atoms. - */ - /* u3a_slab(): create a length-bounded proto-atom. - */ - c3_w* - u3a_slab(c3_w len_w); - - /* u3a_slaq(): u3a_slab() with a defined blocksize. - */ - c3_w* - u3a_slaq(c3_g met_g, c3_w len_w); - - /* u3a_malt(): measure and finish a proto-atom. - */ - u3_noun - u3a_malt(c3_w* sal_w); - - /* u3a_moot(): finish a pre-measured proto-atom; dangerous. - */ - u3_noun - u3a_moot(c3_w* sal_w); - - /* u3a_mint(): finish a measured proto-atom. - */ - u3_noun - u3a_mint(c3_w* sal_w, c3_w len_w); - /* u3a_walk_fore(): preorder traversal, visits ever limb of a noun. ** ** cells are visited *before* their heads and tails diff --git a/pkg/urbit/noun/allocate.c b/pkg/urbit/noun/allocate.c index 9749152368..a57f253f28 100644 --- a/pkg/urbit/noun/allocate.c +++ b/pkg/urbit/noun/allocate.c @@ -2479,77 +2479,6 @@ u3a_rewrite_noun(u3_noun som) cel->tel = u3a_rewritten_noun(cel->tel); } -/* u3a_slab(): create a length-bounded proto-atom. -*/ -c3_w* -u3a_slab(c3_w len_w) -{ - c3_w* nov_w = u3a_walloc(len_w + c3_wiseof(u3a_atom)); - u3a_atom* pug_u = (void *)nov_w; - - pug_u->mug_w = 0; - pug_u->len_w = len_w; - - /* Clear teh slab. - */ - { - c3_w i_w; - - for ( i_w=0; i_w < len_w; i_w++ ) { - pug_u->buf_w[i_w] = 0; - } - } - return pug_u->buf_w; -} - -/* u3a_slaq(): u3a_slab() with a defined blocksize. -*/ -c3_w* -u3a_slaq(c3_g met_g, c3_w len_w) -{ - return u3a_slab(((len_w << met_g) + 31) >> 5); -} - -/* u3a_malt(): measure and finish a proto-atom. -*/ -u3_noun -u3a_malt(c3_w* sal_w) -{ - c3_w* nov_w = (sal_w - c3_wiseof(u3a_atom)); - u3a_atom* nov_u = (void *)nov_w; - c3_w len_w; - - for ( len_w = nov_u->len_w; len_w; len_w-- ) { - if ( 0 != nov_u->buf_w[len_w - 1] ) { - break; - } - } - return u3a_mint(sal_w, len_w); -} - -/* u3a_moot(): finish a pre-measured proto-atom; dangerous. -*/ -u3_noun -u3a_moot(c3_w* sal_w) -{ - c3_w* nov_w = (sal_w - c3_wiseof(u3a_atom)); - u3a_atom* nov_u = (void*)nov_w; - c3_w len_w = nov_u->len_w; - c3_w las_w = nov_u->buf_w[len_w - 1]; - - c3_assert(0 != len_w); - c3_assert(0 != las_w); - - if ( 1 == len_w ) { - if ( _(u3a_is_cat(las_w)) ) { - u3a_wfree(nov_w); - - return las_w; - } - } - return u3a_to_pug(u3a_outa(nov_w)); -} - #if 0 /* _ca_detect(): in u3a_detect(). */ @@ -2596,53 +2525,6 @@ u3a_detect(u3_noun fum, u3_noun som) } #endif -/* u3a_mint(): finish a measured proto-atom. -*/ -u3_noun -u3a_mint(c3_w* sal_w, c3_w len_w) -{ - c3_w* nov_w = (sal_w - c3_wiseof(u3a_atom)); - u3a_atom* nov_u = (void*)nov_w; - - /* See if we can free the slab entirely. - */ - if ( len_w == 0 ) { - u3a_wfree(nov_w); - - return 0; - } - else if ( len_w == 1 ) { - c3_w low_w = nov_u->buf_w[0]; - - if ( _(u3a_is_cat(low_w)) ) { - u3a_wfree(nov_w); - - return low_w; - } - } - - /* See if we can strip off a block on the end. - */ - { - c3_w old_w = nov_u->len_w; - c3_w dif_w = (old_w - len_w); - - if ( dif_w >= u3a_minimum ) { - c3_w* box_w = (void *)u3a_botox(nov_w); - c3_w* end_w = (nov_w + c3_wiseof(u3a_atom) + len_w + 1); - c3_w asz_w = (end_w - box_w); - c3_w bsz_w = box_w[0] - asz_w; - - _box_attach(_box_make(end_w, bsz_w, 0)); - - box_w[0] = asz_w; - box_w[asz_w - 1] = asz_w; - } - nov_u->len_w = len_w; - } - return u3a_to_pug(u3a_outa(nov_w)); -} - #ifdef U3_MEMORY_DEBUG /* u3a_lush(): leak push. */ From ecb9c23e0811e219ac622133add5c1524c35e649 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 28 Sep 2020 11:30:42 -0700 Subject: [PATCH 395/933] u3: adds u3i_slab_from(), removes unnecessary uses of u3r_chop() --- pkg/urbit/include/noun/imprison.h | 5 +++++ pkg/urbit/jets/c/cat.c | 3 +-- pkg/urbit/jets/c/con.c | 5 +---- pkg/urbit/jets/c/dis.c | 5 +---- pkg/urbit/jets/c/mix.c | 7 +++---- pkg/urbit/noun/imprison.c | 12 ++++++++++++ 6 files changed, 23 insertions(+), 14 deletions(-) diff --git a/pkg/urbit/include/noun/imprison.h b/pkg/urbit/include/noun/imprison.h index 7c5e55c0b7..577cec02f0 100644 --- a/pkg/urbit/include/noun/imprison.h +++ b/pkg/urbit/include/noun/imprison.h @@ -32,6 +32,11 @@ void u3i_slab_bare(u3i_slab* sab_u, c3_g met_g, c3_w len_w); + /* u3i_slab_from(): configure bloq-length slab, initialize with [a]. + */ + void + u3i_slab_from(u3i_slab* sab_u, u3_atom a, c3_g met_g, c3_w len_w); + /* u3i_slab_grow(): resize slab, reallocating as necessary. */ void diff --git a/pkg/urbit/jets/c/cat.c b/pkg/urbit/jets/c/cat.c index 0851ddc7c1..2648c2303e 100644 --- a/pkg/urbit/jets/c/cat.c +++ b/pkg/urbit/jets/c/cat.c @@ -25,9 +25,8 @@ } else { u3i_slab sab_u; - u3i_slab_init(&sab_u, a_g, all_w); + u3i_slab_from(&sab_u, b, a_g, all_w); - u3r_chop(a_g, 0, lew_w, 0, sab_u.buf_w, b); u3r_chop(a_g, 0, ler_w, lew_w, sab_u.buf_w, c); return u3i_slab_mint(&sab_u); diff --git a/pkg/urbit/jets/c/con.c b/pkg/urbit/jets/c/con.c index 09db8cbc46..9fa8df142b 100644 --- a/pkg/urbit/jets/c/con.c +++ b/pkg/urbit/jets/c/con.c @@ -20,10 +20,7 @@ c3_w len_w = c3_max(lna_w, lnb_w); c3_w i_w; u3i_slab sab_u; - - u3i_slab_init(&sab_u, 5, len_w); - - u3r_chop(5, 0, lna_w, 0, sab_u.buf_w, a); + u3i_slab_from(&sab_u, a, 5, len_w); for ( i_w = 0; i_w < lnb_w; i_w++ ) { sab_u.buf_w[i_w] |= u3r_word(i_w, b); diff --git a/pkg/urbit/jets/c/dis.c b/pkg/urbit/jets/c/dis.c index cdeae3dd29..a0f478a943 100644 --- a/pkg/urbit/jets/c/dis.c +++ b/pkg/urbit/jets/c/dis.c @@ -20,10 +20,7 @@ c3_w len_w = c3_max(lna_w, lnb_w); c3_w i_w; u3i_slab sab_u; - - u3i_slab_init(&sab_u, 5, len_w); - - u3r_chop(5, 0, lna_w, 0, sab_u.buf_w, a); + u3i_slab_from(&sab_u, a, 5, len_w); for ( i_w = 0; i_w < len_w; i_w++ ) { sab_u.buf_w[i_w] &= (i_w >= lnb_w) ? 0 : u3r_word(i_w, b); diff --git a/pkg/urbit/jets/c/mix.c b/pkg/urbit/jets/c/mix.c index bc013dabce..ccb008c057 100644 --- a/pkg/urbit/jets/c/mix.c +++ b/pkg/urbit/jets/c/mix.c @@ -20,11 +20,10 @@ c3_w len_w = c3_max(lna_w, lnb_w); c3_w i_w; u3i_slab sab_u; + u3i_slab_from(&sab_u, a, 5, len_w); - u3i_slab_init(&sab_u, 5, len_w); - - u3r_chop(5, 0, lna_w, 0, sab_u.buf_w, a); - + // XX use u3r_chop for XOR? + // for ( i_w = 0; i_w < lnb_w; i_w++ ) { sab_u.buf_w[i_w] ^= u3r_word(i_w, b); } diff --git a/pkg/urbit/noun/imprison.c b/pkg/urbit/noun/imprison.c index 2ae4dd70ee..13198d2097 100644 --- a/pkg/urbit/noun/imprison.c +++ b/pkg/urbit/noun/imprison.c @@ -155,6 +155,18 @@ u3i_slab_bare(u3i_slab* sab_u, c3_g met_g, c3_w len_w) u3t_off(mal_o); } +/* u3i_slab_from(): configure bloq-length slab, initialize with [a]. +*/ +void +u3i_slab_from(u3i_slab* sab_u, u3_atom a, c3_g met_g, c3_w len_w) +{ + u3i_slab_bare(sab_u, met_g, len_w); + + // copies [a], zero-initializes any additional space + // + u3r_words(0, sab_u->wor_w, sab_u->buf_w, a); +} + /* u3i_slab_grow(): resize slab, reallocating as necessary. */ void From a0b7f852ee0db8fef0c7a934569ac4e088088521 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 28 Sep 2020 11:49:58 -0700 Subject: [PATCH 396/933] u3: removes unnecessary zero-initialization in +rip jet --- pkg/urbit/jets/c/rip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/urbit/jets/c/rip.c b/pkg/urbit/jets/c/rip.c index cf23140eb5..b5e727b390 100644 --- a/pkg/urbit/jets/c/rip.c +++ b/pkg/urbit/jets/c/rip.c @@ -48,7 +48,7 @@ u3_noun u3qc_rip(u3_atom bloq, u3_atom b) { c3_w j_w; u3_atom rip; u3i_slab sab_u; - u3i_slab_init(&sab_u, 5, sap_w); + u3i_slab_bare(&sab_u, 5, sap_w); for ( j_w = 0; j_w < sap_w; j_w++ ) { sab_u.buf_w[j_w] = u3r_word(wut_w + j_w, b); From 9620fb1545b9a868173ed2d24e93af34af3220f8 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 28 Sep 2020 12:24:36 -0700 Subject: [PATCH 397/933] u3: fixes u3i_slab_grow() --- pkg/urbit/noun/imprison.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/urbit/noun/imprison.c b/pkg/urbit/noun/imprison.c index 13198d2097..5d8d6ddc50 100644 --- a/pkg/urbit/noun/imprison.c +++ b/pkg/urbit/noun/imprison.c @@ -49,7 +49,7 @@ _ci_slab_grow(u3i_slab* sab_u, c3_w len_w) c3_w* old_w = (void*)sab_u->_._vat_u; // XX implement a more efficient u3a_wealloc() // - c3_w* nov_w = u3a_wealloc(old_w, len_w); + c3_w* nov_w = u3a_wealloc(old_w, len_w + c3_wiseof(u3a_atom)); u3a_atom* vat_u = (void *)nov_w; vat_u->len_w = len_w; From f02634371375ac5b8fdbd681036acc4051c158f4 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 28 Sep 2020 12:26:04 -0700 Subject: [PATCH 398/933] u3: refactors u3s_jam_fib to use slab api --- pkg/urbit/bench/ur_bench.c | 6 ++-- pkg/urbit/include/noun/serial.h | 4 +-- pkg/urbit/jets/e/jam.c | 11 ++----- pkg/urbit/noun/jets.c | 24 +++++++------- pkg/urbit/noun/serial.c | 55 ++++++++++++++------------------- pkg/urbit/tests/jam_tests.c | 10 +++--- 6 files changed, 48 insertions(+), 62 deletions(-) diff --git a/pkg/urbit/bench/ur_bench.c b/pkg/urbit/bench/ur_bench.c index 8a29de65a2..82fc6caea7 100644 --- a/pkg/urbit/bench/ur_bench.c +++ b/pkg/urbit/bench/ur_bench.c @@ -52,11 +52,11 @@ _jam_bench(void) gettimeofday(&b4, 0); { - c3_w* wor_w, bit_w; + u3i_slab sab_u; for ( i_w = 0; i_w < max_w; i_w++ ) { - wor_w = u3s_jam_fib(wit, &bit_w); - u3a_wfree(wor_w); + u3s_jam_fib(&sab_u, wit); + u3i_slab_free(&sab_u); } } diff --git a/pkg/urbit/include/noun/serial.h b/pkg/urbit/include/noun/serial.h index f7a06aa4aa..4ae4482c1a 100644 --- a/pkg/urbit/include/noun/serial.h +++ b/pkg/urbit/include/noun/serial.h @@ -15,8 +15,8 @@ ** returns atom-suitable words, and *bit_w will have ** the length (in bits). return should be freed with u3a_wfree(). */ - c3_w* - u3s_jam_fib(u3_noun a, c3_w* bit_w); + c3_w + u3s_jam_fib(u3i_slab* sab_u, u3_noun a); /* u3s_jam_xeno(): jam with off-loom buffer (re-)allocation. */ diff --git a/pkg/urbit/jets/e/jam.c b/pkg/urbit/jets/e/jam.c index 8195eaf4ef..c07ab80adb 100644 --- a/pkg/urbit/jets/e/jam.c +++ b/pkg/urbit/jets/e/jam.c @@ -37,16 +37,9 @@ u3qe_jam(u3_atom a) } #endif - c3_w bit_w; - c3_w* wor_w = u3s_jam_fib(a, &bit_w); - c3_w len_w = (bit_w + 0x1f) >> 5; u3i_slab sab_u; - u3i_slab_init(&sab_u, 5, len_w); - - memcpy(sab_u.buf_y, wor_w, len_w * sizeof(c3_w)); - u3a_wfree(wor_w); - - return u3i_slab_moot(&sab_u); + u3s_jam_fib(&sab_u, a); + return u3i_slab_mint(&sab_u); } u3_noun diff --git a/pkg/urbit/noun/jets.c b/pkg/urbit/noun/jets.c index 8a8682f614..68dd54e159 100644 --- a/pkg/urbit/noun/jets.c +++ b/pkg/urbit/noun/jets.c @@ -121,18 +121,17 @@ _cj_bash(u3_noun bat) rod_u = u3to(u3_road, rod_u->par_p); } else { - c3_w bit_w, met_w; - c3_w* wor_w; - c3_y* fat_y; - c3_y dig_y[32]; + u3i_slab sab_u; + c3_w met_w; + c3_y* fat_y; + c3_y dig_y[32]; + + u3s_jam_fib(&sab_u, bat); + // XX assumes little-endian + // + fat_y = sab_u.buf_y; + met_w = sab_u.byt_d; - wor_w = u3s_jam_fib(bat, &bit_w); - met_w = bit_w >> 3; - if ( bit_w != met_w << 3 ) { - ++met_w; - } - // assume little-endian - fat_y = (c3_y*) wor_w; #if defined(U3_OS_osx) CC_SHA256_CTX ctx_h; @@ -146,9 +145,10 @@ _cj_bash(u3_noun bat) SHA256_Update(&ctx_h, fat_y, met_w); SHA256_Final(dig_y, &ctx_h); #endif + pro = u3i_bytes(32, dig_y); u3h_put(u3R->jed.bas_p, bat, u3k(pro)); - u3a_wfree(wor_w); + u3i_slab_free(&sab_u); break; } } diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index 76337ada68..6b64644862 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -18,11 +18,11 @@ _cs_met0_w(c3_w wid_w) { /* _cs_jam_buf: struct for tracking the fibonacci-allocated jam of a noun */ struct _cs_jam_fib { + u3i_slab* sab_u; u3p(u3h_root) har_p; c3_w a_w; c3_w b_w; c3_w bit_w; - c3_w* buf_w; }; /* _cs_jam_fib_grow(): reallocate buffer with fibonacci growth @@ -39,12 +39,8 @@ _cs_jam_fib_grow(struct _cs_jam_fib* fib_u, c3_w mor_w) } if ( wan_w > fib_u->a_w ) { - c3_w old_w, new_w, c_w = 0; - - old_w = fib_u->a_w >> 5; - if ( (old_w << 5) != fib_u->a_w ) { - ++old_w; - } + c3_w old_w = fib_u->sab_u->wor_w; + c3_w c_w = 0; // fibonacci growth // @@ -54,13 +50,13 @@ _cs_jam_fib_grow(struct _cs_jam_fib* fib_u, c3_w mor_w) fib_u->a_w = c_w; } - new_w = c_w >> 5; - if ( (new_w << 5) != c_w ) { - ++new_w; - } + u3i_slab_grow(fib_u->sab_u, 0, c_w); - fib_u->buf_w = u3a_wealloc(fib_u->buf_w, new_w); - memset(fib_u->buf_w + old_w, 0, (new_w - old_w) * sizeof(c3_w)); + { + c3_w dif_w = fib_u->sab_u->wor_w - old_w; + c3_w* buf_w = fib_u->sab_u->buf_w + old_w; + memset(buf_w, 0, dif_w * sizeof(c3_w)); + } } } @@ -71,8 +67,12 @@ _cs_jam_fib_chop(struct _cs_jam_fib* fib_u, c3_w met_w, u3_noun a) { c3_w bit_w = fib_u->bit_w; _cs_jam_fib_grow(fib_u, met_w); - u3r_chop(0, 0, met_w, bit_w, fib_u->buf_w, a); fib_u->bit_w += met_w; + + { + c3_w* buf_w = fib_u->sab_u->buf_w; + u3r_chop(0, 0, met_w, bit_w, buf_w, a); + } } /* _cs_jam_fib_mat(): length-prefixed encode (mat) [a] into [fib_u] @@ -156,28 +156,21 @@ _cs_jam_fib_cell_cb(u3_noun a, void* ptr_v) ** returns atom-suitable words, and *bit_w will have ** the length (in bits). return should be freed with u3a_wfree(). */ -c3_w* -u3s_jam_fib(u3_noun a, c3_w* bit_w) +c3_w +u3s_jam_fib(u3i_slab* sab_u, u3_noun a) { struct _cs_jam_fib fib_u; fib_u.har_p = u3h_new(); + fib_u.sab_u = sab_u; + // fib(12) is small enough to be reasonably fast to allocate. - // - fib_u.a_w = 144; // fib(11) is needed to get fib(13). // - fib_u.b_w = 89; + // + fib_u.a_w = ur_fib12; + fib_u.b_w = ur_fib11; fib_u.bit_w = 0; - - { - c3_w len_w = fib_u.a_w >> 5; - if ( (len_w << 5) != fib_u.a_w ) { - ++len_w; - } - - fib_u.buf_w = u3a_walloc(len_w); - memset(fib_u.buf_w, 0, len_w * sizeof(c3_w)); - } + u3i_slab_init(sab_u, 0, fib_u.a_w); // as this is a hot path, we unsafely elide overflow checks // @@ -186,9 +179,9 @@ u3s_jam_fib(u3_noun a, c3_w* bit_w) u3a_walk_fore_unsafe(a, &fib_u, _cs_jam_fib_atom_cb, _cs_jam_fib_cell_cb); - *bit_w = fib_u.bit_w; u3h_free(fib_u.har_p); - return fib_u.buf_w; + + return fib_u.bit_w; } typedef struct _jam_xeno_s { diff --git a/pkg/urbit/tests/jam_tests.c b/pkg/urbit/tests/jam_tests.c index 41e5d767b2..6d6d99cd03 100644 --- a/pkg/urbit/tests/jam_tests.c +++ b/pkg/urbit/tests/jam_tests.c @@ -338,13 +338,13 @@ _test_jam_spec(const c3_c* cap_c, } { - c3_w bit_w; - c3_w* wor_w = u3s_jam_fib(ref, &bit_w); + u3i_slab sab_u; + c3_w bit_w = u3s_jam_fib(&sab_u, ref); - out_d = (bit_w >> 3) + !!ur_mask_3(bit_w); + out_d = sab_u.byt_d; // XX assumes little-endian // - out_y = (c3_y*)wor_w; + out_y = sab_u.buf_y; if ( 0 != memcmp(out_y, byt_y, len_w) ) { fprintf(stderr, "\033[31mjam fib %s fail\033[0m\r\n", cap_c); @@ -352,7 +352,7 @@ _test_jam_spec(const c3_c* cap_c, ret_i = 0; } - u3a_wfree(wor_w); + u3i_slab_free(&sab_u); } return ret_i; From 667a5a71dbd67c24cc9fe52f001bd1b1856388db Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 28 Sep 2020 12:38:27 -0700 Subject: [PATCH 399/933] u3: removes redundant bitwidth function in serial.c --- pkg/urbit/noun/serial.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index 6b64644862..f9bf9d3e6c 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -8,13 +8,6 @@ #include "all.h" #include "ur/ur.h" -/* _cs_met0_w(): safe bitwidth for any c3_w -*/ -static inline c3_w -_cs_met0_w(c3_w wid_w) { - return ( wid_w >> 31 ) ? 32 : u3r_met(0, wid_w); -} - /* _cs_jam_buf: struct for tracking the fibonacci-allocated jam of a noun */ struct _cs_jam_fib { @@ -85,7 +78,7 @@ _cs_jam_fib_mat(struct _cs_jam_fib* fib_u, u3_noun a) } else { c3_w a_w = u3r_met(0, a); - c3_w b_w = _cs_met0_w(a_w); + c3_w b_w = c3_bits_word(a_w); _cs_jam_fib_chop(fib_u, b_w+1, 1 << b_w); _cs_jam_fib_chop(fib_u, b_w-1, a_w & ((1 << (b_w-1)) - 1)); From cdb94ae70ed98b18aaf092c65c61fd940d6c49f7 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 28 Sep 2020 17:49:17 -0700 Subject: [PATCH 400/933] u3: uses c3_d for length arguments in slab api --- pkg/urbit/include/noun/imprison.h | 8 ++++---- pkg/urbit/noun/imprison.c | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pkg/urbit/include/noun/imprison.h b/pkg/urbit/include/noun/imprison.h index 577cec02f0..a899a6b182 100644 --- a/pkg/urbit/include/noun/imprison.h +++ b/pkg/urbit/include/noun/imprison.h @@ -25,22 +25,22 @@ /* u3i_slab_init(): configure bloq-length slab, zero-initialize. */ void - u3i_slab_init(u3i_slab* sab_u, c3_g met_g, c3_w len_w); + u3i_slab_init(u3i_slab* sab_u, c3_g met_g, c3_d len_d); /* u3i_slab_bare(): configure bloq-length slab, uninitialized. */ void - u3i_slab_bare(u3i_slab* sab_u, c3_g met_g, c3_w len_w); + u3i_slab_bare(u3i_slab* sab_u, c3_g met_g, c3_d len_d); /* u3i_slab_from(): configure bloq-length slab, initialize with [a]. */ void - u3i_slab_from(u3i_slab* sab_u, u3_atom a, c3_g met_g, c3_w len_w); + u3i_slab_from(u3i_slab* sab_u, u3_atom a, c3_g met_g, c3_d len_d); /* u3i_slab_grow(): resize slab, reallocating as necessary. */ void - u3i_slab_grow(u3i_slab* sab_u, c3_g met_g, c3_w len_w); + u3i_slab_grow(u3i_slab* sab_u, c3_g met_g, c3_d len_d); /* u3i_slab_free(): dispose memory backing slab. */ diff --git a/pkg/urbit/noun/imprison.c b/pkg/urbit/noun/imprison.c index 5d8d6ddc50..8c57fd9526 100644 --- a/pkg/urbit/noun/imprison.c +++ b/pkg/urbit/noun/imprison.c @@ -6,15 +6,15 @@ /* _ci_slab_size(): calculate slab bloq-size, checking for overflow. */ static c3_w -_ci_slab_size(c3_g met_g, c3_w len_w, c3_d* out_d) +_ci_slab_size(c3_g met_g, c3_d len_d, c3_d* out_d) { - c3_d bit_d = (c3_d)len_w << met_g; + c3_d bit_d = len_d << met_g; c3_d byt_d = (bit_d + 0x7) >> 3; c3_d wor_d = (byt_d + 0x3) >> 2; - c3_w wor_w = (c3_d)wor_d; + c3_w wor_w = (c3_w)wor_d; if ( (wor_w != wor_d) - || (len_w != (bit_d >> met_g)) ) + || (len_d != (bit_d >> met_g)) ) { return (c3_w)u3m_bail(c3__fail); } @@ -98,12 +98,12 @@ _ci_atom_mint(u3a_atom* vat_u, c3_w len_w) /* u3i_slab_init(): configure bloq-length slab, zero-initialize. */ void -u3i_slab_init(u3i_slab* sab_u, c3_g met_g, c3_w len_w) +u3i_slab_init(u3i_slab* sab_u, c3_g met_g, c3_d len_d) { u3t_on(mal_o); { c3_d byt_d; - c3_w wor_w = _ci_slab_size(met_g, len_w, &byt_d); + c3_w wor_w = _ci_slab_size(met_g, len_d, &byt_d); // if we only need one word, use the static storage in [sab_u] // @@ -130,12 +130,12 @@ u3i_slab_init(u3i_slab* sab_u, c3_g met_g, c3_w len_w) /* u3i_slab_bare(): configure bloq-length slab, uninitialized. */ void -u3i_slab_bare(u3i_slab* sab_u, c3_g met_g, c3_w len_w) +u3i_slab_bare(u3i_slab* sab_u, c3_g met_g, c3_d len_d) { u3t_on(mal_o); { c3_d byt_d; - c3_w wor_w = _ci_slab_size(met_g, len_w, &byt_d); + c3_w wor_w = _ci_slab_size(met_g, len_d, &byt_d); // if we only need one word, use the static storage in [sab_u] // @@ -158,9 +158,9 @@ u3i_slab_bare(u3i_slab* sab_u, c3_g met_g, c3_w len_w) /* u3i_slab_from(): configure bloq-length slab, initialize with [a]. */ void -u3i_slab_from(u3i_slab* sab_u, u3_atom a, c3_g met_g, c3_w len_w) +u3i_slab_from(u3i_slab* sab_u, u3_atom a, c3_g met_g, c3_d len_d) { - u3i_slab_bare(sab_u, met_g, len_w); + u3i_slab_bare(sab_u, met_g, len_d); // copies [a], zero-initializes any additional space // @@ -170,12 +170,12 @@ u3i_slab_from(u3i_slab* sab_u, u3_atom a, c3_g met_g, c3_w len_w) /* u3i_slab_grow(): resize slab, reallocating as necessary. */ void -u3i_slab_grow(u3i_slab* sab_u, c3_g met_g, c3_w len_w) +u3i_slab_grow(u3i_slab* sab_u, c3_g met_g, c3_d len_d) { u3t_on(mal_o); { c3_d byt_d; - c3_w wor_w = _ci_slab_size(met_g, len_w, &byt_d); + c3_w wor_w = _ci_slab_size(met_g, len_d, &byt_d); // XX actually shrink? // From 02804f8d2113736425417c09fe03a80b84d01653 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 28 Sep 2020 17:49:41 -0700 Subject: [PATCH 401/933] u3: improves effiency of gmp->u3a_atom conversion --- pkg/urbit/noun/imprison.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/urbit/noun/imprison.c b/pkg/urbit/noun/imprison.c index 8c57fd9526..1f6aa3c57b 100644 --- a/pkg/urbit/noun/imprison.c +++ b/pkg/urbit/noun/imprison.c @@ -407,14 +407,19 @@ u3i_chubs(c3_w a_w, u3_atom u3i_mp(mpz_t a_mp) { - c3_w pyg_w = mpz_size(a_mp) * (sizeof(mp_limb_t) / sizeof(c3_w)); + size_t siz_i = mpz_sizeinbase(a_mp, 2); u3i_slab sab_u; - u3i_slab_init(&sab_u, 5, sizeof(c3_w) * pyg_w); + u3i_slab_init(&sab_u, 0, siz_i); mpz_export(sab_u.buf_w, 0, -1, sizeof(c3_w), 0, 0, a_mp); mpz_clear(a_mp); - return u3i_slab_mint(&sab_u); + // per the mpz_export() docs: + // + // > If op is non-zero then the most significant word produced + // > will be non-zero. + // + return u3i_slab_moot(&sab_u); } /* u3i_vint(): increment [a]. From 1ca3fdcf5edd59ea648e191a31a5d0733dac28e1 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 28 Sep 2020 18:20:46 -0700 Subject: [PATCH 402/933] u3: adds u3i_chub(), refactors u3i_chubs() --- pkg/urbit/include/noun/imprison.h | 5 +++ pkg/urbit/noun/imprison.c | 59 ++++++++++++++++++++++--------- 2 files changed, 48 insertions(+), 16 deletions(-) diff --git a/pkg/urbit/include/noun/imprison.h b/pkg/urbit/include/noun/imprison.h index a899a6b182..288e2f4a43 100644 --- a/pkg/urbit/include/noun/imprison.h +++ b/pkg/urbit/include/noun/imprison.h @@ -74,6 +74,11 @@ u3_atom u3i_word(c3_w dat_w); + /* u3i_chub(): construct u3_atom from c3_d. + */ + u3_atom + u3i_chub(c3_d dat_d); + /* u3i_bytes(): Copy [a] bytes from [b] to an LSB first atom. */ u3_atom diff --git a/pkg/urbit/noun/imprison.c b/pkg/urbit/noun/imprison.c index 1f6aa3c57b..19f35e9ea8 100644 --- a/pkg/urbit/noun/imprison.c +++ b/pkg/urbit/noun/imprison.c @@ -316,6 +316,19 @@ u3i_word(c3_w dat_w) return pro; } +/* u3i_chub(): construct u3_atom from c3_d. +*/ +u3_atom +u3i_chub(c3_d dat_d) +{ + c3_w dat_w[2] = { + dat_d & 0xffffffffULL, + dat_d >> 32 + }; + + return u3i_words(2, dat_w); +} + /* u3i_bytes(): Copy [a] bytes from [b] to an LSB first atom. */ u3_atom @@ -382,24 +395,38 @@ u3_atom u3i_chubs(c3_w a_w, const c3_d* b_d) { - u3i_slab sab_u; - u3i_slab_bare(&sab_u, 6, a_w); - - u3t_on(mal_o); - { - c3_w* buf_w = sab_u.buf_w; - c3_w i_w; - c3_d i_d; - - for ( i_w = 0; i_w < a_w; i_w++ ) { - i_d = b_d[i_w]; - *buf_w++ = i_d & 0xffffffffULL; - *buf_w++ = i_d >> 32; - } + // strip trailing zeroes. + // + while ( a_w && !b_d[a_w - 1] ) { + a_w--; } - u3t_off(mal_o); - return u3i_slab_mint(&sab_u); + if ( !a_w ) { + return (u3_atom)0; + } + else if ( 1 == a_w ) { + return u3i_chub(b_d[0]); + } + else { + u3i_slab sab_u; + u3i_slab_bare(&sab_u, 6, a_w); + + u3t_on(mal_o); + { + c3_w* buf_w = sab_u.buf_w; + c3_w i_w; + c3_d i_d; + + for ( i_w = 0; i_w < a_w; i_w++ ) { + i_d = b_d[i_w]; + *buf_w++ = i_d & 0xffffffffULL; + *buf_w++ = i_d >> 32; + } + } + u3t_off(mal_o); + + return u3i_slab_mint(&sab_u); + } } /* u3i_mp(): Copy the GMP integer [a] into an atom, and clear it. From ef3ea316834a257f3d4c1a108ab6432c21a8b951 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 28 Sep 2020 22:15:22 -0700 Subject: [PATCH 403/933] u3: removes redundant condition in +dis jet --- pkg/urbit/jets/c/dis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/urbit/jets/c/dis.c b/pkg/urbit/jets/c/dis.c index a0f478a943..c9cd74f34c 100644 --- a/pkg/urbit/jets/c/dis.c +++ b/pkg/urbit/jets/c/dis.c @@ -23,7 +23,7 @@ u3i_slab_from(&sab_u, a, 5, len_w); for ( i_w = 0; i_w < len_w; i_w++ ) { - sab_u.buf_w[i_w] &= (i_w >= lnb_w) ? 0 : u3r_word(i_w, b); + sab_u.buf_w[i_w] &= u3r_word(i_w, b); } return u3i_slab_mint(&sab_u); From 187fee0406028a60de1110c1d2cd05a9f32fcebd Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 29 Sep 2020 11:48:28 -0700 Subject: [PATCH 404/933] u3: simplifies atom slab-allocation in cue implementations --- pkg/urbit/noun/serial.c | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index f9bf9d3e6c..48fd46ac86 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -612,21 +612,12 @@ _cs_cue_xeno_next(_cue_stack_t* tac_u, if ( 31 >= len_d ) { *out = (u3_noun)ur_bsr32_any(red_u, len_d); } - // XX need a ur_bsr_words_any() - // else { - c3_d byt_d = (len_d + 0x7) >> 3; + u3i_slab sab_u; + u3i_slab_init(&sab_u, 0, len_d); - if ( 0xffffffffULL < byt_d) { - return u3m_bail(c3__meme); - } - else { - u3i_slab sab_u; - u3i_slab_init(&sab_u, 3, (c3_w)byt_d); - - ur_bsr_bytes_any(red_u, len_d, sab_u.buf_y); - *out = u3i_slab_mint_bytes(&sab_u); - } + ur_bsr_bytes_any(red_u, len_d, sab_u.buf_y); + *out = u3i_slab_mint_bytes(&sab_u); } ur_dict32_put(rot_u, dic_u, bit_d, *out); @@ -841,21 +832,12 @@ _cs_cue_full_next(c3_ys mov, if ( 31 >= len_d ) { vat = (u3_noun)ur_bsr32_any(red_u, len_d); } - // XX need a ur_bsr_words_any() - // else { - c3_d byt_d = (len_d + 0x7) >> 3; + u3i_slab sab_u; + u3i_slab_init(&sab_u, 0, len_d); - if ( 0xffffffffULL < byt_d) { - return u3m_bail(c3__meme); - } - else { - u3i_slab sab_u; - u3i_slab_init(&sab_u, 3, (c3_w)byt_d); - - ur_bsr_bytes_any(red_u, len_d, sab_u.buf_y); - vat = u3i_slab_mint_bytes(&sab_u); - } + ur_bsr_bytes_any(red_u, len_d, sab_u.buf_y); + vat = u3i_slab_mint_bytes(&sab_u); } return _cs_cue_put(har_p, bit_d, vat); From 5c8fac43d435e180983ea89a4cf932951ebdadbd Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 29 Sep 2020 12:20:48 -0700 Subject: [PATCH 405/933] u3: minor refactoring/dedupication of slab implementation --- pkg/urbit/noun/imprison.c | 67 ++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 40 deletions(-) diff --git a/pkg/urbit/noun/imprison.c b/pkg/urbit/noun/imprison.c index 19f35e9ea8..f33e3ead7c 100644 --- a/pkg/urbit/noun/imprison.c +++ b/pkg/urbit/noun/imprison.c @@ -100,30 +100,10 @@ _ci_atom_mint(u3a_atom* vat_u, c3_w len_w) void u3i_slab_init(u3i_slab* sab_u, c3_g met_g, c3_d len_d) { + u3i_slab_bare(sab_u, met_g, len_d); + u3t_on(mal_o); - { - c3_d byt_d; - c3_w wor_w = _ci_slab_size(met_g, len_d, &byt_d); - - // if we only need one word, use the static storage in [sab_u] - // - if ( 1 == wor_w ) { - sab_u->_._vat_u = 0; - sab_u->buf_w = &sab_u->_._sat_w; - sab_u->wor_w = 1; - } - // allocate an indirect atom - // - else { - _ci_slab_init(sab_u, wor_w); - } - - sab_u->byt_d = byt_d; - - // XX refactor - // - memset(sab_u->buf_y, 0, (size_t)wor_w * 4); - } + memset(sab_u->buf_y, 0, (size_t)sab_u->wor_w * 4); u3t_off(mal_o); } @@ -206,17 +186,20 @@ u3i_slab_grow(u3i_slab* sab_u, c3_g met_g, c3_d len_d) void u3i_slab_free(u3i_slab* sab_u) { + c3_w len_w = sab_u->wor_w; + u3a_atom* vat_u = sab_u->_._vat_u; + u3t_on(mal_o); - if ( 1 == sab_u->wor_w ) { - c3_assert( !sab_u->_._vat_u ); + + if ( 1 == len_w ) { + c3_assert( !vat_u ); } else { - u3a_atom* vat_u = sab_u->_._vat_u; - - c3_assert( (sab_u->buf_w - c3_wiseof(u3a_atom)) == (c3_w*)vat_u ); - + c3_w* tav_w = (sab_u->buf_w - c3_wiseof(u3a_atom)); + c3_assert( tav_w == (c3_w*)vat_u ); u3a_wfree(vat_u); } + u3t_off(mal_o); } @@ -225,14 +208,16 @@ u3i_slab_free(u3i_slab* sab_u) u3_atom u3i_slab_mint(u3i_slab* sab_u) { - u3_atom pro; + c3_w len_w = sab_u->wor_w; + u3a_atom* vat_u = sab_u->_._vat_u; + u3_atom pro; u3t_on(mal_o); - if ( 1 == sab_u->wor_w ) { + if ( 1 == len_w ) { c3_w dat_w = *sab_u->buf_w; - c3_assert( !sab_u->_._vat_u ); + c3_assert( !vat_u ); u3t_off(mal_o); pro = u3i_word(dat_w); @@ -240,10 +225,11 @@ u3i_slab_mint(u3i_slab* sab_u) } else { u3a_atom* vat_u = sab_u->_._vat_u; - c3_w len_w = sab_u->wor_w; - - c3_assert( (sab_u->buf_w - c3_wiseof(u3a_atom)) == (c3_w*)vat_u ); + c3_w* tav_w = (sab_u->buf_w - c3_wiseof(u3a_atom)); + c3_assert( tav_w == (c3_w*)vat_u ); + // trim trailing zeros + // while ( len_w && !(sab_u->buf_w[len_w - 1]) ) { len_w--; } @@ -261,11 +247,13 @@ u3i_slab_mint(u3i_slab* sab_u) u3_atom u3i_slab_moot(u3i_slab* sab_u) { - u3_atom pro; + c3_w len_w = sab_u->wor_w; + u3a_atom* vat_u = sab_u->_._vat_u; + u3_atom pro; u3t_on(mal_o); - if ( 1 == sab_u->wor_w ) { + if ( 1 == len_w) { c3_w dat_w = *sab_u->buf_w; c3_assert( !sab_u->_._vat_u ); @@ -276,9 +264,8 @@ u3i_slab_moot(u3i_slab* sab_u) } else { u3a_atom* vat_u = sab_u->_._vat_u; - c3_w len_w = sab_u->wor_w; - - c3_assert( (sab_u->buf_w - c3_wiseof(u3a_atom)) == (c3_w*)vat_u ); + c3_w* tav_w = (sab_u->buf_w - c3_wiseof(u3a_atom)); + c3_assert( tav_w == (c3_w*)vat_u ); pro = _ci_atom_mint(vat_u, len_w); } From 5be91ad7b2876f17d700bddf388ed57f8536c2fd Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 29 Sep 2020 12:24:00 -0700 Subject: [PATCH 406/933] u3: tweaks u3s_jam_fib() call sites, correcting byte-length calculation --- pkg/urbit/noun/jets.c | 11 ++++------- pkg/urbit/tests/jam_tests.c | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/pkg/urbit/noun/jets.c b/pkg/urbit/noun/jets.c index 68dd54e159..4085f06a30 100644 --- a/pkg/urbit/noun/jets.c +++ b/pkg/urbit/noun/jets.c @@ -122,15 +122,12 @@ _cj_bash(u3_noun bat) } else { u3i_slab sab_u; - c3_w met_w; - c3_y* fat_y; - c3_y dig_y[32]; - - u3s_jam_fib(&sab_u, bat); + c3_w bit_w = u3s_jam_fib(&sab_u, bat); + c3_w met_w = (bit_w + 0x7) >> 3; // XX assumes little-endian // - fat_y = sab_u.buf_y; - met_w = sab_u.byt_d; + c3_y* fat_y = sab_u.buf_y; + c3_y dig_y[32]; #if defined(U3_OS_osx) CC_SHA256_CTX ctx_h; diff --git a/pkg/urbit/tests/jam_tests.c b/pkg/urbit/tests/jam_tests.c index 6d6d99cd03..3d9c367ea2 100644 --- a/pkg/urbit/tests/jam_tests.c +++ b/pkg/urbit/tests/jam_tests.c @@ -341,7 +341,7 @@ _test_jam_spec(const c3_c* cap_c, u3i_slab sab_u; c3_w bit_w = u3s_jam_fib(&sab_u, ref); - out_d = sab_u.byt_d; + out_d = ((c3_d)bit_w + 0x7) >> 3; // XX assumes little-endian // out_y = sab_u.buf_y; From e8a042cb2522b2a7848bf5fbafb568b49cc08a34 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 29 Sep 2020 12:28:22 -0700 Subject: [PATCH 407/933] u3: removes byte-length from u3i_slab --- pkg/urbit/include/noun/imprison.h | 1 - pkg/urbit/noun/imprison.c | 18 +++++------------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/pkg/urbit/include/noun/imprison.h b/pkg/urbit/include/noun/imprison.h index 288e2f4a43..aebd9620c6 100644 --- a/pkg/urbit/include/noun/imprison.h +++ b/pkg/urbit/include/noun/imprison.h @@ -16,7 +16,6 @@ c3_y* buf_y; // bytes c3_w* buf_w; // words }; // - c3_d byt_d; // byte len c3_w wor_w; // word len } u3i_slab; diff --git a/pkg/urbit/noun/imprison.c b/pkg/urbit/noun/imprison.c index f33e3ead7c..6376deb0b3 100644 --- a/pkg/urbit/noun/imprison.c +++ b/pkg/urbit/noun/imprison.c @@ -6,7 +6,7 @@ /* _ci_slab_size(): calculate slab bloq-size, checking for overflow. */ static c3_w -_ci_slab_size(c3_g met_g, c3_d len_d, c3_d* out_d) +_ci_slab_size(c3_g met_g, c3_d len_d) { c3_d bit_d = len_d << met_g; c3_d byt_d = (bit_d + 0x7) >> 3; @@ -18,10 +18,8 @@ _ci_slab_size(c3_g met_g, c3_d len_d, c3_d* out_d) { return (c3_w)u3m_bail(c3__fail); } - else { - *out_d = byt_d; - return wor_w; - } + + return wor_w; } /* _ci_slab_init(): initialize slab with heap allocation. @@ -114,8 +112,7 @@ u3i_slab_bare(u3i_slab* sab_u, c3_g met_g, c3_d len_d) { u3t_on(mal_o); { - c3_d byt_d; - c3_w wor_w = _ci_slab_size(met_g, len_d, &byt_d); + c3_w wor_w = _ci_slab_size(met_g, len_d); // if we only need one word, use the static storage in [sab_u] // @@ -129,8 +126,6 @@ u3i_slab_bare(u3i_slab* sab_u, c3_g met_g, c3_d len_d) else { _ci_slab_init(sab_u, wor_w); } - - sab_u->byt_d = byt_d; } u3t_off(mal_o); } @@ -154,8 +149,7 @@ u3i_slab_grow(u3i_slab* sab_u, c3_g met_g, c3_d len_d) { u3t_on(mal_o); { - c3_d byt_d; - c3_w wor_w = _ci_slab_size(met_g, len_d, &byt_d); + c3_w wor_w = _ci_slab_size(met_g, len_d); // XX actually shrink? // @@ -175,8 +169,6 @@ u3i_slab_grow(u3i_slab* sab_u, c3_g met_g, c3_d len_d) else { _ci_slab_grow(sab_u, wor_w); } - - sab_u->byt_d = byt_d; } u3t_off(mal_o); } From 190297266a02d07ec29d25bae5d4f27f4bc418cd Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 29 Sep 2020 12:33:37 -0700 Subject: [PATCH 408/933] u3: renames word-length in u3i_slab --- pkg/urbit/include/noun/imprison.h | 2 +- pkg/urbit/noun/imprison.c | 29 ++++++++++++++--------------- pkg/urbit/noun/serial.c | 4 ++-- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/pkg/urbit/include/noun/imprison.h b/pkg/urbit/include/noun/imprison.h index aebd9620c6..8809f24e57 100644 --- a/pkg/urbit/include/noun/imprison.h +++ b/pkg/urbit/include/noun/imprison.h @@ -16,7 +16,7 @@ c3_y* buf_y; // bytes c3_w* buf_w; // words }; // - c3_w wor_w; // word len + c3_w len_w; // word length } u3i_slab; /* staged atom-building api diff --git a/pkg/urbit/noun/imprison.c b/pkg/urbit/noun/imprison.c index 6376deb0b3..c3630ce30b 100644 --- a/pkg/urbit/noun/imprison.c +++ b/pkg/urbit/noun/imprison.c @@ -9,8 +9,7 @@ static c3_w _ci_slab_size(c3_g met_g, c3_d len_d) { c3_d bit_d = len_d << met_g; - c3_d byt_d = (bit_d + 0x7) >> 3; - c3_d wor_d = (byt_d + 0x3) >> 2; + c3_d wor_d = (bit_d + 0x1f) >> 5; c3_w wor_w = (c3_w)wor_d; if ( (wor_w != wor_d) @@ -23,7 +22,7 @@ _ci_slab_size(c3_g met_g, c3_d len_d) } /* _ci_slab_init(): initialize slab with heap allocation. -** NB: [len_w] must be >0 +** NB: callers must ensure [len_w] >0 */ static void _ci_slab_init(u3i_slab* sab_u, c3_w len_w) @@ -36,7 +35,7 @@ _ci_slab_init(u3i_slab* sab_u, c3_w len_w) sab_u->_._vat_u = vat_u; sab_u->buf_w = vat_u->buf_w; - sab_u->wor_w = len_w; + sab_u->len_w = len_w; } /* _ci_slab_grow(): update slab with heap reallocation. @@ -54,7 +53,7 @@ _ci_slab_grow(u3i_slab* sab_u, c3_w len_w) sab_u->_._vat_u = vat_u; sab_u->buf_w = vat_u->buf_w; - sab_u->wor_w = len_w; + sab_u->len_w = len_w; } /* _ci_atom_mint(): finalize a heap-allocated atom at specified length. @@ -101,7 +100,7 @@ u3i_slab_init(u3i_slab* sab_u, c3_g met_g, c3_d len_d) u3i_slab_bare(sab_u, met_g, len_d); u3t_on(mal_o); - memset(sab_u->buf_y, 0, (size_t)sab_u->wor_w * 4); + memset(sab_u->buf_y, 0, (size_t)sab_u->len_w * 4); u3t_off(mal_o); } @@ -119,7 +118,7 @@ u3i_slab_bare(u3i_slab* sab_u, c3_g met_g, c3_d len_d) if ( 1 == wor_w ) { sab_u->_._vat_u = 0; sab_u->buf_w = &sab_u->_._sat_w; - sab_u->wor_w = 1; + sab_u->len_w = 1; } // allocate an indirect atom // @@ -139,7 +138,7 @@ u3i_slab_from(u3i_slab* sab_u, u3_atom a, c3_g met_g, c3_d len_d) // copies [a], zero-initializes any additional space // - u3r_words(0, sab_u->wor_w, sab_u->buf_w, a); + u3r_words(0, sab_u->len_w, sab_u->buf_w, a); } /* u3i_slab_grow(): resize slab, reallocating as necessary. @@ -153,12 +152,12 @@ u3i_slab_grow(u3i_slab* sab_u, c3_g met_g, c3_d len_d) // XX actually shrink? // - if ( wor_w <= sab_u->wor_w ) { - sab_u->wor_w = wor_w; + if ( wor_w <= sab_u->len_w ) { + sab_u->len_w = wor_w; } // upgrade from static storage // - else if ( 1 == sab_u->wor_w ) { + else if ( 1 == sab_u->len_w ) { c3_w dat_w = *sab_u->buf_w; _ci_slab_init(sab_u, wor_w); @@ -178,7 +177,7 @@ u3i_slab_grow(u3i_slab* sab_u, c3_g met_g, c3_d len_d) void u3i_slab_free(u3i_slab* sab_u) { - c3_w len_w = sab_u->wor_w; + c3_w len_w = sab_u->len_w; u3a_atom* vat_u = sab_u->_._vat_u; u3t_on(mal_o); @@ -200,7 +199,7 @@ u3i_slab_free(u3i_slab* sab_u) u3_atom u3i_slab_mint(u3i_slab* sab_u) { - c3_w len_w = sab_u->wor_w; + c3_w len_w = sab_u->len_w; u3a_atom* vat_u = sab_u->_._vat_u; u3_atom pro; @@ -239,7 +238,7 @@ u3i_slab_mint(u3i_slab* sab_u) u3_atom u3i_slab_moot(u3i_slab* sab_u) { - c3_w len_w = sab_u->wor_w; + c3_w len_w = sab_u->len_w; u3a_atom* vat_u = sab_u->_._vat_u; u3_atom pro; @@ -332,7 +331,7 @@ u3i_bytes(c3_w a_w, { // zero-initialize last word // - sab_u.buf_w[sab_u.wor_w - 1] = 0; + sab_u.buf_w[sab_u.len_w - 1] = 0; memcpy(sab_u.buf_y, b_y, a_w); } u3t_off(mal_o); diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index 48fd46ac86..671db80430 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -32,7 +32,7 @@ _cs_jam_fib_grow(struct _cs_jam_fib* fib_u, c3_w mor_w) } if ( wan_w > fib_u->a_w ) { - c3_w old_w = fib_u->sab_u->wor_w; + c3_w old_w = fib_u->sab_u->len_w; c3_w c_w = 0; // fibonacci growth @@ -46,7 +46,7 @@ _cs_jam_fib_grow(struct _cs_jam_fib* fib_u, c3_w mor_w) u3i_slab_grow(fib_u->sab_u, 0, c_w); { - c3_w dif_w = fib_u->sab_u->wor_w - old_w; + c3_w dif_w = fib_u->sab_u->len_w - old_w; c3_w* buf_w = fib_u->sab_u->buf_w + old_w; memset(buf_w, 0, dif_w * sizeof(c3_w)); } From f6279181bb0a919b8547333a62704495213bfbc7 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 29 Sep 2020 12:36:13 -0700 Subject: [PATCH 409/933] u3: adds debug assertion for atom-allocation internal invariant --- pkg/urbit/noun/imprison.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/urbit/noun/imprison.c b/pkg/urbit/noun/imprison.c index c3630ce30b..71d530e6de 100644 --- a/pkg/urbit/noun/imprison.c +++ b/pkg/urbit/noun/imprison.c @@ -33,6 +33,10 @@ _ci_slab_init(u3i_slab* sab_u, c3_w len_w) vat_u->mug_w = 0; vat_u->len_w = len_w; +#ifdef U3_MEMORY_DEBUG + c3_assert( len_w ); +#endif + sab_u->_._vat_u = vat_u; sab_u->buf_w = vat_u->buf_w; sab_u->len_w = len_w; From e189aa13a62ec7fc550d38f2956fcb0c509465fd Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 29 Sep 2020 12:46:16 -0700 Subject: [PATCH 410/933] u3: updates u3i_slab_grow() to always zero-initialize new space --- pkg/urbit/include/noun/imprison.h | 2 +- pkg/urbit/noun/imprison.c | 36 ++++++++++++++++++++----------- pkg/urbit/noun/serial.c | 6 ------ 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/pkg/urbit/include/noun/imprison.h b/pkg/urbit/include/noun/imprison.h index 8809f24e57..71c692242a 100644 --- a/pkg/urbit/include/noun/imprison.h +++ b/pkg/urbit/include/noun/imprison.h @@ -36,7 +36,7 @@ void u3i_slab_from(u3i_slab* sab_u, u3_atom a, c3_g met_g, c3_d len_d); - /* u3i_slab_grow(): resize slab, reallocating as necessary. + /* u3i_slab_grow(): resize slab, zero-initializing new space. */ void u3i_slab_grow(u3i_slab* sab_u, c3_g met_g, c3_d len_d); diff --git a/pkg/urbit/noun/imprison.c b/pkg/urbit/noun/imprison.c index 71d530e6de..0e1dbfd4c1 100644 --- a/pkg/urbit/noun/imprison.c +++ b/pkg/urbit/noun/imprison.c @@ -145,32 +145,42 @@ u3i_slab_from(u3i_slab* sab_u, u3_atom a, c3_g met_g, c3_d len_d) u3r_words(0, sab_u->len_w, sab_u->buf_w, a); } -/* u3i_slab_grow(): resize slab, reallocating as necessary. +/* u3i_slab_grow(): resize slab, zero-initializing new space. */ void u3i_slab_grow(u3i_slab* sab_u, c3_g met_g, c3_d len_d) { + c3_w old_w = sab_u->len_w; + u3t_on(mal_o); { c3_w wor_w = _ci_slab_size(met_g, len_d); // XX actually shrink? // - if ( wor_w <= sab_u->len_w ) { + if ( wor_w <= old_w ) { sab_u->len_w = wor_w; } - // upgrade from static storage - // - else if ( 1 == sab_u->len_w ) { - c3_w dat_w = *sab_u->buf_w; - - _ci_slab_init(sab_u, wor_w); - sab_u->buf_w[0] = dat_w; - } - // reallocate - // else { - _ci_slab_grow(sab_u, wor_w); + // upgrade from static storage + // + if ( 1 == old_w ) { + c3_w dat_w = *sab_u->buf_w; + + _ci_slab_init(sab_u, wor_w); + sab_u->buf_w[0] = dat_w; + } + // reallocate + // + else { + _ci_slab_grow(sab_u, wor_w); + } + + { + c3_y* buf_y = (void*)(sab_u->buf_w + old_w); + size_t dif_i = wor_w - old_w; + memset(buf_y, 0, dif_i * 4); + } } } u3t_off(mal_o); diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index 671db80430..5d6cc932fa 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -44,12 +44,6 @@ _cs_jam_fib_grow(struct _cs_jam_fib* fib_u, c3_w mor_w) } u3i_slab_grow(fib_u->sab_u, 0, c_w); - - { - c3_w dif_w = fib_u->sab_u->len_w - old_w; - c3_w* buf_w = fib_u->sab_u->buf_w + old_w; - memset(buf_w, 0, dif_w * sizeof(c3_w)); - } } } From 54d7b85cabfd97409c20c8426edeada999a2511a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 29 Sep 2020 12:55:06 -0700 Subject: [PATCH 411/933] u3: updates u3i_slab implementation to normalize zero-length allocations to 1 --- pkg/urbit/noun/imprison.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/urbit/noun/imprison.c b/pkg/urbit/noun/imprison.c index 0e1dbfd4c1..8277d43e25 100644 --- a/pkg/urbit/noun/imprison.c +++ b/pkg/urbit/noun/imprison.c @@ -119,7 +119,7 @@ u3i_slab_bare(u3i_slab* sab_u, c3_g met_g, c3_d len_d) // if we only need one word, use the static storage in [sab_u] // - if ( 1 == wor_w ) { + if ( (0 == wor_w) || (1 == wor_w) ) { sab_u->_._vat_u = 0; sab_u->buf_w = &sab_u->_._sat_w; sab_u->len_w = 1; From e03c8f34a0ff6685d2a7cf5dffee44fa2fac14cd Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 30 Sep 2020 17:59:07 -0700 Subject: [PATCH 412/933] u3: updates u3qe_en_base16() to use slab api --- pkg/urbit/jets/e/base.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/pkg/urbit/jets/e/base.c b/pkg/urbit/jets/e/base.c index 409cc659d3..a387153422 100644 --- a/pkg/urbit/jets/e/base.c +++ b/pkg/urbit/jets/e/base.c @@ -9,21 +9,18 @@ const c3_y hex_y[16] = { '0', '1', '2', '3', '4', '5', '6', '7', u3_noun u3qe_en_base16(u3_atom len, u3_atom dat) { - c3_w len_w, byt_w; - if ( c3n == u3a_is_cat(len) ) { return u3m_bail(c3__fail); } else { - len_w = (c3_w)len; - byt_w = len_w * 2; + c3_w len_w = (c3_w)len; + u3i_slab sab_u; - if ( (byt_w / 2) != len_w ) { - return u3m_bail(c3__fail); - } - else { - c3_y* buf_y = u3a_malloc(byt_w); - c3_y* dat_y = buf_y; + u3i_slab_bare(&sab_u, 4, len_w); + sab_u.buf_w[sab_u.len_w - 1] = 0; + + { + c3_y* buf_y = sab_u.buf_y; c3_y inp_y; while ( len_w-- ) { @@ -32,13 +29,9 @@ u3qe_en_base16(u3_atom len, u3_atom dat) *buf_y++ = hex_y[inp_y >> 4]; *buf_y++ = hex_y[inp_y & 0xf]; } - - { - u3_noun pro = u3i_bytes(byt_w, dat_y); - u3a_free(dat_y); - return pro; - } } + + return u3i_slab_moot_bytes(&sab_u); } } From b3746e1cbadefdbd44454bb09bb8a5c2b27f4f0c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 30 Sep 2020 18:06:17 -0700 Subject: [PATCH 413/933] u3: updates u3qe_de_base16() to use slab api --- pkg/urbit/jets/e/base.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/pkg/urbit/jets/e/base.c b/pkg/urbit/jets/e/base.c index a387153422..021b055cce 100644 --- a/pkg/urbit/jets/e/base.c +++ b/pkg/urbit/jets/e/base.c @@ -111,30 +111,30 @@ _of_hex_even(u3_atom inp, c3_w len_w, c3_y* buf_y) u3_noun u3qe_de_base16(u3_atom inp) { - c3_w len_w = u3r_met(4, inp); - c3_y* buf_y = u3a_malloc(len_w); - c3_o ret_o; + c3_w len_w = u3r_met(4, inp); + u3i_slab sab_u; + u3i_slab_bare(&sab_u, 3, len_w); + sab_u.buf_w[sab_u.len_w - 1] = 0; + + // even byte-length input can be parsed in aligned, 16-bit increments, + // but odd byte-length input cannot, and is expressed more simply in bytes. + // { c3_w byt_w = u3r_met(3, inp); + c3_o ret_o = ( byt_w & 1 ) + ? _of_hex_odd(inp, len_w, byt_w, sab_u.buf_y) + : _of_hex_even(inp, len_w, sab_u.buf_y); - if ( byt_w & 1 ) { - ret_o = _of_hex_odd(inp, len_w, byt_w, buf_y); + if ( c3n == ret_o ) { + u3i_slab_free(&sab_u); + return u3_nul; } else { - ret_o = _of_hex_even(inp, len_w, buf_y); + u3_noun dat = u3i_slab_mint_bytes(&sab_u); + return u3nt(u3_nul, u3i_word(len_w), dat); } } - - if ( c3n == ret_o ) { - u3a_free(buf_y); - return u3_nul; - } - else { - u3_noun dat = u3i_bytes(len_w, buf_y); - u3a_free(buf_y); - return u3nt(u3_nul, u3i_words(1, &len_w), dat); - } } u3_noun From 220b01e921bf22fe6bb2eb9a3c8cbf4be70eea65 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 30 Sep 2020 18:38:51 -0700 Subject: [PATCH 414/933] u3: updates +leer and +lore jets to use slab api --- pkg/urbit/jets/e/lore.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/pkg/urbit/jets/e/lore.c b/pkg/urbit/jets/e/lore.c index 64819622e5..e454aa68da 100644 --- a/pkg/urbit/jets/e/lore.c +++ b/pkg/urbit/jets/e/lore.c @@ -3,25 +3,20 @@ */ #include "all.h" - static u3_noun - _lore_cut(c3_w pos_w, c3_w len_w, u3_noun src) + static u3_atom + _lore_cut(c3_w pos_w, c3_w len_w, u3_atom src) { if ( 0 == len_w ) { return 0; } else { - // as an optimization, we alloc small lines on the stack - // (only small to prevent stack overflow) - c3_t big_t = len_w > 255; - c3_y* buf_y = big_t ? u3a_malloc(len_w) : alloca(len_w); - u3_noun red; + u3i_slab sab_u; + u3i_slab_bare(&sab_u, 3, len_w); + sab_u.buf_w[sab_u.len_w - 1] = 0; - u3r_bytes(pos_w, len_w, buf_y, src); - red = u3i_bytes(len_w, buf_y); - if ( big_t ) { - u3a_free(buf_y); - } - return red; + u3r_bytes(pos_w, len_w, sab_u.buf_y, src); + + return u3i_slab_mint_bytes(&sab_u); } } From 1bce077ab438258451196c573338ad77e490c8be Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 1 Oct 2020 15:54:36 +0200 Subject: [PATCH 415/933] vere: don't crash when slogging during replay We're not guaranteed to have the sog_f callback set when _pier_on_lord_slog gets called, so we should make sure there's a function there before we call it. --- pkg/urbit/vere/pier.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index cc330e28b4..b45718b1ea 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -972,11 +972,21 @@ _pier_on_lord_slog(void* ptr_v, c3_w pri_w, u3_noun tan) u3C.stderr_log_f(tan_c); c3_free(tan_c); - pir_u->sog_f(pir_u->sop_p, pri_w, tan); + if ( 0 != pir_u->sog_f ) { + pir_u->sog_f(pir_u->sop_p, pri_w, tan); + } + else { + u3z(tan); + } } else { u3_pier_tank(0, pri_w, u3k(tan)); - pir_u->sog_f(pir_u->sop_p, pri_w, tan); + if ( 0 != pir_u->sog_f ) { + pir_u->sog_f(pir_u->sop_p, pri_w, tan); + } + else { + u3z(tan); + } } } From 6b0aa04a0f97485c16aaf750664638703b5109c2 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 1 Oct 2020 15:59:41 +0200 Subject: [PATCH 416/933] vere: don't close slog stream on-heartbeat It was erroneously flagging the heartbeat responses as "complete". --- pkg/urbit/vere/io/http.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/urbit/vere/io/http.c b/pkg/urbit/vere/io/http.c index b146f3968b..1067b66a26 100644 --- a/pkg/urbit/vere/io/http.c +++ b/pkg/urbit/vere/io/http.c @@ -1924,7 +1924,7 @@ _http_seq_heartbeat_cb(uv_timer_t* tim_u) if ( 0 != seq_u ) { u3_noun dat = u3nt(u3_nul, 1, c3_s1('\n')); while ( 0 != seq_u ) { - _http_continue_respond(seq_u, u3k(dat), c3y); + _http_continue_respond(seq_u, u3k(dat), c3n); seq_u = seq_u->nex_u; } u3z(dat); From 4b2d2b5931155326846ed7977d999c377f3ad108 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 1 Oct 2020 11:10:30 -0400 Subject: [PATCH 417/933] king: more review comments --- pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs | 12 ++++++------ pkg/hs/urbit-king/lib/Urbit/Vere/Term/Demux.hs | 10 +++++----- pkg/hs/urbit-king/lib/Urbit/Vere/Term/Logic.hs | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs index 61554dbf04..27a9e6e12f 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs @@ -186,8 +186,8 @@ localClient doneSignal = fst <$> mkRAcquire start stop -- Track the terminal size, keeping track of the size of the local -- terminal for our own printing, as well as putting size changes into an -- event queue so we can send changes to the terminal muxing system. - tsizeTVar <- newTVarIO (TermSize 80 24) -- Value doesn't matter. - tsSizeChangeQueue <- newTQueueIO + tsizeTVar <- newTVarIO (TermSize 80 24) -- Value doesn't matter. + tsSizeChange <- newEmptyTMVarIO io $ T.liveTermSize (\ts -> atomically $ do -- We keep track of the console's local size for -- our own tank washing. @@ -195,7 +195,7 @@ localClient doneSignal = fst <$> mkRAcquire start stop -- We queue up changes so we can broadcast them -- to the muxing client. - writeTQueue tsSizeChangeQueue ts) + putTMVar tsSizeChange ts) pWriterThread <- asyncBound (writeTerminal tsWriteQueue spinnerMVar tsizeTVar) @@ -215,9 +215,9 @@ localClient doneSignal = fst <$> mkRAcquire start stop pReaderThread <- asyncBound (readTerminal tsReadQueue tsWriteQueue (bell tsWriteQueue)) - let client = Client { take = Just <$> asum [ - readTQueue tsReadQueue <&> ClientTakeBelt, - readTQueue tsSizeChangeQueue <&> ClientTakeSize + let client = Client { take = Just <$> asum + [ readTQueue tsReadQueue <&> ClientTakeBelt, + takeTMVar tsSizeChange <&> ClientTakeSize ] , give = writeTQueue tsWriteQueue } diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Term/Demux.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Term/Demux.hs index c4e98ced7d..e9e7748675 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Term/Demux.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Term/Demux.hs @@ -95,12 +95,12 @@ dTake Demux{..} = do (_, Just (ClientTakeBelt b)) -> pure (Just (ClientTakeBelt b)) (k, Just (ClientTakeSize s)) -> do - newSizeTree <- modifyAndReturnTVar dSizes (insertMap k s) + newSizeTree <- modifyAndReadTVar' dSizes (insertMap k s) maybeUpdateTerminalSize newSizeTree (k, Nothing) -> do writeTVar dConns (ksDelete k conns) - newSizeTree <- modifyAndReturnTVar dSizes (deleteMap k) + newSizeTree <- modifyAndReadTVar' dSizes (deleteMap k) maybeUpdateTerminalSize newSizeTree where @@ -120,10 +120,10 @@ dTake Demux{..} = do writeTVar dMinSize termSize pure $ Just (ClientTakeSize termSize) - modifyAndReturnTVar :: TVar a -> (a -> a) -> STM a - modifyAndReturnTVar var fun = do + modifyAndReadTVar' :: TVar a -> (a -> a) -> STM a + modifyAndReadTVar' var fun = do pre <- readTVar var - let post = fun pre + let !post = fun pre writeTVar var post pure post diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Term/Logic.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Term/Logic.hs index b4f26d4977..0d63bff43f 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Term/Logic.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Term/Logic.hs @@ -110,7 +110,7 @@ step st@St{..} = \case drawState :: St -> [Ev] drawState St{..} = hist <> out <> cur <> spin where - hist = fmap drawHistory $ toList sHistory + hist = drawHistory <$> toList sHistory out = if null sLine then [] else [EvEdit sLine] cur = if 0 == sCurPos then [] else [EvMove $ fromIntegral $ sCurPos] spin = maybe [] (singleton . EvSpin . Just) sSpinner From d0d9437a935895cf54028919daf96b3d0d980680 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 1 Oct 2020 19:58:58 +0200 Subject: [PATCH 418/933] vere: require authentication for webslogs By scrying into Eyre to see if the cookie included in the request makes it an authenticated request. Depends on #3628. --- pkg/urbit/vere/io/http.c | 141 ++++++++++++++++++++++++++++----------- 1 file changed, 102 insertions(+), 39 deletions(-) diff --git a/pkg/urbit/vere/io/http.c b/pkg/urbit/vere/io/http.c index 1067b66a26..b4f1e796d0 100644 --- a/pkg/urbit/vere/io/http.c +++ b/pkg/urbit/vere/io/http.c @@ -801,42 +801,118 @@ typedef struct _h2o_uv_sock { // see private st_h2o_uv_socket_t uv_stream_t* han_u; // client stream handler (u3_hcon) } h2o_uv_sock; +/* _http_req_prepare(): creates u3 req from h2o req and initializes its timer +*/ +static u3_hreq* +_http_req_prepare(h2o_req_t* rec_u, + u3_hreq* (*new_f)(u3_hcon*, h2o_req_t*)) +{ + h2o_uv_sock* suv_u = (h2o_uv_sock*)rec_u->conn-> + callbacks->get_socket(rec_u->conn); + u3_hcon* hon_u = (u3_hcon*)suv_u->han_u; + + // sanity check + c3_assert( hon_u->sok_u == &suv_u->sok_u ); + + u3_hreq* seq_u = new_f(hon_u, rec_u); + + seq_u->tim_u = c3_malloc(sizeof(*seq_u->tim_u)); + seq_u->tim_u->data = seq_u; + uv_timer_init(u3L, seq_u->tim_u); + uv_timer_start(seq_u->tim_u, _http_req_timer_cb, 600 * 1000, 0); + + return seq_u; +} + +static void +_http_seq_continue(void* vod_p, u3_noun nun) +{ + h2o_req_t* rec_u = vod_p; + u3_weak aut = u3r_at(7, nun); + + // if the request is authenticated properly, send slogstream/sse headers + // + if ( c3y == aut ) { + u3_hreq* req_u = _http_req_prepare(rec_u, _http_seq_new); + u3_noun hed = u3nl(u3nc(u3i_string("Content-Type"), + u3i_string("text/event-stream")), + u3nc(u3i_string("Cache-Control"), + u3i_string("no-cache")), + u3nc(u3i_string("Connection"), + u3i_string("keep-alive")), + u3_none); + + _http_start_respond(req_u, 200, hed, u3_nul, c3n); + } + // if the scry failed, the result is unexpected, or there is no auth, + // respond with the appropriate status code + // + else { + //NOTE we use req_new because we don't want to consider this a slog stream + // request, but this means we need to manuualy skip past the "in event + // queue" state on the hreq. + u3_hreq* req_u = _http_req_prepare(rec_u, _http_req_new); + req_u->sat_e = u3_rsat_plan; + + if ( c3n == aut ) { + _http_start_respond(req_u, 403, u3_nul, u3_nul, c3y); + } + else if ( u3_none == aut ) { + u3l_log("http: authentication scry failed\n"); + _http_start_respond(req_u, 500, u3_nul, u3_nul, c3y); + } + else { + u3m_p("http: weird authentication scry result", aut); + _http_start_respond(req_u, 500, u3_nul, u3_nul, c3y); + } + } + + u3z(nun); +} + /* _http_seq_accept(): handle incoming http request on slogstream endpoint */ static int _http_seq_accept(h2o_handler_t* han_u, h2o_req_t* rec_u) { - // store the request in state + // try to find a cookie header // - u3_hreq* seq_u; + u3_weak coo = u3_none; { + u3_noun hed = _http_heds_to_noun(rec_u->headers.entries, + rec_u->headers.size); + u3_noun deh = hed; + while ( u3_nul != deh ) { + if ( c3y == u3r_sing_c("cookie", u3h(u3h(deh))) ) { + coo = u3k(u3t(u3h(deh))); + //TODO http2 allows the client to put multiple 'cookie' headers + break; + } + deh = u3t(deh); + } + u3z(hed); + } + + // if there is no cookie header, it can't possibly be authenticated + // + if ( u3_none == coo ) { + u3_hreq* req_u = _http_req_prepare(rec_u, _http_req_new); + req_u->sat_e = u3_rsat_plan; + _http_start_respond(req_u, 403, u3_nul, u3_nul, c3y); + } + // if there is a cookie, scry to see if it constitutes authentication + // + else { h2o_uv_sock* suv_u = (h2o_uv_sock*)rec_u->conn-> callbacks->get_socket(rec_u->conn); u3_hcon* hon_u = (u3_hcon*)suv_u->han_u; - // sanity check - c3_assert( hon_u->sok_u == &suv_u->sok_u ); - - seq_u = _http_seq_new(hon_u, rec_u); - - seq_u->tim_u = c3_malloc(sizeof(*seq_u->tim_u)); - seq_u->tim_u->data = seq_u; - uv_timer_init(u3L, seq_u->tim_u); - uv_timer_start(seq_u->tim_u, _http_req_timer_cb, 600 * 1000, 0); - } - - // send the initial response - // - { - u3_noun hed = u3nl(u3nc(u3i_string("Content-Type"), - u3i_string("text/event-stream")), - u3nc(u3i_string("Cache-Control"), - u3i_string("no-cache")), - u3nc(u3i_string("Connection"), - u3i_string("keep-alive")), - u3_none); - - _http_start_respond(seq_u, 200, hed, u3_nul, c3n); + u3_noun pax = u3nq(u3i_string("authenticated"), + u3i_string("cookie"), + u3dc("scot", 't', coo), + u3_nul); + u3_pier_peek_last(hon_u->htp_u->htd_u->car_u.pir_u, u3_nul, c3__ex, + u3_nul, pax, rec_u, _http_seq_continue); } return 0; @@ -858,20 +934,7 @@ _http_rec_accept(h2o_handler_t* han_u, h2o_req_t* rec_u) h2o_send_error_generic(rec_u, 400, msg_c, msg_c, 0); } else { - h2o_uv_sock* suv_u = (h2o_uv_sock*)rec_u->conn-> - callbacks->get_socket(rec_u->conn); - u3_hcon* hon_u = (u3_hcon*)suv_u->han_u; - - // sanity check - c3_assert( hon_u->sok_u == &suv_u->sok_u ); - - u3_hreq* req_u = _http_req_new(hon_u, rec_u); - - req_u->tim_u = c3_malloc(sizeof(*req_u->tim_u)); - req_u->tim_u->data = req_u; - uv_timer_init(u3L, req_u->tim_u); - uv_timer_start(req_u->tim_u, _http_req_timer_cb, 600 * 1000, 0); - + u3_hreq* req_u = _http_req_prepare(rec_u, _http_req_new); _http_req_dispatch(req_u, req); } From 6266df6f30d27c88c3769e6fc4f3f51db0948787 Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 2 Oct 2020 01:32:20 +0200 Subject: [PATCH 419/933] vere: include %ex mote --- pkg/urbit/include/c/motes.h | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/urbit/include/c/motes.h b/pkg/urbit/include/c/motes.h index af29527feb..6765024610 100644 --- a/pkg/urbit/include/c/motes.h +++ b/pkg/urbit/include/c/motes.h @@ -380,6 +380,7 @@ # define c3__emph c3_s4('e','m','p','h') # define c3__end c3_s3('e','n','d') # define c3__eq c3_s2('e','q') +# define c3__ex c3_s2('e','x') # define c3__esh c3_s3('e','s','h') # define c3__ergo c3_s4('e','r','g','o') # define c3__etch c3_s4('e','t','c','h') From 236dd0b8945ca231bd8a4c797d78f4a6addd9f29 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 1 Oct 2020 17:14:13 -0700 Subject: [PATCH 420/933] u3: cleans up comments, fixing typos --- pkg/urbit/noun/allocate.c | 11 +++++++---- pkg/urbit/noun/retrieve.c | 26 +++++++++++++------------- pkg/urbit/noun/serial.c | 7 +++---- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/pkg/urbit/noun/allocate.c b/pkg/urbit/noun/allocate.c index 68892b1af2..ed99f1b454 100644 --- a/pkg/urbit/noun/allocate.c +++ b/pkg/urbit/noun/allocate.c @@ -1094,6 +1094,9 @@ _ca_take_cell(u3a_cell* old_u, u3_noun hed, u3_noun tel) return new; } +/* _ca_take: stack frame for recording cell travesal +** (u3_none == hed) == head-frame +*/ typedef struct _ca_take { u3_weak hed; // taken head @@ -1232,7 +1235,7 @@ _ca_take_north(u3_noun veb) fam_u = u3a_peek(&pil_u); do { - // fam_u is a head-frame: stash copy and continue into the tail + // head-frame: stash copy and continue into the tail // if ( u3_none == fam_u->hed ) { u3a_cell* old_u = u3a_to_ptr(fam_u->old); @@ -1240,7 +1243,7 @@ _ca_take_north(u3_noun veb) pro = _ca_take_next_north(&pil_u, old_u->tel); fam_u = u3a_peek(&pil_u); } - // fam_u is a tail-frame: copy cell and pop the stack + // tail-frame: copy cell and pop the stack // else { u3a_cell* old_u = u3a_to_ptr(fam_u->old); @@ -1272,7 +1275,7 @@ _ca_take_south(u3_noun veb) fam_u = u3a_peek(&pil_u); do { - // fam_u is a head-frame: stash copy and continue into the tail + // head-frame: stash copy and continue into the tail // if ( u3_none == fam_u->hed ) { u3a_cell* old_u = u3a_to_ptr(fam_u->old); @@ -1280,7 +1283,7 @@ _ca_take_south(u3_noun veb) pro = _ca_take_next_south(&pil_u, old_u->tel); fam_u = u3a_peek(&pil_u); } - // fam_u is a tail-frame: copy cell and pop the stack + // tail-frame: copy cell and pop the stack // else { u3a_cell* old_u = u3a_to_ptr(fam_u->old); diff --git a/pkg/urbit/noun/retrieve.c b/pkg/urbit/noun/retrieve.c index cd8826e6f6..37b98d8581 100644 --- a/pkg/urbit/noun/retrieve.c +++ b/pkg/urbit/noun/retrieve.c @@ -221,14 +221,14 @@ u3r_mean(u3_noun som, ...) // stack frame for tracking noun comparison and unification // -// We're always comparing arbitrary nouns in a %none frame. -// When we comparing two cells, we change the none frame to -// a head-frame and push a new %none frame for the heads. -// If the heads were equal, the head-frame has the context to -// unify their head pointers. We then repeat with the tails, +// we always comparing arbitrary nouns in a none-frame. +// when we compare two cells, we change the none-frame to a +// head-frame and push a new none-frame for the heads. +// if the heads are equal, the head-frame has the context to +// unify their head pointers. we then repeat with the tails, // mutatis mutandis. // -// In Hoon, this structure would be as follows: +// in Hoon, this structure would be: // // $% [%none a=* b=*] // [%head a=^ b=^] @@ -262,7 +262,7 @@ _cr_sing_push(u3a_pile* pil_u, u3_noun a, u3_noun b) static inline c3_o _cr_sing_mug(u3a_noun* a_u, u3a_noun* b_u) { - // XX debug assertions that both mugs are 31-bit + // XX add debug assertions that both mugs are 31-bit // (ie, not u3a_take() relocation references) // if ( a_u->mug_w && b_u->mug_w && (a_u->mug_w != b_u->mug_w) ) { @@ -456,7 +456,7 @@ _cr_sing_cape(u3a_pile* pil_u, u3p(u3h_root) har_p) return c3y; } -/* _cr_sing(): yes if a and b are the same noun, use uni to unify +/* _cr_sing(): unifying equality. */ static c3_o _cr_sing(u3_noun a, u3_noun b) @@ -550,7 +550,7 @@ _cr_sing(u3_noun a, u3_noun b) // [ovr_s] counts comparisons, if it overflows, we've likely hit // a pathological case (highly duplicated tree), so we de-duplicate - // subsequent comparisons by maintaing a set of equal pairs. + // subsequent comparisons by maintaining a set of equal pairs. // if ( 0 == ++ovr_s ) { u3p(u3h_root) har_p = u3h_new(); @@ -1543,7 +1543,7 @@ u3r_mug_cell(u3_noun hed, return u3r_mug_both(lus_w, biq_w); } -/* _cr_mug: stack frame for recording cell travesal +/* _cr_mug: stack frame for recording cell traversal ** !mug == head-frame */ typedef struct { @@ -1569,7 +1569,7 @@ _cr_mug_next(u3a_pile* pil_u, u3_noun veb) // veb has already been mugged, return memoized value // - // XX debug mode, assert 31-bit? + // XX add debug assertion that mug is 31-bit? // if ( veb_u->mug_w ) { return (c3_l)veb_u->mug_w; @@ -1628,7 +1628,7 @@ u3r_mug(u3_noun veb) fam_u = u3a_peek(&pil_u); do { - // fam_u is a head-frame: stash mug and continue into the tail + // head-frame: stash mug and continue into the tail // if ( !fam_u->mug_l ) { u3a_cell* cel_u = u3a_to_ptr(fam_u->cel); @@ -1637,7 +1637,7 @@ u3r_mug(u3_noun veb) mug_l = _cr_mug_next(&pil_u, cel_u->tel); fam_u = u3a_peek(&pil_u); } - // fam_u is a tail-frame: calculate/memoize cell mug and pop the stack + // tail-frame: calculate/memoize cell mug and pop the stack // else { u3a_cell* cel_u = u3a_to_ptr(fam_u->cel); diff --git a/pkg/urbit/noun/serial.c b/pkg/urbit/noun/serial.c index 9fcb766ec7..d8a616b177 100644 --- a/pkg/urbit/noun/serial.c +++ b/pkg/urbit/noun/serial.c @@ -597,7 +597,7 @@ u3s_cue(u3_atom a) // wid: bitwidth read to produce [pro] // fam_u: stack frame // har_p: backreference table - // pil_u: stack control structur + // pil_u: stack control structure // u3_noun pro; u3_atom wid, cur = 0; @@ -619,7 +619,7 @@ u3s_cue(u3_atom a) fam_u = u3a_peek(&pil_u); do { - // fam_u is a head-frame: stash [pro] and [wid]; continue into the tail + // head-frame: stash [pro] and [wid]; continue into the tail // if ( u3_none == fam_u->hed ) { // NB: fam_u->wid unused in head-frame @@ -635,8 +635,7 @@ u3s_cue(u3_atom a) fam_u = u3a_peek(&pil_u); } - // fam_u is a tail-frame: cons cell and save for backrefs, - // recalculate [wid], and pop the stack + // tail-frame: cons cell, recalculate [wid], and pop the stack // else { pro = u3nc(fam_u->hed, pro); From 2f2af91730d41506dc8c61e9158dfd2572f62018 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 1 Oct 2020 19:15:04 -0700 Subject: [PATCH 421/933] hoon: use +dvr instead of +div/+mod in |co helpers --- pkg/arvo/sys/hoon.hoon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 3a55086412..2ddef09929 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -6027,7 +6027,7 @@ ^- tape ?: &(=(0 hol) =(0 min)) rep - =+ [rad=(mod hol bas) dar=(div hol bas)] + =/ [dar=@ rad=@] (dvr hol bas) %= $ min ?:(=(0 min) 0 (dec min)) hol dar @@ -6041,7 +6041,7 @@ ^- {tape @} ?: &(=(0 hol) =(0 min)) [rep cou] - =+ [rad=(mod hol bas) dar=(div hol bas)] + =/ [dar=@ rad=@] (dvr hol bas) %= $ min ?:(=(0 min) 0 (dec min)) hol dar From ebc638522d3c18e8641951a2eaeda8a00ccadf5d Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 1 Oct 2020 19:15:46 -0700 Subject: [PATCH 422/933] hoon: use +pow instead of handrolled loop in +ox-co:co --- pkg/arvo/sys/hoon.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 2ddef09929..588ad81d10 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -6053,7 +6053,7 @@ ++ ox-co |= {{bas/@ gop/@} dug/$-(@ @)} %+ em-co - [|-(?:(=(0 gop) 1 (mul bas $(gop (dec gop))))) 0] + [(pow bas gop) 0] |= {top/? seg/@ res/tape} %+ weld ?:(top ~ `tape`['.' ~]) From feeb15e3eddbb37850c9d33d5df055104561efeb Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 2 Oct 2020 00:28:29 -0700 Subject: [PATCH 423/933] hoon: refactors +ro-co:co, modernizing syntax --- pkg/arvo/sys/hoon.hoon | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 588ad81d10..3a26e864ee 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -6063,15 +6063,17 @@ |=({? b/@ c/tape} [(dug b) c]) :: ++ ro-co - |= {{buz/@ bas/@ dop/@} dug/$-(@ @)} - |= hol/@ + |= [[buz=@ bas=@ dop=@] dug=$-(@ @)] + |= hol=@ ^- tape ?: =(0 dop) rep - => .(rep $(dop (dec dop))) :- '.' - %- (em-co [bas 1] |=({? b/@ c/tape} [(dug b) c])) - [(cut buz [(dec dop) 1] hol)] + =/ pod (dec dop) + %. (cut buz [pod 1] hol) + %+ em-co(rep $(dop pod)) + [bas 1] + |=([? b=@ c=tape] [(dug b) c]) -- :: :::: 4l: atom parsing From e314d070ea9460d7ce9fdfe3d4940c61aa5793b6 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 2 Oct 2020 14:44:57 -0700 Subject: [PATCH 424/933] u3: corrects a couple more comments --- pkg/urbit/noun/allocate.c | 2 +- pkg/urbit/noun/retrieve.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/urbit/noun/allocate.c b/pkg/urbit/noun/allocate.c index ed99f1b454..1c15390836 100644 --- a/pkg/urbit/noun/allocate.c +++ b/pkg/urbit/noun/allocate.c @@ -1064,7 +1064,7 @@ _ca_take_atom(u3a_atom* old_u) return new; } -/* _ca_take_cell(): reallocate a cell atom off the stack. +/* _ca_take_cell(): reallocate a cell off the stack. */ static inline u3_cell _ca_take_cell(u3a_cell* old_u, u3_noun hed, u3_noun tel) diff --git a/pkg/urbit/noun/retrieve.c b/pkg/urbit/noun/retrieve.c index 37b98d8581..18bf9344d0 100644 --- a/pkg/urbit/noun/retrieve.c +++ b/pkg/urbit/noun/retrieve.c @@ -221,12 +221,12 @@ u3r_mean(u3_noun som, ...) // stack frame for tracking noun comparison and unification // -// we always comparing arbitrary nouns in a none-frame. -// when we compare two cells, we change the none-frame to a -// head-frame and push a new none-frame for the heads. -// if the heads are equal, the head-frame has the context to -// unify their head pointers. we then repeat with the tails, -// mutatis mutandis. +// we always compare arbitrary nouns in a none-frame. +// when we compare two cells, we change the none-frame to a head-frame +// and push a new none-frame for their heads. if the heads are equal, +// we get the cells from the head-frame and unify their head pointers. +// then, we convert the head-frame to a tail-frame and repeat with +// the tails, mutatis mutandis. // // in Hoon, this structure would be: // From 45ad5da9e9a150d270ebc273890e4158c4134cde Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Sun, 4 Oct 2020 16:04:47 -0700 Subject: [PATCH 425/933] king: fix tests in a way that doesn't quite work --- pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs | 7 ++++--- pkg/hs/urbit-king/test/AmesTests.hs | 21 ++++++++++++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs index b71551e027..f684e51cc1 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs @@ -235,11 +235,12 @@ ames env who isFake scry enqueueEv stderr = (initialEvents, runAmes) scryVersion \v -> do v0 <- readTVarIO versSlot atomically $ writeTVar versSlot (Just v) + putStrLn "wow" if (v0 == Just v) then logInfo $ displayShow ("ames: proto version unchanged at", v) else stderr ("ames: protocol version now " <> tshow v) - threadDelay (10 * 60 * 1_000_000) -- 10m + threadDelay (1_000_000) -- 10m queuePacketsThread :: HasLogFunc e => TVar Word @@ -258,7 +259,7 @@ ames env who isFake scry enqueueEv stderr = (initialEvents, runAmes) logDebug $ displayShow ("ames: bon packet", pkt, showUD $ bytesAtom b) if pktRcvr == who - then serf'sUp p a b + then serfsUp p a b else lan pktRcvr $ \case Just (dest:_) -> forward dest $ encode pkt { pktOrigin = pktOrigin <|> Just (ipDest p a) } @@ -269,7 +270,7 @@ ames env who isFake scry enqueueEv stderr = (initialEvents, runAmes) Left e -> logInfo $ displayShow ("ames: dropping malformed", e) where - serf'sUp p a b = + serfsUp p a b = atomically (enqueueEv (EvErr (hearEv p a b) hearFailed)) >>= \case Intake -> pure () Ouster -> do diff --git a/pkg/hs/urbit-king/test/AmesTests.hs b/pkg/hs/urbit-king/test/AmesTests.hs index 41080dd145..cba51cebc6 100644 --- a/pkg/hs/urbit-king/test/AmesTests.hs +++ b/pkg/hs/urbit-king/test/AmesTests.hs @@ -24,6 +24,7 @@ import Network.Socket (tupleToHostAddress) import Urbit.King.App (HasKingId(..)) import qualified Urbit.EventLog.LMDB as Log +import qualified Urbit.Noun.Time as Time -------------------------------------------------------------------------------- @@ -91,13 +92,31 @@ runGala runGala point = do env <- ask que <- newTQueueIO + cry <- newTQueueIO + flip mkRAcquire cancel $ async $ forever $ do + act <- atomically $ readTQueue cry + putStrLn "taking action" + io act let enqueue = \p -> writeTQueue que p $> Intake - let (_, runAmes) = ames env (fromIntegral point) True enqueue noStderr + let (_, runAmes) = + ames env (fromIntegral point) True (scry cry) enqueue noStderr cb <- runAmes io (cb turfEf) pure (que, cb) where noStderr _ = pure () + scry :: TQueue (IO ()) -> Time.Wen -> Gang -> Path -> (Maybe (Term, Noun) -> IO ()) -> STM () + scry q _ _ (Path p) cb = writeTQueue q $ case unKnot <$> p of + ["ax",_,"",_,"protocol","version"] -> (putStrLn "yes" >>) $ cb $ Just + ( error "ames test: should not depend on scry term" + , A 0 + ) :: IO () + ["ax",_,"",_,"peers",ship,"forward-lane"] -> cb $ Just + ( error "ames test: should not depend on scry term" + , toNoun [fromIntegral $ hash ship :: Word32] + ) + pax -> error ("ames test: fell scry " <> show pax) + waitForPacket :: TQueue EvErr -> Bytes -> IO Bool waitForPacket q val = go From e7b69c94072cfa2527eb9155c2c7f8b6807dccc1 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 22 Sep 2020 16:18:35 -0400 Subject: [PATCH 426/933] king: use Data.Map.Strict instead of Data.Map. --- pkg/hs/urbit-king/lib/Urbit/Vere/Ames/DNS.hs | 2 +- pkg/hs/urbit-king/lib/Urbit/Vere/Http/Client.hs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/DNS.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/DNS.hs index 25eccdc4bc..3078646124 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/DNS.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/DNS.hs @@ -64,7 +64,7 @@ import Urbit.Prelude import Network.Socket hiding (recvFrom, sendTo) import Urbit.Arvo hiding (Fake) -import qualified Data.Map as M +import qualified Data.Map.Strict as M import qualified Urbit.Noun.Time as Time import qualified Urbit.Ob as Ob diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Http/Client.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Http/Client.hs index 92e36145b2..ad7da91d53 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Http/Client.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Http/Client.hs @@ -17,7 +17,7 @@ import Urbit.Arvo (BlipEv(..), Ev(..), HttpClientEf(..), HttpClientEv(..), HttpClientReq(..), HttpEvent(..), KingId, ResponseHeader(..)) -import qualified Data.Map as M +import qualified Data.Map.Strict as M import qualified Network.HTTP.Client as H import qualified Network.HTTP.Client.TLS as TLS import qualified Network.HTTP.Types as HT From 37a52136abacdfee6cb7b774d9a3de8b5f3d935e Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 23 Sep 2020 10:51:59 -0400 Subject: [PATCH 427/933] king: Use modifyTVar' instead of modifyTVar. We mostly used modifyTVar', but there were a few lazy cases. --- pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs | 2 +- pkg/hs/urbit-king/lib/Urbit/Vere/Clay.hs | 6 +++--- pkg/hs/urbit-king/lib/Urbit/Vere/Http/Client.hs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs index 5065cb4ace..8ef28294fb 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs @@ -138,7 +138,7 @@ ames' who isFake stderr = do vail <- readTVar avail if vail > 0 then do - modifyTVar avail (subtract 1) + modifyTVar' avail (subtract 1) writeTQueue ventQ p pure Intake else do diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Clay.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Clay.hs index ae626ed08c..4bf767fa3a 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Clay.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Clay.hs @@ -191,7 +191,7 @@ clay env plan = atomically $ plan (EvErr syncEv syncFailed) - atomically $ modifyTVar + atomically $ modifyTVar' (cdMountPoints cd) (applyActionsToMountPoints desk actions) @@ -206,7 +206,7 @@ clay env plan = let hashedActions = map (calculateActionHash dir) actions for_ hashedActions (performAction mountPoint) - atomically $ modifyTVar + atomically $ modifyTVar' (cdMountPoints cd) (applyActionsToMountPoints desk hashedActions) @@ -214,7 +214,7 @@ clay env plan = logInfo $ displayShow ("(clay) ogre:", p, desk) pierPath <- view pierPathL removeDirectoryRecursive $ pierPath deskToPath desk - atomically $ modifyTVar (cdMountPoints cd) (M.delete desk) + atomically $ modifyTVar' (cdMountPoints cd) (M.delete desk) -- Change the structures off of the event into something we can work with diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Http/Client.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Http/Client.hs index ad7da91d53..b3a24ddff9 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Http/Client.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Http/Client.hs @@ -126,7 +126,7 @@ client env plan = (initialEvents, runHttpClient) newReq :: HttpClientDrv -> ReqId -> HttpClientReq -> RIO e () newReq drv id req = do async <- runReq drv id req - atomically $ modifyTVar (hcdLive drv) (insertMap id async) + atomically $ modifyTVar' (hcdLive drv) (insertMap id async) -- The problem with the original http client code was that it was written -- to the idea of what the events "should have" been instead of what they From 0451953822ec81d17116164ea2fe37ec7e3c0623 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 23 Sep 2020 11:16:57 -0400 Subject: [PATCH 428/933] king: evaluate text which goes into the log --- pkg/hs/urbit-king/lib/Urbit/Vere/Term/Logic.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Term/Logic.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Term/Logic.hs index 8e739b88ae..9f69ff7e86 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Term/Logic.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Term/Logic.hs @@ -54,10 +54,10 @@ data Ef deriving (Show) data St = St - { sHistory :: Seq Text - , sLine :: Text - , sCurPos :: Word - , sSpinner :: SpinnerState + { sHistory :: !(Seq Text) + , sLine :: !Text + , sCurPos :: !Word + , sSpinner :: !SpinnerState } deriving (Show) @@ -86,7 +86,7 @@ step st@St{..} = \case word = fromIntegral record :: Text -> St -> St - record t st@St{..} = st { sHistory = trim (sHistory |> t) } + record !t st@St{..} = st { sHistory = trim (sHistory |> t) } trim :: Seq a -> Seq a trim s | length s < 20 = s From 8d3e15c62bfa6c7877e71eabd27712db6a2de3d2 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 2 Oct 2020 11:10:32 -0400 Subject: [PATCH 429/933] king: strictify all parsed nouns At least some of the parsed plea structures were holding on to the raw bytestrings through laziness. --- .../urbit-eventlog-lmdb/lib/Urbit/EventLog/LMDB.hs | 6 +++--- pkg/hs/urbit-king/lib/Urbit/Arvo/Common.hs | 2 ++ pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs | 2 ++ pkg/hs/urbit-king/lib/Urbit/Arvo/Event.hs | 2 ++ pkg/hs/urbit-king/lib/Urbit/Vere/Pier/Types.hs | 8 ++++---- pkg/hs/urbit-king/lib/Urbit/Vere/Serf/IPC.hs | 2 ++ pkg/hs/urbit-king/lib/Urbit/Vere/Serf/Types.hs | 14 +++++++------- pkg/hs/urbit-king/lib/Urbit/Vere/Term/API.hs | 6 +++--- pkg/hs/urbit-noun-core/lib/Urbit/Noun/Convert.hs | 6 +++--- pkg/hs/urbit-noun-core/lib/Urbit/Noun/Core.hs | 4 ++-- pkg/hs/urbit-noun/lib/Urbit/Noun/Tree.hs | 8 ++++---- 11 files changed, 34 insertions(+), 26 deletions(-) diff --git a/pkg/hs/urbit-eventlog-lmdb/lib/Urbit/EventLog/LMDB.hs b/pkg/hs/urbit-eventlog-lmdb/lib/Urbit/EventLog/LMDB.hs index ed53db19c3..14713c29e6 100644 --- a/pkg/hs/urbit-eventlog-lmdb/lib/Urbit/EventLog/LMDB.hs +++ b/pkg/hs/urbit-eventlog-lmdb/lib/Urbit/EventLog/LMDB.hs @@ -41,9 +41,9 @@ import qualified Data.Vector as V -- Public Types ---------------------------------------------------------------- data LogIdentity = LogIdentity - { who :: Ship - , isFake :: Bool - , lifecycleLen :: Word + { who :: !Ship + , isFake :: !Bool + , lifecycleLen :: !Word } deriving (Eq, Ord, Show) deriveNoun ''LogIdentity diff --git a/pkg/hs/urbit-king/lib/Urbit/Arvo/Common.hs b/pkg/hs/urbit-king/lib/Urbit/Arvo/Common.hs index 1b0b4ad4b3..7282e939e9 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Arvo/Common.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Arvo/Common.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE StrictData #-} + {-| Types used in both Events and Effects. -} diff --git a/pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs b/pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs index d77b25051c..2c01faf9e3 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE StrictData #-} + {-| Effect Types and Their Noun Conversions -} diff --git a/pkg/hs/urbit-king/lib/Urbit/Arvo/Event.hs b/pkg/hs/urbit-king/lib/Urbit/Arvo/Event.hs index 39df141e13..eadc524e11 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Arvo/Event.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Arvo/Event.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE StrictData #-} + {-| Event Types and Noun Conversion -} diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier/Types.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier/Types.hs index 6dbffa34c9..ab5adba732 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier/Types.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier/Types.hs @@ -45,13 +45,13 @@ instance Show Nock where -------------------------------------------------------------------------------- data Pill = Pill - { pBootFormulas :: [Nock] - , pKernelOvums :: [Ev] - , pUserspaceOvums :: [Ev] + { pBootFormulas :: ![Nock] + , pKernelOvums :: ![Ev] + , pUserspaceOvums :: ![Ev] } deriving (Eq, Show) -data BootSeq = BootSeq LogIdentity [Nock] [Ev] +data BootSeq = BootSeq !LogIdentity ![Nock] ![Ev] deriving (Eq, Show) deriveNoun ''Pill diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Serf/IPC.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Serf/IPC.hs index 3b0d5b1406..b081851309 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Serf/IPC.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Serf/IPC.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE StrictData #-} + {-| Low-Level IPC flows for interacting with the serf process. diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Serf/Types.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Serf/Types.hs index 1544a56fe6..91f8a659ed 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Serf/Types.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Serf/Types.hs @@ -15,21 +15,21 @@ type PlayBail = (EventId, Mug, Goof) type Slog = (Atom, Tank) data SerfState = SerfState - { ssLast :: EventId - , ssHash :: Mug + { ssLast :: !EventId + , ssHash :: !Mug } deriving (Show, Eq) data RipeInfo = RipeInfo - { riProt :: Atom - , riHoon :: Atom - , riNock :: Atom + { riProt :: !Atom + , riHoon :: !Atom + , riNock :: !Atom } deriving (Show) data SerfInfo = SerfInfo - { siRipe :: RipeInfo - , siStat :: SerfState + { siRipe :: !RipeInfo + , siStat :: !SerfState } deriving (Show) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Term/API.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Term/API.hs index 0d38b8ffd3..624ed7fabe 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Term/API.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Term/API.hs @@ -18,10 +18,10 @@ import Urbit.Arvo (Belt, Blit) %blank -- print a blank line %spinr -- Start or stop the spinner -} -data Ev = Blits [Blit] - | Trace Cord +data Ev = Blits ![Blit] + | Trace !Cord | Blank - | Spinr (Maybe (Maybe Cord)) + | Spinr !(Maybe (Maybe Cord)) deriving (Show) data Client = Client diff --git a/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Convert.hs b/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Convert.hs index 97df9e085c..7875ad6523 100644 --- a/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Convert.hs +++ b/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Convert.hs @@ -88,13 +88,13 @@ fromNoun :: FromNoun a => Noun -> Maybe a fromNoun n = runParser (parseNoun n) [] onFail onSuccess where onFail p m = Nothing - onSuccess x = Just x + onSuccess !x = Just x fromNounErr :: FromNoun a => Noun -> Either ([Text], Text) a fromNounErr n = runParser (parseNoun n) [] onFail onSuccess where onFail p m = Left (p, pack m) - onSuccess x = Right x + onSuccess !x = Right x data BadNoun = BadNoun [Text] String deriving (Eq, Ord) @@ -114,7 +114,7 @@ fromNounExn :: MonadIO m => FromNoun a => Noun -> m a fromNounExn n = runParser (parseNoun n) [] onFail onSuccess where onFail p m = throwIO (BadNoun p m) - onSuccess x = pure x + onSuccess !x = pure x -- Cord Conversions ------------------------------------------------------------ diff --git a/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Core.hs b/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Core.hs index fba92b0c4e..0aeca303d3 100644 --- a/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Core.hs +++ b/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Core.hs @@ -34,8 +34,8 @@ import qualified Data.Char as C -- Types ----------------------------------------------------------------------- data Noun - = NCell Int Word Noun Noun - | NAtom Int Atom + = NCell Int Word !Noun !Noun + | NAtom Int !Atom pattern Cell x y <- NCell _ _ x y where Cell = mkCell pattern Atom a <- NAtom _ a where Atom = mkAtom diff --git a/pkg/hs/urbit-noun/lib/Urbit/Noun/Tree.hs b/pkg/hs/urbit-noun/lib/Urbit/Noun/Tree.hs index 61751cca57..71ff3c56c1 100644 --- a/pkg/hs/urbit-noun/lib/Urbit/Noun/Tree.hs +++ b/pkg/hs/urbit-noun/lib/Urbit/Noun/Tree.hs @@ -27,14 +27,14 @@ import GHC.Natural (Natural) -- Types ----------------------------------------------------------------------- data NounVal a = NounVal - { non ∷ Noun + { non ∷ !Noun , val ∷ !a } data HoonTreeNode a = NTN - { n ∷ NounVal a - , l ∷ HoonTree a - , r ∷ HoonTree a + { n ∷ !(NounVal a) + , l ∷ !(HoonTree a) + , r ∷ !(HoonTree a) } deriving (Eq, Ord, Show) From 7e117f86b7329f28179c914a34eb18ce113255e2 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 5 Oct 2020 14:28:17 -0400 Subject: [PATCH 430/933] king: move internal IPC types to own file This lets us put a StrictData annotation on these datas, without touching the rest. --- pkg/hs/urbit-king/lib/Urbit/Vere/Serf/IPC.hs | 52 +---------------- .../lib/Urbit/Vere/Serf/IPC/Types.hs | 58 +++++++++++++++++++ 2 files changed, 59 insertions(+), 51 deletions(-) create mode 100644 pkg/hs/urbit-king/lib/Urbit/Vere/Serf/IPC/Types.hs diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Serf/IPC.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Serf/IPC.hs index b081851309..58ff3de6e5 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Serf/IPC.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Serf/IPC.hs @@ -1,5 +1,3 @@ -{-# LANGUAGE StrictData #-} - {-| Low-Level IPC flows for interacting with the serf process. @@ -76,6 +74,7 @@ import Data.Bits import Data.Conduit import System.Process import Urbit.Vere.Serf.Types +import Urbit.Vere.Serf.IPC.Types import Control.Monad.STM (retry) import Control.Monad.Trans.Resource (MonadResource, allocate, runResourceT) @@ -105,55 +104,6 @@ data Serf = Serf } --- Internal Protocol Types ----------------------------------------------------- - -data Live - = LExit Atom -- exit status code - | LSave EventId - | LCram EventId - | LPack () - deriving (Show) - -data Play - = PDone Mug - | PBail PlayBail - deriving (Show) - -data Scry - = SDone (Maybe (Term, Noun)) - | SBail Goof - deriving (Show) - -data Work - = WDone EventId Mug FX - | WSwap EventId Mug (Wen, Noun) FX - | WBail [Goof] - deriving (Show) - -data Writ - = WLive Live - | WPeek Atom Wen Gang Path - | WPlay EventId [Noun] - | WWork Atom Wen Ev - deriving (Show) - -data Plea - = PLive () - | PRipe SerfInfo - | PSlog Slog - | PPeek Scry - | PPlay Play - | PWork Work - deriving (Show) - -deriveNoun ''Live -deriveNoun ''Play -deriveNoun ''Scry -deriveNoun ''Work -deriveNoun ''Writ -deriveNoun ''Plea - - -- Access Current Serf State --------------------------------------------------- serfLastEventBlocking :: Serf -> IO EventId diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Serf/IPC/Types.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Serf/IPC/Types.hs new file mode 100644 index 0000000000..88fed803e8 --- /dev/null +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Serf/IPC/Types.hs @@ -0,0 +1,58 @@ +{-# LANGUAGE StrictData #-} + +module Urbit.Vere.Serf.IPC.Types where + +import Urbit.Prelude hiding ((<|)) +import Urbit.Arvo (Ev, FX) +import Urbit.Noun.Time (Wen) +import Urbit.Vere.Serf.Types + +-- Private data structures for Urbit.Vere.Serf.IPC, but made StrictData without +-- making the rest of Urbit.Vere.Serf.IPC strict. + +data Live + = LExit Atom -- exit status code + | LSave EventId + | LCram EventId + | LPack () + deriving (Show) + +data Play + = PDone Mug + | PBail PlayBail + deriving (Show) + +data Scry + = SDone (Maybe (Term, Noun)) + | SBail Goof + deriving (Show) + +data Work + = WDone EventId Mug FX + | WSwap EventId Mug (Wen, Noun) FX + | WBail [Goof] + deriving (Show) + +data Writ + = WLive Live + | WPeek Atom Wen Gang Path + | WPlay EventId [Noun] + | WWork Atom Wen Ev + deriving (Show) + +data Plea + = PLive () + | PRipe SerfInfo + | PSlog Slog + | PPeek Scry + | PPlay Play + | PWork Work + deriving (Show) + +deriveNoun ''Live +deriveNoun ''Play +deriveNoun ''Scry +deriveNoun ''Work +deriveNoun ''Writ +deriveNoun ''Plea + From 2554dad0d855f2a74c28d39a4a166c7e379f605e Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 6 Oct 2020 16:10:04 +0200 Subject: [PATCH 431/933] vere: improve streamslog event construction Assemble as list of atoms, then rap once, instead of catting multiple times. Also fixes refcounts, probably. --- pkg/urbit/vere/io/http.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/urbit/vere/io/http.c b/pkg/urbit/vere/io/http.c index b4f1e796d0..7e95b9ae19 100644 --- a/pkg/urbit/vere/io/http.c +++ b/pkg/urbit/vere/io/http.c @@ -1951,13 +1951,18 @@ _http_stream_slog(void* vop_p, c3_w pri_w, u3_noun tan) if ( u3_none != wol ) { u3_noun low = wol; - u3_atom txt = u3_nul; + u3_noun paz = u3_nul; while ( u3_nul != low ) { - u3_atom lin = u3qc_cat(3, u3qc_rap(3, u3k(u3h(low))), c3_s2('\n', '\n')); - txt = u3qc_cat(3, txt, u3qc_cat(3, u3i_string("data:"), lin)); + u3_noun lin = u3i_list(u3i_string("data:"), + u3qc_rap(3, u3h(low)), + c3_s2('\n', '\n'), + u3_none); + paz = u3kb_weld(paz, lin); low = u3t(low); } + u3_atom txt = u3qc_rap(3, paz); data = u3nt(u3_nul, u3r_met(3, txt), txt); + u3z(paz); } u3z(wol); From 8044692b419c21e62e9c11637b1a5b8c3bb595e1 Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 6 Oct 2020 16:31:21 +0200 Subject: [PATCH 432/933] vere: touch up slogstream style and logic --- pkg/urbit/include/vere/vere.h | 3 ++- pkg/urbit/vere/io/http.c | 8 ++++++-- pkg/urbit/vere/pier.c | 12 ++++-------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index e8f3dcd45e..9fb715b569 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -634,7 +634,8 @@ u3_pico* ext_u; } pec_u; void* sop_p; // slog stream data - void (*sog_f)(void*, c3_w, u3_noun); // slog stream callback + void (*sog_f) // slog stream callback + (void*, c3_w, u3_noun);// // XX remove c3_s por_s; // UDP port u3_save* sav_u; // autosave diff --git a/pkg/urbit/vere/io/http.c b/pkg/urbit/vere/io/http.c index 7e95b9ae19..a7444e9cbf 100644 --- a/pkg/urbit/vere/io/http.c +++ b/pkg/urbit/vere/io/http.c @@ -832,6 +832,9 @@ _http_seq_continue(void* vod_p, u3_noun nun) // if the request is authenticated properly, send slogstream/sse headers // + //TODO authentication might expire after the connection has been opened! + // eyre could notify us about this, or we could re-check periodically. + // if ( c3y == aut ) { u3_hreq* req_u = _http_req_prepare(rec_u, _http_seq_new); u3_noun hed = u3nl(u3nc(u3i_string("Content-Type"), @@ -849,7 +852,7 @@ _http_seq_continue(void* vod_p, u3_noun nun) // else { //NOTE we use req_new because we don't want to consider this a slog stream - // request, but this means we need to manuualy skip past the "in event + // request, but this means we need to manually skip past the "in event // queue" state on the hreq. u3_hreq* req_u = _http_req_prepare(rec_u, _http_req_new); req_u->sat_e = u3_rsat_plan; @@ -2128,7 +2131,8 @@ _http_io_exit(u3_auto* car_u) // } { - u3_noun dat = u3nt(u3_nul, 25, u3i_string("data:urbit shutting down\n\n")); + u3_atom lin = u3i_string("data:urbit shutting down\n\n"); + u3_noun dat = u3nt(u3_nul, u3r_met(3, lin), lin); u3_hreq* seq_u = htd_u->fig_u.seq_u; while ( 0 != seq_u ) { _http_continue_respond(seq_u, u3k(dat), c3y); diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index b45718b1ea..1515ebff5c 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -973,21 +973,17 @@ _pier_on_lord_slog(void* ptr_v, c3_w pri_w, u3_noun tan) c3_free(tan_c); if ( 0 != pir_u->sog_f ) { - pir_u->sog_f(pir_u->sop_p, pri_w, tan); - } - else { - u3z(tan); + pir_u->sog_f(pir_u->sop_p, pri_w, u3k(tan)); } } else { u3_pier_tank(0, pri_w, u3k(tan)); if ( 0 != pir_u->sog_f ) { - pir_u->sog_f(pir_u->sop_p, pri_w, tan); - } - else { - u3z(tan); + pir_u->sog_f(pir_u->sop_p, pri_w, u3k(tan)); } } + + u3z(tan); } /* _pier_on_lord_save(): worker (non-portable) snapshot complete. From cc389c52e9196c5cfa34b90b18559eb7719b0a04 Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 6 Oct 2020 16:37:02 +0200 Subject: [PATCH 433/933] vere: put runtime http bindings under /~_~ --- pkg/urbit/vere/io/http.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/urbit/vere/io/http.c b/pkg/urbit/vere/io/http.c index a7444e9cbf..034de6db5c 100644 --- a/pkg/urbit/vere/io/http.c +++ b/pkg/urbit/vere/io/http.c @@ -1422,7 +1422,7 @@ _http_serv_init_h2o(SSL_CTX* tls_u, c3_o log, c3_o red) // register slog stream endpoint // - h2o_pathconf_t* pac_u = h2o_config_register_path(h2o_u->hos_u, "/~/slog", 0); + h2o_pathconf_t* pac_u = h2o_config_register_path(h2o_u->hos_u, "/~_~/slog", 0); h2o_handler_t* han_u = h2o_create_handler(pac_u, sizeof(*han_u)); han_u->on_req = _http_seq_accept; From f2e64e39b61476a23c3c846c1b121d42618ea921 Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 6 Oct 2020 20:57:45 +0200 Subject: [PATCH 434/933] vere: use h2o functions for finding cookie header --- pkg/urbit/vere/io/http.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/pkg/urbit/vere/io/http.c b/pkg/urbit/vere/io/http.c index 034de6db5c..2eb4ccbe95 100644 --- a/pkg/urbit/vere/io/http.c +++ b/pkg/urbit/vere/io/http.c @@ -882,18 +882,11 @@ _http_seq_accept(h2o_handler_t* han_u, h2o_req_t* rec_u) // u3_weak coo = u3_none; { - u3_noun hed = _http_heds_to_noun(rec_u->headers.entries, - rec_u->headers.size); - u3_noun deh = hed; - while ( u3_nul != deh ) { - if ( c3y == u3r_sing_c("cookie", u3h(u3h(deh))) ) { - coo = u3k(u3t(u3h(deh))); - //TODO http2 allows the client to put multiple 'cookie' headers - break; - } - deh = u3t(deh); + //TODO http2 allows the client to put multiple 'cookie' headers + ssize_t hin_i = h2o_find_header_by_str(&rec_u->headers, "cookie", 6, -1); + if ( hin_i != -1 ) { + coo = _http_vec_to_atom(rec_u->headers.entries[hin_i].value); } - u3z(hed); } // if there is no cookie header, it can't possibly be authenticated From 0e790719d6f1868a64d58d8660881d8ac463f66e Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 6 Oct 2020 20:59:17 +0200 Subject: [PATCH 435/933] vere: add missing function comment --- pkg/urbit/vere/io/http.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/urbit/vere/io/http.c b/pkg/urbit/vere/io/http.c index 2eb4ccbe95..a20128b2eb 100644 --- a/pkg/urbit/vere/io/http.c +++ b/pkg/urbit/vere/io/http.c @@ -824,6 +824,8 @@ _http_req_prepare(h2o_req_t* rec_u, return seq_u; } +/* _http_seq_continue(): respond to slogstream request based on auth scry result +*/ static void _http_seq_continue(void* vod_p, u3_noun nun) { From ebb76c1c5a44943703a1948d0fca5697e1c522f6 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 2 Oct 2020 00:29:05 -0700 Subject: [PATCH 436/933] hoon: comments, modernizes syntax for all +**-co gates --- pkg/arvo/sys/hoon.hoon | 52 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 3a26e864ee..8a3e0c2c18 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -6021,9 +6021,21 @@ ++ z-co |=(dat/@ `tape`['0' 'x' ((x-co 1) dat)]) -- |% + :: +em-co: format in numeric base + :: + :: in .bas, format .min digits of .hol with .par + :: + :: - .hol is processed least-significant digit first + :: - all available digits in .hol will be processed, but + :: .min digits can exceed the number available in .hol + :: - .par handles all accumulated output on each call, + :: and can edit it, prepend or append digits, &c + :: - until .hol is exhausted, .par's sample is [| digit output], + :: subsequently, it's [& 0 output] + :: ++ em-co - |= {{bas/@ min/@} par/$-({? @ tape} tape)} - |= hol/@ + |= [[bas=@ min=@] par=$-([? @ tape] tape)] + |= hol=@ ^- tape ?: &(=(0 hol) =(0 min)) rep @@ -6034,11 +6046,17 @@ rep (par =(0 dar) rad rep) == :: + :: +ed-co: format in numeric base, with output length + :: + :: - like +em-co, but .par's sample will be [| digit output] + :: on the first call, regardless of the available digits in .hol + :: - used only for @r* floats + :: ++ ed-co - |= {{bas/@ min/@} par/$-({? @ tape} tape)} - =+ [fir=& cou=0] - |= hol/@ - ^- {tape @} + |= [[bas=@ min=@] par=$-([? @ tape] tape)] + =| [fir=? cou=@ud] + |= hol=@ + ^- [tape @] ?: &(=(0 hol) =(0 min)) [rep cou] =/ [dar=@ rad=@] (dvr hol bas) @@ -6050,17 +6068,33 @@ cou +(cou) == :: + :: +ox-co: format '.'-separated digit sequences in numeric base + :: + :: in .bas, format each digit of .hol with .dug, + :: with '.' separators every .gop digits. + :: + :: - .hol is processed least-significant digit first + :: - .dug handles individual digits, output is prepended + :: - every segment but the last is zero-padded to .gop + :: ++ ox-co - |= {{bas/@ gop/@} dug/$-(@ @)} + |= [[bas=@ gop=@] dug=$-(@ @)] %+ em-co [(pow bas gop) 0] - |= {top/? seg/@ res/tape} + |= [top=? seg=@ res=tape] %+ weld ?:(top ~ `tape`['.' ~]) %. seg %+ em-co(rep res) [bas ?:(top 0 gop)] - |=({? b/@ c/tape} [(dug b) c]) + |=([? b=@ c=tape] [(dug b) c]) + :: + :: +ro-co: format '.'-prefixed bloqs in numeric base + :: + :: in .bas, for .buz bloqs 0 to .dop, format at least one + :: digit of .hol, prefixed with '.' + :: + :: - used only for @i* addresses :: ++ ro-co |= [[buz=@ bas=@ dop=@] dug=$-(@ @)] From ce9bdb8b735f8311022f0407238548f6d0a96ba6 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 2 Oct 2020 11:25:48 -0700 Subject: [PATCH 437/933] hoon: refactors +r-co:co, modernizing syntax --- pkg/arvo/sys/hoon.hoon | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 8a3e0c2c18..2a3a75af24 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -5992,20 +5992,21 @@ ++ c-co (em-co [58 1] |=({? b/@ c/tape} [~(c ne b) c])) ++ d-co |=(min/@ (em-co [10 min] |=({? b/@ c/tape} [~(d ne b) c]))) ++ r-co - |= a/dn - ?: ?=({$i *} a) (weld ?:(s.a "inf" "-inf") rep) - ?: ?=({$n *} a) (weld "nan" rep) - =+ ^= e %+ ed-co [10 1] - |= {a/? b/@ c/tape} - ?: a [~(d ne b) '.' c] - [~(d ne b) c] - =+ ^= f - =>(.(rep ~) (e a.a)) - =. e.a (sum:si e.a (sun:si (dec +.f))) - =+ b=?:((syn:si e.a) "e" "e-") - => .(rep ?~(e.a rep (weld b ((d-co 1) (abs:si e.a))))) - => .(rep (weld -.f rep)) - ?:(s.a rep ['-' rep]) + |= a=dn + ?: ?=([%i *] a) (weld ?:(s.a "inf" "-inf") rep) + ?: ?=([%n *] a) (weld "nan" rep) + =/ f=(pair tape @) + %. a.a + %+ ed-co(rep ~) [10 1] + |=([a=? b=@ c=tape] [~(d ne b) ?.(a c ['.' c])]) + =. e.a (sum:si e.a (sun:si (dec q.f))) + =/ res + %+ weld p.f + ?~ e.a + rep + %+ weld ?:((syn:si e.a) "e" "e-") + ((d-co 1) (abs:si e.a)) + ?:(s.a res ['-' res]) :: ++ s-co |= esc/(list @) ^- tape From bb4d89af4664c0a0510f0f7559a7fb77743dba7f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 2 Oct 2020 11:26:42 -0700 Subject: [PATCH 438/933] hoon: comments, modernizes syntax for all +*-co:co gates --- pkg/arvo/sys/hoon.hoon | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 2a3a75af24..20b9b3fee2 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -5986,11 +5986,25 @@ ['~' '~' (weld (rip 3 (wood q.p.lot)) rep)] == -- - =+ rep=*tape + =| rep=tape =< |% - ++ a-co |=(dat/@ ((d-co 1) dat)) - ++ c-co (em-co [58 1] |=({? b/@ c/tape} [~(c ne b) c])) - ++ d-co |=(min/@ (em-co [10 min] |=({? b/@ c/tape} [~(d ne b) c]))) + :: rendering idioms, output zero-padded to minimum lengths + :: + :: +a-co: decimal + :: +c-co: base58check + :: +d-co: decimal, takes minimum output digits + :: +r-co: floating point + :: +s-co: list of '.'-prefixed base16, 4 digit minimum + :: +v-co: base32, takes minimum output digits + :: +w-co: base64, takes minimum output digits + :: +x-co: base16, takes minimum output digits + :: +y-co: decimal, 2 digit minimum + :: +z-co: '0x'-prefixed base16 + :: + ++ a-co |=(dat=@ ((d-co 1) dat)) + ++ c-co (em-co [58 1] |=([? b=@ c=tape] [~(c ne b) c])) + ++ d-co |=(min=@ (em-co [10 min] |=([? b=@ c=tape] [~(d ne b) c]))) + :: ++ r-co |= a=dn ?: ?=([%i *] a) (weld ?:(s.a "inf" "-inf") rep) @@ -6009,17 +6023,15 @@ ?:(s.a res ['-' res]) :: ++ s-co - |= esc/(list @) ^- tape - ?~ esc - rep - :- '.' - =>(.(rep $(esc t.esc)) ((x-co 4) i.esc)) + |= esc=(list @) ^- tape + ?~ esc rep + ['.' =>(.(rep $(esc t.esc)) ((x-co 4) i.esc))] :: - ++ v-co |=(min/@ (em-co [32 min] |=({? b/@ c/tape} [~(v ne b) c]))) - ++ w-co |=(min/@ (em-co [64 min] |=({? b/@ c/tape} [~(w ne b) c]))) - ++ x-co |=(min/@ (em-co [16 min] |=({? b/@ c/tape} [~(x ne b) c]))) - ++ y-co |=(dat/@ ((d-co 2) dat)) - ++ z-co |=(dat/@ `tape`['0' 'x' ((x-co 1) dat)]) + ++ v-co |=(min=@ (em-co [32 min] |=([? b=@ c=tape] [~(v ne b) c]))) + ++ w-co |=(min=@ (em-co [64 min] |=([? b=@ c=tape] [~(w ne b) c]))) + ++ x-co |=(min=@ (em-co [16 min] |=([? b=@ c=tape] [~(x ne b) c]))) + ++ y-co |=(dat=@ ((d-co 2) dat)) + ++ z-co |=(dat=@ `tape`['0' 'x' ((x-co 1) dat)]) -- |% :: +em-co: format in numeric base From 934721b6bc34627ca886258b9e93db94db6c0bd1 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 2 Oct 2020 12:14:19 -0700 Subject: [PATCH 439/933] hoon: refactors @da/@dr coin printing --- pkg/arvo/sys/hoon.hoon | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 20b9b3fee2..a8416bcffb 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -5873,31 +5873,28 @@ ?+ hay (z-co q.p.lot) $a =+ yod=(yore q.p.lot) - => ^+(. .(rep ?~(f.t.yod rep ['.' (s-co f.t.yod)]))) - => ^+ . - %= . - rep - ?: &(=(~ f.t.yod) =(0 h.t.yod) =(0 m.t.yod) =(0 s.t.yod)) - rep - => .(rep ['.' (y-co s.t.yod)]) - => .(rep ['.' (y-co m.t.yod)]) - ['.' '.' (y-co h.t.yod)] - == - => .(rep ['.' (a-co d.t.yod)]) - => .(rep ['.' (a-co m.yod)]) - => .(rep ?:(a.yod rep ['-' rep])) + =? rep ?=(^ f.t.yod) ['.' (s-co f.t.yod)] + =? rep ?& ?=(^ f.t.yod) + !|(=(0 h.t.yod) =(0 m.t.yod) =(0 s.t.yod)) + == + =. rep ['.' (y-co s.t.yod)] + =. rep ['.' (y-co m.t.yod)] + ['.' '.' (y-co h.t.yod)] + =. rep ['.' (a-co d.t.yod)] + =. rep ['.' (a-co m.yod)] + =? rep !a.yod ['-' rep] ['~' (a-co y.yod)] :: $r =+ yug=(yell q.p.lot) - => ^+(. .(rep ?~(f.yug rep ['.' (s-co f.yug)]))) + =? rep ?=(^ f.yug) ['.' (s-co f.yug)] :- '~' ?: &(=(0 d.yug) =(0 m.yug) =(0 h.yug) =(0 s.yug)) ['s' '0' rep] - => ^+(. ?:(=(0 s.yug) . .(rep ['.' 's' (a-co s.yug)]))) - => ^+(. ?:(=(0 m.yug) . .(rep ['.' 'm' (a-co m.yug)]))) - => ^+(. ?:(=(0 h.yug) . .(rep ['.' 'h' (a-co h.yug)]))) - => ^+(. ?:(=(0 d.yug) . .(rep ['.' 'd' (a-co d.yug)]))) + =? rep !=(0 s.yug) ['.' 's' (a-co s.yug)] + =? rep !=(0 m.yug) ['.' 'm' (a-co m.yug)] + =? rep !=(0 h.yug) ['.' 'h' (a-co h.yug)] + =? rep !=(0 d.yug) ['.' 'd' (a-co d.yug)] +.rep == :: From 07e17e5895273ded20a1a5e5aad92fb281f6a55e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 2 Oct 2020 12:26:25 -0700 Subject: [PATCH 440/933] hoon: updates @p rendering to avoid intermediate right-shifts --- pkg/arvo/sys/hoon.hoon | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index a8416bcffb..33f1854b4b 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -5917,22 +5917,19 @@ ?: (lte dyx 1) (weld (trip (tod:po sxz)) rep) =+ dyy=(met 4 sxz) - =+ imp=*@ + =| imp=@ud |- ^- tape ?: =(imp dyy) rep %= $ - sxz (rsh 4 1 sxz) - imp +(imp) - rep - =+ log=(end 4 1 sxz) - ;: weld - (trip (tos:po (rsh 3 1 log))) - (trip (tod:po (end 3 1 log))) - ?:(=((mod imp 4) 0) ?:(=(imp 0) "" "--") "-") - rep - == - == + imp +(imp) + rep =/ log (cut 4 [imp 1] sxz) + ;: weld + (trip (tos:po (rsh 3 1 log))) + (trip (tod:po (end 3 1 log))) + ?:(=((mod imp 4) 0) ?:(=(imp 0) "" "--") "-") + rep + == == :: $q =* val q.p.lot From bec9006e53cac9fd9cd714d09f5e610a734b456e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 2 Oct 2020 12:43:25 -0700 Subject: [PATCH 441/933] hoon: modernizes syntax in the rest of |co --- pkg/arvo/sys/hoon.hoon | 82 +++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 33f1854b4b..2610998979 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -5852,14 +5852,14 @@ :: ++ co ~% %co ..co ~ - =< |_ lot/coin - ++ rear |=(rom/tape =>(.(rep rom) rend)) + =< |_ lot=coin + ++ rear |=(rom=tape rend(rep rom)) ++ rent `@ta`(rap 3 rend) ++ rend ^- tape - ?: ?=($blob -.lot) + ?: ?=(%blob -.lot) ['~' '0' ((v-co 1) (jam p.lot))] - ?: ?=($many -.lot) + ?: ?=(%many -.lot) :- '.' |- ^- tape ?~ p.lot @@ -5868,10 +5868,10 @@ =+ [yed=(end 3 1 p.p.lot) hay=(cut 3 [1 1] p.p.lot)] |- ^- tape ?+ yed (z-co q.p.lot) - $c ['~' '-' (weld (rip 3 (wood (tuft q.p.lot))) rep)] - $d + %c ['~' '-' (weld (rip 3 (wood (tuft q.p.lot))) rep)] + %d ?+ hay (z-co q.p.lot) - $a + %a =+ yod=(yore q.p.lot) =? rep ?=(^ f.t.yod) ['.' (s-co f.t.yod)] =? rep ?& ?=(^ f.t.yod) @@ -5885,7 +5885,7 @@ =? rep !a.yod ['-' rep] ['~' (a-co y.yod)] :: - $r + %r =+ yug=(yell q.p.lot) =? rep ?=(^ f.yug) ['.' (s-co f.yug)] :- '~' @@ -5898,19 +5898,19 @@ +.rep == :: - $f + %f ?: =(& q.p.lot) ['.' 'y' rep] ?:(=(| q.p.lot) ['.' 'n' rep] (z-co q.p.lot)) :: - $n ['~' rep] - $i + %n ['~' rep] + %i ?+ hay (z-co q.p.lot) - $f ((ro-co [3 10 4] |=(a/@ ~(d ne a))) q.p.lot) - $s ((ro-co [4 16 8] |=(a/@ ~(x ne a))) q.p.lot) + %f ((ro-co [3 10 4] |=(a=@ ~(d ne a))) q.p.lot) + %s ((ro-co [4 16 8] |=(a=@ ~(x ne a))) q.p.lot) == :: - $p + %p =+ sxz=(fein:ob q.p.lot) =+ dyx=(met 3 sxz) :- '~' @@ -5931,48 +5931,48 @@ rep == == :: - $q - =* val q.p.lot + %q :+ '.' '~' - =- =.(rep (weld - rep) rep) - %- tail - %+ roll ?:(=(0 val) ~[0] (rip 3 val)) + =; res=(pair ? tape) + (weld q.res rep) + %+ roll + =* val q.p.lot + ?:(=(0 val) ~[0] (rip 3 val)) |= [q=@ s=? r=tape] :- !s - ;: weld - (trip (?:(s tod:po tos:po) q)) - ?:(&(s !=(r "")) "-" ~) - r - == + %+ weld + (trip (?:(s tod:po tos:po) q)) + ?.(&(s !=(r "")) r ['-' r]) :: - $r + %r ?+ hay (z-co q.p.lot) - $d ['.' '~' (r-co (rlyd q.p.lot))] - $h ['.' '~' '~' (r-co (rlyh q.p.lot))] - $q ['.' '~' '~' '~' (r-co (rlyq q.p.lot))] - $s ['.' (r-co (rlys q.p.lot))] + %d ['.' '~' (r-co (rlyd q.p.lot))] + %h ['.' '~' '~' (r-co (rlyh q.p.lot))] + %q ['.' '~' '~' '~' (r-co (rlyq q.p.lot))] + %s ['.' (r-co (rlys q.p.lot))] == :: - $u - ?: ?=($c hay) + %u + ?: ?=(%c hay) %+ welp ['0' 'c' (reap (pad:fa q.p.lot) '1')] (c-co (enc:fa q.p.lot)) - =- (weld p.gam ?:(=(0 q.p.lot) `tape`['0' ~] q.gam)) - ^= gam ^- {p/tape q/tape} - ?+ hay [~ ((ox-co [10 3] |=(a/@ ~(d ne a))) q.p.lot)] - $b [['0' 'b' ~] ((ox-co [2 4] |=(a/@ ~(d ne a))) q.p.lot)] - $i [['0' 'i' ~] ((d-co 1) q.p.lot)] - $x [['0' 'x' ~] ((ox-co [16 4] |=(a/@ ~(x ne a))) q.p.lot)] - $v [['0' 'v' ~] ((ox-co [32 5] |=(a/@ ~(x ne a))) q.p.lot)] - $w [['0' 'w' ~] ((ox-co [64 5] |=(a/@ ~(w ne a))) q.p.lot)] + :: + =; gam=(pair tape tape) + (weld p.gam ?:(=(0 q.p.lot) `tape`['0' ~] q.gam)) + ?+ hay [~ ((ox-co [10 3] |=(a=@ ~(d ne a))) q.p.lot)] + %b [['0' 'b' ~] ((ox-co [2 4] |=(a=@ ~(d ne a))) q.p.lot)] + %i [['0' 'i' ~] ((d-co 1) q.p.lot)] + %x [['0' 'x' ~] ((ox-co [16 4] |=(a=@ ~(x ne a))) q.p.lot)] + %v [['0' 'v' ~] ((ox-co [32 5] |=(a=@ ~(x ne a))) q.p.lot)] + %w [['0' 'w' ~] ((ox-co [64 5] |=(a=@ ~(w ne a))) q.p.lot)] == :: - $s + %s %+ weld ?:((syn:si q.p.lot) "--" "-") $(yed 'u', q.p.lot (abs:si q.p.lot)) :: - $t + %t ?: =('a' hay) ?: =('s' (cut 3 [2 1] p.p.lot)) (weld (rip 3 q.p.lot) rep) From d9929a301cd542c37c90dc66ee31ec95210e6546 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 6 Oct 2020 13:48:51 -0700 Subject: [PATCH 442/933] pill: solid --- bin/solid.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index fe551eb17f..3ff1d5cf2a 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2291d9c0febd6ccd7538571ab1e41409f6808b12e5b3d3b0cb3e0fbf8c1bc8aa -size 6319141 +oid sha256:59c3f8e23f5a80aab704d4246ad518f8e66fdf223023b768180b0581df9f47c2 +size 6320375 From 43425061b0c2640c1c04c82af5990d058112bb2e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 6 Oct 2020 13:55:29 -0700 Subject: [PATCH 443/933] u3: adds u3i_defcons(), deferred cell constructor --- pkg/urbit/include/noun/imprison.h | 6 ++++++ pkg/urbit/noun/imprison.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/pkg/urbit/include/noun/imprison.h b/pkg/urbit/include/noun/imprison.h index 71c692242a..d4d28a87e8 100644 --- a/pkg/urbit/include/noun/imprison.h +++ b/pkg/urbit/include/noun/imprison.h @@ -111,6 +111,12 @@ u3_noun u3i_cell(u3_noun a, u3_noun b); + /* u3i_defcons(): allocate cell for deferred construction. + ** NB: [hed] and [tel] pointers MUST be filled. + */ + u3_cell + u3i_defcons(u3_noun** hed, u3_noun** tel); + /* u3i_trel(): Produce the triple `[a b c]`. */ u3_noun diff --git a/pkg/urbit/noun/imprison.c b/pkg/urbit/noun/imprison.c index 8277d43e25..676d66b3a8 100644 --- a/pkg/urbit/noun/imprison.c +++ b/pkg/urbit/noun/imprison.c @@ -465,6 +465,37 @@ u3i_vint(u3_noun a) } } +/* u3i_defcons(): allocate cell for deferred construction. +** NB: [hed] and [tel] pointers MUST be filled. +*/ +u3_cell +u3i_defcons(u3_noun** hed, u3_noun** tel) +{ + u3_noun pro; + u3t_on(mal_o); + +#ifdef U3_CPU_DEBUG + u3R->pro.cel_d++; +#endif + + { + c3_w* nov_w = u3a_celloc(); + u3a_cell* nov_u = (void *)nov_w; + + nov_u->mug_w = 0; + + // XX zero-initialize head and tail? + // + *hed = &nov_u->hed; + *tel = &nov_u->tel; + + pro = u3a_to_pom(u3a_outa(nov_w)); + } + + u3t_off(mal_o); + return pro; +} + /* u3i_cell(): Produce the cell `[a b]`. */ u3_noun From f81c05fd043158bdf9bdeb998ea2372dcb7bceb5 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 6 Oct 2020 13:56:20 -0700 Subject: [PATCH 444/933] u3: rewrites +turn jet using u3i_defcons() --- pkg/urbit/jets/b/turn.c | 65 +++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/pkg/urbit/jets/b/turn.c b/pkg/urbit/jets/b/turn.c index 3d35c1413f..0db951ff21 100644 --- a/pkg/urbit/jets/b/turn.c +++ b/pkg/urbit/jets/b/turn.c @@ -3,43 +3,46 @@ */ #include "all.h" - static u3_noun - _turn_in(u3j_site* sit_u, u3_noun a) - { - u3_noun b = u3_nul; +u3_noun +u3qb_turn(u3_noun a, u3_noun b) +{ + u3_noun pro = u3_nul; - while ( u3_nul != a ) { - b = u3nc(u3j_gate_slam(sit_u, u3k(u3h(a))), - b); - a = u3t(a); - } - - return u3kb_flop(b); + if ( u3_nul == a ) { + return u3_nul; } - -/* functions -*/ - u3_noun - u3qb_turn(u3_noun a, u3_noun b) - { - u3_noun pro; + else { + u3_noun pro; + u3_noun* lit = &pro; u3j_site sit_u; u3j_gate_prep(&sit_u, u3k(b)); - pro = _turn_in(&sit_u, a); + { + u3_noun* hed; + u3_noun* tel; + u3_noun i, t = a; + + do { + u3x_cell(t, &i, &t); + + *lit = u3i_defcons(&hed, &tel); + *hed = u3j_gate_slam(&sit_u, u3k(i)); + lit = tel; + } + while ( u3_nul != t ); + } u3j_gate_lose(&sit_u); + + *lit = u3_nul; + return pro; } +} - u3_noun - u3wb_turn(u3_noun cor) - { - u3_noun a, b; - - if ( c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0) ) { - return u3m_bail(c3__exit); - } else { - return u3qb_turn(a, b); - } - } - +u3_noun +u3wb_turn(u3_noun cor) +{ + u3_noun a, b; + u3x_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0); + return u3qb_turn(a, b); +} From 8d99c90d81c132e09720e6e3dea3f7270833ebe3 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 6 Oct 2020 13:57:10 -0700 Subject: [PATCH 445/933] u3: rewrites +murn jet using u3i_defcons() --- pkg/urbit/jets/b/murn.c | 82 ++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 43 deletions(-) diff --git a/pkg/urbit/jets/b/murn.c b/pkg/urbit/jets/b/murn.c index e0dcb8d234..b2c2a3e70d 100644 --- a/pkg/urbit/jets/b/murn.c +++ b/pkg/urbit/jets/b/murn.c @@ -3,54 +3,50 @@ */ #include "all.h" - u3_noun - _murn_in(u3j_site* sit_u, u3_noun a) - { - if ( 0 == a ) { - return a; - } - else if ( c3n == u3du(a) ) { - return u3m_bail(c3__exit); - } - else { - u3_noun one = u3j_gate_slam(sit_u, u3k(u3h(a))); - u3_noun two = _murn_in(sit_u, u3t(a)); - u3_noun nex; +u3_noun +u3qb_murn(u3_noun a, u3_noun b) +{ + u3_noun pro = u3_nul; - switch ( u3ud(one) ) { - case c3y: u3z(one); - return two; - case c3n: nex = u3nc(u3k(u3t(one)), two); - u3z(one); - return nex; - default: u3z(one); - u3z(two); - return u3_none; - } - } + if ( u3_nul == a ) { + return u3_nul; } - -/* functions -*/ - u3_noun - u3qb_murn(u3_noun a, u3_noun b) - { - u3_noun pro; + else { + u3_noun pro; + u3_noun* lit = &pro; u3j_site sit_u; + u3j_gate_prep(&sit_u, u3k(b)); - pro = _murn_in(&sit_u, a); + { + u3_noun* hed; + u3_noun* tel; + u3_noun res, i, t = a; + + do { + u3x_cell(t, &i, &t); + + res = u3j_gate_slam(&sit_u, u3k(i)); + + if ( u3_nul != res ) { + *lit = u3i_defcons(&hed, &tel); + *hed = u3t(res); + lit = tel; + } + } + while ( u3_nul != t ); + } u3j_gate_lose(&sit_u); + + *lit = u3_nul; + return pro; } - u3_noun - u3wb_murn(u3_noun cor) - { - u3_noun a, b; - - if ( c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0) ) { - return u3m_bail(c3__exit); - } else { - return u3qb_murn(a, b); - } - } +} +u3_noun +u3wb_murn(u3_noun cor) +{ + u3_noun a, b; + u3x_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0); + return u3qb_murn(a, b); +} From d42c858d735f29ff438fc55c9ff6558fc13d31fd Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 6 Oct 2020 13:58:08 -0700 Subject: [PATCH 446/933] u3: rewrites +scag jet using u3i_defcons() --- pkg/urbit/jets/b/scag.c | 81 ++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/pkg/urbit/jets/b/scag.c b/pkg/urbit/jets/b/scag.c index 075497e586..dd66f6954c 100644 --- a/pkg/urbit/jets/b/scag.c +++ b/pkg/urbit/jets/b/scag.c @@ -3,50 +3,49 @@ */ #include "all.h" - -/* functions -*/ - u3_noun - u3qb_scag(u3_atom a, - u3_noun b) - { - if ( u3_nul == b ) { - return u3_nul; - } - else if ( !_(u3a_is_cat(a)) ) { - return u3m_bail(c3__fail); - } - else { - u3_noun acc = u3_nul; - c3_w i_w = a; - - if ( !i_w ) - return u3_nul; - - while ( i_w ) { - if ( c3n == u3du(b) ) { - return u3kb_flop(acc); - } - acc = u3nc(u3k(u3h(b)), acc); - b = u3t(b); - i_w--; - } - - return u3kb_flop(acc); - } +u3_noun +u3qb_scag(u3_atom a, u3_noun b) +{ + if ( u3_nul == b ) { + return u3_nul; } + else if ( !_(u3a_is_cat(a)) ) { + return u3m_bail(c3__fail); + } + else { + u3_noun pro; + u3_noun* lit = &pro; - u3_noun - u3wb_scag(u3_noun cor) - { - u3_noun a, b; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0)) || - (c3n == u3ud(a) && u3_nul != b) ) { - return u3m_bail(c3__exit); - } else { - return u3qb_scag(a, b); + c3_w len_w = (c3_w)a; + u3_noun* hed; + u3_noun* tel; + u3_noun i, t = b; + + while ( len_w-- && (u3_nul != t) ) { + u3x_cell(t, &i, &t); + + *lit = u3i_defcons(&hed, &tel); + *hed = u3k(i); + lit = tel; + } } + + *lit = u3_nul; + + return pro; + } +} + +u3_noun +u3wb_scag(u3_noun cor) +{ + u3_noun a, b; + u3x_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0); + + if ( (c3n == u3ud(a)) && (u3_nul != b) ) { + return u3m_bail(c3__exit); } + return u3qb_scag(a, b); +} From d9d7a4a13b4117aebc1d92fa2ce8ca00361630ea Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 6 Oct 2020 13:59:10 -0700 Subject: [PATCH 447/933] u3: rewrites +weld jet using u3i_defcons() --- pkg/urbit/jets/b/weld.c | 66 ++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/pkg/urbit/jets/b/weld.c b/pkg/urbit/jets/b/weld.c index 496be934c2..c01470b454 100644 --- a/pkg/urbit/jets/b/weld.c +++ b/pkg/urbit/jets/b/weld.c @@ -3,45 +3,43 @@ */ #include "all.h" +u3_noun +u3qb_weld(u3_noun a, u3_noun b) +{ + u3_noun pro; + u3_noun* lit = &pro; -/* functions -*/ - u3_noun - u3qb_weld(u3_noun a, - u3_noun b) { - u3_noun c = u3qb_flop(a); - u3_noun d = c; + u3_noun* hed; + u3_noun* tel; + u3_noun i, t = a; - u3k(b); + while ( u3_nul != t ) { + u3x_cell(t, &i, &t); - while ( u3_nul != c ) { - b = u3nc(u3k(u3h(c)), b); - c = u3t(c); - } - - u3z(d); - - return b; - } - u3_noun - u3wb_weld(u3_noun cor) - { - u3_noun a, b; - - if ( c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0) ) { - return u3m_bail(c3__exit); - } else { - return u3qb_weld(a, b); + *lit = u3i_defcons(&hed, &tel); + *hed = u3k(i); + lit = tel; } } - u3_noun - u3kb_weld(u3_noun a, - u3_noun b) - { - u3_noun c = u3qb_weld(a, b); - u3z(a); u3z(b); - return c; - } + *lit = u3k(b); + return pro; +} + +u3_noun +u3wb_weld(u3_noun cor) +{ + u3_noun a, b; + u3x_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0); + return u3qb_weld(a, b); +} + +u3_noun +u3kb_weld(u3_noun a, u3_noun b) +{ + u3_noun c = u3qb_weld(a, b); + u3z(a); u3z(b); + return c; +} From 20ea17250b6c7291bf21b76de716bb2ed9a7e769 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 6 Oct 2020 14:05:31 -0700 Subject: [PATCH 448/933] u3: rewrites +flop jet using new list iteration idiom --- pkg/urbit/jets/b/flop.c | 63 +++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 40 deletions(-) diff --git a/pkg/urbit/jets/b/flop.c b/pkg/urbit/jets/b/flop.c index b6fb03f8d9..296c134c22 100644 --- a/pkg/urbit/jets/b/flop.c +++ b/pkg/urbit/jets/b/flop.c @@ -3,46 +3,29 @@ */ #include "all.h" +u3_noun +u3qb_flop(u3_noun a) +{ + u3_noun i, t = a, b = u3_nul; -/* functions -*/ - u3_noun - u3qb_flop(u3_noun a) - { - u3_noun b = 0; - - while ( 1 ) { - if ( u3_nul == a ) { - return b; - } - else if ( c3n == u3du(a) ) { - u3z(b); - - return u3m_bail(c3__exit); - } - else { - b = u3nc(u3k(u3h(a)), b); - a = u3t(a); - } - } - } - u3_noun - u3wb_flop(u3_noun cor) - { - u3_noun a; - - if ( u3_none == (a = u3r_at(u3x_sam, cor)) ) { - return u3m_bail(c3__exit); - } else { - return u3qb_flop(a); - } - } - u3_noun - u3kb_flop(u3_noun a) - { - u3_noun b = u3qb_flop(a); - - u3z(a); - return b; + while ( u3_nul != t ) { + u3x_cell(t, &i, &t); + b = u3nc(u3k(i), b); } + return b; +} + +u3_noun +u3wb_flop(u3_noun cor) +{ + return u3qb_flop(u3x_at(u3x_sam, cor)); +} + +u3_noun +u3kb_flop(u3_noun a) +{ + u3_noun b = u3qb_flop(a); + u3z(a); + return b; +} From c4587d9043b8382a4ff7a3c6e17ad961161d9eeb Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 6 Oct 2020 15:07:52 -0700 Subject: [PATCH 449/933] u3: fixes memory leaks in +dvr and +sqt jets caused by unecessary u3k() calls around gmp conversion --- pkg/urbit/jets/c/dvr.c | 2 +- pkg/urbit/jets/c/sqt.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/jets/c/dvr.c b/pkg/urbit/jets/c/dvr.c index 68205286c6..e2c9a9c7b8 100644 --- a/pkg/urbit/jets/c/dvr.c +++ b/pkg/urbit/jets/c/dvr.c @@ -25,7 +25,7 @@ mpz_tdiv_qr(a_mp, b_mp, a_mp, b_mp); - return u3nc(u3k(u3i_mp(a_mp)), u3k(u3i_mp(b_mp))); + return u3nc(u3i_mp(a_mp), u3i_mp(b_mp)); } } } diff --git a/pkg/urbit/jets/c/sqt.c b/pkg/urbit/jets/c/sqt.c index 09775deed4..160967d60a 100644 --- a/pkg/urbit/jets/c/sqt.c +++ b/pkg/urbit/jets/c/sqt.c @@ -15,7 +15,7 @@ mpz_init(b_mp); mpz_sqrtrem(a_mp, b_mp, a_mp); - return u3nc(u3k(u3i_mp(a_mp)), u3k(u3i_mp(b_mp))); + return u3nc(u3i_mp(a_mp), u3i_mp(b_mp)); } u3_noun u3wc_sqt(u3_noun cor) From 247f416a090ec63c9a677340b11b3d4c69238389 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 6 Oct 2020 15:17:37 -0700 Subject: [PATCH 450/933] u3: fixes mismatches in +div and +dvr jets --- pkg/urbit/jets/a/div.c | 2 +- pkg/urbit/jets/c/dvr.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/urbit/jets/a/div.c b/pkg/urbit/jets/a/div.c index fa28531607..ce2df181e5 100644 --- a/pkg/urbit/jets/a/div.c +++ b/pkg/urbit/jets/a/div.c @@ -11,7 +11,7 @@ u3_atom b) { if ( 0 == b ) { - return u3m_bail(c3__exit); + return u3m_error("divide-by-zero"); } else { if ( _(u3a_is_cat(a)) && _(u3a_is_cat(b)) ) { diff --git a/pkg/urbit/jets/c/dvr.c b/pkg/urbit/jets/c/dvr.c index e2c9a9c7b8..826631c999 100644 --- a/pkg/urbit/jets/c/dvr.c +++ b/pkg/urbit/jets/c/dvr.c @@ -10,8 +10,8 @@ u3qc_dvr(u3_atom a, u3_atom b) { - if ( 0 == b) { - return u3m_bail(c3__exit); + if ( 0 == b ) { + return u3m_error("divide-by-zero"); } else { if ( _(u3a_is_cat(a)) && _(u3a_is_cat(b)) ) { From a217ddbed9eadd8fb6cc395e3add6cd95235a22e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 6 Oct 2020 16:12:03 -0700 Subject: [PATCH 451/933] u3: fixes memory leak introduced in +murn jet --- pkg/urbit/jets/b/murn.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/urbit/jets/b/murn.c b/pkg/urbit/jets/b/murn.c index b2c2a3e70d..e5d675a74e 100644 --- a/pkg/urbit/jets/b/murn.c +++ b/pkg/urbit/jets/b/murn.c @@ -29,8 +29,9 @@ u3qb_murn(u3_noun a, u3_noun b) if ( u3_nul != res ) { *lit = u3i_defcons(&hed, &tel); - *hed = u3t(res); + *hed = u3k(u3t(res)); lit = tel; + u3z(res); } } while ( u3_nul != t ); From 4215209f272382db4ef8fef3a555d982c0e09e48 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 6 Oct 2020 16:13:17 -0700 Subject: [PATCH 452/933] u3: moves cell allocation counter into u3a_celloc() --- pkg/urbit/noun/allocate.c | 4 ++++ pkg/urbit/noun/imprison.c | 16 ++++------------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/pkg/urbit/noun/allocate.c b/pkg/urbit/noun/allocate.c index 345de96b31..7beee65a44 100644 --- a/pkg/urbit/noun/allocate.c +++ b/pkg/urbit/noun/allocate.c @@ -789,6 +789,10 @@ u3a_cellblock(c3_w num_w) c3_w* u3a_celloc(void) { +#ifdef U3_CPU_DEBUG + u3R->pro.cel_d++; +#endif + #ifdef U3_MEMORY_DEBUG if ( u3C.wag_w & u3o_debug_ram ) { return u3a_walloc(c3_wiseof(u3a_cell)); diff --git a/pkg/urbit/noun/imprison.c b/pkg/urbit/noun/imprison.c index 676d66b3a8..b007a6e3ef 100644 --- a/pkg/urbit/noun/imprison.c +++ b/pkg/urbit/noun/imprison.c @@ -472,12 +472,8 @@ u3_cell u3i_defcons(u3_noun** hed, u3_noun** tel) { u3_noun pro; + u3t_on(mal_o); - -#ifdef U3_CPU_DEBUG - u3R->pro.cel_d++; -#endif - { c3_w* nov_w = u3a_celloc(); u3a_cell* nov_u = (void *)nov_w; @@ -491,8 +487,8 @@ u3i_defcons(u3_noun** hed, u3_noun** tel) pro = u3a_to_pom(u3a_outa(nov_w)); } - u3t_off(mal_o); + return pro; } @@ -502,12 +498,8 @@ u3_noun u3i_cell(u3_noun a, u3_noun b) { u3_noun pro; + u3t_on(mal_o); - -#ifdef U3_CPU_DEBUG - u3R->pro.cel_d++; -#endif - { c3_w* nov_w = u3a_celloc(); u3a_cell* nov_u = (void *)nov_w; @@ -518,8 +510,8 @@ u3i_cell(u3_noun a, u3_noun b) pro = u3a_to_pom(u3a_outa(nov_w)); } - u3t_off(mal_o); + return pro; } From 94a4dc5f5d346645dfbbf81d8632d5009e5fcc89 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 6 Oct 2020 16:48:38 -0700 Subject: [PATCH 453/933] u3: optimizes +lent jet, avoiding u3i_vint() while possible --- pkg/urbit/jets/b/lent.c | 69 ++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/pkg/urbit/jets/b/lent.c b/pkg/urbit/jets/b/lent.c index e228e6e619..33e46aaa63 100644 --- a/pkg/urbit/jets/b/lent.c +++ b/pkg/urbit/jets/b/lent.c @@ -3,45 +3,56 @@ */ #include "all.h" +u3_noun +u3qb_lent(u3_noun a) +{ + if ( u3_nul == a ) { + return 0; + } -/* functions -*/ - u3_noun - u3qb_lent(u3_noun a) + // loop until we overflow [len_w] + // { - u3_noun len = 0; + c3_w len_w = 1; + + do { + a = u3t(a); + + if ( u3_nul == a ) { + return u3i_words(1, &len_w); + } + } + while ( ++len_w ); + } + + // continue with arbitrary precision + // + { + u3_noun len = u3qc_bex(32); while ( 1 ) { - if ( 0 == a ) { + a = u3t(a); + + if ( u3_nul == a ) { return len; } - else if ( c3n == u3du(a) ) { - u3z(len); - return u3m_bail(c3__exit); - } else { len = u3i_vint(len); - a = u3t(a); } } } - u3_noun - u3wb_lent(u3_noun cor) - { - u3_noun a; +} - if ( u3_none == (a = u3r_at(u3x_sam, cor)) ) { - return u3m_bail(c3__exit); - } else { - return u3qb_lent(a); - } - } - u3_noun - u3kb_lent(u3_noun a) - { - u3_noun b = u3qb_lent(a); - - u3z(a); - return b; - } +u3_noun +u3wb_lent(u3_noun cor) +{ + return u3qb_lent(u3x_at(u3x_sam, cor)); +} +u3_noun +u3kb_lent(u3_noun a) +{ + u3_noun b = u3qb_lent(a); + u3z(a); + return b; +} From f20fe17434127b982a2ccd86bf2615de16e4079b Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 6 Oct 2020 16:53:01 -0700 Subject: [PATCH 454/933] u3: refactors allocator constants, adds u3a_cells and u3a_maximum --- pkg/urbit/include/noun/allocate.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pkg/urbit/include/noun/allocate.h b/pkg/urbit/include/noun/allocate.h index 602077f5c6..4fb4859d40 100644 --- a/pkg/urbit/include/noun/allocate.h +++ b/pkg/urbit/include/noun/allocate.h @@ -24,15 +24,18 @@ */ # define u3a_bytes (c3_w)((1 << (2 + u3a_bits))) - /* u3a_minimum: minimum number of words in a box. - ** - ** wiseof(u3a_cell) + wiseof(u3a_box) + 1 (trailing siz_w) + /* u3a_cells: number of representable cells. */ -#ifdef U3_MEMORY_DEBUG -# define u3a_minimum 8 -#else -# define u3a_minimum 6 -#endif +# define u3a_cells (c3_w)(u3a_words / u3a_minimum) + + /* u3a_maximum: maximum loom object size (largest possible atom). + */ +# define u3a_maximum \ + (c3_w)(u3a_words - (c3_wiseof(u3a_box) + c3_wiseof(u3a_atom))) + + /* u3a_minimum: minimum loom object size (actual size of a cell). + */ +# define u3a_minimum (c3_w)(1 + c3_wiseof(u3a_box) + c3_wiseof(u3a_cell)) /* u3a_fbox_no: number of free lists per size. */ From 0f9fbba66a4e19cf53c25f89ab3c49bb10e385a8 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 6 Oct 2020 16:53:42 -0700 Subject: [PATCH 455/933] u3: further optimizes +lent jet, gated by compile-time assertion --- pkg/urbit/jets/b/lent.c | 42 +++++++++-------------------------------- 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/pkg/urbit/jets/b/lent.c b/pkg/urbit/jets/b/lent.c index 33e46aaa63..f0320c03f6 100644 --- a/pkg/urbit/jets/b/lent.c +++ b/pkg/urbit/jets/b/lent.c @@ -3,44 +3,20 @@ */ #include "all.h" +STATIC_ASSERT( (UINT32_MAX > u3a_cells), + "length precision" ); + u3_noun u3qb_lent(u3_noun a) { - if ( u3_nul == a ) { - return 0; + c3_w len_w = 0; + + while ( u3_nul != a ) { + a = u3t(a); + len_w++; } - // loop until we overflow [len_w] - // - { - c3_w len_w = 1; - - do { - a = u3t(a); - - if ( u3_nul == a ) { - return u3i_words(1, &len_w); - } - } - while ( ++len_w ); - } - - // continue with arbitrary precision - // - { - u3_noun len = u3qc_bex(32); - - while ( 1 ) { - a = u3t(a); - - if ( u3_nul == a ) { - return len; - } - else { - len = u3i_vint(len); - } - } - } + return u3i_word(len_w); } u3_noun From 42b10e4b8075c9249dee51aaa30715ace5692413 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 6 Oct 2020 17:02:30 -0700 Subject: [PATCH 456/933] u3: optimizes +wyt:in jet, gated by compile-time assertion --- pkg/urbit/jets/d/in_wyt.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/pkg/urbit/jets/d/in_wyt.c b/pkg/urbit/jets/d/in_wyt.c index de4d659a14..d28fbac162 100644 --- a/pkg/urbit/jets/d/in_wyt.c +++ b/pkg/urbit/jets/d/in_wyt.c @@ -3,26 +3,31 @@ */ #include "all.h" -/* functions -*/ -u3_noun -u3qdi_wyt(u3_noun a) +STATIC_ASSERT( (UINT32_MAX > u3a_cells), + "width precision" ); + +static c3_w +_wyt_in(u3_noun a) { if ( u3_nul == a ) { return 0; } else { - u3_noun n_a, l_a, r_a; - u3x_trel(a, &n_a, &l_a, &r_a); + u3_noun l_a, r_a; + u3x_trel(a, 0, &l_a, &r_a); - return u3i_vint(u3ka_add(u3qdi_wyt(l_a), u3qdi_wyt(r_a))); + return 1 + _wyt_in(l_a) + _wyt_in(r_a); } } +u3_noun +u3qdi_wyt(u3_noun a) +{ + return u3i_word(_wyt_in(a)); +} + u3_noun u3wdi_wyt(u3_noun cor) { - u3_noun a; - u3x_mean(cor, u3x_con_2, &a, 0); - return u3qdi_wyt(a); + return u3qdi_wyt(u3x_at(u3x_con_2, cor)); } From ce92c405fe3e16b8714445cb4e72f51b152edf2c Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 6 Oct 2020 13:31:58 -0400 Subject: [PATCH 457/933] king: --serf="" is a host option, not a per ship option. This means you don't need to specify this per ship in a multitenant environment when you are alwyas going to set it to the same binary if you're overriding it in the first place. --- pkg/hs/urbit-king/lib/Urbit/King/CLI.hs | 23 +++++++----- pkg/hs/urbit-king/lib/Urbit/King/Main.hs | 47 ++++++++++++------------ 2 files changed, 37 insertions(+), 33 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs index 5657ce8c8c..1fa0c0f822 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs @@ -20,6 +20,7 @@ data Host = Host { hSharedHttpPort :: Maybe Word16 , hSharedHttpsPort :: Maybe Word16 , hUseNatPmp :: Nat + , hSerfExe :: Maybe Text } deriving (Show) @@ -43,7 +44,6 @@ data Opts = Opts , oHttpPort :: Maybe Word16 , oHttpsPort :: Maybe Word16 , oLoopbackPort :: Maybe Word16 - , oSerfExe :: Maybe Text } deriving (Show) @@ -83,6 +83,7 @@ data New = New , nArvoDir :: Maybe FilePath , nBootType :: BootType , nLite :: Bool + , nSerfExe :: Maybe Text } deriving (Show) @@ -220,6 +221,14 @@ pillFromURL = PillSourceURL <$> strOption pierPath :: Parser FilePath pierPath = strArgument (metavar "PIER" <> help "Path to pier") +serfExe :: Parser (Maybe Text) +serfExe = optional + $ strOption + $ metavar "PATH" + <> long "serf" + <> help "Path to serf binary to run ships in" + <> hidden + new :: Parser New new = do nPierPath <- optional pierPath @@ -240,6 +249,8 @@ new = do <> value Nothing <> help "Replace initial clay filesys with contents of PATH" + nSerfExe <- serfExe + pure New{..} opts :: Parser Opts @@ -295,14 +306,6 @@ opts = do <> help "Localhost-only HTTP port" <> hidden - oSerfExe <- - optional - $ strOption - $ metavar "PATH" - <> long "serf" - <> help "Path to Serf" - <> hidden - oHashless <- switch $ short 'S' <> long "hashless" <> help "Disable battery hashing (Ignored for now)" @@ -451,6 +454,8 @@ host = do ) <|> (pure $ NatWhenPrivateNetwork) + hSerfExe <- serfExe + pure (Host{..}) runShip :: Parser (Cmd, Log) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs index 3f13b770f7..a9ec7e7d38 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs @@ -141,12 +141,12 @@ toSerfFlags CLI.Opts{..} = catMaybes m setFrom True flag = Just flag setFrom False _ = Nothing -toPierConfig :: FilePath -> CLI.Opts -> PierConfig -toPierConfig pierPath o@(CLI.Opts{..}) = PierConfig { .. } +toPierConfig :: FilePath -> Maybe Text -> CLI.Opts -> PierConfig +toPierConfig pierPath serfExe o@(CLI.Opts{..}) = PierConfig { .. } where _pcPierPath = pierPath _pcDryRun = oDryRun || isJust oDryFrom - _pcSerfExe = oSerfExe + _pcSerfExe = serfExe _pcSerfFlags = toSerfFlags o toNetworkConfig :: CLI.Opts -> NetworkConfig @@ -552,16 +552,17 @@ newShip CLI.New{..} opts = do -> RIO HostEnv () runTryBootFromPill pill name ship bootEvent = do vKill <- view (kingEnvL . kingEnvKillSignal) - let pierConfig = toPierConfig (pierPath name) opts + let pierConfig = toPierConfig (pierPath name) nSerfExe opts let networkConfig = toNetworkConfig opts runPierEnv pierConfig networkConfig vKill $ tryBootFromPill True pill nLite ship bootEvent -runShipEnv :: CLI.Run -> CLI.Opts -> TMVar () -> RIO PierEnv a -> RIO HostEnv a -runShipEnv (CLI.Run pierPath) opts vKill act = do +runShipEnv :: Maybe Text -> CLI.Run -> CLI.Opts -> TMVar () -> RIO PierEnv a + -> RIO HostEnv a +runShipEnv serfExe (CLI.Run pierPath) opts vKill act = do runPierEnv pierConfig netConfig vKill act where - pierConfig = toPierConfig pierPath opts + pierConfig = toPierConfig pierPath serfExe opts netConfig = toNetworkConfig opts runShip @@ -701,19 +702,17 @@ main = do Once `waitForKillRequ` returns, the ship will be terminated and this routine will exit. - - TODO Use logging system instead of printing. -} runShipRestarting - :: CLI.Run -> CLI.Opts -> RIO HostEnv () -runShipRestarting r o = do + :: Maybe Text -> CLI.Run -> CLI.Opts -> RIO HostEnv () +runShipRestarting serfExe r o = do let pier = pack (CLI.rPierPath r) - loop = runShipRestarting r o + loop = runShipRestarting serfExe r o onKill <- view onKillKingSigL vKillPier <- newEmptyTMVarIO - tid <- asyncBound $ runShipEnv r o vKillPier $ runShip r o True + tid <- asyncBound $ runShipEnv serfExe r o vKillPier $ runShip r o True let onShipExit = Left <$> waitCatchSTM tid onKillRequ = Right <$> onKill @@ -738,11 +737,11 @@ runShipRestarting r o = do TODO This is messy and shared a lot of logic with `runShipRestarting`. -} runShipNoRestart - :: CLI.Run -> CLI.Opts -> Bool -> RIO HostEnv () -runShipNoRestart r o d = do + :: Maybe Text -> CLI.Run -> CLI.Opts -> Bool -> RIO HostEnv () +runShipNoRestart serfExe r o d = do -- killing ship same as killing king vKill <- view (kingEnvL . kingEnvKillSignal) - tid <- asyncBound (runShipEnv r o vKill $ runShip r o d) + tid <- asyncBound (runShipEnv serfExe r o vKill $ runShip r o d) onKill <- view onKillKingSigL let pier = pack (CLI.rPierPath r) @@ -781,14 +780,14 @@ runShips CLI.Host {..} ships = do go :: [(CLI.Run, CLI.Opts, Bool)] -> RIO HostEnv () go = \case [] -> pure () - [rod] -> runSingleShip rod - ships -> runMultipleShips (ships <&> \(r, o, _) -> (r, o)) + [rod] -> runSingleShip hSerfExe rod + ships -> runMultipleShips hSerfExe (ships <&> \(r, o, _) -> (r, o)) -- TODO Duplicated logic. -runSingleShip :: (CLI.Run, CLI.Opts, Bool) -> RIO HostEnv () -runSingleShip (r, o, d) = do - shipThread <- async (runShipNoRestart r o d) +runSingleShip :: Maybe Text -> (CLI.Run, CLI.Opts, Bool) -> RIO HostEnv () +runSingleShip serfExe (r, o, d) = do + shipThread <- async (runShipNoRestart serfExe r o d) {- Wait for the ship to go down. @@ -808,10 +807,10 @@ runSingleShip (r, o, d) = do pure () -runMultipleShips :: [(CLI.Run, CLI.Opts)] -> RIO HostEnv () -runMultipleShips ships = do +runMultipleShips :: Maybe Text -> [(CLI.Run, CLI.Opts)] -> RIO HostEnv () +runMultipleShips serfExe ships = do shipThreads <- for ships $ \(r, o) -> do - async (runShipRestarting r o) + async (runShipRestarting serfExe r o) {- Since `spin` never returns, this will run until the main From 5eeb86a93597ae29602aeeb60f06c9fb5eea6601 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 7 Oct 2020 12:47:42 -0400 Subject: [PATCH 458/933] king: actually try shutting down the piers --- pkg/hs/urbit-king/lib/Urbit/King/Main.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs index a9ec7e7d38..bced7c0fcc 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs @@ -727,6 +727,7 @@ runShipRestarting serfExe r o = do loop Right () -> do logTrace $ display (pier <> " shutdown requested") + atomically $ putTMVar vKillPier () race_ (wait tid) $ do threadDelay 5_000_000 logInfo $ display (pier <> " not down after 5s, killing with fire.") From d7a5f23b12e44234c4fbd5b6d36d1595a794c350 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 7 Oct 2020 15:08:49 -0700 Subject: [PATCH 459/933] u3: initializes head/tail in u3i_defcons() (under U3_MEMORY_DEBUG) --- pkg/urbit/noun/imprison.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/noun/imprison.c b/pkg/urbit/noun/imprison.c index b007a6e3ef..58251cc17a 100644 --- a/pkg/urbit/noun/imprison.c +++ b/pkg/urbit/noun/imprison.c @@ -480,8 +480,11 @@ u3i_defcons(u3_noun** hed, u3_noun** tel) nov_u->mug_w = 0; - // XX zero-initialize head and tail? - // +#ifdef U3_MEMORY_DEBUG + nov_u->hed = u3_none; + nov_u->tel = u3_none; +#endif + *hed = &nov_u->hed; *tel = &nov_u->tel; From 4a0e09efa4a0b8fea332892e6eb895aa9ea1e01c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 7 Oct 2020 19:56:15 -0700 Subject: [PATCH 460/933] u3: updates %leer jet (+to-wain) to use u3i_defcons() --- pkg/urbit/jets/e/lore.c | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/pkg/urbit/jets/e/lore.c b/pkg/urbit/jets/e/lore.c index e454aa68da..e22d806b65 100644 --- a/pkg/urbit/jets/e/lore.c +++ b/pkg/urbit/jets/e/lore.c @@ -83,25 +83,40 @@ u3_noun u3qe_leer(u3_atom txt) { - c3_w pos_w, i_w = 0, len_w = u3r_met(3, txt); - u3_noun out = u3_nul; + u3_noun pro; + u3_noun* lit = &pro; - while ( 1 ) { - // scan till end or newline - for ( pos_w = i_w; i_w < len_w; ++i_w ) { - if ( 10 == u3r_byte(i_w, txt) ) { + { + c3_w pos_w, i_w = 0, len_w = u3r_met(3, txt); + + while ( 1 ) { + // scan till end or newline + for ( pos_w = i_w; i_w < len_w; ++i_w ) { + if ( 10 == u3r_byte(i_w, txt) ) { + break; + } + } + + // append to list + { + u3_noun* hed; + u3_noun* tel; + + *lit = u3i_defcons(&hed, &tel); + *hed = _lore_cut(pos_w, i_w - pos_w, txt); + lit = tel; + } + + // finish or advance + if ( i_w++ == len_w ) { break; } } - // append to list - out = u3nc(_lore_cut(pos_w, i_w - pos_w, txt), out); - // finish or advance - if ( i_w++ == len_w ) { - break; - } } - return u3kb_flop(out); + *lit = u3_nul; + + return pro; } u3_noun From 76b854b3295b9017f40dc534580745336b61ad3e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 7 Oct 2020 20:02:50 -0700 Subject: [PATCH 461/933] u3: refactors %leer jet --- pkg/urbit/jets/e/lore.c | 216 +++++++++++++++++++--------------------- 1 file changed, 105 insertions(+), 111 deletions(-) diff --git a/pkg/urbit/jets/e/lore.c b/pkg/urbit/jets/e/lore.c index e22d806b65..a880f69be6 100644 --- a/pkg/urbit/jets/e/lore.c +++ b/pkg/urbit/jets/e/lore.c @@ -1,134 +1,128 @@ -/* j/5/lore.c +/* j/5/leer.c ** */ #include "all.h" - static u3_atom - _lore_cut(c3_w pos_w, c3_w len_w, u3_atom src) - { - if ( 0 == len_w ) { - return 0; +static u3_atom +_leer_cut(c3_w pos_w, c3_w len_w, u3_atom src) +{ + if ( 0 == len_w ) { + return 0; + } + else { + u3i_slab sab_u; + u3i_slab_bare(&sab_u, 3, len_w); + sab_u.buf_w[sab_u.len_w - 1] = 0; + + u3r_bytes(pos_w, len_w, sab_u.buf_y, src); + + return u3i_slab_mint_bytes(&sab_u); + } +} + +// Leaving the lore jet in place for backwards compatibility. +// TODO: remove u3[qw]e_lore (also from jet tree) + +u3_noun +u3qe_lore(u3_atom lub) +{ + c3_w len_w = u3r_met(3, lub); + c3_w pos_w = 0; + u3_noun tez = u3_nul; + + while ( 1 ) { + c3_w meg_w = 0; + c3_y end_y; + + c3_y byt_y; + while ( 1 ) { + if ( pos_w >= len_w ) { + byt_y = 0; + end_y = c3y; + break; + } + byt_y = u3r_byte(pos_w + meg_w, lub); + + if ( (10 == byt_y) || (0 == byt_y) ) { + end_y = __(byt_y == 0); + break; + } else meg_w++; + } + + if ((byt_y == 0) && ((pos_w + meg_w + 1) < len_w)) { + return u3m_bail(c3__exit); + } + + if ( !_(end_y) && pos_w >= len_w ) { + return u3kb_flop(tez); } else { - u3i_slab sab_u; - u3i_slab_bare(&sab_u, 3, len_w); - sab_u.buf_w[sab_u.len_w - 1] = 0; - - u3r_bytes(pos_w, len_w, sab_u.buf_y, src); - - return u3i_slab_mint_bytes(&sab_u); - } - } - - // Leaving the lore jet in place for backwards compatibility. - // TODO: remove u3[qw]e_lore (also from jet tree) - - u3_noun - u3qe_lore(u3_atom lub) - { - c3_w len_w = u3r_met(3, lub); - c3_w pos_w = 0; - u3_noun tez = u3_nul; - - while ( 1 ) { - c3_w meg_w = 0; - c3_y end_y; - - c3_y byt_y; - while ( 1 ) { - if ( pos_w >= len_w ) { - byt_y = 0; - end_y = c3y; - break; - } - byt_y = u3r_byte(pos_w + meg_w, lub); - - if ( (10 == byt_y) || (0 == byt_y) ) { - end_y = __(byt_y == 0); - break; - } else meg_w++; - } - - if ((byt_y == 0) && ((pos_w + meg_w + 1) < len_w)) { - return u3m_bail(c3__exit); - } - - if ( !_(end_y) && pos_w >= len_w ) { + tez = u3nc(_leer_cut(pos_w, meg_w, lub), tez); + if ( _(end_y) ) { return u3kb_flop(tez); } - else { - tez = u3nc(_lore_cut(pos_w, meg_w, lub), tez); - if ( _(end_y) ) { - return u3kb_flop(tez); - } - pos_w += (meg_w + 1); - } + pos_w += (meg_w + 1); } } +} - u3_noun - u3we_lore(u3_noun cor) +u3_noun +u3we_lore(u3_noun cor) +{ + u3_noun lub; + + if ( (u3_none == (lub = u3r_at(u3x_sam, cor))) || + (c3n == u3ud(lub)) ) { - u3_noun lub; - - if ( (u3_none == (lub = u3r_at(u3x_sam, cor))) || - (c3n == u3ud(lub)) ) - { - return u3m_bail(c3__fail); - } else { - return u3qe_lore(lub); - } + return u3m_bail(c3__fail); + } else { + return u3qe_lore(lub); } +} + +u3_noun +u3qe_leer(u3_atom txt) +{ + u3_noun pro; + u3_noun* lit = &pro; - u3_noun - u3qe_leer(u3_atom txt) { - u3_noun pro; - u3_noun* lit = &pro; + c3_w pos_w, i_w = 0, len_w = u3r_met(3, txt); + u3_noun* hed; + u3_noun* tel; - { - c3_w pos_w, i_w = 0, len_w = u3r_met(3, txt); - - while ( 1 ) { - // scan till end or newline - for ( pos_w = i_w; i_w < len_w; ++i_w ) { - if ( 10 == u3r_byte(i_w, txt) ) { - break; - } - } - - // append to list - { - u3_noun* hed; - u3_noun* tel; - - *lit = u3i_defcons(&hed, &tel); - *hed = _lore_cut(pos_w, i_w - pos_w, txt); - lit = tel; - } - - // finish or advance - if ( i_w++ == len_w ) { + while ( i_w < len_w ) { + // scan till end or newline + // + for ( pos_w = i_w; i_w < len_w; ++i_w ) { + if ( 10 == u3r_byte(i_w, txt) ) { break; } } - } - *lit = u3_nul; + // append to list + // + *lit = u3i_defcons(&hed, &tel); + *hed = _leer_cut(pos_w, i_w - pos_w, txt); + lit = tel; - return pro; - } - - u3_noun - u3we_leer(u3_noun cor) - { - u3_noun txt; - - if ( (u3_none == (txt = u3r_at(u3x_sam, cor))) || - (c3n == u3ud(txt)) ) - { - return u3m_bail(c3__fail); - } else { - return u3qe_leer(txt); + i_w++; } } + + *lit = u3_nul; + + return pro; +} + +u3_noun +u3we_leer(u3_noun cor) +{ + u3_noun txt = u3x_at(u3x_sam, cor); + + if ( c3n == u3ud(txt) ) { + return u3m_bail(c3__fail); + } + + return u3qe_leer(txt); +} From cd4a64d93d4cf36cdf9a9ffff99bb656b35b3100 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 7 Oct 2020 20:03:07 -0700 Subject: [PATCH 462/933] u3: renames lore.c to leer.c --- pkg/urbit/jets/e/{lore.c => leer.c} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename pkg/urbit/jets/e/{lore.c => leer.c} (100%) diff --git a/pkg/urbit/jets/e/lore.c b/pkg/urbit/jets/e/leer.c similarity index 100% rename from pkg/urbit/jets/e/lore.c rename to pkg/urbit/jets/e/leer.c From 84ff37482a85109c4e5661663826fbe944248c72 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 8 Oct 2020 14:05:31 -0700 Subject: [PATCH 463/933] u3: enables gc in ames and newt tests --- pkg/urbit/tests/ames_tests.c | 4 ++++ pkg/urbit/tests/newt_tests.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/pkg/urbit/tests/ames_tests.c b/pkg/urbit/tests/ames_tests.c index 7cf4ba9858..dd4565fc12 100644 --- a/pkg/urbit/tests/ames_tests.c +++ b/pkg/urbit/tests/ames_tests.c @@ -39,6 +39,10 @@ main(int argc, char* argv[]) _test_ames(); + // GC + // + u3m_grab(u3_none); + fprintf(stderr, "ames okeedokee\n"); return 0; } diff --git a/pkg/urbit/tests/newt_tests.c b/pkg/urbit/tests/newt_tests.c index 639cc80e51..7e147d62a2 100644 --- a/pkg/urbit/tests/newt_tests.c +++ b/pkg/urbit/tests/newt_tests.c @@ -343,6 +343,10 @@ main(int argc, char* argv[]) _test_newt_smol(); _test_newt_vast(); + // GC + // + u3m_grab(u3_none); + fprintf(stderr, "test_newt: ok\n"); return 0; From 5350dbfbbd9a7505194e6e05b361f2ba921e9b36 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 8 Oct 2020 14:05:58 -0700 Subject: [PATCH 464/933] u3: cleans up testing protocol, enables gc in hashtable tests --- pkg/urbit/tests/hashtable_tests.c | 135 +++++++++++++++++++++--------- 1 file changed, 96 insertions(+), 39 deletions(-) diff --git a/pkg/urbit/tests/hashtable_tests.c b/pkg/urbit/tests/hashtable_tests.c index 071d05cf30..ee03b9318a 100644 --- a/pkg/urbit/tests/hashtable_tests.c +++ b/pkg/urbit/tests/hashtable_tests.c @@ -14,41 +14,51 @@ _setup(void) /* _test_bit_manipulation(): */ -static void +static c3_i _test_bit_manipulation() { - if ( sizeof(u3_noun) != sizeof(u3h_slot) ){ - c3_assert(!"wrong size\n"); + c3_i ret_i = 1; + + if ( sizeof(u3_noun) != sizeof(u3h_slot) ) { + fprintf(stderr, "bit manipulation: wrong size\r\n"); + ret_i = 0; } u3h_slot a = 0; - if (u3h_slot_is_null(a) != c3y){ - c3_assert(!"nullity\n"); + if (u3h_slot_is_null(a) != c3y) { + fprintf(stderr, "bit manipulation: nullity\r\n"); + ret_i = 0; } a = u3h_noun_be_warm(a); - if (u3h_slot_is_warm(a) != c3y){ - c3_assert(!"warmth\n"); + if (u3h_slot_is_warm(a) != c3y) { + fprintf(stderr, "bit manipulation: warmth\r\n"); + ret_i = 0; } - if (u3h_slot_is_null(a) != c3n){ - c3_assert(!"nullity 2\n"); + if (u3h_slot_is_null(a) != c3n) { + fprintf(stderr, "bit manipulation: nullity 2\r\n"); + ret_i = 0; } a = u3h_noun_be_cold(a); - if (u3h_slot_is_warm(a) != c3n){ - c3_assert(!"coldness\n"); + if (u3h_slot_is_warm(a) != c3n) { + fprintf(stderr, "bit manipulation: coldness\r\n"); + ret_i = 0; } + + return ret_i; } /* _test_no_cache(): test a hashtable without caching. */ -static void +static c3_i _test_no_cache(void) { - c3_w i_w; + c3_i ret_i = 1; c3_w max_w = 1000; + c3_w i_w; u3p(u3h_root) har_p = u3h_new(); @@ -57,52 +67,77 @@ _test_no_cache(void) } for ( i_w = 0; i_w < max_w; i_w++ ) { - c3_assert(i_w + max_w == u3h_get(har_p, i_w)); + if ( (i_w + max_w) != u3h_get(har_p, i_w) ) { + fprintf(stderr, "bit test_no_cache: get failed\r\n"); + ret_i = 0; + } } - printf("test_no_cache: ok\n"); + + u3h_free(har_p); + return ret_i; } /* _test_skip_slot(): */ -static void +static c3_i _test_skip_slot(void) { + c3_i ret_i = 1; + // root table { c3_w mug_w = 0x17 << 25; c3_w res_w = _ch_skip_slot(mug_w, 25); - c3_assert((0x18 << 25) == res_w); + + if ( (0x18 << 25) != res_w ) { + fprintf(stderr, "bit skip_slot (a): failed\r\n"); + ret_i = 0; + } } { c3_w mug_w = 63 << 25; // 6 bits, all ones c3_w res_w = _ch_skip_slot(mug_w, 25); - c3_assert(0 == res_w); + + if ( 0 != res_w ) { + fprintf(stderr, "bit skip_slot (b): failed\r\n"); + ret_i = 0; + } } // child nodes { c3_w mug_w = 17 << 20; c3_w res_w = _ch_skip_slot(mug_w, 20); - c3_assert((18 << 20) == res_w); + + if ( (18 << 20) != res_w ) { + fprintf(stderr, "bit skip_slot (c): failed\r\n"); + ret_i = 0; + } } { c3_w mug_w = 31 << 20; // 5 bits, all ones c3_w res_w = _ch_skip_slot(mug_w, 20); c3_assert((1 << 25) == res_w); + + if ( (1 << 25) != res_w ) { + fprintf(stderr, "bit skip_slot (d): failed\r\n"); + ret_i = 0; + } } - fprintf(stderr, "test_skip_slot: ok\n"); + return ret_i; } /* _test_cache_trimming(): ensure a caching hashtable removes stale items. */ -static void +static c3_i _test_cache_trimming(void) { + c3_i ret_i = 1; c3_w max_w = 620; - c3_w i_w; + c3_w i_w; //u3p(u3h_root) har_p = u3h_new_cache(max_w / 2); u3p(u3h_root) har_p = u3h_new_cache(max_w / 10 ); @@ -113,23 +148,26 @@ _test_cache_trimming(void) } if ( ( max_w + max_w - 1) != u3h_get(har_p, max_w - 1) ) { - fprintf(stderr, "fail\r\n"); - exit(1); + fprintf(stderr, "cache_trimming (a): fail\r\n"); + ret_i = 0; } if ( ( max_w / 10 ) != har_u->use_w ) { - fprintf(stderr, "fail\r\n"); - exit(1); + fprintf(stderr, "cache_trimming (b): fail\r\n"); + ret_i = 0; } - fprintf(stderr, "test_cache_trimming: ok\n"); + + u3h_free(har_p); + return ret_i; } /* _test_cache_replace_value(): */ -static void +static c3_i _test_cache_replace_value(void) { + c3_i ret_i = 1; c3_w max_w = 100; - c3_w i_w; + c3_w i_w; u3p(u3h_root) har_p = u3h_new_cache(max_w); u3h_root* har_u = u3to(u3h_root, har_p); @@ -143,14 +181,30 @@ _test_cache_replace_value(void) } if ( (2 * max_w) != u3h_get(har_p, max_w - 1) ) { - fprintf(stderr, "fail\r\n"); - exit(1); + fprintf(stderr, "cache_replace (a): fail\r\n"); + ret_i = 0; } if ( max_w != har_u->use_w ) { - fprintf(stderr, "fail\r\n"); - exit(1); + fprintf(stderr, "cache_replace (b): fail\r\n"); + ret_i = 0; } - fprintf(stderr, "test_cache_replace_value: ok\r\n"); + + u3h_free(har_p); + return ret_i; +} + +static c3_i +_test_hashtable(void) +{ + c3_i ret_i = 1; + + ret_i &= _test_bit_manipulation(); + ret_i &= _test_no_cache(); + ret_i &= _test_skip_slot(); + ret_i &= _test_cache_trimming(); + ret_i &= _test_cache_replace_value(); + + return ret_i; } /* main(): run all test cases. @@ -160,11 +214,14 @@ main(int argc, char* argv[]) { _setup(); - _test_bit_manipulation(); - _test_no_cache(); - _test_skip_slot(); - _test_cache_trimming(); - _test_cache_replace_value(); + if ( !_test_hashtable() ) { + fprintf(stderr, "test_hashtable: failed\r\n"); + exit(1); + } + + // GC + // + u3m_grab(u3_none); fprintf(stderr, "test_hashtable: ok\r\n"); From 2ca626429e03a5795f182ffc831417a1c2b07abd Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 8 Oct 2020 14:18:37 -0700 Subject: [PATCH 465/933] u3: refactors and enables gc in jam tests --- pkg/urbit/tests/jam_tests.c | 342 ++++-------------------------------- 1 file changed, 34 insertions(+), 308 deletions(-) diff --git a/pkg/urbit/tests/jam_tests.c b/pkg/urbit/tests/jam_tests.c index c34752aec9..9f4e7024ed 100644 --- a/pkg/urbit/tests/jam_tests.c +++ b/pkg/urbit/tests/jam_tests.c @@ -10,291 +10,6 @@ _setup(void) u3m_pave(c3y, c3n); } -/* _test_jam_spot_a(): spot check jam/cue -*/ -static c3_i -_test_jam_spot_a(void) -{ - c3_i ret_i = 1; - - if ( 0xc != u3qe_jam(1) ) { - fprintf(stderr, "jam: fail (a)\r\n"); - ret_i = 0; - } - - if ( 1 != u3ke_cue(u3qe_jam(1)) ) { - fprintf(stderr, "jam: fail (b)\r\n"); - ret_i = 0; - } - - { - u3_noun a = u3nc(1, 2); - - if ( 0x1231 != u3qe_jam(a) ) { - fprintf(stderr, "jam: fail (c)\r\n"); - ret_i = 0; - } - - if ( c3y != u3r_sing(a, u3ke_cue(u3qe_jam(a))) ) { - fprintf(stderr, "jam: fail (d)\r\n"); - ret_i = 0; - } - } - - { - u3_noun a = u3nt(1, 2, 3); - - if ( 0x344871 != u3qe_jam(a) ) { - fprintf(stderr, "jam: fail (e)\r\n"); - ret_i = 0; - } - - if ( c3y != u3r_sing(a, u3ke_cue(u3qe_jam(a))) ) { - fprintf(stderr, "jam: fail (f)\r\n"); - ret_i = 0; - } - } - - { - u3_noun a = u3nc(u3nc(1, 2), 3); - - if ( 0x3448c5 != u3qe_jam(a) ) { - fprintf(stderr, "jam: fail (g)\r\n"); - ret_i = 0; - } - - if ( c3y != u3r_sing(a, u3ke_cue(u3qe_jam(a))) ) { - fprintf(stderr, "jam: fail (h)\r\n"); - ret_i = 0; - } - } - - { - u3_noun b = u3nc(1, 2); - u3_noun a = u3nt(b, b, b); - - if ( c3y != u3r_sing(a, u3ke_cue(u3qe_jam(a))) ) { - fprintf(stderr, "jam: fail (j)\r\n"); - ret_i = 0; - } - } - - { - u3_noun b = u3i_string("abcdefjhijklmnopqrstuvwxyz"); - u3_noun a = u3nq(b, 2, 3, b); - - if ( c3y != u3r_sing(a, u3ke_cue(u3qe_jam(a))) ) { - fprintf(stderr, "jam: fail (k)\r\n"); - ret_i = 0; - } - } - - { - u3_noun a = u3nc(u3nc(u3nc(1, u3nc(u3nc(2, u3nc(u3nc(3, u3nc(u3nc(4, u3nc(u3nt(5, 6, u3nc(7, u3nc(u3nc(8, 0), 0))), 0)), 0)), 0)), 0)), 0), 0); - - if ( c3y != u3r_sing(a, u3ke_cue(u3qe_jam(a))) ) { - fprintf(stderr, "jam: fail (l)\r\n"); - ret_i = 0; - } - } - - return ret_i; -} - -/* _test_jam_spot_b(): more jam/cue spot-checking, ported from the 64-bit effort -*/ -static c3_i -_test_jam_spot_b() -{ - c3_i ret_i = 1; - - // the boot msg from the worker - { - u3_noun dat = u3_nul; - u3_noun in_1 = u3nc(c3__play, dat); - u3_atom jam_1 = u3ke_jam(in_1); - - u3_noun out_1 = u3ke_cue(jam_1); - u3_noun head_out = u3h(out_1); - u3_noun tail_out = u3t(out_1); - - if (c3__play != head_out){ - fprintf(stderr, "*** cue_jam 0 out head\r\n"); - ret_i = 0; - } - - if (u3_nul != tail_out){ - fprintf(stderr, "*** cue_jam 0 out tail\r\n"); - ret_i = 0; - } - } - - // the boot msg from the worker, again, - // but this time torn apart into bytes and rebuilt - { - u3_noun dat = u3_nul; - u3_noun in_1 = u3nc(c3__play, dat); - u3_atom jam_1 = u3ke_jam(in_1); - - c3_y buf_y[1024]; - memset(buf_y, 0, 1024); - c3_w len_w = u3r_met(3, jam_1); - - u3r_bytes(0, // start byte - len_w, // len - buf_y, // buffer - jam_1 ); // input noun - - /// zip ....zap ... communicate between serf and king - - u3_noun jam_2 = u3i_bytes(len_w, buf_y); - - if ( c3n == u3r_sing(jam_1, jam_2) ) { - fprintf(stderr, "*** error in 6 byte message\r\n"); - ret_i = 0; - } - - u3_noun out_1 = u3ke_cue(jam_2); - - u3_noun head_out = u3h(out_1); - u3_noun tail_out = u3t(out_1); - - if (c3__play != head_out){ - fprintf(stderr, "*** cue_jam 0 out head\r\n"); - ret_i = 0; - } - - if (u3_nul != tail_out){ - fprintf(stderr, "*** cue_jam 0 out tail\r\n"); - ret_i = 0; - } - } - - // 1 - { - - u3_atom in_1 = 1; - u3_atom jam_1 = u3ke_jam(in_1); - - if (12 != jam_1){ - fprintf(stderr, "*** cue_jam 1a\r\n"); - ret_i = 0; - } - - u3_noun out_1 = u3ke_cue(jam_1); - - if (1 != out_1){ - fprintf(stderr, "*** cue_jam 1b\r\n"); - ret_i = 0; - } - } - - // [ 1 1 ] - { - - u3_noun in_1 = u3i_cell(1, 1); - u3_atom jam_1 = u3ke_jam(in_1); - - if (817 != jam_1){ - fprintf(stderr, "*** cue_jam 2 in\r\n"); - ret_i = 0; - } - - u3_noun out_1 = u3ke_cue(jam_1); - - - u3_noun head_out = u3h(out_1); - u3_noun tail_out = u3t(out_1); - - if (1 != head_out){ - fprintf(stderr, "*** cue_jam 2 out head\r\n"); - ret_i = 0; - } - - if (1 != tail_out){ - fprintf(stderr, "*** cue_jam 2 out tail\r\n"); - ret_i = 0; - } - } - - // [ 1 2 ] - { - - u3_noun in_1 = u3i_cell(1, 2); - u3_atom jam_1 = u3ke_jam(in_1); - - if (4657 != jam_1){ - fprintf(stderr, "*** cue_jam 2 in\r\n"); - ret_i = 0; - } - - u3_noun out_1 = u3ke_cue(jam_1); - - u3_noun head_out = u3h(out_1); - u3_noun tail_out = u3t(out_1); - - if (1 != head_out){ - fprintf(stderr, "*** cue_jam 2 out head\r\n"); - ret_i = 0; - } - - if (2 != tail_out){ - fprintf(stderr, "*** cue_jam 2 out tail\r\n"); - ret_i = 0; - } - } - - // medium complicated cell - // q - // / \ - // a1 r - // / \ - // b2 s - // / \ - // c3 d4 - { - u3_noun a = (u3_noun) 0x1; - u3_noun b = (u3_noun) 0x2; - u3_noun c = (u3_noun) 0x3; - u3_noun d = (u3_noun) 0x4; - - u3_noun s = u3i_cell(c, d); - u3_noun r = u3i_cell(b, s); - u3_noun q = u3i_cell(a, r); - - u3_atom jam_1 = u3ke_jam(q); - u3_noun out_1 = u3ke_cue(jam_1); - - u3_noun a2 = u3h(out_1); - u3_noun r2 = u3t(out_1); - if (a2 != a){ - fprintf(stderr, "*** _cue_jam: complicated a\r\n"); - ret_i = 0; - } - - u3_noun b2 = u3h(r2); - u3_noun s2 = u3t(r2); - if (b2 != b){ - fprintf(stderr, "*** _cue_jam: complicated b\r\n"); - ret_i = 0; - } - - u3_noun c2 = u3h(s2); - u3_noun d2 = u3t(s2); - if (c2 != c){ - fprintf(stderr, "*** _cue_jam: complicated c\r\n"); - ret_i = 0; - } - - if (d2 != d){ - fprintf(stderr, "*** _cue_jam: complicated d\r\n"); - ret_i = 0; - } - } - - return 1; -} - static void _byte_print(c3_d out_d, c3_y* out_y, @@ -453,6 +168,11 @@ _test_jam_roundtrip(void) TEST_CASE("[1 1]", u3nc(1, 1)); } + { + c3_y res_y[2] = { 0x31, 0x12 }; + TEST_CASE("[1 2]", u3nc(1, 2)); + } + { c3_y res_y[2] = { 0x21, 0xd1 }; TEST_CASE("[2 3]", u3nc(2, 3)); @@ -464,15 +184,30 @@ _test_jam_roundtrip(void) } { - c3_y res_y[2] = { 0x71, 0xcc }; + c3_y res_y[2] = { 0x71, 0xcc }; TEST_CASE("[1 1 1]", u3nc(1, u3nc(1, 1))); } + { + c3_y res_y[3] = { 0x71, 0x48, 0x34 }; + TEST_CASE("[1 2 3]", u3nt(1, 2, 3)); + } + { c3_y res_y[12] = { 0x1, 0xdf, 0x2c, 0x6c, 0x8e, 0x1e, 0xf0, 0xcd, 0xea, 0xd8, 0xd8, 0x93 }; TEST_CASE("[%fast %full %fast]", u3nc(c3__fast, u3nc(c3__full, c3__fast))); } + { + c3_y res_y[3] = { 0xc5, 0x48, 0x34 }; + TEST_CASE("[[1 2] 3]", u3nc(u3nc(1, 2), 3)); + } + + { + c3_y res_y[5] = { 0xc5, 0xc8, 0x26, 0x27, 0x1 }; + TEST_CASE("[[1 2] [1 2] 1 2]", u3nt(u3nc(1, 2), u3nc(1, 2), u3nc(1, 2))); + } + { c3_y res_y[6] = { 0xa5, 0x35, 0x19, 0xf3, 0x18, 0x5 }; TEST_CASE("[[0 0] [[0 0] 1 1] 1 1]", u3nc(u3nc(0, 0), u3nc(u3nc(u3nc(0, 0), u3nc(1, 1)), u3nc(1, 1)))); @@ -495,27 +230,14 @@ _test_jam_roundtrip(void) TEST_CASE("date", u3i_bytes(sizeof(inp_y), inp_y)); } - return ret_i; -} - -static c3_i -_test_jam(void) -{ - c3_i ret_i = 1; - - if ( !_test_jam_spot_a() ) { - fprintf(stderr, "test jam: spot a: failed\r\n"); - ret_i = 0; - } - - if ( !_test_jam_spot_b() ) { - fprintf(stderr, "test jam: spot b: failed\r\n"); - ret_i = 0; - } - - if ( !_test_jam_roundtrip() ) { - fprintf(stderr, "test jam: roundtrip: failed\r\n"); - ret_i = 0; + { + u3_noun a = u3i_string("abcdefjhijklmnopqrstuvwxyz"); + c3_y res_y[32] = { + 0x1, 0xf8, 0xc, 0x13, 0x1b, 0x23, 0x2b, 0x33, 0x53, 0x43, 0x4b, + 0x53, 0x5b, 0x63, 0x6b, 0x73, 0x7b, 0x83, 0x8b, 0x93, 0x9b, 0xa3, + 0xab, 0xb3, 0xbb, 0xc3, 0xcb, 0xd3, 0x87, 0xc, 0x3d, 0x9 + }; + TEST_CASE("alpha", u3nq(u3k(a), 2, 3, a)); } return ret_i; @@ -528,11 +250,15 @@ main(int argc, char* argv[]) { _setup(); - if ( !_test_jam() ) { + if ( !_test_jam_roundtrip() ) { fprintf(stderr, "test jam: failed\r\n"); exit(1); } + // GC + // + u3m_grab(u3_none); + fprintf(stderr, "test jam: ok\r\n"); return 0; } From 074b0cc0b0210a28d1848254e72176c127421754 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 8 Oct 2020 14:20:30 -0700 Subject: [PATCH 466/933] u3: cleans up testing protocol, enables gc in mug tests --- pkg/urbit/include/jets/k.h | 1 + pkg/urbit/jets/a/dec.c | 8 ++ pkg/urbit/tests/mug_tests.c | 215 ++++++++++++++++++++---------------- 3 files changed, 128 insertions(+), 96 deletions(-) diff --git a/pkg/urbit/include/jets/k.h b/pkg/urbit/include/jets/k.h index 7d6329c565..6a14fc5375 100644 --- a/pkg/urbit/include/jets/k.h +++ b/pkg/urbit/include/jets/k.h @@ -5,6 +5,7 @@ /** Tier 1. **/ u3_noun u3ka_add(u3_noun a, u3_noun b); + u3_noun u3ka_dec(u3_atom a); u3_noun u3ka_sub(u3_noun a, u3_noun b); u3_noun u3ka_mul(u3_noun a, u3_noun b); u3_noun u3ka_gth(u3_noun a, u3_noun b); diff --git a/pkg/urbit/jets/a/dec.c b/pkg/urbit/jets/a/dec.c index 67eeae9cad..b3c0f18066 100644 --- a/pkg/urbit/jets/a/dec.c +++ b/pkg/urbit/jets/a/dec.c @@ -45,3 +45,11 @@ return u3qa_dec(a); } } + + u3_noun + u3ka_dec(u3_atom a) + { + u3_noun b = u3qa_dec(a); + u3z(a); + return b; + } diff --git a/pkg/urbit/tests/mug_tests.c b/pkg/urbit/tests/mug_tests.c index ff7736bc06..b279cd6f74 100644 --- a/pkg/urbit/tests/mug_tests.c +++ b/pkg/urbit/tests/mug_tests.c @@ -11,47 +11,73 @@ _setup(void) /* _test_mug(): spot check u3r_mug hashes. */ -static void +static c3_i _test_mug(void) { + c3_i ret_i = 1; + if ( 0x4d441035 != u3r_mug_string("Hello, world!") ) { fprintf(stderr, "fail (a)\r\n"); - exit(1); + ret_i = 0; } - if ( 0x4d441035 != u3r_mug(u3i_string("Hello, world!")) ) { - fprintf(stderr, "fail (b)\r\n"); - exit(1); + { + u3_noun a = u3i_string("Hello, world!"); + + if ( 0x4d441035 != u3r_mug(a) ) { + fprintf(stderr, "fail (b)\r\n"); + ret_i = 0; + } + + u3z(a); } if ( 0x79ff04e8 != u3r_mug_bytes(0, 0) ) { fprintf(stderr, "fail (c)\r\n"); - exit(1); + ret_i = 0; } - if ( 0x64dfda5c != u3r_mug(u3i_string("xxxxxxxxxxxxxxxxxxxxxxxxxxxx")) ) { - fprintf(stderr, "fail (d)\r\n"); - exit(1); + { + u3_noun a = u3i_string("xxxxxxxxxxxxxxxxxxxxxxxxxxxx"); + + if ( 0x64dfda5c != u3r_mug(a) ) { + fprintf(stderr, "fail (d)\r\n"); + ret_i = 0; + } + + u3z(a); } if ( 0x389ca03a != u3r_mug_cell(0, 0) ) { fprintf(stderr, "fail (e)\r\n"); - exit(1); + ret_i = 0; } if ( 0x389ca03a != u3r_mug_cell(1, 1) ) { fprintf(stderr, "fail (f)\r\n"); - exit(1); + ret_i = 0; } - if ( 0x5258a6c0 != u3r_mug_cell(0, u3qc_bex(32)) ) { - fprintf(stderr, "fail (g)\r\n"); - exit(1); + { + u3_noun a = u3qc_bex(32); + + if ( 0x5258a6c0 != u3r_mug_cell(0, a) ) { + fprintf(stderr, "fail (g)\r\n"); + ret_i = 0; + } + + u3z(a); } - if ( 0x2ad39968 != u3r_mug_cell(u3qa_dec(u3qc_bex(128)), 1) ) { - fprintf(stderr, "fail (h)\r\n"); - exit(1); + { + u3_noun a = u3ka_dec(u3qc_bex(128)); + + if ( 0x2ad39968 != u3r_mug_cell(a, 1) ) { + fprintf(stderr, "fail (h)\r\n"); + ret_i = 0; + } + + u3z(a); } { @@ -75,107 +101,95 @@ _test_mug(void) if ( 0x34d08717 != u3r_mug(str) ) { fprintf(stderr, "fail (i) (1) \r\n"); - exit(1); + ret_i = 0; } if ( 0x34d08717 != u3r_mug_bytes(str_y, byt_w) ) { fprintf(stderr, "fail (i) (2)\r\n"); - exit(1); + ret_i = 0; } if ( 0x34d08717 != u3r_mug_words(str_w, wor_w) ) { fprintf(stderr, "fail (i) (3)\r\n"); - exit(1); + ret_i = 0; } if ( u3r_mug_words(str_w, 2) != u3r_mug_chub(str_d) ) { fprintf(stderr, "fail (i) (4)\r\n"); - exit(1); + ret_i = 0; } c3_free(str_y); c3_free(str_w); + u3z(str); } { - c3_w som_w[4]; - u3_noun som; + c3_w som_w[4] = { 0, 0, 0, 1 }; + u3_noun som = u3i_words(4, som_w); - { - som_w[0] = 0; - som_w[1] = 0; - som_w[2] = 0; - som_w[3] = 1; - som = u3i_words(4, som_w); - - if ( 0x519bd45c != u3r_mug(som) ) { - fprintf(stderr, "fail (j) (1)\r\n"); - exit(1); - } - - if ( 0x519bd45c != u3r_mug_words(som_w, 4) ) { - fprintf(stderr, "fail (j) (2)\r\n"); - exit(1); - } - u3z(som); + if ( 0x519bd45c != u3r_mug(som) ) { + fprintf(stderr, "fail (j) (1)\r\n"); + ret_i = 0; } - { - som_w[0] = 0; - som_w[1] = 1; - som_w[2] = 0; - som_w[3] = 1; - som = u3i_words(4, som_w); - - if ( 0x540eb8a9 != u3r_mug(som) ) { - fprintf(stderr, "fail (k) (1)\r\n"); - exit(1); - } - - if ( 0x540eb8a9 != u3r_mug_words(som_w, 4) ) { - fprintf(stderr, "fail (k) (2)\r\n"); - exit(1); - } - u3z(som); + if ( 0x519bd45c != u3r_mug_words(som_w, 4) ) { + fprintf(stderr, "fail (j) (2)\r\n"); + ret_i = 0; } - { - som_w[0] = 1; - som_w[1] = 1; - som_w[2] = 0; - som_w[3] = 1; - som = u3i_words(4, som_w); - - if ( 0x319d28f9 != u3r_mug(som) ) { - fprintf(stderr, "fail (l) (1)\r\n"); - exit(1); - } - - if ( 0x319d28f9 != u3r_mug_words(som_w, 4) ) { - fprintf(stderr, "fail (l) (2)\r\n"); - exit(1); - } - u3z(som); - } - - { - som_w[0] = 0; - som_w[1] = 0; - som_w[2] = 0; - som_w[3] = 0xffff; - som = u3i_words(4, som_w); - - if ( 0x5230a260 != u3r_mug(som) ) { - fprintf(stderr, "fail (m) (1)\r\n"); - exit(1); - } - - if ( 0x5230a260 != u3r_mug_words(som_w, 4) ) { - fprintf(stderr, "fail (m) (2)\r\n"); - exit(1); - } - u3z(som); - } + u3z(som); } - fprintf(stderr, "test_mug: ok\n"); + { + c3_w som_w[4] = { 0, 1, 0, 1 }; + u3_noun som = u3i_words(4, som_w); + + if ( 0x540eb8a9 != u3r_mug(som) ) { + fprintf(stderr, "fail (k) (1)\r\n"); + ret_i = 0; + } + + if ( 0x540eb8a9 != u3r_mug_words(som_w, 4) ) { + fprintf(stderr, "fail (k) (2)\r\n"); + ret_i = 0; + } + + u3z(som); + } + + { + c3_w som_w[4] = { 1, 1, 0, 1 }; + u3_noun som = u3i_words(4, som_w); + + if ( 0x319d28f9 != u3r_mug(som) ) { + fprintf(stderr, "fail (l) (1)\r\n"); + ret_i = 0; + } + + if ( 0x319d28f9 != u3r_mug_words(som_w, 4) ) { + fprintf(stderr, "fail (l) (2)\r\n"); + ret_i = 0; + } + + u3z(som); + } + + { + c3_w som_w[4] = { 0, 0, 0, 0xffff }; + u3_noun som = u3i_words(4, som_w); + + if ( 0x5230a260 != u3r_mug(som) ) { + fprintf(stderr, "fail (m) (1)\r\n"); + ret_i = 0; + } + + if ( 0x5230a260 != u3r_mug_words(som_w, 4) ) { + fprintf(stderr, "fail (m) (2)\r\n"); + ret_i = 0; + } + + u3z(som); + } + + return ret_i; } /* main(): run all test cases. @@ -185,7 +199,16 @@ main(int argc, char* argv[]) { _setup(); - _test_mug(); + if ( !_test_mug() ) { + fprintf(stderr, "test_mug: failed\r\n"); + exit(1); + } + + // GC + // + u3m_grab(u3_none); + + fprintf(stderr, "test_mug: ok\n"); return 0; } From e74ca2c0fd89e691eafc14c0d7bcd36be32d68e8 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 9 Oct 2020 12:02:50 -0700 Subject: [PATCH 467/933] vere: updates ames to only print network send failures once --- pkg/urbit/vere/io/ames.c | 43 +++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 64771cfbb4..4d544425d3 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -44,6 +44,7 @@ c3_w imp_w[256]; // imperial IPs time_t imp_t[256]; // imperial IP timestamps c3_o imp_o[256]; // imperial print status + c3_o net_o; // can send c3_o see_o; // can scry c3_d saw_d; // successive scry failures c3_o fit_o; // filtering active @@ -146,9 +147,14 @@ static void _ames_send_cb(uv_udp_send_t* req_u, c3_i sas_i) { u3_pact* pac_u = (u3_pact*)req_u; + u3_ames* sam_u = pac_u->sam_u; - if ( 0 != sas_i ) { + if ( sas_i && (c3y == sam_u->net_o) ) { u3l_log("ames: send fail: %s\n", uv_strerror(sas_i)); + sam_u->net_o = c3n; + } + else { + sam_u->net_o = c3y; } _ames_pact_free(pac_u); @@ -165,23 +171,31 @@ _ames_send(u3_pact* pac_u) _ames_pact_free(pac_u); return; } + else { + struct sockaddr_in add_u; - struct sockaddr_in add_u; + memset(&add_u, 0, sizeof(add_u)); + add_u.sin_family = AF_INET; + add_u.sin_addr.s_addr = htonl(pac_u->pip_w); + add_u.sin_port = htons(pac_u->por_s); - memset(&add_u, 0, sizeof(add_u)); - add_u.sin_family = AF_INET; - add_u.sin_addr.s_addr = htonl(pac_u->pip_w); - add_u.sin_port = htons(pac_u->por_s); + { + uv_buf_t buf_u = uv_buf_init((c3_c*)pac_u->hun_y, pac_u->len_w); + c3_i sas_i = uv_udp_send(&pac_u->snd_u, + &sam_u->wax_u, + &buf_u, 1, + (const struct sockaddr*)&add_u, + _ames_send_cb); - uv_buf_t buf_u = uv_buf_init((c3_c*)pac_u->hun_y, pac_u->len_w); - c3_i sas_i; + if ( sas_i ) { + if ( c3y == sam_u->net_o ) { + u3l_log("ames: send fail: %s\n", uv_strerror(sas_i)); + sam_u->net_o = c3n; + } - if ( 0 != (sas_i = uv_udp_send(&pac_u->snd_u, - &sam_u->wax_u, - &buf_u, 1, - (const struct sockaddr*)&add_u, - _ames_send_cb)) ) { - u3l_log("ames: send: %s\n", uv_strerror(sas_i)); + _ames_pact_free(pac_u); + } + } } } @@ -1209,6 +1223,7 @@ u3_ames_io_init(u3_pier* pir_u) u3_ames* sam_u = c3_calloc(sizeof(*sam_u)); sam_u->pir_u = pir_u; sam_u->dop_d = 0; + sam_u->net_o = c3y; sam_u->see_o = c3y; sam_u->fit_o = c3n; sam_u->foq_d = 0; From fda817dc61ca80c25e364a2be07383c5cc7204ca Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 9 Oct 2020 16:06:28 -0700 Subject: [PATCH 468/933] u3: rewrites +skid jet with u3i_defcons() --- pkg/urbit/jets/b/skid.c | 89 +++++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 44 deletions(-) diff --git a/pkg/urbit/jets/b/skid.c b/pkg/urbit/jets/b/skid.c index 9578c0832d..4f1a7818bf 100644 --- a/pkg/urbit/jets/b/skid.c +++ b/pkg/urbit/jets/b/skid.c @@ -3,53 +3,54 @@ */ #include "all.h" - static u3_noun - _skid_in(u3j_site* sit_u, u3_noun a) - { - if ( 0 == a ) { - return u3nc(u3_nul, u3_nul); - } - else if ( c3n == u3du(a) ) { - return u3m_bail(c3__exit); - } else { - u3_noun acc = _skid_in(sit_u, u3t(a)); - u3_noun hoz = u3j_gate_slam(sit_u, u3k(u3h(a))); - u3_noun nex; +u3_noun +u3qb_skid(u3_noun a, u3_noun b) +{ + u3_noun l, r; + u3_noun* lef = &l; + u3_noun* rig = &r; - if ( c3y == hoz ) { - nex = u3nc(u3nc(u3k(u3h(a)), u3k(u3h(acc))), u3k(u3t(acc))); - } - else { - nex = u3nc(u3k(u3h(acc)), u3nc(u3k(u3h(a)), u3k(u3t(acc)))); - } - u3z(hoz); - u3z(acc); - - return nex; - } - } - -/* functions -*/ - u3_noun - u3qb_skid(u3_noun a, - u3_noun b) - { - u3_noun pro; + if ( u3_nul != a) { + u3_noun i, t = a; + u3_noun* hed; + u3_noun* tel; u3j_site sit_u; u3j_gate_prep(&sit_u, u3k(b)); - pro = _skid_in(&sit_u, a); - u3j_gate_lose(&sit_u); - return pro; - } - u3_noun - u3wb_skid(u3_noun cor) - { - u3_noun a, b; - if ( c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0) ) { - return u3m_bail(c3__exit); - } else { - return u3qb_skid(a, b); + do { + u3x_cell(t, &i, &t); + + switch ( u3j_gate_slam(&sit_u, u3k(i)) ) { + case c3y: { + *lef = u3i_defcons(&hed, &tel); + *hed = u3k(i); + lef = tel; + } break; + + case c3n: { + *rig = u3i_defcons(&hed, &tel); + *hed = u3k(i); + rig = tel; + } break; + + default: u3m_bail(c3__exit); + } } + while ( u3_nul != t ); + + u3j_gate_lose(&sit_u); } + + *lef = u3_nul; + *rig = u3_nul; + + return u3nc(l, r); +} + +u3_noun +u3wb_skid(u3_noun cor) +{ + u3_noun a, b; + u3x_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0); + return u3qb_skid(a, b); +} From 6010f2a8662c00eeb20deb61bf56960d73ce42f8 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 9 Oct 2020 16:13:12 -0700 Subject: [PATCH 469/933] u3: rewrites +skip jet with u3i_defcons() --- pkg/urbit/jets/b/skip.c | 78 ++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/pkg/urbit/jets/b/skip.c b/pkg/urbit/jets/b/skip.c index 36ff1a3e6d..5d72796b34 100644 --- a/pkg/urbit/jets/b/skip.c +++ b/pkg/urbit/jets/b/skip.c @@ -3,50 +3,48 @@ */ #include "all.h" - static u3_noun - _skip_in(u3j_site* sit_u, u3_noun a) - { - if ( 0 == a ) { - return a; - } - else if ( c3n == u3du(a) ) { - return u3_none; - } else { - u3_noun hoz = u3j_gate_slam(sit_u, u3k(u3h(a))); - u3_noun vyr = _skip_in(sit_u, u3t(a)); +u3_noun +u3qb_skip(u3_noun a, u3_noun b) +{ + u3_noun pro; + u3_noun* lit = &pro; - switch ( hoz ) { - case c3y: return vyr; - case c3n: return u3nc(u3k(u3h(a)), vyr); - default: u3z(hoz); - u3z(vyr); - return u3_none; + if ( u3_nul != a) { + u3_noun i, t = a; + u3_noun* hed; + u3_noun* tel; + u3j_site sit_u; + u3j_gate_prep(&sit_u, u3k(b)); + + do { + u3x_cell(t, &i, &t); + + switch ( u3j_gate_slam(&sit_u, u3k(i)) ) { + case c3y: break; + + case c3n: { + *lit = u3i_defcons(&hed, &tel); + *hed = u3k(i); + lit = tel; + } break; + + default: u3m_bail(c3__exit); } } - } + while ( u3_nul != t ); -/* functions -*/ - u3_noun - u3qb_skip(u3_noun a, - u3_noun b) - { - u3j_site sit_u; - u3_noun pro; - u3j_gate_prep(&sit_u, u3k(b)); - pro = _skip_in(&sit_u, a); u3j_gate_lose(&sit_u); - return pro; - } - u3_noun - u3wb_skip(u3_noun cor) - { - u3_noun a, b; - - if ( c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0) ) { - return u3_none; - } else { - return u3qb_skip(a, b); - } } + *lit = u3_nul; + + return pro; +} + +u3_noun +u3wb_skip(u3_noun cor) +{ + u3_noun a, b; + u3x_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0); + return u3qb_skip(a, b); +} From 880203ec1dbba51a611c70a1e21584f444f27cf9 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 9 Oct 2020 16:15:24 -0700 Subject: [PATCH 470/933] u3: rewrites +skim jet with u3i_defcons() --- pkg/urbit/jets/b/skim.c | 78 ++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/pkg/urbit/jets/b/skim.c b/pkg/urbit/jets/b/skim.c index c5e721ec10..c83c2ad70d 100644 --- a/pkg/urbit/jets/b/skim.c +++ b/pkg/urbit/jets/b/skim.c @@ -3,50 +3,48 @@ */ #include "all.h" - static u3_noun - _skim_in(u3j_site* sit_u, u3_noun a) - { - if ( 0 == a ) { - return a; - } - else if ( c3n == u3du(a) ) { - return u3m_bail(c3__exit); - } else { - u3_noun hoz = u3j_gate_slam(sit_u, u3k(u3h(a))); - u3_noun vyr = _skim_in(sit_u, u3t(a)); +u3_noun +u3qb_skim(u3_noun a, u3_noun b) +{ + u3_noun pro; + u3_noun* lit = &pro; - switch ( hoz ) { - case c3y: return u3nc(u3k(u3h(a)), vyr); - case c3n: return vyr; - default: u3z(hoz); - u3z(vyr); - return u3m_bail(c3__exit); - } - } - } - -/* functions -*/ - u3_noun - u3qb_skim(u3_noun a, - u3_noun b) - { - u3_noun pro; + if ( u3_nul != a) { + u3_noun i, t = a; + u3_noun* hed; + u3_noun* tel; u3j_site sit_u; u3j_gate_prep(&sit_u, u3k(b)); - pro = _skim_in(&sit_u, a); - u3j_gate_lose(&sit_u); - return pro; - } - u3_noun - u3wb_skim(u3_noun cor) - { - u3_noun a, b; - if ( c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0) ) { - return u3m_bail(c3__exit); - } else { - return u3qb_skim(a, b); + do { + u3x_cell(t, &i, &t); + + switch ( u3j_gate_slam(&sit_u, u3k(i)) ) { + case c3y: { + *lit = u3i_defcons(&hed, &tel); + *hed = u3k(i); + lit = tel; + } break; + + case c3n: break; + + default: u3m_bail(c3__exit); + } } + while ( u3_nul != t ); + + u3j_gate_lose(&sit_u); } + *lit = u3_nul; + + return pro; +} + +u3_noun +u3wb_skim(u3_noun cor) +{ + u3_noun a, b; + u3x_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0); + return u3qb_skim(a, b); +} From cabd811091186a2f703eebe6e8be675cbc8a0653 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sun, 11 Oct 2020 00:19:43 -0700 Subject: [PATCH 471/933] u3: refactors +murn/+turn, removing unused variable --- pkg/urbit/jets/b/murn.c | 45 ++++++++++++++++++----------------------- pkg/urbit/jets/b/turn.c | 39 ++++++++++++++++------------------- 2 files changed, 37 insertions(+), 47 deletions(-) diff --git a/pkg/urbit/jets/b/murn.c b/pkg/urbit/jets/b/murn.c index e5d675a74e..fa04ecc7b4 100644 --- a/pkg/urbit/jets/b/murn.c +++ b/pkg/urbit/jets/b/murn.c @@ -6,42 +6,37 @@ u3_noun u3qb_murn(u3_noun a, u3_noun b) { - u3_noun pro = u3_nul; + u3_noun pro; + u3_noun* lit = &pro; - if ( u3_nul == a ) { - return u3_nul; - } - else { - u3_noun pro; - u3_noun* lit = &pro; + if ( u3_nul != a ) { + u3_noun* hed; + u3_noun* tel; + u3_noun res, i, t = a; u3j_site sit_u; u3j_gate_prep(&sit_u, u3k(b)); - { - u3_noun* hed; - u3_noun* tel; - u3_noun res, i, t = a; - do { - u3x_cell(t, &i, &t); + do { + u3x_cell(t, &i, &t); - res = u3j_gate_slam(&sit_u, u3k(i)); + res = u3j_gate_slam(&sit_u, u3k(i)); - if ( u3_nul != res ) { - *lit = u3i_defcons(&hed, &tel); - *hed = u3k(u3t(res)); - lit = tel; - u3z(res); - } + if ( u3_nul != res ) { + *lit = u3i_defcons(&hed, &tel); + *hed = u3k(u3t(res)); + lit = tel; + u3z(res); } - while ( u3_nul != t ); } + while ( u3_nul != t ); + u3j_gate_lose(&sit_u); - - *lit = u3_nul; - - return pro; } + + *lit = u3_nul; + + return pro; } u3_noun diff --git a/pkg/urbit/jets/b/turn.c b/pkg/urbit/jets/b/turn.c index 0db951ff21..1af14d7e33 100644 --- a/pkg/urbit/jets/b/turn.c +++ b/pkg/urbit/jets/b/turn.c @@ -6,37 +6,32 @@ u3_noun u3qb_turn(u3_noun a, u3_noun b) { - u3_noun pro = u3_nul; + u3_noun pro; + u3_noun* lit = &pro; - if ( u3_nul == a ) { - return u3_nul; - } - else { - u3_noun pro; - u3_noun* lit = &pro; + if ( u3_nul != a ) { + u3_noun* hed; + u3_noun* tel; + u3_noun i, t = a; u3j_site sit_u; u3j_gate_prep(&sit_u, u3k(b)); - { - u3_noun* hed; - u3_noun* tel; - u3_noun i, t = a; - do { - u3x_cell(t, &i, &t); + do { + u3x_cell(t, &i, &t); - *lit = u3i_defcons(&hed, &tel); - *hed = u3j_gate_slam(&sit_u, u3k(i)); - lit = tel; - } - while ( u3_nul != t ); + *lit = u3i_defcons(&hed, &tel); + *hed = u3j_gate_slam(&sit_u, u3k(i)); + lit = tel; } + while ( u3_nul != t ); + u3j_gate_lose(&sit_u); - - *lit = u3_nul; - - return pro; } + + *lit = u3_nul; + + return pro; } u3_noun From def318abd9c2d715de57994aaadab11f7fe4021e Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Mon, 12 Oct 2020 21:57:01 -0700 Subject: [PATCH 472/933] king: packet tests, scry tqueue --- pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs | 4 +- .../urbit-king/lib/Urbit/Vere/Ames/Packet.hs | 1 + pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs | 7 +- pkg/hs/urbit-king/test/AmesTests.hs | 174 +++--------------- 4 files changed, 32 insertions(+), 154 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs index f684e51cc1..ac475f7473 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs @@ -235,12 +235,11 @@ ames env who isFake scry enqueueEv stderr = (initialEvents, runAmes) scryVersion \v -> do v0 <- readTVarIO versSlot atomically $ writeTVar versSlot (Just v) - putStrLn "wow" if (v0 == Just v) then logInfo $ displayShow ("ames: proto version unchanged at", v) else stderr ("ames: protocol version now " <> tshow v) - threadDelay (1_000_000) -- 10m + threadDelay (10 * 60 * 1_000_000) -- 10m queuePacketsThread :: HasLogFunc e => TVar Word @@ -335,7 +334,6 @@ ames env who isFake scry enqueueEv stderr = (initialEvents, runAmes) wen <- io Time.now let nkt = MkKnot $ tshow $ Time.MkDate wen let pax = Path $ "ax" : MkKnot (tshow who) : "" : nkt : p - putStrLn ("scrying for " <> tshow pax) let kon = runRIO env . \case Just (_, fromNoun @n -> Just v) -> k (Just v) Just (_, n) -> do diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/Packet.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/Packet.hs index 9566e10599..1801510324 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/Packet.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/Packet.hs @@ -22,6 +22,7 @@ data Packet = Packet , pktOrigin :: Maybe AmesDest , pktContent :: Bytes } + deriving Eq instance Show Packet where show Packet {..} diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs index 997e37ce26..276e9828eb 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs @@ -277,7 +277,6 @@ pier (serf, log) vSlog startedSig = do -- TODO Instead of using a TMVar, pull directly from the IO driver -- event sources. computeQ :: TMVar RunReq <- newEmptyTMVarIO - persistQ :: TQueue (Fact, FX) <- newTQueueIO executeQ :: TQueue FX <- newTQueueIO saveSig :: TMVar () <- newEmptyTMVarIO @@ -305,7 +304,7 @@ pier (serf, log) vSlog startedSig = do atomically $ Term.trace muxed txt logOther "serf" (display $ T.strip txt) - scrySig <- newEmptyTMVarIO + scryQ <- newTQueueIO onKill <- view onKillPierSigL -- Our call above to set the logging function which echos errors from the @@ -315,7 +314,7 @@ pier (serf, log) vSlog startedSig = do let compute = putTMVar computeQ let execute = writeTQueue executeQ let persist = writeTQueue persistQ - let scry = \w b g k -> putTMVar scrySig (w, b, g, k) + let scry = \w b g k -> writeTQueue scryQ (w, b, g, k) let sigint = Serf.sendSIGINT serf (bootEvents, startDrivers) <- do @@ -328,7 +327,7 @@ pier (serf, log) vSlog startedSig = do let computeConfig = ComputeConfig { ccOnWork = takeTMVar computeQ , ccOnKill = onKill , ccOnSave = takeTMVar saveSig - , ccOnScry = takeTMVar scrySig + , ccOnScry = readTQueue scryQ , ccPutResult = persist , ccShowSpinner = Term.spin muxed , ccHideSpinner = Term.stopSpin muxed diff --git a/pkg/hs/urbit-king/test/AmesTests.hs b/pkg/hs/urbit-king/test/AmesTests.hs index cba51cebc6..01cfbcb97d 100644 --- a/pkg/hs/urbit-king/test/AmesTests.hs +++ b/pkg/hs/urbit-king/test/AmesTests.hs @@ -12,12 +12,14 @@ import Urbit.EventLog.LMDB import Urbit.King.Config import Urbit.Noun import Urbit.Noun.Time -import Urbit.Prelude +import Urbit.Prelude hiding (elements) import Urbit.Vere.Ames +import Urbit.Vere.Ames.Packet import Urbit.Vere.Pier.Types import Urbit.Vere.Ports import Control.Concurrent (runInBoundThread) +import Data.Serialize (decode, encode) import Data.LargeWord (LargeKey(..)) import GHC.Natural (Natural) import Network.Socket (tupleToHostAddress) @@ -26,155 +28,14 @@ import Urbit.King.App (HasKingId(..)) import qualified Urbit.EventLog.LMDB as Log import qualified Urbit.Noun.Time as Time - --------------------------------------------------------------------------------- - -type HasAmes e = - ( HasLogFunc e - , HasNetworkConfig e - , HasKingId e - , HasPortControlApi e) - --- Utils ----------------------------------------------------------------------- - -pid :: KingId -pid = KingId 0 - -turfEf :: NewtEf -turfEf = NewtEfTurf (0, ()) [] - -sendEf :: Galaxy -> Wen -> Bytes -> NewtEf -sendEf g w bs = NewtEfSend (0, ()) (EachYes g) bs - -data NetworkTestApp = NetworkTestApp - { _ntaLogFunc :: !LogFunc - , _ntaNetworkConfig :: !NetworkConfig - , _ntaPortControlApi :: !PortControlApi - , _ntaKingId :: !Word16 - } - -makeLenses ''NetworkTestApp - -instance HasLogFunc NetworkTestApp where - logFuncL = ntaLogFunc - -instance HasNetworkConfig NetworkTestApp where - networkConfigL = ntaNetworkConfig - -instance HasKingId NetworkTestApp where - kingIdL = ntaKingId - -instance HasPortControlApi NetworkTestApp where - portControlApiL = ntaPortControlApi - -runNetworkApp :: RIO NetworkTestApp a -> IO a -runNetworkApp = - runRIO NetworkTestApp - { _ntaLogFunc = mkLogFunc (\_ _ _ _ -> pure ()) - , _ntaKingId = 34 - , _ntaPortControlApi = buildInactivePorts - , _ntaNetworkConfig = NetworkConfig { _ncNetMode = NMNormal - , _ncAmesPort = Nothing - , _ncNoAmes = False - , _ncNoHttp = False - , _ncNoHttps = False - , _ncHttpPort = Nothing - , _ncHttpsPort = Nothing - , _ncLocalPort = Nothing - } - } - -runGala - :: forall e - . HasAmes e - => Word8 - -> RAcquire e (TQueue EvErr, NewtEf -> IO ()) -runGala point = do - env <- ask - que <- newTQueueIO - cry <- newTQueueIO - flip mkRAcquire cancel $ async $ forever $ do - act <- atomically $ readTQueue cry - putStrLn "taking action" - io act - let enqueue = \p -> writeTQueue que p $> Intake - let (_, runAmes) = - ames env (fromIntegral point) True (scry cry) enqueue noStderr - cb <- runAmes - io (cb turfEf) - pure (que, cb) - where - noStderr _ = pure () - scry :: TQueue (IO ()) -> Time.Wen -> Gang -> Path -> (Maybe (Term, Noun) -> IO ()) -> STM () - scry q _ _ (Path p) cb = writeTQueue q $ case unKnot <$> p of - ["ax",_,"",_,"protocol","version"] -> (putStrLn "yes" >>) $ cb $ Just - ( error "ames test: should not depend on scry term" - , A 0 - ) :: IO () - ["ax",_,"",_,"peers",ship,"forward-lane"] -> cb $ Just - ( error "ames test: should not depend on scry term" - , toNoun [fromIntegral $ hash ship :: Word32] - ) - pax -> error ("ames test: fell scry " <> show pax) - - -waitForPacket :: TQueue EvErr -> Bytes -> IO Bool -waitForPacket q val = go - where - go = atomically (readTQueue q) >>= \case - EvErr (EvBlip (BlipEvNewt (NewtEvBorn (_, ()) ()))) _ -> go - EvErr (EvBlip (BlipEvAmes (AmesEvHear () _ bs))) _ -> pure (bs == val) - _ -> pure False - -runRAcquire :: RAcquire e a -> RIO e a -runRAcquire acq = rwith acq pure - -sendThread :: (NewtEf -> IO ()) -> (Galaxy, Bytes) -> RAcquire e () -sendThread cb (to, val) = void $ mkRAcquire start cancel - where - start = async $ forever $ do threadDelay 1_000 - wen <- io $ now - io $ cb (sendEf to wen val) - threadDelay 10_000 - -zodSelfMsg :: Property -zodSelfMsg = forAll arbitrary (ioProperty . runNetworkApp . runTest) - where - runTest :: (HasAmes e) => Bytes -> RIO e Bool - runTest val = runRAcquire $ do - env <- ask - (zodQ, zod) <- runGala 0 - () <- sendThread zod (0, val) - liftIO (waitForPacket zodQ val) - -twoTalk :: Property -twoTalk = forAll arbitrary (ioProperty . runNetworkApp . runTest) - where - runTest :: (HasAmes e) => (Word8, Word8, Bytes) -> RIO e Bool - runTest (aliceShip, bobShip, val) = - if aliceShip == bobShip - then pure True - else go aliceShip bobShip val - - go :: (HasAmes e) => Word8 -> Word8 -> Bytes -> RIO e Bool - go aliceShip bobShip val = runRAcquire $ do - (aliceQ, alice) <- runGala aliceShip - (bobQ, bob) <- runGala bobShip - sendThread alice (Patp bobShip, val) - sendThread bob (Patp aliceShip, val) - liftIO (waitForPacket aliceQ val >> waitForPacket bobQ val) +packetSplitMorphism :: Packet -> Bool +packetSplitMorphism p = (decode . encode) p == Right p tests :: TestTree tests = testGroup "Ames" - [ localOption (QuickCheckTests 10) $ - testProperty "Zod can send a message to itself" $ - zodSelfMsg - - -- TODO Why doesn't this work in CI? - -- , localOption (QuickCheckTests 10) $ - -- testProperty "Two galaxies can talk" $ - -- twoTalk + [ testProperty "Packet coding looks good" $ + packetSplitMorphism ] @@ -230,7 +91,26 @@ instance Arbitrary AmesAddress where arbitrary = AAIpv4 <$> arb <*> arb instance Arbitrary Ship where - arbitrary = Ship <$> arb + arbitrary = Ship <$> elements + [ 0 + , 42 + , 256 + , 24_530 + , 2_071_856_128 + , 2_824_325_100 + , 430_648_908_188_615_680 + , 2^60 + 1337 + ] instance Arbitrary LogIdentity where arbitrary = LogIdentity <$> arb <*> arb <*> arb + +instance Arbitrary Packet where + arbitrary = do + pktVersion <- suchThat arb (< 8) + pktEncrypted <- arb + pktSndr <- arb + pktRcvr <- arb + pktOrigin <- arb + pktContent <- arb + pure Packet {..} From e9ed97f8a82fb43992f8d1a16503e4565ea1b040 Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Tue, 13 Oct 2020 12:01:04 -0700 Subject: [PATCH 473/933] king: fix zig-zag in stderr logging --- pkg/hs/urbit-king/lib/Urbit/King/App.hs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/App.hs b/pkg/hs/urbit-king/lib/Urbit/King/App.hs index 107708d16a..c091473fac 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/App.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/App.hs @@ -29,6 +29,7 @@ where import Urbit.King.Config import Urbit.Prelude +import RIO (logGeneric) import System.Directory ( createDirectoryIfMissing , getXdgDirectory , XdgDirectory(XdgCache) @@ -88,7 +89,9 @@ runKingEnvStderr verb lvl inner = do <&> setLogUseTime True <&> setLogUseLoc False <&> setLogMinLevel lvl - withLogFunc logOptions $ \logFunc -> runKingEnv logFunc logFunc inner + withLogFunc logOptions $ \logFunc -> + let lf = wrapCarriage logFunc + in runKingEnv lf lf inner runKingEnvLogFile :: Bool -> LogLevel -> Maybe FilePath -> RIO KingEnv a -> IO a runKingEnvLogFile verb lvl fileM inner = do @@ -107,7 +110,7 @@ runKingEnvLogFile verb lvl fileM inner = do <&> setLogUseLoc False <&> setLogMinLevel lvl withLogFunc stderrLogOptions $ \stderrLogFunc -> withLogFunc logOptions - $ \logFunc -> runKingEnv logFunc stderrLogFunc inner + $ \logFunc -> runKingEnv logFunc (wrapCarriage stderrLogFunc) inner withLogFileHandle :: FilePath -> (Handle -> IO a) -> IO a withLogFileHandle f act = @@ -115,6 +118,11 @@ withLogFileHandle f act = hSetBuffering handle LineBuffering act handle +-- XX loses callstack +wrapCarriage :: LogFunc -> LogFunc +wrapCarriage lf = mkLogFunc $ \_ ls ll bldr -> + runRIO lf $ logGeneric ls ll (bldr <> "\r") + defaultLogFile :: IO FilePath defaultLogFile = do logDir <- getXdgDirectory XdgCache "urbit" From 5088292be3f3255a28363949891d629da2bb2b0b Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 13 Oct 2020 20:33:40 -0700 Subject: [PATCH 474/933] pill: solid --- bin/solid.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index 693b79266a..90def23b29 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:06808af2c089441d2cb497fc95e3292b6229b3dfa034272d46c7c41f34eb6a3b -size 6268465 +oid sha256:9745f1dc04da93914d1a79ea2e8c8eb04d4469ef8a83d084158282056b693a02 +size 6260435 From d8ada45c35764e81e983f88237e61ae741cf3bbe Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 13 Oct 2020 19:50:53 -0700 Subject: [PATCH 475/933] u3: rewrites +zing jet using u3i_defcons() --- pkg/urbit/jets/b/zing.c | 49 +++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/pkg/urbit/jets/b/zing.c b/pkg/urbit/jets/b/zing.c index 20570b4127..3239e2bb30 100644 --- a/pkg/urbit/jets/b/zing.c +++ b/pkg/urbit/jets/b/zing.c @@ -3,42 +3,43 @@ */ #include "all.h" - -/* functions -*/ u3_noun u3qb_zing(u3_noun a) { - u3_noun top = u3qb_flop(a); - u3_noun top_orig = top; - u3_noun l = 0; + u3_noun pro; + u3_noun* lit = &pro; - while ( u3_nul != top ) { - u3_noun f = u3qb_flop(u3h(top)); - u3_noun f_orig = f; + if ( u3_nul == a ) { + *lit = u3_nul; + } + else { + u3_noun i, t = a; + u3x_cell(t, &i, &t); - while ( u3_nul != f ) { - l = u3nc(u3k(u3h(f)), l); - f = u3t(f); + while ( u3_nul != t ) { + u3_noun* hed; + u3_noun* tel; + u3_noun i_i, t_i = i; + + while ( u3_nul != t_i ) { + u3x_cell(t_i, &i_i, &t_i); + + *lit = u3i_defcons(&hed, &tel); + *hed = u3k(i_i); + lit = tel; + } + + u3x_cell(t, &i, &t); } - u3z(f_orig); - top = u3t(top); + *lit = u3k(i); } - u3z(top_orig); - - return l; + return pro; } u3_noun u3wb_zing(u3_noun cor) { - u3_noun a; - - if ( c3n == u3r_mean(cor, u3x_sam, &a, 0) ) { - return u3m_bail(c3__exit); - } else { - return u3qb_zing(a); - } + return u3qb_zing(u3x_at(u3x_sam, cor)); } From 7f0f77ebb91e9ad320da1418ae5cb97584af4f1e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 13 Oct 2020 20:51:32 -0700 Subject: [PATCH 476/933] u3: rewrites +find jet with necessary uint precision and fixes end-of-haystack bug --- pkg/urbit/jets/b/find.c | 51 +++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/pkg/urbit/jets/b/find.c b/pkg/urbit/jets/b/find.c index c8aab5efa6..2a632366d6 100644 --- a/pkg/urbit/jets/b/find.c +++ b/pkg/urbit/jets/b/find.c @@ -3,45 +3,46 @@ */ #include "all.h" +STATIC_ASSERT( (UINT32_MAX > u3a_cells), + "list index precision" ); -/* functions -*/ u3_noun u3qb_find(u3_noun nedl, u3_noun hstk) { - u3_atom i = 0; + if ( u3_nul != nedl ) { + c3_w i_w = 0; - while ( 1 ) { - if ( u3_nul == nedl) { - return u3_nul; - } else if ( u3_nul == hstk ) { - return u3_nul; - } + while ( u3_nul != hstk ) { + u3_noun i_h, t_h = hstk; + u3_noun i_n, t_n = nedl; + u3x_cell(t_h, &i_h, &t_h); + u3x_cell(t_n, &i_n, &t_n); - u3_noun n = nedl; - u3_noun h = hstk; - while (c3y == u3r_sing(u3h(n), u3h(h))) { - if ( u3_nul == u3t(n) ) { - return u3nc(0, i); + while ( c3y == u3r_sing(i_n, i_h) ) { + if ( u3_nul == t_n ) { + return u3nc(u3_nul, u3i_word(i_w)); + } + else if ( u3_nul == t_h ) { + break; + } + else { + u3x_cell(t_h, &i_h, &t_h); + u3x_cell(t_n, &i_n, &t_n); + } } - n = u3t(n); - h = u3t(h); + hstk = u3t(hstk); + i_w++; } - - i = u3i_vint(i); - hstk = u3t(hstk); } + + return u3_nul; } u3_noun u3wb_find(u3_noun cor) { u3_noun a, b; - - if ( c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0) ) { - return u3m_bail(c3__exit); - } else { - return u3qb_find(a, b); - } + u3x_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0); + return u3qb_find(a, b); } From 34176e68ea81ccbd43f95af68d4ed1a4e38030a5 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 13 Oct 2020 23:47:29 -0700 Subject: [PATCH 477/933] u3: refactors +apt:in jet, fixing recursion bugs and normalizing declarations --- pkg/urbit/include/jets/q.h | 1 + pkg/urbit/jets/d/in_apt.c | 88 ++++++++++++++++---------------------- 2 files changed, 38 insertions(+), 51 deletions(-) diff --git a/pkg/urbit/include/jets/q.h b/pkg/urbit/include/jets/q.h index 9af222dac6..7a1c7084d3 100644 --- a/pkg/urbit/include/jets/q.h +++ b/pkg/urbit/include/jets/q.h @@ -82,6 +82,7 @@ # define u3qdb_tap u3qdi_tap u3_noun u3qdb_uni(u3_noun, u3_noun); + u3_noun u3qdi_apt(u3_noun); u3_noun u3qdi_bif(u3_noun, u3_noun); u3_noun u3qdi_dif(u3_noun, u3_noun); u3_noun u3qdi_gas(u3_noun, u3_noun); diff --git a/pkg/urbit/jets/d/in_apt.c b/pkg/urbit/jets/d/in_apt.c index fe041c77fa..c3276bc4a2 100644 --- a/pkg/urbit/jets/d/in_apt.c +++ b/pkg/urbit/jets/d/in_apt.c @@ -3,68 +3,54 @@ */ #include "all.h" -static -c3_o _in_apt(u3_noun a, u3_noun l, u3_noun r) +static c3_o +_in_apt(u3_noun a, u3_weak l, u3_weak r) { - if (a == 0) { + if ( u3_nul == a ) { return c3y; } + else { + u3_noun n_a, l_a, r_a; + u3x_trel(a, &n_a, &l_a, &r_a); - u3_noun n_a, l_a, r_a; - u3x_trel(a, &n_a, &l_a, &r_a); - - if ( u3_nul != l ) { - u3_noun u_l; - u3x_cell(l, 0, &u_l); - if (!_(u3qc_gor(n_a, u_l))) { + if ( (u3_none != l) && (c3n == u3qc_gor(n_a, l)) ) { return c3n; } + + if ( (u3_none != r) && (c3n == u3qc_gor(r, n_a)) ) { + return c3n; + } + + if ( u3_nul != l_a ) { + if ( c3n == u3qc_mor(n_a, u3h(l_a)) ) { + return c3n; + } + + if ( c3n == _in_apt(l_a, n_a, r) ) { + return c3n; + } + } + + if ( u3_nul != r_a ) { + if ( c3n == u3qc_mor(n_a, u3h(r_a)) ) { + return c3n; + } + + return _in_apt(r_a, l, n_a); + } + + return c3y; } +} - if ( u3_nul != r ) { - u3_noun u_r; - u3r_cell(r, 0, &u_r); - if (!_(u3qc_gor(u_r, n_a))) { - return c3n; - } - } - - if ( u3_nul != l_a ) { - u3_noun n_l_a, l_l_a, r_l_a; - u3x_trel(l_a, &n_l_a, &l_l_a, &r_l_a); - if (!_(u3qc_mor(n_a, n_l_a))) { - return c3n; - } - u3_noun nu_l = u3nc(0, n_a); - if (!_(_in_apt(l_a, nu_l, 0))) { - u3z(nu_l); - return c3n; - } - u3z(nu_l); - } - - if ( u3_nul != r_a ) { - u3_noun n_r_a, l_r_a, r_r_a; - u3x_trel(r_a, &n_r_a, &l_r_a, &r_r_a); - if (!_(u3qc_mor(n_a, n_r_a))) { - return c3n; - } - u3_noun nu_r = u3nc(0, n_a); - if (!_(_in_apt(r_a, 0, nu_r))) { - u3z(nu_r); - return c3n; - } - u3z(nu_r); - } - - return c3y; +u3_noun +u3qdi_apt(u3_noun a) +{ + return _in_apt(a, u3_none, u3_none); } u3_noun u3wdi_apt(u3_noun cor) { - u3_noun a; - u3x_mean(cor, u3x_con_sam, &a, 0); - c3_y pro = _in_apt(a, 0, 0); - return pro; + return u3qdi_apt(u3x_at(u3x_con_sam, cor)); } From f216db003a096a749de2cd2e69ab5ee36ab3f698 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 13 Oct 2020 23:48:15 -0700 Subject: [PATCH 478/933] u3: refactors +rep:in jet, normalizing declarations --- pkg/urbit/include/jets/q.h | 1 + pkg/urbit/jets/d/in_rep.c | 37 ++++++++++++++++++++----------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/pkg/urbit/include/jets/q.h b/pkg/urbit/include/jets/q.h index 7a1c7084d3..6152b637ee 100644 --- a/pkg/urbit/include/jets/q.h +++ b/pkg/urbit/include/jets/q.h @@ -89,6 +89,7 @@ u3_noun u3qdi_has(u3_noun, u3_noun); u3_noun u3qdi_int(u3_noun, u3_noun); u3_noun u3qdi_put(u3_noun, u3_noun); + u3_noun u3qdi_rep(u3_noun, u3_noun); u3_noun u3qdi_tap(u3_noun); u3_noun u3qdi_uni(u3_noun, u3_noun); u3_noun u3qdi_wyt(u3_noun); diff --git a/pkg/urbit/jets/d/in_rep.c b/pkg/urbit/jets/d/in_rep.c index a7d7376c84..7af3c5d9eb 100644 --- a/pkg/urbit/jets/d/in_rep.c +++ b/pkg/urbit/jets/d/in_rep.c @@ -3,19 +3,18 @@ */ #include "all.h" -/* internal functions - */ -static -void +// [a] is RETAINED, [out] is TRANSFERRED +// +static void _in_rep(u3_noun a, u3j_site* sit_u, u3_noun* out) { - if (u3_nul == a) { + if ( u3_nul == a ) { return; - } else { + } + else { u3_noun n_a, l_a, r_a; u3x_trel(a, &n_a, &l_a, &r_a); - // consumes out refcount *out = u3j_gate_slam(sit_u, u3nc(u3k(n_a), *out)); _in_rep(l_a, sit_u, out); @@ -23,19 +22,23 @@ _in_rep(u3_noun a, u3j_site* sit_u, u3_noun* out) } } +u3_noun +u3qdi_rep(u3_noun a, u3_noun b) +{ + u3_noun out = u3k(u3x_at(u3x_sam_3, b)); + u3j_site sit_u; + + u3j_gate_prep(&sit_u, u3k(b)); + _in_rep(a, &sit_u, &out); + u3j_gate_lose(&sit_u); + + return out; +} + u3_noun u3wdi_rep(u3_noun cor) { u3_noun a, b; - u3j_site sit_u; - u3x_mean(cor, u3x_sam, &b, u3x_con_sam, &a, 0); - - u3j_gate_prep(&sit_u, u3k(b)); - - u3_noun out = u3k(u3x_at(u3x_sam_3, b)); - _in_rep(a, &sit_u, &out); - - u3j_gate_lose(&sit_u); - return out; + return u3qdi_rep(a, b); } From 42c7885302eccf7d4eebc2f1572169b6f9a11570 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 13 Oct 2020 23:48:35 -0700 Subject: [PATCH 479/933] u3: refactors +run:in jet, normalizing declarations --- pkg/urbit/include/jets/q.h | 1 + pkg/urbit/jets/d/in_run.c | 46 ++++++++++++++++++++++---------------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/pkg/urbit/include/jets/q.h b/pkg/urbit/include/jets/q.h index 6152b637ee..37ab0f8c6a 100644 --- a/pkg/urbit/include/jets/q.h +++ b/pkg/urbit/include/jets/q.h @@ -90,6 +90,7 @@ u3_noun u3qdi_int(u3_noun, u3_noun); u3_noun u3qdi_put(u3_noun, u3_noun); u3_noun u3qdi_rep(u3_noun, u3_noun); + u3_noun u3qdi_run(u3_noun, u3_noun); u3_noun u3qdi_tap(u3_noun); u3_noun u3qdi_uni(u3_noun, u3_noun); u3_noun u3qdi_wyt(u3_noun); diff --git a/pkg/urbit/jets/d/in_run.c b/pkg/urbit/jets/d/in_run.c index 6d398cfa71..2a9747241d 100644 --- a/pkg/urbit/jets/d/in_run.c +++ b/pkg/urbit/jets/d/in_run.c @@ -3,41 +3,49 @@ */ #include "all.h" -/* internal functions - */ -static -void +// [a] is RETAINED, [out] is TRANSFERRED +// +static void _in_run(u3_noun a, u3j_site* sit_u, u3_noun* out) { - if (u3_nul == a) { + if ( u3_nul == a ) { return; - } else { + } + else { u3_noun n_a, l_a, r_a; u3x_trel(a, &n_a, &l_a, &r_a); - u3_noun nu_n_a = u3j_gate_slam(sit_u, u3k(n_a)); + { + u3_noun new = u3j_gate_slam(sit_u, u3k(n_a)); + u3_noun pro = u3qdi_put(*out, new); - u3_noun nuout = u3qdi_put(*out, nu_n_a); - u3z(*out); - u3z(nu_n_a); - *out = nuout; + u3z(new); + u3z(*out); + *out = pro; + } _in_run(l_a, sit_u, out); _in_run(r_a, sit_u, out); } } +u3_noun +u3qdi_run(u3_noun a, u3_noun b) +{ + u3_noun out = u3_nul; + u3j_site sit_u; + + u3j_gate_prep(&sit_u, u3k(b)); + _in_run(a, &sit_u, &out); + u3j_gate_lose(&sit_u); + + return out; +} + u3_noun u3wdi_run(u3_noun cor) { u3_noun a, b; - u3j_site sit_u; - u3x_mean(cor, u3x_sam, &b, u3x_con_sam, &a, 0); - - u3j_gate_prep(&sit_u, u3k(b)); - u3_noun out = 0; - _in_run(a, &sit_u, &out); - u3j_gate_lose(&sit_u); - return out; + return u3qdi_run(a, b); } From 69578a73fca8174cc66acd58074db368ca5865b8 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 13 Oct 2020 23:52:13 -0700 Subject: [PATCH 480/933] u3: refactors +all:by jet, adding tail-recursion and normalizing declarations --- pkg/urbit/include/jets/q.h | 1 + pkg/urbit/jets/d/by_all.c | 58 +++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/pkg/urbit/include/jets/q.h b/pkg/urbit/include/jets/q.h index 37ab0f8c6a..aab96180f8 100644 --- a/pkg/urbit/include/jets/q.h +++ b/pkg/urbit/include/jets/q.h @@ -72,6 +72,7 @@ /** Tier 4. **/ + u3_noun u3qdb_all(u3_noun, u3_noun); u3_noun u3qdb_bif(u3_noun, u3_noun); u3_noun u3qdb_dif(u3_noun, u3_noun); u3_noun u3qdb_gas(u3_noun, u3_noun); diff --git a/pkg/urbit/jets/d/by_all.c b/pkg/urbit/jets/d/by_all.c index db58d73359..df8b288c47 100644 --- a/pkg/urbit/jets/d/by_all.c +++ b/pkg/urbit/jets/d/by_all.c @@ -3,45 +3,45 @@ */ #include "all.h" -/* internal functions - */ static u3_noun _by_all(u3_noun a, u3j_site* sit_u) { - if (u3_nul == a) { - return c3y; - } else { - u3_noun n_a, l_a, r_a; - u3_noun q_n_a; - u3x_trel(a, &n_a, &l_a, &r_a); - u3x_cell(n_a, 0, &q_n_a); - - if (c3n == u3j_gate_slam(sit_u, u3k(q_n_a))) { - return c3n; - } - - if (c3n == _by_all(l_a, sit_u)) { - return c3n; - } - - if (c3n == _by_all(r_a, sit_u)) { - return c3n; - } - + if ( u3_nul == a ) { return c3y; } + else { + u3_noun n_a, l_a, r_a; + u3x_trel(a, &n_a, &l_a, &r_a); + + if ( c3n == u3j_gate_slam(sit_u, u3k(u3t(n_a))) ) { + return c3n; + } + + if ( c3n == _by_all(l_a, sit_u) ) { + return c3n; + } + + return _by_all(r_a, sit_u); + } +} + +u3_noun +u3qdb_all(u3_noun a, u3_noun b) +{ + u3_noun pro; + u3j_site sit_u; + + u3j_gate_prep(&sit_u, u3k(b)); + pro = _by_all(a, &sit_u); + u3j_gate_lose(&sit_u); + + return pro; } u3_noun u3wdb_all(u3_noun cor) { u3_noun a, b; - u3j_site sit_u; - u3x_mean(cor, u3x_sam, &b, u3x_con_sam, &a, 0); - - u3j_gate_prep(&sit_u, u3k(b)); - u3_noun pro = _by_all(a, &sit_u); - u3j_gate_lose(&sit_u); - return pro; + return u3qdb_all(a, b); } From 842f2a8831b0c6af5d89595c3943f6f8c7b80e7c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 13 Oct 2020 23:52:51 -0700 Subject: [PATCH 481/933] u3: refactors +any:by jet, adding tail-recursion and normalizing declarations --- pkg/urbit/include/jets/q.h | 1 + pkg/urbit/jets/d/by_any.c | 58 +++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/pkg/urbit/include/jets/q.h b/pkg/urbit/include/jets/q.h index aab96180f8..d20d291030 100644 --- a/pkg/urbit/include/jets/q.h +++ b/pkg/urbit/include/jets/q.h @@ -73,6 +73,7 @@ /** Tier 4. **/ u3_noun u3qdb_all(u3_noun, u3_noun); + u3_noun u3qdb_any(u3_noun, u3_noun); u3_noun u3qdb_bif(u3_noun, u3_noun); u3_noun u3qdb_dif(u3_noun, u3_noun); u3_noun u3qdb_gas(u3_noun, u3_noun); diff --git a/pkg/urbit/jets/d/by_any.c b/pkg/urbit/jets/d/by_any.c index 7d3e67e421..8280516587 100644 --- a/pkg/urbit/jets/d/by_any.c +++ b/pkg/urbit/jets/d/by_any.c @@ -3,45 +3,45 @@ */ #include "all.h" -/* internal functions - */ static u3_noun _by_any(u3_noun a, u3j_site* sit_u) { - if (u3_nul == a) { - return c3n; - } else { - u3_noun n_a, l_a, r_a; - u3_noun q_n_a; - u3x_trel(a, &n_a, &l_a, &r_a); - u3x_cell(n_a, 0, &q_n_a); - - if (c3y == u3j_gate_slam(sit_u, u3k(q_n_a))) { - return c3y; - } - - if (c3y == _by_any(l_a, sit_u)) { - return c3y; - } - - if (c3y == _by_any(r_a, sit_u)) { - return c3y; - } - + if ( u3_nul == a ) { return c3n; } + else { + u3_noun n_a, l_a, r_a; + u3x_trel(a, &n_a, &l_a, &r_a); + + if ( c3y == u3j_gate_slam(sit_u, u3k(u3t(n_a))) ) { + return c3y; + } + + if ( c3y == _by_any(l_a, sit_u) ) { + return c3y; + } + + return _by_any(r_a, sit_u); + } +} + +u3_noun +u3qdb_any(u3_noun a, u3_noun b) +{ + u3_noun pro; + u3j_site sit_u; + + u3j_gate_prep(&sit_u, u3k(b)); + pro = _by_any(a, &sit_u); + u3j_gate_lose(&sit_u); + + return pro; } u3_noun u3wdb_any(u3_noun cor) { u3_noun a, b; - u3j_site sit_u; - u3x_mean(cor, u3x_sam, &b, u3x_con_sam, &a, 0); - - u3j_gate_prep(&sit_u, u3k(b)); - u3_noun pro = _by_any(a, &sit_u); - u3j_gate_lose(&sit_u); - return pro; + return u3qdb_any(a, b); } From beec5c5c518d6fee095b131e6c320fe863d61666 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 13 Oct 2020 23:53:37 -0700 Subject: [PATCH 482/933] u3: refactors +apt:by jet, fixing recursion bugs and normalizing declarations --- pkg/urbit/include/jets/q.h | 1 + pkg/urbit/jets/d/by_apt.c | 132 ++++++++++++++++--------------------- 2 files changed, 59 insertions(+), 74 deletions(-) diff --git a/pkg/urbit/include/jets/q.h b/pkg/urbit/include/jets/q.h index d20d291030..34b3dc5d48 100644 --- a/pkg/urbit/include/jets/q.h +++ b/pkg/urbit/include/jets/q.h @@ -74,6 +74,7 @@ **/ u3_noun u3qdb_all(u3_noun, u3_noun); u3_noun u3qdb_any(u3_noun, u3_noun); + u3_noun u3qdb_apt(u3_noun); u3_noun u3qdb_bif(u3_noun, u3_noun); u3_noun u3qdb_dif(u3_noun, u3_noun); u3_noun u3qdb_gas(u3_noun, u3_noun); diff --git a/pkg/urbit/jets/d/by_apt.c b/pkg/urbit/jets/d/by_apt.c index c580087d4b..e85bc7f9cb 100644 --- a/pkg/urbit/jets/d/by_apt.c +++ b/pkg/urbit/jets/d/by_apt.c @@ -3,90 +3,74 @@ */ #include "all.h" -static -c3_o _by_apt(u3_noun a, u3_noun l, u3_noun r) +static c3_o +_by_apt(u3_noun a, u3_weak l, u3_weak r) { - if (a == 0) { + if ( u3_nul == a ) { return c3y; } - - u3_noun n_a, l_a, r_a; - u3_noun p_n_a, q_n_a; - u3x_trel(a, &n_a, &l_a, &r_a); - u3x_cell(n_a, &p_n_a, &q_n_a); - - if ( u3_nul != l ) { - u3_noun u_l; - u3x_cell(l, 0, &u_l); - if (!_(u3qc_gor(p_n_a, u_l))) { - return c3n; + else { + u3_noun p_n_a, l_a, r_a; + { + u3_noun n_a; + u3x_trel(a, &n_a, &l_a, &r_a); + p_n_a = u3h(n_a); } - if (c3y == u3r_sing(p_n_a, u_l)) { - return c3n; + + if ( u3_none != l ) { + if ( (c3n == u3qc_gor(p_n_a, l)) + || (c3y == u3r_sing(p_n_a, l)) ) + { + return c3n; + } } + + if ( u3_none != r ) { + if ( (c3n == u3qc_gor(r, p_n_a)) + || (c3y == u3r_sing(r, p_n_a)) ) + { + return c3n; + } + } + + if ( u3_nul != l_a ) { + u3_noun p_n_l_a = u3h(u3h(l_a)); + + if ( (c3n == u3qc_mor(p_n_a, p_n_l_a)) + || (c3y == u3r_sing(p_n_a, p_n_l_a)) ) + { + return c3n; + } + + if ( c3n == _by_apt(l_a, p_n_a, r) ) { + return c3n; + } + } + + if ( u3_nul != r_a ) { + u3_noun p_n_r_a = u3h(u3h(r_a)); + + if ( (c3n == u3qc_mor(p_n_a, p_n_r_a)) + || (c3y == u3r_sing(p_n_a, p_n_r_a)) ) + { + return c3n; + } + + return _by_apt(r_a, l, p_n_a); + } + + return c3y; } - - if ( u3_nul != r ) { - u3_noun u_r; - u3x_cell(r, 0, &u_r); - if (!_(u3qc_gor(u_r, p_n_a))) { - return c3n; - } - if (c3y == u3r_sing(u_r, p_n_a)) { - return c3n; - } - } - - if ( u3_nul != l_a ) { - u3_noun n_l_a, l_l_a, r_l_a; - u3_noun p_n_l_a; - u3x_trel(l_a, &n_l_a, &l_l_a, &r_l_a); - u3x_cell(n_l_a, &p_n_l_a, 0); - - if (!_(u3qc_mor(p_n_a, p_n_l_a))) { - return c3n; - } - if (c3y == u3r_sing(p_n_a, p_n_l_a)) { - return c3n; - } - u3_noun nu_l = u3nc(0, p_n_a); - if (!_(_by_apt(l_a, nu_l, 0))) { - u3z(nu_l); - return c3n; - } - u3z(nu_l); - } - - if ( u3_nul != r_a ) { - u3_noun n_r_a, l_r_a, r_r_a; - u3_noun p_n_r_a; - u3x_trel(r_a, &n_r_a, &l_r_a, &r_r_a); - u3x_cell(n_r_a, &p_n_r_a, 0); - - if (!_(u3qc_mor(p_n_a, p_n_r_a))) { - return c3n; - } - if (c3y == u3r_sing(p_n_a, p_n_r_a)) { - return c3n; - } - u3_noun nu_r = u3nc(0, p_n_a); - if (!_(_by_apt(r_a, 0, nu_r))) { - u3z(nu_r); - return c3n; - } - u3z(nu_r); - } - - return c3y; } +u3_noun +u3qdb_apt(u3_noun a) +{ + return _by_apt(a, u3_none, u3_none); +} u3_noun u3wdb_apt(u3_noun cor) { - u3_noun a; - u3x_mean(cor, u3x_con_sam, &a, 0); - - c3_y pro = _by_apt(a, 0, 0); - return pro; + return u3qdb_apt(u3x_at(u3x_con_sam, cor)); } From 92dfaeb7ebe7f4ecdd0817bfa1846559b6a00c21 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 13 Oct 2020 23:54:18 -0700 Subject: [PATCH 483/933] u3: refactors +key:by jet, simplifying refcounts and normalizing declarations --- pkg/urbit/include/jets/q.h | 1 + pkg/urbit/jets/d/by_key.c | 45 +++++++++++++++++++++----------------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/pkg/urbit/include/jets/q.h b/pkg/urbit/include/jets/q.h index 34b3dc5d48..2ec546be3c 100644 --- a/pkg/urbit/include/jets/q.h +++ b/pkg/urbit/include/jets/q.h @@ -81,6 +81,7 @@ u3_noun u3qdb_get(u3_noun, u3_noun); u3_noun u3qdb_has(u3_noun, u3_noun); u3_noun u3qdb_int(u3_noun, u3_noun); + u3_noun u3qdb_key(u3_noun); u3_noun u3qdb_put(u3_noun, u3_noun, u3_noun); # define u3qdb_tap u3qdi_tap u3_noun u3qdb_uni(u3_noun, u3_noun); diff --git a/pkg/urbit/jets/d/by_key.c b/pkg/urbit/jets/d/by_key.c index 62a8d510d1..e194d71c50 100644 --- a/pkg/urbit/jets/d/by_key.c +++ b/pkg/urbit/jets/d/by_key.c @@ -3,33 +3,38 @@ */ #include "all.h" -/* internal functions - */ +// [a] is RETAINED, [set] is TRANSFERRED +// static u3_noun _by_key(u3_noun a, u3_noun set) { - if (u3_nul == a) { - return u3k(set); - } else { - u3_noun n_a, l_a, r_a; - u3_noun p_n_a, q_n_a; - u3x_trel(a, &n_a, &l_a, &r_a); - u3x_cell(n_a, &p_n_a, &q_n_a); - - u3_noun with_set = u3qdi_put(set, p_n_a); - u3_noun left_set = _by_key(l_a, with_set); - u3z(with_set); - u3_noun right_set = _by_key(r_a, left_set); - u3z(left_set); - - return right_set; + if ( u3_nul == a ) { + return set; } + else { + u3_noun n_a, l_a, r_a; + u3x_trel(a, &n_a, &l_a, &r_a); + + { + u3_noun new = u3qdi_put(set, u3h(n_a)); + u3z(set); + set = new; + } + + set = _by_key(l_a, set); + + return _by_key(r_a, set); + } +} + +u3_noun +u3qdb_key(u3_noun a) +{ + return _by_key(a, u3_nul); } u3_noun u3wdb_key(u3_noun cor) { - u3_noun a; - u3x_mean(cor, u3x_con_sam, &a, 0); - return _by_key(a, 0); + return u3qdb_key(u3x_at(u3x_con_sam, cor)); } From 2832307c5ddeafc51183853ce7d306938e720273 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 13 Oct 2020 23:54:43 -0700 Subject: [PATCH 484/933] u3: refactors +run:by jet, normalizing declarations --- pkg/urbit/include/jets/q.h | 1 + pkg/urbit/jets/d/by_run.c | 37 +++++++++++++++++++++---------------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/pkg/urbit/include/jets/q.h b/pkg/urbit/include/jets/q.h index 2ec546be3c..4b13b3f3f2 100644 --- a/pkg/urbit/include/jets/q.h +++ b/pkg/urbit/include/jets/q.h @@ -83,6 +83,7 @@ u3_noun u3qdb_int(u3_noun, u3_noun); u3_noun u3qdb_key(u3_noun); u3_noun u3qdb_put(u3_noun, u3_noun, u3_noun); + u3_noun u3qdb_run(u3_noun, u3_noun); # define u3qdb_tap u3qdi_tap u3_noun u3qdb_uni(u3_noun, u3_noun); diff --git a/pkg/urbit/jets/d/by_run.c b/pkg/urbit/jets/d/by_run.c index 6fd2d2cf87..f2710e7fbb 100644 --- a/pkg/urbit/jets/d/by_run.c +++ b/pkg/urbit/jets/d/by_run.c @@ -3,36 +3,41 @@ */ #include "all.h" -/* internal functions - */ static u3_noun _by_run(u3_noun a, u3j_site* sit_u) { - if (u3_nul == a) { - return 0; - } else { + if ( u3_nul == a ) { + return u3_nul; + } + else { u3_noun n_a, l_a, r_a; u3_noun p_n_a, q_n_a; u3x_trel(a, &n_a, &l_a, &r_a); u3x_cell(n_a, &p_n_a, &q_n_a); - u3_noun nu_q_n_a = u3j_gate_slam(sit_u, u3k(q_n_a)); - u3_noun nu_l = _by_run(l_a, sit_u); - u3_noun nu_r = _by_run(r_a, sit_u); - return u3nt(u3nc(u3k(p_n_a), nu_q_n_a), nu_l, nu_r); + return u3nt(u3nc(u3k(p_n_a), u3j_gate_slam(sit_u, u3k(q_n_a))), + _by_run(l_a, sit_u), + _by_run(r_a, sit_u)); } } +u3_noun +u3qdb_run(u3_noun a, u3_noun b) +{ + u3_noun pro; + u3j_site sit_u; + + u3j_gate_prep(&sit_u, u3k(b)); + pro = _by_run(a, &sit_u); + u3j_gate_lose(&sit_u); + + return pro; +} + u3_noun u3wdb_run(u3_noun cor) { u3_noun a, b; - u3j_site sit_u; - u3x_mean(cor, u3x_sam, &b, u3x_con_sam, &a, 0); - - u3j_gate_prep(&sit_u, u3k(b)); - u3_noun pro = _by_run(a, &sit_u); - u3j_gate_lose(&sit_u); - return pro; + return u3qdb_run(a, b); } From 6fa50ff69f341ec799ee8e2d1fdb14ad9c22bb2a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 13 Oct 2020 23:55:05 -0700 Subject: [PATCH 485/933] u3: refactors +urn:by jet, normalizing declarations --- pkg/urbit/include/jets/q.h | 1 + pkg/urbit/jets/d/by_urn.c | 37 ++++++++++++++++++++----------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/pkg/urbit/include/jets/q.h b/pkg/urbit/include/jets/q.h index 4b13b3f3f2..243e43497d 100644 --- a/pkg/urbit/include/jets/q.h +++ b/pkg/urbit/include/jets/q.h @@ -86,6 +86,7 @@ u3_noun u3qdb_run(u3_noun, u3_noun); # define u3qdb_tap u3qdi_tap u3_noun u3qdb_uni(u3_noun, u3_noun); + u3_noun u3qdb_urn(u3_noun, u3_noun); u3_noun u3qdi_apt(u3_noun); u3_noun u3qdi_bif(u3_noun, u3_noun); diff --git a/pkg/urbit/jets/d/by_urn.c b/pkg/urbit/jets/d/by_urn.c index 886e249b3f..35ccfa5f30 100644 --- a/pkg/urbit/jets/d/by_urn.c +++ b/pkg/urbit/jets/d/by_urn.c @@ -3,36 +3,39 @@ */ #include "all.h" -/* internal functions - */ -static -u3_noun +static u3_noun _by_urn(u3_noun a, u3j_site* sit_u) { - if (u3_nul == a) { - return 0; - } else { + if ( u3_nul == a ) { + return u3_nul; + } + else { u3_noun n_a, l_a, r_a; - u3_noun p_n_a, q_n_a; u3x_trel(a, &n_a, &l_a, &r_a); - u3x_cell(n_a, &p_n_a, &q_n_a); - return u3nt(u3nc(u3k(p_n_a), u3j_gate_slam(sit_u, u3k(n_a))), + return u3nt(u3nc(u3k(u3h(n_a)), u3j_gate_slam(sit_u, u3k(n_a))), _by_urn(l_a, sit_u), _by_urn(r_a, sit_u)); } } +u3_noun +u3qdb_urn(u3_noun a, u3_noun b) +{ + u3_noun pro; + u3j_site sit_u; + + u3j_gate_prep(&sit_u, u3k(b)); + pro = _by_urn(a, &sit_u); + u3j_gate_lose(&sit_u); + + return pro; +} + u3_noun u3wdb_urn(u3_noun cor) { u3_noun a, b; - u3j_site sit_u; - u3x_mean(cor, u3x_sam, &b, u3x_con_sam, &a, 0); - - u3j_gate_prep(&sit_u, u3k(b)); - u3_noun pro = _by_urn(a, &sit_u); - u3j_gate_lose(&sit_u); - return pro; + return u3qdb_urn(a, b); } From d095960132d4fd9bc75aacd5b50eebd304fad3f4 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 13 Oct 2020 23:55:18 -0700 Subject: [PATCH 486/933] u3: adds u3qdb_wyt declaration --- pkg/urbit/include/jets/q.h | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/urbit/include/jets/q.h b/pkg/urbit/include/jets/q.h index 243e43497d..c79996da4c 100644 --- a/pkg/urbit/include/jets/q.h +++ b/pkg/urbit/include/jets/q.h @@ -87,6 +87,7 @@ # define u3qdb_tap u3qdi_tap u3_noun u3qdb_uni(u3_noun, u3_noun); u3_noun u3qdb_urn(u3_noun, u3_noun); +# define u3qdb_wyt u3qdi_wyt u3_noun u3qdi_apt(u3_noun); u3_noun u3qdi_bif(u3_noun, u3_noun); From 57d2220d36da8cd43a68bb34cf0231bf2c41c64c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 14 Oct 2020 01:39:37 -0700 Subject: [PATCH 487/933] u3: refactors and enables +int:in jet, correcting refcounts --- pkg/urbit/jets/d/in_int.c | 60 +++++++++++++++++++++------------------ pkg/urbit/jets/tree.c | 7 ++--- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/pkg/urbit/jets/d/in_int.c b/pkg/urbit/jets/d/in_int.c index c5341235bd..85cfc3bb4f 100644 --- a/pkg/urbit/jets/d/in_int.c +++ b/pkg/urbit/jets/d/in_int.c @@ -3,52 +3,56 @@ */ #include "all.h" -/* functions -*/ u3_noun -u3qdi_int(u3_noun a, - u3_noun b) +u3qdi_int(u3_noun a, u3_noun b) { - if ( u3_nul == a ) { - return u3k(u3_nul); - } - else if ( u3_nul == b ) { - return u3k(u3_nul); + if ( (u3_nul == a) + || (u3_nul == b) ) + { + return u3_nul; } else { - u3_noun l_a, n_a, r_a, lr_a; - u3_noun l_b, n_b, r_b, lr_b; - u3_noun c; - u3x_cell(a, &n_a, &lr_a); - u3x_cell(b, &n_b, &lr_b); + u3_noun n_a, l_a, r_a; + u3_noun n_b, l_b, r_b; - if ( c3y == u3qc_mor(n_b, n_a) ) { - c = a; a = b; b = c; - c = n_a; n_a = n_b; n_b = c; - c = lr_a; lr_a = lr_b; lr_b = c; + { + u3_noun lr_a, lr_b; + u3x_cell(a, &n_a, &lr_a); + u3x_cell(b, &n_b, &lr_b); + + if ( c3y == u3qc_mor(n_a, n_b) ) { + u3_noun c; + c = a; a = b; b = c; + c = n_a; n_a = n_b; n_b = c; + c = lr_a; lr_a = lr_b; lr_b = c; + } + + u3x_cell(lr_a, &l_a, &r_a); + u3x_cell(lr_b, &l_b, &r_b); } - u3x_cell(lr_a, &l_a, &r_a); - u3x_cell(lr_b, &l_b, &r_b); - - if ( c3y == u3r_sing(n_a, n_b) ) { + if ( c3y == u3r_sing(n_b, n_a) ) { return u3nt(u3k(n_a), u3qdi_int(l_a, l_b), u3qdi_int(r_a, r_b)); } else if ( c3y == u3qc_gor(n_b, n_a) ) { - return u3qdi_uni(u3qdi_int(l_a, u3nt(n_b, l_b, u3_nul)), - u3qdi_int(a, r_b)); + u3_noun new_l_b = u3nt(u3k(n_b), u3k(l_b), u3_nul); + u3_noun new_a = u3qdi_int(l_a, new_l_b); + + u3z(new_l_b); + return u3kdi_uni(new_a, u3qdi_int(a, r_b)); } else { - return u3qdi_uni(u3qdi_int(r_a, u3nt(n_b, u3_nul, r_b)), - u3qdi_int(a, l_b)); + u3_noun new_r_b = u3nt(u3k(n_b), u3_nul, u3k(r_b)); + u3_noun new_a = u3qdi_int(r_a, new_r_b); + + u3z(new_r_b); + return u3kdi_uni(new_a, u3qdi_int(a, l_b)); } } } -// XX disabled in tree.c, reference counts presumed wrong -// u3_noun u3wdi_int(u3_noun cor) { diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 79dcda8021..9a6a0e40bb 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -1626,9 +1626,8 @@ static c3_c* _141_two_xeb_ha[] = { 0 }; - // https://github.com/urbit/urbit/issues/328 - // static u3j_harm _141_two__in_int_a[] = {{".2", u3wdi_int}, {}}; - // static c3_c* _141_two__in_int_ha[] = {0}; + static u3j_harm _141_two__in_int_a[] = {{".2", u3wdi_int}, {}}; + static c3_c* _141_two__in_int_ha[] = {0}; static u3j_harm _141_two__in_put_a[] = {{".2", u3wdi_put}, {}}; static c3_c* _141_two__in_put_ha[] = { @@ -1666,7 +1665,7 @@ static u3j_core _141_two__in_d[] = { "dif", 7, _141_two__in_dif_a, 0, _141_two__in_dif_ha }, { "gas", 7, _141_two__in_gas_a, 0, _141_two__in_gas_ha }, { "has", 7, _141_two__in_has_a, 0, _141_two__in_has_ha }, - // { "int", 7, _141_two__in_int_a, 0, _141_two__in_int_ha }, + { "int", 7, _141_two__in_int_a, 0, _141_two__in_int_ha }, { "put", 7, _141_two__in_put_a, 0, _141_two__in_put_ha }, { "rep", 7, _141_two__in_rep_a, 0, _141_two__in_rep_ha }, { "run", 7, _141_two__in_run_a, 0, _141_two__in_run_ha }, From 0d5b6575b418497c0bb46a1ef389c101b8a38c32 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 14 Oct 2020 10:09:22 -0700 Subject: [PATCH 488/933] u3: adds u3kdb_uni() --- pkg/urbit/include/jets/k.h | 5 +++++ pkg/urbit/jets/d/by_uni.c | 13 +++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/pkg/urbit/include/jets/k.h b/pkg/urbit/include/jets/k.h index 6a14fc5375..0f0968ea19 100644 --- a/pkg/urbit/include/jets/k.h +++ b/pkg/urbit/include/jets/k.h @@ -81,6 +81,11 @@ u3_noun u3kdb_gas(u3_noun a, u3_noun b); + /* u3kdb_uni(): map union. + */ + u3_noun + u3kdb_uni(u3_noun a, u3_noun b); + /* u3kdi_gas(): list to map. */ u3_noun diff --git a/pkg/urbit/jets/d/by_uni.c b/pkg/urbit/jets/d/by_uni.c index b5135a2bc5..49761b3906 100644 --- a/pkg/urbit/jets/d/by_uni.c +++ b/pkg/urbit/jets/d/by_uni.c @@ -2,11 +2,8 @@ */ #include "all.h" -/* functions -*/ u3_noun -u3qdb_uni(u3_noun a, - u3_noun b) +u3qdb_uni(u3_noun a, u3_noun b) { if ( u3_nul == b ) { return u3k(a); @@ -91,3 +88,11 @@ u3wdb_uni(u3_noun cor) u3x_mean(cor, u3x_sam, &b, u3x_con_sam, &a, 0); return u3qdb_uni(a, b); } + +u3_noun +u3kdb_uni(u3_noun a, u3_noun b) +{ + u3_noun pro = u3qdb_uni(a, b); + u3z(a); u3z(b); + return pro; +} From 8f455a2d03137da2f432d61ed8a063a8553dbc10 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 14 Oct 2020 10:13:04 -0700 Subject: [PATCH 489/933] u3: rewrites and enables +int:by jet --- pkg/urbit/jets/d/by_int.c | 76 ++++++++++++++++----------------------- pkg/urbit/jets/tree.c | 7 ++-- 2 files changed, 33 insertions(+), 50 deletions(-) diff --git a/pkg/urbit/jets/d/by_int.c b/pkg/urbit/jets/d/by_int.c index f822514114..f5eb59a158 100644 --- a/pkg/urbit/jets/d/by_int.c +++ b/pkg/urbit/jets/d/by_int.c @@ -1,21 +1,15 @@ /* j/4/by_int.c -** XXX THIS IS DISABLED -** specifically, s/hor/gor/g (already done?) -** and eliminate memory leaks +** */ #include "all.h" -/* functions -*/ u3_noun -u3qdb_int(u3_noun a, - u3_noun b) +u3qdb_int(u3_noun a, u3_noun b) { - if ( u3_nul == a ) { - return u3k(u3_nul); - } - else if ( u3_nul == b ) { - return u3k(u3_nul); + if ( (u3_nul == a) + || (u3_nul == b) ) + { + return u3_nul; } else { u3_noun n_a, l_a, r_a; @@ -28,54 +22,44 @@ u3qdb_int(u3_noun a, u3x_cell(n_b, &p_n_b, &q_n_b); if ( c3y == u3qc_mor(p_n_a, p_n_b) ) { - if ( c3y == u3r_sing(p_n_a, p_n_b) ) { - return u3nt(u3k(n_b), - u3qdb_int(u3k(l_a), u3k(l_b)), - u3qdb_int(u3k(r_a), u3k(r_b))); + if ( c3y == u3r_sing(p_n_b, p_n_a) ) { + return u3nt(u3k(n_b), u3qdb_int(l_a, l_b), u3qdb_int(r_a, r_b)); } else if ( c3y == u3qc_gor(p_n_b, p_n_a) ) { - return u3qdb_uni(u3qdb_int(u3k(l_a), - u3nt(u3k(n_b), - u3k(l_b), - u3k(u3_nul))), - u3qdb_int(u3k(a), - u3k(r_b))); + u3_noun new_l_b = u3nt(u3k(n_b), u3k(l_b), u3_nul); + u3_noun new_a = u3qdb_int(l_a, new_l_b); + + u3z(new_l_b); + return u3kdb_uni(new_a, u3qdb_int(a, r_b)); } else { - return u3qdb_uni(u3qdb_int(u3k(r_a), - u3nt(u3k(n_b), - u3k(u3_nul), - u3k(r_b))), - u3qdb_int(u3k(a), - u3k(l_b))); + u3_noun new_r_b = u3nt(u3k(n_b), u3_nul, u3k(r_b)); + u3_noun new_a = u3qdb_int(r_a, new_r_b); + + u3z(new_r_b); + return u3kdb_uni(new_a, u3qdb_int(a, l_b)); } } - else if ( c3y == u3r_sing(p_n_b, p_n_a) ) { - return u3nt(u3k(n_b), - u3qdb_int(u3k(l_b), u3k(l_a)), - u3qdb_int(u3k(r_b), u3k(r_a))); + else if ( c3y == u3r_sing(p_n_a, p_n_b) ) { + return u3nt(u3k(n_b), u3qdb_int(l_a, l_b), u3qdb_int(r_a, r_b)); } else if ( c3y == u3qc_gor(p_n_a, p_n_b) ) { - return u3qdb_uni(u3qdb_int(u3k(l_b), - u3nt(u3k(n_a), - u3k(l_a), - u3k(u3_nul))), - u3qdb_int(u3k(a), - u3k(r_a))); + u3_noun new_l_a = u3nt(u3k(n_a), u3k(l_a), u3_nul); + u3_noun new_a = u3qdb_int(new_l_a, l_b); + + u3z(new_l_a); + return u3kdb_uni(new_a, u3qdb_int(r_a, b)); } else { - return u3qdb_uni(u3qdb_int(u3k(r_b), - u3nt(u3k(n_a), - u3k(u3_nul), - u3k(r_a))), - u3qdb_int(u3k(a), - u3k(l_a))); + u3_noun new_r_a = u3nt(u3k(n_a), u3_nul, u3k(r_a)); + u3_noun new_a = u3qdb_int(new_r_a, r_b); + + u3z(new_r_a); + return u3kdb_uni(new_a, u3qdb_int(l_a, b)); } } } -// XX disabled in tree.c, reference counts presumed wrong -// u3_noun u3wdb_int(u3_noun cor) { diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 9a6a0e40bb..a7d97a83f0 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -1721,9 +1721,8 @@ static c3_c* _141_two__in_ha[] = { 0 }; - // https://github.com/urbit/urbit/issues/328 - // static u3j_harm _141_two__by_int_a[] = {{".2", u3wdb_int, c3y}, {}}; - // static c3_c* _141_two__by_int_ha[] = {0}; + static u3j_harm _141_two__by_int_a[] = {{".2", u3wdb_int, c3y}, {}}; + static c3_c* _141_two__by_int_ha[] = {0}; static u3j_harm _141_two__by_jab_a[] = {{".2", u3wdb_jab, c3y}, {}}; static c3_c* _141_two__by_jab_ha[] = { @@ -1775,7 +1774,7 @@ static u3j_core _141_two__by_d[] = { "gas", 7, _141_two__by_gas_a, 0, _141_two__by_gas_ha }, { "get", 7, _141_two__by_get_a, 0, _141_two__by_get_ha }, { "has", 7, _141_two__by_has_a, 0, _141_two__by_has_ha }, - // { "int", 7, _141_two__by_int_a, 0, _141_two__by_int_ha }, + { "int", 7, _141_two__by_int_a, 0, _141_two__by_int_ha }, { "jab", 7, _141_two__by_jab_a, 0, _141_two__by_jab_ha }, { "key", 7, _141_two__by_key_a, 0, _141_two__by_key_ha }, { "put", 7, _141_two__by_put_a, 0, _141_two__by_put_ha }, From b786530de00d1c2c49582a8d0486bcc36dff21ea Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 14 Oct 2020 16:32:16 -0700 Subject: [PATCH 490/933] test: adds +find regression test, fixes set/map comment typo --- pkg/arvo/tests/sys/hoon/list.hoon | 5 +++++ pkg/arvo/tests/sys/hoon/map.hoon | 2 +- pkg/arvo/tests/sys/hoon/set.hoon | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/tests/sys/hoon/list.hoon b/pkg/arvo/tests/sys/hoon/list.hoon index cdff49dafb..720914171f 100644 --- a/pkg/arvo/tests/sys/hoon/list.hoon +++ b/pkg/arvo/tests/sys/hoon/list.hoon @@ -55,6 +55,11 @@ %+ expect-eq !> ~ !> (find `(list @)`~[6] l) + :: Checks for incomplete match + :: + %+ expect-eq + !> ~ + !> (find "bcd" "abc") == :: ++ test-list-flop diff --git a/pkg/arvo/tests/sys/hoon/map.hoon b/pkg/arvo/tests/sys/hoon/map.hoon index 9f9e15c3d7..3ea30f6cc2 100644 --- a/pkg/arvo/tests/sys/hoon/map.hoon +++ b/pkg/arvo/tests/sys/hoon/map.hoon @@ -123,7 +123,7 @@ :: :: and the ordering 1 < 2 < 3. :: - :: 1 should be in the left brach and 3 in the right one. + :: 1 should be in the left branch and 3 in the right one. :: =/ balanced-a=(map @ @) [[2 2] [[1 1] ~ ~] [[3 3] ~ ~]] :: doesn't follow vertical ordering diff --git a/pkg/arvo/tests/sys/hoon/set.hoon b/pkg/arvo/tests/sys/hoon/set.hoon index f0bfafc9b2..77ce543d2e 100644 --- a/pkg/arvo/tests/sys/hoon/set.hoon +++ b/pkg/arvo/tests/sys/hoon/set.hoon @@ -92,7 +92,7 @@ :: 1.923.673.882 :: :: and the ordering 1 < 2 < 3. - :: 1 should be in the left brach and 3 in the right one. + :: 1 should be in the left branch and 3 in the right one. :: =/ balanced-a=(set @) [2 [1 ~ ~] [3 ~ ~]] :: Doesn't follow vertical ordering From b35f87950292c623c1e72504b8aef0b9fb4dde83 Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Wed, 14 Oct 2020 17:05:56 -0700 Subject: [PATCH 491/933] king: implement ~_~/slog without cookies; problems with MultiEyre --- pkg/hs/urbit-king/lib/Urbit/Prelude.hs | 19 +++++++ pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs | 22 ++++---- .../urbit-king/lib/Urbit/Vere/Eyre/Multi.hs | 10 ++-- pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs | 18 ++++--- pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Site.hs | 53 +++++++++++++++++++ pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Wai.hs | 39 ++++++++------ pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs | 34 +++++------- 7 files changed, 135 insertions(+), 60 deletions(-) create mode 100644 pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Site.hs diff --git a/pkg/hs/urbit-king/lib/Urbit/Prelude.hs b/pkg/hs/urbit-king/lib/Urbit/Prelude.hs index eee5cef166..88117a3f9b 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Prelude.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Prelude.hs @@ -15,6 +15,7 @@ module Urbit.Prelude , module RIO , io, rio , logTrace + , acquireWorker, acquireWorkerBound ) where import ClassyPrelude @@ -46,3 +47,21 @@ rio = liftRIO logTrace :: HasLogFunc e => Utf8Builder -> RIO e () logTrace = logOther "trace" + + +-- Utils for Spawning Worker Threads ------------------------------------------- + +acquireWorker :: HasLogFunc e => Text -> RIO e () -> RAcquire e (Async ()) +acquireWorker nam act = mkRAcquire (async act) kill + where + kill tid = do + logInfo ("Killing worker thread: " <> display nam) + cancel tid + +acquireWorkerBound :: HasLogFunc e => Text -> RIO e () -> RAcquire e (Async ()) +acquireWorkerBound nam act = mkRAcquire (asyncBound act) kill + where + kill tid = do + logInfo ("Killing worker thread: " <> display nam) + cancel tid + diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs index ee6d616eb4..57d104bc9f 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs @@ -26,7 +26,8 @@ import RIO.Prelude (decodeUtf8Lenient) import System.Random (randomIO) import Urbit.Vere.Http (convertHeaders, unconvertHeaders) -import qualified Network.HTTP.Types as H +import qualified Network.HTTP.Types as H +import qualified Network.Wai.Conduit as W -- Types ----------------------------------------------------------------------- @@ -176,8 +177,9 @@ startServ -> HttpServerConf -> (EvErr -> STM ()) -> (Text -> RIO e ()) + -> W.Application -> RIO e Serv -startServ who isFake conf plan stderr = do +startServ who isFake conf plan stderr sub = do logInfo (displayShow ("EYRE", "startServ")) multi <- view multiEyreApiL @@ -226,7 +228,7 @@ startServ who isFake conf plan stderr = do atomically (joinMultiEyre multi who mCre onReq onKilReq) logInfo $ displayShow ("EYRE", "Starting loopback server") - lop <- serv vLive $ ServConf + lop <- serv sub vLive $ ServConf { scHost = soHost (pttLop ptt) , scPort = soWhich (pttLop ptt) , scRedi = Nothing @@ -238,7 +240,7 @@ startServ who isFake conf plan stderr = do } logInfo $ displayShow ("EYRE", "Starting insecure server") - ins <- serv vLive $ ServConf + ins <- serv sub vLive $ ServConf { scHost = soHost (pttIns ptt) , scPort = soWhich (pttIns ptt) , scRedi = secRedi @@ -251,7 +253,7 @@ startServ who isFake conf plan stderr = do mSec <- for mTls $ \tls -> do logInfo "Starting secure server" - serv vLive $ ServConf + serv sub vLive $ ServConf { scHost = soHost (pttSec ptt) , scPort = soWhich (pttSec ptt) , scRedi = Nothing @@ -291,14 +293,15 @@ eyre' => Ship -> Bool -> (Text -> RIO e ()) + -> W.Application -> RIO e ([Ev], RAcquire e (DriverApi HttpServerEf)) -eyre' who isFake stderr = do +eyre' who isFake stderr sub = do ventQ :: TQueue EvErr <- newTQueueIO env <- ask let (bornEvs, startDriver) = - eyre env who (writeTQueue ventQ) isFake stderr + eyre env who (writeTQueue ventQ) isFake stderr sub let runDriver = do diOnEffect <- startDriver @@ -327,8 +330,9 @@ eyre -> (EvErr -> STM ()) -> Bool -> (Text -> RIO e ()) + -> W.Application -> ([Ev], RAcquire e (HttpServerEf -> IO ())) -eyre env who plan isFake stderr = (initialEvents, runHttpServer) +eyre env who plan isFake sub stderr = (initialEvents, runHttpServer) where king = fromIntegral (env ^. kingIdL) multi = env ^. multiEyreApiL @@ -352,7 +356,7 @@ eyre env who plan isFake stderr = (initialEvents, runHttpServer) restart :: Drv -> HttpServerConf -> RIO e Serv restart (Drv var) conf = do logInfo "Restarting http server" - let startAct = startServ who isFake conf plan stderr + let startAct = startServ who isFake conf plan sub stderr res <- fromEither =<< restartService var startAct kill logInfo "Done restating http server" pure res diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Multi.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Multi.hs index 73a0c5c559..0345d1986a 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Multi.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Multi.hs @@ -22,6 +22,8 @@ import Urbit.Vere.Eyre.Wai import Network.TLS (Credential) +import Network.Wai as W + -- Types ----------------------------------------------------------------------- @@ -70,8 +72,8 @@ leaveMultiEyre MultiEyreApi {..} who = do modifyTVar' meaPlan (deleteMap who) modifyTVar' meaTlsC (deleteMap who) -multiEyre :: HasLogFunc e => MultiEyreConf -> RIO e MultiEyreApi -multiEyre conf@MultiEyreConf {..} = do +multiEyre :: HasLogFunc e => MultiEyreConf -> W.Application -> RIO e MultiEyreApi +multiEyre conf@MultiEyreConf {..} sub = do logInfo (displayShow ("EYRE", "MULTI", conf)) vLive <- io emptyLiveReqs >>= newTVarIO @@ -97,7 +99,7 @@ multiEyre conf@MultiEyreConf {..} = do mIns <- for mecHttpPort $ \por -> do logInfo (displayShow ("EYRE", "MULTI", "HTTP", por)) - serv vLive $ ServConf + serv sub vLive $ ServConf { scHost = host , scPort = SPChoices $ singleton $ fromIntegral por , scRedi = Nothing -- TODO @@ -110,7 +112,7 @@ multiEyre conf@MultiEyreConf {..} = do mSec <- for mecHttpsPort $ \por -> do logInfo (displayShow ("EYRE", "MULTI", "HTTPS", por)) - serv vLive $ ServConf + serv sub vLive $ ServConf { scHost = host , scPort = SPChoices $ singleton $ fromIntegral por , scRedi = Nothing diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs index 0fdab349b6..b848f9c115 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs @@ -247,9 +247,10 @@ startServer -> W.Port -> Net.Socket -> Maybe W.Port + -> W.Application -> TVar E.LiveReqs -> RIO e () -startServer typ hos por sok red vLive = do +startServer typ hos por sok red sub vLive = do envir <- ask let host = case hos of @@ -262,7 +263,8 @@ startServer typ hos por sok red vLive = do & W.setPort (fromIntegral por) & W.setTimeout (5 * 60) - let runAppl who = E.app envir who vLive + -- TODO build Eyre.Site.app in pier, thread through here + let runAppl who = E.app envir who sub vLive reqShip = hostShip . W.requestHeaderHost case typ of @@ -329,8 +331,8 @@ getFirstTlsConfig (MTC var) = do [] -> STM.retry x:_ -> pure (fst x) -realServ :: HasLogFunc e => TVar E.LiveReqs -> ServConf -> RIO e ServApi -realServ vLive conf@ServConf {..} = do +realServ :: HasLogFunc e => W.Application -> TVar E.LiveReqs -> ServConf -> RIO e ServApi +realServ sub vLive conf@ServConf {..} = do logInfo (displayShow ("EYRE", "SERV", "Running Real Server")) kil <- newEmptyTMVarIO por <- newEmptyTMVarIO @@ -347,10 +349,10 @@ realServ vLive conf@ServConf {..} = do logInfo (displayShow ("EYRE", "SERV", "runServ")) rwith (forceOpenSocket scHost scPort) $ \(por, sok) -> do atomically (putTMVar vPort por) - startServer scType scHost por sok scRedi vLive + startServer scType scHost por sok scRedi sub vLive -serv :: HasLogFunc e => TVar E.LiveReqs -> ServConf -> RIO e ServApi -serv vLive conf = do +serv :: HasLogFunc e => W.Application -> TVar E.LiveReqs -> ServConf -> RIO e ServApi +serv sub vLive conf = do if scFake conf then fakeServ conf - else realServ vLive conf + else realServ sub vLive conf diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Site.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Site.hs new file mode 100644 index 0000000000..02a1ea2f23 --- /dev/null +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Site.hs @@ -0,0 +1,53 @@ +module Urbit.Vere.Eyre.Site (app) where + +import Urbit.Prelude hiding (Builder) + +import Data.ByteString.Builder + +import Data.Conduit (ConduitT, Flush(..), yield) +import Data.Text.Encoding (encodeUtf8Builder) +import Urbit.Noun.Tank (wash) + +import qualified Network.HTTP.Types as H +import qualified Network.Wai as W +import qualified Network.Wai.Conduit as W + +data SlogAction + = KeepAlive + | Slog (Atom, Tank) + +-- veify that if you have multiple open uwu slogs, you multiplex +-- thread TVar func and this server through from pier (loopback only) +-- LATER check cookies & scry, support on all servers + +conduit :: SlogAction -> ConduitT () (Flush Builder) IO () +conduit a = do + case a of + KeepAlive -> pure () + Slog (_, t) -> for_ (wash (WashCfg 0 80) (tankTree t)) $ \l -> do + yield $ Chunk "data:" + yield $ Chunk $ encodeUtf8Builder $ unTape l + yield $ Chunk "\n" + yield $ Chunk "\n" + yield $ Flush + +app :: HasLogFunc e + => TVar ((Atom, Tank) -> IO ()) + -> RAcquire e W.Application +app func = do + slogQ :: TQueue (Atom, Tank) <- newTQueueIO + baton :: TMVar () <- newEmptyTMVarIO + atomically $ writeTVar func (\s -> atomically $ writeTQueue slogQ s) + acquireWorker "Runtime subsite keep-alive" $ forever $ do + atomically $ putTMVar baton () + threadDelay 30_000_000 + + let action = (KeepAlive <$ takeTMVar baton) -- every 30s + <|> (Slog <$> readTQueue slogQ) + + -- TODO write more compactly + let loop = forever (atomically action >>= conduit) + + pure $ \req respond -> respond $ case W.pathInfo req of + ("~_~":"slog":_) -> W.responseSource (H.mkStatus 200 "OK") [] loop + _ -> W.responseLBS (H.mkStatus 404 "Not Found") [] "" diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Wai.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Wai.hs index 147c3bd939..2a9d8039f9 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Wai.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Wai.hs @@ -25,6 +25,7 @@ module Urbit.Vere.Eyre.Wai where import Urbit.Prelude hiding (Builder) +import Urbit.Prelude (RIO) import Data.Binary.Builder (Builder, fromByteString) import Data.Bits (shiftL, (.|.)) @@ -206,24 +207,28 @@ app :: HasLogFunc e => e -> Ship + -> W.Application -> TVar LiveReqs -> (Word64 -> ReqInfo -> STM ()) -> (Word64 -> STM ()) -> W.Application -app env who liv inform cancel req respond = - runRIO env $ rwith (liveReq who liv) $ \(reqId, respApi) -> do - bod <- io (toStrict <$> W.strictRequestBody req) - met <- maybe (error "bad method") pure (cookMeth req) - - let adr = reqAddr req - hdr = W.requestHeaders req - url = reqUrl req - - atomically $ inform reqId $ ReqInfo adr met url hdr bod - - try (sendResponse respond respApi) >>= \case - Right rr -> pure rr - Left exn -> do - atomically (cancel reqId) - logError $ display ("Exception during request" <> tshow exn) - throwIO (exn :: SomeException) +app env who kingSubsite liv inform cancel req respond = + case W.pathInfo req of + ("~_~":_) -> kingSubsite req respond + _ -> + runRIO env $ rwith (liveReq who liv) $ \(reqId, respApi) -> do + bod <- io (toStrict <$> W.strictRequestBody req) + met <- maybe (error "bad method") pure (cookMeth req) + + let adr = reqAddr req + hdr = W.requestHeaders req + url = reqUrl req + + atomically $ inform reqId $ ReqInfo adr met url hdr bod + + try (sendResponse respond respApi) >>= \case + Right rr -> pure rr + Left exn -> do + atomically (cancel reqId) + logError $ display ("Exception during request" <> tshow exn) + throwIO (exn :: SomeException) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs index 6e920685c4..a98f544134 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs @@ -35,6 +35,7 @@ import Urbit.TermSize (TermSize(..), termSize) import Urbit.Vere.Serf (Serf) import qualified Data.Text as T +import qualified Network.Wai as W import qualified System.Entropy as Ent import qualified Urbit.EventLog.LMDB as Log import qualified Urbit.King.API as King @@ -43,6 +44,7 @@ import qualified Urbit.Vere.Ames as Ames import qualified Urbit.Vere.Behn as Behn import qualified Urbit.Vere.Clay as Clay import qualified Urbit.Vere.Eyre as Eyre +import qualified Urbit.Vere.Eyre.Site as Site import qualified Urbit.Vere.Http.Client as Iris import qualified Urbit.Vere.Serf as Serf import qualified Urbit.Vere.Term as Term @@ -240,24 +242,6 @@ getSnapshot top last = do pure $ sort (filter (<= fromIntegral last) snapshotNums) --- Utils for Spawning Worker Threads ------------------------------------------- - -acquireWorker :: HasLogFunc e => Text -> RIO e () -> RAcquire e (Async ()) -acquireWorker nam act = mkRAcquire (async act) kill - where - kill tid = do - logInfo ("Killing worker thread: " <> display nam) - cancel tid - -acquireWorkerBound :: HasLogFunc e => Text -> RIO e () -> RAcquire e (Async ()) -acquireWorkerBound nam act = mkRAcquire (asyncBound act) kill - where - kill tid = do - logInfo ("Killing worker thread: " <> display nam) - cancel tid - - - -- Run Pier -------------------------------------------------------------------- pier @@ -296,10 +280,15 @@ pier (serf, log) vSlog startedSig = do Term.addDemux ext demux logInfo "TERMSERV External terminal connected." - -- Slogs go to both stderr and to the terminal. + -- Set up the runtime subsite server and its capability to slog + siteSlog <- newTVarIO (const $ pure ()) + runtimeSubsite <- Site.app siteSlog + + -- Slogs go to stderr, to the runtime subsite, and to the terminal. env <- ask atomically $ writeTVar vSlog $ \s@(_, tank) -> runRIO env $ do atomically $ Term.slog muxed s + io $ readTVarIO siteSlog >>= ($ s) logOther "serf" (display $ T.strip $ tankToText tank) -- Our call above to set the logging function which echos errors from the @@ -316,7 +305,7 @@ pier (serf, log) vSlog startedSig = do let err = atomically . Term.trace muxed . (<> "\r\n") siz <- atomically $ Term.curDemuxSize demux let fak = isFake logId - drivers env ship fak compute (siz, muxed) err sigint + drivers env ship fak compute (siz, muxed) err sigint runtimeSubsite scrySig <- newEmptyTMVarIO onKill <- view onKillPierSigL @@ -423,12 +412,13 @@ drivers -> (TermSize, Term.Client) -> (Text -> RIO e ()) -> IO () + -> W.Application -> RAcquire e ([Ev], RAcquire e Drivers) -drivers env who isFake plan termSys stderr serfSIGINT = do +drivers env who isFake plan termSys stderr serfSIGINT sub = do (behnBorn, runBehn) <- rio Behn.behn' (termBorn, runTerm) <- rio (Term.term' termSys serfSIGINT) (amesBorn, runAmes) <- rio (Ames.ames' who isFake stderr) - (httpBorn, runEyre) <- rio (Eyre.eyre' who isFake stderr) + (httpBorn, runEyre) <- rio (Eyre.eyre' who isFake stderr sub) (clayBorn, runClay) <- rio Clay.clay' (irisBorn, runIris) <- rio Iris.client' From 16b3edfbd0b21f9765963cdead58386416d24965 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 15 Oct 2020 13:05:54 -0400 Subject: [PATCH 492/933] king: derive +code from Ring and print login +code on startup We need to be able to programatically get the +code outside of Urbit, so add an implementation of the derivation in king haskell. --- pkg/hs/urbit-king/lib/Urbit/King/Main.hs | 1 + pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs index bced7c0fcc..bba16c090c 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs @@ -491,6 +491,7 @@ newShip CLI.New{..} opts = do eny <- io $ Sys.randomIO let seed = mineComet (Set.fromList starList) eny putStrLn ("boot: found comet " ++ renderShip (sShip seed)) + putStrLn ("code: " ++ (tshow $ deriveCode $ sRing seed)) bootFromSeed pill seed CLI.BootFake name -> do diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs index 7c3ffc7c64..9fe9ef8ece 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs @@ -10,6 +10,7 @@ module Urbit.Vere.Dawn ( dawnVent , mix , shas , shaf + , deriveCode , cometFingerprintBS , cometFingerprint ) where @@ -461,8 +462,11 @@ mix a b = BS.pack $ loop (BS.unpack a) (BS.unpack b) loop [] b = b loop (x:xs) (y:ys) = (xor x y) : loop xs ys +shax :: BS.ByteString -> BS.ByteString +shax = SHA256.hash + shas :: BS.ByteString -> BS.ByteString -> BS.ByteString -shas salt = SHA256.hash . mix salt . SHA256.hash +shas salt = shax . mix salt . shax shaf :: BS.ByteString -> BS.ByteString -> BS.ByteString shaf salt ruz = (mix a b) @@ -471,6 +475,22 @@ shaf salt ruz = (mix a b) a = (take 16 haz) b = (drop 16 haz) +-- Given a ring, derives the network login code. +-- +-- The Urbit implementation of +code is just overly complicated. It first +-- takes the ring, then passes it into the encryption system, and then has +-- the encryption system spit the input ring back out. +-- +-- Note that the network code is a patp, not a patq: the bytes have been +-- scrambled. +deriveCode :: Ring -> Ob.Patp +deriveCode Ring {..} = Ob.patp $ + bytesAtom $ + take 8 $ + shaf (C.pack "pass") $ + shax $ + C.singleton 'B' <> ringSign <> ringCrypt + cometFingerprintBS :: Pass -> ByteString cometFingerprintBS = (shaf $ C.pack "bfig") . passToBS From 9e2039ee2f3b768298b9d97610ec55b6a2cffea9 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 15 Oct 2020 13:17:20 -0400 Subject: [PATCH 493/933] arvo: Simplify the actual +code implemetation in jael. --- pkg/arvo/sys/vane/jael.hoon | 5 +---- pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs | 4 ---- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/pkg/arvo/sys/vane/jael.hoon b/pkg/arvo/sys/vane/jael.hoon index e4eee1438f..a4ec699004 100644 --- a/pkg/arvo/sys/vane/jael.hoon +++ b/pkg/arvo/sys/vane/jael.hoon @@ -1033,10 +1033,7 @@ =/ who (slaw %p i.tyl) ?~ who [~ ~] =/ sec (~(got by jaw.own.pki.lex) lyf.own.pki.lex) - =/ cub (nol:nu:crub:crypto sec) - :: XX use pac:ex:cub? - :: - ``[%noun !>((end 6 1 (shaf %pass (shax sec:ex:cub))))] + ``[%noun !>((end 6 1 (shaf %pass (shax sec))))] :: %life ?. ?=([@ ~] tyl) [~ ~] diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs index 9fe9ef8ece..571cca5059 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs @@ -477,10 +477,6 @@ shaf salt ruz = (mix a b) -- Given a ring, derives the network login code. -- --- The Urbit implementation of +code is just overly complicated. It first --- takes the ring, then passes it into the encryption system, and then has --- the encryption system spit the input ring back out. --- -- Note that the network code is a patp, not a patq: the bytes have been -- scrambled. deriveCode :: Ring -> Ob.Patp From aa8634ecdddbe1fed1c0450284d596e857d80c8a Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 15 Oct 2020 13:58:41 -0400 Subject: [PATCH 494/933] Revert "king: fix zig-zag in stderr logging" This reverts commit e9ed97f8a82fb43992f8d1a16503e4565ea1b040. --- pkg/hs/urbit-king/lib/Urbit/King/App.hs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/App.hs b/pkg/hs/urbit-king/lib/Urbit/King/App.hs index c091473fac..107708d16a 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/App.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/App.hs @@ -29,7 +29,6 @@ where import Urbit.King.Config import Urbit.Prelude -import RIO (logGeneric) import System.Directory ( createDirectoryIfMissing , getXdgDirectory , XdgDirectory(XdgCache) @@ -89,9 +88,7 @@ runKingEnvStderr verb lvl inner = do <&> setLogUseTime True <&> setLogUseLoc False <&> setLogMinLevel lvl - withLogFunc logOptions $ \logFunc -> - let lf = wrapCarriage logFunc - in runKingEnv lf lf inner + withLogFunc logOptions $ \logFunc -> runKingEnv logFunc logFunc inner runKingEnvLogFile :: Bool -> LogLevel -> Maybe FilePath -> RIO KingEnv a -> IO a runKingEnvLogFile verb lvl fileM inner = do @@ -110,7 +107,7 @@ runKingEnvLogFile verb lvl fileM inner = do <&> setLogUseLoc False <&> setLogMinLevel lvl withLogFunc stderrLogOptions $ \stderrLogFunc -> withLogFunc logOptions - $ \logFunc -> runKingEnv logFunc (wrapCarriage stderrLogFunc) inner + $ \logFunc -> runKingEnv logFunc stderrLogFunc inner withLogFileHandle :: FilePath -> (Handle -> IO a) -> IO a withLogFileHandle f act = @@ -118,11 +115,6 @@ withLogFileHandle f act = hSetBuffering handle LineBuffering act handle --- XX loses callstack -wrapCarriage :: LogFunc -> LogFunc -wrapCarriage lf = mkLogFunc $ \_ ls ll bldr -> - runRIO lf $ logGeneric ls ll (bldr <> "\r") - defaultLogFile :: IO FilePath defaultLogFile = do logDir <- getXdgDirectory XdgCache "urbit" From d4a34c2b6671370da69a9f301bdf85e9c5ff68b6 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 15 Oct 2020 14:33:36 -0700 Subject: [PATCH 495/933] u3: updates +all:by/+any:by jets to validate loobean gate product --- pkg/urbit/jets/d/by_all.c | 6 ++++-- pkg/urbit/jets/d/by_any.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/urbit/jets/d/by_all.c b/pkg/urbit/jets/d/by_all.c index df8b288c47..2a800f5d96 100644 --- a/pkg/urbit/jets/d/by_all.c +++ b/pkg/urbit/jets/d/by_all.c @@ -13,8 +13,10 @@ _by_all(u3_noun a, u3j_site* sit_u) u3_noun n_a, l_a, r_a; u3x_trel(a, &n_a, &l_a, &r_a); - if ( c3n == u3j_gate_slam(sit_u, u3k(u3t(n_a))) ) { - return c3n; + switch ( u3j_gate_slam(sit_u, u3k(u3t(n_a))) ) { + case c3y: break; + case c3n: return c3n; + default: return u3m_bail(c3__exit); } if ( c3n == _by_all(l_a, sit_u) ) { diff --git a/pkg/urbit/jets/d/by_any.c b/pkg/urbit/jets/d/by_any.c index 8280516587..047eb505c8 100644 --- a/pkg/urbit/jets/d/by_any.c +++ b/pkg/urbit/jets/d/by_any.c @@ -13,8 +13,10 @@ _by_any(u3_noun a, u3j_site* sit_u) u3_noun n_a, l_a, r_a; u3x_trel(a, &n_a, &l_a, &r_a); - if ( c3y == u3j_gate_slam(sit_u, u3k(u3t(n_a))) ) { - return c3y; + switch ( u3j_gate_slam(sit_u, u3k(u3t(n_a))) ) { + case c3y: return c3y; + case c3n: break; + default: return u3m_bail(c3__exit); } if ( c3y == _by_any(l_a, sit_u) ) { From 359d6c881b4ff0fbb5604be20c30e2cae2871789 Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Thu, 15 Oct 2020 21:22:48 -0700 Subject: [PATCH 496/933] king: scry reform --- pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs | 51 +++++++++---------- .../lib/Urbit/Vere/Ames/LaneCache.hs | 46 ++++++++--------- pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs | 7 ++- 3 files changed, 51 insertions(+), 53 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs index ac475f7473..c06c12a38d 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs @@ -135,7 +135,7 @@ ames' :: HasPierEnv e => Ship -> Bool - -> (Time.Wen -> Gang -> Path -> (Maybe (Term, Noun) -> IO ()) -> STM ()) + -> (Time.Wen -> Gang -> Path -> IO (Maybe (Term, Noun))) -> (Text -> RIO e ()) -> RIO e ([Ev], RAcquire e (DriverApi NewtEf)) ames' who isFake scry stderr = do @@ -189,7 +189,7 @@ ames => e -> Ship -> Bool - -> (Time.Wen -> Gang -> Path -> (Maybe (Term, Noun) -> IO ()) -> STM ()) + -> (Time.Wen -> Gang -> Path -> IO (Maybe (Term, Noun))) -> (EvErr -> STM PacketOutcome) -> (Text -> RIO e ()) -> ([Ev], RAcquire e (NewtEf -> IO ())) @@ -209,7 +209,7 @@ ames env who isFake scry enqueueEv stderr = (initialEvents, runAmes) start :: RIO e AmesDrv start = do mode <- rio (netMode isFake) - cache <- laneCache scryLane + cachedScryLane <- cache scryLane aTurfs <- newTVarIO Nothing aDropped <- newTVarIO 0 @@ -220,7 +220,7 @@ ames env who isFake scry enqueueEv stderr = (initialEvents, runAmes) aRecvTid <- queuePacketsThread aDropped aVersion - (byCache cache) + cachedScryLane (send aUdpServ aResolvr mode) aUdpServ @@ -230,21 +230,22 @@ ames env who isFake scry enqueueEv stderr = (initialEvents, runAmes) trackVersionThread :: HasLogFunc e => TVar (Maybe Version) -> RIO e (Async ()) trackVersionThread versSlot = async $ forever do - env <- ask + scryVersion >>= \case + Just v -> do + v0 <- readTVarIO versSlot + atomically $ writeTVar versSlot (Just v) + if (v0 == Just v) + then logInfo $ displayShow ("ames: proto version unchanged at", v) + else stderr ("ames: protocol version now " <> tshow v) - scryVersion \v -> do - v0 <- readTVarIO versSlot - atomically $ writeTVar versSlot (Just v) - if (v0 == Just v) - then logInfo $ displayShow ("ames: proto version unchanged at", v) - else stderr ("ames: protocol version now " <> tshow v) + Nothing -> logError "ames: could not scry for version" threadDelay (10 * 60 * 1_000_000) -- 10m queuePacketsThread :: HasLogFunc e => TVar Word -> TVar (Maybe Version) - -> (Ship -> (Maybe [AmesDest] -> RIO e ()) -> RIO e ()) + -> (Ship -> RIO e (Maybe [AmesDest])) -> (AmesDest -> ByteString -> RIO e ()) -> UdpServ -> RIO e (Async ()) @@ -259,7 +260,7 @@ ames env who isFake scry enqueueEv stderr = (initialEvents, runAmes) if pktRcvr == who then serfsUp p a b - else lan pktRcvr $ \case + else lan pktRcvr >>= \case Just (dest:_) -> forward dest $ encode pkt { pktOrigin = pktOrigin <|> Just (ipDest p a) } _ -> logInfo $ displayShow ("ames: dropping unroutable", pkt) @@ -314,33 +315,29 @@ ames env who isFake scry enqueueEv stderr = (initialEvents, runAmes) EachYes gala -> io (rsSend resolvr gala byt) EachNo addr -> to (ipv4Addr addr) - scryVersion :: HasLogFunc e => (Version -> RIO e ()) -> RIO e () + scryVersion :: HasLogFunc e => RIO e (Maybe Version) scryVersion = scry' ["protocol", "version"] - . maybe (logError "ames: could not scry for version") scryLane :: HasLogFunc e => Ship - -> (Maybe [AmesDest] -> RIO e ()) - -> RIO e () + -> RIO e (Maybe [AmesDest]) scryLane ship = scry' ["peers", MkKnot $ tshow ship, "forward-lane"] scry' :: forall e n . (HasLogFunc e, FromNoun n) => [Knot] - -> (Maybe n -> RIO e ()) - -> RIO e () - scry' p k = do + -> RIO e (Maybe n) + scry' p = do env <- ask wen <- io Time.now let nkt = MkKnot $ tshow $ Time.MkDate wen let pax = Path $ "ax" : MkKnot (tshow who) : "" : nkt : p - let kon = runRIO env . \case - Just (_, fromNoun @n -> Just v) -> k (Just v) - Just (_, n) -> do - logError $ displayShow ("ames: uncanny scry result", pax, n) - k Nothing - Nothing -> k Nothing - atomically $ scry wen Nothing pax kon + io (scry wen Nothing pax) >>= \case + Just (_, fromNoun @n -> Just v) -> pure $ Just v + Just (_, n) -> do + logError $ displayShow ("ames: uncanny scry result", pax, n) + pure Nothing + Nothing -> pure Nothing ipv4Addr (Jammed (AAVoid v )) = absurd v ipv4Addr (Jammed (AAIpv4 a p)) = SockAddrInet (fromIntegral p) (unIpv4 a) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/LaneCache.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/LaneCache.hs index 8c8e235c4c..519f5845d5 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/LaneCache.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/LaneCache.hs @@ -1,4 +1,4 @@ -module Urbit.Vere.Ames.LaneCache (LaneCache, laneCache, byCache) where +module Urbit.Vere.Ames.LaneCache (cache) where import Urbit.Prelude @@ -7,28 +7,26 @@ import Urbit.Noun.Time expiry :: Gap expiry = (2 * 60) ^. from secs -data LaneCache m a b = LaneCache - { lcCache :: TVar (Map a (Wen, b)) - , lcAction :: a -> (b -> m ()) -> m () - } +cache :: forall a b m n + . (Ord a, MonadIO m, MonadIO n) + => (a -> m b) + -> n (a -> m b) +cache act = do + cas <- newTVarIO (mempty :: Map a (Wen, b)) -laneCache :: (Ord a, MonadIO n) - => (a -> (b -> m ()) -> m ()) - -> n (LaneCache m a b) -laneCache act = LaneCache <$> newTVarIO mempty <*> pure act + let fun x = lookup x <$> readTVarIO cas >>= \case + Nothing -> thru + Just (t, v) -> do + t' <- io now + if gap t' t > expiry + then thru + else pure v + where + thru :: m b + thru = do + t <- io now + v <- act x + atomically $ modifyTVar' cas (insertMap x (t, v)) + pure v -byCache :: (Ord a, MonadIO m) - => LaneCache m a b - -> a -> (b -> m ()) -> m () -byCache LaneCache {..} x f = lookup x <$> readTVarIO lcCache >>= \case - Nothing -> go - Just (t, v) -> do - t' <- io now - if gap t' t > expiry - then go - else f v - where - go = lcAction x $ \v -> do - t <- io now - atomically $ modifyTVar' lcCache (insertMap x (t, v)) - f v + pure fun diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs index 276e9828eb..587ccbcfcd 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs @@ -314,8 +314,11 @@ pier (serf, log) vSlog startedSig = do let compute = putTMVar computeQ let execute = writeTQueue executeQ let persist = writeTQueue persistQ - let scry = \w b g k -> writeTQueue scryQ (w, b, g, k) let sigint = Serf.sendSIGINT serf + let scry = \w b g -> do + res <- newEmptyMVar + atomically $ writeTQueue scryQ (w, b, g, putMVar res) + takeMVar res (bootEvents, startDrivers) <- do env <- ask @@ -410,7 +413,7 @@ drivers -> Ship -> Bool -> (RunReq -> STM ()) - -> (Wen -> Gang -> Path -> (Maybe (Term, Noun) -> IO ()) -> STM ()) + -> (Wen -> Gang -> Path -> IO (Maybe (Term, Noun))) -> (TermSize, Term.Client) -> (Text -> RIO e ()) -> IO () From 7853c7df9b793cd465b7ef28417f7b8dc95c4fa4 Mon Sep 17 00:00:00 2001 From: fang Date: Fri, 16 Oct 2020 14:06:44 +0200 Subject: [PATCH 497/933] king: improve king subsite implementation Make KingSubsite part of ServConf, handle 404 case more gracefully, make slog endpoint send SSE headers immediately. Remaining work mostly revolves around the slog endpoint's slog queue. It builds up even if nobody is listening, and only the first to pull from the queue gets to handle/emit the slog event. --- pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs | 36 ++++----- .../lib/Urbit/Vere/Eyre/KingSubsite.hs | 75 +++++++++++++++++++ .../urbit-king/lib/Urbit/Vere/Eyre/Multi.hs | 30 +++++--- pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs | 71 ++++++++++-------- pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Site.hs | 53 ------------- pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Wai.hs | 25 ++++--- pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs | 35 +++++---- 7 files changed, 181 insertions(+), 144 deletions(-) create mode 100644 pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/KingSubsite.hs delete mode 100644 pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Site.hs diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs index 57d104bc9f..910f61cf16 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs @@ -20,14 +20,14 @@ import Urbit.Vere.Eyre.Service import Urbit.Vere.Eyre.Wai import Urbit.Vere.Pier.Types -import Data.List.NonEmpty (NonEmpty((:|))) -import Data.PEM (pemParseBS, pemWriteBS) -import RIO.Prelude (decodeUtf8Lenient) -import System.Random (randomIO) -import Urbit.Vere.Http (convertHeaders, unconvertHeaders) +import Data.List.NonEmpty (NonEmpty((:|))) +import Data.PEM (pemParseBS, pemWriteBS) +import RIO.Prelude (decodeUtf8Lenient) +import System.Random (randomIO) +import Urbit.Vere.Http (convertHeaders, unconvertHeaders) +import Urbit.Vere.Eyre.KingSubsite (KingSubsite) import qualified Network.HTTP.Types as H -import qualified Network.Wai.Conduit as W -- Types ----------------------------------------------------------------------- @@ -177,7 +177,7 @@ startServ -> HttpServerConf -> (EvErr -> STM ()) -> (Text -> RIO e ()) - -> W.Application + -> KingSubsite -> RIO e Serv startServ who isFake conf plan stderr sub = do logInfo (displayShow ("EYRE", "startServ")) @@ -225,27 +225,27 @@ startServ who isFake conf plan stderr sub = do logInfo (displayShow ("EYRE", "joinMultiEyre", who, mTls, mCre)) - atomically (joinMultiEyre multi who mCre onReq onKilReq) + atomically (joinMultiEyre multi who mCre onReq onKilReq sub) logInfo $ displayShow ("EYRE", "Starting loopback server") - lop <- serv sub vLive $ ServConf + lop <- serv vLive $ ServConf { scHost = soHost (pttLop ptt) , scPort = soWhich (pttLop ptt) , scRedi = Nothing , scFake = False - , scType = STHttp who $ ReqApi + , scType = STHttp who sub $ ReqApi { rcReq = onReq Loopback , rcKil = onKilReq } } logInfo $ displayShow ("EYRE", "Starting insecure server") - ins <- serv sub vLive $ ServConf + ins <- serv vLive $ ServConf { scHost = soHost (pttIns ptt) , scPort = soWhich (pttIns ptt) , scRedi = secRedi , scFake = noHttp - , scType = STHttp who $ ReqApi + , scType = STHttp who sub $ ReqApi { rcReq = onReq Insecure , rcKil = onKilReq } @@ -253,12 +253,12 @@ startServ who isFake conf plan stderr sub = do mSec <- for mTls $ \tls -> do logInfo "Starting secure server" - serv sub vLive $ ServConf + serv vLive $ ServConf { scHost = soHost (pttSec ptt) , scPort = soWhich (pttSec ptt) , scRedi = Nothing , scFake = noHttps - , scType = STHttps who tls $ ReqApi + , scType = STHttps who tls sub $ ReqApi { rcReq = onReq Secure , rcKil = onKilReq } @@ -293,7 +293,7 @@ eyre' => Ship -> Bool -> (Text -> RIO e ()) - -> W.Application + -> KingSubsite -> RIO e ([Ev], RAcquire e (DriverApi HttpServerEf)) eyre' who isFake stderr sub = do @@ -330,9 +330,9 @@ eyre -> (EvErr -> STM ()) -> Bool -> (Text -> RIO e ()) - -> W.Application + -> KingSubsite -> ([Ev], RAcquire e (HttpServerEf -> IO ())) -eyre env who plan isFake sub stderr = (initialEvents, runHttpServer) +eyre env who plan isFake stderr sub = (initialEvents, runHttpServer) where king = fromIntegral (env ^. kingIdL) multi = env ^. multiEyreApiL @@ -356,7 +356,7 @@ eyre env who plan isFake sub stderr = (initialEvents, runHttpServer) restart :: Drv -> HttpServerConf -> RIO e Serv restart (Drv var) conf = do logInfo "Restarting http server" - let startAct = startServ who isFake conf plan sub stderr + let startAct = startServ who isFake conf plan stderr sub res <- fromEither =<< restartService var startAct kill logInfo "Done restating http server" pure res diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/KingSubsite.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/KingSubsite.hs new file mode 100644 index 0000000000..81159a44c5 --- /dev/null +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/KingSubsite.hs @@ -0,0 +1,75 @@ +{-| + KingSubsite: runtime-exclusive HTTP request handling, for /~_~ +-} + +module Urbit.Vere.Eyre.KingSubsite + ( KingSubsite + , kingSubsite + , runKingSubsite + , fourOhFourSubsite + ) where + +import Urbit.Prelude hiding (Builder) + +import Data.ByteString.Builder + +import Data.Conduit (ConduitT, Flush(..), yield) +import Data.Text.Encoding (encodeUtf8Builder) +import Urbit.Noun.Tank (wash) + +import qualified Network.HTTP.Types as H +import qualified Network.Wai as W +import qualified Network.Wai.Conduit as W + +newtype KingSubsite = KS { runKingSubsite :: W.Application } + +data SlogAction + = KeepAlive + | Slog (Atom, Tank) + +conduit :: SlogAction -> ConduitT () (Flush Builder) IO () +conduit a = do + case a of + KeepAlive -> pure () + Slog (_, t) -> for_ (wash (WashCfg 0 80) (tankTree t)) $ \l -> do + yield $ Chunk "data:" + yield $ Chunk $ encodeUtf8Builder $ unTape l + yield $ Chunk "\n" + yield $ Chunk "\n" + yield $ Flush + +kingSubsite :: HasLogFunc e + => TVar ((Atom, Tank) -> IO ()) + -> RAcquire e KingSubsite +kingSubsite func = do + slogQ :: TQueue (Atom, Tank) <- newTQueueIO + baton :: TMVar () <- newEmptyTMVarIO + atomically $ writeTVar func (\s -> atomically $ writeTQueue slogQ s) + acquireWorker "Runtime subsite keep-alive" $ forever $ do + atomically $ putTMVar baton () + threadDelay 20_000_000 + + let action = (KeepAlive <$ takeTMVar baton) -- every 20s + <|> (Slog <$> readTQueue slogQ) + --TODO queue builds even without listeners connected. + -- and with listeners connected, only one pops from queue! + -- need queue per connection, not global? + + let loop = yield Flush >> forever (atomically action >>= conduit) + + --TODO scry to verify cookie authentication + pure $ KS $ \req respond -> respond $ case W.pathInfo req of + ("~_~":"slog":_) -> W.responseSource (H.mkStatus 200 "OK") heads loop + _ -> W.responseLBS (H.mkStatus 404 "Not Found") [] "" + where + heads = [ ("Content-Type" , "text/event-stream") + , ("Cache-Control", "no-cache") + , ("Connection" , "keep-alive") + ] + +fourOhFourSubsite :: Ship -> KingSubsite +fourOhFourSubsite who = KS $ \req respond -> + respond $ W.responseLBS (H.mkStatus 404 "Not Found") [] body + where + body = toLazyByteString $ foldMap charUtf8 $ msg + msg = "Ship " <> (show who) <> " not docked." diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Multi.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Multi.hs index 0345d1986a..55ccbac189 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Multi.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Multi.hs @@ -20,9 +20,8 @@ import Urbit.Arvo hiding (ServerId, reqUrl, secure) import Urbit.Vere.Eyre.Serv import Urbit.Vere.Eyre.Wai -import Network.TLS (Credential) - -import Network.Wai as W +import Network.TLS (Credential) +import Urbit.Vere.Eyre.KingSubsite (KingSubsite, fourOhFourSubsite) -- Types ----------------------------------------------------------------------- @@ -47,6 +46,7 @@ data MultiEyreApi = MultiEyreApi , meaPlan :: TVar (Map Ship OnMultiReq) , meaCanc :: TVar (Map Ship OnMultiKil) , meaTlsC :: TVar (Map Ship (TlsConfig, Credential)) + , meaSite :: TVar (Map Ship KingSubsite) , meaKill :: STM () } @@ -59,27 +59,36 @@ joinMultiEyre -> Maybe (TlsConfig, Credential) -> OnMultiReq -> OnMultiKil + -> KingSubsite -> STM () -joinMultiEyre api who mTls onReq onKil = do +joinMultiEyre api who mTls onReq onKil sub = do modifyTVar' (meaPlan api) (insertMap who onReq) modifyTVar' (meaCanc api) (insertMap who onKil) for_ mTls $ \creds -> do modifyTVar' (meaTlsC api) (insertMap who creds) + modifyTVar' (meaSite api) (insertMap who sub) leaveMultiEyre :: MultiEyreApi -> Ship -> STM () leaveMultiEyre MultiEyreApi {..} who = do modifyTVar' meaCanc (deleteMap who) modifyTVar' meaPlan (deleteMap who) modifyTVar' meaTlsC (deleteMap who) + modifyTVar' meaSite (deleteMap who) -multiEyre :: HasLogFunc e => MultiEyreConf -> W.Application -> RIO e MultiEyreApi -multiEyre conf@MultiEyreConf {..} sub = do +multiEyre :: HasLogFunc e => MultiEyreConf -> RIO e MultiEyreApi +multiEyre conf@MultiEyreConf {..} = do logInfo (displayShow ("EYRE", "MULTI", conf)) vLive <- io emptyLiveReqs >>= newTVarIO vPlan <- newTVarIO mempty vCanc <- newTVarIO (mempty :: Map Ship (Ship -> Word64 -> STM ())) vTlsC <- newTVarIO mempty + vSite <- newTVarIO mempty + + let site :: Ship -> STM KingSubsite + site who = do + sites <- readTVar vSite + pure $ maybe (fourOhFourSubsite who) id $ lookup who sites let host = if mecLocalhostOnly then SHLocalhost else SHAnyHostOk @@ -99,12 +108,12 @@ multiEyre conf@MultiEyreConf {..} sub = do mIns <- for mecHttpPort $ \por -> do logInfo (displayShow ("EYRE", "MULTI", "HTTP", por)) - serv sub vLive $ ServConf + serv vLive $ ServConf { scHost = host , scPort = SPChoices $ singleton $ fromIntegral por , scRedi = Nothing -- TODO , scFake = False - , scType = STMultiHttp $ ReqApi + , scType = STMultiHttp site $ ReqApi { rcReq = onReq Insecure , rcKil = onKil } @@ -112,12 +121,12 @@ multiEyre conf@MultiEyreConf {..} sub = do mSec <- for mecHttpsPort $ \por -> do logInfo (displayShow ("EYRE", "MULTI", "HTTPS", por)) - serv sub vLive $ ServConf + serv vLive $ ServConf { scHost = host , scPort = SPChoices $ singleton $ fromIntegral por , scRedi = Nothing , scFake = False - , scType = STMultiHttps (MTC vTlsC) $ ReqApi + , scType = STMultiHttps (MTC vTlsC) site $ ReqApi { rcReq = onReq Secure , rcKil = onKil } @@ -128,6 +137,7 @@ multiEyre conf@MultiEyreConf {..} sub = do , meaPlan = vPlan , meaCanc = vCanc , meaTlsC = vTlsC + , meaSite = vSite , meaConf = conf , meaKill = traverse_ saKil (toList mIns <> toList mSec) } diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs index b848f9c115..a2b65a9398 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs @@ -35,11 +35,15 @@ where import Urbit.Prelude hiding (Builder) -import Data.Default (def) -import Data.List.NonEmpty (NonEmpty((:|))) -import Network.TLS (Credential, Credentials(..), ServerHooks(..)) -import Network.TLS (credentialLoadX509ChainFromMemory) -import RIO.Prelude (decodeUtf8Lenient) +import Data.Default (def) +import Data.List.NonEmpty (NonEmpty((:|))) +import Network.TLS ( Credential + , Credentials(..) + , ServerHooks(..) + ) +import Network.TLS (credentialLoadX509ChainFromMemory) +import RIO.Prelude (decodeUtf8Lenient) +import Urbit.Vere.Eyre.KingSubsite (KingSubsite) import qualified Control.Monad.STM as STM import qualified Data.Char as C @@ -67,23 +71,23 @@ data TlsConfig = TlsConfig newtype MultiTlsConfig = MTC (TVar (Map Ship (TlsConfig, Credential))) -instance Show MultiTlsConfig where - show = const "MultiTlsConfig" - data ReqApi = ReqApi { rcReq :: Ship -> Word64 -> E.ReqInfo -> STM () , rcKil :: Ship -> Word64 -> STM () } -instance Show ReqApi where - show = const "ReqApi" - data ServType - = STHttp Ship ReqApi - | STHttps Ship TlsConfig ReqApi - | STMultiHttp ReqApi - | STMultiHttps MultiTlsConfig ReqApi - deriving (Show) + = STHttp Ship KingSubsite ReqApi + | STHttps Ship TlsConfig KingSubsite ReqApi + | STMultiHttp (Ship -> STM KingSubsite) ReqApi + | STMultiHttps MultiTlsConfig (Ship -> STM KingSubsite) ReqApi + +instance Show ServType where + show = \case + STHttp who _ _ -> "STHttp " <> show who + STHttps who tls _ _ -> "STHttps " <> show who <> " " <> show tls + STMultiHttp _ _ -> "STMultiHttp" + STMultiHttps tls _ _ -> "STMultiHttps" data ServPort = SPAnyPort @@ -247,10 +251,9 @@ startServer -> W.Port -> Net.Socket -> Maybe W.Port - -> W.Application -> TVar E.LiveReqs -> RIO e () -startServer typ hos por sok red sub vLive = do +startServer typ hos por sok red vLive = do envir <- ask let host = case hos of @@ -264,26 +267,27 @@ startServer typ hos por sok red sub vLive = do & W.setTimeout (5 * 60) -- TODO build Eyre.Site.app in pier, thread through here - let runAppl who = E.app envir who sub vLive + let runAppl who = E.app envir who vLive reqShip = hostShip . W.requestHeaderHost case typ of - STHttp who api -> do - let app = runAppl who (rcReq api who) (rcKil api who) + STHttp who sub api -> do + let app = runAppl who (rcReq api who) (rcKil api who) sub io (W.runSettingsSocket opts sok app) - STHttps who TlsConfig {..} api -> do + STHttps who TlsConfig {..} sub api -> do let tls = W.tlsSettingsChainMemory tcCerti tcChain tcPrKey - let app = runAppl who (rcReq api who) (rcKil api who) + let app = runAppl who (rcReq api who) (rcKil api who) sub io (W.runTLSSocket tls opts sok app) - STMultiHttp api -> do + STMultiHttp fub api -> do let app req resp = do who <- reqShip req - runAppl who (rcReq api who) (rcKil api who) req resp + sub <- atomically $ fub who + runAppl who (rcReq api who) (rcKil api who) sub req resp io (W.runSettingsSocket opts sok app) - STMultiHttps mtls api -> do + STMultiHttps mtls fub api -> do TlsConfig {..} <- atomically (getFirstTlsConfig mtls) let sni = def { onServerNameIndication = onSniHdr envir mtls } @@ -298,7 +302,8 @@ startServer typ hos por sok red sub vLive = do runRIO envir $ logDbg ctx "Got request" who <- reqShip req runRIO envir $ logDbg ctx ("Parsed HOST", who) - runAppl who (rcReq api who) (rcKil api who) req resp + sub <- atomically $ fub who + runAppl who (rcReq api who) (rcKil api who) sub req resp io (W.runTLSSocket tlsMany opts sok app) @@ -331,8 +336,8 @@ getFirstTlsConfig (MTC var) = do [] -> STM.retry x:_ -> pure (fst x) -realServ :: HasLogFunc e => W.Application -> TVar E.LiveReqs -> ServConf -> RIO e ServApi -realServ sub vLive conf@ServConf {..} = do +realServ :: HasLogFunc e => TVar E.LiveReqs -> ServConf -> RIO e ServApi +realServ vLive conf@ServConf {..} = do logInfo (displayShow ("EYRE", "SERV", "Running Real Server")) kil <- newEmptyTMVarIO por <- newEmptyTMVarIO @@ -349,10 +354,10 @@ realServ sub vLive conf@ServConf {..} = do logInfo (displayShow ("EYRE", "SERV", "runServ")) rwith (forceOpenSocket scHost scPort) $ \(por, sok) -> do atomically (putTMVar vPort por) - startServer scType scHost por sok scRedi sub vLive + startServer scType scHost por sok scRedi vLive -serv :: HasLogFunc e => W.Application -> TVar E.LiveReqs -> ServConf -> RIO e ServApi -serv sub vLive conf = do +serv :: HasLogFunc e => TVar E.LiveReqs -> ServConf -> RIO e ServApi +serv vLive conf = do if scFake conf then fakeServ conf - else realServ sub vLive conf + else realServ vLive conf diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Site.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Site.hs deleted file mode 100644 index 02a1ea2f23..0000000000 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Site.hs +++ /dev/null @@ -1,53 +0,0 @@ -module Urbit.Vere.Eyre.Site (app) where - -import Urbit.Prelude hiding (Builder) - -import Data.ByteString.Builder - -import Data.Conduit (ConduitT, Flush(..), yield) -import Data.Text.Encoding (encodeUtf8Builder) -import Urbit.Noun.Tank (wash) - -import qualified Network.HTTP.Types as H -import qualified Network.Wai as W -import qualified Network.Wai.Conduit as W - -data SlogAction - = KeepAlive - | Slog (Atom, Tank) - --- veify that if you have multiple open uwu slogs, you multiplex --- thread TVar func and this server through from pier (loopback only) --- LATER check cookies & scry, support on all servers - -conduit :: SlogAction -> ConduitT () (Flush Builder) IO () -conduit a = do - case a of - KeepAlive -> pure () - Slog (_, t) -> for_ (wash (WashCfg 0 80) (tankTree t)) $ \l -> do - yield $ Chunk "data:" - yield $ Chunk $ encodeUtf8Builder $ unTape l - yield $ Chunk "\n" - yield $ Chunk "\n" - yield $ Flush - -app :: HasLogFunc e - => TVar ((Atom, Tank) -> IO ()) - -> RAcquire e W.Application -app func = do - slogQ :: TQueue (Atom, Tank) <- newTQueueIO - baton :: TMVar () <- newEmptyTMVarIO - atomically $ writeTVar func (\s -> atomically $ writeTQueue slogQ s) - acquireWorker "Runtime subsite keep-alive" $ forever $ do - atomically $ putTMVar baton () - threadDelay 30_000_000 - - let action = (KeepAlive <$ takeTMVar baton) -- every 30s - <|> (Slog <$> readTQueue slogQ) - - -- TODO write more compactly - let loop = forever (atomically action >>= conduit) - - pure $ \req respond -> respond $ case W.pathInfo req of - ("~_~":"slog":_) -> W.responseSource (H.mkStatus 200 "OK") [] loop - _ -> W.responseLBS (H.mkStatus 404 "Not Found") [] "" diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Wai.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Wai.hs index 2a9d8039f9..e0d0d9d3f1 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Wai.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Wai.hs @@ -27,12 +27,13 @@ where import Urbit.Prelude hiding (Builder) import Urbit.Prelude (RIO) -import Data.Binary.Builder (Builder, fromByteString) -import Data.Bits (shiftL, (.|.)) -import Data.Conduit (ConduitT, Flush(Chunk, Flush), yield) -import Network.Socket (SockAddr(..)) -import System.Random (newStdGen, randoms) -import Urbit.Arvo (Address(..), Ipv4(..), Ipv6(..), Method) +import Data.Binary.Builder (Builder, fromByteString) +import Data.Bits (shiftL, (.|.)) +import Data.Conduit (ConduitT, Flush(Chunk, Flush), yield) +import Network.Socket (SockAddr(..)) +import System.Random (newStdGen, randoms) +import Urbit.Arvo (Address(..), Ipv4(..), Ipv6(..), Method) +import Urbit.Vere.Eyre.KingSubsite (KingSubsite, runKingSubsite) import qualified Network.HTTP.Types as H import qualified Network.Wai as W @@ -207,25 +208,25 @@ app :: HasLogFunc e => e -> Ship - -> W.Application -> TVar LiveReqs -> (Word64 -> ReqInfo -> STM ()) -> (Word64 -> STM ()) + -> KingSubsite -> W.Application -app env who kingSubsite liv inform cancel req respond = +app env who liv inform cancel sub req respond = case W.pathInfo req of - ("~_~":_) -> kingSubsite req respond + ("~_~":_) -> runKingSubsite sub req respond _ -> runRIO env $ rwith (liveReq who liv) $ \(reqId, respApi) -> do bod <- io (toStrict <$> W.strictRequestBody req) met <- maybe (error "bad method") pure (cookMeth req) - + let adr = reqAddr req hdr = W.requestHeaders req url = reqUrl req - + atomically $ inform reqId $ ReqInfo adr met url hdr bod - + try (sendResponse respond respApi) >>= \case Right rr -> pure rr Left exn -> do diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs index a98f544134..aef61a8241 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs @@ -34,22 +34,21 @@ import Urbit.Noun.Time (Wen) import Urbit.TermSize (TermSize(..), termSize) import Urbit.Vere.Serf (Serf) -import qualified Data.Text as T -import qualified Network.Wai as W -import qualified System.Entropy as Ent -import qualified Urbit.EventLog.LMDB as Log -import qualified Urbit.King.API as King -import qualified Urbit.Noun.Time as Time -import qualified Urbit.Vere.Ames as Ames -import qualified Urbit.Vere.Behn as Behn -import qualified Urbit.Vere.Clay as Clay -import qualified Urbit.Vere.Eyre as Eyre -import qualified Urbit.Vere.Eyre.Site as Site -import qualified Urbit.Vere.Http.Client as Iris -import qualified Urbit.Vere.Serf as Serf -import qualified Urbit.Vere.Term as Term -import qualified Urbit.Vere.Term.API as Term -import qualified Urbit.Vere.Term.Demux as Term +import qualified Data.Text as T +import qualified System.Entropy as Ent +import qualified Urbit.EventLog.LMDB as Log +import qualified Urbit.King.API as King +import qualified Urbit.Noun.Time as Time +import qualified Urbit.Vere.Ames as Ames +import qualified Urbit.Vere.Behn as Behn +import qualified Urbit.Vere.Clay as Clay +import qualified Urbit.Vere.Eyre as Eyre +import qualified Urbit.Vere.Eyre.KingSubsite as Site +import qualified Urbit.Vere.Http.Client as Iris +import qualified Urbit.Vere.Serf as Serf +import qualified Urbit.Vere.Term as Term +import qualified Urbit.Vere.Term.API as Term +import qualified Urbit.Vere.Term.Demux as Term -- Initialize pier directory. -------------------------------------------------- @@ -282,7 +281,7 @@ pier (serf, log) vSlog startedSig = do -- Set up the runtime subsite server and its capability to slog siteSlog <- newTVarIO (const $ pure ()) - runtimeSubsite <- Site.app siteSlog + runtimeSubsite <- Site.kingSubsite siteSlog -- Slogs go to stderr, to the runtime subsite, and to the terminal. env <- ask @@ -412,7 +411,7 @@ drivers -> (TermSize, Term.Client) -> (Text -> RIO e ()) -> IO () - -> W.Application + -> Site.KingSubsite -> RAcquire e ([Ev], RAcquire e Drivers) drivers env who isFake plan termSys stderr serfSIGINT sub = do (behnBorn, runBehn) <- rio Behn.behn' From 6400f760c718fefa53956582ad8f671d227841e7 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 22 Sep 2020 14:05:34 -0700 Subject: [PATCH 498/933] vere: renames ames mug helper for consistency --- pkg/urbit/vere/io/ames.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 4d544425d3..f4ec98ef36 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -131,13 +131,11 @@ _ames_panc_free(u3_panc* pac_u) { c3_free(pac_u); } -/* _ca_mug_body(): truncated mug hash of bytes +/* _ames_mug_body(): truncated (20 least-significant bits) mug hash of bytes */ static c3_l -_ca_mug_body(c3_w len_w, c3_y* byt_y) +_ames_mug_body(c3_w len_w, c3_y* byt_y) { - // mask off ((1 << 20) - 1) - // return u3r_mug_bytes(byt_y, len_w) & 0xfffff; } @@ -434,7 +432,7 @@ _ames_serialize_packet(u3_panc* pac_u, c3_o dop_o) // if we updated the origin lane, we need to update the mug too // if ( c3y == nal_o ) { - pac_u->hed_u.mug_l = _ca_mug_body(sen_y + rec_y + bod_u->con_w, + pac_u->hed_u.mug_l = _ames_mug_body(sen_y + rec_y + bod_u->con_w, pac_y + 4); } @@ -800,7 +798,7 @@ _ames_recv_cb(uv_udp_t* wax_u, // ensure the mug is valid // if ( c3y == pas_o - && (hed_u.mug_l != _ca_mug_body(nrd_i - 4, bod_y)) ) + && (hed_u.mug_l != _ames_mug_body(nrd_i - 4, bod_y)) ) { pas_o = c3n; From 7c393a1d71af2752643070b60cfab5d9638dae39 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 22 Sep 2020 14:33:39 -0700 Subject: [PATCH 499/933] vere: factors out ames' packet header parsing/serialization --- pkg/urbit/vere/io/ames.c | 65 ++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index f4ec98ef36..68ce82c889 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -139,6 +139,46 @@ _ames_mug_body(c3_w len_w, c3_y* byt_y) return u3r_mug_bytes(byt_y, len_w) & 0xfffff; } +/* _ames_sift_head(): parse packet header. +*/ +static void +_ames_sift_head(u3_head* hed_u, c3_y buf_y[4]) +{ + c3_w hed_w = buf_y[0] + | (buf_y[1] << 8) + | (buf_y[2] << 16) + | (buf_y[3] << 24); + + // XX only version 0 currently recognized + // + hed_u->ver_y = hed_w & 0x7; + hed_u->mug_l = (hed_w >> 3) & 0xfffff; // 20 bits + hed_u->sac_y = (hed_w >> 23) & 0x3; + hed_u->rac_y = (hed_w >> 25) & 0x3; + hed_u->enc_o = (hed_w >> 27) & 0x1; +} + +/* _ames_etch_head(): serialize packet header. +*/ +static void +_ames_etch_head(u3_head* hed_u, c3_y buf_y[4]) +{ + c3_w hed_w = hed_u->ver_y + | (hed_u->mug_l << 3) + | (hed_u->sac_y << 23) + | (hed_u->rac_y << 25) + | (hed_u->enc_o << 27); + + // only version 0 currently recognized + // + c3_assert( 0 == hed_u->ver_y ); + + buf_y[0] = hed_w & 0xff; + buf_y[1] = (hed_w >> 8) & 0xff; + buf_y[2] = (hed_w >> 16) & 0xff; + buf_y[3] = (hed_w >> 24) & 0xff; +} + /* _ames_send_cb(): send callback. */ static void @@ -438,16 +478,7 @@ _ames_serialize_packet(u3_panc* pac_u, c3_o dop_o) // now we can serialize the head // - u3_head* hed_u = &pac_u->hed_u; - c3_w hed_w = hed_u->ver_y - | (hed_u->mug_l << 3) - | (hed_u->sac_y << 23) - | (hed_u->rac_y << 25) - | (hed_u->enc_o << 27); - - // XX assumes little-endian - // - memcpy(pac_y, &hed_w, 4); + _ames_etch_head(&pac_u->hed_u, pac_y); pac = u3i_bytes(4 + sen_y + rec_y + bod_u->con_w, pac_y); c3_free(pac_y); @@ -766,20 +797,10 @@ _ames_recv_cb(uv_udp_t* wax_u, if ( 4 >= nrd_i ) { pas_o = c3n; } + // unpack the packet header // - else { - c3_w hed_w = (byt_y[0] << 0) - | (byt_y[1] << 8) - | (byt_y[2] << 16) - | (byt_y[3] << 24); - - hed_u.ver_y = hed_w & 0x7; - hed_u.mug_l = (hed_w >> 3) & 0xfffff; //NOTE ((1 << 20) - 1) - hed_u.sac_y = (hed_w >> 23) & 0x3; - hed_u.rac_y = (hed_w >> 25) & 0x3; - hed_u.enc_o = (hed_w >> 27) & 0x1; - } + _ames_sift_head(&hed_u, byt_y); // ensure the protocol version matches ours // From 6c6b2db0d877a08dde928383179c2aec0cf5a0e6 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 16 Oct 2020 16:50:29 -0700 Subject: [PATCH 500/933] vere: factors out ames' ship byte-array to chubs-array conversion --- pkg/urbit/vere/io/ames.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 68ce82c889..a91fe97d15 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -179,6 +179,35 @@ _ames_etch_head(u3_head* hed_u, c3_y buf_y[4]) buf_y[3] = (hed_w >> 24) & 0xff; } +/* _ames_chub_bytes(): c3_y[8] to c3_d +** XX move +*/ +static inline c3_d +_ames_chub_bytes(c3_y byt_y[8]) +{ + return (c3_d)byt_y[0] + | (c3_d)byt_y[1] << 8 + | (c3_d)byt_y[2] << 16 + | (c3_d)byt_y[3] << 24 + | (c3_d)byt_y[4] << 32 + | (c3_d)byt_y[5] << 40 + | (c3_d)byt_y[6] << 48 + | (c3_d)byt_y[7] << 56; +} + +/* _ames_ship_to_chubs(): pack [len_y] bytes into c3_d[2] +** XX move +*/ +static inline void +_ames_ship_to_chubs(c3_d sip_d[2], c3_y len_y, c3_y* buf_y) +{ + c3_y sip_y[16] = {0}; + memcpy(sip_y, buf_y, c3_min(16, len_y)); + + sip_d[0] = _ames_chub_bytes(sip_y); + sip_d[1] = _ames_chub_bytes(sip_y + 8); +} + /* _ames_send_cb(): send callback. */ static void @@ -839,11 +868,8 @@ _ames_recv_cb(uv_udp_t* wax_u, c3_y* con_y = NULL; if ( c3y == pas_o ) { - u3_noun sen = u3i_bytes(sen_y, bod_y); - u3_noun rec = u3i_bytes(rec_y, bod_y + sen_y); - u3r_chubs(0, 2, rec_d, rec); - u3r_chubs(0, 2, sen_d, sen); - u3z(sen); u3z(rec); + _ames_ship_to_chubs(sen_d, sen_y, bod_y); + _ames_ship_to_chubs(rec_d, rec_y, bod_y + sen_y); con_y = c3_malloc(con_w); memcpy(con_y, bod_y + sen_y + rec_y, con_w); From 9b1b303417a9daa83e0df8aa924d541f007e1004 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 16 Oct 2020 16:52:16 -0700 Subject: [PATCH 501/933] vere: factors out ames' ship chubs-array to byte-array conversion --- pkg/urbit/vere/io/ames.c | 41 +++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index a91fe97d15..ab1353b8f2 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -208,6 +208,36 @@ _ames_ship_to_chubs(c3_d sip_d[2], c3_y len_y, c3_y* buf_y) sip_d[1] = _ames_chub_bytes(sip_y + 8); } +/* _ames_chub_bytes(): c3_d to c3_y[8] +** XX move +*/ +static inline void +_ames_bytes_chub(c3_y byt_y[8], c3_d num_d) +{ + byt_y[0] = num_d & 0xff; + byt_y[1] = (num_d >> 8) & 0xff; + byt_y[2] = (num_d >> 16) & 0xff; + byt_y[3] = (num_d >> 24) & 0xff; + byt_y[4] = (num_d >> 32) & 0xff; + byt_y[5] = (num_d >> 40) & 0xff; + byt_y[6] = (num_d >> 48) & 0xff; + byt_y[7] = (num_d >> 56) & 0xff; +} + +/* _ames_ship_of_chubs(): unpack c3_d[2] into [len_y] bytes. +** XX move +*/ +static inline void +_ames_ship_of_chubs(c3_d sip_d[2], c3_y len_y, c3_y* buf_y) +{ + c3_y sip_y[16] = {0}; + + _ames_bytes_chub(sip_y, sip_d[0]); + _ames_bytes_chub(sip_y + 8, sip_d[1]); + + memcpy(buf_y, sip_y, c3_min(16, len_y)); +} + /* _ames_send_cb(): send callback. */ static void @@ -489,13 +519,10 @@ _ames_serialize_packet(u3_panc* pac_u, c3_o dop_o) // u3_body* bod_u = &pac_u->bod_u; c3_y* pac_y = c3_malloc(4 + sen_y + rec_y + bod_u->con_w); - { - u3_atom sen = u3i_chubs(2, bod_u->sen_d); - u3_atom rec = u3i_chubs(2, bod_u->rec_d); - u3r_bytes(0, sen_y, pac_y + 4, sen); - u3r_bytes(0, rec_y, pac_y + 4 + sen_y, rec); - u3z(sen); u3z(rec); - } + + _ames_ship_of_chubs(bod_u->sen_d, sen_y, pac_y + 4); + _ames_ship_of_chubs(bod_u->rec_d, rec_y, pac_y + 4 + sen_y); + memcpy(pac_y + 4 + sen_y + rec_y, bod_u->con_y, bod_u->con_w); // if we updated the origin lane, we need to update the mug too From acbcc53e49d4b09540f95037aa821d9326098128 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 16 Oct 2020 16:55:28 -0700 Subject: [PATCH 502/933] vere: refactors ames' packet serialization --- pkg/urbit/vere/io/ames.c | 76 ++++++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 27 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index ab1353b8f2..5db252a8c0 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -238,6 +238,45 @@ _ames_ship_of_chubs(c3_d sip_d[2], c3_y len_y, c3_y* buf_y) memcpy(buf_y, sip_y, c3_min(16, len_y)); } +/* _ames_etch_pack(): serialize packet header and body. +*/ +static c3_w +_ames_etch_pack(u3_head* hed_u, + u3_body* bod_u, + c3_o mug_o, + c3_y** out_y) +{ + // start with the body + // + c3_y sen_y = 2 << hed_u->sac_y; // sender len + c3_y rec_y = 2 << hed_u->rac_y; // receiver len + c3_w bod_w = sen_y + rec_y + bod_u->con_w; // body len + c3_w len_w = 4 + bod_w; // packet len + c3_y* pac_y = c3_malloc(len_w); + c3_y* bod_y = pac_y + 4; + + _ames_ship_of_chubs(bod_u->sen_d, sen_y, bod_y); + _ames_ship_of_chubs(bod_u->rec_d, rec_y, bod_y + sen_y); + + { + c3_y* con_y = bod_y + sen_y + rec_y; + memcpy(con_y, bod_u->con_y, bod_u->con_w); + } + + // if we updated the origin lane, we need to update the mug too + // + if ( c3y == mug_o ) { + hed_u->mug_l = _ames_mug_body(bod_w, bod_y); + } + + // now we can serialize the head + // + _ames_etch_head(hed_u, pac_y); + + *out_y = pac_y; + return len_w; +} + /* _ames_send_cb(): send callback. */ static void @@ -467,8 +506,6 @@ _ames_lane_from_cache(u3p(u3h_root) lax_p, u3_noun who) { static u3_noun _ames_serialize_packet(u3_panc* pac_u, c3_o dop_o) { - c3_y sen_y = 2 << pac_u->hed_u.sac_y; - c3_y rec_y = 2 << pac_u->hed_u.rac_y; c3_o nal_o = c3n; // update the body's lane, if desired @@ -513,34 +550,19 @@ _ames_serialize_packet(u3_panc* pac_u, c3_o dop_o) // serialize the packet // - u3_noun pac; + // XX serialize on stack? + // { - // start with the body - // - u3_body* bod_u = &pac_u->bod_u; - c3_y* pac_y = c3_malloc(4 + sen_y + rec_y + bod_u->con_w); - - _ames_ship_of_chubs(bod_u->sen_d, sen_y, pac_y + 4); - _ames_ship_of_chubs(bod_u->rec_d, rec_y, pac_y + 4 + sen_y); - - memcpy(pac_y + 4 + sen_y + rec_y, bod_u->con_y, bod_u->con_w); - - // if we updated the origin lane, we need to update the mug too - // - if ( c3y == nal_o ) { - pac_u->hed_u.mug_l = _ames_mug_body(sen_y + rec_y + bod_u->con_w, - pac_y + 4); - } - - // now we can serialize the head - // - _ames_etch_head(&pac_u->hed_u, pac_y); - - pac = u3i_bytes(4 + sen_y + rec_y + bod_u->con_w, pac_y); + u3_noun pac; + c3_y* pac_y; + c3_w len_w = _ames_etch_pack(&pac_u->hed_u, + &pac_u->bod_u, + nal_o, &pac_y); + pac = u3i_bytes(len_w, pac_y); c3_free(pac_y); - } - return pac; + return pac; + } } /* _ames_czar(): galaxy address resolution. From e2b47e02c2f54286b10f064e253af7add94d8ebd Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 19 Oct 2020 22:59:57 -0700 Subject: [PATCH 503/933] vere: refactors ames' packet parsing and forwarding --- pkg/urbit/vere/io/ames.c | 370 +++++++++++++++++++++++---------------- 1 file changed, 219 insertions(+), 151 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 5db252a8c0..c40b435ef5 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -86,6 +86,7 @@ u3_lane ore_u; // origin lane u3_head hed_u; // header u3_body bod_u; // body + void* ptr_v; // buffer (to free) } u3_panc; /* _ames_alloc(): libuv buffer allocator. @@ -116,18 +117,21 @@ _ames_pact_free(u3_pact* pac_u) /* _ames_panc_free(): remove references, lose refcounts and free struct */ static void -_ames_panc_free(u3_panc* pac_u) { +_ames_panc_free(u3_panc* pac_u) +{ if ( 0 != pac_u->nex_u ) { pac_u->nex_u->pre_u = pac_u->pre_u; } + if ( 0 != pac_u->pre_u ) { pac_u->pre_u->nex_u = pac_u->nex_u; - } else { + } + else { c3_assert(pac_u == pac_u->sam_u->pac_u); pac_u->sam_u->pac_u = pac_u->nex_u; } - c3_free(pac_u->bod_u.con_y); + c3_free(pac_u->ptr_v); c3_free(pac_u); } @@ -141,7 +145,7 @@ _ames_mug_body(c3_w len_w, c3_y* byt_y) /* _ames_sift_head(): parse packet header. */ -static void +static c3_o _ames_sift_head(u3_head* hed_u, c3_y buf_y[4]) { c3_w hed_w = buf_y[0] @@ -156,6 +160,7 @@ _ames_sift_head(u3_head* hed_u, c3_y buf_y[4]) hed_u->sac_y = (hed_w >> 23) & 0x3; hed_u->rac_y = (hed_w >> 25) & 0x3; hed_u->enc_o = (hed_w >> 27) & 0x1; + return c3y; } /* _ames_etch_head(): serialize packet header. @@ -238,6 +243,30 @@ _ames_ship_of_chubs(c3_d sip_d[2], c3_y len_y, c3_y* buf_y) memcpy(buf_y, sip_y, c3_min(16, len_y)); } +/* _ames_sift_body(): parse packet body. +*/ +static c3_o +_ames_sift_body(u3_head* hed_u, + u3_body* bod_u, + c3_w len_w, + c3_y* bod_y) +{ + c3_y sen_y = 2 << hed_u->sac_y; + c3_y rec_y = 2 << hed_u->rac_y; + + if ( (sen_y + rec_y) >= len_w ) { + return c3n; + } + else { + _ames_ship_to_chubs(bod_u->sen_d, sen_y, bod_y); + _ames_ship_to_chubs(bod_u->rec_d, rec_y, bod_y + sen_y); + + bod_u->con_w = len_w - sen_y - rec_y; + bod_u->con_y = bod_y + sen_y + rec_y; + return c3y; + } +} + /* _ames_etch_pack(): serialize packet header and body. */ static c3_w @@ -452,17 +481,6 @@ u3_ames_encode_lane(u3_lane lan) { return u3ke_jam(u3nt(c3__ipv4, u3i_words(1, &lan.pip_w), lan.por_s)); } -/* _ames_lane_from_sockaddr(): sockaddr_in to lane struct -*/ -static u3_lane -_ames_lane_from_sockaddr(struct sockaddr_in* add_u) -{ - u3_lane lan_u; - lan_u.por_s = ntohs(add_u->sin_port); - lan_u.pip_w = ntohl(add_u->sin_addr.s_addr); - return lan_u; -} - /* _ames_lane_into_cache(): put las for who into cache, including timestamp */ static void @@ -532,16 +550,27 @@ _ames_serialize_packet(u3_panc* pac_u, c3_o dop_o) // always using the appropriate galaxy lane instead. // if ( u3_nul == lon ) { + c3_w con_w; + c3_y* con_y; + u3z(lon); lon = u3nt(u3_nul, c3n, u3_ames_encode_lane(pac_u->ore_u)); nal_o = c3y; - c3_free(pac_u->bod_u.con_y); - u3_noun jam = u3ke_jam(u3nc(lon, bod)); - pac_u->bod_u.con_w = u3r_met(3, jam); - pac_u->bod_u.con_y = c3_malloc(pac_u->bod_u.con_w); - u3r_bytes(0, pac_u->bod_u.con_w, pac_u->bod_u.con_y, jam); - u3z(jam); + // XX off-loom jam? + // + { + u3_noun jam = u3ke_jam(u3nc(lon, bod)); + con_w = u3r_met(3, jam); + con_y = c3_malloc(con_w); + u3r_bytes(0, con_w, con_y, jam); + u3z(jam); + } + + c3_free(pac_u->ptr_v); + pac_u->ptr_v = con_y; + pac_u->bod_u.con_y = con_y; + pac_u->bod_u.con_w = con_w; } else { u3z(lon); u3z(bod); @@ -855,101 +884,28 @@ _ames_lane_scry_cb(void* vod_p, u3_noun nun) u3z(nun); } -/* _ames_recv_cb(): receive callback. +/* _ames_try_forward(): try to forward a packet for another ship. */ static void -_ames_recv_cb(uv_udp_t* wax_u, - ssize_t nrd_i, - const uv_buf_t * buf_u, - const struct sockaddr* adr_u, - unsigned flg_i) +_ames_try_forward(u3_ames* sam_u, + u3_lane* lan_u, + u3_head* hed_u, + u3_body* bod_u, + c3_y* hun_y) { - u3_ames* sam_u = wax_u->data; - c3_o pas_o = c3y; - c3_y* byt_y = (c3_y*)buf_u->base; - c3_y* bod_y = byt_y + 4; - u3_head hed_u; + u3_weak lac; - // ensure a sane message size + // if the recipient is a galaxy, their lane is always &+~gax // - if ( 4 >= nrd_i ) { - pas_o = c3n; - } - - // unpack the packet header - // - _ames_sift_head(&hed_u, byt_y); - - // ensure the protocol version matches ours - // - if ( c3y == pas_o - && (c3y == sam_u->fit_o) - && (sam_u->ver_y != hed_u.ver_y) ) + if ( (256 > bod_u->rec_d[0]) + && (0 == bod_u->rec_d[1]) ) { - pas_o = c3n; - - sam_u->vet_d++; - if ( 0 == (sam_u->vet_d % 100) ) { - u3l_log("ames: %" PRIu64 " dropped for version mismatch\n", sam_u->vet_d); - } + lac = u3nc(c3y, (c3_y)bod_u->rec_d[0]); } - - // ensure the mug is valid + // otherwise, try to get the lane from cache // - if ( c3y == pas_o - && (hed_u.mug_l != _ames_mug_body(nrd_i - 4, bod_y)) ) - { - pas_o = c3n; - - sam_u->mut_d++; - if ( 0 == (sam_u->mut_d % 100) ) { - u3l_log("ames: %" PRIu64 " dropped for invalid mug\n", sam_u->mut_d); - } - } - - // unpack the body - // - c3_y sen_y = 2 << hed_u.sac_y; - c3_y rec_y = 2 << hed_u.rac_y; - c3_d sen_d[2]; - c3_d rec_d[2]; - c3_w con_w = nrd_i - 4 - sen_y - rec_y; - c3_y* con_y = NULL; - - if ( c3y == pas_o ) { - _ames_ship_to_chubs(sen_d, sen_y, bod_y); - _ames_ship_to_chubs(rec_d, rec_y, bod_y + sen_y); - - con_y = c3_malloc(con_w); - memcpy(con_y, bod_y + sen_y + rec_y, con_w); - - // ensure the content is cue-able - // - pas_o = ur_cue_test_with(sam_u->tes_u, con_w, con_y) ? c3y : c3n; - } - - // if we can scry, - // and we are not the recipient, - // we might want to forward statelessly - // - if ( c3y == pas_o - && c3y == sam_u->see_o - && ( (rec_d[0] != sam_u->pir_u->who_d[0]) - || (rec_d[1] != sam_u->pir_u->who_d[1]) ) ) - { - pas_o = c3n; - - u3_weak lac; - // if the recipient is a galaxy, their lane is always &+~gax - // - if ( (rec_d[1] == 0) && (256 > rec_d[0]) ) { - lac = u3nc(c3y, (c3_y)rec_d[0]); - } - // otherwise, try to get the lane from cache - // - else { - lac = _ames_lane_from_cache(sam_u->lax_p, u3i_chubs(2, rec_d)); - } + else { + lac = _ames_lane_from_cache(sam_u->lax_p, u3i_chubs(2, bod_u->rec_d)); // if we don't know the lane, and the scry queue is full, // just drop the packet @@ -960,70 +916,182 @@ _ames_recv_cb(uv_udp_t* wax_u, // _ames_cap_queue. as such, blocked on u3_lord_peek_cancel or w/e. // if ( (u3_none == lac) && (1000 < sam_u->foq_d) ) { - c3_free(con_y); - sam_u->fod_d++; if ( 0 == (sam_u->fod_d % 10000) ) { u3l_log("ames: dropped %" PRIu64 " forwards total\n", sam_u->fod_d); } + + c3_free(hun_y); + return; } // if we know there's no lane, drop the packet // else if ( u3_nul == lac ) { - c3_free(con_y); - u3z(lac); + c3_free(hun_y); + return; } - // otherwise, proceed with forwarding + } + + // proceed with forwarding + // + { + // store the packet details for later processing + // + // XX allocates unnecessarily when we know the lane + // + u3_panc* pac_u = c3_calloc(sizeof(*pac_u)); + pac_u->sam_u = sam_u; + pac_u->hed_u = *hed_u; + pac_u->bod_u = *bod_u; + pac_u->ore_u = *lan_u; + pac_u->ptr_v = hun_y; + + if ( 0 != sam_u->pac_u ) { + pac_u->nex_u = sam_u->pac_u; + sam_u->pac_u->pre_u = pac_u; + } + sam_u->pac_u = pac_u; + + // if we already know the lane, just forward + // + if ( u3_none != lac ) { + _ames_forward(pac_u, lac); + } + // otherwise, there's space in the scry queue; scry the lane out of ames // else { - // store the packet details for later processing - // - u3_panc* pac_u = c3_calloc(sizeof(*pac_u)); - pac_u->sam_u = sam_u; - pac_u->hed_u = hed_u; - pac_u->bod_u.sen_d[0] = sen_d[0]; - pac_u->bod_u.sen_d[1] = sen_d[1]; - pac_u->bod_u.rec_d[0] = rec_d[0]; - pac_u->bod_u.rec_d[1] = rec_d[1]; - pac_u->bod_u.con_w = con_w; - pac_u->bod_u.con_y = con_y; - pac_u->ore_u = _ames_lane_from_sockaddr((struct sockaddr_in *)adr_u); + sam_u->foq_d++; + u3_noun pax = u3nq(u3i_string("peers"), + u3dc("scot", 'p', u3i_chubs(2, bod_u->rec_d)), + u3i_string("forward-lane"), + u3_nul); + u3_pier_peek_last(sam_u->pir_u, u3_nul, c3__ax, + u3_nul, pax, pac_u, _ames_lane_scry_cb); + } + } +} - if ( 0 != sam_u->pac_u ) { - pac_u->nex_u = sam_u->pac_u; - sam_u->pac_u->pre_u = pac_u; - } - sam_u->pac_u = pac_u; +/* _ames_hear(): parse a (potential packet), dispatch appropriately. +*/ +static void +_ames_hear(u3_ames* sam_u, + u3_lane* lan_u, + c3_w len_w, + c3_y* hun_y) +{ + u3_head hed_u; + u3_body bod_u; - // if we already know the lane, just forward - // - if ( u3_none != lac ) { - _ames_forward(pac_u, lac); + // unpack header, ensuring buffer is large enough + // + if ( (4 > len_w) + || (c3n == _ames_sift_head(&hed_u, hun_y)) ) + { + // XX track stats + // + c3_free(hun_y); + return; + } + + // ensure the protocol version matches ours + // + // XX rethink + // + if ( (c3y == sam_u->fit_o) + && (sam_u->ver_y != hed_u.ver_y) ) + { + sam_u->vet_d++; + if ( 0 == (sam_u->vet_d % 100) ) { + u3l_log("ames: %" PRIu64 " dropped for version mismatch\n", sam_u->vet_d); + } + + c3_free(hun_y); + return; + } + + { + c3_w bod_w = len_w - 4; + c3_y* bod_y = hun_y + 4; + + // ensure the mug is valid + // + if ( _ames_mug_body(bod_w, bod_y) != hed_u.mug_l ) { + sam_u->mut_d++; + if ( 0 == (sam_u->mut_d % 100) ) { + u3l_log("ames: %" PRIu64 " dropped for invalid mug\n", sam_u->mut_d); } - // otherwise, there's space in the scry queue; scry the lane out of ames + + c3_free(hun_y); + return; + } + + // unpack and validate the body + // + if ( (c3n == _ames_sift_body(&hed_u, &bod_u, bod_w, bod_y)) + || !ur_cue_test_with(sam_u->tes_u, bod_u.con_w, bod_u.con_y) ) + { + // XX track stats // - else { - sam_u->foq_d++; - u3_noun pax = u3nq(u3i_string("peers"), - u3dc("scot", 'p', u3i_chubs(2, rec_d)), - u3i_string("forward-lane"), - u3_nul); - u3_pier_peek_last(sam_u->pir_u, u3_nul, c3__ax, - u3_nul, pax, pac_u, _ames_lane_scry_cb); - } + c3_free(hun_y); + return; } } - // if we passed the filter, inject the packet + // if we can scry, + // and we are not the recipient, + // we might want to forward statelessly // - if ( c3y == pas_o ) { - c3_free(con_y); - u3_lane ore_u = _ames_lane_from_sockaddr((struct sockaddr_in *)adr_u); - u3_noun msg = u3i_bytes((c3_w)nrd_i, (c3_y*)buf_u->base); - _ames_put_packet(sam_u, msg, ore_u); + if ( (c3y == sam_u->see_o) + && ( (bod_u.rec_d[0] != sam_u->pir_u->who_d[0]) + || (bod_u.rec_d[1] != sam_u->pir_u->who_d[1]) ) ) + { + _ames_try_forward(sam_u, lan_u, &hed_u, &bod_u, hun_y); } + // otherwise, inject the packet as an event + // + else { + u3_noun msg = u3i_bytes(len_w, hun_y); + c3_free(hun_y); + _ames_put_packet(sam_u, msg, *lan_u); + } +} - c3_free(buf_u->base); +/* _ames_recv_cb(): udp message receive callback. +*/ +static void +_ames_recv_cb(uv_udp_t* wax_u, + ssize_t nrd_i, + const uv_buf_t * buf_u, + const struct sockaddr* adr_u, + unsigned flg_i) +{ + if ( 0 > nrd_i ) { + if ( u3C.wag_w & u3o_verbose ) { + u3l_log("ames: recv: fail: %s\n", uv_strerror(nrd_i)); + } + c3_free(buf_u->base); + } + else if ( 0 == nrd_i ) { + c3_free(buf_u->base); + } + else if ( flg_i & UV_UDP_PARTIAL ) { + if ( u3C.wag_w & u3o_verbose ) { + u3l_log("ames: recv: fail: message truncated\n"); + } + c3_free(buf_u->base); + } + else { + u3_ames* sam_u = wax_u->data; + struct sockaddr_in* add_u = (struct sockaddr_in*)adr_u; + u3_lane lan_u; + + lan_u.por_s = ntohs(add_u->sin_port); + lan_u.pip_w = ntohl(add_u->sin_addr.s_addr); + + // NB: [nrd_i] will never exceed max length from _ames_alloc() + // + _ames_hear(sam_u, &lan_u, (c3_w)nrd_i, (c3_y*)buf_u->base); + } } /* _ames_io_start(): initialize ames I/O. From 0ff8a28ca57e8ea00c8fc786aa091628926b765b Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 20 Oct 2020 11:40:27 -0700 Subject: [PATCH 504/933] vere: refactors ames' galaxy address resolution --- pkg/urbit/vere/io/ames.c | 294 +++++++++++++++++++++------------------ 1 file changed, 157 insertions(+), 137 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index c40b435ef5..614a5bd2de 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -14,12 +14,11 @@ #include "vere/vere.h" #include "ur/serial.h" -/* u3_pact: ames packet, coming or going. +/* u3_pact: outbound ames packet. */ typedef struct _u3_pact { uv_udp_send_t snd_u; // udp send request - c3_w pip_w; // target IPv4 address - c3_s por_s; // target port + u3_lane lan_u; // destination lane c3_w len_w; // length in bytes c3_y* hun_y; // packet buffer c3_y imp_y; // galaxy number (optional) @@ -341,8 +340,8 @@ _ames_send(u3_pact* pac_u) memset(&add_u, 0, sizeof(add_u)); add_u.sin_family = AF_INET; - add_u.sin_addr.s_addr = htonl(pac_u->pip_w); - add_u.sin_port = htons(pac_u->por_s); + add_u.sin_addr.s_addr = htonl(pac_u->lan_u.pip_w); + add_u.sin_port = htons(pac_u->lan_u.por_s); { uv_buf_t buf_u = uv_buf_init((c3_c*)pac_u->hun_y, pac_u->len_w); @@ -364,95 +363,6 @@ _ames_send(u3_pact* pac_u) } } -/* _ames_czar_port(): udp port for galaxy. -*/ -static c3_s -_ames_czar_port(c3_y imp_y) -{ - if ( c3n == u3_Host.ops_u.net ) { - return 31337 + imp_y; - } - else { - return 13337 + imp_y; - } -} - -/* _ames_czar_gone(): galaxy address resolution failed. -*/ -static void -_ames_czar_gone(u3_pact* pac_u, time_t now) -{ - u3_ames* sam_u = pac_u->sam_u; - - if ( c3y == sam_u->imp_o[pac_u->imp_y] ) { - u3l_log("ames: czar at %s: not found (b)\n", pac_u->dns_c); - sam_u->imp_o[pac_u->imp_y] = c3n; - } - - if ( (0 == sam_u->imp_w[pac_u->imp_y]) || - (0xffffffff == sam_u->imp_w[pac_u->imp_y]) ) - { - sam_u->imp_w[pac_u->imp_y] = 0xffffffff; - } - - // keep existing ip for 5 more minutes - // - sam_u->imp_t[pac_u->imp_y] = now; - - _ames_pact_free(pac_u); -} - -/* _ames_czar_cb(): galaxy address resolution callback. -*/ -static void -_ames_czar_cb(uv_getaddrinfo_t* adr_u, - c3_i sas_i, - struct addrinfo* aif_u) -{ - u3_pact* pac_u = (u3_pact*)adr_u->data; - u3_ames* sam_u = pac_u->sam_u; - time_t now = time(0); - - struct addrinfo* rai_u = aif_u; - - while ( 1 ) { - if ( !rai_u ) { - _ames_czar_gone(pac_u, now); - break; - } - - if ( (AF_INET == rai_u->ai_family) ) { - struct sockaddr_in* add_u = (struct sockaddr_in *)rai_u->ai_addr; - c3_w old_w = sam_u->imp_w[pac_u->imp_y]; - - sam_u->imp_w[pac_u->imp_y] = ntohl(add_u->sin_addr.s_addr); - sam_u->imp_t[pac_u->imp_y] = now; - sam_u->imp_o[pac_u->imp_y] = c3y; - -#if 1 - if ( sam_u->imp_w[pac_u->imp_y] != old_w - && sam_u->imp_w[pac_u->imp_y] != 0xffffffff ) { - u3_noun wad = u3i_words(1, &sam_u->imp_w[pac_u->imp_y]); - u3_noun nam = u3dc("scot", c3__if, wad); - c3_c* nam_c = u3r_string(nam); - - u3l_log("ames: czar %s: ip %s\n", pac_u->dns_c, nam_c); - - c3_free(nam_c); u3z(nam); - } -#endif - - _ames_send(pac_u); - break; - } - - rai_u = rai_u->ai_next; - } - - c3_free(adr_u); - uv_freeaddrinfo(aif_u); -} - /* u3_ames_decode_lane(): deserialize noun to lane */ u3_lane @@ -594,24 +504,120 @@ _ames_serialize_packet(u3_panc* pac_u, c3_o dop_o) } } -/* _ames_czar(): galaxy address resolution. +/* _ames_czar_port(): udp port for galaxy. +*/ +static c3_s +_ames_czar_port(c3_y imp_y) +{ + if ( c3n == u3_Host.ops_u.net ) { + return 31337 + imp_y; + } + else { + return 13337 + imp_y; + } +} + +/* _ames_czar_gone(): galaxy address resolution failed. */ static void -_ames_czar(u3_pact* pac_u, c3_c* bos_c) +_ames_czar_gone(u3_pact* pac_u, time_t now) { u3_ames* sam_u = pac_u->sam_u; - pac_u->por_s = _ames_czar_port(pac_u->imp_y); + if ( c3y == sam_u->imp_o[pac_u->imp_y] ) { + u3l_log("ames: czar at %s: not found (b)\n", pac_u->dns_c); + sam_u->imp_o[pac_u->imp_y] = c3n; + } + + if ( (0 == sam_u->imp_w[pac_u->imp_y]) || + (0xffffffff == sam_u->imp_w[pac_u->imp_y]) ) + { + sam_u->imp_w[pac_u->imp_y] = 0xffffffff; + } + + // keep existing ip for 5 more minutes + // + sam_u->imp_t[pac_u->imp_y] = now; + + _ames_pact_free(pac_u); +} + +/* _ames_czar_here(): galaxy address resolution succeeded. +*/ +static void +_ames_czar_here(u3_pact* pac_u, time_t now, struct sockaddr_in* add_u) +{ + u3_ames* sam_u = pac_u->sam_u; + c3_w old_w = sam_u->imp_w[pac_u->imp_y]; + c3_w pip_w = ntohl(add_u->sin_addr.s_addr); + + if ( pip_w != old_w ) { + u3_noun nam = u3dc("scot", c3__if, u3i_word(pip_w)); + c3_c* nam_c = u3r_string(nam); + + u3l_log("ames: czar %s: ip %s\n", pac_u->dns_c, nam_c); + + c3_free(nam_c); + u3z(nam); + } + + sam_u->imp_w[pac_u->imp_y] = pip_w; + sam_u->imp_t[pac_u->imp_y] = now; + sam_u->imp_o[pac_u->imp_y] = c3y; + + pac_u->lan_u.pip_w = pip_w; + _ames_send(pac_u); +} + +/* _ames_czar_cb(): galaxy address resolution callback. +*/ +static void +_ames_czar_cb(uv_getaddrinfo_t* adr_u, + c3_i sas_i, + struct addrinfo* aif_u) +{ + { + u3_pact* pac_u = (u3_pact*)adr_u->data; + struct addrinfo* rai_u = aif_u; + time_t now = time(0); + + while ( rai_u ) { + if ( (AF_INET == rai_u->ai_family) ) { + _ames_czar_here(pac_u, now, (struct sockaddr_in *)rai_u->ai_addr); + break; + } + else { + rai_u = rai_u->ai_next; + } + } + + if ( !rai_u ) { + _ames_czar_gone(pac_u, now); + } + } + + c3_free(adr_u); + uv_freeaddrinfo(aif_u); +} + +/* _ames_czar(): galaxy address resolution. +*/ +static void +_ames_czar(u3_pact* pac_u) +{ + u3_ames* sam_u = pac_u->sam_u; + + pac_u->lan_u.por_s = _ames_czar_port(pac_u->imp_y); if ( c3n == u3_Host.ops_u.net ) { - pac_u->pip_w = 0x7f000001; + pac_u->lan_u.pip_w = 0x7f000001; _ames_send(pac_u); return; } // if we don't have a galaxy domain, no-op // - if ( 0 == bos_c ) { + if ( !sam_u->dns_c ) { u3_noun nam = u3dc("scot", 'p', pac_u->imp_y); c3_c* nam_c = u3r_string(nam); u3l_log("ames: no galaxy domain for %s, no-op\r\n", nam_c); @@ -621,48 +627,64 @@ _ames_czar(u3_pact* pac_u, c3_c* bos_c) return; } - time_t now = time(0); - - // backoff - if ( (0xffffffff == sam_u->imp_w[pac_u->imp_y]) && - (now - sam_u->imp_t[pac_u->imp_y]) < 300 ) { - _ames_pact_free(pac_u); - return; - } - - if ( (0 == sam_u->imp_w[pac_u->imp_y]) || - (now - sam_u->imp_t[pac_u->imp_y]) > 300 ) { /* 5 minute TTL */ - u3_noun nam = u3dc("scot", 'p', pac_u->imp_y); - c3_c* nam_c = u3r_string(nam); - // XX remove extra byte for '~' - pac_u->dns_c = c3_malloc(1 + strlen(bos_c) + 1 + strlen(nam_c)); - - snprintf(pac_u->dns_c, 256, "%s.%s", nam_c + 1, bos_c); - // u3l_log("czar %s, dns %s\n", nam_c, pac_u->dns_c); - - c3_free(nam_c); - u3z(nam); + { + c3_w pip_w = sam_u->imp_w[pac_u->imp_y]; + time_t wen = sam_u->imp_t[pac_u->imp_y]; + time_t now = time(0); + // backoff for 5 minutes after failed lookup + // + if ( ( now < wen ) // time shenanigans! + || ( (0xffffffff == pip_w) // sentinal ip address + && ((now - wen) < 300) ) ) { - uv_getaddrinfo_t* adr_u = c3_malloc(sizeof(*adr_u)); - adr_u->data = pac_u; - + _ames_pact_free(pac_u); + return; + } + // cached addresses have a 5 minute TTL + // + else if ( (0 != pip_w) && ((now - wen) < 300) ) { + pac_u->lan_u.pip_w = pip_w; + _ames_send(pac_u); + return; + } + else { c3_i sas_i; - if ( 0 != (sas_i = uv_getaddrinfo(u3L, adr_u, - _ames_czar_cb, - pac_u->dns_c, 0, 0)) ) { - u3l_log("ames: %s\n", uv_strerror(sas_i)); - _ames_czar_gone(pac_u, now); + { + u3_noun nam = u3dc("scot", 'p', pac_u->imp_y); + c3_c* nam_c = u3r_string(nam); + + // NB: . separator not counted, as [nam_c] includes a ~ that we skip + // + pac_u->dns_c = c3_malloc(1 + strlen(nam_c) + strlen(sam_u->dns_c)); + sas_i = snprintf(pac_u->dns_c, 255, "%s.%s", nam_c + 1, sam_u->dns_c); + + c3_free(nam_c); + u3z(nam); + } + + if ( 0 != sas_i ) { + u3l_log("ames: czar: galaxy domain %s truncated\n", sam_u->dns_c); + _ames_pact_free(pac_u); return; } + + { + uv_getaddrinfo_t* adr_u = c3_malloc(sizeof(*adr_u)); + adr_u->data = pac_u; + + if ( 0 != (sas_i = uv_getaddrinfo(u3L, adr_u, + _ames_czar_cb, + pac_u->dns_c, 0, 0)) ) + { + u3l_log("ames: %s\n", uv_strerror(sas_i)); + _ames_czar_gone(pac_u, now); + return; + } + } } } - else { - pac_u->pip_w = sam_u->imp_w[pac_u->imp_y]; - _ames_send(pac_u); - return; - } } /* _ames_ef_send(): send packet to network (v4). @@ -694,7 +716,7 @@ _ames_ef_send(u3_ames* sam_u, u3_noun lan, u3_noun pac) c3_assert( val < 256 ); pac_u->imp_y = val; - _ames_czar(pac_u, sam_u->dns_c); + _ames_czar(pac_u); } // non-galaxy lane // @@ -711,9 +733,7 @@ _ames_ef_send(u3_ames* sam_u, u3_noun lan, u3_noun pac) // otherwise, mutate destination and send packet // else { - pac_u->pip_w = lan_u.pip_w; - pac_u->por_s = lan_u.por_s; - + pac_u->lan_u = lan_u; _ames_send(pac_u); } } From 0e03bea08dfce86d17f7efa717bd8282cd024ae1 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 20 Oct 2020 12:08:36 -0700 Subject: [PATCH 505/933] vere: groups counters and config in ames' state structure --- pkg/urbit/vere/io/ames.c | 143 ++++++++++++++++++++------------------- 1 file changed, 73 insertions(+), 70 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 614a5bd2de..5134e537d7 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -31,30 +31,34 @@ typedef struct _u3_ames { // packet network state u3_auto car_u; // driver u3_pier* pir_u; // pier - union { // + union { // uv udp handle uv_udp_t wax_u; // uv_handle_t had_u; // }; // ur_cue_test_t* tes_u; // cue-test handle u3_cue_xeno* sil_u; // cue handle c3_c* dns_c; // domain XX multiple/fallback - c3_d dop_d; // drop count - c3_d fal_d; // crash count + c3_y ver_y; // protocol version + u3p(u3h_root) lax_p; // lane scry cache + struct _u3_panc* pac_u; // packets pending forwards c3_w imp_w[256]; // imperial IPs time_t imp_t[256]; // imperial IP timestamps c3_o imp_o[256]; // imperial print status - c3_o net_o; // can send - c3_o see_o; // can scry - c3_d saw_d; // successive scry failures - c3_o fit_o; // filtering active - c3_y ver_y; // protocol version - u3p(u3h_root) lax_p; // lane scry cache - c3_d vet_d; // version mismatches filtered - c3_d mut_d; // invalid mugs filtered - struct _u3_panc* pac_u; // packets pending forwards - c3_d foq_d; // forward queue size - c3_d fow_d; // forwarded count - c3_d fod_d; // forwards dropped count + struct { // config: + c3_o net_o; // can send + c3_o see_o; // can scry + c3_o fit_o; // filtering active + } fig_u; // + struct { // stats: + c3_d dop_d; // drop count + c3_d fal_d; // crash count + c3_d saw_d; // successive scry failures + c3_d vet_d; // version mismatches filtered + c3_d mut_d; // invalid mugs filtered + c3_d foq_d; // forward queue size + c3_d fow_d; // forwarded count + c3_d fod_d; // forwards dropped count + } sat_u; // } u3_ames; /* u3_head: ames packet header @@ -313,12 +317,12 @@ _ames_send_cb(uv_udp_send_t* req_u, c3_i sas_i) u3_pact* pac_u = (u3_pact*)req_u; u3_ames* sam_u = pac_u->sam_u; - if ( sas_i && (c3y == sam_u->net_o) ) { + if ( sas_i && (c3y == sam_u->fig_u.net_o) ) { u3l_log("ames: send fail: %s\n", uv_strerror(sas_i)); - sam_u->net_o = c3n; + sam_u->fig_u.net_o = c3n; } else { - sam_u->net_o = c3y; + sam_u->fig_u.net_o = c3y; } _ames_pact_free(pac_u); @@ -352,9 +356,9 @@ _ames_send(u3_pact* pac_u) _ames_send_cb); if ( sas_i ) { - if ( c3y == sam_u->net_o ) { + if ( c3y == sam_u->fig_u.net_o ) { u3l_log("ames: send fail: %s\n", uv_strerror(sas_i)); - sam_u->net_o = c3n; + sam_u->fig_u.net_o = c3n; } _ames_pact_free(pac_u); @@ -752,20 +756,20 @@ _ames_cap_queue(u3_ames* sam_u) if ( c3__hear == u3h(egg_u->cad) ) { u3_auto_drop(&sam_u->car_u, egg_u); - sam_u->dop_d++; + sam_u->sat_u.dop_d++; if ( u3C.wag_w & u3o_verbose ) { - u3l_log("ames: packet dropped (%" PRIu64 " total)\n", sam_u->dop_d); + u3l_log("ames: packet dropped (%" PRIu64 " total)\n", sam_u->sat_u.dop_d); } } egg_u = nex_u; } - if ( (sam_u->dop_d && (0 == (sam_u->dop_d % 1000))) + if ( (sam_u->sat_u.dop_d && (0 == (sam_u->sat_u.dop_d % 1000))) && !(u3C.wag_w & u3o_verbose) ) { - u3l_log("ames: packet dropped (%" PRIu64 " total)\n", sam_u->dop_d); + u3l_log("ames: packet dropped (%" PRIu64 " total)\n", sam_u->sat_u.dop_d); } } @@ -798,19 +802,19 @@ static void _ames_hear_bail(u3_ovum* egg_u, u3_noun lud) { u3_ames* sam_u = (u3_ames*)egg_u->car_u; - sam_u->fal_d++; + sam_u->sat_u.fal_d++; if ( (u3C.wag_w & u3o_verbose) - || (0 == (sam_u->fal_d % 1000)) ) + || (0 == (sam_u->sat_u.fal_d % 1000)) ) { _ames_punt_goof(lud); - u3l_log("ames: packet failed (%" PRIu64 " total)\n\n", sam_u->fal_d); + u3l_log("ames: packet failed (%" PRIu64 " total)\n\n", sam_u->sat_u.fal_d); } else { u3z(lud); - if ( 0 == (sam_u->fal_d % 1000) ) { - u3l_log("ames: packet failed (%" PRIu64 " total)\n\n", sam_u->fal_d); + if ( 0 == (sam_u->sat_u.fal_d % 1000) ) { + u3l_log("ames: packet failed (%" PRIu64 " total)\n\n", sam_u->sat_u.fal_d); } } @@ -840,16 +844,18 @@ _ames_put_packet(u3_ames* sam_u, static void _ames_forward(u3_panc* pac_u, u3_noun las) { - pac_u->sam_u->fow_d++; - if ( 0 == (pac_u->sam_u->fow_d % 1000000) ) { - u3l_log("ames: forwarded %" PRIu64 " total\n", pac_u->sam_u->fow_d); + u3_ames* sam_u = pac_u->sam_u; + + sam_u->sat_u.fow_d++; + if ( 0 == (sam_u->sat_u.fow_d % 1000000) ) { + u3l_log("ames: forwarded %" PRIu64 " total\n", sam_u->sat_u.fow_d); } { u3_noun los = las; u3_noun pac = _ames_serialize_packet(pac_u, c3y); while ( u3_nul != las ) { - _ames_ef_send(pac_u->sam_u, u3k(u3h(las)), u3k(pac)); + _ames_ef_send(sam_u, u3k(u3h(las)), u3k(pac)); las = u3t(las); } u3z(los); u3z(pac); @@ -864,28 +870,27 @@ static void _ames_lane_scry_cb(void* vod_p, u3_noun nun) { u3_panc* pac_u = vod_p; - u3_weak las = u3r_at(7, nun); + u3_ames* sam_u = pac_u->sam_u; + u3_weak las = u3r_at(7, nun); - pac_u->sam_u->foq_d--; + sam_u->sat_u.foq_d--; // if scry fails, remember we can't scry, and just inject the packet // if ( u3_none == las ) { - if ( 5 < ++pac_u->sam_u->saw_d ) { + if ( 5 < ++sam_u->sat_u.saw_d ) { u3l_log("ames: giving up scry\n"); - pac_u->sam_u->see_o = c3n; + sam_u->fig_u.see_o = c3n; } - _ames_put_packet(pac_u->sam_u, - _ames_serialize_packet(pac_u, c3n), - pac_u->ore_u); + _ames_put_packet(sam_u, _ames_serialize_packet(pac_u, c3n), pac_u->ore_u); _ames_panc_free(pac_u); } else { - pac_u->sam_u->saw_d = 0; + sam_u->sat_u.saw_d = 0; // cache the scry result for later use // - _ames_lane_into_cache(pac_u->sam_u->lax_p, + _ames_lane_into_cache(sam_u->lax_p, u3i_chubs(2, pac_u->bod_u.rec_d), u3k(las)); @@ -935,10 +940,10 @@ _ames_try_forward(u3_ames* sam_u, // so can't pluck these out of the event queue like it does in // _ames_cap_queue. as such, blocked on u3_lord_peek_cancel or w/e. // - if ( (u3_none == lac) && (1000 < sam_u->foq_d) ) { - sam_u->fod_d++; - if ( 0 == (sam_u->fod_d % 10000) ) { - u3l_log("ames: dropped %" PRIu64 " forwards total\n", sam_u->fod_d); + if ( (u3_none == lac) && (1000 < sam_u->sat_u.foq_d) ) { + sam_u->sat_u.fod_d++; + if ( 0 == (sam_u->sat_u.fod_d % 10000) ) { + u3l_log("ames: dropped %" PRIu64 " forwards total\n", sam_u->sat_u.fod_d); } c3_free(hun_y); @@ -980,7 +985,7 @@ _ames_try_forward(u3_ames* sam_u, // otherwise, there's space in the scry queue; scry the lane out of ames // else { - sam_u->foq_d++; + sam_u->sat_u.foq_d++; u3_noun pax = u3nq(u3i_string("peers"), u3dc("scot", 'p', u3i_chubs(2, bod_u->rec_d)), u3i_string("forward-lane"), @@ -1017,12 +1022,12 @@ _ames_hear(u3_ames* sam_u, // // XX rethink // - if ( (c3y == sam_u->fit_o) + if ( (c3y == sam_u->fig_u.fit_o) && (sam_u->ver_y != hed_u.ver_y) ) { - sam_u->vet_d++; - if ( 0 == (sam_u->vet_d % 100) ) { - u3l_log("ames: %" PRIu64 " dropped for version mismatch\n", sam_u->vet_d); + sam_u->sat_u.vet_d++; + if ( 0 == (sam_u->sat_u.vet_d % 100) ) { + u3l_log("ames: %" PRIu64 " dropped for version mismatch\n", sam_u->sat_u.vet_d); } c3_free(hun_y); @@ -1036,9 +1041,9 @@ _ames_hear(u3_ames* sam_u, // ensure the mug is valid // if ( _ames_mug_body(bod_w, bod_y) != hed_u.mug_l ) { - sam_u->mut_d++; - if ( 0 == (sam_u->mut_d % 100) ) { - u3l_log("ames: %" PRIu64 " dropped for invalid mug\n", sam_u->mut_d); + sam_u->sat_u.mut_d++; + if ( 0 == (sam_u->sat_u.mut_d % 100) ) { + u3l_log("ames: %" PRIu64 " dropped for invalid mug\n", sam_u->sat_u.mut_d); } c3_free(hun_y); @@ -1061,7 +1066,7 @@ _ames_hear(u3_ames* sam_u, // and we are not the recipient, // we might want to forward statelessly // - if ( (c3y == sam_u->see_o) + if ( (c3y == sam_u->fig_u.see_o) && ( (bod_u.rec_d[0] != sam_u->pir_u->who_d[0]) || (bod_u.rec_d[1] != sam_u->pir_u->who_d[1]) ) ) { @@ -1222,7 +1227,7 @@ static void _ames_prot_scry_cb(void* vod_p, u3_noun nun) { u3_ames* sam_u = vod_p; - u3_weak ver = u3r_at(7, nun); + u3_weak ver = u3r_at(7, nun); if ( u3_none == ver ) { // assume protocol version 0 @@ -1238,7 +1243,7 @@ _ames_prot_scry_cb(void* vod_p, u3_noun nun) sam_u->ver_y = ver; } - sam_u->fit_o = c3y; + sam_u->fig_u.fit_o = c3y; u3z(nun); } @@ -1387,14 +1392,14 @@ static void _ames_io_info(u3_auto* car_u) { u3_ames* sam_u = (u3_ames*)car_u; - u3l_log(" dropped: %" PRIu64 "\n", sam_u->dop_d); - u3l_log(" forwards dropped: %" PRIu64 "\n", sam_u->fod_d); - u3l_log(" forwards pending: %" PRIu64 "\n", sam_u->foq_d); - u3l_log(" forwarded: %" PRIu64 "\n", sam_u->fow_d); - u3l_log(" filtered (ver): %" PRIu64 "\n", sam_u->vet_d); - u3l_log(" filtered (mug): %" PRIu64 "\n", sam_u->mut_d); - u3l_log(" crashed: %" PRIu64 "\n", sam_u->fal_d); - u3l_log(" cached lanes: %u\n", u3to(u3h_root, sam_u->lax_p)->use_w); + u3l_log(" dropped: %" PRIu64 "\n", sam_u->sat_u.dop_d); + u3l_log(" forwards dropped: %" PRIu64 "\n", sam_u->sat_u.fod_d); + u3l_log(" forwards pending: %" PRIu64 "\n", sam_u->sat_u.foq_d); + u3l_log(" forwarded: %" PRIu64 "\n", sam_u->sat_u.fow_d); + u3l_log(" filtered (ver): %" PRIu64 "\n", sam_u->sat_u.vet_d); + u3l_log(" filtered (mug): %" PRIu64 "\n", sam_u->sat_u.mut_d); + u3l_log(" crashed: %" PRIu64 "\n", sam_u->sat_u.fal_d); + u3l_log(" cached lanes: %u\n", u3h_wyt(sam_u->lax_p)); } /* u3_ames_io_init(): initialize ames I/O. @@ -1404,11 +1409,9 @@ u3_ames_io_init(u3_pier* pir_u) { u3_ames* sam_u = c3_calloc(sizeof(*sam_u)); sam_u->pir_u = pir_u; - sam_u->dop_d = 0; - sam_u->net_o = c3y; - sam_u->see_o = c3y; - sam_u->fit_o = c3n; - sam_u->foq_d = 0; + sam_u->fig_u.net_o = c3y; + sam_u->fig_u.see_o = c3y; + sam_u->fig_u.fit_o = c3n; //NOTE some numbers on memory usage for the lane cache // From 7b4e48deb7d892379b8d49896ed4675649d0ee31 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 20 Oct 2020 15:30:41 -0700 Subject: [PATCH 506/933] vere: updates ames' info handler to also print config --- pkg/urbit/vere/io/ames.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 5134e537d7..d8e47987e8 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -1392,14 +1392,22 @@ static void _ames_io_info(u3_auto* car_u) { u3_ames* sam_u = (u3_ames*)car_u; - u3l_log(" dropped: %" PRIu64 "\n", sam_u->sat_u.dop_d); - u3l_log(" forwards dropped: %" PRIu64 "\n", sam_u->sat_u.fod_d); - u3l_log(" forwards pending: %" PRIu64 "\n", sam_u->sat_u.foq_d); - u3l_log(" forwarded: %" PRIu64 "\n", sam_u->sat_u.fow_d); - u3l_log(" filtered (ver): %" PRIu64 "\n", sam_u->sat_u.vet_d); - u3l_log(" filtered (mug): %" PRIu64 "\n", sam_u->sat_u.mut_d); - u3l_log(" crashed: %" PRIu64 "\n", sam_u->sat_u.fal_d); - u3l_log(" cached lanes: %u\n", u3h_wyt(sam_u->lax_p)); + +# define FLAG(a) ( (c3y == a) ? "&" : "|" ) + + u3l_log(" config:\n"); + u3l_log(" filtering: %s\n", FLAG(sam_u->fig_u.fit_o)); + u3l_log(" can send: %s\n", FLAG(sam_u->fig_u.net_o)); + u3l_log(" can scry: %s\n", FLAG(sam_u->fig_u.see_o)); + u3l_log(" counters:\n"); + u3l_log(" dropped: %" PRIu64 "\n", sam_u->sat_u.dop_d); + u3l_log(" forwards dropped: %" PRIu64 "\n", sam_u->sat_u.fod_d); + u3l_log(" forwards pending: %" PRIu64 "\n", sam_u->sat_u.foq_d); + u3l_log(" forwarded: %" PRIu64 "\n", sam_u->sat_u.fow_d); + u3l_log(" filtered (ver): %" PRIu64 "\n", sam_u->sat_u.vet_d); + u3l_log(" filtered (mug): %" PRIu64 "\n", sam_u->sat_u.mut_d); + u3l_log(" crashed: %" PRIu64 "\n", sam_u->sat_u.fal_d); + u3l_log(" cached lanes: %u\n", u3h_wyt(sam_u->lax_p)); } /* u3_ames_io_init(): initialize ames I/O. From 67f06ce5e5dbd7912ba8a6b9055c2dc28614a411 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 20 Oct 2020 15:44:58 -0700 Subject: [PATCH 507/933] vere: adds comments discussing protocol-version constraints --- pkg/urbit/vere/io/ames.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index d8e47987e8..1634694393 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -1007,6 +1007,19 @@ _ames_hear(u3_ames* sam_u, u3_head hed_u; u3_body bod_u; + // XX packet filtering needs to revised for two protocol-change scenarios + // + // - packets using old protocol versions from our sponsees + // these must be let through, and this is a transitive condition; + // they must also be forwarded where appropriate + // they can be validated, as we know their semantics + // + // - packets using newer protocol versions + // these should probably be let through, or at least + // trigger printfs suggesting upgrade. + // they cannot be filtered, as we do not know their semantics + // + // unpack header, ensuring buffer is large enough // if ( (4 > len_w) @@ -1020,7 +1033,7 @@ _ames_hear(u3_ames* sam_u, // ensure the protocol version matches ours // - // XX rethink + // XX rethink use of [fit_o] here and elsewhere // if ( (c3y == sam_u->fig_u.fit_o) && (sam_u->ver_y != hed_u.ver_y) ) @@ -1243,6 +1256,9 @@ _ames_prot_scry_cb(void* vod_p, u3_noun nun) sam_u->ver_y = ver; } + // XX revise: filtering should probably be disabled if + // we get a protocol version above the latest one we know + // sam_u->fig_u.fit_o = c3y; u3z(nun); } From c8159b7fe882f7e26714e9fcb72a73a290ed2c2a Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Tue, 20 Oct 2020 16:42:20 -0700 Subject: [PATCH 508/933] king: multi-request support lol --- .../lib/Urbit/Vere/Eyre/KingSubsite.hs | 54 +++++++++++-------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/KingSubsite.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/KingSubsite.hs index 81159a44c5..6c987d77ca 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/KingSubsite.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/KingSubsite.hs @@ -27,8 +27,8 @@ data SlogAction = KeepAlive | Slog (Atom, Tank) -conduit :: SlogAction -> ConduitT () (Flush Builder) IO () -conduit a = do +streamSlog :: Monad m => SlogAction -> ConduitT () (Flush Builder) m () +streamSlog a = do case a of KeepAlive -> pure () Slog (_, t) -> for_ (wash (WashCfg 0 80) (tankTree t)) $ \l -> do @@ -42,30 +42,40 @@ kingSubsite :: HasLogFunc e => TVar ((Atom, Tank) -> IO ()) -> RAcquire e KingSubsite kingSubsite func = do - slogQ :: TQueue (Atom, Tank) <- newTQueueIO - baton :: TMVar () <- newEmptyTMVarIO - atomically $ writeTVar func (\s -> atomically $ writeTQueue slogQ s) + clients <- newTVarIO (mempty :: Map Word (SlogAction -> IO ())) + nextId <- newTVarIO (0 :: Word) + baton <- newTMVarIO () + + atomically $ writeTVar func $ \s -> readTVarIO clients >>= traverse_ ($ Slog s) + acquireWorker "Runtime subsite keep-alive" $ forever $ do - atomically $ putTMVar baton () threadDelay 20_000_000 - - let action = (KeepAlive <$ takeTMVar baton) -- every 20s - <|> (Slog <$> readTQueue slogQ) - --TODO queue builds even without listeners connected. - -- and with listeners connected, only one pops from queue! - -- need queue per connection, not global? - - let loop = yield Flush >> forever (atomically action >>= conduit) + io $ readTVarIO clients >>= traverse_ ($ KeepAlive) --TODO scry to verify cookie authentication - pure $ KS $ \req respond -> respond $ case W.pathInfo req of - ("~_~":"slog":_) -> W.responseSource (H.mkStatus 200 "OK") heads loop - _ -> W.responseLBS (H.mkStatus 404 "Not Found") [] "" - where - heads = [ ("Content-Type" , "text/event-stream") - , ("Cache-Control", "no-cache") - , ("Connection" , "keep-alive") - ] + pure $ KS $ \req respond -> case W.pathInfo req of + ("~_~":"slog":_) -> bracket + (do + id <- atomically $ do + id <- readTVar nextId + modifyTVar' nextId (+ 1) + pure id + slogQ <- newTQueueIO + atomically $ + modifyTVar' clients (insertMap id (atomically . writeTQueue slogQ)) + pure (id, slogQ)) + (\(id, _) -> atomically $ modifyTVar' clients (deleteMap id)) + (\(_, q) -> + let loop = yield Flush >> forever (atomically (readTQueue q) >>= streamSlog) + in respond $ W.responseSource (H.mkStatus 200 "OK") heads loop) + + _ -> respond $ W.responseLBS (H.mkStatus 404 "Not Found") [] "" + + where + heads = [ ("Content-Type" , "text/event-stream") + , ("Cache-Control", "no-cache") + , ("Connection" , "keep-alive") + ] fourOhFourSubsite :: Ship -> KingSubsite fourOhFourSubsite who = KS $ \req respond -> From fcd6968e8ec0ebdd3041a63532fe6bd53ff15a09 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 20 Oct 2020 17:14:52 -0700 Subject: [PATCH 509/933] vere: adds comment about re-checking ames' protocol version --- pkg/urbit/vere/io/ames.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 1634694393..bdc488afab 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -1282,6 +1282,10 @@ _ames_io_talk(u3_auto* car_u) // scry the protocol version out of arvo // + // XX this should be re-triggered periodically, + // or, better yet, %ames should emit a %turf + // (or some other reconfig) effect when it is reset. + // u3_pier_peek_last(car_u->pir_u, u3_nul, c3__ax, u3_nul, u3nt(u3i_string("protocol"), u3i_string("version"), u3_nul), sam_u, _ames_prot_scry_cb); From ca023b6db0ad4addce9efc2eb41c3ad44b302dc4 Mon Sep 17 00:00:00 2001 From: crides Date: Tue, 20 Oct 2020 15:07:11 -0500 Subject: [PATCH 510/933] hoon, dill: Add 24-bit true color This commit adds 24bit true color capabilities to `sole-effect` for those terminal supporting it (which most modern terminal does). It adds a RGB type squashed into `$tint`, which will get converted to escape sequences in `dill` for the moment. As Urbit does not do `termcap` detection, this also does not attempt that. But on terminals that doesn't support true color (e.g. linux console), the color would be truncated to the nearest achievable approximate. --- pkg/arvo/sys/hoon.hoon | 4 +++- pkg/arvo/sys/vane/dill.hoon | 37 +++++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 56651627f3..9de992fd0e 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -1972,7 +1972,9 @@ +$ tile :: XX: ?@(knot (pair styl knot)) :: cord -+$ tint ?($r $g $b $c $m $y $k $w $~) :: text color ++$ tint + $@ ?($r $g $b $c $m $y $k $w $~) :: text color + [r=@uxD g=@uxD b=@uxD] :: 24bit true color :: :: A `plum` is the intermediate representation for the pretty-printer. It :: encodes hoon-shaped data with the least amount of structured needed diff --git a/pkg/arvo/sys/vane/dill.hoon b/pkg/arvo/sys/vane/dill.hoon index 04f4d0353e..29849b6f18 100644 --- a/pkg/arvo/sys/vane/dill.hoon +++ b/pkg/arvo/sys/vane/dill.hoon @@ -211,7 +211,6 @@ (bg ~) (fg ~) == - :: ++ ef |=(a/^deco (scap (deco a))) :: ANSI effect :: ++ fg |=(a/^tint (scap (tint a))) :: ANSI foreground @@ -219,13 +218,13 @@ ++ bg :: ANSI background |= a/^tint %- scap - =>((tint a) [+(p) q]) :: (add 10 fg) + =>((tint a) [+(-) +]) :: (add 10 fg) :: ++ scap :: ANSI escape seq - |= a/$@(@ (pair @ @)) + |= a/$@(@ (list @)) %- (list @c) :+ 27 '[' :: "\033[{a}m" - ?@(a :~(a 'm') :~(p.a q.a 'm')) + ?@(a :~(a 'm') (snoc a 'm')) :: ++ deco :: ANSI effects |= a/^deco ^- @ @@ -238,19 +237,25 @@ :: ++ tint :: ANSI colors (fg) |= a/^tint - ^- (pair @ @) + ^- (list @) :- '3' - ?- a - $k '0' - $r '1' - $g '2' - $y '3' - $b '4' - $m '5' - $c '6' - $w '7' - ~ '9' - == + ?@ a + :_ ~ + ?- a + $k '0' + $r '1' + $g '2' + $y '3' + $b '4' + $m '5' + $c '6' + $w '7' + ~ '9' + == + =/ r (~(sit fe 3) r.a) + =/ g (~(sit fe 3) g.a) + =/ b (~(sit fe 3) b.a) + "8;2;{};{};{}" -- :: XX move :: From 04ab7b5eb6cdae6ff2377d318c8a4f349ed2e43d Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 21 Oct 2020 12:51:18 -0400 Subject: [PATCH 511/933] king: implement -I and --inject-event-list This makes it so during `run`, you can inject a series of Events into your Urbit. The `-I` injection was implemented in Vere, and has been ported to KH, with the extended `--inject-event-list` flag which handles a jammed list of events. Also included is a sample generator which builds a list of events. --- pkg/arvo/gen/configure-hosting.hoon | 12 ++++++++++ pkg/hs/urbit-king/TODO.md | 11 +++++---- pkg/hs/urbit-king/lib/Urbit/King/CLI.hs | 19 ++++++++++++++++ pkg/hs/urbit-king/lib/Urbit/King/Main.hs | 29 ++++++++++++++++++++---- pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs | 28 +++++++++++++++++++++-- 5 files changed, 87 insertions(+), 12 deletions(-) create mode 100644 pkg/arvo/gen/configure-hosting.hoon diff --git a/pkg/arvo/gen/configure-hosting.hoon b/pkg/arvo/gen/configure-hosting.hoon new file mode 100644 index 0000000000..ad9c4a7719 --- /dev/null +++ b/pkg/arvo/gen/configure-hosting.hoon @@ -0,0 +1,12 @@ +:: .configuration/pill +configure-hosting +:: +:: boot king haskell with `--inject-event-list /path/to/configuration.pill` +:: +:- %say +|= [[now=@da @ our=@p ^] *] +:- %noun +:~ [//term/1 %belt %txt "|unlink %chat-cli"] + [//term/1 %belt %ret 0] + [//term/1 %belt %txt "|cors-approve 'https://horizon.tlon.network'"] + [//term/1 %belt %ret 0] +== diff --git a/pkg/hs/urbit-king/TODO.md b/pkg/hs/urbit-king/TODO.md index d76f845308..2e3be71087 100644 --- a/pkg/hs/urbit-king/TODO.md +++ b/pkg/hs/urbit-king/TODO.md @@ -85,11 +85,12 @@ Implement Pier-wide process start events - [x] Handle %trim effect - [x] Inject entropy event on pier start: ``[//arvo [%wack ENT]]` - [ ] Verbose flag: `-v` injects `[%verb ~]` -- [ ] CLI event injection: `-I file-path`. The `file-path` is a jammed - noun representing an event: `[wire card]`. - 1. Just parse it as an `Ev` for now. - 2. Make the serf IPC code not care about the shape of events and effects. - 3. Support invalid events throughout the system (use `Lenient`?) + +- CLI event injection: `-I file-path`. The `file-path` is a jammed noun + representing an event: `[wire card]`. + - [x] Just parse it as an `Ev` for now. + - [ ] Make the serf IPC code not care about the shape of events and effects. + - [ ] Support invalid events throughout the system (use `Lenient`?) # Polish diff --git a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs index 1fa0c0f822..8d43a2214d 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs @@ -44,6 +44,7 @@ data Opts = Opts , oHttpPort :: Maybe Word16 , oHttpsPort :: Maybe Word16 , oLoopbackPort :: Maybe Word16 + , oInjectEvents :: [Injection] } deriving (Show) @@ -77,6 +78,11 @@ data Nat | NatNever deriving (Show) +data Injection + = InjectOneEvent FilePath + | InjectManyEvents FilePath + deriving (Show) + data New = New { nPillSource :: PillSource , nPierPath :: Maybe FilePath -- Derived from ship name if not specified. @@ -221,6 +227,17 @@ pillFromURL = PillSourceURL <$> strOption pierPath :: Parser FilePath pierPath = strArgument (metavar "PIER" <> help "Path to pier") +injectEvents :: Parser [Injection] +injectEvents = many (InjectOneEvent <$> strOption ( short 'I' + <> long "inject-event" + <> metavar "JAM" + <> help "Path to a jammed event") <|> + InjectManyEvents <$> strOption ( + long "inject-event-list" + <> metavar "JAM LIST" + <> help "Path to a jammed list of events" + )) + serfExe :: Parser (Maybe Text) serfExe = optional $ strOption @@ -306,6 +323,8 @@ opts = do <> help "Localhost-only HTTP port" <> hidden + oInjectEvents <- injectEvents + oHashless <- switch $ short 'S' <> long "hashless" <> help "Disable battery hashing (Ignored for now)" diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs index bba16c090c..f077987efa 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs @@ -190,7 +190,7 @@ tryBootFromPill tryBootFromPill oExit pill lite ship boot = do mStart <- newEmptyMVar vSlog <- logSlogs - runOrExitImmediately vSlog (bootedPier vSlog) oExit mStart + runOrExitImmediately vSlog (bootedPier vSlog) oExit mStart [] where bootedPier vSlog = do view pierPathL >>= lockFile @@ -204,8 +204,9 @@ runOrExitImmediately -> RAcquire PierEnv (Serf, Log.EventLog) -> Bool -> MVar () + -> [Ev] -> RIO PierEnv () -runOrExitImmediately vSlog getPier oExit mStart = do +runOrExitImmediately vSlog getPier oExit mStart injected = do rwith getPier (if oExit then shutdownImmediately else runPier) where shutdownImmediately :: (Serf, Log.EventLog) -> RIO PierEnv () @@ -216,18 +217,19 @@ runOrExitImmediately vSlog getPier oExit mStart = do runPier :: (Serf, Log.EventLog) -> RIO PierEnv () runPier serfLog = do - runRAcquire (Pier.pier serfLog vSlog mStart) + runRAcquire (Pier.pier serfLog vSlog mStart injected) tryPlayShip :: Bool -> Bool -> Maybe Word64 -> MVar () + -> [Ev] -> RIO PierEnv () -tryPlayShip exitImmediately fullReplay playFrom mStart = do +tryPlayShip exitImmediately fullReplay playFrom mStart injected = do when fullReplay wipeSnapshot vSlog <- logSlogs - runOrExitImmediately vSlog (resumeShip vSlog) exitImmediately mStart + runOrExitImmediately vSlog (resumeShip vSlog) exitImmediately mStart injected where wipeSnapshot = do shipPath <- view pierPathL @@ -586,11 +588,28 @@ runShip (CLI.Run pierPath) opts daemon = do where runPier :: MVar () -> RIO PierEnv () runPier mStart = do + injections <- loadInjections (CLI.oInjectEvents opts) tryPlayShip (CLI.oExit opts) (CLI.oFullReplay opts) (CLI.oDryFrom opts) mStart + injections + + loadInjections :: [CLI.Injection] -> RIO PierEnv [Ev] + loadInjections injections = do + perInjection :: [[Ev]] <- forM injections $ \case + CLI.InjectOneEvent filePath -> do + logInfo $ display $ "boot: reading injected event from " ++ + (pack filePath :: Text) + io (loadFile filePath >>= either throwIO (pure . singleton)) + + CLI.InjectManyEvents filePath -> do + logInfo $ display $ "boot: reading injected event list from " ++ + (pack filePath :: Text) + io (loadFile filePath >>= either throwIO pure) + pure $ concat perInjection + buildPortHandler :: HasLogFunc e => CLI.Nat -> RIO e PortControlApi diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs index 6e920685c4..12e75d26d8 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs @@ -183,7 +183,7 @@ bootNewShip pill lite ship bootEv = do let logPath = (pierPath ".urb/log") rwith (Log.new logPath ident) $ \log -> do - logInfo "Event log onitialized." + logInfo "Event log initialized." jobs <- (\now -> bootSeqJobs now seq) <$> io Time.now writeJobs log (fromList jobs) @@ -264,8 +264,9 @@ pier :: (Serf, EventLog) -> TVar ((Atom, Tank) -> IO ()) -> MVar () + -> [Ev] -> RAcquire PierEnv () -pier (serf, log) vSlog startedSig = do +pier (serf, log) vSlog startedSig injected = do let logId = Log.identity log :: LogIdentity let ship = who logId :: Ship @@ -360,6 +361,29 @@ pier (serf, log) vSlog startedSig = do tExec <- acquireWorker "Effects" (router slog (readTQueue executeQ) drivz) tDisk <- acquireWorkerBound "Persist" (runPersist log persistQ execute) + -- Now that the Serf is configurated, the IO drivers are hooked up, their + -- starting events have been dispatched, and the terminal is live, we can now + -- handle injecting events requested from the command line. + unless (null injected) $ rio $ do + for_ (zip [1..] injected) $ \(num, ev) -> do + logTrace $ display @Text ("Injecting event " ++ (tshow num) ++ " of " ++ + (tshow $ length injected) ++ "...") + okaySig :: MVar (Either [Goof] ()) <- newEmptyMVar + + let inject = atomically $ compute $ RRWork $ EvErr ev $ cb + cb :: WorkError -> IO () + cb = \case + RunOkay _ -> putMVar okaySig (Right ()) + RunSwap _ _ _ _ _ -> putMVar okaySig (Right ()) + RunBail goofs -> putMVar okaySig (Left goofs) + + io inject + + takeMVar okaySig >>= \case + Left goof -> error ("Goof in injected event: " <> show goof) + Right () -> pure () + + let snapshotEverySecs = 120 void $ acquireWorker "Save" $ forever $ do From 61af5b104e49acb9290779049b3afc9e3f8aa56b Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 22 Oct 2020 10:53:28 -0400 Subject: [PATCH 512/933] king: patch cleanup --- pkg/hs/urbit-king/lib/Urbit/King/CLI.hs | 20 +++++++------- pkg/hs/urbit-king/lib/Urbit/King/Main.hs | 2 +- pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs | 33 ++++++++++++------------ 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs index 8d43a2214d..40d132892b 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs @@ -228,15 +228,17 @@ pierPath :: Parser FilePath pierPath = strArgument (metavar "PIER" <> help "Path to pier") injectEvents :: Parser [Injection] -injectEvents = many (InjectOneEvent <$> strOption ( short 'I' - <> long "inject-event" - <> metavar "JAM" - <> help "Path to a jammed event") <|> - InjectManyEvents <$> strOption ( - long "inject-event-list" - <> metavar "JAM LIST" - <> help "Path to a jammed list of events" - )) +injectEvents = many $ InjectOneEvent <$> strOption + ( short 'I' + <> long "inject-event" + <> metavar "JAM" + <> help "Path to a jammed event" + <> hidden) + <|> InjectManyEvents <$> strOption + ( long "inject-event-list" + <> metavar "JAM_LIST" + <> help "Path to a jammed list of events" + <> hidden) serfExe :: Parser (Maybe Text) serfExe = optional diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs index f077987efa..87fb407531 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs @@ -598,7 +598,7 @@ runShip (CLI.Run pierPath) opts daemon = do loadInjections :: [CLI.Injection] -> RIO PierEnv [Ev] loadInjections injections = do - perInjection :: [[Ev]] <- forM injections $ \case + perInjection :: [[Ev]] <- for injections $ \case CLI.InjectOneEvent filePath -> do logInfo $ display $ "boot: reading injected event from " ++ (pack filePath :: Text) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs index 12e75d26d8..f0803c9003 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs @@ -183,7 +183,7 @@ bootNewShip pill lite ship bootEv = do let logPath = (pierPath ".urb/log") rwith (Log.new logPath ident) $ \log -> do - logInfo "Event log initialized." + logInfo "Event log onitialized." jobs <- (\now -> bootSeqJobs now seq) <$> io Time.now writeJobs log (fromList jobs) @@ -361,27 +361,26 @@ pier (serf, log) vSlog startedSig injected = do tExec <- acquireWorker "Effects" (router slog (readTQueue executeQ) drivz) tDisk <- acquireWorkerBound "Persist" (runPersist log persistQ execute) - -- Now that the Serf is configurated, the IO drivers are hooked up, their + -- Now that the Serf is configured, the IO drivers are hooked up, their -- starting events have been dispatched, and the terminal is live, we can now -- handle injecting events requested from the command line. - unless (null injected) $ rio $ do - for_ (zip [1..] injected) $ \(num, ev) -> do - logTrace $ display @Text ("Injecting event " ++ (tshow num) ++ " of " ++ - (tshow $ length injected) ++ "...") - okaySig :: MVar (Either [Goof] ()) <- newEmptyMVar + for_ (zip [1..] injected) $ \(num, ev) -> rio $ do + logTrace $ display @Text ("Injecting event " ++ (tshow num) ++ " of " ++ + (tshow $ length injected) ++ "...") + okaySig :: MVar (Either [Goof] ()) <- newEmptyMVar - let inject = atomically $ compute $ RRWork $ EvErr ev $ cb - cb :: WorkError -> IO () - cb = \case - RunOkay _ -> putMVar okaySig (Right ()) - RunSwap _ _ _ _ _ -> putMVar okaySig (Right ()) - RunBail goofs -> putMVar okaySig (Left goofs) + let inject = atomically $ compute $ RRWork $ EvErr ev $ cb + cb :: WorkError -> IO () + cb = \case + RunOkay _ -> putMVar okaySig (Right ()) + RunSwap _ _ _ _ _ -> putMVar okaySig (Right ()) + RunBail goofs -> putMVar okaySig (Left goofs) - io inject + io inject - takeMVar okaySig >>= \case - Left goof -> error ("Goof in injected event: " <> show goof) - Right () -> pure () + takeMVar okaySig >>= \case + Left goof -> error ("Goof in injected event: " <> show goof) + Right () -> pure () let snapshotEverySecs = 120 From 5cdeecc627be75cee3fdf2c650ac90db7fc0965a Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 22 Oct 2020 13:06:57 -0400 Subject: [PATCH 513/933] king: undo undo --- pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs index f0803c9003..ffb4a46879 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs @@ -183,7 +183,7 @@ bootNewShip pill lite ship bootEv = do let logPath = (pierPath ".urb/log") rwith (Log.new logPath ident) $ \log -> do - logInfo "Event log onitialized." + logInfo "Event log initialized." jobs <- (\now -> bootSeqJobs now seq) <$> io Time.now writeJobs log (fromList jobs) From 7a5d57ce916b58d752a741cfed76e88d2ce54b13 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 22 Oct 2020 10:51:20 -0700 Subject: [PATCH 514/933] vere: adds ames stats for failed header/body parsing --- pkg/urbit/vere/io/ames.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index bdc488afab..5e79d000d1 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -53,8 +53,10 @@ c3_d dop_d; // drop count c3_d fal_d; // crash count c3_d saw_d; // successive scry failures + c3_d hed_d; // failed to read header c3_d vet_d; // version mismatches filtered c3_d mut_d; // invalid mugs filtered + c3_d bod_d; // failed to read body c3_d foq_d; // forward queue size c3_d fow_d; // forwarded count c3_d fod_d; // forwards dropped count @@ -1025,8 +1027,11 @@ _ames_hear(u3_ames* sam_u, if ( (4 > len_w) || (c3n == _ames_sift_head(&hed_u, hun_y)) ) { - // XX track stats - // + sam_u->sat_u.hed_d++; + if ( 0 == (sam_u->sat_u.hed_d % 100) ) { + u3l_log("ames: %" PRIu64 " dropped, failed to read header\n", sam_u->sat_u.hed_d); + } + c3_free(hun_y); return; } @@ -1068,8 +1073,11 @@ _ames_hear(u3_ames* sam_u, if ( (c3n == _ames_sift_body(&hed_u, &bod_u, bod_w, bod_y)) || !ur_cue_test_with(sam_u->tes_u, bod_u.con_w, bod_u.con_y) ) { - // XX track stats - // + sam_u->sat_u.bod_d++; + if ( 0 == (sam_u->sat_u.bod_d % 100) ) { + u3l_log("ames: %" PRIu64 " dropped, failed to read body\n", sam_u->sat_u.bod_d); + } + c3_free(hun_y); return; } @@ -1424,8 +1432,10 @@ _ames_io_info(u3_auto* car_u) u3l_log(" forwards dropped: %" PRIu64 "\n", sam_u->sat_u.fod_d); u3l_log(" forwards pending: %" PRIu64 "\n", sam_u->sat_u.foq_d); u3l_log(" forwarded: %" PRIu64 "\n", sam_u->sat_u.fow_d); + u3l_log(" filtered (hed): %" PRIu64 "\n", sam_u->sat_u.hed_d); u3l_log(" filtered (ver): %" PRIu64 "\n", sam_u->sat_u.vet_d); u3l_log(" filtered (mug): %" PRIu64 "\n", sam_u->sat_u.mut_d); + u3l_log(" filtered (bod): %" PRIu64 "\n", sam_u->sat_u.bod_d); u3l_log(" crashed: %" PRIu64 "\n", sam_u->sat_u.fal_d); u3l_log(" cached lanes: %u\n", u3h_wyt(sam_u->lax_p)); } From c5870b60d12bbb4d36f9d842b5936ff8e44261f0 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 22 Oct 2020 10:52:43 -0700 Subject: [PATCH 515/933] vere: updates ames future-refactoring comments for accuracy --- pkg/urbit/vere/io/ames.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 5e79d000d1..7f1186423b 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -190,7 +190,7 @@ _ames_etch_head(u3_head* hed_u, c3_y buf_y[4]) } /* _ames_chub_bytes(): c3_y[8] to c3_d -** XX move +** XX factor out, deduplicate with other conversions */ static inline c3_d _ames_chub_bytes(c3_y byt_y[8]) @@ -206,7 +206,6 @@ _ames_chub_bytes(c3_y byt_y[8]) } /* _ames_ship_to_chubs(): pack [len_y] bytes into c3_d[2] -** XX move */ static inline void _ames_ship_to_chubs(c3_d sip_d[2], c3_y len_y, c3_y* buf_y) @@ -219,7 +218,7 @@ _ames_ship_to_chubs(c3_d sip_d[2], c3_y len_y, c3_y* buf_y) } /* _ames_chub_bytes(): c3_d to c3_y[8] -** XX move +** XX factor out, deduplicate with other conversions */ static inline void _ames_bytes_chub(c3_y byt_y[8], c3_d num_d) @@ -235,7 +234,6 @@ _ames_bytes_chub(c3_y byt_y[8], c3_d num_d) } /* _ames_ship_of_chubs(): unpack c3_d[2] into [len_y] bytes. -** XX move */ static inline void _ames_ship_of_chubs(c3_d sip_d[2], c3_y len_y, c3_y* buf_y) From caa21b04cf793b87dff8a7b286590c06cdd424c3 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 22 Oct 2020 15:37:48 -0700 Subject: [PATCH 516/933] vere: adds (verbose, debug) ames packet forwarding printfs --- pkg/urbit/vere/io/ames.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 7f1186423b..054a725da2 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -851,6 +851,22 @@ _ames_forward(u3_panc* pac_u, u3_noun las) u3l_log("ames: forwarded %" PRIu64 " total\n", sam_u->sat_u.fow_d); } + if ( u3C.wag_w & u3o_verbose ) { + u3_noun sen = u3dc("scot", 'p', u3i_chubs(2, pac_u->bod_u.sen_d)); + u3_noun rec = u3dc("scot", 'p', u3i_chubs(2, pac_u->bod_u.rec_d)); + c3_c* sen_c = u3r_string(sen); + c3_c* rec_c = u3r_string(rec); + c3_y* pip_y = (c3_y*)&pac_u->ore_u.pip_w; + + u3l_log("ames: forwarding for %s to %s from %d.%d.%d.%d:%d\n", + sen_c, rec_c, + pip_y[0], pip_y[1], pip_y[2], pip_y[3], + pac_u->ore_u.por_s); + + c3_free(sen_c); c3_free(rec_c); + u3z(sen); u3z(rec); + } + { u3_noun los = las; u3_noun pac = _ames_serialize_packet(pac_u, c3y); From e59863bded8671a18a6cb8882dc8fc94785879b4 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 22 Oct 2020 15:38:25 -0700 Subject: [PATCH 517/933] vere: partially prevent forwarding loops by excluding self-galaxy lanes --- pkg/urbit/vere/io/ames.c | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 054a725da2..3a72425608 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -868,16 +868,46 @@ _ames_forward(u3_panc* pac_u, u3_noun las) } { - u3_noun los = las; u3_noun pac = _ames_serialize_packet(pac_u, c3y); - while ( u3_nul != las ) { - _ames_ef_send(sam_u, u3k(u3h(las)), u3k(pac)); - las = u3t(las); + u3_noun tag, dat, lan, t = las; + + while ( u3_nul != t ) { + u3x_cell(t, &lan, &t); + + // validate lane and skip self if galaxy + // + if ( c3n == u3r_cell(lan, &tag, &dat) ) { + u3l_log("ames: bogus lane\n"); + u3m_p("lan", lan); + } + else { + c3_o sen_o = c3y; + c3_d who_d[2]; + + if ( c3y == tag ) { + u3r_chubs(0, 2, who_d, dat); + + if ( (who_d[0] == sam_u->pir_u->who_d[0]) + && (who_d[1] == sam_u->pir_u->who_d[1]) ) + { + sen_o = c3n; + if ( u3C.wag_w & u3o_verbose ) { + u3l_log("ames: forward skipping self\n"); + } + } + } + + if ( c3y == sen_o ) { + _ames_ef_send(sam_u, u3k(lan), u3k(pac)); + } + } } - u3z(los); u3z(pac); + + u3z(pac); } _ames_panc_free(pac_u); + u3z(las); } /* _ames_lane_scry_cb(): learn lane to forward packet on From 3f346e3d39a9ce4d7094973ce487ec5cba47c18a Mon Sep 17 00:00:00 2001 From: fang Date: Fri, 23 Oct 2020 00:50:41 +0200 Subject: [PATCH 518/933] vere: fix -j help text --- pkg/urbit/daemon/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/urbit/daemon/main.c b/pkg/urbit/daemon/main.c index 95d097b31f..9918726406 100644 --- a/pkg/urbit/daemon/main.c +++ b/pkg/urbit/daemon/main.c @@ -398,7 +398,7 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-e url Ethereum gateway\n", "-F ship Fake keys; also disables networking\n", "-g Set GC flag\n", - "-j file Create json trace file\n", + "-j Create json trace file in .urb/put/trace\n", "-K stage Start at Hoon kernel version stage\n", "-k keys Private key file\n", "-L local networking only\n", From 66e3df0b0678c0b240da2961849a405479c3c67b Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Thu, 22 Oct 2020 16:13:26 -0700 Subject: [PATCH 519/933] king: address joe's comments --- pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs | 15 +++++++++++++++ pkg/hs/urbit-king/lib/Urbit/Vere/Serf/IPC.hs | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs index c06c12a38d..d38d7b36a1 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs @@ -267,6 +267,21 @@ ames env who isFake scry enqueueEv stderr = (initialEvents, runAmes) Right pkt -> logInfo $ displayShow ("ames: dropping ill-versed", pkt, ver) + -- XX better handle misversioned or illegible packets. + -- Remarks from 67f06ce5, pkg/urbit/vere/io/ames.c, L1010: + -- + -- [There are] two protocol-change scenarios [which we must think about]: + -- + -- - packets using old protocol versions from our sponsees + -- these must be let through, and this is a transitive condition; + -- they must also be forwarded where appropriate + -- they can be validated, as we know their semantics + -- + -- - packets using newer protocol versions + -- these should probably be let through, or at least + -- trigger printfs suggesting upgrade. + -- they cannot be filtered, as we do not know their semantics + -- Left e -> logInfo $ displayShow ("ames: dropping malformed", e) where diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Serf/IPC.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Serf/IPC.hs index 3b0d5b1406..8772d156ea 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Serf/IPC.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Serf/IPC.hs @@ -250,8 +250,8 @@ recvPeek :: Serf -> IO (Maybe (Term, Noun)) recvPeek serf = do recvPleaHandlingSlog serf >>= \case PPeek (SDone peek) -> pure peek - -- XX produce error - PPeek (SBail dud) -> throwIO (PeekBail dud) + -- XX surface error content + PPeek (SBail dud) -> pure Nothing plea -> throwIO (UnexpectedPlea (toNoun plea) "expecting %peek") From e254c72788e09c1bd7db20e11128687719dc8cb8 Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Fri, 23 Oct 2020 00:02:42 -0700 Subject: [PATCH 520/933] king: address #3778 per joe --- pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs index d38d7b36a1..a49307083f 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs @@ -261,8 +261,13 @@ ames env who isFake scry enqueueEv stderr = (initialEvents, runAmes) if pktRcvr == who then serfsUp p a b else lan pktRcvr >>= \case - Just (dest:_) -> forward dest $ encode pkt - { pktOrigin = pktOrigin <|> Just (ipDest p a) } + Just ls + | dest:_ <- filter notSelf ls + -> forward dest $ encode pkt + { pktOrigin = pktOrigin <|> Just (ipDest p a) } + where + notSelf (EachYes g) = who /= Ship (fromIntegral g) + notSelf (EachNo _) = True _ -> logInfo $ displayShow ("ames: dropping unroutable", pkt) Right pkt -> logInfo $ displayShow ("ames: dropping ill-versed", pkt, ver) From 347a1ffb6614cd24d10f8c5cc63b8d06f481a37d Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 23 Oct 2020 11:02:07 -0700 Subject: [PATCH 521/933] u3: remove timestamp printing in u3v_time() --- pkg/urbit/include/noun/vortex.h | 2 +- pkg/urbit/noun/vortex.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/include/noun/vortex.h b/pkg/urbit/include/noun/vortex.h index 7dcab4e7ee..7c98d52bf8 100644 --- a/pkg/urbit/include/noun/vortex.h +++ b/pkg/urbit/include/noun/vortex.h @@ -10,7 +10,7 @@ c3_d ent_d; // event number u3_noun yot; // cached gates u3_noun now; // current time, as noun - u3_noun wen; // current time, as text + u3_noun wen; // current time, as text, XX remove u3_noun sev_l; // instance number u3_noun sen; // instance string u3_noun roc; // kernel core diff --git a/pkg/urbit/noun/vortex.c b/pkg/urbit/noun/vortex.c index 8288baf03d..29a58d7050 100644 --- a/pkg/urbit/noun/vortex.c +++ b/pkg/urbit/noun/vortex.c @@ -165,8 +165,13 @@ u3v_time(u3_noun now) u3z(u3A->now); u3A->now = now; + // XX unused, removed + // + // u3z() temporarily preserved to avoid leaking + // checkpointed values + // u3z(u3A->wen); - u3A->wen = _cv_scot(u3nc(c3__da, u3k(u3A->now))); + u3A->wen = 0; } /* u3v_numb(): set the instance number. From b2c79860e051aea61b05a9b25da940c8e374eac1 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 23 Oct 2020 13:35:57 -0700 Subject: [PATCH 522/933] u3: moves u3z of printed timestamp to u3m_boot() --- pkg/urbit/noun/manage.c | 8 ++++++++ pkg/urbit/noun/vortex.c | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/urbit/noun/manage.c b/pkg/urbit/noun/manage.c index 2a1c36c7d1..9105f07e51 100644 --- a/pkg/urbit/noun/manage.c +++ b/pkg/urbit/noun/manage.c @@ -1689,6 +1689,14 @@ u3m_boot(c3_c* dir_c) u3j_ream(); u3n_ream(); + // XX unused, removed + // + // u3z() temporarily preserved to avoid leaking + // checkpointed values + // + u3z(u3A->wen); + u3A->wen = 0; + return u3A->ent_d; } else { diff --git a/pkg/urbit/noun/vortex.c b/pkg/urbit/noun/vortex.c index 29a58d7050..63cbb25400 100644 --- a/pkg/urbit/noun/vortex.c +++ b/pkg/urbit/noun/vortex.c @@ -164,14 +164,6 @@ u3v_time(u3_noun now) { u3z(u3A->now); u3A->now = now; - - // XX unused, removed - // - // u3z() temporarily preserved to avoid leaking - // checkpointed values - // - u3z(u3A->wen); - u3A->wen = 0; } /* u3v_numb(): set the instance number. From 759ac51f2770d45a143c72fcb4d20f7ddff98add Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 26 Oct 2020 10:57:07 -0400 Subject: [PATCH 523/933] king: Don't hard error on injected event failure. --- pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs index ffb4a46879..0c918a1770 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs @@ -379,7 +379,8 @@ pier (serf, log) vSlog startedSig injected = do io inject takeMVar okaySig >>= \case - Left goof -> error ("Goof in injected event: " <> show goof) + Left goof -> logError $ display @Text ("Goof in injected event: " <> + tshow goof) Right () -> pure () From 9cc9a308bf217b382d910df9455bb75da1f88742 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 26 Oct 2020 13:32:56 -0700 Subject: [PATCH 524/933] vere: fix snprintf return-code check in ames --- pkg/urbit/vere/io/ames.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index 3a72425608..ae0656c3f1 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -668,7 +668,7 @@ _ames_czar(u3_pact* pac_u) u3z(nam); } - if ( 0 != sas_i ) { + if ( 255 <= sas_i ) { u3l_log("ames: czar: galaxy domain %s truncated\n", sam_u->dns_c); _ames_pact_free(pac_u); return; From ce3cbf0857e54ca31f57bb3c9bc3e05588e5e487 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Tue, 27 Oct 2020 13:55:49 +0100 Subject: [PATCH 525/933] build: rework all nix expressions to support hercules-ci builds This also removes nixcrpkgs and OSX cross compilation in favour of compiling on the target. x86_64/musl targets are still supported on Linux. All sources are now managed via niv (see nix/sources.json) and Haskell package sets are provided/organised via IOHK's haskell.nix. Some effort has been made to expose similar top-level attributes for development, but in some cases there have been changes. Please see the comments in the top-level default.nix and ci.nix files for usage. --- ci.nix | 123 + default.nix | 164 +- nix/cachix/local.nix | 22 - nix/cachix/release.nix | 11 - nix/cachix/tests.nix | 7 - nix/cachix/util.nix | 26 - nix/crossdeps.nix | 14 - nix/default.nix | 45 + nix/deps-env.nix | 31 - nix/deps/argon2/builder.sh | 14 - nix/deps/argon2/cross.nix | 17 - nix/deps/argon2/default.nix | 13 - nix/deps/ca-header/builder.sh | 27 - nix/deps/ca-header/cross.nix | 8 - nix/deps/ca-header/default.nix | 7 - nix/deps/default.nix | 14 - nix/deps/ed25519/builder.sh | 29 - nix/deps/ed25519/cross.nix | 16 - nix/deps/ed25519/default.nix | 12 - nix/deps/h2o/builder.sh | 109 - nix/deps/h2o/cross.nix | 17 - nix/deps/h2o/cross.sh | 26 - nix/deps/h2o/default.nix | 13 - nix/deps/ivory-header/builder.sh | 35 - nix/deps/ivory-header/cross.nix | 11 - nix/deps/ivory-header/default.nix | 11 - nix/deps/murmur3/builder.sh | 11 - nix/deps/murmur3/cross.nix | 16 - nix/deps/murmur3/default.nix | 12 - nix/deps/scrypt/builder.sh | 27 - nix/deps/scrypt/cross.nix | 16 - nix/deps/scrypt/default.nix | 12 - nix/deps/secp256k1/builder.sh | 11 - nix/deps/secp256k1/cross.nix | 25 - nix/deps/secp256k1/default.nix | 25 - nix/deps/softfloat3/builder.sh | 15 - nix/deps/softfloat3/cross.nix | 16 - nix/deps/softfloat3/default.nix | 12 - nix/deps/uv/builder.sh | 9 - nix/deps/uv/cross.nix | 17 - nix/deps/uv/default.nix | 27 - nix/lib/boot-fake-ship.nix | 57 + nix/lib/default.nix | 81 + nix/lib/dimension.nix | 110 + nix/lib/fetch-github-lfs.nix | 107 + nix/lib/make-release-tarball.nix | 37 + nix/lib/push-storage-object.nix | 64 + nix/lib/test-fake-ship.nix | 104 + nix/nixcrpkgs.nix | 12 - nix/nixcrpkgs/.gitignore | 4 - nix/nixcrpkgs/LICENSE.nixpkgs | 31 - nix/nixcrpkgs/LICENSE.txt | 25 - nix/nixcrpkgs/README.md | 175 -- nix/nixcrpkgs/bundle_builder.sh | 8 - nix/nixcrpkgs/cmake_toolchain/builder.sh | 8 - nix/nixcrpkgs/cmake_toolchain/default.nix | 7 - nix/nixcrpkgs/default.nix | 4 - nix/nixcrpkgs/linux/README.md | 14 - nix/nixcrpkgs/linux/binutils/builder.sh | 26 - nix/nixcrpkgs/linux/binutils/default.nix | 26 - .../linux/binutils/deterministic.patch | 12 - nix/nixcrpkgs/linux/default.nix | 78 - nix/nixcrpkgs/linux/gcc/builder.sh | 34 - nix/nixcrpkgs/linux/gcc/default.nix | 81 - .../linux/gcc/libstdc++-target.patch | 32 - .../linux/gcc/link_gcc_c_sequence_spec.patch | 12 - nix/nixcrpkgs/linux/gcc/ubsan.patch | 10 - .../linux/gcc/use-source-date-epoch.patch | 52 - nix/nixcrpkgs/linux/headers_builder.sh | 13 - nix/nixcrpkgs/linux/license_builder.sh | 45 - nix/nixcrpkgs/macos/.gitignore | 1 - nix/nixcrpkgs/macos/ar_builder.sh | 46 - nix/nixcrpkgs/macos/cctools-bytesex.patch | 11 - nix/nixcrpkgs/macos/cctools-format.patch | 2661 ----------------- .../macos/cctools-ld64-registers.patch | 299 -- .../macos/cctools-libstuff-no-error.patch | 93 - .../macos/cctools-private-extern.patch | 271 -- nix/nixcrpkgs/macos/clang_builder.sh | 30 - nix/nixcrpkgs/macos/clang_megapatch.patch | 37 - nix/nixcrpkgs/macos/default.nix | 192 -- nix/nixcrpkgs/macos/gen_sdk_package.sh | 164 - nix/nixcrpkgs/macos/ld_builder.sh | 45 - nix/nixcrpkgs/macos/ranlib_builder.sh | 45 - nix/nixcrpkgs/macos/sdk_builder.sh | 4 - nix/nixcrpkgs/macos/strip_builder.sh | 43 - nix/nixcrpkgs/macos/tapi_builder.sh | 80 - nix/nixcrpkgs/macos/toolchain_builder.sh | 24 - nix/nixcrpkgs/macos/wrapper.cpp | 139 - nix/nixcrpkgs/make_derivation.nix | 91 - nix/nixcrpkgs/mingw-w64/binutils/builder.sh | 26 - nix/nixcrpkgs/mingw-w64/binutils/default.nix | 26 - .../mingw-w64/binutils/deterministic.patch | 12 - nix/nixcrpkgs/mingw-w64/builder.sh | 35 - nix/nixcrpkgs/mingw-w64/default.nix | 106 - nix/nixcrpkgs/mingw-w64/gcc/builder.sh | 63 - nix/nixcrpkgs/mingw-w64/gcc/cppdefault.patch | 35 - nix/nixcrpkgs/mingw-w64/gcc/default.nix | 103 - .../mingw-w64/gcc/libstdc++-target.patch | 32 - .../mingw-w64/gcc/mingw-search-paths.patch | 14 - nix/nixcrpkgs/mingw-w64/gcc/no-sys-dirs.patch | 28 - nix/nixcrpkgs/mingw-w64/gcc/ubsan.patch | 10 - .../mingw-w64/gcc/use-source-date-epoch.patch | 52 - nix/nixcrpkgs/mingw-w64/guid-selectany.patch | 38 - nix/nixcrpkgs/mingw-w64/license_builder.sh | 42 - nix/nixcrpkgs/mingw-w64/usb.patch | 73 - nix/nixcrpkgs/native/default.nix | 54 - nix/nixcrpkgs/native/pkgconf/builder.sh | 21 - nix/nixcrpkgs/native/pkgconf/default.nix | 14 - nix/nixcrpkgs/native/wrappers/builder.sh | 17 - nix/nixcrpkgs/native/wrappers/default.nix | 5 - nix/nixcrpkgs/pkgs.nix | 207 -- nix/nixcrpkgs/pkgs/angle/README.md | 11 - nix/nixcrpkgs/pkgs/angle/builder.sh | 46 - nix/nixcrpkgs/pkgs/angle/debug_bundle.nix | 11 - .../pkgs/angle/debug_bundle_builder.sh | 18 - nix/nixcrpkgs/pkgs/angle/default.nix | 23 - nix/nixcrpkgs/pkgs/angle/examples.nix | 11 - nix/nixcrpkgs/pkgs/angle/lib.nix | 43 - nix/nixcrpkgs/pkgs/angle/megapatch.patch | 24 - nix/nixcrpkgs/pkgs/angle/samples_builder.sh | 54 - nix/nixcrpkgs/pkgs/angle/util.nix | 15 - nix/nixcrpkgs/pkgs/angle/util_builder.sh | 38 - nix/nixcrpkgs/pkgs/at-spi2-headers/builder.sh | 12 - .../pkgs/at-spi2-headers/default.nix | 24 - .../pkgs/at-spi2-headers/license_builder.sh | 10 - nix/nixcrpkgs/pkgs/avrdude/builder.sh | 23 - nix/nixcrpkgs/pkgs/avrdude/config.sub | 1801 ----------- nix/nixcrpkgs/pkgs/avrdude/default.nix | 35 - nix/nixcrpkgs/pkgs/avrdude/extra.conf | 6 - nix/nixcrpkgs/pkgs/curl/builder.sh | 15 - nix/nixcrpkgs/pkgs/curl/default.nix | 22 - nix/nixcrpkgs/pkgs/dejavu-fonts/builder.sh | 6 - nix/nixcrpkgs/pkgs/dejavu-fonts/default.nix | 29 - .../pkgs/dejavu-fonts/license_builder.sh | 14 - nix/nixcrpkgs/pkgs/devcon/builder.sh | 26 - nix/nixcrpkgs/pkgs/devcon/default.nix | 20 - nix/nixcrpkgs/pkgs/devcon/my_xmlhelper.c | 47 - nix/nixcrpkgs/pkgs/expat/builder.sh | 26 - nix/nixcrpkgs/pkgs/expat/cve-2016-0718.patch | 26 - nix/nixcrpkgs/pkgs/expat/default.nix | 20 - nix/nixcrpkgs/pkgs/fixesproto/builder.sh | 16 - nix/nixcrpkgs/pkgs/fixesproto/default.nix | 41 - .../pkgs/fixesproto/license_builder.sh | 11 - nix/nixcrpkgs/pkgs/gdb/builder.sh | 31 - nix/nixcrpkgs/pkgs/gdb/default.nix | 38 - .../gdb/substitute-path-all-filenames.patch | 14 - nix/nixcrpkgs/pkgs/hello/builder.sh | 7 - nix/nixcrpkgs/pkgs/hello/default.nix | 7 - nix/nixcrpkgs/pkgs/hello/hello.c | 15 - nix/nixcrpkgs/pkgs/hello_cpp/builder.sh | 8 - nix/nixcrpkgs/pkgs/hello_cpp/default.nix | 7 - nix/nixcrpkgs/pkgs/hello_cpp/hello.cpp | 15 - nix/nixcrpkgs/pkgs/inputproto/builder.sh | 13 - nix/nixcrpkgs/pkgs/inputproto/default.nix | 27 - .../pkgs/inputproto/license_builder.sh | 14 - nix/nixcrpkgs/pkgs/ion/builder.sh | 20 - nix/nixcrpkgs/pkgs/ion/default.nix | 21 - nix/nixcrpkgs/pkgs/kbproto/builder.sh | 13 - nix/nixcrpkgs/pkgs/kbproto/default.nix | 27 - nix/nixcrpkgs/pkgs/kbproto/license_builder.sh | 14 - nix/nixcrpkgs/pkgs/libgmp/builder.sh | 9 - nix/nixcrpkgs/pkgs/libgmp/default.nix | 16 - nix/nixcrpkgs/pkgs/libsigsegv/builder.sh | 50 - nix/nixcrpkgs/pkgs/libsigsegv/default.nix | 13 - nix/nixcrpkgs/pkgs/libudev/builder.sh | 71 - nix/nixcrpkgs/pkgs/libudev/default.nix | 49 - nix/nixcrpkgs/pkgs/libudev/fill/printf.c | 277 -- nix/nixcrpkgs/pkgs/libudev/fill/printf.h | 50 - nix/nixcrpkgs/pkgs/libudev/license_builder.sh | 14 - nix/nixcrpkgs/pkgs/libudev/megapatch.patch | 102 - nix/nixcrpkgs/pkgs/libusb/builder.sh | 27 - nix/nixcrpkgs/pkgs/libusb/default.nix | 20 - nix/nixcrpkgs/pkgs/libusbp/builder.sh | 23 - nix/nixcrpkgs/pkgs/libusbp/default.nix | 43 - .../pkgs/libusbp/examples_builder.sh | 15 - nix/nixcrpkgs/pkgs/libusbp/license_builder.sh | 20 - nix/nixcrpkgs/pkgs/libx11/builder.sh | 24 - nix/nixcrpkgs/pkgs/libx11/default.nix | 55 - nix/nixcrpkgs/pkgs/libx11/license_builder.sh | 14 - nix/nixcrpkgs/pkgs/libxall/builder.rb | 40 - nix/nixcrpkgs/pkgs/libxall/default.nix | 15 - nix/nixcrpkgs/pkgs/libxau/builder.sh | 16 - nix/nixcrpkgs/pkgs/libxau/default.nix | 40 - nix/nixcrpkgs/pkgs/libxau/license_builder.sh | 14 - nix/nixcrpkgs/pkgs/libxcb/builder.sh | 28 - nix/nixcrpkgs/pkgs/libxcb/default.nix | 56 - nix/nixcrpkgs/pkgs/libxcb/example1.c | 68 - nix/nixcrpkgs/pkgs/libxcb/examples_builder.sh | 10 - nix/nixcrpkgs/pkgs/libxcb/license_builder.sh | 14 - .../pkgs/libxcb/no-pthread-stubs.patch | 12 - nix/nixcrpkgs/pkgs/libxext/builder.sh | 19 - nix/nixcrpkgs/pkgs/libxext/default.nix | 43 - nix/nixcrpkgs/pkgs/libxext/license_builder.sh | 14 - nix/nixcrpkgs/pkgs/libxfixes/builder.sh | 20 - nix/nixcrpkgs/pkgs/libxfixes/default.nix | 42 - .../pkgs/libxfixes/license_builder.sh | 14 - nix/nixcrpkgs/pkgs/libxi/builder.sh | 21 - nix/nixcrpkgs/pkgs/libxi/default.nix | 45 - nix/nixcrpkgs/pkgs/libxi/license_builder.sh | 14 - nix/nixcrpkgs/pkgs/lmdb/builder.sh | 16 - nix/nixcrpkgs/pkgs/lmdb/default.nix | 14 - nix/nixcrpkgs/pkgs/ncurses/builder.sh | 14 - nix/nixcrpkgs/pkgs/ncurses/default.nix | 27 - nix/nixcrpkgs/pkgs/openocd/builder.sh | 24 - nix/nixcrpkgs/pkgs/openocd/default.nix | 39 - nix/nixcrpkgs/pkgs/openssl/builder.sh | 46 - nix/nixcrpkgs/pkgs/openssl/default.nix | 83 - nix/nixcrpkgs/pkgs/p-load/builder.sh | 14 - nix/nixcrpkgs/pkgs/p-load/default.nix | 16 - nix/nixcrpkgs/pkgs/pavr2/builder.sh | 14 - nix/nixcrpkgs/pkgs/pavr2/default.nix | 16 - nix/nixcrpkgs/pkgs/pdcurses/builder.sh | 37 - nix/nixcrpkgs/pkgs/pdcurses/default.nix | 16 - nix/nixcrpkgs/pkgs/pdcurses/demos_builder.sh | 25 - nix/nixcrpkgs/pkgs/pdcurses/examples.nix | 11 - nix/nixcrpkgs/pkgs/pdcurses/lib.nix | 16 - nix/nixcrpkgs/pkgs/qt/absolute-paths.patch | 63 - nix/nixcrpkgs/pkgs/qt/builder.sh | 23 - nix/nixcrpkgs/pkgs/qt/core_macros.cmake | 106 - nix/nixcrpkgs/pkgs/qt/dbus-null-pointer.patch | 12 - nix/nixcrpkgs/pkgs/qt/default.nix | 165 - nix/nixcrpkgs/pkgs/qt/dont-test-uxtheme.patch | 24 - nix/nixcrpkgs/pkgs/qt/examples_builder.sh | 88 - nix/nixcrpkgs/pkgs/qt/find-x-libs.patch | 12 - nix/nixcrpkgs/pkgs/qt/font-dir.patch | 11 - nix/nixcrpkgs/pkgs/qt/license_builder.sh | 151 - nix/nixcrpkgs/pkgs/qt/macos-config.patch | 167 -- nix/nixcrpkgs/pkgs/qt/pc-debug-name.patch | 33 - nix/nixcrpkgs/pkgs/qt/pkg-config-cross.patch | 13 - .../pkgs/qt/win32-link-object-max.patch | 16 - nix/nixcrpkgs/pkgs/qt/wrapper_builder.rb | 499 ---- nix/nixcrpkgs/pkgs/readline/builder.sh | 32 - nix/nixcrpkgs/pkgs/readline/default.nix | 41 - nix/nixcrpkgs/pkgs/readline/readline-1.patch | 171 -- nix/nixcrpkgs/pkgs/tic/builder.sh | 15 - nix/nixcrpkgs/pkgs/tic/default.nix | 16 - nix/nixcrpkgs/pkgs/usbview/builder.sh | 31 - nix/nixcrpkgs/pkgs/usbview/default.nix | 22 - nix/nixcrpkgs/pkgs/usbview/megapatch.patch | 107 - nix/nixcrpkgs/pkgs/usbview/my_xmlhelper.c | 47 - nix/nixcrpkgs/pkgs/xcb-proto/builder.sh | 14 - nix/nixcrpkgs/pkgs/xcb-proto/default.nix | 28 - .../pkgs/xcb-proto/license_builder.sh | 14 - nix/nixcrpkgs/pkgs/xcb-util-image/default.nix | 40 - .../pkgs/xcb-util-image/license_builder.sh | 14 - .../pkgs/xcb-util-image/util_image_builder.sh | 20 - .../pkgs/xcb-util-keysyms/default.nix | 37 - .../pkgs/xcb-util-keysyms/license_builder.sh | 14 - .../xcb-util-keysyms/util_keysyms_builder.sh | 14 - .../pkgs/xcb-util-renderutil/default.nix | 40 - .../xcb-util-renderutil/license_builder.sh | 14 - .../util_renderutil_builder.sh | 16 - nix/nixcrpkgs/pkgs/xcb-util-wm/default.nix | 39 - .../pkgs/xcb-util-wm/license_builder.sh | 14 - .../pkgs/xcb-util-wm/util_wm_builder.sh | 14 - nix/nixcrpkgs/pkgs/xcb-util/default.nix | 37 - .../pkgs/xcb-util/license_builder.sh | 14 - nix/nixcrpkgs/pkgs/xcb-util/util_builder.sh | 14 - nix/nixcrpkgs/pkgs/xextproto/builder.sh | 13 - nix/nixcrpkgs/pkgs/xextproto/default.nix | 27 - .../pkgs/xextproto/license_builder.sh | 14 - nix/nixcrpkgs/pkgs/xorg-macros/builder.sh | 18 - nix/nixcrpkgs/pkgs/xorg-macros/default.nix | 27 - .../pkgs/xorg-macros/license_builder.sh | 14 - nix/nixcrpkgs/pkgs/xproto/builder.sh | 16 - nix/nixcrpkgs/pkgs/xproto/default.nix | 38 - nix/nixcrpkgs/pkgs/xproto/license_builder.sh | 14 - nix/nixcrpkgs/pkgs/xtrans/builder.sh | 16 - nix/nixcrpkgs/pkgs/xtrans/default.nix | 27 - nix/nixcrpkgs/pkgs/xtrans/license_builder.sh | 14 - nix/nixcrpkgs/pkgs/zlib/builder.sh | 15 - nix/nixcrpkgs/pkgs/zlib/default.nix | 14 - nix/nixcrpkgs/pretend_stdenv/setup | 1 - nix/nixcrpkgs/support/derivations.txt | 58 - nix/nixcrpkgs/support/expand_brackets.rb | 43 - nix/nixcrpkgs/support/graph.rb | 74 - nix/nixcrpkgs/support/manage | 541 ---- nix/nixcrpkgs/top.nix | 72 - nix/nixpkgs.nix | 13 - nix/ops/boot-ship.nix | 19 - nix/ops/brass/builder.sh | 22 - nix/ops/brass/default.nix | 11 - nix/ops/default.nix | 86 - nix/ops/fakeship/builder.sh | 26 - nix/ops/fakeship/default.nix | 11 - nix/ops/image/default.nix | 47 - nix/ops/ivory/builder.sh | 22 - nix/ops/ivory/default.nix | 11 - nix/ops/solid/builder.sh | 82 - nix/ops/solid/default.nix | 11 - nix/ops/test/builder.sh | 80 - nix/ops/test/default.nix | 10 - nix/overlays/arm.nix | 13 + nix/overlays/musl.nix | 28 + nix/overlays/native.nix | 28 + nix/overlays/static.nix | 37 + nix/pkgs/argon2u/default.nix | 30 + nix/pkgs/arvo-ropsten/builder.sh | 26 - nix/pkgs/arvo-ropsten/default.nix | 8 - nix/pkgs/arvo/builder.sh | 4 - nix/pkgs/arvo/default.nix | 50 +- nix/pkgs/ca-bundle/default.nix | 29 + nix/pkgs/default.nix | 33 - nix/pkgs/ed25519/default.nix | 21 + nix/pkgs/ent/builder.sh | 8 - nix/pkgs/ent/cross.nix | 10 - nix/pkgs/ent/default.nix | 17 +- nix/pkgs/ge-additions/builder.sh | 7 - nix/pkgs/ge-additions/cross.nix | 12 - nix/pkgs/ge-additions/default.nix | 16 +- nix/pkgs/ge-additions/release.sh | 13 - nix/pkgs/herb/default.nix | 29 + nix/pkgs/hs/default.nix | 91 + nix/pkgs/libaes_siv/builder.sh | 7 - nix/pkgs/libaes_siv/cross.nix | 12 - nix/pkgs/libaes_siv/default.nix | 15 +- nix/pkgs/libaes_siv/release.sh | 13 - nix/pkgs/libscrypt/default.nix | 35 + .../disable-stackvma_fault-linux-arm.patch | 11 + .../disable-stackvma_fault-linux-i386.patch | 11 + nix/pkgs/murmur3/default.nix | 17 + nix/pkgs/pill/brass.nix | 22 + nix/pkgs/pill/brass.sh | 23 + nix/pkgs/pill/builder.nix | 23 + nix/pkgs/pill/ivory.nix | 42 + nix/pkgs/pill/ivory.sh | 23 + nix/pkgs/pill/solid.nix | 23 + nix/pkgs/pill/solid.sh | 73 + nix/pkgs/softfloat3/default.nix | 28 + nix/pkgs/urbit/default.nix | 104 +- nix/pkgs/urbit/libsigsegv_fix.patch | 20 - nix/pkgs/urbit/release.nix | 36 - nix/pkgs/urbit/release.sh | 21 - nix/pkgs/urbit/shell.nix | 16 - nix/release.nix | 54 - nix/sources.json | 134 + nix/sources.nix | 154 + pkg/ent/shell.nix | 8 + pkg/ge-additions/shell.nix | 8 + pkg/herb/default.nix | 39 - pkg/herb/shell.nix | 8 + pkg/hs/default.nix | 51 - pkg/hs/terminal-progress-bar/shell.nix | 2 - pkg/libaes_siv/shell.nix | 10 +- pkg/urbit/shell.nix | 9 +- shell.nix | 72 + 346 files changed, 2055 insertions(+), 15659 deletions(-) create mode 100644 ci.nix delete mode 100644 nix/cachix/local.nix delete mode 100644 nix/cachix/release.nix delete mode 100644 nix/cachix/tests.nix delete mode 100644 nix/cachix/util.nix delete mode 100644 nix/crossdeps.nix create mode 100644 nix/default.nix delete mode 100644 nix/deps-env.nix delete mode 100644 nix/deps/argon2/builder.sh delete mode 100644 nix/deps/argon2/cross.nix delete mode 100644 nix/deps/argon2/default.nix delete mode 100755 nix/deps/ca-header/builder.sh delete mode 100644 nix/deps/ca-header/cross.nix delete mode 100644 nix/deps/ca-header/default.nix delete mode 100644 nix/deps/default.nix delete mode 100644 nix/deps/ed25519/builder.sh delete mode 100644 nix/deps/ed25519/cross.nix delete mode 100644 nix/deps/ed25519/default.nix delete mode 100644 nix/deps/h2o/builder.sh delete mode 100644 nix/deps/h2o/cross.nix delete mode 100644 nix/deps/h2o/cross.sh delete mode 100644 nix/deps/h2o/default.nix delete mode 100755 nix/deps/ivory-header/builder.sh delete mode 100644 nix/deps/ivory-header/cross.nix delete mode 100644 nix/deps/ivory-header/default.nix delete mode 100644 nix/deps/murmur3/builder.sh delete mode 100644 nix/deps/murmur3/cross.nix delete mode 100644 nix/deps/murmur3/default.nix delete mode 100644 nix/deps/scrypt/builder.sh delete mode 100644 nix/deps/scrypt/cross.nix delete mode 100644 nix/deps/scrypt/default.nix delete mode 100644 nix/deps/secp256k1/builder.sh delete mode 100644 nix/deps/secp256k1/cross.nix delete mode 100644 nix/deps/secp256k1/default.nix delete mode 100644 nix/deps/softfloat3/builder.sh delete mode 100644 nix/deps/softfloat3/cross.nix delete mode 100644 nix/deps/softfloat3/default.nix delete mode 100644 nix/deps/uv/builder.sh delete mode 100644 nix/deps/uv/cross.nix delete mode 100644 nix/deps/uv/default.nix create mode 100644 nix/lib/boot-fake-ship.nix create mode 100644 nix/lib/default.nix create mode 100644 nix/lib/dimension.nix create mode 100644 nix/lib/fetch-github-lfs.nix create mode 100644 nix/lib/make-release-tarball.nix create mode 100644 nix/lib/push-storage-object.nix create mode 100644 nix/lib/test-fake-ship.nix delete mode 100644 nix/nixcrpkgs.nix delete mode 100644 nix/nixcrpkgs/.gitignore delete mode 100644 nix/nixcrpkgs/LICENSE.nixpkgs delete mode 100644 nix/nixcrpkgs/LICENSE.txt delete mode 100644 nix/nixcrpkgs/README.md delete mode 100644 nix/nixcrpkgs/bundle_builder.sh delete mode 100644 nix/nixcrpkgs/cmake_toolchain/builder.sh delete mode 100644 nix/nixcrpkgs/cmake_toolchain/default.nix delete mode 100644 nix/nixcrpkgs/default.nix delete mode 100644 nix/nixcrpkgs/linux/README.md delete mode 100644 nix/nixcrpkgs/linux/binutils/builder.sh delete mode 100644 nix/nixcrpkgs/linux/binutils/default.nix delete mode 100644 nix/nixcrpkgs/linux/binutils/deterministic.patch delete mode 100644 nix/nixcrpkgs/linux/default.nix delete mode 100644 nix/nixcrpkgs/linux/gcc/builder.sh delete mode 100644 nix/nixcrpkgs/linux/gcc/default.nix delete mode 100644 nix/nixcrpkgs/linux/gcc/libstdc++-target.patch delete mode 100644 nix/nixcrpkgs/linux/gcc/link_gcc_c_sequence_spec.patch delete mode 100644 nix/nixcrpkgs/linux/gcc/ubsan.patch delete mode 100644 nix/nixcrpkgs/linux/gcc/use-source-date-epoch.patch delete mode 100644 nix/nixcrpkgs/linux/headers_builder.sh delete mode 100644 nix/nixcrpkgs/linux/license_builder.sh delete mode 100644 nix/nixcrpkgs/macos/.gitignore delete mode 100644 nix/nixcrpkgs/macos/ar_builder.sh delete mode 100644 nix/nixcrpkgs/macos/cctools-bytesex.patch delete mode 100644 nix/nixcrpkgs/macos/cctools-format.patch delete mode 100644 nix/nixcrpkgs/macos/cctools-ld64-registers.patch delete mode 100644 nix/nixcrpkgs/macos/cctools-libstuff-no-error.patch delete mode 100644 nix/nixcrpkgs/macos/cctools-private-extern.patch delete mode 100644 nix/nixcrpkgs/macos/clang_builder.sh delete mode 100644 nix/nixcrpkgs/macos/clang_megapatch.patch delete mode 100644 nix/nixcrpkgs/macos/default.nix delete mode 100755 nix/nixcrpkgs/macos/gen_sdk_package.sh delete mode 100644 nix/nixcrpkgs/macos/ld_builder.sh delete mode 100644 nix/nixcrpkgs/macos/ranlib_builder.sh delete mode 100644 nix/nixcrpkgs/macos/sdk_builder.sh delete mode 100644 nix/nixcrpkgs/macos/strip_builder.sh delete mode 100644 nix/nixcrpkgs/macos/tapi_builder.sh delete mode 100644 nix/nixcrpkgs/macos/toolchain_builder.sh delete mode 100644 nix/nixcrpkgs/macos/wrapper.cpp delete mode 100644 nix/nixcrpkgs/make_derivation.nix delete mode 100644 nix/nixcrpkgs/mingw-w64/binutils/builder.sh delete mode 100644 nix/nixcrpkgs/mingw-w64/binutils/default.nix delete mode 100644 nix/nixcrpkgs/mingw-w64/binutils/deterministic.patch delete mode 100644 nix/nixcrpkgs/mingw-w64/builder.sh delete mode 100644 nix/nixcrpkgs/mingw-w64/default.nix delete mode 100644 nix/nixcrpkgs/mingw-w64/gcc/builder.sh delete mode 100644 nix/nixcrpkgs/mingw-w64/gcc/cppdefault.patch delete mode 100644 nix/nixcrpkgs/mingw-w64/gcc/default.nix delete mode 100644 nix/nixcrpkgs/mingw-w64/gcc/libstdc++-target.patch delete mode 100644 nix/nixcrpkgs/mingw-w64/gcc/mingw-search-paths.patch delete mode 100644 nix/nixcrpkgs/mingw-w64/gcc/no-sys-dirs.patch delete mode 100644 nix/nixcrpkgs/mingw-w64/gcc/ubsan.patch delete mode 100644 nix/nixcrpkgs/mingw-w64/gcc/use-source-date-epoch.patch delete mode 100644 nix/nixcrpkgs/mingw-w64/guid-selectany.patch delete mode 100644 nix/nixcrpkgs/mingw-w64/license_builder.sh delete mode 100644 nix/nixcrpkgs/mingw-w64/usb.patch delete mode 100644 nix/nixcrpkgs/native/default.nix delete mode 100644 nix/nixcrpkgs/native/pkgconf/builder.sh delete mode 100644 nix/nixcrpkgs/native/pkgconf/default.nix delete mode 100644 nix/nixcrpkgs/native/wrappers/builder.sh delete mode 100644 nix/nixcrpkgs/native/wrappers/default.nix delete mode 100644 nix/nixcrpkgs/pkgs.nix delete mode 100644 nix/nixcrpkgs/pkgs/angle/README.md delete mode 100644 nix/nixcrpkgs/pkgs/angle/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/angle/debug_bundle.nix delete mode 100644 nix/nixcrpkgs/pkgs/angle/debug_bundle_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/angle/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/angle/examples.nix delete mode 100644 nix/nixcrpkgs/pkgs/angle/lib.nix delete mode 100644 nix/nixcrpkgs/pkgs/angle/megapatch.patch delete mode 100644 nix/nixcrpkgs/pkgs/angle/samples_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/angle/util.nix delete mode 100644 nix/nixcrpkgs/pkgs/angle/util_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/at-spi2-headers/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/at-spi2-headers/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/at-spi2-headers/license_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/avrdude/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/avrdude/config.sub delete mode 100644 nix/nixcrpkgs/pkgs/avrdude/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/avrdude/extra.conf delete mode 100644 nix/nixcrpkgs/pkgs/curl/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/curl/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/dejavu-fonts/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/dejavu-fonts/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/dejavu-fonts/license_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/devcon/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/devcon/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/devcon/my_xmlhelper.c delete mode 100644 nix/nixcrpkgs/pkgs/expat/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/expat/cve-2016-0718.patch delete mode 100644 nix/nixcrpkgs/pkgs/expat/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/fixesproto/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/fixesproto/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/fixesproto/license_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/gdb/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/gdb/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/gdb/substitute-path-all-filenames.patch delete mode 100644 nix/nixcrpkgs/pkgs/hello/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/hello/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/hello/hello.c delete mode 100644 nix/nixcrpkgs/pkgs/hello_cpp/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/hello_cpp/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/hello_cpp/hello.cpp delete mode 100644 nix/nixcrpkgs/pkgs/inputproto/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/inputproto/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/inputproto/license_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/ion/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/ion/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/kbproto/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/kbproto/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/kbproto/license_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/libgmp/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/libgmp/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/libsigsegv/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/libsigsegv/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/libudev/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/libudev/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/libudev/fill/printf.c delete mode 100644 nix/nixcrpkgs/pkgs/libudev/fill/printf.h delete mode 100644 nix/nixcrpkgs/pkgs/libudev/license_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/libudev/megapatch.patch delete mode 100644 nix/nixcrpkgs/pkgs/libusb/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/libusb/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/libusbp/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/libusbp/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/libusbp/examples_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/libusbp/license_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/libx11/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/libx11/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/libx11/license_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/libxall/builder.rb delete mode 100644 nix/nixcrpkgs/pkgs/libxall/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/libxau/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/libxau/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/libxau/license_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/libxcb/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/libxcb/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/libxcb/example1.c delete mode 100644 nix/nixcrpkgs/pkgs/libxcb/examples_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/libxcb/license_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/libxcb/no-pthread-stubs.patch delete mode 100644 nix/nixcrpkgs/pkgs/libxext/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/libxext/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/libxext/license_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/libxfixes/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/libxfixes/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/libxfixes/license_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/libxi/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/libxi/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/libxi/license_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/lmdb/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/lmdb/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/ncurses/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/ncurses/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/openocd/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/openocd/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/openssl/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/openssl/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/p-load/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/p-load/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/pavr2/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/pavr2/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/pdcurses/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/pdcurses/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/pdcurses/demos_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/pdcurses/examples.nix delete mode 100644 nix/nixcrpkgs/pkgs/pdcurses/lib.nix delete mode 100644 nix/nixcrpkgs/pkgs/qt/absolute-paths.patch delete mode 100644 nix/nixcrpkgs/pkgs/qt/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/qt/core_macros.cmake delete mode 100644 nix/nixcrpkgs/pkgs/qt/dbus-null-pointer.patch delete mode 100644 nix/nixcrpkgs/pkgs/qt/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/qt/dont-test-uxtheme.patch delete mode 100644 nix/nixcrpkgs/pkgs/qt/examples_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/qt/find-x-libs.patch delete mode 100644 nix/nixcrpkgs/pkgs/qt/font-dir.patch delete mode 100644 nix/nixcrpkgs/pkgs/qt/license_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/qt/macos-config.patch delete mode 100644 nix/nixcrpkgs/pkgs/qt/pc-debug-name.patch delete mode 100644 nix/nixcrpkgs/pkgs/qt/pkg-config-cross.patch delete mode 100644 nix/nixcrpkgs/pkgs/qt/win32-link-object-max.patch delete mode 100644 nix/nixcrpkgs/pkgs/qt/wrapper_builder.rb delete mode 100644 nix/nixcrpkgs/pkgs/readline/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/readline/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/readline/readline-1.patch delete mode 100644 nix/nixcrpkgs/pkgs/tic/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/tic/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/usbview/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/usbview/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/usbview/megapatch.patch delete mode 100644 nix/nixcrpkgs/pkgs/usbview/my_xmlhelper.c delete mode 100644 nix/nixcrpkgs/pkgs/xcb-proto/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/xcb-proto/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/xcb-proto/license_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/xcb-util-image/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/xcb-util-image/license_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/xcb-util-image/util_image_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/xcb-util-keysyms/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/xcb-util-keysyms/license_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/xcb-util-keysyms/util_keysyms_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/xcb-util-renderutil/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/xcb-util-renderutil/license_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/xcb-util-renderutil/util_renderutil_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/xcb-util-wm/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/xcb-util-wm/license_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/xcb-util-wm/util_wm_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/xcb-util/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/xcb-util/license_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/xcb-util/util_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/xextproto/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/xextproto/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/xextproto/license_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/xorg-macros/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/xorg-macros/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/xorg-macros/license_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/xproto/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/xproto/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/xproto/license_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/xtrans/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/xtrans/default.nix delete mode 100644 nix/nixcrpkgs/pkgs/xtrans/license_builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/zlib/builder.sh delete mode 100644 nix/nixcrpkgs/pkgs/zlib/default.nix delete mode 100644 nix/nixcrpkgs/pretend_stdenv/setup delete mode 100644 nix/nixcrpkgs/support/derivations.txt delete mode 100644 nix/nixcrpkgs/support/expand_brackets.rb delete mode 100644 nix/nixcrpkgs/support/graph.rb delete mode 100755 nix/nixcrpkgs/support/manage delete mode 100644 nix/nixcrpkgs/top.nix delete mode 100644 nix/nixpkgs.nix delete mode 100644 nix/ops/boot-ship.nix delete mode 100755 nix/ops/brass/builder.sh delete mode 100644 nix/ops/brass/default.nix delete mode 100644 nix/ops/default.nix delete mode 100755 nix/ops/fakeship/builder.sh delete mode 100644 nix/ops/fakeship/default.nix delete mode 100644 nix/ops/image/default.nix delete mode 100755 nix/ops/ivory/builder.sh delete mode 100644 nix/ops/ivory/default.nix delete mode 100755 nix/ops/solid/builder.sh delete mode 100644 nix/ops/solid/default.nix delete mode 100644 nix/ops/test/builder.sh delete mode 100644 nix/ops/test/default.nix create mode 100644 nix/overlays/arm.nix create mode 100644 nix/overlays/musl.nix create mode 100644 nix/overlays/native.nix create mode 100644 nix/overlays/static.nix create mode 100644 nix/pkgs/argon2u/default.nix delete mode 100644 nix/pkgs/arvo-ropsten/builder.sh delete mode 100644 nix/pkgs/arvo-ropsten/default.nix delete mode 100644 nix/pkgs/arvo/builder.sh create mode 100644 nix/pkgs/ca-bundle/default.nix delete mode 100644 nix/pkgs/default.nix create mode 100644 nix/pkgs/ed25519/default.nix delete mode 100644 nix/pkgs/ent/builder.sh delete mode 100644 nix/pkgs/ent/cross.nix delete mode 100644 nix/pkgs/ge-additions/builder.sh delete mode 100644 nix/pkgs/ge-additions/cross.nix delete mode 100644 nix/pkgs/ge-additions/release.sh create mode 100644 nix/pkgs/herb/default.nix create mode 100644 nix/pkgs/hs/default.nix delete mode 100644 nix/pkgs/libaes_siv/builder.sh delete mode 100644 nix/pkgs/libaes_siv/cross.nix delete mode 100644 nix/pkgs/libaes_siv/release.sh create mode 100644 nix/pkgs/libscrypt/default.nix create mode 100644 nix/pkgs/libsigsegv/disable-stackvma_fault-linux-arm.patch create mode 100644 nix/pkgs/libsigsegv/disable-stackvma_fault-linux-i386.patch create mode 100644 nix/pkgs/murmur3/default.nix create mode 100644 nix/pkgs/pill/brass.nix create mode 100644 nix/pkgs/pill/brass.sh create mode 100644 nix/pkgs/pill/builder.nix create mode 100644 nix/pkgs/pill/ivory.nix create mode 100644 nix/pkgs/pill/ivory.sh create mode 100644 nix/pkgs/pill/solid.nix create mode 100644 nix/pkgs/pill/solid.sh create mode 100644 nix/pkgs/softfloat3/default.nix delete mode 100644 nix/pkgs/urbit/libsigsegv_fix.patch delete mode 100644 nix/pkgs/urbit/release.nix delete mode 100644 nix/pkgs/urbit/release.sh delete mode 100644 nix/pkgs/urbit/shell.nix delete mode 100644 nix/release.nix create mode 100644 nix/sources.json create mode 100644 nix/sources.nix create mode 100644 pkg/ent/shell.nix create mode 100644 pkg/ge-additions/shell.nix delete mode 100644 pkg/herb/default.nix create mode 100644 pkg/herb/shell.nix delete mode 100644 pkg/hs/default.nix delete mode 100644 pkg/hs/terminal-progress-bar/shell.nix create mode 100644 shell.nix diff --git a/ci.nix b/ci.nix new file mode 100644 index 0000000000..9e03a56a77 --- /dev/null +++ b/ci.nix @@ -0,0 +1,123 @@ +/* Examples + + Perform the same evaluation that occurs on CI via: + + $ NIX_PATH="" nix-instantiate ci.nix --arg supportedSystems '["x86_64-darwin"]' + + Build the release tarball: + + $ NIX_PATH="" nix-instantiate ci.nix -A darwin.tarball +*/ + +{ supportedSystems ? [ "x86_64-linux" "x86_64-darwin" ] }: + +let + + inherit (import ./nix/default.nix { }) + lib recurseIntoAttrs haskell-nix callPackage; + + # Local library import from derivation functions such as fetchGitHubLFS, etc. + # upon which local package defintions are dependent. + localLib = callPackage ./nix/lib { }; + + # The key with google storage bucket write permission, + # deployed to ci via nixops `deployment.keys."service-account.json"`. + serviceAccountKey = builtins.readFile ("/var/run/keys/service-account.json"); + + # Push a split output derivation containing "out" and "hash" outputs. + pushObject = name: extension: drv: + let + # Use the sha256 for the object key suffix. + sha256 = builtins.readFile (drv.hash + "/sha256"); + # Use md5 as an idempotency check for gsutil + md5 = builtins.readFile (drv.hash + "/md5"); + in localLib.pushStorageObject { + inherit serviceAccountKey md5; + + bucket = "bootstrap.urbit.org"; + object = "ci/${name}-${sha256}.${extension}"; + name = "${name}.${extension}"; + file = drv.out; + }; + + # Push a split output pill derivation containing "build" attribute with the + # with the ".pill" file extension. + pushPill = name: drv: pushObject name "pill" drv.build; + + systems = lib.filterAttrs (_: v: builtins.elem v.system supportedSystems) { + linux = { + system = "x86_64-linux"; + crossSystem = lib.systems.examples.musl64; + }; + + darwin = { + system = "x86_64-darwin"; + crossSystem = null; + }; + }; + +in localLib.dimension "system" systems (systemName: + { system, crossSystem }: + let + # Check the pinned haskell.nix hashes for correctness. + checkMaterialization = true; + + # Shared libraries/executables for the build (current) system. + localPackages = import ./default.nix { + inherit system checkMaterialization; + + enableStatic = false; + }; + + # Static libraries/executables for the host (cross) system. + staticPackages = import ./default.nix { + inherit system crossSystem checkMaterialization; + + enableStatic = true; + }; + + # Filter the stack project to only our locally declared packages. + haskellPackages = + haskell-nix.haskellLib.selectProjectPackages staticPackages.hs; + + # The top-level set of attributes to build on ci. + finalPackages = localPackages // { + # Expose the nix-shell derivation as a sanity check. + shell = import ./shell.nix; + + # Replace the top-level urbit attribute with the static variant. + urbit = staticPackages.urbit; + + # Replace the top-level tarball attribute with the static variant. + tarball = staticPackages.tarball; + + # Replace the localPackages.hs attribute with the individual components + # displayed as top-level attributes: + # + # .hs.library.[...] + # .hs.tests.[...] + # .hs.bencharmks.[...] + # ... + hs = localLib.collectHaskellComponents haskellPackages; + + # Push the tarball to the remote google storage bucket. + release = let + version = builtins.readFile ./pkg/urbit/version; + name = "urbit-v${version}-${system}"; + in pushObject name "tar.gz" staticPackages.tarball; + + # Replace top-level pill attributes with push to google storage variants. + } // lib.optionalAttrs (system == "x86_64-linux") { + ivory = pushPill "ivory" localPackages.ivory; + brass = pushPill "brass" localPackages.brass; + solid = pushPill "solid" localPackages.solid; + + ivory-ropsten = pushPill "ivory-ropsten" localPackages.ivory-ropsten; + brass-ropsten = pushPill "brass-ropsten" localPackages.brass-ropsten; + }; + + # Filter derivations that have meta.platform missing the current system, + # such as testFakeShip on darwin. + platformFilter = localLib.platformFilterGeneric system; + + in localLib.filterAttrsOnlyRecursive (_: v: platformFilter v) finalPackages) diff --git a/default.nix b/default.nix index a21725f733..b1782a173b 100644 --- a/default.nix +++ b/default.nix @@ -1,8 +1,164 @@ +/* Examples + + Shared urbit and urbit-worker binaries: + + $ nix-build -A urbit + + Static urbit and urbit-worker binaries: + + $ nix-build -A urbit --arg enableSatic true + + Static urbit-king binary: + + $ nix-build -A hs.urbit-king.components.exes.urbit-king --arg enableStatic true + + Static release tarball: + + $ nix-build -A tarball --arg enableStatic true + + Build a pill: + + $ nix-build -A ivory.build + $ nix-build -A brass.build + $ nix-build -A solid.build + + Build a specific Haskell package from ./pkg/hs: + + $ nix-build -A hs.urbit-noun.components.library + $ nix-build -A hs.urbit-atom.components.benchmarks.urbit-atom-bench + $ nix-build -A hs.urbit-atom.components.tests.urbit-atom-tests +*/ + +# The build system where packages will be _built_. +{ system ? builtins.currentSystem + # The host system where packages will _run_. +, crossSystem ? null + # Additional sources.json overrides. +, sources ? { } + # Additional nixpkgs.config overrides. +, config ? { } + # Additional nixpkgs.overlays. +, overlays ? [ ] + # Overlays to apply to the last package set in cross compilation. +, crossOverlays ? [ ] + # Whether to use pkgs.pkgsStatic.* to obtain statically linked package + # dependencies - ie. when building fully-static libraries or executables. +, enableStatic ? crossSystem != null + # Whether to check that the pinned hashes for haskell.nix are correct. + # Set to false by default since it's a lot slower, but true for ci. +, checkMaterialization ? false }: + let - pkgs = import ./nix/pkgs {}; - deps = import ./nix/deps {}; + pkgs = import ./nix/default.nix { + inherit system crossSystem sources config overlays crossOverlays; + }; -in + # Local library import from derivation functions such as fetchGitHubLFS, etc. + # upon which local package defintions are dependent. + localLib = pkgs.callPackage ./nix/lib { }; - deps // pkgs + # Utilise nixpkgs's top-level/static.nix overlay if required. + hostPackages = if enableStatic then pkgs.pkgsStatic else pkgs; + + # Enrich the global package set with our local functions and packages. + callPackage = + pkgs.lib.callPackageWith (hostPackages // localLib // localPackages); + + # Local vendored packages defined in ./pkg. + # For non-vendored nixpkgs specific package overrides, see ./nix/overlays. + localPackages = { + argon2u = callPackage ./nix/pkgs/argon2u { }; + + ca-bundle = callPackage ./nix/pkgs/ca-bundle { }; + + ed25519 = callPackage ./nix/pkgs/ed25519 { }; + + ent = callPackage ./nix/pkgs/ent { }; + + ge-additions = callPackage ./nix/pkgs/ge-additions { }; + + libaes_siv = callPackage ./nix/pkgs/libaes_siv { }; + + libscrypt = callPackage ./nix/pkgs/libscrypt { }; + + murmur3 = callPackage ./nix/pkgs/murmur3 { }; + + softfloat3 = callPackage ./nix/pkgs/softfloat3 { }; + + herb = callPackage ./nix/pkgs/herb { inherit (pkgs) python; }; + + arvo = callPackage ./nix/pkgs/arvo { }; + + ivory = callPackage ./nix/pkgs/pill/ivory.nix { }; + + brass = callPackage ./nix/pkgs/pill/brass.nix { }; + + solid = callPackage ./nix/pkgs/pill/solid.nix { }; + + urbit = callPackage ./nix/pkgs/urbit { inherit enableStatic; }; + + hs = callPackage ./nix/pkgs/hs { + inherit (pkgs) haskell-nix; + inherit checkMaterialization enableStatic; + }; + }; + + # Additional top-level packages and attributes exposed for convenience. + extraPackages = with localPackages; { + # Expose packages we've local customisations for. + inherit (hostPackages) libsigsegv; + + urbit-debug = urbit.override { enableDebug = true; }; + urbit-tests = localLib.testFakeShip { + inherit urbit herb; + + pill = solid.lfs; + }; + + ivory-ropsten = ivory.override { arvo = arvo.ropsten; }; + brass-ropsten = brass.override { arvo = arvo.ropsten; }; + + # FIXME: tarball binaries need executable permissions set? + + # Create a .tar.gz of the primary binaries. + tarball = localLib.makeReleaseTarball { + name = "urbit-tarball"; + contents = { + "urbit" = "${urbit}/bin/urbit"; + "urbit-worker" = "${urbit}/bin/urbit-worker"; + "urbit-king" = + "${hs.urbit-king.components.exes.urbit-king}/bin/urbit-king"; + }; + }; + + # A convenience function for constructing a shell.nix for any of the + # localPackage derivations by automatically propagating any dependencies such + # as buildInputs to the nix-shell. + # + # Example: + # + # let + # pkgs = import ./default.nix { }; + # in pkgs.shellFor { + # packages = ps: [ + # ps.urbit + # ps.herb + # ]; + # } + # + shellFor = { name, packages, ... }@attrs: + pkgs.mkShell ({ + inputsFrom = packages localPackages; + } // builtins.removeAttrs attrs [ "packages" ]); + }; + + # Ensure that in the case of cross-compilation we're not statically linking + # against glibc. This is typically a sign that crossSystem is misconfigured. + checkPlatform = + if enableStatic && hostPackages.stdenv.hostPlatform.libc == "glibc" then + builtins.trace "warning: statically linking against glibc." + else + pkgs.lib.id; + +in checkPlatform (localPackages // extraPackages) diff --git a/nix/cachix/local.nix b/nix/cachix/local.nix deleted file mode 100644 index 753a00a0cd..0000000000 --- a/nix/cachix/local.nix +++ /dev/null @@ -1,22 +0,0 @@ -# All the non-release builds that should be cached in `cachix`. - -let - - pkgs = import ../pkgs {}; - deps = import ../deps {}; - - # Cache the result of cloning source repos. - repos = { - argon2-src = deps.argon2.src; - ed25519-src = deps.ed25519.src; - h2o-src = deps.h2o.src; - murmur3-src = deps.murmur3.src; - scrypt-src = deps.scrypt.src; - secp256k1-src = deps.secp256k1.src; - softfloat3-src = deps.softfloat3.src; - uv-src = deps.uv.src; - }; - -in - - deps // pkgs // repos diff --git a/nix/cachix/release.nix b/nix/cachix/release.nix deleted file mode 100644 index bc63f052ac..0000000000 --- a/nix/cachix/release.nix +++ /dev/null @@ -1,11 +0,0 @@ -let - - util = import ./util.nix; - nixcrpkgs = import ../nixcrpkgs.nix; - release = import ../release.nix; - all_releases = util.flattenSetPrefix release; - crosstools = { inherit (nixcrpkgs.native) pkgconf; }; - -in - - crosstools // all_releases diff --git a/nix/cachix/tests.nix b/nix/cachix/tests.nix deleted file mode 100644 index 2248a5cea2..0000000000 --- a/nix/cachix/tests.nix +++ /dev/null @@ -1,7 +0,0 @@ -let - ops = import ../ops/default.nix {}; -in - { - results = ops.test; - fakebus = ops.bus; - } diff --git a/nix/cachix/util.nix b/nix/cachix/util.nix deleted file mode 100644 index 6eada20f4c..0000000000 --- a/nix/cachix/util.nix +++ /dev/null @@ -1,26 +0,0 @@ -# Some utility functions: - -rec { - - # The inverse of builtins.listToAttrs - attrsToList = o: - map (a: { name=a; value=builtins.getAttr a o; }) - (builtins.attrNames o); - - # ∀o,x,y. produce o' such that o'.y == o.x.y (assuming no conflicts) - flattenSet = o: - builtins.foldl' (acc: v: acc // v) {} - (builtins.attrValues o); - - prefixSetAttrs = prefix: o: - builtins.listToAttrs - (map ({name, value}: { name=prefix + name; value=value; }) - (attrsToList o)); - - # ∀o,x,y. produce o' such that o'.x-y == o.x.y - flattenSetPrefix = o: - (builtins.foldl' (acc: o: acc // o) {} - (map ({name, value}: prefixSetAttrs name value) - (attrsToList o))); - -} diff --git a/nix/crossdeps.nix b/nix/crossdeps.nix deleted file mode 100644 index e942b842b6..0000000000 --- a/nix/crossdeps.nix +++ /dev/null @@ -1,14 +0,0 @@ -crossenv: - -rec { - argon2 = import ./deps/argon2/cross.nix { inherit crossenv; }; - murmur3 = import ./deps/murmur3/cross.nix { inherit crossenv; }; - uv = import ./deps/uv/cross.nix { inherit crossenv; }; - ed25519 = import ./deps/ed25519/cross.nix { inherit crossenv; }; - scrypt = import ./deps/scrypt/cross.nix { inherit crossenv; }; - softfloat3 = import ./deps/softfloat3/cross.nix { inherit crossenv; }; - secp256k1 = import ./deps/secp256k1/cross.nix { inherit crossenv; }; - h2o = import ./deps/h2o/cross.nix { inherit crossenv uv; }; - ivory-header = import ./deps/ivory-header/cross.nix { inherit crossenv; }; - ca-header = import ./deps/ca-header/cross.nix { inherit crossenv; }; -} diff --git a/nix/default.nix b/nix/default.nix new file mode 100644 index 0000000000..bef5c54a7b --- /dev/null +++ b/nix/default.nix @@ -0,0 +1,45 @@ +# The build system where packages will be _built_. +{ system ? builtins.currentSystem + # The host system where packages will _run_. +, crossSystem ? null + # Additional sources.json overrides. +, sources ? { } + # Additional nixpkgs.config overrides. +, config ? { } + # Additional nixpkgs.overlays. +, overlays ? [ ] + # Overlays to apply to the last package set in cross compilation. +, crossOverlays ? [ ] }: + +let + + finalSources = import ./sources.nix { inherit pkgs; } // sources; + + haskellNix = import finalSources."haskell.nix" { + sourcesOverride = { + hackage = finalSources."hackage.nix"; + stackage = finalSources."stackage.nix"; + }; + }; + + finalOverlays = [ + # Add top-level .sources attribute for other overlays to access niv sources. + (_final: _prev: { sources = finalSources; }) + + # General unguarded (native) overrides for nixpkgs. + (import ./overlays/native.nix) + + # Specific overrides guarded by the host platform. + (import ./overlays/musl.nix) + ] ++ haskellNix.overlays ++ overlays; + + pkgs = import finalSources.nixpkgs { + inherit system crossSystem crossOverlays; + + config = haskellNix.config // config; + overlays = finalOverlays; + }; + +in pkgs // { + pkgsStatic = pkgs.pkgsStatic.extend (import ./overlays/static.nix); +} diff --git a/nix/deps-env.nix b/nix/deps-env.nix deleted file mode 100644 index 6f7357b4f6..0000000000 --- a/nix/deps-env.nix +++ /dev/null @@ -1,31 +0,0 @@ -let - - pkgs = import ./nixpkgs.nix; - tlon = import ./pkgs { pkgs=pkgs; }; - deps = import ./deps { pkgs=pkgs; }; - - tools = - with pkgs; - [ cargo rustc meson ninja pkgconfig libtool gdb ]; - - libs = - with pkgs; - [ openssl curl gmp scrypt libsigsegv openssl zlib lmdb ]; - - osx = - with pkgs; - lib.optionals stdenv.isDarwin ( - with darwin.apple_sdk.frameworks; - [ Cocoa CoreServices ]); - - vendor = - with deps; - [ argon2 ed25519 h2o murmur3 scrypt secp256k1 softfloat3 uv ent ge-additions ivory-header ca-header ]; - -in - -pkgs.stdenv.mkDerivation rec { - name = "urbit-deps-env"; - env = pkgs.buildEnv { name = name; paths = buildInputs; }; - buildInputs = tools ++ libs ++ osx ++ vendor; -} diff --git a/nix/deps/argon2/builder.sh b/nix/deps/argon2/builder.sh deleted file mode 100644 index 9430b939f9..0000000000 --- a/nix/deps/argon2/builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $stdenv/setup - -cp -r $src ./src -chmod -R a+w ./src -cd ./src - -sed -i 's|ar rcs|${AR} rcs|' Makefile - -make libargon2.a -j4 - -mkdir -p $out/{lib,include} -cp libargon2.a $out/lib -cp include/argon2.h $out/include -cp ./src/blake2/*.h $out/include diff --git a/nix/deps/argon2/cross.nix b/nix/deps/argon2/cross.nix deleted file mode 100644 index f7776d03ee..0000000000 --- a/nix/deps/argon2/cross.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ crossenv }: - -crossenv.make_derivation rec { - name = "argon2-4da94"; - builder = ./builder.sh; - - CC = "${crossenv.host}-gcc"; - AR = "${crossenv.host}-ar"; - NO_THREADS = true; - - src = crossenv.nixpkgs.fetchFromGitHub { - owner = "urbit"; - repo = "argon2"; - rev = "4da94a611ee62bad87ab2b131ffda3bcc0723d9c"; - sha256 = "0bqq1hg367l4jkb6cqhxlblpvdbwz3l586qsfakwzfd9wdvnm3yc"; - }; -} diff --git a/nix/deps/argon2/default.nix b/nix/deps/argon2/default.nix deleted file mode 100644 index e101ca6968..0000000000 --- a/nix/deps/argon2/default.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ pkgs }: - -pkgs.stdenv.mkDerivation rec { - name = "argon2-4da94"; - builder = ./builder.sh; - NO_THREADS = true; - src = pkgs.fetchFromGitHub { - owner = "urbit"; - repo = "argon2"; - rev = "4da94a611ee62bad87ab2b131ffda3bcc0723d9c"; - sha256 = "0bqq1hg367l4jkb6cqhxlblpvdbwz3l586qsfakwzfd9wdvnm3yc"; - }; -} diff --git a/nix/deps/ca-header/builder.sh b/nix/deps/ca-header/builder.sh deleted file mode 100755 index 413a515ec4..0000000000 --- a/nix/deps/ca-header/builder.sh +++ /dev/null @@ -1,27 +0,0 @@ -source $stdenv/setup - -set -ex - -cleanup () { - echo "done" -} - -trap cleanup EXIT - - -if ! [ -f "$SSL_CERT_FILE" ]; then - echo "$SSL_CERT_FILE doesn't exist" - exit 1 -fi - -mkdir -p ./include - -cat $SSL_CERT_FILE > include/ca-bundle.crt -xxd -i include/ca-bundle.crt > ca-bundle.h - -mkdir -p $out/include - -mv ca-bundle.h $out/include -rm -rf ./include - -set +x diff --git a/nix/deps/ca-header/cross.nix b/nix/deps/ca-header/cross.nix deleted file mode 100644 index 2595eb01a9..0000000000 --- a/nix/deps/ca-header/cross.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ crossenv }: - -crossenv.make_derivation rec { - name = "ca-bundle.h"; - builder = ./builder.sh; - native_inputs = with crossenv.nixpkgs; [ cacert xxd ]; - SSL_CERT_FILE = "${crossenv.nixpkgs.cacert}/etc/ssl/certs/ca-bundle.crt"; -} diff --git a/nix/deps/ca-header/default.nix b/nix/deps/ca-header/default.nix deleted file mode 100644 index 6e65f14547..0000000000 --- a/nix/deps/ca-header/default.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ pkgs }: - -pkgs.stdenv.mkDerivation { - name = "ca-bundle.h"; - builder = ./builder.sh; - nativeBuildInputs = with pkgs; [ cacert xxd ]; -} diff --git a/nix/deps/default.nix b/nix/deps/default.nix deleted file mode 100644 index 8f44e75015..0000000000 --- a/nix/deps/default.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ pkgs ? import ../nixpkgs.nix }: - -rec { - argon2 = import ./argon2 { inherit pkgs; }; - murmur3 = import ./murmur3 { inherit pkgs; }; - uv = import ./uv { inherit pkgs; }; - ed25519 = import ./ed25519 { inherit pkgs; }; - scrypt = import ./scrypt { inherit pkgs; }; - softfloat3 = import ./softfloat3 { inherit pkgs; }; - secp256k1 = import ./secp256k1 { inherit pkgs; }; - h2o = import ./h2o { inherit pkgs uv; }; - ivory-header = import ./ivory-header { inherit pkgs; }; - ca-header = import ./ca-header { inherit pkgs; }; -} diff --git a/nix/deps/ed25519/builder.sh b/nix/deps/ed25519/builder.sh deleted file mode 100644 index e37423356f..0000000000 --- a/nix/deps/ed25519/builder.sh +++ /dev/null @@ -1,29 +0,0 @@ -source $stdenv/setup - -sources=" \ - $src/src/add_scalar.c \ - $src/src/seed.c \ - $src/src/verify.c \ - $src/src/add_scalar.c \ - $src/src/sha512.c \ - $src/src/ge.c \ - $src/src/fe.c \ - $src/src/keypair.c \ - $src/src/sign.c \ - $src/src/sc.c \ - $src/src/key_exchange.c \ -" - -CFLAGS="-O3 -Wall -I$src/src" - -for fn in $sources -do echo $CC $CFLAGS -c $fn -o $(basename $fn).o - $CC -O3 -Wall -I$src/src -c $fn -o $(basename $fn).o -done - -mkdir -p $out/{lib,include} - -$AR rcs $out/lib/libed25519.a *.o -echo $AR rcs $out/lib/libed25519.a *.o - -cp $src/src/*.h $out/include diff --git a/nix/deps/ed25519/cross.nix b/nix/deps/ed25519/cross.nix deleted file mode 100644 index 76ae2a5d52..0000000000 --- a/nix/deps/ed25519/cross.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ crossenv }: - -crossenv.make_derivation rec { - name = "ed25519-76385"; - builder = ./builder.sh; - - CC = "${crossenv.host}-gcc"; - AR = "${crossenv.host}-ar"; - - src = crossenv.nixpkgs.fetchFromGitHub { - owner = "urbit"; - repo = "ed25519"; - rev = "76385f2ebbbc9580a9c236952d68d11d73a6135c"; - sha256 = "0s1spif4s9lgcwcny3fl2fvpbw6acqn3s8r6qxnrmkd9icgyw4cp"; - }; -} diff --git a/nix/deps/ed25519/default.nix b/nix/deps/ed25519/default.nix deleted file mode 100644 index 4d4ee42c83..0000000000 --- a/nix/deps/ed25519/default.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ pkgs }: - -pkgs.stdenv.mkDerivation rec { - name = "ed25519-76385"; - builder = ./builder.sh; - src = pkgs.fetchFromGitHub { - owner = "urbit"; - repo = "ed25519"; - rev = "76385f2ebbbc9580a9c236952d68d11d73a6135c"; - sha256 = "0s1spif4s9lgcwcny3fl2fvpbw6acqn3s8r6qxnrmkd9icgyw4cp"; - }; -} diff --git a/nix/deps/h2o/builder.sh b/nix/deps/h2o/builder.sh deleted file mode 100644 index 4c5c71723b..0000000000 --- a/nix/deps/h2o/builder.sh +++ /dev/null @@ -1,109 +0,0 @@ -source $stdenv/setup - -sources=" \ - deps/cloexec/cloexec.c \ - deps/libgkc/gkc.c \ - deps/libyrmcds/close.c \ - deps/libyrmcds/connect.c \ - deps/libyrmcds/recv.c \ - deps/libyrmcds/send.c \ - deps/libyrmcds/send_text.c \ - deps/libyrmcds/socket.c \ - deps/libyrmcds/strerror.c \ - deps/libyrmcds/text_mode.c \ - deps/picohttpparser/picohttpparser.c \ - lib/common/cache.c \ - lib/common/file.c \ - lib/common/filecache.c \ - lib/common/hostinfo.c \ - lib/common/http1client.c \ - lib/common/memcached.c \ - lib/common/memory.c \ - lib/common/multithread.c \ - lib/common/serverutil.c \ - lib/common/socket.c \ - lib/common/socketpool.c \ - lib/common/string.c \ - lib/common/time.c \ - lib/common/timeout.c \ - lib/common/url.c \ - lib/core/config.c \ - lib/core/configurator.c \ - lib/core/context.c \ - lib/core/headers.c \ - lib/core/logconf.c \ - lib/core/proxy.c \ - lib/core/request.c \ - lib/core/token.c \ - lib/core/util.c \ - lib/handler/access_log.c \ - lib/handler/chunked.c \ - lib/handler/compress.c \ - lib/handler/compress/gzip.c \ - lib/handler/errordoc.c \ - lib/handler/expires.c \ - lib/handler/fastcgi.c \ - lib/handler/file.c \ - lib/handler/headers.c \ - lib/handler/mimemap.c \ - lib/handler/proxy.c \ - lib/handler/redirect.c \ - lib/handler/reproxy.c \ - lib/handler/throttle_resp.c \ - lib/handler/status.c \ - lib/handler/headers_util.c \ - lib/handler/status/events.c \ - lib/handler/status/requests.c \ - lib/handler/http2_debug_state.c \ - lib/handler/status/durations.c \ - lib/handler/configurator/access_log.c \ - lib/handler/configurator/compress.c \ - lib/handler/configurator/errordoc.c \ - lib/handler/configurator/expires.c \ - lib/handler/configurator/fastcgi.c \ - lib/handler/configurator/file.c \ - lib/handler/configurator/headers.c \ - lib/handler/configurator/proxy.c \ - lib/handler/configurator/redirect.c \ - lib/handler/configurator/reproxy.c \ - lib/handler/configurator/throttle_resp.c \ - lib/handler/configurator/status.c \ - lib/handler/configurator/http2_debug_state.c \ - lib/handler/configurator/headers_util.c \ - lib/http1.c \ - lib/tunnel.c \ - lib/http2/cache_digests.c \ - lib/http2/casper.c \ - lib/http2/connection.c \ - lib/http2/frame.c \ - lib/http2/hpack.c \ - lib/http2/scheduler.c \ - lib/http2/stream.c \ - lib/http2/http2_debug_state.c \ -" - -CFLAGS=" \ - -O3 \ - -Wall -Wno-unused-value -Wno-unused-function \ - -I$src/include \ - -I$src/deps/cloexec \ - -I$src/deps/brotli/enc \ - -I$src/deps/golombset \ - -I$src/deps/libgkc \ - -I$src/deps/libyrmcds \ - -I$src/deps/klib \ - -I$src/deps/neverbleed \ - -I$src/deps/picohttpparser \ - -I$src/deps/picotest \ - -I$src/deps/yaml/include \ - -I$src/deps/yoml -" - -for s in $sources -do cc $CFLAGS -c $src/$s -o $(sed 's|/|_|g; s/.c$/.o/' <<< $s) -done - -mkdir -p $out/{lib,include} -ar rcs $out/lib/libh2o.a *.o -cp -r $src/include/* $out/include -cp $src/deps/picohttpparser/picohttpparser.h $out/include diff --git a/nix/deps/h2o/cross.nix b/nix/deps/h2o/cross.nix deleted file mode 100644 index 49b6ce3dee..0000000000 --- a/nix/deps/h2o/cross.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ crossenv, uv }: - -crossenv.make_derivation rec { - inherit (crossenv) openssl zlib; - inherit uv; - - name = "h2o-0ed9a"; - cross_inputs = [ uv crossenv.openssl crossenv.zlib ]; - builder = ./cross.sh; - - src = crossenv.nixpkgs.fetchFromGitHub { - owner = "urbit"; - repo = "h2o"; - rev = "0ed9ac70757a16ec45f91b8a347850d9699c3fb1"; - sha256 = "16b5zbwdq371hhqga76dh7x4c0qr3xb5ah9r8hnm6rip460p6xpm"; - }; -} diff --git a/nix/deps/h2o/cross.sh b/nix/deps/h2o/cross.sh deleted file mode 100644 index e91314996b..0000000000 --- a/nix/deps/h2o/cross.sh +++ /dev/null @@ -1,26 +0,0 @@ -source $stdenv/setup - -cp -r $src src -chmod -R u+w src -cd src - -cmake-cross . \ - -DZLIB_LIBRARY=$zlib/lib/libz.a \ - -DZLIB_INCLUDE_DIR=$zlib/include \ - -DCMAKE_INSTALL_PREFIX=$out \ - -DBUILD_SHARED_LIBS=off \ - -DWITH_MRUBY=off \ - -DWITH_BUNDLED_SSL=off \ - -DWITH_PICOTLS=on - -make libh2o - -mkdir -p $out/{lib,lib/pkgconfig,include} - -cp ./libh2o.a $out/lib - -cp ./libh2o.pc $out/lib/pkgconfig - -cp -r include/* $out/include - -cp deps/picohttpparser/picohttpparser.h $out/include diff --git a/nix/deps/h2o/default.nix b/nix/deps/h2o/default.nix deleted file mode 100644 index 101edbeb78..0000000000 --- a/nix/deps/h2o/default.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ pkgs, uv }: - -pkgs.stdenv.mkDerivation rec { - name = "h2o-0ed9a"; - buildInputs = [ uv pkgs.openssl pkgs.zlib ]; - builder = ./builder.sh; - src = pkgs.fetchFromGitHub { - owner = "urbit"; - repo = "h2o"; - rev = "0ed9ac70757a16ec45f91b8a347850d9699c3fb1"; - sha256 = "16b5zbwdq371hhqga76dh7x4c0qr3xb5ah9r8hnm6rip460p6xpm"; - }; -} diff --git a/nix/deps/ivory-header/builder.sh b/nix/deps/ivory-header/builder.sh deleted file mode 100755 index 225ed8a608..0000000000 --- a/nix/deps/ivory-header/builder.sh +++ /dev/null @@ -1,35 +0,0 @@ -source $stdenv/setup - -set -e - -if ! [ -f "$IVORY" ]; then - echo "$IVORY doesn't exist" - exit 1 -fi - -# -# heuristics to confirm the ivory pill is valid -# - -# first 7 bytes != "version" (start of an lfs pointer) -# -if [ "$(head -c 7 "$IVORY")" = "version" ]; then - echo "$IVORY is an LFS pointer (it starts with 'version')" - echo "to fix, run: git lfs install" - exit 1 -fi - -# greater than 10KB -# -if ! [ $(du -k "$IVORY" | cut -f1) -gt 10 ]; then - echo "$IVORY is less than 10KB" - exit 1 -fi - -cat $IVORY > u3_Ivory.pill -xxd -i u3_Ivory.pill > ivory.h - -mkdir -p $out/include - -mv ivory.h $out/include -rm u3_Ivory.pill diff --git a/nix/deps/ivory-header/cross.nix b/nix/deps/ivory-header/cross.nix deleted file mode 100644 index 6939a84de0..0000000000 --- a/nix/deps/ivory-header/cross.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ - crossenv, - ivory ? ../../../bin/ivory.pill -}: - -crossenv.make_derivation rec { - name = "ivory.h"; - builder = ./builder.sh; - native_inputs = with crossenv.nixpkgs; [ xxd ]; - IVORY = ivory; -} diff --git a/nix/deps/ivory-header/default.nix b/nix/deps/ivory-header/default.nix deleted file mode 100644 index 0e461a7cab..0000000000 --- a/nix/deps/ivory-header/default.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ - pkgs, - ivory ? ../../../bin/ivory.pill -}: - -pkgs.stdenv.mkDerivation { - name = "ivory.h"; - builder = ./builder.sh; - nativeBuildInputs = with pkgs; [ xxd ]; - IVORY = ivory; -} diff --git a/nix/deps/murmur3/builder.sh b/nix/deps/murmur3/builder.sh deleted file mode 100644 index 9afd6918a0..0000000000 --- a/nix/deps/murmur3/builder.sh +++ /dev/null @@ -1,11 +0,0 @@ -source $stdenv/setup - -echo $CC -fPIC -O3 -o murmur3.o -c $src/murmur3.c -$CC -fPIC -O3 -o murmur3.o -c $src/murmur3.c - -mkdir -p $out/{lib,include} - -echo $AR rcs $out/lib/libmurmur3.a murmur3.o -$AR rcs $out/lib/libmurmur3.a murmur3.o - -cp $src/murmur3.h $out/include diff --git a/nix/deps/murmur3/cross.nix b/nix/deps/murmur3/cross.nix deleted file mode 100644 index 024f58656d..0000000000 --- a/nix/deps/murmur3/cross.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ crossenv }: - -crossenv.make_derivation rec { - name = "murmur3-71a75"; - builder = ./builder.sh; - - CC = "${crossenv.host}-gcc"; - AR = "${crossenv.host}-ar"; - - src = crossenv.nixpkgs.fetchFromGitHub { - owner = "urbit"; - repo = "murmur3"; - rev = "71a75d57ca4e7ca0f7fc2fd84abd93595b0624ca"; - sha256 = "0k7jq2nb4ad9ajkr6wc4w2yy2f2hkwm3nkbj2pklqgwsg6flxzwg"; - }; -} diff --git a/nix/deps/murmur3/default.nix b/nix/deps/murmur3/default.nix deleted file mode 100644 index 01c0ae9cf2..0000000000 --- a/nix/deps/murmur3/default.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ pkgs }: - -pkgs.stdenv.mkDerivation rec { - name = "murmur3-71a75"; - builder = ./builder.sh; - src = pkgs.fetchFromGitHub { - owner = "urbit"; - repo = "murmur3"; - rev = "71a75d57ca4e7ca0f7fc2fd84abd93595b0624ca"; - sha256 = "0k7jq2nb4ad9ajkr6wc4w2yy2f2hkwm3nkbj2pklqgwsg6flxzwg"; - }; -} diff --git a/nix/deps/scrypt/builder.sh b/nix/deps/scrypt/builder.sh deleted file mode 100644 index 94e03d0314..0000000000 --- a/nix/deps/scrypt/builder.sh +++ /dev/null @@ -1,27 +0,0 @@ -source $stdenv/setup - -sources=" \ - crypto_scrypt-check \ - crypto_scrypt-hash \ - crypto_scrypt-hexconvert \ - crypto_scrypt-nosse \ - crypto-mcf \ - crypto-scrypt-saltgen \ - slowequals \ - sha256 \ - b64 \ -" - -CFLAGS="-I$src -Wall -ffast-math -O3 -D_FORTIFY_SOURCE=2 -fstack-protector" - -for s in $sources -do echo $CC $CFLAGS -c $src/$s.c -o $s.o - $CC $CFLAGS -c $src/$s.c -o $s.o -done - -echo $AR rcs libscrypt.a *.o -$AR rcs libscrypt.a *.o - -mkdir -p $out/{lib,include} -cp libscrypt.a $out/lib -cp $src/*.h $out/include diff --git a/nix/deps/scrypt/cross.nix b/nix/deps/scrypt/cross.nix deleted file mode 100644 index 9a74e5b65e..0000000000 --- a/nix/deps/scrypt/cross.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ crossenv }: - -crossenv.make_derivation rec { - name = "scrypt-02969"; - builder = ./builder.sh; - - CC = "${crossenv.host}-gcc"; - AR = "${crossenv.host}-ar"; - - src = crossenv.nixpkgs.fetchFromGitHub { - owner = "urbit"; - repo = "libscrypt"; - rev = "029693ff1cbe4f69d3a2da87d0f4f034f92cc0c2"; - sha256 = "17pcxypzjmmrvacw45cacvibm6mlr9ip30hy30l1appsnywx679n"; - }; -} diff --git a/nix/deps/scrypt/default.nix b/nix/deps/scrypt/default.nix deleted file mode 100644 index a0740f9e1e..0000000000 --- a/nix/deps/scrypt/default.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ pkgs }: - -pkgs.stdenv.mkDerivation rec { - name = "scrypt-02969"; - builder = ./builder.sh; - src = pkgs.fetchFromGitHub { - owner = "urbit"; - repo = "libscrypt"; - rev = "029693ff1cbe4f69d3a2da87d0f4f034f92cc0c2"; - sha256 = "17pcxypzjmmrvacw45cacvibm6mlr9ip30hy30l1appsnywx679n"; - }; -} diff --git a/nix/deps/secp256k1/builder.sh b/nix/deps/secp256k1/builder.sh deleted file mode 100644 index 9e5a114152..0000000000 --- a/nix/deps/secp256k1/builder.sh +++ /dev/null @@ -1,11 +0,0 @@ -source $stdenv/setup - -cp -r $src ./src -chmod -R u+w ./src -cd src - -libtoolize -bash ./autogen.sh -bash ./configure --prefix=$out --host=$host $configureFlags -make -make install diff --git a/nix/deps/secp256k1/cross.nix b/nix/deps/secp256k1/cross.nix deleted file mode 100644 index 67ac2379de..0000000000 --- a/nix/deps/secp256k1/cross.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ crossenv }: - -crossenv.make_derivation rec { - name = "secp256k1-b4e87"; - builder = ./builder.sh; - - CFLAGS = "-fPIC"; - - configureFlags = [ - "--disable-shared" - "--enable-module-recovery" - ]; - - cross_inputs = [ crossenv.libgmp ]; - native_inputs = - with crossenv.nixpkgs; - [ autoconf automake libtool m4 ]; - - src = crossenv.nixpkgs.fetchFromGitHub { - owner = "bitcoin-core"; - repo = "secp256k1"; - rev = "e34ceb333b1c0e6f4115ecbb80c632ac1042fa49"; - sha256 = "0as78s179hcr3ysk3fw98k5wzabgnwri7vkkc17wg31lyz6ids6c"; - }; -} diff --git a/nix/deps/secp256k1/default.nix b/nix/deps/secp256k1/default.nix deleted file mode 100644 index 438b2dc25d..0000000000 --- a/nix/deps/secp256k1/default.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ pkgs }: - -pkgs.stdenv.mkDerivation rec { - name = "secp256k1-b4e87"; - builder = ./builder.sh; - - CFLAGS = "-fPIC"; - - configureFlags = [ - "--disable-shared" - "--enable-module-recovery" - ]; - - buildInputs = [ pkgs.gmp ]; - nativeBuildInputs = - with pkgs; - [ autoconf automake libtool m4 ]; - - src = pkgs.fetchFromGitHub { - owner = "bitcoin-core"; - repo = "secp256k1"; - rev = "e34ceb333b1c0e6f4115ecbb80c632ac1042fa49"; - sha256 = "0as78s179hcr3ysk3fw98k5wzabgnwri7vkkc17wg31lyz6ids6c"; - }; -} diff --git a/nix/deps/softfloat3/builder.sh b/nix/deps/softfloat3/builder.sh deleted file mode 100644 index 6a8efbaf85..0000000000 --- a/nix/deps/softfloat3/builder.sh +++ /dev/null @@ -1,15 +0,0 @@ -source $stdenv/setup - -cp -r $src $TMP/$name -chmod -R u+w $TMP/$name -cd $TMP/$name - -cd ./build/Linux-386-SSE2-GCC -sed -i 's|gcc|$(CC)|' Makefile -sed -i 's/ar crs/$(AR) crs/' Makefile - -make -j4 - -mkdir -p $out/{lib,include} -cp $src/source/include/*.h $out/include -cp softfloat.a $out/lib/libsoftfloat3.a diff --git a/nix/deps/softfloat3/cross.nix b/nix/deps/softfloat3/cross.nix deleted file mode 100644 index 9d76c7e699..0000000000 --- a/nix/deps/softfloat3/cross.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ crossenv }: - -crossenv.make_derivation rec { - name = "softfloat3-ec4c7"; - builder = ./builder.sh; - - CC = "${crossenv.host}-gcc"; - AR = "${crossenv.host}-ar"; - - src = crossenv.nixpkgs.fetchFromGitHub { - owner = "urbit"; - repo = "berkeley-softfloat-3"; - rev = "ec4c7e31b32e07aad80e52f65ff46ac6d6aad986"; - sha256 = "1lz4bazbf7lns1xh8aam19c814a4n4czq5xsq5rmi9sgqw910339"; - }; -} diff --git a/nix/deps/softfloat3/default.nix b/nix/deps/softfloat3/default.nix deleted file mode 100644 index c101b28c24..0000000000 --- a/nix/deps/softfloat3/default.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ pkgs }: - -pkgs.stdenv.mkDerivation rec { - name = "softfloat3-ec4c7"; - builder = ./builder.sh; - src = pkgs.fetchFromGitHub { - owner = "urbit"; - repo = "berkeley-softfloat-3"; - rev = "ec4c7e31b32e07aad80e52f65ff46ac6d6aad986"; - sha256 = "1lz4bazbf7lns1xh8aam19c814a4n4czq5xsq5rmi9sgqw910339"; - }; -} diff --git a/nix/deps/uv/builder.sh b/nix/deps/uv/builder.sh deleted file mode 100644 index d9f0ff42c0..0000000000 --- a/nix/deps/uv/builder.sh +++ /dev/null @@ -1,9 +0,0 @@ -source $stdenv/setup - -cp -r $src ./src -chmod -R a+w ./src -cd ./src - -LIBTOOLIZE=libtoolize ./autogen.sh -bash ./configure --prefix=$out --host=$host $configureFlags -make install diff --git a/nix/deps/uv/cross.nix b/nix/deps/uv/cross.nix deleted file mode 100644 index 4e81e4bd7b..0000000000 --- a/nix/deps/uv/cross.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ crossenv }: - -crossenv.make_derivation rec { - name = "uv-64294"; - native_inputs = with crossenv.nixpkgs; [ autoconf automake libtool m4 ]; - builder = ./builder.sh; - - configureFlags = [ "--disable-shared" ]; - CFLAGS = "-fPIC"; - - src = crossenv.nixpkgs.fetchFromGitHub { - owner = "urbit"; - repo = "libuv"; - rev = "6429495dc9a80aaf1c243038b381451f12bc7dcf"; - sha256 = "07m2m4v9mds0wihzjxjwswwfj3rnk2ycr3vgwfcrvnb5xjz7rs15"; - }; -} diff --git a/nix/deps/uv/default.nix b/nix/deps/uv/default.nix deleted file mode 100644 index ecf8383d26..0000000000 --- a/nix/deps/uv/default.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ pkgs }: - -let - - osx = - with pkgs; - lib.optionals stdenv.isDarwin ( - with darwin.apple_sdk.frameworks; - [ Cocoa CoreServices ]); - -in - -pkgs.stdenv.mkDerivation rec { - name = "uv-64294"; - buildInputs = osx ++ (with pkgs; [ autoconf automake libtool m4 ]); - builder = ./builder.sh; - - CFLAGS = "-fPIC"; - configureFlags = [ "--disable-shared" ]; - - src = pkgs.fetchFromGitHub { - owner = "urbit"; - repo = "libuv"; - rev = "6429495dc9a80aaf1c243038b381451f12bc7dcf"; - sha256 = "07m2m4v9mds0wihzjxjwswwfj3rnk2ycr3vgwfcrvnb5xjz7rs15"; - }; -} diff --git a/nix/lib/boot-fake-ship.nix b/nix/lib/boot-fake-ship.nix new file mode 100644 index 0000000000..e189818e47 --- /dev/null +++ b/nix/lib/boot-fake-ship.nix @@ -0,0 +1,57 @@ +{ stdenvNoCC, cacert }: + +{ urbit, herb, arvo ? null, pill, ship }: + +stdenvNoCC.mkDerivation { + name = "fake-${ship}"; + + buildInputs = [ cacert urbit herb ]; + + phases = [ "buildPhase" "installPhase " ]; + + buildPhase = '' + set -xeuo pipefail + + if ! [ -f "$SSL_CERT_FILE" ]; then + header "$SSL_CERT_FILE doesn't exist" + exit 1 + fi + + ARVO=${if arvo == null then "" else arvo} + PILL=${pill} + SHIP=${ship} + + if [ -z "$ARVO" ]; then + urbit -d -F "$SHIP" -B "$PILL" ./pier + else + urbit -d -F "$SHIP" -A "$ARVO" -B "$PILL" ./pier + fi + + cleanup () { + if [ -f ./pier/.vere.lock ]; then + kill $(< ./pier/.vere.lock) || true + fi + + set +x + } + + trap cleanup EXIT + + check () { + [ 3 -eq "$(herb ./pier -d 3)" ] + } + + if check && sleep 10 && check; then + header "boot success" + herb ./pier -p hood -d '+hood/exit' + else + header "boot failure" + kill $(< ./pier/.vere.lock) || true + exit 1 + fi + ''; + + installPhase = '' + mv ./pier $out + ''; +} diff --git a/nix/lib/default.nix b/nix/lib/default.nix new file mode 100644 index 0000000000..d14915c9bc --- /dev/null +++ b/nix/lib/default.nix @@ -0,0 +1,81 @@ +{ lib, recurseIntoAttrs, haskell-nix, callPackage }: + +let + + # Fetchers + Import from derivations (IFDs) + fetchers = { + bootFakeShip = callPackage ./boot-fake-ship.nix { }; + + testFakeShip = callPackage ./test-fake-ship.nix { }; + + fetchGitHubLFS = callPackage ./fetch-github-lfs.nix { }; + + makeReleaseTarball = callPackage ./make-release-tarball.nix { }; + + pushStorageObject = callPackage ./push-storage-object.nix { }; + }; + +in fetchers // rec { + # Library functions + + inherit (import ./dimension.nix) dimension; + + # A filter for removing packages that aren't supported on the current platform + # according to 'meta.platforms'. + platformFilterGeneric = system: + # This needs to use the correct nixpkgs version so all the systems line up + let + platform = lib.systems.elaborate { inherit system; }; + # Can't just default to [] for platforms, since no meta.platforms + # means "all platforms" not "no platforms" + in drv: + if drv ? meta && drv.meta ? platforms then + lib.any (lib.meta.platformMatch platform) drv.meta.platforms + else + true; + + # Keep derivations and attrsets with 'recurseForDerivations'. + # This ensures that we match the derivations that Hercules will see. + filterDerivations = filterAttrsOnlyRecursive + (n: attrs: lib.isDerivation attrs || attrs.recurseForDerivations or false); + + # A version of 'filterAttrsRecursive' that doesn't recurse into derivations. + # This prevents us from going into an infinite loop with the 'out' attribute + # on derivations. + filterAttrsOnlyRecursive = pred: set: + lib.listToAttrs (lib.concatMap (name: + let v = set.${name}; + in if pred name v then + [ + (lib.nameValuePair name + (if builtins.isAttrs v && !lib.isDerivation v then + filterAttrsOnlyRecursive pred v + else + v)) + ] + else + [ ]) (builtins.attrNames set)); + + collectHaskellComponents = packages: + let + + # These functions pull out from the Haskell package set either all the + # components of a particular type, or all the checks. + + collectChecks = _: ps: + recurseIntoAttrs (builtins.mapAttrs (_: p: p.checks) ps); + + collectComponents = type: ps: + haskell-nix.haskellLib.collectComponents' type ps; + + # This computes the Haskell package set sliced by component type + in recurseIntoAttrs (dimension "haskell" { + # These names must match the subcomponent: components..<...> + "library" = collectComponents; + "tests" = collectComponents; + "benchmarks" = collectComponents; + "exes" = collectComponents; + "checks" = collectChecks; + } # Apply the selector to the Haskell package set + (type: selector: (selector type) packages)); +} diff --git a/nix/lib/dimension.nix b/nix/lib/dimension.nix new file mode 100644 index 0000000000..b4dcaf5eb8 --- /dev/null +++ b/nix/lib/dimension.nix @@ -0,0 +1,110 @@ +# From https://github.com/input-output-hk/plutus/blob/99f3a16cdf20e9e78a6105a097956a3773466b14/nix/dimension.nix +{ + /* dimension: name -> attrs -> function -> attrs + where + function: keyText -> value -> attrsOf package + + WARNING: Attribute names must not contain periods ("."). + See https://github.com/NixOS/nix/issues/3088 + + NOTE: The dimension name will be picked up by agent and web ui soon. + + Specifies a dimension of the build matrix. For example + + dimension "Example" { + withP = { p = true; } + withoutP = { p = false; } + } (key: # either "withP" or "withoutP" + { p }: # either p = true or p = false + myProject p + ) + + evaluates roughly to + + { + withP = myProject true; + withoutP = myProject false; + } + + Use nested calls for multiple dimensions. + + Example: + + dimension "System" { + "x86_64-linux" = {}; + # ... + }: (system: {}: + + dimension "Nixpkgs release" ( + { + "nixpkgs-19_03".nixpkgs = someSource + } // optionalAttrs (system != "...") { + "nixpkgs-unstable".nixpkgs = someOtherSource + } + ) (_key: { nixpkgs }: + + myProject system nixpkgs + + ) + ) + + evaluates roughly to + + { + x86_64-linux.nixpkgs-19_03 = myProject "x86_64-linux" someSource; + x86_64-linux.nixpkgs-unstable = myProject "x86_64-linux" someOtherSource; + ... + } + + If you need to make references across attributes, you can do so by binding + the result. Wherever you write + + dimension "My dimension" {} (key: value: f1 key value) + + You can also write + + let + myDimension = dimension "My dimension" {} (key: value: f2 key value myDimension) + in + myDimension + + This example builds a single test runner to reuse across releases: + + let + overlay = + testRunnerPkgs: self: super: { + # ... + }; + myProject = + { nixpkgs, + pkgs ? import nixpkgs { overlays = [ overlay ]; }, + testRunnerPkgs ? pkgs + }: pkgs; + in + + let + latest = "nixpkgs-19_03"; + releases = + dimension "Nixpkgs release" + { + nixpkgs-18_09.nixpkgs = someSource + nixpkgs-19_03.nixpkgs = someOtherSource + } + (_key: { nixpkgs }: + + myProject { + inherit nixpkgs; + testRunnerPkgs = releases."${latest}"; + } + + ); + in releases; + */ + dimension = name: attrs: f: + builtins.mapAttrs (k: v: + let o = f k v; + in o // { recurseForDerivations = o.recurseForDerivations or true; }) + attrs // { + meta.dimension.name = name; + }; +} diff --git a/nix/lib/fetch-github-lfs.nix b/nix/lib/fetch-github-lfs.nix new file mode 100644 index 0000000000..1b5596cd8a --- /dev/null +++ b/nix/lib/fetch-github-lfs.nix @@ -0,0 +1,107 @@ +{ lib, stdenvNoCC, runCommandLocal, cacert, curl, jq }: + +{ src +# `name` shouldn't use `baseNameOf` otherwise we'll +# get `is not allowed to refer to a store path` errors. +, name ? baseNameOf src, owner ? "urbit", repo ? "urbit" +, preferLocalBuild ? true }: + +assert builtins.isPath src; + +let + + # Parse the first 7 characters of the supplied `src` path for the required + # `version` key as defined by the lfs specification: + # https://github.com/git-lfs/git-lfs/blob/master/docs/spec.md + # + # If `version` exists we assume we're dealing with a lfs pointer and parse + # the `oid` and `size` from the pointer and write these into a JSON object. + # + # If the first 7 characters are unrecognised we assume the path is a binary + # file and set both `oid` and `size` to `null`. + # + # The `oid` and `size` are then JSON decoded into an expression to use + # as the fixed-output derivation's `sha256 = oid`, and to form a download + # operation payload to request the actual lfs blob's real url. + pointer = builtins.fromJSON (builtins.readFile + (runCommandLocal "lfs-pointer-${name}" { } '' + oid="null" + size="null" + + if [[ "$(head -c 7 "${src}")" != "version" ]]; then + header "lfs ${src} is a binary blob, skipping" + else + header "reading lfs pointer from ${src}" + + contents=($(awk '{print $2}' "${src}")) + oid="''${contents[1]#sha256:}" + size="''${contents[2]}" + fi + + cat < "$out" + {"oid": "$oid", "size": $size} + EOF + '')); + + downloadUrl = + "https://github.com/${owner}/${repo}.git/info/lfs/objects/batch"; + + # Encode `oid` and `size` into a download operation per: + # https://github.com/git-lfs/git-lfs/blob/master/docs/api/batch.md + # + # This is done using toJSON to avoid bash quotation issuthe configurationes. + downloadPayload = builtins.toJSON { + operation = "download"; + objects = [ pointer ]; + }; + + # Define a fixed-output derivation using the lfs pointer's `oid` as the + # expected sha256 output hash, if `oid` is not null. + # + + # 1. Request the actual url of the binary file from the lfs batch api. + # 2. Download the binary file contents to `$out`. + download = stdenvNoCC.mkDerivation { + name = "lfs-blob-${name}"; + nativeBuildInputs = [ curl jq ]; + phases = [ "installPhase" ]; + installPhase = '' + curl=( + curl + --location + --max-redirs 20 + --retry 3 + --disable-epsv + --cookie-jar cookies + $NIX_CURL_FLAGS + ) + + header "reading lfs metadata from ${downloadUrl}" + + href=$("''${curl[@]}" \ + -d '${downloadPayload}' \ + -H 'Accept: application/vnd.git-lfs+json' \ + '${downloadUrl}' \ + | jq -r '.objects[0].actions.download.href') + + header "download lfs data from remote" + + # Pozor/Achtung: the href contains credential and signature information, + # so we avoid echoing it to stdout/err. + "''${curl[@]}" -s --output "$out" "$href" + ''; + + impureEnvVars = stdenvNoCC.lib.fetchers.proxyImpureEnvVars; + + SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt"; + + outputHashAlgo = "sha256"; + outputHashMode = "flat"; + outputHash = pointer.oid; + + inherit preferLocalBuild; + }; + + # If `pointer.oid` is null then supplied the `src` must be a binary + # blob and can be returned directly. +in if pointer.oid == null || pointer.size == null then src else download diff --git a/nix/lib/make-release-tarball.nix b/nix/lib/make-release-tarball.nix new file mode 100644 index 0000000000..3d77445ace --- /dev/null +++ b/nix/lib/make-release-tarball.nix @@ -0,0 +1,37 @@ +{ lib, stdenvNoCC, coreutils }: + +{ name, contents # { target = source, ... } +}: + +let + + transforms = builtins.concatStringsSep " " (lib.mapAttrsToList + (target: source: ''--transform "s,${source},${target},"'') contents); + + sources = builtins.concatStringsSep " " + (lib.mapAttrsToList (_target: source: "${source}") contents); + +in stdenvNoCC.mkDerivation { + name = "${name}.tar.gz"; + outputs = [ "out" "hash" ]; + nativeBuildInputs = [ coreutils ]; + phases = [ "buildPhase" "hashPhase" ]; + + buildPhase = '' + tar vczf $out \ + --owner=0 --group=0 --mode=u+rw,uga+r \ + --absolute-names \ + --hard-dereference \ + ${transforms} \ + ${sources} + ''; + + hashPhase = '' + mkdir $hash + + md5sum $out | awk '{printf $1}' > $hash/md5 + sha256sum $out | awk '{printf $1}' > $hash/sha256 + ''; + + preferLocalBuild = true; +} diff --git a/nix/lib/push-storage-object.nix b/nix/lib/push-storage-object.nix new file mode 100644 index 0000000000..f942265157 --- /dev/null +++ b/nix/lib/push-storage-object.nix @@ -0,0 +1,64 @@ +{ lib, stdenvNoCC, coreutils, google-cloud-sdk, xxd }: + +# Somewhat annoyingly due to needing to use Google Storage's Content-MD5 +# to ensure a fixed output derivation - we need an md5sum of the file to +# upload. This is in additional to any sha256sum you might want to actually +# name the object key under. + +{ bucket, object, name, file, md5, serviceAccountKey, preferLocalBuild ? true }: + +assert lib.asserts.assertMsg (builtins.isString serviceAccountKey) + "`serviceAccountKey` must contain the JSON contents of a service-account key"; + +let + + uri = "gs://${bucket}/${lib.removePrefix "/" object}"; + +in stdenvNoCC.mkDerivation { + name = "push-${lib.strings.sanitizeDerivationName name}"; + + nativeBuildInputs = [ coreutils google-cloud-sdk xxd ]; + + phases = [ "installPhase" ]; + + installPhase = '' + set -euo pipefail + + export HOME="." + + gcloud auth activate-service-account --key-file=- <<< '${serviceAccountKey}' + + local_md5=$(echo -n '${md5}' | xxd -r -p | base64) + remote_md5= + + stat_uri() { + header "retrieving md5 for ${uri}" + + remote_md5=$(gsutil stat '${uri}' \ + | sed -n -e '/Hash (md5):/{s/.*: *//p}' \ + | base64 -d \ + | xxd -p) + } + + if ! stat_uri; then + header "copying ${file} to ${uri}" + + gsutil cp '${file}' '${uri}' + + if ! stat_uri; then + echo "failed calculating remote uri md5" >&2 + exit 1 + fi + fi + + # This is the same format as md5sum (double space separator) and + # is used as the outputHash to ensure a fixed output derivation. + echo -n "$remote_md5 ${uri}" > $out + ''; + + outputHashAlgo = "sha256"; + outputHashMode = "flat"; + outputHash = builtins.hashString "sha256" "${md5} ${uri}"; + + inherit preferLocalBuild; +} diff --git a/nix/lib/test-fake-ship.nix b/nix/lib/test-fake-ship.nix new file mode 100644 index 0000000000..3b463c42f1 --- /dev/null +++ b/nix/lib/test-fake-ship.nix @@ -0,0 +1,104 @@ +{ stdenvNoCC, cacert }: + +{ urbit, herb, arvo ? null, pill, ship ? "bus" }: + +stdenvNoCC.mkDerivation { + name = "test-${ship}"; + + buildInputs = [ cacert urbit herb ]; + + phases = [ "buildPhase" "installPhase " ]; + + buildPhase = '' + set -xeuo pipefail + + if ! [ -f "$SSL_CERT_FILE" ]; then + header "$SSL_CERT_FILE doesn't exist" + exit 1 + fi + + ARVO=${if arvo == null then "" else arvo} + PILL=${pill} + SHIP=${ship} + + if [ -z "$ARVO" ]; then + urbit -d -F $SHIP -B $PILL ./pier 2> urbit-output + else + urbit -d -F $SHIP -A $ARVO -B $PILL ./pier 2> urbit-output + fi + + tail -f urbit-output >&2 & + tailproc=$! + + cleanup () { + if [ -e ./pier/.vere.lock ]; then + kill $(< ./pier/.vere.lock) || true + fi + + kill "$tailproc" || true + + set +x + } + + trap cleanup EXIT + + herb ./pier -p hood -d '+hood/mass' + + # Run the unit tests and then print scrollback + herb ./pier -d '~& ~ ~& %test-unit-start ~' + herb ./pier -d '####-test %/tests' + herb ./pier -d '~& ~ ~& %test-unit-end ~' + + # Start and run the test app + herb ./pier -p hood -d '+hood/start %test' + + herb ./pier -d '~& ~ ~& %test-agents-start ~' + herb ./pier -p test -d '%agents' + herb ./pier -d '~& ~ ~& %test-agents-end ~' + + herb ./pier -d '~& ~ ~& %test-generators-start ~' + herb ./pier -p test -d '%generators' + herb ./pier -d '~& ~ ~& %test-generators-end ~' + + herb ./pier -d '~& ~ ~& %test-marks-start ~' + herb ./pier -p test -d '%marks' + herb ./pier -d '~& ~ ~& %test-marks-end ~' + + # Compact the loom, comparing memory use before and after + herb ./pier -p hood -d '+hood/mass' + + herb ./pier -d '~& ~ ~& %pack-start ~' + herb ./pier -p hood -d '+hood/pack' + herb ./pier -d '~& ~ ~& %pack-end ~' + + herb ./pier -p hood -d '+hood/mass' + herb ./pier -p hood -d '+hood/exit' + + # Collect output + cp urbit-output test-output-unit + cp urbit-output test-output-agents + cp urbit-output test-output-generators + cp urbit-output test-output-marks + + rm urbit-output + + sed -i '0,/test-unit-start/d' test-output-unit + sed -i '/test-unit-end/,$d' test-output-unit + + sed -i '0,/test-agents-start/d' test-output-agents + sed -i '/test-agents-end/,$d' test-output-agents + + sed -i '0,/test-generators-start/d' test-output-generators + sed -i '/test-generators-end/,$d' test-output-generators + + sed -i '0,/test-marks-start/d' test-output-marks + sed -i '/test-marks-end/,$d' test-output-marks + ''; + + installPhase = '' + mkdir $out + cp -r test-output-* $out/ + ''; + + meta = { platforms = [ "x86_64-linux" ]; }; +} diff --git a/nix/nixcrpkgs.nix b/nix/nixcrpkgs.nix deleted file mode 100644 index c65bdc3d68..0000000000 --- a/nix/nixcrpkgs.nix +++ /dev/null @@ -1,12 +0,0 @@ -let - - nixpkgs = import ./nixpkgs.nix; - - osx_sdk = builtins.fetchurl { - sha256 = "89aa34dfe5bcbc7d53d3c55a84b35ac810ecfbcdd16a64c9667992b0c36c60c4"; - url = "https://github.com/phracker/MacOSX-SDKs/releases/download/10.13/MacOSX10.11.sdk.tar.xz"; - }; - -in - -import ./nixcrpkgs/top.nix { inherit osx_sdk nixpkgs; } diff --git a/nix/nixcrpkgs/.gitignore b/nix/nixcrpkgs/.gitignore deleted file mode 100644 index fed8256b10..0000000000 --- a/nix/nixcrpkgs/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/result* -/support/results -macos/MacOSX10.12.sdk.tar.xz -macos/MacOSX10.13.sdk.tar.xz diff --git a/nix/nixcrpkgs/LICENSE.nixpkgs b/nix/nixcrpkgs/LICENSE.nixpkgs deleted file mode 100644 index a632d6f58b..0000000000 --- a/nix/nixcrpkgs/LICENSE.nixpkgs +++ /dev/null @@ -1,31 +0,0 @@ -Copyright (c) 2003-2017 Eelco Dolstra and the Nixpkgs/NixOS contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -====================================================================== - -Note: the license above does not apply to the packages built by the -Nix Packages collection, merely to the package descriptions (i.e., Nix -expressions, build scripts, etc.). Also, the license does not apply -to some of the binaries used for bootstrapping Nixpkgs (e.g., -pkgs/stdenv/linux/tools/bash). It also might not apply to patches -included in Nixpkgs, which may be derivative works of the packages to -which they apply. The aforementioned artifacts are all covered by the -licenses of the respective packages. diff --git a/nix/nixcrpkgs/LICENSE.txt b/nix/nixcrpkgs/LICENSE.txt deleted file mode 100644 index 714d2d141b..0000000000 --- a/nix/nixcrpkgs/LICENSE.txt +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) 2017 Pololu Corporation. For more information, see - -http://www.pololu.com/ -http://forum.pololu.com/ - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/nix/nixcrpkgs/README.md b/nix/nixcrpkgs/README.md deleted file mode 100644 index 4e0f1f6f8d..0000000000 --- a/nix/nixcrpkgs/README.md +++ /dev/null @@ -1,175 +0,0 @@ -# nixcrpkgs - -[www.pololu.com](https://www.pololu.com/) - -*nixcrpkgs* is a collection of tools for cross-compiling statically-linked, -standalone software applications. With nixcrpkgs, you can specify what -platforms you want to target, what libraries and build tools you depend on, and -the commands that build your software. When you build your software, nixcrpkgs -will automatically take care of building or retrieving everything you need, -including cross-compilers and libraries. - -nixcrpkgs primarily consists of *Nix expressions*, which are recipes for -building software with [Nix, the purely functional package -manager][nix]. These recipes build on top of the [Nix -Packages collection (Nixpkgs)][nixpkgs]. - -## Features - -- Supported target platforms: - - Windows (32-bit or 64-bit) using [mingw-w64](https://mingw-w64.org/) and [GCC](https://gcc.gnu.org/) 6.3.0 - - Linux (32-bit, 64-bit, and ARM) using [musl](https://www.musl-libc.org/) and [GCC](https://gcc.gnu.org/) 6.3.0 - - macOS using [Clang](https://clang.llvm.org/) 5.0.0 -- Supported languages for cross-compiling: - - C - - C++ -- Supported build platforms: - - Linux -- Supported build tools: - - [CMake](https://cmake.org/) - - [GNU Make](https://www.gnu.org/software/make/) - - [Ninja](https://ninja-build.org/) - - pkg-config (as implemented by [pkgconf](https://github.com/pkgconf/pkgconf)) - - [GNU Bash](https://www.gnu.org/software/bash/) - - [Ruby](https://www.ruby-lang.org/) -- Notable supported libraries: - - [Qt](https://www.qt.io/) 5.9.6 - - [libusb](https://libusb.info/) - - [libusbp](https://github.com/pololu/libusbp) - - [Windows API](https://en.wikipedia.org/wiki/Windows_API) (thanks to mingw-w64) - - -## Getting started - -To get started, you should first install Nix on a Linux machine by following the -instructions on the [Nix website][nix]. - -Next, run `df -h` to make sure you have enough disk space. - -- The filesystem that holds `/nix` should have several gigabytes of free -space. Each GCC cross-compiler takes about 300 MB while each Qt installation -takes about 800 MB. -- The filesystem that holds `/tmp` should have at least 4 gigabytes of free -space, which will be needed while building cross-compilers. If that is not the -case on your system, you can set the `TMPDIR` environment variable to tell -`nix-build` to perform its builds in a different directory on a filesystem with -more free space. - -Next, clone or download this repository and use `cd` to change into the -top-level directory. - -To build a simple "Hello, World!" program for Windows, run: - - nix-build -A win32.hello - -The first time you run this command, it will take a while because Nix has to -build a cross-compiling toolchain. When `nix-build` is done, it will print the -name of a directory in `/nix/store` that holds the resulting program, and it -will create a symbolic link in the current directory named `result` that points -to that directory. - -If you copy `result/bin/hello.exe` to a Windows machine and run it, you should -see a message box appear that says "Hello, World!". - -If you run `nix-build -A win32.hello` a second time, Nix will detect that -nothing about the build recipes has changed, so it will simply print the -directory name and remake the symbolic link. - -To see how the `hello` package is specified in nixcrpkgs, you can look in -`pkgs.nix` and the `pkgs/hello` directory. To see how the GCC cross-compiler -for Windows was specified, you can look in the `mingw-w64` directory. If you -change any of the build recipes for `hello` or its dependencies and then run the -`nix-build` command again, Nix will automatically rebuild those dependencies and -anything that depends on them, ensuring that you always get a consistent build. - - -### Obtaining the macOS SDK - -If you are trying to build software for macOS, you will need to get a -macOS SDK tarball and put it in the the right place. Otherwise, you -will get an error like this: - - error: getting attributes of path '/home/yourname/nixcrpkgs/macos/MacOSX.sdk.tar.xz': No such file or directory - -To generate the tarball, follow these steps: - -1. On a macOS machine, install [Xcode](https://developer.apple.com/xcode/). -2. Download this repository to the machine. -3. In a Terminal window, run the `macos/gen_sdk_package.sh` script from this repository. -4. After several minutes, the current directory should have a tarball with a name like - `MacOSX10.12.sdk.tar.xz` and a size of about 25 MB. -5. Copy the SDK tarball file to the machine where you will be building software, - and put it in the `macos` directory. -6. The nixcrpkgs build recipe for the SDK is hardcoded to look for a file named - `MacOSX.sdk.tar.xz`, so rename the tarball to that. -7. Consider keeping a backup of the tarball so you can always rebuild any software you - made with it. - -Now you should be able to build your software for macOS. - - -## Integrating nixcrpkgs into your project - -The instructions above show how to cross-compile a "Hello, World!" program that -is included with nixcrpkgs. Instead of including your project in nixcrpkgs like -the hello program, you will probably want to just use nixcrpkgs as a tool in -your project. To get an idea of how to do that, you can look at other projects -that have done the same. In the projects listed below, you should look for a -file named `default.nix` in the top-level directory and look for build -instructions that explain what `nix-build` commands to run. - -* The [Pololu Tic Stepper Motor Controller software](https://github.com/pololu/pololu-tic-software) is a C/C++ project that uses CMake and nixcrpkgs. -* The [Pololu USB AVR Programmer v2 software](https://github.com/pololu/pololu-usb-avr-programmer-v2) is a C++ project that uses CMake and nixcrpkgs. -* The [Pololu USB Bootloader Utility (p-load)](https://github.com/pololu/p-load) is a C++ project that uses CMake and nixcrpkgs. - -[nix]: http://nixos.org/nix/ -[nixpkgs]: http://nixos.org/nixpkgs/ - -## Updating package versions - -Each build recipe in nixcrpkgs specifies a version number for the software that it builds. It is relatively easy to update the recipes even if you have not worked with Nix before. The general procedure is: - -1) Find the build recipe you want to update. For example, if you wanted to update the version of GCC used to build Linux programs, you would update the build recipe in `linux/gcc/default.nix`. -2) Find the part of the build recipe where the software sources are downloaded from the internet. It is usually a `fetchurl` command with two parameters: `url` and `sha256`. The `url` parameter usually refers to a version string defined nearby, so update that version string and/or the `url` parameter as desired. -3) In a shell, run `nix-prefetch-url URL`, where URL is the new URL specified in your modified build recipe with all version variables fully expanded). This command will download the URL you specified, store it in the Nix store, and output the hash of it in the proper format for Nix build recipes. -3) Update the `sha256` hash string in the build recipe by replacing it with the hash that was printed in the output of `nix-prefetch-url`. Updating the hash in the build recipe is important: Nix uses it to determine whether you already downloaded the right file, so if you don't update the hash then Nix might use the wrong file (e.g. an older version of the software that you downloaded earlier). -4) Run the usual `nix-build` command that you use to build your software. For example, you could go to the top-level directory of nixcrpkgs and run `nix-build -A rpi.hello` to build a "Hello world" program for the Raspberry Pi, or you could run `nix-build -A rpi.gcc` to just build the cross-compiler. -5) Fix any error messages that happen, one at a time. (Tip: to make a `.patch` file, run `diff -ur old new` where `old` and `new` are directories that contain the unpatched and patched versions of the source code, respectively.) -6) Once things are working, consider publishing your work on Github so others can benefit from what you figured out. - - -## Maintaining the nixcrpkgs system - -You should occasionally run `nix-collect-garbage` to remove items that are no -longer needed and reclaim your disk space. However, note that Nix will -typically remove all of your cross compilers and libraries when you run this -command, so be prepared to do a lengthy mass rebuild. The Nix manual has more -information about [Nix garbage -collection](http://nixos.org/nix/manual/#sec-garbage-collection). - -You should occasionally run `nix-channel --update` to update to the latest -version of Nixpkgs. However, when doing this, be aware that the new version of -Nixpkgs might require you to do a mass rebuild. - -You should occasionally update your checkout of the nixcrpkgs repository to get -the latest versions of build tools, new features, and bug fixes. Once again, -this might require a mass rebuild. - -If you want your builds to be very stable and reliable, you could make forks of -nixcrpkgs and/or Nixpkgs and update them at your own pace, carefully considering -any changes made by others before merging them in. That's one of the beauties -of Nix when compared to other package management systems: you will never be -forced to upgrade your build tools, and using old tools is just as easy as using -new ones. You can use the `NIX_PATH` environment variable to tell `nix-build` -to use your forked versions. - - -## Related projects - -* [osxcross]: Cross-compiling toolchain targeting macOS. -* [musl-cross-make]: Makefile-based build tool for creating cross-compilers targeting musl. -* [musl_nix_arm]: A fork of nixcrpkgs with a focus on building Docker images for ARM Linux. - -[osxcross]: https://github.com/tpoechtrager/osxcross -[musl-cross-make]: https://github.com/richfelker/musl-cross-make -[musl_nix_arm]: https://github.com/filleduchaos/musl_nix_arm diff --git a/nix/nixcrpkgs/bundle_builder.sh b/nix/nixcrpkgs/bundle_builder.sh deleted file mode 100644 index 9cb37fda5f..0000000000 --- a/nix/nixcrpkgs/bundle_builder.sh +++ /dev/null @@ -1,8 +0,0 @@ -source $setup -names=($names) -dirs=($dirs) -mkdir $out -cd $out -for ((i=0;i<${#names[@]};i++)); do - ln -s "${dirs[i]}" "${names[i]}" -done diff --git a/nix/nixcrpkgs/cmake_toolchain/builder.sh b/nix/nixcrpkgs/cmake_toolchain/builder.sh deleted file mode 100644 index 6d422fcc7b..0000000000 --- a/nix/nixcrpkgs/cmake_toolchain/builder.sh +++ /dev/null @@ -1,8 +0,0 @@ -source $stdenv/setup - -cat > $out < {}; - osx_sdk = ./macos/MacOSX.sdk.tar.xz; -} diff --git a/nix/nixcrpkgs/linux/README.md b/nix/nixcrpkgs/linux/README.md deleted file mode 100644 index 14a41d067e..0000000000 --- a/nix/nixcrpkgs/linux/README.md +++ /dev/null @@ -1,14 +0,0 @@ -## Linux GCC toolchain - -The files in this directory define how we build our GCC cross-compiler that -targets Linux, using the musl libc. - -### A note about `-rdynamic` - -Do not pass `-rdynamic` to GCC when building an executable; it will cause the compiled executable to depend on a musl libc dynamic loader in `/lib` that probably doesn't exist, and defeats the point of static linking. The `-static` option overrides `-rdynamic`, so adding`-static` to the linker flags of a project using `-rdynamic` is one way to fix the issue. - -CMake will pass `-rdynamic` unless you set [CMP0065](https://cmake.org/cmake/help/v3.8/policy/CMP0065.html) to new as shown below, or set your [CMake policy version](https://cmake.org/cmake/help/v3.8/command/cmake_policy.html) to 3.4 or later. - - # Don't use -rdynamic since it causes Musl static linking to not work. - cmake_policy(SET CMP0065 NEW) - diff --git a/nix/nixcrpkgs/linux/binutils/builder.sh b/nix/nixcrpkgs/linux/binutils/builder.sh deleted file mode 100644 index 8795ea0ce1..0000000000 --- a/nix/nixcrpkgs/linux/binutils/builder.sh +++ /dev/null @@ -1,26 +0,0 @@ -source $stdenv/setup - -unset CC CXX CFLAGS LDFLAGS LD AR AS RANLIB SIZE STRINGS NM STRIP OBJCOPY - -tar -xf $src - -cd binutils-$version -for patch in $patches; do - echo applying patch $patch - patch -p1 -i $patch -done - -# Clear the default library search path (noSysDirs) -echo 'NATIVE_LIB_DIRS=' >> ld/configure.tgt - -cd .. - -mkdir build -cd build - -../binutils-$version/configure --prefix=$out $configure_flags - -make - -make install - diff --git a/nix/nixcrpkgs/linux/binutils/default.nix b/nix/nixcrpkgs/linux/binutils/default.nix deleted file mode 100644 index 824b3d3955..0000000000 --- a/nix/nixcrpkgs/linux/binutils/default.nix +++ /dev/null @@ -1,26 +0,0 @@ -{ native, host }: - -native.make_derivation rec { - name = "binutils-${version}-${host}"; - - version = "2.27"; - - src = native.nixpkgs.fetchurl { - url = "mirror://gnu/binutils/binutils-${version}.tar.bz2"; - sha256 = "125clslv17xh1sab74343fg6v31msavpmaa1c1394zsqa773g5rn"; - }; - - patches = [ - ./deterministic.patch - ]; - - native_inputs = [ native.nixpkgs.bison native.nixpkgs.zlib ]; - - configure_flags = - "--target=${host} " + - "--enable-shared " + - "--enable-deterministic-archives " + - "--disable-werror "; - - builder = ./builder.sh; -} diff --git a/nix/nixcrpkgs/linux/binutils/deterministic.patch b/nix/nixcrpkgs/linux/binutils/deterministic.patch deleted file mode 100644 index 0a264b35c7..0000000000 --- a/nix/nixcrpkgs/linux/binutils/deterministic.patch +++ /dev/null @@ -1,12 +0,0 @@ -Make binutils output deterministic by default. ---- orig/ld/ldlang.c -+++ new/ld/ldlang.c -@@ -3095,6 +3095,8 @@ - ldfile_output_machine)) - einfo (_("%P%F:%s: can not set architecture: %E\n"), name); - -+ link_info.output_bfd->flags |= BFD_DETERMINISTIC_OUTPUT; -+ - link_info.hash = bfd_link_hash_table_create (link_info.output_bfd); - if (link_info.hash == NULL) - einfo (_("%P%F: can not create hash table: %E\n")); diff --git a/nix/nixcrpkgs/linux/default.nix b/nix/nixcrpkgs/linux/default.nix deleted file mode 100644 index 188cd02614..0000000000 --- a/nix/nixcrpkgs/linux/default.nix +++ /dev/null @@ -1,78 +0,0 @@ -{ native, arch, gcc_options ? "" }: -let - nixpkgs = native.nixpkgs; - - host = "${arch}-linux-musleabi"; - - os = "linux"; - - compiler = "gcc"; - - exe_suffix = ""; - - binutils = import ./binutils { inherit native host; }; - - linux_arch = - if arch == "i686" || arch == "x86_64" then "x86" - else if arch == "armv6" || arch == "armv7" then "arm" - else throw "not sure what Linux architecture code to use"; - - headers = native.make_derivation rec { - name = "linux-headers-${linux_arch}-${version}"; - inherit linux_arch; - version = "4.4.10"; - src = nixpkgs.fetchurl { - url = "https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-${version}.tar.xz"; - sha256 = "1kpjvvd9q9wwr3314q5ymvxii4dv2d27295bzly225wlc552xhja"; - }; - builder = ./headers_builder.sh; - }; - - gcc = import ./gcc { - inherit native host binutils headers gcc_options; - }; - - license = native.make_derivation { - name = "linux-license"; - inherit (gcc) musl_src gcc_src; - linux_src = headers.src; - builder = ./license_builder.sh; - }; - - global_license_set = { _global = license; }; - - cmake_toolchain = import ../cmake_toolchain { - cmake_system_name = "Linux"; - inherit nixpkgs host; - }; - - crossenv = { - is_cross = true; - - # Build tools available on the PATH for every derivation. - default_native_inputs = native.default_native_inputs ++ - [ gcc binutils native.pkgconf native.wrappers ]; - - # Target info environment variables. - inherit host arch os compiler exe_suffix; - - # CMake toolchain file. - inherit cmake_toolchain; - - # A wide variety of programs and build tools. - inherit nixpkgs; - - # Some native build tools made by nixcrpkgs. - inherit native; - - # License information that should be shipped with any software - # compiled by this environment. - inherit global_license_set; - - # Make it easy to refer to the build tools. - inherit headers gcc binutils; - - make_derivation = import ../make_derivation.nix crossenv; - }; -in - crossenv diff --git a/nix/nixcrpkgs/linux/gcc/builder.sh b/nix/nixcrpkgs/linux/gcc/builder.sh deleted file mode 100644 index f134826cc6..0000000000 --- a/nix/nixcrpkgs/linux/gcc/builder.sh +++ /dev/null @@ -1,34 +0,0 @@ -source $setup - -tar -xf $gcc_src -mv gcc-* gcc -cd gcc -for patch in $gcc_patches; do - echo applying patch $patch - patch -p1 -i $patch -done -cd .. - -tar -xf $musl_src -mv musl-* musl - -mkdir -p $out/$host -cp -r --no-preserve=mode $headers/include $out/$host - -mkdir build_gcc -cd build_gcc -../gcc/configure --prefix=$out $gcc_conf -cd .. -make -C build_gcc all-gcc -mkdir build_musl -cd build_musl -../musl/configure --prefix=$out/$host $musl_conf \ - CC="../build_gcc/gcc/xgcc -B ../build_gcc/gcc" \ - LIBCC=../build_gcc/$host/libgcc/libgcc.a -cd .. -make -C build_musl install-headers -make -C build_gcc all-target-libgcc -make -C build_musl -make -C build_musl install -make -C build_gcc -make -C build_gcc install diff --git a/nix/nixcrpkgs/linux/gcc/default.nix b/nix/nixcrpkgs/linux/gcc/default.nix deleted file mode 100644 index 8500cde1a4..0000000000 --- a/nix/nixcrpkgs/linux/gcc/default.nix +++ /dev/null @@ -1,81 +0,0 @@ -{ native, host, binutils, headers, gcc_options }: - -let - nixpkgs = native.nixpkgs; - isl = nixpkgs.isl_0_14; - inherit (nixpkgs) stdenv lib fetchurl; - inherit (nixpkgs) gmp libmpc libelf mpfr zlib; -in - -native.make_derivation rec { - name = "gcc-${gcc_version}-${host}"; - - gcc_version = "6.3.0"; - gcc_src = fetchurl { - url = "mirror://gnu/gcc/gcc-${gcc_version}/gcc-${gcc_version}.tar.bz2"; - sha256 = "17xjz30jb65hcf714vn9gcxvrrji8j20xm7n33qg1ywhyzryfsph"; - }; - - musl_version = "1.1.16"; - musl_src = nixpkgs.fetchurl { - url = "https://www.musl-libc.org/releases/musl-${musl_version}.tar.gz"; - sha256 = "048h0w4yjyza4h05bkc6dpwg3hq6l03na46g0q1ha8fpwnjqawck"; - }; - - inherit host headers; - - builder = ./builder.sh; - - gcc_patches = [ - # These patches are from nixpkgs. - ./use-source-date-epoch.patch - ./libstdc++-target.patch - - # Without this, we cannot build a simple hello world program for ARM. - # See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31798 - ./link_gcc_c_sequence_spec.patch - - # Fix a compiler error in GCC's ubsan.c: ISO C++ forbids comparison - # between pointer and integer. - ./ubsan.patch - ]; - - native_inputs = [ binutils ]; - - gcc_conf = - "--target=${host} " + - gcc_options + - "--with-gnu-as " + - "--with-gnu-ld " + - "--with-as=${binutils}/bin/${host}-as " + - "--with-ld=${binutils}/bin/${host}-ld " + - "--with-isl=${isl} " + - "--with-gmp-include=${gmp.dev}/include " + - "--with-gmp-lib=${gmp.out}/lib " + - "--with-libelf=${libelf}" + - "--with-mpfr=${mpfr.dev} " + - "--with-mpfr-include=${mpfr.dev}/include " + - "--with-mpfr-lib=${mpfr.out}/lib " + - "--with-mpc=${libmpc.out} " + - "--with-zlib-include=${zlib.dev}/include " + - "--with-zlib-lib=${zlib.out}/lib " + - "--enable-deterministic-archives " + - "--enable-languages=c,c++ " + - "--enable-libstdcxx-time " + - "--enable-static " + - "--enable-tls " + - "--disable-gnu-indirect-function " + - "--disable-libmudflap " + - "--disable-libmpx " + - "--disable-libsanitizer " + - "--disable-multilib " + - "--disable-shared " + - "--disable-werror"; - - musl_conf = - "--target=${host} " + - "--disable-shared"; - - hardeningDisable = [ "format" ]; -} - diff --git a/nix/nixcrpkgs/linux/gcc/libstdc++-target.patch b/nix/nixcrpkgs/linux/gcc/libstdc++-target.patch deleted file mode 100644 index fb622b3958..0000000000 --- a/nix/nixcrpkgs/linux/gcc/libstdc++-target.patch +++ /dev/null @@ -1,32 +0,0 @@ -Patch to make the target libraries 'configure' scripts find the proper CPP. -I noticed that building the mingw32 cross compiler. -Looking at the build script for mingw in archlinux, I think that only nixos -needs this patch. I don't know why. -diff --git a/Makefile.in b/Makefile.in -index 93f66b6..d691917 100644 ---- a/Makefile.in -+++ b/Makefile.in -@@ -266,6 +266,7 @@ BASE_TARGET_EXPORTS = \ - AR="$(AR_FOR_TARGET)"; export AR; \ - AS="$(COMPILER_AS_FOR_TARGET)"; export AS; \ - CC="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CC; \ -+ CPP="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CC; \ - CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \ - CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ - CPPFLAGS="$(CPPFLAGS_FOR_TARGET)"; export CPPFLAGS; \ -@@ -291,11 +292,13 @@ BASE_TARGET_EXPORTS = \ - RAW_CXX_TARGET_EXPORTS = \ - $(BASE_TARGET_EXPORTS) \ - CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \ -- CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; -+ CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \ -+ CXXCPP="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX; - - NORMAL_TARGET_EXPORTS = \ - $(BASE_TARGET_EXPORTS) \ -- CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; -+ CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \ -+ CXXCPP="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX; - - # Where to find GMP - HOST_GMPLIBS = @gmplibs@ diff --git a/nix/nixcrpkgs/linux/gcc/link_gcc_c_sequence_spec.patch b/nix/nixcrpkgs/linux/gcc/link_gcc_c_sequence_spec.patch deleted file mode 100644 index 5c976bcb85..0000000000 --- a/nix/nixcrpkgs/linux/gcc/link_gcc_c_sequence_spec.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -ur gcc-6.3.0-orig/gcc/config/gnu-user.h gcc-6.3.0/gcc/config/gnu-user.h ---- gcc-6.3.0-orig/gcc/config/gnu-user.h 2017-08-13 19:03:08.671572528 -0700 -+++ gcc-6.3.0/gcc/config/gnu-user.h 2017-08-13 19:15:00.768588499 -0700 -@@ -123,7 +123,7 @@ - - #undef LINK_GCC_C_SEQUENCE_SPEC - #define LINK_GCC_C_SEQUENCE_SPEC \ -- "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}" -+ "--start-group %G %L --end-group" - - /* Use --as-needed -lgcc_s for eh support. */ - #ifdef HAVE_LD_AS_NEEDED diff --git a/nix/nixcrpkgs/linux/gcc/ubsan.patch b/nix/nixcrpkgs/linux/gcc/ubsan.patch deleted file mode 100644 index 0ad3b79912..0000000000 --- a/nix/nixcrpkgs/linux/gcc/ubsan.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- gcc-6.3.0-orig/gcc/ubsan.c -+++ gcc-6.3.0/gcc/ubsan.c -@@ -1471,7 +1471,7 @@ - - expanded_location xloc = expand_location (loc); - if (xloc.file == NULL || strncmp (xloc.file, "\1", 2) == 0 -- || xloc.file == '\0' || xloc.file[0] == '\xff' -+ || xloc.file == NULL || xloc.file[0] == '\xff' - || xloc.file[1] == '\xff') - return false; diff --git a/nix/nixcrpkgs/linux/gcc/use-source-date-epoch.patch b/nix/nixcrpkgs/linux/gcc/use-source-date-epoch.patch deleted file mode 100644 index 65a5ab028c..0000000000 --- a/nix/nixcrpkgs/linux/gcc/use-source-date-epoch.patch +++ /dev/null @@ -1,52 +0,0 @@ -https://gcc.gnu.org/ml/gcc-patches/2015-06/msg02210.html - -diff --git a/libcpp/macro.c b/libcpp/macro.c -index 1e0a0b5..a52e3cb 100644 ---- a/libcpp/macro.c -+++ b/libcpp/macro.c -@@ -349,14 +349,38 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node) - slow on some systems. */ - time_t tt; - struct tm *tb = NULL; -+ char *source_date_epoch; - -- /* (time_t) -1 is a legitimate value for "number of seconds -- since the Epoch", so we have to do a little dance to -- distinguish that from a genuine error. */ -- errno = 0; -- tt = time(NULL); -- if (tt != (time_t)-1 || errno == 0) -- tb = localtime (&tt); -+ /* Allow the date and time to be set externally by an exported -+ environment variable to enable reproducible builds. */ -+ source_date_epoch = getenv ("SOURCE_DATE_EPOCH"); -+ if (source_date_epoch) -+ { -+ errno = 0; -+ tt = (time_t) strtol (source_date_epoch, NULL, 10); -+ if (errno == 0) -+ { -+ tb = gmtime (&tt); -+ if (tb == NULL) -+ cpp_error (pfile, CPP_DL_ERROR, -+ "SOURCE_DATE_EPOCH=\"%s\" is not a valid date", -+ source_date_epoch); -+ } -+ else -+ cpp_error (pfile, CPP_DL_ERROR, -+ "SOURCE_DATE_EPOCH=\"%s\" is not a valid number", -+ source_date_epoch); -+ } -+ else -+ { -+ /* (time_t) -1 is a legitimate value for "number of seconds -+ since the Epoch", so we have to do a little dance to -+ distinguish that from a genuine error. */ -+ errno = 0; -+ tt = time(NULL); -+ if (tt != (time_t)-1 || errno == 0) -+ tb = localtime (&tt); -+ } - - if (tb) - { diff --git a/nix/nixcrpkgs/linux/headers_builder.sh b/nix/nixcrpkgs/linux/headers_builder.sh deleted file mode 100644 index 9f4a5db09d..0000000000 --- a/nix/nixcrpkgs/linux/headers_builder.sh +++ /dev/null @@ -1,13 +0,0 @@ -source $setup -shopt -u nullglob - -tar -xf $src -mv linux-$version linux - -mkdir -p obj/staged -make -C linux headers_install \ - ARCH=$linux_arch \ - O=$(pwd)/obj \ - INSTALL_HDR_PATH=$out - -find $out '(' -name .install -o -name ..install.cmd ')' -exec rm {} + diff --git a/nix/nixcrpkgs/linux/license_builder.sh b/nix/nixcrpkgs/linux/license_builder.sh deleted file mode 100644 index 0a7d950738..0000000000 --- a/nix/nixcrpkgs/linux/license_builder.sh +++ /dev/null @@ -1,45 +0,0 @@ -source $setup - -tar -xf $gcc_src -mv gcc-* gcc - -tar -xf $musl_src -mv musl-* musl - -tar -xf $linux_src -mv linux-* linux - -license_gcc=$(cat gcc/COPYING3.LIB) -license_musl=$(cat musl/COPYRIGHT) -license_linux=$(cat linux/COPYING) - -cat > $out < - The third-party software included with this software may - have been patched or otherwise modified. -

- -

GCC run-time libraries

- -

- The GCC run-time libraries libgcc and libstdc++ are licensed under the GNU - General Public License Version 3 (GPLv3) as shown below. -

- -
-$license_gcc
-
- -

musl libc

- -
-$license_musl
-
- -

Linux headers

- -
-$license_linux
-
- -EOF diff --git a/nix/nixcrpkgs/macos/.gitignore b/nix/nixcrpkgs/macos/.gitignore deleted file mode 100644 index 40af159624..0000000000 --- a/nix/nixcrpkgs/macos/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/MacOSX.sdk.tar.xz diff --git a/nix/nixcrpkgs/macos/ar_builder.sh b/nix/nixcrpkgs/macos/ar_builder.sh deleted file mode 100644 index 14f1e438c7..0000000000 --- a/nix/nixcrpkgs/macos/ar_builder.sh +++ /dev/null @@ -1,46 +0,0 @@ -source $setup - -tar -xf $src -mv cctools-port-* cctools-port - -cd cctools-port - -for patch in $patches; do - echo applying patch $patch - patch -p1 -i $patch -done - -# Similar to but not the same as the other _structs.h. -rm cctools/include/foreign/mach/i386/_structs.h - -# Causes a troublesome undefined reference. -rm cctools/libstuff/vm_flush_cache.c - -cd .. - -mv cctools-port/cctools/ar . -mv cctools-port/cctools/include . -mv cctools-port/cctools/libstuff . -rm -r cctools-port - -mkdir build -cd build - -CFLAGS="-Wno-deprecated -Wno-deprecated-declarations -Wno-unused-result -Werror -Wfatal-errors -O2 -g -I../include -I../include/foreign -DPROGRAM_PREFIX=\\\"$host-\\\" -D__LITTLE_ENDIAN__ -D__private_extern__= -D__DARWIN_UNIX03 -DPACKAGE_NAME=\\\"cctools\\\" -DPACKAGE_VERSION=\\\"$apple_version\\\" -DEMULATED_HOST_CPU_TYPE=16777223 -DEMULATED_HOST_CPU_SUBTYPE=3" - -CXXFLAGS="-std=gnu++11 $CFLAGS" - -LDFLAGS="-ldl -lpthread" - -for f in ../ar/*.c ../libstuff/*.c; do - echo "compiling $f" - eval "gcc -c $CFLAGS $f -o $(basename $f).o" -done - -gcc *.o $LDFLAGS -o $host-ar - -mkdir -p $out/bin -cp $host-ar $out/bin/ - -# ar looks for ranlib in this directory -ln -s $ranlib/bin/$host-ranlib $out/bin/ diff --git a/nix/nixcrpkgs/macos/cctools-bytesex.patch b/nix/nixcrpkgs/macos/cctools-bytesex.patch deleted file mode 100644 index 19ac3845f3..0000000000 --- a/nix/nixcrpkgs/macos/cctools-bytesex.patch +++ /dev/null @@ -1,11 +0,0 @@ -diff -ur cctools-port-c1cc758/cctools/include/stuff/bytesex.h cctools-port-bytesex/cctools/include/stuff/bytesex.h ---- cctools-port-c1cc758/cctools/include/stuff/bytesex.h 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-bytesex/cctools/include/stuff/bytesex.h 2017-11-10 19:07:26.338161875 -0800 -@@ -48,6 +48,7 @@ - #include - #include - #include -+#include - #include - #include - /* cctools-port: need to undef these to avoid warnings */ diff --git a/nix/nixcrpkgs/macos/cctools-format.patch b/nix/nixcrpkgs/macos/cctools-format.patch deleted file mode 100644 index f38ffe7efc..0000000000 --- a/nix/nixcrpkgs/macos/cctools-format.patch +++ /dev/null @@ -1,2661 +0,0 @@ -diff -ur cctools-port-c1cc758/cctools/ar/archive.h cctools-port-format/cctools/ar/archive.h ---- cctools-port-c1cc758/cctools/ar/archive.h 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-format/cctools/ar/archive.h 2017-11-10 21:42:36.315713255 -0800 -@@ -112,11 +112,11 @@ - } CHDR; - - /* Header format strings. */ --#define HDR1 "%s%-13d%-12ld%-6u%-6u%-8o%-10qd%2s" --#define HDR2 "%-16.16s%-12ld%-6u%-6u%-8o%-10qd%2s" -+#define HDR1 "%s%-13d%-12ld%-6u%-6u%-8o%-10ld%2s" -+#define HDR2 "%-16.16s%-12ld%-6u%-6u%-8o%-10ld%2s" - - #define OLDARMAXNAME 15 --#define HDR3 "%-16.15s%-12ld%-6u%-6u%-8o%-10qd%2s" -+#define HDR3 "%-16.15s%-12ld%-6u%-6u%-8o%-10ld%2s" - - - #include -diff -ur cctools-port-c1cc758/cctools/ar/contents.c cctools-port-format/cctools/ar/contents.c ---- cctools-port-c1cc758/cctools/ar/contents.c 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-format/cctools/ar/contents.c 2017-11-10 21:43:06.022707300 -0800 -@@ -107,7 +107,7 @@ - goto next; - if (options & AR_V) { - (void)strmode(chdr.mode, buf); -- (void)printf("%s %6d/%-6d %8qd ", -+ (void)printf("%s %6d/%-6d %8ld ", - buf + 1, chdr.uid, chdr.gid, chdr.size); - tp = localtime(&chdr.date); - (void)strftime(buf, sizeof(buf), "%b %e %H:%M %Y", tp); -diff -ur cctools-port-c1cc758/cctools/ld64/src/ld/debugline.c cctools-port-format/cctools/ld64/src/ld/debugline.c ---- cctools-port-c1cc758/cctools/ld64/src/ld/debugline.c 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-format/cctools/ld64/src/ld/debugline.c 2017-11-10 19:13:05.914926185 -0800 -@@ -396,11 +396,11 @@ - case DW_LNE_set_address: - if (sz == 9) { - lnd->cur.pc = read_64 (eop); -- if (verbose) fprintf(stderr, "DW_LNE_set_address(0x%08llX)\n", lnd->cur.pc); -+ if (verbose) fprintf(stderr, "DW_LNE_set_address(0x%08lX)\n", lnd->cur.pc); - } - else if (sz == 5) { - lnd->cur.pc = read_32 (eop); -- if (verbose) fprintf(stderr, "DW_LNE_set_address(0x%08llX)\n", lnd->cur.pc); -+ if (verbose) fprintf(stderr, "DW_LNE_set_address(0x%08lX)\n", lnd->cur.pc); - } - else - return false; -@@ -442,11 +442,11 @@ - if (tmp == (uint64_t) -1) - return false; - lnd->cur.pc += tmp * lnd->minimum_instruction_length; -- if (verbose) fprintf(stderr, "DW_LNS_advance_pc(0x%08llX)\n", lnd->cur.pc); -+ if (verbose) fprintf(stderr, "DW_LNS_advance_pc(0x%08lX)\n", lnd->cur.pc); - break; - case DW_LNS_advance_line: - lnd->cur.line += read_sleb128 (lnd); -- if (verbose) fprintf(stderr, "DW_LNS_advance_line(%lld)\n", lnd->cur.line); -+ if (verbose) fprintf(stderr, "DW_LNS_advance_line(%ld)\n", lnd->cur.line); - break; - case DW_LNS_set_file: - if (verbose) fprintf(stderr, "DW_LNS_set_file\n"); -diff -ur cctools-port-c1cc758/cctools/ld64/src/ld/InputFiles.cpp cctools-port-format/cctools/ld64/src/ld/InputFiles.cpp ---- cctools-port-c1cc758/cctools/ld64/src/ld/InputFiles.cpp 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-format/cctools/ld64/src/ld/InputFiles.cpp 2017-11-10 19:13:05.914926185 -0800 -@@ -226,7 +226,7 @@ - if ( fd == -1 ) - throwf("can't open file, errno=%d", errno); - if ( info.fileLen < 20 ) -- throwf("file too small (length=%llu)", info.fileLen); -+ throwf("file too small (length=%lu)", info.fileLen); - - uint8_t* p = (uint8_t*)::mmap(NULL, info.fileLen, PROT_READ, MAP_FILE | MAP_PRIVATE, fd, 0); - if ( p == (uint8_t*)(-1) ) -@@ -276,7 +276,7 @@ - newFileLen = statBuffer.st_size; - } - if ( fileOffset+len > newFileLen ) { -- throwf("truncated fat file. Slice from %u to %llu is past end of file with length %llu", -+ throwf("truncated fat file. Slice from %u to %lu is past end of file with length %lu", - fileOffset, fileOffset+len, info.fileLen); - } - } -diff -ur cctools-port-c1cc758/cctools/ld64/src/ld/ld.cpp cctools-port-format/cctools/ld64/src/ld/ld.cpp ---- cctools-port-c1cc758/cctools/ld64/src/ld/ld.cpp 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-format/cctools/ld64/src/ld/ld.cpp 2017-11-10 19:13:05.914926185 -0800 -@@ -1026,10 +1026,10 @@ - // sanity check size - if ( ((address + sect->size) > _options.maxAddress()) && (_options.outputKind() != Options::kObjectFile) - && (_options.outputKind() != Options::kStaticExecutable) ) -- throwf("section %s (address=0x%08llX, size=%llu) would make the output executable exceed available address range", -+ throwf("section %s (address=0x%08lX, size=%lu) would make the output executable exceed available address range", - sect->sectionName(), address, sect->size); - -- if ( log ) fprintf(stderr, " address=0x%08llX, hidden=%d, alignment=%02d, section=%s,%s\n", -+ if ( log ) fprintf(stderr, " address=0x%08lX, hidden=%d, alignment=%02d, section=%s,%s\n", - sect->address, sect->isSectionHidden(), sect->alignment, sect->segmentName(), sect->sectionName()); - // update running totals - if ( !sect->isSectionHidden() || hiddenSectionsOccupyAddressSpace ) -@@ -1060,7 +1060,7 @@ - address = ( (unalignedAddress+alignment-1) & (-alignment) ); - sect->alignmentPaddingBytes = (address - unalignedAddress); - sect->address = address; -- if ( log ) fprintf(stderr, " address=0x%08llX, hidden=%d, alignment=%02d, section=%s,%s\n", -+ if ( log ) fprintf(stderr, " address=0x%08lX, hidden=%d, alignment=%02d, section=%s,%s\n", - sect->address, sect->isSectionHidden(), sect->alignment, sect->segmentName(), sect->sectionName()); - // update running totals - if ( !sect->isSectionHidden() || hiddenSectionsOccupyAddressSpace ) -@@ -1119,7 +1119,7 @@ - // sanity check size - if ( ((address + sect->size) > _options.maxAddress()) && (_options.outputKind() != Options::kObjectFile) - && (_options.outputKind() != Options::kStaticExecutable) ) -- throwf("section %s (address=0x%08llX, size=%llu) would make the output executable exceed available address range", -+ throwf("section %s (address=0x%08lX, size=%lu) would make the output executable exceed available address range", - sect->sectionName(), address, sect->size); - - // sanity check it does not overlap a fixed address segment -@@ -1145,7 +1145,7 @@ - } - } - -- if ( log ) fprintf(stderr, " address=0x%08llX, size=0x%08llX, hidden=%d, alignment=%02d, padBytes=%d, section=%s,%s\n", -+ if ( log ) fprintf(stderr, " address=0x%08lX, size=0x%08lX, hidden=%d, alignment=%02d, padBytes=%d, section=%s,%s\n", - sect->address, sect->size, sect->isSectionHidden(), sect->alignment, sect->alignmentPaddingBytes, - sect->segmentName(), sect->sectionName()); - // update running totals -@@ -1159,7 +1159,7 @@ - ld::Internal::FinalSection* sect = *it; - //if ( sect->isSectionHidden() ) - // continue; -- fprintf(stderr, " address:0x%08llX, alignment:2^%d, size:0x%08llX, padBytes:%d, section:%s/%s\n", -+ fprintf(stderr, " address:0x%08lX, alignment:2^%d, size:0x%08lX, padBytes:%d, section:%s/%s\n", - sect->address, sect->alignment, sect->size, sect->alignmentPaddingBytes, - sect->segmentName(), sect->sectionName()); - -@@ -1200,7 +1200,7 @@ - fileOffset += sect->size; - } - -- if ( log ) fprintf(stderr, " fileoffset=0x%08llX, address=0x%08llX, hidden=%d, size=%lld, alignment=%02d, section=%s,%s\n", -+ if ( log ) fprintf(stderr, " fileoffset=0x%08lX, address=0x%08lX, hidden=%d, size=%ld, alignment=%02d, section=%s,%s\n", - sect->fileOffset, sect->address, sect->isSectionHidden(), sect->size, sect->alignment, - sect->segmentName(), sect->sectionName()); - } -@@ -1226,7 +1226,7 @@ - { - char* result = out; - char rawNum[30]; -- sprintf(rawNum, "%llu", in); -+ sprintf(rawNum, "%lu", in); - const int rawNumLen = strlen(rawNum); - for(int i=0; i < rawNumLen-1; ++i) { - *out++ = rawNum[i]; -diff -ur cctools-port-c1cc758/cctools/ld64/src/ld/LinkEdit.hpp cctools-port-format/cctools/ld64/src/ld/LinkEdit.hpp ---- cctools-port-c1cc758/cctools/ld64/src/ld/LinkEdit.hpp 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-format/cctools/ld64/src/ld/LinkEdit.hpp 2017-11-10 19:13:05.914926185 -0800 -@@ -324,39 +324,39 @@ - done = true; - break; - case REBASE_OPCODE_SET_TYPE_IMM: -- if ( log ) fprintf(stderr, "REBASE_OPCODE_SET_TYPE_IMM(%lld)\n", it->operand1); -+ if ( log ) fprintf(stderr, "REBASE_OPCODE_SET_TYPE_IMM(%ld)\n", it->operand1); - this->_encodedData.append_byte(REBASE_OPCODE_SET_TYPE_IMM | it->operand1); - break; - case REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB: -- if ( log ) fprintf(stderr, "REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB(%lld, 0x%llX)\n", it->operand1, it->operand2); -+ if ( log ) fprintf(stderr, "REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB(%ld, 0x%lX)\n", it->operand1, it->operand2); - this->_encodedData.append_byte(REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB | it->operand1); - this->_encodedData.append_uleb128(it->operand2); - break; - case REBASE_OPCODE_ADD_ADDR_ULEB: -- if ( log ) fprintf(stderr, "REBASE_OPCODE_ADD_ADDR_ULEB(0x%llX)\n", it->operand1); -+ if ( log ) fprintf(stderr, "REBASE_OPCODE_ADD_ADDR_ULEB(0x%lX)\n", it->operand1); - this->_encodedData.append_byte(REBASE_OPCODE_ADD_ADDR_ULEB); - this->_encodedData.append_uleb128(it->operand1); - break; - case REBASE_OPCODE_ADD_ADDR_IMM_SCALED: -- if ( log ) fprintf(stderr, "REBASE_OPCODE_ADD_ADDR_IMM_SCALED(%lld=0x%llX)\n", it->operand1, it->operand1*sizeof(pint_t)); -+ if ( log ) fprintf(stderr, "REBASE_OPCODE_ADD_ADDR_IMM_SCALED(%ld=0x%lX)\n", it->operand1, it->operand1*sizeof(pint_t)); - this->_encodedData.append_byte(REBASE_OPCODE_ADD_ADDR_IMM_SCALED | it->operand1 ); - break; - case REBASE_OPCODE_DO_REBASE_IMM_TIMES: -- if ( log ) fprintf(stderr, "REBASE_OPCODE_DO_REBASE_IMM_TIMES(%lld)\n", it->operand1); -+ if ( log ) fprintf(stderr, "REBASE_OPCODE_DO_REBASE_IMM_TIMES(%ld)\n", it->operand1); - this->_encodedData.append_byte(REBASE_OPCODE_DO_REBASE_IMM_TIMES | it->operand1); - break; - case REBASE_OPCODE_DO_REBASE_ULEB_TIMES: -- if ( log ) fprintf(stderr, "REBASE_OPCODE_DO_REBASE_ULEB_TIMES(%lld)\n", it->operand1); -+ if ( log ) fprintf(stderr, "REBASE_OPCODE_DO_REBASE_ULEB_TIMES(%ld)\n", it->operand1); - this->_encodedData.append_byte(REBASE_OPCODE_DO_REBASE_ULEB_TIMES); - this->_encodedData.append_uleb128(it->operand1); - break; - case REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB: -- if ( log ) fprintf(stderr, "REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB(0x%llX)\n", it->operand1); -+ if ( log ) fprintf(stderr, "REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB(0x%lX)\n", it->operand1); - this->_encodedData.append_byte(REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB); - this->_encodedData.append_uleb128(it->operand1); - break; - case REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB: -- if ( log ) fprintf(stderr, "REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB(%lld, %lld)\n", it->operand1, it->operand2); -+ if ( log ) fprintf(stderr, "REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB(%ld, %ld)\n", it->operand1, it->operand2); - this->_encodedData.append_byte(REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB); - this->_encodedData.append_uleb128(it->operand1); - this->_encodedData.append_uleb128(it->operand2); -@@ -534,39 +534,39 @@ - done = true; - break; - case BIND_OPCODE_SET_DYLIB_ORDINAL_IMM: -- if ( log ) fprintf(stderr, "BIND_OPCODE_SET_DYLIB_ORDINAL_IMM(%lld)\n", it->operand1); -+ if ( log ) fprintf(stderr, "BIND_OPCODE_SET_DYLIB_ORDINAL_IMM(%ld)\n", it->operand1); - this->_encodedData.append_byte(BIND_OPCODE_SET_DYLIB_ORDINAL_IMM | it->operand1); - break; - case BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB: -- if ( log ) fprintf(stderr, "BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB(%lld)\n", it->operand1); -+ if ( log ) fprintf(stderr, "BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB(%ld)\n", it->operand1); - this->_encodedData.append_byte(BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB); - this->_encodedData.append_uleb128(it->operand1); - break; - case BIND_OPCODE_SET_DYLIB_SPECIAL_IMM: -- if ( log ) fprintf(stderr, "BIND_OPCODE_SET_DYLIB_SPECIAL_IMM(%lld)\n", it->operand1); -+ if ( log ) fprintf(stderr, "BIND_OPCODE_SET_DYLIB_SPECIAL_IMM(%ld)\n", it->operand1); - this->_encodedData.append_byte(BIND_OPCODE_SET_DYLIB_SPECIAL_IMM | (it->operand1 & BIND_IMMEDIATE_MASK)); - break; - case BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM: -- if ( log ) fprintf(stderr, "BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM(0x%0llX, %s)\n", it->operand1, it->name); -+ if ( log ) fprintf(stderr, "BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM(0x%0lX, %s)\n", it->operand1, it->name); - this->_encodedData.append_byte(BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM | it->operand1); - this->_encodedData.append_string(it->name); - break; - case BIND_OPCODE_SET_TYPE_IMM: -- if ( log ) fprintf(stderr, "BIND_OPCODE_SET_TYPE_IMM(%lld)\n", it->operand1); -+ if ( log ) fprintf(stderr, "BIND_OPCODE_SET_TYPE_IMM(%ld)\n", it->operand1); - this->_encodedData.append_byte(BIND_OPCODE_SET_TYPE_IMM | it->operand1); - break; - case BIND_OPCODE_SET_ADDEND_SLEB: -- if ( log ) fprintf(stderr, "BIND_OPCODE_SET_ADDEND_SLEB(%lld)\n", it->operand1); -+ if ( log ) fprintf(stderr, "BIND_OPCODE_SET_ADDEND_SLEB(%ld)\n", it->operand1); - this->_encodedData.append_byte(BIND_OPCODE_SET_ADDEND_SLEB); - this->_encodedData.append_sleb128(it->operand1); - break; - case BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB: -- if ( log ) fprintf(stderr, "BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB(%lld, 0x%llX)\n", it->operand1, it->operand2); -+ if ( log ) fprintf(stderr, "BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB(%ld, 0x%lX)\n", it->operand1, it->operand2); - this->_encodedData.append_byte(BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB | it->operand1); - this->_encodedData.append_uleb128(it->operand2); - break; - case BIND_OPCODE_ADD_ADDR_ULEB: -- if ( log ) fprintf(stderr, "BIND_OPCODE_ADD_ADDR_ULEB(0x%llX)\n", it->operand1); -+ if ( log ) fprintf(stderr, "BIND_OPCODE_ADD_ADDR_ULEB(0x%lX)\n", it->operand1); - this->_encodedData.append_byte(BIND_OPCODE_ADD_ADDR_ULEB); - this->_encodedData.append_uleb128(it->operand1); - break; -@@ -575,16 +575,16 @@ - this->_encodedData.append_byte(BIND_OPCODE_DO_BIND); - break; - case BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB: -- if ( log ) fprintf(stderr, "BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB(0x%llX)\n", it->operand1); -+ if ( log ) fprintf(stderr, "BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB(0x%lX)\n", it->operand1); - this->_encodedData.append_byte(BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB); - this->_encodedData.append_uleb128(it->operand1); - break; - case BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED: -- if ( log ) fprintf(stderr, "BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED(%lld=0x%llX)\n", it->operand1, it->operand1*sizeof(pint_t)); -+ if ( log ) fprintf(stderr, "BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED(%ld=0x%lX)\n", it->operand1, it->operand1*sizeof(pint_t)); - this->_encodedData.append_byte(BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED | it->operand1 ); - break; - case BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB: -- if ( log ) fprintf(stderr, "BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB(%lld, %lld)\n", it->operand1, it->operand2); -+ if ( log ) fprintf(stderr, "BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB(%ld, %ld)\n", it->operand1, it->operand2); - this->_encodedData.append_byte(BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB); - this->_encodedData.append_uleb128(it->operand1); - this->_encodedData.append_uleb128(it->operand2); -@@ -772,39 +772,39 @@ - done = true; - break; - case BIND_OPCODE_SET_DYLIB_ORDINAL_IMM: -- if ( log ) fprintf(stderr, "BIND_OPCODE_SET_DYLIB_ORDINAL_IMM(%lld)\n", it->operand1); -+ if ( log ) fprintf(stderr, "BIND_OPCODE_SET_DYLIB_ORDINAL_IMM(%ld)\n", it->operand1); - this->_encodedData.append_byte(BIND_OPCODE_SET_DYLIB_ORDINAL_IMM | it->operand1); - break; - case BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB: -- if ( log ) fprintf(stderr, "BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB(%lld)\n", it->operand1); -+ if ( log ) fprintf(stderr, "BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB(%ld)\n", it->operand1); - this->_encodedData.append_byte(BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB); - this->_encodedData.append_uleb128(it->operand1); - break; - case BIND_OPCODE_SET_DYLIB_SPECIAL_IMM: -- if ( log ) fprintf(stderr, "BIND_OPCODE_SET_DYLIB_SPECIAL_IMM(%lld)\n", it->operand1); -+ if ( log ) fprintf(stderr, "BIND_OPCODE_SET_DYLIB_SPECIAL_IMM(%ld)\n", it->operand1); - this->_encodedData.append_byte(BIND_OPCODE_SET_DYLIB_SPECIAL_IMM | (it->operand1 & BIND_IMMEDIATE_MASK)); - break; - case BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM: -- if ( log ) fprintf(stderr, "BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM(0x%0llX, %s)\n", it->operand1, it->name); -+ if ( log ) fprintf(stderr, "BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM(0x%0lX, %s)\n", it->operand1, it->name); - this->_encodedData.append_byte(BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM | it->operand1); - this->_encodedData.append_string(it->name); - break; - case BIND_OPCODE_SET_TYPE_IMM: -- if ( log ) fprintf(stderr, "BIND_OPCODE_SET_TYPE_IMM(%lld)\n", it->operand1); -+ if ( log ) fprintf(stderr, "BIND_OPCODE_SET_TYPE_IMM(%ld)\n", it->operand1); - this->_encodedData.append_byte(BIND_OPCODE_SET_TYPE_IMM | it->operand1); - break; - case BIND_OPCODE_SET_ADDEND_SLEB: -- if ( log ) fprintf(stderr, "BIND_OPCODE_SET_ADDEND_SLEB(%lld)\n", it->operand1); -+ if ( log ) fprintf(stderr, "BIND_OPCODE_SET_ADDEND_SLEB(%ld)\n", it->operand1); - this->_encodedData.append_byte(BIND_OPCODE_SET_ADDEND_SLEB); - this->_encodedData.append_sleb128(it->operand1); - break; - case BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB: -- if ( log ) fprintf(stderr, "BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB(%lld, 0x%llX)\n", it->operand1, it->operand2); -+ if ( log ) fprintf(stderr, "BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB(%ld, 0x%lX)\n", it->operand1, it->operand2); - this->_encodedData.append_byte(BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB | it->operand1); - this->_encodedData.append_uleb128(it->operand2); - break; - case BIND_OPCODE_ADD_ADDR_ULEB: -- if ( log ) fprintf(stderr, "BIND_OPCODE_ADD_ADDR_ULEB(0x%llX)\n", it->operand1); -+ if ( log ) fprintf(stderr, "BIND_OPCODE_ADD_ADDR_ULEB(0x%lX)\n", it->operand1); - this->_encodedData.append_byte(BIND_OPCODE_ADD_ADDR_ULEB); - this->_encodedData.append_uleb128(it->operand1); - break; -@@ -813,16 +813,16 @@ - this->_encodedData.append_byte(BIND_OPCODE_DO_BIND); - break; - case BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB: -- if ( log ) fprintf(stderr, "BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB(0x%llX)\n", it->operand1); -+ if ( log ) fprintf(stderr, "BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB(0x%lX)\n", it->operand1); - this->_encodedData.append_byte(BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB); - this->_encodedData.append_uleb128(it->operand1); - break; - case BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED: -- if ( log ) fprintf(stderr, "BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED(%lld=0x%llX)\n", it->operand1, it->operand1*sizeof(pint_t)); -+ if ( log ) fprintf(stderr, "BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED(%ld=0x%lX)\n", it->operand1, it->operand1*sizeof(pint_t)); - this->_encodedData.append_byte(BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED | it->operand1 ); - break; - case BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB: -- if ( log ) fprintf(stderr, "BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB(%lld, %lld)\n", it->operand1, it->operand2); -+ if ( log ) fprintf(stderr, "BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB(%ld, %ld)\n", it->operand1, it->operand2); - this->_encodedData.append_byte(BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB); - this->_encodedData.append_uleb128(it->operand1); - this->_encodedData.append_uleb128(it->operand2); -@@ -1018,7 +1018,7 @@ - entry.importName = atom->name(); - } - entries.push_back(entry); -- //fprintf(stderr, "re-export %s from lib %llu as %s\n", entry.importName, entry.other, entry.name); -+ //fprintf(stderr, "re-export %s from lib %lu as %s\n", entry.importName, entry.other, entry.name); - } - else if ( atom->definition() == ld::Atom::definitionAbsolute ) { - entry.name = atom->name(); -@@ -1136,7 +1136,7 @@ - _64bitPointerLocations.push_back(address); - break; - default: -- warning("codegen at address 0x%08llX prevents image from working in dyld shared cache", address); -+ warning("codegen at address 0x%08lX prevents image from working in dyld shared cache", address); - break; - } - } -@@ -1152,7 +1152,7 @@ - _32bitPointerLocations.push_back(address); - break; - default: -- warning("codegen at address 0x%08llX prevents image from working in dyld shared cache", address); -+ warning("codegen at address 0x%08lX prevents image from working in dyld shared cache", address); - break; - } - } -@@ -1179,7 +1179,7 @@ - _thumbHi16Locations[extra].push_back(address); - break; - default: -- warning("codegen at address 0x%08llX prevents image from working in dyld shared cache", address); -+ warning("codegen at address 0x%08lX prevents image from working in dyld shared cache", address); - break; - } - } -@@ -1207,7 +1207,7 @@ - _64bitPointerLocations.push_back(address); - break; - default: -- warning("codegen at address 0x%08llX prevents image from working in dyld shared cache", address); -+ warning("codegen at address 0x%08lX prevents image from working in dyld shared cache", address); - break; - } - } -@@ -1219,9 +1219,9 @@ - pint_t addr = this->_options.baseAddress(); - for(typename std::vector::const_iterator it = locations.begin(); it != locations.end(); ++it) { - pint_t nextAddr = *it; -- //fprintf(stderr, "nextAddr=0x%0llX\n", (uint64_t)nextAddr); -+ //fprintf(stderr, "nextAddr=0x%0lX\n", (uint64_t)nextAddr); - uint64_t delta = nextAddr - addr; -- //fprintf(stderr, "delta=0x%0llX\n", delta); -+ //fprintf(stderr, "delta=0x%0lX\n", delta); - if ( delta == 0 ) - throw "double split seg info for same address"; - // uleb128 encode -diff -ur cctools-port-c1cc758/cctools/ld64/src/ld/Options.cpp cctools-port-format/cctools/ld64/src/ld/Options.cpp ---- cctools-port-c1cc758/cctools/ld64/src/ld/Options.cpp 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-format/cctools/ld64/src/ld/Options.cpp 2017-11-10 19:13:05.914926185 -0800 -@@ -2622,7 +2622,7 @@ - fBaseAddress = parseAddress(address); - uint64_t temp = ((fBaseAddress+fSegmentAlignment-1) & (-fSegmentAlignment)); - if ( fBaseAddress != temp ) { -- warning("-seg1addr not %lld byte aligned, rounding up", fSegmentAlignment); -+ warning("-seg1addr not %ld byte aligned, rounding up", fSegmentAlignment); - fBaseAddress = temp; - } - cannotBeUsedWithBitcode(arg); -@@ -2886,7 +2886,7 @@ - seg.address = parseAddress(argv[++i]); - uint64_t temp = ((seg.address+fSegmentAlignment-1) & (-fSegmentAlignment)); - if ( seg.address != temp ) -- warning("-segaddr %s not %lld byte aligned", seg.name, fSegmentAlignment); -+ warning("-segaddr %s not %ld byte aligned", seg.name, fSegmentAlignment); - fCustomSegmentAddresses.push_back(seg); - cannotBeUsedWithBitcode(arg); - } -@@ -4572,7 +4572,7 @@ - } - // range check -seg1addr for ARM - if ( fBaseAddress > fMaxAddress ) { -- warning("ignoring -seg1addr 0x%08llX. Address out of range.", fBaseAddress); -+ warning("ignoring -seg1addr 0x%08lX. Address out of range.", fBaseAddress); - fBaseAddress = 0; - } - break; -@@ -5207,7 +5207,7 @@ - // Make sure -image_base matches alignment - uint64_t alignedBaseAddress = (fBaseAddress+fSegmentAlignment-1) & (-fSegmentAlignment); - if ( alignedBaseAddress != fBaseAddress ) { -- warning("base address 0x%llX is not properly aligned. Changing it to 0x%llX", fBaseAddress, alignedBaseAddress); -+ warning("base address 0x%lX is not properly aligned. Changing it to 0x%lX", fBaseAddress, alignedBaseAddress); - fBaseAddress = alignedBaseAddress; - } - -@@ -5401,7 +5401,7 @@ - break; - } - if ( (fStackSize & (-fSegmentAlignment)) != fStackSize ) -- throwf("-stack_size must be multiple of segment alignment (%lldKB)", fSegmentAlignment/1024); -+ throwf("-stack_size must be multiple of segment alignment (%ldKB)", fSegmentAlignment/1024); - switch ( fOutputKind ) { - case Options::kDynamicExecutable: - case Options::kStaticExecutable: -@@ -5416,7 +5416,7 @@ - throw "-stack_size option can only be used when linking a main executable"; - } - if ( fStackSize > fStackAddr ) -- throwf("-stack_size (0x%08llX) must be smaller than -stack_addr (0x%08llX)", fStackSize, fStackAddr); -+ throwf("-stack_size (0x%08lX) must be smaller than -stack_addr (0x%08lX)", fStackSize, fStackAddr); - } - - // check that -allow_stack_execute is only used with main executables -@@ -5582,7 +5582,7 @@ - if ( fZeroPageSize != ULLONG_MAX ) { - for (std::vector::iterator it = fCustomSegmentAddresses.begin(); it != fCustomSegmentAddresses.end(); ++it) { - if ( it->address < fZeroPageSize ) -- throwf("-segaddr %s 0x%llX conflicts with -pagezero_size", it->name, it->address); -+ throwf("-segaddr %s 0x%lX conflicts with -pagezero_size", it->name, it->address); - } - } - // verify no duplicates -diff -ur cctools-port-c1cc758/cctools/ld64/src/ld/OutputFile.cpp cctools-port-format/cctools/ld64/src/ld/OutputFile.cpp ---- cctools-port-c1cc758/cctools/ld64/src/ld/OutputFile.cpp 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-format/cctools/ld64/src/ld/OutputFile.cpp 2017-11-10 19:13:05.918259550 -0800 -@@ -132,13 +132,13 @@ - { - fprintf(stderr, "SORTED:\n"); - for (std::vector::iterator it = state.sections.begin(); it != state.sections.end(); ++it) { -- fprintf(stderr, "final section %p %s/%s %s start addr=0x%08llX, size=0x%08llX, alignment=%02d, fileOffset=0x%08llX\n", -+ fprintf(stderr, "final section %p %s/%s %s start addr=0x%08lX, size=0x%08lX, alignment=%02d, fileOffset=0x%08lX\n", - (*it), (*it)->segmentName(), (*it)->sectionName(), (*it)->isSectionHidden() ? "(hidden)" : "", - (*it)->address, (*it)->size, (*it)->alignment, (*it)->fileOffset); - if ( printAtoms ) { - std::vector& atoms = (*it)->atoms; - for (std::vector::iterator ait = atoms.begin(); ait != atoms.end(); ++ait) { -- fprintf(stderr, " %p (0x%04llX) %s\n", *ait, (*ait)->size(), (*ait)->name()); -+ fprintf(stderr, " %p (0x%04lX) %s\n", *ait, (*ait)->size(), (*ait)->name()); - } - } - } -@@ -179,7 +179,7 @@ - ld::Internal::FinalSection* sect = *it; - if ( (segFirstSection == NULL ) || strcmp(segFirstSection->segmentName(), sect->segmentName()) != 0 ) { - if ( segFirstSection != NULL ) { -- //fprintf(stderr, "findSegment(0x%llX) seg changed to %s\n", addr, sect->segmentName()); -+ //fprintf(stderr, "findSegment(0x%lX) seg changed to %s\n", addr, sect->segmentName()); - if ( (addr >= segFirstSection->address) && (addr < lastSection->address+lastSection->size) ) { - *start = segFirstSection->address; - *end = lastSection->address+lastSection->size; -@@ -219,7 +219,7 @@ - break; - default: - (const_cast(atom))->setSectionStartAddress(sect->address); -- if ( log ) fprintf(stderr, " atom=%p, addr=0x%08llX, name=%s\n", atom, atom->finalAddress(), atom->name()); -+ if ( log ) fprintf(stderr, " atom=%p, addr=0x%08lX, name=%s\n", atom, atom->finalAddress(), atom->name()); - break; - } - } -@@ -435,7 +435,7 @@ - switch ( atom.symbolTableInclusion() ) { - case ld::Atom::symbolTableNotIn: - case ld::Atom::symbolTableNotInFinalLinkedImages: -- sprintf(buffer, "%s@0x%08llX", atom.name(), atom.objectAddress()); -+ sprintf(buffer, "%s@0x%08lX", atom.name(), atom.objectAddress()); - break; - case ld::Atom::symbolTableIn: - case ld::Atom::symbolTableInAndNeverStrip: -@@ -598,7 +598,7 @@ - for (std::vector::iterator it = state.sections.begin(); it != state.sections.end(); ++it) { - if ( (*it)->isSectionHidden() ) - continue; -- fprintf(stderr, " %s/%s addr=0x%08llX, size=0x%08llX, fileOffset=0x%08llX, type=%d\n", -+ fprintf(stderr, " %s/%s addr=0x%08lX, size=0x%08lX, fileOffset=0x%08lX, type=%d\n", - (*it)->segmentName(), (*it)->sectionName(), - (*it)->address, (*it)->size, (*it)->fileOffset, (*it)->type()); - } -@@ -612,7 +612,7 @@ - printSectionLayout(state); - - const ld::Atom* target; -- throwf("8-bit reference out of range (%lld max is +/-127B): from %s (0x%08llX) to %s (0x%08llX)", -+ throwf("8-bit reference out of range (%ld max is +/-127B): from %s (0x%08lX) to %s (0x%08lX)", - displacement, atom->name(), atom->finalAddress(), referenceTargetAtomName(state, fixup), - addressOf(state, fixup, &target)); - } -@@ -626,7 +626,7 @@ - printSectionLayout(state); - - const ld::Atom* target; -- throwf("16-bit reference out of range (%lld max is +/-32KB): from %s (0x%08llX) to %s (0x%08llX)", -+ throwf("16-bit reference out of range (%ld max is +/-32KB): from %s (0x%08lX) to %s (0x%08lX)", - displacement, atom->name(), atom->finalAddress(), referenceTargetAtomName(state, fixup), - addressOf(state, fixup, &target)); - } -@@ -640,7 +640,7 @@ - printSectionLayout(state); - - const ld::Atom* target; -- throwf("32-bit branch out of range (%lld max is +/-2GB): from %s (0x%08llX) to %s (0x%08llX)", -+ throwf("32-bit branch out of range (%ld max is +/-2GB): from %s (0x%08lX) to %s (0x%08lX)", - displacement, atom->name(), atom->finalAddress(), referenceTargetAtomName(state, fixup), - addressOf(state, fixup, &target)); - } -@@ -659,7 +659,7 @@ - if ( (_options.architecture() == CPU_TYPE_ARM) || (_options.architecture() == CPU_TYPE_I386) ) { - // Unlikely userland code does funky stuff like this, so warn for them, but not warn for -preload or -static - if ( (_options.outputKind() != Options::kPreload) && (_options.outputKind() != Options::kStaticExecutable) ) { -- warning("32-bit absolute address out of range (0x%08llX max is 4GB): from %s + 0x%08X (0x%08llX) to 0x%08llX", -+ warning("32-bit absolute address out of range (0x%08lX max is 4GB): from %s + 0x%08X (0x%08lX) to 0x%08lX", - displacement, atom->name(), fixup->offsetInAtom, atom->finalAddress(), displacement); - } - return; -@@ -669,10 +669,10 @@ - - const ld::Atom* target; - if ( fixup->binding == ld::Fixup::bindingNone ) -- throwf("32-bit absolute address out of range (0x%08llX max is 4GB): from %s + 0x%08X (0x%08llX) to 0x%08llX", -+ throwf("32-bit absolute address out of range (0x%08lX max is 4GB): from %s + 0x%08X (0x%08lX) to 0x%08lX", - displacement, atom->name(), fixup->offsetInAtom, atom->finalAddress(), displacement); - else -- throwf("32-bit absolute address out of range (0x%08llX max is 4GB): from %s + 0x%08X (0x%08llX) to %s (0x%08llX)", -+ throwf("32-bit absolute address out of range (0x%08lX max is 4GB): from %s + 0x%08X (0x%08lX) to %s (0x%08lX)", - displacement, atom->name(), fixup->offsetInAtom, atom->finalAddress(), referenceTargetAtomName(state, fixup), - addressOf(state, fixup, &target)); - } -@@ -687,7 +687,7 @@ - printSectionLayout(state); - - const ld::Atom* target; -- throwf("32-bit RIP relative reference out of range (%lld max is +/-4GB): from %s (0x%08llX) to %s (0x%08llX)", -+ throwf("32-bit RIP relative reference out of range (%ld max is +/-4GB): from %s (0x%08lX) to %s (0x%08lX)", - displacement, atom->name(), atom->finalAddress(), referenceTargetAtomName(state, fixup), - addressOf(state, fixup, &target)); - } -@@ -700,7 +700,7 @@ - printSectionLayout(state); - - const ld::Atom* target; -- throwf("ARM ldr 12-bit displacement out of range (%lld max is +/-4096B): from %s (0x%08llX) to %s (0x%08llX)", -+ throwf("ARM ldr 12-bit displacement out of range (%ld max is +/-4096B): from %s (0x%08lX) to %s (0x%08lX)", - displacement, atom->name(), atom->finalAddress(), referenceTargetAtomName(state, fixup), - addressOf(state, fixup, &target)); - } -@@ -720,7 +720,7 @@ - printSectionLayout(state); - - const ld::Atom* target; -- throwf("b/bl/blx ARM branch out of range (%lld max is +/-32MB): from %s (0x%08llX) to %s (0x%08llX)", -+ throwf("b/bl/blx ARM branch out of range (%ld max is +/-32MB): from %s (0x%08lX) to %s (0x%08lX)", - displacement, atom->name(), atom->finalAddress(), referenceTargetAtomName(state, fixup), - addressOf(state, fixup, &target)); - } -@@ -752,12 +752,12 @@ - - const ld::Atom* target; - if ( _options.preferSubArchitecture() && _options.archSupportsThumb2() ) { -- throwf("b/bl/blx thumb2 branch out of range (%lld max is +/-16MB): from %s (0x%08llX) to %s (0x%08llX)", -+ throwf("b/bl/blx thumb2 branch out of range (%ld max is +/-16MB): from %s (0x%08lX) to %s (0x%08lX)", - displacement, atom->name(), atom->finalAddress(), referenceTargetAtomName(state, fixup), - addressOf(state, fixup, &target)); - } - else { -- throwf("b/bl/blx thumb1 branch out of range (%lld max is +/-4MB): from %s (0x%08llX) to %s (0x%08llX)", -+ throwf("b/bl/blx thumb1 branch out of range (%ld max is +/-4MB): from %s (0x%08lX) to %s (0x%08lX)", - displacement, atom->name(), atom->finalAddress(), referenceTargetAtomName(state, fixup), - addressOf(state, fixup, &target)); - } -@@ -772,7 +772,7 @@ - printSectionLayout(state); - - const ld::Atom* target; -- throwf("b(l) ARM64 branch out of range (%lld max is +/-128MB): from %s (0x%08llX) to %s (0x%08llX)", -+ throwf("b(l) ARM64 branch out of range (%ld max is +/-128MB): from %s (0x%08lX) to %s (0x%08lX)", - displacement, atom->name(), atom->finalAddress(), referenceTargetAtomName(state, fixup), - addressOf(state, fixup, &target)); - } -@@ -786,7 +786,7 @@ - printSectionLayout(state); - - const ld::Atom* target; -- throwf("ARM64 ADRP out of range (%lld max is +/-4GB): from %s (0x%08llX) to %s (0x%08llX)", -+ throwf("ARM64 ADRP out of range (%ld max is +/-4GB): from %s (0x%08lX) to %s (0x%08lX)", - displacement, atom->name(), atom->finalAddress(), referenceTargetAtomName(state, fixup), - addressOf(state, fixup, &target)); - } -@@ -1871,7 +1871,7 @@ - uint32_t nextDisp = (j1 << 13) | (j2 << 11) | imm11; - uint32_t firstDisp = (s << 10) | imm10; - newInstruction = instruction | (nextDisp << 16) | firstDisp; -- //warning("s=%d, j1=%d, j2=%d, imm10=0x%0X, imm11=0x%0X, instruction=0x%08X, first=0x%04X, next=0x%04X, new=0x%08X, disp=0x%llX for %s to %s\n", -+ //warning("s=%d, j1=%d, j2=%d, imm10=0x%0X, imm11=0x%0X, instruction=0x%08X, first=0x%04X, next=0x%04X, new=0x%08X, disp=0x%lX for %s to %s\n", - // s, j1, j2, imm10, imm11, instruction, firstDisp, nextDisp, newInstruction, delta, atom->name(), toTarget->name()); - set32LE(fixUpLocation, newInstruction); - } -@@ -2003,7 +2003,7 @@ - // vector and byte LDR/STR have same "size" bits, need to check other bits to differenciate - implictShift = 4; - if ( (offset & 0xF) != 0 ) { -- throwf("128-bit LDR/STR not 16-byte aligned: from %s (0x%08llX) to %s (0x%08llX)", -+ throwf("128-bit LDR/STR not 16-byte aligned: from %s (0x%08lX) to %s (0x%08lX)", - atom->name(), atom->finalAddress(), referenceTargetAtomName(state, fit), - addressOf(state, fit, &toTarget)); - } -@@ -2011,21 +2011,21 @@ - break; - case 1: - if ( (offset & 0x1) != 0 ) { -- throwf("16-bit LDR/STR not 2-byte aligned: from %s (0x%08llX) to %s (0x%08llX)", -+ throwf("16-bit LDR/STR not 2-byte aligned: from %s (0x%08lX) to %s (0x%08lX)", - atom->name(), atom->finalAddress(), referenceTargetAtomName(state, fit), - addressOf(state, fit, &toTarget)); - } - break; - case 2: - if ( (offset & 0x3) != 0 ) { -- throwf("32-bit LDR/STR not 4-byte aligned: from %s (0x%08llX) to %s (0x%08llX)", -+ throwf("32-bit LDR/STR not 4-byte aligned: from %s (0x%08lX) to %s (0x%08lX)", - atom->name(), atom->finalAddress(), referenceTargetAtomName(state, fit), - addressOf(state, fit, &toTarget)); - } - break; - case 3: - if ( (offset & 0x7) != 0 ) { -- throwf("64-bit LDR/STR not 8-byte aligned: from %s (0x%08llX) to %s (0x%08llX)", -+ throwf("64-bit LDR/STR not 8-byte aligned: from %s (0x%08lX) to %s (0x%08lX)", - atom->name(), atom->finalAddress(), referenceTargetAtomName(state, fit), - addressOf(state, fit, &toTarget)); - } -@@ -2177,11 +2177,11 @@ - set32LE(infoA.instructionContent, makeNOP()); - set32LE(infoB.instructionContent, makeLDR_literal(ldrInfoB, infoA.targetAddress, infoB.instructionAddress)); - if ( _options.verboseOptimizationHints() ) -- fprintf(stderr, "adrp-ldr at 0x%08llX transformed to LDR literal, usableSegment=%d usableSegment\n", infoB.instructionAddress, usableSegment); -+ fprintf(stderr, "adrp-ldr at 0x%08lX transformed to LDR literal, usableSegment=%d usableSegment\n", infoB.instructionAddress, usableSegment); - } - else { - if ( _options.verboseOptimizationHints() ) -- fprintf(stderr, "adrp-ldr at 0x%08llX not transformed, isLDR=%d, literalableSize=%d, inRange=%d, usableSegment=%d, scaledOffset=%d\n", -+ fprintf(stderr, "adrp-ldr at 0x%08lX not transformed, isLDR=%d, literalableSize=%d, inRange=%d, usableSegment=%d, scaledOffset=%d\n", - infoB.instructionAddress, isLDR, literalableSize, withinOneMeg(infoB.instructionAddress, infoA.targetAddress), usableSegment, ldrInfoB.offset); - } - break; -@@ -2208,7 +2208,7 @@ - set32LE(infoB.instructionContent, makeNOP()); - set32LE(infoC.instructionContent, makeLDR_literal(ldrInfoC, infoA.targetAddress+ldrInfoC.offset, infoC.instructionAddress)); - if ( _options.verboseOptimizationHints() ) { -- fprintf(stderr, "adrp-add-ldr at 0x%08llX T1 transformed to LDR literal\n", infoC.instructionAddress); -+ fprintf(stderr, "adrp-add-ldr at 0x%08lX T1 transformed to LDR literal\n", infoC.instructionAddress); - } - } - else if ( usableSegment && withinOneMeg(infoA.instructionAddress, infoA.targetAddress+ldrInfoC.offset) ) { -@@ -2219,7 +2219,7 @@ - set32LE(infoC.instructionContent, makeLoadOrStore(ldrInfoC)); - set32LE(infoC.instructionContent, infoC.instruction & 0xFFC003FF); - if ( _options.verboseOptimizationHints() ) -- fprintf(stderr, "adrp-add-ldr at 0x%08llX T4 transformed to ADR/LDR\n", infoB.instructionAddress); -+ fprintf(stderr, "adrp-add-ldr at 0x%08lX T4 transformed to ADR/LDR\n", infoB.instructionAddress); - } - else if ( ((infoB.targetAddress % ldrInfoC.size) == 0) && (ldrInfoC.offset == 0) ) { - // can do T2 transformation by merging ADD into LD -@@ -2228,11 +2228,11 @@ - ldrInfoC.offset += addInfoB.addend; - set32LE(infoC.instructionContent, makeLoadOrStore(ldrInfoC)); - if ( _options.verboseOptimizationHints() ) -- fprintf(stderr, "adrp-add-ldr at 0x%08llX T2 transformed to ADRP/LDR \n", infoC.instructionAddress); -+ fprintf(stderr, "adrp-add-ldr at 0x%08lX T2 transformed to ADRP/LDR \n", infoC.instructionAddress); - } - else { - if ( _options.verboseOptimizationHints() ) -- fprintf(stderr, "adrp-add-ldr at 0x%08llX could not be transformed, loadSize=%d, literalableSize=%d, inRange=%d, usableSegment=%d, targetFourByteAligned=%d, imm12=%d\n", -+ fprintf(stderr, "adrp-add-ldr at 0x%08lX could not be transformed, loadSize=%d, literalableSize=%d, inRange=%d, usableSegment=%d, targetFourByteAligned=%d, imm12=%d\n", - infoC.instructionAddress, ldrInfoC.size, literalableSize, withinOneMeg(infoC.instructionAddress, infoA.targetAddress+ldrInfoC.offset), usableSegment, targetFourByteAligned, ldrInfoC.offset); - } - break; -@@ -2252,11 +2252,11 @@ - set32LE(infoA.instructionContent, makeADR(addInfoB.destReg, infoA.targetAddress, infoA.instructionAddress)); - set32LE(infoB.instructionContent, makeNOP()); - if ( _options.verboseOptimizationHints() ) -- fprintf(stderr, "adrp-add at 0x%08llX transformed to ADR\n", infoB.instructionAddress); -+ fprintf(stderr, "adrp-add at 0x%08lX transformed to ADR\n", infoB.instructionAddress); - } - else { - if ( _options.verboseOptimizationHints() ) -- fprintf(stderr, "adrp-add at 0x%08llX not transformed, isAdd=%d, inRange=%d, usableSegment=%d\n", -+ fprintf(stderr, "adrp-add at 0x%08lX not transformed, isAdd=%d, inRange=%d, usableSegment=%d\n", - infoB.instructionAddress, isADD, withinOneMeg(infoA.targetAddress, infoA.instructionAddress), usableSegment); - } - break; -@@ -2278,19 +2278,19 @@ - LOH_ASSERT(ldrInfoB.size == 8); - LOH_ASSERT(!ldrInfoB.isFloat); - LOH_ASSERT(ldrInfoC.baseReg == ldrInfoB.reg); -- //fprintf(stderr, "infoA.target=%p, %s, infoA.targetAddress=0x%08llX\n", infoA.target, infoA.target->name(), infoA.targetAddress); -+ //fprintf(stderr, "infoA.target=%p, %s, infoA.targetAddress=0x%08lX\n", infoA.target, infoA.target->name(), infoA.targetAddress); - targetFourByteAligned = ( ((infoA.targetAddress + ldrInfoC.offset) & 0x3) == 0 ); - if ( usableSegment && targetFourByteAligned && withinOneMeg(infoB.instructionAddress, infoA.targetAddress + ldrInfoC.offset) ) { - // can do T5 transform - set32LE(infoA.instructionContent, makeNOP()); - set32LE(infoB.instructionContent, makeLDR_literal(ldrInfoB, infoA.targetAddress, infoB.instructionAddress)); - if ( _options.verboseOptimizationHints() ) { -- fprintf(stderr, "adrp-ldr-got-ldr at 0x%08llX T5 transformed to LDR literal of GOT plus LDR\n", infoC.instructionAddress); -+ fprintf(stderr, "adrp-ldr-got-ldr at 0x%08lX T5 transformed to LDR literal of GOT plus LDR\n", infoC.instructionAddress); - } - } - else { - if ( _options.verboseOptimizationHints() ) -- fprintf(stderr, "adrp-ldr-got-ldr at 0x%08llX no optimization done\n", infoC.instructionAddress); -+ fprintf(stderr, "adrp-ldr-got-ldr at 0x%08lX no optimization done\n", infoC.instructionAddress); - } - } - else if ( isADD ) { -@@ -2305,7 +2305,7 @@ - set32LE(infoB.instructionContent, makeNOP()); - set32LE(infoC.instructionContent, makeLDR_literal(ldrInfoC, infoA.targetAddress + ldrInfoC.offset, infoC.instructionAddress)); - if ( _options.verboseOptimizationHints() ) -- fprintf(stderr, "adrp-ldr-got-ldr at 0x%08llX T1 transformed to LDR literal\n", infoC.instructionAddress); -+ fprintf(stderr, "adrp-ldr-got-ldr at 0x%08lX T1 transformed to LDR literal\n", infoC.instructionAddress); - } - else if ( usableSegment && withinOneMeg(infoA.instructionAddress, infoA.targetAddress) ) { - // can do T4 transform -@@ -2313,7 +2313,7 @@ - set32LE(infoB.instructionContent, makeNOP()); - set32LE(infoC.instructionContent, makeLoadOrStore(ldrInfoC)); - if ( _options.verboseOptimizationHints() ) { -- fprintf(stderr, "adrp-ldr-got-ldr at 0x%08llX T4 transformed to ADR/LDR\n", infoC.instructionAddress); -+ fprintf(stderr, "adrp-ldr-got-ldr at 0x%08lX T4 transformed to ADR/LDR\n", infoC.instructionAddress); - } - } - else if ( ((infoA.targetAddress % ldrInfoC.size) == 0) && ((addInfoB.addend + ldrInfoC.offset) < 4096) ) { -@@ -2323,19 +2323,19 @@ - ldrInfoC.offset += addInfoB.addend; - set32LE(infoC.instructionContent, makeLoadOrStore(ldrInfoC)); - if ( _options.verboseOptimizationHints() ) { -- fprintf(stderr, "adrp-ldr-got-ldr at 0x%08llX T2 transformed to ADRP/NOP/LDR\n", infoC.instructionAddress); -+ fprintf(stderr, "adrp-ldr-got-ldr at 0x%08lX T2 transformed to ADRP/NOP/LDR\n", infoC.instructionAddress); - } - } - else { - // T3 transform already done by ld::passes:got:doPass() - if ( _options.verboseOptimizationHints() ) { -- fprintf(stderr, "adrp-ldr-got-ldr at 0x%08llX T3 transformed to ADRP/ADD/LDR\n", infoC.instructionAddress); -+ fprintf(stderr, "adrp-ldr-got-ldr at 0x%08lX T3 transformed to ADRP/ADD/LDR\n", infoC.instructionAddress); - } - } - } - else { - if ( _options.verboseOptimizationHints() ) -- fprintf(stderr, "adrp-ldr-got-ldr at 0x%08llX not ADD or LDR\n", infoC.instructionAddress); -+ fprintf(stderr, "adrp-ldr-got-ldr at 0x%08lX not ADD or LDR\n", infoC.instructionAddress); - } - break; - case LOH_ARM64_ADRP_ADD_STR: -@@ -2361,7 +2361,7 @@ - set32LE(infoC.instructionContent, makeLoadOrStore(ldrInfoC)); - set32LE(infoC.instructionContent, infoC.instruction & 0xFFC003FF); - if ( _options.verboseOptimizationHints() ) -- fprintf(stderr, "adrp-add-str at 0x%08llX T4 transformed to ADR/STR\n", infoB.instructionAddress); -+ fprintf(stderr, "adrp-add-str at 0x%08lX T4 transformed to ADR/STR\n", infoB.instructionAddress); - } - else if ( ((infoB.targetAddress % ldrInfoC.size) == 0) && (ldrInfoC.offset == 0) ) { - // can do T2 transformation by merging ADD into STR -@@ -2370,11 +2370,11 @@ - ldrInfoC.offset += addInfoB.addend; - set32LE(infoC.instructionContent, makeLoadOrStore(ldrInfoC)); - if ( _options.verboseOptimizationHints() ) -- fprintf(stderr, "adrp-add-str at 0x%08llX T2 transformed to ADRP/STR \n", infoC.instructionAddress); -+ fprintf(stderr, "adrp-add-str at 0x%08lX T2 transformed to ADRP/STR \n", infoC.instructionAddress); - } - else { - if ( _options.verboseOptimizationHints() ) -- fprintf(stderr, "adrp-add-str at 0x%08llX could not be transformed, loadSize=%d, inRange=%d, usableSegment=%d, imm12=%d\n", -+ fprintf(stderr, "adrp-add-str at 0x%08lX could not be transformed, loadSize=%d, inRange=%d, usableSegment=%d, imm12=%d\n", - infoC.instructionAddress, ldrInfoC.size, withinOneMeg(infoC.instructionAddress, infoA.targetAddress+ldrInfoC.offset), usableSegment, ldrInfoC.offset); - } - break; -@@ -2402,12 +2402,12 @@ - set32LE(infoA.instructionContent, makeNOP()); - set32LE(infoB.instructionContent, makeLDR_literal(ldrInfoB, infoA.targetAddress, infoB.instructionAddress)); - if ( _options.verboseOptimizationHints() ) { -- fprintf(stderr, "adrp-ldr-got-str at 0x%08llX T5 transformed to LDR literal of GOT plus STR\n", infoC.instructionAddress); -+ fprintf(stderr, "adrp-ldr-got-str at 0x%08lX T5 transformed to LDR literal of GOT plus STR\n", infoC.instructionAddress); - } - } - else { - if ( _options.verboseOptimizationHints() ) -- fprintf(stderr, "adrp-ldr-got-str at 0x%08llX no optimization done\n", infoC.instructionAddress); -+ fprintf(stderr, "adrp-ldr-got-str at 0x%08lX no optimization done\n", infoC.instructionAddress); - } - } - else if ( isADD ) { -@@ -2422,7 +2422,7 @@ - set32LE(infoB.instructionContent, makeNOP()); - set32LE(infoC.instructionContent, makeLoadOrStore(ldrInfoC)); - if ( _options.verboseOptimizationHints() ) { -- fprintf(stderr, "adrp-ldr-got-str at 0x%08llX T4 transformed to ADR/STR\n", infoC.instructionAddress); -+ fprintf(stderr, "adrp-ldr-got-str at 0x%08lX T4 transformed to ADR/STR\n", infoC.instructionAddress); - } - } - else if ( ((infoA.targetAddress % ldrInfoC.size) == 0) && (ldrInfoC.offset == 0) ) { -@@ -2432,19 +2432,19 @@ - ldrInfoC.offset += addInfoB.addend; - set32LE(infoC.instructionContent, makeLoadOrStore(ldrInfoC)); - if ( _options.verboseOptimizationHints() ) { -- fprintf(stderr, "adrp-ldr-got-str at 0x%08llX T4 transformed to ADRP/NOP/STR\n", infoC.instructionAddress); -+ fprintf(stderr, "adrp-ldr-got-str at 0x%08lX T4 transformed to ADRP/NOP/STR\n", infoC.instructionAddress); - } - } - else { - // T3 transform already done by ld::passes:got:doPass() - if ( _options.verboseOptimizationHints() ) { -- fprintf(stderr, "adrp-ldr-got-str at 0x%08llX T3 transformed to ADRP/ADD/STR\n", infoC.instructionAddress); -+ fprintf(stderr, "adrp-ldr-got-str at 0x%08lX T3 transformed to ADRP/ADD/STR\n", infoC.instructionAddress); - } - } - } - else { - if ( _options.verboseOptimizationHints() ) -- fprintf(stderr, "adrp-ldr-got-str at 0x%08llX not ADD or LDR\n", infoC.instructionAddress); -+ fprintf(stderr, "adrp-ldr-got-str at 0x%08lX not ADD or LDR\n", infoC.instructionAddress); - } - break; - case LOH_ARM64_ADRP_LDR_GOT: -@@ -2463,7 +2463,7 @@ - set32LE(infoA.instructionContent, makeNOP()); - set32LE(infoB.instructionContent, makeLDR_literal(ldrInfoB, infoA.targetAddress, infoB.instructionAddress)); - if ( _options.verboseOptimizationHints() ) { -- fprintf(stderr, "adrp-ldr-got at 0x%08llX T5 transformed to NOP/LDR\n", infoC.instructionAddress); -+ fprintf(stderr, "adrp-ldr-got at 0x%08lX T5 transformed to NOP/LDR\n", infoC.instructionAddress); - } - } - } -@@ -2473,23 +2473,23 @@ - set32LE(infoA.instructionContent, makeADR(addInfoB.destReg, infoA.targetAddress, infoA.instructionAddress)); - set32LE(infoB.instructionContent, makeNOP()); - if ( _options.verboseOptimizationHints() ) { -- fprintf(stderr, "adrp-ldr-got at 0x%08llX T4 transformed to ADR/STR\n", infoC.instructionAddress); -+ fprintf(stderr, "adrp-ldr-got at 0x%08lX T4 transformed to ADR/STR\n", infoC.instructionAddress); - } - } - } - else { - if ( _options.verboseOptimizationHints() ) -- fprintf(stderr, "adrp-ldr-got at 0x%08llX not LDR or ADD\n", infoB.instructionAddress); -+ fprintf(stderr, "adrp-ldr-got at 0x%08lX not LDR or ADD\n", infoB.instructionAddress); - } - } - else { - if ( _options.verboseOptimizationHints() ) -- fprintf(stderr, "adrp-ldr-got at 0x%08llX not ADRP\n", infoA.instructionAddress); -+ fprintf(stderr, "adrp-ldr-got at 0x%08lX not ADRP\n", infoA.instructionAddress); - } - break; - default: - if ( _options.verboseOptimizationHints() ) -- fprintf(stderr, "unknown hint kind %d alt.info.kind at 0x%08llX\n", alt.info.kind, infoA.instructionAddress); -+ fprintf(stderr, "unknown hint kind %d alt.info.kind at 0x%08lX\n", alt.info.kind, infoA.instructionAddress); - break; - } - } -@@ -2511,13 +2511,13 @@ - LOH_ASSERT(isPageKind(infoB.fixup)); - if ( (infoA.instruction & 0x9F000000) != 0x90000000 ) { - if ( _options.verboseOptimizationHints() ) -- fprintf(stderr, "may-reused-adrp at 0x%08llX no longer an ADRP, now 0x%08X\n", infoA.instructionAddress, infoA.instruction); -+ fprintf(stderr, "may-reused-adrp at 0x%08lX no longer an ADRP, now 0x%08X\n", infoA.instructionAddress, infoA.instruction); - sAdrpNA++; - break; - } - if ( (infoB.instruction & 0x9F000000) != 0x90000000 ) { - if ( _options.verboseOptimizationHints() ) -- fprintf(stderr, "may-reused-adrp at 0x%08llX no longer an ADRP, now 0x%08X\n", infoB.instructionAddress, infoA.instruction); -+ fprintf(stderr, "may-reused-adrp at 0x%08lX no longer an ADRP, now 0x%08X\n", infoB.instructionAddress, infoA.instruction); - sAdrpNA++; - break; - } -@@ -2607,7 +2607,7 @@ - if ( takesNoDiskSpace(sect) ) - continue; - const bool sectionUsesNops = (sect->type() == ld::Section::typeCode); -- //fprintf(stderr, "file offset=0x%08llX, section %s\n", sect->fileOffset, sect->sectionName()); -+ //fprintf(stderr, "file offset=0x%08lX, section %s\n", sect->fileOffset, sect->sectionName()); - std::vector& atoms = sect->atoms; - bool lastAtomWasThumb = false; - for (std::vector::iterator ait = atoms.begin(); ait != atoms.end(); ++ait) { -@@ -2662,11 +2662,11 @@ - // the bitcode section should also be excluded in the UUID computation. - // Bitcode section should appears before LINKEDIT - // Exclude section cmd -- if ( log ) fprintf(stderr, "bundle cmd start=0x%08llX, bundle cmd end=0x%08llX\n", -+ if ( log ) fprintf(stderr, "bundle cmd start=0x%08lX, bundle cmd end=0x%08lX\n", - bitcodeCmdOffset, bitcodeCmdEnd); - excludeRegions.emplace_back(std::pair(bitcodeCmdOffset, bitcodeCmdEnd)); - // Exclude section content -- if ( log ) fprintf(stderr, "bundle start=0x%08llX, bundle end=0x%08llX\n", -+ if ( log ) fprintf(stderr, "bundle start=0x%08lX, bundle end=0x%08lX\n", - bitcodeSectOffset, bitcodePaddingEnd); - excludeRegions.emplace_back(std::pair(bitcodeSectOffset, bitcodePaddingEnd)); - } -@@ -2691,8 +2691,8 @@ - uint64_t lastStabNlistFileOffset = symbolTableFileOffset + stabsOffsetEnd; - uint64_t firstStabStringFileOffset = stringPoolFileOffset + stabsStringsOffsetStart; - uint64_t lastStabStringFileOffset = stringPoolFileOffset + tabsStringsOffsetEnd; -- if ( log ) fprintf(stderr, "stabNlist offset=0x%08llX, size=0x%08llX\n", firstStabNlistFileOffset, lastStabNlistFileOffset-firstStabNlistFileOffset); -- if ( log ) fprintf(stderr, "stabString offset=0x%08llX, size=0x%08llX\n", firstStabStringFileOffset, lastStabStringFileOffset-firstStabStringFileOffset); -+ if ( log ) fprintf(stderr, "stabNlist offset=0x%08lX, size=0x%08lX\n", firstStabNlistFileOffset, lastStabNlistFileOffset-firstStabNlistFileOffset); -+ if ( log ) fprintf(stderr, "stabString offset=0x%08lX, size=0x%08lX\n", firstStabStringFileOffset, lastStabStringFileOffset-firstStabStringFileOffset); - assert(firstStabNlistFileOffset <= firstStabStringFileOffset); - excludeRegions.emplace_back(std::pair(firstStabNlistFileOffset, lastStabNlistFileOffset)); - excludeRegions.emplace_back(std::pair(firstStabStringFileOffset, lastStabStringFileOffset)); -@@ -2701,12 +2701,12 @@ - uint64_t linkeditSegCmdSize; - _headersAndLoadCommandAtom->linkeditCmdInfo(linkeditSegCmdOffset, linkeditSegCmdSize); - excludeRegions.emplace_back(std::pair(linkeditSegCmdOffset, linkeditSegCmdOffset+linkeditSegCmdSize)); -- if ( log ) fprintf(stderr, "linkedit SegCmdOffset=0x%08llX, size=0x%08llX\n", linkeditSegCmdOffset, linkeditSegCmdSize); -+ if ( log ) fprintf(stderr, "linkedit SegCmdOffset=0x%08lX, size=0x%08lX\n", linkeditSegCmdOffset, linkeditSegCmdSize); - uint64_t symbolTableCmdOffset; - uint64_t symbolTableCmdSize; - _headersAndLoadCommandAtom->symbolTableCmdInfo(symbolTableCmdOffset, symbolTableCmdSize); - excludeRegions.emplace_back(std::pair(symbolTableCmdOffset, symbolTableCmdOffset+symbolTableCmdSize)); -- if ( log ) fprintf(stderr, "linkedit SegCmdOffset=0x%08llX, size=0x%08llX\n", symbolTableCmdOffset, symbolTableCmdSize); -+ if ( log ) fprintf(stderr, "linkedit SegCmdOffset=0x%08lX, size=0x%08lX\n", symbolTableCmdOffset, symbolTableCmdSize); - } - if ( !excludeRegions.empty() ) { - CC_MD5_CTX md5state; -@@ -2722,11 +2722,11 @@ - uint64_t regionStart = region.first; - uint64_t regionEnd = region.second; - assert(checksumStart <= regionStart && regionStart <= regionEnd && "Region overlapped"); -- if ( log ) fprintf(stderr, "checksum 0x%08llX -> 0x%08llX\n", checksumStart, regionStart); -+ if ( log ) fprintf(stderr, "checksum 0x%08lX -> 0x%08lX\n", checksumStart, regionStart); - CC_MD5_Update(&md5state, &wholeBuffer[checksumStart], regionStart - checksumStart); - checksumStart = regionEnd; - } -- if ( log ) fprintf(stderr, "checksum 0x%08llX -> 0x%08llX\n", checksumStart, _fileSize); -+ if ( log ) fprintf(stderr, "checksum 0x%08lX -> 0x%08lX\n", checksumStart, _fileSize); - CC_MD5_Update(&md5state, &wholeBuffer[checksumStart], _fileSize-checksumStart); - CC_MD5_Final(digest, &md5state); - if ( log ) fprintf(stderr, "uuid=%02X, %02X, %02X, %02X, %02X, %02X, %02X, %02X\n", digest[0], digest[1], digest[2], -@@ -2857,7 +2857,7 @@ - - wholeBuffer = (uint8_t *)mmap(NULL, _fileSize, PROT_WRITE|PROT_READ, MAP_SHARED, fd, 0); - if ( wholeBuffer == MAP_FAILED ) -- throwf("can't create buffer of %llu bytes for output", _fileSize); -+ throwf("can't create buffer of %lu bytes for output", _fileSize); - } - else { - if ( outputIsRegularFile ) -@@ -2869,7 +2869,7 @@ - // try to allocate buffer for entire output file content - wholeBuffer = (uint8_t*)calloc(_fileSize, 1); - if ( wholeBuffer == NULL ) -- throwf("can't create buffer of %llu bytes for output", _fileSize); -+ throwf("can't create buffer of %lu bytes for output", _fileSize); - } - - if ( _options.UUIDMode() == Options::kUUIDRandom ) { -@@ -4284,7 +4284,7 @@ - uint64_t sctEnd = (sct->address+sct->size); - if ( (sct->address <= targetAddress) && (targetAddress < sctEnd) ) { - if ( (targetAddress+checkAddend) > sctEnd ) { -- warning("data symbol %s from %s has pointer to %s + 0x%08llX. " -+ warning("data symbol %s from %s has pointer to %s + 0x%08lX. " - "That large of an addend may disable %s from being put in the dyld shared cache.", - atom->name(), atom->file()->path(), target->name(), addend, _options.installPath() ); - } -@@ -4728,7 +4728,7 @@ - if ( sect->isSectionHidden() ) - continue; - bool codeSection = (sect->type() == ld::Section::typeCode); -- if (log) fprintf(stderr, "sect: %s, address=0x%llX\n", sect->sectionName(), sect->address); -+ if (log) fprintf(stderr, "sect: %s, address=0x%lX\n", sect->sectionName(), sect->address); - for (std::vector::iterator ait = sect->atoms.begin(); ait != sect->atoms.end(); ++ait) { - const ld::Atom* atom = *ait; - const ld::Atom* target = NULL; -@@ -4887,7 +4887,7 @@ - if ( !hadSubtract && addend ) - toOffset += addend; - assert(toSectionIndex != 255); -- if (log) fprintf(stderr, "from (%d.%s + 0x%llX) to (%d.%s + 0x%llX), kind=%d, atomAddr=0x%llX, sectAddr=0x%llx\n", -+ if (log) fprintf(stderr, "from (%d.%s + 0x%lX) to (%d.%s + 0x%lX), kind=%d, atomAddr=0x%lX, sectAddr=0x%lx\n", - fromSectionIndex, sect->sectionName(), fromOffset, toSectionIndex, state.atomToSection[target]->sectionName(), - toOffset, kind, atom->finalAddress(), sect->address); - _splitSegV2Infos.push_back(SplitSegInfoV2Entry(fromSectionIndex, fromOffset, toSectionIndex, toOffset, kind)); -@@ -4961,7 +4961,7 @@ - ld::Internal::FinalSection* sect = *sit; - if ( sect->isSectionHidden() ) - continue; -- fprintf(mapFile, "0x%08llX\t0x%08llX\t%s\t%s\n", sect->address, sect->size, -+ fprintf(mapFile, "0x%08lX\t0x%08lX\t%s\t%s\n", sect->address, sect->size, - sect->segmentName(), sect->sectionName()); - } - // write table of symbols -@@ -5026,7 +5026,7 @@ - } - name = buffer; - } -- fprintf(mapFile, "0x%08llX\t0x%08llX\t[%3u] %s\n", atom->finalAddress(), atom->size(), -+ fprintf(mapFile, "0x%08lX\t0x%08lX\t[%3u] %s\n", atom->finalAddress(), atom->size(), - readerToFileOrdinal[atom->originalFile()], name); - } - } -@@ -5060,7 +5060,7 @@ - buffer[4095] = '\0'; - name = buffer; - } -- fprintf(mapFile, "<> \t0x%08llX\t[%3u] %s\n", atom->size(), -+ fprintf(mapFile, "<> \t0x%08lX\t[%3u] %s\n", atom->size(), - readerToFileOrdinal[atom->originalFile()], name); - } - } -diff -ur cctools-port-c1cc758/cctools/ld64/src/ld/parsers/archive_file.cpp cctools-port-format/cctools/ld64/src/ld/parsers/archive_file.cpp ---- cctools-port-c1cc758/cctools/ld64/src/ld/parsers/archive_file.cpp 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-format/cctools/ld64/src/ld/parsers/archive_file.cpp 2017-11-10 19:13:05.918259550 -0800 -@@ -601,7 +601,7 @@ - const char* entryName = &_tableOfContentStrings[E::get32(entry->ran_un.ran_strx)]; - uint64_t offset = E::get32(entry->ran_off); - if ( offset > _archiveFilelength ) { -- throwf("malformed archive TOC entry for %s, offset %d is beyond end of file %lld\n", -+ throwf("malformed archive TOC entry for %s, offset %d is beyond end of file %ld\n", - entryName, entry->ran_off, _archiveFilelength); - } - -@@ -622,11 +622,11 @@ - const char* entryName = &_tableOfContentStrings[E::get64(entry->ran_un.ran_strx)]; - uint64_t offset = E::get64(entry->ran_off); - if ( offset > _archiveFilelength ) { -- throwf("malformed archive TOC entry for %s, offset %lld is beyond end of file %lld\n", -+ throwf("malformed archive TOC entry for %s, offset %ld is beyond end of file %ld\n", - entryName, entry->ran_off, _archiveFilelength); - } - -- //fprintf(stderr, "adding hash %d: %s -> 0x%0llX\n", i, entryName, offset); -+ //fprintf(stderr, "adding hash %d: %s -> 0x%0lX\n", i, entryName, offset); - _hashTable[entryName] = offset; - } - } -diff -ur cctools-port-c1cc758/cctools/ld64/src/ld/parsers/libunwind/DwarfInstructions.hpp cctools-port-format/cctools/ld64/src/ld/parsers/libunwind/DwarfInstructions.hpp ---- cctools-port-c1cc758/cctools/ld64/src/ld/parsers/libunwind/DwarfInstructions.hpp 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-format/cctools/ld64/src/ld/parsers/libunwind/DwarfInstructions.hpp 2017-11-10 19:13:05.918259550 -0800 -@@ -245,7 +245,7 @@ - pint_t offsetOfFunctionAddress = p-currentCFI; - pint_t pcStart = addressSpace.getEncodedP(p, nextCFI, cieInfo.pointerEncoding); - pint_t pcRange = addressSpace.getEncodedP(p, nextCFI, cieInfo.pointerEncoding & 0x0F); -- //fprintf(stderr, "FDE with pcRange [0x%08llX, 0x%08llX)\n",(uint64_t)pcStart, (uint64_t)(pcStart+pcRange)); -+ //fprintf(stderr, "FDE with pcRange [0x%08lX, 0x%08lX)\n",(uint64_t)pcStart, (uint64_t)(pcStart+pcRange)); - entry->u.fdeInfo.function.targetAddress = pcStart; - entry->u.fdeInfo.function.offsetInCFI = offsetOfFunctionAddress; - entry->u.fdeInfo.function.encodingOfTargetAddress = cieInfo.pointerEncoding; -@@ -429,7 +429,7 @@ - template - int DwarfInstructions::stepWithDwarf(A& addressSpace, pint_t pc, pint_t fdeStart, R& registers) - { -- //fprintf(stderr, "stepWithDwarf(pc=0x%0llX, fdeStart=0x%0llX)\n", (uint64_t)pc, (uint64_t)fdeStart); -+ //fprintf(stderr, "stepWithDwarf(pc=0x%0lX, fdeStart=0x%0lX)\n", (uint64_t)pc, (uint64_t)fdeStart); - typename CFI_Parser::FDE_Info fdeInfo; - typename CFI_Parser::CIE_Info cieInfo; - if ( CFI_Parser::decodeFDE(addressSpace, fdeStart, &fdeInfo, &cieInfo) == NULL ) { -@@ -483,7 +483,7 @@ - pint_t expressionEnd = expression+20; // just need something until length is read - uint64_t length = addressSpace.getULEB128(p, expressionEnd); - expressionEnd = p + length; -- if (log) fprintf(stderr, "evaluateExpression(): length=%llu\n", length); -+ if (log) fprintf(stderr, "evaluateExpression(): length=%lu\n", length); - pint_t stack[100]; - pint_t* sp = stack; - *(++sp) = initialStackValue; -@@ -491,7 +491,7 @@ - while ( p < expressionEnd ) { - if (log) { - for(pint_t* t = sp; t > stack; --t) { -- fprintf(stderr, "sp[] = 0x%llX\n", (uint64_t)(*t)); -+ fprintf(stderr, "sp[] = 0x%lX\n", (uint64_t)(*t)); - } - } - uint8_t opcode = addressSpace.get8(p++); -@@ -504,14 +504,14 @@ - value = addressSpace.getP(p); - p += sizeof(pint_t); - *(++sp) = value; -- if (log) fprintf(stderr, "push 0x%llX\n", (uint64_t)value); -+ if (log) fprintf(stderr, "push 0x%lX\n", (uint64_t)value); - break; - - case DW_OP_deref: - // pop stack, dereference, push result - value = *sp--; - *(++sp) = addressSpace.getP(value); -- if (log) fprintf(stderr, "dereference 0x%llX\n", (uint64_t)value); -+ if (log) fprintf(stderr, "dereference 0x%lX\n", (uint64_t)value); - break; - - case DW_OP_const1u: -@@ -519,7 +519,7 @@ - value = addressSpace.get8(p); - p += 1; - *(++sp) = value; -- if (log) fprintf(stderr, "push 0x%llX\n", (uint64_t)value); -+ if (log) fprintf(stderr, "push 0x%lX\n", (uint64_t)value); - break; - - case DW_OP_const1s: -@@ -527,7 +527,7 @@ - svalue = (int8_t)addressSpace.get8(p); - p += 1; - *(++sp) = svalue; -- if (log) fprintf(stderr, "push 0x%llX\n", (uint64_t)svalue); -+ if (log) fprintf(stderr, "push 0x%lX\n", (uint64_t)svalue); - break; - - case DW_OP_const2u: -@@ -535,7 +535,7 @@ - value = addressSpace.get16(p); - p += 2; - *(++sp) = value; -- if (log) fprintf(stderr, "push 0x%llX\n", (uint64_t)value); -+ if (log) fprintf(stderr, "push 0x%lX\n", (uint64_t)value); - break; - - case DW_OP_const2s: -@@ -543,7 +543,7 @@ - svalue = (int16_t)addressSpace.get16(p); - p += 2; - *(++sp) = svalue; -- if (log) fprintf(stderr, "push 0x%llX\n", (uint64_t)svalue); -+ if (log) fprintf(stderr, "push 0x%lX\n", (uint64_t)svalue); - break; - - case DW_OP_const4u: -@@ -551,7 +551,7 @@ - value = addressSpace.get32(p); - p += 4; - *(++sp) = value; -- if (log) fprintf(stderr, "push 0x%llX\n", (uint64_t)value); -+ if (log) fprintf(stderr, "push 0x%lX\n", (uint64_t)value); - break; - - case DW_OP_const4s: -@@ -559,7 +559,7 @@ - svalue = (int32_t)addressSpace.get32(p); - p += 4; - *(++sp) = svalue; -- if (log) fprintf(stderr, "push 0x%llX\n", (uint64_t)svalue); -+ if (log) fprintf(stderr, "push 0x%lX\n", (uint64_t)svalue); - break; - - case DW_OP_const8u: -@@ -567,7 +567,7 @@ - value = addressSpace.get64(p); - p += 8; - *(++sp) = value; -- if (log) fprintf(stderr, "push 0x%llX\n", (uint64_t)value); -+ if (log) fprintf(stderr, "push 0x%lX\n", (uint64_t)value); - break; - - case DW_OP_const8s: -@@ -575,21 +575,21 @@ - value = (int32_t)addressSpace.get64(p); - p += 8; - *(++sp) = value; -- if (log) fprintf(stderr, "push 0x%llX\n", (uint64_t)value); -+ if (log) fprintf(stderr, "push 0x%lX\n", (uint64_t)value); - break; - - case DW_OP_constu: - // push immediate ULEB128 value - value = addressSpace.getULEB128(p, expressionEnd); - *(++sp) = value; -- if (log) fprintf(stderr, "push 0x%llX\n", (uint64_t)value); -+ if (log) fprintf(stderr, "push 0x%lX\n", (uint64_t)value); - break; - - case DW_OP_consts: - // push immediate SLEB128 value - svalue = addressSpace.getSLEB128(p, expressionEnd); - *(++sp) = svalue; -- if (log) fprintf(stderr, "push 0x%llX\n", (uint64_t)svalue); -+ if (log) fprintf(stderr, "push 0x%lX\n", (uint64_t)svalue); - break; - - case DW_OP_dup: -@@ -642,7 +642,7 @@ - // pop stack, dereference, push result - value = *sp--; - *sp = *((uint64_t*)value); -- if (log) fprintf(stderr, "x-dereference 0x%llX\n", (uint64_t)value); -+ if (log) fprintf(stderr, "x-dereference 0x%lX\n", (uint64_t)value); - break; - - case DW_OP_abs: -@@ -740,7 +740,7 @@ - svalue = (int16_t)addressSpace.get16(p); - p += 2; - p += svalue; -- if (log) fprintf(stderr, "skip %lld\n", (uint64_t)svalue); -+ if (log) fprintf(stderr, "skip %ld\n", (uint64_t)svalue); - break; - - case DW_OP_bra: -@@ -748,7 +748,7 @@ - p += 2; - if ( *sp-- ) - p += svalue; -- if (log) fprintf(stderr, "bra %lld\n", (uint64_t)svalue); -+ if (log) fprintf(stderr, "bra %ld\n", (uint64_t)svalue); - break; - - case DW_OP_eq: -@@ -821,7 +821,7 @@ - case DW_OP_lit31: - value = opcode - DW_OP_lit0; - *(++sp) = value; -- if (log) fprintf(stderr, "push literal 0x%llX\n", (uint64_t)value); -+ if (log) fprintf(stderr, "push literal 0x%lX\n", (uint64_t)value); - break; - - case DW_OP_reg0: -@@ -864,7 +864,7 @@ - case DW_OP_regx: - reg = addressSpace.getULEB128(p, expressionEnd); - *(++sp) = registers.getRegister(reg); -- if (log) fprintf(stderr, "push reg %d + 0x%llX\n", reg, (uint64_t)svalue); -+ if (log) fprintf(stderr, "push reg %d + 0x%lX\n", reg, (uint64_t)svalue); - break; - - case DW_OP_breg0: -@@ -902,14 +902,14 @@ - reg = opcode - DW_OP_breg0; - svalue = addressSpace.getSLEB128(p, expressionEnd); - *(++sp) = registers.getRegister(reg) + svalue; -- if (log) fprintf(stderr, "push reg %d + 0x%llX\n", reg, (uint64_t)svalue); -+ if (log) fprintf(stderr, "push reg %d + 0x%lX\n", reg, (uint64_t)svalue); - break; - - case DW_OP_bregx: - reg = addressSpace.getULEB128(p, expressionEnd); - svalue = addressSpace.getSLEB128(p, expressionEnd); - *(++sp) = registers.getRegister(reg) + svalue; -- if (log) fprintf(stderr, "push reg %d + 0x%llX\n", reg, (uint64_t)svalue); -+ if (log) fprintf(stderr, "push reg %d + 0x%lX\n", reg, (uint64_t)svalue); - break; - - case DW_OP_fbreg: -@@ -940,7 +940,7 @@ - ABORT("DW_OP_deref_size with bad size"); - } - *(++sp) = value; -- if (log) fprintf(stderr, "sized dereference 0x%llX\n", (uint64_t)value); -+ if (log) fprintf(stderr, "sized dereference 0x%lX\n", (uint64_t)value); - break; - - case DW_OP_xderef_size: -@@ -954,7 +954,7 @@ - } - - } -- if (log) fprintf(stderr, "expression evaluates to 0x%llX\n", (uint64_t)*sp); -+ if (log) fprintf(stderr, "expression evaluates to 0x%lX\n", (uint64_t)*sp); - return *sp; - } - -diff -ur cctools-port-c1cc758/cctools/ld64/src/ld/parsers/libunwind/DwarfParser.hpp cctools-port-format/cctools/ld64/src/ld/parsers/libunwind/DwarfParser.hpp ---- cctools-port-c1cc758/cctools/ld64/src/ld/parsers/libunwind/DwarfParser.hpp 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-format/cctools/ld64/src/ld/parsers/libunwind/DwarfParser.hpp 2017-11-10 19:13:05.918259550 -0800 -@@ -212,12 +212,12 @@ - template - bool CFI_Parser::findFDE(A& addressSpace, pint_t pc, pint_t ehSectionStart, uint32_t sectionLength, pint_t fdeHint, FDE_Info* fdeInfo, CIE_Info* cieInfo) - { -- //fprintf(stderr, "findFDE(0x%llX)\n", (long long)pc); -+ //fprintf(stderr, "findFDE(0x%lX)\n", (long long)pc); - pint_t p = (fdeHint != 0) ? fdeHint : ehSectionStart; - const pint_t ehSectionEnd = p + sectionLength; - while ( p < ehSectionEnd ) { - pint_t currentCFI = p; -- //fprintf(stderr, "findFDE() CFI at 0x%llX\n", (long long)p); -+ //fprintf(stderr, "findFDE() CFI at 0x%lX\n", (long long)p); - uint64_t cfiLength = addressSpace.get32(p); - p += 4; - if ( cfiLength == 0xffffffff ) { -@@ -244,7 +244,7 @@ - // parse pc begin and range - pint_t pcStart = addressSpace.getEncodedP(p, nextCFI, cieInfo->pointerEncoding); - pint_t pcRange = addressSpace.getEncodedP(p, nextCFI, cieInfo->pointerEncoding & 0x0F); -- //fprintf(stderr, "FDE with pcRange [0x%08llX, 0x%08llX)\n",(uint64_t)pcStart, (uint64_t)(pcStart+pcRange)); -+ //fprintf(stderr, "FDE with pcRange [0x%08lX, 0x%08lX)\n",(uint64_t)pcStart, (uint64_t)(pcStart+pcRange)); - // test if pc is within the function this FDE covers - if ( (pcStart < pc) && (pc <= pcStart+pcRange) ) { - // parse rest of info -@@ -269,11 +269,11 @@ - fdeInfo->fdeInstructions = p; - fdeInfo->pcStart = pcStart; - fdeInfo->pcEnd = pcStart+pcRange; -- //fprintf(stderr, "findFDE(pc=0x%llX) found with pcRange [0x%08llX, 0x%08llX)\n",(uint64_t)pc, (uint64_t)pcStart, (uint64_t)(pcStart+pcRange)); -+ //fprintf(stderr, "findFDE(pc=0x%lX) found with pcRange [0x%08lX, 0x%08lX)\n",(uint64_t)pc, (uint64_t)pcStart, (uint64_t)(pcStart+pcRange)); - return true; - } - else { -- //fprintf(stderr, "findFDE(pc=0x%llX) not found with pcRange [0x%08llX, 0x%08llX)\n",(uint64_t)pc, (uint64_t)pcStart, (uint64_t)(pcStart+pcRange)); -+ //fprintf(stderr, "findFDE(pc=0x%lX) not found with pcRange [0x%08lX, 0x%08lX)\n",(uint64_t)pc, (uint64_t)pcStart, (uint64_t)(pcStart+pcRange)); - // pc is not in begin/range, skip this FDE - } - } -@@ -284,13 +284,13 @@ - } - else { - // malformed FDE. CIE is bad -- //fprintf(stderr, "malformed FDE, cieStart=0x%llX, ehSectionStart=0x%llX, ehSectionEnd=0x%llX\n", -+ //fprintf(stderr, "malformed FDE, cieStart=0x%lX, ehSectionStart=0x%lX, ehSectionEnd=0x%lX\n", - // (uint64_t)cieStart, (uint64_t)ehSectionStart, (uint64_t)ehSectionEnd); - } - p = nextCFI; - } - } -- //fprintf(stderr, "findFDE(pc=0x%llX) not found\n",(uint64_t)pc); -+ //fprintf(stderr, "findFDE(pc=0x%lX) not found\n",(uint64_t)pc); - return false; - } - -@@ -302,7 +302,7 @@ - template - const char* CFI_Parser::parseCIE(A& addressSpace, pint_t cie, CIE_Info* cieInfo) - { -- //fprintf(stderr, "parseCIE(0x%llX)\n", (long long)cie); -+ //fprintf(stderr, "parseCIE(0x%lX)\n", (long long)cie); - cieInfo->pointerEncoding = 0; - cieInfo->lsdaEncoding = 0; - cieInfo->personalityEncoding = 0; -@@ -463,7 +463,7 @@ - pint_t offsetOfFunctionAddress = p-currentCFI; - pint_t pcStart = addressSpace.getEncodedP(p, nextCFI, cieInfo.pointerEncoding); - pint_t pcRange = addressSpace.getEncodedP(p, nextCFI, cieInfo.pointerEncoding & 0x0F); -- //fprintf(stderr, "FDE with pcRange [0x%08llX, 0x%08llX)\n",(uint64_t)pcStart, (uint64_t)(pcStart+pcRange)); -+ //fprintf(stderr, "FDE with pcRange [0x%08lX, 0x%08lX)\n",(uint64_t)pcStart, (uint64_t)(pcStart+pcRange)); - // test if pc is within the function this FDE covers - entry.function.address = pcStart; - entry.function.offsetInFDE = offsetOfFunctionAddress; -@@ -518,7 +518,7 @@ - pint_t p = instructions; - uint32_t codeOffset = 0; - PrologInfo initialState = *results; -- if ( logDwarf ) fprintf(stderr, "parseInstructions(instructions=0x%0llX)\n", (uint64_t)instructionsEnd); -+ if ( logDwarf ) fprintf(stderr, "parseInstructions(instructions=0x%0lX)\n", (uint64_t)instructionsEnd); - - // see Dwarf Spec, section 6.4.2 for details on unwind opcodes - while ( (p < instructionsEnd) && (codeOffset < pcoffset) ) { -@@ -564,7 +564,7 @@ - results->registerSavedMoreThanOnce = true; - results->savedRegisters[reg].location = kRegisterInCFA; - results->savedRegisters[reg].value = offset; -- if ( logDwarf ) fprintf(stderr, "DW_CFA_offset_extended(reg=%lld, offset=%lld)\n", reg, offset); -+ if ( logDwarf ) fprintf(stderr, "DW_CFA_offset_extended(reg=%ld, offset=%ld)\n", reg, offset); - break; - case DW_CFA_restore_extended: - reg = addressSpace.getULEB128(p, instructionsEnd);; -@@ -573,7 +573,7 @@ - return false; - } - results->savedRegisters[reg] = initialState.savedRegisters[reg]; -- if ( logDwarf ) fprintf(stderr, "DW_CFA_restore_extended(reg=%lld)\n", reg); -+ if ( logDwarf ) fprintf(stderr, "DW_CFA_restore_extended(reg=%ld)\n", reg); - break; - case DW_CFA_undefined: - reg = addressSpace.getULEB128(p, instructionsEnd); -@@ -582,7 +582,7 @@ - return false; - } - results->savedRegisters[reg].location = kRegisterUnused; -- if ( logDwarf ) fprintf(stderr, "DW_CFA_undefined(reg=%lld)\n", reg); -+ if ( logDwarf ) fprintf(stderr, "DW_CFA_undefined(reg=%ld)\n", reg); - break; - case DW_CFA_same_value: - reg = addressSpace.getULEB128(p, instructionsEnd); -@@ -597,7 +597,7 @@ - results->savedRegisters[reg].location = kRegisterUnused; - // set flag to disable conversion to compact unwind - results->sameValueUsed = true; -- if ( logDwarf ) fprintf(stderr, "DW_CFA_same_value(reg=%lld)\n", reg); -+ if ( logDwarf ) fprintf(stderr, "DW_CFA_same_value(reg=%ld)\n", reg); - break; - case DW_CFA_register: - reg = addressSpace.getULEB128(p, instructionsEnd); -@@ -614,7 +614,7 @@ - results->savedRegisters[reg].value = reg2; - // set flag to disable conversion to compact unwind - results->registersInOtherRegisters = true; -- if ( logDwarf ) fprintf(stderr, "DW_CFA_register(reg=%lld, reg2=%lld)\n", reg, reg2); -+ if ( logDwarf ) fprintf(stderr, "DW_CFA_register(reg=%ld, reg2=%ld)\n", reg, reg2); - break; - case DW_CFA_remember_state: - // avoid operator new, because that would be an upward dependency -@@ -652,7 +652,7 @@ - results->cfaRegisterOffset = offset; - if ( offset > 0x80000000 ) - results->cfaOffsetWasNegative = true; -- if ( logDwarf ) fprintf(stderr, "DW_CFA_def_cfa(reg=%lld, offset=%lld)\n", reg, offset); -+ if ( logDwarf ) fprintf(stderr, "DW_CFA_def_cfa(reg=%ld, offset=%ld)\n", reg, offset); - break; - case DW_CFA_def_cfa_register: - reg = addressSpace.getULEB128(p, instructionsEnd); -@@ -661,7 +661,7 @@ - return false; - } - results->cfaRegister = reg; -- if ( logDwarf ) fprintf(stderr, "DW_CFA_def_cfa_register(%lld)\n", reg); -+ if ( logDwarf ) fprintf(stderr, "DW_CFA_def_cfa_register(%ld)\n", reg); - break; - case DW_CFA_def_cfa_offset: - results->cfaRegisterOffset = addressSpace.getULEB128(p, instructionsEnd); -@@ -673,7 +673,7 @@ - results->cfaExpression = p; - length = addressSpace.getULEB128(p, instructionsEnd); - p += length; -- if ( logDwarf ) fprintf(stderr, "DW_CFA_def_cfa_expression(expression=0x%llX, length=%llu)\n", -+ if ( logDwarf ) fprintf(stderr, "DW_CFA_def_cfa_expression(expression=0x%lX, length=%lu)\n", - results->cfaExpression, length); - break; - case DW_CFA_expression: -@@ -686,7 +686,7 @@ - results->savedRegisters[reg].value = p; - length = addressSpace.getULEB128(p, instructionsEnd); - p += length; -- if ( logDwarf ) fprintf(stderr, "DW_CFA_expression(reg=%lld, expression=0x%llX, length=%llu)\n", -+ if ( logDwarf ) fprintf(stderr, "DW_CFA_expression(reg=%ld, expression=0x%lX, length=%lu)\n", - reg, results->savedRegisters[reg].value, length); - break; - case DW_CFA_offset_extended_sf: -@@ -700,7 +700,7 @@ - results->registerSavedMoreThanOnce = true; - results->savedRegisters[reg].location = kRegisterInCFA; - results->savedRegisters[reg].value = offset; -- if ( logDwarf ) fprintf(stderr, "DW_CFA_offset_extended_sf(reg=%lld, offset=%lld)\n", reg, offset); -+ if ( logDwarf ) fprintf(stderr, "DW_CFA_offset_extended_sf(reg=%ld, offset=%ld)\n", reg, offset); - break; - case DW_CFA_def_cfa_sf: - reg = addressSpace.getULEB128(p, instructionsEnd); -@@ -711,7 +711,7 @@ - } - results->cfaRegister = reg; - results->cfaRegisterOffset = offset; -- if ( logDwarf ) fprintf(stderr, "DW_CFA_def_cfa_sf(reg=%lld, offset=%lld)\n", reg, offset); -+ if ( logDwarf ) fprintf(stderr, "DW_CFA_def_cfa_sf(reg=%ld, offset=%ld)\n", reg, offset); - break; - case DW_CFA_def_cfa_offset_sf: - results->cfaRegisterOffset = addressSpace.getSLEB128(p, instructionsEnd) * cieInfo.dataAlignFactor; -@@ -723,7 +723,7 @@ - offset = addressSpace.getULEB128(p, instructionsEnd) * cieInfo.dataAlignFactor; - results->savedRegisters[reg].location = kRegisterOffsetFromCFA; - results->savedRegisters[reg].value = offset; -- if ( logDwarf ) fprintf(stderr, "DW_CFA_val_offset(reg=%lld, offset=%lld\n", reg, offset); -+ if ( logDwarf ) fprintf(stderr, "DW_CFA_val_offset(reg=%ld, offset=%ld\n", reg, offset); - break; - case DW_CFA_val_offset_sf: - reg = addressSpace.getULEB128(p, instructionsEnd); -@@ -734,7 +734,7 @@ - offset = addressSpace.getSLEB128(p, instructionsEnd) * cieInfo.dataAlignFactor; - results->savedRegisters[reg].location = kRegisterOffsetFromCFA; - results->savedRegisters[reg].value = offset; -- if ( logDwarf ) fprintf(stderr, "DW_CFA_val_offset_sf(reg=%lld, offset=%lld\n", reg, offset); -+ if ( logDwarf ) fprintf(stderr, "DW_CFA_val_offset_sf(reg=%ld, offset=%ld\n", reg, offset); - break; - case DW_CFA_val_expression: - reg = addressSpace.getULEB128(p, instructionsEnd); -@@ -746,13 +746,13 @@ - results->savedRegisters[reg].value = p; - length = addressSpace.getULEB128(p, instructionsEnd); - p += length; -- if ( logDwarf ) fprintf(stderr, "DW_CFA_val_expression(reg=%lld, expression=0x%llX, length=%lld)\n", -+ if ( logDwarf ) fprintf(stderr, "DW_CFA_val_expression(reg=%ld, expression=0x%lX, length=%ld)\n", - reg, results->savedRegisters[reg].value, length); - break; - case DW_CFA_GNU_args_size: - offset = addressSpace.getULEB128(p, instructionsEnd); - results->spExtraArgSize = offset; -- if ( logDwarf ) fprintf(stderr, "DW_CFA_GNU_args_size(%lld)\n", offset); -+ if ( logDwarf ) fprintf(stderr, "DW_CFA_GNU_args_size(%ld)\n", offset); - break; - case DW_CFA_GNU_negative_offset_extended: - reg = addressSpace.getULEB128(p, instructionsEnd); -@@ -765,7 +765,7 @@ - results->registerSavedMoreThanOnce = true; - results->savedRegisters[reg].location = kRegisterInCFA; - results->savedRegisters[reg].value = -offset; -- if ( logDwarf ) fprintf(stderr, "DW_CFA_GNU_negative_offset_extended(%lld)\n", offset); -+ if ( logDwarf ) fprintf(stderr, "DW_CFA_GNU_negative_offset_extended(%ld)\n", offset); - break; - default: - operand = opcode & 0x3F; -@@ -784,7 +784,7 @@ - } - results->savedRegisters[reg].location = kRegisterInCFA; - results->savedRegisters[reg].value = offset; -- if ( logDwarf ) fprintf(stderr, "DW_CFA_offset(reg=%d, offset=%lld)\n", operand, offset); -+ if ( logDwarf ) fprintf(stderr, "DW_CFA_offset(reg=%d, offset=%ld)\n", operand, offset); - break; - case DW_CFA_advance_loc: - codeOffset += operand * cieInfo.codeAlignFactor; -@@ -796,7 +796,7 @@ - //return true; // gcc-4.5 starts the epilog with this - reg = operand; - results->savedRegisters[reg] = initialState.savedRegisters[reg]; -- if ( logDwarf ) fprintf(stderr, "DW_CFA_restore(reg=%lld)\n", reg); -+ if ( logDwarf ) fprintf(stderr, "DW_CFA_restore(reg=%ld)\n", reg); - break; - default: - if ( logDwarf ) fprintf(stderr, "unknown CFA opcode 0x%02X\n", opcode); -diff -ur cctools-port-c1cc758/cctools/ld64/src/ld/parsers/macho_relocatable_file.cpp cctools-port-format/cctools/ld64/src/ld/parsers/macho_relocatable_file.cpp ---- cctools-port-c1cc758/cctools/ld64/src/ld/parsers/macho_relocatable_file.cpp 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-format/cctools/ld64/src/ld/parsers/macho_relocatable_file.cpp 2017-11-10 19:13:05.918259550 -0800 -@@ -902,7 +902,7 @@ - { - const macho_section

* sct = this->sect().machoSection(); - if ( this->_objAddress > sct->addr() + sct->size() ) -- throwf("malformed .o file, symbol has address 0x%0llX which is outside range of its section", (uint64_t)this->_objAddress); -+ throwf("malformed .o file, symbol has address 0x%0lX which is outside range of its section", (uint64_t)this->_objAddress); - uint32_t fileOffset = sct->offset() - sct->addr() + this->_objAddress; - return this->sect().file().fileContent()+fileOffset; - } -@@ -1561,7 +1561,7 @@ - const macho_nlist

& sym = parser.symbolFromIndex(sortedSymbolIndexes[symIndex]); - if ( ! sect.ignoreLabel(parser.nameFromSymbol(sym)) ) { - pint_t nextSymbolAddr = sym.n_value(); -- //fprintf(stderr, "sectNum=%d, nextSymbolAddr=0x%08llX, name=%s\n", sectNum, (uint64_t)nextSymbolAddr, parser.nameFromSymbol(sym)); -+ //fprintf(stderr, "sectNum=%d, nextSymbolAddr=0x%08lX, name=%s\n", sectNum, (uint64_t)nextSymbolAddr, parser.nameFromSymbol(sym)); - if ( (nextSymbolAddr > startAddr) || ((nextSymbolAddr == startAddr) && (sym.n_sect() == sectNum)) ) - break; - } -@@ -1801,7 +1801,7 @@ - for(uint32_t i=0; i < countOfCFIs; ++i) { - if ( cfiArray[i].isCIE ) - continue; -- //fprintf(stderr, "cfiArray[i].func = 0x%08llX, cfiArray[i].lsda = 0x%08llX, encoding=0x%08X\n", -+ //fprintf(stderr, "cfiArray[i].func = 0x%08lX, cfiArray[i].lsda = 0x%08lX, encoding=0x%08X\n", - // (uint64_t)cfiArray[i].u.fdeInfo.function.targetAddress, - // (uint64_t)cfiArray[i].u.fdeInfo.lsda.targetAddress, - // cfiArray[i].u.fdeInfo.compactUnwindInfo); -@@ -1865,7 +1865,7 @@ - breakIterator.beginSection(); - uint32_t count = sections[i]->computeAtomCount(*this, breakIterator, cfis); - //const macho_section

* sect = sections[i]->machoSection(); -- //fprintf(stderr, "computed count=%u for section %s size=%llu\n", count, sect->sectname(), (sect != NULL) ? sect->size() : 0); -+ //fprintf(stderr, "computed count=%u for section %s size=%lu\n", count, sect->sectname(), (sect != NULL) ? sect->size() : 0); - computedAtomCount += count; - } - //fprintf(stderr, "allocating %d atoms * sizeof(Atom)=%ld, sizeof(ld::Atom)=%ld\n", computedAtomCount, sizeof(Atom), sizeof(ld::Atom)); -@@ -2340,7 +2340,7 @@ - if ( log ) { - fprintf(stderr, "unsorted sections:\n"); - for(unsigned int i=0; i < _machOSectionsCount; ++i ) -- fprintf(stderr, "0x%08llX %s %s\n", _sectionsStart[i].addr(), _sectionsStart[i].segname(), _sectionsStart[i].sectname()); -+ fprintf(stderr, "0x%08lX %s %s\n", _sectionsStart[i].addr(), _sectionsStart[i].segname(), _sectionsStart[i].sectname()); - } - - // sort by symbol table address -@@ -2351,7 +2351,7 @@ - if ( log ) { - fprintf(stderr, "sorted sections:\n"); - for(unsigned int i=0; i < _machOSectionsCount; ++i ) -- fprintf(stderr, "0x%08llX %s %s\n", _sectionsStart[array[i]].addr(), _sectionsStart[array[i]].segname(), _sectionsStart[array[i]].sectname()); -+ fprintf(stderr, "0x%08lX %s %s\n", _sectionsStart[array[i]].addr(), _sectionsStart[array[i]].segname(), _sectionsStart[array[i]].sectname()); - } - } - -@@ -2446,7 +2446,7 @@ - _overlappingSymbols = false; - for (unsigned int i=1; i < _symbolsInSections; ++i) { - if ( symbolFromIndex(array[i-1]).n_value() == symbolFromIndex(array[i]).n_value() ) { -- //fprintf(stderr, "overlapping symbols at 0x%08llX\n", symbolFromIndex(array[i-1]).n_value()); -+ //fprintf(stderr, "overlapping symbols at 0x%08lX\n", symbolFromIndex(array[i-1]).n_value()); - _overlappingSymbols = true; - break; - } -@@ -2455,7 +2455,7 @@ - if ( log ) { - fprintf(stderr, "sorted symbols:\n"); - for(unsigned int i=0; i < _symbolsInSections; ++i ) -- fprintf(stderr, "0x%09llX symIndex=%d sectNum=%2d, %s\n", symbolFromIndex(array[i]).n_value(), array[i], symbolFromIndex(array[i]).n_sect(), nameFromSymbol(symbolFromIndex(array[i])) ); -+ fprintf(stderr, "0x%09lX symIndex=%d sectNum=%2d, %s\n", symbolFromIndex(array[i]).n_value(), array[i], symbolFromIndex(array[i]).n_sect(), nameFromSymbol(symbolFromIndex(array[i])) ); - } - } - -@@ -2553,7 +2553,7 @@ - _file->_swiftVersion = ((flags >> 8) & 0xFF); - _file->_objcHasCategoryClassPropertiesField = (flags & 64); - if ( sect->size() > 8 ) { -- warning("section %s/%s has unexpectedly large size %llu in %s", -+ warning("section %s/%s has unexpectedly large size %lu in %s", - sect->segname(), Section::makeSectionName(sect), sect->size(), _file->path()); - } - } -@@ -2805,7 +2805,7 @@ - } - } - -- throwf("sectionForAddress(0x%llX) address not in any section", (uint64_t)addr); -+ throwf("sectionForAddress(0x%lX) address not in any section", (uint64_t)addr); - } - - template -@@ -3540,7 +3540,7 @@ - di += 4; - break; - default: -- warning("unknown dwarf string encoding (form=%lld) in %s", form, this->_path); -+ warning("unknown dwarf string encoding (form=%ld) in %s", form, this->_path); - break; - } - return result; -@@ -3647,7 +3647,7 @@ - std::map dwarfIndexToFile; - if ( lines != NULL ) { - while ( line_next(lines, &result, line_stop_pc) ) { -- //fprintf(stderr, "curAtom=%p, result.pc=0x%llX, result.line=%llu, result.end_of_sequence=%d," -+ //fprintf(stderr, "curAtom=%p, result.pc=0x%lX, result.line=%lu, result.end_of_sequence=%d," - // " curAtomAddress=0x%X, curAtomSize=0x%X\n", - // curAtom, result.pc, result.line, result.end_of_sequence, curAtomAddress, curAtomSize); - // work around weird debug line table compiler generates if no functions in __text section -@@ -3720,7 +3720,7 @@ - entry.info.atomOffset = curAtomOffset; - entry.info.fileName = filename; - entry.info.lineNumber = result.line; -- //fprintf(stderr, "addr=0x%08llX, line=%lld, file=%s, atom=%s, atom.size=0x%X, end=%d\n", -+ //fprintf(stderr, "addr=0x%08lX, line=%ld, file=%s, atom=%s, atom.size=0x%X, end=%d\n", - // result.pc, result.line, filename, curAtom->name(), curAtomSize, result.end_of_sequence); - entries.push_back(entry); - curAtom->incrementLineInfoCount(); -@@ -3796,7 +3796,7 @@ - stab.string = symString; - } - else { -- fprintf(stderr, "can't find atom for stabs BNSYM at %08llX in %s", -+ fprintf(stderr, "can't find atom for stabs BNSYM at %08lX in %s", - (uint64_t)sym.n_value(), _path); - } - break; -@@ -3859,7 +3859,7 @@ - stab.string = symString; - } - else { -- warning("can't find atom for stabs FUN at %08llX in %s", -+ warning("can't find atom for stabs FUN at %08lX in %s", - (uint64_t)currentAtomAddress, _path); - } - } -@@ -3895,7 +3895,7 @@ - stab.string = symString; - } - else { -- warning("can't find atom for stabs 0x%X at %08llX in %s", -+ warning("can't find atom for stabs 0x%X at %08lX in %s", - type, (uint64_t)sym.n_value(), _path); - } - break; -@@ -3927,7 +3927,7 @@ - stab.string = symString; - } - else { -- warning("can't find atom for stabs FUN at %08llX in %s", -+ warning("can't find atom for stabs FUN at %08lX in %s", - (uint64_t)currentAtomAddress, _path); - } - } -@@ -4339,7 +4339,7 @@ - const uint32_t sectionAlignment = this->_machOSection->align(); - uint32_t modulus = (addr % (1 << sectionAlignment)); - if ( modulus > 0xFFFF ) -- warning("alignment for symbol at address 0x%08llX in %s exceeds 2^16", (uint64_t)addr, this->file().path()); -+ warning("alignment for symbol at address 0x%08lX in %s exceeds 2^16", (uint64_t)addr, this->file().path()); - return ld::Atom::Alignment(sectionAlignment, modulus); - } - -@@ -4842,7 +4842,7 @@ - } - } - } -- throwf("__eh_frame parsing problem. Can't find target of reference to address 0x%08llX", (uint64_t)addr); -+ throwf("__eh_frame parsing problem. Can't find target of reference to address 0x%08lX", (uint64_t)addr); - } - } - -@@ -5403,7 +5403,7 @@ - skip = true; - } - else { -- //fprintf(stderr, " 0x%08llX make annon, size=%lld\n", (uint64_t)foundAddr, (uint64_t)size); -+ //fprintf(stderr, " 0x%08lX make annon, size=%ld\n", (uint64_t)foundAddr, (uint64_t)size); - new (allocatedSpace) Atom(*this, this->unlabeledAtomName(parser, foundAddr), foundAddr, - this->elementSizeAtAddress(foundAddr), this->definition(), - this->combine(parser, foundAddr), this->scopeAtAddress(parser, foundAddr), -@@ -5413,7 +5413,7 @@ - } - else { - // make named atom for label -- //fprintf(stderr, " 0x%08llX make labeled\n", (uint64_t)foundAddr); -+ //fprintf(stderr, " 0x%08lX make labeled\n", (uint64_t)foundAddr); - new (allocatedSpace) Atom(*this, parser, *foundLabel, labeledAtomSize); - } - if ( !skip ) { -@@ -5427,7 +5427,7 @@ - for (pint_t addr = foundAddr; addr < (foundAddr+size); addr += elementSizeAtAddress(addr) ) { - // make anon atoms for area before label - if ( this->useElementAt(parser, it, addr) ) { -- //fprintf(stderr, " 0x%08llX make annon, size=%lld\n", (uint64_t)addr, (uint64_t)elementSizeAtAddress(addr)); -+ //fprintf(stderr, " 0x%08lX make annon, size=%ld\n", (uint64_t)addr, (uint64_t)elementSizeAtAddress(addr)); - allocatedSpace = (Atom*)p; - new (allocatedSpace) Atom(*this, this->unlabeledAtomName(parser, addr), addr, this->elementSizeAtAddress(addr), - this->definition(), this->combine(parser, addr), this->scopeAtAddress(parser, addr), -@@ -7587,17 +7587,17 @@ - const uint64_t atomEndAddr = atomStartAddr + inAtom->size(); - for(int i=0; i < count; ++i) { - if ( (addrs[i] < atomStartAddr) || (addrs[i] >= atomEndAddr) ) { -- warning("arm64 Linker Optimiztion Hint addresses are not in same atom: 0x%08llX and 0x%08llX", -+ warning("arm64 Linker Optimiztion Hint addresses are not in same atom: 0x%08lX and 0x%08lX", - lowestAddress, addrs[i]); - return; // skip this LOH - } - if ( (addrs[i] & 0x3) != 0 ) { -- warning("arm64 Linker Optimiztion Hint address is not 4-byte aligned: 0x%08llX", addrs[i]); -+ warning("arm64 Linker Optimiztion Hint address is not 4-byte aligned: 0x%08lX", addrs[i]); - return; // skip this LOH - } - if ( (addrs[i] - lowestAddress) > 0xFFFF ) { - if ( parser.verboseOptimizationHints() ) { -- warning("arm64 Linker Optimiztion Hint addresses are too far apart: 0x%08llX and 0x%08llX", -+ warning("arm64 Linker Optimiztion Hint addresses are too far apart: 0x%08lX and 0x%08lX", - lowestAddress, addrs[i]); - } - return; // skip this LOH -@@ -7785,7 +7785,7 @@ - this->addLOH(parser, kind, count, addrs); - //fprintf(stderr, "kind=%d", kind); - //for (int32_t i=0; i < count; ++i) { -- // fprintf(stderr, ", addr=0x%08llX", addrs[i]); -+ // fprintf(stderr, ", addr=0x%08lX", addrs[i]); - //} - //fprintf(stderr, "\n"); - } -diff -ur cctools-port-c1cc758/cctools/ld64/src/ld/passes/branch_island.cpp cctools-port-format/cctools/ld64/src/ld/passes/branch_island.cpp ---- cctools-port-c1cc758/cctools/ld64/src/ld/passes/branch_island.cpp 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-format/cctools/ld64/src/ld/passes/branch_island.cpp 2017-11-10 19:13:05.918259550 -0800 -@@ -451,7 +451,7 @@ - uint64_t totalTextSize = offset + stubCount*16; - if ( (totalTextSize < textSizeWhenMightNeedBranchIslands(opts, hasThumbBranches)) && !haveCrossSectionBranches ) - return; -- if (_s_log) fprintf(stderr, "ld: section %s size=%llu, might need branch islands\n", textSection->sectionName(), totalTextSize); -+ if (_s_log) fprintf(stderr, "ld: section %s size=%lu, might need branch islands\n", textSection->sectionName(), totalTextSize); - - // Figure out how many regions of branch islands will be needed, and their locations. - // Construct a vector containing the atoms after which branch islands will be inserted, -@@ -493,7 +493,7 @@ - regionsMap[i] = new AtomToIsland(); - regionsIslands[i] = new std::vector(); - regionAddresses[i] = branchIslandInsertionPoints[i]->sectionOffset() + branchIslandInsertionPoints[i]->size(); -- if (_s_log) fprintf(stderr, "ld: branch islands will be inserted at 0x%08llX after %s\n", regionAddresses[i], branchIslandInsertionPoints[i]->name()); -+ if (_s_log) fprintf(stderr, "ld: branch islands will be inserted at 0x%08lX after %s\n", regionAddresses[i], branchIslandInsertionPoints[i]->name()); - } - unsigned int islandCount = 0; - -@@ -561,7 +561,7 @@ - if ( pos == region->end() ) { - island = makeBranchIsland(opts, fit->kind, 0, target, finalTargetAndOffset, atom->section(), true); - (*region)[finalTargetAndOffset] = island; -- if (_s_log) fprintf(stderr, "added absolute branching island %p %s, displacement=%lld\n", -+ if (_s_log) fprintf(stderr, "added absolute branching island %p %s, displacement=%ld\n", - island, island->name(), displacement); - ++islandCount; - regionsIslands[0]->push_back(island); -@@ -577,7 +577,7 @@ - else if ( displacement > kBranchLimit ) { - // create forward branch chain - const ld::Atom* nextTarget = target; -- if (_s_log) fprintf(stderr, "need forward branching island srcAdr=0x%08llX, dstAdr=0x%08llX, target=%s\n", -+ if (_s_log) fprintf(stderr, "need forward branching island srcAdr=0x%08lX, dstAdr=0x%08lX, target=%s\n", - srcAddr, dstAddr, target->name()); - for (int i=kIslandRegionsCount-1; i >=0 ; --i) { - AtomToIsland* region = regionsMap[i]; -@@ -609,7 +609,7 @@ - AtomToIsland* region = regionsMap[i]; - int64_t islandRegionAddr = regionAddresses[i]; - if ( (dstAddr < islandRegionAddr) && (islandRegionAddr <= srcAddr) ) { -- if (_s_log) fprintf(stderr, "need backward branching island srcAdr=0x%08llX, dstAdr=0x%08llX, target=%s\n", srcAddr, dstAddr, target->name()); -+ if (_s_log) fprintf(stderr, "need backward branching island srcAdr=0x%08lX, dstAdr=0x%08lX, target=%s\n", srcAddr, dstAddr, target->name()); - AtomToIsland::iterator pos = region->find(finalTargetAndOffset); - if ( pos == region->end() ) { - ld::Atom* island = makeBranchIsland(opts, fit->kind, i, prevTarget, finalTargetAndOffset, atom->section(), false); -@@ -670,7 +670,7 @@ - ld::Internal::FinalSection* sect = *sit; - uint16_t maxAlignment = 0; - uint64_t offset = 0; -- if ( log ) fprintf(stderr, " section=%s/%s, address=0x%08llX\n", sect->segmentName(), sect->sectionName(), sect->address); -+ if ( log ) fprintf(stderr, " section=%s/%s, address=0x%08lX\n", sect->segmentName(), sect->sectionName(), sect->address); - for (std::vector::iterator ait = sect->atoms.begin(); ait != sect->atoms.end(); ++ait) { - const ld::Atom* atom = *ait; - uint32_t atomAlignmentPowerOf2 = atom->alignment().powerOf2; -@@ -688,7 +688,7 @@ - offset += requiredModulus+alignment-currentModulus; - } - -- if ( log ) fprintf(stderr, " 0x%08llX atom=%p, name=%s\n", sect->address+offset, atom, atom->name()); -+ if ( log ) fprintf(stderr, " 0x%08lX atom=%p, name=%s\n", sect->address+offset, atom, atom->name()); - sAtomToAddress[atom] = sect->address + offset; - - offset += atom->size(); -diff -ur cctools-port-c1cc758/cctools/ld64/src/ld/passes/code_dedup.cpp cctools-port-format/cctools/ld64/src/ld/passes/code_dedup.cpp ---- cctools-port-c1cc758/cctools/ld64/src/ld/passes/code_dedup.cpp 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-format/cctools/ld64/src/ld/passes/code_dedup.cpp 2017-11-10 19:13:05.918259550 -0800 -@@ -296,7 +296,7 @@ - continue; - if ( verbose ) { - dedupSavings += ((dups.size() - 1) * masterAtom->size()); -- fprintf(stderr, "deduplicate the following %lu functions (%llu bytes apiece):\n", dups.size(), masterAtom->size()); -+ fprintf(stderr, "deduplicate the following %lu functions (%lu bytes apiece):\n", dups.size(), masterAtom->size()); - } - for (const ld::Atom* dupAtom : dups) { - if ( verbose ) -@@ -313,7 +313,7 @@ - } - } - if ( verbose ) { -- fprintf(stderr, "deduplication saved %llu bytes of __text\n", dedupSavings); -+ fprintf(stderr, "deduplication saved %lu bytes of __text\n", dedupSavings); - } - - if ( log ) { -@@ -348,7 +348,7 @@ - if ( log ) { - fprintf(stderr, "atoms before pruning:\n"); - for (const ld::Atom* atom : textSection->atoms) -- fprintf(stderr, " %p (size=%llu) %sp\n", atom, atom->size(), atom->name()); -+ fprintf(stderr, " %p (size=%lu) %sp\n", atom, atom->size(), atom->name()); - } - // remove replaced atoms from section - textSection->atoms.erase(std::remove_if(textSection->atoms.begin(), textSection->atoms.end(), -@@ -363,7 +363,7 @@ - if ( log ) { - fprintf(stderr, "atoms after pruning:\n"); - for (const ld::Atom* atom : textSection->atoms) -- fprintf(stderr, " %p (size=%llu) %sp\n", atom, atom->size(), atom->name()); -+ fprintf(stderr, " %p (size=%lu) %sp\n", atom, atom->size(), atom->name()); - } - - //fprintf(stderr, "hash-count=%lu, fixup-compares=%lu, atom-count=%u\n", sHashCount, sFixupCompareCount, atomsBeingComparedCount); -diff -ur cctools-port-c1cc758/cctools/ld64/src/ld/passes/dtrace_dof.cpp cctools-port-format/cctools/ld64/src/ld/passes/dtrace_dof.cpp ---- cctools-port-c1cc758/cctools/ld64/src/ld/passes/dtrace_dof.cpp 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-format/cctools/ld64/src/ld/passes/dtrace_dof.cpp 2017-11-10 19:13:05.918259550 -0800 -@@ -308,9 +308,9 @@ - f->reserveFixups(3*probeCount); - for (uint32_t i=0; i < probeCount; ++i) { - uint64_t offset = offsetsInDOF[i]; -- //fprintf(stderr, "%s offset[%d]=0x%08llX\n", providerName, i, offset); -+ //fprintf(stderr, "%s offset[%d]=0x%08lX\n", providerName, i, offset); - if ( offset > dofSectionSize ) -- throwf("offsetsInDOF[%d]=%0llX > dofSectionSize=%0lX\n", i, offset, dofSectionSize); -+ throwf("offsetsInDOF[%d]=%0lX > dofSectionSize=%0lX\n", i, offset, dofSectionSize); - f->addSectionFixup(ld::Fixup(offset, ld::Fixup::k1of4, ld::Fixup::kindSetTargetAddress, probes[i].atom)); - f->addSectionFixup(ld::Fixup(offset, ld::Fixup::k2of4, ld::Fixup::kindAddAddend, probes[i].offset)); - f->addSectionFixup(ld::Fixup(offset, ld::Fixup::k3of4, ld::Fixup::kindSubtractTargetAddress, &f->atom())); -diff -ur cctools-port-c1cc758/cctools/ld64/src/ld/passes/huge.cpp cctools-port-format/cctools/ld64/src/ld/passes/huge.cpp ---- cctools-port-c1cc758/cctools/ld64/src/ld/passes/huge.cpp 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-format/cctools/ld64/src/ld/passes/huge.cpp 2017-11-10 19:13:05.921592917 -0800 -@@ -115,7 +115,7 @@ - const ld::Atom* atom = *ait; - if ( (address > 0x7FFFFFFFLL) && !sect->isSectionHidden() ) { - state.usingHugeSections = true; -- if (log) fprintf(stderr, "atom: %s is >2GB (0x%09llX), so enabling huge mode\n", atom->name(), address); -+ if (log) fprintf(stderr, "atom: %s is >2GB (0x%09lX), so enabling huge mode\n", atom->name(), address); - break; - } - address += atom->size(); -@@ -139,7 +139,7 @@ - if ( atom->size() > 1024*1024 ) { - hugeSection->atoms.push_back(atom); - state.atomToSection[atom] = hugeSection; -- if (log) fprintf(stderr, "moved to __huge: %s, size=%llu\n", atom->name(), atom->size()); -+ if (log) fprintf(stderr, "moved to __huge: %s, size=%lu\n", atom->name(), atom->size()); - *ait = NULL; // change atom to NULL for later bulk removal - movedSome = true; - } -diff -ur cctools-port-c1cc758/cctools/ld64/src/ld/SymbolTable.cpp cctools-port-format/cctools/ld64/src/ld/SymbolTable.cpp ---- cctools-port-c1cc758/cctools/ld64/src/ld/SymbolTable.cpp 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-format/cctools/ld64/src/ld/SymbolTable.cpp 2017-11-10 19:13:05.921592917 -0800 -@@ -324,7 +324,7 @@ - if ( _atomB.size() > _atomA.size() ) { - const char* atomApath = (_atomA.file() != NULL) ? _atomA.file()->path() : ""; - const char* atomBpath = (_atomB.file() != NULL) ? _atomB.file()->path() : ""; -- warning("tentative definition of '%s' with size %llu from '%s' is being replaced by real definition of smaller size %llu from '%s'", -+ warning("tentative definition of '%s' with size %lu from '%s' is being replaced by real definition of smaller size %lu from '%s'", - _atomA.name(), _atomB.size(), atomBpath, _atomA.size(), atomApath); - } - pickAtomA(); -@@ -344,7 +344,7 @@ - if ( _atomA.size() > _atomB.size() ) { - const char* atomApath = (_atomA.file() != NULL) ? _atomA.file()->path() : ""; - const char* atomBpath = (_atomB.file() != NULL) ? _atomB.file()->path() : ""; -- warning("tentative definition of '%s' with size %llu from '%s' is being replaced by real definition of smaller size %llu from '%s'", -+ warning("tentative definition of '%s' with size %lu from '%s' is being replaced by real definition of smaller size %lu from '%s'", - _atomA.name(), _atomA.size(),atomApath, _atomB.size(), atomBpath); - } - pickAtomB(); -diff -ur cctools-port-c1cc758/cctools/ld64/src/other/dyldinfo.cpp cctools-port-format/cctools/ld64/src/other/dyldinfo.cpp ---- cctools-port-c1cc758/cctools/ld64/src/other/dyldinfo.cpp 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-format/cctools/ld64/src/other/dyldinfo.cpp 2017-11-10 19:13:05.921592917 -0800 -@@ -587,7 +587,7 @@ - return i; - } - } -- throwf("address 0x%llX is not in any segment", (uint64_t)address); -+ throwf("address 0x%lX is not in any segment", (uint64_t)address); - } - - template -@@ -599,7 +599,7 @@ - return (pint_t*)((uint8_t*)fHeader + offsetInMappedFile); - } - } -- throwf("address 0x%llX is not in any segment", (uint64_t)vmaddress); -+ throwf("address 0x%lX is not in any segment", (uint64_t)vmaddress); - } - - template -@@ -686,26 +686,26 @@ - break; - case REBASE_OPCODE_DO_REBASE_IMM_TIMES: - for (int i=0; i < immediate; ++i) { -- printf("%-7s %-16s 0x%08llX %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName); -+ printf("%-7s %-16s 0x%08lX %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName); - segOffset += sizeof(pint_t); - } - break; - case REBASE_OPCODE_DO_REBASE_ULEB_TIMES: - count = read_uleb128(p, end); - for (uint32_t i=0; i < count; ++i) { -- printf("%-7s %-16s 0x%08llX %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName); -+ printf("%-7s %-16s 0x%08lX %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName); - segOffset += sizeof(pint_t); - } - break; - case REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB: -- printf("%-7s %-16s 0x%08llX %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName); -+ printf("%-7s %-16s 0x%08lX %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName); - segOffset += read_uleb128(p, end) + sizeof(pint_t); - break; - case REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB: - count = read_uleb128(p, end); - skip = read_uleb128(p, end); - for (uint32_t i=0; i < count; ++i) { -- printf("%-7s %-16s 0x%08llX %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName); -+ printf("%-7s %-16s 0x%08lX %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName); - segOffset += skip + sizeof(pint_t); - } - break; -@@ -754,15 +754,15 @@ - case REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB: - segmentIndex = immediate; - address = read_uleb128(p, end); -- printf("0x%04X REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB(%d, 0x%08llX)\n", opcodeOffset, segmentIndex, address); -+ printf("0x%04X REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB(%d, 0x%08lX)\n", opcodeOffset, segmentIndex, address); - break; - case REBASE_OPCODE_ADD_ADDR_ULEB: - address = read_uleb128(p, end); -- printf("0x%04X REBASE_OPCODE_ADD_ADDR_ULEB(0x%0llX)\n", opcodeOffset, address); -+ printf("0x%04X REBASE_OPCODE_ADD_ADDR_ULEB(0x%0lX)\n", opcodeOffset, address); - break; - case REBASE_OPCODE_ADD_ADDR_IMM_SCALED: - address = immediate*sizeof(pint_t); -- printf("0x%04X REBASE_OPCODE_ADD_ADDR_IMM_SCALED(0x%0llX)\n", opcodeOffset, address); -+ printf("0x%04X REBASE_OPCODE_ADD_ADDR_IMM_SCALED(0x%0lX)\n", opcodeOffset, address); - break; - case REBASE_OPCODE_DO_REBASE_IMM_TIMES: - printf("0x%04X REBASE_OPCODE_DO_REBASE_IMM_TIMES(%d)\n", opcodeOffset, immediate); -@@ -871,12 +871,12 @@ - break; - case BIND_OPCODE_SET_ADDEND_SLEB: - addend = read_sleb128(p, end); -- printf("0x%04X BIND_OPCODE_SET_ADDEND_SLEB(%lld)\n", opcodeOffset, addend); -+ printf("0x%04X BIND_OPCODE_SET_ADDEND_SLEB(%ld)\n", opcodeOffset, addend); - break; - case BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB: - segmentIndex = immediate; - address = read_uleb128(p, end); -- printf("0x%04X BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB(0x%02X, 0x%08llX)\n", opcodeOffset, segmentIndex, address); -+ printf("0x%04X BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB(0x%02X, 0x%08lX)\n", opcodeOffset, segmentIndex, address); - break; - case BIND_OPCODE_ADD_ADDR_ULEB: - skip = read_uleb128(p, end); -@@ -987,22 +987,22 @@ - segOffset += read_uleb128(p, end); - break; - case BIND_OPCODE_DO_BIND: -- printf("%-7s %-16s 0x%08llX %10s %5lld %-16s %s%s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName, addend, fromDylib, symbolName, weak_import ); -+ printf("%-7s %-16s 0x%08lX %10s %5ld %-16s %s%s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName, addend, fromDylib, symbolName, weak_import ); - segOffset += sizeof(pint_t); - break; - case BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB: -- printf("%-7s %-16s 0x%08llX %10s %5lld %-16s %s%s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName, addend, fromDylib, symbolName, weak_import ); -+ printf("%-7s %-16s 0x%08lX %10s %5ld %-16s %s%s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName, addend, fromDylib, symbolName, weak_import ); - segOffset += read_uleb128(p, end) + sizeof(pint_t); - break; - case BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED: -- printf("%-7s %-16s 0x%08llX %10s %5lld %-16s %s%s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName, addend, fromDylib, symbolName, weak_import ); -+ printf("%-7s %-16s 0x%08lX %10s %5ld %-16s %s%s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName, addend, fromDylib, symbolName, weak_import ); - segOffset += immediate*sizeof(pint_t) + sizeof(pint_t); - break; - case BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB: - count = read_uleb128(p, end); - skip = read_uleb128(p, end); - for (uint32_t i=0; i < count; ++i) { -- printf("%-7s %-16s 0x%08llX %10s %5lld %-16s %s%s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName, addend, fromDylib, symbolName, weak_import ); -+ printf("%-7s %-16s 0x%08lX %10s %5ld %-16s %s%s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName, addend, fromDylib, symbolName, weak_import ); - segOffset += skip + sizeof(pint_t); - } - break; -@@ -1070,22 +1070,22 @@ - segOffset += read_uleb128(p, end); - break; - case BIND_OPCODE_DO_BIND: -- printf("%-7s %-16s 0x%08llX %10s %5lld %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName, addend, symbolName ); -+ printf("%-7s %-16s 0x%08lX %10s %5ld %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName, addend, symbolName ); - segOffset += sizeof(pint_t); - break; - case BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB: -- printf("%-7s %-16s 0x%08llX %10s %5lld %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName, addend, symbolName ); -+ printf("%-7s %-16s 0x%08lX %10s %5ld %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName, addend, symbolName ); - segOffset += read_uleb128(p, end) + sizeof(pint_t); - break; - case BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED: -- printf("%-7s %-16s 0x%08llX %10s %5lld %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName, addend, symbolName ); -+ printf("%-7s %-16s 0x%08lX %10s %5ld %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName, addend, symbolName ); - segOffset += immediate*sizeof(pint_t) + sizeof(pint_t); - break; - case BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB: - count = read_uleb128(p, end); - skip = read_uleb128(p, end); - for (uint32_t i=0; i < count; ++i) { -- printf("%-7s %-16s 0x%08llX %10s %5lld %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName, addend, symbolName ); -+ printf("%-7s %-16s 0x%08lX %10s %5ld %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName, addend, symbolName ); - segOffset += skip + sizeof(pint_t); - } - break; -@@ -1178,7 +1178,7 @@ - segOffset += read_uleb128(p, end); - break; - case BIND_OPCODE_DO_BIND: -- printf("%-7s %-16s 0x%08llX 0x%04X %-16s %s%s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, lazy_offset, fromDylib, symbolName, weak_import); -+ printf("%-7s %-16s 0x%08lX 0x%04X %-16s %s%s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, lazy_offset, fromDylib, symbolName, weak_import); - segOffset += sizeof(pint_t); - break; - default: -@@ -1252,12 +1252,12 @@ - break; - case BIND_OPCODE_SET_ADDEND_SLEB: - addend = read_sleb128(p, end); -- printf("0x%04X BIND_OPCODE_SET_ADDEND_SLEB(%lld)\n", opcodeOffset, addend); -+ printf("0x%04X BIND_OPCODE_SET_ADDEND_SLEB(%ld)\n", opcodeOffset, addend); - break; - case BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB: - segmentIndex = immediate; - address = read_uleb128(p, end); -- printf("0x%04X BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB(0x%02X, 0x%08llX)\n", opcodeOffset, segmentIndex, address); -+ printf("0x%04X BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB(0x%02X, 0x%08lX)\n", opcodeOffset, segmentIndex, address); - break; - case BIND_OPCODE_ADD_ADDR_ULEB: - skip = read_uleb128(p, end); -@@ -1317,7 +1317,7 @@ - if ( reExport ) - printf("[re-export] "); - else -- printf("0x%08llX ", fBaseAddress+it->address); -+ printf("0x%08lX ", fBaseAddress+it->address); - printf("%s", it->name); - if ( weakDef || threadLocal || resolver || abs ) { - bool needComma = false; -@@ -1341,7 +1341,7 @@ - if ( resolver ) { - if ( needComma ) - printf(", "); -- printf("resolver=0x%08llX", it->other); -+ printf("resolver=0x%08lX", it->other); - needComma = true; - } - printf("]"); -@@ -1375,13 +1375,13 @@ - ++p; - ++p; - if ( *importName == '\0' ) -- printf("\tnode%03ld [ label=%s,re-export from dylib=%llu ];\n", (long)(me-start), cummulativeString, ordinal); -+ printf("\tnode%03ld [ label=%s,re-export from dylib=%lu ];\n", (long)(me-start), cummulativeString, ordinal); - else -- printf("\tnode%03ld [ label=%s,re-export %s from dylib=%llu ];\n", (long)(me-start), cummulativeString, importName, ordinal); -+ printf("\tnode%03ld [ label=%s,re-export %s from dylib=%lu ];\n", (long)(me-start), cummulativeString, importName, ordinal); - } - else { - uint64_t address = read_uleb128(p, end); -- printf("\tnode%03ld [ label=%s,addr0x%08llX ];\n", (long)(me-start), cummulativeString, address); -+ printf("\tnode%03ld [ label=%s,addr0x%08lX ];\n", (long)(me-start), cummulativeString, address); - if ( flags & EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER ) - read_uleb128(p, end); - } -@@ -1469,25 +1469,25 @@ - ++p; - ++p; - if ( strlen(importName) == 0 ) -- printf("[flags=REEXPORT ordinal=%llu] ", ordinal); -+ printf("[flags=REEXPORT ordinal=%lu] ", ordinal); - else -- printf("[flags=REEXPORT ordinal=%llu import=%s] ", ordinal, importName); -+ printf("[flags=REEXPORT ordinal=%lu import=%s] ", ordinal, importName); - } - else if ( flags & EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER ) { - uint64_t stub = read_uleb128(p, end); - uint64_t resolver = read_uleb128(p, end); -- printf("[flags=STUB_AND_RESOLVER stub=0x%06llX resolver=0x%06llX] ", stub, resolver); -+ printf("[flags=STUB_AND_RESOLVER stub=0x%06lX resolver=0x%06lX] ", stub, resolver); - } - else { - uint64_t address = read_uleb128(p, end); - if ( (flags & EXPORT_SYMBOL_FLAGS_KIND_MASK) == EXPORT_SYMBOL_FLAGS_KIND_REGULAR ) -- printf("[addr=0x%06llX] ", address); -+ printf("[addr=0x%06lX] ", address); - else if ( (flags & EXPORT_SYMBOL_FLAGS_KIND_MASK) == EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL) -- printf("[flags=THREAD_LOCAL addr=0x%06llX] ", address); -+ printf("[flags=THREAD_LOCAL addr=0x%06lX] ", address); - else if ( (flags & EXPORT_SYMBOL_FLAGS_KIND_MASK) == EXPORT_SYMBOL_FLAGS_KIND_ABSOLUTE) -- printf("[flags=ABSOLUTE addr=0x%06llX] ", address); -+ printf("[flags=ABSOLUTE addr=0x%06lX] ", address); - else -- printf("[flags=0x%llX addr=0x%06llX] ", flags, address); -+ printf("[flags=0x%lX addr=0x%06lX] ", flags, address); - } - } - // print child edges -@@ -1627,7 +1627,7 @@ - do { - delta = read_uleb128(p, end); - address += delta; -- printf("0x%0llX %s\n", address+fBaseAddress, kindStr); -+ printf("0x%0lX %s\n", address+fBaseAddress, kindStr); - } while (delta); - - return p; -@@ -1659,7 +1659,7 @@ - char fromSectionName[20]; - strncpy(fromSectionName, fromSection->sectname(), 16); - fromSectionName[16] = '\0'; -- printf("from sect=%s/%s, to sect=%s/%s, count=%lld:\n", fromSection->segname(), fromSectionName, toSection->segname(), toSection->sectname(), toOffsetCount); -+ printf("from sect=%s/%s, to sect=%s/%s, count=%ld:\n", fromSection->segname(), fromSectionName, toSection->segname(), toSection->sectname(), toOffsetCount); - uint64_t toSectionOffset = 0; - const char* lastFromSymbol = NULL; - for (uint64_t j=0; j < toOffsetCount; ++j) { -@@ -1678,12 +1678,12 @@ - if ( (s != lastFromSymbol) && (s != NULL) ) - printf(" %s:\n", s); - const char* toSymbol = closestSymbolNameForAddress(toSection->addr()+toSectionOffset, &symbolOffset, toSectionIndex); -- printf(" from addr=0x%0llX %s to addr=0x%0llX", fromSection->addr()+fromSectionOffset, sharedRegionKindName(kind), toSection->addr()+toSectionOffset); -+ printf(" from addr=0x%0lX %s to addr=0x%0lX", fromSection->addr()+fromSectionOffset, sharedRegionKindName(kind), toSection->addr()+toSectionOffset); - if ( toSymbol != NULL ) { - if ( symbolOffset == 0 ) - printf(" (%s)", toSymbol); - else -- printf(" (%s + %lld)", toSymbol, symbolOffset); -+ printf(" (%s + %ld)", toSymbol, symbolOffset); - } - printf("\n"); - lastFromSymbol = s; -@@ -1740,16 +1740,16 @@ - void DyldInfoPrinter::printFunctionStartLine(uint64_t addr) - { - if ( addr & 1 ) -- printf("0x%0llX [thumb] %s\n", (addr & -2), symbolNameForAddress(addr & -2)); -+ printf("0x%0lX [thumb] %s\n", (addr & -2), symbolNameForAddress(addr & -2)); - else -- printf("0x%0llX %s\n", addr, symbolNameForAddress(addr)); -+ printf("0x%0lX %s\n", addr, symbolNameForAddress(addr)); - } - #endif - - template - void DyldInfoPrinter::printFunctionStartLine(uint64_t addr) - { -- printf("0x%0llX %s\n", addr, symbolNameForAddress(addr)); -+ printf("0x%0lX %s\n", addr, symbolNameForAddress(addr)); - } - - -@@ -2023,7 +2023,7 @@ - const char* typeName = relocTypeName(reloc->r_type()); - const char* segName = segmentName(segIndex); - const char* sectName = sectionName(segIndex, addr); -- printf("%-8s %-16s 0x%08llX %s\n", segName, sectName, (uint64_t)addr, typeName); -+ printf("%-8s %-16s 0x%08lX %s\n", segName, sectName, (uint64_t)addr, typeName); - } - else { - const macho_scattered_relocation_info

* sreloc = (macho_scattered_relocation_info

*)reloc; -@@ -2032,7 +2032,7 @@ - const char* typeName = relocTypeName(sreloc->r_type()); - const char* segName = segmentName(segIndex); - const char* sectName = sectionName(segIndex, addr); -- printf("%-8s %-16s 0x%08llX %s\n", segName, sectName, (uint64_t)addr, typeName); -+ printf("%-8s %-16s 0x%08lX %s\n", segName, sectName, (uint64_t)addr, typeName); - } - } - // look for local non-lazy-pointers -@@ -2054,7 +2054,7 @@ - const char* typeName = "pointer"; - const char* segName = segmentName(segIndex); - const char* sectName = sectionName(segIndex, addr); -- printf("%-8s %-16s 0x%08llX %s\n", segName, sectName, (uint64_t)addr, typeName); -+ printf("%-8s %-16s 0x%08lX %s\n", segName, sectName, (uint64_t)addr, typeName); - } - } - } -@@ -2080,7 +2080,7 @@ - pint_t thumb = 0; - if ( sym->n_desc() & N_ARM_THUMB_DEF ) - thumb = 1; -- printf("0x%08llX %s%s\n", sym->n_value()+thumb, flags, &fStrings[sym->n_strx()]); -+ printf("0x%08lX %s%s\n", sym->n_value()+thumb, flags, &fStrings[sym->n_strx()]); - } - } - } -@@ -2176,7 +2176,7 @@ - // To get the addend requires subtracting out the base address it was prebound to. - addend -= sym->n_value(); - } -- printf("%-8s %-16s 0x%08llX %10s %4s %5lld %-16s %s\n", segName, sectName, (uint64_t)addr, -+ printf("%-8s %-16s 0x%08lX %10s %4s %5ld %-16s %s\n", segName, sectName, (uint64_t)addr, - typeName, weak_import, addend, fromDylib, symbolName); - } - // look for non-lazy pointers -@@ -2203,7 +2203,7 @@ - const char* segName = segmentName(segIndex); - const char* sectName = sectionName(segIndex, addr); - int64_t addend = 0; -- printf("%-8s %-16s 0x%08llX %10s %4s %5lld %-16s %s\n", segName, sectName, (uint64_t)addr, -+ printf("%-8s %-16s 0x%08lX %10s %4s %5ld %-16s %s\n", segName, sectName, (uint64_t)addr, - typeName, weak_import, addend, fromDylib, symbolName); - } - } -@@ -2242,7 +2242,7 @@ - uint8_t segIndex = segmentIndexForAddress(addr); - const char* segName = segmentName(segIndex); - const char* sectName = sectionName(segIndex, addr); -- printf("%-7s %-16s 0x%08llX 0x%04X %-16s %s\n", segName, sectName, (uint64_t)addr, symbolIndex, fromDylib, symbolName); -+ printf("%-7s %-16s 0x%08lX 0x%04X %-16s %s\n", segName, sectName, (uint64_t)addr, symbolIndex, fromDylib, symbolName); - } - } - else if ( (type == S_SYMBOL_STUBS) && (((sect->flags() & S_ATTR_SELF_MODIFYING_CODE) != 0)) && (sect->reserved2() == 5) ) { -@@ -2259,7 +2259,7 @@ - uint8_t segIndex = segmentIndexForAddress(addr); - const char* segName = segmentName(segIndex); - const char* sectName = sectionName(segIndex, addr); -- printf("%-7s %-16s 0x%08llX 0x%04X %-16s %s\n", segName, sectName, (uint64_t)addr, symbolIndex, fromDylib, symbolName); -+ printf("%-7s %-16s 0x%08lX 0x%04X %-16s %s\n", segName, sectName, (uint64_t)addr, symbolIndex, fromDylib, symbolName); - } - } - } -diff -ur cctools-port-c1cc758/cctools/ld64/src/other/machochecker.cpp cctools-port-format/cctools/ld64/src/other/machochecker.cpp ---- cctools-port-c1cc758/cctools/ld64/src/other/machochecker.cpp 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-format/cctools/ld64/src/other/machochecker.cpp 2017-11-10 19:13:05.921592917 -0800 -@@ -639,12 +639,12 @@ - if ( threadInfo != NULL ) { - pint_t initialPC = getEntryPoint(threadInfo); - if ( (initialPC < fTEXTSegment->vmaddr()) || (initialPC >= (fTEXTSegment->vmaddr()+fTEXTSegment->vmsize())) ) -- throwf("entry point 0x%0llX is outside __TEXT segment", (long long)initialPC); -+ throwf("entry point 0x%0lX is outside __TEXT segment", (long long)initialPC); - } - else if ( entryPoint != NULL ) { - pint_t initialOffset = entryPoint->entryoff(); - if ( (initialOffset < fTEXTSegment->fileoff()) || (initialOffset >= (fTEXTSegment->fileoff()+fTEXTSegment->filesize())) ) -- throwf("entry point 0x%0llX is outside __TEXT segment", (long long)initialOffset); -+ throwf("entry point 0x%0lX is outside __TEXT segment", (long long)initialOffset); - } - - // checks for executables -@@ -1086,7 +1086,7 @@ - for (pint_t* p=arrayStart; p < arrayEnd; ++p) { - pint_t pointer = P::getP(*p); - if ( (pointer < fTEXTSegment->vmaddr()) || (pointer >= (fTEXTSegment->vmaddr()+fTEXTSegment->vmsize())) ) -- throwf("%s 0x%08llX points outside __TEXT segment", kind, (long long)pointer); -+ throwf("%s 0x%08lX points outside __TEXT segment", kind, (long long)pointer); - } - // check each pointer in array will be rebased and not bound - if ( fSlidableImage ) { -@@ -1094,9 +1094,9 @@ - pint_t sectionEndddr = sect->addr() + sect->size(); - for(pint_t addr = sectionBeginAddr; addr < sectionEndddr; addr += sizeof(pint_t)) { - if ( addressIsBindingSite(addr) ) -- throwf("%s at 0x%0llX has binding to external symbol", kind, (long long)addr); -+ throwf("%s at 0x%0lX has binding to external symbol", kind, (long long)addr); - if ( ! addressIsRebaseSite(addr) ) -- throwf("%s at 0x%0llX is not rebased", kind, (long long)addr); -+ throwf("%s at 0x%0lX is not rebased", kind, (long long)addr); - } - } - break; -@@ -1392,7 +1392,7 @@ - addr = segStartAddr+segOffset; - if ( (rangeStart <= addr) && (addr < rangeEnd) ) - return true; -- //printf("%-7s %-16s 0x%08llX %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName); -+ //printf("%-7s %-16s 0x%08lX %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName); - segOffset += sizeof(pint_t); - } - break; -@@ -1402,7 +1402,7 @@ - addr = segStartAddr+segOffset; - if ( (rangeStart <= addr) && (addr < rangeEnd) ) - return true; -- //printf("%-7s %-16s 0x%08llX %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName); -+ //printf("%-7s %-16s 0x%08lX %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName); - segOffset += sizeof(pint_t); - } - break; -@@ -1410,7 +1410,7 @@ - addr = segStartAddr+segOffset; - if ( (rangeStart <= addr) && (addr < rangeEnd) ) - return true; -- //printf("%-7s %-16s 0x%08llX %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName); -+ //printf("%-7s %-16s 0x%08lX %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName); - segOffset += read_uleb128(p, end) + sizeof(pint_t); - break; - case REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB: -@@ -1420,7 +1420,7 @@ - addr = segStartAddr+segOffset; - if ( (rangeStart <= addr) && (addr < rangeEnd) ) - return true; -- //printf("%-7s %-16s 0x%08llX %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName); -+ //printf("%-7s %-16s 0x%08lX %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName); - segOffset += skip + sizeof(pint_t); - } - break; -@@ -1482,7 +1482,7 @@ - addr = segStartAddr+segOffset; - if ( addr == targetAddr ) - return true; -- //printf("%-7s %-16s 0x%08llX %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName); -+ //printf("%-7s %-16s 0x%08lX %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName); - segOffset += sizeof(pint_t); - } - break; -@@ -1492,7 +1492,7 @@ - addr = segStartAddr+segOffset; - if ( addr == targetAddr ) - return true; -- //printf("%-7s %-16s 0x%08llX %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName); -+ //printf("%-7s %-16s 0x%08lX %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName); - segOffset += sizeof(pint_t); - } - break; -@@ -1500,7 +1500,7 @@ - addr = segStartAddr+segOffset; - if ( addr == targetAddr ) - return true; -- //printf("%-7s %-16s 0x%08llX %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName); -+ //printf("%-7s %-16s 0x%08lX %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName); - segOffset += read_uleb128(p, end) + sizeof(pint_t); - break; - case REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB: -@@ -1510,7 +1510,7 @@ - addr = segStartAddr+segOffset; - if ( addr == targetAddr ) - return true; -- //printf("%-7s %-16s 0x%08llX %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName); -+ //printf("%-7s %-16s 0x%08lX %s\n", segName, sectionName(segIndex, segStartAddr+segOffset), segStartAddr+segOffset, typeName); - segOffset += skip + sizeof(pint_t); - } - break; -diff -ur cctools-port-c1cc758/cctools/ld64/src/other/ObjectDump.cpp cctools-port-format/cctools/ld64/src/other/ObjectDump.cpp ---- cctools-port-c1cc758/cctools/ld64/src/other/ObjectDump.cpp 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-format/cctools/ld64/src/other/ObjectDump.cpp 2017-11-10 19:13:05.921592917 -0800 -@@ -630,7 +630,7 @@ - } - else { - uint64_t sectAddr = addressOfFirstAtomInSection(atom.section()); -- sprintf(buffer, "%s@%s+0x%08llX", atom.name(), atom.section().sectionName(), atom.objectAddress()-sectAddr); -+ sprintf(buffer, "%s@%s+0x%08lX", atom.name(), atom.section().sectionName(), atom.objectAddress()-sectAddr); - } - break; - case ld::Atom::symbolTableNotInFinalLinkedImages: -@@ -704,10 +704,10 @@ - printf(" - %s", referenceTargetAtomName(ref)); - break; - case ld::Fixup::kindAddAddend: -- printf(" + 0x%llX", ref->u.addend); -+ printf(" + 0x%lX", ref->u.addend); - break; - case ld::Fixup::kindSubtractAddend: -- printf(" - 0x%llX", ref->u.addend); -+ printf(" - 0x%lX", ref->u.addend); - break; - case ld::Fixup::kindSetTargetImageOffset: - printf("imageOffset(%s)", referenceTargetAtomName(ref)); -@@ -1063,7 +1063,7 @@ - void dumper::dumpAtom(const ld::Atom& atom) - { - printf("name: %s\n", makeName(atom)); -- printf("size: 0x%0llX\n", atom.size()); -+ printf("size: 0x%0lX\n", atom.size()); - printf("align: %u mod %u\n", atom.alignment().modulus, (1 << atom.alignment().powerOf2) ); - printf("scope: %s\n", scopeString(atom)); - if ( sShowDefinitionKind ) -diff -ur cctools-port-c1cc758/cctools/ld64/src/other/rebase.cpp cctools-port-format/cctools/ld64/src/other/rebase.cpp ---- cctools-port-c1cc758/cctools/ld64/src/other/rebase.cpp 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-format/cctools/ld64/src/other/rebase.cpp 2017-11-10 19:13:05.921592917 -0800 -@@ -454,7 +454,7 @@ - template - void Rebaser::rebaseAt(int segIndex, uint64_t offset, uint8_t type) - { -- //fprintf(stderr, "rebaseAt(seg=%d, offset=0x%08llX, type=%d\n", segIndex, offset, type); -+ //fprintf(stderr, "rebaseAt(seg=%d, offset=0x%08lX, type=%d\n", segIndex, offset, type); - static int lastSegIndex = -1; - static uint8_t* lastSegMappedStart = NULL; - if ( segIndex != lastSegIndex ) { -@@ -857,7 +857,7 @@ - ai.vmSize = rebaser->getVMSize(); - ai.orgBase = rebaser->getBaseAddress(); - ai.newBase = 0; -- //fprintf(stderr, "base=0x%llX, size=0x%llX\n", ai.orgBase, ai.vmSize); -+ //fprintf(stderr, "base=0x%lX, size=0x%lX\n", ai.orgBase, ai.vmSize); - info.archs.push_back(ai); - } - } -@@ -903,7 +903,7 @@ - if ( (*rit)->getArchitecture() == fait->arch ) { - (*rit)->setBaseAddress(fait->newBase); - if ( verbose ) -- printf("%8s 0x%0llX -> 0x%0llX %s\n", nameForArch(fait->arch), fait->orgBase, fait->newBase, info.path); -+ printf("%8s 0x%0lX -> 0x%0lX %s\n", nameForArch(fait->arch), fait->orgBase, fait->newBase, info.path); - } - } - } -diff -ur cctools-port-c1cc758/cctools/ld64/src/other/unwinddump.cpp cctools-port-format/cctools/ld64/src/other/unwinddump.cpp ---- cctools-port-c1cc758/cctools/ld64/src/other/unwinddump.cpp 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-format/cctools/ld64/src/other/unwinddump.cpp 2017-11-10 19:13:05.924926282 -0800 -@@ -250,7 +250,7 @@ - value |= 1; - if ( value == addr ) { - const char* r = &fStrings[fSymbols[i].n_strx()]; -- //fprintf(stderr, "addr=0x%08llX, i=%u, n_type=0x%0X, r=%s\n", (long long)(fSymbols[i].n_value()), i, fSymbols[i].n_type(), r); -+ //fprintf(stderr, "addr=0x%08lX, i=%u, n_type=0x%0X, r=%s\n", (long long)(fSymbols[i].n_value()), i, fSymbols[i].n_type(), r); - return r; - } - else if ( offset != NULL ) { -@@ -904,14 +904,14 @@ - template - void UnwindPrinter::printObjectUnwindSection(bool showFunctionNames) - { -- printf("Arch: %s, Section: __LD,__compact_unwind (size=0x%08llX, => %lld entries)\n", -+ printf("Arch: %s, Section: __LD,__compact_unwind (size=0x%08lX, => %ld entries)\n", - archName(), fUnwindSection->size(), fUnwindSection->size() / sizeof(macho_compact_unwind_entry

)); - - const macho_compact_unwind_entry

* const entriesStart = (macho_compact_unwind_entry

*)((uint8_t*)fHeader + fUnwindSection->offset()); - const macho_compact_unwind_entry

* const entriesEnd = (macho_compact_unwind_entry

*)((uint8_t*)fHeader + fUnwindSection->offset() + fUnwindSection->size()); - for (const macho_compact_unwind_entry

* entry=entriesStart; entry < entriesEnd; ++entry) { - uint64_t entryAddress = ((char*)entry - (char*)entriesStart) + fUnwindSection->addr(); -- printf("0x%08llX:\n", entryAddress); -+ printf("0x%08lX:\n", entryAddress); - const char* functionNameStr; - pint_t funcAddress; - uint32_t offsetInFunction; -@@ -923,11 +923,11 @@ - funcAddress = entry->codeStart(); - } - if ( offsetInFunction == 0 ) -- printf(" start: 0x%08llX %s\n", (uint64_t)funcAddress, functionNameStr); -+ printf(" start: 0x%08lX %s\n", (uint64_t)funcAddress, functionNameStr); - else -- printf(" start: 0x%08llX %s+0x%X\n", (uint64_t)funcAddress+offsetInFunction, functionNameStr, offsetInFunction); -+ printf(" start: 0x%08lX %s+0x%X\n", (uint64_t)funcAddress+offsetInFunction, functionNameStr, offsetInFunction); - -- printf(" end: 0x%08llX (len=0x%08X)\n", (uint64_t)(funcAddress+offsetInFunction+entry->codeLen()), entry->codeLen()); -+ printf(" end: 0x%08lX (len=0x%08X)\n", (uint64_t)(funcAddress+offsetInFunction+entry->codeLen()), entry->codeLen()); - - char encodingString[200]; - this->decode(entry->compactUnwindInfo(), ((const uint8_t*)fHeader), encodingString); -@@ -947,9 +947,9 @@ - uint32_t lsdaOffset; - const char* lsdaName = this->functionName(entry->lsda(), &lsdaOffset); - if ( lsdaOffset == 0 ) -- printf(" lsda: 0x%08llX %s\n", (uint64_t)entry->lsda(), lsdaName); -+ printf(" lsda: 0x%08lX %s\n", (uint64_t)entry->lsda(), lsdaName); - else -- printf(" lsda: 0x%08llX %s+0x%X\n", (uint64_t)entry->lsda(), lsdaName, lsdaOffset); -+ printf(" lsda: 0x%08lX %s+0x%X\n", (uint64_t)entry->lsda(), lsdaName, lsdaOffset); - } - } - } -@@ -962,7 +962,7 @@ - const uint8_t* sectionContent = (uint8_t*)fHeader + fUnwindSection->offset(); - macho_unwind_info_section_header

* sectionHeader = (macho_unwind_info_section_header

*)(sectionContent); - -- printf("Arch: %s, Section: __TEXT,__unwind_info (addr=0x%08llX, size=0x%08llX, fileOffset=0x%08X)\n", -+ printf("Arch: %s, Section: __TEXT,__unwind_info (addr=0x%08lX, size=0x%08lX, fileOffset=0x%08X)\n", - archName(), fUnwindSection->addr(), fUnwindSection->size(), fUnwindSection->offset()); - printf("\tversion=0x%08X\n", sectionHeader->version()); - printf("\tcommonEncodingsArraySectionOffset=0x%08X\n", sectionHeader->commonEncodingsArraySectionOffset()); -diff -ur cctools-port-c1cc758/cctools/libstuff/ofile.c cctools-port-format/cctools/libstuff/ofile.c ---- cctools-port-c1cc758/cctools/libstuff/ofile.c 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-format/cctools/libstuff/ofile.c 2017-11-10 19:38:34.511211634 -0800 -@@ -3108,7 +3108,7 @@ - } - if(offset % - (1 << align) != 0){ -- error("fat file: %s offset: %llu for cputype (%d) cpusubtype " -+ error("fat file: %s offset: %lu for cputype (%d) cpusubtype " - "(%d)) not aligned on it's alignment (2^%u)", - ofile->file_name, offset, cputype, - cpusubtype & ~CPU_SUBTYPE_MASK, align); -@@ -3210,7 +3210,7 @@ - return(CHECK_BAD); - } - if(offset % (1 << align) != 0){ -- archive_member_error(ofile, "fat file's offset: %llu for " -+ archive_member_error(ofile, "fat file's offset: %lu for " - "cputype (%d) cpusubtype (%d) not aligned on it's " - "alignment (2^%u)", offset, cputype, - cpusubtype & ~CPU_SUBTYPE_MASK, align); -diff -ur cctools-port-c1cc758/cctools/libstuff/writeout.c cctools-port-format/cctools/libstuff/writeout.c ---- cctools-port-c1cc758/cctools/libstuff/writeout.c 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-format/cctools/libstuff/writeout.c 2017-11-10 19:40:56.792695079 -0800 -@@ -421,7 +421,7 @@ - if((r = vm_allocate(mach_task_self(), (vm_address_t *)&file, - file_size, TRUE)) != KERN_SUCCESS) - mach_fatal(r, "can't vm_allocate() buffer for output file: %s of " -- "size %llu", filename, file_size); -+ "size %lu", filename, file_size); - - /* - * If there is more than one architecture then fill in the fat file -@@ -460,7 +460,7 @@ - if(offset > UINT32_MAX && archs[i].fat_arch64 == NULL){ - error("file too large to create as a fat file because " - "offset field in struct fat_arch is only 32-bits and " -- "offset (%llu) to architecture %s exceeds that", -+ "offset (%lu) to architecture %s exceeds that", - offset, archs[i].fat_arch_name); - return; - } -diff -ur cctools-port-c1cc758/cctools/misc/libtool.c cctools-port-format/cctools/misc/libtool.c ---- cctools-port-c1cc758/cctools/misc/libtool.c 2017-11-10 19:22:01.790476705 -0800 -+++ cctools-port-format/cctools/misc/libtool.c 2017-11-10 19:24:48.435607249 -0800 -@@ -2545,7 +2545,7 @@ - if((r = vm_allocate(mach_task_self(), (vm_address_t *)&library, - library_size, TRUE)) != KERN_SUCCESS) - mach_fatal(r, "can't vm_allocate() buffer for output file: %s " -- "of size %llu", output, library_size); -+ "of size %lu", output, library_size); - - - /* put in the archive magic string in the buffer */ -@@ -2581,7 +2581,7 @@ - if((r = vm_allocate(mach_task_self(), (vm_address_t *)&library, - library_size, TRUE)) != KERN_SUCCESS) - mach_fatal(r, "can't vm_allocate() buffer for output file: %s of " -- "size %llu", output, library_size); -+ "size %lu", output, library_size); - - /* - * Create the output file. The unlink() is done to handle the problem -@@ -2635,7 +2635,7 @@ - if(cmd_flags.fat64 == FALSE && offset > UINT32_MAX) - error("file too large to create as a fat file because " - "offset field in struct fat_arch is only 32-bits and " -- "offset (%llu) to architecture %s exceeds that", -+ "offset (%lu) to architecture %s exceeds that", - offset, archs[i].arch_flag.name); - if(archs[i].arch_flag.cputype & CPU_ARCH_ABI64){ - if(cmd_flags.fat64 == TRUE) -@@ -2660,7 +2660,7 @@ - if(cmd_flags.fat64 == FALSE && archs[i].size > UINT32_MAX) - error("file too large to create as a fat file because " - "size field in struct fat_arch is only 32-bits and " -- "size (%llu) of architecture %s exceeds that", -+ "size (%lu) of architecture %s exceeds that", - archs[i].size, archs[i].arch_flag.name); - if(cmd_flags.fat64 == TRUE) - fat_arch64[i].size = archs[i].size; -@@ -3043,15 +3043,15 @@ - return; - - if(offset + size > library_size) -- fatal("internal error: output_flush(offset = %llu, size = %llu) " -- "out of range for library_size = %llu", offset, size, -+ fatal("internal error: output_flush(offset = %lu, size = %lu) " -+ "out of range for library_size = %lu", offset, size, - library_size); - - #ifdef DEBUG - if(cmd_flags.debug & (1 << 2)) - print_block_list(); - if(cmd_flags.debug & (1 << 1)) -- printf("output_flush(offset = %llu, size %llu)", offset, size); -+ printf("output_flush(offset = %lu, size %lu)", offset, size); - #endif /* DEBUG */ - - if(size == 0){ -@@ -3087,9 +3087,9 @@ - */ - if(before != NULL){ - if(before->offset + before->size > offset){ -- warning("internal error: output_flush(offset = %llu, size = " -- "%llu) overlaps with flushed block(offset = %llu, " -- "size = %llu)", offset, size, before->offset, -+ warning("internal error: output_flush(offset = %lu, size = " -+ "%lu) overlaps with flushed block(offset = %lu, " -+ "size = %lu)", offset, size, before->offset, - before->size); - printf("calling abort()\n"); - abort(); -@@ -3097,9 +3097,9 @@ - } - if(after != NULL){ - if(offset + size > after->offset){ -- warning("internal error: output_flush(offset = %llu, size = " -- "%llu) overlaps with flushed block(offset = %llu, " -- "size = %llu)", offset, size, after->offset, -+ warning("internal error: output_flush(offset = %lu, size = " -+ "%lu) overlaps with flushed block(offset = %lu, " -+ "size = %lu)", offset, size, after->offset, - after->size); - printf("calling abort()\n"); - abort(); diff --git a/nix/nixcrpkgs/macos/cctools-ld64-registers.patch b/nix/nixcrpkgs/macos/cctools-ld64-registers.patch deleted file mode 100644 index 70963e253c..0000000000 --- a/nix/nixcrpkgs/macos/cctools-ld64-registers.patch +++ /dev/null @@ -1,299 +0,0 @@ -diff -ur cctools-port-c1cc758/cctools/ld64/src/ld/parsers/libunwind/Registers.hpp cctools-port-patched/cctools/ld64/src/ld/parsers/libunwind/Registers.hpp ---- cctools-port-c1cc758/cctools/ld64/src/ld/parsers/libunwind/Registers.hpp 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-patched/cctools/ld64/src/ld/parsers/libunwind/Registers.hpp 2017-10-29 10:12:23.150301208 -0700 -@@ -72,22 +72,22 @@ - const char* getRegisterName(int num); - void jumpto(); - -- uint32_t getSP() const { return fRegisters.__esp; } -- void setSP(uint32_t value) { fRegisters.__esp = value; } -- uint32_t getIP() const { return fRegisters.__eip; } -- void setIP(uint32_t value) { fRegisters.__eip = value; } -- uint32_t getEBP() const { return fRegisters.__ebp; } -- void setEBP(uint32_t value) { fRegisters.__ebp = value; } -- uint32_t getEBX() const { return fRegisters.__ebx; } -- void setEBX(uint32_t value) { fRegisters.__ebx = value; } -- uint32_t getECX() const { return fRegisters.__ecx; } -- void setECX(uint32_t value) { fRegisters.__ecx = value; } -- uint32_t getEDX() const { return fRegisters.__edx; } -- void setEDX(uint32_t value) { fRegisters.__edx = value; } -- uint32_t getESI() const { return fRegisters.__esi; } -- void setESI(uint32_t value) { fRegisters.__esi = value; } -- uint32_t getEDI() const { return fRegisters.__edi; } -- void setEDI(uint32_t value) { fRegisters.__edi = value; } -+ uint32_t getSP() const { return fRegisters.esp; } -+ void setSP(uint32_t value) { fRegisters.esp = value; } -+ uint32_t getIP() const { return fRegisters.eip; } -+ void setIP(uint32_t value) { fRegisters.eip = value; } -+ uint32_t getEBP() const { return fRegisters.ebp; } -+ void setEBP(uint32_t value) { fRegisters.ebp = value; } -+ uint32_t getEBX() const { return fRegisters.ebx; } -+ void setEBX(uint32_t value) { fRegisters.ebx = value; } -+ uint32_t getECX() const { return fRegisters.ecx; } -+ void setECX(uint32_t value) { fRegisters.ecx = value; } -+ uint32_t getEDX() const { return fRegisters.edx; } -+ void setEDX(uint32_t value) { fRegisters.edx = value; } -+ uint32_t getESI() const { return fRegisters.esi; } -+ void setESI(uint32_t value) { fRegisters.esi = value; } -+ uint32_t getEDI() const { return fRegisters.edi; } -+ void setEDI(uint32_t value) { fRegisters.edi = value; } - - private: - i386_thread_state_t fRegisters; -@@ -122,25 +122,25 @@ - { - switch ( regNum ) { - case UNW_REG_IP: -- return fRegisters.__eip; -+ return fRegisters.eip; - case UNW_REG_SP: -- return fRegisters.__esp; -+ return fRegisters.esp; - case UNW_X86_EAX: -- return fRegisters.__eax; -+ return fRegisters.eax; - case UNW_X86_ECX: -- return fRegisters.__ecx; -+ return fRegisters.ecx; - case UNW_X86_EDX: -- return fRegisters.__edx; -+ return fRegisters.edx; - case UNW_X86_EBX: -- return fRegisters.__ebx; -+ return fRegisters.ebx; - case UNW_X86_EBP: -- return fRegisters.__ebp; -+ return fRegisters.ebp; - case UNW_X86_ESP: -- return fRegisters.__esp; -+ return fRegisters.esp; - case UNW_X86_ESI: -- return fRegisters.__esi; -+ return fRegisters.esi; - case UNW_X86_EDI: -- return fRegisters.__edi; -+ return fRegisters.edi; - } - ABORT("unsupported x86 register"); - } -@@ -149,34 +149,34 @@ - { - switch ( regNum ) { - case UNW_REG_IP: -- fRegisters.__eip = value; -+ fRegisters.eip = value; - return; - case UNW_REG_SP: -- fRegisters.__esp = value; -+ fRegisters.esp = value; - return; - case UNW_X86_EAX: -- fRegisters.__eax = value; -+ fRegisters.eax = value; - return; - case UNW_X86_ECX: -- fRegisters.__ecx = value; -+ fRegisters.ecx = value; - return; - case UNW_X86_EDX: -- fRegisters.__edx = value; -+ fRegisters.edx = value; - return; - case UNW_X86_EBX: -- fRegisters.__ebx = value; -+ fRegisters.ebx = value; - return; - case UNW_X86_EBP: -- fRegisters.__ebp = value; -+ fRegisters.ebp = value; - return; - case UNW_X86_ESP: -- fRegisters.__esp = value; -+ fRegisters.esp = value; - return; - case UNW_X86_ESI: -- fRegisters.__esi = value; -+ fRegisters.esi = value; - return; - case UNW_X86_EDI: -- fRegisters.__edi = value; -+ fRegisters.edi = value; - return; - } - ABORT("unsupported x86 register"); -@@ -253,22 +253,22 @@ - void setVectorRegister(int num, v128 value); - const char* getRegisterName(int num); - void jumpto(); -- uint64_t getSP() const { return fRegisters.__rsp; } -- void setSP(uint64_t value) { fRegisters.__rsp = value; } -- uint64_t getIP() const { return fRegisters.__rip; } -- void setIP(uint64_t value) { fRegisters.__rip = value; } -- uint64_t getRBP() const { return fRegisters.__rbp; } -- void setRBP(uint64_t value) { fRegisters.__rbp = value; } -- uint64_t getRBX() const { return fRegisters.__rbx; } -- void setRBX(uint64_t value) { fRegisters.__rbx = value; } -- uint64_t getR12() const { return fRegisters.__r12; } -- void setR12(uint64_t value) { fRegisters.__r12 = value; } -- uint64_t getR13() const { return fRegisters.__r13; } -- void setR13(uint64_t value) { fRegisters.__r13 = value; } -- uint64_t getR14() const { return fRegisters.__r14; } -- void setR14(uint64_t value) { fRegisters.__r14 = value; } -- uint64_t getR15() const { return fRegisters.__r15; } -- void setR15(uint64_t value) { fRegisters.__r15 = value; } -+ uint64_t getSP() const { return fRegisters.rsp; } -+ void setSP(uint64_t value) { fRegisters.rsp = value; } -+ uint64_t getIP() const { return fRegisters.rip; } -+ void setIP(uint64_t value) { fRegisters.rip = value; } -+ uint64_t getRBP() const { return fRegisters.rbp; } -+ void setRBP(uint64_t value) { fRegisters.rbp = value; } -+ uint64_t getRBX() const { return fRegisters.rbx; } -+ void setRBX(uint64_t value) { fRegisters.rbx = value; } -+ uint64_t getR12() const { return fRegisters.r12; } -+ void setR12(uint64_t value) { fRegisters.r12 = value; } -+ uint64_t getR13() const { return fRegisters.r13; } -+ void setR13(uint64_t value) { fRegisters.r13 = value; } -+ uint64_t getR14() const { return fRegisters.r14; } -+ void setR14(uint64_t value) { fRegisters.r14 = value; } -+ uint64_t getR15() const { return fRegisters.r15; } -+ void setR15(uint64_t value) { fRegisters.r15 = value; } - private: - x86_thread_state64_t fRegisters; - }; -@@ -302,41 +302,41 @@ - { - switch ( regNum ) { - case UNW_REG_IP: -- return fRegisters.__rip; -+ return fRegisters.rip; - case UNW_REG_SP: -- return fRegisters.__rsp; -+ return fRegisters.rsp; - case UNW_X86_64_RAX: -- return fRegisters.__rax; -+ return fRegisters.rax; - case UNW_X86_64_RDX: -- return fRegisters.__rdx; -+ return fRegisters.rdx; - case UNW_X86_64_RCX: -- return fRegisters.__rcx; -+ return fRegisters.rcx; - case UNW_X86_64_RBX: -- return fRegisters.__rbx; -+ return fRegisters.rbx; - case UNW_X86_64_RSI: -- return fRegisters.__rsi; -+ return fRegisters.rsi; - case UNW_X86_64_RDI: -- return fRegisters.__rdi; -+ return fRegisters.rdi; - case UNW_X86_64_RBP: -- return fRegisters.__rbp; -+ return fRegisters.rbp; - case UNW_X86_64_RSP: -- return fRegisters.__rsp; -+ return fRegisters.rsp; - case UNW_X86_64_R8: -- return fRegisters.__r8; -+ return fRegisters.r8; - case UNW_X86_64_R9: -- return fRegisters.__r9; -+ return fRegisters.r9; - case UNW_X86_64_R10: -- return fRegisters.__r10; -+ return fRegisters.r10; - case UNW_X86_64_R11: -- return fRegisters.__r11; -+ return fRegisters.r11; - case UNW_X86_64_R12: -- return fRegisters.__r12; -+ return fRegisters.r12; - case UNW_X86_64_R13: -- return fRegisters.__r13; -+ return fRegisters.r13; - case UNW_X86_64_R14: -- return fRegisters.__r14; -+ return fRegisters.r14; - case UNW_X86_64_R15: -- return fRegisters.__r15; -+ return fRegisters.r15; - } - ABORT("unsupported x86_64 register"); - } -@@ -345,58 +345,58 @@ - { - switch ( regNum ) { - case UNW_REG_IP: -- fRegisters.__rip = value; -+ fRegisters.rip = value; - return; - case UNW_REG_SP: -- fRegisters.__rsp = value; -+ fRegisters.rsp = value; - return; - case UNW_X86_64_RAX: -- fRegisters.__rax = value; -+ fRegisters.rax = value; - return; - case UNW_X86_64_RDX: -- fRegisters.__rdx = value; -+ fRegisters.rdx = value; - return; - case UNW_X86_64_RCX: -- fRegisters.__rcx = value; -+ fRegisters.rcx = value; - return; - case UNW_X86_64_RBX: -- fRegisters.__rbx = value; -+ fRegisters.rbx = value; - return; - case UNW_X86_64_RSI: -- fRegisters.__rsi = value; -+ fRegisters.rsi = value; - return; - case UNW_X86_64_RDI: -- fRegisters.__rdi = value; -+ fRegisters.rdi = value; - return; - case UNW_X86_64_RBP: -- fRegisters.__rbp = value; -+ fRegisters.rbp = value; - return; - case UNW_X86_64_RSP: -- fRegisters.__rsp = value; -+ fRegisters.rsp = value; - return; - case UNW_X86_64_R8: -- fRegisters.__r8 = value; -+ fRegisters.r8 = value; - return; - case UNW_X86_64_R9: -- fRegisters.__r9 = value; -+ fRegisters.r9 = value; - return; - case UNW_X86_64_R10: -- fRegisters.__r10 = value; -+ fRegisters.r10 = value; - return; - case UNW_X86_64_R11: -- fRegisters.__r11 = value; -+ fRegisters.r11 = value; - return; - case UNW_X86_64_R12: -- fRegisters.__r12 = value; -+ fRegisters.r12 = value; - return; - case UNW_X86_64_R13: -- fRegisters.__r13 = value; -+ fRegisters.r13 = value; - return; - case UNW_X86_64_R14: -- fRegisters.__r14 = value; -+ fRegisters.r14 = value; - return; - case UNW_X86_64_R15: -- fRegisters.__r15 = value; -+ fRegisters.r15 = value; - return; - } - ABORT("unsupported x86_64 register"); diff --git a/nix/nixcrpkgs/macos/cctools-libstuff-no-error.patch b/nix/nixcrpkgs/macos/cctools-libstuff-no-error.patch deleted file mode 100644 index 6be415388f..0000000000 --- a/nix/nixcrpkgs/macos/cctools-libstuff-no-error.patch +++ /dev/null @@ -1,93 +0,0 @@ -diff -ur cctools-port-c1cc758/cctools/include/stuff/errors.h cctools-port-libstuff-no-error/cctools/include/stuff/errors.h ---- cctools-port-c1cc758/cctools/include/stuff/errors.h 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-libstuff-no-error/cctools/include/stuff/errors.h 2017-11-10 21:52:54.172522281 -0800 -@@ -40,7 +40,7 @@ - __attribute__ ((format (printf, 1, 2))) - #endif - __attribute__((visibility("hidden"))); --extern void error( -+extern void errorf( - const char *format, ...) - #ifdef __GNUC__ - __attribute__ ((format (printf, 1, 2))) -diff -ur cctools-port-c1cc758/cctools/libstuff/errors.c cctools-port-libstuff-no-error/cctools/libstuff/errors.c ---- cctools-port-c1cc758/cctools/libstuff/errors.c 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-libstuff-no-error/cctools/libstuff/errors.c 2017-11-10 21:52:42.795730237 -0800 -@@ -57,7 +57,7 @@ - */ - __private_extern__ - void --error( -+errorf( - const char *format, - ...) - { -diff -ur cctools-port-c1cc758/cctools/libstuff/ofile.c cctools-port-libstuff-no-error/cctools/libstuff/ofile.c ---- cctools-port-c1cc758/cctools/libstuff/ofile.c 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-libstuff-no-error/cctools/libstuff/ofile.c 2017-11-10 21:54:20.156803208 -0800 -@@ -115,6 +115,8 @@ - }; - #endif /* !defined(OTOOL) */ - -+#define error errorf -+ - static enum bool ofile_specific_arch( - struct ofile *ofile, - uint32_t narch); -diff -ur cctools-port-c1cc758/cctools/libstuff/swap_headers.c cctools-port-libstuff-no-error/cctools/libstuff/swap_headers.c ---- cctools-port-c1cc758/cctools/libstuff/swap_headers.c 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-libstuff-no-error/cctools/libstuff/swap_headers.c 2017-11-10 21:54:49.873797374 -0800 -@@ -50,6 +50,8 @@ - #include "stuff/bytesex.h" - #include "stuff/errors.h" - -+#define error errorf -+ - /* - * swap_object_headers() swaps the object file headers from the host byte sex - * into the non-host byte sex. It returns TRUE if it can and did swap the -diff -ur cctools-port-c1cc758/cctools/libstuff/SymLoc.c cctools-port-libstuff-no-error/cctools/libstuff/SymLoc.c ---- cctools-port-c1cc758/cctools/libstuff/SymLoc.c 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-libstuff-no-error/cctools/libstuff/SymLoc.c 2017-11-10 21:53:06.199321490 -0800 -@@ -118,7 +118,7 @@ - if(fclose(file) != 0) - system_error("fclose() failed"); - if (!*viewPath) { -- error("symLocForDylib(): Can't locate view path for release %s", -+ errorf("symLocForDylib(): Can't locate view path for release %s", - releaseName); - return NULL; - } -@@ -252,7 +252,7 @@ - // process return value - if (!c) { - if(no_error_if_missing == FALSE) -- error("Can't find project that builds %s", installName); -+ errorf("Can't find project that builds %s", installName); - return NULL; - } else { - *found_project = TRUE; -diff -ur cctools-port-c1cc758/cctools/libstuff/version_number.c cctools-port-libstuff-no-error/cctools/libstuff/version_number.c ---- cctools-port-c1cc758/cctools/libstuff/version_number.c 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-libstuff-no-error/cctools/libstuff/version_number.c 2017-11-10 21:55:18.674114769 -0800 -@@ -27,6 +27,8 @@ - #include "stuff/allocate.h" - #include "stuff/errors.h" - -+#define error errorf -+ - /* - * get_version_number() converts an ascii version number string of the form: - * X[.Y[.Z]] -diff -ur cctools-port-c1cc758/cctools/libstuff/writeout.c cctools-port-libstuff-no-error/cctools/libstuff/writeout.c ---- cctools-port-c1cc758/cctools/libstuff/writeout.c 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-libstuff-no-error/cctools/libstuff/writeout.c 2017-11-10 21:55:43.537722114 -0800 -@@ -37,6 +37,8 @@ - #include "stuff/lto.h" - #endif /* LTO_SUPPORT */ - -+#define error errorf -+ - static void copy_new_symbol_info( - char *p, - uint32_t *size, diff --git a/nix/nixcrpkgs/macos/cctools-private-extern.patch b/nix/nixcrpkgs/macos/cctools-private-extern.patch deleted file mode 100644 index ce0f099fdf..0000000000 --- a/nix/nixcrpkgs/macos/cctools-private-extern.patch +++ /dev/null @@ -1,271 +0,0 @@ -diff -ur cctools-port-c1cc758/cctools/include/foreign/extern.h cctools-port-private-extern/cctools/include/foreign/extern.h ---- cctools-port-c1cc758/cctools/include/foreign/extern.h 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-private-extern/cctools/include/foreign/extern.h 2017-11-10 18:32:37.035890924 -0800 -@@ -1 +1,2 @@ -+#pragma once - #define __private_extern__ __attribute__((visibility("hidden"))) -diff -ur cctools-port-c1cc758/cctools/include/mach-o/dyld.h cctools-port-private-extern/cctools/include/mach-o/dyld.h ---- cctools-port-c1cc758/cctools/include/mach-o/dyld.h 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-private-extern/cctools/include/mach-o/dyld.h 2017-11-10 18:32:37.035890924 -0800 -@@ -27,9 +27,7 @@ - extern "C" { - #endif /* __cplusplus */ - --#if defined(__MWERKS__) && !defined(__private_extern__) --#define __private_extern__ __declspec(private_extern) --#endif -+#include - - #include - #include -diff -ur cctools-port-c1cc758/cctools/include/stuff/allocate.h cctools-port-private-extern/cctools/include/stuff/allocate.h ---- cctools-port-c1cc758/cctools/include/stuff/allocate.h 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-private-extern/cctools/include/stuff/allocate.h 2017-11-10 18:33:52.006780029 -0800 -@@ -20,9 +20,8 @@ - * - * @APPLE_LICENSE_HEADER_END@ - */ --#if defined(__MWERKS__) && !defined(__private_extern__) --#define __private_extern__ __declspec(private_extern) --#endif -+ -+#include - - /* defined in allocate.c */ - -diff -ur cctools-port-c1cc758/cctools/include/stuff/arch.h cctools-port-private-extern/cctools/include/stuff/arch.h ---- cctools-port-c1cc758/cctools/include/stuff/arch.h 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-private-extern/cctools/include/stuff/arch.h 2017-11-10 18:34:36.487305108 -0800 -@@ -23,9 +23,8 @@ - #ifndef _STUFF_ARCH_H_ - #define _STUFF_ARCH_H_ - --#if defined(__MWERKS__) && !defined(__private_extern__) --#define __private_extern__ __declspec(private_extern) --#endif -+#include -+ - /* - * This file contains the current known set of flags and constants for the - * known architectures. -diff -ur cctools-port-c1cc758/cctools/include/stuff/best_arch.h cctools-port-private-extern/cctools/include/stuff/best_arch.h ---- cctools-port-c1cc758/cctools/include/stuff/best_arch.h 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-private-extern/cctools/include/stuff/best_arch.h 2017-11-10 18:34:48.764116432 -0800 -@@ -20,9 +20,8 @@ - * - * @APPLE_LICENSE_HEADER_END@ - */ --#if defined(__MWERKS__) && !defined(__private_extern__) --#define __private_extern__ __declspec(private_extern) --#endif -+ -+#include - - #include - #include -diff -ur cctools-port-c1cc758/cctools/include/stuff/breakout.h cctools-port-private-extern/cctools/include/stuff/breakout.h ---- cctools-port-c1cc758/cctools/include/stuff/breakout.h 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-private-extern/cctools/include/stuff/breakout.h 2017-11-10 18:35:04.334299743 -0800 -@@ -20,9 +20,8 @@ - * - * @APPLE_LICENSE_HEADER_END@ - */ --#if defined(__MWERKS__) && !defined(__private_extern__) --#define __private_extern__ __declspec(private_extern) --#endif -+ -+#include - - #import "stuff/ofile.h" - -diff -ur cctools-port-c1cc758/cctools/include/stuff/bytesex.h cctools-port-private-extern/cctools/include/stuff/bytesex.h ---- cctools-port-c1cc758/cctools/include/stuff/bytesex.h 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-private-extern/cctools/include/stuff/bytesex.h 2017-11-10 18:35:12.637730768 -0800 -@@ -29,9 +29,7 @@ - #ifndef _STUFF_BYTESEX_H_ - #define _STUFF_BYTESEX_H_ - --#if defined(__MWERKS__) && !defined(__private_extern__) --#define __private_extern__ __declspec(private_extern) --#endif -+#include - - #include - #include -diff -ur cctools-port-c1cc758/cctools/include/stuff/execute.h cctools-port-private-extern/cctools/include/stuff/execute.h ---- cctools-port-c1cc758/cctools/include/stuff/execute.h 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-private-extern/cctools/include/stuff/execute.h 2017-11-10 18:35:34.417986815 -0800 -@@ -20,9 +20,8 @@ - * - * @APPLE_LICENSE_HEADER_END@ - */ --#if defined(__MWERKS__) && !defined(__private_extern__) --#define __private_extern__ __declspec(private_extern) --#endif -+ -+#include - - /* - * execute() does an execvp using the argv passed to it. If the parameter -diff -ur cctools-port-c1cc758/cctools/include/stuff/guess_short_name.h cctools-port-private-extern/cctools/include/stuff/guess_short_name.h ---- cctools-port-c1cc758/cctools/include/stuff/guess_short_name.h 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-private-extern/cctools/include/stuff/guess_short_name.h 2017-11-10 18:40:11.801171715 -0800 -@@ -22,6 +22,8 @@ - */ - #include "stuff/bool.h" - -+#include -+ - __private_extern__ char * guess_short_name( - char *name, - enum bool *is_framework, -diff -ur cctools-port-c1cc758/cctools/include/stuff/hash_string.h cctools-port-private-extern/cctools/include/stuff/hash_string.h ---- cctools-port-c1cc758/cctools/include/stuff/hash_string.h 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-private-extern/cctools/include/stuff/hash_string.h 2017-11-10 18:35:43.698095826 -0800 -@@ -20,9 +20,8 @@ - * - * @APPLE_LICENSE_HEADER_END@ - */ --#if defined(__MWERKS__) && !defined(__private_extern__) --#define __private_extern__ __declspec(private_extern) --#endif -+ -+#include - - __private_extern__ int32_t hash_string( - char *key); -diff -ur cctools-port-c1cc758/cctools/include/stuff/hppa.h cctools-port-private-extern/cctools/include/stuff/hppa.h ---- cctools-port-c1cc758/cctools/include/stuff/hppa.h 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-private-extern/cctools/include/stuff/hppa.h 2017-11-10 18:36:01.414970472 -0800 -@@ -20,9 +20,8 @@ - * - * @APPLE_LICENSE_HEADER_END@ - */ --#if defined(__MWERKS__) && !defined(__private_extern__) --#define __private_extern__ __declspec(private_extern) --#endif -+ -+#include - - __private_extern__ void calc_hppa_HILO( - uint32_t base, -diff -ur cctools-port-c1cc758/cctools/include/stuff/lto.h cctools-port-private-extern/cctools/include/stuff/lto.h ---- cctools-port-c1cc758/cctools/include/stuff/lto.h 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-private-extern/cctools/include/stuff/lto.h 2017-11-10 18:40:27.811342692 -0800 -@@ -3,6 +3,8 @@ - - #include "stuff/arch.h" - -+#include -+ - #ifdef LTO_SUPPORT - - __private_extern__ int is_llvm_bitcode_from_memory( -diff -ur cctools-port-c1cc758/cctools/include/stuff/macosx_deployment_target.h cctools-port-private-extern/cctools/include/stuff/macosx_deployment_target.h ---- cctools-port-c1cc758/cctools/include/stuff/macosx_deployment_target.h 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-private-extern/cctools/include/stuff/macosx_deployment_target.h 2017-11-10 18:39:47.814249693 -0800 -@@ -22,6 +22,8 @@ - */ - #include - -+#include -+ - struct macosx_deployment_target { - uint32_t major; /* major version */ - uint32_t minor; /* minor version (if any or zero) */ -diff -ur cctools-port-c1cc758/cctools/include/stuff/ofile.h cctools-port-private-extern/cctools/include/stuff/ofile.h ---- cctools-port-c1cc758/cctools/include/stuff/ofile.h 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-private-extern/cctools/include/stuff/ofile.h 2017-11-10 18:36:14.268454589 -0800 -@@ -24,9 +24,7 @@ - #ifndef _STUFF_OFILE_H_ - #define _STUFF_OFILE_H_ - --#if defined(__MWERKS__) && !defined(__private_extern__) --#define __private_extern__ __declspec(private_extern) --#endif -+#include - - #import - #ifndef AR_EFMT1 -diff -ur cctools-port-c1cc758/cctools/include/stuff/print.h cctools-port-private-extern/cctools/include/stuff/print.h ---- cctools-port-c1cc758/cctools/include/stuff/print.h 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-private-extern/cctools/include/stuff/print.h 2017-11-10 18:36:24.805244801 -0800 -@@ -20,9 +20,8 @@ - * - * @APPLE_LICENSE_HEADER_END@ - */ --#if defined(__MWERKS__) && !defined(__private_extern__) --#define __private_extern__ __declspec(private_extern) --#endif -+ -+#include - - #import - -diff -ur cctools-port-c1cc758/cctools/include/stuff/reloc.h cctools-port-private-extern/cctools/include/stuff/reloc.h ---- cctools-port-c1cc758/cctools/include/stuff/reloc.h 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-private-extern/cctools/include/stuff/reloc.h 2017-11-10 18:36:31.878661041 -0800 -@@ -20,9 +20,8 @@ - * - * @APPLE_LICENSE_HEADER_END@ - */ --#if defined(__MWERKS__) && !defined(__private_extern__) --#define __private_extern__ __declspec(private_extern) --#endif -+ -+#include - - #import - #import "stuff/bool.h" -diff -ur cctools-port-c1cc758/cctools/include/stuff/rnd.h cctools-port-private-extern/cctools/include/stuff/rnd.h ---- cctools-port-c1cc758/cctools/include/stuff/rnd.h 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-private-extern/cctools/include/stuff/rnd.h 2017-11-10 18:36:39.068745293 -0800 -@@ -27,9 +27,7 @@ - */ - #include - --#if defined(__MWERKS__) && !defined(__private_extern__) --#define __private_extern__ __declspec(private_extern) --#endif -+#include - - /* - * rnd() rounds v to a multiple of r. -diff -ur cctools-port-c1cc758/cctools/include/stuff/symbol_list.h cctools-port-private-extern/cctools/include/stuff/symbol_list.h ---- cctools-port-c1cc758/cctools/include/stuff/symbol_list.h 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-private-extern/cctools/include/stuff/symbol_list.h 2017-11-10 18:37:11.605792928 -0800 -@@ -23,6 +23,8 @@ - #include - #include - -+#include -+ - /* - * Data structures to perform selective stripping of symbol table entries. - */ -diff -ur cctools-port-c1cc758/cctools/include/stuff/unix_standard_mode.h cctools-port-private-extern/cctools/include/stuff/unix_standard_mode.h ---- cctools-port-c1cc758/cctools/include/stuff/unix_standard_mode.h 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-private-extern/cctools/include/stuff/unix_standard_mode.h 2017-11-10 18:37:42.596155389 -0800 -@@ -22,5 +22,7 @@ - */ - #include "stuff/bool.h" - -+#include -+ - __private_extern__ enum bool get_unix_standard_mode( - void); -diff -ur cctools-port-c1cc758/cctools/include/stuff/vm_flush_cache.h cctools-port-private-extern/cctools/include/stuff/vm_flush_cache.h ---- cctools-port-c1cc758/cctools/include/stuff/vm_flush_cache.h 2017-10-01 13:47:04.000000000 -0700 -+++ cctools-port-private-extern/cctools/include/stuff/vm_flush_cache.h 2017-11-10 18:37:59.973025145 -0800 -@@ -20,9 +20,8 @@ - * - * @APPLE_LICENSE_HEADER_END@ - */ --#if defined(__MWERKS__) && !defined(__private_extern__) --#define __private_extern__ __declspec(private_extern) --#endif -+ -+#include - - #import - __private_extern__ kern_return_t vm_flush_cache( diff --git a/nix/nixcrpkgs/macos/clang_builder.sh b/nix/nixcrpkgs/macos/clang_builder.sh deleted file mode 100644 index 2afa96bb95..0000000000 --- a/nix/nixcrpkgs/macos/clang_builder.sh +++ /dev/null @@ -1,30 +0,0 @@ -source $setup - -tar -xf $llvm_src -mv llvm-* llvm - -tar -xf $lld_src -mv lld-* lld -mv lld llvm/tools/ - -tar -xf $src -mv cfe-* clang -cd clang -for patch in $patches; do - echo applying patch $patch - patch -p1 -i $patch -done -cd .. -mv clang llvm/projects/ - -mkdir build -cd build - -cmake ../llvm -GNinja -DDEFAULT_SYSROOT=$out -DCMAKE_INSTALL_PREFIX=$out $cmake_flags - -ninja - -ninja install - -# clang-tblgen is supposed to be an internal tool, but tapi needs it -cp bin/clang-tblgen $out/bin diff --git a/nix/nixcrpkgs/macos/clang_megapatch.patch b/nix/nixcrpkgs/macos/clang_megapatch.patch deleted file mode 100644 index b5941e2c36..0000000000 --- a/nix/nixcrpkgs/macos/clang_megapatch.patch +++ /dev/null @@ -1,37 +0,0 @@ -diff -ur cfe-5.0.0.src.orig/lib/Driver/ToolChains/Gnu.cpp cfe-5.0.0.src/lib/Driver/ToolChains/Gnu.cpp ---- cfe-5.0.0.src.orig/lib/Driver/ToolChains/Gnu.cpp 2017-09-13 07:15:52.419093088 -0700 -+++ cfe-5.0.0.src/lib/Driver/ToolChains/Gnu.cpp 2017-09-13 07:21:58.892639000 -0700 -@@ -493,10 +493,6 @@ - CmdArgs.push_back("-export-dynamic"); - - if (!Args.hasArg(options::OPT_shared)) { -- const std::string Loader = -- D.DyldPrefix + ToolChain.getDynamicLinker(Args); -- CmdArgs.push_back("-dynamic-linker"); -- CmdArgs.push_back(Args.MakeArgString(Loader)); - } - } - -diff -ur cfe-5.0.0.src.orig/lib/Driver/ToolChains/Linux.cpp cfe-5.0.0.src/lib/Driver/ToolChains/Linux.cpp ---- cfe-5.0.0.src.orig/lib/Driver/ToolChains/Linux.cpp 2017-09-13 07:15:52.419093088 -0700 -+++ cfe-5.0.0.src/lib/Driver/ToolChains/Linux.cpp 2017-09-13 07:17:58.530311694 -0700 -@@ -195,18 +195,7 @@ - llvm::Triple::ArchType Arch = Triple.getArch(); - std::string SysRoot = computeSysRoot(); - -- // Cross-compiling binutils and GCC installations (vanilla and openSUSE at -- // least) put various tools in a triple-prefixed directory off of the parent -- // of the GCC installation. We use the GCC triple here to ensure that we end -- // up with tools that support the same amount of cross compiling as the -- // detected GCC installation. For example, if we find a GCC installation -- // targeting x86_64, but it is a bi-arch GCC installation, it can also be -- // used to target i386. -- // FIXME: This seems unlikely to be Linux-specific. -- ToolChain::path_list &PPaths = getProgramPaths(); -- PPaths.push_back(Twine(GCCInstallation.getParentLibPath() + "/../" + -- GCCInstallation.getTriple().str() + "/bin") -- .str()); -+ // Removed some code here that found programs like ld in "/..//bin" - - Distro Distro(D.getVFS()); - diff --git a/nix/nixcrpkgs/macos/default.nix b/nix/nixcrpkgs/macos/default.nix deleted file mode 100644 index c82f42d5b5..0000000000 --- a/nix/nixcrpkgs/macos/default.nix +++ /dev/null @@ -1,192 +0,0 @@ -# Note: To reduce clutter here, it might be nice to move clang to -# `native`, and also make `native` provide a function for building -# binutils. So clang and binutils recipes could be shared by the -# different platforms we targets. - -{ osx_sdk, native }: -let - nixpkgs = native.nixpkgs; - - arch = "x86_64"; - - # was darwin15, changed to darwin so that lld guesses flavor=Darwin correctly - darwin_name = "darwin15"; - - macos_version_min = "10.11"; - - host = "${arch}-apple-${darwin_name}"; - - os = "macos"; - - compiler = "clang"; - - exe_suffix = ""; - - clang = native.make_derivation rec { - name = "clang"; - - version = "5.0.0"; - - src = nixpkgs.fetchurl { - url = "https://llvm.org/releases/${version}/cfe-${version}.src.tar.xz"; - sha256 = "0w09s8fn3lkn6i04nj0cisgp821r815fk5b5fjn97xrd371277q1"; - }; - - llvm_src = nixpkgs.fetchurl { - url = "https://llvm.org/releases/${version}/llvm-${version}.src.tar.xz"; - sha256 = "1nin64vz21hyng6jr19knxipvggaqlkl2l9jpd5czbc4c2pcnpg3"; - }; - - # Note: We aren't actually using lld for anything yet. - lld_src = nixpkgs.fetchurl { - url = "http://releases.llvm.org/${version}/lld-${version}.src.tar.xz"; - sha256 = "15rqsmfw0jlsri7hszbs8l0j7v1030cy9xvvdb245397llh7k6ir"; - }; - - patches = [ ./clang_megapatch.patch ]; - - builder = ./clang_builder.sh; - - native_inputs = [ nixpkgs.python2 ]; - - cmake_flags = - "-DCMAKE_BUILD_TYPE=Release " + - # "-DCMAKE_BUILD_TYPE=Debug " + - "-DLLVM_TARGETS_TO_BUILD=X86\;ARM " + - "-DLLVM_ENABLE_RTTI=ON " + # ld64 uses dynamic_cast, requiring rtti - "-DLLVM_ENABLE_ASSERTIONS=OFF"; - }; - - # Note: There is an alternative version we could use, but it - # has a copy of LLVM in it: https://github.com/tpoechtrager/apple-libtapi - tapi = native.make_derivation rec { - name = "tapi"; - version = "${version0}.${version1}.${version2}"; - version0 = "2"; - version1 = "0"; - version2 = "0"; - src = nixpkgs.fetchurl { - url = "https://github.com/DavidEGrayson/tapi/archive/f98d0c3.tar.gz"; - sha256 = "0jibz0fsyh47q8y3w6f0qspjh6fhs164rkhjg7x6k7qhlawcdy6g"; - }; - builder = ./tapi_builder.sh; - native_inputs = [ clang ]; - inherit clang; - }; - - cctools_commit = "c1cc758"; - cctools_apple_version = "274.2"; # from README.md - cctools_port_src = nixpkgs.fetchurl { - url = "https://github.com/tpoechtrager/cctools-port/archive/${cctools_commit}.tar.gz"; - sha256= "11bfcndzbdmjp2piabyqs34da617fh5fhirqvb9w87anfan15ffa"; - }; - - ld = native.make_derivation rec { - name = "cctools-ld64"; - apple_version = cctools_apple_version; - src = cctools_port_src; - patches = [ - ./cctools-format.patch - ./cctools-ld64-registers.patch - ]; - builder = ./ld_builder.sh; - native_inputs = [ tapi ]; - inherit host; - }; - - ranlib = native.make_derivation rec { - name = "cctools-ranlib"; - apple_version = cctools_apple_version; - src = ld.src; - builder = ./ranlib_builder.sh; - patches = [ - ./cctools-format.patch - ./cctools-bytesex.patch - ]; - inherit host; - }; - - ar = native.make_derivation rec { - name = "cctools-ar"; - apple_version = cctools_apple_version; - src = cctools_port_src; - builder = ./ar_builder.sh; - patches = [ - ./cctools-format.patch - ./cctools-libstuff-no-error.patch - ]; - inherit host ranlib; - }; - - strip = native.make_derivation rec { - name = "cctools-strip"; - apple_version = cctools_apple_version; - src = cctools_port_src; - builder = ./strip_builder.sh; - patches = [ - ./cctools-format.patch - ]; - inherit host; - }; - - # TODO: add instructions for building the SDK tarball, probably want a copy of - # the script from osxcross. - sdk = native.make_derivation rec { - name = "macos-sdk"; - builder = ./sdk_builder.sh; - src = osx_sdk; - }; - - toolchain = native.make_derivation rec { - name = "macos-toolchain"; - builder = ./toolchain_builder.sh; - src_file = ./wrapper.cpp; - inherit host clang ld ranlib ar strip sdk; - - CXXFLAGS = - "-std=c++11 " + - "-Wall " + - "-I. " + - "-O2 -g " + - "-DWRAPPER_OS_VERSION_MIN=\\\"${macos_version_min}\\\" " + - "-DWRAPPER_HOST=\\\"${host}\\\" " + - "-DWRAPPER_ARCH=\\\"${arch}\\\" " + - "-DWRAPPER_SDK_PATH=\\\"${sdk}\\\" " + - "-DWRAPPER_LINKER_VERSION=\\\"${ld.apple_version}\\\""; - }; - - cmake_toolchain = import ../cmake_toolchain { - cmake_system_name = "Darwin"; - inherit nixpkgs host; - }; - - crossenv = { - is_cross = true; - - # Build tools available on the PATH for every derivation. - default_native_inputs = native.default_native_inputs - ++ [ clang toolchain native.wrappers ]; - - # Target info environment variables. - inherit host arch os compiler exe_suffix macos_version_min; - - # CMake toolchain file. - inherit cmake_toolchain; - - # A wide variety of programs and build tools. - inherit nixpkgs; - - # Some native build tools made by nixcrpkgs. - inherit native; - - # License information that should be shipped with any software - # compiled by this environment. - global_license_set = { }; - - # Make it easy to build or refer to the build tools. - inherit clang tapi ld ranlib ar sdk toolchain strip; - - make_derivation = import ../make_derivation.nix crossenv; - }; -in - crossenv diff --git a/nix/nixcrpkgs/macos/gen_sdk_package.sh b/nix/nixcrpkgs/macos/gen_sdk_package.sh deleted file mode 100755 index 843171ba69..0000000000 --- a/nix/nixcrpkgs/macos/gen_sdk_package.sh +++ /dev/null @@ -1,164 +0,0 @@ -#!/usr/bin/env bash -# -# Package the OS X SDKs into a tar file to be used by `build.sh`. -# - -# This file comes from the osxcross project and is licensed under the GNU GPLv2. -# For more information, see the `COPYING` file from: -# https://github.com/tpoechtrager/osxcross/tree/1a1733a773fe26e7b6c93b16fbf9341f22fac831 - -export LC_ALL=C - -function set_xcode_dir() -{ - local tmp=$(ls $1 2>/dev/null | grep "^Xcode.*.app" | grep -v "beta" | head -n1) - - if [ -z "$tmp" ]; then - tmp=$(ls $1 2>/dev/null | grep "^Xcode.*.app" | head -n1) - fi - - if [ -n "$tmp" ]; then - XCODEDIR="$1/$tmp" - fi -} - -if [ $(uname -s) != "Darwin" ]; then - if [ -z "$XCODEDIR" ]; then - echo "This script must be run on OS X" 1>&2 - echo "... Or with XCODEDIR=... on Linux" 1>&2 - exit 1 - else - case $XCODEDIR in - /*) ;; - *) XCODEDIR="$PWD/$XCODEDIR" ;; - esac - set_xcode_dir $XCODEDIR - fi -else - set_xcode_dir $(echo /Volumes/Xcode* | tr ' ' '\n' | grep -v "beta" | head -n1) - - if [ -z "$XCODEDIR" ]; then - set_xcode_dir /Applications - - if [ -z "$XCODEDIR" ]; then - set_xcode_dir $(echo /Volumes/Xcode* | tr ' ' '\n' | head -n1) - - if [ -z "$XCODEDIR" ]; then - echo "please mount Xcode.dmg" 1>&2 - exit 1 - fi - fi - fi -fi - -if [ ! -d $XCODEDIR ]; then - echo "cannot find Xcode (XCODEDIR=$XCODEDIR)" 1>&2 - exit 1 -fi - -echo -e "found Xcode: $XCODEDIR" - -WDIR=$(pwd) - -which gnutar &>/dev/null - -if [ $? -eq 0 ]; then - TAR=gnutar -else - TAR=tar -fi - -which xz &>/dev/null - -if [ $? -eq 0 ]; then - COMPRESSOR=xz - PKGEXT="tar.xz" -else - COMPRESSOR=bzip2 - PKGEXT="tar.bz2" -fi - -set -e - -pushd $XCODEDIR &>/dev/null - -if [ -d "Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs" ]; then - pushd "Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs" &>/dev/null -else - if [ -d "../Packages" ]; then - pushd "../Packages" &>/dev/null - elif [ -d "Packages" ]; then - pushd "Packages" &>/dev/null - else - if [ $? -ne 0 ]; then - echo "Xcode (or this script) is out of date" 1>&2 - echo "trying some magic to find the SDKs anyway ..." 1>&2 - - SDKDIR=$(find . -name SDKs -type d | grep MacOSX | head -n1) - - if [ -z "$SDKDIR" ]; then - echo "cannot find SDKs!" 1>&2 - exit 1 - fi - - pushd $SDKDIR &>/dev/null - fi - fi -fi - -SDKS=$(ls | grep "^MacOSX10.*" | grep -v "Patch") - -if [ -z "$SDKS" ]; then - echo "No SDK found" 1>&2 - exit 1 -fi - -# Xcode 5 -LIBCXXDIR1="Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1" - -# Xcode 6 -LIBCXXDIR2="Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1" - -# Manual directory -MANDIR="Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man" - -for SDK in $SDKS; do - echo -n "packaging $(echo "$SDK" | sed -E "s/(.sdk|.pkg)//g") SDK " - echo "(this may take several minutes) ..." - - if [[ $SDK == *.pkg ]]; then - cp $SDK $WDIR - continue - fi - - TMP=$(mktemp -d /tmp/XXXXXXXXXXX) - cp -r $SDK $TMP &>/dev/null || true - - pushd $XCODEDIR &>/dev/null - - # libc++ headers for C++11/C++14 - if [ -d $LIBCXXDIR1 ]; then - cp -rf $LIBCXXDIR1 "$TMP/$SDK/usr/include/c++" - elif [ -d $LIBCXXDIR2 ]; then - cp -rf $LIBCXXDIR2 "$TMP/$SDK/usr/include/c++" - fi - - if [ -d $MANDIR ]; then - mkdir -p $TMP/$SDK/usr/share/man - cp -rf $MANDIR/* $TMP/$SDK/usr/share/man - fi - - popd &>/dev/null - - pushd $TMP &>/dev/null - $TAR -cf - * | $COMPRESSOR -9 -c - > "$WDIR/$SDK.$PKGEXT" - popd &>/dev/null - - rm -rf $TMP -done - -popd &>/dev/null -popd &>/dev/null - -echo "" -ls -lh | grep MacOSX diff --git a/nix/nixcrpkgs/macos/ld_builder.sh b/nix/nixcrpkgs/macos/ld_builder.sh deleted file mode 100644 index 29453d31c8..0000000000 --- a/nix/nixcrpkgs/macos/ld_builder.sh +++ /dev/null @@ -1,45 +0,0 @@ -source $setup - -tar -xf $src -mv cctools-port-* cctools-port - -cd cctools-port - -for patch in $patches; do - echo applying patch $patch - patch -p1 -i $patch -done - -# Similar to but not the same as the other _structs.h. -rm cctools/include/foreign/mach/i386/_structs.h - -cd .. - -mv cctools-port/cctools/ld64 ld64 -mv cctools-port/cctools/include include -rm -r cctools-port -rm -r ld64/src/other - -mkdir build -cd build - -CFLAGS="-Wno-deprecated -Wno-deprecated-declarations -Wno-unused-result -Werror -Wfatal-errors -O2 -g -I../ld64/src -I../ld64/src/ld -I../ld64/src/ld/parsers -I../ld64/src/abstraction -I../ld64/src/3rd -I../ld64/src/3rd/include -I../ld64/src/3rd/BlocksRuntime -I../include -I../include/foreign -DTAPI_SUPPORT -DPROGRAM_PREFIX=\\\"$host-\\\" -D__LITTLE_ENDIAN__ -D__private_extern__= $(pkg-config --cflags libtapi)" - -CXXFLAGS="-std=gnu++11 $CFLAGS" - -LDFLAGS="$(pkg-config --libs libtapi) -ldl -lpthread" - -for f in ../ld64/src/ld/*.c ../ld64/src/3rd/*.c; do - echo "compiling $f" - eval "gcc -c $CFLAGS $f -o $(basename $f).o" -done - -for f in $(find ../ld64/src -name \*.cpp); do - echo "compiling $f" - eval "g++ -c $CXXFLAGS $f -o $(basename $f).o" -done - -g++ *.o $LDFLAGS -o $host-ld - -mkdir -p $out/bin -cp $host-ld $out/bin diff --git a/nix/nixcrpkgs/macos/ranlib_builder.sh b/nix/nixcrpkgs/macos/ranlib_builder.sh deleted file mode 100644 index 15c0bd206d..0000000000 --- a/nix/nixcrpkgs/macos/ranlib_builder.sh +++ /dev/null @@ -1,45 +0,0 @@ -source $setup - -tar -xf $src -mv cctools-port-* cctools-port - -cd cctools-port - -for patch in $patches; do - echo applying patch $patch - patch -p1 -i $patch -done - -# Similar to but not the same as the other _structs.h. -rm cctools/include/foreign/mach/i386/_structs.h - -# Causes a troublesome undefined reference. -rm cctools/libstuff/vm_flush_cache.c - -cd .. - -mv cctools-port/cctools/misc . -mv cctools-port/cctools/include . -mv cctools-port/cctools/libstuff . -rm -r cctools-port - -mkdir build -cd build - -CFLAGS="-Wno-deprecated -Wno-deprecated-declarations -Wno-unused-result -Wno-format-overflow -Werror -Wfatal-errors -O2 -g -I../include -I../include/foreign -DPROGRAM_PREFIX=\\\"$host-\\\" -D__LITTLE_ENDIAN__ -D__private_extern__= -D__DARWIN_UNIX03 -DPACKAGE_NAME=\\\"cctools\\\" -DPACKAGE_VERSION=\\\"$apple_version\\\" -DEMULATED_HOST_CPU_TYPE=16777223 -DEMULATED_HOST_CPU_SUBTYPE=3" - -CXXFLAGS="-std=gnu++11 $CFLAGS" - -LDFLAGS="-ldl" - -for f in ../libstuff/*.c ; do - echo "compiling $f" - eval "gcc -c $CFLAGS $f -o $(basename $f).o" -done - -eval "gcc $CFLAGS ../misc/libtool.c *.o $LDFLAGS -o $host-libtool" -eval "gcc $CFLAGS -DRANLIB ../misc/libtool.c *.o $LDFLAGS -o $host-ranlib" - -mkdir -p $out/bin -cp $host-libtool $host-ranlib $out/bin/ - diff --git a/nix/nixcrpkgs/macos/sdk_builder.sh b/nix/nixcrpkgs/macos/sdk_builder.sh deleted file mode 100644 index 8a0f872e01..0000000000 --- a/nix/nixcrpkgs/macos/sdk_builder.sh +++ /dev/null @@ -1,4 +0,0 @@ -source $setup - -tar -xf $src -mv MacOSX*.sdk $out diff --git a/nix/nixcrpkgs/macos/strip_builder.sh b/nix/nixcrpkgs/macos/strip_builder.sh deleted file mode 100644 index e69a129493..0000000000 --- a/nix/nixcrpkgs/macos/strip_builder.sh +++ /dev/null @@ -1,43 +0,0 @@ -source $setup - -tar -xf $src -mv cctools-port-* cctools-port - -cd cctools-port - -for patch in $patches; do - echo applying patch $patch - patch -p1 -i $patch -done - -# Similar to but not the same as the other _structs.h. -rm cctools/include/foreign/mach/i386/_structs.h - -# Causes a troublesome undefined reference. -rm cctools/libstuff/vm_flush_cache.c - -cd .. - -mv cctools-port/cctools/misc . -mv cctools-port/cctools/include . -mv cctools-port/cctools/libstuff . -rm -r cctools-port - -mkdir build -cd build - -CFLAGS="-Wno-deprecated -Wno-deprecated-declarations -Wno-unused-result -Werror -Wfatal-errors -O2 -g -I../include -I../include/foreign -DPROGRAM_PREFIX=\\\"$host-\\\" -D__LITTLE_ENDIAN__ -D__private_extern__= -D__DARWIN_UNIX03 -DPACKAGE_NAME=\\\"cctools\\\" -DPACKAGE_VERSION=\\\"$apple_version\\\" -DEMULATED_HOST_CPU_TYPE=16777223 -DEMULATED_HOST_CPU_SUBTYPE=3" - -CXXFLAGS="-std=gnu++11 $CFLAGS" - -LDFLAGS="-ldl -lpthread" - -for f in ../misc/strip.c ../libstuff/*.c; do - echo "compiling $f" - eval "gcc -c $CFLAGS $f -o $(basename $f).o" -done - -gcc *.o $LDFLAGS -o $host-strip - -mkdir -p $out/bin -cp $host-strip $out/bin/ diff --git a/nix/nixcrpkgs/macos/tapi_builder.sh b/nix/nixcrpkgs/macos/tapi_builder.sh deleted file mode 100644 index d8c15a6a10..0000000000 --- a/nix/nixcrpkgs/macos/tapi_builder.sh +++ /dev/null @@ -1,80 +0,0 @@ -source $setup - -tar -xf $src -mv tapi-* tapi - -mkdir build -cd build - -mkdir -p include/tapi/{Core,Driver} -cat > include/tapi/Core/ArchitectureConfig.h < include/tapi/Version.inc < $out/lib/pkgconfig/libtapi.pc < -#include -#include -#include -#include -#include - -int do_exec(const std::string & compiler_name, - const std::vector & args) -{ - char ** exec_args = new char *[args.size() + 1]; - size_t i = 0; - for (const std::string & arg : args) - { - exec_args[i++] = (char *)arg.c_str(); - } - exec_args[i] = nullptr; - - execvp(compiler_name.c_str(), exec_args); - - int result = errno; - std::cerr << "execvp failed: " << compiler_name << ": " - << strerror(result) << std::endl; - return 1; -} - -int compiler_main(int argc, char ** argv, - const std::string & compiler_name) -{ - std::vector args; - - args.push_back(compiler_name); - - args.push_back("-target"); - args.push_back(WRAPPER_HOST); - - args.push_back("-mmacosx-version-min=" WRAPPER_OS_VERSION_MIN); - - // The ld64 linker will just assume sdk_version is the same as - // macosx-version-min if we don't supply it. That probably will not - // do any harm. - // args.push_back("-Wl,-sdk_version," WRAPPER_SDK_VERSION); - - // Suppress warnings about the -Wl arguments not being used when we're just - // compiling and not linking. - args.push_back("-Wno-unused-command-line-argument"); - - args.push_back("--sysroot"); - args.push_back(WRAPPER_SDK_PATH); - - // Causes clang to pass -demangle, -lto_library, -no_deduplicate, and other - // options that could be useful. Version 274.2 is the version number used here: - // https://github.com/tpoechtrager/osxcross/blob/474f359/build.sh#L140 - if (WRAPPER_LINKER_VERSION[0]) - { - args.push_back("-mlinker-version=" WRAPPER_LINKER_VERSION); - } - - if (compiler_name == "clang++") - { - args.push_back("-stdlib=libc++"); - args.push_back("-cxx-isystem"); - args.push_back(WRAPPER_SDK_PATH "/usr/include/c++/v1"); - } - - for (int i = 1; i < argc; ++i) - { - args.push_back(argv[i]); - } - - return do_exec(compiler_name, args); -} - -int c_compiler_main(int argc, char ** argv) -{ - return compiler_main(argc, argv, "clang"); -} - -int cxx_compiler_main(int argc, char ** argv) -{ - return compiler_main(argc, argv, "clang++"); -} - -int wrapper_main(int argc, char ** argv) -{ - std::cout << - "host: " WRAPPER_HOST "\n" - "path: " WRAPPER_PATH "\n" - "sdk_path: " WRAPPER_SDK_PATH "\n"; - return 0; -} - -struct { - const char * name; - int (*main_func)(int argc, char ** argv); -} prgms[] = { - { WRAPPER_HOST "-gcc", c_compiler_main }, - { WRAPPER_HOST "-cc", c_compiler_main }, - { WRAPPER_HOST "-clang", c_compiler_main }, - { WRAPPER_HOST "-g++", cxx_compiler_main }, - { WRAPPER_HOST "-c++", cxx_compiler_main }, - { WRAPPER_HOST "-clang++", cxx_compiler_main }, - { WRAPPER_HOST "-wrapper", wrapper_main }, - { nullptr, nullptr }, -}; - -const char * get_program_name(const char * path) -{ - const char * p = strrchr(path, '/'); - if (p) { path = p + 1; } - return path; -} - -int main(int argc, char ** argv) -{ - // We only want this wrapper and the compiler it invokes to access a certain - // set of tools that are determined at build time. Ignore whatever is on the - // user's path and use the path specified by our Nix expression instead. - int result = setenv("PATH", WRAPPER_PATH, 1); - if (result) - { - std::cerr << "wrapper failed to set PATH" << std::endl; - return 1; - } - - std::string program_name = get_program_name(argv[0]); - - for (auto * p = prgms; p->name; p++) - { - if (program_name == p->name) - { - return p->main_func(argc, argv); - } - } - - std::cerr << "compiler wrapper invoked with unknown program name: " - << argv[0] << std::endl; - return 1; -} diff --git a/nix/nixcrpkgs/make_derivation.nix b/nix/nixcrpkgs/make_derivation.nix deleted file mode 100644 index af74ee91fd..0000000000 --- a/nix/nixcrpkgs/make_derivation.nix +++ /dev/null @@ -1,91 +0,0 @@ -env: attrs: - -let - nixpkgs = env.nixpkgs; - - native_inputs = - (attrs.native_inputs or []) - ++ env.default_native_inputs; - - cross_inputs = (attrs.cross_inputs or []); - - path_join = builtins.concatStringsSep ":"; - - path_map = dir: inputs: (map (i: "${i}" + dir) inputs); - - # We can't just set PATH in our derivation because nix-shell will make the - # derivation's PATH override the system PATH, meaning we can't use utilities - # like "git" or "which" form the host system. So we set _PATH instead, and we - # use a setup script ($setup) that copies _PATH to PATH. And we provide - # $stdenv/setup so that nix-shell can find our setup script. - # - # nixcrpkgs does not expose its users to this mess. The user can specify a - # PATH if they want, and it will be automatically moved to _PATH in the - # derivation. - filtered_attrs = nixpkgs.lib.filterAttrs (n: v: n != "PATH") attrs; - - path_attrs = { - _PATH = path_join ( - (if attrs ? PATH then [attrs.PATH] else []) ++ - (path_map "/bin" native_inputs) - ); - }; - - default_attrs = { - system = builtins.currentSystem; - - SHELL = "${nixpkgs.bashInteractive}/bin/bash"; - - setup = ./pretend_stdenv/setup; - - # This allows nix-shell to find our setup script. - stdenv = ./pretend_stdenv; - - PKG_CONFIG_PATH = path_join ( - (if attrs ? PKG_CONFIG_PATH then [attrs.PKG_CONFIG_PATH] else []) ++ - (path_map "/lib/pkgconfig" native_inputs) - ); - }; - - cross_attrs = if !env.is_cross then {} else { - NIXCRPKGS = true; - - inherit (env) host arch os exe_suffix; - inherit (env) cmake_toolchain; - - PKG_CONFIG_CROSS_PATH = path_join ( - (if attrs ? PKG_CONFIG_CROSS_PATH then [attrs.PKG_CONFIG_CROSS_PATH] else []) ++ - (path_map "/lib/pkgconfig" cross_inputs) - ); - - CMAKE_CROSS_PREFIX_PATH = path_join ( - (if attrs ? CMAKE_CROSS_PREFIX_PATH then [attrs.CMAKE_CROSS_PREFIX_PATH] else []) ++ - cross_inputs - ); - }; - - name_attrs = { - name = (attrs.name or "package") - + (if env.is_cross then "-${env.host}" else ""); - }; - - builder_attrs = - if builtins.isAttrs attrs.builder then - if attrs.builder ? ruby then - { - builder = "${nixpkgs.ruby}/bin/ruby"; - args = [attrs.builder.ruby]; - } - else - attrs.builder - else - rec { - builder = "${nixpkgs.bashInteractive}/bin/bash"; - args = ["-ue" attrs.builder]; - }; - - drv_attrs = default_attrs // cross_attrs - // filtered_attrs // name_attrs // builder_attrs // path_attrs; - -in - derivation drv_attrs diff --git a/nix/nixcrpkgs/mingw-w64/binutils/builder.sh b/nix/nixcrpkgs/mingw-w64/binutils/builder.sh deleted file mode 100644 index 8795ea0ce1..0000000000 --- a/nix/nixcrpkgs/mingw-w64/binutils/builder.sh +++ /dev/null @@ -1,26 +0,0 @@ -source $stdenv/setup - -unset CC CXX CFLAGS LDFLAGS LD AR AS RANLIB SIZE STRINGS NM STRIP OBJCOPY - -tar -xf $src - -cd binutils-$version -for patch in $patches; do - echo applying patch $patch - patch -p1 -i $patch -done - -# Clear the default library search path (noSysDirs) -echo 'NATIVE_LIB_DIRS=' >> ld/configure.tgt - -cd .. - -mkdir build -cd build - -../binutils-$version/configure --prefix=$out $configure_flags - -make - -make install - diff --git a/nix/nixcrpkgs/mingw-w64/binutils/default.nix b/nix/nixcrpkgs/mingw-w64/binutils/default.nix deleted file mode 100644 index 1a52fd2260..0000000000 --- a/nix/nixcrpkgs/mingw-w64/binutils/default.nix +++ /dev/null @@ -1,26 +0,0 @@ -{ native, host }: - -native.make_derivation rec { - name = "binutils-${version}-${host}"; - - version = "2.27"; - - src = native.nixpkgs.fetchurl { - url = "mirror://gnu/binutils/binutils-${version}.tar.bz2"; - sha256 = "125clslv17xh1sab74343fg6v31msavpmaa1c1394zsqa773g5rn"; - }; - - patches = [ - ./deterministic.patch - ]; - - build_inputs = [ native.nixpkgs.bison native.nixpkgs.zlib ]; - - configure_flags = - "--target=${host} " + - "--enable-shared " + - "--enable-deterministic-archives " + - "--disable-werror "; - - builder = ./builder.sh; -} diff --git a/nix/nixcrpkgs/mingw-w64/binutils/deterministic.patch b/nix/nixcrpkgs/mingw-w64/binutils/deterministic.patch deleted file mode 100644 index 0a264b35c7..0000000000 --- a/nix/nixcrpkgs/mingw-w64/binutils/deterministic.patch +++ /dev/null @@ -1,12 +0,0 @@ -Make binutils output deterministic by default. ---- orig/ld/ldlang.c -+++ new/ld/ldlang.c -@@ -3095,6 +3095,8 @@ - ldfile_output_machine)) - einfo (_("%P%F:%s: can not set architecture: %E\n"), name); - -+ link_info.output_bfd->flags |= BFD_DETERMINISTIC_OUTPUT; -+ - link_info.hash = bfd_link_hash_table_create (link_info.output_bfd); - if (link_info.hash == NULL) - einfo (_("%P%F: can not create hash table: %E\n")); diff --git a/nix/nixcrpkgs/mingw-w64/builder.sh b/nix/nixcrpkgs/mingw-w64/builder.sh deleted file mode 100644 index 65c9e68e38..0000000000 --- a/nix/nixcrpkgs/mingw-w64/builder.sh +++ /dev/null @@ -1,35 +0,0 @@ -source $setup - -cp -r $src mingw-w64 -chmod -R u+w mingw-w64 - -cd mingw-w64 -for patch in $patches; do - echo applying patch $patch - patch -p1 -i $patch -done -cd .. - -if [ -n "$just_headers" ]; then - mkdir build_headers - cd build_headers - ../mingw-w64/mingw-w64-headers/configure --prefix=$out $configure_flags - make - make install - cd .. -else - mkdir build_crt_and_headers - cd build_crt_and_headers - ../mingw-w64/configure --prefix=$out $configure_flags - make - make install - cd .. - - mkdir build_winpthreads - cd build_winpthreads - LDFLAGS="-L${out}/lib" ../mingw-w64/mingw-w64-libraries/winpthreads/configure \ - --host=$host --prefix=$out --disable-shared --enable-static - make - make install - cd .. -fi diff --git a/nix/nixcrpkgs/mingw-w64/default.nix b/nix/nixcrpkgs/mingw-w64/default.nix deleted file mode 100644 index 691c271549..0000000000 --- a/nix/nixcrpkgs/mingw-w64/default.nix +++ /dev/null @@ -1,106 +0,0 @@ -{ native, arch }: - -let - nixpkgs = native.nixpkgs; - - host = "${arch}-w64-mingw32"; - - binutils = import ./binutils { inherit native host; }; - - mingw-w64_info = rec { - name = "mingw-w64-${version}"; - version = "2017-08-03"; - src = nixpkgs.fetchgit { - url = "git://git.code.sf.net/p/mingw-w64/mingw-w64"; - rev = "6de0055f99ed447ec63c1a650a3830f266a808bd"; - sha256 = "1830rcd0vsbvpr5m1lrabcqh12qrw1flq333b8xrs5b3n542xy2i"; - }; - patches = [ - ./usb.patch - ./guid-selectany.patch - ]; - configure_flags = "--enable-secure-api --enable-idl"; - }; - - mingw-w64_headers = native.make_derivation { - name = "${mingw-w64_info.name}-headers"; - inherit host; - inherit (mingw-w64_info) src patches configure_flags; - builder = ./builder.sh; - just_headers = true; - }; - - gcc_stage_1 = import ./gcc { - stage = 1; - libc = mingw-w64_headers; - inherit native arch binutils; - }; - - mingw-w64_full = native.make_derivation { - name = "${mingw-w64_info.name}-${host}"; - inherit host; - inherit (mingw-w64_info) version src patches; - configure_flags = - "--host=${host} " + - "--disable-shared --enable-static " + - mingw-w64_info.configure_flags; - native_inputs = [ binutils gcc_stage_1 ]; - builder = ./builder.sh; - just_headers = false; - }; - - gcc = import ./gcc { - libc = mingw-w64_full; - inherit native arch binutils; - }; - - license = native.make_derivation { - name = "${mingw-w64_info.name}-license"; - inherit (mingw-w64_info) version src; - gcc_src = gcc.src; - builder = ./license_builder.sh; - }; - - global_license_set = { _global = license; }; - - cmake_toolchain = import ../cmake_toolchain { - cmake_system_name = "Windows"; - inherit nixpkgs host; - }; - - os = "windows"; - - compiler = "gcc"; - - exe_suffix = ".exe"; - - crossenv = { - is_cross = true; - - default_native_inputs = native.default_native_inputs - ++ [ gcc binutils native.pkgconf native.wrappers ]; - - # Target info variables. - inherit host arch os compiler exe_suffix; - - # CMake toolchain file. - inherit cmake_toolchain; - - # A wide variety of programs and build tools. - inherit nixpkgs; - - # Some native build tools made by nixcrpkgs. - inherit native; - - # License information that should be shipped with any software compiled by - # this environment. - inherit global_license_set; - - # Make it easy to build or refer to the build tools. - inherit gcc binutils mingw-w64_full mingw-w64_info mingw-w64_headers gcc_stage_1; - mingw-w64 = mingw-w64_full; - - make_derivation = import ../make_derivation.nix crossenv; - }; -in - crossenv diff --git a/nix/nixcrpkgs/mingw-w64/gcc/builder.sh b/nix/nixcrpkgs/mingw-w64/gcc/builder.sh deleted file mode 100644 index ae8462f8d8..0000000000 --- a/nix/nixcrpkgs/mingw-w64/gcc/builder.sh +++ /dev/null @@ -1,63 +0,0 @@ -source $setup - -tar -xf $src - -cd gcc-$version -for patch in $patches; do - echo applying patch $patch - patch -p1 -i $patch -done - -# Prevents a name collision with mingw-w64 headers. -# See: https://gcc.gnu.org/ml/gcc-help/2017-05/msg00121.html -cd libstdc++-v3 -sed -i 's/\b__in\b/___in/g' \ - include/ext/random.tcc \ - include/ext/vstring.tcc \ - include/std/utility \ - include/std/tuple \ - include/std/istream \ - include/tr2/bool_set.tcc \ - include/tr2/bool_set \ - include/bits/basic_string.h \ - include/bits/basic_string.tcc \ - include/bits/locale_facets.h \ - include/bits/istream.tcc \ - include/tr1/utility \ - include/tr1/tuple -sed -i 's/\b__out\b/___out/g' \ - include/ext/random.tcc \ - include/ext/algorithm \ - include/ext/pb_ds/detail/debug_map_base.hpp \ - include/std/ostream \ - include/std/thread \ - include/tr2/bool_set \ - include/bits/ostream.tcc \ - include/bits/regex.tcc \ - include/bits/stl_algo.h \ - include/bits/locale_conv.h \ - include/bits/regex.h \ - include/bits/ostream_insert.h \ - include/tr1/regex \ - include/parallel/algo.h \ - include/parallel/set_operations.h \ - include/parallel/multiway_merge.h \ - include/parallel/unique_copy.h \ - include/experimental/algorithm \ - config/locale/dragonfly/c_locale.h \ - config/locale/generic/c_locale.h \ - config/locale/gnu/c_locale.h - -cd ../.. - -mkdir build -cd build - -../gcc-$version/configure --prefix=$out $configure_flags - -make $make_flags - -make $install_targets - -# Remove "install-tools" so we don't have a reference to bash. -rm -r "$out/libexec/gcc/$target/$version/install-tools/" diff --git a/nix/nixcrpkgs/mingw-w64/gcc/cppdefault.patch b/nix/nixcrpkgs/mingw-w64/gcc/cppdefault.patch deleted file mode 100644 index adc979e68b..0000000000 --- a/nix/nixcrpkgs/mingw-w64/gcc/cppdefault.patch +++ /dev/null @@ -1,35 +0,0 @@ -cppdefault.c If CROSS_DIRECTORY_STRUCTURE is defined, don't use the native -system header dir; use CROSS_INCLUDE_DIR instead if it is defined. - -This just makes GCC's behavior match the documentation for the -"--with-sysroot" configure option, which corresponds to -TARGET_SYSTEM_ROOT. The documentation says that if you specify -directories with --with-sysroot and --with-native-system-header-dir, -then the compilter will concatenate the the two together (with the -sysroot coming first) and search that directory instead of the default -/usr/include. - -The concatenation is done with this line in configure.ac: - - CROSS_SYSTEM_HEADER_DIR='$(TARGET_SYSTEM_ROOT)$${sysroot_headers_suffix}$(NATIVE_SYSTEM_HEADER_DIR)' - -Then Makefile.in sets the preprocessor macro CROSS_INCLUDE_DIR equal to -CROSS_SYSTEM_HEADER_DIR. - -This patch reverts one of the changes from Daniel Jacobowitz on 2013-02-13. -https://github.com/gcc-mirror/gcc/commit/17acc97af91fbd116659301b0b7d4965ecc1631d - ---- gcc-5.4.0/gcc/cppdefault.c -+++ gcc-5.4.0/gcc/cppdefault.c -@@ -28,9 +28,9 @@ - #define NATIVE_SYSTEM_HEADER_COMPONENT 0 - #endif - --#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT) -+#if defined (CROSS_DIRECTORY_STRUCTURE) - # undef LOCAL_INCLUDE_DIR - # undef NATIVE_SYSTEM_HEADER_DIR - #else - # undef CROSS_INCLUDE_DIR - #endif - diff --git a/nix/nixcrpkgs/mingw-w64/gcc/default.nix b/nix/nixcrpkgs/mingw-w64/gcc/default.nix deleted file mode 100644 index 8a5a46b7b7..0000000000 --- a/nix/nixcrpkgs/mingw-w64/gcc/default.nix +++ /dev/null @@ -1,103 +0,0 @@ -{ native, arch, stage ? 2, binutils, libc }: - -let - nixpkgs = native.nixpkgs; - isl = nixpkgs.isl_0_14; - inherit (nixpkgs) stdenv lib fetchurl; - inherit (nixpkgs) gettext gmp libmpc libelf mpfr texinfo which zlib; - - stageName = if stage == 1 then "-stage1" - else assert stage == 2; ""; -in - -native.make_derivation rec { - name = "gcc-${version}-${target}${stageName}"; - - target = "${arch}-w64-mingw32"; - - version = "6.3.0"; - - src = fetchurl { - url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.bz2"; - sha256 = "17xjz30jb65hcf714vn9gcxvrrji8j20xm7n33qg1ywhyzryfsph"; - }; - - builder = ./builder.sh; - - patches = [ - # TODO: combine three of these patches into one called search-dirs.patch - ./mingw-search-paths.patch - ./use-source-date-epoch.patch - ./libstdc++-target.patch - ./no-sys-dirs.patch - ./cppdefault.patch - - # Fix a compiler error in GCC's ubsan.c: ISO C++ forbids comparison - # between pointer and integer. - ./ubsan.patch - ]; - - # TODO: can probably remove libelf here, and might as well remove - # the libraries that are given to GCC as configure flags - # TODO: just let GCC use its own gettext (intl) - native_inputs = [ - binutils gettext libelf texinfo which zlib - ]; - - configure_flags = - "--target=${arch}-w64-mingw32 " + - "--with-sysroot=${libc} " + - "--with-native-system-header-dir=/include " + - "--with-gnu-as " + - "--with-gnu-ld " + - "--with-as=${binutils}/bin/${arch}-w64-mingw32-as " + - "--with-ld=${binutils}/bin/${arch}-w64-mingw32-ld " + - "--with-isl=${isl} " + - "--with-gmp-include=${gmp.dev}/include " + - "--with-gmp-lib=${gmp.out}/lib " + - "--with-mpfr-include=${mpfr.dev}/include " + - "--with-mpfr-lib=${mpfr.out}/lib " + - "--with-mpc=${libmpc} " + - "--with-zlib-include=${zlib.dev}/include " + - "--with-zlib-lib=${zlib.out}/lib " + - "--enable-lto " + - "--enable-plugin " + - "--enable-static " + - "--enable-sjlj-exceptions " + - "--enable-__cxa_atexit " + - "--enable-long-long " + - "--with-dwarf2 " + - "--enable-fully-dynamic-string " + - (if stage == 1 then - "--enable-languages=c " + - "--enable-threads=win32 " - else - "--enable-languages=c,c++ " + - "--enable-threads=posix " - ) + - "--without-included-gettext " + - "--disable-libstdcxx-pch " + - "--disable-nls " + - "--disable-shared " + - "--disable-multilib " + - "--disable-libssp " + - "--disable-win32-registry " + - "--disable-bootstrap"; # TODO: not needed, --disable-bootstrap - # only applies to native builds - - make_flags = - if stage == 1 then - ["all-gcc" "all-target-libgcc"] - else - []; - - install_targets = - if stage == 1 then - ["install-gcc install-target-libgcc"] - else - ["install-strip"]; - - hardeningDisable = [ "format" ]; -} - -# TODO: why is GCC providing a fixed limits.h? diff --git a/nix/nixcrpkgs/mingw-w64/gcc/libstdc++-target.patch b/nix/nixcrpkgs/mingw-w64/gcc/libstdc++-target.patch deleted file mode 100644 index fb622b3958..0000000000 --- a/nix/nixcrpkgs/mingw-w64/gcc/libstdc++-target.patch +++ /dev/null @@ -1,32 +0,0 @@ -Patch to make the target libraries 'configure' scripts find the proper CPP. -I noticed that building the mingw32 cross compiler. -Looking at the build script for mingw in archlinux, I think that only nixos -needs this patch. I don't know why. -diff --git a/Makefile.in b/Makefile.in -index 93f66b6..d691917 100644 ---- a/Makefile.in -+++ b/Makefile.in -@@ -266,6 +266,7 @@ BASE_TARGET_EXPORTS = \ - AR="$(AR_FOR_TARGET)"; export AR; \ - AS="$(COMPILER_AS_FOR_TARGET)"; export AS; \ - CC="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CC; \ -+ CPP="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CC; \ - CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \ - CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ - CPPFLAGS="$(CPPFLAGS_FOR_TARGET)"; export CPPFLAGS; \ -@@ -291,11 +292,13 @@ BASE_TARGET_EXPORTS = \ - RAW_CXX_TARGET_EXPORTS = \ - $(BASE_TARGET_EXPORTS) \ - CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \ -- CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; -+ CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \ -+ CXXCPP="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX; - - NORMAL_TARGET_EXPORTS = \ - $(BASE_TARGET_EXPORTS) \ -- CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; -+ CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \ -+ CXXCPP="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX; - - # Where to find GMP - HOST_GMPLIBS = @gmplibs@ diff --git a/nix/nixcrpkgs/mingw-w64/gcc/mingw-search-paths.patch b/nix/nixcrpkgs/mingw-w64/gcc/mingw-search-paths.patch deleted file mode 100644 index c79730e10d..0000000000 --- a/nix/nixcrpkgs/mingw-w64/gcc/mingw-search-paths.patch +++ /dev/null @@ -1,14 +0,0 @@ -Make it so GCC does not force us to have a "mingw" symlink. - ---- gcc-6.3.0-orig/gcc/config/i386/mingw32.h -+++ gcc-6.3.0/gcc/config/i386/mingw32.h -@@ -163,3 +163,3 @@ - #ifndef STANDARD_STARTFILE_PREFIX_1 --#define STANDARD_STARTFILE_PREFIX_1 "/mingw/lib/" -+#define STANDARD_STARTFILE_PREFIX_1 "/lib/" - #endif -@@ -172,3 +172,3 @@ - #undef NATIVE_SYSTEM_HEADER_DIR --#define NATIVE_SYSTEM_HEADER_DIR "/mingw/include" -+#define NATIVE_SYSTEM_HEADER_DIR "/include" - diff --git a/nix/nixcrpkgs/mingw-w64/gcc/no-sys-dirs.patch b/nix/nixcrpkgs/mingw-w64/gcc/no-sys-dirs.patch deleted file mode 100644 index 36df51904a..0000000000 --- a/nix/nixcrpkgs/mingw-w64/gcc/no-sys-dirs.patch +++ /dev/null @@ -1,28 +0,0 @@ -diff -ru -x '*~' gcc-4.8.3-orig/gcc/cppdefault.c gcc-4.8.3/gcc/cppdefault.c ---- gcc-4.8.3-orig/gcc/cppdefault.c 2013-01-10 21:38:27.000000000 +0100 -+++ gcc-4.8.3/gcc/cppdefault.c 2014-08-18 16:20:32.893944536 +0200 -@@ -35,6 +35,8 @@ - # undef CROSS_INCLUDE_DIR - #endif - -+#undef LOCAL_INCLUDE_DIR -+ - const struct default_include cpp_include_defaults[] - #ifdef INCLUDE_DEFAULTS - = INCLUDE_DEFAULTS; -diff -ru -x '*~' gcc-4.8.3-orig/gcc/gcc.c gcc-4.8.3/gcc/gcc.c ---- gcc-4.8.3-orig/gcc/gcc.c 2014-03-23 12:30:57.000000000 +0100 -+++ gcc-4.8.3/gcc/gcc.c 2014-08-18 13:19:32.689201690 +0200 -@@ -1162,10 +1162,10 @@ - /* Default prefixes to attach to command names. */ - - #ifndef STANDARD_STARTFILE_PREFIX_1 --#define STANDARD_STARTFILE_PREFIX_1 "/lib/" -+#define STANDARD_STARTFILE_PREFIX_1 "" - #endif - #ifndef STANDARD_STARTFILE_PREFIX_2 --#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/" -+#define STANDARD_STARTFILE_PREFIX_2 "" - #endif - - #ifdef CROSS_DIRECTORY_STRUCTURE /* Don't use these prefixes for a cross compiler. */ diff --git a/nix/nixcrpkgs/mingw-w64/gcc/ubsan.patch b/nix/nixcrpkgs/mingw-w64/gcc/ubsan.patch deleted file mode 100644 index 0ad3b79912..0000000000 --- a/nix/nixcrpkgs/mingw-w64/gcc/ubsan.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- gcc-6.3.0-orig/gcc/ubsan.c -+++ gcc-6.3.0/gcc/ubsan.c -@@ -1471,7 +1471,7 @@ - - expanded_location xloc = expand_location (loc); - if (xloc.file == NULL || strncmp (xloc.file, "\1", 2) == 0 -- || xloc.file == '\0' || xloc.file[0] == '\xff' -+ || xloc.file == NULL || xloc.file[0] == '\xff' - || xloc.file[1] == '\xff') - return false; diff --git a/nix/nixcrpkgs/mingw-w64/gcc/use-source-date-epoch.patch b/nix/nixcrpkgs/mingw-w64/gcc/use-source-date-epoch.patch deleted file mode 100644 index 65a5ab028c..0000000000 --- a/nix/nixcrpkgs/mingw-w64/gcc/use-source-date-epoch.patch +++ /dev/null @@ -1,52 +0,0 @@ -https://gcc.gnu.org/ml/gcc-patches/2015-06/msg02210.html - -diff --git a/libcpp/macro.c b/libcpp/macro.c -index 1e0a0b5..a52e3cb 100644 ---- a/libcpp/macro.c -+++ b/libcpp/macro.c -@@ -349,14 +349,38 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node) - slow on some systems. */ - time_t tt; - struct tm *tb = NULL; -+ char *source_date_epoch; - -- /* (time_t) -1 is a legitimate value for "number of seconds -- since the Epoch", so we have to do a little dance to -- distinguish that from a genuine error. */ -- errno = 0; -- tt = time(NULL); -- if (tt != (time_t)-1 || errno == 0) -- tb = localtime (&tt); -+ /* Allow the date and time to be set externally by an exported -+ environment variable to enable reproducible builds. */ -+ source_date_epoch = getenv ("SOURCE_DATE_EPOCH"); -+ if (source_date_epoch) -+ { -+ errno = 0; -+ tt = (time_t) strtol (source_date_epoch, NULL, 10); -+ if (errno == 0) -+ { -+ tb = gmtime (&tt); -+ if (tb == NULL) -+ cpp_error (pfile, CPP_DL_ERROR, -+ "SOURCE_DATE_EPOCH=\"%s\" is not a valid date", -+ source_date_epoch); -+ } -+ else -+ cpp_error (pfile, CPP_DL_ERROR, -+ "SOURCE_DATE_EPOCH=\"%s\" is not a valid number", -+ source_date_epoch); -+ } -+ else -+ { -+ /* (time_t) -1 is a legitimate value for "number of seconds -+ since the Epoch", so we have to do a little dance to -+ distinguish that from a genuine error. */ -+ errno = 0; -+ tt = time(NULL); -+ if (tt != (time_t)-1 || errno == 0) -+ tb = localtime (&tt); -+ } - - if (tb) - { diff --git a/nix/nixcrpkgs/mingw-w64/guid-selectany.patch b/nix/nixcrpkgs/mingw-w64/guid-selectany.patch deleted file mode 100644 index b495a67b52..0000000000 --- a/nix/nixcrpkgs/mingw-w64/guid-selectany.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 339371eafd2fb2bcbf8b0a08e5328fc7c16b892f Mon Sep 17 00:00:00 2001 -From: David Grayson -Date: Thu, 4 May 2017 06:41:28 -0700 -Subject: [PATCH] guiddef.h: Use __declspec(selectany) on GUID declarations. - -If __declspec(selectany) is not used on the prototype but later used -on a definition, GCC 6+ seems to ignore it, and you can get -multiple-definition errors at link time. - -That situation can arise in code like Microsoft's usbview utility that -has multiple translation units including the following headers in this -order: windows.h, initguid.h, winioctl.h. - -However, this patch cannot be upstreamed to mingw-w64 because it -breaks older versions of GCC, and MSDN says that putting selectany on -a declaration is "incorrect". Once GCC is fixed, we can remove this -patch. ---- - mingw-w64-headers/include/guiddef.h | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/mingw-w64-headers/include/guiddef.h b/mingw-w64-headers/include/guiddef.h -index 9ecea3e2..6c9444cf 100644 ---- a/mingw-w64-headers/include/guiddef.h -+++ b/mingw-w64-headers/include/guiddef.h -@@ -58,8 +58,7 @@ __extension__ template const GUID &__mingw_uuidof(); - #define DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) const GUID DECLSPEC_SELECTANY name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } - #endif - #else --/* __declspec(selectany) must be applied to initialized objects on GCC 5 hence must not be used here. */ --#define DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) EXTERN_C const GUID name -+#define DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) EXTERN_C const GUID DECLSPEC_SELECTANY name - #endif - - #define DEFINE_OLEGUID(name, l, w1, w2) DEFINE_GUID (name, l, w1, w2, 0xc0, 0, 0, 0, 0, 0, 0, 0x46) --- -2.12.1 - diff --git a/nix/nixcrpkgs/mingw-w64/license_builder.sh b/nix/nixcrpkgs/mingw-w64/license_builder.sh deleted file mode 100644 index beb53ee270..0000000000 --- a/nix/nixcrpkgs/mingw-w64/license_builder.sh +++ /dev/null @@ -1,42 +0,0 @@ -source $setup - -tar -xf $gcc_src -mv gcc-* gcc - -license_gcc=$(cat gcc/COPYING3.LIB) -cd $src -license_runtime=$(cat COPYING.MinGW-w64-runtime/COPYING.MinGW-w64-runtime.txt) -license_winpthread=$(cat mingw-w64-libraries/winpthreads/COPYING) - -cat > $out < - The third-party software included with this software may - have been patched or otherwise modified. -

- -

GCC run-time libraries

- -

- The GCC run-time libraries libgcc and libstdc++ are licensed under the GNU - General Public License Version 3 (GPLv3) as shown below. -

- -
-$license_gcc
-
- -

MinGW-w64 runtime components

- -
-$license_runtime
-
- -

- libwinpthread also comes from the mingw-w64 project and its license is below. -

- -
-$license_winpthread
-
- -EOF diff --git a/nix/nixcrpkgs/mingw-w64/usb.patch b/nix/nixcrpkgs/mingw-w64/usb.patch deleted file mode 100644 index 768c4a9791..0000000000 --- a/nix/nixcrpkgs/mingw-w64/usb.patch +++ /dev/null @@ -1,73 +0,0 @@ -diff --git a/mingw-w64-headers/include/usbspec.h b/mingw-w64-headers/include/usbspec.h -index 86557d8d..97ab5f3b 100644 ---- a/mingw-w64-headers/include/usbspec.h -+++ b/mingw-w64-headers/include/usbspec.h -@@ -213,6 +213,13 @@ typedef struct _USB_BOS_DESCRIPTOR { - #define USB_DEVICE_CAPABILITY_USB20_EXTENSION 0x02 - #define USB_DEVICE_CAPABILITY_SUPERSPEED_USB 0x03 - #define USB_DEVICE_CAPABILITY_CONTAINER_ID 0x04 -+#define USB_DEVICE_CAPABILITY_PLATFORM 0x05 -+#define USB_DEVICE_CAPABILITY_POWER_DELIVERY 0x06 -+#define USB_DEVICE_CAPABILITY_BATTERY_INFO 0x07 -+#define USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT 0x08 -+#define USB_DEVICE_CAPABILITY_PD_PROVIDER_PORT 0x09 -+#define USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB 0x0A -+#define USB_DEVICE_CAPABILITY_PRECISION_TIME_MEASUREMENT 0x0B - #define USB_DEVICE_CAPABILITY_BILLBOARD 0x0D - - typedef struct _USB_DEVICE_CAPABILITY_USB20_EXTENSION_DESCRIPTOR { -@@ -666,6 +673,54 @@ typedef struct _USB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR { - ULONG dwBytesPerInterval; - } USB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR,*PUSB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR; - -+typedef union _USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED { -+ ULONG AsUlong32; -+ struct { -+ ULONG SublinkSpeedAttrID:4; -+ ULONG LaneSpeedExponent:2; -+ ULONG SublinkTypeMode:1; -+ ULONG SublinkTypeDir:1; -+ ULONG Reserved:6; -+ ULONG LinkProtocol:2; -+ ULONG LaneSpeedMantissa:16; -+ }; -+} USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED, *PUSB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED; -+ -+typedef struct _USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR { -+ UCHAR bLength; -+ UCHAR bDescriptorType; -+ UCHAR bDevCapabilityType; -+ UCHAR bReserved; -+ union { -+ ULONG AsUlong; -+ struct { -+ ULONG SublinkSpeedAttrCount:5; -+ ULONG SublinkSpeedIDCount:4; -+ ULONG Reserved:23; -+ }; -+ } bmAttributes; -+ union { -+ USHORT AsUshort; -+ struct { -+ USHORT SublinkSpeedAttrID:4; -+ USHORT Reserved:4; -+ USHORT MinRxLaneCount:4; -+ USHORT MinTxLaneCount:4; -+ }; -+ } wFunctionalitySupport; -+ USHORT wReserved; -+ USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED bmSublinkSpeedAttr[1]; -+} USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR,*PUSB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR; -+ -+typedef struct _USB_DEVICE_CAPABILITY_PLATFORM_DESCRIPTOR { -+ UCHAR bLength; -+ UCHAR bDescriptorType; -+ UCHAR bDevCapabilityType; -+ UCHAR bReserved; -+ GUID PlatformCapabilityUuid; -+ UCHAR CapabililityData[1]; -+} USB_DEVICE_CAPABILITY_PLATFORM_DESCRIPTOR,*PUSB_DEVICE_CAPABILITY_PLATFORM_DESCRIPTOR; -+ - #include - - #endif diff --git a/nix/nixcrpkgs/native/default.nix b/nix/nixcrpkgs/native/default.nix deleted file mode 100644 index e56c5ce5c5..0000000000 --- a/nix/nixcrpkgs/native/default.nix +++ /dev/null @@ -1,54 +0,0 @@ -{ nixpkgs }: - -let - native_base = { - inherit nixpkgs; - - is_cross = false; - - default_native_inputs = [ - nixpkgs.bashInteractive - nixpkgs.binutils - (nixpkgs.binutils-unwrapped or nixpkgs.binutils) - nixpkgs.bzip2 - nixpkgs.cmake - nixpkgs.coreutils - nixpkgs.diffutils - nixpkgs.findutils - nixpkgs.gcc - nixpkgs.gawk - nixpkgs.gnumake - nixpkgs.gnugrep - nixpkgs.gnused - nixpkgs.gnutar - nixpkgs.gzip - nixpkgs.ninja - nixpkgs.patch - nixpkgs.which - nixpkgs.xz - ]; - - make_derivation = import ../make_derivation.nix native_base; - }; - - pkgconf = import ./pkgconf { env = native_base; }; - - wrappers = import ./wrappers { env = native_base; }; - - gnu_config = nixpkgs.fetchgit { - url = "https://git.savannah.gnu.org/git/config.git"; - rev = "81497f5aaf50a12a9fe0cba30ef18bda46b62959"; - sha256 = "1fq0nki2118zwbc8rdkqx5i04lbfw7gqbsyf5bscg5im6sfphq1d"; - }; - - native = native_base // { - default_native_inputs = native_base.default_native_inputs ++ [ - pkgconf - ]; - - inherit pkgconf wrappers gnu_config; - - make_derivation = import ../make_derivation.nix native; - }; - -in native diff --git a/nix/nixcrpkgs/native/pkgconf/builder.sh b/nix/nixcrpkgs/native/pkgconf/builder.sh deleted file mode 100644 index e58ccf98a9..0000000000 --- a/nix/nixcrpkgs/native/pkgconf/builder.sh +++ /dev/null @@ -1,21 +0,0 @@ -source $setup - -tar -xf $src - -mkdir build - -cd build - -../pkgconf-$version/configure \ - --prefix=$out \ - --with-system-libdir=/no-system-libdir/ \ - --with-system-includedir=/no-system-includedir/ - -make - -make install - -ln -s $out/bin/pkgconf $out/bin/pkg-config - -mkdir $out/license -cp ../pkgconf-$version/COPYING $out/license/LICENSE diff --git a/nix/nixcrpkgs/native/pkgconf/default.nix b/nix/nixcrpkgs/native/pkgconf/default.nix deleted file mode 100644 index cd7eea7bd4..0000000000 --- a/nix/nixcrpkgs/native/pkgconf/default.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ env }: - -env.make_derivation rec { - name = "pkgconf-${version}"; - - version = "1.0.1"; - - src = env.nixpkgs.fetchurl { - url = "https://github.com/pkgconf/pkgconf/releases/download/pkgconf-${version}/pkgconf-${version}.tar.gz"; - sha256 = "1w9wb2z7zz6s4mifbllvhx0401bwsynhp02v312i6i9jn1m2zkj5"; - }; - - builder = ./builder.sh; -} diff --git a/nix/nixcrpkgs/native/wrappers/builder.sh b/nix/nixcrpkgs/native/wrappers/builder.sh deleted file mode 100644 index 64d149cef2..0000000000 --- a/nix/nixcrpkgs/native/wrappers/builder.sh +++ /dev/null @@ -1,17 +0,0 @@ -source $setup - -mkdir -p $out/bin - -cat > $out/bin/pkg-config-cross < $out/bin/cmake-cross < $out/gdbcmd.txt -set substitute-path ../samples src/angle/samples -set substitute-path ../util src/angle/util -EOF diff --git a/nix/nixcrpkgs/pkgs/angle/default.nix b/nix/nixcrpkgs/pkgs/angle/default.nix deleted file mode 100644 index da5a76c37e..0000000000 --- a/nix/nixcrpkgs/pkgs/angle/default.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ crossenv, gdb, debug ? false }: - -if crossenv.os != "windows" then "" else - -let - angle = import ./lib.nix { - inherit crossenv debug; - }; - - util = import ./util.nix { - inherit crossenv angle; - }; - - examples = import ./examples.nix { - inherit crossenv angle; - angle_util = util; - }; - - debug_bundle = import ./debug_bundle.nix { - inherit crossenv gdb angle examples; - }; - -in angle // { inherit util examples debug_bundle; } diff --git a/nix/nixcrpkgs/pkgs/angle/examples.nix b/nix/nixcrpkgs/pkgs/angle/examples.nix deleted file mode 100644 index 6ccb47f051..0000000000 --- a/nix/nixcrpkgs/pkgs/angle/examples.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ crossenv, angle, angle_util }: - -crossenv.make_derivation rec { - name = "angle-samples-${angle.version}"; - - src = angle.src; - - inherit angle angle_util; - - builder = ./samples_builder.sh; -} diff --git a/nix/nixcrpkgs/pkgs/angle/lib.nix b/nix/nixcrpkgs/pkgs/angle/lib.nix deleted file mode 100644 index 7357d905fa..0000000000 --- a/nix/nixcrpkgs/pkgs/angle/lib.nix +++ /dev/null @@ -1,43 +0,0 @@ -{ crossenv, debug ? false }: - -if crossenv.os != "windows" then "windows only" else - -crossenv.make_derivation rec { - name = "angle-${version}"; - - version = "2017-03-09"; - - src = crossenv.nixpkgs.fetchgit { - url = "https://chromium.googlesource.com/angle/angle"; - rev = "fe9306a8e5bb6a8d52368e8e7b8e92f3bc7e77d4"; - sha256 = "0m2pbkl9x9kybcxzhai0s3bk9k0r8nb531gzlxcvb3gb2za388bn"; - }; - - patches = [ ./megapatch.patch ]; - - builder = ./builder.sh; - - native_inputs = [ - crossenv.nixpkgs.pythonPackages.gyp - ]; - - GYP_GENERATORS = "ninja"; - - gyp_flags = - "-D OS=win " + - "-D TARGET=win32 " + - "-D use_ozone=0 " + - "-D angle_enable_vulkan=0 " + # Vulkan support is in progress - "-D angle_gl_library_type=static_library " + - "-I ../src/gyp/common.gypi " + - "--depth ."; - - CC_target = "${crossenv.host}-gcc"; - CXX_target = "${crossenv.host}-g++"; - AR = "${crossenv.host}-ar"; - RANLIB = "${crossenv.host}-ranlib"; - - CXXFLAGS = "-msse2 -Wno-conversion-null"; - - inherit debug; -} diff --git a/nix/nixcrpkgs/pkgs/angle/megapatch.patch b/nix/nixcrpkgs/pkgs/angle/megapatch.patch deleted file mode 100644 index 319b192a70..0000000000 --- a/nix/nixcrpkgs/pkgs/angle/megapatch.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff -ur angle-src-orig/src/angle.gyp angle-src/src/angle.gyp ---- angle-src-orig/src/angle.gyp 2017-02-07 07:42:35.090343332 -0800 -+++ angle-src/src/angle.gyp 2017-02-09 08:44:52.752006998 -0800 -@@ -286,7 +286,7 @@ - } - ] - }], -- ['OS=="win"', -+ ['OS=="win" and 0', - { - 'targets': - [ -diff -ur angle-src-orig/src/libGLESv2.gypi angle-src/src/libGLESv2.gypi ---- angle-src-orig/src/libGLESv2.gypi 2017-02-07 07:42:35.113676666 -0800 -+++ angle-src/src/libGLESv2.gypi 2017-02-09 09:19:37.985340331 -0800 -@@ -1078,7 +1078,7 @@ - '<@(libangle_null_sources)', - ], - }], -- ['angle_build_winrt==0 and OS=="win"', -+ ['angle_build_winrt==0 and OS=="win" and 0', - { - 'dependencies': - [ diff --git a/nix/nixcrpkgs/pkgs/angle/samples_builder.sh b/nix/nixcrpkgs/pkgs/angle/samples_builder.sh deleted file mode 100644 index 3b89c9c0b1..0000000000 --- a/nix/nixcrpkgs/pkgs/angle/samples_builder.sh +++ /dev/null @@ -1,54 +0,0 @@ -source $setup - -cp -r $src/samples . -cp -r $src/util . - -mkdir include -cp -r $src/samples/sample_util/* include/ - -mkdir build -cd build -mkdir bin - -CFLAGS="-mwindows -g -O2 -I../include -I$angle_util/include -I$angle/include" -CFLAGS="$CFLAGS -DGL_APICALL= -DANGLE_EXPORT= -DGL_GLEXT_PROTOTYPES" -LDFLAGS="-L$angle_util/lib -L$angle/lib" -LIBS="-langle_util -lEGL_static -lGLESv2_static -lANGLE -ltranslator --lpreprocessor -langle_image_util -langle_common -ld3d9 -lgdi32" - -echo "compiling texture_wrap" -$host-g++ $CFLAGS $LDFLAGS \ - ../samples/texture_wrap/TextureWrap.cpp \ - ../samples/sample_util/texture_utils.cpp \ - ../samples/sample_util/SampleApplication.cpp \ - $LIBS -o bin/texture_wrap${exe_suffix} - -echo "compiling simple_texture_2d" -$host-g++ $CFLAGS $LDFLAGS \ - ../samples/simple_texture_2d/SimpleTexture2D.cpp \ - ../samples/sample_util/texture_utils.cpp \ - ../samples/sample_util/SampleApplication.cpp \ - $LIBS -o bin/simple_texture_2d${exe_suffix} - -echo "compiling particle_system" -$host-g++ $CFLAGS $LDFLAGS \ - ../samples/particle_system/ParticleSystem.cpp \ - ../samples/sample_util/tga_utils.cpp \ - ../samples/sample_util/SampleApplication.cpp \ - $LIBS -o bin/particle_system${exe_suffix} -cp ../samples/particle_system/smoke.tga bin/ - -echo "compiling hello_triangle" -$host-g++ $CFLAGS $LDFLAGS \ - ../samples/hello_triangle/HelloTriangle.cpp \ - ../samples/sample_util/SampleApplication.cpp \ - $LIBS -o bin/hello_triangle${exe_suffix} - -echo "compiling window_test" -$host-g++ $CFLAGS $LDFLAGS \ - ../samples/WindowTest/WindowTest.cpp \ - -langle_util -lgdi32 -o bin/window_test${exe_suffix} - -mkdir -p $out/license -cp $src/LICENSE $out/license/ -cp -r bin $out/ diff --git a/nix/nixcrpkgs/pkgs/angle/util.nix b/nix/nixcrpkgs/pkgs/angle/util.nix deleted file mode 100644 index 83d7038820..0000000000 --- a/nix/nixcrpkgs/pkgs/angle/util.nix +++ /dev/null @@ -1,15 +0,0 @@ -# libangle_util is a helper library for programs like tests -# and samples that surround ANGLE but that are not the ANGLE libraries -# themselves - -{ crossenv, angle }: - -crossenv.make_derivation rec { - name = "angle_util-${angle.version}"; - - src = angle.src; - - inherit angle; - - builder = ./util_builder.sh; -} diff --git a/nix/nixcrpkgs/pkgs/angle/util_builder.sh b/nix/nixcrpkgs/pkgs/angle/util_builder.sh deleted file mode 100644 index 7929083b6e..0000000000 --- a/nix/nixcrpkgs/pkgs/angle/util_builder.sh +++ /dev/null @@ -1,38 +0,0 @@ -source $setup - -cp -r $src/util . - -mkdir include -cp -r $src/util/*.h include/ -cp -r $src/include/export.h include/ -mkdir include/common -cp -r $src/src/common/*.h include/common/ -mkdir -p include/windows/win32 -cp -r $src/util/windows/*.h include/windows/ -cp -r $src/util/windows/win32/*.h include/windows/win32/ - -mkdir -p build/{obj,lib} -cd build - -source_files=../util/*.cpp - -if [ "$os" == "windows" ]; then - source_files="$source_files ../util/windows/*.cpp ../util/windows/win32/*.cpp" -fi - -for c in $source_files; do - echo "compiling $(basename $c)" - $host-g++ -c -g -O2 -fpermissive \ - -I../include -I"$angle/include" -L"$angle/lib" \ - -DGL_APICALL= -DANGLE_EXPORT= -DEGLAPI= \ - -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES -DLIBANGLE_UTIL_IMPLEMENTATION \ - $c -lGLESv2 -lEGL \ - -o obj/$(basename $c).o -done - -$host-ar r lib/libangle_util.a obj/*.o - -mkdir -p $out/{license,lib} -cp $src/LICENSE $out/license/ -cp lib/libangle_util.a $out/lib/ -cp -r ../include $out/ diff --git a/nix/nixcrpkgs/pkgs/at-spi2-headers/builder.sh b/nix/nixcrpkgs/pkgs/at-spi2-headers/builder.sh deleted file mode 100644 index 04ac14fda5..0000000000 --- a/nix/nixcrpkgs/pkgs/at-spi2-headers/builder.sh +++ /dev/null @@ -1,12 +0,0 @@ -source $setup - -mkdir -p $out/include/atspi $out/lib/pkgconfig - -cp $src/atspi/*.h $out/include/atspi/ - -cat > $out/lib/pkgconfig/atspi-2.pc < $out <at-spi2-headers -
-$license
-
-EOF diff --git a/nix/nixcrpkgs/pkgs/avrdude/builder.sh b/nix/nixcrpkgs/pkgs/avrdude/builder.sh deleted file mode 100644 index 8c7f2c078f..0000000000 --- a/nix/nixcrpkgs/pkgs/avrdude/builder.sh +++ /dev/null @@ -1,23 +0,0 @@ -source $setup - -tar -xf $src -mv avrdude-* avrdude - -ls -lad avrdude -cd avrdude -chmod -R u+w . -cp $config_dot_sub config.sub -cat $extra_conf >> avrdude.conf.in -cd .. - -mkdir build -cd build - -../avrdude/configure --host=$host --prefix=$out \ - --enable-static \ - --disable-shared \ - --disable-dependency-tracking - -make - -make install diff --git a/nix/nixcrpkgs/pkgs/avrdude/config.sub b/nix/nixcrpkgs/pkgs/avrdude/config.sub deleted file mode 100644 index 1d8e98bcee..0000000000 --- a/nix/nixcrpkgs/pkgs/avrdude/config.sub +++ /dev/null @@ -1,1801 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright 1992-2018 Free Software Foundation, Inc. - -timestamp='2018-02-22' - -# This file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that -# program. This Exception is an additional permission under section 7 -# of the GNU General Public License, version 3 ("GPLv3"). - - -# Please send patches to . -# -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# You can get the latest version of this script from: -# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS - -Canonicalize a configuration name. - -Options: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.sub ($timestamp) - -Copyright 1992-2018 Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" - exit 1 ;; - - *local*) - # First pass through any local machine types. - echo "$1" - exit ;; - - * ) - break ;; - esac -done - -case $# in - 0) echo "$me: missing argument$help" >&2 - exit 1;; - 1) ;; - *) echo "$me: too many arguments$help" >&2 - exit 1;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ - kopensolaris*-gnu* | cloudabi*-eabi* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - android-linux) - os=-linux-android - basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; - *) - basic_machine=`echo "$1" | sed 's/-[^-]*$//'` - if [ "$basic_machine" != "$1" ] - then os=`echo "$1" | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze*) - os= - basic_machine=$1 - ;; - -bluegene*) - os=-cnk - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco6) - os=-sco5v6 - basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` - ;; - -sco5v6*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*178) - os=-lynxos178 - ;; - -lynx*5) - os=-lynxos5 - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo "$1" | sed -e 's/86-.*/86-sequent/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | aarch64 | aarch64_be \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arceb \ - | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ - | avr | avr32 \ - | ba \ - | be32 | be64 \ - | bfin \ - | c4x | c8051 | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | e2k | epiphany \ - | fido | fr30 | frv | ft32 \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ - | i370 | i860 | i960 | ia16 | ia64 \ - | ip2k | iq2000 \ - | k1om \ - | le32 | le64 \ - | lm32 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ - | mips64vr | mips64vrel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa32r6 | mipsisa32r6el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64r6 | mipsisa64r6el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipsr5900 | mipsr5900el \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | moxie \ - | mt \ - | msp430 \ - | nds32 | nds32le | nds32be \ - | nios | nios2 | nios2eb | nios2el \ - | ns16k | ns32k \ - | open8 | or1k | or1knd | or32 \ - | pdp10 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pru \ - | pyramid \ - | riscv32 | riscv64 \ - | rl78 | rx \ - | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ - | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ - | visium \ - | wasm32 \ - | x86 | xc16x | xstormy16 | xtensa \ - | z8k | z80) - basic_machine=$basic_machine-unknown - ;; - c54x) - basic_machine=tic54x-unknown - ;; - c55x) - basic_machine=tic55x-unknown - ;; - c6x) - basic_machine=tic6x-unknown - ;; - leon|leon[3-9]) - basic_machine=sparc-$basic_machine - ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65) - ;; - ms1) - basic_machine=mt-unknown - ;; - - strongarm | thumb | xscale) - basic_machine=arm-unknown - ;; - xgate) - basic_machine=$basic_machine-unknown - os=-none - ;; - xscaleeb) - basic_machine=armeb-unknown - ;; - - xscaleel) - basic_machine=armel-unknown - ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | aarch64-* | aarch64_be-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | ba-* \ - | be32-* | be64-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | c8051-* | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | e2k-* | elxsi-* \ - | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | hexagon-* \ - | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ - | ip2k-* | iq2000-* \ - | k1om-* \ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ - | microblaze-* | microblazeel-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64octeon-* | mips64octeonel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64r5900-* | mips64r5900el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa32r6-* | mipsisa32r6el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64r6-* | mipsisa64r6el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipsr5900-* | mipsr5900el-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* | nios2eb-* | nios2el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ - | or1k*-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pru-* \ - | pyramid-* \ - | riscv32-* | riscv64-* \ - | rl78-* | romp-* | rs6000-* | rx-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ - | tahoe-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ - | tron-* \ - | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ - | visium-* \ - | wasm32-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ - | xstormy16-* | xtensa*-* \ - | ymp-* \ - | z8k-* | z80-*) - ;; - # Recognize the basic CPU types without company name, with glob match. - xtensa*) - basic_machine=$basic_machine-unknown - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-pc - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aros) - basic_machine=i386-pc - os=-aros - ;; - asmjs) - basic_machine=asmjs-unknown - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - blackfin) - basic_machine=bfin-unknown - os=-linux - ;; - blackfin-*) - basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'` - os=-linux - ;; - bluegene*) - basic_machine=powerpc-ibm - os=-cnk - ;; - c54x-*) - basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'` - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - cegcc) - basic_machine=arm-unknown - os=-cegcc - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16 | cr16-*) - basic_machine=cr16-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 - ;; - decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dicos) - basic_machine=i686-pc - os=-dicos - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2*) - basic_machine=m68k-bull - os=-sysv3 - ;; - e500v[12]) - basic_machine=powerpc-unknown - os=$os"spe" - ;; - e500v[12]-*) - basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` - os=$os"spe" - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; - i*86v32) - basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - leon-*|leon[3-9]-*) - basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'` - ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux - ;; - m68knommu-*) - basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'` - os=-linux - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - microblaze*) - basic_machine=microblaze-xilinx - ;; - mingw64) - basic_machine=x86_64-pc - os=-mingw64 - ;; - mingw32) - basic_machine=i686-pc - os=-mingw32 - ;; - mingw32ce) - basic_machine=arm-unknown - os=-mingw32ce - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - moxiebox) - basic_machine=moxie-unknown - os=-moxiebox - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - ms1-*) - basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'` - ;; - msys) - basic_machine=i686-pc - os=-msys - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - neo-tandem) - basic_machine=neo-tandem - ;; - nse-tandem) - basic_machine=nse-tandem - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - nsv-tandem) - basic_machine=nsv-tandem - ;; - nsx-tandem) - basic_machine=nsx-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - parisc) - basic_machine=hppa-unknown - os=-linux - ;; - parisc-*) - basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'` - os=-linux - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pc98) - basic_machine=i386-pc - ;; - pc98-*) - basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'` - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc - ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc | ppcbe) basic_machine=powerpc-unknown - ;; - ppc-* | ppcbe-*) - basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos | rdos64) - basic_machine=x86_64-pc - os=-rdos - ;; - rdos32) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown - ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown - ;; - sde) - basic_machine=mipsisa32-sde - os=-elf - ;; - sei) - basic_machine=mips-sei - os=-seiux - ;; - sequent) - basic_machine=i386-sequent - ;; - sh5el) - basic_machine=sh5le-unknown - ;; - simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - strongarm-* | thumb-*) - basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'` - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; - tile*) - basic_machine=$basic_machine-unknown - os=-linux-gnu - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - x64) - basic_machine=x86_64-pc - ;; - xbox) - basic_machine=i686-pc - os=-mingw32 - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - xscale-* | xscalee[bl]-*) - basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'` - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond - ;; - op50n) - basic_machine=hppa1.1-oki - ;; - op60c) - basic_machine=hppa1.1-oki - ;; - romp) - basic_machine=romp-ibm - ;; - mmix) - basic_machine=mmix-knuth - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple - ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; - *) - echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases that might get confused - # with valid system types. - # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux - ;; - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # es1800 is here to avoid being matched by es* (a different OS) - -es1800*) - os=-ose - ;; - # Now accept the basic system types. - # The portable systems comes first. - # Each alternative MUST end in a * to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ - | -sym* | -kopensolaris* | -plan9* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* | -cloudabi* | -sortix* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -knetbsd* | -mirbsd* | -netbsd* \ - | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ - | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ - | -linux-newlib* | -linux-musl* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ - | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox* | -bme* \ - | -midnightbsd*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac - ;; - -nto-qnx*) - ;; - -nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` - ;; - -sim | -xray | -os68k* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo "$os" | sed -e 's|mac|macos|'` - ;; - -linux-dietlibc) - os=-linux-dietlibc - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo "$os" | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo "$os" | sed -e 's|sunos6|solaris3|'` - ;; - -opened*) - os=-openedition - ;; - -os400*) - os=-os400 - ;; - -wince*) - os=-wince - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -atheos*) - os=-atheos - ;; - -syllable*) - os=-syllable - ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; - -nova*) - os=-rtmk-nova - ;; - -ns2) - os=-nextstep2 - ;; - -nsk*) - os=-nsk - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -tpf*) - os=-tpf - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4*) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -ose*) - os=-ose - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint - ;; - -zvmoe) - os=-zvmoe - ;; - -dicos*) - os=-dicos - ;; - -pikeos*) - # Until real need of OS specific support for - # particular features comes up, bare metal - # configurations are quite functional. - case $basic_machine in - arm*) - os=-eabi - ;; - *) - os=-elf - ;; - esac - ;; - -nacl*) - ;; - -ios) - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - score-*) - os=-elf - ;; - spu-*) - os=-elf - ;; - *-acorn) - os=-riscix1.2 - ;; - arm*-rebel) - os=-linux - ;; - arm*-semi) - os=-aout - ;; - c4x-* | tic4x-*) - os=-coff - ;; - c8051-*) - os=-elf - ;; - hexagon-*) - os=-elf - ;; - tic54x-*) - os=-coff - ;; - tic55x-*) - os=-coff - ;; - tic6x-*) - os=-coff - ;; - # This must come before the *-dec entry. - pdp10-*) - os=-tops20 - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - ;; - m68*-cisco) - os=-aout - ;; - mep-*) - os=-elf - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - or32-*) - os=-coff - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - pru-*) - os=-elf - ;; - *-be) - os=-beos - ;; - *-ibm) - os=-aix - ;; - *-knuth) - os=-mmixware - ;; - *-wec) - os=-proelf - ;; - *-winbond) - os=-proelf - ;; - *-oki) - os=-proelf - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f30[01]-fujitsu | f700-fujitsu) - os=-uxpv - ;; - *-rom68k) - os=-coff - ;; - *-*bug) - os=-coff - ;; - *-apple) - os=-macos - ;; - *-atari*) - os=-mint - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -cnk*|-aix*) - vendor=ibm - ;; - -beos*) - vendor=be - ;; - -hpux*) - vendor=hp - ;; - -mpeix*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs* | -opened*) - vendor=ibm - ;; - -os400*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -tpf*) - vendor=ibm - ;; - -vxsim* | -vxworks* | -windiss*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -hms*) - vendor=hitachi - ;; - -mpw* | -macos*) - vendor=apple - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - vendor=atari - ;; - -vos*) - vendor=stratus - ;; - esac - basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"` - ;; -esac - -echo "$basic_machine$os" -exit - -# Local variables: -# eval: (add-hook 'write-file-functions 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/nix/nixcrpkgs/pkgs/avrdude/default.nix b/nix/nixcrpkgs/pkgs/avrdude/default.nix deleted file mode 100644 index d5442cc907..0000000000 --- a/nix/nixcrpkgs/pkgs/avrdude/default.nix +++ /dev/null @@ -1,35 +0,0 @@ -# TODO: remove giveio.sys and any other sketchy drivers or binaries from the source - -# Note: There are no patches to help AVRDUDE find its configuration -# file, so it will expect that file to be at -# /nix/store/...-avrdude/etc/avrdude.conf - -{ crossenv }: - -crossenv.make_derivation rec { - name = "avrdude-${version}"; - - version = "6.3"; # February 2016 - - src = crossenv.nixpkgs.fetchurl { - url = "http://download.savannah.gnu.org/releases/avrdude/avrdude-${version}.tar.gz"; - sha256 = "15m1w1qad3dj7r8n5ng1qqcaiyx1gyd6hnc3p2apgjllccdp77qg"; - }; - - native_inputs = [ - crossenv.nixpkgs.yacc - crossenv.nixpkgs.flex - ]; - - cross_inputs = [ - # TODO: libusb - # TODO: libftdi - # TODO: libelf - # TODO: libhid - ]; - - config_dot_sub = ./config.sub; - extra_conf = ./extra.conf; - - builder = ./builder.sh; -} diff --git a/nix/nixcrpkgs/pkgs/avrdude/extra.conf b/nix/nixcrpkgs/pkgs/avrdude/extra.conf deleted file mode 100644 index 539cd65f4c..0000000000 --- a/nix/nixcrpkgs/pkgs/avrdude/extra.conf +++ /dev/null @@ -1,6 +0,0 @@ -part parent "m328p" - id = "m328pb"; - desc = "ATmega328PB"; - signature = 0x1e 0x95 0x16; - ocdrev = 1; -; \ No newline at end of file diff --git a/nix/nixcrpkgs/pkgs/curl/builder.sh b/nix/nixcrpkgs/pkgs/curl/builder.sh deleted file mode 100644 index 303f6278e6..0000000000 --- a/nix/nixcrpkgs/pkgs/curl/builder.sh +++ /dev/null @@ -1,15 +0,0 @@ -source $setup - -tar -xf $src -cd * - -export CFLAGS=-fPIC - -case $host in - *darwin*) CFLAGS="$CFLAGS -mmacosx-version-min=10.11";; -esac - -./configure --prefix=$out --host=$host $configureFlags - -make -make install diff --git a/nix/nixcrpkgs/pkgs/curl/default.nix b/nix/nixcrpkgs/pkgs/curl/default.nix deleted file mode 100644 index 8268e288ed..0000000000 --- a/nix/nixcrpkgs/pkgs/curl/default.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ crossenv, openssl, zlib }: - -crossenv.make_derivation rec { - name = "curl-${version}"; - version = "7.62.0"; - - cross_inputs = [ crossenv.nixpkgs.perl ]; - native_inputs = [ zlib openssl ]; - builder = ./builder.sh; - - configureFlags = [ - "--disable-shared" - "--disable-manual" - "--disable-ldap" - "--with-ssl=${openssl}" - ]; - - src = crossenv.nixpkgs.fetchurl { - url = "https://curl.haxx.se/download/${name}.tar.bz2"; - sha256 = "084niy7cin13ba65p8x38w2xcyc54n3fgzbin40fa2shfr0ca0kq"; - }; -} diff --git a/nix/nixcrpkgs/pkgs/dejavu-fonts/builder.sh b/nix/nixcrpkgs/pkgs/dejavu-fonts/builder.sh deleted file mode 100644 index 1161ce85ab..0000000000 --- a/nix/nixcrpkgs/pkgs/dejavu-fonts/builder.sh +++ /dev/null @@ -1,6 +0,0 @@ -source $setup - -tar -xf $src -cd dejavu-* -mkdir $out -cp -r * $out/ diff --git a/nix/nixcrpkgs/pkgs/dejavu-fonts/default.nix b/nix/nixcrpkgs/pkgs/dejavu-fonts/default.nix deleted file mode 100644 index bd8a9d7436..0000000000 --- a/nix/nixcrpkgs/pkgs/dejavu-fonts/default.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ crossenv }: - -let - version = "2.37"; - - name = "dejavu-fonts-${version}"; - - src = crossenv.nixpkgs.fetchurl { - # Sourceforge went down. The original URL was: - # http://sourceforge.net/projects/dejavu/files/dejavu/${version}/dejavu-fonts-ttf-${version}.tar.bz2"; - url = "https://files.tmphax.com/repo1/dejavu-fonts-ttf-${version}.tar.bz2"; - sha256 = "1mqpds24wfs5cmfhj57fsfs07mji2z8812i5c4pi5pbi738s977s"; - }; - - fonts = crossenv.native.make_derivation { - inherit version name src; - builder = ./builder.sh; - }; - - license = crossenv.native.make_derivation { - name = "${name}-license"; - inherit src; - builder = ./license_builder.sh; - }; - - license_set = { "${name}" = license; }; - -in - fonts // { inherit license_set; } diff --git a/nix/nixcrpkgs/pkgs/dejavu-fonts/license_builder.sh b/nix/nixcrpkgs/pkgs/dejavu-fonts/license_builder.sh deleted file mode 100644 index 4ba33030b2..0000000000 --- a/nix/nixcrpkgs/pkgs/dejavu-fonts/license_builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -mv dejavu-* dejavu - -license=$(cat dejavu/LICENSE) - -cat > $out <DejaVu Fonts - -
-$license
-
-EOF diff --git a/nix/nixcrpkgs/pkgs/devcon/builder.sh b/nix/nixcrpkgs/pkgs/devcon/builder.sh deleted file mode 100644 index 166abe2ad0..0000000000 --- a/nix/nixcrpkgs/pkgs/devcon/builder.sh +++ /dev/null @@ -1,26 +0,0 @@ -source $setup - -cp --no-preserve=mode -r $src/setup/devcon . - -cd devcon -for patch in $patches; do - echo applying patch $patch - patch -p1 -i $patch -done -$host-windmc msg.mc -cd .. - -mkdir build -cd build - -$host-windres ../devcon/devcon.rc rc.o - -$host-g++ -municode -O2 \ - -DUNICODE -D_UNICODE \ - ../devcon/*.cpp rc.o \ - -lsetupapi -lole32 \ - -o devcon.exe - -mkdir -p $out/bin $out/license -cp devcon.exe $out/bin -cp $src/LICENSE $out/license diff --git a/nix/nixcrpkgs/pkgs/devcon/default.nix b/nix/nixcrpkgs/pkgs/devcon/default.nix deleted file mode 100644 index e9410aee8b..0000000000 --- a/nix/nixcrpkgs/pkgs/devcon/default.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ crossenv }: - -if crossenv.os != "windows" then "windows only" else - -crossenv.make_derivation rec { - name = "devcon-${version}"; - - version = "2017-05-01"; - - src = crossenv.nixpkgs.fetchFromGitHub { - owner = "Microsoft"; - repo = "Windows-driver-samples"; - rev = "4c5c5e0297c7a61e151f92af702cdac650a14489"; - sha256 = "1drq26bnad98xqn805qx0b6g4y65lmrdj7v40b3jhhzdsp8993pf"; - }; - - patches = []; - - builder = ./builder.sh; -} diff --git a/nix/nixcrpkgs/pkgs/devcon/my_xmlhelper.c b/nix/nixcrpkgs/pkgs/devcon/my_xmlhelper.c deleted file mode 100644 index 0cdf29140b..0000000000 --- a/nix/nixcrpkgs/pkgs/devcon/my_xmlhelper.c +++ /dev/null @@ -1,47 +0,0 @@ -#include "xmlhelper.h" - -EXTERN_C HRESULT InitXmlHelper() -{ - return 0; -} - -EXTERN_C HRESULT ReleaseXmlWriter() -{ - return 0; -} - -EXTERN_C HRESULT SaveXml(LPTSTR szfileName, DWORD dwCreationDisposition) -{ - MessageBox(NULL, - "Sorry, XML saving is not supported in this build.", - "XML not supported", - MB_OK | MB_ICONEXCLAMATION); - return 0; -} - -EXTERN_C HRESULT XmlAddHostController( - PSTR hcName, - PUSBHOSTCONTROLLERINFO hcInfo - ) -{ - return 0; -} - -EXTERN_C HRESULT XmlAddRootHub(PSTR rhName, PUSBROOTHUBINFO rhInfo) -{ - return 0; -} - -EXTERN_C HRESULT XmlAddExternalHub(PSTR ehName, PUSBEXTERNALHUBINFO ehInfo) -{ - return 0; -} - -EXTERN_C HRESULT XmlAddUsbDevice(PSTR devName, PUSBDEVICEINFO deviceInfo) -{ - return 0; -} - -EXTERN_C VOID XmlNotifyEndOfNodeList(PVOID pContext) -{ -} diff --git a/nix/nixcrpkgs/pkgs/expat/builder.sh b/nix/nixcrpkgs/pkgs/expat/builder.sh deleted file mode 100644 index 3a8bfb7312..0000000000 --- a/nix/nixcrpkgs/pkgs/expat/builder.sh +++ /dev/null @@ -1,26 +0,0 @@ -source $setup - -tar -xf $src - -cd expat-$version -for patch in $patches; do - echo applying patch $patch - patch -p1 -i $patch -done -cd .. - -mkdir build -cd build - -../expat-$version/configure \ - --prefix=$out --host=$host \ - --enable-static --disable-shared - -make - -make install - -mv $out/bin/xmlwf $out/bin/xmlwf.exe - -mkdir $out/license -cp ../expat-$version/COPYING $out/license/LICENSE diff --git a/nix/nixcrpkgs/pkgs/expat/cve-2016-0718.patch b/nix/nixcrpkgs/pkgs/expat/cve-2016-0718.patch deleted file mode 100644 index 6d66fec0c7..0000000000 --- a/nix/nixcrpkgs/pkgs/expat/cve-2016-0718.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 3e6190e433479e56f8c1e5adc1198b3c86b15577 Mon Sep 17 00:00:00 2001 -From: Sebastian Pipping -Date: Sun, 17 Jul 2016 20:22:29 +0200 -Subject: [PATCH] Fix regression introduced by patch to CVE-2016-0718 (bug - #539) - -Tag names were cut off in some cases; reported by Andy Wang ---- - expat/lib/xmlparse.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c -index 13e080d..2630310 100644 ---- expat/lib/xmlparse.c -+++ expat-fixed/lib/xmlparse.c -@@ -2430,7 +2430,7 @@ doContent(XML_Parser parser, - &fromPtr, rawNameEnd, - (ICHAR **)&toPtr, (ICHAR *)tag->bufEnd - 1); - convLen = (int)(toPtr - (XML_Char *)tag->buf); -- if ((convert_res == XML_CONVERT_COMPLETED) || (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) { -+ if ((fromPtr >= rawNameEnd) || (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) { - tag->name.strLen = convLen; - break; - } --- -2.9.2 diff --git a/nix/nixcrpkgs/pkgs/expat/default.nix b/nix/nixcrpkgs/pkgs/expat/default.nix deleted file mode 100644 index 860f540044..0000000000 --- a/nix/nixcrpkgs/pkgs/expat/default.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ crossenv }: - -crossenv.make_derivation rec { - name = "expat-${version}"; - - version = "2.2.0"; - - src = crossenv.nixpkgs.fetchurl { - # Sourceforge went down. The original URL we used was: - # mirror://sourceforge/expat/expat-${version}.tar.bz2 - url = "https://files.tmphax.com/repo1/expat-${version}.tar.bz2"; - sha256 = "1zq4lnwjlw8s9mmachwfvfjf2x3lk24jm41746ykhdcvs7r0zrfr"; - }; - - patches = [ - ./cve-2016-0718.patch - ]; - - builder = ./builder.sh; -} diff --git a/nix/nixcrpkgs/pkgs/fixesproto/builder.sh b/nix/nixcrpkgs/pkgs/fixesproto/builder.sh deleted file mode 100644 index 4d91d6e9f3..0000000000 --- a/nix/nixcrpkgs/pkgs/fixesproto/builder.sh +++ /dev/null @@ -1,16 +0,0 @@ -source $setup - -cp -r $src src -chmod -R u+w src -cd src -autoreconf -v --install -cd .. - -mkdir build -cd build - -../src/configure --prefix=$out -make -make install - -ln -sf $xextproto/lib/pkgconfig/*.pc $out/lib/pkgconfig diff --git a/nix/nixcrpkgs/pkgs/fixesproto/default.nix b/nix/nixcrpkgs/pkgs/fixesproto/default.nix deleted file mode 100644 index 49936287eb..0000000000 --- a/nix/nixcrpkgs/pkgs/fixesproto/default.nix +++ /dev/null @@ -1,41 +0,0 @@ -{ crossenv, xorg-macros, xextproto }: - -let - version = "2017-01-26"; - - name = "fixesproto-${version}"; - - src = crossenv.nixpkgs.fetchgit { - url = "https://anongit.freedesktop.org/git/xorg/proto/fixesproto"; - rev = "4292ec1c63180c5f4e7c0e606fa68c51913f172b"; - sha256 = "0mmx4cmkbrsmbq1j58g8gcx4h3qz9y4xbjpz7jcl7crki7zrz3kx"; - }; - - lib = crossenv.native.make_derivation rec { - inherit version name src; - - builder = ./builder.sh; - - native_inputs = [ - crossenv.nixpkgs.autoconf - crossenv.nixpkgs.automake - ]; - - ACLOCAL_PATH = "${xorg-macros}/lib/aclocal"; - - inherit xextproto; - }; - - license = crossenv.native.make_derivation { - name = "${name}-license"; - inherit src; - builder = ./license_builder.sh; - }; - - license_set = - xorg-macros.license_set // - xextproto.license_set // - { "${name}" = license; }; - -in - lib // { inherit license_set; } diff --git a/nix/nixcrpkgs/pkgs/fixesproto/license_builder.sh b/nix/nixcrpkgs/pkgs/fixesproto/license_builder.sh deleted file mode 100644 index 8e347c3613..0000000000 --- a/nix/nixcrpkgs/pkgs/fixesproto/license_builder.sh +++ /dev/null @@ -1,11 +0,0 @@ -source $setup - -license=$(cat $src/COPYING) - -cat > $out <fixesproto - -
-$license
-
-EOF diff --git a/nix/nixcrpkgs/pkgs/gdb/builder.sh b/nix/nixcrpkgs/pkgs/gdb/builder.sh deleted file mode 100644 index 8133f5199d..0000000000 --- a/nix/nixcrpkgs/pkgs/gdb/builder.sh +++ /dev/null @@ -1,31 +0,0 @@ -source $setup - -tar -xf $src - -cd gdb-$version -for patch in $patches -do - echo applying patch $patch - patch -p1 -i $patch -done -cd .. - -mkdir build -cd build - -export LDFLAGS="-L$curses/lib" -export CFLAGS="-I$curses/include" -export CXXFLAGS="-I$curses/include" - -../gdb-$version/configure \ - --prefix=$out \ - --host=$host \ - --target=$host \ - --with-expat=yes --with-libexpat-prefix=$expat \ - --enable-tui \ - --disable-win32-registry \ - --disable-rpath - -make - -make install diff --git a/nix/nixcrpkgs/pkgs/gdb/default.nix b/nix/nixcrpkgs/pkgs/gdb/default.nix deleted file mode 100644 index 43378cb681..0000000000 --- a/nix/nixcrpkgs/pkgs/gdb/default.nix +++ /dev/null @@ -1,38 +0,0 @@ -# Note: This package has only been tested on Windows, and the pdcurses library -# it uses does not support Linux in console mode or mac OS X. - -# Note: GDB has a bundled copy of readline that it uses. -# There is a --with-system-readline option we could try to use. - -# Note: consider providing a mingw-w64 isl to gdb because its configure script looks for it - -{ crossenv, expat, curses }: - -crossenv.make_derivation rec { - name = "gdb-${version}"; - - version = "7.12.1"; - - src = crossenv.nixpkgs.fetchurl { - url = "https://ftp.gnu.org/gnu/gdb/gdb-${version}.tar.xz"; - sha256 = "11ii260h1sd7v0bs3cz6d5l8gqxxgldry0md60ncjgixjw5nh1s6"; - }; - - patches = [ - # Make GCC better at finding source files. - # https://sourceware.org/ml/gdb-patches/2017-02/msg00693.html - ./substitute-path-all-filenames.patch - ]; - - native_inputs = [ - crossenv.nixpkgs.texinfo - crossenv.nixpkgs.bison - crossenv.nixpkgs.yacc - crossenv.nixpkgs.m4 - crossenv.nixpkgs.flex - ]; - - inherit expat curses; - - builder = ./builder.sh; -} diff --git a/nix/nixcrpkgs/pkgs/gdb/substitute-path-all-filenames.patch b/nix/nixcrpkgs/pkgs/gdb/substitute-path-all-filenames.patch deleted file mode 100644 index f1821a772d..0000000000 --- a/nix/nixcrpkgs/pkgs/gdb/substitute-path-all-filenames.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff -ur gdb-7.12.1-orig/gdb/source.c gdb-7.12.1/gdb/source.c ---- gdb-7.12.1-orig/gdb/source.c 2017-02-24 19:33:13.340349333 -0800 -+++ gdb-7.12.1/gdb/source.c 2017-02-24 19:34:40.660349333 -0800 -@@ -1103,10 +1103,7 @@ - } - } - -- if (IS_ABSOLUTE_PATH (filename)) - { -- /* If filename is absolute path, try the source path -- substitution on it. */ - char *rewritten_filename = rewrite_source_path (filename); - - if (rewritten_filename != NULL) diff --git a/nix/nixcrpkgs/pkgs/hello/builder.sh b/nix/nixcrpkgs/pkgs/hello/builder.sh deleted file mode 100644 index 36c57adc7d..0000000000 --- a/nix/nixcrpkgs/pkgs/hello/builder.sh +++ /dev/null @@ -1,7 +0,0 @@ -source $setup - -$host-gcc $src_file -o hello$exe_suffix - -mkdir -p $out/bin - -cp hello$exe_suffix $out/bin/ diff --git a/nix/nixcrpkgs/pkgs/hello/default.nix b/nix/nixcrpkgs/pkgs/hello/default.nix deleted file mode 100644 index c8e4d5208a..0000000000 --- a/nix/nixcrpkgs/pkgs/hello/default.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ crossenv }: - -crossenv.make_derivation rec { - name = "hello"; - src_file = ./hello.c; - builder = ./builder.sh; -} diff --git a/nix/nixcrpkgs/pkgs/hello/hello.c b/nix/nixcrpkgs/pkgs/hello/hello.c deleted file mode 100644 index 98e2277bc6..0000000000 --- a/nix/nixcrpkgs/pkgs/hello/hello.c +++ /dev/null @@ -1,15 +0,0 @@ -#include - -#ifdef _WIN32 -#include -#endif - -int main(int argc, char ** argv) -{ - printf("Hello, World!\n"); - -#ifdef _WIN32 - MessageBoxA(NULL, "Hello, World!", "Hello", MB_OK); -#endif - return 0; -} diff --git a/nix/nixcrpkgs/pkgs/hello_cpp/builder.sh b/nix/nixcrpkgs/pkgs/hello_cpp/builder.sh deleted file mode 100644 index dae159775d..0000000000 --- a/nix/nixcrpkgs/pkgs/hello_cpp/builder.sh +++ /dev/null @@ -1,8 +0,0 @@ -. $setup - -$host-g++ $src_file -o hello$exe_suffix - -mkdir -p $out/bin/ - -cp hello$exe_suffix $out/bin/ - diff --git a/nix/nixcrpkgs/pkgs/hello_cpp/default.nix b/nix/nixcrpkgs/pkgs/hello_cpp/default.nix deleted file mode 100644 index 8f35d0b6f0..0000000000 --- a/nix/nixcrpkgs/pkgs/hello_cpp/default.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ crossenv }: - -crossenv.make_derivation rec { - name = "hello_cpp"; - src_file = ./hello.cpp; - builder = ./builder.sh; -} diff --git a/nix/nixcrpkgs/pkgs/hello_cpp/hello.cpp b/nix/nixcrpkgs/pkgs/hello_cpp/hello.cpp deleted file mode 100644 index d081ace709..0000000000 --- a/nix/nixcrpkgs/pkgs/hello_cpp/hello.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include - -#ifdef _WIN32 -#include -#endif - -int main(int argc, char ** argv) -{ - std::cout << "hello world" << std::endl; - -#ifdef _WIN32 - MessageBoxA(NULL, "Hello world", "Hello Box", MB_OK); -#endif - return 0; -} diff --git a/nix/nixcrpkgs/pkgs/inputproto/builder.sh b/nix/nixcrpkgs/pkgs/inputproto/builder.sh deleted file mode 100644 index ff349bbcd3..0000000000 --- a/nix/nixcrpkgs/pkgs/inputproto/builder.sh +++ /dev/null @@ -1,13 +0,0 @@ -source $setup - -tar -xf $src -mv inputproto-* proto - -mkdir build -cd build - -../proto/configure --prefix=$out - -make - -make install diff --git a/nix/nixcrpkgs/pkgs/inputproto/default.nix b/nix/nixcrpkgs/pkgs/inputproto/default.nix deleted file mode 100644 index 7c384049dc..0000000000 --- a/nix/nixcrpkgs/pkgs/inputproto/default.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ crossenv }: - -let - version = "2.3.2"; - - name = "inputproto-${version}"; - - src = crossenv.nixpkgs.fetchurl { - url = "https://xorg.freedesktop.org/releases/individual/proto/inputproto-${version}.tar.bz2"; - sha256 = "07gk7v006zqn3dcfh16l06gnccy7xnqywf3vl9c209ikazsnlfl9"; - }; - - lib = crossenv.native.make_derivation rec { - inherit version name src; - builder = ./builder.sh; - }; - - license = crossenv.native.make_derivation { - name = "${name}-license"; - inherit src; - builder = ./license_builder.sh; - }; - - license_set = { "${name}" = license; }; - -in - lib // { inherit license_set; } diff --git a/nix/nixcrpkgs/pkgs/inputproto/license_builder.sh b/nix/nixcrpkgs/pkgs/inputproto/license_builder.sh deleted file mode 100644 index aad143efb6..0000000000 --- a/nix/nixcrpkgs/pkgs/inputproto/license_builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -mv inputproto-* inputproto - -license=$(cat inputproto/COPYING) - -cat > $out <inputproto - -
-$license
-
-EOF diff --git a/nix/nixcrpkgs/pkgs/ion/builder.sh b/nix/nixcrpkgs/pkgs/ion/builder.sh deleted file mode 100644 index 6ac7950a25..0000000000 --- a/nix/nixcrpkgs/pkgs/ion/builder.sh +++ /dev/null @@ -1,20 +0,0 @@ -source $setup - -tar -xf $src -mv bitwise-* bitwise - -mkdir build -cd build - -$host-gcc -O2 ../bitwise/ion/main.c -o ion$exe_suffix \ - -DIONHOME=\"$out/ionhome\" - -# TODO: make -DIONHOME actually work - -mkdir $out - -mkdir $out/bin -mv ion$exe_suffix $out/bin/ - -mkdir $out/ionhome -mv ../bitwise/ion/system_packages $out/ionhome/ diff --git a/nix/nixcrpkgs/pkgs/ion/default.nix b/nix/nixcrpkgs/pkgs/ion/default.nix deleted file mode 100644 index 222f6c8856..0000000000 --- a/nix/nixcrpkgs/pkgs/ion/default.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ crossenv }: - -# TODO: SDL integration would be nice, so we can use noir.ion - -let - version = "7524dc7"; # 2018-04-30 - - name = "ion-${version}"; - - src = crossenv.nixpkgs.fetchurl { - url = "https://github.com/DavidEGrayson/bitwise/archive/${version}.tar.gz"; - sha256 = "169j7yhphvcyfbqgi5p1i4lhd9n5a31n99fv2kxyrh7djmr8g2s9"; - }; - - ion = crossenv.make_derivation { - inherit version name src; - builder = ./builder.sh; - }; - -in - ion diff --git a/nix/nixcrpkgs/pkgs/kbproto/builder.sh b/nix/nixcrpkgs/pkgs/kbproto/builder.sh deleted file mode 100644 index 3f21643e88..0000000000 --- a/nix/nixcrpkgs/pkgs/kbproto/builder.sh +++ /dev/null @@ -1,13 +0,0 @@ -source $setup - -tar -xf $src -mv kbproto-* proto - -mkdir build -cd build - -../proto/configure --prefix=$out - -make - -make install diff --git a/nix/nixcrpkgs/pkgs/kbproto/default.nix b/nix/nixcrpkgs/pkgs/kbproto/default.nix deleted file mode 100644 index 6af2fcf908..0000000000 --- a/nix/nixcrpkgs/pkgs/kbproto/default.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ crossenv }: - -let - version = "1.0.7"; - - name = "kbproto-${version}"; - - src = crossenv.nixpkgs.fetchurl { - url = "https://xorg.freedesktop.org/releases/individual/proto/kbproto-${version}.tar.bz2"; - sha256 = "0mxqj1pzhjpz9495vrjnpi10kv2n1s4vs7di0sh3yvipfq5j30pq"; - }; - - lib = crossenv.native.make_derivation rec { - inherit version name src; - builder = ./builder.sh; - }; - - license = crossenv.native.make_derivation { - name = "${name}-license"; - inherit src; - builder = ./license_builder.sh; - }; - - license_set = { "${name}" = license; }; - -in - lib // { inherit license_set; } diff --git a/nix/nixcrpkgs/pkgs/kbproto/license_builder.sh b/nix/nixcrpkgs/pkgs/kbproto/license_builder.sh deleted file mode 100644 index 65776595af..0000000000 --- a/nix/nixcrpkgs/pkgs/kbproto/license_builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -mv kbproto-* kbproto - -license=$(cat kbproto/COPYING) - -cat > $out <kbproto - -
-$license
-
-EOF diff --git a/nix/nixcrpkgs/pkgs/libgmp/builder.sh b/nix/nixcrpkgs/pkgs/libgmp/builder.sh deleted file mode 100644 index c284c9a5f1..0000000000 --- a/nix/nixcrpkgs/pkgs/libgmp/builder.sh +++ /dev/null @@ -1,9 +0,0 @@ -source $setup - -tar -xf $src - -mkdir build -cd build -../gmp-$version/configure --host=$host --prefix=$out --disable-shared -make -make install diff --git a/nix/nixcrpkgs/pkgs/libgmp/default.nix b/nix/nixcrpkgs/pkgs/libgmp/default.nix deleted file mode 100644 index 52af7aefbc..0000000000 --- a/nix/nixcrpkgs/pkgs/libgmp/default.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ crossenv }: - -crossenv.make_derivation rec { - name = "gmp-${version}"; - version = "6.1.2"; - builder = ./builder.sh; - native_inputs = [ crossenv.nixpkgs.m4 ]; - - src = crossenv.nixpkgs.fetchurl { - urls = [ "mirror://gnu/gmp/${name}.tar.bz2" - "ftp://ftp.gmplib.org/pub/${name}/${name}.tar.bz2" - ]; - sha256 = "1clg7pbpk6qwxj5b2mw0pghzawp2qlm3jf9gdd8i6fl6yh2bnxaj"; - }; - -} diff --git a/nix/nixcrpkgs/pkgs/libsigsegv/builder.sh b/nix/nixcrpkgs/pkgs/libsigsegv/builder.sh deleted file mode 100644 index f5e7072de6..0000000000 --- a/nix/nixcrpkgs/pkgs/libsigsegv/builder.sh +++ /dev/null @@ -1,50 +0,0 @@ -source $setup - -tar -xf $src - -cd libsigsegv-$version -patch -p1 << 'PATCH_I386' ---- a/src/fault-linux-i386.h 2020-06-25 23:46:02.099235491 +0000 -+++ b/src/fault-linux-i386.h 2020-06-25 23:45:48.679156892 +0000 -@@ -18,6 +18,7 @@ - - #include "fault-posix-ucontext.h" - -+#define HAVE_STACKVMA 0 - #if defined __x86_64__ - /* 64 bit registers */ - -PATCH_I386 -patch -p1 << 'PATCH_ARM' ---- a/src/fault-linux-arm.h -+++ b/src/fault-linux-arm.h -@@ -17,6 +17,7 @@ - - #include "fault-posix-ucontext.h" - -+#define HAVE_STACKVMA 0 - #if defined(__aarch64__) || defined(__ARM_64BIT_STATE) || defined(__ARM_PCS_AAPCS64) /* 64-bit */ - - /* See glibc/sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h. - -PATCH_ARM -cd .. - -mkdir build -cd build - -# Hack -if [ $host = aarch64-linux-musleabi ] -then - sed -i 's/^CFG_FAULT=$/CFG_FAULT=fault-linux-arm.h/' \ - ../libsigsegv-$version/configure -fi - -../libsigsegv-$version/configure \ - --host=$host \ - --prefix=$out \ - --enable-static=yes \ - --enable-shared=no - -make -make install diff --git a/nix/nixcrpkgs/pkgs/libsigsegv/default.nix b/nix/nixcrpkgs/pkgs/libsigsegv/default.nix deleted file mode 100644 index 60e8c7b6a8..0000000000 --- a/nix/nixcrpkgs/pkgs/libsigsegv/default.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ crossenv }: - -crossenv.make_derivation rec { - name = "libsigsegv-${version}"; - version = "2.12"; - - src = crossenv.nixpkgs.fetchurl { - url = "mirror://gnu/libsigsegv/${name}.tar.gz"; - sha256 = "1dlhqf4igzpqayms25lkhycjq1ccavisx8cnb3y4zapbkqsszq9s"; - }; - - builder = ./builder.sh; -} diff --git a/nix/nixcrpkgs/pkgs/libudev/builder.sh b/nix/nixcrpkgs/pkgs/libudev/builder.sh deleted file mode 100644 index aad209a221..0000000000 --- a/nix/nixcrpkgs/pkgs/libudev/builder.sh +++ /dev/null @@ -1,71 +0,0 @@ -source $setup - -tar -xf $src -mv systemd-* systemd - -cd systemd -for patch in $patches; do - echo applying patch $patch - patch -p1 -i $patch -done -cd .. - -$host-g++ -x c++ -c $size_flags - -o test.o < -#include -#include -static_assert(sizeof(pid_t) == SIZEOF_PID_T); -static_assert(sizeof(uid_t) == SIZEOF_UID_T); -static_assert(sizeof(gid_t) == SIZEOF_GID_T); -static_assert(sizeof(time_t) == SIZEOF_TIME_T); -static_assert(sizeof(rlim_t) == SIZEOF_RLIM_T); -static_assert(sizeof(dev_t) == SIZEOF_DEV_T); -static_assert(sizeof(ino_t) == SIZEOF_INO_T); -EOF - -rm test.o - -mkdir build -cd build - -# -DHAVE_SECURE_GETENV: We don't have secure_getenv but we want to avoid a header error, -# and hopefully secure_getenv isn't actually needed by libudev. - -$host-gcc -c -Werror -I$fill $fill/*.c -$host-gcc -c $CFLAGS \ - -I../systemd/src/libudev \ - -I../systemd/src/basic \ - -I../systemd/src/libsystemd/sd-device \ - -I../systemd/src/libsystemd/sd-hwdb \ - -I../systemd/src/systemd \ - ../systemd/src/libudev/*.c -$host-gcc -c $CFLAGS \ - -I../systemd/src/libsystemd/sd-device \ - -I../systemd/src/basic \ - -I../systemd/src/systemd \ - ../systemd/src/libsystemd/sd-device/{device-enumerator,device-private,sd-device}.c -$host-gcc -c $CFLAGS \ - -DPACKAGE_STRING="\"libudev $version\"" \ - -DFALLBACK_HOSTNAME="\"localhost\"" \ - -DDEFAULT_HIERARCHY_NAME="\"hybrid\"" \ - -DDEFAULT_HIERARCHY=CGROUP_UNIFIED_SYSTEMD \ - -I../systemd/src/basic \ - -I../systemd/src/systemd \ - -I$fill \ - ../systemd/src/basic/{alloc-util,architecture,bus-label,cgroup-util,device-nodes,dirent-util,env-util,escape,extract-word,fd-util,fileio,fs-util,gunicode,glob-util,hashmap,hash-funcs,hexdecoct,hostname-util,io-util,log,login-util,mempool,mkdir,path-util,proc-cmdline,parse-util,prioq,process-util,random-util,signal-util,siphash24,socket-util,stat-util,string-table,string-util,strv,strxcpyx,syslog-util,terminal-util,time-util,unit-name,user-util,utf8,util,virt,MurmurHash2}.c -$host-ar cr libudev.a *.o - -mkdir -p $out/lib/pkgconfig $out/include -cp libudev.a $out/lib/ -cp ../systemd/src/libudev/libudev.h $out/include/ - -cat > $out/lib/pkgconfig/libudev.pc < - - With parts from the musl C library - Copyright 2005-2014 Rich Felker, et al. - - systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1 of the License, or - (at your option) any later version. - - systemd is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with systemd; If not, see . -***/ - -#include -#include -#include - -static const char *consume_nonarg(const char *fmt) -{ - do { - if (*fmt == '\0') - return fmt; - } while (*fmt++ != '%'); - return fmt; -} - -static const char *consume_num(const char *fmt) -{ - for (;*fmt >= '0' && *fmt <= '9'; fmt++) - /* do nothing */; - return fmt; -} - -static const char *consume_argn(const char *fmt, size_t *arg) -{ - const char *p = fmt; - size_t val = 0; - - if (*p < '1' || *p > '9') - return fmt; - do { - val = 10*val + (*p++ - '0'); - } while (*p >= '0' && *p <= '9'); - - if (*p != '$') - return fmt; - *arg = val; - return p+1; -} - -static const char *consume_flags(const char *fmt) -{ - while (1) { - switch (*fmt) { - case '#': - case '0': - case '-': - case ' ': - case '+': - case '\'': - case 'I': - fmt++; - continue; - } - return fmt; - } -} - -enum state { - BARE, - LPRE, - LLPRE, - HPRE, - HHPRE, - BIGLPRE, - ZTPRE, - JPRE, - STOP -}; - -enum type { - NONE, - PTR, - INT, - UINT, - ULLONG, - LONG, - ULONG, - SHORT, - USHORT, - CHAR, - UCHAR, - LLONG, - SIZET, - IMAX, - UMAX, - PDIFF, - UIPTR, - DBL, - LDBL, - MAXTYPE -}; - -static const short pa_types[MAXTYPE] = { - [NONE] = PA_INT, - [PTR] = PA_POINTER, - [INT] = PA_INT, - [UINT] = PA_INT, - [ULLONG] = PA_INT | PA_FLAG_LONG_LONG, - [LONG] = PA_INT | PA_FLAG_LONG, - [ULONG] = PA_INT | PA_FLAG_LONG, - [SHORT] = PA_INT | PA_FLAG_SHORT, - [USHORT] = PA_INT | PA_FLAG_SHORT, - [CHAR] = PA_CHAR, - [UCHAR] = PA_CHAR, - [LLONG] = PA_INT | PA_FLAG_LONG_LONG, - [SIZET] = PA_INT | PA_FLAG_LONG, - [IMAX] = PA_INT | PA_FLAG_LONG_LONG, - [UMAX] = PA_INT | PA_FLAG_LONG_LONG, - [PDIFF] = PA_INT | PA_FLAG_LONG_LONG, - [UIPTR] = PA_INT | PA_FLAG_LONG, - [DBL] = PA_DOUBLE, - [LDBL] = PA_DOUBLE | PA_FLAG_LONG_DOUBLE -}; - -#define S(x) [(x)-'A'] -#define E(x) (STOP + (x)) - -static const unsigned char states[]['z'-'A'+1] = { - { /* 0: bare types */ - S('d') = E(INT), S('i') = E(INT), - S('o') = E(UINT),S('u') = E(UINT),S('x') = E(UINT), S('X') = E(UINT), - S('e') = E(DBL), S('f') = E(DBL), S('g') = E(DBL), S('a') = E(DBL), - S('E') = E(DBL), S('F') = E(DBL), S('G') = E(DBL), S('A') = E(DBL), - S('c') = E(CHAR),S('C') = E(INT), - S('s') = E(PTR), S('S') = E(PTR), S('p') = E(UIPTR),S('n') = E(PTR), - S('m') = E(NONE), - S('l') = LPRE, S('h') = HPRE, S('L') = BIGLPRE, - S('z') = ZTPRE, S('j') = JPRE, S('t') = ZTPRE - }, { /* 1: l-prefixed */ - S('d') = E(LONG), S('i') = E(LONG), - S('o') = E(ULONG),S('u') = E(ULONG),S('x') = E(ULONG),S('X') = E(ULONG), - S('e') = E(DBL), S('f') = E(DBL), S('g') = E(DBL), S('a') = E(DBL), - S('E') = E(DBL), S('F') = E(DBL), S('G') = E(DBL), S('A') = E(DBL), - S('c') = E(INT), S('s') = E(PTR), S('n') = E(PTR), - S('l') = LLPRE - }, { /* 2: ll-prefixed */ - S('d') = E(LLONG), S('i') = E(LLONG), - S('o') = E(ULLONG),S('u') = E(ULLONG), - S('x') = E(ULLONG),S('X') = E(ULLONG), - S('n') = E(PTR) - }, { /* 3: h-prefixed */ - S('d') = E(SHORT), S('i') = E(SHORT), - S('o') = E(USHORT),S('u') = E(USHORT), - S('x') = E(USHORT),S('X') = E(USHORT), - S('n') = E(PTR), - S('h') = HHPRE - }, { /* 4: hh-prefixed */ - S('d') = E(CHAR), S('i') = E(CHAR), - S('o') = E(UCHAR),S('u') = E(UCHAR), - S('x') = E(UCHAR),S('X') = E(UCHAR), - S('n') = E(PTR) - }, { /* 5: L-prefixed */ - S('e') = E(LDBL),S('f') = E(LDBL),S('g') = E(LDBL), S('a') = E(LDBL), - S('E') = E(LDBL),S('F') = E(LDBL),S('G') = E(LDBL), S('A') = E(LDBL), - S('n') = E(PTR) - }, { /* 6: z- or t-prefixed (assumed to be same size) */ - S('d') = E(PDIFF),S('i') = E(PDIFF), - S('o') = E(SIZET),S('u') = E(SIZET), - S('x') = E(SIZET),S('X') = E(SIZET), - S('n') = E(PTR) - }, { /* 7: j-prefixed */ - S('d') = E(IMAX), S('i') = E(IMAX), - S('o') = E(UMAX), S('u') = E(UMAX), - S('x') = E(UMAX), S('X') = E(UMAX), - S('n') = E(PTR) - } -}; - -size_t parse_printf_format(const char *fmt, size_t n, int *types) -{ - size_t i = 0; - size_t last = 0; - - memset(types, 0, n); - - while (1) { - size_t arg; - unsigned int state; - - fmt = consume_nonarg(fmt); - if (*fmt == '\0') - break; - if (*fmt == '%') { - fmt++; - continue; - } - arg = 0; - fmt = consume_argn(fmt, &arg); - /* flags */ - fmt = consume_flags(fmt); - /* width */ - if (*fmt == '*') { - size_t warg = 0; - fmt = consume_argn(fmt+1, &warg); - if (warg == 0) - warg = ++i; - if (warg > last) - last = warg; - if (warg <= n && types[warg-1] == NONE) - types[warg-1] = INT; - } else - fmt = consume_num(fmt); - /* precision */ - if (*fmt == '.') { - fmt++; - if (*fmt == '*') { - size_t parg = 0; - fmt = consume_argn(fmt+1, &parg); - if (parg == 0) - parg = ++i; - if (parg > last) - last = parg; - if (parg <= n && types[parg-1] == NONE) - types[parg-1] = INT; - } else { - if (*fmt == '-') - fmt++; - fmt = consume_num(fmt); - } - } - /* length modifier and conversion specifier */ - state = BARE; - do { - unsigned char c = *fmt++; - - if (c < 'A' || c > 'z') - continue; - state = states[state]S(c); - if (state == 0) - continue; - } while (state < STOP); - - if (state == E(NONE)) - continue; - - if (arg == 0) - arg = ++i; - if (arg > last) - last = arg; - if (arg <= n) - types[arg-1] = state - STOP; - } - - if (last > n) - last = n; - for (i = 0; i < last; i++) - types[i] = pa_types[types[i]]; - - return last; -} diff --git a/nix/nixcrpkgs/pkgs/libudev/fill/printf.h b/nix/nixcrpkgs/pkgs/libudev/fill/printf.h deleted file mode 100644 index ee64bdca49..0000000000 --- a/nix/nixcrpkgs/pkgs/libudev/fill/printf.h +++ /dev/null @@ -1,50 +0,0 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - -/*** - This file is part of systemd. - - Copyright 2014 Emil Renner Berthing - - With parts from the GNU C Library - Copyright 1991-2014 Free Software Foundation, Inc. - - systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1 of the License, or - (at your option) any later version. - - systemd is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with systemd; If not, see . -***/ - -#pragma once - -#include - -enum { /* C type: */ - PA_INT, /* int */ - PA_CHAR, /* int, cast to char */ - PA_WCHAR, /* wide char */ - PA_STRING, /* const char *, a '\0'-terminated string */ - PA_WSTRING, /* const wchar_t *, wide character string */ - PA_POINTER, /* void * */ - PA_FLOAT, /* float */ - PA_DOUBLE, /* double */ - PA_LAST -}; - -/* Flag bits that can be set in a type returned by `parse_printf_format'. */ -#define PA_FLAG_MASK 0xff00 -#define PA_FLAG_LONG_LONG (1 << 8) -#define PA_FLAG_LONG_DOUBLE PA_FLAG_LONG_LONG -#define PA_FLAG_LONG (1 << 9) -#define PA_FLAG_SHORT (1 << 10) -#define PA_FLAG_PTR (1 << 11) - -size_t parse_printf_format(const char *fmt, size_t n, int *types); - diff --git a/nix/nixcrpkgs/pkgs/libudev/license_builder.sh b/nix/nixcrpkgs/pkgs/libudev/license_builder.sh deleted file mode 100644 index 9b612b976f..0000000000 --- a/nix/nixcrpkgs/pkgs/libudev/license_builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -mv systemd-* systemd - -license=$(cat systemd/LICENSE.LGPL2.1) - -cat > $out <libudev (part of systemd) - -
-$license
-
-EOF diff --git a/nix/nixcrpkgs/pkgs/libudev/megapatch.patch b/nix/nixcrpkgs/pkgs/libudev/megapatch.patch deleted file mode 100644 index a22af551f0..0000000000 --- a/nix/nixcrpkgs/pkgs/libudev/megapatch.patch +++ /dev/null @@ -1,102 +0,0 @@ -diff -ur systemd-234-orig/src/basic/glob-util.c systemd-234/src/basic/glob-util.c ---- systemd-234-orig/src/basic/glob-util.c 2017-07-17 19:46:03.031674662 -0700 -+++ systemd-234/src/basic/glob-util.c 2017-07-22 20:11:56.931514364 -0700 -@@ -31,22 +31,8 @@ - int safe_glob(const char *path, int flags, glob_t *pglob) { - int k; - -- /* We want to set GLOB_ALTDIRFUNC ourselves, don't allow it to be set. */ -- assert(!(flags & GLOB_ALTDIRFUNC)); -- -- if (!pglob->gl_closedir) -- pglob->gl_closedir = (void (*)(void *)) closedir; -- if (!pglob->gl_readdir) -- pglob->gl_readdir = (struct dirent *(*)(void *)) readdir_no_dot; -- if (!pglob->gl_opendir) -- pglob->gl_opendir = (void *(*)(const char *)) opendir; -- if (!pglob->gl_lstat) -- pglob->gl_lstat = lstat; -- if (!pglob->gl_stat) -- pglob->gl_stat = stat; -- - errno = 0; -- k = glob(path, flags | GLOB_ALTDIRFUNC, NULL, pglob); -+ k = glob(path, flags, NULL, pglob); - - if (k == GLOB_NOMATCH) - return -ENOENT; -@@ -66,7 +52,7 @@ - - assert(path); - -- k = safe_glob(path, GLOB_NOSORT|GLOB_BRACE, &g); -+ k = safe_glob(path, GLOB_NOSORT, &g); - if (k == -ENOENT) - return false; - if (k < 0) -@@ -78,7 +64,7 @@ - _cleanup_globfree_ glob_t g = {}; - int k; - -- k = safe_glob(path, GLOB_NOSORT|GLOB_BRACE, &g); -+ k = safe_glob(path, GLOB_NOSORT, &g); - if (k < 0) - return k; - -diff -ur systemd-234-orig/src/basic/missing.h systemd-234/src/basic/missing.h ---- systemd-234-orig/src/basic/missing.h 2017-07-17 19:46:03.031674662 -0700 -+++ systemd-234/src/basic/missing.h 2017-07-21 08:02:12.349505168 -0700 -@@ -40,6 +40,22 @@ - #include - #include - -+static __inline__ char * canonicalize_file_name(const char * path) -+{ -+ return realpath(path, NULL); -+} -+ -+static __inline__ char * strndupa(const char * s, size_t n) -+{ -+ size_t length = strnlen(s, n); -+ char * new_string = (char *)__builtin_alloca(length + 1); -+ new_string[length] = 0; -+ memcpy(new_string, s, length); -+ return new_string; -+} -+ -+typedef int comparison_fn_t(const void *, const void *); -+ - #ifdef HAVE_AUDIT - #include - #endif -@@ -550,7 +566,7 @@ - # ifdef HAVE___SECURE_GETENV - # define secure_getenv __secure_getenv - # else --# error "neither secure_getenv nor __secure_getenv are available" -+# define secure_getenv getenv - # endif - #endif - -diff -ur systemd-234-orig/src/basic/mkdir.c systemd-234/src/basic/mkdir.c ---- systemd-234-orig/src/basic/mkdir.c 2017-07-17 19:46:03.031674662 -0700 -+++ systemd-234/src/basic/mkdir.c 2017-07-22 21:09:51.065274838 -0700 -@@ -28,6 +28,7 @@ - #include "path-util.h" - #include "stat-util.h" - #include "user-util.h" -+#include "missing.h" - - int mkdir_safe_internal(const char *path, mode_t mode, uid_t uid, gid_t gid, mkdir_func_t _mkdir) { - struct stat st; -diff -ur systemd-234-orig/src/basic/parse-util.c systemd-234/src/basic/parse-util.c ---- systemd-234-orig/src/basic/parse-util.c 2017-07-17 19:46:03.031674662 -0700 -+++ systemd-234/src/basic/parse-util.c 2017-07-21 07:59:05.337491775 -0700 -@@ -30,6 +30,7 @@ - #include "parse-util.h" - #include "process-util.h" - #include "string-util.h" -+#include "missing.h" - - int parse_boolean(const char *v) { - assert(v); diff --git a/nix/nixcrpkgs/pkgs/libusb/builder.sh b/nix/nixcrpkgs/pkgs/libusb/builder.sh deleted file mode 100644 index 211ee465a0..0000000000 --- a/nix/nixcrpkgs/pkgs/libusb/builder.sh +++ /dev/null @@ -1,27 +0,0 @@ -source $setup - -tar -xf $src -mv libusb-* libusb - -mkdir build -cd build - -if [ -n "$libudev" ]; then - export CFLAGS="${CFLAGS:=} -isystem $libudev/include" - export LDFLAGS="${LDFLAGS:=} -L$libudev/lib" -fi - -../libusb/configure \ - --prefix=$out \ - --host=$host \ - --enable-static \ - --disable-shared - -make - -make install - -if [ -n "$libudev" ]; then - ln -s $libudev/lib/pkgconfig/*.pc $out/lib/pkgconfig/ - echo "Requires: libudev" >> $out/lib/pkgconfig/libusb-1.0.pc -fi diff --git a/nix/nixcrpkgs/pkgs/libusb/default.nix b/nix/nixcrpkgs/pkgs/libusb/default.nix deleted file mode 100644 index 3edc45f0b8..0000000000 --- a/nix/nixcrpkgs/pkgs/libusb/default.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ crossenv, libudev }: - -let - version = "1.0.22"; - - name = "libusbp-${version}"; - - src = crossenv.nixpkgs.fetchurl { - url = "https://github.com/libusb/libusb/releases/download/v1.0.22/libusb-1.0.22.tar.bz2"; - sha256 = "0mw1a5ss4alg37m6bd4k44v35xwrcwp5qm4s686q1nsgkbavkbkm"; - }; - - lib = crossenv.make_derivation { - inherit version name src; - builder = ./builder.sh; - libudev = if crossenv.os == "linux" then libudev else null; - }; - -in - lib diff --git a/nix/nixcrpkgs/pkgs/libusbp/builder.sh b/nix/nixcrpkgs/pkgs/libusbp/builder.sh deleted file mode 100644 index f117fa5783..0000000000 --- a/nix/nixcrpkgs/pkgs/libusbp/builder.sh +++ /dev/null @@ -1,23 +0,0 @@ -source $setup - -tar -xf $src -mv libusbp-* libusbp - -mkdir build -cd build - -cmake-cross ../libusbp \ - -DCMAKE_INSTALL_PREFIX=$out \ - -DBUILD_SHARED_LIBS=false - -make - -make install - -if [ -d $out/bin ]; then - find $out/bin -type f -exec $host-strip {} + -fi - -if [ -n "$libudev" ]; then - ln -s $libudev/lib/pkgconfig/*.pc $out/lib/pkgconfig/ -fi diff --git a/nix/nixcrpkgs/pkgs/libusbp/default.nix b/nix/nixcrpkgs/pkgs/libusbp/default.nix deleted file mode 100644 index 75c58a2416..0000000000 --- a/nix/nixcrpkgs/pkgs/libusbp/default.nix +++ /dev/null @@ -1,43 +0,0 @@ -{ crossenv, libudev }: - -let - version = "1.1.0"; - - name = "libusbp-${version}"; - - src = crossenv.nixpkgs.fetchurl { - url = "https://github.com/pololu/libusbp/archive/${version}.tar.gz"; - sha256 = "18l34580ci1pq8p3133dnp8nzlz17qw2796xsz1gn0aca6978izc"; - }; - - lib = crossenv.make_derivation { - inherit version name src; - builder = ./builder.sh; - - cross_inputs = - if crossenv.os == "linux" then - [ libudev ] - else - []; - - libudev = if crossenv.os == "linux" then libudev else null; - }; - - examples = crossenv.make_derivation { - name = "${name}-examples"; - inherit src version; - builder = ./examples_builder.sh; - cross_inputs = [ lib ]; - }; - - license = crossenv.native.make_derivation { - name = "${name}-license"; - inherit src; - builder = ./license_builder.sh; - }; - - license_set = - (if crossenv.os == "linux" then libudev.license_set else {}) // - { "${name}" = license; }; -in - lib // { inherit examples license_set; } diff --git a/nix/nixcrpkgs/pkgs/libusbp/examples_builder.sh b/nix/nixcrpkgs/pkgs/libusbp/examples_builder.sh deleted file mode 100644 index 563608be01..0000000000 --- a/nix/nixcrpkgs/pkgs/libusbp/examples_builder.sh +++ /dev/null @@ -1,15 +0,0 @@ -source $setup - -tar -xf $src -mv libusbp-* libusbp - -mkdir build -cd build - -FLAGS="-std=gnu++11 $(pkg-config-cross --cflags --libs libusbp-1)" - -$host-g++ ../libusbp/examples/lsusb/*.cpp -o lsusb$exe_suffix $FLAGS -$host-g++ ../libusbp/examples/lsport/*.cpp -o lsport$exe_suffix $FLAGS - -mkdir -p $out/bin -cp * $out/bin/ diff --git a/nix/nixcrpkgs/pkgs/libusbp/license_builder.sh b/nix/nixcrpkgs/pkgs/libusbp/license_builder.sh deleted file mode 100644 index 93111231a0..0000000000 --- a/nix/nixcrpkgs/pkgs/libusbp/license_builder.sh +++ /dev/null @@ -1,20 +0,0 @@ -source $setup - -tar -xf $src -mv libusbp-* libusbp - -license=$(cat libusbp/LICENSE.txt) - -{ - cat > $out <Pololu USB library (libusbp) - -

- The Pololu USB Library (libusbp) is licensed under the following license: -

- -
-$license
-
-EOF -} > $out diff --git a/nix/nixcrpkgs/pkgs/libx11/builder.sh b/nix/nixcrpkgs/pkgs/libx11/builder.sh deleted file mode 100644 index 9f46ef8aca..0000000000 --- a/nix/nixcrpkgs/pkgs/libx11/builder.sh +++ /dev/null @@ -1,24 +0,0 @@ -source $setup - -tar -xf $src -mv libX11-* libx11 - -mkdir build -cd build - -PKG_CONFIG=pkg-config-cross \ -../libx11/configure --prefix $out $configure_flags - -make - -make install - -# Make static linking work. -sed -i 's/Requires.private/Requires/' $out/lib/pkgconfig/*.pc - -ln -s x11-xcb.pc $out/lib/pkgconfig/X11-xcb.pc -ln -s x11.pc $out/lib/pkgconfig/X11.pc - -ln -sf $xproto/lib/pkgconfig/*.pc $out/lib/pkgconfig/ -ln -sf $kbproto/lib/pkgconfig/*.pc $out/lib/pkgconfig/ -ln -sf $libxcb/lib/pkgconfig/*.pc $out/lib/pkgconfig/ diff --git a/nix/nixcrpkgs/pkgs/libx11/default.nix b/nix/nixcrpkgs/pkgs/libx11/default.nix deleted file mode 100644 index a20b63f757..0000000000 --- a/nix/nixcrpkgs/pkgs/libx11/default.nix +++ /dev/null @@ -1,55 +0,0 @@ -{ crossenv, xorg-macros, xproto, libxcb, xtrans, - xextproto, inputproto, kbproto }: - -let - version = "1.6.5"; - - name = "libx11-${version}"; - - src = crossenv.nixpkgs.fetchurl { - url = "https://xorg.freedesktop.org/releases/individual/libX11-${version}.tar.bz2"; - sha256 = "0pa3cfp6h9rl2vxmkph65250gfqyki0ccqyaan6bl9d25gdr0f2d"; - }; - - lib = crossenv.make_derivation rec { - inherit version name src; - - builder = ./builder.sh; - - configure_flags = - "--host=${crossenv.host} " + - "--disable-malloc0returnsnull " + - "--enable-static " + - "--disable-shared"; - - cross_inputs = [ - xorg-macros - xproto - libxcb - xtrans - xextproto - inputproto - kbproto - ]; - - inherit kbproto xproto libxcb; - }; - - license = crossenv.native.make_derivation { - name = "${name}-license"; - inherit src; - builder = ./license_builder.sh; - }; - - license_set = - xorg-macros.license_set // - xproto.license_set // - libxcb.license_set // - xtrans.license_set // - xextproto.license_set // - inputproto.license_set // - kbproto.license_set // - { "${name}" = license; }; - -in - lib // { inherit license_set; } diff --git a/nix/nixcrpkgs/pkgs/libx11/license_builder.sh b/nix/nixcrpkgs/pkgs/libx11/license_builder.sh deleted file mode 100644 index 030bafd88b..0000000000 --- a/nix/nixcrpkgs/pkgs/libx11/license_builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -mv libX11-* libx11 - -license=$(cat libx11/COPYING) - -cat > $out <libx11 - -
-$license
-
-EOF diff --git a/nix/nixcrpkgs/pkgs/libxall/builder.rb b/nix/nixcrpkgs/pkgs/libxall/builder.rb deleted file mode 100644 index f7937666aa..0000000000 --- a/nix/nixcrpkgs/pkgs/libxall/builder.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'pathname' -require 'fileutils' -include FileUtils - -OutDir = Pathname(ENV.fetch('out')) -LibDirs = ENV.fetch('libs').split(' ').map { |s| Pathname(s) } - -def symlink_file(target, dest) - real_target = target.realpath - - if dest.exist? - if !dest.symlink? - raise "Want to link #{dest} (to #{target}) " \ - "but it already exists and is not a symlink." - end - - current_target = dest.readlink - if current_target != real_target - raise "Conflict: #{dest} links to #{current_target} " \ - "but we want to link it to #{real_target}." - end - else - dest.make_symlink(real_target) - end -end - -def recursive_symlink(target, dest) - if target.directory? - dest.mkdir if !dest.directory? - target.children(false).each do |c| - recursive_symlink(target + c, dest + c) - end - else - symlink_file(target, dest) - end -end - -LibDirs.each do |libdir| - recursive_symlink(libdir, OutDir) -end diff --git a/nix/nixcrpkgs/pkgs/libxall/default.nix b/nix/nixcrpkgs/pkgs/libxall/default.nix deleted file mode 100644 index f570802ea7..0000000000 --- a/nix/nixcrpkgs/pkgs/libxall/default.nix +++ /dev/null @@ -1,15 +0,0 @@ -# Amalgamates all of our X libraries into one derivation to make it easier to -# build projects like Qt that expect them all to be installed in one place. - -{ crossenv, libs }: - -let - lib = crossenv.make_derivation { - name = "libxall"; - builder.ruby = ./builder.rb; - inherit libs; - }; - - license_set = builtins.foldl' (x: y: x // y) {} (map (x: x.license_set) libs); -in - lib // { inherit license_set; } diff --git a/nix/nixcrpkgs/pkgs/libxau/builder.sh b/nix/nixcrpkgs/pkgs/libxau/builder.sh deleted file mode 100644 index b1dd74899f..0000000000 --- a/nix/nixcrpkgs/pkgs/libxau/builder.sh +++ /dev/null @@ -1,16 +0,0 @@ -source $setup - -tar -xf $src -mv libXau-* libxau - -mkdir build -cd build - -PKG_CONFIG=pkg-config-cross \ -../libxau/configure --prefix=$out $configure_flags - -make - -make install - -ln -s $xproto/lib/pkgconfig/xproto.pc $out/lib/pkgconfig/ diff --git a/nix/nixcrpkgs/pkgs/libxau/default.nix b/nix/nixcrpkgs/pkgs/libxau/default.nix deleted file mode 100644 index fcfabbb0cd..0000000000 --- a/nix/nixcrpkgs/pkgs/libxau/default.nix +++ /dev/null @@ -1,40 +0,0 @@ -{ crossenv, xorg-macros, xproto }: - -let - version = "1.0.8"; - - name = "libxau-${version}"; - - src = crossenv.nixpkgs.fetchurl { - url = "https://www.x.org/archive/individual/lib/libXau-${version}.tar.bz2"; - sha256 = "1wm4pv12f36cwzhldpp7vy3lhm3xdcnp4f184xkxsp7b18r7gm7x"; - }; - - lib = crossenv.make_derivation rec { - inherit version name src; - - builder = ./builder.sh; - - configure_flags = - "--host=${crossenv.host} " + - "--enable-static " + - "--disable-shared"; - - cross_inputs = [ xorg-macros xproto ]; - - inherit xproto; - }; - - license = crossenv.native.make_derivation { - name = "${name}-license"; - inherit src; - builder = ./license_builder.sh; - }; - - license_set = - xorg-macros.license_set // - xproto.license_set // - { "${name}" = license; }; - -in - lib // { inherit license_set; } diff --git a/nix/nixcrpkgs/pkgs/libxau/license_builder.sh b/nix/nixcrpkgs/pkgs/libxau/license_builder.sh deleted file mode 100644 index fb3825f7a4..0000000000 --- a/nix/nixcrpkgs/pkgs/libxau/license_builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -mv libXau-* libxau - -license=$(cat libxau/COPYING) - -cat > $out <libxau - -
-$license
-
-EOF diff --git a/nix/nixcrpkgs/pkgs/libxcb/builder.sh b/nix/nixcrpkgs/pkgs/libxcb/builder.sh deleted file mode 100644 index 19162ca987..0000000000 --- a/nix/nixcrpkgs/pkgs/libxcb/builder.sh +++ /dev/null @@ -1,28 +0,0 @@ -source $setup - -tar -xf $src -mv libxcb-* libxcb - -cd libxcb -for patch in $patches; do - echo applying patch $patch - patch -p1 -i $patch -done -cd .. - -mkdir build -cd build - -PKG_CONFIG=pkg-config-cross \ -../libxcb/configure --prefix=$out $configure_flags - -make - -make install - -# Make static linking work. -sed -i 's/Requires.private/Requires/' $out/lib/pkgconfig/*.pc -sed -i 's/Libs.private/Libs/' $out/lib/pkgconfig/*.pc - -ln -sf $libxau/lib/pkgconfig/*.pc $out/lib/pkgconfig/ - diff --git a/nix/nixcrpkgs/pkgs/libxcb/default.nix b/nix/nixcrpkgs/pkgs/libxcb/default.nix deleted file mode 100644 index d927f15557..0000000000 --- a/nix/nixcrpkgs/pkgs/libxcb/default.nix +++ /dev/null @@ -1,56 +0,0 @@ -{ crossenv, xcb-proto, libxau }: - -let - version = "1.12"; - - name = "libxcb-${version}"; - - src = crossenv.nixpkgs.fetchurl { - url = "https://xcb.freedesktop.org/dist/libxcb-${version}.tar.bz2"; - sha256 = "0nvv0la91cf8p5qqlb3r5xnmg1jn2wphn4fb5jfbr6byqsvv3psa"; - }; - - lib = crossenv.make_derivation rec { - inherit version name src; - - patches = [ ./no-pthread-stubs.patch ]; - - builder = ./builder.sh; - - configure_flags = - "--host=${crossenv.host} " + - "--enable-static " + - "--disable-shared " + - "--enable-xinput " + - "--enable-xkb"; - - cross_inputs = [ xcb-proto libxau ]; - - inherit libxau; - - native_inputs = [ crossenv.nixpkgs.python2 ]; - }; - - examples = crossenv.make_derivation rec { - name = "libxcb-examples"; - - builder = ./examples_builder.sh; - - cross_inputs = [ lib ]; - - example1 = ./example1.c; - }; - - license = crossenv.native.make_derivation { - name = "${name}-license"; - inherit src; - builder = ./license_builder.sh; - }; - - license_set = - xcb-proto.license_set // - libxau.license_set // - { "${name}" = license; }; - -in - lib // { inherit examples license_set; } diff --git a/nix/nixcrpkgs/pkgs/libxcb/example1.c b/nix/nixcrpkgs/pkgs/libxcb/example1.c deleted file mode 100644 index 48c2846366..0000000000 --- a/nix/nixcrpkgs/pkgs/libxcb/example1.c +++ /dev/null @@ -1,68 +0,0 @@ -// Source: https://en.wikipedia.org/wiki/XCB#Example - -#include -#include -#include - -int main(void) -{ - xcb_connection_t *c; - xcb_screen_t *s; - xcb_window_t w; - xcb_gcontext_t g; - xcb_generic_event_t *e; - uint32_t mask; - uint32_t values[2]; - int done = 0; - xcb_rectangle_t r = { 20, 20, 60, 60 }; - - /* open connection with the server */ - c = xcb_connect(NULL,NULL); - if (xcb_connection_has_error(c)) { - printf("Cannot open display\n"); - exit(1); - } - /* get the first screen */ - s = xcb_setup_roots_iterator( xcb_get_setup(c) ).data; - - /* create black graphics context */ - g = xcb_generate_id(c); - w = s->root; - mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES; - values[0] = s->black_pixel; - values[1] = 0; - xcb_create_gc(c, g, w, mask, values); - - /* create window */ - w = xcb_generate_id(c); - mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; - values[0] = s->white_pixel; - values[1] = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS; - xcb_create_window(c, s->root_depth, w, s->root, - 10, 10, 100, 100, 1, - XCB_WINDOW_CLASS_INPUT_OUTPUT, s->root_visual, - mask, values); - - /* map (show) the window */ - xcb_map_window(c, w); - - xcb_flush(c); - - /* event loop */ - while (!done && (e = xcb_wait_for_event(c))) { - switch (e->response_type & ~0x80) { - case XCB_EXPOSE: /* draw or redraw the window */ - xcb_poly_fill_rectangle(c, w, g, 1, &r); - xcb_flush(c); - break; - case XCB_KEY_PRESS: /* exit on key press */ - done = 1; - break; - } - free(e); - } - /* close connection to server */ - xcb_disconnect(c); - - return 0; -} diff --git a/nix/nixcrpkgs/pkgs/libxcb/examples_builder.sh b/nix/nixcrpkgs/pkgs/libxcb/examples_builder.sh deleted file mode 100644 index 1a936f7342..0000000000 --- a/nix/nixcrpkgs/pkgs/libxcb/examples_builder.sh +++ /dev/null @@ -1,10 +0,0 @@ -source $setup - -pkg-config-cross xcb --cflags --libs - -$host-gcc -Wall $example1 \ - $(pkg-config-cross xcb --cflags --libs) \ - -o example1$exe_suffix - -mkdir -p $out/bin -cp example1$exe_suffix $out/bin/ diff --git a/nix/nixcrpkgs/pkgs/libxcb/license_builder.sh b/nix/nixcrpkgs/pkgs/libxcb/license_builder.sh deleted file mode 100644 index 31dd9f821e..0000000000 --- a/nix/nixcrpkgs/pkgs/libxcb/license_builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -mv libxcb-* libxcb - -license=$(cat libxcb/COPYING) - -cat > $out <libxcb - -
-$license
-
-EOF diff --git a/nix/nixcrpkgs/pkgs/libxcb/no-pthread-stubs.patch b/nix/nixcrpkgs/pkgs/libxcb/no-pthread-stubs.patch deleted file mode 100644 index 53c66b74e5..0000000000 --- a/nix/nixcrpkgs/pkgs/libxcb/no-pthread-stubs.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -ur libxcb-1.12-orig/configure libxcb-1.12/configure ---- libxcb-1.12-orig/configure 2017-07-29 22:28:37.986987240 -0700 -+++ libxcb-1.12/configure 2017-07-29 22:51:26.410210675 -0700 -@@ -19666,7 +19666,7 @@ - $as_echo "yes" >&6; } - - fi --NEEDED="pthread-stubs xau >= 0.99.2" -+NEEDED="xau >= 0.99.2" - - pkg_failed=no - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for NEEDED" >&5 diff --git a/nix/nixcrpkgs/pkgs/libxext/builder.sh b/nix/nixcrpkgs/pkgs/libxext/builder.sh deleted file mode 100644 index 53bec15525..0000000000 --- a/nix/nixcrpkgs/pkgs/libxext/builder.sh +++ /dev/null @@ -1,19 +0,0 @@ -source $setup - -tar -xf $src -mv libXext-* xext - -mkdir build -cd build - -PKG_CONFIG=pkg-config-cross \ -../xext/configure --prefix=$out $configure_flags - -make - -make install - -sed -i 's/Requires.private/Requires/' $out/lib/pkgconfig/*.pc - -ln -sf $xextproto/lib/pkgconfig/*.pc $out/lib/pkgconfig/ -ln -sf $libx11/lib/pkgconfig/*.pc $out/lib/pkgconfig/ diff --git a/nix/nixcrpkgs/pkgs/libxext/default.nix b/nix/nixcrpkgs/pkgs/libxext/default.nix deleted file mode 100644 index 7cb0295bac..0000000000 --- a/nix/nixcrpkgs/pkgs/libxext/default.nix +++ /dev/null @@ -1,43 +0,0 @@ -{ crossenv, xproto, libx11, xextproto }: - -let - version = "1.3.3"; - - name = "libxext-${version}"; - - src = crossenv.nixpkgs.fetchurl { - url = "https://www.x.org/releases/individual/lib/libXext-${version}.tar.bz2"; - sha256 = "0dbfn5bznnrhqzvkrcmw4c44yvvpwdcsrvzxf4rk27r36b9x865m"; - }; - - lib = crossenv.make_derivation rec { - inherit version name src; - - builder = ./builder.sh; - - configure_flags = - "--host=${crossenv.host} " + - "--disable-malloc0returnsnull " + - "--enable-static " + - "--disable-shared"; - - cross_inputs = [ xproto libx11 xextproto ]; - - inherit xextproto libx11; - }; - - license = crossenv.native.make_derivation { - name = "${name}-license"; - inherit src; - builder = ./license_builder.sh; - }; - - license_set = - xproto.license_set // - libx11.license_set // - xextproto.license_set // - { "${name}" = license; }; - -in - lib // { inherit license_set; } - diff --git a/nix/nixcrpkgs/pkgs/libxext/license_builder.sh b/nix/nixcrpkgs/pkgs/libxext/license_builder.sh deleted file mode 100644 index 9911963100..0000000000 --- a/nix/nixcrpkgs/pkgs/libxext/license_builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -mv libXext-* libxext - -license=$(cat libxext/COPYING) - -cat > $out <libxext - -
-$license
-
-EOF diff --git a/nix/nixcrpkgs/pkgs/libxfixes/builder.sh b/nix/nixcrpkgs/pkgs/libxfixes/builder.sh deleted file mode 100644 index 0217ce743e..0000000000 --- a/nix/nixcrpkgs/pkgs/libxfixes/builder.sh +++ /dev/null @@ -1,20 +0,0 @@ -source $setup - -tar -xf $src -mv libXfixes-* xfixes - -mkdir build -cd build - -PKG_CONFIG=pkg-config-cross \ -../xfixes/configure --prefix=$out $configure_flags - -make - -make install - -sed -i 's/Requires.private/Requires/' $out/lib/pkgconfig/*.pc - -ln -sf $xproto/lib/pkgconfig/*.pc $out/lib/pkgconfig/ -ln -sf $fixesproto/lib/pkgconfig/*.pc $out/lib/pkgconfig/ -ln -sf $libx11/lib/pkgconfig/*.pc $out/lib/pkgconfig/ diff --git a/nix/nixcrpkgs/pkgs/libxfixes/default.nix b/nix/nixcrpkgs/pkgs/libxfixes/default.nix deleted file mode 100644 index fb98228ecb..0000000000 --- a/nix/nixcrpkgs/pkgs/libxfixes/default.nix +++ /dev/null @@ -1,42 +0,0 @@ -{ crossenv, xproto, xextproto, libx11, fixesproto }: - -let - version = "5.0.3"; - - name = "libxfixes-${version}"; - - src = crossenv.nixpkgs.fetchurl { - url = "https://www.x.org/releases/individual/lib/libXfixes-${version}.tar.bz2"; - sha256 = "1miana3y4hwdqdparsccmygqr3ic3hs5jrqfzp70hvi2zwxd676y"; - }; - - lib = crossenv.make_derivation rec { - inherit version name src; - - builder = ./builder.sh; - - configure_flags = - "--host=${crossenv.host} " + - "--enable-static " + - "--disable-shared"; - - cross_inputs = [ xproto xextproto libx11 fixesproto ]; - - inherit xproto libx11 fixesproto; - }; - - license = crossenv.native.make_derivation { - name = "${name}-license"; - inherit src; - builder = ./license_builder.sh; - }; - - license_set = - xproto.license_set // - xextproto.license_set // - libx11.license_set // - fixesproto.license_set // - { "${name}" = license; }; - -in - lib // { inherit license_set; } diff --git a/nix/nixcrpkgs/pkgs/libxfixes/license_builder.sh b/nix/nixcrpkgs/pkgs/libxfixes/license_builder.sh deleted file mode 100644 index 72bd5a2228..0000000000 --- a/nix/nixcrpkgs/pkgs/libxfixes/license_builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -mv libXfixes-* libxfixes - -license=$(cat libxfixes/COPYING) - -cat > $out <libxfixes - -
-$license
-
-EOF diff --git a/nix/nixcrpkgs/pkgs/libxi/builder.sh b/nix/nixcrpkgs/pkgs/libxi/builder.sh deleted file mode 100644 index 8c07f9da26..0000000000 --- a/nix/nixcrpkgs/pkgs/libxi/builder.sh +++ /dev/null @@ -1,21 +0,0 @@ -source $setup - -tar -xf $src -mv libXi-* libxi - -mkdir build -cd build - -PKG_CONFIG=pkg-config-cross \ -../libxi/configure --prefix=$out $configure_flags - -make - -make install - -sed -i 's/Requires.private/Requires/' $out/lib/pkgconfig/*.pc - -ln -sf $inputproto/lib/pkgconfig/*.pc $out/lib/pkgconfig/ -ln -sf $libx11/lib/pkgconfig/*.pc $out/lib/pkgconfig/ -ln -sf $libxext/lib/pkgconfig/*.pc $out/lib/pkgconfig/ -ln -sf $libxfixes/lib/pkgconfig/*.pc $out/lib/pkgconfig/ diff --git a/nix/nixcrpkgs/pkgs/libxi/default.nix b/nix/nixcrpkgs/pkgs/libxi/default.nix deleted file mode 100644 index ab41d41d8d..0000000000 --- a/nix/nixcrpkgs/pkgs/libxi/default.nix +++ /dev/null @@ -1,45 +0,0 @@ -{ crossenv, xproto, xextproto, inputproto, libx11, libxext, libxfixes }: - -let - version = "1.7.9"; - - name = "libxi-${version}"; - - src = crossenv.nixpkgs.fetchurl { - url = "https://www.x.org/releases/individual/lib/libXi-${version}.tar.bz2"; - sha256 = "0idg1wc01hndvaa820fvfs7phvd1ymf0lldmq6386i7rhkzvirn2"; - }; - - lib = crossenv.make_derivation rec { - inherit version name src; - - builder = ./builder.sh; - - configure_flags = - "--host=${crossenv.host} " + - "--disable-malloc0returnsnull " + - "--enable-static " + - "--disable-shared"; - - cross_inputs = [ xproto xextproto inputproto libx11 libxext libxfixes ]; - - inherit inputproto libx11 libxext libxfixes; - }; - - license = crossenv.native.make_derivation { - name = "${name}-license"; - inherit src; - builder = ./license_builder.sh; - }; - - license_set = - xproto.license_set // - xextproto.license_set // - inputproto.license_set // - libx11.license_set // - libxext.license_set // - libxfixes.license_set // - { "${name}" = license; }; - -in - lib // { inherit license_set; } diff --git a/nix/nixcrpkgs/pkgs/libxi/license_builder.sh b/nix/nixcrpkgs/pkgs/libxi/license_builder.sh deleted file mode 100644 index 966f930964..0000000000 --- a/nix/nixcrpkgs/pkgs/libxi/license_builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -mv libXi-* libxi - -license=$(cat libxi/COPYING) - -cat > $out <libxi - -
-$license
-
-EOF diff --git a/nix/nixcrpkgs/pkgs/lmdb/builder.sh b/nix/nixcrpkgs/pkgs/lmdb/builder.sh deleted file mode 100644 index a8d2909d89..0000000000 --- a/nix/nixcrpkgs/pkgs/lmdb/builder.sh +++ /dev/null @@ -1,16 +0,0 @@ -source $setup - -cp -r $src ./src -chmod -R u+w ./src -cd src/libraries/liblmdb - -sed -i 's/liblmdb.a liblmdb..SOEXT.$/liblmdb.a/' Makefile -sed -i "s/gcc/$host-gcc/" Makefile -sed -i "s/ar/$host-ar/" Makefile -sed -i 's/^CC.*/CC = '"$host-gcc/" Makefile - -cat Makefile - -make CFLAGS+="-fPIC" - -make DESTDIR="$out" prefix=/ install diff --git a/nix/nixcrpkgs/pkgs/lmdb/default.nix b/nix/nixcrpkgs/pkgs/lmdb/default.nix deleted file mode 100644 index 140fc16094..0000000000 --- a/nix/nixcrpkgs/pkgs/lmdb/default.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ crossenv }: - -crossenv.make_derivation rec { - name = "lmdb-${version}"; - version = "0.9.23"; - builder = ./builder.sh; - - src = crossenv.nixpkgs.fetchFromGitHub { - owner = "LMDB"; - repo = "lmdb"; - rev = "LMDB_${version}"; - sha256 = "0ag7l5180ajvm73y59m7sn3p52xm8m972d08cshxhpwgwa4v35k6"; - }; -} diff --git a/nix/nixcrpkgs/pkgs/ncurses/builder.sh b/nix/nixcrpkgs/pkgs/ncurses/builder.sh deleted file mode 100644 index d7740f353d..0000000000 --- a/nix/nixcrpkgs/pkgs/ncurses/builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -cd * - -./configure --host=$host --prefix=$out $configureFlags - -make - -make install.{libs,includes,data} - -# TODO Why do I need to do this? -mkdir -p $out/lib/pkgconfig -cp misc/*.pc $out/lib/pkgconfig diff --git a/nix/nixcrpkgs/pkgs/ncurses/default.nix b/nix/nixcrpkgs/pkgs/ncurses/default.nix deleted file mode 100644 index e602b2ec65..0000000000 --- a/nix/nixcrpkgs/pkgs/ncurses/default.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ crossenv }: - -crossenv.make_derivation rec { - name = "ncurses-${version}"; - version = "6.1-20181027"; - builder = ./builder.sh; - - # Needs to be the same version. - native_inputs = [ crossenv.nixpkgs.ncurses ]; - - configureFlags = [ - "--without-debug" - "--enable-pc-files" - "--enable-symlinks" - # "--with-manpage-format=normal" - "--without-cxx" - # "--enable-widec" - ]; - - src = crossenv.nixpkgs.fetchurl { - urls = [ - "https://invisible-mirror.net/archives/ncurses/current/ncurses-${version}.tgz" - "ftp://ftp.invisible-island.net/ncurses/current/ncurses-${version}.tgz" - ]; - sha256 = "1xn6wpi22jc61158w4ifq6s1fvilhmsy1in2srn3plk8pm0d4902"; - }; -} diff --git a/nix/nixcrpkgs/pkgs/openocd/builder.sh b/nix/nixcrpkgs/pkgs/openocd/builder.sh deleted file mode 100644 index c1c388d88d..0000000000 --- a/nix/nixcrpkgs/pkgs/openocd/builder.sh +++ /dev/null @@ -1,24 +0,0 @@ -source $setup - -cp -r $src openocd -chmod -R u+w openocd - -cd openocd -SKIP_SUBMODULE=1 ./bootstrap -cd .. - -mkdir build -cd build - -PKG_CONFIG=pkg-config-cross ../openocd/configure \ - --prefix=$out \ - --host=$host \ - --disable-dependency-tracking \ - --enable-static \ - --disable-shared - -make - -make install - -$host-strip $out/bin/openocd diff --git a/nix/nixcrpkgs/pkgs/openocd/default.nix b/nix/nixcrpkgs/pkgs/openocd/default.nix deleted file mode 100644 index 756ce99897..0000000000 --- a/nix/nixcrpkgs/pkgs/openocd/default.nix +++ /dev/null @@ -1,39 +0,0 @@ -{ crossenv, libusb }: - -let - version = "2018-08-16"; - - name = "openocd-${version}"; - - nixpkgs = crossenv.nixpkgs; - - src = nixpkgs.fetchgit { - url = "git://repo.or.cz/openocd"; # official mirror - rev = "b2d259f67cc3ee4b689e704228d97943bae94064"; - sha256 = "0c5zpjplwp0ivl4mpiix628j0iad9gkmg9f7lidgqjr5a80cr6hg"; - deepClone = true; - }; - - drv = crossenv.make_derivation { - inherit version name src; - builder = ./builder.sh; - - native_inputs = [ - nixpkgs.autoconf - nixpkgs.automake - nixpkgs.libtool - nixpkgs.m4 - ]; - - ACLOCAL_PATH = - "${nixpkgs.libtool}/share/aclocal:" + - "${crossenv.native.pkgconf}/share/aclocal"; - - # Avoid a name conflict: get_home_dir is also defined in libudev. - CFLAGS = "-Dget_home_dir=openocd_get_home_dir"; - - cross_inputs = [ libusb ]; - }; - -in - drv diff --git a/nix/nixcrpkgs/pkgs/openssl/builder.sh b/nix/nixcrpkgs/pkgs/openssl/builder.sh deleted file mode 100644 index e47e43ab11..0000000000 --- a/nix/nixcrpkgs/pkgs/openssl/builder.sh +++ /dev/null @@ -1,46 +0,0 @@ -source $setup - -tar -xf $src - -mkdir build -cd build - -err () { echo ERR "$@" >&2; } - -case $host in - i686-linux-musleabi) - confighost=linux-x86;; - x86_64-linux-musleabi) - confighost=linux-x86_64;; - x86_64-apple-darwin*) - confighost=darwin64-x86_64-cc;; - *) - err openssl builder.sh needs to excplicitly translate - err "'host=$host'" to something openssl understands. - confighost=$host;; -esac - -# TODO The `no-async` option seems weird, but -# https://github.com/openssl/openssl/issues/1607 - -# TODO I stole the no-dso option from the here[1], but is it -# needed? I seems to be related to shared libraries, which we aren't using -# anyways, but I don't like not understanding. -# -# [1]: https://github.com/rust-embedded/cross/blob/master/docker/openssl.sh - -# TODO Why `-fPIC`? I stole it from [2] -# -# [2]: https://github.com/rust-embedded/cross/pull/218/files - -../openssl-$version/Configure \ - --prefix=$out \ - --cross-compile-prefix=$host- \ - no-shared \ - no-dso \ - no-async \ - $confighost \ - -fPIC - -make -make install diff --git a/nix/nixcrpkgs/pkgs/openssl/default.nix b/nix/nixcrpkgs/pkgs/openssl/default.nix deleted file mode 100644 index de9b876f90..0000000000 --- a/nix/nixcrpkgs/pkgs/openssl/default.nix +++ /dev/null @@ -1,83 +0,0 @@ -{ crossenv }: - -crossenv.make_derivation rec { - name = "openssl-${version}"; - version = "1.1.1"; - - native_inputs = [ crossenv.nixpkgs.perl ]; - - src = crossenv.nixpkgs.fetchurl { - url = "https://www.openssl.org/source/${name}.tar.gz"; - sha256 = "0gbab2fjgms1kx5xjvqx8bxhr98k4r8l2fa8vw7kvh491xd8fdi8"; - }; - - builder = ./builder.sh; -} - -# let -# -# coreutils = crossenv.nixpkgs.coreutils; -# -# # with stdenv.lib; -# -# in -# -# { -# -# patches = [ ./nix-ssl-cert-file.patch ]; -# -# native_inputs = [ crossenv.nixpkgs.perl ]; -# -# postPatch = '' -# patchShebangs Configure -# '' + optionalString (versionAtLeast version "1.1.1") '' -# substituteInPlace config --replace '/usr/bin/env' '${coreutils}/bin/env' -# '' + optionalString (versionAtLeast version "1.1.0" && stdenv.hostPlatform.isMusl) '' -# substituteInPlace crypto/async/arch/async_posix.h \ -# --replace '!defined(__ANDROID__) && !defined(__OpenBSD__)' \ -# '!defined(__ANDROID__) && !defined(__OpenBSD__) && 0' -# ''; -# -# configureScript = { -# "x86_64-darwin" = "./Configure darwin64-x86_64-cc"; -# "x86_64-solaris" = "./Configure solaris64-x86_64-gcc"; -# "armv6l-linux" = "./Configure linux-armv4 -march=armv6"; -# "armv7l-linux" = "./Configure linux-armv4 -march=armv7-a"; -# }.${stdenv.hostPlatform.system} or ( -# if stdenv.hostPlatform == stdenv.buildPlatform -# then "./config" -# else if stdenv.hostPlatform.isMinGW -# then "./Configure mingw${optionalString -# (stdenv.hostPlatform.parsed.cpu.bits != 32) -# (toString stdenv.hostPlatform.parsed.cpu.bits)}" -# else if stdenv.hostPlatform.isLinux -# then "./Configure linux-generic${toString stdenv.hostPlatform.parsed.cpu.bits}" -# else if stdenv.hostPlatform.isiOS -# then "./Configure ios${toString stdenv.hostPlatform.parsed.cpu.bits}-cross" -# else -# throw "Not sure what configuration to use for ${stdenv.hostPlatform.config}" -# ); -# -# configureFlags = [ -# "shared" # "shared" builds both shared and static libraries -# "--libdir=lib" -# "--openssldir=etc/ssl" -# ] ++ stdenv.lib.optionals withCryptodev [ -# "-DHAVE_CRYPTODEV" -# "-DUSE_CRYPTODEV_DIGESTS" -# ] -# ++ stdenv.lib.optional (versionAtLeast version "1.1.0" && stdenv.hostPlatform.isAarch64) "no-afalgeng"; -# -# postInstall = '' -# mkdir -p $bin -# mv $out/bin $bin/ -# -# mkdir $dev -# mv $out/include $dev/ -# -# # remove dependency on Perl at runtime -# rm -r $out/etc/ssl/misc -# -# rmdir $out/etc/ssl/{certs,private} -# ''; -# }; diff --git a/nix/nixcrpkgs/pkgs/p-load/builder.sh b/nix/nixcrpkgs/pkgs/p-load/builder.sh deleted file mode 100644 index 7ebc2e6ace..0000000000 --- a/nix/nixcrpkgs/pkgs/p-load/builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -mv p-load-* p-load - -mkdir build -cd build - -cmake-cross ../p-load \ - -DCMAKE_INSTALL_PREFIX=$out - -make - -make install diff --git a/nix/nixcrpkgs/pkgs/p-load/default.nix b/nix/nixcrpkgs/pkgs/p-load/default.nix deleted file mode 100644 index 6ce88528bf..0000000000 --- a/nix/nixcrpkgs/pkgs/p-load/default.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ crossenv, libusbp }: - -crossenv.make_derivation rec { - name = "p-load-${version}"; - - version = "2041b02"; # 2.1.0ish - - src = crossenv.nixpkgs.fetchurl { - url = "https://github.com/pololu/p-load/archive/${version}.tar.gz"; - sha256 = "07xn0k96pkvirsh45zn9976lwliiqkfx76vy1yrbx6kp55ssp2zp"; - }; - - builder = ./builder.sh; - - cross_inputs = [ libusbp ]; -} diff --git a/nix/nixcrpkgs/pkgs/pavr2/builder.sh b/nix/nixcrpkgs/pkgs/pavr2/builder.sh deleted file mode 100644 index b516b69263..0000000000 --- a/nix/nixcrpkgs/pkgs/pavr2/builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -mv pololu-usb-avr-programmer-v2-* pavr2 - -mkdir build -cd build - -cmake-cross ../pavr2 \ - -DCMAKE_INSTALL_PREFIX=$out - -make - -make install diff --git a/nix/nixcrpkgs/pkgs/pavr2/default.nix b/nix/nixcrpkgs/pkgs/pavr2/default.nix deleted file mode 100644 index 379e61b51d..0000000000 --- a/nix/nixcrpkgs/pkgs/pavr2/default.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ crossenv, qt, libusbp }: - -crossenv.make_derivation rec { - name = "pavr2-${version}"; - - version = "a113a3b"; # 1.0.2ish - - src = crossenv.nixpkgs.fetchurl { - url = "https://github.com/pololu/pololu-usb-avr-programmer-v2/archive/${version}.tar.gz"; - sha256 = "1mg467jx7mpcn01vh8rq80w7p8mbj7l69dmpyni0nik44ggsj7ij"; - }; - - builder = ./builder.sh; - - cross_inputs = [ libusbp qt ]; -} diff --git a/nix/nixcrpkgs/pkgs/pdcurses/builder.sh b/nix/nixcrpkgs/pkgs/pdcurses/builder.sh deleted file mode 100644 index e9dc462058..0000000000 --- a/nix/nixcrpkgs/pkgs/pdcurses/builder.sh +++ /dev/null @@ -1,37 +0,0 @@ -source $setup - -tar -xf $src -mv PDCurses-* pdcurses - -mkdir build -cd build - -source_files=../pdcurses/pdcurses/*.c - -if [ "$os" == "windows" ]; then - os_files=../pdcurses/win32/*.c -fi - -if [ "$os" == "linux" ]; then - os_files= -fi - -source_files="$source_files $os_files" - -for s in $source_files; do - echo "compiling $s" - $host-gcc -g -O2 -I../pdcurses \ - -DPDC_WIDE -DPDC_FORCE_UTF8 -c "$s" -o "$(basename $s).o" -done - -$host-ar r libpdcurses.a *.o -$host-ranlib libpdcurses.a - -mkdir -p $out/{lib,include} -cp libpdcurses.a $out/lib/libpdcurses.a - -# Make libcurses.a so programs like GDB can find pdcurses. -ln -s $out/lib/libpdcurses.a $out/lib/libcurses.a - -cd ../pdcurses -cp curses.h panel.h term.h $out/include/ diff --git a/nix/nixcrpkgs/pkgs/pdcurses/default.nix b/nix/nixcrpkgs/pkgs/pdcurses/default.nix deleted file mode 100644 index 0a47f6564d..0000000000 --- a/nix/nixcrpkgs/pkgs/pdcurses/default.nix +++ /dev/null @@ -1,16 +0,0 @@ -# Note: This only seems to work on Windows. - -{ crossenv }: - -let - - pdcurses = import ./lib.nix { - inherit crossenv; - }; - - examples = import ./examples.nix { - inherit crossenv pdcurses; - }; - -in - pdcurses // { inherit examples; } diff --git a/nix/nixcrpkgs/pkgs/pdcurses/demos_builder.sh b/nix/nixcrpkgs/pkgs/pdcurses/demos_builder.sh deleted file mode 100644 index eea6a67379..0000000000 --- a/nix/nixcrpkgs/pkgs/pdcurses/demos_builder.sh +++ /dev/null @@ -1,25 +0,0 @@ -source $setup - -tar -xf $src -mv PDCurses-$version/demos . -rm -r PDCurses-$version - -mkdir build -cd build - -CFLAGS="-g -O2 -I$pdcurses/include -DPDC_WIDE" - -$host-gcc $CFLAGS -c ../demos/tui.c -o tui.o -$host-ar r tui.a tui.o - -demos="firework newdemo ptest rain testcurs worm xmas tuidemo" - -for name in $demos; do - src=../demos/$name.c - echo "compiling $name" - $host-gcc $CFLAGS -L"$pdcurses/lib" \ - "$src" tui.a -lpdcurses -o "$name.exe" -done - -mkdir -p $out/bin -mv *.exe $out/bin/ diff --git a/nix/nixcrpkgs/pkgs/pdcurses/examples.nix b/nix/nixcrpkgs/pkgs/pdcurses/examples.nix deleted file mode 100644 index 8b3dbee385..0000000000 --- a/nix/nixcrpkgs/pkgs/pdcurses/examples.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ crossenv, pdcurses }: - -crossenv.make_derivation rec { - name = "pdcurses_demos-${version}"; - - inherit pdcurses; - inherit (pdcurses) src version; - - builder = ./demos_builder.sh; -} - diff --git a/nix/nixcrpkgs/pkgs/pdcurses/lib.nix b/nix/nixcrpkgs/pkgs/pdcurses/lib.nix deleted file mode 100644 index ef4293502d..0000000000 --- a/nix/nixcrpkgs/pkgs/pdcurses/lib.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ crossenv }: - -crossenv.make_derivation rec { - name = "pdcurses-${version}"; - - version = "3.4"; - - src = crossenv.nixpkgs.fetchurl { - # Sourceforge went down. The original URL was: - # url = "mirror://sourceforge/pdcurses/PDCurses-${version}.tar.gz"; - url = "https://files.tmphax.com/repo1/pdcurses-${version}.tar.gz"; - sha256 = "0jz6l8552fnf1j542yhzifgknrdzrisxg158ks0l87g777a8zba6"; - }; - - builder = ./builder.sh; -} diff --git a/nix/nixcrpkgs/pkgs/qt/absolute-paths.patch b/nix/nixcrpkgs/pkgs/qt/absolute-paths.patch deleted file mode 100644 index 93ab1e1fc2..0000000000 --- a/nix/nixcrpkgs/pkgs/qt/absolute-paths.patch +++ /dev/null @@ -1,63 +0,0 @@ -diff -ur qtbase-opensource-src-5.9.2-orig/configure qtbase-opensource-src-5.9.2/configure ---- qtbase-opensource-src-5.9.2-orig/configure 2017-10-26 08:10:12.932646805 -0700 -+++ qtbase-opensource-src-5.9.2/configure 2017-11-01 08:48:44.973917507 -0700 -@@ -36,9 +36,9 @@ - relconf=`basename $0` - # the directory of this script is the "source tree" - relpath=`dirname $0` --relpath=`(cd "$relpath"; /bin/pwd)` -+relpath=`(cd "$relpath"; pwd)` - # the current directory is the "build tree" or "object tree" --outpath=`/bin/pwd` -+outpath=`pwd` - - WHICH="which" - -@@ -232,7 +232,7 @@ - - sdk=$(getSingleQMakeVariable "QMAKE_MAC_SDK" "$1") - if [ -z "$sdk" ]; then echo "QMAKE_MAC_SDK must be set when building on Mac" >&2; exit 1; fi -- sysroot=$(/usr/bin/xcrun --sdk $sdk --show-sdk-path 2>/dev/null) -+ sysroot=$(xcrun --sdk $sdk --show-sdk-path 2>/dev/null) - if [ -z "$sysroot" ]; then echo "Failed to resolve SDK path for '$sdk'" >&2; exit 1; fi - - case "$sdk" in -@@ -267,7 +267,7 @@ - # Prefix tool with toolchain path - var=$(echo "$line" | cut -d '=' -f 1) - val=$(echo "$line" | cut -d '=' -f 2-) -- sdk_val=$(/usr/bin/xcrun -sdk $sdk -find $(echo $val | cut -d ' ' -f 1)) -+ sdk_val=$(xcrun -sdk $sdk -find $(echo $val | cut -d ' ' -f 1)) - val=$(echo $sdk_val $(echo $val | cut -s -d ' ' -f 2-)) - echo "$var=$val" - ;; -@@ -305,9 +305,6 @@ - UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown - - BUILD_ON_MAC=no --if [ -d /System/Library/Frameworks/Carbon.framework ]; then -- BUILD_ON_MAC=yes --fi - if [ "$OSTYPE" = "msys" ]; then - relpath=`(cd "$relpath"; pwd -W)` - outpath=`pwd -W` -@@ -318,7 +315,7 @@ - #------------------------------------------------------------------------------- - - if [ "$BUILD_ON_MAC" = "yes" ]; then -- if ! /usr/bin/xcode-select --print-path >/dev/null 2>&1; then -+ if ! xcode-select --print-path >/dev/null 2>&1; then - echo >&2 - echo " No Xcode selected. Please install Xcode via the App Store, " >&2 - echo " or the command line developer tools via xcode-select --install, " >&2 -@@ -329,8 +326,8 @@ - fi - - # In the else case we are probably using a Command Line Tools installation -- if /usr/bin/xcrun -find xcodebuild >/dev/null 2>&1; then -- if ! /usr/bin/xcrun xcodebuild -license check 2>/dev/null; then -+ if xcrun -find xcodebuild >/dev/null 2>&1; then -+ if ! xcrun xcodebuild -license check 2>/dev/null; then - echo >&2 - echo " Xcode setup not complete. You need to confirm the license" >&2 - echo " agreement by running 'sudo xcrun xcodebuild -license accept'." >&2 diff --git a/nix/nixcrpkgs/pkgs/qt/builder.sh b/nix/nixcrpkgs/pkgs/qt/builder.sh deleted file mode 100644 index 1668ce2800..0000000000 --- a/nix/nixcrpkgs/pkgs/qt/builder.sh +++ /dev/null @@ -1,23 +0,0 @@ -source $setup - -mkdir -p $out -pushd $out -tar -xf $src -mv qtbase-opensource-src-* src -cd src -for patch in $patches; do - echo applying patch $patch - patch -p1 -i $patch -done -popd - -mkdir build -cd build - -PKG_CONFIG=pkg-config-cross \ -$out/src/configure -prefix $out $configure_flags - -make - -make install - diff --git a/nix/nixcrpkgs/pkgs/qt/core_macros.cmake b/nix/nixcrpkgs/pkgs/qt/core_macros.cmake deleted file mode 100644 index f3ef672fda..0000000000 --- a/nix/nixcrpkgs/pkgs/qt/core_macros.cmake +++ /dev/null @@ -1,106 +0,0 @@ -# These macros come from src/corelib/Qt5CoreMacros.cmake originally. - -#============================================================================= -# Copyright 2005-2011 Kitware, Inc. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Kitware, Inc. nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#============================================================================= - -macro(QT5_MAKE_OUTPUT_FILE infile prefix ext outfile ) - string(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength) - string(LENGTH ${infile} _infileLength) - set(_checkinfile ${CMAKE_CURRENT_SOURCE_DIR}) - if(_infileLength GREATER _binlength) - string(SUBSTRING "${infile}" 0 ${_binlength} _checkinfile) - if(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") - file(RELATIVE_PATH rel ${CMAKE_CURRENT_BINARY_DIR} ${infile}) - else() - file(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile}) - endif() - else() - file(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile}) - endif() - if(WIN32 AND rel MATCHES "^([a-zA-Z]):(.*)$") # absolute path - set(rel "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}") - endif() - set(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}") - string(REPLACE ".." "__" _outfile ${_outfile}) - get_filename_component(outpath ${_outfile} PATH) - get_filename_component(_outfile ${_outfile} NAME_WE) - file(MAKE_DIRECTORY ${outpath}) - set(${outfile} ${outpath}/${prefix}${_outfile}.${ext}) -endmacro() - -function(_QT5_PARSE_QRC_FILE infile _out_depends _rc_depends) - get_filename_component(rc_path ${infile} PATH) - if(EXISTS "${infile}") - file(READ "${infile}" RC_FILE_CONTENTS) - string(REGEX MATCHALL "]*>" "" RC_FILE "${RC_FILE}") - if(NOT IS_ABSOLUTE "${RC_FILE}") - set(RC_FILE "${rc_path}/${RC_FILE}") - endif() - set(RC_DEPENDS ${RC_DEPENDS} "${RC_FILE}") - endforeach() - qt5_make_output_file("${infile}" "" "qrc.depends" out_depends) - configure_file("${infile}" "${out_depends}" COPYONLY) - else() - set(out_depends) - endif() - set(${_out_depends} ${out_depends} PARENT_SCOPE) - set(${_rc_depends} ${RC_DEPENDS} PARENT_SCOPE) -endfunction() - -function(QT5_ADD_RESOURCES outfiles ) - set(options) - set(oneValueArgs) - set(multiValueArgs OPTIONS) - cmake_parse_arguments(_RCC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - set(rcc_files ${_RCC_UNPARSED_ARGUMENTS}) - set(rcc_options ${_RCC_OPTIONS}) - - if("${rcc_options}" MATCHES "-binary") - message(WARNING "Use qt5_add_binary_resources for binary option") - endif() - - foreach(it ${rcc_files}) - get_filename_component(outfilename ${it} NAME_WE) - get_filename_component(infile ${it} ABSOLUTE) - set(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cpp) - _QT5_PARSE_QRC_FILE(${infile} _out_depends _rc_depends) - add_custom_command(OUTPUT ${outfile} - COMMAND ${Qt5Core_RCC_EXECUTABLE} - ARGS ${rcc_options} --name ${outfilename} --output ${outfile} ${infile} - MAIN_DEPENDENCY ${infile} - DEPENDS ${_rc_depends} "${out_depends}" VERBATIM) - list(APPEND ${outfiles} ${outfile}) - endforeach() - set(${outfiles} ${${outfiles}} PARENT_SCOPE) -endfunction() diff --git a/nix/nixcrpkgs/pkgs/qt/dbus-null-pointer.patch b/nix/nixcrpkgs/pkgs/qt/dbus-null-pointer.patch deleted file mode 100644 index 8e8543c62c..0000000000 --- a/nix/nixcrpkgs/pkgs/qt/dbus-null-pointer.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -ur qtbase-opensource-src-5.9.6-orig/src/platformsupport/linuxaccessibility/dbusconnection.cpp qtbase-opensource-src-5.9.6/src/platformsupport/linuxaccessibility/dbusconnection.cpp ---- qtbase-opensource-src-5.9.6-orig/src/platformsupport/linuxaccessibility/dbusconnection.cpp 2018-06-19 12:42:00.533895696 -0700 -+++ qtbase-opensource-src-5.9.6/src/platformsupport/linuxaccessibility/dbusconnection.cpp 2018-06-19 12:45:03.308744607 -0700 -@@ -75,7 +75,7 @@ - connect(dbusWatcher, SIGNAL(serviceRegistered(QString)), this, SLOT(serviceRegistered())); - - // If it is registered already, setup a11y right away -- if (c.interface()->isServiceRegistered(A11Y_SERVICE)) -+ if (c.interface() && c.interface()->isServiceRegistered(A11Y_SERVICE)) - serviceRegistered(); - - // In addition try if there is an xatom exposing the bus address, this allows applications run as root to work diff --git a/nix/nixcrpkgs/pkgs/qt/default.nix b/nix/nixcrpkgs/pkgs/qt/default.nix deleted file mode 100644 index 5a9f4d6752..0000000000 --- a/nix/nixcrpkgs/pkgs/qt/default.nix +++ /dev/null @@ -1,165 +0,0 @@ -# TODO: look into why were compiling with this impure option on Linux: -# -DDFLT_XKB_CONFIG_ROOT=\"/usr/share/X11/xkb\" - -# TODO: patch qt to not use /bin/pwd, test building it in a sandbox - -{ crossenv, libudev, libxall, at-spi2-headers, dejavu-fonts }: - -let - version = "5.9.6"; - - name = "qtbase-${version}"; - - platform = - let - os_code = - if crossenv.os == "windows" then "win32" - else if crossenv.os == "macos" then "macx" - else if crossenv.os == "linux" then "devices/linux-generic" - else crossenv.os; - compiler_code = - if crossenv.compiler == "gcc" then "g++" - else crossenv.compiler; - in "${os_code}-${compiler_code}"; - - base_src = crossenv.nixpkgs.fetchurl { - url = "https://download.qt.io/official_releases/qt/5.9/${version}/submodules/qtbase-opensource-src-${version}.tar.xz"; - sha256 = "0vz3rgx7bk50jzy78lxv5pff2l8xqmqs9iiz7gc9n6cb4v5j1mpf"; - }; - - base_raw = crossenv.make_derivation { - name = "qtbase-raw-${version}"; - inherit version; - src = base_src; - builder = ./builder.sh; - - patches = [ - # Purity issue: Don't look at the build system using absolute paths. - ./absolute-paths.patch - - # macOS configuration: Don't run tools from /usr/bin, use the right - # compiler, and don't pass redundant options to it (-arch, -isysroot, - # -mmacosx-version-min). - ./macos-config.patch - - # libX11.a depends on libxcb.a. This makes tests.xlib in - # src/gui/configure.json pass, enabling lots of X functionality in Qt. - ./find-x-libs.patch - - # Fix the build error caused by https://bugreports.qt.io/browse/QTBUG-63637 - ./win32-link-object-max.patch - - # The .pc files have incorrect library names without this (e.g. Qt5Cored) - ./pc-debug-name.patch - - # uxtheme.h test is broken, always returns false, and results in QtWidgets - # apps looking bad on Windows. https://stackoverflow.com/q/44784414/28128 - ./dont-test-uxtheme.patch - - # When cross-compiling, Qt uses some heuristics about whether to trust the - # pkg-config executable supplied by the PKG_CONFIG environment variable. - # These heuristics are wrong for us, so disable them, making qt use - # pkg-config-cross. - ./pkg-config-cross.patch - - # When the DBus session bus is not available, Qt tries to dereference a - # null pointer, so Linux applications can't start up. - ./dbus-null-pointer.patch - - # Look for fonts in the same directory as the application by default if - # the QT_QPA_FONTDIR environment variable is not present. Without this - # patch, Qt tries to look for a font directory in the nix store that does - # not exists, and prints warnings. - # You must ship a .ttf, .ttc, .pfa, .pfb, or .otf font file - # with your application (e.g. https://dejavu-fonts.github.io/ ). - # That list of extensions comes from qbasicfontdatabase.cpp. - ./font-dir.patch - ]; - - configure_flags = - "-opensource -confirm-license " + - "-xplatform ${platform} " + - "-device-option CROSS_COMPILE=${crossenv.host}- " + - "-release " + # change to -debug if you want debugging symbols - "-static " + - "-pkg-config " + - "-nomake examples " + - "-no-icu " + - "-no-fontconfig " + - "-no-reduce-relocations " + - ( if crossenv.os == "windows" then - "-opengl desktop" - else if crossenv.os == "linux" then - "-qpa xcb " + - "-system-xcb " + - "-no-opengl " + - "-device-option QMAKE_INCDIR_X11=${libxall}/include " + - "-device-option QMAKE_LIBDIR_X11=${libxall}/lib" - else if crossenv.os == "macos" then - "-device-option QMAKE_MAC_SDK.macosx.--show-sdk-path=" + - "${crossenv.sdk} " + - "-device-option QMAKE_MAC_SDK.macosx.--show-sdk-platform-path=" + - "${crossenv.sdk}/does-not-exist " + - "-device-option QMAKE_MAC_SDK.macosx.--show-sdk-version=" + - "${crossenv.macos_version_min} " + - "-device-option QMAKE_XCODE_VERSION=7.0" - else "" ); - - cross_inputs = - if crossenv.os == "linux" then [ - libudev # not sure if this helps, but Qt does look for it - libxall - at-spi2-headers # for accessibility - ] - else []; - }; - - # This wrapper aims to make Qt easier to use by generating CMake package files - # for it. The existing support for CMake in Qt does not handle static - # linking; other projects maintian large, messy patches to fix it, but we - # prefer to generate the CMake files in a clean way from scratch. - base = crossenv.make_derivation { - inherit version name; - os = crossenv.os; - qtbase = base_raw; - cross_inputs = base_raw.cross_inputs; - builder.ruby = ./wrapper_builder.rb; - core_macros = ./core_macros.cmake; - }; - - examples = crossenv.make_derivation { - name = "qtbase-examples-${version}"; - inherit version; - os = crossenv.os; - qtbase = base; - cross_inputs = [ base ]; - dejavu = dejavu-fonts; - builder = ./examples_builder.sh; - }; - - license_fragment = crossenv.native.make_derivation { - name = "qtbase-${version}-license-fragment"; - inherit version; - src = base_src; - builder = ./license_builder.sh; - }; - - license_set = - ( - if crossenv.os == "linux" then - libudev.license_set // - libxall.license_set // - at-spi2-headers.license_set - else - {} - ) // - { "${name}" = license_fragment; }; -in - base // { - recurseForDerivations = true; - inherit base_src; - inherit base_raw; - inherit base; - inherit examples; - inherit license_set; - } diff --git a/nix/nixcrpkgs/pkgs/qt/dont-test-uxtheme.patch b/nix/nixcrpkgs/pkgs/qt/dont-test-uxtheme.patch deleted file mode 100644 index c416201388..0000000000 --- a/nix/nixcrpkgs/pkgs/qt/dont-test-uxtheme.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff -ur qtbase-opensource-src-5.9.2-orig/src/widgets/configure.json qtbase-opensource-src-5.9.2/src/widgets/configure.json ---- qtbase-opensource-src-5.9.2-orig/src/widgets/configure.json 2017-10-25 13:52:49.173421900 -0700 -+++ qtbase-opensource-src-5.9.2/src/widgets/configure.json 2017-10-25 13:53:42.891341214 -0700 -@@ -28,11 +28,6 @@ - }, - - "tests": { -- "uxtheme": { -- "label": "uxtheme.h", -- "type": "files", -- "files": [ "uxtheme.h" ] -- } - }, - - "features": { -@@ -57,7 +52,7 @@ - }, - "style-windowsxp": { - "label": "WindowsXP", -- "condition": "features.style-windows && config.win32 && !config.winrt && tests.uxtheme", -+ "condition": "features.style-windows && config.win32 && !config.winrt", - "output": [ "privateFeature", "styles" ] - }, - "style-windowsvista": { diff --git a/nix/nixcrpkgs/pkgs/qt/examples_builder.sh b/nix/nixcrpkgs/pkgs/qt/examples_builder.sh deleted file mode 100644 index d5d56e11c0..0000000000 --- a/nix/nixcrpkgs/pkgs/qt/examples_builder.sh +++ /dev/null @@ -1,88 +0,0 @@ -source $setup - -examples=$qtbase/src/examples - -mkdir build -cd build -mkdir bin moc obj - -cat > obj/plugins.cpp < -#ifdef _WIN32 -Q_IMPORT_PLUGIN (QWindowsIntegrationPlugin); -#endif -#ifdef __linux__ -Q_IMPORT_PLUGIN (QLinuxFbIntegrationPlugin); -Q_IMPORT_PLUGIN (QXcbIntegrationPlugin); -#endif -EOF - -CFLAGS="-std=gnu++11" - -echo "compiling reference to plugins" -$host-g++ $CFLAGS \ - $(pkg-config-cross --cflags Qt5Core) \ - -c obj/plugins.cpp \ - -o obj/plugins.o - -CFLAGS="$CFLAGS -g -I. $(pkg-config-cross --cflags Qt5Widgets)" -LIBS="$(pkg-config-cross --libs Qt5Widgets)" -LDFLAGS="" - -if [ $os = "windows" ]; then - CFLAGS="-mwindows $CFLAGS" -fi - -echo "compiling dynamiclayouts" -$qtbase/bin/moc $examples/widgets/layouts/dynamiclayouts/dialog.h > moc/dynamiclayouts.cpp -$host-g++ $CFLAGS $LDFLAGS \ - $examples/widgets/layouts/dynamiclayouts/dialog.cpp \ - $examples/widgets/layouts/dynamiclayouts/main.cpp \ - moc/dynamiclayouts.cpp \ - obj/plugins.o \ - $LIBS -o bin/dynamiclayouts$exe_suffix - -echo "compiling rasterwindow" -$qtbase/bin/moc $examples/gui/rasterwindow/rasterwindow.h > moc/rasterwindow.cpp -$host-g++ $CFLAGS $LDFLAGS \ - $examples/gui/rasterwindow/rasterwindow.cpp \ - $examples/gui/rasterwindow/main.cpp \ - moc/rasterwindow.cpp \ - obj/plugins.o \ - $LIBS -o bin/rasterwindow$exe_suffix - -echo "compiling analogclock" -$host-g++ $CFLAGS $LDFLAGS \ - -I$examples/gui/rasterwindow/ \ - $examples/gui/analogclock/main.cpp \ - $examples/gui/rasterwindow/rasterwindow.cpp \ - moc/rasterwindow.cpp \ - obj/plugins.o \ - $LIBS -o bin/analogclock$exe_suffix - -# We haven't gotten OpenGL support to work on Linux yet (TODO) -if [ $os != "linux" ]; then - echo "compiling openglwindow" - $qtbase/bin/moc $examples/gui/openglwindow/openglwindow.h > moc/openglwindow.cpp - $host-g++ $CFLAGS $LDFLAGS \ - $examples/gui/openglwindow/main.cpp \ - $examples/gui/openglwindow/openglwindow.cpp \ - moc/openglwindow.cpp \ - obj/plugins.o \ - $LIBS -o bin/openglwindow$exe_suffix -fi - -# TODO: try to compile some stuff with $qtbase/bin/qmake too, make sure that works - -mkdir -p $out/bin - -for prog in analogclock dynamiclayouts openglwindow rasterwindow; do - if [ -f bin/$prog ]; then - $host-strip bin/$prog - cp bin/$prog $out/bin/ - fi -done - -if [ $os = "linux" ]; then - cp $dejavu/ttf/DejaVuSans.ttf $out/bin/ -fi diff --git a/nix/nixcrpkgs/pkgs/qt/find-x-libs.patch b/nix/nixcrpkgs/pkgs/qt/find-x-libs.patch deleted file mode 100644 index 73bd770050..0000000000 --- a/nix/nixcrpkgs/pkgs/qt/find-x-libs.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -ur qtbase-opensource-src-5.9.2-orig/mkspecs/common/linux.conf qtbase-opensource-src-5.9.2/mkspecs/common/linux.conf ---- qtbase-opensource-src-5.9.2-orig/mkspecs/common/linux.conf 2017-10-26 08:10:12.922646692 -0700 -+++ qtbase-opensource-src-5.9.2/mkspecs/common/linux.conf 2017-10-26 21:44:37.695088447 -0700 -@@ -28,7 +28,7 @@ - - QMAKE_LIBS = - QMAKE_LIBS_DYNLOAD = -ldl --QMAKE_LIBS_X11 = -lXext -lX11 -lm -+QMAKE_LIBS_X11 = -lXext -lX11 -lxcb -lXau - QMAKE_LIBS_EGL = -lEGL - QMAKE_LIBS_OPENGL = -lGL - QMAKE_LIBS_OPENGL_ES2 = -lGLESv2 diff --git a/nix/nixcrpkgs/pkgs/qt/font-dir.patch b/nix/nixcrpkgs/pkgs/qt/font-dir.patch deleted file mode 100644 index ab83847648..0000000000 --- a/nix/nixcrpkgs/pkgs/qt/font-dir.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- qt-5.8.0-orig/src/gui/text/qplatformfontdatabase.cpp -+++ qt-5.8.0/src/gui/text/qplatformfontdatabase.cpp -@@ -396,7 +396,7 @@ - { - QString fontpath = QString::fromLocal8Bit(qgetenv("QT_QPA_FONTDIR")); - if (fontpath.isEmpty()) -- fontpath = QLibraryInfo::location(QLibraryInfo::LibrariesPath) + QLatin1String("/fonts"); -+ fontpath = QCoreApplication::applicationDirPath(); - - return fontpath; - } diff --git a/nix/nixcrpkgs/pkgs/qt/license_builder.sh b/nix/nixcrpkgs/pkgs/qt/license_builder.sh deleted file mode 100644 index f0fec23547..0000000000 --- a/nix/nixcrpkgs/pkgs/qt/license_builder.sh +++ /dev/null @@ -1,151 +0,0 @@ -# Last updated for qtbase-opensource-src-5.8.0.tar.xz - -source $setup - -if [ "$version" != "5.9.6" ]; then - echo "You need to update the license fragment builder for Qt $version." - exit 1 -fi - -tar -xf $src -mv qtbase-* qtbase - -# Read the license files here instead of in the big string so it is a fatal -# error if any of them are missing. -license_qt=$(cat qtbase/LICENSE.LGPLv3) -cd qtbase/src/3rdparty -license_android=$(cat android/LICENSE) -license_angle1=$(cat angle/LICENSE) -license_angle2=$(cat angle/TRACEEVENT_LICENSE) -license_angle3=$(cat angle/SYSTEMINFO_LICENSE) -license_dc=$(cat double-conversion/LICENSE) -license_easing=$(cat easing/LICENSE) -license_forkfd=$(cat forkfd/LICENSE) -license_freebsd=$(cat freebsd/LICENSE) -license_freetype=$(cat freetype/docs/GPLv2.TXT) -license_gradle=$(cat gradle/LICENSE-GRADLEW.txt) -license_harfbuzz=$(cat harfbuzz/COPYING) -license_harfbuzz_ng=$(cat harfbuzz-ng/COPYING) -license_ia2=$(cat iaccessible2/LICENSE) -license_libjpeg=$(cat libjpeg/LICENSE) -license_libpng=$(cat libpng/LICENSE) -license_pcre2=$(cat pcre2/LICENCE) -license_pixman=$(cat pixman/LICENSE) -license_rfc6234=$(cat rfc6234/LICENSE) -license_sha3_1=$(cat sha3/BRG_ENDIAN_LICENSE) -license_sha3_2=$(cat sha3/CC0_LICENSE) -license_xcb=$(cat xcb/LICENSE) -license_xkbcommon=$(cat xkbcommon/COPYING) -license_zlib=$(cat zlib/LICENSE) - -cat > $out <Qt - -

- The Qt Toolkit is licensed under the - GNU Lesser General Public License Version 3 (LGPLv3) as shown below. -

- -
-$license_qt
-
- -

Third-party components bundled with Qt

- -

- This software might include code from third-party comoponents bundled with Qt. - The copyright notices of those components are reproduced below. -

- -
-$license_android
-
- -
-$license_angle1
-
- -
-$license_angle2
-
- -
-$license_angle3
-
- -
-$license_dc
-
- -
-$license_easing
-
- -
-$license_forkfd
-
- -
-$license_freebsd
-
- -
-$license_freetype
-
- -
-$license_gradle
-
- -
-$license_harfbuzz
-
- -
-$license_harfbuzz_ng
-
- -
-$license_ia2
-
- -
-$license_libjpeg
-
- -
-$license_libpng
-
- -
-$license_pcre2
-
- -
-$license_pixman
-
- -
-$license_rfc6234
-
- -
-$license_sha3_1
-
- -
-$license_sha3_2
-
- -
-$license_xcb
-
- -
-$license_xkbcommon
-
- -
-$license_zlib
-
-EOF diff --git a/nix/nixcrpkgs/pkgs/qt/macos-config.patch b/nix/nixcrpkgs/pkgs/qt/macos-config.patch deleted file mode 100644 index de8c3a2829..0000000000 --- a/nix/nixcrpkgs/pkgs/qt/macos-config.patch +++ /dev/null @@ -1,167 +0,0 @@ -diff -ur qtbase-opensource-src-5.9.2-orig/mkspecs/common/clang.conf qtbase-opensource-src-5.9.2-mac/mkspecs/common/clang.conf ---- qtbase-opensource-src-5.9.2-orig/mkspecs/common/clang.conf 2017-11-03 20:37:01.001539490 -0700 -+++ qtbase-opensource-src-5.9.2-mac/mkspecs/common/clang.conf 2017-11-03 20:46:20.159382848 -0700 -@@ -4,8 +4,8 @@ - - QMAKE_COMPILER = gcc clang llvm # clang pretends to be gcc - --QMAKE_CC = clang --QMAKE_CXX = clang++ -+QMAKE_CC = $${CROSS_COMPILE}clang -+QMAKE_CXX = $${CROSS_COMPILE}clang++ - - QMAKE_LINK_C = $$QMAKE_CC - QMAKE_LINK_C_SHLIB = $$QMAKE_CC -diff -ur qtbase-opensource-src-5.9.2-orig/mkspecs/common/clang-mac.conf qtbase-opensource-src-5.9.2-mac/mkspecs/common/clang-mac.conf ---- qtbase-opensource-src-5.9.2-orig/mkspecs/common/clang-mac.conf 2017-11-03 20:37:01.001539490 -0700 -+++ qtbase-opensource-src-5.9.2-mac/mkspecs/common/clang-mac.conf 2017-11-03 20:55:13.878575754 -0700 -@@ -6,8 +6,6 @@ - - QMAKE_XCODE_GCC_VERSION = com.apple.compilers.llvm.clang.1_0 - --QMAKE_CXXFLAGS += -stdlib=libc++ --QMAKE_LFLAGS += -stdlib=libc++ - QMAKE_AR_LTCG = libtool -static -o - - QMAKE_CFLAGS_APPLICATION_EXTENSION = -fapplication-extension -diff -ur qtbase-opensource-src-5.9.2-orig/mkspecs/common/mac.conf qtbase-opensource-src-5.9.2-mac/mkspecs/common/mac.conf ---- qtbase-opensource-src-5.9.2-orig/mkspecs/common/mac.conf 2017-11-03 20:37:01.001539490 -0700 -+++ qtbase-opensource-src-5.9.2-mac/mkspecs/common/mac.conf 2017-11-03 22:03:30.960602142 -0700 -@@ -35,10 +35,10 @@ - - QMAKE_ACTOOL = actool - --QMAKE_DSYMUTIL = dsymutil --QMAKE_STRIP = strip -+QMAKE_DSYMUTIL = $${CROSS_COMPILE}dsymutil -+QMAKE_STRIP = $${CROSS_COMPILE}strip - QMAKE_STRIPFLAGS_LIB += -S -x - --QMAKE_AR = ar cq --QMAKE_RANLIB = ranlib -s --QMAKE_NM = nm -P -+QMAKE_AR = $${CROSS_COMPILE}ar cq -+QMAKE_RANLIB = $${CROSS_COMPILE}ranlib -s -+QMAKE_NM = $${CROSS_COMPILE}nm -P -diff -ur qtbase-opensource-src-5.9.2-orig/mkspecs/features/mac/default_post.prf qtbase-opensource-src-5.9.2-mac/mkspecs/features/mac/default_post.prf ---- qtbase-opensource-src-5.9.2-orig/mkspecs/features/mac/default_post.prf 2017-11-03 20:37:01.008206202 -0700 -+++ qtbase-opensource-src-5.9.2-mac/mkspecs/features/mac/default_post.prf 2017-11-03 21:06:25.247871399 -0700 -@@ -2,29 +2,6 @@ - - !no_objective_c:CONFIG += objective_c - --qt { -- qtConfig(static) { -- # C++11 support means using libc++ instead of libstd++. As the -- # two libraries are incompatible we need to ensure the end user -- # project is built using the same C++11 support/no support as Qt. -- qtConfig(c++11) { -- CONFIG += c++11 -- } else: c++11 { -- warning("Qt was not built with C++11 enabled, disabling feature") -- CONFIG -= c++11 -- } -- -- !c++11 { -- # Explicitly use libstdc++ if C++11 support is not enabled, -- # as otherwise the compiler will choose the standard library -- # based on the deployment target, which for iOS 7 and OS X 10.9 -- # is libc++, and we can't mix and match the two. -- QMAKE_CXXFLAGS += -stdlib=libstdc++ -- QMAKE_LFLAGS += -stdlib=libstdc++ -- } -- } --} -- - # Add the same default rpaths as Xcode does for new projects. - # This is especially important for iOS/tvOS/watchOS where no other option is possible. - !no_default_rpath { -@@ -89,10 +66,6 @@ - - arch_flags = $(EXPORT_ARCH_ARGS) - -- QMAKE_CFLAGS += $$arch_flags -- QMAKE_CXXFLAGS += $$arch_flags -- QMAKE_LFLAGS += $$arch_flags -- - QMAKE_PCH_ARCHS = $$VALID_ARCHS - - macos: deployment_target = $$QMAKE_MACOSX_DEPLOYMENT_TARGET -@@ -149,9 +122,6 @@ - else: \ - version_identifier = $$device.deployment_identifier - version_min_flag = -m$${version_identifier}-version-min=$$deployment_target -- QMAKE_CFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH $$version_min_flag -- QMAKE_CXXFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH $$version_min_flag -- QMAKE_LFLAGS += -Wl,-syslibroot,$$QMAKE_MAC_SDK_PATH $$version_min_flag - } - - # Enable precompiled headers for multiple architectures -diff -ur qtbase-opensource-src-5.9.2-orig/mkspecs/features/mac/default_pre.prf qtbase-opensource-src-5.9.2-mac/mkspecs/features/mac/default_pre.prf ---- qtbase-opensource-src-5.9.2-orig/mkspecs/features/mac/default_pre.prf 2017-11-03 20:37:01.008206202 -0700 -+++ qtbase-opensource-src-5.9.2-mac/mkspecs/features/mac/default_pre.prf 2017-11-03 20:46:20.159382848 -0700 -@@ -1,43 +1,6 @@ - CONFIG = asset_catalogs rez $$CONFIG - load(default_pre) - --isEmpty(QMAKE_XCODE_DEVELOPER_PATH) { -- # Get path of Xcode's Developer directory -- QMAKE_XCODE_DEVELOPER_PATH = $$system("/usr/bin/xcode-select --print-path 2>/dev/null") -- isEmpty(QMAKE_XCODE_DEVELOPER_PATH): \ -- error("Xcode path is not set. Please use xcode-select to choose Xcode installation path.") -- -- # Make sure Xcode path is valid -- !exists($$QMAKE_XCODE_DEVELOPER_PATH): \ -- error("Xcode is not installed in $${QMAKE_XCODE_DEVELOPER_PATH}. Please use xcode-select to choose Xcode installation path.") --} -- --isEmpty(QMAKE_XCODEBUILD_PATH): \ -- QMAKE_XCODEBUILD_PATH = $$system("/usr/bin/xcrun -find xcodebuild 2>/dev/null") -- --!isEmpty(QMAKE_XCODEBUILD_PATH) { -- # Make sure Xcode is set up properly -- !system("/usr/bin/xcrun xcodebuild -license check 2>/dev/null"): \ -- error("Xcode not set up properly. You need to confirm the license agreement by running 'sudo xcrun xcodebuild -license accept'.") -- -- isEmpty(QMAKE_XCODE_VERSION) { -- # Extract Xcode version using xcodebuild -- xcode_version = $$system("/usr/bin/xcrun xcodebuild -version") -- QMAKE_XCODE_VERSION = $$member(xcode_version, 1) -- isEmpty(QMAKE_XCODE_VERSION): error("Could not resolve Xcode version.") -- unset(xcode_version) -- } --} -- --isEmpty(QMAKE_TARGET_BUNDLE_PREFIX) { -- QMAKE_XCODE_PREFERENCES_FILE = $$(HOME)/Library/Preferences/com.apple.dt.Xcode.plist -- exists($$QMAKE_XCODE_PREFERENCES_FILE): \ -- QMAKE_TARGET_BUNDLE_PREFIX = $$system("/usr/libexec/PlistBuddy -c 'print IDETemplateOptions:bundleIdentifierPrefix' $$QMAKE_XCODE_PREFERENCES_FILE 2>/dev/null") -- -- !isEmpty(_QMAKE_CACHE_):!isEmpty(QMAKE_TARGET_BUNDLE_PREFIX): \ -- cache(QMAKE_TARGET_BUNDLE_PREFIX) --} -- - QMAKE_ASSET_CATALOGS_APP_ICON = AppIcon - - # Make the default debug info format for static debug builds -diff -ur qtbase-opensource-src-5.9.2-orig/mkspecs/features/mac/sdk.prf qtbase-opensource-src-5.9.2-mac/mkspecs/features/mac/sdk.prf ---- qtbase-opensource-src-5.9.2-orig/mkspecs/features/mac/sdk.prf 2017-11-03 20:37:01.008206202 -0700 -+++ qtbase-opensource-src-5.9.2-mac/mkspecs/features/mac/sdk.prf 2017-11-03 20:46:20.159382848 -0700 -@@ -18,7 +18,7 @@ - sdk = $$QMAKE_MAC_SDK - - isEmpty(QMAKE_MAC_SDK.$${sdk}.$${info}) { -- QMAKE_MAC_SDK.$${sdk}.$${info} = $$system("/usr/bin/xcrun --sdk $$sdk $$info 2>/dev/null") -+ QMAKE_MAC_SDK.$${sdk}.$${info} = $$system("xcrun --sdk $$sdk $$info 2>/dev/null") - # --show-sdk-platform-path won't work for Command Line Tools; this is fine - # only used by the XCTest backend to testlib - isEmpty(QMAKE_MAC_SDK.$${sdk}.$${info}):if(!isEmpty(QMAKE_XCODEBUILD_PATH)|!equals(info, "--show-sdk-platform-path")): \ -@@ -50,7 +50,7 @@ - value = $$eval($$tool) - isEmpty(value): next() - -- sysrooted = $$system("/usr/bin/xcrun -sdk $$QMAKE_MAC_SDK -find $$first(value) 2>/dev/null") -+ sysrooted = $$system("xcrun -sdk $$QMAKE_MAC_SDK -find $$first(value) 2>/dev/null") - isEmpty(sysrooted): next() - - $$tool = $$sysrooted $$member(value, 1, -1) diff --git a/nix/nixcrpkgs/pkgs/qt/pc-debug-name.patch b/nix/nixcrpkgs/pkgs/qt/pc-debug-name.patch deleted file mode 100644 index 690e8bea74..0000000000 --- a/nix/nixcrpkgs/pkgs/qt/pc-debug-name.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 995313e0795df5500fd84350e80a3f88202b473d Mon Sep 17 00:00:00 2001 -From: Martchus -Date: Sun, 18 Sep 2016 14:01:14 +0200 -Subject: [PATCH 07/30] Prevent debug library names in pkg-config files - -qmake generates the pkgconfig .pc files two times, once for the -release build and once for the debug build (which we're not actually -building in this package). For both generations the exact same -pkgconfig file name is used. This causes references to the debug -build ending up in the .pc files which are unwanted -Prevent this from happening by giving the pkgconfig .pc -files for the debug build an unique file name. ---- - qmake/generators/makefile.cpp | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp -index 182fe79238..a762443fe2 100644 ---- a/qmake/generators/makefile.cpp -+++ b/qmake/generators/makefile.cpp -@@ -3164,6 +3164,9 @@ MakefileGenerator::pkgConfigFileName(bool fixify, bool onlyPrependDestdir) - if (dot != -1) - ret = ret.left(dot); - } -+ if (project->isActiveConfig("debug")) { -+ ret += "d"; -+ } - ret += Option::pkgcfg_ext; - QString subdir = project->first("QMAKE_PKGCONFIG_DESTDIR").toQString(); - if(!subdir.isEmpty()) { --- -2.11.1 - diff --git a/nix/nixcrpkgs/pkgs/qt/pkg-config-cross.patch b/nix/nixcrpkgs/pkgs/qt/pkg-config-cross.patch deleted file mode 100644 index 506df0ff8d..0000000000 --- a/nix/nixcrpkgs/pkgs/qt/pkg-config-cross.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff -ur qt-orig/configure.pri qt/configure.pri ---- qt-orig/configure.pri 2017-07-27 18:16:48.205591390 -0700 -+++ qt/configure.pri 2017-07-29 13:11:08.957085166 -0700 -@@ -139,7 +139,8 @@ - } - } - -- $$qtConfEvaluate("features.cross_compile") { -+ qtLog("Blindly trusting this pkg-config to be valid."); -+ false { - # cross compiling, check that pkg-config is set up sanely - sysroot = $$config.input.sysroot - diff --git a/nix/nixcrpkgs/pkgs/qt/win32-link-object-max.patch b/nix/nixcrpkgs/pkgs/qt/win32-link-object-max.patch deleted file mode 100644 index c47279b2ee..0000000000 --- a/nix/nixcrpkgs/pkgs/qt/win32-link-object-max.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff -ur qtbase-opensource-src-5.9.6-orig/mkspecs/win32-g++/qmake.conf qtbase-opensource-src-5.9.6/mkspecs/win32-g++/qmake.conf ---- qtbase-opensource-src-5.9.6-orig/mkspecs/win32-g++/qmake.conf 2018-06-19 12:41:49.061465695 -0700 -+++ qtbase-opensource-src-5.9.6/mkspecs/win32-g++/qmake.conf 2018-06-19 12:42:15.406453120 -0700 -@@ -54,10 +54,8 @@ - QMAKE_LFLAGS_WINDOWS = -Wl,-subsystem,windows - QMAKE_LFLAGS_DLL = -shared - QMAKE_LFLAGS_GCSECTIONS = -Wl,--gc-sections --equals(QMAKE_HOST.os, Windows) { -- QMAKE_LINK_OBJECT_MAX = 10 -- QMAKE_LINK_OBJECT_SCRIPT = object_script --} -+QMAKE_LINK_OBJECT_MAX = 10 -+QMAKE_LINK_OBJECT_SCRIPT = object_script - QMAKE_EXT_OBJ = .o - QMAKE_EXT_RES = _res.o - QMAKE_PREFIX_SHLIB = diff --git a/nix/nixcrpkgs/pkgs/qt/wrapper_builder.rb b/nix/nixcrpkgs/pkgs/qt/wrapper_builder.rb deleted file mode 100644 index 49b3efd8a0..0000000000 --- a/nix/nixcrpkgs/pkgs/qt/wrapper_builder.rb +++ /dev/null @@ -1,499 +0,0 @@ -require 'pathname' -require 'fileutils' -include FileUtils - -STDOUT.sync = true - -ENV['PATH'] = ENV.fetch('_PATH') - -Os = ENV.fetch('os') -QtVersionString = ENV.fetch('version') -QtVersionMajor = QtVersionString.split('.').first.to_i - -QtBaseDir = Pathname(ENV.fetch('qtbase')) - -OutDir = Pathname(ENV.fetch('out')) -OutPcDir = OutDir + 'lib' + 'pkgconfig' -CMakeDir = OutDir + 'lib' + 'cmake' -OutIncDir = OutDir + 'include' -MocExe = OutDir + 'bin' + 'moc' -RccExe = OutDir + 'bin' + 'rcc' - -DepGraph = {} -DepGraphBack = {} - -DepInfo = {} -DepInfo.default_proc = proc do |hash, name| - hash[name] = find_dep_info(name) -end - -case Os -when "windows" - PrlPrefix = '' -else - PrlPrefix = 'lib' -end - -# Note: These dependencies just came from me fixing errors for specific -# programs. There are likely misisng dependencies in this graph, and there -# might be a few dependencies that could be safely removed because they are -# purely transitive. -def make_dep_graph - # High-level dependencies. - add_dep 'Qt5Widgets.x', 'libQt5Widgets.a' - add_dep 'Qt5Widgets.x', 'Qt5Gui.x' - add_dep 'Qt5Gui.x', 'Qt5GuiNoPlugins.x' - add_dep 'Qt5GuiNoPlugins.x', 'libQt5Gui.a' - add_dep 'Qt5GuiNoPlugins.x', 'Qt5Core.x' - add_dep 'Qt5Core.x', 'libQt5Core.a' - - # Include directories. - add_dep 'Qt5Core.x', '-I' + OutIncDir.to_s - add_dep 'Qt5Core.x', '-I' + (OutIncDir + 'QtCore').to_s - add_dep 'Qt5Gui.x', '-I' + (OutIncDir + 'QtGui').to_s - add_dep 'Qt5Widgets.x', '-I' + (OutIncDir + 'QtWidgets').to_s - - # Libraries that Qt depends on. - add_dep 'libQt5Widgets.a', 'libQt5Gui.a' - add_dep 'libQt5FontDatabaseSupport.a', 'libqtfreetype.a' - add_dep 'libQt5Gui.a', 'libQt5Core.a' - add_dep 'libQt5Gui.a', 'libqtlibpng.a' - add_dep 'libQt5Gui.a', 'libqtharfbuzz.a' - add_dep 'libQt5Core.a', 'libqtpcre2.a' - - if Os == 'windows' - add_dep 'Qt5Gui.x', 'qwindows.x' - add_dep 'qwindows.x', 'libqwindows.a' - - add_dep 'libqwindows.a', '-ldwmapi' - add_dep 'libqwindows.a', '-limm32' - add_dep 'libqwindows.a', '-loleaut32' - add_dep 'libqwindows.a', 'libQt5Gui.a' - add_dep 'libqwindows.a', 'libQt5EventDispatcherSupport.a' - add_dep 'libqwindows.a', 'libQt5FontDatabaseSupport.a' - add_dep 'libqwindows.a', 'libQt5ThemeSupport.a' - - add_dep 'libQt5Core.a', '-lole32' - add_dep 'libQt5Core.a', '-luuid' - add_dep 'libQt5Core.a', '-lversion' - add_dep 'libQt5Core.a', '-lwinmm' - add_dep 'libQt5Core.a', '-lws2_32' - - add_dep 'libQt5Gui.a', '-lopengl32' - - add_dep 'libQt5Widgets.a', '-luxtheme' - end - - if Os == 'linux' - add_dep 'Qt5Gui.x', 'qlinuxfb.x' - add_dep 'Qt5Gui.x', 'qxcb.x' - add_dep 'qlinuxfb.x', 'libqlinuxfb.a' - add_dep 'qxcb.x', 'libqxcb.a' - - add_dep 'libqlinuxfb.a', 'libQt5FbSupport.a' - add_dep 'libqlinuxfb.a', 'libQt5InputSupport.a' - - add_dep 'libqxcb.a', 'libQt5XcbQpa.a' - - add_dep 'libQt5DBus.a', 'libQt5Core.a' - add_dep 'libQt5DBus.a', 'libQt5Gui.a' - add_dep 'libQt5DeviceDiscoverySupport.a', 'libudev.pc' - add_dep 'libQt5InputSupport.a', 'libQt5DeviceDiscoverySupport.a' - add_dep 'libQt5LinuxAccessibilitySupport.a', 'libQt5AccessibilitySupport.a' - add_dep 'libQt5LinuxAccessibilitySupport.a', 'libQt5DBus.a' - add_dep 'libQt5LinuxAccessibilitySupport.a', 'xcb-aux.pc' - add_dep 'libQt5ThemeSupport.a', 'libQt5DBus.a' - - add_dep 'libQt5XcbQpa.a', 'libQt5EventDispatcherSupport.a' - add_dep 'libQt5XcbQpa.a', 'libQt5FontDatabaseSupport.a' - add_dep 'libQt5XcbQpa.a', 'libQt5Gui.a' - add_dep 'libQt5XcbQpa.a', 'libQt5LinuxAccessibilitySupport.a' - add_dep 'libQt5XcbQpa.a', 'libQt5ServiceSupport.a' - add_dep 'libQt5XcbQpa.a', 'libQt5ThemeSupport.a' - add_dep 'libQt5XcbQpa.a', 'x11.pc' - add_dep 'libQt5XcbQpa.a', 'x11-xcb.pc' - add_dep 'libQt5XcbQpa.a', 'xcb.pc' - add_dep 'libQt5XcbQpa.a', 'xcb-icccm.pc' - add_dep 'libQt5XcbQpa.a', 'xcb-image.pc' - add_dep 'libQt5XcbQpa.a', 'xcb-keysyms.pc' - add_dep 'libQt5XcbQpa.a', 'xcb-randr.pc' - add_dep 'libQt5XcbQpa.a', 'xcb-renderutil.pc' - add_dep 'libQt5XcbQpa.a', 'xcb-shape.pc' - add_dep 'libQt5XcbQpa.a', 'xcb-shm.pc' - add_dep 'libQt5XcbQpa.a', 'xcb-sync.pc' - add_dep 'libQt5XcbQpa.a', 'xcb-xfixes.pc' - add_dep 'libQt5XcbQpa.a', 'xcb-xinerama.pc' - add_dep 'libQt5XcbQpa.a', 'xcb-xkb.pc' - add_dep 'libQt5XcbQpa.a', 'xi.pc' - end - - if Os == 'macos' - add_dep 'Qt5Gui.x', 'qcocoa.x' - add_dep 'qcocoa.x', 'libqcocoa.a' - - add_dep 'libqcocoa.a', 'libcocoaprintersupport.a' - add_dep 'libqcocoa.a', '-lcups' # Also available: -lcups.2 - add_dep 'libqcocoa.a', 'libQt5AccessibilitySupport.a' - add_dep 'libqcocoa.a', 'libQt5ClipboardSupport.a' - add_dep 'libqcocoa.a', 'libQt5CglSupport.a' - add_dep 'libqcocoa.a', 'libQt5GraphicsSupport.a' - add_dep 'libqcocoa.a', 'libQt5FontDatabaseSupport.a' - add_dep 'libqcocoa.a', 'libQt5ThemeSupport.a' - add_dep 'libqcocoa.a', 'libQt5PrintSupport.a' - - add_dep 'libqtlibpng.a', '-lz' - - add_dep 'libQt5Core.a', '-lobjc' - add_dep 'libQt5Core.a', '-framework CoreServices' - add_dep 'libQt5Core.a', '-framework CoreText' - add_dep 'libQt5Gui.a', '-framework CoreGraphics' - add_dep 'libQt5Gui.a', '-framework OpenGL' - add_dep 'libQt5Widgets.a', '-framework Carbon' - add_dep 'libQt5Widgets.a', '-framework AppKit' - end - - add_deps_of_pc_files -end - -# Qt depends on some system libraries with .pc files. It tends to only depend -# on these things at link time, not compile time. So use pkg-config with --libs -# to get those dependencies, for use in .cmake files. -def add_deps_of_pc_files - DepGraph.keys.each do |dep| - next if determine_dep_type(dep) != :pc - name = dep.chomp('.pc') - new_deps = `pkg-config-cross --libs #{name}`.split(' ') - raise "Failed to #{dep} libs" if $?.exitstatus != 0 - new_deps.each do |new_dep| - add_dep dep, new_dep - end - end -end - -def add_dep(library, *deps) - a = DepGraph[library] ||= [] - DepGraphBack[library] ||= [] - deps.each do |dep| - DepGraph[dep] ||= [] - a << dep unless a.include? dep - (DepGraphBack[dep] ||= []) << library - end -end - -# Given a name of a dep in the graph, figure out what kind of dep -# it use. -def determine_dep_type(name) - extension = Pathname(name).extname - case - when extension == '.a' then :a - when extension == '.pc' then :pc - when extension == '.x' then :x - when name.start_with?('-I') then :incdirflag - when name.start_with?('-L') then :libdirflag - when name.start_with?('-l') then :ldflag - when name.start_with?('-framework') then :ldflag - end -end - -def find_pkg_config_file(name) - ENV.fetch('PKG_CONFIG_CROSS_PATH').split(':').each do |dir| - path = Pathname(dir) + name - return path if path.exist? - end - nil -end - -def find_qt_library(name) - debug_name = Pathname(name).sub_ext("d.a").to_s - - search_dirs = [ OutDir + 'lib' ] + - (OutDir + 'plugins').children - - search_dirs.each do |dir| - lib = dir + name - return lib if lib.exist? - end - - search_dirs.each do |dir| - lib = dir + debug_name - return lib if lib.exist? - end - - nil -end - -def find_dep_info(name) - case determine_dep_type(name) - when :a then find_qt_library(name) - when :pc then find_pkg_config_file(name) - end -end - -# Given an array of dependencies and a block for retrieving dependencies of an -# dependency, returns an array of dependencies with three guarantees: -# -# 1) Contains all the listed dependencies. -# 2) Has no duplicates. -# 3) For any dependency in the list, all of its dependencies are before it. -# -# Guarantee 3 only holds if the underlying graph has no circul dependencies. If -# there is a circular dependency, it will not be detected, but it will not cause -# an infinite loop either. -def flatten_deps(deps) - work = [].concat(deps) - expanded = {} - output = {} - while !work.empty? - dep = work.last - if expanded[dep] - output[dep] = true - work.pop - else - expanded[dep] = true - deps = yield dep - work.concat(deps) - end - end - output.keys # relies on Ruby's ordered hashes -end - -def canonical_x_file(dep) - return nil if determine_dep_type(dep) != :a - x_files = DepGraphBack.fetch(dep).select do |name| - determine_dep_type(name) == :x - end - if x_files.size > 2 - raise "There is more than one .x file #{dep}." - end - x_files.first -end - -# Note: It would be nice to find some solution so that Qt5Widgets.pc does not -# require Qt5GuiNoPlugins, since it already requires Qt5Gui. -def flatten_deps_for_pc_file(pc_file) - flatten_deps(DepGraph[pc_file]) do |dep| - deps = case determine_dep_type(dep) - when :x, :pc then - # Don't expand dependencies for a .pc file because we can just - # refer to them with the Requires line in our .pc file. - [] - else DepGraph.fetch(dep) - end - - # Replace .a files with a canonical .x file if there is one. - deps.map do |name| - substitute = canonical_x_file(name) - substitute = nil if substitute == pc_file - substitute || name - end - end -end - -def flatten_deps_for_cmake_file(cmake_file) - flatten_deps(DepGraph[cmake_file]) do |dep| - DepGraph.fetch(dep) - end -end - -def create_pc_file(name) - requires = [] - libdirs = [] - ldflags = [] - cflags = [] - - deps = flatten_deps_for_pc_file(name) - - deps.each do |dep| - dep = dep.dup - case determine_dep_type(dep) - when :a then - full_path = DepInfo[dep] - raise "Could not find library: #{dep}" if !full_path - libdir = full_path.dirname.to_s - libdir.sub!((OutDir + 'lib').to_s, '${libdir}') - libdir.sub!(OutDir.to_s, '${prefix}') - libname = full_path.basename.to_s - libname.sub!(/\Alib/, '') - libname.sub!(/.a\Z/, '') - libdirs << "-L#{libdir}" - ldflags << "-l#{libname}" - when :x then - dep.chomp!('.x') - requires << dep - when :pc then - dep.chomp!('.pc') - requires << dep - when :ldflag then - ldflags << dep - when :libdirflag then - libdirs << dep - when :incdirflag then - dep.sub!(OutIncDir.to_s, '${includedir}') - cflags << dep - end - end - - r = "" - r << "prefix=#{OutDir}\n" - r << "libdir=${prefix}/lib\n" - r << "includedir=${prefix}/include\n" - r << "Version: #{QtVersionString}\n" - if !libdirs.empty? || !ldflags.empty? - r << "Libs: #{libdirs.reverse.uniq.join(' ')} #{ldflags.reverse.join(' ')}\n" - end - if !cflags.empty? - r << "Cflags: #{cflags.join(' ')}\n" - end - if !requires.empty? - r << "Requires: #{requires.sort.join(' ')}\n" - end - - path = OutPcDir + Pathname(name).sub_ext(".pc") - File.open(path.to_s, 'w') do |f| - f.write r - end -end - -# For .pc files we depend on, add symlinks to the .pc file and any other .pc -# files in the same directory which might be transitive dependencies. -def symlink_pc_file_closure(name) - dep_pc_dir = DepInfo[name].dirname - dep_pc_dir.each_child do |target| - link = OutPcDir + target.basename - - # Skip it if we already made this link. - next if link.symlink? - - # Link directly to the real PC file. - target = target.realpath - - ln_s target, link - end -end - -def create_pc_files - mkdir OutPcDir - DepGraph.each_key do |name| - case determine_dep_type(name) - when :x then create_pc_file(name) - when :pc then symlink_pc_file_closure(name) - end - end -end - -def set_property(f, target_name, property_name, value) - if value.is_a?(Array) - value = value.map do |entry| - if entry.to_s.include?(' ') - "\"#{entry}\"" - else - entry - end - end.join(' ') - end - - f.puts "set_property(TARGET #{target_name} " \ - "PROPERTY #{property_name} #{value})" -end - -def set_properties(f, target_name, properties) - properties.each do |property_name, value| - set_property(f, target_name, property_name, value) - end -end - -def import_static_lib(f, target_name, properties) - f.puts "add_library(#{target_name} STATIC IMPORTED)" - set_properties(f, target_name, properties) -end - -def create_cmake_core_files - File.open(CMakeDir + 'core.cmake', 'w') do |f| - f.puts "set(QT_VERSION_MAJOR #{QtVersionMajor})" - f.puts - - f.puts "set(QT_MOC_EXECUTABLE #{MocExe})" - f.puts "add_executable(Qt5::moc IMPORTED)" - f.puts "set_target_properties(Qt5::moc PROPERTIES " \ - "IMPORTED_LOCATION ${QT_MOC_EXECUTABLE})" - f.puts - - f.puts "add_executable(Qt5::rcc IMPORTED)" - f.puts "set_target_properties(Qt5::rcc PROPERTIES " \ - "IMPORTED_LOCATION #{RccExe})" - f.puts "set(Qt5Core_RCC_EXECUTABLE Qt5::rcc)" - f.puts - - f.write File.read(ENV.fetch('core_macros')) - end -end - -def create_cmake_qt5widgets - mkdir CMakeDir + 'Qt5Widgets' - - widgets_a = find_qt_library('libQt5Widgets.a') || raise - - deps = flatten_deps_for_cmake_file('Qt5Widgets.x') - - incdirs = [] - libdirflags = [] - ldflags = [] - deps.each do |dep| - dep = dep.dup - case determine_dep_type(dep) - when :a then - full_path = DepInfo[dep] - raise "Could not find library: #{dep}" if !full_path - libdir = full_path.dirname.to_s - libname = full_path.basename.to_s - libname.sub!(/\Alib/, '') - libname.sub!(/.a\Z/, '') - libdirflags << "-L#{libdir}" - ldflags << "-l#{libname}" - when :ldflag then - ldflags << dep - when :libdirflag then - libdirflags << dep - when :incdirflag then - incdir = dep.sub(/\A-I/, '') - incdirs << incdir - end - end - - File.open(CMakeDir + 'Qt5Widgets' + 'Qt5WidgetsConfig.cmake', 'w') do |f| - import_static_lib f, 'Qt5::Widgets', - IMPORTED_LOCATION: widgets_a, - IMPORTED_LINK_INTERFACE_LANGUAGES: 'CXX', - INTERFACE_LINK_LIBRARIES: libdirflags.reverse.uniq + ldflags.reverse, - INTERFACE_INCLUDE_DIRECTORIES: incdirs, - INTERFACE_COMPILE_DEFINITIONS: 'QT_STATIC' - - f.puts "include(#{CMakeDir + 'core.cmake'})" - end -end - -def main - # Symlink the include, bin, and plugins directories into $out. - mkdir OutDir - ln_s QtBaseDir + 'include', OutDir + 'include' - ln_s QtBaseDir + 'bin', OutDir + 'bin' - ln_s QtBaseDir + 'plugins', OutDir + 'plugins' - ln_s QtBaseDir + 'src', OutDir + 'src' - - # Symlink the .a files and copy the .prl files into $out/lib. - mkdir OutDir + 'lib' - (QtBaseDir + 'lib').each_child do |c| - ln_s c, OutDir + 'lib' if c.extname == '.a' - cp c, OutDir + 'lib' if c.extname == '.prl' - end - - make_dep_graph - - create_pc_files - - mkdir CMakeDir - create_cmake_core_files - create_cmake_qt5widgets -end - -main diff --git a/nix/nixcrpkgs/pkgs/readline/builder.sh b/nix/nixcrpkgs/pkgs/readline/builder.sh deleted file mode 100644 index defaa8b7d3..0000000000 --- a/nix/nixcrpkgs/pkgs/readline/builder.sh +++ /dev/null @@ -1,32 +0,0 @@ -source $setup - -# This is from the mingw-w64-readline AUR arch package. -export bash_cv_wcwidth_broken=no - -tar -xf $src - -cd readline-$version -for patch in $patches_p2; do - echo applying patch $patch - patch -p2 -i $patch -done -for patch in $patches; do - echo applying patch $patch - patch -p1 -i $patch -done -cd .. - -mkdir build -cd build - -../readline-$version/configure \ - --prefix=$out --host=$host \ - --enable-static --disable-shared \ - --with-curses=$curses - -make - -make install - -mkdir $out/license -cp ../readline-$version/COPYING $out/license/LICENSE diff --git a/nix/nixcrpkgs/pkgs/readline/default.nix b/nix/nixcrpkgs/pkgs/readline/default.nix deleted file mode 100644 index b1369e70f9..0000000000 --- a/nix/nixcrpkgs/pkgs/readline/default.nix +++ /dev/null @@ -1,41 +0,0 @@ -# Note: This has only been tested on Windows, and is using pdcurses -# which only seems to work on Windows. - -{ crossenv, curses }: - -let - fetchurl = crossenv.nixpkgs.fetchurl; -in -crossenv.make_derivation rec { - name = "readline-${version}"; - - version = "7.0"; - - src = fetchurl { - url = "mirror://gnu/readline/readline-${version}.tar.gz"; - sha256 = "0d13sg9ksf982rrrmv5mb6a2p4ys9rvg9r71d6il0vr8hmql63bm"; - }; - - patches_p2 = [ - (fetchurl { - url = "mirror://gnu/readline/readline-7.0-patches/readline70-001"; - sha256 = "0xm3sxvwmss7ddyfb11n6pgcqd1aglnpy15g143vzcf75snb7hcs"; - }) - (fetchurl { - url = "mirror://gnu/readline/readline-7.0-patches/readline70-002"; - sha256 = "0n1dxmqsbjgrfxb1hgk5c6lsraw4ncbnzxlsx7m35nym6lncjiw7"; - }) - (fetchurl { - url = "mirror://gnu/readline/readline-7.0-patches/readline70-003"; - sha256 = "1027kmymniizcy0zbdlrczxfx3clxcdln5yq05q9yzlc6y9slhwy"; - }) - ]; - - patches = [ - ./readline-1.patch - ]; - - builder = ./builder.sh; - - inherit curses; -} diff --git a/nix/nixcrpkgs/pkgs/readline/readline-1.patch b/nix/nixcrpkgs/pkgs/readline/readline-1.patch deleted file mode 100644 index 52938b8048..0000000000 --- a/nix/nixcrpkgs/pkgs/readline/readline-1.patch +++ /dev/null @@ -1,171 +0,0 @@ -We got this patch from the mingw-w64-readline AUR Arch package. - -This patch originall comes from MXE, and is licensed under the MIT license. - -https://github.com/mxe/mxe/blob/master/src/readline-1.patch - -Copyright (c) 2007-2016 - -Volker Diels-Grabsch -Mark Brand -Tony Theodore -Martin Gerhardy -Tiancheng "Timothy" Gu -Boris Nagaev -... and many other contributors -(contact via the project mailing list or issue tracker) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of -the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. - -From 6896ffa4fc85bf0dfae58e69a860d2076c1d9fd2 Mon Sep 17 00:00:00 2001 -From: Timothy Gu -Date: Tue, 30 Sep 2014 17:16:32 -0700 -Subject: [PATCH 2/2] Handle missing S_IS* macros more gracefully - -diff --git a/colors.c b/colors.c -index 89d9035..ec19844 100644 ---- a/colors.c -+++ b/colors.c -@@ -152,14 +152,22 @@ _rl_print_color_indicator (char *f) - { - colored_filetype = C_FILE; - -+#if defined (S_ISUID) - if ((mode & S_ISUID) != 0 && is_colored (C_SETUID)) - colored_filetype = C_SETUID; -- else if ((mode & S_ISGID) != 0 && is_colored (C_SETGID)) -+ else -+#endif -+#if defined (S_ISGID) -+ if ((mode & S_ISGID) != 0 && is_colored (C_SETGID)) - colored_filetype = C_SETGID; -- else if (is_colored (C_CAP) && 0) //f->has_capability) -+ else -+#endif -+ if (is_colored (C_CAP) && 0) //f->has_capability) - colored_filetype = C_CAP; -+#if defined(S_IXUGO) - else if ((mode & S_IXUGO) != 0 && is_colored (C_EXEC)) - colored_filetype = C_EXEC; -+#endif - else if ((1 < astat.st_nlink) && is_colored (C_MULTIHARDLINK)) - colored_filetype = C_MULTIHARDLINK; - } -@@ -173,8 +181,10 @@ _rl_print_color_indicator (char *f) - colored_filetype = C_STICKY_OTHER_WRITABLE; - else - #endif -+#if defined (S_IWOTH) - if ((mode & S_IWOTH) != 0 && is_colored (C_OTHER_WRITABLE)) - colored_filetype = C_OTHER_WRITABLE; -+#endif - #if defined (S_ISVTX) - else if ((mode & S_ISVTX) != 0 && is_colored (C_STICKY)) - colored_filetype = C_STICKY; -diff --git a/colors.h b/colors.h -index fc926e5..e62edd0 100644 ---- a/colors.h -+++ b/colors.h -@@ -96,7 +96,7 @@ enum indicator_no - }; - - --#if !S_IXUGO -+#if !S_IXUGO && defined(S_IXUSR) && defined(S_IXGRP) && defined(S_IXOTH) - # define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH) - #endif - -diff --git a/posixstat.h b/posixstat.h -index 3eb7f29..854a2c9 100644 ---- a/posixstat.h -+++ b/posixstat.h -@@ -78,30 +78,44 @@ - - #if defined (S_IFBLK) && !defined (S_ISBLK) - #define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK) /* block device */ -+#elif !defined (S_IFBLK) -+#define S_ISBLK(m) 0 - #endif - - #if defined (S_IFCHR) && !defined (S_ISCHR) - #define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR) /* character device */ -+#elif !defined (S_IFCHR) -+#define S_ISCHR(m) 0 - #endif - - #if defined (S_IFDIR) && !defined (S_ISDIR) - #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) /* directory */ -+#elif !defined (S_IFDIR) -+#define S_ISDIR(m) 0 - #endif - - #if defined (S_IFREG) && !defined (S_ISREG) - #define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) /* file */ -+#elif !defined (S_IFREG) -+#define S_ISREG(m) 0 - #endif - - #if defined (S_IFIFO) && !defined (S_ISFIFO) - #define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO) /* fifo - named pipe */ -+#elif !defined (S_IFIFO) -+#define S_ISFIFO(m) 0 - #endif - - #if defined (S_IFLNK) && !defined (S_ISLNK) - #define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK) /* symbolic link */ -+#elif !defined (S_IFLNK) -+#define S_ISLNK(m) 0 - #endif - - #if defined (S_IFSOCK) && !defined (S_ISSOCK) - #define S_ISSOCK(m) (((m)&S_IFMT) == S_IFSOCK) /* socket */ -+#elif !defined (S_IFSOCK) -+#define S_ISSOCK(m) 0 - #endif - - /* -@@ -137,6 +151,8 @@ - /* These are non-standard, but are used in builtins.c$symbolic_umask() */ - #define S_IRUGO (S_IRUSR | S_IRGRP | S_IROTH) - #define S_IWUGO (S_IWUSR | S_IWGRP | S_IWOTH) -+#if defined(S_IXUSR) && defined(S_IXGRP) && defined(S_IXOTH) - #define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH) -+#endif - - #endif /* _POSIXSTAT_H_ */ --- -1.8.3.2 - -diff --git a/histfile.c b/histfile.c ---- a/histfile.c -+++ b/histfile.c -@@ -610,8 +610,6 @@ - user is running this, it's a no-op. If the shell is running after sudo - with a shared history file, we don't want to leave the history file - owned by root. */ -- if (rv == 0 && exists) -- r = chown (filename, finfo.st_uid, finfo.st_gid); - - xfree (filename); - FREE (tempname); -@@ -757,8 +755,6 @@ - user is running this, it's a no-op. If the shell is running after sudo - with a shared history file, we don't want to leave the history file - owned by root. */ -- if (rv == 0 && exists) -- mode = chown (histname, finfo.st_uid, finfo.st_gid); - - FREE (histname); - FREE (tempname); diff --git a/nix/nixcrpkgs/pkgs/tic/builder.sh b/nix/nixcrpkgs/pkgs/tic/builder.sh deleted file mode 100644 index 5052b2583a..0000000000 --- a/nix/nixcrpkgs/pkgs/tic/builder.sh +++ /dev/null @@ -1,15 +0,0 @@ -source $setup - -tar -xf $src -mv pololu-tic-software-* tic - -mkdir build -cd build - -cmake-cross ../tic \ - -DCMAKE_INSTALL_PREFIX=$out \ - -DBUILD_SHARED_LIBS=false - -make - -make install diff --git a/nix/nixcrpkgs/pkgs/tic/default.nix b/nix/nixcrpkgs/pkgs/tic/default.nix deleted file mode 100644 index 6f870d911c..0000000000 --- a/nix/nixcrpkgs/pkgs/tic/default.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ crossenv, qt, libusbp }: - -crossenv.make_derivation rec { - name = "tic-${version}"; - - version = "e1693cd"; # 1.5.0ish - - src = crossenv.nixpkgs.fetchurl { - url = "https://github.com/pololu/pololu-tic-software/archive/${version}.tar.gz"; - sha256 = "07m75w0walr61yqki7h1ipzbfz7x417g7qnx0p1l6qdz89fyc7i8"; - }; - - builder = ./builder.sh; - - cross_inputs = [ libusbp qt ]; -} diff --git a/nix/nixcrpkgs/pkgs/usbview/builder.sh b/nix/nixcrpkgs/pkgs/usbview/builder.sh deleted file mode 100644 index 3aa4cb9019..0000000000 --- a/nix/nixcrpkgs/pkgs/usbview/builder.sh +++ /dev/null @@ -1,31 +0,0 @@ -source $setup - -cp --no-preserve=mode -r $src/usb/usbview . - -cd usbview -rm usbschema.hpp xmlhelper.cpp -for patch in $patches; do - echo applying patch $patch - patch -p1 -i $patch -done -cp $my_xmlhelper_c . -cd .. - -mkdir build -cd build - -$host-windres ../usbview/uvcview.rc rc.o - -# TODO: after fixing bug with selectany in GCC, remove -DINITGUID - -$host-gcc -mwindows -std=gnu99 -O2 \ - -Iinclude \ - -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0602 \ - -DSTRSAFE_NO_DEPRECATE -Doffsetof=__builtin_offsetof \ - ../usbview/*.c rc.o \ - -lcomctl32 -lcomdlg32 -lsetupapi -lshell32 -lshlwapi -lole32 -lgdi32 \ - -o usbview.exe - -mkdir -p $out/bin $out/license -cp usbview.exe $out/bin -cp $src/LICENSE $out/license diff --git a/nix/nixcrpkgs/pkgs/usbview/default.nix b/nix/nixcrpkgs/pkgs/usbview/default.nix deleted file mode 100644 index 7d5260859a..0000000000 --- a/nix/nixcrpkgs/pkgs/usbview/default.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ crossenv }: - -if crossenv.os != "windows" then "windows only" else - -crossenv.make_derivation rec { - name = "usbview-${version}"; - - version = "2017-05-01"; - - src = crossenv.nixpkgs.fetchFromGitHub { - owner = "Microsoft"; - repo = "Windows-driver-samples"; - rev = "4c5c5e0297c7a61e151f92af702cdac650a14489"; - sha256 = "1drq26bnad98xqn805qx0b6g4y65lmrdj7v40b3jhhzdsp8993pf"; - }; - - patches = [ ./megapatch.patch ]; - - my_xmlhelper_c = ./my_xmlhelper.c; - - builder = ./builder.sh; -} diff --git a/nix/nixcrpkgs/pkgs/usbview/megapatch.patch b/nix/nixcrpkgs/pkgs/usbview/megapatch.patch deleted file mode 100644 index fe3227aee6..0000000000 --- a/nix/nixcrpkgs/pkgs/usbview/megapatch.patch +++ /dev/null @@ -1,107 +0,0 @@ -diff -ur usbview-orig/usbdesc.h usbview/usbdesc.h ---- usbview-orig/usbdesc.h 2017-04-01 16:00:09.314007997 -0700 -+++ usbview/usbdesc.h 2017-04-01 16:10:23.667341332 -0700 -@@ -81,7 +81,7 @@ - #define USB_OTHER_SPEED_CONFIGURATION_DESCRIPTOR_TYPE 0x07 - #define USB_INTERFACE_POWER_DESCRIPTOR_TYPE 0x08 - #define USB_OTG_DESCRIPTOR_TYPE 0x09 --#define USB_DEBUG_DESCRIPTOR_TYPE 0x0A -+//#define USB_DEBUG_DESCRIPTOR_TYPE 0x0A - #define USB_IAD_DESCRIPTOR_TYPE 0x0B - - // -diff -ur usbview-orig/uvcdesc.h usbview/uvcdesc.h ---- usbview-orig/uvcdesc.h 2017-04-01 16:00:09.314007997 -0700 -+++ usbview/uvcdesc.h 2017-04-01 17:43:09.134007999 -0700 -@@ -15,7 +15,7 @@ - - - // USB Video Device Class Code --#define USB_DEVICE_CLASS_VIDEO 0x0E -+//#define USB_DEVICE_CLASS_VIDEO 0x0E - - // Video sub-classes - #define SUBCLASS_UNDEFINED 0x00 -diff -ur usbview-orig/uvcview.h usbview/uvcview.h ---- usbview-orig/uvcview.h 2017-04-01 16:00:09.314007997 -0700 -+++ usbview/uvcview.h 2017-04-03 20:25:08.145676664 -0700 -@@ -34,10 +33,10 @@ - #include - #include - #include --#include - #include - #include - #include -+#include - #include - #include - #include -@@ -50,6 +49,8 @@ - #include - #include - #include -+#include -+#include - - // This is mostly a private USB Audio descriptor header - #include "usbdesc.h" -@@ -381,7 +382,7 @@ - // ENUM.C - // - --PCHAR ConnectionStatuses[]; -+extern PCHAR ConnectionStatuses[]; - - // - // DISPVID.C -Only in usbview: uvcview.h.orig -diff -ur usbview-orig/uvcview.rc usbview/uvcview.rc ---- usbview-orig/uvcview.rc 2017-04-01 16:00:09.314007997 -0700 -+++ usbview/uvcview.rc 2017-04-01 16:04:07.210674665 -0700 -@@ -22,19 +22,19 @@ - // - // ICON - // --IDI_ICON ICON DISCARDABLE "USB.ICO" --IDI_BADICON ICON DISCARDABLE "BANG.ICO" --IDI_COMPUTER ICON DISCARDABLE "MONITOR.ICO" --IDI_HUB ICON DISCARDABLE "HUB.ICO" --IDI_NODEVICE ICON DISCARDABLE "PORT.ICO" --IDI_NOSSDEVICE ICON DISCARDABLE "SSPORT.ICO" --IDI_SSICON ICON DISCARDABLE "SSUSB.ICO" -+IDI_ICON ICON DISCARDABLE "usb.ico" -+IDI_BADICON ICON DISCARDABLE "bang.ico" -+IDI_COMPUTER ICON DISCARDABLE "monitor.ico" -+IDI_HUB ICON DISCARDABLE "hub.ico" -+IDI_NODEVICE ICON DISCARDABLE "port.ico" -+IDI_NOSSDEVICE ICON DISCARDABLE "ssport.ico" -+IDI_SSICON ICON DISCARDABLE "ssusb.ico" - - ////////////////////////////////////////////////////////////////////////////// - // - // Cursor - // --IDC_SPLIT CURSOR DISCARDABLE "SPLIT.CUR" -+IDC_SPLIT CURSOR DISCARDABLE "split.cur" - - ///////////////////////////////////////////////////////////////////////////// - // -@@ -84,7 +84,7 @@ - BEGIN - MENUITEM "&Refresh\tF5", ID_REFRESH - MENUITEM SEPARATOR -- MENUITEM "Save Current &View ..." ID_SAVE -+ MENUITEM "Save Current &View ...", ID_SAVE - MENUITEM "Save As (&txt) ...", ID_SAVEALL - MENUITEM "Save As (&xml) ...\tF2", ID_SAVEXML - MENUITEM SEPARATOR -@@ -130,7 +130,7 @@ - BEGIN - IDS_STANDARD_FONT "Courier" - IDS_STANDARD_FONT_HEIGHT "\13" -- IDS_STANDARD_FONT_WIDTH "\8" -+ IDS_STANDARD_FONT_WIDTH "\08" - END - - STRINGTABLE DISCARDABLE diff --git a/nix/nixcrpkgs/pkgs/usbview/my_xmlhelper.c b/nix/nixcrpkgs/pkgs/usbview/my_xmlhelper.c deleted file mode 100644 index 0cdf29140b..0000000000 --- a/nix/nixcrpkgs/pkgs/usbview/my_xmlhelper.c +++ /dev/null @@ -1,47 +0,0 @@ -#include "xmlhelper.h" - -EXTERN_C HRESULT InitXmlHelper() -{ - return 0; -} - -EXTERN_C HRESULT ReleaseXmlWriter() -{ - return 0; -} - -EXTERN_C HRESULT SaveXml(LPTSTR szfileName, DWORD dwCreationDisposition) -{ - MessageBox(NULL, - "Sorry, XML saving is not supported in this build.", - "XML not supported", - MB_OK | MB_ICONEXCLAMATION); - return 0; -} - -EXTERN_C HRESULT XmlAddHostController( - PSTR hcName, - PUSBHOSTCONTROLLERINFO hcInfo - ) -{ - return 0; -} - -EXTERN_C HRESULT XmlAddRootHub(PSTR rhName, PUSBROOTHUBINFO rhInfo) -{ - return 0; -} - -EXTERN_C HRESULT XmlAddExternalHub(PSTR ehName, PUSBEXTERNALHUBINFO ehInfo) -{ - return 0; -} - -EXTERN_C HRESULT XmlAddUsbDevice(PSTR devName, PUSBDEVICEINFO deviceInfo) -{ - return 0; -} - -EXTERN_C VOID XmlNotifyEndOfNodeList(PVOID pContext) -{ -} diff --git a/nix/nixcrpkgs/pkgs/xcb-proto/builder.sh b/nix/nixcrpkgs/pkgs/xcb-proto/builder.sh deleted file mode 100644 index e83c5bbb34..0000000000 --- a/nix/nixcrpkgs/pkgs/xcb-proto/builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -ls -mv xcb-proto-* xcb-proto - -mkdir build -cd build - -../xcb-proto/configure --prefix=$out - -make - -make install diff --git a/nix/nixcrpkgs/pkgs/xcb-proto/default.nix b/nix/nixcrpkgs/pkgs/xcb-proto/default.nix deleted file mode 100644 index b9cdc0b1fc..0000000000 --- a/nix/nixcrpkgs/pkgs/xcb-proto/default.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ crossenv }: - -let - version = "1.12"; - - name = "xcb-proto-${version}"; - - src = crossenv.nixpkgs.fetchurl { - url = "https://xcb.freedesktop.org/dist/xcb-proto-${version}.tar.bz2"; - sha256 = "01j91946q8f34l1mbvmmgvyc393sm28ym4lxlacpiav4qsjan8jr"; - }; - - lib = crossenv.native.make_derivation rec { - inherit version name src; - builder = ./builder.sh; - native_inputs = [ crossenv.nixpkgs.python2 ]; - }; - - license = crossenv.native.make_derivation { - name = "${name}-license"; - inherit src; - builder = ./license_builder.sh; - }; - - license_set = { "${name}" = license; }; - -in - lib // { inherit license_set; } diff --git a/nix/nixcrpkgs/pkgs/xcb-proto/license_builder.sh b/nix/nixcrpkgs/pkgs/xcb-proto/license_builder.sh deleted file mode 100644 index 2ea7114353..0000000000 --- a/nix/nixcrpkgs/pkgs/xcb-proto/license_builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -mv xcb-proto-* xcb-proto - -license=$(cat xcb-proto/COPYING) - -cat > $out <xcb-proto - -
-$license
-
-EOF diff --git a/nix/nixcrpkgs/pkgs/xcb-util-image/default.nix b/nix/nixcrpkgs/pkgs/xcb-util-image/default.nix deleted file mode 100644 index 14a5b54583..0000000000 --- a/nix/nixcrpkgs/pkgs/xcb-util-image/default.nix +++ /dev/null @@ -1,40 +0,0 @@ -{ crossenv, libxcb, xcb-util }: - -let - version = "0.4.0"; - - name = "xcb-util-image-${version}"; - - src = crossenv.nixpkgs.fetchurl { - url = "https://xcb.freedesktop.org/dist/xcb-util-image-${version}.tar.bz2"; - sha256 = "1z1gxacg7q4cw6jrd26gvi5y04npsyavblcdad1xccc8swvnmf9d"; - }; - - lib = crossenv.make_derivation rec { - inherit version name src; - builder = ./util_image_builder.sh; - - configure_flags = - "--host=${crossenv.host} " + - "--enable-static " + - "--disable-shared"; - - cross_inputs = [ libxcb xcb-util ]; - - inherit libxcb; - libxcb_util = xcb-util; - }; - - license = crossenv.native.make_derivation { - name = "${name}-license"; - inherit src; - builder = ./license_builder.sh; - }; - - license_set = - libxcb.license_set // - xcb-util.license_set // - { "${name}" = license; }; - -in - lib // { inherit license_set; } diff --git a/nix/nixcrpkgs/pkgs/xcb-util-image/license_builder.sh b/nix/nixcrpkgs/pkgs/xcb-util-image/license_builder.sh deleted file mode 100644 index 9cc75651e6..0000000000 --- a/nix/nixcrpkgs/pkgs/xcb-util-image/license_builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -mv xcb-util-image-* xcb-util-image - -license=$(cat xcb-util-image/COPYING) - -cat > $out <xcb-util-image - -
-$license
-
-EOF diff --git a/nix/nixcrpkgs/pkgs/xcb-util-image/util_image_builder.sh b/nix/nixcrpkgs/pkgs/xcb-util-image/util_image_builder.sh deleted file mode 100644 index 3b5d1e6cf3..0000000000 --- a/nix/nixcrpkgs/pkgs/xcb-util-image/util_image_builder.sh +++ /dev/null @@ -1,20 +0,0 @@ -source $setup - -tar -xf $src -mv xcb-* util - -mkdir build -cd build - -PKG_CONFIG=pkg-config-cross \ -../util/configure --prefix=$out $configure_flags - -make - -make install - -# xcb-util-image-0.4.0/image/xcb_image.c includes -echo "Requires: xcb-aux" >> $out/lib/pkgconfig/xcb-image.pc -ln -sf $libxcb/lib/pkgconfig/*.pc $out/lib/pkgconfig/ -ln -sf $libxcb_util/lib/pkgconfig/*.pc $out/lib/pkgconfig/ - diff --git a/nix/nixcrpkgs/pkgs/xcb-util-keysyms/default.nix b/nix/nixcrpkgs/pkgs/xcb-util-keysyms/default.nix deleted file mode 100644 index 6d5b8298f0..0000000000 --- a/nix/nixcrpkgs/pkgs/xcb-util-keysyms/default.nix +++ /dev/null @@ -1,37 +0,0 @@ -{ crossenv, libxcb }: - -let - version = "0.4.0"; - - name = "xcb-util-keysyms"; - - src = crossenv.nixpkgs.fetchurl { - url = "https://xcb.freedesktop.org/dist/xcb-util-keysyms-${version}.tar.bz2"; - sha256 = "1nbd45pzc1wm6v5drr5338j4nicbgxa5hcakvsvm5pnyy47lky0f"; - }; - - lib = crossenv.make_derivation rec { - inherit version name src; - - builder = ./util_keysyms_builder.sh; - - configure_flags = - "--host=${crossenv.host} " + - "--enable-static " + - "--disable-shared"; - - cross_inputs = [ libxcb ]; - }; - - license = crossenv.native.make_derivation { - name = "${name}-license"; - inherit src; - builder = ./license_builder.sh; - }; - - license_set = - libxcb.license_set // - { "${name}" = license; }; - -in - lib // { inherit license_set; } diff --git a/nix/nixcrpkgs/pkgs/xcb-util-keysyms/license_builder.sh b/nix/nixcrpkgs/pkgs/xcb-util-keysyms/license_builder.sh deleted file mode 100644 index 66175097fa..0000000000 --- a/nix/nixcrpkgs/pkgs/xcb-util-keysyms/license_builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -mv xcb-util-keysyms-* xcb-util-keysyms - -license=$(head -n31 xcb-util-keysyms/keysyms/keysyms.c) - -cat > $out <xcb-util-keysyms - -
-$license
-
-EOF diff --git a/nix/nixcrpkgs/pkgs/xcb-util-keysyms/util_keysyms_builder.sh b/nix/nixcrpkgs/pkgs/xcb-util-keysyms/util_keysyms_builder.sh deleted file mode 100644 index eaa8982251..0000000000 --- a/nix/nixcrpkgs/pkgs/xcb-util-keysyms/util_keysyms_builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -mv xcb-* util - -mkdir build -cd build - -PKG_CONFIG=pkg-config-cross \ -../util/configure --prefix=$out $configure_flags - -make - -make install diff --git a/nix/nixcrpkgs/pkgs/xcb-util-renderutil/default.nix b/nix/nixcrpkgs/pkgs/xcb-util-renderutil/default.nix deleted file mode 100644 index f20b271e31..0000000000 --- a/nix/nixcrpkgs/pkgs/xcb-util-renderutil/default.nix +++ /dev/null @@ -1,40 +0,0 @@ -{ crossenv, libxcb }: - -let - version = "0.3.9"; - - name = "xcb-util-renderutil"; # TODO: add -${version} (mass rebuild) - - src = crossenv.nixpkgs.fetchurl { - url = "https://xcb.freedesktop.org/dist/xcb-util-renderutil-${version}.tar.bz2"; - sha256 = "0nza1csdvvxbmk8vgv8vpmq7q8h05xrw3cfx9lwxd1hjzd47xsf6"; - }; - - lib = crossenv.make_derivation { - inherit version name src; - - # TODO: rename all xcb-util builders to builder.sh (mass rebuild) - builder = ./util_renderutil_builder.sh; - - configure_flags = - "--host=${crossenv.host} " + - "--enable-static " + - "--disable-shared"; - - cross_inputs = [ libxcb ]; - - xcb = libxcb; - }; - - license = crossenv.native.make_derivation { - name = "${name}-license"; - inherit src; - builder = ./license_builder.sh; - }; - - license_set = - libxcb.license_set // - { "${name}" = license; }; - -in - lib // { inherit license_set; } diff --git a/nix/nixcrpkgs/pkgs/xcb-util-renderutil/license_builder.sh b/nix/nixcrpkgs/pkgs/xcb-util-renderutil/license_builder.sh deleted file mode 100644 index 96f60bcf96..0000000000 --- a/nix/nixcrpkgs/pkgs/xcb-util-renderutil/license_builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -mv xcb-util-renderutil-* xcb-util-renderutil - -license=$(cat xcb-util-renderutil/COPYING) - -cat > $out <xcb-util-renderutil - -
-$license
-
-EOF diff --git a/nix/nixcrpkgs/pkgs/xcb-util-renderutil/util_renderutil_builder.sh b/nix/nixcrpkgs/pkgs/xcb-util-renderutil/util_renderutil_builder.sh deleted file mode 100644 index 4540eae4cb..0000000000 --- a/nix/nixcrpkgs/pkgs/xcb-util-renderutil/util_renderutil_builder.sh +++ /dev/null @@ -1,16 +0,0 @@ -source $setup - -tar -xf $src -mv xcb-* util - -mkdir build -cd build - -PKG_CONFIG=pkg-config-cross \ -../util/configure --prefix=$out $configure_flags - -make - -make install - -ln -s $xcb/lib/pkgconfig/{xcb,xcb-render}.pc $out/lib/pkgconfig/ diff --git a/nix/nixcrpkgs/pkgs/xcb-util-wm/default.nix b/nix/nixcrpkgs/pkgs/xcb-util-wm/default.nix deleted file mode 100644 index 1390a4abdf..0000000000 --- a/nix/nixcrpkgs/pkgs/xcb-util-wm/default.nix +++ /dev/null @@ -1,39 +0,0 @@ -{ crossenv, libxcb }: - -let - version = "0.4.1"; - - name = "xcb-util-wm-${version}"; - - src = crossenv.nixpkgs.fetchurl { - url = "https://xcb.freedesktop.org/dist/xcb-util-wm-${version}.tar.bz2"; - sha256 = "0gra7hfyxajic4mjd63cpqvd20si53j1q3rbdlkqkahfciwq3gr8"; - }; - - lib = crossenv.make_derivation rec { - inherit version name src; - - builder = ./util_wm_builder.sh; - - configure_flags = - "--host=${crossenv.host} " + - "--enable-static " + - "--disable-shared"; - - cross_inputs = [ libxcb ]; - - native_inputs = [ crossenv.nixpkgs.m4 ]; - }; - - license = crossenv.native.make_derivation { - name = "${name}-license"; - inherit src; - builder = ./license_builder.sh; - }; - - license_set = - libxcb.license_set // - { "${name}" = license; }; - -in - lib // { inherit license_set; } diff --git a/nix/nixcrpkgs/pkgs/xcb-util-wm/license_builder.sh b/nix/nixcrpkgs/pkgs/xcb-util-wm/license_builder.sh deleted file mode 100644 index adbaa5ed50..0000000000 --- a/nix/nixcrpkgs/pkgs/xcb-util-wm/license_builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -mv xcb-util-wm-* xcb-util-wm - -license=$(cat xcb-util-wm/COPYING) - -cat > $out <xcb-util-wm - -
-$license
-
-EOF diff --git a/nix/nixcrpkgs/pkgs/xcb-util-wm/util_wm_builder.sh b/nix/nixcrpkgs/pkgs/xcb-util-wm/util_wm_builder.sh deleted file mode 100644 index eaa8982251..0000000000 --- a/nix/nixcrpkgs/pkgs/xcb-util-wm/util_wm_builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -mv xcb-* util - -mkdir build -cd build - -PKG_CONFIG=pkg-config-cross \ -../util/configure --prefix=$out $configure_flags - -make - -make install diff --git a/nix/nixcrpkgs/pkgs/xcb-util/default.nix b/nix/nixcrpkgs/pkgs/xcb-util/default.nix deleted file mode 100644 index 48cadb58d1..0000000000 --- a/nix/nixcrpkgs/pkgs/xcb-util/default.nix +++ /dev/null @@ -1,37 +0,0 @@ -{ crossenv, libxcb }: - -let - version = "0.4.0"; - - name = "xcb-util-${version}"; - - src = crossenv.nixpkgs.fetchurl { - url = "https://xcb.freedesktop.org/dist/xcb-util-${version}.tar.bz2"; - sha256 = "1sahmrgbpyki4bb72hxym0zvxwnycmswsxiisgqlln9vrdlr9r26"; - }; - - lib = crossenv.make_derivation rec { - inherit version name src; - - builder = ./util_builder.sh; - - configure_flags = - "--host=${crossenv.host} " + - "--enable-static " + - "--disable-shared"; - - cross_inputs = [ libxcb ]; - }; - - license = crossenv.native.make_derivation { - name = "${name}-license"; - inherit src; - builder = ./license_builder.sh; - }; - - license_set = - libxcb.license_set // - { "${name}" = license; }; - -in - lib // { inherit license_set; } diff --git a/nix/nixcrpkgs/pkgs/xcb-util/license_builder.sh b/nix/nixcrpkgs/pkgs/xcb-util/license_builder.sh deleted file mode 100644 index 7d65ade3bd..0000000000 --- a/nix/nixcrpkgs/pkgs/xcb-util/license_builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -mv xcb-util-* xcb-util - -license=$(cat xcb-util/COPYING) - -cat > $out <xcb-util - -
-$license
-
-EOF diff --git a/nix/nixcrpkgs/pkgs/xcb-util/util_builder.sh b/nix/nixcrpkgs/pkgs/xcb-util/util_builder.sh deleted file mode 100644 index 6264407a65..0000000000 --- a/nix/nixcrpkgs/pkgs/xcb-util/util_builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -mv xcb-util-* util - -mkdir build -cd build - -PKG_CONFIG=pkg-config-cross \ -../util/configure --prefix=$out $configure_flags - -make - -make install diff --git a/nix/nixcrpkgs/pkgs/xextproto/builder.sh b/nix/nixcrpkgs/pkgs/xextproto/builder.sh deleted file mode 100644 index 6bf1c02c59..0000000000 --- a/nix/nixcrpkgs/pkgs/xextproto/builder.sh +++ /dev/null @@ -1,13 +0,0 @@ -source $setup - -tar -xf $src -mv xextproto-* xextproto - -mkdir build -cd build - -../xextproto/configure --prefix=$out - -make - -make install diff --git a/nix/nixcrpkgs/pkgs/xextproto/default.nix b/nix/nixcrpkgs/pkgs/xextproto/default.nix deleted file mode 100644 index 82b0a626ec..0000000000 --- a/nix/nixcrpkgs/pkgs/xextproto/default.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ crossenv }: - -let - version = "7.3.0"; - - name = "xextproto-${version}"; - - src = crossenv.nixpkgs.fetchurl { - url = "https://xorg.freedesktop.org/releases/individual/proto/xextproto-${version}.tar.bz2"; - sha256 = "1c2vma9gqgc2v06rfxdiqgwhxmzk2cbmknwf1ng3m76vr0xb5x7k"; - }; - - lib = crossenv.native.make_derivation rec { - inherit version name src; - builder = ./builder.sh; - }; - - license = crossenv.native.make_derivation { - name = "${name}-license"; - inherit src; - builder = ./license_builder.sh; - }; - - license_set = { "${name}" = license; }; - -in - lib // { inherit license_set; } diff --git a/nix/nixcrpkgs/pkgs/xextproto/license_builder.sh b/nix/nixcrpkgs/pkgs/xextproto/license_builder.sh deleted file mode 100644 index 9fbf3543d3..0000000000 --- a/nix/nixcrpkgs/pkgs/xextproto/license_builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -mv xextproto-* xextproto - -license=$(cat xextproto/COPYING) - -cat > $out <xextproto - -
-$license
-
-EOF diff --git a/nix/nixcrpkgs/pkgs/xorg-macros/builder.sh b/nix/nixcrpkgs/pkgs/xorg-macros/builder.sh deleted file mode 100644 index f940d965f1..0000000000 --- a/nix/nixcrpkgs/pkgs/xorg-macros/builder.sh +++ /dev/null @@ -1,18 +0,0 @@ -source $setup - -tar -xf $src -ls -mv util-macros-* macros - -mkdir build -cd build - -../macros/configure --prefix=$out - -make - -make install - -# The .pc files gets installed to /share/pkgconfig, but we want to see it in -# /lib/pkgconfig. -ln -s share $out/lib diff --git a/nix/nixcrpkgs/pkgs/xorg-macros/default.nix b/nix/nixcrpkgs/pkgs/xorg-macros/default.nix deleted file mode 100644 index 2f5c8508f9..0000000000 --- a/nix/nixcrpkgs/pkgs/xorg-macros/default.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ crossenv }: - -let - version = "1.19.1"; - - name = "xorg-macros-${version}"; - - src = crossenv.nixpkgs.fetchurl { - url = "https://www.x.org/releases/individual/util/util-macros-1.19.1.tar.gz"; - sha256 = "1f27cmbxq0kdyvqsplxpsi9pxm5qy45lcagxr9gby2hy3pjd0aj7"; - }; - - lib = crossenv.native.make_derivation { - inherit version name src; - builder = ./builder.sh; - }; - - license = crossenv.native.make_derivation { - name = "${name}-license"; - inherit src; - builder = ./license_builder.sh; - }; - - license_set = { "${name}" = license; }; - -in - lib // { inherit license_set; } diff --git a/nix/nixcrpkgs/pkgs/xorg-macros/license_builder.sh b/nix/nixcrpkgs/pkgs/xorg-macros/license_builder.sh deleted file mode 100644 index fb723a09de..0000000000 --- a/nix/nixcrpkgs/pkgs/xorg-macros/license_builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -mv util-macros-* xorg-macros - -license=$(cat xorg-macros/COPYING) - -cat > $out <xorg-macros - -
-$license
-
-EOF diff --git a/nix/nixcrpkgs/pkgs/xproto/builder.sh b/nix/nixcrpkgs/pkgs/xproto/builder.sh deleted file mode 100644 index 7f6b13edbd..0000000000 --- a/nix/nixcrpkgs/pkgs/xproto/builder.sh +++ /dev/null @@ -1,16 +0,0 @@ -source $setup - -tar -xf $src -mv xproto-* xproto - -cp $gnu_config/{config.guess,config.sub} xproto - -mkdir build -cd build - -PKG_CONFIG=pkg-config-cross \ -../xproto/configure --prefix=$out $configure_flags - -make - -make install diff --git a/nix/nixcrpkgs/pkgs/xproto/default.nix b/nix/nixcrpkgs/pkgs/xproto/default.nix deleted file mode 100644 index 6b16b0b4ec..0000000000 --- a/nix/nixcrpkgs/pkgs/xproto/default.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ crossenv, xorg-macros }: - -let - version = "7.0.31"; - - name = "xproto-${version}"; - - src = crossenv.nixpkgs.fetchurl { - url = "https://www.x.org/releases/individual/proto/xproto-${version}.tar.gz"; - sha256 = "1is3xl0zjk4l0d8d0zinkfbfapgdby2i56jjfp6caibvwam5wxbd"; - }; - - lib = crossenv.make_derivation { - inherit version name src; - - builder = ./builder.sh; - - configure_flags = - "--host=${crossenv.host} " + - "--enable-static " + - "--disable-shared"; - - cross_inputs = [ xorg-macros ]; - - # Need the latest version of config.sub so we can support musl. - gnu_config = crossenv.native.gnu_config; - }; - - license = crossenv.native.make_derivation { - name = "${name}-license"; - inherit src; - builder = ./license_builder.sh; - }; - - license_set = xorg-macros.license_set // { "${name}" = license; }; - -in - lib // { inherit license_set; } diff --git a/nix/nixcrpkgs/pkgs/xproto/license_builder.sh b/nix/nixcrpkgs/pkgs/xproto/license_builder.sh deleted file mode 100644 index 4ed0509f16..0000000000 --- a/nix/nixcrpkgs/pkgs/xproto/license_builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -mv xproto-* xproto - -license=$(cat xproto/COPYING) - -cat > $out <xproto - -
-$license
-
-EOF diff --git a/nix/nixcrpkgs/pkgs/xtrans/builder.sh b/nix/nixcrpkgs/pkgs/xtrans/builder.sh deleted file mode 100644 index 354670cb0a..0000000000 --- a/nix/nixcrpkgs/pkgs/xtrans/builder.sh +++ /dev/null @@ -1,16 +0,0 @@ -source $setup - -tar -xf $src -mv xtrans-* xtrans - -mkdir build -cd build - -../xtrans/configure --prefix $out - -make - -make install - -# So we can find the pkgconfig files in lib/pkgconfig -ln -s share $out/lib diff --git a/nix/nixcrpkgs/pkgs/xtrans/default.nix b/nix/nixcrpkgs/pkgs/xtrans/default.nix deleted file mode 100644 index 44daf818ac..0000000000 --- a/nix/nixcrpkgs/pkgs/xtrans/default.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ crossenv }: - -let - version = "1.3.5"; - - name = "xtrans-${version}"; - - src = crossenv.nixpkgs.fetchurl { - url = "https://xorg.freedesktop.org/releases/individual/lib/xtrans-${version}.tar.bz2"; - sha256 = "00c3ph17acnsch3gbdmx33b9ifjnl5w7vx8hrmic1r1cjcv3pgdd"; - }; - - lib = crossenv.native.make_derivation rec { - inherit version name src; - builder = ./builder.sh; - }; - - license = crossenv.native.make_derivation { - name = "${name}-license"; - inherit src; - builder = ./license_builder.sh; - }; - - license_set = { "${name}" = license; }; - -in - lib // { inherit license_set; } diff --git a/nix/nixcrpkgs/pkgs/xtrans/license_builder.sh b/nix/nixcrpkgs/pkgs/xtrans/license_builder.sh deleted file mode 100644 index 0b43e8b786..0000000000 --- a/nix/nixcrpkgs/pkgs/xtrans/license_builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -source $setup - -tar -xf $src -mv xtrans-* xtrans - -license=$(cat xtrans/COPYING) - -cat > $out <xtrans - -
-$license
-
-EOF diff --git a/nix/nixcrpkgs/pkgs/zlib/builder.sh b/nix/nixcrpkgs/pkgs/zlib/builder.sh deleted file mode 100644 index b7906b5a2e..0000000000 --- a/nix/nixcrpkgs/pkgs/zlib/builder.sh +++ /dev/null @@ -1,15 +0,0 @@ -source $setup - -tar -xf $src - -mkdir build -cd build - -sed -i 's$Darwin. | darwin.$Ignore* | ignore*$' ../zlib-$version/configure - -CHOST=$host \ -../zlib-$version/configure --prefix=$out --static - -make - -make install diff --git a/nix/nixcrpkgs/pkgs/zlib/default.nix b/nix/nixcrpkgs/pkgs/zlib/default.nix deleted file mode 100644 index 11242407ac..0000000000 --- a/nix/nixcrpkgs/pkgs/zlib/default.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ crossenv }: - -crossenv.make_derivation rec { - name = "zlib-${version}"; - - version = "1.2.11"; - - src = crossenv.nixpkgs.fetchurl { - url = "https://zlib.net/zlib-${version}.tar.gz"; - sha256 = "18dighcs333gsvajvvgqp8l4cx7h1x7yx9gd5xacnk80spyykrf3"; - }; - - builder = ./builder.sh; -} diff --git a/nix/nixcrpkgs/pretend_stdenv/setup b/nix/nixcrpkgs/pretend_stdenv/setup deleted file mode 100644 index a0f3af7009..0000000000 --- a/nix/nixcrpkgs/pretend_stdenv/setup +++ /dev/null @@ -1 +0,0 @@ -export PATH=$_PATH diff --git a/nix/nixcrpkgs/support/derivations.txt b/nix/nixcrpkgs/support/derivations.txt deleted file mode 100644 index d5d9f09afa..0000000000 --- a/nix/nixcrpkgs/support/derivations.txt +++ /dev/null @@ -1,58 +0,0 @@ -define all = win32,win64,linux32,linux64,linux-rpi,mac -define windows = win32,win64 -define linux = linux32,linux64,linux-rpi - -# Cross-compiler toolchains -{$windows,$linux}.gcc slow=1 -mac.toolchain slow=1 - -# Packages -{$windows}.angle{,.examples} slow=1 -{$windows}.angle.examples -omni.at-spi2-headers -{$all}.avrdude -omni.dejavu-fonts -{$windows}.devcon -{$all}.expat -omni.fixesproto -{$windows}.gdb -{$all}.hello -{$all}.hello_cpp -omni.inputproto -{$all}.ion -omni.kbproto -{$linux}.libudev -{$all}.libusb -{$all}.libusbp{,.examples} -{$linux}.libx11 -{$linux}.libxall -{$all}.libxau -{$all}.libxcb{,.examples} -{$linux}.libxext -{$linux}.libxfixes -{$linux}.libxi -{$all}.openocd -{$all}.pavr2 -{$windows}.pdcurses{,.examples} -{$all}.p-load -{$all}.qt slow=1 -{$all}.qt.examples -{$windows}.readline -{$all}.tic -{$windows}.usbview -omni.xcb-proto -{$all}.xcb-util -{$all}.xcb-util-image -{$all}.xcb-util-keysyms -{$all}.xcb-util-renderutil -{$all}.xcb-util-wm -omni.xextproto -omni.xorg-macros -{$all}.xproto -omni.xtrans -{$all}.zlib - -# Derivations we care about at Pololu -{win32,linux32,linux-rpi,mac}.{p-load,pavr2,tic} priority=1 - -# TODO: Test building the license_sets somehow too. diff --git a/nix/nixcrpkgs/support/expand_brackets.rb b/nix/nixcrpkgs/support/expand_brackets.rb deleted file mode 100644 index fccee45104..0000000000 --- a/nix/nixcrpkgs/support/expand_brackets.rb +++ /dev/null @@ -1,43 +0,0 @@ -def expand_brackets_core(str, depth) - finished_parts = [] - active_parts = [+''] - while true - if str.empty? - raise AnticipatedError, "Unmatched opening brace" if depth > 0 - break - elsif str.start_with?('}') - str.slice!(0) - raise AnticipatedError, "Unmatched closing brace" if depth == 0 - break - elsif str.start_with?('{') - # Recurse, which removes everything up to and - # including the matching closing brace. - str.slice!(0) - options = expand_brackets_core(str, depth + 1) - raise if options.empty? - active_parts = active_parts.flat_map { |p1| - options.map { |p2| p1 + p2 } - } - elsif str.start_with?(',') - raise AnticipatedError, "Comma at top level" if depth == 0 - # Remove the comma, mark the parts we are working - # on as finished, and start a new part. - str.slice!(0) - finished_parts += active_parts - active_parts = [''] - else - part_length = str.index(/[{},]|$/) - raise if part_length < 1 - part = str.slice!(0, part_length) - active_parts.each do |s| - s.insert(-1, part) - end - end - end - finished_parts + active_parts -end - -# Expands something like "{a,b}{,.x}" to ["a", "a.x", "b", "b.x"] -def expand_brackets(str) - expand_brackets_core(str.dup, 0) -end diff --git a/nix/nixcrpkgs/support/graph.rb b/nix/nixcrpkgs/support/graph.rb deleted file mode 100644 index b1db811371..0000000000 --- a/nix/nixcrpkgs/support/graph.rb +++ /dev/null @@ -1,74 +0,0 @@ -def print_graph(graph) - graph.each do |parent, children| - puts "#{parent} ->" - children.each do |child| - puts " #{child}" - end - end -end - -def check_graph!(graph) - graph.each do |parent, children| - children.each do |child| - if !graph.key?(child) - raise "Graph is missing an entry for #{child}" - end - end - end -end - -def depth_first_search_exclude_start(graph, start) - stack = [graph.fetch(start).to_a.reverse] - visited = Set.new - until stack.empty? - node = stack.last.pop - if node.nil? - stack.pop - next - end - next if visited.include?(node) - visited << node - stack << graph.fetch(node).to_a.reverse - yield node - end -end - -def transitive_closure(graph) - tc = {} - graph.each_key do |node| - tc[node] = enum_for(:depth_first_search_exclude_start, graph, node).to_a - end - tc -end - -def restricted_transitive_closure(graph, allowed) - rtc = {} - graph.each_key do |node| - next if !allowed.include?(node) - reached_nodes = [] - depth_first_search_exclude_start(graph, node) do |reached_node| - next if !allowed.include?(reached_node) - reached_nodes << reached_node - end - rtc[node] = reached_nodes - end - rtc -end - -def transitive_reduction(graph) - tr = {} - graph.each do |start_node, nodes| - nodes_with_max_distance_1 = Set.new(nodes) - distance = 1 - until nodes.empty? - nodes = Set.new nodes.flat_map &graph.method(:fetch) - nodes_with_max_distance_1 -= nodes - distance += 1 - if distance > graph.size - raise "Cycle detected: this algorithm only works with DAGs." - end - end - tr[start_node] = nodes_with_max_distance_1.to_a - end - tr -end diff --git a/nix/nixcrpkgs/support/manage b/nix/nixcrpkgs/support/manage deleted file mode 100755 index a21f3ec9f8..0000000000 --- a/nix/nixcrpkgs/support/manage +++ /dev/null @@ -1,541 +0,0 @@ -#!/usr/bin/env ruby - -# This part of hte code is under construction. It will eventually be a script that -# helps us check that the derivations we care about are all building, -# and prints the status of those builds. - - -# This requires Ruby 2.5.0 or later because it uses a new syntax for rescuing -# exceptions in a block with needing to make an extra begin/end pair. - -require 'open3' -require 'pathname' -require 'set' -require 'sqlite3' # gem install sqlite3 -require_relative 'graph' -require_relative 'expand_brackets' - -ResultsDir = Pathname('support/results') - -class AnticipatedError < RuntimeError -end - -# Don't automatically change directory because maybe people want to test one -# nixcrpkgs repository using the test script from another one. But do give an -# early, friendly warning if they are running in the wrong directory. -def check_directory! - return if File.directory?('pretend_stdenv') - $stderr.puts "You should run this script from the nixcrpkgs directory." - dir = Pathname(__FILE__).parent.parent - $stderr.puts "Try running these commands:\n cd #{dir}\n test/test.rb" - exit 1 -end - -def substitute_definitions(defs, str) - str.gsub(/\$([\w-]+)/) do |x| - defs.fetch($1) - end -end - -def parse_derivation_list(filename) - defs = {} - all_paths = Set.new - all_attrs = {} - File.foreach(filename).with_index do |line, line_index| - line.strip! - - # Handle empty lines and comments. - next if line.empty? || line.start_with?('#') - - # Handle variable definitions (e.g. "define windows = win32,win64"). - if line.start_with?('define') - md = line.match(/^define\s+([\w-]+)\s*=\s*(.*)$/) - if !md - raise AnticipatedError, "Invalid definition syntax." - end - name, value = md[1], md[2] - defs[name] = value - next - end - - # Expand variable definitions (e.g. $windows expands to "win32,win64"). - line = substitute_definitions(defs, line) - - # Figure out which parts of the line are attribute paths with brackets and - # which are attributes. - items = line.split(' ') - attr_defs, path_items = items.partition { |p| p.include?('=') } - - # Expand any brackets in the attribute paths to get the complete list of - # paths specified on this line. - paths = path_items.flat_map { |p| expand_brackets(p) }.map(&:to_sym) - - # Process attribute definitions on the line, like "priority=1". - attrs = {} - attr_defs.each do |attr_def| - md = attr_def.match(/^(\w+)=(\d+)$/) - if !md - raise AnticipatedError, "Invalid attribute definition: #{attr_def.inspect}." - end - name, value = md[1], md[2] - case name - when 'priority', 'slow' - attrs[name.to_sym] = value.to_i - else - raise AnticipatedError, "Unrecognized attribute: #{name.inspect}." - end - end - - # Record the paths for this line and the attributes for those paths, - # overriding previous attributes values if necessary. - all_paths += paths - if !attrs.empty? - paths.each do |path| - (all_attrs[path] ||= {}).merge!(attrs) - end - end - rescue AnticipatedError => e - raise AnticipatedError, "#{filename}:#{line_index + 1}: error: #{e}" - end - - if all_paths.empty? - raise AnticipatedError, "#{filename} specifies no paths" - end - - all_paths.each do |path| - if !path.match?(/^[\w.-]+$/) - raise "Invalid characters in path name: #{path}" - end - end - - { defs: defs, paths: all_paths.to_a, attrs: all_attrs } -end - -# Make a hash holding the priority of each Nix attribute path we want to build. -# This routine determines the default priority. -def make_path_priority_map(settings) - attrs = settings.fetch(:attrs) - m = {} - settings.fetch(:paths).each do |path| - m[path] = attrs.fetch(path, {}).fetch(:priority, 0) - end - m -end - -# Make a hash holding the relative build time of each Nix attribute path we want -# to build. This routine detrmines the default time, and what "slow" means. -def make_path_time_map(settings) - attrs = settings.fetch(:attrs) - m = {} - settings.fetch(:paths).each do |path| - m[path] = attrs.fetch(path, {})[:slow] ? 100 : 1 - end - m -end - -def instantiate_drvs(paths) - cmd = 'nix-instantiate ' + paths.map { |p| "-A #{p}" }.join(' ') - stdout_str, stderr_str, status = Open3.capture3(cmd) - if !status.success? - $stderr.puts stderr_str - raise AnticipatedError, "Failed to instantiate derivations." - end - paths.zip(stdout_str.split.map(&:to_sym)).to_h -end - -# We want there to be a one-to-one mapping between paths in the derivations.txt -# list and derivations, so we can make a graph of dependencies of the -# derivations and each derivation in the graph will have a unique path in the -# derivations.txt list. -def check_paths_are_unique!(path_drv_map) - set = Set.new - path_drv_map.each do |key, drv| - if set.include?(drv) - raise AnticipatedError, "The derivation #{key} is the same as " \ - "other derivations in the list. Maybe use the 'omni' namespace." - end - set << drv - end -end - -# Makes a new map that has the same keys as map1, and the values -# have all been mapped by map2. -# -# Requires map2 to have a key for every value in map1. -def map_compose(map1, map2) - map1.transform_values &map2.method(:fetch) -end - -# Like map_compose, but excludes keys from map1 where the corresponding map1 -# value is not a key of map2. -def map_join(map1, map2) - r = {} - map1.each do |key, value| - if map2.key?(value) - r[key] = map2.fetch(value) - end - end - r -end - -def nix_db - return $db if $db - $db = SQLite3::Database.new '/nix/var/nix/db/db.sqlite', readonly: true -end - -# Given an array of derivations (paths to .drv files in /nix), this function -# queries the Nix database and returns hash table mapping derivations to -# a boolean that is true if they have already been built. -def get_build_status(drvs) - drv_list_str = drvs.map { |d| "\"#{d}\"" }.join(", ") - query = < 0 - more_attrs << " penwidth=3" - end - - # Draw slow nodes as a double octagon. - if path_time_map.fetch(path) > 10 - more_attrs << " shape=doubleoctagon" - end - f.puts "\"#{path}\" [label=\"#{component}\"#{more_attrs}]" - end - f.puts "}" - end - - # Output dependencies between nodes. - visible_paths.each do |path| - path_graph.fetch(path).each do |dep| - next if decompose.(dep).first == 'omni' - f.puts "\"#{path}\" -> \"#{dep}\"" - end - end - f.puts "}" - end -end - -def make_build_plan(path_state) - path_graph = path_state.fetch(:graph) - path_priority_map = path_state.fetch(:priority_map) - path_time_map = path_state.fetch(:time_map) - path_built_map = path_state.fetch(:built_map) - - # It's handy to be able to get all the dependencies of a node in one step, and - # we will use that frequently to calculate how expensive it is to build a - # node and to make the toplogical sort. - path_graph = transitive_closure(path_graph).freeze - - # The paths we need to build. In the future we could filter this by priority. - required_paths = Set.new(path_graph.keys).freeze - - # built_paths: The set of paths that are already built. We will mutate this - # as we simulate our build plan. - built_paths = Set.new - path_built_map.each do |path, built| - built_paths << path if built - end - - # List of paths to build. Each path should only be built once all the paths it - # depends on are built. I know nix-build can take care of that for us, but it's - # nice to see the precise order of what is going to be built so we can tell when - # slow things will get built. - build_plan = [] - - # Computes the time to build a path, taking into account what has already been - # built. - calculate_time = lambda do |path| - deps = path_graph.fetch(path) + [path] - deps.reject! &built_paths.method(:include?) - deps.map(&path_time_map.method(:fetch)).sum - end - - # Adds plans to build this path and all of its unbuilt depedencies. - add_to_build_plan = lambda do |path| - deps = path_graph.fetch(path) + [path] - - # Remove dependencies that are already built. - deps.reject! &built_paths.method(:include?) - - # Topological sort - deps.sort! do |p1, p2| - case - when path_graph.fetch(p1).include?(p2) then 1 - when path_graph.fetch(p2).include?(p1) then -1 - else 0 - end - end - - deps.each do |path| - build_plan << path - built_paths << path - end - end - - while true - unbuilt_required_paths = required_paths - built_paths - break if unbuilt_required_paths.empty? - - # Find the maximum priority of the unbuilt required paths. - max_priority = nil - unbuilt_required_paths.each do |path| - priority = path_priority_map.fetch(path) - if !max_priority || priority > max_priority - max_priority = priority - end - end - - top_priority_paths = unbuilt_required_paths.select do |path| - path_priority_map.fetch(path) == max_priority - end - - target = top_priority_paths.min_by(&calculate_time) - - add_to_build_plan.(target) - end - - build_plan -end - -# Updates the 'support/results' directory, which holds -# symbolic links to all the derivations defined by nixcrpkgs and -# listed in support/derivations.txt which have already been built. -# -# Intended use: -# ln -s $PWD/support/results /nix/var/nix/gcroots/nixcrpkgs-results -# support/manage results -# nix-collect-garbage -def update_results_dir(path_valid_results_map) - ResultsDir.mkdir if !ResultsDir.directory? - ResultsDir.children.each do |p| - p.unlink - end - modern_links = Set.new - path_valid_results_map.each do |path, results_map| - results_map.each do |id, result| - suffix = id == :out ? '' : ".#{id}" - link_name = "#{path}#{suffix}" - (ResultsDir + link_name).make_symlink(result) - modern_links << link_name - end - end -end - -def build_paths(path_graph, path_built_map, build_plan, keep_going: true) - path_built_map = path_built_map.dup - path_graph = transitive_closure(path_graph) - build_plan.each do |path| - if !path_graph.fetch(path).all?(&path_built_map.method(:fetch)) - # One of the dependencies of this path has not been built, presumably - # because there was an error. - puts "# skipping #{path}" - next - end - - print "nix-build -A #{path}" - system("nix-build -A #{path} > /dev/null 2> /dev/null") - - if $?.success? - path_built_map[path] = true - puts - else - puts " # failed" - return false if !keep_going - end - end - true -end - -def parse_args(argv) - action = case argv.first - when 'graph' then :graph - when 'results' then :results - when 'build' then :build - when 'plan' then :plan - when 'stats', nil then :stats - else raise AnticipatedError, "Invalid action: #{argv.first.inspect}" - end - - { action: action } -end - -begin - check_directory! - args = parse_args(ARGV) - action = args.fetch(:action) - - settings = parse_derivation_list('support/derivations.txt') - - path_drv_map = instantiate_drvs(settings.fetch(:paths)) - check_paths_are_unique!(path_drv_map) - - drvs = path_drv_map.values.uniq - drv_built_map = get_build_status(drvs) - - if [:graph, :build, :plan].include?(action) - global_drv_graph = get_drv_graph - drv_graph = graph_restrict_nodes(global_drv_graph, drvs) - path_state = { - graph: graph_unmap(drv_graph, path_drv_map).freeze, - priority_map: make_path_priority_map(settings).freeze, - time_map: make_path_time_map(settings).freeze, - built_map: map_compose(path_drv_map, drv_built_map).freeze, - }.freeze - end - - if action == :graph - output_graphviz(path_state) - end - - if [:build, :plan].include?(action) - build_plan = make_build_plan(path_state) - end - - if action == :plan - puts "Build plan:" - build_plan.each do |path| - puts "nix-build -A #{path}" - end - end - - if action == :build - success = build_paths(path_state[:graph], path_state[:built_map], build_plan) - exit(1) if !success - end - - if action == :results || action == :build - drv_valid_results_map = get_valid_results(drvs) - path_valid_results_map = map_join(path_drv_map, drv_valid_results_map).freeze - update_results_dir(path_valid_results_map) - end - - if action == :stats - print_stats(drv_built_map) - end -rescue AnticipatedError => e - $stderr.puts e -end diff --git a/nix/nixcrpkgs/top.nix b/nix/nixcrpkgs/top.nix deleted file mode 100644 index 5e1aa63a65..0000000000 --- a/nix/nixcrpkgs/top.nix +++ /dev/null @@ -1,72 +0,0 @@ -{ osx_sdk, nixpkgs }: - -rec { - inherit nixpkgs; - - # Some native build tools. - native = import ./native { inherit nixpkgs; }; - - # Cross-compiling environments for each target system. - crossenvs = { - i686-w64-mingw32 = import ./mingw-w64 { inherit native; arch = "i686"; }; - x86_64-w64-mingw32 = import ./mingw-w64 { inherit native; arch = "x86_64"; }; - i686-linux-musl = import ./linux { inherit native; arch = "i686"; }; - x86_64-linux-musl = import ./linux { inherit native; arch = "x86_64"; }; - armv6-linux-musl = import ./linux { - inherit native; - arch = "armv6"; - gcc_options = "--with-fpu=vfp --with-float=hard "; - }; - macos = import ./macos { inherit osx_sdk native; }; - }; - - pkgFun = crossenv: import ./pkgs.nix { inherit crossenv; } // crossenv; - - # Sets of packages for each target system. - i686-w64-mingw32 = pkgFun crossenvs.i686-w64-mingw32; - x86_64-w64-mingw32 = pkgFun crossenvs.x86_64-w64-mingw32; - i686-linux-musl = pkgFun crossenvs.i686-linux-musl; - x86_64-linux-musl = pkgFun crossenvs.x86_64-linux-musl; - armv6-linux-musl = pkgFun crossenvs.armv6-linux-musl; - macos = pkgFun crossenvs.macos; - - # omni is convenient name for packages that are used for cross-compiling but - # are actually the same on all platforms. You can just refer to it by - # 'omni.package_name' instead of 'some_platform.package_name'. - omni = pkgFun { inherit native nixpkgs; }; - - # Handy aliases. - win32 = i686-w64-mingw32; - win64 = x86_64-w64-mingw32; - linux32 = i686-linux-musl; - linux-x86 = i686-linux-musl; - linux-i686 = i686-linux-musl; - linux64 = x86_64-linux-musl; - linux-x86_64 = x86_64-linux-musl; - linux-rpi = armv6-linux-musl; - rpi = armv6-linux-musl; - mac = macos; - - # filter is a function that can be applied to a local directory to filter out - # files that are likely to change frequently without affecting the build, - # causing unneeded rebuilds. - filter_func = name: type: let bn = baseNameOf (toString name); in !( - (type == "directory" && bn == ".git") || - (type == "symlink" && nixpkgs.lib.hasPrefix "result" bn) || - (type == "directory" && bn == "nix") || - (type == "directory" && bn == "build") || - nixpkgs.lib.hasSuffix ".nix" bn || - nixpkgs.lib.hasSuffix "~" bn - ); - filter = builtins.filterSource filter_func; - - # bundle is a function that takes a set of derivations and makes a - # derivation for a bundle that has symbolic links in it to each of - # the input derivations. - bundle = drvs: native.make_derivation rec { - name = "bundle"; - builder = ./bundle_builder.sh; - names = builtins.attrNames drvs; - dirs = builtins.attrValues drvs; - }; -} diff --git a/nix/nixpkgs.nix b/nix/nixpkgs.nix deleted file mode 100644 index fd2d2cd4a4..0000000000 --- a/nix/nixpkgs.nix +++ /dev/null @@ -1,13 +0,0 @@ -let - - rev = "61c3169a0e17d789c566d5b241bfe309ce4a6275"; - hash = "0qbycg7wkb71v20rchlkafrjfpbk2fnlvvbh3ai9pyfisci5wxvq"; - pkgs = builtins.fetchTarball { - name = "nixpkgs-2019-01-15"; - url = "https://github.com/nixos/nixpkgs/archive/${rev}.tar.gz"; - sha256 = hash; - }; - -in - -import pkgs {} diff --git a/nix/ops/boot-ship.nix b/nix/ops/boot-ship.nix deleted file mode 100644 index b54a7a90ae..0000000000 --- a/nix/ops/boot-ship.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ pkgs ? import ../nixpkgs.nix -, debug ? false -, ship ? "zod" -, pill ? ../../bin/solid.pill -}: - -let - - deps = import ../deps { inherit pkgs; }; - tlon = import ../pkgs { inherit pkgs; }; - arvo = tlon.arvo; - urbit = tlon.urbit; - herb = tlon.herb; - -in - -import ./fakeship { - inherit pkgs arvo pill ship urbit herb; -} diff --git a/nix/ops/brass/builder.sh b/nix/ops/brass/builder.sh deleted file mode 100755 index 75f76e872b..0000000000 --- a/nix/ops/brass/builder.sh +++ /dev/null @@ -1,22 +0,0 @@ -source $stdenv/setup - -set -ex - -cp -r $PIER ./pier -chmod -R u+rw ./pier - -$URBIT -d ./pier - -cleanup () { - if [ -e ./pier/.vere.lock ] - then kill $(< ./pier/.vere.lock) || true; - fi -} - -trap cleanup EXIT - -herb ./pier -P brass.pill -d '+brass' - -mv brass.pill $out - -set +x diff --git a/nix/ops/brass/default.nix b/nix/ops/brass/default.nix deleted file mode 100644 index ea83c4ff7b..0000000000 --- a/nix/ops/brass/default.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ pkgs, herb, urbit, pier, arvo }: - -pkgs.stdenv.mkDerivation rec { - name = "brass"; - builder = ./builder.sh; - buildInputs = [ herb pkgs.coreutils ]; - - URBIT = urbit.meta.exe; - PIER = pier; - ARVO = arvo; -} diff --git a/nix/ops/default.nix b/nix/ops/default.nix deleted file mode 100644 index d048d783ed..0000000000 --- a/nix/ops/default.nix +++ /dev/null @@ -1,86 +0,0 @@ -{ pkgs ? import ../nixpkgs.nix, debug ? false }: - -let - - tlon = import ../pkgs { inherit pkgs; }; - arvo = tlon.arvo; - arvo-ropsten = tlon.arvo-ropsten; - herb = tlon.herb; - urbit = if debug then tlon.urbit-debug else tlon.urbit; - - bootbrass = ../../bin/brass.pill; - bootsolid = ../../bin/solid.pill; - - rawzod = import ./fakeship { - inherit pkgs herb urbit; - pill = bootsolid; - ship = "zod"; - arvo = null; - }; - - ropzod = import ./fakeship { - inherit pkgs herb urbit; - pill = bootsolid; - ship = "zod"; - arvo = arvo-ropsten; - }; - - zod = import ./fakeship { - inherit pkgs herb urbit arvo; - pill = bootsolid; - ship = "zod"; - }; - -in - -rec { - - bus = import ./fakeship { - inherit pkgs herb urbit arvo; - pill = bootsolid; - ship = "bus"; - }; - - test = import ./test { - inherit pkgs herb urbit; - ship = bus; - }; - - solid = import ./solid { - inherit pkgs herb urbit arvo; - pier = rawzod; - }; - - brass = import ./brass { - inherit pkgs herb urbit arvo; - pier = zod; - }; - - brass-ropsten = import ./brass { - inherit pkgs herb urbit; - arvo = arvo-ropsten; - pier = ropzod; - }; - - ivory = import ./ivory { - inherit pkgs herb urbit arvo; - pier = zod; - }; - - ivory-ropsten = import ./ivory { - inherit pkgs herb urbit; - arvo = arvo-ropsten; - pier = ropzod; - }; - - image = import ./image { - inherit pkgs herb urbit solid; - }; - - image-ropsten = import ./image { - inherit pkgs herb urbit; - brass = brass-ropsten; - ivory = ivory-ropsten; - }; - -} diff --git a/nix/ops/fakeship/builder.sh b/nix/ops/fakeship/builder.sh deleted file mode 100755 index 19ef10b87e..0000000000 --- a/nix/ops/fakeship/builder.sh +++ /dev/null @@ -1,26 +0,0 @@ -source $stdenv/setup - -set -ex - -if [ -z "$ARVO" ] -then - $URBIT -d -F $SHIP -B "$PILL" $out -else - $URBIT -d -F $SHIP -A "$ARVO" -B "$PILL" $out -fi - -check () { - [ 3 -eq "$(herb $out -d 3)" ] -} - -if check && sleep 10 && check -then - echo "Boot success." >&2 - herb $out -p hood -d '+hood/exit' || true -else - echo "Boot failure." >&2 - kill $(< $out/.vere.lock) || true - exit 1 -fi - -set +x diff --git a/nix/ops/fakeship/default.nix b/nix/ops/fakeship/default.nix deleted file mode 100644 index 8ebfa4a5e4..0000000000 --- a/nix/ops/fakeship/default.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ pkgs, herb, urbit, pill, ship, arvo }: - -pkgs.stdenv.mkDerivation { - name = "fake" + ship; - builder = ./builder.sh; - buildInputs = [ herb ]; - URBIT = urbit.meta.exe; - ARVO = arvo; - PILL = pill; - SHIP = ship; -} diff --git a/nix/ops/image/default.nix b/nix/ops/image/default.nix deleted file mode 100644 index ecfc97d267..0000000000 --- a/nix/ops/image/default.nix +++ /dev/null @@ -1,47 +0,0 @@ -{ pkgs -, herb -, urbit -, solid ? null -, brass ? null -, ivory ? null -}: - -let - link = pill: path: - if pill == null then "" - else "${pkgs.coreutils}/bin/ln -sf ${pill} ${path}"; - -in pkgs.dockerTools.buildImage { - name = urbit.meta.name; - - runAsRoot = '' - #!${pkgs.stdenv.shell} - - set -euo pipefail - - ${pkgs.dockerTools.shadowSetup} - - mkdir -p /share /data /tmp - - ${link solid "/share/solid.pill"} - ${link brass "/share/brass.pill"} - ${link ivory "/share/ivory.pill"} - ''; - - contents = [ urbit herb ]; - - config = { - Entrypoint = [ urbit.meta.name ]; - - WorkingDir = "/data"; - - Volumes = { - "/data" = {}; - }; - - ExposedPorts = { - "80/tcp" = {}; - "443/tcp" = {}; - }; - }; -} diff --git a/nix/ops/ivory/builder.sh b/nix/ops/ivory/builder.sh deleted file mode 100755 index 1e929a84fd..0000000000 --- a/nix/ops/ivory/builder.sh +++ /dev/null @@ -1,22 +0,0 @@ -source $stdenv/setup - -set -ex - -cp -r $PIER ./pier -chmod -R u+rw ./pier - -$URBIT -d ./pier - -cleanup () { - if [ -e ./pier/.vere.lock ] - then kill $(< ./pier/.vere.lock) || true; - fi -} - -trap cleanup EXIT - -herb ./pier -P ivory.pill -d '+ivory' - -mv ivory.pill $out - -set +x diff --git a/nix/ops/ivory/default.nix b/nix/ops/ivory/default.nix deleted file mode 100644 index 36532b7b55..0000000000 --- a/nix/ops/ivory/default.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ pkgs, herb, urbit, pier, arvo }: - -pkgs.stdenv.mkDerivation rec { - name = "ivory"; - builder = ./builder.sh; - buildInputs = [ herb pkgs.coreutils ]; - - URBIT = urbit.meta.exe; - PIER = pier; - ARVO = arvo; -} diff --git a/nix/ops/solid/builder.sh b/nix/ops/solid/builder.sh deleted file mode 100755 index f5b39a057f..0000000000 --- a/nix/ops/solid/builder.sh +++ /dev/null @@ -1,82 +0,0 @@ -source $stdenv/setup - -set -ex - -cp -r $PIER ./pier -chmod -R u+rw ./pier - -$URBIT -d ./pier - -shutdown () { - if [ -e ./pier/.vere.lock ] - then kill $(< ./pier/.vere.lock) || true; - fi -} - -trap shutdown EXIT - -# update pill strategy to ensure correct staging -# - -herb ./pier -p hood -d "+hood/mount /=home=" - -until [ -d ./pier/home ] -do - sleep 1 -done - -# update :lens, :dojo and dependencies -# -# XX reduce this list -# -cp $ARVO/app/lens.hoon ./pier/home/app/ 2>/dev/null || true -cp $ARVO/app/dojo.hoon ./pier/home/app/ 2>/dev/null || true -cp $ARVO/lib/base64.hoon ./pier/home/lib/ 2>/dev/null || true -cp $ARVO/lib/server.hoon ./pier/home/lib/ 2>/dev/null || true -cp $ARVO/lib/sole.hoon ./pier/home/lib/ 2>/dev/null || true -cp $ARVO/lib/xray.hoon ./pier/home/lib/ 2>/dev/null || true -cp $ARVO/lib/pprint.hoon ./pier/home/lib/ 2>/dev/null || true -mkdir -p ./pier/home/mar/lens/ -cp $ARVO/mar/lens/* ./pier/home/mar/lens/ 2>/dev/null || true - -cp $ARVO/sur/lens.hoon ./pier/home/sur/ 2>/dev/null || true -cp $ARVO/sur/sole.hoon ./pier/home/sur/ 2>/dev/null || true - -# update +solid and its dependencies -# -cp $ARVO/lib/pill.hoon ./pier/home/lib/ 2>/dev/null || true -cp $ARVO/gen/solid.hoon ./pier/home/gen/ 2>/dev/null || true - -chmod -R u+rw ./pier/home/ - -herb ./pier -p hood -d "+hood/commit %home" -herb ./pier -p hood -d "+hood/unmount %home" - -# XX horrible hack to ensure the update is applied first -# -sleep 10 - -# stage new desk for pill contents -# -herb ./pier -p hood -d '+hood/merge %stage our %home' -herb ./pier -p hood -d "+hood/mount /=stage=" - -until [ -d ./pier/stage ] -do - sleep 1 -done - -rm -rf ./pier/stage -cp -r $ARVO ./pier/stage -chmod -R u+rw ./pier/stage - -herb ./pier -p hood -d "+hood/commit %stage" -herb ./pier -p hood -d "+hood/unmount %stage" - -herb ./pier -P solid.pill -d '+solid /=stage=/sys, =dub &' - -herb ./pier -p hood -d '+hood/exit' || true - -mv solid.pill $out - -set +x diff --git a/nix/ops/solid/default.nix b/nix/ops/solid/default.nix deleted file mode 100644 index 050763c3b7..0000000000 --- a/nix/ops/solid/default.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ pkgs, herb, urbit, pier, arvo }: - -pkgs.stdenv.mkDerivation rec { - name = "solid"; - builder = ./builder.sh; - buildInputs = [ herb pkgs.coreutils ]; - - URBIT = urbit.meta.exe; - PIER = pier; - ARVO = arvo; -} diff --git a/nix/ops/test/builder.sh b/nix/ops/test/builder.sh deleted file mode 100644 index 2746797abf..0000000000 --- a/nix/ops/test/builder.sh +++ /dev/null @@ -1,80 +0,0 @@ -source $stdenv/setup - -set -ex - -cp -r $SHIP ./ship -chmod -R u+rw ./ship - -$URBIT -d ./ship 2> urbit-output - -tail -f urbit-output >&2 & -tailproc=$! - -shutdown () { - if [ -e ./ship/.vere.lock ] - then kill $(< ./ship/.vere.lock) || true; - fi - - kill "$tailproc" || true; -} - -trap shutdown EXIT - -herb ./ship -p hood -d '+hood/mass' - -# Run the unit tests and then print scrollback -herb ./ship -d '~& ~ ~& %test-unit-start ~' -herb ./ship -d '####-test %/tests' -herb ./ship -d '~& ~ ~& %test-unit-end ~' - -# Start and run the test app -herb ./ship -p hood -d '+hood/start %test' - -herb ./ship -d '~& ~ ~& %test-agents-start ~' -herb ./ship -p test -d '%agents' -herb ./ship -d '~& ~ ~& %test-agents-end ~' - -herb ./ship -d '~& ~ ~& %test-generators-start ~' -herb ./ship -p test -d '%generators' -herb ./ship -d '~& ~ ~& %test-generators-end ~' - -herb ./ship -d '~& ~ ~& %test-marks-start ~' -herb ./ship -p test -d '%marks' -herb ./ship -d '~& ~ ~& %test-marks-end ~' - -# compact the loom, comparing memory use before and after -herb ./ship -p hood -d '+hood/mass' - -herb ./ship -d '~& ~ ~& %pack-start ~' -herb ./ship -p hood -d '+hood/pack' -herb ./ship -d '~& ~ ~& %pack-end ~' - -herb ./ship -p hood -d '+hood/mass' - -shutdown - -# Collect output - -cp urbit-output test-output-unit -cp urbit-output test-output-agents -cp urbit-output test-output-generators -cp urbit-output test-output-marks -rm urbit-output - -sed -i '0,/test-unit-start/d' test-output-unit -sed -i '/test-unit-end/,$d' test-output-unit - -sed -i '0,/test-agents-start/d' test-output-agents -sed -i '/test-agents-end/,$d' test-output-agents - -sed -i '0,/test-generators-start/d' test-output-generators -sed -i '/test-generators-end/,$d' test-output-generators - -sed -i '0,/test-marks-start/d' test-output-marks -sed -i '/test-marks-end/,$d' test-output-marks - -mkdir $out - -cp -r test-output-* $out/ - -set +x diff --git a/nix/ops/test/default.nix b/nix/ops/test/default.nix deleted file mode 100644 index e901d2dc58..0000000000 --- a/nix/ops/test/default.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ pkgs, herb, urbit, ship }: - -pkgs.stdenv.mkDerivation rec { - name = "test"; - builder = ./builder.sh; - buildInputs = [ herb ]; - - URBIT = urbit.meta.exe; - SHIP = ship; -} diff --git a/nix/overlays/arm.nix b/nix/overlays/arm.nix new file mode 100644 index 0000000000..62bb1eb0de --- /dev/null +++ b/nix/overlays/arm.nix @@ -0,0 +1,13 @@ +final: prev: + +let + + isAarch64 = prev.stdenv.hostPlatform.isAarch64; + +in prev.lib.optionalAttrs isAarch64 { + libsigsegv = prev.libsigsegv.overrideAttrs (attrs: { + preConfigure = (old.preConfigure or "") + '' + sed -i 's/^CFG_FAULT=$/CFG_FAULT=fault-linux-arm.h/' configure + ''; + }); +} diff --git a/nix/overlays/musl.nix b/nix/overlays/musl.nix new file mode 100644 index 0000000000..857cb75041 --- /dev/null +++ b/nix/overlays/musl.nix @@ -0,0 +1,28 @@ +final: prev: + +let + + isMusl = prev.stdenv.hostPlatform.isMusl; + + optionalList = xs: if xs == null then [ ] else xs; + + overrideStdenv = pkg: pkg.override { stdenv = prev.gcc9Stdenv; }; + +in prev.lib.optionalAttrs isMusl { + libsigsegv = prev.libsigsegv.overrideAttrs (attrs: { + preConfigure = (attrs.preConfigure or "") + '' + sed -i 's/^CFG_FAULT=$/CFG_FAULT=fault-linux-i386.h/' configure + ''; + }); + + secp256k1 = prev.secp256k1.overrideAttrs (attrs: { + nativeBuildInputs = (attrs.nativeBuildInputs or [ ]) + ++ [ prev.buildPackages.stdenv.cc ]; + }); + + rhash = overrideStdenv prev.rhash; + + numactl = overrideStdenv prev.numactl; + + lmdb = overrideStdenv prev.lmdb; +} diff --git a/nix/overlays/native.nix b/nix/overlays/native.nix new file mode 100644 index 0000000000..2ab55e3751 --- /dev/null +++ b/nix/overlays/native.nix @@ -0,0 +1,28 @@ +final: prev: + +let + + optionalList = xs: if xs == null then [ ] else xs; + +in { + h2o = prev.h2o.overrideAttrs (_attrs: { + version = final.sources.h2o.rev; + src = final.sources.h2o; + outputs = [ "out" "dev" "lib" ]; + }); + + libsigsegv = prev.libsigsegv.overrideAttrs (attrs: { + patches = optionalList attrs.patches ++ [ + ../pkgs/libsigsegv/disable-stackvma_fault-linux-arm.patch + ../pkgs/libsigsegv/disable-stackvma_fault-linux-i386.patch + ]; + }); + + curlMinimal = prev.curl.override { + http2Support = false; + scpSupport = false; + gssSupport = false; + ldapSupport = false; + brotliSupport = false; + }; +} diff --git a/nix/overlays/static.nix b/nix/overlays/static.nix new file mode 100644 index 0000000000..fa0cfdd89a --- /dev/null +++ b/nix/overlays/static.nix @@ -0,0 +1,37 @@ +final: prev: + +let + + # https://github.com/NixOS/nixpkgs/pull/97047/files + # Will make pkgs.stdenv.isStatic available indepedent of the platform. + # isStatic = prev.stdenv.hostPlatform.isStatic; + + configureFlags = attrs: { + configureFlags = (attrs.configureFlags or [ ]) + ++ [ "--disable-shared" "--enable-static" ]; + }; + + enableStatic = pkg: pkg.overrideAttrs configureFlags; + +in { + gmp = enableStatic prev.gmp; + + curlMinimal = enableStatic prev.curlMinimal; + + libuv = enableStatic prev.libuv; + + libffi = enableStatic prev.libffi; + + secp256k1 = enableStatic prev.secp256k1; + + lmdb = prev.lmdb.overrideAttrs (old: + configureFlags old // { + # Why remove the so version? It's easier than preventing it from being + # built with lmdb's custom Makefiles, and it can't exist in the output + # because otherwise the linker will preferentially choose the .so over + # the .a. + postInstall = '' + rm $out/lib/liblmdb.so + ''; + }); +} diff --git a/nix/pkgs/argon2u/default.nix b/nix/pkgs/argon2u/default.nix new file mode 100644 index 0000000000..60c7a10896 --- /dev/null +++ b/nix/pkgs/argon2u/default.nix @@ -0,0 +1,30 @@ +{ stdenv, sources, enableParallelBuilding ? true }: + +stdenv.mkDerivation { + pname = "argon2u"; + version = sources.argon2u.rev; + src = sources.argon2u; + + postPatch = '' + substituteInPlace Makefile --replace 'ar rcs' '$(AR) rcs' + ''; + + buildPhase = '' + make libargon2.a + ''; + + installPhase = '' + mkdir -p $out/{lib,include} + cp libargon2.a $out/lib/ + cp include/argon2.h $out/include/ + cp ./src/blake2/*.h $out/include/ + ''; + + makeFlags = [ + "AR=${stdenv.cc.targetPrefix}ar" # Fix cross-compilation + ]; + + NO_THREADS = true; + + inherit enableParallelBuilding; +} diff --git a/nix/pkgs/arvo-ropsten/builder.sh b/nix/pkgs/arvo-ropsten/builder.sh deleted file mode 100644 index af133a2f27..0000000000 --- a/nix/pkgs/arvo-ropsten/builder.sh +++ /dev/null @@ -1,26 +0,0 @@ -source $stdenv/setup - -cp -r $src tmp -chmod -R u+w tmp - -ZUSE=tmp/sys/zuse.hoon -AMES=tmp/sys/vane/ames.hoon -ACME=tmp/app/acme.hoon - -# replace the mainnet azimuth contract with the ropsten contract -sed --in-place \ - 's/\(\+\+ contracts \)mainnet\-contracts/\1ropsten-contracts/' \ - $ZUSE - -# increment the %ames protocol version -sed -r --in-place \ - 's_^(=/ protocol\-version=\?\(.*\) %)([0-7])_echo "\1$(echo "(\2+1) % 8" | bc)"_e' \ - $AMES - -# use the staging API in :acme -sed --in-place \ - 's_https://acme-v02.api.letsencrypt.org/directory_https://acme-staging-v02.api.letsencrypt.org/directory_' \ - $ACME - -cp -r tmp $out -chmod -R u+w $out diff --git a/nix/pkgs/arvo-ropsten/default.nix b/nix/pkgs/arvo-ropsten/default.nix deleted file mode 100644 index 9f4bb7e7d1..0000000000 --- a/nix/pkgs/arvo-ropsten/default.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ pkgs }: - -pkgs.stdenv.mkDerivation { - name = "arvo-ropsten"; - buildInputs = [ pkgs.bc ]; - builder = ./builder.sh; - src = pkgs.buildRustCrateHelpers.exclude [ ".git" ] ../../../pkg/arvo; -} diff --git a/nix/pkgs/arvo/builder.sh b/nix/pkgs/arvo/builder.sh deleted file mode 100644 index 3a0c49ad29..0000000000 --- a/nix/pkgs/arvo/builder.sh +++ /dev/null @@ -1,4 +0,0 @@ -source $stdenv/setup - -cp -r $src/ $out -chmod -R u+w $out diff --git a/nix/pkgs/arvo/default.nix b/nix/pkgs/arvo/default.nix index 8b31237cf1..c9204a01fa 100644 --- a/nix/pkgs/arvo/default.nix +++ b/nix/pkgs/arvo/default.nix @@ -1,10 +1,46 @@ -{ pkgs }: +{ lib, stdenvNoCC, bc }: -pkgs.stdenv.mkDerivation { +stdenvNoCC.mkDerivation { name = "arvo"; - builder = ./builder.sh; - src = pkgs.buildRustCrateHelpers.exclude [ ".git" ] ../../../pkg/arvo; - meta = { - priority = 0; - }; + src = lib.cleanSource ../../../pkg/arvo; + + buildInputs = [ bc ]; + + outputs = [ "out" "ropsten" ]; + + phases = [ "mainnetPhase" "ropstenPhase" ]; + + mainnetPhase = '' + cp -r $src/ $out + chmod -R u+w $out + ''; + + ropstenPhase = '' + cp -r $src tmp + chmod -R u+w tmp + + ZUSE=tmp/sys/zuse.hoon + AMES=tmp/sys/vane/ames.hoon + ACME=tmp/app/acme.hoon + + # Replace the mainnet azimuth contract with the ropsten contract + sed --in-place \ + 's/\(\+\+ contracts \)mainnet\-contracts/\1ropsten-contracts/' \ + $ZUSE + + # Increment the %ames protocol version + sed -r --in-place \ + 's_^(=/ protocol\-version=\?\(.*\) %)([0-7])_echo "\1$(echo "(\2+1) % 8" | bc)"_e' \ + $AMES + + # Use the staging API in :acme + sed --in-place \ + 's_https://acme-v02.api.letsencrypt.org/directory_https://acme-staging-v02.api.letsencrypt.org/directory_' \ + $ACME + + cp -r tmp $ropsten + chmod -R u+w $ropsten + ''; + + preferLocalBuild = true; } diff --git a/nix/pkgs/ca-bundle/default.nix b/nix/pkgs/ca-bundle/default.nix new file mode 100644 index 0000000000..ddef1fb3e5 --- /dev/null +++ b/nix/pkgs/ca-bundle/default.nix @@ -0,0 +1,29 @@ +{ stdenvNoCC, xxd, cacert }: + +stdenvNoCC.mkDerivation { + name = "ca-bundle"; + + nativeBuildInputs = [ cacert xxd ]; + + phases = [ "installPhase" ]; + + installPhase = '' + set -euo pipefail + + if ! [ -f "$SSL_CERT_FILE" ]; then + header "$SSL_CERT_FILE doesn't exist" + exit 1 + fi + + mkdir include + + cat $SSL_CERT_FILE > include/ca-bundle.crt + xxd -i include/ca-bundle.crt > ca-bundle.h + + mkdir -p $out/include + + mv ca-bundle.h $out/include + ''; + + preferLocalBuild = true; +} diff --git a/nix/pkgs/default.nix b/nix/pkgs/default.nix deleted file mode 100644 index ba1129dd31..0000000000 --- a/nix/pkgs/default.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ pkgs ? import ../nixpkgs.nix }: - -let - - deps = import ../deps { inherit pkgs; }; - - ent = import ./ent { inherit pkgs; }; - arvo = import ./arvo { inherit pkgs; }; - arvo-ropsten = import ./arvo-ropsten { inherit pkgs; }; - herb = import ../../pkg/herb { inherit pkgs; }; - - ge-additions = import ./ge-additions { - inherit pkgs; - inherit (deps) ed25519; - }; - - libaes_siv = import ./libaes_siv { - inherit pkgs; - }; - - mkUrbit = { debug }: - import ./urbit { - inherit pkgs ent debug ge-additions libaes_siv; - inherit (deps) argon2 murmur3 uv ed25519 scrypt softfloat3; - inherit (deps) secp256k1 h2o ivory-header ca-header; - }; - - urbit = mkUrbit { debug = false; }; - urbit-debug = mkUrbit { debug = true; }; - -in - -{ inherit ent ge-additions libaes_siv arvo arvo-ropsten herb urbit urbit-debug; } diff --git a/nix/pkgs/ed25519/default.nix b/nix/pkgs/ed25519/default.nix new file mode 100644 index 0000000000..7edd85223e --- /dev/null +++ b/nix/pkgs/ed25519/default.nix @@ -0,0 +1,21 @@ +{ stdenv, sources }: + +stdenv.mkDerivation { + pname = "ed25519"; + version = sources.ed25519.rev; + src = sources.ed25519; + + buildPhase = '' + CFLAGS="-O3 -Wall -I$src/src" + + for f in $(find src -type f -name '*.c'); do + $CC $CFLAGS -c $f -o "''${f//\//_}.o" + done + ''; + + installPhase = '' + mkdir -p $out/{lib,include} + $AR rcs $out/lib/libed25519.a *.o + cp $src/src/*.h $out/include/ + ''; +} diff --git a/nix/pkgs/ent/builder.sh b/nix/pkgs/ent/builder.sh deleted file mode 100644 index 464f62e0ba..0000000000 --- a/nix/pkgs/ent/builder.sh +++ /dev/null @@ -1,8 +0,0 @@ -source $stdenv/setup - -cp -r $src ./src -chmod -R u+w ./src -cd ./src - -bash ./configure -PREFIX=$out make install diff --git a/nix/pkgs/ent/cross.nix b/nix/pkgs/ent/cross.nix deleted file mode 100644 index e84d7a01ed..0000000000 --- a/nix/pkgs/ent/cross.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ env_name, env, deps }: - -env.make_derivation rec { - name = "ent-7506f"; - builder = ./builder.sh; - src = ../../../pkg/ent; - - CC = "${env.host}-gcc"; - AR = "${env.host}-ar"; -} diff --git a/nix/pkgs/ent/default.nix b/nix/pkgs/ent/default.nix index ce7c2088cc..ee13758f58 100644 --- a/nix/pkgs/ent/default.nix +++ b/nix/pkgs/ent/default.nix @@ -1,7 +1,14 @@ -{ pkgs }: +{ lib, stdenv, enableParallelBuilding ? true }: -pkgs.stdenv.mkDerivation rec { - name = "ent-7506f"; - builder = ./builder.sh; - src = ../../../pkg/ent; +stdenv.mkDerivation { + name = "ent"; + src = lib.cleanSource ../../../pkg/ent; + + postPatch = '' + patchShebangs ./configure + ''; + + installFlags = [ "PREFIX=$(out)" ]; + + inherit enableParallelBuilding; } diff --git a/nix/pkgs/ge-additions/builder.sh b/nix/pkgs/ge-additions/builder.sh deleted file mode 100644 index 5a04043770..0000000000 --- a/nix/pkgs/ge-additions/builder.sh +++ /dev/null @@ -1,7 +0,0 @@ -source $stdenv/setup - -cp -r $src ./src -chmod -R u+w ./src -cd ./src - -PREFIX=$out make install diff --git a/nix/pkgs/ge-additions/cross.nix b/nix/pkgs/ge-additions/cross.nix deleted file mode 100644 index f16afad0bf..0000000000 --- a/nix/pkgs/ge-additions/cross.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ env_name, env, deps }: - -env.make_derivation rec { - name = "ge-additions"; - builder = ./release.sh; - src = ../../../pkg/ge-additions; - - cross_inputs = [ deps.ed25519 ]; - - CC = "${env.host}-gcc"; - AR = "${env.host}-ar"; -} diff --git a/nix/pkgs/ge-additions/default.nix b/nix/pkgs/ge-additions/default.nix index e77098cffb..e317972d6d 100644 --- a/nix/pkgs/ge-additions/default.nix +++ b/nix/pkgs/ge-additions/default.nix @@ -1,9 +1,13 @@ -{ pkgs, ed25519 }: +{ lib, stdenv, ed25519, enableParallelBuilding ? true }: -pkgs.stdenv.mkDerivation rec { - name = "ge-additions"; - builder = ./builder.sh; - src = ../../../pkg/ge-additions; +stdenv.mkDerivation { + name = "ge-additions"; + src = lib.cleanSource ../../../pkg/ge-additions; - nativeBuildInputs = [ ed25519 ]; + buildInputs = [ ed25519 ]; + + installFlags = [ "PREFIX=$(out)" ]; + + inherit enableParallelBuilding; } + diff --git a/nix/pkgs/ge-additions/release.sh b/nix/pkgs/ge-additions/release.sh deleted file mode 100644 index aaa54b5e13..0000000000 --- a/nix/pkgs/ge-additions/release.sh +++ /dev/null @@ -1,13 +0,0 @@ -source $setup - -cp -r $src ./src -chmod -R u+w ./src -cd ./src - -for dep in $cross_inputs; do - export CFLAGS="${CFLAGS-} -I$dep/include" - export LDFLAGS="${LDFLAGS-} -L$dep/lib" -done - -PREFIX=$out make install - diff --git a/nix/pkgs/herb/default.nix b/nix/pkgs/herb/default.nix new file mode 100644 index 0000000000..ac9ae8dca7 --- /dev/null +++ b/nix/pkgs/herb/default.nix @@ -0,0 +1,29 @@ +{ lib, stdenvNoCC, python }: + +# Avoid using `python.withPackages` as it creates a wrapper script to set +# PYTHONPATH, and the script is used verbatim as a python shebang. +# +# Unfortunately Darwin does not allow scripts as a shebang - so to get a +# cross platform python interpreter with appropriate site-packages setup +# we use `wrapPython/Packages` which handles these cases correctly. + +stdenvNoCC.mkDerivation { + name = "herb"; + src = ../../../pkg/herb/herb; + + nativeBuildInputs = [ python.pkgs.wrapPython ]; + buildInputs = [ python python.pkgs.requests ]; + pythonPath = [ python.pkgs.requests ]; + + phases = [ "installPhase" "fixupPhase" ]; + + installPhase = '' + mkdir -p $out/bin + cp $src $out/bin/herb + chmod +x $out/bin/herb + ''; + + postFixup = '' + wrapPythonPrograms + ''; +} diff --git a/nix/pkgs/hs/default.nix b/nix/pkgs/hs/default.nix new file mode 100644 index 0000000000..5dd7ae1865 --- /dev/null +++ b/nix/pkgs/hs/default.nix @@ -0,0 +1,91 @@ +{ lib, stdenv, darwin, haskell-nix, gmp, zlib, libffi, checkMaterialization +, enableStatic ? stdenv.hostPlatform.isStatic }: + +let + + compiler-nix-name = "ghc884"; + index-state = "2020-09-24T00:00:00Z"; + + project = haskell-nix.stackProject { + inherit compiler-nix-name index-state checkMaterialization; + + # This is incredibly difficult to get right, almost everything goes wrong. + # See: https://github.com/input-output-hk/haskell.nix/issues/496 + src = haskell-nix.haskellLib.cleanSourceWith { + # Otherwise this depends on the name in the parent directory, which + # reduces caching, and is particularly bad on Hercules. + # See: https://github.com/hercules-ci/support/issues/40 + name = "urbit-hs"; + src = ../../../pkg/hs; + }; + + modules = [{ + # This corresponds to the set of packages (boot libs) that ship with GHC. + # We declare them yere to ensure any dependency gets them from GHC itself + # rather than trying to re-install them into the package database. + nonReinstallablePkgs = [ + "Cabal" + "Win32" + "array" + "base" + "binary" + "bytestring" + "containers" + "deepseq" + "directory" + "filepath" + "ghc" + "ghc-boot" + "ghc-boot-th" + "ghc-compact" + "ghc-heap" + "ghc-prim" + "ghci" + "ghcjs-prim" + "ghcjs-th" + "haskeline" + "hpc" + "integer-gmp" + "integer-simple" + "mtl" + "parsec" + "pretty" + "process" + "rts" + "stm" + "template-haskell" + "terminfo" + "text" + "time" + "transformers" + "unix" + "xhtml" + ]; + + packages = { + # Disable the urbit-king test-suite for now - since it relies + # on relative paths to lfs pills. + urbit-king.doCheck = false; + urbit-king.components.exes.urbit-king.enableStatic = enableStatic; + urbit-king.components.exes.urbit-king.enableShared = !enableStatic; + urbit-king.components.exes.urbit-king.configureFlags = + lib.optionals enableStatic [ + "--ghc-option=-optl=-L${gmp}/lib" + "--ghc-option=-optl=-L${libffi}/lib" + "--ghc-option=-optl=-L${zlib}/lib" + ] ++ lib.optionals (enableStatic && stdenv.isDarwin) + [ "--ghc-option=-optl=-L${darwin.libiconv}/lib" ]; + }; + }]; + }; + +in project // { + # Build and obtain an executable from Hackage, using the same compiler + # and cabal index-state as the stackProject. + # + # This allows specifying the executable name, in contrast with shellFor.tools. + hackageTool = { name, version, exe ? lib.toLower name }: + (haskell-nix.hackage-package { + inherit compiler-nix-name index-state name version; + }).components.exes.${exe}; +} diff --git a/nix/pkgs/libaes_siv/builder.sh b/nix/pkgs/libaes_siv/builder.sh deleted file mode 100644 index 5a04043770..0000000000 --- a/nix/pkgs/libaes_siv/builder.sh +++ /dev/null @@ -1,7 +0,0 @@ -source $stdenv/setup - -cp -r $src ./src -chmod -R u+w ./src -cd ./src - -PREFIX=$out make install diff --git a/nix/pkgs/libaes_siv/cross.nix b/nix/pkgs/libaes_siv/cross.nix deleted file mode 100644 index f782400584..0000000000 --- a/nix/pkgs/libaes_siv/cross.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ env_name, env, deps }: - -env.make_derivation rec { - name = "libaes_siv"; - builder = ./release.sh; - src = ../../../pkg/libaes_siv; - - cross_inputs = [ env.openssl ]; - - CC = "${env.host}-gcc"; - AR = "${env.host}-ar"; -} diff --git a/nix/pkgs/libaes_siv/default.nix b/nix/pkgs/libaes_siv/default.nix index fbdda7ebed..8b298f72f7 100644 --- a/nix/pkgs/libaes_siv/default.nix +++ b/nix/pkgs/libaes_siv/default.nix @@ -1,9 +1,12 @@ -{ pkgs }: +{ lib, stdenv, openssl, enableParallelBuilding ? true }: -pkgs.stdenv.mkDerivation rec { - name = "libaes_siv"; - builder = ./builder.sh; - src = ../../../pkg/libaes_siv; +stdenv.mkDerivation { + name = "libaes_siv"; + src = lib.cleanSource ../../../pkg/libaes_siv; - nativeBuildInputs = [ pkgs.openssl ]; + buildInputs = [ openssl ]; + + installFlags = [ "PREFIX=$(out)" ]; + + inherit enableParallelBuilding; } diff --git a/nix/pkgs/libaes_siv/release.sh b/nix/pkgs/libaes_siv/release.sh deleted file mode 100644 index aaa54b5e13..0000000000 --- a/nix/pkgs/libaes_siv/release.sh +++ /dev/null @@ -1,13 +0,0 @@ -source $setup - -cp -r $src ./src -chmod -R u+w ./src -cd ./src - -for dep in $cross_inputs; do - export CFLAGS="${CFLAGS-} -I$dep/include" - export LDFLAGS="${LDFLAGS-} -L$dep/lib" -done - -PREFIX=$out make install - diff --git a/nix/pkgs/libscrypt/default.nix b/nix/pkgs/libscrypt/default.nix new file mode 100644 index 0000000000..55ed88f2cb --- /dev/null +++ b/nix/pkgs/libscrypt/default.nix @@ -0,0 +1,35 @@ +{ stdenv, sources }: + +stdenv.mkDerivation { + pname = "libscrypt"; + version = sources.libscrypt.rev; + src = sources.libscrypt; + + buildPhase = '' + sources=" \ + crypto_scrypt-check \ + crypto_scrypt-hash \ + crypto_scrypt-hexconvert \ + crypto_scrypt-nosse \ + crypto-mcf \ + crypto-scrypt-saltgen \ + slowequals \ + sha256 \ + b64 \ + " + + CFLAGS="-I$src -Wall -ffast-math -O3 -D_FORTIFY_SOURCE=2 -fstack-protector" + + for s in $sources; do + $CC $CFLAGS -c $src/$s.c -o $s.o + done + + $AR rcs libscrypt.a *.o + ''; + + installPhase = '' + mkdir -p $out/{lib,include} + cp libscrypt.a $out/lib + cp $src/*.h $out/include/ + ''; +} diff --git a/nix/pkgs/libsigsegv/disable-stackvma_fault-linux-arm.patch b/nix/pkgs/libsigsegv/disable-stackvma_fault-linux-arm.patch new file mode 100644 index 0000000000..56d2b4b757 --- /dev/null +++ b/nix/pkgs/libsigsegv/disable-stackvma_fault-linux-arm.patch @@ -0,0 +1,11 @@ +--- a/src/fault-linux-arm.h ++++ b/src/fault-linux-arm.h +@@ -17,6 +17,8 @@ + + #include "fault-posix-ucontext.h" + ++#define HAVE_STACKVMA 0 ++ + #if defined(__aarch64__) || defined(__ARM_64BIT_STATE) || defined(__ARM_PCS_AAPCS64) /* 64-bit */ + + /* See glibc/sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h. diff --git a/nix/pkgs/libsigsegv/disable-stackvma_fault-linux-i386.patch b/nix/pkgs/libsigsegv/disable-stackvma_fault-linux-i386.patch new file mode 100644 index 0000000000..9d7d03bd16 --- /dev/null +++ b/nix/pkgs/libsigsegv/disable-stackvma_fault-linux-i386.patch @@ -0,0 +1,11 @@ +--- a/src/fault-linux-i386.h ++++ b/src/fault-linux-i386.h +@@ -18,6 +18,8 @@ + + #include "fault-posix-ucontext.h" + ++#define HAVE_STACKVMA 0 ++ + #if defined __x86_64__ + /* 64 bit registers */ + diff --git a/nix/pkgs/murmur3/default.nix b/nix/pkgs/murmur3/default.nix new file mode 100644 index 0000000000..abac84c95c --- /dev/null +++ b/nix/pkgs/murmur3/default.nix @@ -0,0 +1,17 @@ +{ stdenv, sources }: + +stdenv.mkDerivation { + pname = "murmur3"; + version = sources.murmur3.rev; + src = sources.murmur3; + + buildPhase = '' + $CC -fPIC -O3 -o murmur3.o -c $src/murmur3.c + ''; + + installPhase = '' + mkdir -p $out/{lib,include} + $AR rcs $out/lib/libmurmur3.a murmur3.o + cp $src/*.h $out/include/ + ''; +} diff --git a/nix/pkgs/pill/brass.nix b/nix/pkgs/pill/brass.nix new file mode 100644 index 0000000000..54a816df0a --- /dev/null +++ b/nix/pkgs/pill/brass.nix @@ -0,0 +1,22 @@ +{ lib, stdenvNoCC, fetchGitHubLFS, bootFakeShip, solid, urbit, arvo, herb +, withRopsten ? false }: + +let + + lfs = fetchGitHubLFS { src = ../../../bin/brass.pill; }; + +in { + build = import ./builder.nix { + inherit stdenvNoCC urbit herb; + + name = "brass" + lib.optionalString withRopsten "-ropsten"; + builder = ./brass.sh; + arvo = if withRopsten then arvo.ropsten else arvo; + pier = bootFakeShip { + inherit urbit herb; + + pill = solid.lfs; + ship = "zod"; + }; + }; +} // lib.optionalAttrs (!withRopsten) { inherit lfs; } diff --git a/nix/pkgs/pill/brass.sh b/nix/pkgs/pill/brass.sh new file mode 100644 index 0000000000..114578d6b9 --- /dev/null +++ b/nix/pkgs/pill/brass.sh @@ -0,0 +1,23 @@ +source $stdenv/setup + +set -euo pipefail + +cp -r $src ./pier +chmod -R u+rw ./pier + +urbit -d ./pier + +cleanup () { + if [ -f ./pier/.vere.lock ]; then + kill $(< ./pier/.vere.lock) || true + fi +} + +trap cleanup EXIT + +header "running herb +brass" + +herb ./pier -P brass.pill -d '+brass' +herb ./pier -p hood -d '+hood/exit' + +stopNest diff --git a/nix/pkgs/pill/builder.nix b/nix/pkgs/pill/builder.nix new file mode 100644 index 0000000000..dc9a67afb6 --- /dev/null +++ b/nix/pkgs/pill/builder.nix @@ -0,0 +1,23 @@ +{ stdenvNoCC, urbit, arvo, herb, name, builder, pier }: + +stdenvNoCC.mkDerivation { + name = "${name}.pill"; + src = pier; + outputs = [ "out" "hash" ]; + buildInputs = [ urbit herb ]; + + dontUnpack = true; + + buildPhase = builtins.readFile builder; + + installPhase = '' + mv ${name}.pill $out + + mkdir $hash + + md5sum $out | awk '{printf $1}' > $hash/md5 + sha256sum $out | awk '{printf $1}' > $hash/sha256 + ''; + + ARVO = arvo; +} diff --git a/nix/pkgs/pill/ivory.nix b/nix/pkgs/pill/ivory.nix new file mode 100644 index 0000000000..354cfbd396 --- /dev/null +++ b/nix/pkgs/pill/ivory.nix @@ -0,0 +1,42 @@ +{ lib, stdenvNoCC, fetchGitHubLFS, bootFakeShip, solid, urbit, arvo, herb, xxd +, withRopsten ? false }: + +let + + lfs = fetchGitHubLFS { src = ../../../bin/ivory.pill; }; + +in { + build = import ./builder.nix { + inherit stdenvNoCC urbit herb; + + name = "ivory" + lib.optionalString withRopsten "-ropsten"; + builder = ./ivory.sh; + arvo = if withRopsten then arvo.ropsten else arvo; + pier = bootFakeShip { + inherit urbit herb; + + pill = solid.lfs; + ship = "zod"; + }; + }; + + # The hexdump of the `.lfs` pill contents as a C header. + header = stdenvNoCC.mkDerivation { + name = "ivory-header"; + src = lfs; + nativeBuildInputs = [ xxd ]; + phases = [ "installPhase" ]; + + installPhase = '' + file=u3_Ivory.pill + + header "writing $file" + + mkdir -p $out/include + cat $src > $file + xxd -i $file > $out/include/ivory.h + ''; + + preferLocalBuild = true; + }; +} // lib.optionalAttrs (!withRopsten) { inherit lfs; } diff --git a/nix/pkgs/pill/ivory.sh b/nix/pkgs/pill/ivory.sh new file mode 100644 index 0000000000..fc5ced9a66 --- /dev/null +++ b/nix/pkgs/pill/ivory.sh @@ -0,0 +1,23 @@ +source $stdenv/setup + +set -euo pipefail + +cp -r $src ./pier +chmod -R u+rw ./pier + +urbit -d ./pier + +cleanup () { + if [ -f ./pier/.vere.lock ]; then + kill $(< ./pier/.vere.lock) || true + fi +} + +trap cleanup EXIT + +header "running herb +ivory" + +herb ./pier -P ivory.pill -d '+ivory' +herb ./pier -p hood -d '+hood/exit' + +stopNest diff --git a/nix/pkgs/pill/solid.nix b/nix/pkgs/pill/solid.nix new file mode 100644 index 0000000000..17bcd4433e --- /dev/null +++ b/nix/pkgs/pill/solid.nix @@ -0,0 +1,23 @@ +{ stdenvNoCC, fetchGitHubLFS, bootFakeShip, solid, urbit, arvo, herb }: + +let + + lfs = fetchGitHubLFS { src = ../../../bin/solid.pill; }; + +in { + inherit lfs; + + build = import ./builder.nix { + inherit stdenvNoCC urbit arvo herb; + + name = "solid"; + builder = ./solid.sh; + pier = bootFakeShip { + inherit urbit herb; + + arvo = null; + pill = solid.lfs; + ship = "zod"; + }; + }; +} diff --git a/nix/pkgs/pill/solid.sh b/nix/pkgs/pill/solid.sh new file mode 100644 index 0000000000..1e395f09f5 --- /dev/null +++ b/nix/pkgs/pill/solid.sh @@ -0,0 +1,73 @@ +source $stdenv/setup + +set -euo pipefail + +ARVO=${ARVO?:ARVO location is unset} + +cp -r $src ./pier +chmod -R u+rw ./pier + +urbit -d ./pier + +cleanup () { + if [ -f ./pier/.vere.lock ]; then + kill $(< ./pier/.vere.lock) || true + fi +} + +trap cleanup EXIT + +# Update pill strategy to ensure correct staging +herb ./pier -p hood -d "+hood/mount /=home=" + +until [ -d ./pier/home ]; do + sleep 1 +done + +# Update :lens, :dojo and dependencies +# FIXME: reduce this list +cp $ARVO/app/lens.hoon ./pier/home/app/ +cp $ARVO/app/dojo.hoon ./pier/home/app/ +cp $ARVO/lib/base64.hoon ./pier/home/lib/ +cp $ARVO/lib/server.hoon ./pier/home/lib/ +cp $ARVO/lib/sole.hoon ./pier/home/lib/ +cp $ARVO/lib/xray.hoon ./pier/home/lib/ +cp $ARVO/lib/pprint.hoon ./pier/home/lib/ + +mkdir -p ./pier/home/mar/lens/ + +cp $ARVO/mar/lens/* ./pier/home/mar/lens/ + +cp $ARVO/sur/lens.hoon ./pier/home/sur/ +cp $ARVO/sur/sole.hoon ./pier/home/sur/ + +# Update +solid and its dependencies +cp $ARVO/lib/pill.hoon ./pier/home/lib/ +cp $ARVO/gen/solid.hoon ./pier/home/gen/ + +chmod -R u+rw ./pier/home/ + +herb ./pier -p hood -d "+hood/commit %home" +herb ./pier -p hood -d "+hood/unmount %home" + +# FIXME: horrible hack to ensure the update is applied first +sleep 10 + +# Stage new desk for pill contents +herb ./pier -p hood -d '+hood/merge %stage our %home' +herb ./pier -p hood -d "+hood/mount /=stage=" + +until [ -d ./pier/stage ]; do + sleep 1 +done + +rm -rf ./pier/stage +cp -r $ARVO ./pier/stage +chmod -R u+rw ./pier/stage + +herb ./pier -p hood -d "+hood/commit %stage" +herb ./pier -p hood -d "+hood/unmount %stage" +herb ./pier -P solid.pill -d '+solid /=stage=/sys, =dub &' +herb ./pier -p hood -d '+hood/exit' + +stopNest diff --git a/nix/pkgs/softfloat3/default.nix b/nix/pkgs/softfloat3/default.nix new file mode 100644 index 0000000000..cae76a3662 --- /dev/null +++ b/nix/pkgs/softfloat3/default.nix @@ -0,0 +1,28 @@ +{ stdenv, sources, enableParallelBuilding ? true }: + +stdenv.mkDerivation { + pname = "softfloat3"; + version = sources.softfloat3.rev; + src = sources.softfloat3; + + postPatch = '' + for f in $(find build -type f -name 'Makefile'); do + substituteInPlace $f \ + --replace 'gcc' '$(CC)' \ + --replace 'ar crs' '$(AR) crs' + done + ''; + + preBuild = '' + cd build/Linux-x86_64-GCC + ''; + + installPhase = '' + mkdir -p $out/{lib,include} + cp $src/source/include/*.h $out/include/ + cp softfloat.a $out/lib/libsoftfloat3.a + ''; + + inherit enableParallelBuilding; +} + diff --git a/nix/pkgs/urbit/default.nix b/nix/pkgs/urbit/default.nix index 19befa1ef3..dcd62b3488 100644 --- a/nix/pkgs/urbit/default.nix +++ b/nix/pkgs/urbit/default.nix @@ -1,61 +1,73 @@ -{ - pkgs, - debug, - argon2, ed25519, ent, ge-additions, libaes_siv, h2o, murmur3, scrypt, secp256k1, softfloat3, uv, ivory-header, ca-header -}: +{ lib, stdenv, coreutils, pkgconfig, argon2u, cacert, ca-bundle, curlMinimal +, ed25519, ent, ge-additions, gmp, h2o, herb, ivory, libaes_siv, libscrypt +, libsigsegv, libuv, lmdb, murmur3, openssl, secp256k1, softfloat3, zlib +, enableStatic ? stdenv.hostPlatform.isStatic, enableDebug ? false +, doCheck ? true, enableParallelBuilding ? true }: let - name = - if debug then "urbit-debug" else "urbit"; + src = lib.cleanSource ../../../pkg/urbit; - meta = rec { - inherit debug; - bin = "${urbit}/bin/${name}"; - flags = if debug then [ "-g" ] else []; - exe = ''${meta.bin} ${pkgs.lib.strings.concatStringsSep " " meta.flags}''; - }; +in stdenv.mkDerivation { + inherit src; - sigseg = - pkgs.libsigsegv.overrideAttrs (oldAttrs: rec { - patches = [ ./libsigsegv_fix.patch ]; - }); + pname = "urbit" + lib.optionalString enableDebug "-debug" + + lib.optionalString enableStatic "-static"; - deps = - with pkgs; - [ curl gmp sigseg openssl zlib lmdb ]; + version = builtins.readFile "${src}/version"; - vendor = - [ argon2 softfloat3 ed25519 ent ge-additions libaes_siv h2o scrypt uv murmur3 secp256k1 ivory-header ca-header ]; + nativeBuildInputs = [ pkgconfig ]; - urbit = pkgs.stdenv.mkDerivation { - inherit name meta; - exename = name; - src = ../../../pkg/urbit; - nativeBuildInputs = deps ++ vendor; + buildInputs = [ + argon2u + cacert + ca-bundle + curlMinimal + ed25519 + ent + ge-additions + gmp + h2o + ivory.header + libaes_siv + libscrypt + libsigsegv + libuv + lmdb + murmur3 + openssl + secp256k1 + softfloat3 + zlib + ]; - configurePhase = '' - bash ./configure - ''; + checkInputs = [ herb ]; - installPhase = '' - make all -j8 - make test + # Ensure any `/usr/bin/env bash` shebang is patched. + postPatch = '' + patchShebangs ./configure + ''; - mkdir -p $out/bin - cp ./build/urbit $out/bin/$exename - cp ./build/urbit-worker $out/bin/$exename-worker - ''; + checkTarget = "test"; - # See https://github.com/NixOS/nixpkgs/issues/18995 - hardeningDisable = if debug then [ "all" ] else []; + installPhase = '' + mkdir -p $out/bin + cp ./build/urbit $out/bin/urbit + cp ./build/urbit-worker $out/bin/urbit-worker + ''; - CFLAGS = "-O3 -g -Werror"; - MEMORY_DEBUG = debug; - CPU_DEBUG = debug; - EVENT_TIME_DEBUG = false; - }; + CFLAGS = [ (if enableDebug then "-O0" else "-O3") "-g" ] + ++ lib.optionals (!enableDebug) [ "-Werror" ] + ++ lib.optionals enableStatic [ "-static" ]; -in + MEMORY_DEBUG = enableDebug; + CPU_DEBUG = enableDebug; + EVENT_TIME_DEBUG = false; -urbit + # See https://github.com/NixOS/nixpkgs/issues/18995 + hardeningDisable = lib.optionals enableDebug [ "all" ]; + + inherit enableParallelBuilding doCheck; + + meta = { debug = enableDebug; }; +} diff --git a/nix/pkgs/urbit/libsigsegv_fix.patch b/nix/pkgs/urbit/libsigsegv_fix.patch deleted file mode 100644 index 3f69cef520..0000000000 --- a/nix/pkgs/urbit/libsigsegv_fix.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/src/fault-linux-i386.h 2020-06-25 23:46:02.099235491 +0000 -+++ b/src/fault-linux-i386.h 2020-06-25 23:45:48.679156892 +0000 -@@ -18,6 +18,7 @@ - - #include "fault-posix-ucontext.h" - -+#define HAVE_STACKVMA 0 - #if defined __x86_64__ - /* 64 bit registers */ - ---- a/src/fault-linux-arm.h -+++ b/src/fault-linux-arm.h -@@ -17,6 +17,7 @@ - - #include "fault-posix-ucontext.h" - -+#define HAVE_STACKVMA 0 - #if defined(__aarch64__) || defined(__ARM_64BIT_STATE) || defined(__ARM_PCS_AAPCS64) /* 64-bit */ - - /* See glibc/sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h. diff --git a/nix/pkgs/urbit/release.nix b/nix/pkgs/urbit/release.nix deleted file mode 100644 index 9d486f3dfd..0000000000 --- a/nix/pkgs/urbit/release.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ env_name, env, deps }: - -{ - ent, - name ? "urbit", - debug ? false, - ge-additions, - libaes_siv -}: - -let - - crossdeps = - with env; - [ curl libgmp libsigsegv openssl zlib lmdb ]; - - vendor = - with deps; - [ argon2 softfloat3 ed25519 ge-additions libaes_siv h2o scrypt uv murmur3 secp256k1 ivory-header ca-header ]; - -in - -env.make_derivation { - CFLAGS = if debug then "-O0 -g" else "-O3 -g"; - # binary stripping disabled - # LDFLAGS = if debug then "" else "-s"; - MEMORY_DEBUG = debug; - CPU_DEBUG = debug; - EVENT_TIME_DEBUG = false; - - name = "${name}-${env_name}"; - exename = name; - src = ../../../pkg/urbit; - cross_inputs = crossdeps ++ vendor ++ [ ent ]; - builder = ./release.sh; -} diff --git a/nix/pkgs/urbit/release.sh b/nix/pkgs/urbit/release.sh deleted file mode 100644 index 4bff817e42..0000000000 --- a/nix/pkgs/urbit/release.sh +++ /dev/null @@ -1,21 +0,0 @@ -source $setup - -cp -r $src ./src -chmod -R u+w ./src -cd src - -for dep in $cross_inputs; do - export CFLAGS="${CFLAGS-} -I$dep/include" - export LDFLAGS="${LDFLAGS-} -L$dep/lib" -done - -CC=$host-gcc \ -PKG_CONFIG=pkg-config-cross \ -HOST=$host \ -bash ./configure - -make build/urbit build/urbit-worker -j8 - -mkdir -p $out/bin -cp ./build/urbit $out/bin/$exename -cp ./build/urbit-worker $out/bin/$exename-worker diff --git a/nix/pkgs/urbit/shell.nix b/nix/pkgs/urbit/shell.nix deleted file mode 100644 index dee99d9620..0000000000 --- a/nix/pkgs/urbit/shell.nix +++ /dev/null @@ -1,16 +0,0 @@ -let - - pkgs = import ../../nixpkgs.nix; - deps = import ../../deps { inherit pkgs; }; - tlon = import ../../pkgs { inherit pkgs; }; - -in - -import ./default.nix { - inherit pkgs; - debug = false; - inherit (tlon) - ent ge-additions libaes_siv; - inherit (deps) - argon2 ed25519 h2o murmur3 scrypt secp256k1 softfloat3 uv ivory-header ca-header; -} diff --git a/nix/release.nix b/nix/release.nix deleted file mode 100644 index 2ccd1098bc..0000000000 --- a/nix/release.nix +++ /dev/null @@ -1,54 +0,0 @@ -let - - nixpkgs = import ./nixpkgs.nix; - nixcrpkgs = import ./nixcrpkgs.nix; - crossdeps = import ./crossdeps.nix; - - release = - env_name: env: { - inherit env env_name; - deps = crossdeps env; - }; - - linux64 = release "linux64" nixcrpkgs.linux64; - darwin = release "darwin" nixcrpkgs.mac; - - ent = env: - import ./pkgs/ent/cross.nix env; - - ge-additions = env: - import ./pkgs/ge-additions/cross.nix env; - - libaes_siv = env: - import ./pkgs/libaes_siv/cross.nix env; - - urbit = { env, debug }: - import ./pkgs/urbit/release.nix env { - inherit debug; - name = if debug then "urbit-debug" else "urbit"; - ent = ent env; - ge-additions = ge-additions env; - libaes_siv = libaes_siv env; - }; - - builds-for-platform = plat: - plat.deps // { - inherit (plat.env) curl libgmp libsigsegv openssl zlib lmdb; - inherit (plat.env) cmake_toolchain; - ent = ent plat; - ge-additions = ge-additions plat; - libaes_siv = libaes_siv plat; - urbit = urbit { env = plat; debug = false; }; - urbit-debug = urbit { env = plat; debug = true; }; - }; - - darwin_extra = { - inherit (darwin.env) ranlib ld sdk ar toolchain tapi strip; - }; - -in - -{ - linux64 = builds-for-platform linux64; - darwin = darwin_extra // builds-for-platform darwin; -} diff --git a/nix/sources.json b/nix/sources.json new file mode 100644 index 0000000000..abe295cd04 --- /dev/null +++ b/nix/sources.json @@ -0,0 +1,134 @@ +{ + "argon2u": { + "branch": "master", + "description": "With argon2u. Based off https://github.com/P-H-C/phc-winner-argon2", + "homepage": "", + "owner": "urbit", + "repo": "argon2", + "rev": "4da94a611ee62bad87ab2b131ffda3bcc0723d9c", + "sha256": "0bqq1hg367l4jkb6cqhxlblpvdbwz3l586qsfakwzfd9wdvnm3yc", + "type": "tarball", + "url": "https://github.com/urbit/argon2/archive/4da94a611ee62bad87ab2b131ffda3bcc0723d9c.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "ed25519": { + "branch": "master", + "description": "Submodule included by Urbit", + "homepage": null, + "owner": "urbit", + "repo": "ed25519", + "rev": "76385f2ebbbc9580a9c236952d68d11d73a6135c", + "sha256": "0s1spif4s9lgcwcny3fl2fvpbw6acqn3s8r6qxnrmkd9icgyw4cp", + "type": "tarball", + "url": "https://github.com/urbit/ed25519/archive/76385f2ebbbc9580a9c236952d68d11d73a6135c.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "h2o": { + "branch": "master", + "description": "H2O - the optimized HTTP/1, HTTP/2, HTTP/3 server", + "homepage": "https://h2o.examp1e.net", + "owner": "h2o", + "repo": "h2o", + "rev": "v2.2.4", + "sha256": "0176x0bzjry19zs074a9i5vhncc842xikmx43wj61jky318nq4w4", + "type": "tarball", + "url": "https://github.com/h2o/h2o/archive/v2.2.4.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "hackage.nix": { + "branch": "master", + "description": "Automatically generated Nix expressions for Hackage", + "homepage": "", + "owner": "input-output-hk", + "repo": "hackage.nix", + "rev": "ed4d2759c9e6ca8133a4170f99fabdd76f30f51a", + "sha256": "1n5fk8zsxnbca96zk4ikh74iz3lzh35m302q65zk1rx3nmy4027d", + "type": "tarball", + "url": "https://github.com/input-output-hk/hackage.nix/archive/ed4d2759c9e6ca8133a4170f99fabdd76f30f51a.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "haskell.nix": { + "branch": "master", + "description": "Alternative Haskell Infrastructure for Nixpkgs", + "homepage": "https://input-output-hk.github.io/haskell.nix", + "owner": "input-output-hk", + "repo": "haskell.nix", + "rev": "bbb34dcdf7b90d478002f91713531f418ddf1b53", + "sha256": "1qq397j8vnlp5npk8r675fzjfimg74fcvrkxcdgx7vj48315bh2w", + "type": "tarball", + "url": "https://github.com/input-output-hk/haskell.nix/archive/bbb34dcdf7b90d478002f91713531f418ddf1b53.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "libscrypt": { + "branch": "master", + "description": null, + "homepage": null, + "owner": "urbit", + "repo": "libscrypt", + "rev": "029693ff1cbe4f69d3a2da87d0f4f034f92cc0c2", + "sha256": "17pcxypzjmmrvacw45cacvibm6mlr9ip30hy30l1appsnywx679n", + "type": "tarball", + "url": "https://github.com/urbit/libscrypt/archive/029693ff1cbe4f69d3a2da87d0f4f034f92cc0c2.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "murmur3": { + "branch": "master", + "description": null, + "homepage": null, + "owner": "urbit", + "repo": "murmur3", + "rev": "71a75d57ca4e7ca0f7fc2fd84abd93595b0624ca", + "sha256": "0k7jq2nb4ad9ajkr6wc4w2yy2f2hkwm3nkbj2pklqgwsg6flxzwg", + "type": "tarball", + "url": "https://github.com/urbit/murmur3/archive/71a75d57ca4e7ca0f7fc2fd84abd93595b0624ca.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "niv": { + "branch": "master", + "description": "Easy dependency management for Nix projects", + "homepage": "https://github.com/nmattia/niv", + "owner": "nmattia", + "repo": "niv", + "rev": "9d35b9e4837ab88517210b1701127612c260eccf", + "sha256": "0q50xhnm8g2yfyakrh0nly4swyygxpi0a8cb9gp65wcakcgvzvdh", + "type": "tarball", + "url": "https://github.com/nmattia/niv/archive/9d35b9e4837ab88517210b1701127612c260eccf.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "nixpkgs": { + "branch": "master", + "description": "Nix Packages collection", + "homepage": null, + "owner": "nixos", + "repo": "nixpkgs", + "rev": "166ab9d237409c4b74b1f8ca31476ead35e8fe53", + "sha256": "13i43kvbkdl3dh8b986j6mxbn355mqjhcxrd8cni8zfx1z0wrscr", + "type": "tarball", + "url": "https://github.com/nixos/nixpkgs/archive/166ab9d237409c4b74b1f8ca31476ead35e8fe53.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "softfloat3": { + "branch": "master", + "description": null, + "homepage": null, + "owner": "urbit", + "repo": "berkeley-softfloat-3", + "rev": "ec4c7e31b32e07aad80e52f65ff46ac6d6aad986", + "sha256": "1lz4bazbf7lns1xh8aam19c814a4n4czq5xsq5rmi9sgqw910339", + "type": "tarball", + "url": "https://github.com/urbit/berkeley-softfloat-3/archive/ec4c7e31b32e07aad80e52f65ff46ac6d6aad986.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "stackage.nix": { + "branch": "master", + "description": "Automatically generated Nix expressions of Stackage snapshots", + "homepage": "", + "owner": "input-output-hk", + "repo": "stackage.nix", + "rev": "08312f475f4f5f3b6578e7a78dc501de6fea8792", + "sha256": "15j1l6616kfv7351jxwgb9kj6y8227fcm87nxwabmbn1q6a8q2kf", + "type": "tarball", + "url": "https://github.com/input-output-hk/stackage.nix/archive/08312f475f4f5f3b6578e7a78dc501de6fea8792.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + } +} diff --git a/nix/sources.nix b/nix/sources.nix new file mode 100644 index 0000000000..0286dec14a --- /dev/null +++ b/nix/sources.nix @@ -0,0 +1,154 @@ +# This file has been generated by Niv. + +let + + # + # The fetchers. fetch_ fetches specs of type . + # + + fetch_file = pkgs: spec: + if spec.builtin or true then + builtins_fetchurl { inherit (spec) url sha256; } + else + pkgs.fetchurl { inherit (spec) url sha256; }; + + fetch_tarball = pkgs: name: spec: + let + ok = str: !builtins.isNull (builtins.match "[a-zA-Z0-9+-._?=]" str); + # sanitize the name, though nix will still fail if name starts with period + name' = stringAsChars (x: if !ok x then "-" else x) "${name}-src"; + in if spec.builtin or true then + builtins_fetchTarball { + name = name'; + inherit (spec) url sha256; + } + else + pkgs.fetchzip { + name = name'; + inherit (spec) url sha256; + }; + + fetch_git = spec: + builtins.fetchGit { + url = spec.repo; + inherit (spec) rev ref; + }; + + fetch_local = spec: spec.path; + + fetch_builtin-tarball = name: + throw '' + [${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`. + $ niv modify ${name} -a type=tarball -a builtin=true''; + + fetch_builtin-url = name: + throw '' + [${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`. + $ niv modify ${name} -a type=file -a builtin=true''; + + # + # Various helpers + # + + # The set of packages used when specs are fetched using non-builtins. + mkPkgs = sources: + let + sourcesNixpkgs = + import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) + { }; + hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; + hasThisAsNixpkgsPath = == ./.; + in if builtins.hasAttr "nixpkgs" sources then + sourcesNixpkgs + else if hasNixpkgsPath && !hasThisAsNixpkgsPath then + import { } + else + abort '' + Please specify either (through -I or NIX_PATH=nixpkgs=...) or + add a package called "nixpkgs" to your sources.json. + ''; + + # The actual fetching function. + fetch = pkgs: name: spec: + + if !builtins.hasAttr "type" spec then + abort "ERROR: niv spec ${name} does not have a 'type' attribute" + else if spec.type == "file" then + fetch_file pkgs spec + else if spec.type == "tarball" then + fetch_tarball pkgs name spec + else if spec.type == "git" then + fetch_git spec + else if spec.type == "local" then + fetch_local spec + else if spec.type == "builtin-tarball" then + fetch_builtin-tarball name + else if spec.type == "builtin-url" then + fetch_builtin-url name + else + abort + "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; + + # Ports of functions for older nix versions + + # a Nix version of mapAttrs if the built-in doesn't exist + mapAttrs = builtins.mapAttrs or (f: set: + with builtins; + listToAttrs (map (attr: { + name = attr; + value = f attr set.${attr}; + }) (attrNames set))); + + # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 + range = first: last: + if first > last then + [ ] + else + builtins.genList (n: first + n) (last - first + 1); + + # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 + stringToCharacters = s: + map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); + + # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269 + stringAsChars = f: s: concatStrings (map f (stringToCharacters s)); + concatStrings = builtins.concatStringsSep ""; + + # fetchTarball version that is compatible between all the versions of Nix + builtins_fetchTarball = { url, name, sha256 }@attrs: + let inherit (builtins) lessThan nixVersion fetchTarball; + in if lessThan nixVersion "1.12" then + fetchTarball { inherit name url; } + else + fetchTarball attrs; + + # fetchurl version that is compatible between all the versions of Nix + builtins_fetchurl = { url, sha256 }@attrs: + let inherit (builtins) lessThan nixVersion fetchurl; + in if lessThan nixVersion "1.12" then + fetchurl { inherit url; } + else + fetchurl attrs; + + # Create the final "sources" from the config + mkSources = config: + mapAttrs (name: spec: + if builtins.hasAttr "outPath" spec then + abort + "The values in sources.json should not have an 'outPath' attribute" + else + spec // { outPath = fetch config.pkgs name spec; }) config.sources; + + # The "config" used by the fetchers + mkConfig = { sourcesFile ? ./sources.json + , sources ? builtins.fromJSON (builtins.readFile sourcesFile) + , pkgs ? mkPkgs sources }: rec { + # The sources, i.e. the attribute set of spec name to spec + inherit sources; + + # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers + inherit pkgs; + }; +in mkSources (mkConfig { }) // { + __functor = _: settings: mkSources (mkConfig settings); +} diff --git a/pkg/ent/shell.nix b/pkg/ent/shell.nix new file mode 100644 index 0000000000..0866cb96f2 --- /dev/null +++ b/pkg/ent/shell.nix @@ -0,0 +1,8 @@ +let + + pkgs = import ../../default.nix { }; + +in pkgs.shellFor { + name = "ent"; + packages = ps: [ ps.ent ]; +} diff --git a/pkg/ge-additions/shell.nix b/pkg/ge-additions/shell.nix new file mode 100644 index 0000000000..4e07f72b5b --- /dev/null +++ b/pkg/ge-additions/shell.nix @@ -0,0 +1,8 @@ +let + + pkgs = import ../../default.nix { }; + +in pkgs.shellFor { + name = "ge-additions"; + packages = ps: [ ps.ge-additions ]; +} diff --git a/pkg/herb/default.nix b/pkg/herb/default.nix deleted file mode 100644 index b1dd819a6a..0000000000 --- a/pkg/herb/default.nix +++ /dev/null @@ -1,39 +0,0 @@ -let - - rev = "61c3169a0e17d789c566d5b241bfe309ce4a6275"; - hash = "0qbycg7wkb71v20rchlkafrjfpbk2fnlvvbh3ai9pyfisci5wxvq"; - - nixpkgs = builtins.fetchTarball { - name = "nixpkgs-2019-01-15"; - url = "https://github.com/nixos/nixpkgs/archive/${rev}.tar.gz"; - sha256 = hash; - }; - -in - -{ pkgs ? import nixpkgs {} }: - -let - - pyenv = pkgs.python2.withPackages (py: [ py.requests ]); - pyexe = "${pyenv}/bin/python"; - -in - -pkgs.stdenv.mkDerivation rec { - name = "herb"; - buildInputs = [ pyenv ]; - unpackPhase = "true"; - installPhase = '' - mkdir -p $out/bin - - cp ${./herb} $out/bin/herb.py - - cat > $out/bin/herb < {} }: -with pkgs; -stdenv.mkDerivation { +let + + pkgs = import ../../default.nix { }; + +in pkgs.shellFor { name = "libaes_siv"; - buildInputs = [ cmake openssl ]; + packages = ps: [ ps.libaes_siv ]; } diff --git a/pkg/urbit/shell.nix b/pkg/urbit/shell.nix index 6974e63c9e..62e0f72cd0 100644 --- a/pkg/urbit/shell.nix +++ b/pkg/urbit/shell.nix @@ -1 +1,8 @@ -import ../../nix/pkgs/urbit/shell.nix +let + + pkgs = import ../../default.nix { }; + +in pkgs.shellFor { + name = "urbit"; + packages = ps: [ ps.urbit ]; +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000000..184b9d9f00 --- /dev/null +++ b/shell.nix @@ -0,0 +1,72 @@ +# A repository wide shell.nix containing all tools, formatters, and inputs +# required to build any of the C or Haskell packages. +# +# Entering a nix-shell using this derivation will allow you to cd anywhere +# in the ./pkg directory and run the appropriate build tooling. +# +# See the individual ./pkg/* directories for shell.nix derivations that only +# propagate minimal sets of buildInputs for the related package. +# (import ./default.nix { }).shell + +let + + pkgs = import ./nix/default.nix { }; + localPackages = import ./default.nix { }; + + # The non-Haskell packages which build inputs (dependencies) will be + # propagated into the shell. This combines nixpkgs' mkShell behaviour + # with Haskell.nix's shellFor. + # + # For example, adding urbit here results in gmp, h2o, zlib, etc. being + # made available, so you can just run make. + # + # Typically the inputs listed here also have a shell.nix in their respective + # source directory you can use, to avoid the Haskell/GHC dependencies. + inputsFrom = with localPackages; [ ent ge-additions herb libaes_siv urbit ]; + + merge = name: pkgs.lib.concatLists (pkgs.lib.catAttrs name inputsFrom); + +in localPackages.hs.shellFor { + # Haskell packages from the stackProject which will have their + # dependencies available in the shell. + packages = ps: + with ps; [ + lmdb-static + racquire + terminal-progress-bar + urbit-atom + urbit-azimuth + urbit-eventlog-lmdb + urbit-king + urbit-noun + urbit-noun-core + urbit-termsize + ]; + + # Build tools to make available in the shell's PATH. + buildInputs = [ + pkgs.cacert + pkgs.stack + pkgs.nixfmt + pkgs.shfmt + + (import pkgs.sources.niv { }).niv + + (localPackages.hs.hackageTool { + name = "ormolu"; + version = "0.1.3.0"; + }) + + (localPackages.hs.hackageTool { + name = "ShellCheck"; + version = "0.7.1"; + }) + ] ++ merge "buildInputs"; + + nativeBuildInputs = merge "nativeBuildInputs"; + propagatedBuildInputs = merge "propagatedBuildInputs"; + propagatedNativeBuildInputs = merge "propagatedNativeBuildInputs"; + + shellHook = pkgs.lib.concatStringsSep "\n" + (pkgs.lib.catAttrs "shellHook" (pkgs.lib.reverseList inputsFrom)); +} From eeff3034cd755dc221a5df0ea940010f3576b5c2 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Tue, 27 Oct 2020 11:42:36 +0100 Subject: [PATCH 526/933] king: update stackage resolver to lts-16.15 This allows us to drop flat/urbit-hob as they're now in the package set, web3/vinyl need to be added to account for urbit-azimuth's dependencies. --- pkg/hs/stack.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/hs/stack.yaml b/pkg/hs/stack.yaml index 88e2364f1b..efd4d81f9b 100644 --- a/pkg/hs/stack.yaml +++ b/pkg/hs/stack.yaml @@ -1,4 +1,4 @@ -resolver: lts-14.21 +resolver: lts-16.15 packages: - lmdb-static @@ -15,11 +15,11 @@ packages: - urbit-noun-core extra-deps: - - flat-0.3.4@sha256:002a0e0ae656ea8cc02a772d0bcb6ea7dbd7f2e79070959cc748ad1e7138eb38 - base58-bytestring-0.1.0@sha256:a1da72ee89d5450bac1c792d9fcbe95ed7154ab7246f2172b57bd4fd9b5eab79 - lock-file-0.7.0.0@sha256:3ad84b5e454145e1d928063b56abb96db24a99a21b493989520e58fa0ab37b00 - para-1.1@sha256:a90eebb063ad70271e6e2a7f00a93e8e8f8b77273f100f39852fbf8301926f81 - - urbit-hob-0.3.3@sha256:ff8dae3844881cd979fee96bcb3ab3d5ea95f7c3ad2302dbc4b2dc417ff6595b + - web3-0.9.1.0@sha256:6b7faac0b63e7d0aae46588dd9a42e11f54ce0fdf4c2744bdf4cc6c5cbf39aa2 + - vinyl-0.12.3@sha256:66553fc71cabfa86837bf5f98558e3e6d1807c47af5f5f1cd758081d3fb023ea # This allows building on NixOS. nix: From 345bf2c39a5c183f82122a4c7b6b725b15a8d9a8 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Tue, 27 Oct 2020 11:48:26 +0100 Subject: [PATCH 527/933] king: remove broken/unused regex-tdfa-text dependency Text instances are now contained in the parent regex-tdfa package. --- pkg/hs/urbit-king/package.yaml | 1 - pkg/hs/urbit-noun/package.yaml | 1 - 2 files changed, 2 deletions(-) diff --git a/pkg/hs/urbit-king/package.yaml b/pkg/hs/urbit-king/package.yaml index 583cd6b6cd..a3bb3673ec 100644 --- a/pkg/hs/urbit-king/package.yaml +++ b/pkg/hs/urbit-king/package.yaml @@ -78,7 +78,6 @@ dependencies: - racquire - random - regex-tdfa - - regex-tdfa-text - resourcet - rio - semigroups diff --git a/pkg/hs/urbit-noun/package.yaml b/pkg/hs/urbit-noun/package.yaml index d94be31f67..17edb72f7e 100644 --- a/pkg/hs/urbit-noun/package.yaml +++ b/pkg/hs/urbit-noun/package.yaml @@ -20,7 +20,6 @@ dependencies: - lens - murmur3 - regex-tdfa - - regex-tdfa-text - rio - text - time From 48aa77a2fa8b88f411665a5a856263e23a0c49bf Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Tue, 27 Oct 2020 11:50:05 +0100 Subject: [PATCH 528/933] build: adding nix, shell, and haskell code formatters These need to be run through the top-level nix-shell/shell.nix --- sh/fmt | 15 +++++++++++++++ sh/fmt-haskell | 18 ++++++++++++++++++ sh/fmt-nix | 12 ++++++++++++ sh/fmt-shell | 14 ++++++++++++++ 4 files changed, 59 insertions(+) create mode 100755 sh/fmt create mode 100755 sh/fmt-haskell create mode 100755 sh/fmt-nix create mode 100755 sh/fmt-shell diff --git a/sh/fmt b/sh/fmt new file mode 100755 index 0000000000..c15ff4492e --- /dev/null +++ b/sh/fmt @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +# Usage: fmt + +# Run all formatters and linters ensuring codebase consistency + +set -euo pipefail + +cd "${0%/*}" + +./fmt-shell +./fmt-nix +./fmt-haskell + +echo 'Done.' diff --git a/sh/fmt-haskell b/sh/fmt-haskell new file mode 100755 index 0000000000..6b5de61178 --- /dev/null +++ b/sh/fmt-haskell @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +# Usage: fmt-haskell + +set -euo pipefail + +cd "${0%/*}/.." + +echo "Formatting Haskell" + +# FIXME: Avoid inplace (-i) modifications for now. +find pkg/hs -type f -name '*.hs' \ + -exec ormolu --mode check \ + -o '-XBangPatterns' \ + -o '-XMagicHash' \ + -o '-XTypeApplications' \ + -o '-XPatternSynonyms' \ + {} \+ diff --git a/sh/fmt-nix b/sh/fmt-nix new file mode 100755 index 0000000000..6998b75b16 --- /dev/null +++ b/sh/fmt-nix @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# Usage: fmt-nix + +set -euo pipefail + +cd "${0%/*}/.." + +echo "Formatting Nix" + +find . -type f -name '*.nix' \ + -exec nixfmt {} \+ diff --git a/sh/fmt-shell b/sh/fmt-shell new file mode 100755 index 0000000000..d89128dfd0 --- /dev/null +++ b/sh/fmt-shell @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# Usage: fmt-shell + +set -euo pipefail + +cd "${0%/*}/.." + +echo "Formatting Shell" + +# FIXME: Avoid inplace (-w) modifications for now. +find sh -type f \ + -exec shfmt -s -i 2 -ln bash -l {} \+ \ + -exec shellcheck --shell=bash --format=tty {} \+ From 887a78920fdea08402abfe6775d07cc2d2ce6f68 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Tue, 27 Oct 2020 11:51:19 +0100 Subject: [PATCH 529/933] build: removing travis ci configuration --- .travis.yml | 80 ----------------------------------------------------- 1 file changed, 80 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e9f7b659fc..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,80 +0,0 @@ -stages: - - compile - # Don't run the combine stage in pull requests, because deploy is disabled there. - - name: combine - if: type != pull_request - -jobs: - include: - - stage: compile - os: linux - language: nix - nix: 2.3.6 - before_install: - - git lfs pull - - echo "trusted-users = root travis" | sudo tee -a /etc/nix/nix.conf && sudo pkill nix-daemon - install: - - nix-env -iA cachix -f https://cachix.org/api/v1/install - script: - - cachix use urbit2 - - ./sh/cachix - - make build - - make release - - sh/ci-tests - - - stage: compile - os: linux - language: generic - env: STACK_YAML=pkg/hs/stack.yaml - cache: - directories: - - $HOME/.ghc - - $HOME/.cabal - - $HOME/.stack - - $TRAVIS_BUILD_DIR/.stack-work - before_install: - - sh/travis-install-stack - install: - - stack --no-terminal --install-ghc build urbit-king --only-dependencies - script: - - stack test - - sh/release-king-linux64-dynamic - - - stage: compile - os: osx - language: generic - sudo: required - env: STACK_YAML=pkg/hs/stack.yaml - cache: - directories: - - $HOME/.ghc - - $HOME/.cabal - - $HOME/.stack - - $TRAVIS_BUILD_DIR/.stack-work - before_install: - - sh/travis-install-stack - install: - - stack --no-terminal --install-ghc build urbit-king --only-dependencies - script: - - stack test - - sh/release-king-darwin-dynamic - - - stage: combine - os: linux - language: generic - script: - - sh/combine-release-builds - -deploy: - - skip_cleanup: true - provider: gcs - access_key_id: GOOGTADOPP55X5ZTH3IKAXQW - secret_access_key: - secure: rSPif0VHX3Q3QpWM9iUt/Z9sicCY8ABuwVFPeT3YUnAAmSXM46PIHKieoGs79kx9IelFyQsM8xS0XWyt4S/haR7VaTJY+zHJjf0AnA1sr5ZIV70t3K0SXzq4+E1ffOZRiC0VmHatPz10wjaIpHxpjcROqQV4M1dBCq2H/rpccIE= - bucket: bootstrap.urbit.org - local-dir: release/ - acl: public-read - on: - condition: "-d release/" - repo: urbit/urbit - all_branches: true From db3383ff6705b5b61d2367aa4717902a66b71007 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Tue, 27 Oct 2020 11:52:04 +0100 Subject: [PATCH 530/933] build: update makefile and scripts to match new nix expressions --- Makefile | 9 ++---- sh/boot | 22 -------------- sh/bootstrap | 4 --- sh/cachix | 51 --------------------------------- sh/ci-tests | 14 --------- sh/combine-release-builds | 41 -------------------------- sh/create-ropsten-pills | 22 ++++++++++---- sh/cross | 28 ------------------ sh/image | 17 ----------- sh/release | 38 +++++++++--------------- sh/release-king-darwin-dynamic | 29 ------------------- sh/release-king-linux64-dynamic | 29 ------------------- sh/release-king-linux64-static | 26 ----------------- sh/test | 10 +++---- sh/travis-install-stack | 45 ----------------------------- sh/update-brass-pill | 7 +++-- sh/update-ivory-pill | 9 +++--- sh/update-solid-pill | 7 +++-- 18 files changed, 50 insertions(+), 358 deletions(-) delete mode 100755 sh/boot delete mode 100755 sh/bootstrap delete mode 100755 sh/cachix delete mode 100755 sh/ci-tests delete mode 100755 sh/combine-release-builds delete mode 100755 sh/cross delete mode 100755 sh/image delete mode 100755 sh/release-king-darwin-dynamic delete mode 100755 sh/release-king-linux64-dynamic delete mode 100755 sh/release-king-linux64-static delete mode 100755 sh/travis-install-stack diff --git a/Makefile b/Makefile index 4347069709..19f3255bb0 100644 --- a/Makefile +++ b/Makefile @@ -3,15 +3,9 @@ build: nix-build -A urbit -A herb --no-out-link -build-all: - nix-build --no-out-link - install: nix-env -f . -iA urbit -iA urbit-debug -iA herb -cross: - sh/cross - release: sh/release @@ -32,3 +26,6 @@ interface: clean: rm -rf ./out ./work rm -f result result-* + +fmt: + sh/fmt diff --git a/sh/boot b/sh/boot deleted file mode 100755 index c57759e24c..0000000000 --- a/sh/boot +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -set -e - -case $# in - 0) ship=zod; target=./s/zod;; - 1) ship=$1; target=./s/$1;; - 2) ship=$1; target=$2;; - *) echo "Usage: $0 [ship] [target-dir]" >&2 - exit 1;; -esac - -if [ -e "$target" ] -then echo "Target directory '$target' already exists." >&2 - exit 1 -fi - -pkg=$(nix-build nix/ops/boot-ship.nix --arg ship "\"$ship\"" --no-out-link) - -mkdir -p "$(dirname "$target")" -cp -r $pkg/ $target -chmod -R u+rw $target diff --git a/sh/bootstrap b/sh/bootstrap deleted file mode 100755 index 3a8a74e560..0000000000 --- a/sh/bootstrap +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -git submodule init -git submodule update diff --git a/sh/cachix b/sh/cachix deleted file mode 100755 index 15394f45fe..0000000000 --- a/sh/cachix +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env bash - -fail () { - echo "$@" - if [ "$TRAVIS_PULL_REQUEST" = false ] - then exit 1 - else exit 0 - fi -} - -cache=1 - -if [ -z "$CACHIX_SIGNING_KEY" ] -then - echo "The CACHIX_SIGNING_KEY environment variable needs to be set." - echo "Disabling cachix uploads" - cache=0 -fi - -if [ -z "$CACHIX_AUTH_TOKEN" ] -then - echo "The CACHIX_AUTH_TOKEN environment variable needs to be set." - echo "Disabling cachix uploads" - cache=0 -fi - -cleanup () { - rm -f .cache.list -} - -trap cleanup EXIT - -set -ex - -if [ $cache = 1 ] -then cachix authtoken "$CACHIX_AUTH_TOKEN" >/dev/null -fi - -cachix use urbit2 || true - -build () { - nix-build --no-out-link --max-jobs 3 "$@" > .cache.list - if [ $cache = 1 ] - then cachix push urbit2 < .cache.list - fi -} - -time build nix/cachix/local.nix -#time build nix/cachix/tests.nix -A fakebus -time build nix/cachix/tests.nix -A results -time build nix/cachix/release.nix diff --git a/sh/ci-tests b/sh/ci-tests deleted file mode 100755 index 3a53726535..0000000000 --- a/sh/ci-tests +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -set -ex - -if [ "$TRAVIS_PULL_REQUEST" = false ] -then - - sh/test --arg debug false - -else - - sh/test --arg debug true - -fi diff --git a/sh/combine-release-builds b/sh/combine-release-builds deleted file mode 100755 index 844b542f09..0000000000 --- a/sh/combine-release-builds +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash - -set -ex - -if [ -n "${TRAVIS_TAG-}" ] -then - ver="$TRAVIS_TAG" -elif [ -n "${TRAVIS_COMMIT-}" ] -then - ver="$TRAVIS_COMMIT" -else - ver="$(git rev-parse HEAD)" -fi - -traced () { - echo '$' "$@" >&2; "$@" -} - -buildTarball () { - local plat=${1} - local haskbin=${2} - - tmp=$(mktemp -d) - mkdir -p $tmp/$ver-$plat - - # Fetch the vere binary and unpack it into its destination - wget "https://bootstrap.urbit.org/vere-$ver-$plat.tgz" - tar xzvf vere-$ver-$plat.tgz --strip=1 -C $tmp/$ver-$plat - - # Fetch king haskell and give it executable permissions. - wget "https://bootstrap.urbit.org/$haskbin-$ver" -O $tmp/$ver-$plat/urbit-king - chmod 555 $tmp/$ver-$plat/urbit-king - - echo "packaging release/$ver-$plat.tgz" - (cd $tmp; tar cz $ver-$plat) > release/$ver-$plat.tgz -} - -mkdir -p release - -buildTarball "linux64" "king-linux64-dynamic" -buildTarball "darwin" "king-darwin-dynamic" diff --git a/sh/create-ropsten-pills b/sh/create-ropsten-pills index 86d2e41d86..d288795f3b 100755 --- a/sh/create-ropsten-pills +++ b/sh/create-ropsten-pills @@ -1,11 +1,21 @@ #!/usr/bin/env bash -set -e +# Usage: create-ropsten-pills -sha=$(git rev-parse HEAD) +# Build the ivory and brass ropsten pills, copying them to the local directory, +# named with the current give revision -brass=$(nix-build nix/ops -A brass-ropsten --no-out-link) -ivory=$(nix-build nix/ops -A ivory-ropsten --no-out-link) +set -xeuo pipefail -cp $brass ./brass-ropsten-${sha:0:5}.pill -cp $ivory ./ivory-ropsten-${sha:0:5}.pill +cd "${0%/*}/.." + +rev="$(git rev-parse HEAD)" +sha="${rev:0:5}" + +brass="brass-ropsten-${sha}.pill" +ivory="ivory-ropsten-${sha}.pill" + +cp -f "$(nix-build -A brass-ropsten.build --no-out-link)" "$brass" +cp -f "$(nix-build -A ivory-ropsten.build --no-out-link)" "$ivory" + +chmod 0644 "$brass" "$ivory" diff --git a/sh/cross b/sh/cross deleted file mode 100755 index 28d1aa8772..0000000000 --- a/sh/cross +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash - -set -e - -err () { echo "$@" >&2; exit 1; } - -[ $# = 2 ] || { - sh/cross urbit linux64 - sh/cross urbit darwin - exit 0 -} - -traced () { - echo '$' "$@" >&2; "$@" -} - -release () { - traced nix-build nix/release.nix --no-out-link -A "$1" -} - -pkg="$1" -env="$2" - -res=$(release "$env.$pkg") - -mkdir -p ./cross/$env -traced cp -f $res/bin/$pkg ./cross/$env/$pkg -traced cp -f $res/bin/$pkg-worker ./cross/$env/$pkg-worker diff --git a/sh/image b/sh/image deleted file mode 100755 index 4220904a58..0000000000 --- a/sh/image +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -say() { - echo "$1" >&2 -} - -say "Building nix/ops/image..." -nix_out="$(nix-build nix/ops -A image --no-out-link "$@")" - -say "Loading $nix_out into Docker..." -nix_name="$(docker load --quiet --input $nix_out)" -nix_name="${nix_name#Loaded image: }" - -# Output only the tag on stdout for subsequent pipes/tooling. -echo $nix_name diff --git a/sh/release b/sh/release index 0207a9390d..1235130770 100755 --- a/sh/release +++ b/sh/release @@ -1,33 +1,21 @@ #!/usr/bin/env bash -set -ex +# Usage: release -if [ -n "${TRAVIS_TAG-}" ] -then - ver="$TRAVIS_TAG" -elif [ -n "${TRAVIS_COMMIT-}" ] -then - ver="$TRAVIS_COMMIT" -else - ver="$(git rev-parse HEAD)" -fi +# Create a static tarball under ./release named with the current git revision. -traced () { - echo '$' "$@" >&2; "$@" -} +set -xeuo pipefail + +cd "${0%/*}/.." + +rev="$(git rev-parse HEAD)" +sha="${rev:0:5}" +ver="$(cat pkg/urbit/version)" +tgz="release/urbit-v${ver}-${sha}.tar.gz" +out="$(nix-build -A tarball --arg enableStatic true --no-out-link)" mkdir -p release -for plat in linux64 darwin -do - sh/cross urbit "$plat" +cp -f "$out" "$tgz" - tmp=$(mktemp -d) - mkdir -p $tmp/vere-$ver-$plat - traced cp -r cross/$plat/* $tmp/vere-$ver-$plat - - echo "packaging release/vere-$ver-$plat.tgz" - (cd $tmp; tar cz vere-$ver-$plat) > release/vere-$ver-$plat.tgz - - rm -rf $tmp -done +chmod 0644 "$tgz" diff --git a/sh/release-king-darwin-dynamic b/sh/release-king-darwin-dynamic deleted file mode 100755 index e5e5416caa..0000000000 --- a/sh/release-king-darwin-dynamic +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -set -ex - -if [ -n "${TRAVIS_TAG-}" ] -then - ver="$TRAVIS_TAG" -elif [ -n "${TRAVIS_COMMIT-}" ] -then - ver="$TRAVIS_COMMIT" -else - ver="$(git rev-parse HEAD)" -fi - -export STACK_YAML="`pwd`/pkg/hs/stack.yaml" - -mkdir -p release - -stack clean # Make sure we optimize - -stack install urbit-king \ - --local-bin-path "`pwd`/release" \ - --test --no-run-tests - -out="release/king-darwin-dynamic-$ver" - -mv release/urbit-king "$out" - -otool -L "$out" diff --git a/sh/release-king-linux64-dynamic b/sh/release-king-linux64-dynamic deleted file mode 100755 index 183904b245..0000000000 --- a/sh/release-king-linux64-dynamic +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -set -ex - -if [ -n "${TRAVIS_TAG-}" ] -then - ver="$TRAVIS_TAG" -elif [ -n "${TRAVIS_COMMIT-}" ] -then - ver="$TRAVIS_COMMIT" -else - ver="$(git rev-parse HEAD)" -fi - -export STACK_YAML="`pwd`/pkg/hs/stack.yaml" - -mkdir -p release - -stack clean # Make sure we optimize - -stack install urbit-king \ - --local-bin-path "`pwd`/release" \ - --test --no-run-tests - -out="release/king-linux64-dynamic-$ver" - -mv release/urbit-king "$out" - -ldd "$out" diff --git a/sh/release-king-linux64-static b/sh/release-king-linux64-static deleted file mode 100755 index a08e2b6f15..0000000000 --- a/sh/release-king-linux64-static +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -set -ex - -if [ -n "${TRAVIS_TAG-}" ] -then - ver="$TRAVIS_TAG" -elif [ -n "${TRAVIS_COMMIT-}" ] -then - ver="$TRAVIS_COMMIT" -else - ver="$(git rev-parse HEAD)" -fi - -pushd pkg/hs - -king=$(bash $(nix-build --no-link -A fullBuildScript)) - -popd - -mkdir -p release - -out="release/king-linux64-static-$ver" - -cp "$king"/bin/urbit-king "$out" - diff --git a/sh/test b/sh/test index c3b7f37081..8db22d247e 100755 --- a/sh/test +++ b/sh/test @@ -1,8 +1,8 @@ #!/usr/bin/env bash -set -e +set -euo pipefail -pkg=$(nix-build nix/ops -A test --no-out-link "$@") +pkg="$(nix-build -A urbit-tests --no-out-link "$@")" hdr () { echo =====$(sed 's/./=/g' <<< "$1")===== @@ -10,10 +10,10 @@ hdr () { echo =====$(sed 's/./=/g' <<< "$1")===== } -for f in $(find $pkg/ -type f) +for f in $(find "$pkg/" -type f) do - hdr $(basename $f) - cat $f + hdr "$(basename $f)" + cat "$f" done fail=0 diff --git a/sh/travis-install-stack b/sh/travis-install-stack deleted file mode 100755 index 8bd3128c52..0000000000 --- a/sh/travis-install-stack +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env bash - -set -ex - - -## -## Make sure this is running OSX/Linux in Travis -## - -os="$TRAVIS_OS_NAME" - -[ "$os" = osx ] || [ "$os" = linux ] - - -## -## Download the stack executable. -## - -mkdir -p ~/.local/bin - -stackurl="https://get.haskellstack.org/stable/$os-x86_64.tar.gz" - -case $os in - osx) - curl -L "$stackurl" | - tar xz --strip-components=1 --include '*/stack' -C ~/.local/bin - ;; - linux) - mkdir -p tmp - curl -L "$stackurl" | tar xz -C tmp - mv tmp/stack-*/stack ~/.local/bin - ;; -esac - - -## -## Use the more reliable S3 mirror of Hackage. -## - -mkdir -p ~/.cabal - -cat > ~/.cabal/config < Date: Tue, 27 Oct 2020 11:56:40 +0100 Subject: [PATCH 531/933] vere: externalise version from configure script This allows tooling such as ci expressions to easily inspect the build's current version. --- pkg/urbit/configure | 2 +- pkg/urbit/version | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 pkg/urbit/version diff --git a/pkg/urbit/configure b/pkg/urbit/configure index 313d11a10e..cfc42f83e3 100755 --- a/pkg/urbit/configure +++ b/pkg/urbit/configure @@ -2,7 +2,7 @@ set -e -URBIT_VERSION="0.10.9-rc1" +URBIT_VERSION="$(cat ./version)" deps=" \ curl gmp sigsegv argon2 ed25519 ent h2o scrypt uv murmur3 secp256k1 \ diff --git a/pkg/urbit/version b/pkg/urbit/version new file mode 100644 index 0000000000..706e712b06 --- /dev/null +++ b/pkg/urbit/version @@ -0,0 +1 @@ +0.10.9-rc1 \ No newline at end of file From 8a830934b1092f33ff6150f34e0134ce5c77f005 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Tue, 27 Oct 2020 11:59:15 +0100 Subject: [PATCH 532/933] build: reorganising top-level .gitignore and add nix ignores --- .gitignore | 89 ++++++++++++++++++++++++++++++-------------- pkg/hs/.gitignore | 1 - pkg/urbit/.gitignore | 13 +------ 3 files changed, 62 insertions(+), 41 deletions(-) delete mode 100644 pkg/hs/.gitignore diff --git a/.gitignore b/.gitignore index 74b439d227..e79759dc67 100644 --- a/.gitignore +++ b/.gitignore @@ -1,46 +1,79 @@ -# nix symlink artifacts -# +# OSX +.DS_Store + +# Editors +*~ +*# +.#* +\#*# +.*.sw[a-z] +*.un~ +*.org +.projectile +s/* +cscope.* + +# Tags +.tags +.etags +TAGS +GPATH +GRTAGS +GTAGS + +# Nix result result-* -# common dev piers -# +# Common Piers /zod /bus /nec /fakezod -# package manager caches -# -.stack-work +# NodeJS node_modules -# build and release artifacts -# +# Haskell +.stack-work +stack.yaml.lock +dist-newstyle +.ghc* + +# Profiling +*.prof +*.aux +*.hp +*.ps +*.pdf + +# Build/Release Artifacts +build/ cross/ release/ -dist -/out -/work +dist/ +out/ +work/ +*.o -# landscape dev -# +# Landscape Dev urbitrc *-min.js pkg/interface/link-webext/web-ext-artifacts -# catchall editor and OS stuff -# -.tags -.etags -tags -TAGS -GPATH -GRTAGS -GTAGS -.DS_Store -*.swp -*.swo -\#*\# -s/* +# Certificates +*.pem +*.key +*.secret +*.sec +*.asc +# Archives +*.zip +*.gz +*.tar +*.bzip2 +*.xz + +# Logs +*.log \ No newline at end of file diff --git a/pkg/hs/.gitignore b/pkg/hs/.gitignore deleted file mode 100644 index 609770f0c7..0000000000 --- a/pkg/hs/.gitignore +++ /dev/null @@ -1 +0,0 @@ -stack.yaml.lock diff --git a/pkg/urbit/.gitignore b/pkg/urbit/.gitignore index fc91e91c25..6c94be2f8c 100644 --- a/pkg/urbit/.gitignore +++ b/pkg/urbit/.gitignore @@ -1,14 +1,3 @@ -# # Configuration Result -# /config.mk -include/config.h -# -# Build Outputs -# -*.o -/build/* -# -# Editor Bullshit -# -cscope.* +/include/config.h From a6e748627cceb43fc7fb242a678528e78ff5163c Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Tue, 27 Oct 2020 12:34:31 +0100 Subject: [PATCH 533/933] herb: correct python shebang This ensures the shebang works and can be run or patched via nix. --- pkg/herb/herb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/herb/herb b/pkg/herb/herb index 315992f01d..94c02942a8 100755 --- a/pkg/herb/herb +++ b/pkg/herb/herb @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # TODO: # - -h text From c089f4c55779656ab8115f6714ed2977b5d8f5b9 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Tue, 27 Oct 2020 12:36:47 +0100 Subject: [PATCH 534/933] herb: removing unnecessary .gitattributes --- pkg/herb/.gitattributes | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 pkg/herb/.gitattributes diff --git a/pkg/herb/.gitattributes b/pkg/herb/.gitattributes deleted file mode 100644 index fe423d56a6..0000000000 --- a/pkg/herb/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -.gitattributes export-ignore -default.nix export-ignore From d7522561265157d4374416fb730e5b98c031f42e Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Tue, 27 Oct 2020 12:43:52 +0100 Subject: [PATCH 535/933] king: replace use of deprecated network/socket address lookup --- pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs index 0fdab349b6..2d55a48c02 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs @@ -16,8 +16,6 @@ TODO How to detect socket closed during server run? -} -{-# OPTIONS_GHC -Wno-deprecations #-} - module Urbit.Vere.Eyre.Serv ( ServApi(..) , TlsConfig(..) @@ -140,8 +138,12 @@ openFreePort hos = do Right ps -> pure (Right ps) where doBind sok = do - adr <- Net.inet_addr hos - Net.bind sok (Net.SockAddrInet Net.defaultPort adr) + adr <- + Net.getAddrInfo Nothing (Just hos) Nothing >>= \case + [] -> error ("unable to determine numeric hostname from " ++ hos) + ip : _ -> pure (Net.addrAddress ip) + + Net.bind sok adr Net.listen sok 1 port <- Net.socketPort sok pure (fromIntegral port, sok) From 2b74a8edd68c7b9ce0e6960f18e737312a7312ce Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Tue, 27 Oct 2020 13:04:31 +0100 Subject: [PATCH 536/933] king: disable overlapping patterns for deriveNoun/Void usage --- pkg/hs/urbit-king/lib/Urbit/Arvo/Common.hs | 4 ++++ pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs | 4 ++++ pkg/hs/urbit-king/lib/Urbit/Arvo/Event.hs | 7 +++++-- pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs | 5 +++++ pkg/hs/urbit-king/lib/Urbit/Vere/Behn.hs | 4 ++++ 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Arvo/Common.hs b/pkg/hs/urbit-king/lib/Urbit/Arvo/Common.hs index 7282e939e9..19f97d9791 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Arvo/Common.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Arvo/Common.hs @@ -1,5 +1,9 @@ {-# LANGUAGE StrictData #-} +-- This is required due to the use of 'Void' in a constructor slot in +-- combination with 'deriveNoun' which generates an unreachable pattern. +{-# OPTIONS_GHC -Wno-overlapping-patterns #-} + {-| Types used in both Events and Effects. -} diff --git a/pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs b/pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs index 2c01faf9e3..f79b2a7874 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs @@ -1,5 +1,9 @@ {-# LANGUAGE StrictData #-} +-- This is required due to the use of 'Void' in a constructor slot in +-- combination with 'deriveNoun' which generates an unreachable pattern. +{-# OPTIONS_GHC -Wno-overlapping-patterns #-} + {-| Effect Types and Their Noun Conversions -} diff --git a/pkg/hs/urbit-king/lib/Urbit/Arvo/Event.hs b/pkg/hs/urbit-king/lib/Urbit/Arvo/Event.hs index eadc524e11..583c4ed644 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Arvo/Event.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Arvo/Event.hs @@ -1,12 +1,15 @@ {-# LANGUAGE StrictData #-} +-- This is required due to the use of 'Void' in a constructor slot in +-- combination with 'deriveNoun' which generates an unreachable pattern. +{-# OPTIONS_GHC -Wno-overlapping-patterns #-} + {-| Event Types and Noun Conversion -} module Urbit.Arvo.Event where -import Urbit.Noun.Tree (HoonMap, HoonSet) -import Urbit.Prelude hiding (Term) +import Urbit.Prelude hiding (Term) import Urbit.Arvo.Common (KingId(..), ServId(..)) import Urbit.Arvo.Common (Desk, Mime) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs index 8ef28294fb..94d7d7c3d2 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs @@ -1,3 +1,7 @@ +-- This is required due to the use of 'Void' in a constructor slot in +-- combination with 'deriveNoun' which generates an unreachable pattern. +{-# OPTIONS_GHC -Wno-overlapping-patterns #-} + {-| Ames IO Driver -} @@ -57,6 +61,7 @@ localhost = tupleToHostAddress (127, 0, 0, 1) inaddrAny :: HostAddress inaddrAny = tupleToHostAddress (0, 0, 0, 0) + modeAddress :: NetworkMode -> Maybe HostAddress modeAddress = \case diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Behn.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Behn.hs index 72ae5218f1..aab87ebff3 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Behn.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Behn.hs @@ -1,3 +1,7 @@ +-- This is required due to the use of 'Void' in a constructor slot in +-- combination with 'deriveNoun', which will generate an unreachable pattern. +{-# OPTIONS_GHC -Wno-overlapping-patterns #-} + {-| Behn: Timer Driver -} From 74db584ad7cec33ec18e563f3a514e5a28a22747 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Tue, 27 Oct 2020 13:05:42 +0100 Subject: [PATCH 537/933] king: simplify parser types to avoid invalid existential newtype --- pkg/hs/urbit-noun-core/lib/Urbit/Noun/Convert.hs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Convert.hs b/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Convert.hs index 7875ad6523..d78a097b95 100644 --- a/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Convert.hs +++ b/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Convert.hs @@ -12,10 +12,9 @@ module Urbit.Noun.Convert import ClassyPrelude hiding (hash) +import Control.Monad.Fail (MonadFail (fail)) import Urbit.Noun.Core -import qualified Control.Monad.Fail as Fail - -- Types ----------------------------------------------------------------------- @@ -24,11 +23,11 @@ type ParseStack = [Text] -- "Parser" -------------------------------------------------------------------- -type Failure f r = ParseStack -> String -> f r -type Success a f r = a -> f r +type Failure a = ParseStack -> String -> a +type Success a b = a -> b newtype Parser a = Parser { - runParser :: forall f r. ParseStack -> Failure f r -> Success a f r -> f r + runParser :: forall r. ParseStack -> Failure r -> Success a r -> r } named :: Text -> Parser a -> Parser a @@ -39,9 +38,8 @@ instance Monad Parser where m >>= g = Parser $ \path kf ks -> let ks' a = runParser (g a) path kf ks in runParser m path kf ks' return = pure - fail = Fail.fail -instance Fail.MonadFail Parser where +instance MonadFail Parser where fail msg = Parser $ \path kf _ks -> kf (reverse path) msg instance Functor Parser where From de17409fd61658e3728365b5863e16a8ff8f3b5f Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Tue, 27 Oct 2020 13:22:33 +0100 Subject: [PATCH 538/933] king: various warning and -Werror related fixes This also removes -Werror from racqure due to the sheer number build failures arising from compiler warnings. --- pkg/hs/racquire/package.yaml | 1 - pkg/hs/urbit-king/lib/Urbit/Arvo/Common.hs | 2 ++ pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs | 1 + pkg/hs/urbit-king/lib/Urbit/Arvo/Event.hs | 1 + pkg/hs/urbit-king/lib/Urbit/King/Main.hs | 3 --- pkg/hs/urbit-king/lib/Urbit/Prelude.hs | 5 ++--- pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs | 19 +++++++++---------- pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs | 2 +- pkg/hs/urbit-king/lib/Urbit/Vere/Term/API.hs | 1 + pkg/hs/urbit-noun-core/lib/Urbit/Noun/Cue.hs | 18 ++++++++++-------- pkg/hs/urbit-noun-core/lib/Urbit/Noun/TH.hs | 1 + .../urbit-noun/lib/Urbit/Noun/Conversions.hs | 3 ++- 12 files changed, 30 insertions(+), 27 deletions(-) diff --git a/pkg/hs/racquire/package.yaml b/pkg/hs/racquire/package.yaml index 36b562d11c..b882b2753b 100644 --- a/pkg/hs/racquire/package.yaml +++ b/pkg/hs/racquire/package.yaml @@ -9,7 +9,6 @@ library: - -fwarn-incomplete-patterns - -fwarn-unused-binds - -fwarn-unused-imports - - -Werror - -O2 dependencies: diff --git a/pkg/hs/urbit-king/lib/Urbit/Arvo/Common.hs b/pkg/hs/urbit-king/lib/Urbit/Arvo/Common.hs index 19f97d9791..645b8a1f7a 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Arvo/Common.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Arvo/Common.hs @@ -20,6 +20,8 @@ module Urbit.Arvo.Common import Urbit.Prelude hiding (Term) +import Control.Monad.Fail (fail) + import qualified Network.HTTP.Types.Method as H import qualified Urbit.Ob as Ob diff --git a/pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs b/pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs index f79b2a7874..b6a2bd1747 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs @@ -12,6 +12,7 @@ module Urbit.Arvo.Effect where import Urbit.Noun.Time import Urbit.Prelude +import Control.Monad.Fail (fail) import Urbit.Arvo.Common (KingId(..), ServId(..)) import Urbit.Arvo.Common (Header, HttpEvent, HttpServerConf, Method, Mime) import Urbit.Arvo.Common (AmesDest, Turf) diff --git a/pkg/hs/urbit-king/lib/Urbit/Arvo/Event.hs b/pkg/hs/urbit-king/lib/Urbit/Arvo/Event.hs index 583c4ed644..f95166a495 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Arvo/Event.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Arvo/Event.hs @@ -11,6 +11,7 @@ module Urbit.Arvo.Event where import Urbit.Prelude hiding (Term) +import Control.Monad.Fail (fail) import Urbit.Arvo.Common (KingId(..), ServId(..)) import Urbit.Arvo.Common (Desk, Mime) import Urbit.Arvo.Common (Header(..), HttpEvent) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs index bba16c090c..2a21a144af 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs @@ -90,11 +90,8 @@ import Urbit.King.App import Control.Concurrent (myThreadId) import Control.Exception (AsyncException(UserInterrupt)) -import Control.Lens ((&)) import System.Process (system) import System.IO (hPutStrLn) -import Text.Show.Pretty (pPrint) -import Urbit.Noun.Conversions (cordToUW) import Urbit.Noun.Time (Wen) import Urbit.Vere.LockFile (lockFile) diff --git a/pkg/hs/urbit-king/lib/Urbit/Prelude.hs b/pkg/hs/urbit-king/lib/Urbit/Prelude.hs index eee5cef166..cf9aae210c 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Prelude.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Prelude.hs @@ -20,10 +20,9 @@ module Urbit.Prelude import ClassyPrelude import Urbit.Noun -import Control.Lens hiding (Each, Index, cons, index, snoc, uncons, unsnoc, - (<.>), (<|)) - import Control.Arrow ((<<<), (>>>)) +import Control.Lens hiding (Each, Index, cons, index, snoc, uncons, unsnoc, + (<.>), (<|)) import Data.Acquire (Acquire, mkAcquire, with) import Data.RAcquire (RAcquire, mkRAcquire, rwith) import Data.RAcquire (MonadAcquire(..), MonadRIO(..)) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs index 571cca5059..41d165577a 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs @@ -19,7 +19,6 @@ import Urbit.Arvo.Common import Urbit.Arvo.Event hiding (Address) import Urbit.Prelude hiding (Call, rights, to, (.=)) -import Data.Bifunctor (bimap) import Data.Bits (xor) import Data.List (nub) import Data.Text (splitOn) @@ -351,10 +350,10 @@ validateShipAndGetSponsor endpoint block (Seed ship life ring oaf) = -- A comet address is the fingerprint of the keypair let shipFromPass = cometFingerprint $ ringToPass ring when (ship /= shipFromPass) $ - fail ("comet name doesn't match fingerprint " <> show ship <> " vs " <> + error ("comet name doesn't match fingerprint " <> show ship <> " vs " <> show shipFromPass) when (life /= 1) $ - fail ("comet can never be re-keyed") + error ("comet can never be re-keyed") pure (shipSein ship) validateMoon = do @@ -368,14 +367,14 @@ validateShipAndGetSponsor endpoint block (Seed ship life ring oaf) = whoP <- retrievePoint endpoint block ship case epNet whoP of - Nothing -> fail "ship not keyed" + Nothing -> error "ship not keyed" Just (netLife, pass, contNum, (hasSponsor, who), _) -> do when (netLife /= life) $ - fail ("keyfile life mismatch; keyfile claims life " <> + error ("keyfile life mismatch; keyfile claims life " <> show life <> ", but Azimuth claims life " <> show netLife) when ((ringToPass ring) /= pass) $ - fail "keyfile does not match blockchain" + error "keyfile does not match blockchain" -- TODO: The hoon code does a breach check, but the C code never -- supplies the data necessary for it to function. pure who @@ -391,16 +390,16 @@ getSponsorshipChain endpoint block = loop ethPoint <- retrievePoint endpoint block ship case (clanFromShip ship, epNet ethPoint) of - (Ob.Comet, _) -> fail "Comets cannot be sponsors" - (Ob.Moon, _) -> fail "Moons cannot be sponsors" + (Ob.Comet, _) -> error "Comets cannot be sponsors" + (Ob.Moon, _) -> error "Moons cannot be sponsors" (_, Nothing) -> - fail $ unpack ("Ship " <> renderShip ship <> " not booted") + error $ unpack ("Ship " <> renderShip ship <> " not booted") (Ob.Galaxy, Just _) -> pure [(ship, ethPoint)] (_, Just (_, _, _, (False, _), _)) -> - fail $ unpack ("Ship " <> renderShip ship <> " has no sponsor") + error $ unpack ("Ship " <> renderShip ship <> " has no sponsor") (_, Just (_, _, _, (True, sponsor), _)) -> do chain <- loop sponsor diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs index 6e920685c4..6b712c474b 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs @@ -26,7 +26,7 @@ import Urbit.Vere.Pier.Types import Control.Monad.STM (retry) import System.Environment (getExecutablePath) -import System.FilePath (splitFileName, ()) +import System.FilePath (splitFileName) import System.Posix.Files (ownerModes, setFileMode) import Urbit.EventLog.LMDB (EventLog) import Urbit.King.API (TermConn) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Term/API.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Term/API.hs index c94f5198f5..7e65d49e5e 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Term/API.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Term/API.hs @@ -13,6 +13,7 @@ import Urbit.Prelude hiding (trace) import Urbit.Arvo (Belt, Blit) +import Control.Monad.Fail (fail) import Urbit.TermSize -- External Types -------------------------------------------------------------- diff --git a/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Cue.hs b/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Cue.hs index 0bc122fb38..7fcc79ff40 100644 --- a/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Cue.hs +++ b/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Cue.hs @@ -12,14 +12,15 @@ import ClassyPrelude import Urbit.Atom import Urbit.Noun.Core -import Data.Bits (shiftL, shiftR, (.&.), (.|.)) -import Data.Function ((&)) -import Foreign.Ptr (Ptr, castPtr, plusPtr, ptrToWordPtr) -import Foreign.Storable (peek) -import GHC.Prim (ctz#) -import GHC.Word (Word(..)) -import System.IO.Unsafe (unsafePerformIO) -import Text.Printf (printf) +import Control.Monad.Fail (MonadFail (fail)) +import Data.Bits (shiftL, shiftR, (.&.), (.|.)) +import Data.Function ((&)) +import Foreign.Ptr (Ptr, castPtr, plusPtr, ptrToWordPtr) +import Foreign.Storable (peek) +import GHC.Prim (ctz#) +import GHC.Word (Word(..)) +import System.IO.Unsafe (unsafePerformIO) +import Text.Printf (printf) import qualified Data.ByteString.Unsafe as BS import qualified Data.HashTable.IO as H @@ -136,6 +137,7 @@ instance Monad Get where runGet (f x') end tbl s' {-# INLINE (>>=) #-} +instance MonadFail Get where fail msg = Get $ \end tbl s -> do badEncoding end s msg {-# INLINE fail #-} diff --git a/pkg/hs/urbit-noun-core/lib/Urbit/Noun/TH.hs b/pkg/hs/urbit-noun-core/lib/Urbit/Noun/TH.hs index 641161d1dc..f2a97569a5 100644 --- a/pkg/hs/urbit-noun-core/lib/Urbit/Noun/TH.hs +++ b/pkg/hs/urbit-noun-core/lib/Urbit/Noun/TH.hs @@ -4,6 +4,7 @@ module Urbit.Noun.TH (deriveNoun, deriveToNoun, deriveFromNoun) where import ClassyPrelude hiding (fromList) +import Control.Monad.Fail (fail) import Language.Haskell.TH import Language.Haskell.TH.Syntax import Urbit.Noun.Convert diff --git a/pkg/hs/urbit-noun/lib/Urbit/Noun/Conversions.hs b/pkg/hs/urbit-noun/lib/Urbit/Noun/Conversions.hs index 6a8b5fddfe..44169d216d 100644 --- a/pkg/hs/urbit-noun/lib/Urbit/Noun/Conversions.hs +++ b/pkg/hs/urbit-noun/lib/Urbit/Noun/Conversions.hs @@ -17,6 +17,7 @@ module Urbit.Noun.Conversions import ClassyPrelude hiding (hash) import Control.Lens hiding (Each, Index, (<.>)) +import Control.Monad.Fail (fail) import Data.Void import Data.Word import Text.Regex.TDFA @@ -33,7 +34,7 @@ import GHC.Types (Char(C#)) import GHC.Word (Word32(W32#)) import Prelude ((!!)) import RIO.FilePath (joinPath, splitDirectories, takeBaseName, - takeDirectory, takeExtension, (<.>)) + takeDirectory, takeExtension) import Urbit.Noun.Cue (cue) import Urbit.Noun.Jam (jam) From 5aafa0c79f6f04b61ce95cdcf2df378278f2bc12 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Tue, 27 Oct 2020 16:24:27 +0100 Subject: [PATCH 539/933] build: abbreviate bootstrap.urbit.org/ci artefact system name --- ci.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci.nix b/ci.nix index 9e03a56a77..0949987052 100644 --- a/ci.nix +++ b/ci.nix @@ -103,7 +103,7 @@ in localLib.dimension "system" systems (systemName: # Push the tarball to the remote google storage bucket. release = let version = builtins.readFile ./pkg/urbit/version; - name = "urbit-v${version}-${system}"; + name = "urbit-v${version}-${systemName}"; in pushObject name "tar.gz" staticPackages.tarball; # Replace top-level pill attributes with push to google storage variants. From b3c145ee35fd6cb6d1fa85cb01d9a0914c1b8a59 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 27 Oct 2020 14:01:59 -0400 Subject: [PATCH 540/933] king: port the '-e' option to specify ethereum node endpoint. --- pkg/hs/urbit-king/lib/Urbit/King/CLI.hs | 16 ++++++++++++++-- pkg/hs/urbit-king/lib/Urbit/King/Main.hs | 10 +++++----- pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs | 13 +++++-------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs index 40d132892b..b9e7fadaa4 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/CLI.hs @@ -89,6 +89,7 @@ data New = New , nArvoDir :: Maybe FilePath , nBootType :: BootType , nLite :: Bool + , nEthNode :: String , nSerfExe :: Maybe Text } deriving (Show) @@ -125,7 +126,8 @@ data Bug , bFinalEvt :: Word64 } | CheckDawn - { bKeyfilePath :: FilePath + { bEthNode :: String + , bKeyfilePath :: FilePath } | CheckComet deriving (Show) @@ -248,6 +250,14 @@ serfExe = optional <> help "Path to serf binary to run ships in" <> hidden +ethNode :: Parser String +ethNode = strOption + $ short 'e' + <> long "eth-node" + <> value "http://eth-mainnet.urbit.org:8545" + <> help "Ethereum gateway URL" + <> hidden + new :: Parser New new = do nPierPath <- optional pierPath @@ -268,6 +278,8 @@ new = do <> value Nothing <> help "Replace initial clay filesys with contents of PATH" + nEthNode <- ethNode + nSerfExe <- serfExe pure New{..} @@ -522,7 +534,7 @@ browseEvs :: Parser Bug browseEvs = EventBrowser <$> pierPath checkDawn :: Parser Bug -checkDawn = CheckDawn <$> keyfilePath +checkDawn = CheckDawn <$> ethNode <*> keyfilePath bugCmd :: Parser (Cmd, Log) bugCmd = (flip (,) <$> log <*>) $ fmap CmdBug diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs index 87fb407531..bb91c9d162 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs @@ -537,7 +537,7 @@ newShip CLI.New{..} opts = do bootFromSeed :: Pill -> Seed -> RIO HostEnv () bootFromSeed pill seed = do - ethReturn <- dawnVent seed + ethReturn <- dawnVent nEthNode seed case ethReturn of Left x -> error $ unpack x @@ -627,8 +627,8 @@ startBrowser pierPath = runRAcquire $ do log <- Log.existing (pierPath <> "/.urb/log") rio $ EventBrowser.run log -checkDawn :: HasLogFunc e => FilePath -> RIO e () -checkDawn keyfilePath = do +checkDawn :: HasLogFunc e => String -> FilePath -> RIO e () +checkDawn provider keyfilePath = do -- The keyfile is a jammed Seed then rendered in UW format text <- readFileUtf8 keyfilePath asAtom <- case cordToUW (Cord $ T.strip text) of @@ -642,7 +642,7 @@ checkDawn keyfilePath = do print $ show seed - e <- dawnVent seed + e <- dawnVent provider seed print $ show e @@ -673,7 +673,7 @@ main = do CLI.CmdBug (CLI.ValidateEvents pax f l) -> checkEvs pax f l CLI.CmdBug (CLI.ValidateFX pax f l) -> checkFx pax f l CLI.CmdBug (CLI.ReplayEvents pax l ) -> replayPartEvs pax l - CLI.CmdBug (CLI.CheckDawn pax ) -> checkDawn pax + CLI.CmdBug (CLI.CheckDawn provider pax ) -> checkDawn provider pax CLI.CmdBug CLI.CheckComet -> checkComet CLI.CmdCon pier -> connTerm pier diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs index 571cca5059..316db642b3 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs @@ -40,10 +40,6 @@ import qualified Urbit.Ob as Ob import qualified Network.HTTP.Client.TLS as TLS import qualified Network.HTTP.Types as HT --- During boot, use the infura provider -provider :: String -provider = "http://eth-mainnet.urbit.org:8545" - -- The address of the azimuth contract as a string. azimuthAddr :: Text azimuthAddr = "0x223c067f8cf28ae173ee5cafea60ca44c335fecb" @@ -154,7 +150,7 @@ dawnPostRequests endpoint responseBuilder requests = do -- Send to the server responses <- dawnSendHTTP endpoint requestPayload >>= \case - Left err -> error $ "error fetching " <> provider <> ": HTTP " <> (show err) + Left err -> error $ "error fetching " <> endpoint <> ": HTTP " <> (show err) Right x -> pure x -- Get a list of the result texts in the order of the submitted requests @@ -335,7 +331,7 @@ parseTurfResponse a raw = turf retrievePoint :: String -> TextBlockNum -> Ship -> RIO e EthPoint retrievePoint endpoint block ship = - dawnPostRequests provider parseEthPoint + dawnPostRequests endpoint parseEthPoint [PointRequest block (fromIntegral ship)] >>= \case [x] -> pure x _ -> error "JSON server returned multiple return values." @@ -407,10 +403,11 @@ getSponsorshipChain endpoint block = loop pure $ chain <> [(ship, ethPoint)] -- Produces either an error or a validated boot event structure. -dawnVent :: HasLogFunc e => Seed -> RIO e (Either Text Dawn) -dawnVent dSeed@(Seed ship life ring oaf) = +dawnVent :: HasLogFunc e => String -> Seed -> RIO e (Either Text Dawn) +dawnVent provider dSeed@(Seed ship life ring oaf) = -- The type checker can't figure this out on its own. (onLeft tshow :: Either SomeException Dawn -> Either Text Dawn) <$> try do + putStrLn ("boot: requesting ethereum information from " <> pack provider) blockResponses <- dawnPostRequests provider parseBlockRequest [BlockRequest] From 155e367daab4b80a6ed1355c7dfcb662e6b41d6c Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Wed, 28 Oct 2020 10:04:56 +0100 Subject: [PATCH 541/933] build: correcting double hash in update-ivory-pill shebang --- sh/update-ivory-pill | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/update-ivory-pill b/sh/update-ivory-pill index c5e4f37e01..9465920658 100755 --- a/sh/update-ivory-pill +++ b/sh/update-ivory-pill @@ -1,4 +1,4 @@ -##!/usr/bin/env bash +#!/usr/bin/env bash set -xeuo pipefail From 689c0eb6a0bbd33950d844ba7442c9cbd21f84eb Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Wed, 28 Oct 2020 10:48:44 +0100 Subject: [PATCH 542/933] build: ensuring release tarball contains singular parent directory This ensures parity with the current release tarballs. --- ci.nix | 7 ++----- default.nix | 17 ++++++++++------- nix/lib/make-release-tarball.nix | 5 +++-- nix/pkgs/urbit/default.nix | 6 +++--- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/ci.nix b/ci.nix index 0949987052..232c23a9a3 100644 --- a/ci.nix +++ b/ci.nix @@ -81,7 +81,7 @@ in localLib.dimension "system" systems (systemName: haskell-nix.haskellLib.selectProjectPackages staticPackages.hs; # The top-level set of attributes to build on ci. - finalPackages = localPackages // { + finalPackages = localPackages // rec { # Expose the nix-shell derivation as a sanity check. shell = import ./shell.nix; @@ -101,10 +101,7 @@ in localLib.dimension "system" systems (systemName: hs = localLib.collectHaskellComponents haskellPackages; # Push the tarball to the remote google storage bucket. - release = let - version = builtins.readFile ./pkg/urbit/version; - name = "urbit-v${version}-${systemName}"; - in pushObject name "tar.gz" staticPackages.tarball; + release = pushObject tarball.name "tgz" tarball; # Replace top-level pill attributes with push to google storage variants. } // lib.optionalAttrs (system == "x86_64-linux") { diff --git a/default.nix b/default.nix index b1782a173b..0427ea80ba 100644 --- a/default.nix +++ b/default.nix @@ -121,14 +121,17 @@ let # FIXME: tarball binaries need executable permissions set? - # Create a .tar.gz of the primary binaries. - tarball = localLib.makeReleaseTarball { - name = "urbit-tarball"; + # Create a .tgz of the primary binaries. + tarball = let + name = "urbit-v${urbit.version}-${urbit.system}"; + urbit-king = hs.urbit-king.components.exes.urbit-king; + in localLib.makeReleaseTarball { + inherit name; + contents = { - "urbit" = "${urbit}/bin/urbit"; - "urbit-worker" = "${urbit}/bin/urbit-worker"; - "urbit-king" = - "${hs.urbit-king.components.exes.urbit-king}/bin/urbit-king"; + "${name}/urbit" = "${urbit}/bin/urbit"; + "${name}/urbit-worker" = "${urbit}/bin/urbit-worker"; + "${name}/urbit-king" = "${urbit-king}/bin/urbit-king"; }; }; diff --git a/nix/lib/make-release-tarball.nix b/nix/lib/make-release-tarball.nix index 3d77445ace..754d3ae4a0 100644 --- a/nix/lib/make-release-tarball.nix +++ b/nix/lib/make-release-tarball.nix @@ -12,13 +12,14 @@ let (lib.mapAttrsToList (_target: source: "${source}") contents); in stdenvNoCC.mkDerivation { - name = "${name}.tar.gz"; + inherit name; + outputs = [ "out" "hash" ]; nativeBuildInputs = [ coreutils ]; phases = [ "buildPhase" "hashPhase" ]; buildPhase = '' - tar vczf $out \ + tar -vczf $out \ --owner=0 --group=0 --mode=u+rw,uga+r \ --absolute-names \ --hard-dereference \ diff --git a/nix/pkgs/urbit/default.nix b/nix/pkgs/urbit/default.nix index dcd62b3488..4339953286 100644 --- a/nix/pkgs/urbit/default.nix +++ b/nix/pkgs/urbit/default.nix @@ -8,14 +8,14 @@ let src = lib.cleanSource ../../../pkg/urbit; + version = builtins.readFile "${src}/version"; + in stdenv.mkDerivation { - inherit src; + inherit src version; pname = "urbit" + lib.optionalString enableDebug "-debug" + lib.optionalString enableStatic "-static"; - version = builtins.readFile "${src}/version"; - nativeBuildInputs = [ pkgconfig ]; buildInputs = [ From 2c17f382ed27cdb6a3bc15cfe6a1b88610a004c6 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Wed, 28 Oct 2020 11:07:58 +0100 Subject: [PATCH 543/933] build: removing unused nix imports --- ci.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ci.nix b/ci.nix index 232c23a9a3..4333887e1f 100644 --- a/ci.nix +++ b/ci.nix @@ -13,8 +13,7 @@ let - inherit (import ./nix/default.nix { }) - lib recurseIntoAttrs haskell-nix callPackage; + inherit (import ./nix/default.nix { }) lib haskell-nix callPackage; # Local library import from derivation functions such as fetchGitHubLFS, etc. # upon which local package defintions are dependent. From 59709752eb187b27e18decc009cb0fb194b777ed Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Wed, 28 Oct 2020 11:43:22 +0100 Subject: [PATCH 544/933] build: simplify pushed artefact naming and set object content-type --- ci.nix | 32 +++++++++++++++++++++----------- nix/lib/make-release-tarball.nix | 6 ++++-- nix/lib/push-storage-object.nix | 13 ++++++++----- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/ci.nix b/ci.nix index 4333887e1f..cf4b242e34 100644 --- a/ci.nix +++ b/ci.nix @@ -24,24 +24,29 @@ let serviceAccountKey = builtins.readFile ("/var/run/keys/service-account.json"); # Push a split output derivation containing "out" and "hash" outputs. - pushObject = name: extension: drv: + pushObject = + { name, extension, drv, contentType ? "application/octet-stream" }: let - # Use the sha256 for the object key suffix. + # Use the sha256 for the object key prefix. sha256 = builtins.readFile (drv.hash + "/sha256"); - # Use md5 as an idempotency check for gsutil - md5 = builtins.readFile (drv.hash + "/md5"); + # Use md5 as an idempotency check for gsutil. + contentMD5 = builtins.readFile (drv.hash + "/md5"); in localLib.pushStorageObject { - inherit serviceAccountKey md5; + inherit serviceAccountKey name contentMD5 contentType; bucket = "bootstrap.urbit.org"; - object = "ci/${name}-${sha256}.${extension}"; - name = "${name}.${extension}"; + object = "ci/${lib.removeSuffix extension name}.${sha256}.${extension}"; file = drv.out; }; - # Push a split output pill derivation containing "build" attribute with the - # with the ".pill" file extension. - pushPill = name: drv: pushObject name "pill" drv.build; + # Build and push a split output pill derivation with the ".pill" file extension. + pushPill = name: pill: + pushObject { + inherit name; + + drv = pill.build; + extension = "pill"; + }; systems = lib.filterAttrs (_: v: builtins.elem v.system supportedSystems) { linux = { @@ -100,7 +105,12 @@ in localLib.dimension "system" systems (systemName: hs = localLib.collectHaskellComponents haskellPackages; # Push the tarball to the remote google storage bucket. - release = pushObject tarball.name "tgz" tarball; + release = pushObject { + name = tarball.name; + extension = tarball.meta.extension; + contentType = "application/x-gtar"; + drv = tarball; + }; # Replace top-level pill attributes with push to google storage variants. } // lib.optionalAttrs (system == "x86_64-linux") { diff --git a/nix/lib/make-release-tarball.nix b/nix/lib/make-release-tarball.nix index 754d3ae4a0..a374568961 100644 --- a/nix/lib/make-release-tarball.nix +++ b/nix/lib/make-release-tarball.nix @@ -1,6 +1,6 @@ { lib, stdenvNoCC, coreutils }: -{ name, contents # { target = source, ... } +{ name, extension ? "tgz", contents # { target = source, ... } }: let @@ -12,7 +12,7 @@ let (lib.mapAttrsToList (_target: source: "${source}") contents); in stdenvNoCC.mkDerivation { - inherit name; + name = "${name}.${extension}"; outputs = [ "out" "hash" ]; nativeBuildInputs = [ coreutils ]; @@ -35,4 +35,6 @@ in stdenvNoCC.mkDerivation { ''; preferLocalBuild = true; + + meta = { inherit extension; }; } diff --git a/nix/lib/push-storage-object.nix b/nix/lib/push-storage-object.nix index f942265157..23ca36d72b 100644 --- a/nix/lib/push-storage-object.nix +++ b/nix/lib/push-storage-object.nix @@ -5,7 +5,8 @@ # upload. This is in additional to any sha256sum you might want to actually # name the object key under. -{ bucket, object, name, file, md5, serviceAccountKey, preferLocalBuild ? true }: +{ bucket, object, name, file, contentMD5, contentType, serviceAccountKey +, preferLocalBuild ? true }: assert lib.asserts.assertMsg (builtins.isString serviceAccountKey) "`serviceAccountKey` must contain the JSON contents of a service-account key"; @@ -28,7 +29,7 @@ in stdenvNoCC.mkDerivation { gcloud auth activate-service-account --key-file=- <<< '${serviceAccountKey}' - local_md5=$(echo -n '${md5}' | xxd -r -p | base64) + local_md5=$(echo -n '${contentMD5}' | xxd -r -p | base64) remote_md5= stat_uri() { @@ -43,7 +44,9 @@ in stdenvNoCC.mkDerivation { if ! stat_uri; then header "copying ${file} to ${uri}" - gsutil cp '${file}' '${uri}' + gsutil -h "Content-MD5:$local_md5" \ + -h "Content-Type:${contentType}" \ + cp '${file}' '${uri}' if ! stat_uri; then echo "failed calculating remote uri md5" >&2 @@ -52,13 +55,13 @@ in stdenvNoCC.mkDerivation { fi # This is the same format as md5sum (double space separator) and - # is used as the outputHash to ensure a fixed output derivation. + # needs to match the .outputHash to ensure a fixed output derivation. echo -n "$remote_md5 ${uri}" > $out ''; outputHashAlgo = "sha256"; outputHashMode = "flat"; - outputHash = builtins.hashString "sha256" "${md5} ${uri}"; + outputHash = builtins.hashString "sha256" "${contentMD5} ${uri}"; inherit preferLocalBuild; } From 5c28d34300d6d09fbc37ee3a4786a4968049f1ce Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Wed, 28 Oct 2020 12:55:29 +0100 Subject: [PATCH 545/933] build: removing extraneous '.' from object key --- ci.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci.nix b/ci.nix index cf4b242e34..8691d948c0 100644 --- a/ci.nix +++ b/ci.nix @@ -35,7 +35,7 @@ let inherit serviceAccountKey name contentMD5 contentType; bucket = "bootstrap.urbit.org"; - object = "ci/${lib.removeSuffix extension name}.${sha256}.${extension}"; + object = "ci/${lib.removeSuffix extension name}${sha256}.${extension}"; file = drv.out; }; @@ -107,9 +107,9 @@ in localLib.dimension "system" systems (systemName: # Push the tarball to the remote google storage bucket. release = pushObject { name = tarball.name; + drv = tarball; extension = tarball.meta.extension; contentType = "application/x-gtar"; - drv = tarball; }; # Replace top-level pill attributes with push to google storage variants. From fada33dfe6bd1964523772cfeb96a8023178cae0 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Wed, 28 Oct 2020 18:19:53 +0100 Subject: [PATCH 546/933] build: remove checkMaterialization flag --- ci.nix | 7 ++----- default.nix | 7 ++----- nix/pkgs/hs/default.nix | 4 ++-- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/ci.nix b/ci.nix index 8691d948c0..4f27891732 100644 --- a/ci.nix +++ b/ci.nix @@ -63,19 +63,16 @@ let in localLib.dimension "system" systems (systemName: { system, crossSystem }: let - # Check the pinned haskell.nix hashes for correctness. - checkMaterialization = true; - # Shared libraries/executables for the build (current) system. localPackages = import ./default.nix { - inherit system checkMaterialization; + inherit system; enableStatic = false; }; # Static libraries/executables for the host (cross) system. staticPackages = import ./default.nix { - inherit system crossSystem checkMaterialization; + inherit system crossSystem; enableStatic = true; }; diff --git a/default.nix b/default.nix index 0427ea80ba..dd6cd0a231 100644 --- a/default.nix +++ b/default.nix @@ -43,10 +43,7 @@ , crossOverlays ? [ ] # Whether to use pkgs.pkgsStatic.* to obtain statically linked package # dependencies - ie. when building fully-static libraries or executables. -, enableStatic ? crossSystem != null - # Whether to check that the pinned hashes for haskell.nix are correct. - # Set to false by default since it's a lot slower, but true for ci. -, checkMaterialization ? false }: +, enableStatic ? crossSystem != null }: let @@ -100,7 +97,7 @@ let hs = callPackage ./nix/pkgs/hs { inherit (pkgs) haskell-nix; - inherit checkMaterialization enableStatic; + inherit enableStatic; }; }; diff --git a/nix/pkgs/hs/default.nix b/nix/pkgs/hs/default.nix index 5dd7ae1865..5664607325 100644 --- a/nix/pkgs/hs/default.nix +++ b/nix/pkgs/hs/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, darwin, haskell-nix, gmp, zlib, libffi, checkMaterialization +{ lib, stdenv, darwin, haskell-nix, gmp, zlib, libffi , enableStatic ? stdenv.hostPlatform.isStatic }: let @@ -7,7 +7,7 @@ let index-state = "2020-09-24T00:00:00Z"; project = haskell-nix.stackProject { - inherit compiler-nix-name index-state checkMaterialization; + inherit compiler-nix-name index-state; # This is incredibly difficult to get right, almost everything goes wrong. # See: https://github.com/input-output-hk/haskell.nix/issues/496 From 418b9fda7eb2ea3c659b4fff8d0772fcd92fd400 Mon Sep 17 00:00:00 2001 From: fang Date: Wed, 28 Oct 2020 19:13:23 +0100 Subject: [PATCH 547/933] king: add helper for escaping Text into @ta format Behavior should match (scot %t the-text). --- pkg/hs/urbit-noun/lib/Urbit/Noun/Conversions.hs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/hs/urbit-noun/lib/Urbit/Noun/Conversions.hs b/pkg/hs/urbit-noun/lib/Urbit/Noun/Conversions.hs index d1f1f94dac..f9f93151eb 100644 --- a/pkg/hs/urbit-noun/lib/Urbit/Noun/Conversions.hs +++ b/pkg/hs/urbit-noun/lib/Urbit/Noun/Conversions.hs @@ -13,6 +13,7 @@ module Urbit.Noun.Conversions , Mug(..), Path(..), EvilPath(..), Ship(..) , Lenient(..), pathToFilePath, filePathToPath , showUD, tshowUD + , textAsTa ) where import ClassyPrelude hiding (hash) @@ -40,7 +41,9 @@ import Urbit.Noun.Jam (jam) import Urbit.Ob (patp) import qualified Data.Char as C +import qualified Data.Text as T import qualified Data.Text.Encoding as T +import qualified Numeric as N -- Noun ------------------------------------------------------------------------ @@ -551,6 +554,18 @@ instance FromNoun Knot where then pure (MkKnot txt) else fail ("Non-ASCII chars in knot: " <> unpack txt) +-- equivalent of (cury scot %t) +textAsTa :: Text -> Text +textAsTa = ("~~" <>) . concatMap \case + ' ' -> "." + '.' -> "~." + '~' -> "~~" + c -> + if C.isAlphaNum c || (c == '-') then + T.singleton c + else + if C.ord c < 0x10 then "~0" else "~" + <> (pack $ N.showHex (C.ord c) ".") -- Term ------------------------------------------------------------------------ From d1c5f97bd70cf68cd1c20565f9ec3a413e51c2ca Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 28 Oct 2020 14:24:52 -0400 Subject: [PATCH 548/933] king: cancel http servers immediately on shutdown. --- pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs | 6 +++--- pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Multi.hs | 2 +- pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs | 6 ++---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs index ee6d616eb4..256728a449 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs @@ -344,9 +344,9 @@ eyre env who plan isFake stderr = (initialEvents, runHttpServer) kill :: HasLogFunc e => Serv -> RIO e () kill Serv{..} = do atomically (leaveMultiEyre multi who) - atomically (saKil sLop) - atomically (saKil sIns) - for_ sSec (\sec -> atomically (saKil sec)) + io (saKil sLop) + io (saKil sIns) + io $ for_ sSec (\sec -> (saKil sec)) io (removePortsFile sPortsFile) restart :: Drv -> HttpServerConf -> RIO e Serv diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Multi.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Multi.hs index 73a0c5c559..2c60a9c781 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Multi.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Multi.hs @@ -45,7 +45,7 @@ data MultiEyreApi = MultiEyreApi , meaPlan :: TVar (Map Ship OnMultiReq) , meaCanc :: TVar (Map Ship OnMultiKil) , meaTlsC :: TVar (Map Ship (TlsConfig, Credential)) - , meaKill :: STM () + , meaKill :: IO () } diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs index 0fdab349b6..ad4f0eea9d 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs @@ -54,7 +54,7 @@ import qualified Urbit.Vere.Eyre.Wai as E -- Internal Types -------------------------------------------------------------- data ServApi = ServApi - { saKil :: STM () + { saKil :: IO () , saPor :: STM W.Port } @@ -332,14 +332,12 @@ getFirstTlsConfig (MTC var) = do realServ :: HasLogFunc e => TVar E.LiveReqs -> ServConf -> RIO e ServApi realServ vLive conf@ServConf {..} = do logInfo (displayShow ("EYRE", "SERV", "Running Real Server")) - kil <- newEmptyTMVarIO por <- newEmptyTMVarIO tid <- async (runServ por) - _ <- async (atomically (takeTMVar kil) >> cancel tid) pure $ ServApi - { saKil = void (tryPutTMVar kil ()) + { saKil = cancel tid , saPor = readTMVar por } where From af225f673ada46d98dffd0b613ec529f7ea1e432 Mon Sep 17 00:00:00 2001 From: fang Date: Wed, 28 Oct 2020 19:33:21 +0100 Subject: [PATCH 549/933] king: scry to check authentication of webslog reqs Instead of giving webslogs to anyone who asks, only acknowledge requests with valid session cookies. Send 403s to all others. --- .../lib/Urbit/Vere/Eyre/KingSubsite.hs | 55 +++++++++++++++++-- pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs | 24 ++++---- 2 files changed, 62 insertions(+), 17 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/KingSubsite.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/KingSubsite.hs index 6c987d77ca..2cd5e83699 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/KingSubsite.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/KingSubsite.hs @@ -12,14 +12,17 @@ module Urbit.Vere.Eyre.KingSubsite import Urbit.Prelude hiding (Builder) import Data.ByteString.Builder +import Urbit.Vere.Serf.Types import Data.Conduit (ConduitT, Flush(..), yield) import Data.Text.Encoding (encodeUtf8Builder) import Urbit.Noun.Tank (wash) +import qualified Data.Text.Encoding as E import qualified Network.HTTP.Types as H import qualified Network.Wai as W import qualified Network.Wai.Conduit as W +import qualified Urbit.Noun.Time as Time newtype KingSubsite = KS { runKingSubsite :: W.Application } @@ -39,12 +42,15 @@ streamSlog a = do yield $ Flush kingSubsite :: HasLogFunc e - => TVar ((Atom, Tank) -> IO ()) + => Ship + -> (Time.Wen -> Gang -> Path -> IO (Maybe (Term, Noun))) + -> TVar ((Atom, Tank) -> IO ()) -> RAcquire e KingSubsite -kingSubsite func = do +kingSubsite who scry func = do --TODO unify who into scry clients <- newTVarIO (mempty :: Map Word (SlogAction -> IO ())) nextId <- newTVarIO (0 :: Word) baton <- newTMVarIO () + env <- ask atomically $ writeTVar func $ \s -> readTVarIO clients >>= traverse_ ($ Slog s) @@ -65,9 +71,13 @@ kingSubsite func = do modifyTVar' clients (insertMap id (atomically . writeTQueue slogQ)) pure (id, slogQ)) (\(id, _) -> atomically $ modifyTVar' clients (deleteMap id)) - (\(_, q) -> - let loop = yield Flush >> forever (atomically (readTQueue q) >>= streamSlog) - in respond $ W.responseSource (H.mkStatus 200 "OK") heads loop) + (\(_, q) -> do + authed <- authenticated env req + if not authed then + respond $ W.responseLBS (H.mkStatus 403 "Permission Denied") [] "" + else + let loop = yield Flush >> forever (atomically (readTQueue q) >>= streamSlog) + in respond $ W.responseSource (H.mkStatus 200 "OK") heads loop) _ -> respond $ W.responseLBS (H.mkStatus 404 "Not Found") [] "" @@ -77,6 +87,41 @@ kingSubsite func = do , ("Connection" , "keep-alive") ] + authenticated env req = runRIO env + $ (scryAuth $ getCookie req) + >>= pure . fromMaybe False + + getCookie req = intercalate "; " + $ fmap (E.decodeUtf8 . snd) + $ filter ((== "cookie") . fst) + (W.requestHeaders req) + + scryAuth :: HasLogFunc e + => Text + -> RIO e (Maybe Bool) + scryAuth cookie = + scry' $ fmap MkKnot ["authenticated", "cookie", textAsTa cookie] + + --TODO refactor into scry lib, as: + -- (forall n. FromNoun n => Text -> Text -> [Text] -> IO (Maybe n)) + -- vanecare -> desk -> restofpath + scry' :: forall e n + . (HasLogFunc e, FromNoun n) + => [Knot] + -> RIO e (Maybe n) + scry' p = do + env <- ask + wen <- io Time.now + let nkt = MkKnot $ tshow $ Time.MkDate wen + let pax = Path $ "ex" : MkKnot (tshow who) : "" : nkt : p + putStrLn (tshow pax) + io (scry wen Nothing pax) >>= \case + Just (_, fromNoun @n -> Just v) -> pure $ Just v + Just (_, n) -> do + logError $ displayShow ("eyre: uncanny scry result", pax, n) + pure Nothing + Nothing -> pure Nothing + fourOhFourSubsite :: Ship -> KingSubsite fourOhFourSubsite who = KS $ \req respond -> respond $ W.responseLBS (H.mkStatus 404 "Not Found") [] body diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs index 4ef1d519c0..ab9690ec68 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Pier.hs @@ -278,17 +278,6 @@ pier (serf, log) vSlog startedSig = do Term.addDemux ext demux logInfo "TERMSERV External terminal connected." - -- Set up the runtime subsite server and its capability to slog - siteSlog <- newTVarIO (const $ pure ()) - runtimeSubsite <- Site.kingSubsite siteSlog - - -- Slogs go to stderr, to the runtime subsite, and to the terminal. - env <- ask - atomically $ writeTVar vSlog $ \s@(_, tank) -> runRIO env $ do - atomically $ Term.slog muxed s - io $ readTVarIO siteSlog >>= ($ s) - logOther "serf" (display $ T.strip $ tankToText tank) - scryQ <- newTQueueIO onKill <- view onKillPierSigL @@ -305,12 +294,23 @@ pier (serf, log) vSlog startedSig = do atomically $ writeTQueue scryQ (w, b, g, putMVar res) takeMVar res + -- Set up the runtime subsite server and its capability to slog + siteSlog <- newTVarIO (const $ pure ()) + runtimeSubsite <- Site.kingSubsite ship scry siteSlog + + -- Slogs go to stderr, to the runtime subsite, and to the terminal. + env <- ask + atomically $ writeTVar vSlog $ \s@(_, tank) -> runRIO env $ do + atomically $ Term.slog muxed s + io $ readTVarIO siteSlog >>= ($ s) + logOther "serf" (display $ T.strip $ tankToText tank) + (bootEvents, startDrivers) <- do env <- ask let err = atomically . Term.trace muxed . (<> "\r\n") siz <- atomically $ Term.curDemuxSize demux let fak = isFake logId - drivers env ship fak compute scry (siz, muxed) err sigint + drivers env ship fak compute scry (siz, muxed) err sigint runtimeSubsite let computeConfig = ComputeConfig { ccOnWork = takeTMVar computeQ , ccOnKill = onKill From 5615b5dc1afb3598b61689906745b5f9e022899c Mon Sep 17 00:00:00 2001 From: fang Date: Wed, 28 Oct 2020 19:56:03 +0100 Subject: [PATCH 550/933] king: factor scrying logic into helper lib Takes care of constructing the full scry path based off the given components. Fills in timestamp with the current time. Logs errors on result conversion failures. --- pkg/hs/urbit-king/lib/Urbit/King/Scry.hs | 31 +++++++++++++++++++ pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs | 17 +++------- .../lib/Urbit/Vere/Eyre/KingSubsite.hs | 23 ++------------ 3 files changed, 37 insertions(+), 34 deletions(-) create mode 100644 pkg/hs/urbit-king/lib/Urbit/King/Scry.hs diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Scry.hs b/pkg/hs/urbit-king/lib/Urbit/King/Scry.hs new file mode 100644 index 0000000000..a8201843b8 --- /dev/null +++ b/pkg/hs/urbit-king/lib/Urbit/King/Scry.hs @@ -0,0 +1,31 @@ +{-| + Scry helpers +-} + +module Urbit.King.Scry (scryNow) where + +import Urbit.Prelude +import Urbit.Vere.Serf.Types + +import qualified Urbit.Noun.Time as Time + +scryNow :: forall e n + . (HasLogFunc e, FromNoun n) + => (Time.Wen -> Gang -> Path -> IO (Maybe (Term, Noun))) + -> Text + -> Ship + -> Text + -> [Text] + -> RIO e (Maybe n) +scryNow scry vare ship desk path = do + env <- ask + wen <- io Time.now + let wan = tshow $ Time.MkDate wen + let pax = Path $ fmap MkKnot $ vare : (tshow ship) : desk : wan : path + io (scry wen Nothing pax) >>= \case + Just (_, fromNoun @n -> Just v) -> pure $ Just v + Just (_, n) -> do + logError $ displayShow (vare, "uncanny scry result", pax, n) + pure Nothing + Nothing -> pure Nothing + diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs index 34bfbcbd78..c017c19d48 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs @@ -9,6 +9,7 @@ import Urbit.Prelude import Network.Socket hiding (recvFrom, sendTo) import Urbit.Arvo hiding (Fake) import Urbit.King.Config +import Urbit.King.Scry import Urbit.Vere.Ames.LaneCache import Urbit.Vere.Ames.Packet import Urbit.Vere.Pier.Types @@ -341,23 +342,13 @@ ames env who isFake scry enqueueEv stderr = (initialEvents, runAmes) scryLane :: HasLogFunc e => Ship -> RIO e (Maybe [AmesDest]) - scryLane ship = scry' ["peers", MkKnot $ tshow ship, "forward-lane"] + scryLane ship = scry' ["peers", tshow ship, "forward-lane"] scry' :: forall e n . (HasLogFunc e, FromNoun n) - => [Knot] + => [Text] -> RIO e (Maybe n) - scry' p = do - env <- ask - wen <- io Time.now - let nkt = MkKnot $ tshow $ Time.MkDate wen - let pax = Path $ "ax" : MkKnot (tshow who) : "" : nkt : p - io (scry wen Nothing pax) >>= \case - Just (_, fromNoun @n -> Just v) -> pure $ Just v - Just (_, n) -> do - logError $ displayShow ("ames: uncanny scry result", pax, n) - pure Nothing - Nothing -> pure Nothing + scry' = scryNow scry "ax" who "" ipv4Addr (Jammed (AAVoid v )) = absurd v ipv4Addr (Jammed (AAIpv4 a p)) = SockAddrInet (fromIntegral p) (unIpv4 a) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/KingSubsite.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/KingSubsite.hs index 2cd5e83699..22c3ab1a7f 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/KingSubsite.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/KingSubsite.hs @@ -12,6 +12,7 @@ module Urbit.Vere.Eyre.KingSubsite import Urbit.Prelude hiding (Builder) import Data.ByteString.Builder +import Urbit.King.Scry import Urbit.Vere.Serf.Types import Data.Conduit (ConduitT, Flush(..), yield) @@ -100,27 +101,7 @@ kingSubsite who scry func = do --TODO unify who into scry => Text -> RIO e (Maybe Bool) scryAuth cookie = - scry' $ fmap MkKnot ["authenticated", "cookie", textAsTa cookie] - - --TODO refactor into scry lib, as: - -- (forall n. FromNoun n => Text -> Text -> [Text] -> IO (Maybe n)) - -- vanecare -> desk -> restofpath - scry' :: forall e n - . (HasLogFunc e, FromNoun n) - => [Knot] - -> RIO e (Maybe n) - scry' p = do - env <- ask - wen <- io Time.now - let nkt = MkKnot $ tshow $ Time.MkDate wen - let pax = Path $ "ex" : MkKnot (tshow who) : "" : nkt : p - putStrLn (tshow pax) - io (scry wen Nothing pax) >>= \case - Just (_, fromNoun @n -> Just v) -> pure $ Just v - Just (_, n) -> do - logError $ displayShow ("eyre: uncanny scry result", pax, n) - pure Nothing - Nothing -> pure Nothing + scryNow scry "ex" who "" $ ["authenticated", "cookie", textAsTa cookie] fourOhFourSubsite :: Ship -> KingSubsite fourOhFourSubsite who = KS $ \req respond -> From 50f66ce431a906859a7870cd802dc168d58e5dd5 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Thu, 29 Oct 2020 13:16:20 +0100 Subject: [PATCH 551/933] build: simplify make test and re-enable on darwin ci for testing --- Makefile | 2 +- nix/lib/fetch-github-lfs.nix | 2 +- nix/lib/test-fake-ship.nix | 43 +++++++++++++++++++++++++++++++----- sh/test | 40 --------------------------------- 4 files changed, 40 insertions(+), 47 deletions(-) delete mode 100755 sh/test diff --git a/Makefile b/Makefile index 19f3255bb0..9efd4c1350 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ release: sh/release test: - sh/test + nix-build -A urbit-tests --no-out-link pills: sh/update-solid-pill diff --git a/nix/lib/fetch-github-lfs.nix b/nix/lib/fetch-github-lfs.nix index 1b5596cd8a..ecffd76b9c 100644 --- a/nix/lib/fetch-github-lfs.nix +++ b/nix/lib/fetch-github-lfs.nix @@ -49,7 +49,7 @@ let # Encode `oid` and `size` into a download operation per: # https://github.com/git-lfs/git-lfs/blob/master/docs/api/batch.md # - # This is done using toJSON to avoid bash quotation issuthe configurationes. + # This is done using toJSON to avoid bash quotation issues. downloadPayload = builtins.toJSON { operation = "download"; objects = [ pointer ]; diff --git a/nix/lib/test-fake-ship.nix b/nix/lib/test-fake-ship.nix index 3b463c42f1..2819bfa7d6 100644 --- a/nix/lib/test-fake-ship.nix +++ b/nix/lib/test-fake-ship.nix @@ -2,12 +2,10 @@ { urbit, herb, arvo ? null, pill, ship ? "bus" }: -stdenvNoCC.mkDerivation { - name = "test-${ship}"; - +stdenvNoCC.mkDerivation {name = "test-${ship}"; buildInputs = [ cacert urbit herb ]; - phases = [ "buildPhase" "installPhase " ]; + phases = [ "buildPhase" "installPhase" "checkPhase" ]; buildPhase = '' set -xeuo pipefail @@ -100,5 +98,40 @@ stdenvNoCC.mkDerivation { cp -r test-output-* $out/ ''; - meta = { platforms = [ "x86_64-linux" ]; }; + checkPhase = '' + hdr () { + echo =====$(sed 's/./=/g' <<< "$1")===== + echo ==== $1 ==== + echo =====$(sed 's/./=/g' <<< "$1")===== + } + + for f in $(find "$out/" -type f); do + hdr "$(basename $f)" + cat "$f" + done + + fail=0 + + for f in $(find "$out/" -type f); do + if egrep "((FAILED|CRASHED)|(ford|warn):) " $f >/dev/null; then + if [[ $fail -eq 0 ]]; then + hdr "Test Failures" + fi + + echo "ERROR Test failure in $(basename $f)" + + ((fail++)) + fi + done + + if [[ $fail -eq 0 ]]; then + hdr "Success" + fi + + exit "$fail" + ''; + + meta = { + platforms = [ "x86_64-linux" "x86_64-darwin" ]; + }; } diff --git a/sh/test b/sh/test deleted file mode 100755 index 8db22d247e..0000000000 --- a/sh/test +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -pkg="$(nix-build -A urbit-tests --no-out-link "$@")" - -hdr () { - echo =====$(sed 's/./=/g' <<< "$1")===== - echo ==== $1 ==== - echo =====$(sed 's/./=/g' <<< "$1")===== -} - -for f in $(find "$pkg/" -type f) -do - hdr "$(basename $f)" - cat "$f" -done - -fail=0 - -for f in $(find "$pkg/" -type f) -do - if egrep "((FAILED|CRASHED)|(ford|warn):) " $f >/dev/null - then - if [[ $fail -eq 0 ]] - then - hdr "Test Failures" - fi - - echo "ERROR Test failure in $(basename $f)" - ((fail++)) - fi -done - -if [[ $fail -eq 0 ]] -then - hdr "Success" -fi - -exit "$fail" From 6599a85b99744cf3121d5fb7caa7f973f4bae219 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Thu, 29 Oct 2020 16:20:41 +0100 Subject: [PATCH 552/933] king: ensure tests are enabled on ci and don't depend on lfs pills --- default.nix | 4 ++ nix/lib/test-fake-ship.nix | 19 +++--- nix/pkgs/hs/default.nix | 9 +-- pkg/hs/shell.nix | 1 + pkg/hs/urbit-king/package.yaml | 3 + pkg/hs/urbit-king/test/HoonMapSetTests.hs | 76 ++++++++++++++++++----- pkg/hs/urbit-king/test/LogTests.hs | 30 +++++---- pkg/hs/urbit-king/test/Main.hs | 42 ++++++++----- pkg/hs/urbit-king/test/Options.hs | 48 ++++++++++++++ 9 files changed, 173 insertions(+), 59 deletions(-) create mode 100644 pkg/hs/shell.nix create mode 100644 pkg/hs/urbit-king/test/Options.hs diff --git a/default.nix b/default.nix index dd6cd0a231..3d7fe82d24 100644 --- a/default.nix +++ b/default.nix @@ -22,6 +22,10 @@ $ nix-build -A brass.build $ nix-build -A solid.build + Run the king-haskell tests: + + $ nix-build -A hs.urbit-king.checks.urbit-king-tests + Build a specific Haskell package from ./pkg/hs: $ nix-build -A hs.urbit-noun.components.library diff --git a/nix/lib/test-fake-ship.nix b/nix/lib/test-fake-ship.nix index 2819bfa7d6..f34862cc0f 100644 --- a/nix/lib/test-fake-ship.nix +++ b/nix/lib/test-fake-ship.nix @@ -2,7 +2,8 @@ { urbit, herb, arvo ? null, pill, ship ? "bus" }: -stdenvNoCC.mkDerivation {name = "test-${ship}"; +stdenvNoCC.mkDerivation { + name = "test-${ship}"; buildInputs = [ cacert urbit herb ]; phases = [ "buildPhase" "installPhase" "checkPhase" ]; @@ -104,34 +105,32 @@ stdenvNoCC.mkDerivation {name = "test-${ship}"; echo ==== $1 ==== echo =====$(sed 's/./=/g' <<< "$1")===== } - + for f in $(find "$out/" -type f); do hdr "$(basename $f)" cat "$f" done - + fail=0 - + for f in $(find "$out/" -type f); do if egrep "((FAILED|CRASHED)|(ford|warn):) " $f >/dev/null; then if [[ $fail -eq 0 ]]; then hdr "Test Failures" fi - + echo "ERROR Test failure in $(basename $f)" ((fail++)) fi done - + if [[ $fail -eq 0 ]]; then hdr "Success" fi - + exit "$fail" ''; - meta = { - platforms = [ "x86_64-linux" "x86_64-darwin" ]; - }; + meta = { platforms = [ "x86_64-linux" "x86_64-darwin" ]; }; } diff --git a/nix/pkgs/hs/default.nix b/nix/pkgs/hs/default.nix index 5664607325..62c78c59e7 100644 --- a/nix/pkgs/hs/default.nix +++ b/nix/pkgs/hs/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, darwin, haskell-nix, gmp, zlib, libffi +{ lib, stdenv, darwin, haskell-nix, gmp, zlib, libffi, brass , enableStatic ? stdenv.hostPlatform.isStatic }: let @@ -63,11 +63,9 @@ let ]; packages = { - # Disable the urbit-king test-suite for now - since it relies - # on relative paths to lfs pills. - urbit-king.doCheck = false; urbit-king.components.exes.urbit-king.enableStatic = enableStatic; urbit-king.components.exes.urbit-king.enableShared = !enableStatic; + urbit-king.components.exes.urbit-king.configureFlags = lib.optionals enableStatic [ "--ghc-option=-optl=-L${gmp}/lib" @@ -75,6 +73,9 @@ let "--ghc-option=-optl=-L${zlib}/lib" ] ++ lib.optionals (enableStatic && stdenv.isDarwin) [ "--ghc-option=-optl=-L${darwin.libiconv}/lib" ]; + + urbit-king.components.tests.urbit-king-tests.testFlags = + [ "--brass-pill=${brass.lfs}" ]; }; }]; }; diff --git a/pkg/hs/shell.nix b/pkg/hs/shell.nix new file mode 100644 index 0000000000..b8d5d1fe75 --- /dev/null +++ b/pkg/hs/shell.nix @@ -0,0 +1 @@ +import ../../shell.nix diff --git a/pkg/hs/urbit-king/package.yaml b/pkg/hs/urbit-king/package.yaml index a3bb3673ec..5ff82e31fe 100644 --- a/pkg/hs/urbit-king/package.yaml +++ b/pkg/hs/urbit-king/package.yaml @@ -2,6 +2,9 @@ name: urbit-king version: 0.10.8 license: MIT license-file: LICENSE +data-files: + - test/gold/hoontree.gold + - test/gold/hoontree.pill library: source-dirs: lib diff --git a/pkg/hs/urbit-king/test/HoonMapSetTests.hs b/pkg/hs/urbit-king/test/HoonMapSetTests.hs index 9cb8deaf9e..a012e16eae 100644 --- a/pkg/hs/urbit-king/test/HoonMapSetTests.hs +++ b/pkg/hs/urbit-king/test/HoonMapSetTests.hs @@ -1,17 +1,22 @@ module HoonMapSetTests (tests) where import RIO.Directory -import Urbit.Prelude hiding (encodeUtf8) +import Urbit.Prelude -import Data.Text.Lazy.Encoding (encodeUtf8) +import Data.ByteString.Lazy (ByteString) import Numeric.Natural (Natural) import Test.QuickCheck hiding ((.&.)) import Test.Tasty -import Test.Tasty.Golden as G import Test.Tasty.QuickCheck import Test.Tasty.TH -import qualified Data.ByteString.Lazy as L +import qualified Data.ByteString as ByteString +import qualified Data.ByteString.Lazy as ByteString.Lazy +import qualified Data.Text.Lazy as Text.Lazy +import qualified Data.Text.Lazy.Encoding as Text.Lazy.Encoding +import qualified Paths_urbit_king +import qualified Test.Tasty.Golden as Golden +import qualified Test.Tasty.Golden.Advanced as Golden.Advanced -- Types ----------------------------------------------------------------------- @@ -50,7 +55,6 @@ mapRoundtrip = roundTrip (mapFromHoonMap . mapToHoonMap) setRoundtrip :: Set SmallNoun -> Bool setRoundtrip = roundTrip (setFromHoonSet . setToHoonSet) - -- Golden Tests ---------------------------------------------------------------- treeTestsIdentity :: TreeTests -> TreeTests @@ -60,30 +64,72 @@ treeTestsIdentity = fmap go TTSet s -> (TTSet . setToHoonSet . setFromHoonSet) s TTMap m -> (TTMap . mapToHoonMap . mapFromHoonMap) m -treeRTMug :: FilePath -> IO L.ByteString +treeRTMug :: FilePath -> IO ByteString.Lazy.ByteString treeRTMug inp = do byt <- readFile inp non <- cueBSExn byt tee <- fromNounExn non mug <- evaluate $ mug $ toNoun $ treeTestsIdentity tee - pure $ encodeUtf8 $ tlshow (mug :: Natural) + pure $ Text.Lazy.Encoding.encodeUtf8 $ tlshow (mug :: Natural) - -goldenFile :: String -> String -> (FilePath -> IO L.ByteString) -> TestTree -goldenFile testName testFileName action = - goldenVsString testName gold (action pill) +goldenPill + :: TestName + -> String + -> (FilePath -> IO ByteString.Lazy.ByteString) + -> TestTree +goldenPill test name action = + goldenVsString test gold (action pill) + where + gold = "test/gold" name <.> "gold" + pill = "test/gold" name <.> "pill" + +-- | Compare a given string against the golden file's contents. +goldenVsString + :: TestName + -- ^ Test name + -> String + -- ^ The «golden» file that will be retrieved via 'getDataFileName'. + -> IO ByteString.Lazy.ByteString + -- ^ Action that returns the string for comparison. + -> TestTree + -- ^ Verifies the golden file contents is identical to the returned string. +goldenVsString test name action = + askOption $ \cutoff -> + Golden.Advanced.goldenTest name acquire action (comparator cutoff) update where - root = "pkg/hs/urbit-king/test/gold" testFileName - gold = root <.> "gold" - pill = root <.> "pill" + acquire = do + path <- Paths_urbit_king.getDataFileName name + bytes <- ByteString.readFile path + pure (ByteString.Lazy.fromStrict bytes) + + comparator cutoff x y = + pure $ + if x == y + then Nothing + else Just + ( printf "Test output was different from '%s'. It was:\n" name + <> unpackUTF8 (truncate cutoff y) + ) + unpackUTF8 = Text.Lazy.unpack . Text.Lazy.Encoding.decodeUtf8 + + truncate (Golden.SizeCutoff cutoff) bytes = + if ByteString.Lazy.length bytes <= cutoff + then bytes + else ByteString.Lazy.take cutoff bytes + <> "" + <> "\nUse --accept or increase --size-cutoff to see full output." + + -- The update function is a noop as we don't have the golden file name. + update _ = pure () + -- Test Tree ------------------------------------------------------------------- tests :: TestTree tests = testGroup "Map/Set Conversions" - [ goldenFile "Golden Map Roundtrip" "hoontree" treeRTMug + [ goldenPill "Golden Map Roundtrip" "hoontree" treeRTMug , testProperty "Map Rountrip" mapRoundtrip , testProperty "Set Rountrip" setRoundtrip ] diff --git a/pkg/hs/urbit-king/test/LogTests.hs b/pkg/hs/urbit-king/test/LogTests.hs index d4317069ea..ef34e2c953 100644 --- a/pkg/hs/urbit-king/test/LogTests.hs +++ b/pkg/hs/urbit-king/test/LogTests.hs @@ -16,6 +16,7 @@ import Data.LargeWord (LargeKey(..)) import GHC.Natural (Natural) import Urbit.King.App (KingEnv, runKingEnvNoLog) +import qualified Options import qualified Urbit.EventLog.LMDB as Log @@ -123,15 +124,17 @@ tryAppend = forAll arbitrary (ioProperty . runApp . runTest) readDb log >>= assertEqual db' pure True -tryAppendHuge :: Property -tryAppendHuge = forAll arbitrary (ioProperty . runApp . runTest) +tryAppendHuge :: Options.Brass -> Property +tryAppendHuge brass = + forAll arbitrary (ioProperty . runApp . runTest) where runTest :: ([ByteString], Db) -> RIO KingEnv Bool runTest (extra, db) = do env <- ask io $ runInBoundThread $ runRIO env $ do - extra <- do b <- readFile "./bin/brass.pill" - pure (extra <> [b] <> extra) + extra <- do + b <- readFile =<< Options.getPillPath brass + pure (extra <> [b] <> extra) withTestDir $ \dir -> do db' <- pure (addEvents db extra) withDb dir db $ \log -> do @@ -147,20 +150,21 @@ tests :: TestTree tests = testGroup "Log" [ localOption (QuickCheckTests 10) $ - testProperty "Read/Write Log Identity" $ - tryReadIdentity + testProperty "Read/Write Log Identity" $ + tryReadIdentity , localOption (QuickCheckTests 15) $ - testProperty "Read/Write Database" $ - tryReadDatabase + testProperty "Read/Write Database" $ + tryReadDatabase , localOption (QuickCheckTests 5) $ - testProperty "Read/Write Database Multiple Times" $ - tryReadDatabaseFuzz + testProperty "Read/Write Database Multiple Times" $ + tryReadDatabaseFuzz , localOption (QuickCheckTests 10) $ - testProperty "Append Random Events" $ - tryAppend + testProperty "Append Random Events" $ + tryAppend , localOption (QuickCheckTests 1) $ + askOption $ \path -> testProperty "Append Huge Events" $ - tryAppendHuge + tryAppendHuge path ] diff --git a/pkg/hs/urbit-king/test/Main.hs b/pkg/hs/urbit-king/test/Main.hs index cc76dd6dbf..f58e2bb4ea 100644 --- a/pkg/hs/urbit-king/test/Main.hs +++ b/pkg/hs/urbit-king/test/Main.hs @@ -2,14 +2,14 @@ module Main (main) where import ClassyPrelude +import Control.Concurrent (runInBoundThread) +import Data.Proxy (Proxy (Proxy)) import RIO.Directory import Test.QuickCheck hiding ((.&.)) import Test.Tasty import Test.Tasty.QuickCheck import Test.Tasty.TH - -import Control.Concurrent (runInBoundThread) -import System.Environment (setEnv) +import Test.Tasty.Options (OptionDescription (Option)) import qualified AmesTests import qualified ArvoTests @@ -21,20 +21,28 @@ import qualified HoonMapSetTests import qualified JamTests import qualified LogTests import qualified NounConversionTests +import qualified Options +import qualified Test.Tasty.Runners as Runners main :: IO () main = do - makeAbsolute "../../.." >>= setCurrentDirectory - setEnv "TASTY_NUM_THREADS" "1" - runInBoundThread $ defaultMain $ testGroup "Urbit" - [ AmesTests.tests - , ArvoTests.tests - , BehnTests.tests - , ClayTests.tests - , DawnTests.tests - , DeriveNounTests.tests - , HoonMapSetTests.tests - , JamTests.tests - , LogTests.tests - , NounConversionTests.tests - ] + let ingredients = + includingOptions + [ Option (Proxy @Options.Brass) + ] : defaultIngredients + + runInBoundThread $ + defaultMainWithIngredients ingredients $ + localOption (Runners.NumThreads 1) $ + testGroup "Urbit" + [ AmesTests.tests + , ArvoTests.tests + , BehnTests.tests + , ClayTests.tests + , DawnTests.tests + , DeriveNounTests.tests + , HoonMapSetTests.tests + , JamTests.tests + , LogTests.tests + , NounConversionTests.tests + ] diff --git a/pkg/hs/urbit-king/test/Options.hs b/pkg/hs/urbit-king/test/Options.hs new file mode 100644 index 0000000000..21f1f826ad --- /dev/null +++ b/pkg/hs/urbit-king/test/Options.hs @@ -0,0 +1,48 @@ +module Options + ( Brass + , Pill + , getPillPath + ) where + +import Control.Monad.IO.Class (MonadIO) +import Data.Proxy (Proxy (Proxy)) +import Data.String (IsString) +import GHC.TypeLits (KnownSymbol, Symbol) +import Prelude + +import qualified GHC.TypeLits as TypeLits +import qualified RIO.Directory as Directory +import qualified Test.Tasty as Tasty +import qualified Test.Tasty.Options as Options + +type Brass = Pill "brass" + +-- | A file-system path tagged by the pill name. +newtype Pill (name :: Symbol) = Pill FilePath + deriving stock (Eq, Show) + deriving newtype (IsString) + +instance KnownSymbol name => Options.IsOption (Pill name) where + optionName = + pure ( TypeLits.symbolVal (Proxy @name) + ++ "-pill" + ) + + optionHelp = + pure ( "The file path to the " + ++ TypeLits.symbolVal (Proxy @name) + ++ " pill" + ) + + defaultValue = + Pill ( "../../../bin" + ++ TypeLits.symbolVal (Proxy @name) + ++ ".pill" + ) + + parseValue = \case + "" -> Nothing + path -> Just (Pill path) + +getPillPath :: MonadIO m => Pill name -> m FilePath +getPillPath (Pill path) = Directory.canonicalizePath path From 6ed18bb825c0687b6020a35beeb393ceb77c633f Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Thu, 29 Oct 2020 17:43:23 +0100 Subject: [PATCH 553/933] build: removing shell set options from inline buildPhase for tests --- nix/lib/test-fake-ship.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/nix/lib/test-fake-ship.nix b/nix/lib/test-fake-ship.nix index f34862cc0f..6a42e806c7 100644 --- a/nix/lib/test-fake-ship.nix +++ b/nix/lib/test-fake-ship.nix @@ -9,8 +9,6 @@ stdenvNoCC.mkDerivation { phases = [ "buildPhase" "installPhase" "checkPhase" ]; buildPhase = '' - set -xeuo pipefail - if ! [ -f "$SSL_CERT_FILE" ]; then header "$SSL_CERT_FILE doesn't exist" exit 1 From 3f9cd4a79443123ecddce1746a9ba38d01d0469c Mon Sep 17 00:00:00 2001 From: fang Date: Thu, 29 Oct 2020 23:22:48 +0100 Subject: [PATCH 554/933] king: get rid of unnecessary helper --- pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs index c017c19d48..e64ccdb458 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs @@ -337,18 +337,12 @@ ames env who isFake scry enqueueEv stderr = (initialEvents, runAmes) EachNo addr -> to (ipv4Addr addr) scryVersion :: HasLogFunc e => RIO e (Maybe Version) - scryVersion = scry' ["protocol", "version"] + scryVersion = scryNow scry "ax" who "" ["protocol", "version"] scryLane :: HasLogFunc e => Ship -> RIO e (Maybe [AmesDest]) - scryLane ship = scry' ["peers", tshow ship, "forward-lane"] - - scry' :: forall e n - . (HasLogFunc e, FromNoun n) - => [Text] - -> RIO e (Maybe n) - scry' = scryNow scry "ax" who "" + scryLane ship = scryNow scry "ax" who "" ["peers", tshow ship, "forward-lane"] ipv4Addr (Jammed (AAVoid v )) = absurd v ipv4Addr (Jammed (AAIpv4 a p)) = SockAddrInet (fromIntegral p) (unIpv4 a) From 58094c265c5962ca7b83eba54c0a01a686e9cf11 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Fri, 30 Oct 2020 10:51:56 +0100 Subject: [PATCH 555/933] build: bludgeon write/EAGAIN stdout errors into submission --- nix/lib/boot-fake-ship.nix | 4 +-- nix/lib/default.nix | 4 +-- nix/lib/test-fake-ship.nix | 55 ++++++++++++++++++-------------------- 3 files changed, 30 insertions(+), 33 deletions(-) diff --git a/nix/lib/boot-fake-ship.nix b/nix/lib/boot-fake-ship.nix index e189818e47..93adb27ebd 100644 --- a/nix/lib/boot-fake-ship.nix +++ b/nix/lib/boot-fake-ship.nix @@ -10,8 +10,6 @@ stdenvNoCC.mkDerivation { phases = [ "buildPhase" "installPhase " ]; buildPhase = '' - set -xeuo pipefail - if ! [ -f "$SSL_CERT_FILE" ]; then header "$SSL_CERT_FILE doesn't exist" exit 1 @@ -21,6 +19,8 @@ stdenvNoCC.mkDerivation { PILL=${pill} SHIP=${ship} + set -xeuo pipefail + if [ -z "$ARVO" ]; then urbit -d -F "$SHIP" -B "$PILL" ./pier else diff --git a/nix/lib/default.nix b/nix/lib/default.nix index d14915c9bc..2f82313e84 100644 --- a/nix/lib/default.nix +++ b/nix/lib/default.nix @@ -3,10 +3,10 @@ let # Fetchers + Import from derivations (IFDs) - fetchers = { + fetchers = rec { bootFakeShip = callPackage ./boot-fake-ship.nix { }; - testFakeShip = callPackage ./test-fake-ship.nix { }; + testFakeShip = callPackage ./test-fake-ship.nix { inherit bootFakeShip; }; fetchGitHubLFS = callPackage ./fetch-github-lfs.nix { }; diff --git a/nix/lib/test-fake-ship.nix b/nix/lib/test-fake-ship.nix index 6a42e806c7..bb5218cffa 100644 --- a/nix/lib/test-fake-ship.nix +++ b/nix/lib/test-fake-ship.nix @@ -1,38 +1,36 @@ -{ stdenvNoCC, cacert }: +{ stdenvNoCC, cacert, python3, bootFakeShip }: -{ urbit, herb, arvo ? null, pill, ship ? "bus" }: +{ urbit, herb, arvo ? null, pill, ship ? "bus", doCheck ? true }: stdenvNoCC.mkDerivation { - name = "test-${ship}"; - buildInputs = [ cacert urbit herb ]; + inherit doCheck; - phases = [ "buildPhase" "installPhase" "checkPhase" ]; + name = "test-${ship}"; + src = bootFakeShip { inherit urbit herb arvo pill ship; }; + phases = [ "unpackPhase" "buildPhase" "checkPhase" ]; + buildInputs = [ cacert urbit herb python3 ]; + + unpackPhase = '' + cp -R $src ./pier + chmod -R u+rw ./pier + ''; buildPhase = '' - if ! [ -f "$SSL_CERT_FILE" ]; then - header "$SSL_CERT_FILE doesn't exist" - exit 1 - fi + set -x - ARVO=${if arvo == null then "" else arvo} - PILL=${pill} - SHIP=${ship} + urbit -d ./pier 2> urbit-output - if [ -z "$ARVO" ]; then - urbit -d -F $SHIP -B $PILL ./pier 2> urbit-output - else - urbit -d -F $SHIP -A $ARVO -B $PILL ./pier 2> urbit-output - fi + # Sledge Hammer! + # See: https://github.com/travis-ci/travis-ci/issues/4704#issuecomment-348435959 + python3 -c $'import os\n[os.set_blocking(i, True) for i in range(3)]\n' + + tail -F urbit-output >&2 & - tail -f urbit-output >&2 & tailproc=$! cleanup () { - if [ -e ./pier/.vere.lock ]; then - kill $(< ./pier/.vere.lock) || true - fi - - kill "$tailproc" || true + kill $(cat ./pier/.vere.lock) || true + kill "$tailproc" 2>/dev/null || true set +x } @@ -71,14 +69,14 @@ stdenvNoCC.mkDerivation { herb ./pier -p hood -d '+hood/mass' herb ./pier -p hood -d '+hood/exit' + cleanup + # Collect output cp urbit-output test-output-unit cp urbit-output test-output-agents cp urbit-output test-output-generators cp urbit-output test-output-marks - rm urbit-output - sed -i '0,/test-unit-start/d' test-output-unit sed -i '/test-unit-end/,$d' test-output-unit @@ -90,11 +88,10 @@ stdenvNoCC.mkDerivation { sed -i '0,/test-marks-start/d' test-output-marks sed -i '/test-marks-end/,$d' test-output-marks - ''; - installPhase = '' - mkdir $out - cp -r test-output-* $out/ + mkdir -p $out + + cp test-output-* $out/ ''; checkPhase = '' From 3e31aae7b92231ff084ad5dfb5241d09e02598cf Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Fri, 30 Oct 2020 13:02:27 +0100 Subject: [PATCH 556/933] build: default crossSystem to musl64 on linux if enableStatic --- ci.nix | 50 ++++++++++++++++++++------------------------------ default.nix | 17 +++++++++++++++-- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/ci.nix b/ci.nix index 4f27891732..038e57003d 100644 --- a/ci.nix +++ b/ci.nix @@ -48,31 +48,21 @@ let extension = "pill"; }; - systems = lib.filterAttrs (_: v: builtins.elem v.system supportedSystems) { - linux = { - system = "x86_64-linux"; - crossSystem = lib.systems.examples.musl64; - }; - - darwin = { - system = "x86_64-darwin"; - crossSystem = null; - }; + systems = lib.filterAttrs (_: v: builtins.elem v supportedSystems) { + linux = "x86_64-linux"; + darwin = "x86_64-darwin"; }; -in localLib.dimension "system" systems (systemName: - { system, crossSystem }: +in localLib.dimension "system" systems (systemName: system: let - # Shared libraries/executables for the build (current) system. - localPackages = import ./default.nix { + dynamicPackages = import ./default.nix { inherit system; enableStatic = false; }; - # Static libraries/executables for the host (cross) system. staticPackages = import ./default.nix { - inherit system crossSystem; + inherit system; enableStatic = true; }; @@ -82,23 +72,23 @@ in localLib.dimension "system" systems (systemName: haskell-nix.haskellLib.selectProjectPackages staticPackages.hs; # The top-level set of attributes to build on ci. - finalPackages = localPackages // rec { + finalPackages = dynamicPackages // rec { + # Replace some top-level attributes with their static variant. + inherit (staticPackages) urbit tarball; + # Expose the nix-shell derivation as a sanity check. shell = import ./shell.nix; - # Replace the top-level urbit attribute with the static variant. - urbit = staticPackages.urbit; - - # Replace the top-level tarball attribute with the static variant. - tarball = staticPackages.tarball; - - # Replace the localPackages.hs attribute with the individual components + # Replace the .hs attribute with the individual collections of components # displayed as top-level attributes: # # .hs.library.[...] + # .hs.checks.[...] # .hs.tests.[...] - # .hs.bencharmks.[...] + # .hs.benchmarks.[...] # ... + # + # Note that .checks are the actual _execution_ of the tests. hs = localLib.collectHaskellComponents haskellPackages; # Push the tarball to the remote google storage bucket. @@ -111,12 +101,12 @@ in localLib.dimension "system" systems (systemName: # Replace top-level pill attributes with push to google storage variants. } // lib.optionalAttrs (system == "x86_64-linux") { - ivory = pushPill "ivory" localPackages.ivory; - brass = pushPill "brass" localPackages.brass; - solid = pushPill "solid" localPackages.solid; + ivory = pushPill "ivory" dynamicPackages.ivory; + brass = pushPill "brass" dynamicPackages.brass; + solid = pushPill "solid" dynamicPackages.solid; - ivory-ropsten = pushPill "ivory-ropsten" localPackages.ivory-ropsten; - brass-ropsten = pushPill "brass-ropsten" localPackages.brass-ropsten; + ivory-ropsten = pushPill "ivory-ropsten" dynamicPackages.ivory-ropsten; + brass-ropsten = pushPill "brass-ropsten" dynamicPackages.brass-ropsten; }; # Filter derivations that have meta.platform missing the current system, diff --git a/default.nix b/default.nix index 3d7fe82d24..dd3a617199 100644 --- a/default.nix +++ b/default.nix @@ -8,6 +8,11 @@ $ nix-build -A urbit --arg enableSatic true + Note that on linux the previous command is equivalent to: + + $ nix-build -A urbit --argstr crossSystem x86_64-unknown-linux-musl \ + --arg enableSatic true + Static urbit-king binary: $ nix-build -A hs.urbit-king.components.exes.urbit-king --arg enableStatic true @@ -47,12 +52,20 @@ , crossOverlays ? [ ] # Whether to use pkgs.pkgsStatic.* to obtain statically linked package # dependencies - ie. when building fully-static libraries or executables. -, enableStatic ? crossSystem != null }: +, enableStatic ? false }: let pkgs = import ./nix/default.nix { - inherit system crossSystem sources config overlays crossOverlays; + inherit system sources config overlays crossOverlays; + + crossSystem = + # If we're running on linux and crossSystem is unspecified but static + # builds are requested - set the crossSystem to musl64. + if system == "x86_64-linux" && crossSystem == null && enableStatic then + "x86_64-unknown-linux-musl" + else + crossSystem; }; # Local library import from derivation functions such as fetchGitHubLFS, etc. From bd0672cb8eda955055c29b32fef653338913783c Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Fri, 30 Oct 2020 14:54:33 -0700 Subject: [PATCH 557/933] king: 1 TiB mapsize for event log --- pkg/hs/urbit-eventlog-lmdb/lib/Urbit/EventLog/LMDB.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/hs/urbit-eventlog-lmdb/lib/Urbit/EventLog/LMDB.hs b/pkg/hs/urbit-eventlog-lmdb/lib/Urbit/EventLog/LMDB.hs index 569c418abb..7444296e83 100644 --- a/pkg/hs/urbit-eventlog-lmdb/lib/Urbit/EventLog/LMDB.hs +++ b/pkg/hs/urbit-eventlog-lmdb/lib/Urbit/EventLog/LMDB.hs @@ -100,7 +100,7 @@ rawOpen :: MonadIO m => FilePath -> m Env rawOpen dir = io $ do env <- mdb_env_create mdb_env_set_maxdbs env 3 - mdb_env_set_mapsize env (100 * 1024 * 1024 * 1024) + mdb_env_set_mapsize env (1024 * 1024 * 1024 * 1024) mdb_env_open env dir [] pure env From c0f1fe8433cb9d510ff74b730e213bb7179b92b0 Mon Sep 17 00:00:00 2001 From: fang Date: Fri, 30 Oct 2020 23:42:33 +0100 Subject: [PATCH 558/933] king: improve code style in KingSubsite --- .../lib/Urbit/Vere/Eyre/KingSubsite.hs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/KingSubsite.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/KingSubsite.hs index 4f9e63124a..e3b41ac579 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/KingSubsite.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/KingSubsite.hs @@ -73,13 +73,14 @@ kingSubsite who scry func = do --TODO unify who into scry (\(id, _) -> atomically $ modifyTVar' clients (deleteMap id)) (\(_, q) -> do authed <- authenticated env req - if not authed then - respond $ W.responseLBS (H.mkStatus 403 "Permission Denied") [] "" - else - let loop = yield Flush >> forever (atomically (readTQueue q) >>= streamSlog) - in respond $ W.responseSource (H.mkStatus 200 "OK") heads loop) + if not authed + then respond $ emptyResponse 403 "Permission Denied" + else + let loop = yield Flush >> + forever (atomically (readTQueue q) >>= streamSlog) + in respond $ W.responseSource (H.mkStatus 200 "OK") heads loop) - _ -> respond $ W.responseLBS (H.mkStatus 404 "Not Found") [] "" + _ -> respond $ emptyResponse 404 "Not Found" where heads = [ ("Content-Type" , "text/event-stream") @@ -87,6 +88,8 @@ kingSubsite who scry func = do --TODO unify who into scry , ("Connection" , "keep-alive") ] + emptyResponse cod mes = W.responseLBS (H.mkStatus cod mes) [] "" + authenticated env req = runRIO env $ (scryAuth $ getCookie req) >>= pure . fromMaybe False @@ -100,11 +103,11 @@ kingSubsite who scry func = do --TODO unify who into scry => Text -> RIO e (Maybe Bool) scryAuth cookie = - scryNow scry "ex" who "" $ ["authenticated", "cookie", textAsTa cookie] + scryNow scry "ex" who "" ["authenticated", "cookie", textAsTa cookie] fourOhFourSubsite :: Ship -> KingSubsite fourOhFourSubsite who = KS $ \req respond -> respond $ W.responseLBS (H.mkStatus 404 "Not Found") [] body where body = toLazyByteString $ foldMap charUtf8 $ msg - msg = "Ship " <> (show who) <> " not docked." + msg = "Ship " <> show who <> " not docked." From 06f3dc2d3ea1160723ce3d7079d39771ddbba45e Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Fri, 30 Oct 2020 16:17:34 -0700 Subject: [PATCH 559/933] king: fix MonadFail issue in Packet.hs caused by merge --- pkg/hs/urbit-king/lib/Urbit/Vere/Ames/Packet.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/Packet.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/Packet.hs index 1801510324..60bfab6f58 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/Packet.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/Packet.hs @@ -6,6 +6,7 @@ module Urbit.Vere.Ames.Packet where import Urbit.Prelude +import Control.Monad.Fail import Data.Bits import Data.LargeWord import Data.Serialize From a211390e7725864985fe59f5ad70d2d20444d0fd Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Fri, 30 Oct 2020 16:35:52 -0700 Subject: [PATCH 560/933] king: and fix a warning in Packet.hs --- pkg/hs/urbit-king/lib/Urbit/Vere/Ames/Packet.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/Packet.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/Packet.hs index 60bfab6f58..193a1da365 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/Packet.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/Packet.hs @@ -12,7 +12,6 @@ import Data.LargeWord import Data.Serialize import Urbit.Arvo (AmesDest) -import Urbit.Noun.Tree (mug) data Packet = Packet { pktVersion :: Word8 From 2497283ff2c15d92b09c5199395ac6dadc263a8b Mon Sep 17 00:00:00 2001 From: fang Date: Sat, 31 Oct 2020 21:00:00 +0100 Subject: [PATCH 561/933] king: more code style weaks, remove stale todo's --- pkg/hs/urbit-king/lib/Urbit/King/Scry.hs | 10 +++++----- pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs | 2 +- pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/KingSubsite.hs | 11 +++++------ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Scry.hs b/pkg/hs/urbit-king/lib/Urbit/King/Scry.hs index a8201843b8..f2a989be39 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Scry.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Scry.hs @@ -12,10 +12,10 @@ import qualified Urbit.Noun.Time as Time scryNow :: forall e n . (HasLogFunc e, FromNoun n) => (Time.Wen -> Gang -> Path -> IO (Maybe (Term, Noun))) - -> Text - -> Ship - -> Text - -> [Text] + -> Text -- ^ vane + care as two-letter string + -> Ship -- ^ ship in scry path, usually the local ship + -> Text -- ^ desk in scry path + -> [Text] -- ^ resource path to scry for -> RIO e (Maybe n) scryNow scry vare ship desk path = do env <- ask @@ -25,7 +25,7 @@ scryNow scry vare ship desk path = do io (scry wen Nothing pax) >>= \case Just (_, fromNoun @n -> Just v) -> pure $ Just v Just (_, n) -> do - logError $ displayShow (vare, "uncanny scry result", pax, n) + logError $ displayShow ("uncanny scry result", vare, pax, n) pure Nothing Nothing -> pure Nothing diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs index 2daad60efa..2aea990569 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs @@ -27,7 +27,7 @@ import System.Random (randomIO) import Urbit.Vere.Http (convertHeaders, unconvertHeaders) import Urbit.Vere.Eyre.KingSubsite (KingSubsite) -import qualified Network.HTTP.Types as H +import qualified Network.HTTP.Types as H -- Types ----------------------------------------------------------------------- diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/KingSubsite.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/KingSubsite.hs index e3b41ac579..3430c1612f 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/KingSubsite.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/KingSubsite.hs @@ -46,7 +46,7 @@ kingSubsite :: HasLogFunc e -> (Time.Wen -> Gang -> Path -> IO (Maybe (Term, Noun))) -> TVar ((Atom, Tank) -> IO ()) -> RAcquire e KingSubsite -kingSubsite who scry func = do --TODO unify who into scry +kingSubsite who scry func = do clients <- newTVarIO (mempty :: Map Word (SlogAction -> IO ())) nextId <- newTVarIO (0 :: Word) baton <- newTMVarIO () @@ -58,9 +58,8 @@ kingSubsite who scry func = do --TODO unify who into scry threadDelay 20_000_000 io $ readTVarIO clients >>= traverse_ ($ KeepAlive) - --TODO scry to verify cookie authentication pure $ KS $ \req respond -> case W.pathInfo req of - ("~_~":"slog":_) -> bracket + ["~_~", "slog"] -> bracket (do id <- atomically $ do id <- readTVar nextId @@ -76,8 +75,8 @@ kingSubsite who scry func = do --TODO unify who into scry if not authed then respond $ emptyResponse 403 "Permission Denied" else - let loop = yield Flush >> - forever (atomically (readTQueue q) >>= streamSlog) + let loop = yield Flush + >> forever (atomically (readTQueue q) >>= streamSlog) in respond $ W.responseSource (H.mkStatus 200 "OK") heads loop) _ -> respond $ emptyResponse 404 "Not Found" @@ -97,7 +96,7 @@ kingSubsite who scry func = do --TODO unify who into scry getCookie req = intercalate "; " $ fmap (E.decodeUtf8 . snd) $ filter ((== "cookie") . fst) - (W.requestHeaders req) + $ W.requestHeaders req scryAuth :: HasLogFunc e => Text From af35b8043558ccc4b09021c7d7154d620384146f Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Tue, 3 Nov 2020 08:28:05 +0100 Subject: [PATCH 562/933] build: change service-account secret location to non-ephemeral mount --- ci.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci.nix b/ci.nix index 038e57003d..f95db63043 100644 --- a/ci.nix +++ b/ci.nix @@ -21,7 +21,8 @@ let # The key with google storage bucket write permission, # deployed to ci via nixops `deployment.keys."service-account.json"`. - serviceAccountKey = builtins.readFile ("/var/run/keys/service-account.json"); + serviceAccountKey = + builtins.readFile ("/var/lib/hercules-ci-agent/secrets/service-account.json"); # Push a split output derivation containing "out" and "hash" outputs. pushObject = From 52308c4977a5c23120d33f8dd90c9f20c3918bd0 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 3 Nov 2020 00:30:40 -0800 Subject: [PATCH 563/933] test: cleans up output, adds |trim and |meld with intervening |mass measurements --- nix/lib/test-fake-ship.nix | 40 +++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/nix/lib/test-fake-ship.nix b/nix/lib/test-fake-ship.nix index bb5218cffa..0a2d6bddd1 100644 --- a/nix/lib/test-fake-ship.nix +++ b/nix/lib/test-fake-ship.nix @@ -37,14 +37,20 @@ stdenvNoCC.mkDerivation { trap cleanup EXIT + # measure initial memory usage + # + herb ./pier -d '~& ~ ~& %init-mass-start ~' herb ./pier -p hood -d '+hood/mass' + herb ./pier -d '~& ~ ~& %init-mass-end ~' - # Run the unit tests and then print scrollback + # run the unit tests + # herb ./pier -d '~& ~ ~& %test-unit-start ~' herb ./pier -d '####-test %/tests' herb ./pier -d '~& ~ ~& %test-unit-end ~' - # Start and run the test app + # use the :test app to build all agents, generators, and marks + # herb ./pier -p hood -d '+hood/start %test' herb ./pier -d '~& ~ ~& %test-agents-start ~' @@ -59,14 +65,42 @@ stdenvNoCC.mkDerivation { herb ./pier -p test -d '%marks' herb ./pier -d '~& ~ ~& %test-marks-end ~' - # Compact the loom, comparing memory use before and after + # measure memory usage post tests + # + herb ./pier -d '~& ~ ~& %test-mass-start ~' herb ./pier -p hood -d '+hood/mass' + herb ./pier -d '~& ~ ~& %test-mass-end ~' + # defragment the loom + # herb ./pier -d '~& ~ ~& %pack-start ~' herb ./pier -p hood -d '+hood/pack' herb ./pier -d '~& ~ ~& %pack-end ~' + # reclaim space within arvo + # + herb ./pier -d '~& ~ ~& %trim-start ~' + herb ./pier -p hood -d '+hood/trim' + herb ./pier -d '~& ~ ~& %trim-end ~' + + # measure memory usage pre |meld + # + herb ./pier -d '~& ~ ~& %trim-mass-start ~' herb ./pier -p hood -d '+hood/mass' + herb ./pier -d '~& ~ ~& %trim-mass-end ~' + + # globally deduplicate + # + herb ./pier -d '~& ~ ~& %meld-start ~' + herb ./pier -p hood -d '+hood/meld' + herb ./pier -d '~& ~ ~& %meld-end ~' + + # measure memory usage post |meld + # + herb ./pier -d '~& ~ ~& %meld-mass-start ~' + herb ./pier -p hood -d '+hood/mass' + herb ./pier -d '~& ~ ~& %meld-mass-end ~' + herb ./pier -p hood -d '+hood/exit' cleanup From 190557cf887e918b4d112dbb3258ff49d8af8387 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 3 Nov 2020 10:51:34 -0800 Subject: [PATCH 564/933] vere: set maximum http request to 512 MiB --- pkg/urbit/vere/io/http.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/urbit/vere/io/http.c b/pkg/urbit/vere/io/http.c index a20128b2eb..c635792be5 100644 --- a/pkg/urbit/vere/io/http.c +++ b/pkg/urbit/vere/io/http.c @@ -1395,6 +1395,10 @@ _http_serv_init_h2o(SSL_CTX* tls_u, c3_o log, c3_o red) h2o_u->fig_u.server_name = h2o_iovec_init( H2O_STRLIT("urbit/vere-" URBIT_VERSION)); + // set maximum request size to 512 MiB + // + h2o_u->fig_u.max_request_entity_size = 512 * 1024 * 1024; + // XX default pending vhost/custom-domain design // XX revisit the effect of specifying the port h2o_u->hos_u = h2o_config_register_host(&h2o_u->fig_u, From 0d617eefc96a878044cf44095356d35d4c2f91ae Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 3 Nov 2020 11:57:55 -0800 Subject: [PATCH 565/933] vere: save snapshot upon completed replay --- pkg/urbit/vere/pier.c | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index 1515ebff5c..0da9f6bb19 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -725,6 +725,7 @@ _pier_play(u3_play* pay_u) u3_pier_cram(pir_u); } else if ( pay_u->eve_d == log_u->dun_d ) { + u3_lord_save(pir_u->god_u); _pier_work_init(pir_u); } } From 94da5c9102d746cc13618f3fd316e8a0de3c543a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 3 Nov 2020 12:00:54 -0800 Subject: [PATCH 566/933] vere: add comment noting possible ctrl-z deadlock --- pkg/urbit/vere/disk.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/urbit/vere/disk.c b/pkg/urbit/vere/disk.c index 756ec9ab8b..8b11c1962c 100644 --- a/pkg/urbit/vere/disk.c +++ b/pkg/urbit/vere/disk.c @@ -633,6 +633,9 @@ u3_disk_exit(u3_disk* log_u) // cancel write thread // + // XX can deadlock when called from signal handler + // XX revise SIGTSTP handling + // if ( c3y == log_u->ted_o ) { c3_i sas_i; From cc766666ef3ef884690f82ccfd50320c3b8d60ce Mon Sep 17 00:00:00 2001 From: fang Date: Tue, 3 Nov 2020 22:01:15 +0100 Subject: [PATCH 567/933] pill: clean up pill contents Various not-in-repo junk files had been accruing. This rebuilds the pill with those deleted from the filesystem. --- bin/solid.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index 26dab8f0bc..e61e1df295 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5b04001a5524d4898a71fc8af428e2870aa9b141658c091951e1036a86d583dd -size 6501179 +oid sha256:934fa478c4f586ca26e1e9cb878c5fbae9cd6307b960460f7a8998f87dd0029c +size 6330928 From cf5c2a40abfb8b6f5900614ed9174129034fe2da Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Wed, 4 Nov 2020 11:11:39 +0100 Subject: [PATCH 568/933] build: remove unnecessary test platform dependence An alternative approach is being considerd for more granular platform dependence for tests. --- nix/lib/test-fake-ship.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/nix/lib/test-fake-ship.nix b/nix/lib/test-fake-ship.nix index 0a2d6bddd1..caed88c733 100644 --- a/nix/lib/test-fake-ship.nix +++ b/nix/lib/test-fake-ship.nix @@ -160,6 +160,4 @@ stdenvNoCC.mkDerivation { exit "$fail" ''; - - meta = { platforms = [ "x86_64-linux" "x86_64-darwin" ]; }; } From 8a02593f2d30cabcfc6e63c66e1da0f9a0b292c4 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Wed, 4 Nov 2020 11:12:49 +0100 Subject: [PATCH 569/933] build: run urbit-tests using the urbit-debug binary by default --- default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index dd3a617199..19907da9db 100644 --- a/default.nix +++ b/default.nix @@ -119,14 +119,15 @@ let }; # Additional top-level packages and attributes exposed for convenience. - extraPackages = with localPackages; { + extraPackages = with localPackages; rec { # Expose packages we've local customisations for. inherit (hostPackages) libsigsegv; urbit-debug = urbit.override { enableDebug = true; }; urbit-tests = localLib.testFakeShip { - inherit urbit herb; + inherit herb; + urbit = urbit-debug; pill = solid.lfs; }; From 5728a1876b09ec41cd2011ac40fd94b09bf8609e Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Wed, 4 Nov 2020 11:14:57 +0100 Subject: [PATCH 570/933] build: intentionally limit the number of expose ci attributes This is an investigative test for signal-to-noise on the ci dashboard. --- ci.nix | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ci.nix b/ci.nix index f95db63043..6f1c647d32 100644 --- a/ci.nix +++ b/ci.nix @@ -21,8 +21,8 @@ let # The key with google storage bucket write permission, # deployed to ci via nixops `deployment.keys."service-account.json"`. - serviceAccountKey = - builtins.readFile ("/var/lib/hercules-ci-agent/secrets/service-account.json"); + serviceAccountKey = builtins.readFile + ("/var/lib/hercules-ci-agent/secrets/service-account.json"); # Push a split output derivation containing "out" and "hash" outputs. pushObject = @@ -73,11 +73,11 @@ in localLib.dimension "system" systems (systemName: system: haskell-nix.haskellLib.selectProjectPackages staticPackages.hs; # The top-level set of attributes to build on ci. - finalPackages = dynamicPackages // rec { - # Replace some top-level attributes with their static variant. - inherit (staticPackages) urbit tarball; + finalPackages = rec { + # Expose select packages to increase signal-to-noise of the ci dashboard. + inherit (staticPackages) urbit urbit-tests tarball; - # Expose the nix-shell derivation as a sanity check. + # Expose the nix-shell derivation as a sanity check + possible cache hit. shell = import ./shell.nix; # Replace the .hs attribute with the individual collections of components @@ -92,7 +92,7 @@ in localLib.dimension "system" systems (systemName: system: # Note that .checks are the actual _execution_ of the tests. hs = localLib.collectHaskellComponents haskellPackages; - # Push the tarball to the remote google storage bucket. + # Push the tarball to the google storage bucket for the current platform. release = pushObject { name = tarball.name; drv = tarball; @@ -100,7 +100,7 @@ in localLib.dimension "system" systems (systemName: system: contentType = "application/x-gtar"; }; - # Replace top-level pill attributes with push to google storage variants. + # Top-level pill attributes build and push-to-storage - only on linux. } // lib.optionalAttrs (system == "x86_64-linux") { ivory = pushPill "ivory" dynamicPackages.ivory; brass = pushPill "brass" dynamicPackages.brass; From b501a802935c4db4e3226de37e168d633af05ce6 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Wed, 4 Nov 2020 11:35:12 +0100 Subject: [PATCH 571/933] build: removing extraneous top-level tarball attribute from ci --- ci.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ci.nix b/ci.nix index 6f1c647d32..cbe4965bf7 100644 --- a/ci.nix +++ b/ci.nix @@ -73,9 +73,9 @@ in localLib.dimension "system" systems (systemName: system: haskell-nix.haskellLib.selectProjectPackages staticPackages.hs; # The top-level set of attributes to build on ci. - finalPackages = rec { + finalPackages = { # Expose select packages to increase signal-to-noise of the ci dashboard. - inherit (staticPackages) urbit urbit-tests tarball; + inherit (staticPackages) urbit urbit-tests; # Expose the nix-shell derivation as a sanity check + possible cache hit. shell = import ./shell.nix; @@ -93,7 +93,8 @@ in localLib.dimension "system" systems (systemName: system: hs = localLib.collectHaskellComponents haskellPackages; # Push the tarball to the google storage bucket for the current platform. - release = pushObject { + release = let inherit (staticPackages) tarball; + in pushObject { name = tarball.name; drv = tarball; extension = tarball.meta.extension; From 00d236501e49dc510c919a6693ff1a6020fbfed8 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Wed, 4 Nov 2020 11:48:46 +0100 Subject: [PATCH 572/933] build: fix bind errors in darwin sandboxes See https://github.com/NixOS/nix/blob/5f6840fbb49ae5b534423bd8a4360646ee93dbaf/src/libstore/build.cc#L2961 --- nix/lib/test-fake-ship.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nix/lib/test-fake-ship.nix b/nix/lib/test-fake-ship.nix index caed88c733..f8db793f3d 100644 --- a/nix/lib/test-fake-ship.nix +++ b/nix/lib/test-fake-ship.nix @@ -160,4 +160,8 @@ stdenvNoCC.mkDerivation { exit "$fail" ''; + + # Fix 'bind: operation not permitted' when nix.useSandbox = true on darwin. + # See https://github.com/NixOS/nix/blob/5f6840fbb49ae5b534423bd8a4360646ee93dbaf/src/libstore/build.cc#L2961 + __darwinAllowLocalNetworking = true; } From 17592b5cfc01fa0551078fa8a52596bfb3eb7872 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Wed, 4 Nov 2020 11:50:50 +0100 Subject: [PATCH 573/933] build: expose the shared object test variant This sidesteps having to build static python and other life problems, rather than confronting our demons. --- ci.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci.nix b/ci.nix index cbe4965bf7..f6ea1ce1f1 100644 --- a/ci.nix +++ b/ci.nix @@ -75,7 +75,8 @@ in localLib.dimension "system" systems (systemName: system: # The top-level set of attributes to build on ci. finalPackages = { # Expose select packages to increase signal-to-noise of the ci dashboard. - inherit (staticPackages) urbit urbit-tests; + inherit (staticPackages) urbit; + inherit (dynamicPackages) urbit-tests; # Expose the nix-shell derivation as a sanity check + possible cache hit. shell = import ./shell.nix; From eae7406157f572a533ccc24e2e93fc374b67add6 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Wed, 4 Nov 2020 12:36:40 +0100 Subject: [PATCH 574/933] build: group pills under shared attribute name --- ci.nix | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ci.nix b/ci.nix index f6ea1ce1f1..3677fd7597 100644 --- a/ci.nix +++ b/ci.nix @@ -13,7 +13,8 @@ let - inherit (import ./nix/default.nix { }) lib haskell-nix callPackage; + inherit (import ./nix/default.nix { }) + lib haskell-nix recurseIntoAttrs callPackage; # Local library import from derivation functions such as fetchGitHubLFS, etc. # upon which local package defintions are dependent. @@ -104,12 +105,14 @@ in localLib.dimension "system" systems (systemName: system: # Top-level pill attributes build and push-to-storage - only on linux. } // lib.optionalAttrs (system == "x86_64-linux") { - ivory = pushPill "ivory" dynamicPackages.ivory; - brass = pushPill "brass" dynamicPackages.brass; - solid = pushPill "solid" dynamicPackages.solid; + pill = recurseIntoAttrs { + ivory = pushPill "ivory" dynamicPackages.ivory; + brass = pushPill "brass" dynamicPackages.brass; + solid = pushPill "solid" dynamicPackages.solid; - ivory-ropsten = pushPill "ivory-ropsten" dynamicPackages.ivory-ropsten; - brass-ropsten = pushPill "brass-ropsten" dynamicPackages.brass-ropsten; + ivory-ropsten = pushPill "ivory-ropsten" dynamicPackages.ivory-ropsten; + brass-ropsten = pushPill "brass-ropsten" dynamicPackages.brass-ropsten; + }; }; # Filter derivations that have meta.platform missing the current system, From 684005e20079a46ac9283df6ebb2ec21db62e6c4 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Wed, 4 Nov 2020 12:45:40 +0100 Subject: [PATCH 575/933] build: disable full test-suite on darwin Linux remains enabled. This prevents CI errors while figuring out darwinAllowLocalNetworking and sandboxing. --- nix/lib/test-fake-ship.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nix/lib/test-fake-ship.nix b/nix/lib/test-fake-ship.nix index f8db793f3d..0c83f57d3f 100644 --- a/nix/lib/test-fake-ship.nix +++ b/nix/lib/test-fake-ship.nix @@ -3,8 +3,6 @@ { urbit, herb, arvo ? null, pill, ship ? "bus", doCheck ? true }: stdenvNoCC.mkDerivation { - inherit doCheck; - name = "test-${ship}"; src = bootFakeShip { inherit urbit herb arvo pill ship; }; phases = [ "unpackPhase" "buildPhase" "checkPhase" ]; @@ -161,7 +159,13 @@ stdenvNoCC.mkDerivation { exit "$fail" ''; + inherit doCheck; + # Fix 'bind: operation not permitted' when nix.useSandbox = true on darwin. # See https://github.com/NixOS/nix/blob/5f6840fbb49ae5b534423bd8a4360646ee93dbaf/src/libstore/build.cc#L2961 __darwinAllowLocalNetworking = true; + + meta = { + systems = [ "x86_64-linux" ]; + }; } From 24c63cb078bdaaed12c2a4b44f98c0e43511d89d Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Wed, 4 Nov 2020 12:55:27 +0100 Subject: [PATCH 576/933] build: reformatting and triggering tests --- nix/lib/test-fake-ship.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nix/lib/test-fake-ship.nix b/nix/lib/test-fake-ship.nix index 0c83f57d3f..f0da7e4b9e 100644 --- a/nix/lib/test-fake-ship.nix +++ b/nix/lib/test-fake-ship.nix @@ -4,8 +4,11 @@ stdenvNoCC.mkDerivation { name = "test-${ship}"; + src = bootFakeShip { inherit urbit herb arvo pill ship; }; + phases = [ "unpackPhase" "buildPhase" "checkPhase" ]; + buildInputs = [ cacert urbit herb python3 ]; unpackPhase = '' @@ -166,6 +169,6 @@ stdenvNoCC.mkDerivation { __darwinAllowLocalNetworking = true; meta = { - systems = [ "x86_64-linux" ]; + platforms = [ "x86_64-linux" ]; }; } From 9e1f75da6462ec533061baac7397ec70ca8e3b5b Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Wed, 4 Nov 2020 15:34:03 +0100 Subject: [PATCH 577/933] build: simplify build tool selection for shell.nix --- nix/default.nix | 4 +- nix/lib/test-fake-ship.nix | 4 +- nix/overlays/native.nix | 6 ++ nix/pkgs/hs/default.nix | 152 +++++++++++++++++-------------------- shell.nix | 22 +++--- 5 files changed, 87 insertions(+), 101 deletions(-) diff --git a/nix/default.nix b/nix/default.nix index bef5c54a7b..1d7c87dda0 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -22,7 +22,7 @@ let }; }; - finalOverlays = [ + finalOverlays = haskellNix.overlays ++ [ # Add top-level .sources attribute for other overlays to access niv sources. (_final: _prev: { sources = finalSources; }) @@ -31,7 +31,7 @@ let # Specific overrides guarded by the host platform. (import ./overlays/musl.nix) - ] ++ haskellNix.overlays ++ overlays; + ] ++ overlays; pkgs = import finalSources.nixpkgs { inherit system crossSystem crossOverlays; diff --git a/nix/lib/test-fake-ship.nix b/nix/lib/test-fake-ship.nix index f0da7e4b9e..4e722210fe 100644 --- a/nix/lib/test-fake-ship.nix +++ b/nix/lib/test-fake-ship.nix @@ -168,7 +168,5 @@ stdenvNoCC.mkDerivation { # See https://github.com/NixOS/nix/blob/5f6840fbb49ae5b534423bd8a4360646ee93dbaf/src/libstore/build.cc#L2961 __darwinAllowLocalNetworking = true; - meta = { - platforms = [ "x86_64-linux" ]; - }; + meta = { platforms = [ "x86_64-linux" ]; }; } diff --git a/nix/overlays/native.nix b/nix/overlays/native.nix index 2ab55e3751..b385273f93 100644 --- a/nix/overlays/native.nix +++ b/nix/overlays/native.nix @@ -5,6 +5,12 @@ let optionalList = xs: if xs == null then [ ] else xs; in { + haskell-nix = prev.haskell-nix // { + toolPackageName = prev.haskell-nix.toolPackageName // { + shellcheck = "ShellCheck"; + }; + }; + h2o = prev.h2o.overrideAttrs (_attrs: { version = final.sources.h2o.rev; src = final.sources.h2o; diff --git a/nix/pkgs/hs/default.nix b/nix/pkgs/hs/default.nix index 62c78c59e7..26b55a6051 100644 --- a/nix/pkgs/hs/default.nix +++ b/nix/pkgs/hs/default.nix @@ -1,92 +1,78 @@ { lib, stdenv, darwin, haskell-nix, gmp, zlib, libffi, brass , enableStatic ? stdenv.hostPlatform.isStatic }: -let - +haskell-nix.stackProject { compiler-nix-name = "ghc884"; index-state = "2020-09-24T00:00:00Z"; - project = haskell-nix.stackProject { - inherit compiler-nix-name index-state; - - # This is incredibly difficult to get right, almost everything goes wrong. - # See: https://github.com/input-output-hk/haskell.nix/issues/496 - src = haskell-nix.haskellLib.cleanSourceWith { - # Otherwise this depends on the name in the parent directory, which - # reduces caching, and is particularly bad on Hercules. - # See: https://github.com/hercules-ci/support/issues/40 - name = "urbit-hs"; - src = ../../../pkg/hs; - }; - - modules = [{ - # This corresponds to the set of packages (boot libs) that ship with GHC. - # We declare them yere to ensure any dependency gets them from GHC itself - # rather than trying to re-install them into the package database. - nonReinstallablePkgs = [ - "Cabal" - "Win32" - "array" - "base" - "binary" - "bytestring" - "containers" - "deepseq" - "directory" - "filepath" - "ghc" - "ghc-boot" - "ghc-boot-th" - "ghc-compact" - "ghc-heap" - "ghc-prim" - "ghci" - "ghcjs-prim" - "ghcjs-th" - "haskeline" - "hpc" - "integer-gmp" - "integer-simple" - "mtl" - "parsec" - "pretty" - "process" - "rts" - "stm" - "template-haskell" - "terminfo" - "text" - "time" - "transformers" - "unix" - "xhtml" - ]; - - packages = { - urbit-king.components.exes.urbit-king.enableStatic = enableStatic; - urbit-king.components.exes.urbit-king.enableShared = !enableStatic; - - urbit-king.components.exes.urbit-king.configureFlags = - lib.optionals enableStatic [ - "--ghc-option=-optl=-L${gmp}/lib" - "--ghc-option=-optl=-L${libffi}/lib" - "--ghc-option=-optl=-L${zlib}/lib" - ] ++ lib.optionals (enableStatic && stdenv.isDarwin) - [ "--ghc-option=-optl=-L${darwin.libiconv}/lib" ]; - - urbit-king.components.tests.urbit-king-tests.testFlags = - [ "--brass-pill=${brass.lfs}" ]; - }; - }]; + # This is incredibly difficult to get right, almost everything goes wrong. + # See: https://github.com/input-output-hk/haskell.nix/issues/496 + src = haskell-nix.haskellLib.cleanSourceWith { + # Otherwise this depends on the name in the parent directory, which + # reduces caching, and is particularly bad on Hercules. + # See: https://github.com/hercules-ci/support/issues/40 + name = "urbit-hs"; + src = ../../../pkg/hs; }; -in project // { - # Build and obtain an executable from Hackage, using the same compiler - # and cabal index-state as the stackProject. - # - # This allows specifying the executable name, in contrast with shellFor.tools. - hackageTool = { name, version, exe ? lib.toLower name }: - (haskell-nix.hackage-package { - inherit compiler-nix-name index-state name version; - }).components.exes.${exe}; + modules = [{ + # This corresponds to the set of packages (boot libs) that ship with GHC. + # We declare them yere to ensure any dependency gets them from GHC itself + # rather than trying to re-install them into the package database. + nonReinstallablePkgs = [ + "Cabal" + "Win32" + "array" + "base" + "binary" + "bytestring" + "containers" + "deepseq" + "directory" + "filepath" + "ghc" + "ghc-boot" + "ghc-boot-th" + "ghc-compact" + "ghc-heap" + "ghc-prim" + "ghci" + "ghcjs-prim" + "ghcjs-th" + "haskeline" + "hpc" + "integer-gmp" + "integer-simple" + "mtl" + "parsec" + "pretty" + "process" + "rts" + "stm" + "template-haskell" + "terminfo" + "text" + "time" + "transformers" + "unix" + "xhtml" + ]; + + packages = { + urbit-king.components.exes.urbit-king.enableStatic = enableStatic; + urbit-king.components.exes.urbit-king.enableShared = !enableStatic; + + urbit-king.components.exes.urbit-king.configureFlags = + lib.optionals enableStatic [ + "--ghc-option=-optl=-L${gmp}/lib" + "--ghc-option=-optl=-L${libffi}/lib" + "--ghc-option=-optl=-L${zlib}/lib" + ] ++ lib.optionals (enableStatic && stdenv.isDarwin) + [ "--ghc-option=-optl=-L${darwin.libiconv}/lib" ]; + + urbit-king.components.tests.urbit-king-tests.testFlags = + [ "--brass-pill=${brass.lfs}" ]; + }; + }]; } + diff --git a/shell.nix b/shell.nix index 184b9d9f00..405e1ca93c 100644 --- a/shell.nix +++ b/shell.nix @@ -11,6 +11,7 @@ let pkgs = import ./nix/default.nix { }; + localPackages = import ./default.nix { }; # The non-Haskell packages which build inputs (dependencies) will be @@ -43,24 +44,19 @@ in localPackages.hs.shellFor { urbit-termsize ]; - # Build tools to make available in the shell's PATH. + # Haskell tools to make available on the shell's PATH. + tools = { + shellcheck = "0.7.1"; + ormolu = "0.1.3.0"; + }; + + # Nixpkgs tools to make available on the shell's PATH. buildInputs = [ pkgs.cacert - pkgs.stack pkgs.nixfmt pkgs.shfmt - + pkgs.stack (import pkgs.sources.niv { }).niv - - (localPackages.hs.hackageTool { - name = "ormolu"; - version = "0.1.3.0"; - }) - - (localPackages.hs.hackageTool { - name = "ShellCheck"; - version = "0.7.1"; - }) ] ++ merge "buildInputs"; nativeBuildInputs = merge "nativeBuildInputs"; From 8d0a65bb6e39dc924ac61771018818b17f35ce2a Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Wed, 4 Nov 2020 20:47:33 +0100 Subject: [PATCH 578/933] vere: remove dependency on nix-store path for static darwin binary Poached from @eglaysher's work in #3380. --- nix/pkgs/urbit/default.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nix/pkgs/urbit/default.nix b/nix/pkgs/urbit/default.nix index 4339953286..4ec03e0b76 100644 --- a/nix/pkgs/urbit/default.nix +++ b/nix/pkgs/urbit/default.nix @@ -54,6 +54,12 @@ in stdenv.mkDerivation { mkdir -p $out/bin cp ./build/urbit $out/bin/urbit cp ./build/urbit-worker $out/bin/urbit-worker + '' + lib.optionalString (stdenv.isDarwin && enableStatic) '' + # Hack stolen from //nixpkgs/pkgs/stdenv/darwin/portable-libsystem.sh + find "$out/bin" -exec \ + install_name_tool -change \ + ${stdenv.cc.libc}/lib/libSystem.B.dylib \ + /usr/lib/libSystem.B.dylib {} \; ''; CFLAGS = [ (if enableDebug then "-O0" else "-O3") "-g" ] From 573d47e6a78fe56ddd5a1f921ee8e038689a3e7e Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Wed, 4 Nov 2020 21:01:00 +0100 Subject: [PATCH 579/933] build: remove from-scratch ropsten pill builds on ci --- ci.nix | 3 --- 1 file changed, 3 deletions(-) diff --git a/ci.nix b/ci.nix index 3677fd7597..d52dfb079a 100644 --- a/ci.nix +++ b/ci.nix @@ -109,9 +109,6 @@ in localLib.dimension "system" systems (systemName: system: ivory = pushPill "ivory" dynamicPackages.ivory; brass = pushPill "brass" dynamicPackages.brass; solid = pushPill "solid" dynamicPackages.solid; - - ivory-ropsten = pushPill "ivory-ropsten" dynamicPackages.ivory-ropsten; - brass-ropsten = pushPill "brass-ropsten" dynamicPackages.brass-ropsten; }; }; From dd782e062eac3a91e5e70737d64231bdb98ef0fb Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Wed, 4 Nov 2020 19:57:24 +0100 Subject: [PATCH 580/933] vere: ensure debug symbols aren't stripped by default (by nix) --- nix/pkgs/urbit/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nix/pkgs/urbit/default.nix b/nix/pkgs/urbit/default.nix index 4ec03e0b76..5b54caf6b5 100644 --- a/nix/pkgs/urbit/default.nix +++ b/nix/pkgs/urbit/default.nix @@ -2,7 +2,7 @@ , ed25519, ent, ge-additions, gmp, h2o, herb, ivory, libaes_siv, libscrypt , libsigsegv, libuv, lmdb, murmur3, openssl, secp256k1, softfloat3, zlib , enableStatic ? stdenv.hostPlatform.isStatic, enableDebug ? false -, doCheck ? true, enableParallelBuilding ? true }: +, doCheck ? true, enableParallelBuilding ? true, dontStrip ? true }: let @@ -73,7 +73,7 @@ in stdenv.mkDerivation { # See https://github.com/NixOS/nixpkgs/issues/18995 hardeningDisable = lib.optionals enableDebug [ "all" ]; - inherit enableParallelBuilding doCheck; + inherit enableParallelBuilding doCheck dontStrip; meta = { debug = enableDebug; }; } From 644acd50024cc3a05c17113b0051be9390dcd55c Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Wed, 4 Nov 2020 20:15:50 +0100 Subject: [PATCH 581/933] build: ensure urbit tests are run with the -g argument --- nix/lib/boot-fake-ship.nix | 10 +++++++--- nix/lib/test-fake-ship.nix | 6 ++++-- nix/pkgs/urbit/default.nix | 5 ++++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/nix/lib/boot-fake-ship.nix b/nix/lib/boot-fake-ship.nix index 93adb27ebd..48917b63ee 100644 --- a/nix/lib/boot-fake-ship.nix +++ b/nix/lib/boot-fake-ship.nix @@ -1,4 +1,4 @@ -{ stdenvNoCC, cacert }: +{ lib, stdenvNoCC, cacert }: { urbit, herb, arvo ? null, pill, ship }: @@ -22,9 +22,13 @@ stdenvNoCC.mkDerivation { set -xeuo pipefail if [ -z "$ARVO" ]; then - urbit -d -F "$SHIP" -B "$PILL" ./pier + urbit ${ + lib.concatStringsSep " " urbit.meta.arguments + } -d -F "$SHIP" -B "$PILL" ./pier else - urbit -d -F "$SHIP" -A "$ARVO" -B "$PILL" ./pier + urbit ${ + lib.concatStringsSep " " urbit.meta.arguments + } -d -F "$SHIP" -A "$ARVO" -B "$PILL" ./pier fi cleanup () { diff --git a/nix/lib/test-fake-ship.nix b/nix/lib/test-fake-ship.nix index 4e722210fe..a82fc7bcaa 100644 --- a/nix/lib/test-fake-ship.nix +++ b/nix/lib/test-fake-ship.nix @@ -1,4 +1,4 @@ -{ stdenvNoCC, cacert, python3, bootFakeShip }: +{ lib, stdenvNoCC, cacert, python3, bootFakeShip }: { urbit, herb, arvo ? null, pill, ship ? "bus", doCheck ? true }: @@ -19,7 +19,9 @@ stdenvNoCC.mkDerivation { buildPhase = '' set -x - urbit -d ./pier 2> urbit-output + urbit ${ + lib.concatStringsSep " " urbit.meta.arguments + } -d ./pier 2> urbit-output # Sledge Hammer! # See: https://github.com/travis-ci/travis-ci/issues/4704#issuecomment-348435959 diff --git a/nix/pkgs/urbit/default.nix b/nix/pkgs/urbit/default.nix index 5b54caf6b5..d31579d991 100644 --- a/nix/pkgs/urbit/default.nix +++ b/nix/pkgs/urbit/default.nix @@ -75,5 +75,8 @@ in stdenv.mkDerivation { inherit enableParallelBuilding doCheck dontStrip; - meta = { debug = enableDebug; }; + meta = { + debug = enableDebug; + arguments = lib.optionals enableDebug [ "-g" ]; + }; } From 3a0b975f4d61965bb85cb5b3ec1baff039ecfa6b Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Thu, 5 Nov 2020 09:31:31 +0100 Subject: [PATCH 582/933] build: expose configurable arguments when booting/testing fake ships This also sets -l (lite boot) by default for boot-fake-ship to speed up the initial pier creation used by pills/tests, and uses urbit.meta.arguments by default for tests - seems a little less likely to footgun. --- nix/lib/boot-fake-ship.nix | 23 ++++++++--------------- nix/lib/test-fake-ship.nix | 7 +++---- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/nix/lib/boot-fake-ship.nix b/nix/lib/boot-fake-ship.nix index 48917b63ee..610f9f0e70 100644 --- a/nix/lib/boot-fake-ship.nix +++ b/nix/lib/boot-fake-ship.nix @@ -1,8 +1,13 @@ { lib, stdenvNoCC, cacert }: -{ urbit, herb, arvo ? null, pill, ship }: +{ urbit, herb, arvo ? null, pill, ship, arguments ? [ "-l" ] }: -stdenvNoCC.mkDerivation { +let + + args = arguments ++ [ "-d" "-F" "${ship}" "-B" "${pill}" ] + ++ lib.optionals (arvo != null) [ "-A" "${arvo}" ]; + +in stdenvNoCC.mkDerivation { name = "fake-${ship}"; buildInputs = [ cacert urbit herb ]; @@ -15,21 +20,9 @@ stdenvNoCC.mkDerivation { exit 1 fi - ARVO=${if arvo == null then "" else arvo} - PILL=${pill} - SHIP=${ship} - set -xeuo pipefail - if [ -z "$ARVO" ]; then - urbit ${ - lib.concatStringsSep " " urbit.meta.arguments - } -d -F "$SHIP" -B "$PILL" ./pier - else - urbit ${ - lib.concatStringsSep " " urbit.meta.arguments - } -d -F "$SHIP" -A "$ARVO" -B "$PILL" ./pier - fi + urbit ${lib.concatStringsSep " " args} ./pier cleanup () { if [ -f ./pier/.vere.lock ]; then diff --git a/nix/lib/test-fake-ship.nix b/nix/lib/test-fake-ship.nix index a82fc7bcaa..133c041b8d 100644 --- a/nix/lib/test-fake-ship.nix +++ b/nix/lib/test-fake-ship.nix @@ -1,6 +1,7 @@ { lib, stdenvNoCC, cacert, python3, bootFakeShip }: -{ urbit, herb, arvo ? null, pill, ship ? "bus", doCheck ? true }: +{ urbit, herb, arvo ? null, pill, ship ? "bus", arguments ? urbit.meta.arguments +, doCheck ? true }: stdenvNoCC.mkDerivation { name = "test-${ship}"; @@ -19,9 +20,7 @@ stdenvNoCC.mkDerivation { buildPhase = '' set -x - urbit ${ - lib.concatStringsSep " " urbit.meta.arguments - } -d ./pier 2> urbit-output + urbit ${lib.concatStringsSep " " arguments} -d ./pier 2> urbit-output # Sledge Hammer! # See: https://github.com/travis-ci/travis-ci/issues/4704#issuecomment-348435959 From ff3d7c15745398a50769d241602e0ed7470bb7d8 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Thu, 5 Nov 2020 10:02:36 +0100 Subject: [PATCH 583/933] arvo: run %lens when lite boot (-l) is specified --- pkg/arvo/lib/hood/drum.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/arvo/lib/hood/drum.hoon b/pkg/arvo/lib/hood/drum.hoon index a41c917a7c..0388ab894e 100644 --- a/pkg/arvo/lib/hood/drum.hoon +++ b/pkg/arvo/lib/hood/drum.hoon @@ -69,11 +69,11 @@ %azimuth-tracker %ping %goad + %lens == ?: lit ~ :~ %acme - %lens %clock %dojo %launch From 88e9d0eaec48250455851798f058c0576662abb5 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Thu, 5 Nov 2020 10:10:50 +0100 Subject: [PATCH 584/933] pill: rebuild solid pill with %lens included in lite boot apps --- bin/solid.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index e61e1df295..22c296b168 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:934fa478c4f586ca26e1e9cb878c5fbae9cd6307b960460f7a8998f87dd0029c -size 6330928 +oid sha256:f57a9431a104d1d26b379c6db37cc11d3747bf291d58399a6ce9cda9a3cb988d +size 6322424 From 8073de5cc9e31a98cfe40b8771a49fcc2b0c0b1c Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Thu, 5 Nov 2020 10:28:51 +0100 Subject: [PATCH 585/933] build: remove push-to-storage for ivory, brass, and solid pills --- ci.nix | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/ci.nix b/ci.nix index d52dfb079a..672bef9e99 100644 --- a/ci.nix +++ b/ci.nix @@ -102,16 +102,8 @@ in localLib.dimension "system" systems (systemName: system: extension = tarball.meta.extension; contentType = "application/x-gtar"; }; - - # Top-level pill attributes build and push-to-storage - only on linux. - } // lib.optionalAttrs (system == "x86_64-linux") { - pill = recurseIntoAttrs { - ivory = pushPill "ivory" dynamicPackages.ivory; - brass = pushPill "brass" dynamicPackages.brass; - solid = pushPill "solid" dynamicPackages.solid; - }; }; - + # Filter derivations that have meta.platform missing the current system, # such as testFakeShip on darwin. platformFilter = localLib.platformFilterGeneric system; From b1790b1b3a61f3d64bf8fe92828d67a8b9e38b2e Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Thu, 5 Nov 2020 12:07:24 +0100 Subject: [PATCH 586/933] build: adding support for hercules ci effects --- ci.nix | 33 ++--- nix/lib/default.nix | 5 +- nix/lib/effect/default.nix | 122 +++++++++++++++++++ nix/lib/effect/effects-setup-hook.sh | 173 +++++++++++++++++++++++++++ nix/lib/push-storage-object.nix | 52 ++------ 5 files changed, 325 insertions(+), 60 deletions(-) create mode 100644 nix/lib/effect/default.nix create mode 100644 nix/lib/effect/effects-setup-hook.sh diff --git a/ci.nix b/ci.nix index 672bef9e99..149c82ffb4 100644 --- a/ci.nix +++ b/ci.nix @@ -25,30 +25,24 @@ let serviceAccountKey = builtins.readFile ("/var/lib/hercules-ci-agent/secrets/service-account.json"); - # Push a split output derivation containing "out" and "hash" outputs. - pushObject = - { name, extension, drv, contentType ? "application/octet-stream" }: - let - # Use the sha256 for the object key prefix. - sha256 = builtins.readFile (drv.hash + "/sha256"); - # Use md5 as an idempotency check for gsutil. - contentMD5 = builtins.readFile (drv.hash + "/md5"); - in localLib.pushStorageObject { - inherit serviceAccountKey name contentMD5 contentType; + # Push a derivation to a remote storage bucket as a post-build effect. + pushObject = { name, drv, contentType ? "application/octet-stream" }: + localLib.pushStorageObject { + inherit name contentType serviceAccountKey; bucket = "bootstrap.urbit.org"; - object = "ci/${lib.removeSuffix extension name}${sha256}.${extension}"; + object = "ci/${lib.removePrefix "/nix/store/" (toString drv)}"; file = drv.out; }; - # Build and push a split output pill derivation with the ".pill" file extension. - pushPill = name: pill: - pushObject { - inherit name; + # # Build and push a split output pill derivation with the ".pill" file extension. + # pushPill = name: pill: + # pushObject { + # inherit name; - drv = pill.build; - extension = "pill"; - }; + # drv = pill.build; + # extension = "pill"; + # }; systems = lib.filterAttrs (_: v: builtins.elem v supportedSystems) { linux = "x86_64-linux"; @@ -99,11 +93,10 @@ in localLib.dimension "system" systems (systemName: system: in pushObject { name = tarball.name; drv = tarball; - extension = tarball.meta.extension; contentType = "application/x-gtar"; }; }; - + # Filter derivations that have meta.platform missing the current system, # such as testFakeShip on darwin. platformFilter = localLib.platformFilterGeneric system; diff --git a/nix/lib/default.nix b/nix/lib/default.nix index 2f82313e84..eff7aedfda 100644 --- a/nix/lib/default.nix +++ b/nix/lib/default.nix @@ -12,7 +12,10 @@ let makeReleaseTarball = callPackage ./make-release-tarball.nix { }; - pushStorageObject = callPackage ./push-storage-object.nix { }; + pushStorageObject = + callPackage ./push-storage-object.nix { inherit makeEffect; }; + + makeEffect = callPackage ./effect { }; }; in fetchers // rec { diff --git a/nix/lib/effect/default.nix b/nix/lib/effect/default.nix new file mode 100644 index 0000000000..c85a693cc6 --- /dev/null +++ b/nix/lib/effect/default.nix @@ -0,0 +1,122 @@ +{ cacert, curl, jq, lib, runCommandNoCC, stdenvNoCC }: + +let + + defaultInputs = [ effectSetupHook cacert curl jq ]; + + mkDrv = args: + stdenvNoCC.mkDerivation (args // { + + phases = args.phases or "initPhase unpackPhase patchPhase ${ + args.preGetStatePhases or "" + } getStatePhase userSetupPhase ${ + args.preEffectPhases or "" + } effectPhase putStatePhase ${args.postEffectPhases or ""}"; + + name = args.name + "-effect"; + + # nativeBuildInputs normally corresponds to what the building machine can + # execute. Likewise, effects are executed on the machine type that would + # otherwise perform the build. + # To keep things simple and avoid "build" terminology, we alias this as "inputs". + nativeBuildInputs = (args.defaultInputs or defaultInputs) + ++ (args.inputs or [ ]) ++ (args.nativeBuildInputs or [ ]); + + isEffect = true; + + # TODO: Use structured attrs instead + secretsMap = builtins.toJSON (args.secretsMap or { }); + + }); + + invokeOverride = f: defaults: (lib.makeOverridable f defaults).override; + + effectSetupHook = runCommandNoCC "hercules-ci-effect-sh" { } '' + mkdir -p $out/nix-support + cp ${./effects-setup-hook.sh} $out/nix-support/setup-hook + ''; + +in invokeOverride mkDrv { + + preGetStatePhases = ""; + preEffectPhases = "priorCheckPhase"; + + # Extension point for reporting notifications etc that are less criticial and + # don't write state. + postEffectPhases = "effectCheckPhase"; + + initPhase = '' + # eof on stdin + exec /etc/passwd root:x:0:0:System administrator:/build/home:/run/current-system/sw/bin/bash + mkdir -p ~/.ssh + echo "BatchMode yes" >>~/.ssh/config + ''; + + userSetupPhase = '' + runHook preUserSetup + eval "$userSetupScript" + runHook postUserSetup + ''; + userSetupScript = ""; + + # TODO Read a variable to optionally bail out if not already ok. That won't + # permit a commit to fix a problem, which is why that isn't the current + # behavior. + # This variable can also be set dynamically by priorCheckScript to signal + # that the problem is severe enough to abort the effect and thus require + # manual intervention. + priorCheckPhase = '' + runHook prePriorCheck + if [[ -n "$priorCheckScript" ]]; then + if eval "$priorCheckScript"; then + echo 1>&2 -e 'Prior check \e[32;1mOK\e[0m.' + else + echo 1>&2 + echo 1>&2 -e 'WARNING: Prior check \e[31;1mFAILED\e[0m!' + echo 1>&2 + echo 1>&2 Continuing execution to allow subsequent steps to hopefully fix the problem. + fi + fi + + runHook postPriorCheck + ''; + priorCheckScript = ""; + + effectPhase = '' + runHook preEffect + eval "$effectScript" + runHook postEffect + ''; + effectScript = ""; + + effectCheckPhase = '' + runHook preEffectCheck + eval "$effectCheckScript" + runHook postEffectCheck + ''; + + getStatePhase = '' + runHook preGetState + eval "$getStateScript" + runHook postGetState + registerPutStatePhaseOnFailure + ''; + putStatePhase = '' + if [[ -z ''${PUT_STATE_DONE:-} ]]; then + runHook prePutState + eval "$putStateScript" + runHook postPutState + PUT_STATE_DONE=true + else + echo 1>&2 "NOTE: State has already been uploaded and was not uploaded again." + fi + ''; +} diff --git a/nix/lib/effect/effects-setup-hook.sh b/nix/lib/effect/effects-setup-hook.sh new file mode 100644 index 0000000000..7e89ac64d7 --- /dev/null +++ b/nix/lib/effect/effects-setup-hook.sh @@ -0,0 +1,173 @@ +# ---------------------------------------------------------------------------- +# prepare headers file for curl to talk to Hercules CI + + +initHerculesCIAPI() { + herculesCIHeaders=$PWD/hercules-ci.headers + jq $herculesCIHeaders -r '"Authorization: Bearer \(."hercules-ci".token)"' +} +preInitHooks+=("initHerculesCIAPI") + + +# ---------------------------------------------------------------------------- +# state crud + +getStateFile() { + local stateName="$1" + local stateFileName="${2:-$1}" + echo 1>&2 "fetching state file $stateName" + while true; do + http_code=$(curl \ + -H @$herculesCIHeaders \ + --retry-max-time 86400 --retry-connrefused --max-time 1800 \ + --silent --show-error \ + --location \ + "$HERCULES_CI_API_BASE_URL/api/v1/current-task/state/$stateName/data" \ + -o "$stateFileName" \ + -w '%{http_code}' + ); + case $http_code in + 200|204) + go_curl="false"; + break ;; + 408|421|429|5*) + echo 1>&2 "http status $http_code. Retrying..." + sleep 60 + continue ;; + 404) + echo 1>&2 "state file does not exist." + rm -f "$stateFileName" + break ;; + *) + echo 1>&2 "request failed with fatal status $http_code" + exit 1 ;; + esac + done +} + +putStateFile() { + local stateName="$1" + local stateFileName="${2:-$1}" + echo "pushing state file $stateName..." + curl \ + -H @$herculesCIHeaders \ + --retry-max-time 86400 --retry-connrefused --max-time 1800 \ + --silent --show-error \ + --location --fail \ + -XPUT \ + --upload-file "$stateFileName" \ + "$HERCULES_CI_API_BASE_URL/api/v1/current-task/state/$stateName/data" \ + ; + echo "pushing state successful." +} + + +# ---------------------------------------------------------------------------- +# uploading state on error too + +putStatePhaseOnFailure() { + if [[ -n $putStatePhase ]]; then + echo 'uploading state files after failure' 1>&2 + eval "$putStatePhase" + fi +} + +registerPutStatePhaseOnFailure() { + failureHooks=("putStatePhaseOnFailure" "${failureHooks[@]}") +} + +# ---------------------------------------------------------------------------- +# unpack fix + + +simpleCopyUnpack() { + local fn="$1" + cp --no-preserve=ownership --recursive --reflink=auto \ + -- $fn "$(stripHash "$fn")" \ + ; +} + +unpackCmdHooks+=(simpleCopyUnpack) + + +# ---------------------------------------------------------------------------- +# warn if run in wrong environment + + +if [[ "true" != ${IN_HERCULES_CI_EFFECT:-} ]]; then + + if [[ -n ${NIX_LOG_FD:-} ]]; then + cat 1>&2 <&2 <&2 "Could not find path $dataPath in secret $secretName" + fi +} + +readSecretJSON() { + local secretName="$1" + local dataPath="$2" + jq -c >~/.aws/credentials <"$privateName" + chmod 0400 "$privateName" + ssh-keygen -y -f "$privateName" >"$privateName.pub" +} + +writeDockerKey() { + local secretName="${1:-docker}" + local directory="${2:-$HOME/.docker}" + + mkdir -p $directory + + readSecretString "$secretName" .clientKey >"$directory/key.pem" + readSecretString "$secretName" .clientCertificate >"$directory/cert.pem" + readSecretString "$secretName" .CACertificate >"$directory/ca.pem" + + # Please permission checks if any + chmod 0400 "$directory"/{key,cert,ca}.pem +} +useDockerHost() { + local host="${1}" + local port="${2:-2376}" + export DOCKER_HOST=tcp://$host:$port + export DOCKER_TLS_VERIFY=1 +} diff --git a/nix/lib/push-storage-object.nix b/nix/lib/push-storage-object.nix index 23ca36d72b..7354cad081 100644 --- a/nix/lib/push-storage-object.nix +++ b/nix/lib/push-storage-object.nix @@ -1,12 +1,6 @@ -{ lib, stdenvNoCC, coreutils, google-cloud-sdk, xxd }: +{ lib, makeEffect, google-cloud-sdk }: -# Somewhat annoyingly due to needing to use Google Storage's Content-MD5 -# to ensure a fixed output derivation - we need an md5sum of the file to -# upload. This is in additional to any sha256sum you might want to actually -# name the object key under. - -{ bucket, object, name, file, contentMD5, contentType, serviceAccountKey -, preferLocalBuild ? true }: +{ bucket, object, name, file, contentType, serviceAccountKey }: assert lib.asserts.assertMsg (builtins.isString serviceAccountKey) "`serviceAccountKey` must contain the JSON contents of a service-account key"; @@ -15,53 +9,33 @@ let uri = "gs://${bucket}/${lib.removePrefix "/" object}"; -in stdenvNoCC.mkDerivation { - name = "push-${lib.strings.sanitizeDerivationName name}"; +in makeEffect { + inherit file uri contentType serviceAccountKey; - nativeBuildInputs = [ coreutils google-cloud-sdk xxd ]; + name = "push-${name}"; - phases = [ "installPhase" ]; + inputs = [ google-cloud-sdk ]; - installPhase = '' - set -euo pipefail + dontUnpack = true; + effectScript = '' export HOME="." - gcloud auth activate-service-account --key-file=- <<< '${serviceAccountKey}' + gcloud auth activate-service-account --key-file=- <<< $serviceAccountKey - local_md5=$(echo -n '${contentMD5}' | xxd -r -p | base64) - remote_md5= - stat_uri() { - header "retrieving md5 for ${uri}" - - remote_md5=$(gsutil stat '${uri}' \ - | sed -n -e '/Hash (md5):/{s/.*: *//p}' \ - | base64 -d \ - | xxd -p) + gsutil stat $uri } if ! stat_uri; then - header "copying ${file} to ${uri}" + header "copying $file to $uri" - gsutil -h "Content-MD5:$local_md5" \ - -h "Content-Type:${contentType}" \ - cp '${file}' '${uri}' + gsutil -h "Content-Type:$contentType" cp $file $uri if ! stat_uri; then - echo "failed calculating remote uri md5" >&2 + echo "failed pushing $file to $url" >&2 exit 1 fi fi - - # This is the same format as md5sum (double space separator) and - # needs to match the .outputHash to ensure a fixed output derivation. - echo -n "$remote_md5 ${uri}" > $out ''; - - outputHashAlgo = "sha256"; - outputHashMode = "flat"; - outputHash = builtins.hashString "sha256" "${contentMD5} ${uri}"; - - inherit preferLocalBuild; } From 244a9b6a0616a738e1677f3ab30cfbc0a9e56ff2 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Thu, 5 Nov 2020 12:57:18 +0100 Subject: [PATCH 587/933] build: force google-cloud-sdk to use python3 This prevents an error where the python2 version of the SDK tries to use the monotonic library which is unable to detect the host operating system inside the sandbox - exploding in typical python fashion. By using python3 it obviates the need for the monotonic dependency by using the builtin time.monotonic call. --- nix/lib/push-storage-object.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nix/lib/push-storage-object.nix b/nix/lib/push-storage-object.nix index 7354cad081..5e161092df 100644 --- a/nix/lib/push-storage-object.nix +++ b/nix/lib/push-storage-object.nix @@ -1,4 +1,4 @@ -{ lib, makeEffect, google-cloud-sdk }: +{ lib, makeEffect, python3, google-cloud-sdk }: { bucket, object, name, file, contentType, serviceAccountKey }: @@ -14,7 +14,7 @@ in makeEffect { name = "push-${name}"; - inputs = [ google-cloud-sdk ]; + inputs = [ (google-cloud-sdk.override { python = python3; }) ]; dontUnpack = true; From e9cf0a3518227094343c5d9f714f953d1a2958e4 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Thu, 5 Nov 2020 13:01:27 +0100 Subject: [PATCH 588/933] build: add log message when destination object already exists --- nix/lib/push-storage-object.nix | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/nix/lib/push-storage-object.nix b/nix/lib/push-storage-object.nix index 5e161092df..427f50917c 100644 --- a/nix/lib/push-storage-object.nix +++ b/nix/lib/push-storage-object.nix @@ -28,14 +28,16 @@ in makeEffect { } if ! stat_uri; then - header "copying $file to $uri" + header "copying $file to $uri" - gsutil -h "Content-Type:$contentType" cp $file $uri + gsutil -h "Content-Type:$contentType" cp $file $uri - if ! stat_uri; then - echo "failed pushing $file to $url" >&2 - exit 1 - fi + if ! stat_uri; then + header "failed pushing $file to $url" + exit 1 + fi + else + header "$uri already exists, skipping" fi ''; } From 767a6f85a4c899b71b2a31d5b19f7fc3b333e420 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Thu, 5 Nov 2020 13:19:09 +0100 Subject: [PATCH 589/933] build: remove {sha256,md5} output for push-storage-object effects --- ci.nix | 32 ++++++++++---------------------- nix/lib/make-release-tarball.nix | 12 +----------- nix/pkgs/pill/builder.nix | 7 ------- 3 files changed, 11 insertions(+), 40 deletions(-) diff --git a/ci.nix b/ci.nix index 149c82ffb4..347fe8a80d 100644 --- a/ci.nix +++ b/ci.nix @@ -21,34 +21,18 @@ let localLib = callPackage ./nix/lib { }; # The key with google storage bucket write permission, - # deployed to ci via nixops `deployment.keys."service-account.json"`. + # deployed to ci via nixops deployment.keys."service-account.json". serviceAccountKey = builtins.readFile ("/var/lib/hercules-ci-agent/secrets/service-account.json"); - # Push a derivation to a remote storage bucket as a post-build effect. - pushObject = { name, drv, contentType ? "application/octet-stream" }: - localLib.pushStorageObject { - inherit name contentType serviceAccountKey; - - bucket = "bootstrap.urbit.org"; - object = "ci/${lib.removePrefix "/nix/store/" (toString drv)}"; - file = drv.out; - }; - - # # Build and push a split output pill derivation with the ".pill" file extension. - # pushPill = name: pill: - # pushObject { - # inherit name; - - # drv = pill.build; - # extension = "pill"; - # }; - + # Filter out systems that this machine does not support. systems = lib.filterAttrs (_: v: builtins.elem v supportedSystems) { linux = "x86_64-linux"; darwin = "x86_64-darwin"; }; + # Build the ci matrix for each of the supported systems, see finalPackages + # for the total set of attributes that will be evaluated per system. in localLib.dimension "system" systems (systemName: system: let dynamicPackages = import ./default.nix { @@ -90,9 +74,13 @@ in localLib.dimension "system" systems (systemName: system: # Push the tarball to the google storage bucket for the current platform. release = let inherit (staticPackages) tarball; - in pushObject { + in localLib.pushStorageObject { + inherit serviceAccountKey; + + bucket = "bootstrap.urbit.org"; + object = "ci/${lib.removePrefix "/nix/store/" (toString tarball)}"; name = tarball.name; - drv = tarball; + file = tarball.out; contentType = "application/x-gtar"; }; }; diff --git a/nix/lib/make-release-tarball.nix b/nix/lib/make-release-tarball.nix index a374568961..48ba1865d7 100644 --- a/nix/lib/make-release-tarball.nix +++ b/nix/lib/make-release-tarball.nix @@ -13,10 +13,9 @@ let in stdenvNoCC.mkDerivation { name = "${name}.${extension}"; + phases = [ "buildPhase" ]; - outputs = [ "out" "hash" ]; nativeBuildInputs = [ coreutils ]; - phases = [ "buildPhase" "hashPhase" ]; buildPhase = '' tar -vczf $out \ @@ -27,14 +26,5 @@ in stdenvNoCC.mkDerivation { ${sources} ''; - hashPhase = '' - mkdir $hash - - md5sum $out | awk '{printf $1}' > $hash/md5 - sha256sum $out | awk '{printf $1}' > $hash/sha256 - ''; - preferLocalBuild = true; - - meta = { inherit extension; }; } diff --git a/nix/pkgs/pill/builder.nix b/nix/pkgs/pill/builder.nix index dc9a67afb6..f97d0f81e9 100644 --- a/nix/pkgs/pill/builder.nix +++ b/nix/pkgs/pill/builder.nix @@ -3,20 +3,13 @@ stdenvNoCC.mkDerivation { name = "${name}.pill"; src = pier; - outputs = [ "out" "hash" ]; buildInputs = [ urbit herb ]; - dontUnpack = true; buildPhase = builtins.readFile builder; installPhase = '' mv ${name}.pill $out - - mkdir $hash - - md5sum $out | awk '{printf $1}' > $hash/md5 - sha256sum $out | awk '{printf $1}' > $hash/sha256 ''; ARVO = arvo; From 3915047d735ef97708881bdb4bb235c49ba1a321 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 5 Nov 2020 18:02:13 -0800 Subject: [PATCH 590/933] u3: refactors fatal exception handling in u3m_bail() --- pkg/urbit/noun/manage.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/pkg/urbit/noun/manage.c b/pkg/urbit/noun/manage.c index 9105f07e51..96272fb4a9 100644 --- a/pkg/urbit/noun/manage.c +++ b/pkg/urbit/noun/manage.c @@ -651,30 +651,15 @@ u3m_bail(u3_noun how) } } + // intercept fatal errors + // switch ( how ) { - case c3__fail: { - break; - } - - case c3__meme: { + case c3__foul: + case c3__meme: + case c3__oops: { fprintf(stderr, "bailing out\r\n"); abort(); } - case c3__exit: { - - static c3_w xuc_w = 0; - - { - // u3l_log("exit %d\r\n", xuc_w); - // if ( 49 == xuc_w ) { abort(); } - xuc_w++; - break; - } - } - case c3__foul: - case c3__oops: - fprintf(stderr, "bailing out\r\n"); - assert(0); } if ( &(u3H->rod_u) == u3R ) { From 46b19538b10e512ba894fe516d7af2dd004ffe45 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 5 Nov 2020 18:09:37 -0800 Subject: [PATCH 591/933] u3: removes obsolete bail:need assertion --- pkg/urbit/noun/manage.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/pkg/urbit/noun/manage.c b/pkg/urbit/noun/manage.c index 96272fb4a9..febc3d373b 100644 --- a/pkg/urbit/noun/manage.c +++ b/pkg/urbit/noun/manage.c @@ -612,7 +612,6 @@ c3_w Exit; ** %intr :: interrupt ** %fail :: computability failure ** %over :: stack overflow (a kind of %fail) -** %need :: namespace block ** %meme :: out of memory ** ** These are equivalents of the full exception noun, the error ball: @@ -673,21 +672,15 @@ u3m_bail(u3_noun how) /* Reconstruct a correct error ball. */ - { - if ( _(u3ud(how)) ) { - switch ( how ) { - case c3__exit: { - how = u3nc(2, u3R->bug.tax); - break; - } - case c3__need: { - c3_assert(0); - } - default: { - how = u3nt(3, how, u3R->bug.tax); - break; - } - } + if ( _(u3ud(how)) ) { + switch ( how ) { + case c3__exit: { + how = u3nc(2, u3R->bug.tax); + } break; + + default: { + how = u3nt(3, how, u3R->bug.tax); + } break; } } From 7b42ae75fc787a220e18fc7b593a8d3ede36b2cd Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 5 Nov 2020 18:09:55 -0800 Subject: [PATCH 592/933] u3: removes unused `Exit` variable --- pkg/urbit/noun/manage.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/urbit/noun/manage.c b/pkg/urbit/noun/manage.c index febc3d373b..383304c2fa 100644 --- a/pkg/urbit/noun/manage.c +++ b/pkg/urbit/noun/manage.c @@ -600,8 +600,6 @@ u3m_dump(void) } #endif -c3_w Exit; - /* u3m_bail(): bail out. Does not return. ** ** Bail motes: From 464351abc2fd4fc86852da1958ba068deb260f8f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 6 Oct 2020 23:08:30 -0700 Subject: [PATCH 593/933] u3: fixes incorrect double ref-counting in |ff jets --- pkg/urbit/jets/e/fl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/jets/e/fl.c b/pkg/urbit/jets/e/fl.c index 45deff06a2..5b759dd278 100644 --- a/pkg/urbit/jets/e/fl.c +++ b/pkg/urbit/jets/e/fl.c @@ -118,7 +118,7 @@ u3_atom b = _mp_to_satom(a->e); u3_atom c = u3i_mp(a->a); - return u3i_cell(u3k(b), u3k(c)); + return u3nc(b, c); } static void @@ -317,7 +317,7 @@ mpz_set_ui(c.e, 0); } } - u3_noun ret = u3nq(c3__f, c3y, u3k(_mp_to_satom(c.e)), u3k(u3i_mp(c.a))); + u3_noun ret = u3nq(c3__f, c3y, _mp_to_satom(c.e), u3i_mp(c.a)); mpz_clear(d.minExp); mpz_clear(d.expWidth); return ret; } From 983261a3d8c74a9fb295e9b2449a38e8033db6d1 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Fri, 6 Nov 2020 09:47:11 +0100 Subject: [PATCH 594/933] build: move darwin install_name_tool fixup from vere to king haskell As well as some variable naming consistency to appease the nixpkgs gremlins and keep the git history lords on their toes. --- ci.nix | 29 +++++++++++----------- default.nix | 49 ++++++++++++++++++++------------------ nix/lib/default.nix | 2 ++ nix/pkgs/hs/default.nix | 19 +++++++++++---- nix/pkgs/urbit/default.nix | 6 ----- 5 files changed, 56 insertions(+), 49 deletions(-) diff --git a/ci.nix b/ci.nix index 347fe8a80d..991efdd300 100644 --- a/ci.nix +++ b/ci.nix @@ -18,7 +18,7 @@ let # Local library import from derivation functions such as fetchGitHubLFS, etc. # upon which local package defintions are dependent. - localLib = callPackage ./nix/lib { }; + libLocal = callPackage ./nix/lib { }; # The key with google storage bucket write permission, # deployed to ci via nixops deployment.keys."service-account.json". @@ -31,31 +31,30 @@ let darwin = "x86_64-darwin"; }; - # Build the ci matrix for each of the supported systems, see finalPackages + # Build the ci matrix for each of the supported systems, see pkgsFinal # for the total set of attributes that will be evaluated per system. -in localLib.dimension "system" systems (systemName: system: +in libLocal.dimension "system" systems (systemName: system: let - dynamicPackages = import ./default.nix { + pkgsShared = import ./default.nix { inherit system; enableStatic = false; }; - staticPackages = import ./default.nix { + pkgsStatic = import ./default.nix { inherit system; enableStatic = true; }; # Filter the stack project to only our locally declared packages. - haskellPackages = - haskell-nix.haskellLib.selectProjectPackages staticPackages.hs; + pkgsHaskell = haskell-nix.haskellLib.selectProjectPackages pkgsStatic.hs; # The top-level set of attributes to build on ci. - finalPackages = { + pkgsFinal = { # Expose select packages to increase signal-to-noise of the ci dashboard. - inherit (staticPackages) urbit; - inherit (dynamicPackages) urbit-tests; + inherit (pkgsStatic) urbit; + inherit (pkgsShared) urbit-tests; # Expose the nix-shell derivation as a sanity check + possible cache hit. shell = import ./shell.nix; @@ -70,11 +69,11 @@ in localLib.dimension "system" systems (systemName: system: # ... # # Note that .checks are the actual _execution_ of the tests. - hs = localLib.collectHaskellComponents haskellPackages; + hs = libLocal.collectHaskellComponents pkgsHaskell; # Push the tarball to the google storage bucket for the current platform. - release = let inherit (staticPackages) tarball; - in localLib.pushStorageObject { + release = let inherit (pkgsStatic) tarball; + in libLocal.pushStorageObject { inherit serviceAccountKey; bucket = "bootstrap.urbit.org"; @@ -87,6 +86,6 @@ in localLib.dimension "system" systems (systemName: system: # Filter derivations that have meta.platform missing the current system, # such as testFakeShip on darwin. - platformFilter = localLib.platformFilterGeneric system; + platformFilter = libLocal.platformFilterGeneric system; - in localLib.filterAttrsOnlyRecursive (_: v: platformFilter v) finalPackages) + in libLocal.filterAttrsOnlyRecursive (_: v: platformFilter v) pkgsFinal) diff --git a/default.nix b/default.nix index 19907da9db..6b8c96c835 100644 --- a/default.nix +++ b/default.nix @@ -6,7 +6,7 @@ Static urbit and urbit-worker binaries: - $ nix-build -A urbit --arg enableSatic true + $ nix-build -A urbit --arg enableStatic true Note that on linux the previous command is equivalent to: @@ -56,32 +56,35 @@ let - pkgs = import ./nix/default.nix { + pkgsNative = import ./nix/default.nix { inherit system; }; + + pkgsCross = import ./nix/default.nix { inherit system sources config overlays crossOverlays; + # If we're running on linux and crossSystem is unspecified but + # enableStatic = true - set the crossSystem to musl64. crossSystem = - # If we're running on linux and crossSystem is unspecified but static - # builds are requested - set the crossSystem to musl64. if system == "x86_64-linux" && crossSystem == null && enableStatic then "x86_64-unknown-linux-musl" else crossSystem; }; - # Local library import from derivation functions such as fetchGitHubLFS, etc. - # upon which local package defintions are dependent. - localLib = pkgs.callPackage ./nix/lib { }; - - # Utilise nixpkgs's top-level/static.nix overlay if required. - hostPackages = if enableStatic then pkgs.pkgsStatic else pkgs; + # Use nixpkgs' top-level/static overlay if enableStatic = true. + pkgsStatic = if enableStatic then pkgsCross.pkgsStatic else pkgsCross; # Enrich the global package set with our local functions and packages. + # Cross vs static build dependencies can be selectively overridden for + # inputs like python and haskell-nix callPackage = - pkgs.lib.callPackageWith (hostPackages // localLib // localPackages); + pkgsNative.lib.callPackageWith (pkgsStatic // libLocal // pkgsLocal); + + # Local library import-from-derivation functions such as fetchGitHubLFS, etc. + libLocal = pkgsNative.callPackage ./nix/lib { }; # Local vendored packages defined in ./pkg. # For non-vendored nixpkgs specific package overrides, see ./nix/overlays. - localPackages = { + pkgsLocal = { argon2u = callPackage ./nix/pkgs/argon2u { }; ca-bundle = callPackage ./nix/pkgs/ca-bundle { }; @@ -100,7 +103,7 @@ let softfloat3 = callPackage ./nix/pkgs/softfloat3 { }; - herb = callPackage ./nix/pkgs/herb { inherit (pkgs) python; }; + herb = callPackage ./nix/pkgs/herb { inherit (pkgsCross) python; }; arvo = callPackage ./nix/pkgs/arvo { }; @@ -113,18 +116,18 @@ let urbit = callPackage ./nix/pkgs/urbit { inherit enableStatic; }; hs = callPackage ./nix/pkgs/hs { - inherit (pkgs) haskell-nix; inherit enableStatic; + inherit (pkgsCross) haskell-nix; }; }; # Additional top-level packages and attributes exposed for convenience. - extraPackages = with localPackages; rec { - # Expose packages we've local customisations for. - inherit (hostPackages) libsigsegv; + pkgsExtra = with pkgsLocal; rec { + # Expose packages we've local customisations (like patches) for easy access. + inherit (pkgsCross) libsigsegv; urbit-debug = urbit.override { enableDebug = true; }; - urbit-tests = localLib.testFakeShip { + urbit-tests = libLocal.testFakeShip { inherit herb; urbit = urbit-debug; @@ -140,7 +143,7 @@ let tarball = let name = "urbit-v${urbit.version}-${urbit.system}"; urbit-king = hs.urbit-king.components.exes.urbit-king; - in localLib.makeReleaseTarball { + in libLocal.makeReleaseTarball { inherit name; contents = { @@ -167,16 +170,16 @@ let # shellFor = { name, packages, ... }@attrs: pkgs.mkShell ({ - inputsFrom = packages localPackages; + inputsFrom = packages pkgsLocal; } // builtins.removeAttrs attrs [ "packages" ]); }; # Ensure that in the case of cross-compilation we're not statically linking # against glibc. This is typically a sign that crossSystem is misconfigured. checkPlatform = - if enableStatic && hostPackages.stdenv.hostPlatform.libc == "glibc" then + if enableStatic && pkgsCross.stdenv.hostPlatform.libc == "glibc" then builtins.trace "warning: statically linking against glibc." else - pkgs.lib.id; + pkgsNative.lib.id; -in checkPlatform (localPackages // extraPackages) +in checkPlatform (pkgsLocal // pkgsExtra) diff --git a/nix/lib/default.nix b/nix/lib/default.nix index eff7aedfda..72e083a693 100644 --- a/nix/lib/default.nix +++ b/nix/lib/default.nix @@ -1,3 +1,5 @@ +# Functions that are expected run on the native (non-cross) system. + { lib, recurseIntoAttrs, haskell-nix, callPackage }: let diff --git a/nix/pkgs/hs/default.nix b/nix/pkgs/hs/default.nix index 26b55a6051..91a2102e5c 100644 --- a/nix/pkgs/hs/default.nix +++ b/nix/pkgs/hs/default.nix @@ -58,17 +58,26 @@ haskell-nix.stackProject { "xhtml" ]; + # Override various project-local flags and build configuration. packages = { - urbit-king.components.exes.urbit-king.enableStatic = enableStatic; - urbit-king.components.exes.urbit-king.enableShared = !enableStatic; + urbit-king.components.exes.urbit-king = { + enableStatic = enableStatic; + enableShared = !enableStatic; - urbit-king.components.exes.urbit-king.configureFlags = - lib.optionals enableStatic [ + configureFlags = lib.optionals enableStatic [ "--ghc-option=-optl=-L${gmp}/lib" "--ghc-option=-optl=-L${libffi}/lib" "--ghc-option=-optl=-L${zlib}/lib" ] ++ lib.optionals (enableStatic && stdenv.isDarwin) - [ "--ghc-option=-optl=-L${darwin.libiconv}/lib" ]; + [ "--ghc-option=-optl=-L${darwin.libiconv}/lib" ]; + + postInstall = lib.optionalString (enableStatic && stdenv.isDarwin) '' + find "$out/bin" -type f -exec \ + install_name_tool -change \ + ${stdenv.cc.libc}/lib/libSystem.B.dylib \ + /usr/lib/libSystem.B.dylib {} \; + ''; + }; urbit-king.components.tests.urbit-king-tests.testFlags = [ "--brass-pill=${brass.lfs}" ]; diff --git a/nix/pkgs/urbit/default.nix b/nix/pkgs/urbit/default.nix index d31579d991..c925439645 100644 --- a/nix/pkgs/urbit/default.nix +++ b/nix/pkgs/urbit/default.nix @@ -54,12 +54,6 @@ in stdenv.mkDerivation { mkdir -p $out/bin cp ./build/urbit $out/bin/urbit cp ./build/urbit-worker $out/bin/urbit-worker - '' + lib.optionalString (stdenv.isDarwin && enableStatic) '' - # Hack stolen from //nixpkgs/pkgs/stdenv/darwin/portable-libsystem.sh - find "$out/bin" -exec \ - install_name_tool -change \ - ${stdenv.cc.libc}/lib/libSystem.B.dylib \ - /usr/lib/libSystem.B.dylib {} \; ''; CFLAGS = [ (if enableDebug then "-O0" else "-O3") "-g" ] From b7d417a4b21a93964ca3aecc5b1086227369614d Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Fri, 6 Nov 2020 10:22:34 +0100 Subject: [PATCH 595/933] build: minor refactoring of haskell-nix overlays --- nix/default.nix | 31 +++++++++++++++++++++---------- nix/overlays/native.nix | 6 ------ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/nix/default.nix b/nix/default.nix index 1d7c87dda0..38611d9f7b 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -13,18 +13,29 @@ let - finalSources = import ./sources.nix { inherit pkgs; } // sources; + sourcesFinal = import ./sources.nix { inherit pkgs; } // sources; - haskellNix = import finalSources."haskell.nix" { + haskellNix = import sourcesFinal."haskell.nix" { sourcesOverride = { - hackage = finalSources."hackage.nix"; - stackage = finalSources."stackage.nix"; + hackage = sourcesFinal."hackage.nix"; + stackage = sourcesFinal."stackage.nix"; }; }; - finalOverlays = haskellNix.overlays ++ [ - # Add top-level .sources attribute for other overlays to access niv sources. - (_final: _prev: { sources = finalSources; }) + configFinal = haskellNix.config // config; + + overlaysFinal = haskellNix.overlays ++ [ + (_final: prev: { + # Add top-level .sources attribute for other overlays to access sources. + sources = sourcesFinal; + + # Additional non-convential package/exe mappings for shellFor.tools. + haskell-nix = prev.haskell-nix // { + toolPackageName = prev.haskell-nix.toolPackageName // { + shellcheck = "ShellCheck"; + }; + }; + }) # General unguarded (native) overrides for nixpkgs. (import ./overlays/native.nix) @@ -33,11 +44,11 @@ let (import ./overlays/musl.nix) ] ++ overlays; - pkgs = import finalSources.nixpkgs { + pkgs = import sourcesFinal.nixpkgs { inherit system crossSystem crossOverlays; - config = haskellNix.config // config; - overlays = finalOverlays; + config = configFinal; + overlays = overlaysFinal; }; in pkgs // { diff --git a/nix/overlays/native.nix b/nix/overlays/native.nix index b385273f93..2ab55e3751 100644 --- a/nix/overlays/native.nix +++ b/nix/overlays/native.nix @@ -5,12 +5,6 @@ let optionalList = xs: if xs == null then [ ] else xs; in { - haskell-nix = prev.haskell-nix // { - toolPackageName = prev.haskell-nix.toolPackageName // { - shellcheck = "ShellCheck"; - }; - }; - h2o = prev.h2o.overrideAttrs (_attrs: { version = final.sources.h2o.rev; src = final.sources.h2o; From 12e1a536336fc7e069b5b2661dd67552eacefb49 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Fri, 6 Nov 2020 10:47:49 +0100 Subject: [PATCH 596/933] build: silence service account activation output --- nix/lib/push-storage-object.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nix/lib/push-storage-object.nix b/nix/lib/push-storage-object.nix index 427f50917c..11ee8a48e5 100644 --- a/nix/lib/push-storage-object.nix +++ b/nix/lib/push-storage-object.nix @@ -21,7 +21,9 @@ in makeEffect { effectScript = '' export HOME="." - gcloud auth activate-service-account --key-file=- <<< $serviceAccountKey + gcloud auth activate-service-account \ + --verbosity=none --quiet --no-user-output-enabled \ + --key-file=- <<< $serviceAccountKey stat_uri() { gsutil stat $uri From e4d2cd3fa214d29f6ceda60c62371b6e05f90042 Mon Sep 17 00:00:00 2001 From: Ted Blackman Date: Fri, 6 Nov 2020 15:06:46 -0500 Subject: [PATCH 597/933] vere/aes_siv: check claimed length --- pkg/urbit/jets/e/aes_siv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/urbit/jets/e/aes_siv.c b/pkg/urbit/jets/e/aes_siv.c index b31ab84cf3..6fc2cf5bd2 100644 --- a/pkg/urbit/jets/e/aes_siv.c +++ b/pkg/urbit/jets/e/aes_siv.c @@ -327,7 +327,10 @@ u3qea_sivc_de(u3_atom key, u3_atom txt) { c3_y key_y[64]; - if (u3r_met(3, key) > 64) { + if ( u3r_met(3, key) > 64 ) { + return u3_none; + } + if ( c3y == u3qa_gth(u3r_met(3, txt), len) ) { return u3_none; } From a70c8cb2046646cca8654d59e2510634984b9c10 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sat, 7 Nov 2020 21:08:34 -0800 Subject: [PATCH 598/933] vere: print error and exit if stdin is not a tty --- pkg/urbit/vere/io/term.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/urbit/vere/io/term.c b/pkg/urbit/vere/io/term.c index 273092682c..937ccf156c 100644 --- a/pkg/urbit/vere/io/term.c +++ b/pkg/urbit/vere/io/term.c @@ -147,6 +147,12 @@ u3_term_log_init(void) { uty_u->fid_i = 0; // stdin, yes we write to it... + if ( !isatty(uty_u->fid_i) ) { + fprintf(stderr, "vere: unable to initialize terminal (not a tty)\r\n" + " use -t to disable interactivity\r\n"); + u3_king_bail(); + } + uv_pipe_init(u3L, &(uty_u->pop_u), 0); uv_pipe_open(&(uty_u->pop_u), uty_u->fid_i); } From 1c8d229fb7447d57e8006fcf733fd729942beebc Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Mon, 9 Nov 2020 22:26:13 -0800 Subject: [PATCH 599/933] gall: fade initial commit --- pkg/arvo/gen/hood/fade.hoon | 17 ++++++++++++++++ pkg/arvo/gen/hood/pass.hoon | 3 +++ pkg/arvo/lib/hood/drum.hoon | 28 +++++++++++++++++++++++++- pkg/arvo/lib/hood/helm.hoon | 5 +++++ pkg/arvo/sys/vane/clay.hoon | 28 ++++++++++++++++++++------ pkg/arvo/sys/vane/gall.hoon | 39 +++++++++++++++++++++++++++++++++++++ pkg/arvo/sys/zuse.hoon | 1 + 7 files changed, 114 insertions(+), 7 deletions(-) create mode 100644 pkg/arvo/gen/hood/fade.hoon create mode 100644 pkg/arvo/gen/hood/pass.hoon diff --git a/pkg/arvo/gen/hood/fade.hoon b/pkg/arvo/gen/hood/fade.hoon new file mode 100644 index 0000000000..e794f805c8 --- /dev/null +++ b/pkg/arvo/gen/hood/fade.hoon @@ -0,0 +1,17 @@ +:: Drum: destroy app +:: +:::: /hoon/start/hood/gen + :: +/? 310 +:: +:::: + :: +:- %say +|= $: [now=@da eny=@uvJ bec=beak] + [arg=[@ $@(~ [@ ~])] ~] + == +:- %drum-fade +?> ((sane %tas) -.arg) +?@ +.arg [q.bec -.arg] +?> ((sane %tas) +<.arg) +[-.arg +<.arg] diff --git a/pkg/arvo/gen/hood/pass.hoon b/pkg/arvo/gen/hood/pass.hoon new file mode 100644 index 0000000000..84bee18a41 --- /dev/null +++ b/pkg/arvo/gen/hood/pass.hoon @@ -0,0 +1,3 @@ +:- %say +|= [^ [=note-arvo ~] ~] +[%helm-pass note-arvo] diff --git a/pkg/arvo/lib/hood/drum.hoon b/pkg/arvo/lib/hood/drum.hoon index a41c917a7c..3a0150243a 100644 --- a/pkg/arvo/lib/hood/drum.hoon +++ b/pkg/arvo/lib/hood/drum.hoon @@ -177,6 +177,11 @@ =< se-abet =< se-view (se-born & wel) :: +++ poke-fade :: fade app + |= wel/well:gall + =< se-abet =< se-view + (se-fade wel) +:: ++ poke-link :: connect app |= gyl/gill:gall =< se-abet =< se-view @@ -205,6 +210,7 @@ %drum-put =;(f (f !<(_+<.f vase)) poke-put) %drum-set-boot-apps =;(f (f !<(_+<.f vase)) poke-set-boot-apps) %drum-start =;(f (f !<(_+<.f vase)) poke-start) + %drum-fade =;(f (f !<(_+<.f vase)) poke-fade) %drum-unlink =;(f (f !<(_+<.f vase)) poke-unlink) == :: @@ -309,7 +315,7 @@ :: :: :: ++ se-abet :: resolve ^- (quip card:agent:gall state) - =. . se-subze:se-adze:se-adit + =. . se-subze:se-adze:se-subit:se-adit :_ sat(bin (~(put by bin) ost dev)) ^- (list card:agent:gall) ?~ biz (flop moz) @@ -374,6 +380,17 @@ $(priorities t.priorities) -- :: +++ se-subit :: downdate servers + =/ ruf=(list term) ~(tap in ~(key by fur)) + |- ^+ this + ?~ ruf + this + ?: (~(has in ray) [%home i.ruf]) + $(ruf t.ruf) + =/ wire [%drum %fade i.ruf ~] + =. this (se-emit %pass wire %arvo %g %fade i.ruf %gone) + $(ruf t.ruf, fur (~(del by fur) i.ruf)) +:: ++ se-adze :: update connections ^+ . %+ roll @@ -469,6 +486,15 @@ eel (~(put in eel) [our.hid q.wel]) == :: +++ se-fade :: delete server + |= wel=well:gall + ^+ +> + ?. (~(has in ray) wel) + (se-text "[fade not running {}/{}]") + %= +> + ray (~(del in ray) wel) + == +:: ++ se-drop :: disconnect |= {pej/? gyl/gill:gall} ^+ +> diff --git a/pkg/arvo/lib/hood/helm.hoon b/pkg/arvo/lib/hood/helm.hoon index 9c80595238..fe3e1aaef0 100644 --- a/pkg/arvo/lib/hood/helm.hoon +++ b/pkg/arvo/lib/hood/helm.hoon @@ -108,6 +108,10 @@ |= ~ =< abet (emit %pass /pack %arvo %d %flog %pack ~) :: +++ poke-pass + |= =note-arvo =< abet + (emit %pass /pass %arvo note-arvo) +:: ++ take-wake-automass |= [way=wire error=(unit tang)] ?^ error @@ -247,6 +251,7 @@ %helm-meld =;(f (f !<(_+<.f vase)) poke-meld) %helm-moon =;(f (f !<(_+<.f vase)) poke-moon) %helm-pack =;(f (f !<(_+<.f vase)) poke-pack) + %helm-pass =;(f (f !<(_+<.f vase)) poke-pass) %helm-rekey =;(f (f !<(_+<.f vase)) poke-rekey) %helm-reload =;(f (f !<(_+<.f vase)) poke-reload) %helm-reload-desk =;(f (f !<(_+<.f vase)) poke-reload-desk) diff --git a/pkg/arvo/sys/vane/clay.hoon b/pkg/arvo/sys/vane/clay.hoon index edc3ca3ffb..919fd3b626 100644 --- a/pkg/arvo/sys/vane/clay.hoon +++ b/pkg/arvo/sys/vane/clay.hoon @@ -165,7 +165,6 @@ hez=(unit duct) :: sync duct cez=(map @ta crew) :: permission groups pud=(unit [=desk =yoki]) :: pending update - pun=(list move) :: upgrade moves == :: :: :: Object store. @@ -3949,7 +3948,7 @@ :: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: =| :: instrument state - $: ver=%5 :: vane version + $: ver=%6 :: vane version ruf=raft :: revision tree == :: |= [our=ship now=@da eny=@uvJ ski=sley] :: current invocation @@ -4151,7 +4150,7 @@ =^ moves-1 ..^^$ $(desks t.desks) =^ moves-2 ruf abet:wake:((de our now ski hen ruf) [ship desk]:i.desks) [(weld moves-1 moves-2) ..^^$] - [(welp wake-moves pun.ruf) ..^$(pun.ruf ~)] + [wake-moves ..^$] :: ?(%warp %werp) :: capture whether this read is on behalf of another ship @@ -4209,9 +4208,15 @@ =? old ?=(%2 -.old) (load-2-to-3 old) =? old ?=(%3 -.old) (load-3-to-4 old) =? old ?=(%4 -.old) (load-4-to-5 old) - ?> ?=(%5 -.old) + =? old ?=(%5 -.old) (load-5-to-6 old) + ?> ?=(%6 -.old) ..^^$(ruf +.old) :: + ++ load-5-to-6 + |= =state-5 + ^- state-6 + state-5(- %6, |7 pud.state-5) + :: ++ load-4-to-5 |= =state-4 ^- state-5 @@ -4424,8 +4429,19 @@ -- -- :: - +$ any-state $%(state-5 state-4 state-3 state-2) - +$ state-5 [%5 raft] + +$ any-state $%(state-6 state-5 state-4 state-3 state-2) + +$ state-6 [%6 raft] + ++ state-5 + $: %5 + rom=room + hoy=(map ship rung) + ran=rang + mon=(map term beam) + hez=(unit duct) + cez=(map @ta crew) + pud=(unit [=desk =yoki]) + pun=(list *) + == :: +$ state-4 $: %4 rom=room diff --git a/pkg/arvo/sys/vane/gall.hoon b/pkg/arvo/sys/vane/gall.hoon index efd6783171..dfb78b5fe8 100644 --- a/pkg/arvo/sys/vane/gall.hoon +++ b/pkg/arvo/sys/vane/gall.hoon @@ -851,6 +851,19 @@ =? new-blocked !=(ship attributing.routes.mov) (~(put to new-blocked) mov) $ + :: +mo-fade: put app to sleep + :: + ++ mo-fade + |= [dap=term style=?(%rest %doze %gone)] + ^+ mo-core + =/ =routes [disclosing=~ attributing=our] + =/ app (ap-abed:ap dap routes) + =. mo-core ap-abet:(ap-fade:app style) + ?- style + %gone mo-core(yokes.state (~(del by yokes.state) dap)) + %rest !! + %doze !! + == :: +mo-beak: assemble a beak for the specified agent. :: ++ mo-beak @@ -1071,6 +1084,31 @@ yokes.state running moves moves == + :: +ap-fade: put affairs in order. + :: + :: For %gone, remove all incoming and outgoing subscriptions. + :: + ++ ap-fade + |= style=?(%rest %doze %gone) + ^+ ap-core + ?> ?=(%gone style) + =/ out=(list [[=wire =ship =term] ? =path]) + ~(tap by outbound.watches.current-agent) + =/ inbound-paths=(set path) + %- silt + %+ turn ~(tap by inbound.watches.current-agent) + |= [=duct =ship =path] + path + =/ will=(list card:agent:gall) + %+ welp + ?: =(~ inbound-paths) + ~ + [%give %kick ~(tap in inbound-paths) ~]~ + %+ turn ~(tap by outbound.watches.current-agent) + |= [[=wire =ship =term] ? =path] + [%pass wire %agent [ship term] %leave ~] + =^ maybe-tang ap-core (ap-ingest ~ |.([will agent.current-agent])) + ap-core :: +ap-from-internal: internal move to move. :: :: We convert from cards to duct-indexed moves when resolving @@ -1707,6 +1745,7 @@ mo-abet :: %sear mo-abet:(mo-filter-queue:mo-core ship.task) + %fade mo-abet:(mo-fade:mo-core dap.task style.task) %trim [~ gall-payload] %vega [~ gall-payload] == diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index 4dc733ca8f..6df1249f16 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -1723,6 +1723,7 @@ [$deal p=sock q=term r=deal] :: full transmission [%goad force=? agent=(unit dude)] :: rebuild agent(s) [%sear =ship] :: clear pending queues + [%fade dap=term style=?(%rest %doze %gone)] :: put app to sleep $>(%init vane-task) :: set owner $>(%trim vane-task) :: trim state $>(%vega vane-task) :: report upgrade From 16e48a74847dba1e4e0665a86889afea12a578b9 Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Wed, 11 Nov 2020 16:28:04 -0800 Subject: [PATCH 600/933] king: this is a holdup! --- .../urbit-king/lib/Urbit/Vere/Ames/Packet.hs | 7 +- pkg/hs/urbit-noun-core/lib/Urbit/Noun/Core.hs | 35 +++++----- pkg/hs/urbit-noun-core/lib/Urbit/Noun/Mug.hs | 32 +++++++++ pkg/hs/urbit-noun-core/package.yaml | 1 + pkg/hs/urbit-noun/lib/Urbit/Noun.hs | 2 + .../urbit-noun/lib/Urbit/Noun/Conversions.hs | 7 +- pkg/hs/urbit-noun/lib/Urbit/Noun/Tree.hs | 66 +------------------ 7 files changed, 57 insertions(+), 93 deletions(-) create mode 100644 pkg/hs/urbit-noun-core/lib/Urbit/Noun/Mug.hs diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/Packet.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/Packet.hs index 193a1da365..4c1ebb6bd3 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/Packet.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/Packet.hs @@ -53,9 +53,7 @@ instance Serialize Packet where lookAhead $ do len <- remaining body <- getBytes len - -- XX mug (marked "TODO") is implemented as "slowMug" in U.N.Tree. Ominous - -- Also, toNoun will copy the bytes into an atom. We probably want a mugBS - let chk = fromIntegral (mug $ toNoun $ MkBytes body) .&. (2 ^ 20 - 1) + let chk = fromIntegral (mugBS body) .&. (2 ^ 20 - 1) when (checksum /= chk) $ fail ("checksum mismatch: expected " <> show checksum <> "; got " <> show chk) @@ -84,8 +82,7 @@ instance Serialize Packet where let (sndR, putSndr) = putShipGetRank pktSndr let (rcvR, putRcvr) = putShipGetRank pktRcvr let body = runPut (putSndr <> putRcvr <> putByteString load) - -- XX again maybe mug can be made better here - let chek = fromIntegral (mug $ toNoun $ MkBytes body) .&. (2 ^ 20 - 1) + let chek = fromIntegral (mugBS body) .&. (2 ^ 20 - 1) let encr = pktEncrypted let vers = fromIntegral pktVersion .&. 0b111 let head = vers diff --git a/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Core.hs b/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Core.hs index 0aeca303d3..cff0be4f76 100644 --- a/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Core.hs +++ b/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Core.hs @@ -14,11 +14,13 @@ module Urbit.Noun.Core , pattern Cell, pattern Atom , pattern C, pattern A , textToUtf8Atom, utf8AtomToText + , mug ) where import ClassyPrelude hiding (hash) import Urbit.Atom +import Urbit.Noun.Mug import Data.Bits (xor) import Data.Function ((&)) @@ -34,8 +36,8 @@ import qualified Data.Char as C -- Types ----------------------------------------------------------------------- data Noun - = NCell Int Word !Noun !Noun - | NAtom Int !Atom + = NCell ~Mug Word Noun Noun + | NAtom ~Mug Atom pattern Cell x y <- NCell _ _ x y where Cell = mkCell pattern Atom a <- NAtom _ a where Atom = mkAtom @@ -51,10 +53,9 @@ pattern A a <- NAtom _ a where A = mkAtom -------------------------------------------------------------------------------- instance Hashable Noun where - hash = \case NCell h _ _ _ -> h - NAtom h _ -> h + hash = fromIntegral . mug {-# INLINE hash #-} - hashWithSalt = defaultHashWithSalt + hashWithSalt salt x = salt `combine` hash x {-# INLINE hashWithSalt #-} textToUtf8Atom :: Text -> Noun @@ -140,6 +141,10 @@ genAtom = do False -> genNatural True -> (`mod` 16) <$> genNatural +-- From http://hackage.haskell.org/package/hashable-1.2.7.0/docs/src/Data-Hashable-Class.html +combine :: Int -> Int -> Int +combine h1 h2 = (h1 * 16777619) `xor` h2 + -------------------------------------------------------------------------------- {-# INLINE nounSize #-} @@ -148,24 +153,18 @@ nounSize = \case NCell _ s _ _ -> s NAtom _ _ -> 1 +{-# INLINE mug #-} +mug :: Noun -> Mug +mug = \case NCell h _ _ _ -> h + NAtom h _ -> h + {-# INLINE mkAtom #-} mkAtom :: Atom -> Noun -mkAtom a = NAtom (hash a) a +mkAtom a = NAtom (mugAtom a) a {-# INLINE mkCell #-} mkCell :: Noun -> Noun -> Noun mkCell h t = NCell has siz h t where siz = nounSize h + nounSize t - has = hash h `combine` hash t - - --- Stolen from Hashable Library ------------------------------------------------ - -{-# INLINE combine #-} -combine :: Int -> Int -> Int -combine h1 h2 = (h1 * 16777619) `xor` h2 - -{-# INLINE defaultHashWithSalt #-} -defaultHashWithSalt :: Hashable a => Int -> a -> Int -defaultHashWithSalt salt x = salt `combine` hash x + has = mugBoth (mug h) (mug t) diff --git a/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Mug.hs b/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Mug.hs new file mode 100644 index 0000000000..3847ed6419 --- /dev/null +++ b/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Mug.hs @@ -0,0 +1,32 @@ +{-# OPTIONS_GHC -O2 #-} + +module Urbit.Noun.Mug where + +import ClassyPrelude + +import Data.Bits +import Urbit.Atom + +import Data.Hash.Murmur (murmur3) + +type Mug = Word32 + +{-# INLINE mugBS #-} +mugBS :: ByteString -> Word32 +mugBS = go 0xcafebabe + where + go seed buf = + let haz = murmur3 seed buf + ham = shiftR haz 31 `xor` (haz .&. 0x7fff_ffff) + in if ham == 0 + then go (seed + 1) buf + else ham + +-- XX is there a way to do this without copy? +{-# INLINE mugAtom #-} +mugAtom :: Atom -> Word32 +mugAtom = mugBS . atomBytes + +{-# INLINE mugBoth #-} +mugBoth :: Word32 -> Word32 -> Word32 +mugBoth m n = mugAtom $ fromIntegral $ m `xor` 0x7fff_ffff `xor` n diff --git a/pkg/hs/urbit-noun-core/package.yaml b/pkg/hs/urbit-noun-core/package.yaml index f9fee33741..aa1b579f29 100644 --- a/pkg/hs/urbit-noun-core/package.yaml +++ b/pkg/hs/urbit-noun-core/package.yaml @@ -24,6 +24,7 @@ dependencies: - vector - integer-gmp - template-haskell + - murmur3 default-extensions: - ApplicativeDo diff --git a/pkg/hs/urbit-noun/lib/Urbit/Noun.hs b/pkg/hs/urbit-noun/lib/Urbit/Noun.hs index ac62f5c3fc..3357e91d99 100644 --- a/pkg/hs/urbit-noun/lib/Urbit/Noun.hs +++ b/pkg/hs/urbit-noun/lib/Urbit/Noun.hs @@ -11,6 +11,7 @@ module Urbit.Noun , module Urbit.Noun.Core , module Urbit.Noun.Cue , module Urbit.Noun.Jam + , module Urbit.Noun.Mug , module Urbit.Noun.Tank , module Urbit.Noun.TH , module Urbit.Noun.Tree @@ -29,6 +30,7 @@ import Urbit.Noun.Convert import Urbit.Noun.Core import Urbit.Noun.Cue import Urbit.Noun.Jam +import Urbit.Noun.Mug import Urbit.Noun.Tank import Urbit.Noun.TH import Urbit.Noun.Tree diff --git a/pkg/hs/urbit-noun/lib/Urbit/Noun/Conversions.hs b/pkg/hs/urbit-noun/lib/Urbit/Noun/Conversions.hs index 499712fc7b..b8104a77ae 100644 --- a/pkg/hs/urbit-noun/lib/Urbit/Noun/Conversions.hs +++ b/pkg/hs/urbit-noun/lib/Urbit/Noun/Conversions.hs @@ -10,7 +10,7 @@ module Urbit.Noun.Conversions , BigTape(..), BigCord(..) , Wain(..), Wall, Each(..) , UD(..), UV(..), UW(..), cordToUW - , Mug(..), Path(..), EvilPath(..), Ship(..) + , Path(..), EvilPath(..), Ship(..) , Lenient(..), pathToFilePath, filePathToPath , showUD, tshowUD , textAsTa @@ -639,11 +639,6 @@ filePathToPath fp = Path path ('.':xs) -> xs x -> x --- Mug ------------------------------------------------------------------------- - -newtype Mug = Mug Word32 - deriving newtype (Eq, Ord, Show, Num, ToNoun, FromNoun) - -- Bool ------------------------------------------------------------------------ diff --git a/pkg/hs/urbit-noun/lib/Urbit/Noun/Tree.hs b/pkg/hs/urbit-noun/lib/Urbit/Noun/Tree.hs index 6ff6d7586c..7588b4239d 100644 --- a/pkg/hs/urbit-noun/lib/Urbit/Noun/Tree.hs +++ b/pkg/hs/urbit-noun/lib/Urbit/Noun/Tree.hs @@ -7,7 +7,6 @@ module Urbit.Noun.Tree ( HoonSet, setToHoonSet, setFromHoonSet , HoonMap, mapToHoonMap, mapFromHoonMap - , mug ) where import ClassyPrelude @@ -78,67 +77,6 @@ instance FromNoun a => FromNoun (HoonTree a) where deriveNoun ''HoonTreeNode --- Mug ------------------------------------------------------------------------- - -type Nat = Natural - -slowMug :: Noun -> Nat -slowMug = trim 0xcafe_babe . \case - A a -> a - C h t -> mix (slowMug h) $ mix 0x7fff_ffff (slowMug t) - where - trim :: Nat -> Nat -> Nat - trim syd key = - if 0/=ham then ham else trim (succ syd) key - where - haz = muk syd (met 3 key) key - ham = mix (rsh 0 31 haz) (end 0 31 haz) - -mix :: Nat -> Nat -> Nat -mix = xor - --- Murmur3 -muk :: Nat -> Nat -> Nat -> Nat -muk seed len = - fromIntegral . murmur3 (word32 seed) . resize . atomBytes - where - resize :: ByteString -> ByteString - resize buf = - case compare (length buf) (int len) of - EQ -> buf - LT -> error "bad-muk" - GT -> error "bad-muk" --- LT -> buf <> replicate (len - length buf) 0 --- GT -> take len buf - -int :: Integral i => i -> Int -int = fromIntegral - -word32 :: Integral i => i -> Word32 -word32 = fromIntegral - -bex :: Nat -> Nat -bex = (2^) - -end :: Nat -> Nat -> Nat -> Nat -end blockSize blocks n = - n `mod` (bex (bex blockSize * blocks)) - -rsh :: Nat -> Nat -> Nat -> Nat -rsh blockSize blocks n = - shiftR n $ fromIntegral $ (bex blockSize * blocks) - -met :: Nat -> Nat -> Nat -met bloq = go 0 - where - go c 0 = c - go c n = go (succ c) (rsh bloq 1 n) - --- XX TODO -mug :: Noun -> Nat -mug = slowMug - - -- Order ----------------------------------------------------------------------- {- @@ -147,8 +85,8 @@ mug = slowMug mor :: Noun -> Noun -> Bool mor a b = if c == d then dor a b else c < d where - c = mug $ A $ mug a - d = mug $ A $ mug b + c = mug $ A $ fromIntegral $ mug a + d = mug $ A $ fromIntegral $ mug b {- Orders in ascending tree depth. From d7de50be07b5f54fbd80455e163be23bb6529cc8 Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Wed, 11 Nov 2020 16:42:55 -0800 Subject: [PATCH 601/933] king: fix warnings in Tree (thanks dad) --- pkg/hs/urbit-noun/lib/Urbit/Noun/Tree.hs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pkg/hs/urbit-noun/lib/Urbit/Noun/Tree.hs b/pkg/hs/urbit-noun/lib/Urbit/Noun/Tree.hs index 7588b4239d..777f465779 100644 --- a/pkg/hs/urbit-noun/lib/Urbit/Noun/Tree.hs +++ b/pkg/hs/urbit-noun/lib/Urbit/Noun/Tree.hs @@ -12,16 +12,11 @@ module Urbit.Noun.Tree import ClassyPrelude import Control.Lens hiding (non) -import Urbit.Atom import Urbit.Noun.Conversions () import Urbit.Noun.Convert import Urbit.Noun.Core import Urbit.Noun.TH -import Data.Bits (shiftR, xor) -import Data.Hash.Murmur (murmur3) -import GHC.Natural (Natural) - -- Types ----------------------------------------------------------------------- From f08d7c603154b1b7df6717f71f52467d9e5fe0e3 Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Wed, 11 Nov 2020 16:56:56 -0800 Subject: [PATCH 602/933] king: fix test (daaad) --- pkg/hs/urbit-king/test/HoonMapSetTests.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/hs/urbit-king/test/HoonMapSetTests.hs b/pkg/hs/urbit-king/test/HoonMapSetTests.hs index a012e16eae..13101ab01a 100644 --- a/pkg/hs/urbit-king/test/HoonMapSetTests.hs +++ b/pkg/hs/urbit-king/test/HoonMapSetTests.hs @@ -70,7 +70,7 @@ treeRTMug inp = do non <- cueBSExn byt tee <- fromNounExn non mug <- evaluate $ mug $ toNoun $ treeTestsIdentity tee - pure $ Text.Lazy.Encoding.encodeUtf8 $ tlshow (mug :: Natural) + pure $ Text.Lazy.Encoding.encodeUtf8 $ tlshow mug goldenPill :: TestName From 6106852b31dd365cf24faee7e5a10d71ac582cac Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 11 Nov 2020 17:26:29 -0800 Subject: [PATCH 603/933] nix: fixes `shellFor` nix-shell helper --- default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.nix b/default.nix index 6b8c96c835..3448a2a586 100644 --- a/default.nix +++ b/default.nix @@ -169,7 +169,7 @@ let # } # shellFor = { name, packages, ... }@attrs: - pkgs.mkShell ({ + pkgsNative.mkShell ({ inputsFrom = packages pkgsLocal; } // builtins.removeAttrs attrs [ "packages" ]); }; From b3b3df06b5cdd5197947ea36fadacc07af8fb90b Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 11 Nov 2020 18:14:08 -0800 Subject: [PATCH 604/933] pill: all --- bin/brass.pill | 4 ++-- bin/ivory.pill | 4 ++-- bin/solid.pill | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/brass.pill b/bin/brass.pill index 1fb9455f0b..b5f47de1bd 100644 --- a/bin/brass.pill +++ b/bin/brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fb5f4e0d57a17d068f7606dc245ec786862b5522a6d6a78484c10b804df55c6e -size 4453633 +oid sha256:f4a6a782b2193a16dc10340e40787522ec34df50eb517fef849bc32b87a3e512 +size 4508418 diff --git a/bin/ivory.pill b/bin/ivory.pill index 2c6600ce55..40004edc42 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:85706d503bd88b8a78224aa97b09d2b5b004afff7ca9d28680f8ddb7eff36f56 -size 1311412 +oid sha256:db42476704efdbb5c2cbf81ea67f15603da5b848850b538081e7b108f969fa19 +size 1315294 diff --git a/bin/solid.pill b/bin/solid.pill index 3d7c973a08..e662f47214 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9f23812618c63622aee1a56deafb066cb41915db0f8250ba8ad91b57d04fcd8f -size 6181413 +oid sha256:680ebc2bb2fd224541b5aa6dbfda5a981df59089172410ddabc6b3f4b93d54c4 +size 6327612 From a1aa129f42ba0f8571f5400a1fabb96922fa33f3 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 11 Nov 2020 18:16:30 -0800 Subject: [PATCH 605/933] u3: re-enables fixed +apt:in/+apt:by jets --- pkg/urbit/jets/tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index c7f7b84b0d..46b8acb0e9 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -1689,7 +1689,7 @@ static c3_c* _141_two_xeb_ha[] = { }; static u3j_core _141_two__in_d[] = - { // { "apt", 7, _141_two__in_apt_a, 0, _141_two__in_apt_ha }, + { { "apt", 7, _141_two__in_apt_a, 0, _141_two__in_apt_ha }, { "bif", 7, _141_two__in_bif_a, 0, _141_two__in_bif_ha }, { "del", 7, _141_two__in_del_a, 0, _141_two__in_del_ha }, { "dif", 7, _141_two__in_dif_a, 0, _141_two__in_dif_ha }, @@ -1797,7 +1797,7 @@ static c3_c* _141_two__in_ha[] = { static u3j_core _141_two__by_d[] = { { "all", 7, _141_two__by_all_a, 0, _141_two__by_all_ha }, { "any", 7, _141_two__by_any_a, 0, _141_two__by_any_ha }, - // { "apt", 7, _141_two__by_apt_a, 0, _141_two__by_apt_ha }, + { "apt", 7, _141_two__by_apt_a, 0, _141_two__by_apt_ha }, { "bif", 7, _141_two__by_bif_a, 0, _141_two__by_bif_ha }, { "del", 7, _141_two__by_del_a, 0, _141_two__by_del_ha }, { "dif", 7, _141_two__by_dif_a, 0, _141_two__by_dif_ha }, From d729746c38933e6b6624ce5f6bde14360f35744d Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 13 Nov 2020 12:35:01 -0800 Subject: [PATCH 606/933] arvo: reforms state and upgrade structures --- pkg/arvo/sys/arvo.hoon | 179 ++++++++++++++++------------------------- 1 file changed, 70 insertions(+), 109 deletions(-) diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index 7c28d9e595..2a2ed64756 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -153,13 +153,52 @@ :: +| %implementation :: +:: $debt: ephemeral state +:: $germ: worklist source and bar stack +:: $heir: upgradeable state :: $pane: kernel modules +:: $plan: worklist :: $pone: kernel modules old +:: $soil: working state +:: $soul: persistent state :: $vane: kernel module :: $vile: reflexive constants :: +:: ++$ debt + $~ [~ ~ *germ ~] + $: :: run: list of worklists + :: out: pending output + :: gem: worklist metadata + :: dud: propagate error + :: + run=(list plan) + out=(list ovum) + gem=germ + dud=(unit goof) + == ++$ germ [vane=term bars=(list duct)] ++$ heir + $% [%arvo-kelvin now=@da =debt =soul] + == +$ pane (list (pair @tas vase)) ++$ plan (pair germ (list move)) +$ pone (list (pair @tas vise)) ++$ soil :: XX use $soul + $: our=ship + now=@da + eny=@uvJ + lac=? + vil=vile + van=(map term vane) + == ++$ soul + $: lac=? :: laconic bit + eny=@uvJ :: entropy + our=ship :: identity + bud=vase :: %zuse + vanes=(list [label=@tas =vane]) :: modules + == +$ vane [=vase =worm] +$ vile $: typ=type :: -:!>(*type) @@ -528,38 +567,11 @@ :: |le: arvo event-loop engine :: ++ le - => |% - :: $germ: worklist source and bar stack - :: $plan: worklist - :: $debt: in-progress state - :: - +$ germ [vane=term bars=(list duct)] - +$ plan (pair germ (list move)) - +$ debt - $~ [~ ~ *germ ~] - $: :: run: list of worklists - :: out: pending output - :: gem: worklist metadata - :: dud: propagate error - :: - run=(list plan) - out=(list ovum) - gem=germ - dud=(unit goof) - == - -- - :: - ~% %le part ~ + ~% %le ..le ~ =| debt =* nub - :: - |_ $: our=ship - now=@da - eny=@uvJ - lac=? - vil=vile - van=(map term vane) - == + |_ soil +* this . ++ plot run.nub ++ then |=(paz=(list plan) this(run (weld run paz))) @@ -977,7 +989,7 @@ =/ fip=ship (dec (bex 128)) ~> %slog.[0 leaf+"arvo: larval identity {(scow %p fip)}"] fip - =. soul (veer our now q.ovo) + =. ..veer (veer our now q.ovo) +>.$(bod ?^(bod bod `bud.^poke)) :: add entropy :: @@ -998,9 +1010,9 @@ [~ +>.$] ~> %slog.[0 leaf+"arvo: metamorphosis"] ~< %slog.[0 leaf+"arvo: metamorphosed"] - =/ nyf - (turn vanes.^poke |=([label=@tas =vane] [label vase.vane])) - (load u.who now u.eny *pram u.bod nyf) + =/ =soul + [lac=& u.eny u.who u.bod vanes.^poke] + (load %arvo-kelvin now *debt soul) :: ++ wish |= txt=* :: 22 ?> ?=(@ txt) @@ -1011,92 +1023,48 @@ :: =/ pit=vase !>(..is) :: =/ vil=vile (viol p.pit) :: cached reflexives -=| $: lac=_& :: laconic bit - eny=@ :: entropy - our=ship :: identity - bud=vase :: %zuse - vanes=(list [label=@tas =vane]) :: modules - == :: +=| soul :: +=* sol - :: produce an interface that vere understands :: =< arvo -:: soul: arvo implementation core -:: |% -++ soul . :: arvo: structural interface core :: ++ arvo |% - ++ come |= [@ @ @ pram vise pone] :: 4 - (come:soul +<) + ++ come |=(* !!) :: 4 + ++ load ^load :: 10 :: - ++ load |= [@ @ @ pram vase pane] :: 10 - (load:soul +<) - :: - ++ peek |= * :: 46 + ++ peek |= * :: 46 =/ rob (^peek ;;([@da path] +<)) ?~ rob ~ ?~ u.rob ~ [~ u.u.rob] :: - ++ poke |= * :: 47 + ++ poke |= * :: 47 => .(+< ;;([now=@da ovo=ovum] +<)) - (poke:soul now ovo) + (^poke now ovo) :: - ++ wish |=(* (^wish ;;(@ta +<))) :: 22 + ++ wish |=(* (^wish ;;(@ta +<))) :: 22 -- -:: $pram: upgradeable state -:: +dram: upgrade $pram, compatible :: -+$ pram - $~ [%~2020.6.28 nub=*debt:le:part] - $% [%~2020.6.28 nub=debt:le:part] - (list ovum) - == -++ dram - |= ram=pram - ^- pram - ?: ?=([%~2020.6.28 *] ram) - ram - ~| ram+ram - =| nub=debt:le:part - =/ =plan:le:part - :- [%$ ~] - %+ turn ;;((list ovum) ram) - |= ovo=ovum - ^- move - [[p.ovo]~ %give %& %noun q.ovo] - [%~2020.6.28 nub(run [plan]~)] -:: $prim: old $pram -:: +drum: upgrade $prim to $pram, incompatible -:: -+$ prim pram -++ drum |=(prim +<) :: +come: load incompatible :: -++ come - |= [who=ship now=@da yen=@ rim=prim dub=vise nyf=pone] - ^- [(list ovum) *] - ~| %come - =/ fyn (turn nyf |=([a=@tas b=vise] [a (slim b)])) - =/ rum (drum rim) - (load who now yen rum (slim dub) fyn) +++ come |=(* !!) :: +load: load compatible, notifying vanes :: ++ load - |= [who=ship now=@da yen=@ ram=pram dub=vase nyf=pane] + |= hir=heir ^- [(list ovum) *] ~| %load - =: our who - eny yen - bud dub - vanes (turn nyf |=({a/@tas b/vise} [a [b *worm]])) + =. sol + ?- -.hir + %arvo-kelvin soul.hir == - =. ram (dram ram) - ?> ?=([%~2020.6.28 *] ram) - =/ run plot:(spam:(lead now ~) [//arvo %vega ~]) - (leap now (then:(lead now `nub.ram) run)) + =. vanes (turn vanes |=(a=[lal=@tas =vane] a(vane vane.a(worm *worm)))) + =/ run plot:(spam:(lead now.hir ~) [//arvo %vega ~]) + (leap now.hir (then:(lead now.hir `debt.hir) run)) :: +peek: external inspect :: ++ peek @@ -1134,7 +1102,7 @@ ~ :: Process these events just as if they had come from a vane :: - ?(%lyra %veer %verb %wack %whey) (feck now ovo *debt:le:part) + ?(%lyra %veer %verb %wack %whey) (feck now ovo *debt) :: These external events (currently only %trim) are global :: notifications, spammed to every vane :: @@ -1169,7 +1137,7 @@ :: +lead: initialize +le core :: ++ lead - |= [now=@da nub=(unit debt:le:part)] + |= [now=@da nub=(unit debt)] ^+ le:part ~| lead+.?(nub) =; el @@ -1199,7 +1167,7 @@ :: +feck: handle an effect from a vane :: ++ feck - |= [now=@da ovo=ovum nub=debt:le:part] + |= [now=@da ovo=ovum nub=debt] ^- [(list ovum) *] ~| feck+-.q.ovo ?: ?=(%lyra -.q.ovo) @@ -1218,7 +1186,7 @@ :: %veer: install %zuse or vane :: %veer - =. soul (veer our now q.ovo) + =. ..veer (veer our now q.ovo) (leap now (lead now `nub)) :: %wack: add entropy :: @@ -1236,7 +1204,7 @@ :: arv: arvo.hoon source :: now=@da - nub=debt:le:part + nub=debt hun=(unit @t) van=@t == @@ -1319,14 +1287,7 @@ .*(voc fol) :: upgrade gate sample :: - =/ sam - :* our - now - eny - [%~2020.6.28 nub] - bud - (turn vanes |=([label=@tas =vane] [label vase.vane])) - == + =/ sam=heir [%arvo-kelvin now nub sol] :: call into the new kernel :: ~> %slog.[0 leaf+"vega: evolving"] @@ -1342,7 +1303,7 @@ :: ++ veer |= [who=ship now=@da fav=curd] - ^+ soul + ^+ ..veer => .(fav ;;([%veer lal=@tas pax=path txt=@t] fav)) =; res ?-(-.res %& p.res, %| (mean leaf+"veer: {}" p.res)) %- mule |. @@ -1350,8 +1311,8 @@ ~> %slog.[0 leaf+"zuse: {(scow p+(mug txt.fav))}"] =+ gen=(rain pax.fav txt.fav) =+ vax=(slap pit gen) - soul(bud vax) - %_ soul + ..veer(bud vax) + %_ ..veer vanes |- ^+ vanes ?~ vanes From 5eb35b9bb55fd69195d17939e84fa92ca3b53d50 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 13 Nov 2020 12:37:40 -0800 Subject: [PATCH 607/933] pill: solid --- bin/solid.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index e662f47214..9f48f9c725 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:680ebc2bb2fd224541b5aa6dbfda5a981df59089172410ddabc6b3f4b93d54c4 -size 6327612 +oid sha256:818ea685af79b5bcfed24c811004aad424ba914dff7fd09c22b4053f1e8c7fdb +size 6287695 From bd4edb7fa4b57bc4ff28cc5b9ca50a34f8bcdc9c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 13 Nov 2020 14:31:24 -0800 Subject: [PATCH 608/933] vere: refactors pier initialization to fix -X --- pkg/urbit/vere/pier.c | 144 ++++++++++++++++++++++-------------------- 1 file changed, 74 insertions(+), 70 deletions(-) diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index 0da9f6bb19..fd0828a40e 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -477,6 +477,51 @@ u3_pier_peek_last(u3_pier* pir_u, _pier_peek_plan(pir_u, pic_u); } +/* _pier_on_scry_done(): scry callback. +*/ +static void +_pier_on_scry_done(void* ptr_v, u3_noun nun) +{ + u3_pier* pir_u = ptr_v; + u3_weak res = u3r_at(7, nun); + + if (u3_none == res) { + u3l_log("pier: scry failed\n"); + } + else { + u3l_log("pier: scry succeeded\n"); + + c3_c* pac_c = u3_Host.ops_u.puk_c; + if (!pac_c) { + pac_c = u3_Host.ops_u.pek_c; + } + + u3_noun pad; + { + // XX crashes if [pac_c] is not a valid path + // XX virtualize or fix + // + u3_noun pax = u3do("stab", u3i_string(pac_c)); + c3_w len_w = u3kb_lent(u3k(pax)); + pad = u3nt(c3_s4('.','u','r','b'), + c3_s3('p','u','t'), + u3qb_scag(len_w - 1, pax)); + u3z(pax); + } + + c3_c fil_c[2048]; + snprintf(fil_c, 2048, "%s/.urb/put/%s.jam", pir_u->pax_c, pac_c+1); + + u3_walk_save(fil_c, 0, u3qe_jam(res), pir_u->pax_c, pad); + u3l_log("pier: scry in %s\n", fil_c); + } + + u3l_log("pier: exit\n"); + u3_pier_exit(pir_u); + + u3z(nun); +} + /* _pier_work_init(): begin processing new events */ static void @@ -529,11 +574,6 @@ _pier_work_init(u3_pier* pir_u) uv_idle_init(u3L, &wok_u->idl_u); wok_u->idl_u.data = wok_u; - // initialize i/o drivers - // - wok_u->car_u = u3_auto_init(pir_u); - u3_auto_talk(wok_u->car_u); - // // setup u3_lord work callbacks // // // u3_lord_work_cb cb_u = { @@ -545,6 +585,34 @@ _pier_work_init(u3_pier* pir_u) // }; // u3_lord_work_init(pir_u->god_u, cb_u); + // XX this is messy, revise + // + if ( u3_Host.ops_u.pek_c ) { + u3_noun pex = u3do("stab", u3i_string(u3_Host.ops_u.pek_c)); + u3_noun car; + u3_noun dek; + u3_noun pax; + if ( c3n == u3r_trel(pex, &car, &dek, &pax) + || c3n == u3a_is_cat(car) ) + { + u3m_p("pier: invalid scry", pex); + _pier_on_scry_done(pir_u, u3_nul); + } else { + // run the requested scry, jam to disk, then exit + // + u3l_log("pier: scry\n"); + u3_pier_peek_last(pir_u, u3_nul, u3k(car), u3k(dek), u3k(pax), + pir_u, _pier_on_scry_done); + } + u3z(pex); + } + else { + // initialize i/o drivers + // + wok_u->car_u = u3_auto_init(pir_u); + u3_auto_talk(wok_u->car_u); + } + _pier_work(wok_u); } @@ -1068,51 +1136,6 @@ _pier_on_lord_bail(void* ptr_v) u3_pier_bail(pir_u); } -/* _pier_on_scry_done(): scry callback. -*/ -static void -_pier_on_scry_done(void* ptr_v, u3_noun nun) -{ - u3_pier* pir_u = ptr_v; - u3_weak res = u3r_at(7, nun); - - if (u3_none == res) { - u3l_log("pier: scry failed\n"); - } - else { - u3l_log("pier: scry succeeded\n"); - - c3_c* pac_c = u3_Host.ops_u.puk_c; - if (!pac_c) { - pac_c = u3_Host.ops_u.pek_c; - } - - u3_noun pad; - { - // XX crashes if [pac_c] is not a valid path - // XX virtualize or fix - // - u3_noun pax = u3do("stab", u3i_string(pac_c)); - c3_w len_w = u3kb_lent(u3k(pax)); - pad = u3nt(c3_s4('.','u','r','b'), - c3_s3('p','u','t'), - u3qb_scag(len_w - 1, pax)); - u3z(pax); - } - - c3_c fil_c[2048]; - snprintf(fil_c, 2048, "%s/.urb/put/%s.jam", pir_u->pax_c, pac_c+1); - - u3_walk_save(fil_c, 0, u3qe_jam(res), pir_u->pax_c, pad); - u3l_log("pier: scry in %s\n", fil_c); - } - - u3l_log("pier: exit"); - u3_pier_exit(pir_u); - - u3z(nun); -} - /* _pier_on_lord_live(): worker is ready. */ static void @@ -1143,26 +1166,7 @@ _pier_on_lord_live(void* ptr_v) c3_assert( u3_psat_init == pir_u->sat_e ); c3_assert( log_u->sen_d == log_u->dun_d ); - if (u3_Host.ops_u.pek_c) { - u3_noun pex = u3do("stab", u3i_string(u3_Host.ops_u.pek_c)); - u3_noun car; - u3_noun dek; - u3_noun pax; - if ( c3n == u3r_trel(pex, &car, &dek, &pax) - || c3n == u3a_is_cat(car) ) - { - u3m_p("pier: invalid scry", pex); - _pier_on_scry_done(pir_u, u3_nul); - } else { - // run the requested scry, jam to disk, then exit - // - u3l_log("pier: scry\n"); - u3_pier_peek_last(pir_u, u3_nul, u3k(car), u3k(dek), u3k(pax), - pir_u, _pier_on_scry_done); - } - u3z(pex); - } - else if ( god_u->eve_d < log_u->dun_d ) { + if ( god_u->eve_d < log_u->dun_d ) { c3_d eve_d; // XX revisit From 2e72724d44412b9910b411670bfafcc3706a899a Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Wed, 11 Nov 2020 08:48:53 +0100 Subject: [PATCH 609/933] build: github actions workflow configuration --- .github/workflows/build.yml | 120 +++++++++++++++++++ ci.nix | 91 -------------- default.nix | 15 ++- nix/lib/default.nix | 81 +++---------- nix/lib/dimension.nix | 110 ----------------- nix/lib/effect/default.nix | 122 ------------------- nix/lib/effect/effects-setup-hook.sh | 173 --------------------------- nix/lib/push-storage-object.nix | 45 ------- shell.nix | 17 +-- 9 files changed, 154 insertions(+), 620 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 ci.nix delete mode 100644 nix/lib/dimension.nix delete mode 100644 nix/lib/effect/default.nix delete mode 100644 nix/lib/effect/effects-setup-hook.sh delete mode 100644 nix/lib/push-storage-object.nix diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000..83c4bbbd9f --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,120 @@ +# Notes: +# +# jobs. +# +# A seperate job id results in a lot of duplication of nix/cachix work. +# The build will have to download any substituted derivations from cachix +# for the steps with each distinct job id and upload built derivations to +# cachix after each job has completed, either succesfully or on failure. +# +# jobs..steps.run +# +# build + test are distinct as each step entry results in a collapsable title +# within the log output, which makes it easier to view failing builds or +# tests independently. +# +# jobs..strategy.fail-fast +# +# Set to false so developers working on vere or king-haskell can have their +# respective builds proceed without the other causing failure. +# +# shell.nix +# +# mkShell doesn't allow you to build it - so instantiate all the subshells +# defined for the individual pkg/*/shell.nix as a sanity check and to create +# some artefacts suitable for developers to pull from cachix. The top-level +# shell.nix build time is dominated by Haskell dependencies so it's built as +# part of the haskell build steps. +# +# Syntax: +# +# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions + +name: Build, test, and upload urbit release tarball + +on: + push: null + pull_request: null + +jobs: + urbit: + strategy: + fail-fast: false + matrix: + include: + - { os: ubuntu-latest } + - { os: macos-latest } + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + - uses: cachix/install-nix-action@v12 + - uses: cachix/cachix-action@v8 + with: + name: mars + authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + + - run: nix-build -A urbit --arg enableStatic true + + - if: ${{ matrix.os == 'ubuntu-latest' }} + run: nix-build -A urbit-tests + + haskell: + strategy: + fail-fast: false + matrix: + include: + - { os: ubuntu-latest } + - { os: macos-latest } + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + - uses: cachix/install-nix-action@v12 + - uses: cachix/cachix-action@v8 + with: + name: mars + authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + + - run: nix-build -A hs.urbit-king.components.exes.urbit-king --arg enableStatic true + - run: nix-build -A hs-checks + - run: nix-build shell.nix + + upload: + needs: [urbit, haskell] + strategy: + matrix: + include: + - { os: ubuntu-latest, system: x86_64-linux } + - { os: macos-latest, system: x86_64-darwin } + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + - uses: cachix/install-nix-action@v12 + - uses: cachix/cachix-action@v8 + with: + name: mars + authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + + - uses: GoogleCloudPlatform/github-actions/setup-gcloud@0.1.2 + with: + version: '290.0.1' + service_account_key: ${{ secrets.GCS_SERVICE_ACCOUNT_KEY }} + project_id: ${{ secrets.GCS_PROJECT }} + export_default_credentials: true + + - run: nix-build -A tarball + + - name: Run upload to bootstrap.urbit.org + run: | + version="$(cat ./pkg/urbit/version)" + system="$(nix eval --raw '(builtins.currentSystem)')" + target="gs://bootstrap.urbit.org/ci/urbit-v${version}-${system}-${GITHUB_SHA:0:9}.tgz" + + gsutil cp -n ./result "$target" + + echo "upload to $target complete." diff --git a/ci.nix b/ci.nix deleted file mode 100644 index 991efdd300..0000000000 --- a/ci.nix +++ /dev/null @@ -1,91 +0,0 @@ -/* Examples - - Perform the same evaluation that occurs on CI via: - - $ NIX_PATH="" nix-instantiate ci.nix --arg supportedSystems '["x86_64-darwin"]' - - Build the release tarball: - - $ NIX_PATH="" nix-instantiate ci.nix -A darwin.tarball -*/ - -{ supportedSystems ? [ "x86_64-linux" "x86_64-darwin" ] }: - -let - - inherit (import ./nix/default.nix { }) - lib haskell-nix recurseIntoAttrs callPackage; - - # Local library import from derivation functions such as fetchGitHubLFS, etc. - # upon which local package defintions are dependent. - libLocal = callPackage ./nix/lib { }; - - # The key with google storage bucket write permission, - # deployed to ci via nixops deployment.keys."service-account.json". - serviceAccountKey = builtins.readFile - ("/var/lib/hercules-ci-agent/secrets/service-account.json"); - - # Filter out systems that this machine does not support. - systems = lib.filterAttrs (_: v: builtins.elem v supportedSystems) { - linux = "x86_64-linux"; - darwin = "x86_64-darwin"; - }; - - # Build the ci matrix for each of the supported systems, see pkgsFinal - # for the total set of attributes that will be evaluated per system. -in libLocal.dimension "system" systems (systemName: system: - let - pkgsShared = import ./default.nix { - inherit system; - - enableStatic = false; - }; - - pkgsStatic = import ./default.nix { - inherit system; - - enableStatic = true; - }; - - # Filter the stack project to only our locally declared packages. - pkgsHaskell = haskell-nix.haskellLib.selectProjectPackages pkgsStatic.hs; - - # The top-level set of attributes to build on ci. - pkgsFinal = { - # Expose select packages to increase signal-to-noise of the ci dashboard. - inherit (pkgsStatic) urbit; - inherit (pkgsShared) urbit-tests; - - # Expose the nix-shell derivation as a sanity check + possible cache hit. - shell = import ./shell.nix; - - # Replace the .hs attribute with the individual collections of components - # displayed as top-level attributes: - # - # .hs.library.[...] - # .hs.checks.[...] - # .hs.tests.[...] - # .hs.benchmarks.[...] - # ... - # - # Note that .checks are the actual _execution_ of the tests. - hs = libLocal.collectHaskellComponents pkgsHaskell; - - # Push the tarball to the google storage bucket for the current platform. - release = let inherit (pkgsStatic) tarball; - in libLocal.pushStorageObject { - inherit serviceAccountKey; - - bucket = "bootstrap.urbit.org"; - object = "ci/${lib.removePrefix "/nix/store/" (toString tarball)}"; - name = tarball.name; - file = tarball.out; - contentType = "application/x-gtar"; - }; - }; - - # Filter derivations that have meta.platform missing the current system, - # such as testFakeShip on darwin. - platformFilter = libLocal.platformFilterGeneric system; - - in libLocal.filterAttrsOnlyRecursive (_: v: platformFilter v) pkgsFinal) diff --git a/default.nix b/default.nix index 3448a2a586..439899c3c4 100644 --- a/default.nix +++ b/default.nix @@ -27,7 +27,7 @@ $ nix-build -A brass.build $ nix-build -A solid.build - Run the king-haskell tests: + Run the king-haskell checks (.tests are _build_ the test code, .checks _runs_): $ nix-build -A hs.urbit-king.checks.urbit-king-tests @@ -123,9 +123,14 @@ let # Additional top-level packages and attributes exposed for convenience. pkgsExtra = with pkgsLocal; rec { - # Expose packages we've local customisations (like patches) for easy access. + # Expose packages with local customisations (like patches) for dev access. inherit (pkgsCross) libsigsegv; + # Collect haskell check (aka "run the tests") attributes so we can run every + # test for our local haskell packages, similar to the urbit-tests attribute. + hs-checks = (pkgsNative.recurseIntoAttrs + (libLocal.collectHaskellComponents pkgsLocal.hs)).checks; + urbit-debug = urbit.override { enableDebug = true; }; urbit-tests = libLocal.testFakeShip { inherit herb; @@ -137,8 +142,6 @@ let ivory-ropsten = ivory.override { arvo = arvo.ropsten; }; brass-ropsten = brass.override { arvo = arvo.ropsten; }; - # FIXME: tarball binaries need executable permissions set? - # Create a .tgz of the primary binaries. tarball = let name = "urbit-v${urbit.version}-${urbit.system}"; @@ -154,8 +157,8 @@ let }; # A convenience function for constructing a shell.nix for any of the - # localPackage derivations by automatically propagating any dependencies such - # as buildInputs to the nix-shell. + # pkgsLocal derivations by automatically propagating any dependencies + # to the nix-shell. # # Example: # diff --git a/nix/lib/default.nix b/nix/lib/default.nix index 72e083a693..3d70c745ca 100644 --- a/nix/lib/default.nix +++ b/nix/lib/default.nix @@ -2,85 +2,36 @@ { lib, recurseIntoAttrs, haskell-nix, callPackage }: -let +rec { + bootFakeShip = callPackage ./boot-fake-ship.nix { }; - # Fetchers + Import from derivations (IFDs) - fetchers = rec { - bootFakeShip = callPackage ./boot-fake-ship.nix { }; + testFakeShip = callPackage ./test-fake-ship.nix { inherit bootFakeShip; }; - testFakeShip = callPackage ./test-fake-ship.nix { inherit bootFakeShip; }; + fetchGitHubLFS = callPackage ./fetch-github-lfs.nix { }; - fetchGitHubLFS = callPackage ./fetch-github-lfs.nix { }; + makeReleaseTarball = callPackage ./make-release-tarball.nix { }; - makeReleaseTarball = callPackage ./make-release-tarball.nix { }; - - pushStorageObject = - callPackage ./push-storage-object.nix { inherit makeEffect; }; - - makeEffect = callPackage ./effect { }; - }; - -in fetchers // rec { - # Library functions - - inherit (import ./dimension.nix) dimension; - - # A filter for removing packages that aren't supported on the current platform - # according to 'meta.platforms'. - platformFilterGeneric = system: - # This needs to use the correct nixpkgs version so all the systems line up - let - platform = lib.systems.elaborate { inherit system; }; - # Can't just default to [] for platforms, since no meta.platforms - # means "all platforms" not "no platforms" - in drv: - if drv ? meta && drv.meta ? platforms then - lib.any (lib.meta.platformMatch platform) drv.meta.platforms - else - true; - - # Keep derivations and attrsets with 'recurseForDerivations'. - # This ensures that we match the derivations that Hercules will see. - filterDerivations = filterAttrsOnlyRecursive - (n: attrs: lib.isDerivation attrs || attrs.recurseForDerivations or false); - - # A version of 'filterAttrsRecursive' that doesn't recurse into derivations. - # This prevents us from going into an infinite loop with the 'out' attribute - # on derivations. - filterAttrsOnlyRecursive = pred: set: - lib.listToAttrs (lib.concatMap (name: - let v = set.${name}; - in if pred name v then - [ - (lib.nameValuePair name - (if builtins.isAttrs v && !lib.isDerivation v then - filterAttrsOnlyRecursive pred v - else - v)) - ] - else - [ ]) (builtins.attrNames set)); - - collectHaskellComponents = packages: + collectHaskellComponents = project: let - # These functions pull out from the Haskell package set either all the + # These functions pull out from the Haskell project either all the # components of a particular type, or all the checks. - collectChecks = _: ps: - recurseIntoAttrs (builtins.mapAttrs (_: p: p.checks) ps); + pkgs = haskell-nix.haskellLib.selectProjectPackages project; - collectComponents = type: ps: - haskell-nix.haskellLib.collectComponents' type ps; + collectChecks = _: + recurseIntoAttrs (builtins.mapAttrs (_: p: p.checks) pkgs); - # This computes the Haskell package set sliced by component type - in recurseIntoAttrs (dimension "haskell" { + collectComponents = type: + haskell-nix.haskellLib.collectComponents' type pkgs; + + # Recompute the Haskell package set sliced by component type + in builtins.mapAttrs (type: f: f type) { # These names must match the subcomponent: components..<...> "library" = collectComponents; "tests" = collectComponents; "benchmarks" = collectComponents; "exes" = collectComponents; "checks" = collectChecks; - } # Apply the selector to the Haskell package set - (type: selector: (selector type) packages)); + }; } diff --git a/nix/lib/dimension.nix b/nix/lib/dimension.nix deleted file mode 100644 index b4dcaf5eb8..0000000000 --- a/nix/lib/dimension.nix +++ /dev/null @@ -1,110 +0,0 @@ -# From https://github.com/input-output-hk/plutus/blob/99f3a16cdf20e9e78a6105a097956a3773466b14/nix/dimension.nix -{ - /* dimension: name -> attrs -> function -> attrs - where - function: keyText -> value -> attrsOf package - - WARNING: Attribute names must not contain periods ("."). - See https://github.com/NixOS/nix/issues/3088 - - NOTE: The dimension name will be picked up by agent and web ui soon. - - Specifies a dimension of the build matrix. For example - - dimension "Example" { - withP = { p = true; } - withoutP = { p = false; } - } (key: # either "withP" or "withoutP" - { p }: # either p = true or p = false - myProject p - ) - - evaluates roughly to - - { - withP = myProject true; - withoutP = myProject false; - } - - Use nested calls for multiple dimensions. - - Example: - - dimension "System" { - "x86_64-linux" = {}; - # ... - }: (system: {}: - - dimension "Nixpkgs release" ( - { - "nixpkgs-19_03".nixpkgs = someSource - } // optionalAttrs (system != "...") { - "nixpkgs-unstable".nixpkgs = someOtherSource - } - ) (_key: { nixpkgs }: - - myProject system nixpkgs - - ) - ) - - evaluates roughly to - - { - x86_64-linux.nixpkgs-19_03 = myProject "x86_64-linux" someSource; - x86_64-linux.nixpkgs-unstable = myProject "x86_64-linux" someOtherSource; - ... - } - - If you need to make references across attributes, you can do so by binding - the result. Wherever you write - - dimension "My dimension" {} (key: value: f1 key value) - - You can also write - - let - myDimension = dimension "My dimension" {} (key: value: f2 key value myDimension) - in - myDimension - - This example builds a single test runner to reuse across releases: - - let - overlay = - testRunnerPkgs: self: super: { - # ... - }; - myProject = - { nixpkgs, - pkgs ? import nixpkgs { overlays = [ overlay ]; }, - testRunnerPkgs ? pkgs - }: pkgs; - in - - let - latest = "nixpkgs-19_03"; - releases = - dimension "Nixpkgs release" - { - nixpkgs-18_09.nixpkgs = someSource - nixpkgs-19_03.nixpkgs = someOtherSource - } - (_key: { nixpkgs }: - - myProject { - inherit nixpkgs; - testRunnerPkgs = releases."${latest}"; - } - - ); - in releases; - */ - dimension = name: attrs: f: - builtins.mapAttrs (k: v: - let o = f k v; - in o // { recurseForDerivations = o.recurseForDerivations or true; }) - attrs // { - meta.dimension.name = name; - }; -} diff --git a/nix/lib/effect/default.nix b/nix/lib/effect/default.nix deleted file mode 100644 index c85a693cc6..0000000000 --- a/nix/lib/effect/default.nix +++ /dev/null @@ -1,122 +0,0 @@ -{ cacert, curl, jq, lib, runCommandNoCC, stdenvNoCC }: - -let - - defaultInputs = [ effectSetupHook cacert curl jq ]; - - mkDrv = args: - stdenvNoCC.mkDerivation (args // { - - phases = args.phases or "initPhase unpackPhase patchPhase ${ - args.preGetStatePhases or "" - } getStatePhase userSetupPhase ${ - args.preEffectPhases or "" - } effectPhase putStatePhase ${args.postEffectPhases or ""}"; - - name = args.name + "-effect"; - - # nativeBuildInputs normally corresponds to what the building machine can - # execute. Likewise, effects are executed on the machine type that would - # otherwise perform the build. - # To keep things simple and avoid "build" terminology, we alias this as "inputs". - nativeBuildInputs = (args.defaultInputs or defaultInputs) - ++ (args.inputs or [ ]) ++ (args.nativeBuildInputs or [ ]); - - isEffect = true; - - # TODO: Use structured attrs instead - secretsMap = builtins.toJSON (args.secretsMap or { }); - - }); - - invokeOverride = f: defaults: (lib.makeOverridable f defaults).override; - - effectSetupHook = runCommandNoCC "hercules-ci-effect-sh" { } '' - mkdir -p $out/nix-support - cp ${./effects-setup-hook.sh} $out/nix-support/setup-hook - ''; - -in invokeOverride mkDrv { - - preGetStatePhases = ""; - preEffectPhases = "priorCheckPhase"; - - # Extension point for reporting notifications etc that are less criticial and - # don't write state. - postEffectPhases = "effectCheckPhase"; - - initPhase = '' - # eof on stdin - exec /etc/passwd root:x:0:0:System administrator:/build/home:/run/current-system/sw/bin/bash - mkdir -p ~/.ssh - echo "BatchMode yes" >>~/.ssh/config - ''; - - userSetupPhase = '' - runHook preUserSetup - eval "$userSetupScript" - runHook postUserSetup - ''; - userSetupScript = ""; - - # TODO Read a variable to optionally bail out if not already ok. That won't - # permit a commit to fix a problem, which is why that isn't the current - # behavior. - # This variable can also be set dynamically by priorCheckScript to signal - # that the problem is severe enough to abort the effect and thus require - # manual intervention. - priorCheckPhase = '' - runHook prePriorCheck - if [[ -n "$priorCheckScript" ]]; then - if eval "$priorCheckScript"; then - echo 1>&2 -e 'Prior check \e[32;1mOK\e[0m.' - else - echo 1>&2 - echo 1>&2 -e 'WARNING: Prior check \e[31;1mFAILED\e[0m!' - echo 1>&2 - echo 1>&2 Continuing execution to allow subsequent steps to hopefully fix the problem. - fi - fi - - runHook postPriorCheck - ''; - priorCheckScript = ""; - - effectPhase = '' - runHook preEffect - eval "$effectScript" - runHook postEffect - ''; - effectScript = ""; - - effectCheckPhase = '' - runHook preEffectCheck - eval "$effectCheckScript" - runHook postEffectCheck - ''; - - getStatePhase = '' - runHook preGetState - eval "$getStateScript" - runHook postGetState - registerPutStatePhaseOnFailure - ''; - putStatePhase = '' - if [[ -z ''${PUT_STATE_DONE:-} ]]; then - runHook prePutState - eval "$putStateScript" - runHook postPutState - PUT_STATE_DONE=true - else - echo 1>&2 "NOTE: State has already been uploaded and was not uploaded again." - fi - ''; -} diff --git a/nix/lib/effect/effects-setup-hook.sh b/nix/lib/effect/effects-setup-hook.sh deleted file mode 100644 index 7e89ac64d7..0000000000 --- a/nix/lib/effect/effects-setup-hook.sh +++ /dev/null @@ -1,173 +0,0 @@ -# ---------------------------------------------------------------------------- -# prepare headers file for curl to talk to Hercules CI - - -initHerculesCIAPI() { - herculesCIHeaders=$PWD/hercules-ci.headers - jq $herculesCIHeaders -r '"Authorization: Bearer \(."hercules-ci".token)"' -} -preInitHooks+=("initHerculesCIAPI") - - -# ---------------------------------------------------------------------------- -# state crud - -getStateFile() { - local stateName="$1" - local stateFileName="${2:-$1}" - echo 1>&2 "fetching state file $stateName" - while true; do - http_code=$(curl \ - -H @$herculesCIHeaders \ - --retry-max-time 86400 --retry-connrefused --max-time 1800 \ - --silent --show-error \ - --location \ - "$HERCULES_CI_API_BASE_URL/api/v1/current-task/state/$stateName/data" \ - -o "$stateFileName" \ - -w '%{http_code}' - ); - case $http_code in - 200|204) - go_curl="false"; - break ;; - 408|421|429|5*) - echo 1>&2 "http status $http_code. Retrying..." - sleep 60 - continue ;; - 404) - echo 1>&2 "state file does not exist." - rm -f "$stateFileName" - break ;; - *) - echo 1>&2 "request failed with fatal status $http_code" - exit 1 ;; - esac - done -} - -putStateFile() { - local stateName="$1" - local stateFileName="${2:-$1}" - echo "pushing state file $stateName..." - curl \ - -H @$herculesCIHeaders \ - --retry-max-time 86400 --retry-connrefused --max-time 1800 \ - --silent --show-error \ - --location --fail \ - -XPUT \ - --upload-file "$stateFileName" \ - "$HERCULES_CI_API_BASE_URL/api/v1/current-task/state/$stateName/data" \ - ; - echo "pushing state successful." -} - - -# ---------------------------------------------------------------------------- -# uploading state on error too - -putStatePhaseOnFailure() { - if [[ -n $putStatePhase ]]; then - echo 'uploading state files after failure' 1>&2 - eval "$putStatePhase" - fi -} - -registerPutStatePhaseOnFailure() { - failureHooks=("putStatePhaseOnFailure" "${failureHooks[@]}") -} - -# ---------------------------------------------------------------------------- -# unpack fix - - -simpleCopyUnpack() { - local fn="$1" - cp --no-preserve=ownership --recursive --reflink=auto \ - -- $fn "$(stripHash "$fn")" \ - ; -} - -unpackCmdHooks+=(simpleCopyUnpack) - - -# ---------------------------------------------------------------------------- -# warn if run in wrong environment - - -if [[ "true" != ${IN_HERCULES_CI_EFFECT:-} ]]; then - - if [[ -n ${NIX_LOG_FD:-} ]]; then - cat 1>&2 <&2 <&2 "Could not find path $dataPath in secret $secretName" - fi -} - -readSecretJSON() { - local secretName="$1" - local dataPath="$2" - jq -c >~/.aws/credentials <"$privateName" - chmod 0400 "$privateName" - ssh-keygen -y -f "$privateName" >"$privateName.pub" -} - -writeDockerKey() { - local secretName="${1:-docker}" - local directory="${2:-$HOME/.docker}" - - mkdir -p $directory - - readSecretString "$secretName" .clientKey >"$directory/key.pem" - readSecretString "$secretName" .clientCertificate >"$directory/cert.pem" - readSecretString "$secretName" .CACertificate >"$directory/ca.pem" - - # Please permission checks if any - chmod 0400 "$directory"/{key,cert,ca}.pem -} -useDockerHost() { - local host="${1}" - local port="${2:-2376}" - export DOCKER_HOST=tcp://$host:$port - export DOCKER_TLS_VERIFY=1 -} diff --git a/nix/lib/push-storage-object.nix b/nix/lib/push-storage-object.nix deleted file mode 100644 index 11ee8a48e5..0000000000 --- a/nix/lib/push-storage-object.nix +++ /dev/null @@ -1,45 +0,0 @@ -{ lib, makeEffect, python3, google-cloud-sdk }: - -{ bucket, object, name, file, contentType, serviceAccountKey }: - -assert lib.asserts.assertMsg (builtins.isString serviceAccountKey) - "`serviceAccountKey` must contain the JSON contents of a service-account key"; - -let - - uri = "gs://${bucket}/${lib.removePrefix "/" object}"; - -in makeEffect { - inherit file uri contentType serviceAccountKey; - - name = "push-${name}"; - - inputs = [ (google-cloud-sdk.override { python = python3; }) ]; - - dontUnpack = true; - - effectScript = '' - export HOME="." - - gcloud auth activate-service-account \ - --verbosity=none --quiet --no-user-output-enabled \ - --key-file=- <<< $serviceAccountKey - - stat_uri() { - gsutil stat $uri - } - - if ! stat_uri; then - header "copying $file to $uri" - - gsutil -h "Content-Type:$contentType" cp $file $uri - - if ! stat_uri; then - header "failed pushing $file to $url" - exit 1 - fi - else - header "$uri already exists, skipping" - fi - ''; -} diff --git a/shell.nix b/shell.nix index 405e1ca93c..28a4c19f4a 100644 --- a/shell.nix +++ b/shell.nix @@ -12,7 +12,7 @@ let pkgs = import ./nix/default.nix { }; - localPackages = import ./default.nix { }; + pkgsLocal = import ./default.nix { }; # The non-Haskell packages which build inputs (dependencies) will be # propagated into the shell. This combines nixpkgs' mkShell behaviour @@ -23,11 +23,12 @@ let # # Typically the inputs listed here also have a shell.nix in their respective # source directory you can use, to avoid the Haskell/GHC dependencies. - inputsFrom = with localPackages; [ ent ge-additions herb libaes_siv urbit ]; + inputsFrom = with pkgsLocal; [ ent ge-additions herb libaes_siv urbit ]; - merge = name: pkgs.lib.concatLists (pkgs.lib.catAttrs name inputsFrom); + # Collect the named attribute from all dependencies listed in inputsFrom. + mergeFrom = name: pkgs.lib.concatLists (pkgs.lib.catAttrs name inputsFrom); -in localPackages.hs.shellFor { +in pkgsLocal.hs.shellFor { # Haskell packages from the stackProject which will have their # dependencies available in the shell. packages = ps: @@ -57,11 +58,11 @@ in localPackages.hs.shellFor { pkgs.shfmt pkgs.stack (import pkgs.sources.niv { }).niv - ] ++ merge "buildInputs"; + ] ++ mergeFrom "buildInputs"; - nativeBuildInputs = merge "nativeBuildInputs"; - propagatedBuildInputs = merge "propagatedBuildInputs"; - propagatedNativeBuildInputs = merge "propagatedNativeBuildInputs"; + nativeBuildInputs = mergeFrom "nativeBuildInputs"; + propagatedBuildInputs = mergeFrom "propagatedBuildInputs"; + propagatedNativeBuildInputs = mergeFrom "propagatedNativeBuildInputs"; shellHook = pkgs.lib.concatStringsSep "\n" (pkgs.lib.catAttrs "shellHook" (pkgs.lib.reverseList inputsFrom)); From 41ce22d6ae18678f9979f7ab5bef54f5c65fb6e7 Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Mon, 16 Nov 2020 15:57:35 -0800 Subject: [PATCH 610/933] herb/lens: add utilites for import/export --- pkg/arvo/app/dojo.hoon | 2 ++ pkg/arvo/app/lens.hoon | 63 ++++++++++++++++++++++++++++++---- pkg/arvo/mar/lens/command.hoon | 2 ++ pkg/arvo/sur/lens.hoon | 2 ++ pkg/herb/herb | 37 ++++++++++++++++++-- 5 files changed, 98 insertions(+), 8 deletions(-) diff --git a/pkg/arvo/app/dojo.hoon b/pkg/arvo/app/dojo.hoon index 2716c009f7..d225ef9e0b 100644 --- a/pkg/arvo/app/dojo.hoon +++ b/pkg/arvo/app/dojo.hoon @@ -1144,6 +1144,8 @@ $listen-api !! $export !! $import !! + $export-all !! + $import-all !! $as :* %as mar.source.com $(num +(num), source.com next.source.com) diff --git a/pkg/arvo/app/lens.hoon b/pkg/arvo/app/lens.hoon index 8c86f8f8d6..e08d3e395d 100644 --- a/pkg/arvo/app/lens.hoon +++ b/pkg/arvo/app/lens.hoon @@ -14,6 +14,28 @@ job=(unit [eyre-id=@ta com=command:lens]) == == +:: +++ export-app + |= [app=@tas our=@p now=@da] + .^(@ %gx /(scot %p our)/[app]/(scot %da now)/export/noun) +++ export-all + |= [our=@p now=@da] + ^- (list [@tas @]) + %+ turn + ^- (list @tas) + :~ %group-store + %metadata-store + %metadata-hook + %contact-store + %contact-hook + %invite-store + %chat-store + %chat-hook + %publish + %graph-store + == + |= app=@tas + [app (export-app app our now)] -- :: =| =state @@ -43,12 +65,15 @@ =/ com=command:lens (json:grab:lens-mark jon) :: - ?: ?=(%export -.source.com) - ~& [%export app.source.com] + ?+ -.source.com + :_ this(job.state (some [eyre-id com])) + [%pass /sole %agent [our.bowl %dojo] %watch /sole/[eyre-id]]~ + :: + %export :_ this(job.state (some [eyre-id com])) [%pass /export %agent [our.bowl app.source.com] %watch /export]~ :: - ?: ?=(%import -.source.com) + %import ?~ enc=(de:base64 base64-jam.source.com) !! :: @@ -57,8 +82,28 @@ :_ this(job.state (some [eyre-id com])) [%pass /import %agent [our.bowl app.source.com] %poke %import !>(c)]~ :: - :_ this(job.state (some [eyre-id com])) - [%pass /sole %agent [our.bowl %dojo] %watch /sole/[eyre-id]]~ + %export-all + =/ output (crip "{}-export/atom") + =/ jon + =/ =atom (jam (export-all our.bowl now.bowl)) + =/ =octs [(met 3 atom) atom] + =/ enc (en:base64 octs) + (pairs:enjs:format file+s+output data+s+enc ~) + :_ this + %+ give-simple-payload:app eyre-id + (json-response:gen jon) + :: + %import-all + =/ enc (de:base64 base64-jam.source.com) + ?~ enc !! + =/ by-app ;;((list [@tas @]) (cue q.u.enc)) + :_ this + %+ weld (give-simple-payload:app eyre-id not-found:gen) + %+ turn by-app + |= [app=@tas data=@] + ^- card:agent:gall + [%pass /import-all %agent [our.bowl app] %poke %import !>(data)] + == :: ++ on-watch |= =path @@ -68,7 +113,13 @@ (on-watch:def path) :: ++ on-leave on-leave:def -++ on-peek on-peek:def +++ on-peek + |= =path + ^- (unit (unit cage)) + ?+ path (on-peek:def path) + [%x %export-all ~] + ``noun+!>((jam (export-all our.bowl now.bowl))) + == ++ on-agent |= [=wire =sign:agent:gall] ^- (quip card:agent:gall _this) diff --git a/pkg/arvo/mar/lens/command.hoon b/pkg/arvo/mar/lens/command.hoon index b8f0532f2e..bd8a88cc9f 100644 --- a/pkg/arvo/mar/lens/command.hoon +++ b/pkg/arvo/mar/lens/command.hoon @@ -42,6 +42,8 @@ listen-api+(su ;~(plug sym ;~(pfix col sym))) export+so import+(ot app+so base64-jam+so ~) + export-all+none + import-all+(ot base64-jam+so ~) as+(ot mark+(su sym) next+source ~) hoon+(ot code+so next+source ~) == diff --git a/pkg/arvo/sur/lens.hoon b/pkg/arvo/sur/lens.hoon index 5503aa7581..0c75afa8c7 100644 --- a/pkg/arvo/sur/lens.hoon +++ b/pkg/arvo/sur/lens.hoon @@ -17,6 +17,8 @@ {$listen-api api/term event/term} {$export app/@t} {$import app/@t base64-jam/@t} + {$export-all ~} + {$import-all base64-jam/@t} == ++ sink $% {$stdout ~} diff --git a/pkg/herb/herb b/pkg/herb/herb index 94c02942a8..7f5bd69f88 100755 --- a/pkg/herb/herb +++ b/pkg/herb/herb @@ -145,6 +145,34 @@ class importFileAction(argparse.Action): res.source = {"import": {"app": new_value, "base64-jam": base_data}} +class importAllAction(argparse.Action): + """Handles the import-all statement. + + The --import-all statement reads in a jammed noun file from the path passed + in and stuffs it the base64 encoded version which gets passed into your + Urbit. + + """ + def __call__(self, parser, res, new_value, option_string): + logging.debug('%r %r' % (new_value, option_string)) + logging.debug('source %s' % res.source) + logging.debug('level %s' % res.level) + + # We check to see if there's a "{new_value}" file in the current + # working directory. If there isn't, we error + data = "" + filename = new_value + with open(filename, 'rb') as f: + data = f.read() + + if data == "": + raise ValueError('Failed to read jamfile') + + base_data = base64.b64encode(data) + + res.source = {"import-all": {"base64-jam": base_data}} + + class transformerAction(argparse.Action): """Handle transformer flag. @@ -350,6 +378,13 @@ parser.add_argument('-i', '--import', metavar='app-name', help='imports the application state', action=importFileAction) +parser.add_argument('-E', '--export-all', const={'export-all': None}, + help='exports data from all landscape apps', + action='store_const', dest='source') +parser.add_argument('-I', '--import-all', + metavar='jam-file', + help='imports data for all landscape apps', + action=importAllAction) parser.add_argument('-m', '--mark', which='as', metavar='mark', help='transform a source to another mark', @@ -398,10 +433,8 @@ sinks.add_argument('-p', '--app', which='app', metavar='app', action=sinkAction) - args = parser.parse_args(args) - if args.source is None: args.source = {"data": ''.join(sys.stdin)} From 050bcf0ab9908e5dcc1707db3a7bbea7f7cc4d38 Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Mon, 16 Nov 2020 15:59:40 -0800 Subject: [PATCH 611/933] vere: add -i and -o options for import and export --- pkg/urbit/daemon/main.c | 12 ++++++++++-- pkg/urbit/include/vere/vere.h | 2 ++ pkg/urbit/vere/io/fore.c | 30 ++++++++++++++++++++++++++++++ pkg/urbit/vere/pier.c | 17 +++++++++++++++++ 4 files changed, 59 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/daemon/main.c b/pkg/urbit/daemon/main.c index 9918726406..4ef173240c 100644 --- a/pkg/urbit/daemon/main.c +++ b/pkg/urbit/daemon/main.c @@ -74,6 +74,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.abo = c3n; u3_Host.ops_u.dem = c3n; u3_Host.ops_u.dry = c3n; + u3_Host.ops_u.exp = c3n; u3_Host.ops_u.gab = c3n; u3_Host.ops_u.git = c3n; @@ -96,7 +97,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.kno_w = DefaultKernel; while ( -1 != (ch_i=getopt(argc, argv, - "X:Y:G:J:B:K:A:H:I:C:w:u:e:F:k:n:p:r:LljacdgqstvxPDRS")) ) + "X:Y:G:J:B:K:A:H:I:C:w:u:e:F:k:n:p:r:i:LljacdgoqstvxPDRS")) ) { switch ( ch_i ) { case 'X': { @@ -187,6 +188,10 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.roc_c = strdup(optarg); break; } + case 'i': { + u3_Host.ops_u.imp_c = strdup(optarg); + break; + } case 'L': { u3_Host.ops_u.net = c3n; break; } case 'l': { u3_Host.ops_u.lit = c3y; break; } case 'j': { u3_Host.ops_u.tra = c3y; break; } @@ -194,6 +199,7 @@ _main_getopt(c3_i argc, c3_c** argv) case 'c': { u3_Host.ops_u.nuu = c3y; break; } case 'd': { u3_Host.ops_u.dem = c3y; break; } case 'g': { u3_Host.ops_u.gab = c3y; break; } + case 'o': { u3_Host.ops_u.exp = c3y; break; } case 'P': { u3_Host.ops_u.pro = c3y; break; } case 'D': { u3_Host.ops_u.dry = c3y; break; } case 'q': { u3_Host.ops_u.qui = c3y; break; } @@ -398,10 +404,12 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-e url Ethereum gateway\n", "-F ship Fake keys; also disables networking\n", "-g Set GC flag\n", + "-i jam_file import pier state\n", "-j Create json trace file in .urb/put/trace\n", "-K stage Start at Hoon kernel version stage\n", "-k keys Private key file\n", "-L local networking only\n", + "-o export pier state\n", "-P Profiling\n", "-p ames_port Set the ames port to bind to\n", "-q Quiet\n", @@ -415,7 +423,7 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-w name Boot as ~name\n", "-X path Scry, jam to file, then exit\n" "-x Exit immediately\n", - "-Y file Optional name of jamfile (for -X)\n" + "-Y file Optional name of jamfile (for -X and -o)\n" "\n", "Development Usage:\n", " To create a development ship, use a fakezod:\n", diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index de62a3fdd1..ba38d0c666 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -265,6 +265,8 @@ c3_o gab; // -g, test garbage collection c3_c* dns_c; // -H, ames bootstrap domain c3_c* jin_c; // -I, inject raw event + c3_c* imp_c; // -i, import pier state + c3_o exp; // -o, export pier state c3_w hap_w; // -C, cap memo cache c3_c* lit_c; // -J, ivory (fastboot) kernel c3_o tra; // -j, json trace diff --git a/pkg/urbit/vere/io/fore.c b/pkg/urbit/vere/io/fore.c index 96f6dd53b7..8eea61f226 100644 --- a/pkg/urbit/vere/io/fore.c +++ b/pkg/urbit/vere/io/fore.c @@ -69,6 +69,32 @@ _fore_inject(u3_auto* car_u, c3_c* pax_c) u3z(ovo); } +/* _fore_import(): form an ovum from jammed archive at [pax_c] and inject it. +*/ +static void +_fore_import(u3_auto* car_u, c3_c* pax_c) +{ + // With apologies + u3_noun arc = u3ke_cue(u3m_file(pax_c)); + c3_c * b64_c = u3r_string(u3do("crip", u3do("en-base64:mimes:html", arc))); + c3_w siz = strlen(b64_c) + 120; + + c3_c bod_c[siz]; + snprintf(bod_c, siz, + "{\"source\": {\"import-all\": {\"base64-jam\": \"%s\"}}, \ + \"sink\": {\"stdout\": null}}", b64_c); + u3_noun dat = u3nt(u3_nul, u3i_word(strlen(bod_c)), u3i_string(bod_c)); + + u3_noun req = u3nt(c3n, + u3nc(u3i_string("ipv4"), u3i_word(0x7f000001)), + u3nq(u3i_string("POST"), u3i_string("/"), u3_nul, dat)); + u3_noun wir = u3nc(u3i_string("http-server"), u3_nul); + u3_noun cad = u3nc(u3i_string("request-local"), req); + u3_auto_peer( + u3_auto_plan(car_u, u3_ovum_init(0, c3__e, wir, cad)), + 0, 0, _fore_inject_bail); +} + /* _fore_io_talk(): */ static void @@ -106,6 +132,10 @@ _fore_io_talk(u3_auto* car_u) if ( u3_Host.ops_u.jin_c ) { _fore_inject(car_u, u3_Host.ops_u.jin_c); } + + if ( u3_Host.ops_u.imp_c ) { + _fore_import(car_u, u3_Host.ops_u.imp_c); + } } /* _fore_io_kick(): handle no effects. diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index fd0828a40e..289f1768a9 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -606,6 +606,23 @@ _pier_work_init(u3_pier* pir_u) } u3z(pex); } + else if ( _(u3_Host.ops_u.exp) ) { + u3_noun pex = u3do("stab", u3i_string("/gx/lens/export-all/noun")); + u3_noun car; + u3_noun dek; + u3_noun pax; + u3r_trel(pex, &car, &dek, &pax); + if (!u3_Host.ops_u.puk_c) { + u3_Host.ops_u.puk_c = strdup("/archive"); + } + // run the requested scry, jam to disk, then exit + // + u3l_log("pier: scry\n"); + u3_pier_peek_last(pir_u, u3_nul, u3k(car), u3k(dek), u3k(pax), + pir_u, _pier_on_scry_done); + u3z(pex); + + } else { // initialize i/o drivers // From 11f8ba23d783a751722f3ff87e5a002c113cbf3b Mon Sep 17 00:00:00 2001 From: John Franklin Date: Tue, 17 Nov 2020 01:05:17 -0600 Subject: [PATCH 612/933] hoon: bscl to bccl, etc --- pkg/arvo/app/dojo.hoon | 2 +- pkg/arvo/gen/ivory.hoon | 4 +- pkg/arvo/gen/solid.hoon | 2 +- pkg/arvo/lib/language-server/complete.hoon | 10 +- pkg/arvo/lib/language-server/easy-print.hoon | 12 +- pkg/arvo/lib/pprint.hoon | 80 +-- pkg/arvo/lib/xray.hoon | 32 +- pkg/arvo/sys/hoon.hoon | 594 +++++++++---------- pkg/arvo/sys/vane/clay.hoon | 6 +- 9 files changed, 372 insertions(+), 370 deletions(-) diff --git a/pkg/arvo/app/dojo.hoon b/pkg/arvo/app/dojo.hoon index a15980b70d..242730996c 100644 --- a/pkg/arvo/app/dojo.hoon +++ b/pkg/arvo/app/dojo.hoon @@ -897,7 +897,7 @@ ++ dy-hoon-var =+ ^= ope |= gen/hoon ^- hoon - ?: ?=(?($sgld $sgbn) -.gen) + ?: ?=(?($sggl $sggr) -.gen) $(gen q.gen) =+ ~(open ap gen) ?.(=(gen -) $(gen -) gen) diff --git a/pkg/arvo/gen/ivory.hoon b/pkg/arvo/gen/ivory.hoon index 36299409be..7e281858e4 100644 --- a/pkg/arvo/gen/ivory.hoon +++ b/pkg/arvo/gen/ivory.hoon @@ -33,8 +33,8 @@ :: Parsed with a static path for reproducibility. :: =/ whole-hoon=hoon - :+ %tsbn compiler-hoon - :+ %tsld (rain /sys/arvo/hoon arvo-source) + :+ %tsgr compiler-hoon + :+ %tsgl (rain /sys/arvo/hoon arvo-source) [%$ 7] :: compile the whole schmeer :: diff --git a/pkg/arvo/gen/solid.hoon b/pkg/arvo/gen/solid.hoon index 7a26757ef6..e5fbe63fde 100644 --- a/pkg/arvo/gen/solid.hoon +++ b/pkg/arvo/gen/solid.hoon @@ -35,7 +35,7 @@ :: compile arvo against hoon, with our current compiler :: =/ whole-hoon=hoon - [%tsbn compiler-hoon [%tsbn [%$ 7] (rain arvo-path arvo-src)]] + [%tsgr compiler-hoon [%tsgr [%$ 7] (rain arvo-path arvo-src)]] ~& %solid-parsed =/ whole-formula q:(~(mint ut %noun) %noun whole-hoon) ~& %solid-arvo diff --git a/pkg/arvo/lib/language-server/complete.hoon b/pkg/arvo/lib/language-server/complete.hoon index b42b65448d..a413203caa 100644 --- a/pkg/arvo/lib/language-server/complete.hoon +++ b/pkg/arvo/lib/language-server/complete.hoon @@ -144,7 +144,7 @@ [^ *] (both p.gen q.gen) [%ktcn *] loop(gen p.gen) [%brcn *] (grow q.gen) - [%brvt *] (grow q.gen) + [%brpt *] (grow q.gen) [%cnts *] |- ^- (unit [term type]) =* inner-loop $ @@ -165,13 +165,13 @@ [%hand *] ~ [%ktbr *] loop(gen p.gen) [%ktls *] (both p.gen q.gen) - [%ktpd *] loop(gen p.gen) + [%ktpm *] loop(gen p.gen) [%ktsg *] loop(gen p.gen) [%ktwt *] loop(gen p.gen) [%note *] loop(gen q.gen) [%sgzp *] (both p.gen q.gen) - [%sgbn *] loop(gen q.gen) :: should check for hoon in p.gen - [%tsbn *] (change p.gen q.gen) + [%sggr *] loop(gen q.gen) :: should check for hoon in p.gen + [%tsgr *] (change p.gen q.gen) [%tscm *] %+ replace loop(gen p.gen) @@ -185,7 +185,7 @@ [%lost *] loop(gen p.gen) [%zpmc *] (both p.gen q.gen) [%zpts *] loop(gen p.gen) - [%zpvt *] (both q.gen r.gen) + [%zppt *] (both q.gen r.gen) [%zpzp *] ~ * =+ doz=~(open ap gen) diff --git a/pkg/arvo/lib/language-server/easy-print.hoon b/pkg/arvo/lib/language-server/easy-print.hoon index 0c6827dde1..1a24152754 100644 --- a/pkg/arvo/lib/language-server/easy-print.hoon +++ b/pkg/arvo/lib/language-server/easy-print.hoon @@ -17,7 +17,7 @@ {$face p/term q/wine} {$list p/term q/wine} {$pear p/term q/@} - {$bswt p/(list wine)} + {$bcwt p/(list wine)} {$plot p/(list wine)} {$stop p/@ud} {$tree p/term q/wine} @@ -122,7 +122,7 @@ =^ cox gid $(q.ham q.q.ham) :_(gid [%rose [" " (weld (trip p.q.ham) "(") ")"] cox ~]) :: - {$bswt *} + {$bcwt *} =^ coz gid (many p.q.ham) :_(gid [%rose [[' ' ~] ['?' '(' ~] [')' ~]] coz]) :: @@ -265,7 +265,7 @@ ~ [~ u.for u.aft] :: - {$bswt *} + {$bcwt *} |- ^- (unit tank) ?~ p.q.ham ~ @@ -354,7 +354,7 @@ ^= woz ^- wine ?. ?=({$stop *} q.ham) - ?: ?& ?= {$bswt {$pear $n $0} {$plot {$pear $n $0} {$face *} ~} ~} + ?: ?& ?= {$bcwt {$pear $n $0} {$plot {$pear $n $0} {$face *} ~} ~} q.ham =(1 (met 3 p.i.t.p.i.t.p.q.ham)) == @@ -364,7 +364,7 @@ ?~ may q.ham =+ nul=[%pear %n 0] - ?. ?& ?=({$bswt *} u.may) + ?. ?& ?=({$bcwt *} u.may) ?=({* * ~} p.u.may) |(=(nul i.p.u.may) =(nul i.t.p.u.may)) == @@ -458,7 +458,7 @@ :: {$fork *} =+ yed=(sort ~(tap in p.sut) aor) - =- [p [%bswt q]] + =- [p [%bcwt q]] |- ^- {p/{p/(map type @) q/(map @ wine)} q/(list wine)} ?~ yed [dex ~] diff --git a/pkg/arvo/lib/pprint.hoon b/pkg/arvo/lib/pprint.hoon index fcb2cf5184..baecd5e7fe 100644 --- a/pkg/arvo/lib/pprint.hoon +++ b/pkg/arvo/lib/pprint.hoon @@ -340,7 +340,7 @@ [%brsg *] (rune '|~' ~ ~ (spec p.x) (hn q.x) ~) [%brtr *] (rune '|*' ~ ~ (spec p.x) (hn q.x) ~) [%brts *] (rune '|=' ~ ~ (spec p.x) (hn q.x) ~) - [%brvt *] (chapter '|@' ~ q.x) :: Ignoring p.x + [%brpt *] (chapter '|@' ~ q.x) :: Ignoring p.x [%brwt *] (rune '|?' ~ ~ (hn p.x) ~) [%clcb *] (rune ':_' ~ ~ (hoons ~[p q]:x)) [%clkt *] (rune ':^' ~ ~ (hoons ~[p q r s]:x)) @@ -370,7 +370,7 @@ [%ktdt *] (rune '^.' ~ ~ (hoons ~[p q]:x)) [%ktls *] (rune '^+' ~ ~ (hoons ~[p q]:x)) [%kthp *] (rune '^-' ~ ~ ~[(spec p.x) (hn q.x)]) - [%ktpd *] (rune '^&' ~ ~ (hoons ~[p]:x)) + [%ktpm *] (rune '^&' ~ ~ (hoons ~[p]:x)) [%ktsg *] (rune '^~' ~ ~ (hoons ~[p]:x)) [%ktts *] (rune '^=' ~ `['' '=' ''] ~[(skin p.x) (hn q.x)]) [%ktwt *] (rune '^?' ~ ~ (hoons ~[p]:x)) @@ -379,56 +379,58 @@ [%sgbr *] (rune '~|' ~ ~ (hoons ~[p q]:x)) [%sgcb *] (rune '~_' ~ ~ (hoons ~[p q]:x)) [%sgcn *] (rune '~%' ~ ~ (chum p.x) (hn q.x) (tyre r.x) (hn s.x) ~) - [%sgnt *] (rune '~/' ~ ~ (chum p.x) (hn q.x) ~) - [%sgld *] (rune '~<' ~ ~ (hint p.x) (hn q.x) ~) - [%sgbn *] (rune '~>' ~ ~ (hint p.x) (hn q.x) ~) - [%sgbs *] (rune '~$' ~ ~ p.x (hn q.x) ~) + [%sgfs *] (rune '~/' ~ ~ (chum p.x) (hn q.x) ~) + [%sggl *] (rune '~<' ~ ~ (hint p.x) (hn q.x) ~) + [%sggr *] (rune '~>' ~ ~ (hint p.x) (hn q.x) ~) + [%sgbc *] (rune '~$' ~ ~ p.x (hn q.x) ~) [%sgls *] (rune '~+' ~ ~ (hn q.x) ~) :: Ignoring p.x - [%sgpd *] (rune '~&' ~ ~ (hoons ~[q r]:x)) :: Ignoring p.x + [%sgpm *] (rune '~&' ~ ~ (hoons ~[q r]:x)) :: Ignoring p.x [%sgts *] (rune '~=' ~ ~ (hoons ~[p q]:x)) [%sgwt *] (rune '~?' ~ ~ (hoons ~[q r s]:x)) :: Ignoring p.x [%sgzp *] (rune '~!' ~ ~ (hoons ~[p q]:x)) [%mcts *] %ast-node-mcts [%mccl *] (rune ';:' `'==' `[':(' spc ')'] (hoons [p q]:x)) - [%mcnt *] (rune ';/' ~ ~ (hoons ~[p]:x)) + [%mcfs *] (rune ';/' ~ ~ (hoons ~[p]:x)) [%mcgl *] (rune ';<' ~ ~ (spec p.x) (hoons ~[q r s]:x)) [%mcsg *] (rune ';~' `'==' ~ (hoons [p q]:x)) [%mcmc *] (rune ';;' ~ ~ ~[(spec p.x) (hn q.x)]) [%tsbr *] (rune '=|' ~ ~ ~[(spec p.x) (hn q.x)]) [%tscl *] (tiscol-to-plum p.x q.x) - [%tsnt *] (rune '=/' ~ ~ (skin p.x) (hn q.x) (hn r.x) ~) + [%tsfs *] (rune '=/' ~ ~ (skin p.x) (hn q.x) (hn r.x) ~) [%tsmc *] (rune '=;' ~ ~ [(skin p.x) (hoons ~[q r]:x)]) [%tsdt *] (rune '=.' ~ ~ [(wing p.x) (hoons ~[q r]:x)]) [%tswt *] (rune '=?' ~ ~ [(wing p.x) (hoons ~[q r s]:x)]) - [%tsld *] (rune '=>' ~ `['' ':' ''] (hoons ~[p q]:x)) +:: XX %tsld to %tsgl, but should be %tsgr? (to match =>) + [%tsgl *] (rune '=>' ~ `['' ':' ''] (hoons ~[p q]:x)) [%tshp *] (rune '=-' ~ ~ (hoons ~[p q]:x)) - [%tsbn *] (rune '=<' ~ ~ (hoons ~[p q]:x)) +:: XX %tsbn to %tsgr, but should be %tsgl? (to match =<) + [%tsgr *] (rune '=<' ~ ~ (hoons ~[p q]:x)) [%tskt *] (rune '=^' ~ ~ [(skin p.x) (wing q.x) (hoons ~[r s]:x)]) [%tsls *] (rune '=+' ~ ~ (hoons ~[p q]:x)) [%tssg *] (rune '=~' `'==' ~ (hoons p:x)) [%tstr *] ?~ q.p.x (rune '=*' ~ ~ p.p.x (hoons ~[q r]:x)) - (rune '=*' ~ ~ (spec [%bsts p.p.x u.q.p.x]) (hoons ~[q r]:x)) + (rune '=*' ~ ~ (spec [%bcts p.p.x u.q.p.x]) (hoons ~[q r]:x)) [%tscm *] (rune '=,' ~ ~ (hoons ~[p q]:x)) [%wtbr *] (rune '?|' `'--' `['|(' ' ' ')'] (hoons p:x)) [%wthp *] (rune '?-' `'==' ~ (wing p.x) (matches q.x)) [%wtcl *] (rune '?:' ~ ~ (hoons ~[p q r]:x)) [%wtdt *] (rune '?.' ~ ~ (hoons ~[p q r]:x)) [%wtkt *] (rune '?^' ~ ~ [(wing p.x) (hoons ~[q r]:x)]) - [%wtld *] (rune '?<' ~ ~ (hoons ~[p q]:x)) - [%wtbn *] (rune '?>' ~ ~ (hoons ~[p q]:x)) + [%wtgl *] (rune '?<' ~ ~ (hoons ~[p q]:x)) + [%wtgr *] (rune '?>' ~ ~ (hoons ~[p q]:x)) [%wtls *] (rune '?+' `'==' ~ (wing p.x) (hn q.x) (matches r.x)) - [%wtpd *] (rune '?&' `'==' `['&(' ' ' ')'] (hoons p:x)) - [%wtvt *] (rune '?@' ~ ~ (wing p.x) (hoons ~[q r]:x)) + [%wtpm *] (rune '?&' `'==' `['&(' ' ' ')'] (hoons p:x)) + [%wtpt *] (rune '?@' ~ ~ (wing p.x) (hoons ~[q r]:x)) [%wtsg *] (rune '?~' ~ ~ (wing p.x) (hoons ~[q r]:x)) [%wthx *] (rune '?#' ~ ~ (skin p.x) (wing q.x) ~) [%wtts *] (rune '?=' ~ ~ (spec p.x) (wing q.x) ~) [%wtzp *] (rune '?!' ~ `['!' '' ''] (hoons ~[p]:x)) [%zpcm *] (rune '!,' ~ ~ (hoons ~[p q]:x)) - [%zpbn *] (rune '!>' ~ ~ (hoons ~[p]:x)) + [%zpgr *] (rune '!>' ~ ~ (hoons ~[p]:x)) [%zpmc *] (rune '!;' ~ ~ (hoons ~[p q]:x)) [%zpts *] (rune '!=' ~ ~ (hoons ~[p]:x)) - [%zpvt *] (rune '!@' ~ ~ (wingseq p.x) (hoons ~[q r]:x)) + [%zppt *] (rune '!@' ~ ~ (wingseq p.x) (hoons ~[q r]:x)) [%zpwt *] (hn q.x) :: Ignore p.x [%zpzp ~] '!!' == @@ -642,37 +644,37 @@ ?: =(- 3) '%^' ?: =(- 2) '%+' '%-' [(dohoon p.spec) (turn q.spec ..$)] - %bsbs (core-spec-to-plum '$$' p.spec q.spec) - %bsbr (subtree (fixed '$|') $(spec p.spec) (dohoon q.spec) ~) - %bscb (dohoon p.spec) - %bscl :- %sbrk + %bcbc (core-spec-to-plum '$$' p.spec q.spec) + %bcbr (subtree (fixed '$|') $(spec p.spec) (dohoon q.spec) ~) + %bccb (dohoon p.spec) + %bccl :- %sbrk :+ %tree [`[' ' `['[' ']']] `['$:' `['' '==']]] (turn `(list ^spec)`+.spec ..$) - %bscn (subtree (varying '$%' '==') (turn `(list ^spec)`+.spec ..$)) - %bsdt (core-spec-to-plum '$.' p.spec q.spec) - %bsld (subtree (fixed '$<') $(spec p.spec) $(spec q.spec) ~) - %bsbn (subtree (fixed '$>') $(spec p.spec) $(spec q.spec) ~) - %bshp (subtree (fixed '$-') $(spec p.spec) $(spec q.spec) ~) - %bskt (subtree (fixed '$^') $(spec p.spec) $(spec q.spec) ~) - %bsls (subtree (fixed '$+') (stud-to-plum p.spec) $(spec q.spec) ~) - %bsnt (core-spec-to-plum '$/' p.spec q.spec) - %bsmc (subtree (fixed '$;') (dohoon p.spec) ~) - %bspd (subtree (fixed '$&') $(spec p.spec) (dohoon q.spec) ~) - %bssg (subtree (fixed '$~') (dohoon p.spec) $(spec q.spec) ~) - %bstc (core-spec-to-plum '$`' p.spec q.spec) - %bsts :- %sbrk + %bccn (subtree (varying '$%' '==') (turn `(list ^spec)`+.spec ..$)) + %bcdt (core-spec-to-plum '$.' p.spec q.spec) + %bcgl (subtree (fixed '$<') $(spec p.spec) $(spec q.spec) ~) + %bcgr (subtree (fixed '$>') $(spec p.spec) $(spec q.spec) ~) + %bchp (subtree (fixed '$-') $(spec p.spec) $(spec q.spec) ~) + %bckt (subtree (fixed '$^') $(spec p.spec) $(spec q.spec) ~) + %bcls (subtree (fixed '$+') (stud-to-plum p.spec) $(spec q.spec) ~) + %bcfs (core-spec-to-plum '$/' p.spec q.spec) + %bcmc (subtree (fixed '$;') (dohoon p.spec) ~) + %bcpm (subtree (fixed '$&') $(spec p.spec) (dohoon q.spec) ~) + %bcsg (subtree (fixed '$~') (dohoon p.spec) $(spec q.spec) ~) + %bctc (core-spec-to-plum '$`' p.spec q.spec) + %bcts :- %sbrk :+ %tree [`['=' ~] `['$=' ~]] :~ (skin-to-plum p.spec) $(spec q.spec) == - %bsvt (subtree (fixed '$@') $(spec p.spec) $(spec q.spec) ~) - %bswt :- %sbrk + %bcpt (subtree (fixed '$@') $(spec p.spec) $(spec q.spec) ~) + %bcwt :- %sbrk :+ %tree [`[' ' `['?(' ')']] `['$?' `['' '==']]] (turn `(list ^spec)`+.spec ..$) - %bszp (core-spec-to-plum '$.' p.spec q.spec) + %bczp (core-spec-to-plum '$.' p.spec q.spec) == :: ++ varying @@ -850,7 +852,7 @@ |= [=sample=xkey =product=xkey] ^- plum %- spec-to-plum :* - %bshp + %bchp (ximage-to-spec:libxray sample-xkey img) (ximage-to-spec:libxray product-xkey img) == diff --git a/pkg/arvo/lib/xray.hoon b/pkg/arvo/lib/xray.hoon index b9d340255f..54d3e1a63a 100644 --- a/pkg/arvo/lib/xray.hoon +++ b/pkg/arvo/lib/xray.hoon @@ -355,8 +355,8 @@ =^ params=(list xkey) st |- ^- [(list xkey) xtable] ?~ u.q.note [~ st] - =/ tsld [%tsld [%limb %$] [%wing i.u.q.note]] - =/ part (~(play ut subject-of-note) tsld) + =/ tsgl [%tsgl [%limb %$] [%wing i.u.q.note]] + =/ part (~(play ut subject-of-note) tsgl) =^ this st (main st part) =^ more st $(u.q.note t.u.q.note) [[this more] st] @@ -1774,34 +1774,34 @@ =/ tl `spec`$(i tail.d) =/ both-basic &(=([%base %noun] hd) =([%base %noun] tl)) ?: both-basic [%base %cell] - ?: ?=(%bscl -.tl) [%bscl hd +.tl] - [%bscl hd tl ~] + ?: ?=(%bccl -.tl) [%bccl hd +.tl] + [%bccl hd tl ~] %core =/ payld $(i xray.d) =/ batt ^- (map term spec) %- ~(run by (flatten-battery batt.d)) |= =xkey ^$(i xkey) ?- r.garb.d - %lead [%bszp payld batt] - %gold [%bsdt payld batt] - %zinc [%bstc payld batt] - %iron [%bsnt payld batt] + %lead [%bczp payld batt] + %gold [%bcdt payld batt] + %zinc [%bctc payld batt] + %iron [%bcfs payld batt] == %pntr !! %face =/ =spec $(i xray.d) - ?^(face.d spec [%bsts face.d spec]) + ?^(face.d spec [%bcts face.d spec]) %fork =/ =xrole (need xrole.x) |^ ?+ xrole ~& [%unexpected-fork-xrole xkey.x d xrole choices] - [%bswt choices] + [%bcwt choices] %noun [%base %noun] %void [%base %void] - [%option *] [%bswt choices] - [%union *] [%bscn choices] - [%misjunction *] [%bswt choices] - [%junction *] :+ %bsvt + [%option *] [%bcwt choices] + [%union *] [%bccn choices] + [%misjunction *] [%bcwt choices] + [%junction *] :+ %bcpt ^$(i flat.xrole) ^$(i deep.xrole) - [%conjunction *] :+ %bskt + [%conjunction *] :+ %bckt ^$(i wide.xrole) ^$(i tall.xrole) == @@ -1821,7 +1821,7 @@ ^- spec ?. (need loop.xr) sp =/ nm (synthetic xkey.xr) - [%bsbs [%loop nm] [[nm sp] ~ ~]] + [%bcbc [%loop nm] [[nm sp] ~ ~]] :: :: If we have a `recipe`, we can generate much nicer output. :: diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 205d99107e..a1c02abfb6 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -2004,7 +2004,7 @@ :: A `wide` is a description of how to render a plum in a single :: line. The nested (`kids`) sub-plums will be interleaved with `delimit` :: strings, and, if `enclose` is set, then the output will be enclosed -:: with `p.u.enclose` abnd `q.u.enclose`. +:: with `p.u.enclose` and `q.u.enclose`. :: :: For example, to build a plumfmt for string literals, we could write: :: @@ -6653,26 +6653,26 @@ {$name p/term q/spec} :: annotate simple {$over p/wing q/spec} :: relative to subject :: :: - {$bsbn p/spec q/spec} :: $>, filter: require - {$bsbs p/spec q/(map term spec)} :: $$, recursion - {$bsbr p/spec q/hoon} :: $|, verify - {$bscb p/hoon} :: $_, example - {$bscl p/{i/spec t/(list spec)}} :: $:, tuple - {$bscn p/{i/spec t/(list spec)}} :: $%, head pick - {$bsdt p/spec q/(map term spec)} :: $., read-write core - {$bsld p/spec q/spec} :: $<, filter: exclude - {$bshp p/spec q/spec} :: $-, function core - {$bskt p/spec q/spec} :: $^, cons pick - {$bsls p/stud q/spec} :: $+, standard - {$bsnt p/spec q/(map term spec)} :: $/, write-only core - {$bsmc p/hoon} :: $;, manual - {$bspd p/spec q/hoon} :: $&, repair - {$bssg p/hoon q/spec} :: $~, default - {$bstc p/spec q/(map term spec)} :: $`, read-only core - {$bsts p/skin q/spec} :: $=, name - {$bsvt p/spec q/spec} :: $@, atom pick - {$bswt p/{i/spec t/(list spec)}} :: $?, full pick - {$bszp p/spec q/(map term spec)} :: $!, opaque core + {$bcgr p/spec q/spec} :: $>, filter: require + {$bcbc p/spec q/(map term spec)} :: $$, recursion + {$bcbr p/spec q/hoon} :: $|, verify + {$bccb p/hoon} :: $_, example + {$bccl p/{i/spec t/(list spec)}} :: $:, tuple + {$bccn p/{i/spec t/(list spec)}} :: $%, head pick + {$bcdt p/spec q/(map term spec)} :: $., read-write core + {$bcgl p/spec q/spec} :: $<, filter: exclude + {$bchp p/spec q/spec} :: $-, function core + {$bckt p/spec q/spec} :: $^, cons pick + {$bcls p/stud q/spec} :: $+, standard + {$bcfs p/spec q/(map term spec)} :: $/, write-only core + {$bcmc p/hoon} :: $;, manual + {$bcpm p/spec q/hoon} :: $&, repair + {$bcsg p/hoon q/spec} :: $~, default + {$bctc p/spec q/(map term spec)} :: $`, read-only core + {$bcts p/skin q/spec} :: $=, name + {$bcpt p/spec q/spec} :: $@, atom pick + {$bcwt p/{i/spec t/(list spec)}} :: $?, full pick + {$bczp p/spec q/(map term spec)} :: $!, opaque core == :: +$ tent :: model builder $% {%| p/wing q/tent r/(list spec)} :: ~(p q r...) @@ -6742,7 +6742,7 @@ {$yell p/(list hoon)} :: render as tank {$xray p/manx:hoot} :: ;foo; templating :: :::::: cores - {$brbs sample/(lest term) body/spec} :: |$ + {$brbc sample/(lest term) body/spec} :: |$ {$brcb p/spec q/alas r/(map term tome)} :: |_ {$brcl p/hoon q/hoon} :: |: {$brcn p/(unit term) q/(map term tome)} :: |% @@ -6752,7 +6752,7 @@ {$brsg p/spec q/hoon} :: |~ {$brtr p/spec q/hoon} :: |* {$brts p/spec q/hoon} :: |= - {$brvt p/(unit term) q/(map term tome)} :: |@ + {$brpt p/(unit term) q/(map term tome)} :: |@ {$brwt p/hoon} :: |? :: :::::: tuples {$clcb p/hoon q/hoon} :: :_ [q p] @@ -6783,7 +6783,7 @@ {$ktdt p/hoon q/hoon} :: ^. self-cast {$ktls p/hoon q/hoon} :: ^+ expression cast {$kthp p/spec q/hoon} :: ^- structure cast - {$ktpd p/hoon} :: ^& covariant + {$ktpm p/hoon} :: ^& covariant {$ktsg p/hoon} :: ^~ constant {$ktts p/skin q/hoon} :: ^= label {$ktwt p/hoon} :: ^? bivariant @@ -6793,32 +6793,32 @@ {$sgbr p/hoon q/hoon} :: ~| sell on trace {$sgcb p/hoon q/hoon} :: ~_ tank on trace {$sgcn p/chum q/hoon r/tyre s/hoon} :: ~% general jet hint - {$sgnt p/chum q/hoon} :: ~/ function j-hint - {$sgld p/$@(term {p/term q/hoon}) q/hoon} :: ~< backward hint - {$sgbn p/$@(term {p/term q/hoon}) q/hoon} :: ~> forward hint - {$sgbs p/term q/hoon} :: ~$ profiler hit + {$sgfs p/chum q/hoon} :: ~/ function j-hint + {$sggl p/$@(term {p/term q/hoon}) q/hoon} :: ~< backward hint + {$sggr p/$@(term {p/term q/hoon}) q/hoon} :: ~> forward hint + {$sgbc p/term q/hoon} :: ~$ profiler hit {$sgls p/@ q/hoon} :: ~+ cache/memoize - {$sgpd p/@ud q/hoon r/hoon} :: ~& printf/priority + {$sgpm p/@ud q/hoon r/hoon} :: ~& printf/priority {$sgts p/hoon q/hoon} :: ~= don't duplicate {$sgwt p/@ud q/hoon r/hoon s/hoon} :: ~? tested printf {$sgzp p/hoon q/hoon} :: ~! type on trace :: :::::: miscellaneous {$mcts p/marl:hoot} :: ;= list templating {$mccl p/hoon q/(list hoon)} :: ;: binary to nary - {$mcnt p/hoon} :: ;/ [%$ [%$ p ~] ~] + {$mcfs p/hoon} :: ;/ [%$ [%$ p ~] ~] {$mcgl p/spec q/hoon r/hoon s/hoon} :: ;< bind {$mcsg p/hoon q/(list hoon)} :: ;~ kleisli arrow {$mcmc p/spec q/hoon} :: ;; normalize :: :::::: compositions {$tsbr p/spec q/hoon} :: =| push bunt {$tscl p/(list (pair wing hoon)) q/hoon} :: =: q w/ p changes - {$tsnt p/skin q/hoon r/hoon} :: =/ typed variable + {$tsfs p/skin q/hoon r/hoon} :: =/ typed variable {$tsmc p/skin q/hoon r/hoon} :: =; =/(q p r) {$tsdt p/wing q/hoon r/hoon} :: =. r with p as q {$tswt p/wing q/hoon r/hoon s/hoon} :: =? conditional =. - {$tsld p/hoon q/hoon} :: =< =>(q p) + {$tsgl p/hoon q/hoon} :: =< =>(q p) {$tshp p/hoon q/hoon} :: =- =+(q p) - {$tsbn p/hoon q/hoon} :: => q w/subject p + {$tsgr p/hoon q/hoon} :: => q w/subject p {$tskt p/skin q/wing r/hoon s/hoon} :: =^ state machine {$tsls p/hoon q/hoon} :: =+ q w/[p subject] {$tssg p/(list hoon)} :: =~ hoon stack @@ -6830,22 +6830,22 @@ {$wtcl p/hoon q/hoon r/hoon} :: ?: if/then/else {$wtdt p/hoon q/hoon r/hoon} :: ?. ?:(p r q) {$wtkt p/wing q/hoon r/hoon} :: ?^ if p is a cell - {$wtld p/hoon q/hoon} :: ?< ?:(p !! q) - {$wtbn p/hoon q/hoon} :: ?> ?:(p q !!) + {$wtgl p/hoon q/hoon} :: ?< ?:(p !! q) + {$wtgr p/hoon q/hoon} :: ?> ?:(p q !!) {$wtls p/wing q/hoon r/(list (pair spec hoon))} :: ?+ ?- w/default - {$wtpd p/(list hoon)} :: ?& loobean and - {$wtvt p/wing q/hoon r/hoon} :: ?@ if p is atom + {$wtpm p/(list hoon)} :: ?& loobean and + {$wtpt p/wing q/hoon r/hoon} :: ?@ if p is atom {$wtsg p/wing q/hoon r/hoon} :: ?~ if p is null {$wthx p/skin q/wing} :: ?# if q matches p {$wtts p/spec q/wing} :: ?= if q matches p {$wtzp p/hoon} :: ?! loobean not :: :::::: special {$zpcm p/hoon q/hoon} :: !, - {$zpbn p/hoon} :: !> - {$zpld p/spec q/hoon} :: !< + {$zpgr p/hoon} :: !> + {$zpgl p/spec q/hoon} :: !< {$zpmc p/hoon q/hoon} :: !; {$zpts p/hoon} :: != - {$zpvt p/(list wing) q/hoon r/hoon} :: !@ + {$zppt p/(list wing) q/hoon r/hoon} :: !@ {$zpwt p/$@(p/@ {p/@ q/@}) q/hoon} :: !? {$zpzp ~} :: !! == :: @@ -7807,7 +7807,7 @@ |= gen/hoon ^- hoon ?. &(?=(%| -.tik) ?=(~ p.tik)) gen - [%tsbn [%$ 3] gen] + [%tsgr [%$ 3] gen] :: ++ teal |= mod/spec @@ -7843,7 +7843,7 @@ ++ wtls |= {gen/hoon opt/(list (pair spec hoon))} %+ gray %wtls [puce (blue gen) (turn opt |=({a/spec b/hoon} [a (blue b)]))] - ++ wtvt |=({sic/hoon non/hoon} (gray [%wtvt puce (blue sic) (blue non)])) + ++ wtpt |=({sic/hoon non/hoon} (gray [%wtpt puce (blue sic) (blue non)])) ++ wtsg |=({sic/hoon non/hoon} (gray [%wtsg puce (blue sic) (blue non)])) ++ wthx |=(syn/skin (gray [%wthx (tele syn) puce])) ++ wtts |=(mod/spec (gray [%wtts (teal mod) puce])) @@ -7880,26 +7880,26 @@ $over $(mod q.mod) $name $(mod q.mod) :: - $bsbs $(mod p.mod) - $bsbr $(mod p.mod) - $bscb ~(name ap p.mod) - $bscl $(mod i.p.mod) - $bscn $(mod i.p.mod) - $bsdt ~ - $bsld $(mod q.mod) - $bsbn $(mod q.mod) - $bshp $(mod p.mod) - $bskt $(mod q.mod) - $bsls $(mod q.mod) - $bsnt ~ - $bsmc ~(name ap p.mod) - $bspd $(mod p.mod) - $bssg $(mod q.mod) - $bstc ~ - $bsts $(mod q.mod) - $bsvt $(mod q.mod) - $bswt $(mod i.p.mod) - $bszp ~ + $bcbc $(mod p.mod) + $bcbr $(mod p.mod) + $bccb ~(name ap p.mod) + $bccl $(mod i.p.mod) + $bccn $(mod i.p.mod) + $bcdt ~ + $bcgl $(mod q.mod) + $bcgr $(mod q.mod) + $bchp $(mod p.mod) + $bckt $(mod q.mod) + $bcls $(mod q.mod) + $bcfs ~ + $bcmc ~(name ap p.mod) + $bcpm $(mod p.mod) + $bcsg $(mod q.mod) + $bctc ~ + $bcts $(mod q.mod) + $bcpt $(mod q.mod) + $bcwt $(mod i.p.mod) + $bczp ~ == ++ hint |= not/note @@ -7913,7 +7913,7 @@ ^- hoon :: minimal context as subject :: - :+ %tsbn + :+ %tsgr :: context is example of both specs :: [example:clear(mod fun) example:clear(mod arg)] @@ -7936,11 +7936,11 @@ =- ?- variance %gold - %lead [%ktwt -] - %zinc [%ktpd -] + %zinc [%ktpm -] %iron [%ktbr -] == ^- hoon - :+ %tsbn example:clear(mod payload) + :+ %tsgr example:clear(mod payload) :+ %brcn ~ =- [[%$ ~ -] ~ ~] %- ~(gas by *(map term hoon)) @@ -7964,7 +7964,7 @@ hay (weld hay `wing`[[%& dom] ~]) ?~ - gen - [%tsbn [%wing -] gen] + [%tsgr [%wing -] gen] :: ++ clear :: clear annotations @@ -8012,7 +8012,7 @@ ++ unreel |= [one/wing res/(list wing)] ^- hoon - ?~(res [%wing one] [%tsld [%wing one] $(one i.res, res t.res)]) + ?~(res [%wing one] [%tsgl [%wing one] $(one i.res, res t.res)]) :: ++ descend :: record an axis to original subject @@ -8060,7 +8060,7 @@ |- ^- hoon ?- mod {$base *} ?:(=(%void p.mod) [%rock %n 0] (basal p.mod)) - {$bsbs *} :: track hygienic recursion points lexically + {$bcbc *} :: track hygienic recursion points lexically :: %= $ mod p.mod @@ -8071,46 +8071,46 @@ {$dbug *} [%dbug p.mod $(mod q.mod)] {$leaf *} [%rock p.mod q.mod] {$loop *} ~|([%loop p.mod] $(mod (~(got by cox) p.mod))) - {$like *} $(mod bsmc/(unreel p.mod q.mod)) + {$like *} $(mod bcmc/(unreel p.mod q.mod)) {$made *} $(mod q.mod) - {$make *} $(mod bsmc/(unfold p.mod q.mod)) + {$make *} $(mod bcmc/(unfold p.mod q.mod)) {$name *} $(mod q.mod) {$over *} $(hay p.mod, mod q.mod) :: - {$bsbr *} $(mod p.mod) - {$bscb *} [%rock %n 0] - {$bscl *} |- ^- hoon + {$bcbr *} $(mod p.mod) + {$bccb *} [%rock %n 0] + {$bccl *} |- ^- hoon ?~ t.p.mod ^$(mod i.p.mod) :- ^$(mod i.p.mod) $(i.p.mod i.t.p.mod, t.p.mod t.t.p.mod) - {$bscn *} :: use last entry + {$bccn *} :: use last entry :: |- ^- hoon ?~ t.p.mod ^$(mod i.p.mod) $(i.p.mod i.t.p.mod, t.p.mod t.t.p.mod) - {$bshp *} :: see under %bscb + {$bchp *} :: see under %bccb :: [%rock %n 0] - {$bsld *} $(mod q.mod) - {$bsbn *} $(mod q.mod) - {$bskt *} $(mod q.mod) - {$bsls *} $(mod q.mod) - {$bsmc *} :: borrow sample + {$bcgl *} $(mod q.mod) + {$bcgr *} $(mod q.mod) + {$bckt *} $(mod q.mod) + {$bcls *} $(mod q.mod) + {$bcmc *} :: borrow sample :: - [%tsld [%$ 6] p.mod] - {$bspd *} $(mod p.mod) - {$bssg *} [%kthp q.mod p.mod] - {$bsts *} [%ktts p.mod $(mod q.mod)] - {$bsvt *} $(mod p.mod) - {$bswt *} :: use last entry + [%tsgl [%$ 6] p.mod] + {$bcpm *} $(mod p.mod) + {$bcsg *} [%kthp q.mod p.mod] + {$bcts *} [%ktts p.mod $(mod q.mod)] + {$bcpt *} $(mod p.mod) + {$bcwt *} :: use last entry :: |- ^- hoon ?~ t.p.mod ^$(mod i.p.mod) $(i.p.mod i.t.p.mod, t.p.mod t.t.p.mod) - {$bsdt *} [%rock %n 0] - {$bsnt *} [%rock %n 0] - {$bstc *} [%rock %n 0] - {$bszp *} [%rock %n 0] + {$bcdt *} [%rock %n 0] + {$bcfs *} [%rock %n 0] + {$bctc *} [%rock %n 0] + {$bczp *} [%rock %n 0] == :: ++ example @@ -8128,29 +8128,29 @@ {$base *} (decorate (basal p.mod)) {$dbug *} example(mod q.mod, bug [p.mod bug]) {$leaf *} (decorate [%rock p.mod q.mod]) - {$like *} example(mod bsmc/(unreel p.mod q.mod)) + {$like *} example(mod bcmc/(unreel p.mod q.mod)) {$loop *} [%limb p.mod] {$made *} example(mod q.mod, nut `made/[p.p.mod `(pieces q.p.mod)]) - {$make *} example(mod bsmc/(unfold p.mod q.mod)) + {$make *} example(mod bcmc/(unfold p.mod q.mod)) {$name *} example(mod q.mod, nut `made/[p.mod ~]) {$over *} example(hay p.mod, mod q.mod) :: - {$bscb *} (decorate (home p.mod)) - {$bscl *} %- decorate + {$bccb *} (decorate (home p.mod)) + {$bccl *} %- decorate |- ^- hoon ?~ t.p.mod example:clear(mod i.p.mod) :- example:clear(mod i.p.mod) example:clear(i.p.mod i.t.p.mod, t.p.mod t.t.p.mod) - {$bshp *} (decorate (function:clear p.mod q.mod)) - {$bsmc *} (decorate (home [%tsld [%limb %$] p.mod])) - {$bssg *} [%ktls example(mod q.mod) (home p.mod)] - {$bsls *} (decorate example(mod q.mod)) - {$bsts *} (decorate [%ktts p.mod example:clear(mod q.mod)]) - {$bsdt *} (decorate (home (interface %gold p.mod q.mod))) - {$bsnt *} (decorate (home (interface %iron p.mod q.mod))) - {$bszp *} (decorate (home (interface %lead p.mod q.mod))) - {$bstc *} (decorate (home (interface %zinc p.mod q.mod))) + {$bchp *} (decorate (function:clear p.mod q.mod)) + {$bcmc *} (decorate (home [%tsgl [%limb %$] p.mod])) + {$bcsg *} [%ktls example(mod q.mod) (home p.mod)] + {$bcls *} (decorate example(mod q.mod)) + {$bcts *} (decorate [%ktts p.mod example:clear(mod q.mod)]) + {$bcdt *} (decorate (home (interface %gold p.mod q.mod))) + {$bcfs *} (decorate (home (interface %iron p.mod q.mod))) + {$bczp *} (decorate (home (interface %lead p.mod q.mod))) + {$bctc *} (decorate (home (interface %zinc p.mod q.mod))) == :: ++ factory @@ -8160,17 +8160,17 @@ :: process annotations outside construct, to catch default :: ?: ?=($dbug -.mod) factory(mod q.mod, bug [p.mod bug]) - ?: ?=($bssg -.mod) factory(mod q.mod, def `[%kthp q.mod p.mod]) + ?: ?=($bcsg -.mod) factory(mod q.mod, def `[%kthp q.mod p.mod]) ^- hoon :: if we recognize an indirection :: - ?: &(=(~ def) ?=(?(%bsmc %like %loop %make) -.mod)) + ?: &(=(~ def) ?=(?(%bcmc %like %loop %make) -.mod)) :: then short-circuit it :: %- decorate %- home ?- -.mod - %bsmc p.mod + %bcmc p.mod %like (unreel p.mod q.mod) %loop [%limb p.mod] %make (unfold p.mod q.mod) @@ -8195,10 +8195,10 @@ {%atom *} :+ %ktls example ^- hoon - :^ %zpvt + :^ %zppt [[[%| 0 `%ruth] ~] ~] [%cnls [%limb %ruth] [%sand %ta p.bas] fetch] - [%wtvt fetch-wing fetch [%zpzp ~]] + [%wtpt fetch-wing fetch [%zpzp ~]] :: $cell :+ %ktls example @@ -8210,7 +8210,7 @@ :^ %wtcl [%dtts [%rock %$ &] [%$ axe]] [%rock %f &] - :+ %wtbn + :+ %wtgr [%dtts [%rock %$ |] [%$ axe]] [%rock %f |] :: @@ -8218,7 +8218,7 @@ fetch :: $null - :+ %wtbn + :+ %wtgr [%dtts [%bust %noun] [%$ axe]] [%rock %n ~] ::: @@ -8286,7 +8286,7 @@ :: test if the head matches this wing :: :+ %fits - [%tsld [%$ 2] example:clear(mod one)] + [%tsgl [%$ 2] example:clear(mod one)] fetch-wing(axe (peg axe 2)) :: if so, use this form :: @@ -8316,19 +8316,19 @@ :: {$leaf *} %- decorate - :+ %wtbn + :+ %wtgr [%dtts fetch [%rock %$ q.mod]] [%rock p.mod q.mod] :: :: composite :: {$make *} - relative(mod bsmc/(unfold p.mod q.mod)) + relative(mod bcmc/(unfold p.mod q.mod)) :: :: indirect :: {$like *} - relative(mod bsmc/(unreel p.mod q.mod)) + relative(mod bcmc/(unreel p.mod q.mod)) :: :: loop :: @@ -8352,7 +8352,7 @@ :: :: recursive, $$ :: - {$bsbs *} + {$bcbc *} :: :: apply semantically :: @@ -8368,21 +8368,21 @@ :: :: normalize, $& :: - {$bspd *} + {$bcpm *} :: push the raw result :: :+ %tsls relative(mod p.mod) :: push repair function :: :+ %tsls - [%tsbn $/3 q.mod] + [%tsgr $/3 q.mod] :: push repaired product :: :+ %tsls [%cnhp $/2 $/6] :: sanity-check repaired product :: - :+ %wtbn + :+ %wtgr :: either :: :~ %wtbr @@ -8397,7 +8397,7 @@ :: :: verify, $| :: - {$bsbr *} + {$bcbr *} ^- hoon :: push the raw product :: @@ -8405,27 +8405,27 @@ ^- hoon :: assert :: - :+ %wtbn + :+ %wtgr :: run the verifier :: - [%cnhp [%tsbn $/3 q.mod] $/2] + [%cnhp [%tsgr $/3 q.mod] $/2] :: produce verified product :: $/2 :: :: special, $_ :: - {$bscb *} + {$bccb *} (decorate (home p.mod)) :: :: switch, $% :: - {$bscn *} + {$bccn *} (decorate (switch i.p.mod t.p.mod)) :: :: tuple, $: :: - {$bscl *} + {$bccl *} %- decorate |- ^- hoon ?~ t.p.mod @@ -8439,25 +8439,25 @@ :: :: exclude, $< :: - {$bsld *} + {$bcgl *} :+ %tsls relative:clear(mod q.mod) - :+ %wtld + :+ %wtgl [%wtts [%over ~[&/3] p.mod] ~[&/4]] $/2 :: :: require, $> :: - {$bsbn *} + {$bcgr *} :+ %tsls relative:clear(mod q.mod) - :+ %wtbn + :+ %wtgr [%wtts [%over ~[&/3] p.mod] ~[&/4]] $/2 :: :: function :: - {$bshp *} + {$bchp *} %- decorate =/ fun (function:clear p.mod q.mod) ?^ def @@ -8466,7 +8466,7 @@ :: :: bridge, $^ :: - {$bskt *} + {$bckt *} %- decorate :^ %wtcl [%dtwt fetch(axe (peg axe 2))] @@ -8475,38 +8475,38 @@ :: :: synthesis, $; :: - {$bsmc *} + {$bcmc *} (decorate [%cncl (home p.mod) fetch ~]) :: :: default :: - {$bssg *} + {$bcsg *} relative(mod q.mod, def `[%kthp q.mod p.mod]) :: :: choice, $? :: - {$bswt *} + {$bcwt *} (decorate (choice i.p.mod t.p.mod)) :: :: name, $= :: - {$bsts *} + {$bcts *} [%ktts p.mod relative(mod q.mod)] :: :: branch, $@ :: - {$bsvt *} + {$bcpt *} %- decorate :^ %wtcl [%dtwt fetch] relative:clear(mod q.mod) relative:clear(mod p.mod) :: - {$bsls *} relative(mod q.mod) - {$bsdt *} (decorate (home (interface %gold p.mod q.mod))) - {$bsnt *} (decorate (home (interface %iron p.mod q.mod))) - {$bszp *} (decorate (home (interface %lead p.mod q.mod))) - {$bstc *} (decorate (home (interface %zinc p.mod q.mod))) + {$bcls *} relative(mod q.mod) + {$bcdt *} (decorate (home (interface %gold p.mod q.mod))) + {$bcfs *} (decorate (home (interface %iron p.mod q.mod))) + {$bczp *} (decorate (home (interface %lead p.mod q.mod))) + {$bctc *} (decorate (home (interface %zinc p.mod q.mod))) == -- -- @@ -8527,7 +8527,7 @@ |- ^- hoon ?- skin @ - [%tsld [%tune skin] gen] + [%tsgl [%tune skin] gen] [%base *] ?: ?=(%noun base.skin) gen @@ -8553,7 +8553,7 @@ [%note [%help help.skin] $(skin skin.skin)] :: [%name *] - [%tsld [%tune term.skin] $(skin skin.skin)] + [%tsgl [%tune term.skin] $(skin skin.skin)] :: [%over *] $(skin skin.skin, rel (weld wing.skin rel)) @@ -8564,7 +8564,7 @@ $(skin skin.skin) :: [%wash *] - :+ %tsld + :+ %tsgl :- %wing |- ^- wing ?: =(0 depth.skin) ~ @@ -8581,8 +8581,8 @@ `i.p.gen {$limb *} `p.gen {$dbug *} $(gen ~(open ap gen)) - {$tsld *} $(gen ~(open ap gen)) - {$tsbn *} $(gen q.gen) + {$tsgl *} $(gen ~(open ap gen)) + {$tsgr *} $(gen q.gen) == :: ++ feck @@ -8636,7 +8636,7 @@ [%cnts [@ ~] ~] `i.p.gen :: - [%tsbn *] + [%tsgr *] %+ biff reek(gen p.gen) |= =wing (bind ^$(gen q.gen) |=(=skin [%over wing skin])) @@ -8682,7 +8682,7 @@ {$eror *} ~>(%slog.[0 leaf/p.gen] !!) :: {$knit *} :: - :+ %tsbn [%ktts %v %$ 1] :: => v=. + :+ %tsgr [%ktts %v %$ 1] :: => v=. :- %brhp :: |- :+ %ktls :: ^+ :- %brhp :: |- @@ -8703,32 +8703,32 @@ %a :: a :+ %ktls :: ^+ [%limb %$] :: $ - [%tsbn [%limb %v] p.i.p.gen] :: =>(v {p.i.p.gen}) + [%tsgr [%limb %v] p.i.p.gen] :: =>(v {p.i.p.gen}) [%ktts %b res] :: b={res} ^- hoon :: :- %brhp :: |- - :^ %wtvt :: ?@ + :^ %wtpt :: ?@ [%a ~] :: a [%limb %b] :: b - :- [%tsld [%$ 2] [%limb %a]] :: :- -.a + :- [%tsgl [%$ 2] [%limb %a]] :: :- -.a :+ %cnts :: %= [%$ ~] :: $ - [[[%a ~] [%tsld [%$ 3] [%limb %a]]] ~] :: a +.a + [[[%a ~] [%tsgl [%$ 3] [%limb %a]]] ~] :: a +.a :: {$leaf *} ~(factory ax fab `spec`gen) {$limb *} [%cnts [p.gen ~] ~] - {$tell *} [%cncl [%limb %noah] [%zpbn [%cltr p.gen]] ~] + {$tell *} [%cncl [%limb %noah] [%zpgr [%cltr p.gen]] ~] {$wing *} [%cnts p.gen ~] - {$yell *} [%cncl [%limb %cain] [%zpbn [%cltr p.gen]] ~] + {$yell *} [%cncl [%limb %cain] [%zpgr [%cltr p.gen]] ~] {$note *} q.gen :: - {$brbs *} =- ?~ - !! - [%brtr [%bscl -] [%ktcl body.gen]] + {$brbc *} =- ?~ - !! + [%brtr [%bccl -] [%ktcl body.gen]] %+ turn `(list term)`sample.gen |= =term ^- spec =/ tar [%base %noun] - [%bsts term [%bssg tar [%bshp tar tar]]] + [%bcts term [%bcsg tar [%bchp tar tar]]] {$brcb *} :+ %tsls [%kttr p.gen] :+ %brcn ~ %- ~(run by r.gen) @@ -8742,7 +8742,7 @@ {$brdt *} :+ %brcn ~ =- [[%$ ~ -] ~ ~] (~(put by *(map term hoon)) %$ p.gen) - {$brkt *} :+ %tsld [%limb %$] + {$brkt *} :+ %tsgl [%limb %$] :+ %brcn ~ =+ zil=(~(get by q.gen) %$) ?~ zil @@ -8750,10 +8750,10 @@ [*what [[%$ p.gen] ~ ~]] %+ ~(put by q.gen) %$ [p.u.zil (~(put by q.u.zil) %$ p.gen)] - {$brhp *} [%tsld [%limb %$] [%brdt p.gen]] + {$brhp *} [%tsgl [%limb %$] [%brdt p.gen]] {$brsg *} [%ktbr [%brts p.gen q.gen]] {$brtr *} :+ %tsls [%kttr p.gen] - :+ %brvt ~ + :+ %brpt ~ =- [[%$ ~ -] ~ ~] (~(put by *(map term hoon)) %$ q.gen) {$brts *} :+ %brcb p.gen @@ -8804,28 +8804,28 @@ :: {$cntr *} ?: =(~ r.gen) - [%tsbn q.gen [%wing p.gen]] + [%tsgr q.gen [%wing p.gen]] :+ %tsls q.gen :+ %cnts (weld p.gen `wing`[[%& 2] ~]) - (turn r.gen |=({p/wing q/hoon} [p [%tsbn [%$ 3] q]])) + (turn r.gen |=({p/wing q/hoon} [p [%tsgr [%$ 3] q]])) :: {$ktdt *} [%ktls [%cncl p.gen q.gen ~] q.gen] {$kthp *} [%ktls ~(example ax fab p.gen) q.gen] {$ktts *} (grip(gen q.gen) p.gen) :: {$sgbr *} - :+ %sgbn + :+ %sggr :- %mean =+ fek=~(feck ap p.gen) ?^ fek [%rock %tas u.fek] - [%brdt [%cncl [%limb %cain] [%zpbn [%tsbn [%$ 3] p.gen]] ~]] + [%brdt [%cncl [%limb %cain] [%zpgr [%tsgr [%$ 3] p.gen]] ~]] q.gen :: - {$sgcb *} [%sgbn [%mean [%brdt p.gen]] q.gen] + {$sgcb *} [%sggr [%mean [%brdt p.gen]] q.gen] {$sgcn *} - :+ %sgld + :+ %sggl :- %fast :- %clls :+ [%rock %$ p.gen] @@ -8838,21 +8838,21 @@ [[[%rock %$ p.i.r.gen] [%zpts q.i.r.gen]] $(r.gen t.r.gen)] s.gen :: - {$sgnt *} [%sgcn p.gen [%$ 7] ~ q.gen] - {$sgld *} [%tsld [%sgbn p.gen [%$ 1]] q.gen] - {$sgbs *} [%sgbn [%live [%rock %$ p.gen]] q.gen] - {$sgls *} [%sgbn [%memo %rock %$ p.gen] q.gen] - {$sgpd *} - :+ %sgbn - [%slog [%sand %$ p.gen] [%cncl [%limb %cain] [%zpbn q.gen] ~]] + {$sgfs *} [%sgcn p.gen [%$ 7] ~ q.gen] + {$sggl *} [%tsgl [%sggr p.gen [%$ 1]] q.gen] + {$sgbc *} [%sggr [%live [%rock %$ p.gen]] q.gen] + {$sgls *} [%sggr [%memo %rock %$ p.gen] q.gen] + {$sgpm *} + :+ %sggr + [%slog [%sand %$ p.gen] [%cncl [%limb %cain] [%zpgr q.gen] ~]] r.gen :: - {$sgts *} [%sgbn [%germ p.gen] q.gen] + {$sgts *} [%sggr [%germ p.gen] q.gen] {$sgwt *} :+ %tsls [%wtdt q.gen [%bust %null] [[%bust %null] r.gen]] :^ %wtsg [%& 2]~ - [%tsbn [%$ 3] s.gen] - [%sgpd p.gen [%$ 5] [%tsbn [%$ 3] s.gen]] + [%tsgr [%$ 3] s.gen] + [%sgpm p.gen [%$ 5] [%tsgr [%$ 3] s.gen]] :: {$mcts *} |- @@ -8860,12 +8860,12 @@ ?- -.i.p.gen ^ [[%xray i.p.gen] $(p.gen t.p.gen)] $manx [p.i.p.gen $(p.gen t.p.gen)] - $tape [[%mcnt p.i.p.gen] $(p.gen t.p.gen)] + $tape [[%mcfs p.i.p.gen] $(p.gen t.p.gen)] $call [%cncl p.i.p.gen [$(p.gen t.p.gen)]~] $marl =- [%cndt [p.i.p.gen $(p.gen t.p.gen)] -] ^- hoon :+ %tsbr [%base %cell] - :+ %brvt ~ + :+ %brpt ~ ^- (map term tome) =- [[%$ ~ -] ~ ~] ^- (map term hoon) @@ -8887,13 +8887,13 @@ =+ yex=`(list hoon)`q.gen |- ^- hoon ?- yex - {* ~} [%tsbn [%$ 3] i.yex] - {* ^} [%cncl [%$ 2] [%tsbn [%$ 3] i.yex] $(yex t.yex) ~] + {* ~} [%tsgr [%$ 3] i.yex] + {* ^} [%cncl [%$ 2] [%tsgr [%$ 3] i.yex] $(yex t.yex) ~] ~ !! == == :: - {$mcnt *} =+(zoy=[%rock %ta %$] [%clsg [zoy [%clsg [zoy p.gen] ~]] ~]) + {$mcfs *} =+(zoy=[%rock %ta %$] [%clsg [zoy [%clsg [zoy p.gen] ~]] ~]) {$mcgl *} :^ %cnls :+ %cnhp @@ -8909,21 +8909,21 @@ ?- q.gen ~ ~_(leaf+"open-mcsg" !!) ^ - :+ %tsbn [%ktts %v %$ 1] :: => v=. + :+ %tsgr [%ktts %v %$ 1] :: => v=. |- ^- hoon :: ?: ?=(~ t.q.gen) :: - [%tsbn [%limb %v] i.q.gen] :: =>(v {i.q.gen}) + [%tsgr [%limb %v] i.q.gen] :: =>(v {i.q.gen}) :+ %tsls [%ktts %a $(q.gen t.q.gen)] :: =+ ^= a :+ %tsls :: {$(q.gen t.q.gen)} - [%ktts %b [%tsbn [%limb %v] i.q.gen]] :: =+ ^= b + [%ktts %b [%tsgr [%limb %v] i.q.gen]] :: =+ ^= b :+ %tsls :: =>(v {i.q.gen}) :+ %ktts %c :: =+ c=,.+6.b - :+ %tsld :: + :+ %tsgl :: [%wing [%| 0 ~] [%& 6] ~] :: [%limb %b] :: :- %brdt :: |. :^ %cnls :: %+ - [%tsbn [%limb %v] p.gen] :: =>(v {p.gen}) + [%tsgr [%limb %v] p.gen] :: =>(v {p.gen}) [%cncl [%limb %b] [%limb %c] ~] :: (b c) :+ %cnts [%a ~] :: a(,.+6 c) [[[[%| 0 ~] [%& 6] ~] [%limb %c]] ~] :: @@ -8936,48 +8936,48 @@ [%tsls ~(example ax fab p.gen) q.gen] :: {$tstr *} - :+ %tsld + :+ %tsgl r.gen [%tune [[p.p.gen ~ ?~(q.p.gen q.gen [%kthp u.q.p.gen q.gen])] ~ ~] ~] :: {$tscl *} - [%tsbn [%cncb [[%& 1] ~] p.gen] q.gen] + [%tsgr [%cncb [[%& 1] ~] p.gen] q.gen] :: - {$tsnt *} + {$tsfs *} [%tsls [%ktts p.gen q.gen] r.gen] :: - {$tsmc *} [%tsnt p.gen r.gen q.gen] + {$tsmc *} [%tsfs p.gen r.gen q.gen] {$tsdt *} - [%tsbn [%cncb [[%& 1] ~] [[p.gen q.gen] ~]] r.gen] + [%tsgr [%cncb [[%& 1] ~] [[p.gen q.gen] ~]] r.gen] {$tswt *} :: =? [%tsdt p.gen [%wtcl q.gen r.gen [%wing p.gen]] s.gen] :: {$tskt *} :: =^ =+ wuy=(weld q.gen `wing`[%v ~]) :: - :+ %tsbn [%ktts %v %$ 1] :: => v=. - :+ %tsls [%ktts %a %tsbn [%limb %v] r.gen] :: =+ a==>(v \r.gen) - :^ %tsdt wuy [%tsld [%$ 3] [%limb %a]] - :+ %tsbn :- :+ %ktts [%over [%v ~] p.gen] - [%tsld [%$ 2] [%limb %a]] + :+ %tsgr [%ktts %v %$ 1] :: => v=. + :+ %tsls [%ktts %a %tsgr [%limb %v] r.gen] :: =+ a==>(v \r.gen) + :^ %tsdt wuy [%tsgl [%$ 3] [%limb %a]] + :+ %tsgr :- :+ %ktts [%over [%v ~] p.gen] + [%tsgl [%$ 2] [%limb %a]] [%limb %v] s.gen :: - {$tsld *} [%tsbn q.gen p.gen] - {$tsls *} [%tsbn [p.gen [%$ 1]] q.gen] + {$tsgl *} [%tsgr q.gen p.gen] + {$tsls *} [%tsgr [p.gen [%$ 1]] q.gen] {$tshp *} [%tsls q.gen p.gen] {$tssg *} |- ^- hoon ?~ p.gen [%$ 1] ?~ t.p.gen i.p.gen - [%tsbn i.p.gen $(p.gen t.p.gen)] + [%tsgr i.p.gen $(p.gen t.p.gen)] :: {$wtbr *} |- ?~(p.gen [%rock %f 1] [%wtcl i.p.gen [%rock %f 0] $(p.gen t.p.gen)]) :: {$wtdt *} [%wtcl p.gen r.gen q.gen] - {$wtld *} [%wtcl p.gen [%zpzp ~] q.gen] - {$wtbn *} [%wtcl p.gen q.gen [%zpzp ~]] + {$wtgl *} [%wtcl p.gen [%zpzp ~] q.gen] + {$wtgr *} [%wtcl p.gen q.gen [%zpzp ~]] {$wtkt *} [%wtcl [%wtts [%base %atom %$] p.gen] r.gen q.gen] :: {$wthp *} @@ -8992,7 +8992,7 @@ {$wtls *} [%wthp p.gen (weld r.gen `_r.gen`[[[%base %noun] q.gen] ~])] :: - {$wtpd *} + {$wtpm *} |- ?~(p.gen [%rock %f 0] [%wtcl i.p.gen $(p.gen t.p.gen) [%rock %f 1]]) :: @@ -9009,12 +9009,12 @@ [(open-mane n) %knit v] -- :: - {$wtvt *} [%wtcl [%wtts [%base %atom %$] p.gen] q.gen r.gen] + {$wtpt *} [%wtcl [%wtts [%base %atom %$] p.gen] q.gen r.gen] {$wtsg *} [%wtcl [%wtts [%base %null] p.gen] q.gen r.gen] {$wtts *} [%fits ~(example ax fab p.gen) q.gen] {$wtzp *} [%wtcl p.gen [%rock %f 1] [%rock %f 0]] - {$zpbn *} - [%cncl [%limb %onan] [%zpmc [%kttr [%bsmc %limb %abel]] p.gen] ~] + {$zpgr *} + [%cncl [%limb %onan] [%zpmc [%kttr [%bcmc %limb %abel]] p.gen] ~] :: {$zpwt *} ?: ?: ?=(@ p.gen) @@ -10200,7 +10200,7 @@ - ~(gain ar - p.gen) ~(lose ar - p.gen) - ?: ?&(how ?=({$wtpd *} gen)) + ?: ?&(how ?=({$wtpm *} gen)) |-(?~(p.gen sut $(p.gen t.p.gen, sut ^$(gen i.p.gen)))) ?: ?&(!how ?=({$wtbr *} gen)) |-(?~(p.gen sut $(p.gen t.p.gen, sut ^$(gen i.p.gen)))) @@ -10417,7 +10417,7 @@ :: {$ktcn *} $(fab |, gen p.gen) {$brcn *} (grow %gold p.gen %dry [%$ 1] q.gen) - {$brvt *} (grow %gold p.gen %wet [%$ 1] q.gen) + {$brpt *} (grow %gold p.gen %wet [%$ 1] q.gen) :: {$cnts *} (~(mint et p.gen q.gen) gol) :: @@ -10443,7 +10443,7 @@ {$ktls *} =+(hif=(nice (play p.gen)) [hif q:$(gen q.gen, gol hif)]) :: - {$ktpd *} =+(vat=$(gen p.gen) [(nice (wrap(sut p.vat) %zinc)) q.vat]) + {$ktpm *} =+(vat=$(gen p.gen) [(nice (wrap(sut p.vat) %zinc)) q.vat]) {$ktsg *} (blow gol p.gen) {$tune *} [(face p.gen sut) [%0 %1]] {$ktwt *} =+(vat=$(gen p.gen) [(nice (wrap(sut p.vat) %lead)) q.vat]) @@ -10453,7 +10453,7 @@ [(hint [sut p.gen] p.hum) q.hum] :: {$sgzp *} ~_(duck(sut (play p.gen)) $(gen q.gen)) - {$sgbn *} + {$sggr *} =+ hum=$(gen q.gen) :: ?: &(huz !?=(%|(@ [?(%sgcn %sgls) ^]) p.gen)) :: hum @@ -10465,7 +10465,7 @@ == q.hum :: - {$tsbn *} + {$tsgr *} =+ fid=$(gen p.gen, gol %noun) =+ dov=$(sut p.fid, gen q.gen) [p.dov (comb q.fid q.dov)] @@ -10523,7 +10523,7 @@ =+ ref=p:$(gol %noun, gen p.gen) [(nice (cell ref p.vos)) (cons [%1 burp(sut p.vos)] q.vos)] :: - {$zpld *} + {$zpgl *} =/ typ (nice (play [%kttr p.gen])) =/ val =< q @@ -10532,16 +10532,16 @@ gen :^ %wtcl :+ %cncl [%limb %levi] - :~ [%tsbn [%zpbn [%kttr p.gen]] [%$ 2]] - [%tsbn q.gen [%$ 2]] + :~ [%tsgr [%zpgr [%kttr p.gen]] [%$ 2]] + [%tsgr q.gen [%$ 2]] == - [%tsbn q.gen [%$ 3]] + [%tsgr q.gen [%$ 3]] [%zpzp ~] == [typ val] :: {$zpts *} [(nice %noun) [%1 q:$(vet |, gen p.gen)]] - {$zpvt *} ?:((feel p.gen) $(gen q.gen) $(gen r.gen)) + {$zppt *} ?:((feel p.gen) $(gen q.gen) $(gen r.gen)) :: {$zpzp ~} [%void [%0 0]] * @@ -10596,7 +10596,7 @@ :: {$ktcn *} $(fab |, gen p.gen) {$brcn *} (grow %gold p.gen %dry [%$ 1] q.gen) - {$brvt *} (grow %gold p.gen %wet [%$ 1] q.gen) + {$brpt *} (grow %gold p.gen %wet [%$ 1] q.gen) {$cnts *} (~(mull et p.gen q.gen) gol dox) {$dtkt *} =+($(gen q.gen, gol %noun) $(gen [%kttr p.gen])) {$dtls *} =+($(gen p.gen, gol [%atom %$ ~]) (beth [%atom %$ ~])) @@ -10618,7 +10618,7 @@ =+ hif=[p=(nice (play p.gen)) q=(play(sut dox) p.gen)] =+($(gen q.gen, gol p.hif) hif) :: - {$ktpd *} + {$ktpm *} =+(vat=$(gen p.gen) [(wrap(sut p.vat) %zinc) (wrap(sut q.vat) %zinc)]) :: {$tune *} @@ -10633,8 +10633,8 @@ :: {$ktsg *} $(gen p.gen) {$sgzp *} ~_(duck(sut (play p.gen)) $(gen q.gen)) - {$sgbn *} $(gen q.gen) - {$tsbn *} + {$sggr *} $(gen q.gen) + {$tsgr *} =+ lem=$(gen p.gen, gol %noun) $(gen q.gen, sut p.lem, dox q.lem) :: @@ -10702,11 +10702,11 @@ =+ vos=$(gol %noun, gen q.gen) :: XX validate! [(nice (cell (play p.gen) p.vos)) (cell (play(sut dox) p.gen) q.vos)] :: - {$zpld *} + {$zpgl *} :: XX is this right? (beth (play [%kttr p.gen])) :: - {$zpvt *} + {$zppt *} =+ [(feel p.gen) (feel(sut dox) p.gen)] ?. =(-< ->) ~>(%mean.'mull-bonk-f' !!) @@ -10971,7 +10971,7 @@ {^ *} (cell $(gen p.gen) $(gen q.gen)) {$ktcn *} $(fab |, gen p.gen) {$brcn *} (core sut [p.gen %dry %gold] sut *seminoun q.gen) - {$brvt *} (core sut [p.gen %wet %gold] sut *seminoun q.gen) + {$brpt *} (core sut [p.gen %wet %gold] sut *seminoun q.gen) {$cnts *} ~(play et p.gen q.gen) {$dtkt *} $(gen [%kttr p.gen]) {$dtls *} [%atom %$ ~] @@ -10990,13 +10990,13 @@ {$hand *} p.gen {$ktbr *} (wrap(sut $(gen p.gen)) %iron) {$ktls *} $(gen p.gen) - {$ktpd *} (wrap(sut $(gen p.gen)) %zinc) + {$ktpm *} (wrap(sut $(gen p.gen)) %zinc) {$ktsg *} $(gen p.gen) {$ktwt *} (wrap(sut $(gen p.gen)) %lead) {$note *} (hint [sut p.gen] $(gen q.gen)) {$sgzp *} ~_(duck(sut ^$(gen p.gen)) $(gen q.gen)) - {$sgbn *} $(gen q.gen) - {$tsbn *} $(gen q.gen, sut $(gen p.gen)) + {$sggr *} $(gen q.gen) + {$tsgr *} $(gen q.gen, sut $(gen p.gen)) {$tscm *} $(gen q.gen, sut (busk p.gen)) {$wtcl *} =+ [fex=(gain p.gen) wux=(lose p.gen)] %- fork :~ @@ -11009,9 +11009,9 @@ {$zpcm *} $(gen p.gen) {$lost *} %void {$zpmc *} (cell $(gen p.gen) $(gen q.gen)) - {$zpld *} (play [%kttr p.gen]) + {$zpgl *} (play [%kttr p.gen]) {$zpts *} %noun - {$zpvt *} ?:((feel p.gen) $(gen q.gen) $(gen r.gen)) + {$zppt *} ?:((feel p.gen) $(gen q.gen) $(gen r.gen)) {$zpzp *} %void * =+ doz=~(open ap gen) ?: =(doz gen) @@ -11354,7 +11354,7 @@ {$face p/term q/wine} :: {$list p/term q/wine} :: {$pear p/term q/@} :: - {$bswt p/(list wine)} :: + {$bcwt p/(list wine)} :: {$plot p/(list wine)} :: {$stop p/@ud} :: {$tree p/term q/wine} :: @@ -11420,7 +11420,7 @@ =^ cox gid $(q.ham q.q.ham) :_(gid [%rose [" " (weld (trip p.q.ham) "(") ")"] cox ~]) :: - {$bswt *} + {$bcwt *} =^ coz gid (many p.q.ham) :_(gid [%rose [[' ' ~] ['?' '(' ~] [')' ~]] coz]) :: @@ -11560,7 +11560,7 @@ ~ [~ u.for u.aft] :: - {$bswt *} + {$bcwt *} |- ^- (unit tank) ?~ p.q.ham ~ @@ -11649,7 +11649,7 @@ ^= woz ^- wine ?. ?=({$stop *} q.ham) - ?: ?& ?= {$bswt {$pear $n $0} {$plot {$pear $n $0} {$face *} ~} ~} + ?: ?& ?= {$bcwt {$pear $n $0} {$plot {$pear $n $0} {$face *} ~} ~} q.ham =(1 (met 3 p.i.t.p.i.t.p.q.ham)) == @@ -11659,7 +11659,7 @@ ?~ may q.ham =+ nul=[%pear %n 0] - ?. ?& ?=({$bswt *} u.may) + ?. ?& ?=({$bcwt *} u.may) ?=({* * ~} p.u.may) |(=(nul i.p.u.may) =(nul i.t.p.u.may)) == @@ -11748,7 +11748,7 @@ :: {$fork *} =+ yed=(sort ~(tap in p.sut) aor) - =- [p [%bswt q]] + =- [p [%bcwt q]] |- ^- {p/{p/(map type @) q/(map @ wine)} q/(list wine)} ?~ yed [dex ~] @@ -12173,7 +12173,7 @@ ?@ -.q.vax ^= typ %- ~(play ut p.vax) - [%wtbn [%wtts [%leaf %tas -.q.vax] [%& 2]~] [%$ 1]] + [%wtgr [%wtts [%leaf %tas -.q.vax] [%& 2]~] [%$ 1]] (~(fuse ut p.vax) [%cell %noun %noun]) :: :::: 5d: parser @@ -12342,7 +12342,7 @@ ++ phax |= ruw/(list (list woof)) =+ [yun=*(list hoon) cah=*(list @)] - =+ wod=|=({a/tape b/(list hoon)} ^+(b ?~(a b [[%mcnt %knit (flop a)] b]))) + =+ wod=|=({a/tape b/(list hoon)} ^+(b ?~(a b [[%mcfs %knit (flop a)] b]))) |- ^+ yun ?~ ruw (flop (wod cah yun)) @@ -13403,9 +13403,9 @@ ^. stet ^. limo :~ :- '_' - ;~(pfix cab (stag %bscb wide)) + ;~(pfix cab (stag %bccb wide)) :- ',' - ;~(pfix com (stag %bsmc wide)) + ;~(pfix com (stag %bcmc wide)) :- '$' ;~ pose ;~ pfix buc @@ -13442,9 +13442,9 @@ :- '{' :: XX deprecated :: - (stag %bscl (ifix [kel ker] (most ace wyde))) + (stag %bccl (ifix [kel ker] (most ace wyde))) :- '[' - (stag %bscl (ifix [sel ser] (most ace wyde))) + (stag %bccl (ifix [sel ser] (most ace wyde))) :- '*' (cold [%base %noun] tar) :- '/' @@ -13453,7 +13453,7 @@ ;~(pfix pat (stag %base (stag %atom mota))) :- '?' ;~ pose - %+ stag %bswt + %+ stag %bcwt ;~(pfix wut (ifix [pal par] (most ace wyde))) :: (cold [%base %flag] wut) @@ -13475,7 +13475,7 @@ ~(autoname ax & spec) |= =term =* name ?~(unit term (cat 3 u.unit (cat 3 '-' term))) - [%bsts name spec] + [%bcts name spec] ;~ pose ;~(plug (stag ~ ;~(sfix sym tis)) wyde) (stag ~ wyde) @@ -13483,7 +13483,7 @@ == :- ['a' 'z'] ;~ pose - (stag %bsts ;~(plug sym ;~(pfix ;~(pose fas tis) wyde))) + (stag %bcts ;~(plug sym ;~(pfix ;~(pose fas tis) wyde))) (stag %like (most col rope)) == == @@ -13504,7 +13504,7 @@ (stag %zpzp (cold ~ ;~(plug zap zap))) == :- '_' - ;~(pfix cab (stag %ktcl (stag %bscb wide))) + ;~(pfix cab (stag %ktcl (stag %bccb wide))) :- '$' ;~ pose ;~ pfix buc @@ -13533,7 +13533,7 @@ :- '&' ;~ pose (cook |=(a/wing [%cnts a ~]) rope) - (stag %wtpd ;~(pfix pam (ifix [pal par] (most ace wide)))) + (stag %wtpm ;~(pfix pam (ifix [pal par] (most ace wide)))) ;~(plug (stag %rock (stag %f (cold & pam))) wede) (stag %sand (stag %f (cold & pam))) == @@ -13542,7 +13542,7 @@ :- '(' (stag %cncl (ifix [pal par] (most ace wide))) :- '{' - (stag %ktcl (stag %bscl (ifix [kel ker] (most ace wyde)))) + (stag %ktcl (stag %bccl (ifix [kel ker] (most ace wyde)))) :- '*' ;~ pose (stag %kttr ;~(pfix tar wyde)) @@ -13556,7 +13556,7 @@ :: %+ cook |= a/(list (list woof)) - :- %mcnt + :- %mcfs [%knit |-(^-((list woof) ?~(a ~ (weld i.a $(a t.a)))))] (most dog ;~(pfix lus soil)) :: @@ -13587,7 +13587,7 @@ ;~ pfix col ;~ pose (stag %mccl (ifix [pal par] (most ace wide))) - ;~(pfix fas (stag %mcnt wide)) + ;~(pfix fas (stag %mcfs wide)) == == :- '=' @@ -13608,7 +13608,7 @@ :- '?' ;~ pose %+ stag %ktcl - (stag %bswt ;~(pfix wut (ifix [pal par] (most ace wyde)))) + (stag %bcwt ;~(pfix wut (ifix [pal par] (most ace wyde)))) :: (cold [%base %flag] wut) == @@ -13706,20 +13706,20 @@ ;~ pfix buc %- stew ^. stet ^. limo - :~ [':' (rune col %bscl exqs)] - ['%' (rune cen %bscn exqs)] - ['<' (rune gal %bsld exqb)] - ['>' (rune gar %bsbn exqb)] - ['^' (rune ket %bskt exqb)] - ['~' (rune sig %bssg exqd)] - ['|' (rune bar %bsbr exqc)] - ['&' (rune pam %bspd exqc)] - ['@' (rune pat %bsvt exqb)] - ['_' (rune cab %bscb expa)] - ['-' (rune hep %bshp exqb)] - ['=' (rune tis %bsts exqg)] - ['?' (rune wut %bswt exqs)] - [';' (rune mic %bsmc expa)] + :~ [':' (rune col %bccl exqs)] + ['%' (rune cen %bccn exqs)] + ['<' (rune gal %bcgl exqb)] + ['>' (rune gar %bcgr exqb)] + ['^' (rune ket %bckt exqb)] + ['~' (rune sig %bcsg exqd)] + ['|' (rune bar %bcbr exqc)] + ['&' (rune pam %bcpm exqc)] + ['@' (rune pat %bcpt exqb)] + ['_' (rune cab %bccb expa)] + ['-' (rune hep %bchp exqb)] + ['=' (rune tis %bcts exqg)] + ['?' (rune wut %bcwt exqs)] + [';' (rune mic %bcmc expa)] == == :- '%' @@ -13761,7 +13761,7 @@ ^. stet ^. limo :~ ['_' (rune cab %brcb exqr)] ['%' (runo cen %brcn ~ expe)] - ['@' (runo pat %brvt ~ expe)] + ['@' (runo pat %brpt ~ expe)] [':' (rune col %brcl expb)] ['.' (rune dot %brdt expa)] ['-' (rune hep %brhp expa)] @@ -13770,26 +13770,26 @@ ['*' (rune tar %brtr exqc)] ['=' (rune tis %brts exqc)] ['?' (rune wut %brwt expa)] - ['$' (rune buc %brbs exqe)] + ['$' (rune buc %brbc exqe)] == == :- '$' ;~ pfix buc %- stew ^. stet ^. limo - :~ ['@' (stag %ktcl (rune pat %bsvt exqb))] - ['_' (stag %ktcl (rune cab %bscb expa))] - [':' (stag %ktcl (rune col %bscl exqs))] - ['%' (stag %ktcl (rune cen %bscn exqs))] - ['<' (stag %ktcl (rune gal %bsld exqb))] - ['>' (stag %ktcl (rune gar %bsbn exqb))] - ['|' (stag %ktcl (rune bar %bsbr exqc))] - ['&' (stag %ktcl (rune pam %bspd exqc))] - ['^' (stag %ktcl (rune ket %bskt exqb))] - ['~' (stag %ktcl (rune sig %bssg exqd))] - ['-' (stag %ktcl (rune hep %bshp exqb))] - ['=' (stag %ktcl (rune tis %bsts exqg))] - ['?' (stag %ktcl (rune wut %bswt exqs))] + :~ ['@' (stag %ktcl (rune pat %bcpt exqb))] + ['_' (stag %ktcl (rune cab %bccb expa))] + [':' (stag %ktcl (rune col %bccl exqs))] + ['%' (stag %ktcl (rune cen %bccn exqs))] + ['<' (stag %ktcl (rune gal %bcgl exqb))] + ['>' (stag %ktcl (rune gar %bcgr exqb))] + ['|' (stag %ktcl (rune bar %bcbr exqc))] + ['&' (stag %ktcl (rune pam %bcpm exqc))] + ['^' (stag %ktcl (rune ket %bckt exqb))] + ['~' (stag %ktcl (rune sig %bcsg exqd))] + ['-' (stag %ktcl (rune hep %bchp exqb))] + ['=' (stag %ktcl (rune tis %bcts exqg))] + ['?' (stag %ktcl (rune wut %bcwt exqs))] ['.' (rune dot %kttr exqa)] [',' (rune com %ktcl exqa)] == @@ -13840,7 +13840,7 @@ ['.' (rune dot %ktdt expb)] ['-' (rune hep %kthp exqc)] ['+' (rune lus %ktls expb)] - ['&' (rune pam %ktpd expa)] + ['&' (rune pam %ktpm expa)] ['~' (rune sig %ktsg expa)] ['=' (rune tis %ktts expj)] ['?' (rune wut %ktwt expa)] @@ -13854,14 +13854,14 @@ %- stew ^. stet ^. limo :~ ['|' (rune bar %sgbr expb)] - ['$' (rune buc %sgbs expf)] + ['$' (rune buc %sgbc expf)] ['_' (rune cab %sgcb expb)] ['%' (rune cen %sgcn hind)] - ['/' (rune fas %sgnt hine)] - ['<' (rune gal %sgld hinb)] - ['>' (rune gar %sgbn hinb)] + ['/' (rune fas %sgfs hine)] + ['<' (rune gal %sggl hinb)] + ['>' (rune gar %sggr hinb)] ['+' (rune lus %sgls hinc)] - ['&' (rune pam %sgpd hinf)] + ['&' (rune pam %sgpm hinf)] ['?' (rune wut %sgwt hing)] ['=' (rune tis %sgts expb)] ['!' (rune zap %sgzp expb)] @@ -13872,7 +13872,7 @@ %- stew ^. stet ^. limo :~ [':' (rune col %mccl expi)] - ['/' (rune fas %mcnt expa)] + ['/' (rune fas %mcfs expa)] ['<' (rune gal %mcgl exp1)] ['~' (rune sig %mcsg expi)] [';' (rune mic %mcmc exqc)] @@ -13887,10 +13887,10 @@ ['?' (rune wut %tswt expw)] ['^' (rune ket %tskt expt)] [':' (rune col %tscl expp)] - ['/' (rune fas %tsnt expo)] + ['/' (rune fas %tsfs expo)] [';' (rune mic %tsmc expo)] - ['<' (rune gal %tsld expb)] - ['>' (rune gar %tsbn expb)] + ['<' (rune gal %tsgl expb)] + ['>' (rune gar %tsgr expb)] ['-' (rune hep %tshp expb)] ['*' (rune tar %tstr expg)] [',' (rune com %tscm expb)] @@ -13905,14 +13905,14 @@ :~ ['|' (rune bar %wtbr exps)] [':' (rune col %wtcl expc)] ['.' (rune dot %wtdt expc)] - ['<' (rune gal %wtld expb)] - ['>' (rune gar %wtbn expb)] + ['<' (rune gal %wtgl expb)] + ['>' (rune gar %wtgr expb)] ['-' ;~(pfix hep (toad txhp))] ['^' ;~(pfix ket (toad tkkt))] ['=' ;~(pfix tis (toad txts))] ['#' ;~(pfix hax (toad txhx))] ['+' ;~(pfix lus (toad txls))] - ['&' (rune pam %wtpd exps)] + ['&' (rune pam %wtpm exps)] ['@' ;~(pfix pat (toad tkvt))] ['~' ;~(pfix sig (toad tksg))] ['!' (rune zap %wtzp expa)] @@ -13926,9 +13926,9 @@ ['.' ;~(pfix dot (toad |.(loaf(bug |))))] [',' (rune com %zpcm expb)] [';' (rune mic %zpmc expb)] - ['>' (rune gar %zpbn expa)] - ['<' (rune gal %zpld exqc)] - ['@' (rune pat %zpvt expy)] + ['>' (rune gar %zpgr expa)] + ['<' (rune gal %zpgl exqc)] + ['@' (rune pat %zppt expy)] ['=' (rune tis %zpts expa)] ['?' (rune wut %zpwt hinh)] == @@ -13963,7 +13963,7 @@ ^- [term hoon] :- b :+ %brtr - :- %bscl + :- %bccl =- ?>(?=(^ -) -) :: for each .term in .c, produce $=(term $~(* $-(* *))) :: ie {term}=mold @@ -13972,7 +13972,7 @@ |= =term ^- spec =/ tar [%base %noun] - [%bsts term [%bssg tar [%bshp tar tar]]] + [%bcts term [%bcsg tar [%bchp tar tar]]] [%ktcl [%made [b c] e]] ;~ pfix (jest '+*') ;~ plug @@ -14194,7 +14194,7 @@ (~(wtls ah a) b c) (butt ;~(gunk teak loaf ruck)) ++ tkvt |. %+ cook |= {a/tiki b/hoon c/hoon} - (~(wtvt ah a) b c) + (~(wtpt ah a) b c) ;~(gunk teak loaf loaf) ++ tksg |. %+ cook |= {a/tiki b/hoon c/hoon} (~(wtsg ah a) b c) @@ -14270,7 +14270,7 @@ |: $:lang ^- (unit hoon) ?- -.vil - $col ?:(=([%base %flag] ros) ~ [~ %tsld ros p.vil]) + $col ?:(=([%base %flag] ros) ~ [~ %tsgl ros p.vil]) $lit (bind ~(reek ap ros) |=(hyp/wing [%cnts hyp p.vil])) $ket [~ ros p.vil] $tis =+ rud=~(flay ap ros) @@ -14546,7 +14546,7 @@ ?@ q.vax [%wtts [%base [%atom %$]] [%& 1]~] ?@ -.q.vax [%wtts [%leaf %tas -.q.vax] [%& 2]~] [%wtts [%base %cell] [%& 1]~] - =^ typ +>+<.$ (play p.vax [%wtbn gen [%$ 1]]) + =^ typ +>+<.$ (play p.vax [%wtgr gen [%$ 1]]) [[typ q.vax] +>+<.$] :: ++ spot :: slot then sped diff --git a/pkg/arvo/sys/vane/clay.hoon b/pkg/arvo/sys/vane/clay.hoon index 290a7c4b8b..190face4da 100644 --- a/pkg/arvo/sys/vane/clay.hoon +++ b/pkg/arvo/sys/vane/clay.hoon @@ -654,7 +654,7 @@ (with-faces old+old sam+sam ~) :+ %sgzp !,(*hoon old=old) :+ %sgzp !,(*hoon sam=sam) - :+ %tsld [%limb b] + :+ %tsgl [%limb b] !, *hoon ~(grow old sam) :: try direct +grab @@ -663,7 +663,7 @@ =/ rab %- mule |. %+ slap new - :+ %tsld [%limb a] + :+ %tsgl [%limb a] [%limb %grab] ?: &(?=(%& -.rab) ?=(^ q.p.rab)) :_(nub |=(sam=vase ~|([%grab a b] (slam p.rab sam)))) @@ -672,7 +672,7 @@ =/ jum %- mule |. %+ slap old - :+ %tsld [%limb b] + :+ %tsgl [%limb b] [%limb %jump] ?: ?=(%& -.jum) (compose-casts a !<(mark p.jum) b) From 491034b4eb91f13d5a25b60a36f2e45a94fe729d Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Tue, 3 Nov 2020 11:03:58 -0800 Subject: [PATCH 613/933] king: fix warnings; more consistent warn policy --- pkg/hs/proto/lib/SimpleNoun.hs | 3 ++- pkg/hs/proto/lib/Untyped/CST.hs | 2 +- pkg/hs/proto/lib/Untyped/Core.hs | 3 --- pkg/hs/proto/lib/Untyped/Parser.hs | 6 +----- pkg/hs/urbit-atom/package.yaml | 8 +++++--- pkg/hs/urbit-eventlog-lmdb/package.yaml | 8 +++++--- pkg/hs/urbit-king/lib/Urbit/Arvo/Common.hs | 2 +- pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs | 2 +- pkg/hs/urbit-king/lib/Urbit/Vere/Ames/DNS.hs | 2 +- pkg/hs/urbit-king/lib/Urbit/Vere/Ames/UDP.hs | 2 +- pkg/hs/urbit-king/lib/Urbit/Vere/Behn.hs | 3 +++ pkg/hs/urbit-king/lib/Urbit/Vere/Clay.hs | 3 ++- pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs | 2 +- pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs | 2 +- pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Multi.hs | 2 +- pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs | 5 ++++- pkg/hs/urbit-king/package.yaml | 8 +++++--- pkg/hs/urbit-noun-core/lib/Urbit/Noun/Core.hs | 6 ++++++ pkg/hs/urbit-noun-core/package.yaml | 7 ++++--- pkg/hs/urbit-noun/lib/Urbit/Noun/Tree.hs | 1 + pkg/hs/urbit-noun/package.yaml | 8 +++++--- 21 files changed, 51 insertions(+), 34 deletions(-) diff --git a/pkg/hs/proto/lib/SimpleNoun.hs b/pkg/hs/proto/lib/SimpleNoun.hs index e8b63cb216..1c6294a451 100644 --- a/pkg/hs/proto/lib/SimpleNoun.hs +++ b/pkg/hs/proto/lib/SimpleNoun.hs @@ -45,7 +45,8 @@ loob = \case textToAtom :: Text -> Atom textToAtom t = case N.textToUtf8Atom t of - N.A a -> a + N.A a -> a + N.C _ _ -> error "textToAtom: nani!?" showA :: Atom -> String showA a = show (N.A a) diff --git a/pkg/hs/proto/lib/Untyped/CST.hs b/pkg/hs/proto/lib/Untyped/CST.hs index e5c75eaa32..5ac2a37ec5 100644 --- a/pkg/hs/proto/lib/Untyped/CST.hs +++ b/pkg/hs/proto/lib/Untyped/CST.hs @@ -38,7 +38,7 @@ hone = go Atom a -> H.HAtom a Tag tx -> H.HAtom (textToAtom tx) Cord tx -> H.HAtom (textToAtom tx) - Tape tx -> undefined + Tape tx -> error "hone: tapes not implemented" Incr c -> H.DotLus (go c) IncrIrr c -> H.DotLus (go c) AppIrr c d -> H.CenHep (go c) (go d) diff --git a/pkg/hs/proto/lib/Untyped/Core.hs b/pkg/hs/proto/lib/Untyped/Core.hs index fc8cd99d7f..e70dcebb79 100644 --- a/pkg/hs/proto/lib/Untyped/Core.hs +++ b/pkg/hs/proto/lib/Untyped/Core.hs @@ -5,11 +5,8 @@ import ClassyPrelude import Bound import Control.Monad.Writer hiding (fix) import Data.Deriving (deriveEq1, deriveOrd1, deriveRead1, deriveShow1) -import qualified Data.Function as F -import Data.List (elemIndex) import Data.Maybe (fromJust) import qualified Data.Set as Set -import Data.Void import Dashboard (pattern FastAtom) import Nock diff --git a/pkg/hs/proto/lib/Untyped/Parser.hs b/pkg/hs/proto/lib/Untyped/Parser.hs index be32011cdb..d012d0a6f7 100644 --- a/pkg/hs/proto/lib/Untyped/Parser.hs +++ b/pkg/hs/proto/lib/Untyped/Parser.hs @@ -11,12 +11,7 @@ import Control.Monad.State.Lazy import Data.List.NonEmpty (NonEmpty(..)) import Data.Void (Void) import Prelude (head) -import Text.Format.Para (formatParas) -import qualified Data.MultiMap as MM -import qualified Data.Text as T -import qualified Data.Text.Lazy as LT -import qualified Data.Text.Lazy.IO as LT import qualified Prelude @@ -325,6 +320,7 @@ cst = irregular <|> rune <|> literal -- Entry Point ----------------------------------------------------------------- +hoonFile :: StateT Mode (Parsec Void Text) CST hoonFile = do option () whitespace h <- cst diff --git a/pkg/hs/urbit-atom/package.yaml b/pkg/hs/urbit-atom/package.yaml index 369c2a1aa0..a41b95d23a 100644 --- a/pkg/hs/urbit-atom/package.yaml +++ b/pkg/hs/urbit-atom/package.yaml @@ -4,10 +4,12 @@ license: MIT license-file: LICENSE ghc-options: - - -fwarn-incomplete-patterns - - -fwarn-unused-binds - - -fwarn-unused-imports + - -Wall - -Werror + - -Wno-type-defaults + - -Wno-unused-matches + - -Wno-name-shadowing + - -Wno-unused-do-bind - -O2 library: diff --git a/pkg/hs/urbit-eventlog-lmdb/package.yaml b/pkg/hs/urbit-eventlog-lmdb/package.yaml index 9e53f1a116..1644cf6c70 100644 --- a/pkg/hs/urbit-eventlog-lmdb/package.yaml +++ b/pkg/hs/urbit-eventlog-lmdb/package.yaml @@ -6,10 +6,12 @@ license-file: LICENSE library: source-dirs: lib ghc-options: - - -fwarn-incomplete-patterns - - -fwarn-unused-binds - - -fwarn-unused-imports + - -Wall - -Werror + - -Wno-type-defaults + - -Wno-unused-matches + - -Wno-name-shadowing + - -Wno-unused-do-bind - -O2 dependencies: diff --git a/pkg/hs/urbit-king/lib/Urbit/Arvo/Common.hs b/pkg/hs/urbit-king/lib/Urbit/Arvo/Common.hs index 645b8a1f7a..312f288d93 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Arvo/Common.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Arvo/Common.hs @@ -15,7 +15,7 @@ module Urbit.Arvo.Common , HttpServerConf(..), PEM(..), Key, Cert , HttpEvent(..), Method, Header(..), ResponseHeader(..) , ReOrg(..), reorgThroughNoun - , AmesDest(..), Ipv4(..), Ipv6(..), Patp(..), Galaxy, AmesAddress(..) + , AmesDest, Ipv4(..), Ipv6(..), Patp(..), Galaxy, AmesAddress(..) ) where import Urbit.Prelude hiding (Term) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs index 251eb7b145..b83e187921 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames.hs @@ -10,7 +10,7 @@ module Urbit.Vere.Ames (ames, ames', PacketOutcome(..)) where import Urbit.Prelude -import Network.Socket hiding (recvFrom, sendTo) +import Network.Socket import Urbit.Arvo hiding (Fake) import Urbit.King.Config import Urbit.King.Scry diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/DNS.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/DNS.hs index 3078646124..442e23faca 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/DNS.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/DNS.hs @@ -61,7 +61,7 @@ where import Urbit.Prelude -import Network.Socket hiding (recvFrom, sendTo) +import Network.Socket import Urbit.Arvo hiding (Fake) import qualified Data.Map.Strict as M diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/UDP.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/UDP.hs index 75014dd0d0..a0175b8292 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/UDP.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Ames/UDP.hs @@ -35,7 +35,7 @@ where import Urbit.Prelude import Urbit.Vere.Ports -import Network.Socket hiding (recvFrom, sendTo) +import Network.Socket import Control.Monad.STM (retry) import Network.Socket.ByteString (recvFrom, sendTo) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Behn.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Behn.hs index aab87ebff3..35c462ac22 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Behn.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Behn.hs @@ -8,6 +8,8 @@ module Urbit.Vere.Behn (behn, DriverApi(..), behn') where +import Data.Time.Clock.System (SystemTime) + import Urbit.Arvo hiding (Behn) import Urbit.Prelude import Urbit.Vere.Pier.Types @@ -39,6 +41,7 @@ bornEv king = EvBlip $ BlipEvBehn $ BehnEvBorn (king, ()) () wakeEv :: Ev wakeEv = EvBlip $ BlipEvBehn $ BehnEvWake () () +sysTime :: Wen -> SystemTime sysTime = view Time.systemTime wakeErr :: WorkError -> IO () diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Clay.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Clay.hs index 4bf767fa3a..c29fced795 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Clay.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Clay.hs @@ -8,7 +8,7 @@ module Urbit.Vere.Clay ) where -import Urbit.Arvo hiding (Term) +import Urbit.Arvo import Urbit.King.App import Urbit.Prelude import Urbit.Vere.Pier.Types @@ -32,6 +32,7 @@ deskToPath :: Desk -> FilePath deskToPath (Desk (Cord t)) = unpack t -- | The hard coded mime type of every file. +textPlain :: Path textPlain = Path [(MkKnot "text"), (MkKnot "plain")] -- | Filter for dotfiles, tempfiles and backup files. diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs index b30ade42b9..de590d0138 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Dawn.hs @@ -17,7 +17,7 @@ module Urbit.Vere.Dawn ( dawnVent import Urbit.Arvo.Common import Urbit.Arvo.Event hiding (Address) -import Urbit.Prelude hiding (Call, rights, to, (.=)) +import Urbit.Prelude hiding (rights, to, (.=)) import Data.Bits (xor) import Data.List (nub) diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs index 2aea990569..bea9e1962b 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs @@ -10,7 +10,7 @@ where import Urbit.Prelude hiding (Builder) -import Urbit.Arvo hiding (ServerId, reqUrl, secure) +import Urbit.Arvo hiding (ServerId, reqUrl) import Urbit.King.App (HasKingId(..), HasMultiEyreApi(..), HasPierEnv(..)) import Urbit.King.Config import Urbit.Vere.Eyre.Multi diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Multi.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Multi.hs index 667e686d22..7a3c27c12a 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Multi.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Multi.hs @@ -16,7 +16,7 @@ where import Urbit.Prelude hiding (Builder) -import Urbit.Arvo hiding (ServerId, reqUrl, secure) +import Urbit.Arvo hiding (ServerId, reqUrl) import Urbit.Vere.Eyre.Serv import Urbit.Vere.Eyre.Wai diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs index b6c8db0d23..a5ab80b92e 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs @@ -18,7 +18,7 @@ import Foreign.Storable import RIO.FilePath import System.Posix.IO import System.Posix.Terminal -import Urbit.Arvo hiding (Term) +import Urbit.Arvo import Urbit.King.App import Urbit.Noun.Time import Urbit.Prelude hiding (getCurrentTime) @@ -71,8 +71,10 @@ data Private = Private -- Utils ----------------------------------------------------------------------- +blewEvent :: Word -> Word -> Ev blewEvent w h = EvBlip $ BlipEvTerm $ TermEvBlew (UD 1, ()) w h +initialHail :: Ev initialHail = EvBlip $ BlipEvTerm $ TermEvHail (UD 1, ()) () -- Version one of this is punting on the ops_u.dem flag: whether we're running @@ -162,6 +164,7 @@ leftBracket, rightBracket :: Text leftBracket = "«" rightBracket = "»" +_spin_cool_us, _spin_warm_us, _spin_rate_us, _spin_idle_us :: Integral i => i _spin_cool_us = 500000 _spin_warm_us = 50000 _spin_rate_us = 250000 diff --git a/pkg/hs/urbit-king/package.yaml b/pkg/hs/urbit-king/package.yaml index 10bbe83284..4879b06701 100644 --- a/pkg/hs/urbit-king/package.yaml +++ b/pkg/hs/urbit-king/package.yaml @@ -9,10 +9,12 @@ data-files: library: source-dirs: lib ghc-options: - - -fwarn-incomplete-patterns - - -fwarn-unused-binds - - -fwarn-unused-imports + - -Wall - -Werror + - -Wno-type-defaults + - -Wno-unused-matches + - -Wno-name-shadowing + - -Wno-unused-do-bind - -O2 tests: diff --git a/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Core.hs b/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Core.hs index 0aeca303d3..ba042f9b1a 100644 --- a/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Core.hs +++ b/pkg/hs/urbit-noun-core/lib/Urbit/Noun/Core.hs @@ -37,11 +37,17 @@ data Noun = NCell Int Word !Noun !Noun | NAtom Int !Atom +pattern Cell :: Noun -> Noun -> Noun +pattern Atom :: Atom -> Noun + pattern Cell x y <- NCell _ _ x y where Cell = mkCell pattern Atom a <- NAtom _ a where Atom = mkAtom {-# COMPLETE Cell, Atom #-} +pattern C :: Noun -> Noun -> Noun +pattern A :: Atom -> Noun + pattern C x y <- NCell _ _ x y where C = mkCell pattern A a <- NAtom _ a where A = mkAtom diff --git a/pkg/hs/urbit-noun-core/package.yaml b/pkg/hs/urbit-noun-core/package.yaml index f9fee33741..a786bfffe4 100644 --- a/pkg/hs/urbit-noun-core/package.yaml +++ b/pkg/hs/urbit-noun-core/package.yaml @@ -6,10 +6,11 @@ license-file: LICENSE library: source-dirs: lib ghc-options: - - -fwarn-incomplete-patterns - - -fwarn-unused-binds - - -fwarn-unused-imports + - -Wall - -Werror + - -Wno-type-defaults + - -Wno-unused-matches + - -Wno-name-shadowing - -O2 dependencies: diff --git a/pkg/hs/urbit-noun/lib/Urbit/Noun/Tree.hs b/pkg/hs/urbit-noun/lib/Urbit/Noun/Tree.hs index 6ff6d7586c..d7459737de 100644 --- a/pkg/hs/urbit-noun/lib/Urbit/Noun/Tree.hs +++ b/pkg/hs/urbit-noun/lib/Urbit/Noun/Tree.hs @@ -41,6 +41,7 @@ data HoonTreeNode a = NTN data HoonTree a = E | Node (HoonTreeNode a) deriving (Eq, Ord, Show) +pattern N :: NounVal a -> HoonTree a -> HoonTree a -> HoonTree a pattern N n l r = Node (NTN n l r) newtype HoonSet a = HoonSet { unHoonSet :: HoonTree a } diff --git a/pkg/hs/urbit-noun/package.yaml b/pkg/hs/urbit-noun/package.yaml index 03d08a117e..2ba714abb8 100644 --- a/pkg/hs/urbit-noun/package.yaml +++ b/pkg/hs/urbit-noun/package.yaml @@ -6,10 +6,12 @@ license-file: LICENSE library: source-dirs: lib ghc-options: - - -fwarn-incomplete-patterns - - -fwarn-unused-binds - - -fwarn-unused-imports + - -Wall - -Werror + - -Wno-type-defaults + - -Wno-unused-matches + - -Wno-name-shadowing + - -Wno-orphans - -O2 dependencies: From 0567f249591a365536c6dece18a10e7bbada430e Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Tue, 3 Nov 2020 11:29:51 -0800 Subject: [PATCH 614/933] king: more warnery --- pkg/hs/proto/package.yaml | 1 + pkg/hs/racquire/lib/Data/RAcquire.hs | 4 +--- pkg/hs/racquire/package.yaml | 8 +++++--- pkg/hs/urbit-atom/package.yaml | 2 +- pkg/hs/urbit-king/lib/Urbit/Arvo/Common.hs | 3 +++ pkg/hs/urbit-termsize/app/Main.hs | 1 - pkg/hs/urbit-termsize/package.yaml | 9 ++++++--- 7 files changed, 17 insertions(+), 11 deletions(-) diff --git a/pkg/hs/proto/package.yaml b/pkg/hs/proto/package.yaml index 4427b11615..bb8f9e8829 100644 --- a/pkg/hs/proto/package.yaml +++ b/pkg/hs/proto/package.yaml @@ -64,6 +64,7 @@ library: - -fwarn-incomplete-patterns - -fwarn-unused-binds - -fwarn-unused-imports + - -Wwarn - -O2 executables: diff --git a/pkg/hs/racquire/lib/Data/RAcquire.hs b/pkg/hs/racquire/lib/Data/RAcquire.hs index 618013aa52..588db777fe 100644 --- a/pkg/hs/racquire/lib/Data/RAcquire.hs +++ b/pkg/hs/racquire/lib/Data/RAcquire.hs @@ -18,9 +18,7 @@ import qualified Control.Exception as E import qualified Control.Monad.Catch as C () import qualified Data.Acquire.Internal as Act -import Control.Applicative (Applicative(..)) -import Control.Monad (ap, liftM) -import Control.Monad.IO.Unlift (MonadIO(..), MonadUnliftIO, withRunInIO) +import Control.Monad.IO.Unlift (MonadUnliftIO, withRunInIO) import Control.Monad.Reader import Data.Typeable (Typeable) diff --git a/pkg/hs/racquire/package.yaml b/pkg/hs/racquire/package.yaml index b882b2753b..bbaca592cc 100644 --- a/pkg/hs/racquire/package.yaml +++ b/pkg/hs/racquire/package.yaml @@ -6,9 +6,11 @@ license-file: LICENSE library: source-dirs: lib ghc-options: - - -fwarn-incomplete-patterns - - -fwarn-unused-binds - - -fwarn-unused-imports + - -Wall + - -Werror + - -Wno-type-defaults + - -Wno-unused-matches + - -Wno-name-shadowing - -O2 dependencies: diff --git a/pkg/hs/urbit-atom/package.yaml b/pkg/hs/urbit-atom/package.yaml index a41b95d23a..088da5055a 100644 --- a/pkg/hs/urbit-atom/package.yaml +++ b/pkg/hs/urbit-atom/package.yaml @@ -9,7 +9,7 @@ ghc-options: - -Wno-type-defaults - -Wno-unused-matches - -Wno-name-shadowing - - -Wno-unused-do-bind + - -Wno-unbanged-strict-patterns - -O2 library: diff --git a/pkg/hs/urbit-king/lib/Urbit/Arvo/Common.hs b/pkg/hs/urbit-king/lib/Urbit/Arvo/Common.hs index 312f288d93..f02c7f69d5 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Arvo/Common.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Arvo/Common.hs @@ -4,6 +4,9 @@ -- combination with 'deriveNoun' which generates an unreachable pattern. {-# OPTIONS_GHC -Wno-overlapping-patterns #-} +-- Hack. See comment above instance ToNoun H.StdMethod +{-# OPTIONS_GHC -Wno-orphans #-} + {-| Types used in both Events and Effects. -} diff --git a/pkg/hs/urbit-termsize/app/Main.hs b/pkg/hs/urbit-termsize/app/Main.hs index 798ece23fa..aed583c746 100644 --- a/pkg/hs/urbit-termsize/app/Main.hs +++ b/pkg/hs/urbit-termsize/app/Main.hs @@ -3,7 +3,6 @@ module Main where import Prelude import Urbit.TermSize (liveTermSize) -import System.IO (getLine) main :: IO () main = do diff --git a/pkg/hs/urbit-termsize/package.yaml b/pkg/hs/urbit-termsize/package.yaml index 83efc8c17a..d63d312f7f 100644 --- a/pkg/hs/urbit-termsize/package.yaml +++ b/pkg/hs/urbit-termsize/package.yaml @@ -9,9 +9,12 @@ dependencies: - unix ghc-options: - - -fwarn-incomplete-patterns - - -fwarn-unused-binds - - -fwarn-unused-imports + - -Wall + - -Werror + - -Wno-type-defaults + - -Wno-unused-matches + - -Wno-name-shadowing + - -Wno-unused-do-bind - -O2 library: From 108b6ed485e69e05a84d2892ae4fab22fbb45d76 Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Tue, 3 Nov 2020 21:45:39 -0800 Subject: [PATCH 615/933] king: diswarn tests --- pkg/hs/urbit-atom/bench/Main.hs | 2 ++ pkg/hs/urbit-atom/test/Main.hs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/hs/urbit-atom/bench/Main.hs b/pkg/hs/urbit-atom/bench/Main.hs index 26975a9703..c4fbd225bd 100644 --- a/pkg/hs/urbit-atom/bench/Main.hs +++ b/pkg/hs/urbit-atom/bench/Main.hs @@ -1,3 +1,5 @@ +{-# OPTIONS_GHC -Wno-missing-signatures #-} + module Main (main) where import Prelude diff --git a/pkg/hs/urbit-atom/test/Main.hs b/pkg/hs/urbit-atom/test/Main.hs index e41449b5d0..0ba9611ccc 100644 --- a/pkg/hs/urbit-atom/test/Main.hs +++ b/pkg/hs/urbit-atom/test/Main.hs @@ -1,4 +1,4 @@ -{-# OPTIONS_GHC -Wno-deprecations #-} +{-# OPTIONS_GHC -Wno-deprecations -Wno-orphans #-} module Main (main) where From 9062f398a5b44f28567a0e2a39d55965e2fe98f5 Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Fri, 6 Nov 2020 10:45:25 -0800 Subject: [PATCH 616/933] king: try undoing warnings in eventlog-lmdb --- pkg/hs/urbit-eventlog-lmdb/package.yaml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/hs/urbit-eventlog-lmdb/package.yaml b/pkg/hs/urbit-eventlog-lmdb/package.yaml index 1644cf6c70..9e53f1a116 100644 --- a/pkg/hs/urbit-eventlog-lmdb/package.yaml +++ b/pkg/hs/urbit-eventlog-lmdb/package.yaml @@ -6,12 +6,10 @@ license-file: LICENSE library: source-dirs: lib ghc-options: - - -Wall + - -fwarn-incomplete-patterns + - -fwarn-unused-binds + - -fwarn-unused-imports - -Werror - - -Wno-type-defaults - - -Wno-unused-matches - - -Wno-name-shadowing - - -Wno-unused-do-bind - -O2 dependencies: From 506e7685079ddb40891ec62461f5506db62074d9 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Tue, 17 Nov 2020 18:54:17 +0100 Subject: [PATCH 617/933] build: update GoogleCloudPlatform/github-actions/setup-gcloud to 0.2.0 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 83c4bbbd9f..bad482dd78 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -100,7 +100,7 @@ jobs: name: mars authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} - - uses: GoogleCloudPlatform/github-actions/setup-gcloud@0.1.2 + - uses: GoogleCloudPlatform/github-actions/setup-gcloud@0.2.0 with: version: '290.0.1' service_account_key: ${{ secrets.GCS_SERVICE_ACCOUNT_KEY }} From a7cc18072a699e7a6bc8154b96c2678f3593daf7 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Tue, 17 Nov 2020 12:53:05 -0800 Subject: [PATCH 618/933] gall: add %doze-style fade --- bin/solid.pill | 4 +- pkg/arvo/lib/hood/helm.hoon | 4 +- pkg/arvo/sys/vane/clay.hoon | 4 +- pkg/arvo/sys/vane/gall.hoon | 166 +++++++++++++++++++++++------------- pkg/arvo/sys/zuse.hoon | 2 +- 5 files changed, 115 insertions(+), 65 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index 5b5feb799b..c0a09d745e 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b5d3225b222544eae6f78d18a4a2343ff4c746fbcb72914760b79598ff90813d -size 6278785 +oid sha256:5abdec8bcb76937c12e784a67d596ecfe58ecad0d04b466ebd3eeb6caa41aa79 +size 6513179 diff --git a/pkg/arvo/lib/hood/helm.hoon b/pkg/arvo/lib/hood/helm.hoon index fe3e1aaef0..f47bd9ddee 100644 --- a/pkg/arvo/lib/hood/helm.hoon +++ b/pkg/arvo/lib/hood/helm.hoon @@ -110,7 +110,7 @@ :: ++ poke-pass |= =note-arvo =< abet - (emit %pass /pass %arvo note-arvo) + (emit %pass /helm/pass %arvo note-arvo) :: ++ take-wake-automass |= [way=wire error=(unit tang)] @@ -281,5 +281,7 @@ ?>(?=(%wake +<.sign-arvo) +>.sign-arvo) [%serv *] %+ take-bound t.wire ?>(?=(%bound +<.sign-arvo) +>.sign-arvo) + [%pass *] ~& [%pass-response [- +<]:sign-arvo] + abet == -- diff --git a/pkg/arvo/sys/vane/clay.hoon b/pkg/arvo/sys/vane/clay.hoon index 919fd3b626..bbe5b2f4f0 100644 --- a/pkg/arvo/sys/vane/clay.hoon +++ b/pkg/arvo/sys/vane/clay.hoon @@ -1748,7 +1748,7 @@ =/ additions=(set path) (~(dif in upsert-set) old-set) ?~ hun ~ - ?: =(0 let.dom) + ?: (lte let.dom 1) ~ |^ ;: weld @@ -1765,7 +1765,7 @@ :: ++ path-to-tank |= =path - =/ pre=^path ~[(scot %p our) syd (scot %ud +(let.dom))] + =/ pre=^path ~[(scot %p our) syd (scot %ud let.dom)] :+ %rose ["/" "/" ~] %+ turn (weld pre path) |= a=cord diff --git a/pkg/arvo/sys/vane/gall.hoon b/pkg/arvo/sys/vane/gall.hoon index dfb78b5fe8..c04462b7bc 100644 --- a/pkg/arvo/sys/vane/gall.hoon +++ b/pkg/arvo/sys/vane/gall.hoon @@ -56,13 +56,13 @@ live=? =stats =watches - =agent + agent=(each agent vase) =beak marks=(map duct mark) == :: $blocked-move: enqueued move to an agent :: -+$ blocked-move [=duct =routes =deal] ++$ blocked-move [=duct =routes move=(each deal sign:agent)] :: $stats: statistics :: :: change: how many moves this agent has processed @@ -126,7 +126,7 @@ live=? =stats =watches - old-state=vase + old-state=(each vase vase) =beak marks=(map duct mark) == @@ -166,9 +166,11 @@ ?~ apps mo-core ~> %slog.[0 leaf+"gall: upgrading {}"] =/ ap-core (ap-abut:ap:mo-core i.apps) - =^ tan ap-core (ap-install:ap-core `old-state.egg.i.apps) - ?^ tan - (mean u.tan) + =? ap-core ?=(%& -.old-state.egg.i.apps) + =^ tan ap-core (ap-install:ap-core `p.old-state.egg.i.apps) + ?^ tan + (mean u.tan) + ap-core =? ap-core wipe-eyre-subs.spore =/ ducts=(list ^duct) %+ skim ~(tap in ~(key by inbound.watches.egg.i.apps)) @@ -270,7 +272,8 @@ - %6 outstanding ~ :: TODO: do we need to process these somehow? running - (~(run by running.s) |=(y=yoke-0 +:y(agent on-save:agent.y))) + :: XXX &+ should be in next state adapter + (~(run by running.s) |=(y=yoke-0 +:y(agent &+on-save:agent.y))) == :: ++ state-4-to-5 |=(s=state-4 `state-5`s(- %5, outstanding ~)) @@ -419,12 +422,13 @@ =/ =routes [disclosing=~ attributing=our] =/ ap-core (ap-abed:ap dap routes) =. ap-core (ap-reinstall:ap-core agent) - ap-abet:ap-core + =. mo-core ap-abet:ap-core + (mo-clear-queue dap) :: =. yokes.state %+ ~(put by yokes.state) dap =/ default-yoke *yoke - default-yoke(control-duct hen, beak bek, agent agent) + default-yoke(control-duct hen, beak bek, agent &+agent) :: =/ old mo-core =/ wag @@ -461,10 +465,12 @@ [%z /sys/arvo/hoon] [%z /sys/zuse/hoon] [%z /sys/vane/gall/hoon] - %+ turn ~(tap in ~(key by yokes.state)) - |= dap=term - ^- [care:clay path] - [%a /app/[dap]/hoon] + %+ murn ~(tap by yokes.state) + |= [dap=term =yoke] + ^- (unit [care:clay path]) + ?: ?=(%| -.agent.yoke) + ~ + `[%a /app/[dap]/hoon] == (mo-pass wire %c %warp our %home ~ %mult mool) :: +mo-scry-agent-cage: read $agent core from clay @@ -789,22 +795,38 @@ ~& [%mo-handle-use-bad-path path] !! :: + =/ dap=term i.path + =/ yoke (~(get by yokes.state) dap) + ?~ yoke + %- (slog leaf+"gall: {} dead, got {<+<.sign-arvo>}" ~) + mo-core ?. ?=([?(%g %b) %unto *] sign-arvo) + ?: ?=(%| -.agent.u.yoke) + %- (slog leaf+"gall: {} dozing, dropping {<+<.sign-arvo>}" ~) + mo-core =/ app - =/ =term i.path =/ =ship (slav %p i.t.path) =/ =routes [disclosing=~ attributing=ship] - (ap-abed:ap term routes) + (ap-abed:ap dap routes) :: =. app (ap-generic-take:app t.t.path sign-arvo) ap-abet:app + ?> ?=([%out @ @ *] t.t.path) + =/ =ship (slav %p i.t.t.t.path) + =/ =routes [disclosing=~ attributing=ship] =/ =sign:agent +>.sign-arvo - =/ app - ?> ?=([%out @ @ *] t.t.path) - =/ =term i.path - =/ =ship (slav %p i.t.t.t.path) - =/ =routes [disclosing=~ attributing=ship] - (ap-abed:ap term routes) + ?: ?=(%| -.agent.u.yoke) + =/ blocked=(qeu blocked-move) + =/ waiting (~(get by blocked.state) dap) + =/ deals (fall waiting *(qeu blocked-move)) + =/ deal [hen routes |+sign] + (~(put to deals) deal) + :: + %- (slog leaf+"gall: {} dozing, got {<-.sign>}" ~) + %_ mo-core + blocked.state (~(put by blocked.state) dap blocked) + == + =/ app (ap-abed:ap dap routes) =. app (ap-specific-take:app t.t.path sign) ap-abet:app @@ -822,10 +844,14 @@ ?: =(~ blocked) =. blocked.state (~(del by blocked.state) dap) mo-core - =^ [=duct =routes =deal] blocked ~(get to blocked) - =/ move + =^ [=duct =routes blocker=(each deal sign:agent)] blocked + ~(get to blocked) + =/ =move =/ =sock [attributing.routes our] - =/ card [%slip %g %deal sock dap deal] + =/ card + ?: ?=(%& -.blocker) + [%slip %g %deal sock dap p.blocker] + [%pass /clear-huck %b %huck %g %unto p.blocker] [duct card] $(moves [move moves]) :: +mo-filter-queue: remove all blocked tasks from ship. @@ -854,15 +880,15 @@ :: +mo-fade: put app to sleep :: ++ mo-fade - |= [dap=term style=?(%rest %doze %gone)] + |= [dap=term style=?(%gone %doze %wake)] ^+ mo-core =/ =routes [disclosing=~ attributing=our] =/ app (ap-abed:ap dap routes) =. mo-core ap-abet:(ap-fade:app style) ?- style %gone mo-core(yokes.state (~(del by yokes.state) dap)) - %rest !! - %doze !! + %doze mo-core + %wake (mo-boot dap our %home) == :: +mo-beak: assemble a beak for the specified agent. :: @@ -943,22 +969,23 @@ ap-abet:app :: +mo-handle-local: handle locally. :: - :: If the agent is running or blocked, assign it the supplied +deal. - :: Otherwise simply apply the action to the agent. + :: If the agent is not running or blocked, assign it the supplied + :: +deal. Otherwise simply apply the action to the agent. :: ++ mo-handle-local |= [=ship agent=term =deal] ^+ mo-core :: =/ =routes [disclosing=~ attributing=ship] - =/ is-running (~(has by yokes.state) agent) + =/ running (~(get by yokes.state) agent) + =/ is-running ?~(running %| ?=(%& -.agent.u.running)) =/ is-blocked (~(has by blocked.state) agent) :: ?: |(!is-running is-blocked) =/ blocked=(qeu blocked-move) =/ waiting (~(get by blocked.state) agent) =/ deals (fall waiting *(qeu blocked-move)) - =/ deal [hen routes deal] + =/ deal [hen routes &+deal] (~(put to deals) deal) :: %- (slog leaf+"gall: not running {} yet, got {<-.deal>}" ~) @@ -1049,10 +1076,13 @@ ++ ap-abut |= [dap=term =egg] ^+ ap-core - =/ res (mo-scry-agent-cage dap da+now) - ?: ?=(%| -.res) - (mean p.res) - =/ =yoke egg(old-state `agent`p.res) + =/ =yoke + ?: ?=(%| -.old-state.egg) + egg + =/ res (mo-scry-agent-cage dap da+now) + ?: ?=(%| -.res) + (mean p.res) + egg(p.old-state `agent`p.res) =/ =routes [disclosing=~ attributing=our] (ap-yoke dap routes yoke) :: +ap-yoke: initialize agent state, starting from a $yoke @@ -1089,26 +1119,33 @@ :: For %gone, remove all incoming and outgoing subscriptions. :: ++ ap-fade - |= style=?(%rest %doze %gone) + |= style=?(%gone %doze %wake) ^+ ap-core - ?> ?=(%gone style) - =/ out=(list [[=wire =ship =term] ? =path]) - ~(tap by outbound.watches.current-agent) - =/ inbound-paths=(set path) - %- silt - %+ turn ~(tap by inbound.watches.current-agent) - |= [=duct =ship =path] - path - =/ will=(list card:agent:gall) - %+ welp - ?: =(~ inbound-paths) - ~ - [%give %kick ~(tap in inbound-paths) ~]~ - %+ turn ~(tap by outbound.watches.current-agent) - |= [[=wire =ship =term] ? =path] - [%pass wire %agent [ship term] %leave ~] - =^ maybe-tang ap-core (ap-ingest ~ |.([will agent.current-agent])) - ap-core + ?- style + %doze + =. agent.current-agent |+on-save:ap-agent-core + ap-core + :: + %wake ap-core + %gone + =/ out=(list [[=wire =ship =term] ? =path]) + ~(tap by outbound.watches.current-agent) + =/ inbound-paths=(set path) + %- silt + %+ turn ~(tap by inbound.watches.current-agent) + |= [=duct =ship =path] + path + =/ will=(list card:agent:gall) + %+ welp + ?: =(~ inbound-paths) + ~ + [%give %kick ~(tap in inbound-paths) ~]~ + %+ turn ~(tap by outbound.watches.current-agent) + |= [[=wire =ship =term] ? =path] + [%pass wire %agent [ship term] %leave ~] + =^ maybe-tang ap-core (ap-ingest ~ |.([will *agent])) + ap-core + == :: +ap-from-internal: internal move to move. :: :: We convert from cards to duct-indexed moves when resolving @@ -1238,7 +1275,8 @@ :: +ap-agent-core: agent core with current bowl and state :: ++ ap-agent-core - ~(. agent.current-agent ap-construct-bowl) + ?> ?=(%& -.agent.current-agent) + ~(. p.agent.current-agent ap-construct-bowl) :: +ap-ducts-from-paths: get ducts subscribed to paths :: ++ ap-ducts-from-paths @@ -1372,9 +1410,12 @@ ~/ %ap-reinstall |= =agent ^+ ap-core - =/ old-state=vase ~(on-save agent.current-agent ap-construct-bowl) + =/ old-state=vase + ?: ?=(%& -.agent.current-agent) + on-save:ap-agent-core + p.agent.current-agent =^ error ap-core - (ap-install(agent.current-agent agent) `old-state) + (ap-install(agent.current-agent &+agent) `old-state) ?~ error ap-core (mean >%load-failed< u.error) @@ -1641,7 +1682,7 @@ ?: ?=(%| -.result) `ap-core :: - =. agent.current-agent +.p.result + =. agent.current-agent &++.p.result =/ moves (zing (turn -.p.result ap-from-internal)) =. inbound.watches.current-agent (ap-handle-kicks moves) @@ -1800,7 +1841,14 @@ ^- spore =; eggs=(map term egg) [- | +]:state(yokes eggs) %- ~(run by yokes.state) - |=(=yoke `egg`yoke(agent on-save:agent.yoke)) + |= =yoke + ^- egg + %= yoke + agent + ?: ?=(%& -.agent.yoke) + [%& on-save:p.agent.yoke] + [%| p.agent.yoke] + == :: +take: response :: ++ take diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index 6df1249f16..f6ac7d37ac 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -1723,7 +1723,7 @@ [$deal p=sock q=term r=deal] :: full transmission [%goad force=? agent=(unit dude)] :: rebuild agent(s) [%sear =ship] :: clear pending queues - [%fade dap=term style=?(%rest %doze %gone)] :: put app to sleep + [%fade dap=term style=?(%gone %doze %wake)] :: put app to sleep $>(%init vane-task) :: set owner $>(%trim vane-task) :: trim state $>(%vega vane-task) :: report upgrade From 8f66508d63c320a30d9d25c5b3244c600d97b197 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sun, 15 Nov 2020 00:56:52 -0800 Subject: [PATCH 619/933] arvo: moves arvo state management into |le and sketches out new event/effect routing --- pkg/arvo/sys/arvo.hoon | 979 ++++++++++++++++++----------------------- 1 file changed, 436 insertions(+), 543 deletions(-) diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index 2a2ed64756..4469875696 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -11,7 +11,7 @@ :: urbit's formal lifecycle function. a practical interpreter :: can ignore it. :: - |= [now=@da ovo=*] + |= [now=@da ovo=ovum] ^- * ~> %slog.[0 leaf+"arvo: formal event"] .(+> +:(poke now ovo)) @@ -156,48 +156,30 @@ :: $debt: ephemeral state :: $germ: worklist source and bar stack :: $heir: upgradeable state -:: $pane: kernel modules :: $plan: worklist -:: $pone: kernel modules old -:: $soil: working state :: $soul: persistent state :: $vane: kernel module :: $vile: reflexive constants :: :: +$ debt - $~ [~ ~ *germ ~] $: :: run: list of worklists :: out: pending output - :: gem: worklist metadata - :: dud: propagate error :: run=(list plan) out=(list ovum) - gem=germ - dud=(unit goof) == +$ germ [vane=term bars=(list duct)] +$ heir $% [%arvo-kelvin now=@da =debt =soul] == -+$ pane (list (pair @tas vase)) +$ plan (pair germ (list move)) -+$ pone (list (pair @tas vise)) -+$ soil :: XX use $soul - $: our=ship - now=@da - eny=@uvJ - lac=? - vil=vile - van=(map term vane) - == +$ soul - $: lac=? :: laconic bit + $: our=ship :: identity eny=@uvJ :: entropy - our=ship :: identity - bud=vase :: %zuse - vanes=(list [label=@tas =vane]) :: modules + lac=? :: laconic bit + zus=vase :: %zuse + van=(map term vane) :: modules == +$ vane [=vase =worm] +$ vile @@ -461,7 +443,45 @@ :: |va: vane engine :: ++ va - ~/ %va + => |% + :: XX move next to +slap + :: + ++ swat + |= [vax=vase gen=hoon] + ^- (trap vase) + =/ gun (~(mint ut p.vax) %noun gen) + |.([p.gun .*(q.vax q.gun)]) + :: + ++ smit + |= [cap=tape pit=vase pax=path txt=@t] + ^- (trap vase) + ~> %slog.[0 leaf+"{cap}: {(scow p+(mug txt))}"] + %- road |. + ~_ leaf/cap + (swat pit (rain pax txt)) + :: + ++ create + |= [zus=vase lal=term pax=path txt=@t] + ^- vase + (slym $:(smit "vane {}" zus pax txt) zus) + :: + ++ settle + |= van=vase + ^- (pair vase worm) + =/ [rig=vase wor=worm] (~(slym wa *worm) van *vane-sample) + [van +:(~(slap wa wor) rig [%limb %scry])] + :: + :: XX pass identity to preserve behavior? + :: + ++ update + |= [las=vase nex=vase] + ^- vase + =/ sam=vase (slap (slym las *vane-sample) [%limb %stay]) + =/ gat=vase (slap (slym nex *vane-sample) [%limb %load]) + (slam gat sam) + -- + :: + ~% %va ..va ~ |_ [our=ship vil=vile vax=vase sac=worm] :: :: |plow:va: operate in time and space @@ -570,107 +590,66 @@ ~% %le ..le ~ =| debt =* nub - + =| $: :: gem: worklist metadata + :: dud: propagate error + :: but: reboot gate + :: + gem=germ + dud=(unit goof) + but=(unit $-(heir (trap ^))) + == :: - |_ soil + |_ [[pit=vase vil=vile] now=@da soul] +* this . - ++ plot run.nub - ++ then |=(paz=(list plan) this(run (weld run paz))) - ++ abed |=(nib=debt this(nub nib)) + sol +<+> + :: :: +abet: finalize loop :: - :: .ovo: optional effect to arvo itself - :: - :: If ovo is ~, the loop is over; produce ova. - :: Else, produce u.ovo and the unfinished .nub internal state. - :: ++ abet - |= ovo=(unit ovum) - ^- $: %+ each (list ovum) - $: fec=ovum - nub=debt - == - van=(list (pair term vane)) - == - :- ?~ ovo - &+(flop out) - |+[u.ovo nub] - :: - %+ sort ~(tap by van) - |=([[a=@tas *] [b=@tas *]] (aor a b)) + ^- (each (pair (list ovum) soul) (trap ^)) + ?~ but + &/[(flop out) sol] + |/(u.but [%arvo-kelvin now [run out] sol]) + :: +poke: prepare a worklist-of-one from outside + :: + ++ poke + |= =ovum + ^+ this + ~> %mean.'arvo: poke crashed' + ~? !lac ["" %unix p.card.ovum wire.ovum now] + (poke:pith ovum) + :: + ++ jump + |= =debt + ^+ this + =: run run.debt + out out.debt + == + this :: +emit: enqueue a worklist with source :: ++ emit |= pan=plan this(run [pan run]) - :: +poke: prepare a worklist-of-one from outside - :: - ++ poke - |= [vane=term =ovum] - ^+ this - ~> %mean.'arvo: poke crashed' - ~? !lac ["" %unix p.card.ovum wire.ovum now] - =/ =maze - =/ =type [%cell [%atom %tas `%soft] %noun] - [%& type [%soft card.ovum]] - =/ =move - ~| [%bad-wire wire.ovum] - ?> ?=([%$ *] wire.ovum) - [duct=~ %pass t.wire.ovum vane maze] - (emit [%$ ~] move ~) - :: +crud: prepare a worklist-of-one with error report from outside - :: - ++ crud - |= [vane=term =goof =ovum] - ^+ this - ~> %mean.'arvo: crud crashed' - ~? !lac ["" %unix %crud p.card.ovum wire.ovum now] - =/ =maze - =/ =type [%cell [%atom %tas `%soft] %noun] - [%& type [%soft card.ovum]] - =/ =move - ~| [%bad-wire wire.ovum] - ?> ?=([%$ *] wire.ovum) - [duct=~ %hurl goof %pass t.wire.ovum vane maze] - (emit [%$ ~] move ~) - :: +spam: prepare a worklist for all targets - :: - ++ spam - |= =ovum - ^+ this - ~> %mean.'arvo: spam crashed' - :: fix up wire on %vega from previous kernel - :: - =? wire.ovum =(ovum [/ %vega ~]) //arvo - =/ ord=(list (pair term *)) - %+ sort - ~(tap by van) - |=([[a=@ *] [b=@ *]] (aor b a)) - |- ^+ this - ?~ ord - this - =. this (poke p.i.ord ovum) - $(ord t.ord) :: +loop: until done :: ++ loop - ^- abet - ?~ run - (abet ~) + ^+ abet + ?: ?| ?=(~ run) + ?=(^ but) + == + abet ?: =(~ q.i.run) :: XX TMI loop(run t.run) =. dud ~ =. gem p.i.run =^ mov=move q.i.run q.i.run - => .(run `(list plan)`run) :: XX TMI - =^ ovo=(unit ovum) this (step mov) - ?~ ovo - loop - (abet `u.ovo) + loop:(step mov) :: +step: advance the loop one step by routing a move :: ++ step |= =move - ^- [(unit ovum) _this] + ^+ this :: ~? &(!lac ?=(^ dud)) %goof :: @@ -696,7 +675,7 @@ :: :: cons source onto wire, and wire onto duct :: - `(call [[vane.gem wire] duct] vane task) + (call [[vane.gem wire] duct] vane task) :: :: %slip: lateral move :: @@ -709,7 +688,7 @@ :- (runt [(lent bars.gem) '|'] "") [%slip vane.gem (symp +>-.task) duct] :: - `(call duct vane task) + (call duct vane task) :: :: %give: return move :: @@ -743,7 +722,7 @@ (symp +>-.gift) duct.move :: - `(take duct wire vane gift) + (take duct wire vane gift) :: :: %hurl: action with error :: @@ -756,7 +735,14 @@ :: +whey: measure memory usage :: ++ whey - ^- (list mass) + ^- mass + =; mod=(list mass) + :+ %arvo %| + :~ hoon+&+pit + zuse+&+zus + vane+|+mod + == + :: =/ von %+ turn (sort ~(tap by van) |=([[a=@tas *] [b=@tas *]] (aor a b))) @@ -798,16 +784,25 @@ :: ++ xeno |= [=wire gift=maze] - ^- [(unit ovum) _this] - =/ ovo=ovum [wire ;;(card q.p.gift)] - ?: ?=(?(%lyra %veer %wack %verb %whey) -.card.ovo) - [`ovo this] - [~ this(out [ovo out])] + ^+ this + =/ ovo=ovum [wire ;;(card q.p.gift)] + :: + :: XX update clients to %pass to arvo, remove + :: + ?: ?=(?(%lyra %veer %verb %wack %whey) -.card.ovo) + ~> %mean.'xeno: bad waif' + (call:pith ;;(waif:pith card.ovo)) + :: + this(out [ovo out]) :: +call: advance to target :: ++ call |= [=duct way=term task=maze] ^+ this + ?: ?=(%$ way) + ~> %mean.'call: bad waif' + (call:pith ;;(waif:pith q.p.task)) + :: %+ push [way duct bars.gem] ~| bar-stack=`(list ^duct)`[duct bars.gem] %. task @@ -843,6 +838,121 @@ ~| [%missing-vane way] (~(got by van) way) (~(plow va [our vil vane]) now peek) + :: + :: |pith: operate on arvo internals + :: + ++ pith + => |% + :: $waif: arvo effect, from anywhere + :: $wasp: arvo effect, from Outside + :: + +$ waif + :: %lyra: upgrade kernel + :: %vega: notify vanes post upgrade + :: %whey: produce $mass :: XX remove, scry + :: %verb: toggle laconicity + :: %veer: upgrade module + :: %wack: iterate entropy :: XX move to $wasp + :: NB: %warn removed + :: + $% [%lyra hun=(unit @t) van=@t] + [%vega ~] + [%whey ~] + [%verb ~] + [%veer lal=@tas pax=path txt=@t] + [%wack p=@uvJ] + == + :: + +$ wasp + :: %crud: reroute $ovum with $goof :: NB: different + :: %trim: trim state, spam to all :: XX move to $waif + :: + $% [%trim p=@ud] + [%crud =goof =ovum] + == + -- + :: + |% + :: + ++ gest + |= =ovum + ^- $>(%pass ball) + =^ way=term wire.ovum wire.ovum + =? way ?=(%$ way) + :: patch up wire for backward-compatible routing + :: + :: XX update clients and remove + :: + (dint wire.ovum) + :: + :: %$: default, routed to arvo-proper as trivial vase + :: @: route to vane XX remove %soft, clam via %zuse + :: + =/ =vase + ?- way + %$ noun/card.ovum + @ [cell/[atom/tas/`%soft %noun] soft/card.ovum] + == + [%pass wire.ovum way &/vase] + :: + ++ call + |= =waif + ^+ ..pith + ?^ dud ~>(%mean.'pith: goof' !!) + ?- -.waif + %lyra =/ pos=plan [$/~ [*duct (gest [//arvo vega/~])] ~] + %_ ..pith + but `(boot [hun van]:waif) + run (weld run [pos ~]) + == + :: + %vega (emit $/~ (spam /arvo !>(waif))) + %verb ..pith(lac !lac) + :: + %veer ?: ?=(%$ lal.waif) + ..pith(zus $:(smit:va "zuse" pit [pax txt]:waif)) + :: + =/ nex (create:va zus [lal pax txt]:waif) + =/ nav (~(get by van) lal.waif) + =? nex ?=(^ nav) (update:va vase.u.nav nex) + ..pith(van (~(put by van) lal.waif (settle:va nex))) + :: + %wack ..pith(eny (shaz (cat 3 eny p.waif))) :: XX review + %whey ..pith(out [[//arvo mass/whey] out]) + == + :: + ++ poke + |= =ovum + ^+ ..pith + ?~ wire.ovum + ~>(%mean.'pith: bad wire' !!) + ?~ buz=((soft wasp) card.ovum) + (emit $/~ [*duct (gest ovum)] ~) + :: + ?- -.u.buz + :: + :: %trim: clear state + :: + :: clears compiler caches if high-priority + :: XX add separate $wasp if this should happen last + :: + %trim =? van =(0 p.u.buz) + (~(run by van) |=(=vane vane(worm *worm))) + (emit $/~ (spam t.wire.ovum !>(u.buz))) + :: + :: %crud: forward error notification + :: + %crud (emit $/~ [*duct hurl/[goof.u.buz (gest ovum.u.buz)]] ~) + == + :: + ++ spam + |= [=wire =vase] + ^- (list move) + %+ turn + %+ sort ~(tap by van) + |=([[a=@tas *] [b=@tas *]] (aor a b)) + |=([way=term *] `move`[*duct %pass wire way `maze`&/vase]) + -- -- -- :: @@ -850,69 +960,88 @@ |= a=* ^- @tas ?.(&(?=(@ a) ((sane %tas) a)) %$ a) :: -++ vent :: vane core - |= [who=ship lal=@tas vil=vile bud=vase =vane] - ~% %vent +>+ ~ - |% - ++ ruck :: update vase - |= {pax/path txt/@ta} - ^+ +> - :: XX should use real entropy and the real date - :: - =/ arg=vane-sample - [who ~2000.1.1 *@uvJ =>(~ |~(* ~))] - =+ rig=(slym vase.vane arg) - =+ gen=(rain pax txt) - =+ rev=(slym (slap bud gen) bud) - =+ syg=(slym rev arg) - :: update the vane itself - :: - :: We don't cache the n+slap/+slam types because they're only used once - :: right here; they'll never be used again. - :: - =. vase.vane - ~| %load-lost - (slam (slap syg [%limb %load]) (slap rig [%limb %stay])) - :: prime the new compiler cache - :: - prime - :: reset and prime the worm cache for scrys +++ boot + |= [hun=(unit @t) van=@t] + ^- $-(heir (trap ^)) + ~> %mean.'vega: ruin' + ?~ hun + =/ gat + ~> %slog.[0 leaf/"vega: compiling arvo"] + %- road |. + (slap !>(..ride) (rain /sys/arvo/hoon van)) + =/ lod + (slap (slot 7 gat) [%limb %load]) + |= =heir + |. ;;(^ q:(slam lod !>(heir))) :: - :: If the +slap/+slym in scry isn't cached, we spend the majority of - :: the time in a scry in the compiler. The +scry gate cannot have side - :: effects so we can't modify the cache at access time. So we seed the - :: cache with all the things +scry will need when we install the vane + :: hyp: hoon core type + :: hoc: hoon core + :: cop: compiler gate :: - ++ prime - ^+ ..prime + =/ [hyp=* hoc=* cop=*] + :: compile new hoon.hoon source with the current compiler :: - %_ ..prime - worm.vane - :: reset cache and add in vane activation entry + =/ raw + ~> %slog.[0 leaf/"vega: compiling hoon"] + (road |.((ride %noun u.hun))) + :: activate the new compiler gate, producing +ride + :: + =/ cop .*(0 +.raw) + :: find the kelvin version number of the new compiler + :: + =/ nex + ;;(@ .*(cop q:(~(mint ut p.raw) %noun [%limb %hoon-version]))) + :: require single-step upgrade + :: + ?. |(=(nex hoon-version) =(+(nex) hoon-version)) + :: XX %wyrd hint :: - =^ rig worm.vane - (~(slym wa *worm) vase.vane *vane-sample) - :: cache the access of the %scry arm - :: - +:(~(slap wa worm.vane) rig [%limb %scry]) - == - -- -:: -++ vint :: create vane - |= $: who=ship - lal=@tas - vil=vile - bud=vase - pax=path - txt=@ta - == - =; res ?-(-.res %& p.res, %| (mean leaf+"vint: {}" p.res)) - %- mule |. - =+ gen=(rain pax txt) - ~> %slog.[0 leaf+"vane: parsed {(scow p+(mug gen))}"] - =+ pro=(vent who lal vil bud [(slym (slap bud gen) bud) *worm]) - ~> %slog.[0 leaf+"vane: compiled {(scow p+(mug pro))}"] - prime:pro + ~>(%mean.'wyrd: vega:' !!) + :: + :: if we're upgrading language versions, recompile the compiler + :: + =^ hot=* cop + ?: =(nex hoon-version) + [raw cop] + =/ hot + ~> %slog.[0 leaf+"vega: recompiling hoon %{<`@`nex>}"] + (road |.((slum cop [%noun hun]))) + [hot .*(0 +.hot)] + :: extract the hoon core from the outer gate (+ride) + :: + =/ hoc .*(cop [%0 7]) + :: compute the type of the hoon.hoon core + :: + =/ hyp -:(slum cop [-.hot '+>']) + :: + [hyp hoc cop] + :: + :: compile arvo + :: + =/ rav + ~> %slog.[0 leaf/"vega: compiling arvo"] + (road |.((slum cop [hyp van]))) + :: activate arvo and extract the arvo core from the outer gate + :: + =/ voc .*(hoc [%7 +.rav %0 7]) + :: + :: extract the upgrade gate +load + :: + :: XX +come is now ignored, remove? + :: XX could be a constant axis now (currently +10) + :: + =/ lod + :: vip: type of the arvo.hoon core + :: fol: formula for the +load gate + :: + =/ vip -:(slum cop [-.rav '+>']) + =/ fol +:(slum cop [vip 'load']) + :: produce the upgrade gate + :: + .*(voc fol) + :: + |= =heir + |. ;;(^ (slum lod heir)) :: ++ viol :: vane tools |= but/type @@ -925,99 +1054,21 @@ == :: ++ dint :: input routing - |= hap/path ^- @tas - ?+ hap ~|([%bad-dint hap] !!) - {@ $ames *} %a - {@ $boat *} %c - {@ $newt *} %a - {@ $sync *} %c - {@ $term *} %d - {@ $http-client *} %i - {@ $http-server *} %e - {@ $behn *} %b + |= hap=path ^- @tas + ?+ hap %$ + [%ames *] %a + [%boat *] %c + [%newt *] %a + [%sync *] %c + [%term *] %d + [%http-client *] %i + [%http-server *] %e + [%behn *] %b == :: ++ is & -- -=< :: Arvo larval stage - :: - :: The true Arvo kernel knows who it is. It should not *maybe* - :: have an identity, nor should it contain multitudes. This outer - :: kernel exists to accumulate identity, entropy, and the - :: standard library. Upon having done so, it upgrades itself into - :: the true Arvo kernel. Subsequent upgrades will fall through - :: the larval stage directly into the actual kernel. - :: - :: For convenience, this larval stage also supports hoon compilation - :: with +wish and vane installation with the %veer event. - :: - =/ pit=vase !>(..is) - =| $: :: who: our identity once we know it - :: eny: entropy once we learn it - :: bod: %zuse once we receive it - :: - who=(unit ship) - eny=(unit @) - bod=(unit vase) - == - :: larval Arvo structural interface - :: - |% - ++ come ^come :: 4 - ++ load ^load :: 10 - ++ peek |=(* ~) :: 46 - :: - ++ poke |= * :: 47 - ^- [(list ovum) *] - => .(+< ;;([now=@da ovo=ovum] +<)) - ^- [(list ovum) *] - =. +>.$ - ?+ -.q.ovo - :: ignore unrecognized - :: - ~& [%larval-ignore p.ovo -.q.ovo] - +>.$ - :: install %zuse or vane - :: - %veer - ^+ +>.$ - :: use the maximum comet if we don't know who we are yet - :: - =/ our - ?^ who - u.who - =/ fip=ship (dec (bex 128)) - ~> %slog.[0 leaf+"arvo: larval identity {(scow %p fip)}"] - fip - =. ..veer (veer our now q.ovo) - +>.$(bod ?^(bod bod `bud.^poke)) - :: add entropy - :: - %wack - ^+ +>.$ - ?> ?=(@ q.q.ovo) - +>.$(eny `q.q.ovo) - :: become who you were born to be - :: - %whom - ^+ +>.$ - ?> ?=(@ q.q.ovo) - +>.$(who `q.q.ovo) - == - :: upgrade once we've accumulated identity, entropy, and %zuse - :: - ?. &(?=(^ who) ?=(^ eny) ?=(^ bod)) - [~ +>.$] - ~> %slog.[0 leaf+"arvo: metamorphosis"] - ~< %slog.[0 leaf+"arvo: metamorphosed"] - =/ =soul - [lac=& u.eny u.who u.bod vanes.^poke] - (load %arvo-kelvin now *debt soul) - :: - ++ wish |= txt=* :: 22 - ?> ?=(@ txt) - q:(slap ?~(bod pit u.bod) (ream txt)) - -- +=> :: :: persistent arvo state :: @@ -1025,313 +1076,155 @@ =/ vil=vile (viol p.pit) :: cached reflexives =| soul :: =* sol - -:: produce an interface that vere understands -:: -=< arvo -|% :: arvo: structural interface core :: -++ arvo - |% - ++ come |=(* !!) :: 4 - ++ load ^load :: 10 - :: - ++ peek |= * :: 46 - =/ rob (^peek ;;([@da path] +<)) - ?~ rob ~ - ?~ u.rob ~ - [~ u.u.rob] - :: - ++ poke |= * :: 47 - => .(+< ;;([now=@da ovo=ovum] +<)) - (^poke now ovo) - :: - ++ wish |=(* (^wish ;;(@ta +<))) :: 22 - -- +|% :: :: +come: load incompatible :: -++ come |=(* !!) +++ come |=(* !!) :: +4 +:: :: +load: load compatible, notifying vanes :: -++ load +++ load :: +10 |= hir=heir - ^- [(list ovum) *] + ^- ^ ~| %load + :: store persistent state + :: =. sol ?- -.hir %arvo-kelvin soul.hir == - =. vanes (turn vanes |=(a=[lal=@tas =vane] a(vane vane.a(worm *worm)))) - =/ run plot:(spam:(lead now.hir ~) [//arvo %vega ~]) - (leap now.hir (then:(lead now.hir `debt.hir) run)) + :: clear compiler caches + :: + =. van (~(run by van) |=(=vane vane(worm *worm))) + :: restore working state and resume + :: + =/ zef=(each (pair (list ovum) soul) (trap ^)) + loop:(~(jump le:part [pit vil] now.hir sol) debt.hir) + ?- -.zef + %& [p.p.zef ..load(sol q.p.zef)] + %| $:p.zef + == +:: :: +peek: external inspect :: -++ peek +++ peek :: +46 |= {now/@da hap/path} - ^- (unit (unit)) - ?~ hap [~ ~ hoon-version] + ^- (unit) + ?~ hap + [~ ~ hoon-version] + :: + =/ el ~(. le:part [pit vil] now sol) ?: =(hap /whey) - ``mass+(whey now) - ((sloy peek:(lead now ~)) [[151 %noun] hap]) + ``whey:el + =/ rob + ((sloy peek:el) [[151 %noun] hap]) + ?~ rob ~ + ?~ u.rob ~ + [~ u.u.rob] +:: :: +poke: external apply :: -++ poke +++ poke :: +47 |= [now=@da ovo=ovum] - =. eny (shaz (cat 3 eny now)) + ^- ^ + =. eny (shaz (cat 3 eny now)) :: XX review + :: ~| poke+-.q.ovo - |- ^- [(list ovum) *] - ?+ -.q.ovo - :: Normal events are routed to a single vane - :: - (leap now (poke:(lead now ~) (dint p.ovo) ovo)) - :: Print warning and no-op. - :: - %warn - :_ arvo - ?. ?=(^ +.q.ovo) - ~ - =/ msg=tape - :(weld "(for %" (trip (symp +<.q.ovo)) ") failed") - ~> %slog.[0 leaf+(weld "arvo: replacement event " msg)] - ?: lac - ~ - =/ rep - %- mule |. - ((slog (tang +>.q.ovo)) ~) - ~ - :: Process these events just as if they had come from a vane - :: - ?(%lyra %veer %verb %wack %whey) (feck now ovo *debt) - :: These external events (currently only %trim) are global - :: notifications, spammed to every vane - :: - %trim - => .(ovo ;;((pair wire [%trim p=@ud]) ovo)) - =^ zef vanes loop:(spam:(lead now ~) ovo) - :: clear compiler caches if high-priority - :: - =? vanes =(0 p.q.ovo) - ~> %slog.[0 leaf+"arvo: trim: clearing caches"] - (turn vanes |=([a=@tas =vane] [a vase.vane *worm])) - ?: ?=(%& -.zef) - [p.zef arvo] - (feck now [fec nub]:p.zef) - :: Error notifications are unwrapped and routed as usual - :: - %crud - ?. ?=(^ q.q.ovo) - ~|([%unknown-crud q.ovo] !!) - :: - %+ leap now - ?@ -.q.q.ovo - :: legacy %crud, directly routed - :: - (poke:(lead now ~) (dint p.ovo) ovo) - :: modern %crud, unwrapped and routed w/ $goof - :: - =/ =goof ;;(goof -.q.q.ovo) - =/ =curd ;;(curd +.q.q.ovo) - (crud:(lead now ~) (dint p.ovo) goof p.ovo curd) + =/ zef=(each (pair (list ovum) soul) (trap ^)) + loop:(~(poke le:part [pit vil] now sol) ovo) + ?- -.zef + %& [p.p.zef ..poke(sol q.p.zef)] + %| $:p.zef == -:: +lead: initialize +le core :: -++ lead - |= [now=@da nub=(unit debt)] - ^+ le:part - ~| lead+.?(nub) - =; el - ?~ nub el - (abed:el u.nub) - ~(. le:part our now eny lac vil (~(gas by *(map term vane)) vanes)) -:: +leap: run vane loop and handle effects -:: -++ leap - |= [now=@da el=_le:part] - ^- [(list ovum) *] - ~| %leap - =^ zef vanes loop:el - ?: ?=(%& -.zef) - [p.zef arvo] - (feck now [fec nub]:p.zef) -:: +whey: report memory usage -:: -++ whey - |= now=@da - ^- mass - :+ %arvo %| - :~ hoon+&+pit - zuse+&+bud - vane+|+whey:(lead now ~) - == -:: +feck: handle an effect from a vane -:: -++ feck - |= [now=@da ovo=ovum nub=debt] - ^- [(list ovum) *] - ~| feck+-.q.ovo - ?: ?=(%lyra -.q.ovo) - (vega now nub ;;([(unit @) @] +.q.ovo)) - ?+ -.q.ovo ~|(bad-fec+-.q.ovo !!) - :: produce memory usage report - :: - %whey - =. out.nub [[p.ovo mass+(whey now)] out.nub] - (leap now (lead now `nub)) - :: %verb: toggle event verbose event printfs - :: - %verb - =. lac !lac - (leap now (lead now `nub)) - :: %veer: install %zuse or vane - :: - %veer - =. ..veer (veer our now q.ovo) - (leap now (lead now `nub)) - :: %wack: add entropy - :: - %wack - ?> ?=(@ q.q.ovo) - =. eny (shaz (cat 3 eny q.q.ovo)) - (leap now (lead now `nub)) - == -:: +vega: reboot kernel -:: -++ vega - |= $: :: now: current date - :: nub: vane continuation state - :: hun: hoon.hoon source, or ~ if unchanged - :: arv: arvo.hoon source - :: - now=@da - nub=debt - hun=(unit @t) - van=@t - == - :: produce a new kernel and an effect list - :: - ^- [(list ovum) *] - :: go metacircular as hint to vere to run in new memory arena - :: - =; res ?-(-.res %& p.res, %| (mean leaf+"vega: ruin" p.res)) - %- mule |. - :: obtain hoon compiler data - :: - :: Arvo is compiled against the hoon.hoon vase with its outer +ride - :: gate stripped off, leaving the main core. - :: - :: hyp: hoon core type - :: hoc: hoon core - :: cop: compiler gate - :: lod: can we use the +load arm? (language-compatible upgrade) - :: - =/ [hyp=* hoc=* cop=* lod=?] - :: if no new hoon.hoon source, use current compiler - :: - ?~ hun - [-:!>(+>:ride) +>:ride ride &] - :: compile new hoon.hoon source with the current compiler - :: - =/ raw - ~> %slog.[0 leaf+"vega: compiling hoon"] - (road |.((ride %noun u.hun))) - :: activate the new compiler gate, producing +ride - :: - =/ cop .*(0 +.raw) - :: find the hoon version number of the new kernel - :: - =/ nex - (@ .*(cop q:(~(mint ut p.raw) %noun [%limb %hoon-version]))) - ?> |(=(nex hoon-version) =(+(nex) hoon-version)) - :: if we're upgrading language versions, recompile the compiler - :: - =^ hot=* cop - ?: =(nex hoon-version) - [raw cop] - ~> %slog.[0 leaf+"vega: recompiling hoon {}k"] - ~& [%hoon-compile-upgrade nex] - %- road |. - =/ hot (slum cop [%noun hun]) - [hot .*(0 +.hot)] - :: extract the hoon core from the outer gate (+ride) - :: - =/ hoc .*(cop [%0 7]) - :: compute the type of the hoon.hoon core - :: - =/ hyp -:(slum cop [-.hot '+>']) - :: - [hyp hoc cop =(nex hoon-version)] - :: compile arvo - :: - =/ rav - ~> %slog.[0 leaf+"vega: compiling kernel {(scow %p (mug hyp))}"] - %- road |. - (slum cop [hyp van]) - :: activate arvo, and extract the arvo core from the outer gate - :: - ~> %slog.[0 leaf+"vega: extracting core"] - =/ voc .*(hoc [%7 +.rav %0 7]) - :: entry gate: ++load for the normal case, ++come for upgrade - :: - =/ gat - =/ arm ?:(lod 'load' 'come') - ~> %slog.[0 leaf+"vega: +{(trip arm)}"] - :: compute the type of the arvo.hoon core - :: - =/ vip -:(slum cop [-.rav '+>']) - :: compute the formula for the upgrade gate - :: - =/ fol +:(slum cop [vip arm]) - :: produce the upgrade gate - :: - .*(voc fol) - :: upgrade gate sample - :: - =/ sam=heir [%arvo-kelvin now nub sol] - :: call into the new kernel - :: - ~> %slog.[0 leaf+"vega: evolving"] - ~< %slog.[0 leaf+"vega: evolution"] - =/ out (slum gat sam) - :: add types to the product - :: - ;;([(list ovum) *] out) -:: +veer: install %zuse or a vane -:: -:: Identity is in the sample so the larval stage -:: can use this too. -:: -++ veer - |= [who=ship now=@da fav=curd] - ^+ ..veer - => .(fav ;;([%veer lal=@tas pax=path txt=@t] fav)) - =; res ?-(-.res %& p.res, %| (mean leaf+"veer: {}" p.res)) - %- mule |. - ?: =(%$ lal.fav) - ~> %slog.[0 leaf+"zuse: {(scow p+(mug txt.fav))}"] - =+ gen=(rain pax.fav txt.fav) - =+ vax=(slap pit gen) - ..veer(bud vax) - %_ ..veer - vanes - |- ^+ vanes - ?~ vanes - ~> %slog.[0 leaf+"vane: {} {(scow p+(mug txt.fav))}"] - =/ vin (vint who lal.fav vil bud pax.fav txt.fav) - [[lal.fav vane.vin] vanes] - ?. =(lal.fav label.i.vanes) - [i.vanes $(vanes t.vanes)] - ~> %slog.[0 leaf+"vane: {} {(scow p+(mug txt.fav))}"] - :_ t.vanes - :- label.i.vanes - ~| [%failed-vane-activation lal.fav] - =< vane - %. [pax txt]:fav - ruck:(vent who lal.fav vil bud [vase.vane.i.vanes *worm]) - == :: +wish: external compute :: -++ wish +++ wish :: +22 |= txt/@ - q:(slap bud (ream txt)) + q:(slap zus (ream txt)) +-- +:: +:: larval stage +:: +:: The true Arvo kernel knows who it is. It should not *maybe* +:: have an identity, nor should it contain multitudes. This outer +:: kernel exists to accumulate identity, entropy, and the +:: standard library. Upon having done so, it upgrades itself into +:: the true Arvo kernel. Subsequent upgrades will fall through +:: the larval stage directly into the actual kernel. +:: +:: For convenience, this larval stage also supports hoon compilation +:: with +wish and vane installation with the %veer event. +:: +=| $: :: who: identity once we know it + :: eny: entropy once we learn it + :: bod: %zuse once we receive it + :: + who=(unit ship) + eny=(unit @) + bod=(unit (trap vase)) + van=(map term (trap vase)) + == +=> |% + :: $grub: larval events + :: + +$ grub + $% $>(%veer waif:pith:le:part) + $>(%wack waif:pith:le:part) :: XX $wasp + [%whom p=ship] + == + :: + ++ mint + |= [vax=vase lal=term pax=path txt=@t] + ^- (trap vase) + =/ cap ?:(?=(%$ lal) "zuse" "vane {}") + (smit:va:part cap vax pax txt) + :: + ++ molt + |= $: [our=ship now=@da eny=@uvJ] + zus=vase + van=(map term (trap vase)) + == + ^- heir + =/ nav %- ~(run by van) + |=(a=(trap vase) (settle:va:part (slym $:a zus))) + [%arvo-kelvin now *debt [our eny & zus nav]] + -- +:: +|% +++ come ^come :: +4 +++ load ^load :: +10 +++ peek _~ :: +46 +++ poke :: +47 + |= [now=@da ovo=ovum] + ^- ^ + =/ gub + ~> %mean.'arvo: bad grub' + ;;(grub q.ovo) + :: + =. ..poke + ?- -.gub + %veer ?: ?=(%$ lal.gub) + ..poke(bod `(mint pit [lal pax txt]:gub)) + =/ zus =<($ (need bod)) :: XX misparse + ..poke(van (~(put by van) lal.gub (mint zus [lal pax txt]:gub))) + :: + %wack ..poke(eny `p.gub) + %whom ..poke(who `p.gub) + == + :: + :: upgrade once we've accumulated identity, entropy, and %zuse + :: + ?. &(?=(^ who) ?=(^ eny) ?=(^ bod)) + [~ ..poke] + :: + ~> %slog.[0 leaf+"arvo: metamorphosis"] + (load (molt [u.who now u.eny] $:u.bod van)) +:: +++ wish :: +22 + |= txt=* + q:(slap ?~(bod pit $:u.bod) (ream ;;(@t txt))) -- From e2ba632a419f7e79f46115ba1939ef9d0c208fd8 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 16 Nov 2020 19:31:50 -0800 Subject: [PATCH 620/933] pill: solid --- bin/solid.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index 9f48f9c725..dfcf1426b1 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:818ea685af79b5bcfed24c811004aad424ba914dff7fd09c22b4053f1e8c7fdb -size 6287695 +oid sha256:10d985d85d13ac807f788cdf2aace62e7c0e037aefe85d71b87324d2f34888b8 +size 6355394 From 6ff7f12c16480e7bf9a428697b73cf5476b3b2e2 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 16 Nov 2020 11:22:24 -0800 Subject: [PATCH 621/933] vere: switches (mostly) to new event/effect routing --- pkg/urbit/vere/auto.c | 13 +++++++------ pkg/urbit/vere/io/unix.c | 2 +- pkg/urbit/vere/pier.c | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pkg/urbit/vere/auto.c b/pkg/urbit/vere/auto.c index cca6fae144..759f9a6e47 100644 --- a/pkg/urbit/vere/auto.c +++ b/pkg/urbit/vere/auto.c @@ -237,11 +237,7 @@ u3_auto_next(u3_auto* car_u, u3_noun* ovo) u3_auto_work(egg_u); - // XX cons [tar] route onto wire - // - // *ovo = u3nt(u3nc(u3k(egg_u->tar), u3k(egg_u->wir)), - // u3k(egg_u->cad)); - *ovo = u3nc(u3nc(u3_blip, u3k(egg_u->wir)), + *ovo = u3nc(u3nc(u3k(egg_u->tar), u3k(egg_u->wir)), u3k(egg_u->cad)); return egg_u; @@ -289,7 +285,12 @@ u3_auto_kick(u3_auto* car_u, u3_noun act) while ( u3_nul != act ) { fec = u3h(act); u3x_cell(fec, &pax, &cad); - u3_assent(u3r_p(pax, u3_blip, &wir)); + + // XX temporary backwards compatibility, remove + // + if ( c3n == u3r_p(pax, u3_blip, &wir) ) { + wir = pax; + } while ( c3n == _auto_kick(car_u, u3k(wir), u3k(cad)) ) { if ( car_u->nex_u ) { diff --git a/pkg/urbit/vere/io/unix.c b/pkg/urbit/vere/io/unix.c index debca0c833..56ed9a4c1d 100644 --- a/pkg/urbit/vere/io/unix.c +++ b/pkg/urbit/vere/io/unix.c @@ -1090,7 +1090,7 @@ u3_unix_initial_into_card(c3_c* arv_c) { u3_noun can = _unix_initial_update_dir(arv_c, arv_c); - return u3nc(u3nt(u3_blip, c3__sync, u3_nul), + return u3nc(u3nt(c3__c, c3__sync, u3_nul), u3nq(c3__into, u3_nul, c3y, can)); } diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index 0da9f6bb19..af02fdd25a 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -1465,7 +1465,7 @@ _pier_boot_make(u3_noun who, u3_noun ven, u3_noun pil) // c3_assert( c3y == u3a_is_cell(ven) ); - u3_noun wir = u3nq(u3_blip, c3__term, '1', u3_nul); + u3_noun wir = u3nq(c3__d, c3__term, '1', u3_nul); u3_noun cad = u3nt(c3__boot, u3_Host.ops_u.lit, ven); // transfer bot_u.use = u3nc(u3nc(wir, cad), bot_u.use); From 8b83760c33468b894f02e359671876ac5db88433 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 16 Nov 2020 19:25:13 -0800 Subject: [PATCH 622/933] serf: switches to new new crud --- pkg/urbit/worker/serf.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/urbit/worker/serf.c b/pkg/urbit/worker/serf.c index 71460db93a..6bfb771b68 100644 --- a/pkg/urbit/worker/serf.c +++ b/pkg/urbit/worker/serf.c @@ -444,11 +444,13 @@ _serf_sure(u3_serf* sef_u, c3_w pre_w, u3_noun par) static u3_noun _serf_make_crud(u3_noun job, u3_noun dud) { - u3_noun now, ovo, wir, cad, new; + u3_noun now, ovo, new; u3x_cell(job, &now, &ovo); - u3x_cell(ovo, &wir, &cad); - new = u3nt(u3i_vint(u3k(now)), u3k(wir), u3nt(c3__crud, dud, u3k(cad))); + new = u3nt(u3i_vint(u3k(now)), + u3nt(u3_blip, c3__arvo, u3_nul), + u3nt(c3__crud, dud, u3k(ovo))); + u3z(job); return new; } From 17ae2572a8c3aa87b1e57373c92849aaf6d5531c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 16 Nov 2020 11:53:21 -0800 Subject: [PATCH 623/933] arvo: disables old event/effect routing regime --- pkg/arvo/lib/pill.hoon | 2 +- pkg/arvo/sys/arvo.hoon | 63 ++++++++++++++++++++---------------------- 2 files changed, 31 insertions(+), 34 deletions(-) diff --git a/pkg/arvo/lib/pill.hoon b/pkg/arvo/lib/pill.hoon index 06493edc8c..59d800aea2 100644 --- a/pkg/arvo/lib/pill.hoon +++ b/pkg/arvo/lib/pill.hoon @@ -66,7 +66,7 @@ :: hav: all user files :: =; hav ~& user-files+(lent hav) - [[%$ %sync ~] [%into %$ & hav]] + [/c/sync [%into %$ & hav]] =| hav/mode:clay |- ^+ hav ?~ sal ~ diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index 4469875696..a96d78f85e 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -700,21 +700,11 @@ =/ duct t.duct.move =* gift gift.ball.move :: - ?~ duct - :: - :: the caller was Outside - :: - ~| [%xeno wire (symp -.q.p.gift)] - ?> ?=([%$ *] wire) - (xeno wire gift) - :: - :: the caller was a vane - :: - =^ vane=term wire + =^ way=term wire ~| [%give duct.move (symp -.q.p.gift)] ?>(?=(^ wire) wire) :: - ~? &(!lac |(!=(%blit +>-.gift) !=(%d vane.gem))) + ~? &(!lac !=(%$ way) |(!=(%blit +>-.gift) !=(%d vane.gem))) :- (runt [(lent bars.gem) '|'] "") :^ %give vane.gem ?: ?=(%unto +>-.gift) @@ -722,7 +712,7 @@ (symp +>-.gift) duct.move :: - (take duct wire vane gift) + (take duct wire way gift) :: :: %hurl: action with error :: @@ -780,20 +770,6 @@ ?. (~(has by van) lal) ~ (peek:(plow lal) fur ren bed) - :: +xeno: stash pending output - :: - ++ xeno - |= [=wire gift=maze] - ^+ this - =/ ovo=ovum [wire ;;(card q.p.gift)] - :: - :: XX update clients to %pass to arvo, remove - :: - ?: ?=(?(%lyra %veer %verb %wack %whey) -.card.ovo) - ~> %mean.'xeno: bad waif' - (call:pith ;;(waif:pith card.ovo)) - :: - this(out [ovo out]) :: +call: advance to target :: ++ call @@ -812,6 +788,15 @@ ++ take |= [=duct =wire way=term gift=maze] ^+ this + ?: ?=(%$ way) + :: + :: the caller was Outside + :: + ?> ?=(~ duct) + (xeno:pith wire ;;(card q.p.gift)) + :: + :: the caller was a vane + :: %+ push [way duct bars.gem] :: :: cons source onto .gift to make a $sign @@ -878,12 +863,10 @@ |= =ovum ^- $>(%pass ball) =^ way=term wire.ovum wire.ovum - =? way ?=(%$ way) - :: patch up wire for backward-compatible routing - :: - :: XX update clients and remove - :: - (dint wire.ovum) + :: + :: XX uncomment to restore previous routing + :: + :: =? way ?=(%$ way) (dint wire.ovum) :: :: %$: default, routed to arvo-proper as trivial vase :: @: route to vane XX remove %soft, clam via %zuse @@ -952,6 +935,20 @@ %+ sort ~(tap by van) |=([[a=@tas *] [b=@tas *]] (aor a b)) |=([way=term *] `move`[*duct %pass wire way `maze`&/vase]) + :: + ++ xeno + |= =ovum + ^+ this + :: XX update clients to %pass to arvo, remove + :: + ?: ?=(?(%lyra %veer %verb %wack %whey) -.card.ovum) + ~> %mean.'xeno: bad waif' + (call ;;(waif:pith card.ovum)) + :: + :: XX uncomment to restore previous routing + :: + :: =. wire.ovum $/wire.ovum + this(out [ovum out]) -- -- -- From 7645b4d096e005359f488e675223ae38ca6a8592 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 16 Nov 2020 19:24:35 -0800 Subject: [PATCH 624/933] vere: fixes crash on bailing bail --- pkg/urbit/vere/pier.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index af02fdd25a..41b48fc096 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -347,7 +347,11 @@ _pier_on_lord_work_bail(void* ptr_v, u3_ovum* egg_u, u3_noun lud) u3_auto_bail(egg_u, lud); - _pier_work(pir_u->wok_u); + // XX groace + // + if ( pir_u->wok_u ) { + _pier_work(pir_u->wok_u); + } } /* _pier_work_time(): set time. From 5ecc184638f0cf566ea14a3ea5198aaa4bfbb360 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 16 Nov 2020 19:47:43 -0800 Subject: [PATCH 625/933] arvo: refines arvo internal ($waif) and external ($wasp) effects --- pkg/arvo/sys/arvo.hoon | 63 +++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index a96d78f85e..95e9cef08c 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -833,27 +833,27 @@ :: +$ waif :: %lyra: upgrade kernel + :: %trim: trim state, spam to all :: %vega: notify vanes post upgrade :: %whey: produce $mass :: XX remove, scry :: %verb: toggle laconicity :: %veer: upgrade module - :: %wack: iterate entropy :: XX move to $wasp :: NB: %warn removed :: $% [%lyra hun=(unit @t) van=@t] + [%trim p=@ud] [%vega ~] [%whey ~] - [%verb ~] + [%verb p=(unit ?)] [%veer lal=@tas pax=path txt=@t] - [%wack p=@uvJ] == :: +$ wasp :: %crud: reroute $ovum with $goof :: NB: different - :: %trim: trim state, spam to all :: XX move to $waif + :: %wack: iterate entropy :: - $% [%trim p=@ud] - [%crud =goof =ovum] + $% [%crud =goof =ovum] + [%wack p=@uvJ] == -- :: @@ -888,9 +888,18 @@ but `(boot [hun van]:waif) run (weld run [pos ~]) == + :: + :: %trim: clear state + :: + :: clears compiler caches if high-priority + :: XX add separate $wasp if this should happen last + :: + %trim =? van =(0 p.waif) + (~(run by van) |=(=vane vane(worm *worm))) + (emit $/~ (spam /arvo !>(waif))) :: %vega (emit $/~ (spam /arvo !>(waif))) - %verb ..pith(lac !lac) + %verb ..pith(lac ?~(p.waif !lac u.p.waif)) :: %veer ?: ?=(%$ lal.waif) ..pith(zus $:(smit:va "zuse" pit [pax txt]:waif)) @@ -900,7 +909,6 @@ =? nex ?=(^ nav) (update:va vase.u.nav nex) ..pith(van (~(put by van) lal.waif (settle:va nex))) :: - %wack ..pith(eny (shaz (cat 3 eny p.waif))) :: XX review %whey ..pith(out [[//arvo mass/whey] out]) == :: @@ -909,23 +917,20 @@ ^+ ..pith ?~ wire.ovum ~>(%mean.'pith: bad wire' !!) - ?~ buz=((soft wasp) card.ovum) + :: + ?. ?=(?(%crud %wack) -.card.ovum) (emit $/~ [*duct (gest ovum)] ~) :: - ?- -.u.buz - :: - :: %trim: clear state - :: - :: clears compiler caches if high-priority - :: XX add separate $wasp if this should happen last - :: - %trim =? van =(0 p.u.buz) - (~(run by van) |=(=vane vane(worm *worm))) - (emit $/~ (spam t.wire.ovum !>(u.buz))) + =/ buz ;;(wasp card.ovum) + ?- -.buz :: :: %crud: forward error notification :: - %crud (emit $/~ [*duct hurl/[goof.u.buz (gest ovum.u.buz)]] ~) + %crud (emit $/~ [*duct hurl/[goof.buz (gest ovum.buz)]] ~) + :: + :: XX review + :: + %wack ..pith(eny (shaz (cat 3 eny p.buz))) == :: ++ spam @@ -941,7 +946,7 @@ ^+ this :: XX update clients to %pass to arvo, remove :: - ?: ?=(?(%lyra %veer %verb %wack %whey) -.card.ovum) + ?: ?=(?(%lyra %veer %verb %whey) -.card.ovum) ~> %mean.'xeno: bad waif' (call ;;(waif:pith card.ovum)) :: @@ -1162,6 +1167,7 @@ :: who=(unit ship) eny=(unit @) + lac=? bod=(unit (trap vase)) van=(map term (trap vase)) == @@ -1169,8 +1175,9 @@ :: $grub: larval events :: +$ grub - $% $>(%veer waif:pith:le:part) - $>(%wack waif:pith:le:part) :: XX $wasp + $% $>(%verb waif:pith:le:part) + $>(%veer waif:pith:le:part) + $>(%wack wasp:pith:le:part) [%whom p=ship] == :: @@ -1182,13 +1189,15 @@ :: ++ molt |= $: [our=ship now=@da eny=@uvJ] - zus=vase + lac=? + bod=(trap vase) van=(map term (trap vase)) == ^- heir + =/ zus $:bod =/ nav %- ~(run by van) |=(a=(trap vase) (settle:va:part (slym $:a zus))) - [%arvo-kelvin now *debt [our eny & zus nav]] + [%arvo-kelvin now *debt [our eny lac zus nav]] -- :: |% @@ -1204,6 +1213,8 @@ :: =. ..poke ?- -.gub + %verb ..poke(lac ?~(p.gub !lac u.p.gub)) + :: %veer ?: ?=(%$ lal.gub) ..poke(bod `(mint pit [lal pax txt]:gub)) =/ zus =<($ (need bod)) :: XX misparse @@ -1219,7 +1230,7 @@ [~ ..poke] :: ~> %slog.[0 leaf+"arvo: metamorphosis"] - (load (molt [u.who now u.eny] $:u.bod van)) + (load (molt [u.who now u.eny] lac u.bod van)) :: ++ wish :: +22 |= txt=* From 79633c3559d2a4eff9d63ecc2d7a6c30297feb7f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 17 Nov 2020 15:04:26 -0800 Subject: [PATCH 626/933] arvo: adds (no-op) version negotiation --- pkg/arvo/sys/arvo.hoon | 147 +++++++++++++++++++++++++++++++++-------- 1 file changed, 120 insertions(+), 27 deletions(-) diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index 95e9cef08c..0c6eb81434 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -159,8 +159,9 @@ :: $plan: worklist :: $soul: persistent state :: $vane: kernel module +:: $vere: runtime version :: $vile: reflexive constants -:: +:: $wynn: kelvin stack :: +$ debt $: :: run: list of worklists @@ -178,16 +179,24 @@ $: our=ship :: identity eny=@uvJ :: entropy lac=? :: laconic bit + ver=vere :: runtime zus=vase :: %zuse van=(map term vane) :: modules == +$ vane [=vase =worm] ++$ vere + $: $: non=@ta + rev=(pair term (trel @ud @ud @ud)) :: XX path? + == + kel=wynn + == +$ vile $: typ=type :: -:!>(*type) duc=type :: -:!>(*duct) wir=type :: -:!>(*wire) dud=type :: -:!>(*(unit goof)) == ++$ wynn (list (pair term @ud)) -- => ~% %hex ..ut ~ @@ -264,6 +273,44 @@ == ~>(%slog.[0 leaf+"arvo: scry-dark"] ~) [~ ~ +.q.u.u.bop] +:: +wyrd: kelvin negotiation +:: +:: specified but unimplemented: +:: arvo should produce a [wend/wynn] effect +:: to signal downgrade +:: +++ wyrd + |= [run=wynn hav=wynn] + :: wyr: ~: runtime supports all required kelvins + :: ^: runtime support is missing or lagging + :: + =; wyr + ~& wyrd=wyr + :: XX revise hint, crash + :: + :: ?^ wyr + :: ~> %wyrd.[p.u.wyr] + :: ~_ ?~ q.u.wyr + :: leaf/"missing" + :: leaf/"wyrd: %({(trip p.p.u.wyr)} {(scow %ud q.p.u.wyr)} {(scow %ud q.u.wyr)}" + :: !! + :: + same + |- ^- (unit (pair (pair term @ud) (unit @ud))) + ?~ hav ~ + :: + :: fel: %&: runtime kelvin for [i.hav] + :: %|: no specified runtime support + :: + =/ fel + |- ^- (each @ud (pair term @ud)) + ?~ run |/i.hav + ?:(=(p.i.hav p.i.run) &/q.i.run $(run t.run)) + :: + ?- -.fel + %| `[p.fel ~] + %& ?.((lte q.i.hav p.fel) `[i.hav `p.fel] $(hav t.hav)) + == :: |part: arvo structures and engines :: ++ part @@ -851,9 +898,11 @@ +$ wasp :: %crud: reroute $ovum with $goof :: NB: different :: %wack: iterate entropy + :: %wyrd: check/record runtime kelvin stack :: $% [%crud =goof =ovum] [%wack p=@uvJ] + [%wyrd p=vere] == -- :: @@ -885,7 +934,7 @@ ?- -.waif %lyra =/ pos=plan [$/~ [*duct (gest [//arvo vega/~])] ~] %_ ..pith - but `(boot [hun van]:waif) + but `(boot kel.ver [hun van]:waif) run (weld run [pos ~]) == :: @@ -902,7 +951,10 @@ %verb ..pith(lac ?~(p.waif !lac u.p.waif)) :: %veer ?: ?=(%$ lal.waif) - ..pith(zus $:(smit:va "zuse" pit [pax txt]:waif)) + =. zus $:(smit:va "zuse" pit [pax txt]:waif) + %- (wyrd kel.ver [zuse/;;(@ud q:(slap zus limb/%zuse)) ~]) + ..pith + :: :: =/ nex (create:va zus [lal pax txt]:waif) =/ nav (~(get by van) lal.waif) @@ -918,7 +970,7 @@ ?~ wire.ovum ~>(%mean.'pith: bad wire' !!) :: - ?. ?=(?(%crud %wack) -.card.ovum) + ?. ?=(?(%crud %wack %wyrd) -.card.ovum) (emit $/~ [*duct (gest ovum)] ~) :: =/ buz ;;(wasp card.ovum) @@ -931,6 +983,17 @@ :: XX review :: %wack ..pith(eny (shaz (cat 3 eny p.buz))) + :: + :: %wyrd: check for runtime kelvin compatibility + :: + %wyrd =. ver p.buz + %- %+ wyrd kel.ver + ^- (list (pair term @)) + :~ hoon/hoon-version + arvo/%arvo-kelvin + zuse/;;(@ q:(slap zus limb/%zuse)) + == + ..pith == :: ++ spam @@ -963,7 +1026,7 @@ ?.(&(?=(@ a) ((sane %tas) a)) %$ a) :: ++ boot - |= [hun=(unit @t) van=@t] + |= [kel=wynn hun=(unit @t) van=@t] ^- $-(heir (trap ^)) ~> %mean.'vega: ruin' ?~ hun @@ -996,9 +1059,12 @@ :: require single-step upgrade :: ?. |(=(nex hoon-version) =(+(nex) hoon-version)) - :: XX %wyrd hint + :: XX revise hint :: ~>(%mean.'wyrd: vega:' !!) + :: require runtime compatibility + :: + %- (wyrd kel [hoon/nex ~]) :: :: if we're upgrading language versions, recompile the compiler :: @@ -1101,6 +1167,13 @@ :: clear compiler caches :: =. van (~(run by van) |=(=vane vane(worm *worm))) + :: + %- %+ wyrd kel.ver + ^- (list (pair term @)) + :~ hoon/hoon-version + arvo/%arvo-kelvin + zuse/;;(@ q:(slap zus limb/%zuse)) + == :: restore working state and resume :: =/ zef=(each (pair (list ovum) soul) (trap ^)) @@ -1161,24 +1234,29 @@ :: For convenience, this larval stage also supports hoon compilation :: with +wish and vane installation with the %veer event. :: -=| $: :: who: identity once we know it - :: eny: entropy once we learn it - :: bod: %zuse once we receive it - :: - who=(unit ship) - eny=(unit @) - lac=? - bod=(unit (trap vase)) - van=(map term (trap vase)) - == => |% + :: $foal: larval state :: $grub: larval events :: + +$ foal + $: :: who: identity once we know it + :: eny: entropy once we learn it + :: bod: %zuse once we receive it + :: + who=(unit ship) + eny=(unit @) + lac=? + ver=vere :: XX unit + bod=(unit (trap vase)) + van=(map term (trap vase)) + == +$ grub + $~ verb/~ $% $>(%verb waif:pith:le:part) $>(%veer waif:pith:le:part) $>(%wack wasp:pith:le:part) [%whom p=ship] + $>(%wyrd wasp:pith:le:part) == :: ++ mint @@ -1188,18 +1266,24 @@ (smit:va:part cap vax pax txt) :: ++ molt - |= $: [our=ship now=@da eny=@uvJ] - lac=? - bod=(trap vase) - van=(map term (trap vase)) + |= [now=@da foal] + ^- (unit heir) + ?. &(?=(^ who) ?=(^ eny) ?=(^ bod)) + ~ + =/ zus $:u.bod + %- %+ wyrd kel.ver + ^- (list (pair term @)) + :~ hoon/hoon-version + arvo/%arvo-kelvin + zuse/;;(@ud q:(slap zus limb/%zuse)) == - ^- heir - =/ zus $:bod =/ nav %- ~(run by van) |=(a=(trap vase) (settle:va:part (slym $:a zus))) - [%arvo-kelvin now *debt [our eny lac zus nav]] + `[%arvo-kelvin now *debt [u.who u.eny lac ver zus nav]] -- :: +=| foal +=* fol - |% ++ come ^come :: +4 ++ load ^load :: +10 @@ -1222,15 +1306,24 @@ :: %wack ..poke(eny `p.gub) %whom ..poke(who `p.gub) + %wyrd =. ver p.gub + %- %+ wyrd kel.ver + ^- (list (pair term @)) + :* hoon/hoon-version + arvo/%arvo-kelvin + ?~ bod ~ + [zuse/;;(@ud q:(slap $:u.bod limb/%zuse)) ~] + == + ..poke == :: - :: upgrade once we've accumulated identity, entropy, and %zuse - :: - ?. &(?=(^ who) ?=(^ eny) ?=(^ bod)) + ?~ hir=(molt now fol) [~ ..poke] :: + :: upgrade once we've accumulated necessary state + :: ~> %slog.[0 leaf+"arvo: metamorphosis"] - (load (molt [u.who now u.eny] lac u.bod van)) + (load u.hir) :: ++ wish :: +22 |= txt=* From 5f1d75c1194ab813b50d3f699d3fa24a6faed8c6 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 17 Nov 2020 15:10:15 -0800 Subject: [PATCH 627/933] pill: solid --- bin/solid.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index dfcf1426b1..af127b16b9 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:10d985d85d13ac807f788cdf2aace62e7c0e037aefe85d71b87324d2f34888b8 -size 6355394 +oid sha256:5edb7587624d1bcc5e764bf525f5fae7817c44587be46effe1b749afb192f99d +size 6409061 From 2cd4c29613e314a54aef24fa9c7fa4a7a9defbe4 Mon Sep 17 00:00:00 2001 From: John Franklin Date: Wed, 18 Nov 2020 01:47:42 -0600 Subject: [PATCH 628/933] pill: solid.pill --- bin/solid.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index e8bcd892b2..17d47dca6c 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b4e0acf6459d5d17f2dff4de71e9ddd0732148f00bd13d0c092fdfa14774a015 -size 6332407 +oid sha256:d18233ffa40c24e0e3d43b201788cf5d880ea4517fb33f12f6850af2b6a8100c +size 6436148 From 16b9d810f980f7ff5957cb3c8f2ca6aa04ce1816 Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Wed, 18 Nov 2020 12:56:31 -0800 Subject: [PATCH 629/933] vere: manage memory properly in _fore_import --- pkg/urbit/vere/io/fore.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/pkg/urbit/vere/io/fore.c b/pkg/urbit/vere/io/fore.c index 8eea61f226..1da96bcc6d 100644 --- a/pkg/urbit/vere/io/fore.c +++ b/pkg/urbit/vere/io/fore.c @@ -22,6 +22,17 @@ _fore_inject_bail(u3_ovum* egg_u, u3_noun lud) u3_ovum_free(egg_u); } +/* _fore_import_bail(): handle failure on arbitrary injection. +*/ +static void +_fore_import_bail(u3_ovum* egg_u, u3_noun lud) +{ + u3_auto_bail_slog(egg_u, lud); + u3l_log("pier: import failed\n"); + + u3_ovum_free(egg_u); +} + /* _fore_inject(): inject an arbitrary ovum from a jammed file at [pax_c]. */ static void @@ -75,16 +86,17 @@ static void _fore_import(u3_auto* car_u, c3_c* pax_c) { // With apologies - u3_noun arc = u3ke_cue(u3m_file(pax_c)); - c3_c * b64_c = u3r_string(u3do("crip", u3do("en-base64:mimes:html", arc))); - c3_w siz = strlen(b64_c) + 120; + u3_noun arc = u3ke_cue(u3m_file(pax_c)); + u3_noun b64 = u3do("crip", u3do("en-base64:mimes:html", arc)); + c3_c * b64_c = u3r_string(b64); - c3_c bod_c[siz]; - snprintf(bod_c, siz, + c3_w siz_w = strlen(b64_c) + 120; + c3_c * bod_c = (c3_c *) c3_malloc(siz_w); + snprintf(bod_c, siz_w, "{\"source\": {\"import-all\": {\"base64-jam\": \"%s\"}}, \ \"sink\": {\"stdout\": null}}", b64_c); - u3_noun dat = u3nt(u3_nul, u3i_word(strlen(bod_c)), u3i_string(bod_c)); + u3_noun dat = u3nt(u3_nul, u3i_word(strlen(bod_c)), u3i_string(bod_c)); u3_noun req = u3nt(c3n, u3nc(u3i_string("ipv4"), u3i_word(0x7f000001)), u3nq(u3i_string("POST"), u3i_string("/"), u3_nul, dat)); @@ -92,7 +104,11 @@ _fore_import(u3_auto* car_u, c3_c* pax_c) u3_noun cad = u3nc(u3i_string("request-local"), req); u3_auto_peer( u3_auto_plan(car_u, u3_ovum_init(0, c3__e, wir, cad)), - 0, 0, _fore_inject_bail); + 0, 0, _fore_import_bail); + + u3z(b64); + c3_free(b64_c); + c3_free(bod_c); } /* _fore_io_talk(): From ffaba0be4570d0757ef0e02d9ee1f24961f79a86 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Thu, 19 Nov 2020 12:17:55 +1000 Subject: [PATCH 630/933] hark: update graph marks for editable comments --- pkg/arvo/mar/graph/validator/link.hoon | 2 +- pkg/arvo/mar/graph/validator/publish.hoon | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/mar/graph/validator/link.hoon b/pkg/arvo/mar/graph/validator/link.hoon index 482060d9ae..a860b20155 100644 --- a/pkg/arvo/mar/graph/validator/link.hoon +++ b/pkg/arvo/mar/graph/validator/link.hoon @@ -6,7 +6,7 @@ ++ notification-kind ?+ index.p.i ~ [@ ~] `[%link 0] - [@ @ ~] `[%comment 1] + [@ @ @ ~] `[%comment 1] == -- ++ grab diff --git a/pkg/arvo/mar/graph/validator/publish.hoon b/pkg/arvo/mar/graph/validator/publish.hoon index f39ce990ba..cddf69073e 100644 --- a/pkg/arvo/mar/graph/validator/publish.hoon +++ b/pkg/arvo/mar/graph/validator/publish.hoon @@ -9,7 +9,7 @@ ++ notification-kind ?+ index.p.i ~ [@ %1 @ ~] `[%note 0] - [@ %2 @ ~] `[%comment 1] + [@ %2 @ @ ~] `[%comment 1] == -- ++ grab From 7fa2376aa58a77e7d3040b62c194dd1ab01b5e23 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Thu, 19 Nov 2020 12:21:44 +1000 Subject: [PATCH 631/933] hark-fe: fix crash --- .../src/views/apps/notifications/graph.tsx | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/pkg/interface/src/views/apps/notifications/graph.tsx b/pkg/interface/src/views/apps/notifications/graph.tsx index fc2ae4efa1..80f846de81 100644 --- a/pkg/interface/src/views/apps/notifications/graph.tsx +++ b/pkg/interface/src/views/apps/notifications/graph.tsx @@ -19,6 +19,7 @@ import GlobalApi from "~/logic/api/global"; import ReactMarkdown from "react-markdown"; import { getSnippet } from "~/logic/lib/publish"; import styled from "styled-components"; +import {MentionText} from "~/views/components/MentionText"; function getGraphModuleIcon(module: string) { if (module === "link") { @@ -59,24 +60,28 @@ const GraphUrl = ({ url, title }) => ( ); -const GraphNodeContent = ({ contents, mod, description, index, remoteContentPolicy }) => { +const GraphNodeContent = ({ contents, contacts, mod, description, index, remoteContentPolicy }) => { const idx = index.slice(1).split("/"); if (mod === "link") { if (idx.length === 1) { const [{ text }, { url }] = contents; return ; } else if (idx.length === 2) { - const [{ text }] = contents; - return {text}; + return } return null; } if (mod === "publish") { - if (idx.length !== 3) { - return null; - } else if (idx[1] === "2") { - const [{ text }] = contents; - return {text}; + if (idx[1] === "2") { + return } else if (idx[1] === "1") { const [{ text: header }, { text: body }] = contents; const snippet = getSnippet(body); @@ -116,6 +121,7 @@ function getNodeUrl(mod: string, group: string, graph: string, index: string) { } const GraphNode = ({ contents, + contacts, author, mod, description, @@ -138,7 +144,9 @@ const GraphNode = ({ color={`#000000`} classes="mix-blend-diff" /> - ); + ); + + const groupContacts = contacts[group]; const nodeUrl = getNodeUrl(mod, group, graph, index); @@ -169,6 +177,7 @@ const GraphNode = ({ Date: Thu, 19 Nov 2020 12:51:52 +1000 Subject: [PATCH 632/933] glob: update to 0v4.3fbh4.p7j6i.2pi9g.d1ltq.5u7uu --- pkg/arvo/app/glob.hoon | 2 +- pkg/arvo/app/landscape/index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/app/glob.hoon b/pkg/arvo/app/glob.hoon index bd7232057c..8a04497c35 100644 --- a/pkg/arvo/app/glob.hoon +++ b/pkg/arvo/app/glob.hoon @@ -5,7 +5,7 @@ /- glob /+ default-agent, verb, dbug |% -++ hash 0v5.67obv.15auf.c2rc7.jpcu2.iain3 +++ hash 0v4.3fbh4.p7j6i.2pi9g.d1ltq.5u7uu +$ state-0 [%0 hash=@uv glob=(unit (each glob:glob tid=@ta))] +$ all-states $% state-0 diff --git a/pkg/arvo/app/landscape/index.html b/pkg/arvo/app/landscape/index.html index 52d79814ff..ffc4cce279 100644 --- a/pkg/arvo/app/landscape/index.html +++ b/pkg/arvo/app/landscape/index.html @@ -24,6 +24,6 @@
- + From a56565b07f483b2131b583ff8aa07b1ab48ef896 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Thu, 19 Nov 2020 12:57:03 +1000 Subject: [PATCH 633/933] inbox: fix link routing and rendering --- pkg/interface/src/views/apps/notifications/graph.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/interface/src/views/apps/notifications/graph.tsx b/pkg/interface/src/views/apps/notifications/graph.tsx index 80f846de81..971bc4c783 100644 --- a/pkg/interface/src/views/apps/notifications/graph.tsx +++ b/pkg/interface/src/views/apps/notifications/graph.tsx @@ -66,7 +66,7 @@ const GraphNodeContent = ({ contents, contacts, mod, description, index, remoteC if (idx.length === 1) { const [{ text }, { url }] = contents; return ; - } else if (idx.length === 2) { + } else if (idx.length === 3) { return Date: Thu, 19 Nov 2020 13:30:25 +1000 Subject: [PATCH 634/933] inbox: fix graph resource redirects --- pkg/interface/src/views/apps/graph/app.js | 16 +++++++------- .../src/views/apps/notifications/inbox.tsx | 21 +++++++++---------- .../src/views/landscape/components/Content.js | 2 ++ 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/pkg/interface/src/views/apps/graph/app.js b/pkg/interface/src/views/apps/graph/app.js index bfe47dc91a..9e11127134 100644 --- a/pkg/interface/src/views/apps/graph/app.js +++ b/pkg/interface/src/views/apps/graph/app.js @@ -25,6 +25,10 @@ export default class GraphApp extends PureComponent { render={ (props) => { const resource = `${deSig(props.match.params.ship)}/${props.match.params.name}`; + const { ship, name } = props.match.params; + const path = `/ship/~${deSig(ship)}/${name}`; + const association = associations.graph[path]; + const autoJoin = () => { try { @@ -33,13 +37,7 @@ export default class GraphApp extends PureComponent { props.match.params.name ); - if (props.match.params.module) { - props.history.push( - `/~${props.match.params.module}/${resource}` - ); - } else { - props.history.push('/'); - } + } catch(err) { setTimeout(autoJoin, 2000); } @@ -47,8 +45,8 @@ export default class GraphApp extends PureComponent { if(!graphKeys.has(resource)) { autoJoin(); - } else if(props.match.params.module) { - props.history.push(`/~${props.match.params.module}/${resource}`); + } else if(!!association) { + props.history.push(`/~landscape/home/resource/${association.metadata.module}${path}`); } return (
diff --git a/pkg/interface/src/views/apps/notifications/inbox.tsx b/pkg/interface/src/views/apps/notifications/inbox.tsx index c80384c5c5..9f06402cae 100644 --- a/pkg/interface/src/views/apps/notifications/inbox.tsx +++ b/pkg/interface/src/views/apps/notifications/inbox.tsx @@ -94,20 +94,19 @@ export default function Inbox(props: { name: invite.resource.name }; - let resourcePath = resourceAsPath(invite.resource); - if(app === 'chat') { - resourcePath = resourcePath.slice(5); - } - - let path = `/home/resource/${app}${resourcePath}`; + const resourcePath = resourceAsPath(invite.resource); if(app === 'contacts') { await api.contacts.join(resource); - path = resourceAsPath(invite.resource); - await waiter(p => path in p.associations?.contacts); + await waiter(p => resourcePath in p.associations?.contacts); + await api.invite.accept(app, uid); + history.push(`/~landscape${resourcePath}`); + } else if ( app === 'chat') { + await api.invite.accept(app, uid); + history.push(`/~landscape/home/resource/chat${resourcePath.slice(5)}`); + } else if ( app === 'graph') { + await api.invite.accept(app, uid); + history.push(`/~graph/join${resourcePath}`); } - await api.invite.accept(app, uid); - - history.push(`/~landscape${path}`); }; const inviteItems = (invites, api) => { diff --git a/pkg/interface/src/views/landscape/components/Content.js b/pkg/interface/src/views/landscape/components/Content.js index 41bf906179..d7fa95561b 100644 --- a/pkg/interface/src/views/landscape/components/Content.js +++ b/pkg/interface/src/views/landscape/components/Content.js @@ -9,6 +9,7 @@ import Landscape from '~/views/landscape/index'; import Profile from '~/views/apps/profile/profile'; import ErrorComponent from '~/views/components/Error'; import Notifications from '~/views/apps/notifications/notifications'; +import GraphApp from '../../apps/graph/app'; export const Container = styled(Box)` @@ -68,6 +69,7 @@ export const Content = (props) => { )} /> + ( Date: Thu, 19 Nov 2020 13:40:32 +1000 Subject: [PATCH 635/933] glob: update to 0v1.pak02.pfla3.gh56f.qhc6h.3h881 --- bin/solid.pill | 4 ++-- pkg/arvo/app/glob.hoon | 2 +- pkg/arvo/app/landscape/index.html | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index b09c3ae96a..9cb5faba1a 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:76de5b7d0a764af59018acdb78b5bbfb47f93bc166b0179d12501cdc84070f80 -size 6316045 +oid sha256:62fd8135114de8e5e6b00db62688029265593d646f4b03d12db8771fd9fc574a +size 6316013 diff --git a/pkg/arvo/app/glob.hoon b/pkg/arvo/app/glob.hoon index 8a04497c35..894b655234 100644 --- a/pkg/arvo/app/glob.hoon +++ b/pkg/arvo/app/glob.hoon @@ -5,7 +5,7 @@ /- glob /+ default-agent, verb, dbug |% -++ hash 0v4.3fbh4.p7j6i.2pi9g.d1ltq.5u7uu +++ hash 0v1.pak02.pfla3.gh56f.qhc6h.3h881 +$ state-0 [%0 hash=@uv glob=(unit (each glob:glob tid=@ta))] +$ all-states $% state-0 diff --git a/pkg/arvo/app/landscape/index.html b/pkg/arvo/app/landscape/index.html index ffc4cce279..fc92cf2405 100644 --- a/pkg/arvo/app/landscape/index.html +++ b/pkg/arvo/app/landscape/index.html @@ -24,6 +24,6 @@
- + From 99fb6bb4e857f4bb9c802bb41928854b8d3ad484 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Wed, 18 Nov 2020 20:12:29 -0800 Subject: [PATCH 636/933] gall: add nonce to agent wires Give each agent a nonce so that when you delete an agent, any outstanding responses don't go to a later app of the same name. --- bin/solid.pill | 4 ++-- pkg/arvo/gen/hood/doze.hoon | 4 ++++ pkg/arvo/gen/hood/fade.hoon | 2 +- pkg/arvo/sys/vane/gall.hoon | 31 +++++++++++++++++++------------ 4 files changed, 26 insertions(+), 15 deletions(-) create mode 100644 pkg/arvo/gen/hood/doze.hoon diff --git a/bin/solid.pill b/bin/solid.pill index c0a09d745e..43e69bf942 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5abdec8bcb76937c12e784a67d596ecfe58ecad0d04b466ebd3eeb6caa41aa79 -size 6513179 +oid sha256:3df27a5311fa269bb605deeaa5e85f0b347bea3d54ba5b4d08cba47e7ff32b3b +size 6519283 diff --git a/pkg/arvo/gen/hood/doze.hoon b/pkg/arvo/gen/hood/doze.hoon new file mode 100644 index 0000000000..f70496b280 --- /dev/null +++ b/pkg/arvo/gen/hood/doze.hoon @@ -0,0 +1,4 @@ +:- %say +|= [^ [dap=term wake=$@(~ [%wake ~])] ~] +=/ mode ?@(wake %doze %wake) +[%helm-pass %g %fade dap mode] diff --git a/pkg/arvo/gen/hood/fade.hoon b/pkg/arvo/gen/hood/fade.hoon index e794f805c8..11a7a5821b 100644 --- a/pkg/arvo/gen/hood/fade.hoon +++ b/pkg/arvo/gen/hood/fade.hoon @@ -1,6 +1,6 @@ :: Drum: destroy app :: -:::: /hoon/start/hood/gen +:::: /hoon/fade/hood/gen :: /? 310 :: diff --git a/pkg/arvo/sys/vane/gall.hoon b/pkg/arvo/sys/vane/gall.hoon index c04462b7bc..f39eab2680 100644 --- a/pkg/arvo/sys/vane/gall.hoon +++ b/pkg/arvo/sys/vane/gall.hoon @@ -53,6 +53,7 @@ :: +$ yoke $: control-duct=duct + nonce=@t live=? =stats =watches @@ -123,6 +124,7 @@ :: +$ egg $: control-duct=duct + nonce=@t live=? =stats =watches @@ -273,7 +275,9 @@ outstanding ~ :: TODO: do we need to process these somehow? running :: XXX &+ should be in next state adapter - (~(run by running.s) |=(y=yoke-0 +:y(agent &+on-save:agent.y))) + %- ~(run by running.s) + |= y=yoke-0 + [+< %nonce +>]:y(agent &+on-save:agent.y) == :: ++ state-4-to-5 |=(s=state-4 `state-5`s(- %5, outstanding ~)) @@ -427,8 +431,12 @@ :: =. yokes.state %+ ~(put by yokes.state) dap - =/ default-yoke *yoke - default-yoke(control-duct hen, beak bek, agent &+agent) + %* . *yoke + control-duct hen + beak bek + agent &+agent + nonce (scot %uw (end 5 1 (shas %yoke-nonce eny))) + == :: =/ old mo-core =/ wag @@ -791,7 +799,7 @@ |= [=path =sign-arvo] ^+ mo-core :: - ?. ?=([@ @ *] path) + ?. ?=([@ @ @ *] path) ~& [%mo-handle-use-bad-path path] !! :: @@ -800,16 +808,19 @@ ?~ yoke %- (slog leaf+"gall: {} dead, got {<+<.sign-arvo>}" ~) mo-core + ?. =(nonce.u.yoke i.t.path) + %- (slog leaf+"gall: got old {<+<.sign-arvo>} for {}" ~) + mo-core ?. ?=([?(%g %b) %unto *] sign-arvo) ?: ?=(%| -.agent.u.yoke) %- (slog leaf+"gall: {} dozing, dropping {<+<.sign-arvo>}" ~) mo-core =/ app - =/ =ship (slav %p i.t.path) + =/ =ship (slav %p i.t.t.path) =/ =routes [disclosing=~ attributing=ship] (ap-abed:ap dap routes) :: - =. app (ap-generic-take:app t.t.path sign-arvo) + =. app (ap-generic-take:app t.t.t.path sign-arvo) ap-abet:app ?> ?=([%out @ @ *] t.t.path) =/ =ship (slav %p i.t.t.t.path) @@ -1212,13 +1223,9 @@ =/ =neat q.card =. wire ?: ?=(%agent -.neat) - :: remove `our` in next breach after 2019/12 and reflect in - :: +mo-handle-use (non-unto case) - :: - :- (scot %p our) [%out (scot %p ship.neat) name.neat wire] [(scot %p attributing.agent-routes) wire] - =. wire [%use agent-name wire] + =. wire [%use agent-name nonce.current-agent wire] =/ =note-arvo ?- -.neat %arvo note-arvo.neat @@ -1841,7 +1848,7 @@ ^- spore =; eggs=(map term egg) [- | +]:state(yokes eggs) %- ~(run by yokes.state) - |= =yoke + |= =yoke ^- egg %= yoke agent From 17c16d5887ccda2f2a80fb250b86cf70253db289 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Wed, 18 Nov 2020 20:39:58 -0800 Subject: [PATCH 637/933] gall: refresh clay subscription on fade --- pkg/arvo/lib/hood/helm.hoon | 3 +-- pkg/arvo/sys/vane/gall.hoon | 13 ++++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/arvo/lib/hood/helm.hoon b/pkg/arvo/lib/hood/helm.hoon index f47bd9ddee..31dd63a662 100644 --- a/pkg/arvo/lib/hood/helm.hoon +++ b/pkg/arvo/lib/hood/helm.hoon @@ -281,7 +281,6 @@ ?>(?=(%wake +<.sign-arvo) +>.sign-arvo) [%serv *] %+ take-bound t.wire ?>(?=(%bound +<.sign-arvo) +>.sign-arvo) - [%pass *] ~& [%pass-response [- +<]:sign-arvo] - abet + [%pass *] abet == -- diff --git a/pkg/arvo/sys/vane/gall.hoon b/pkg/arvo/sys/vane/gall.hoon index f39eab2680..4a2cee2fa4 100644 --- a/pkg/arvo/sys/vane/gall.hoon +++ b/pkg/arvo/sys/vane/gall.hoon @@ -896,11 +896,14 @@ =/ =routes [disclosing=~ attributing=our] =/ app (ap-abed:ap dap routes) =. mo-core ap-abet:(ap-fade:app style) - ?- style - %gone mo-core(yokes.state (~(del by yokes.state) dap)) - %doze mo-core - %wake (mo-boot dap our %home) - == + =. mo-core + ?- style + %gone mo-core(yokes.state (~(del by yokes.state) dap)) + %doze mo-core + %wake (mo-boot dap our %home) + == + =? mo-core !?=(%wake style) (mo-subscribe-to-agent-builds now) + mo-core :: +mo-beak: assemble a beak for the specified agent. :: ++ mo-beak From 1b45848d1d1b925ab8efb52f82224524af94cca9 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Thu, 19 Nov 2020 14:56:20 +1000 Subject: [PATCH 638/933] notifications: fix scroll to load --- pkg/interface/src/views/apps/notifications/inbox.tsx | 7 ++++--- .../src/views/apps/notifications/notifications.tsx | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/interface/src/views/apps/notifications/inbox.tsx b/pkg/interface/src/views/apps/notifications/inbox.tsx index 9f06402cae..cff3acff35 100644 --- a/pkg/interface/src/views/apps/notifications/inbox.tsx +++ b/pkg/interface/src/views/apps/notifications/inbox.tsx @@ -83,7 +83,7 @@ export default function Inbox(props: { const onScroll = useCallback((e) => { let container = e.target; const { scrollHeight, scrollTop, clientHeight } = container; - if((scrollHeight - scrollTop - clientHeight) < 20) { + if((scrollHeight - scrollTop) < 1.5 * clientHeight) { api.hark.getMore(props.showArchive); } }, [props.showArchive]); @@ -129,7 +129,7 @@ export default function Inbox(props: { }; return ( - + {inviteItems(invites, api)} {newNotifications && ( nots.length).reduce(f.add, 0); + if (lent === 0 || timeboxes.length === 0) { return null; } diff --git a/pkg/interface/src/views/apps/notifications/notifications.tsx b/pkg/interface/src/views/apps/notifications/notifications.tsx index 0c7302c3a0..e76b927947 100644 --- a/pkg/interface/src/views/apps/notifications/notifications.tsx +++ b/pkg/interface/src/views/apps/notifications/notifications.tsx @@ -53,7 +53,7 @@ export default function NotificationsScreen(props: any) { const { view } = routeProps.match.params; return ( - + Date: Thu, 19 Nov 2020 15:03:28 +1000 Subject: [PATCH 639/933] launch: loosen property access in unread count --- pkg/interface/src/views/apps/launch/components/Groups.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/interface/src/views/apps/launch/components/Groups.tsx b/pkg/interface/src/views/apps/launch/components/Groups.tsx index 91b74830c1..98692be606 100644 --- a/pkg/interface/src/views/apps/launch/components/Groups.tsx +++ b/pkg/interface/src/views/apps/launch/components/Groups.tsx @@ -19,7 +19,7 @@ const getKindUnreads = (associations: Associations) => (path: string) => ( ): ((unreads: Unreads) => number) => f.flow( (x) => x[kind], - f.pickBy((_v, key) => associations[kind]?.[key]["group-path"] === path), + f.pickBy((_v, key) => associations[kind]?.[key]?.["group-path"] === path), f.values, f.reduce(f.add, 0) ); @@ -28,14 +28,14 @@ export default function Groups(props: GroupsProps & Parameters[0]) { const { associations, unreads, ...boxProps } = props; const groups = Object.values(associations?.contacts || {}) - .filter((e) => e["group-path"] in props.groups) + .filter((e) => e?.["group-path"] in props.groups) .sort(sortGroupsAlph); const getUnreads = getKindUnreads(associations || {}); return ( <> {groups.map((group) => { - const path = group["group-path"]; + const path = group?.["group-path"]; const unreadCount = (["chat", "graph"] as const) .map(getUnreads(path)) .map((f) => f(unreads)) @@ -43,7 +43,7 @@ export default function Groups(props: GroupsProps & Parameters[0]) { return ( ); From 2f456206c9866dd7cf529524565246e29fc65da1 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Thu, 19 Nov 2020 15:04:44 +1000 Subject: [PATCH 640/933] Sidebar: loosen property access --- .../src/views/landscape/components/Sidebar/SidebarList.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/interface/src/views/landscape/components/Sidebar/SidebarList.tsx b/pkg/interface/src/views/landscape/components/Sidebar/SidebarList.tsx index fa0a8100c9..110b6fd5f3 100644 --- a/pkg/interface/src/views/landscape/components/Sidebar/SidebarList.tsx +++ b/pkg/interface/src/views/landscape/components/Sidebar/SidebarList.tsx @@ -23,8 +23,8 @@ function sidebarSort( const aAppName = aAssoc?.["app-name"]; const bAppName = bAssoc?.["app-name"]; - const aUpdated = apps[aAppName].lastUpdated(a); - const bUpdated = apps[bAppName].lastUpdated(b); + const aUpdated = apps[aAppName]?.lastUpdated(a) || 0; + const bUpdated = apps[bAppName]?.lastUpdated(b) || 0; return bUpdated - aUpdated || alphabetical(a, b); }; From 217da2acf4e3e2ffeefb64dd015e8e6944a0c25f Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Thu, 19 Nov 2020 15:20:35 +1000 Subject: [PATCH 641/933] glob: update to 0v5.91i1u.1g535.t3de3.6c3ih.fanmv --- bin/solid.pill | 4 ++-- pkg/arvo/app/glob.hoon | 2 +- pkg/arvo/app/landscape/index.html | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index 9cb5faba1a..fb21f40388 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:62fd8135114de8e5e6b00db62688029265593d646f4b03d12db8771fd9fc574a -size 6316013 +oid sha256:685c6c22dd9b1165ba89d1a9b1bb4ded3727bdecc3ad5244c3f4888ff71f3477 +size 6316026 diff --git a/pkg/arvo/app/glob.hoon b/pkg/arvo/app/glob.hoon index 894b655234..5302e56b7d 100644 --- a/pkg/arvo/app/glob.hoon +++ b/pkg/arvo/app/glob.hoon @@ -5,7 +5,7 @@ /- glob /+ default-agent, verb, dbug |% -++ hash 0v1.pak02.pfla3.gh56f.qhc6h.3h881 +++ hash 0v5.91i1u.1g535.t3de3.6c3ih.fanmv +$ state-0 [%0 hash=@uv glob=(unit (each glob:glob tid=@ta))] +$ all-states $% state-0 diff --git a/pkg/arvo/app/landscape/index.html b/pkg/arvo/app/landscape/index.html index fc92cf2405..a493e415f7 100644 --- a/pkg/arvo/app/landscape/index.html +++ b/pkg/arvo/app/landscape/index.html @@ -24,6 +24,6 @@
- + From 65578165b4c495bc4893e2085c258a515434d227 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Thu, 19 Nov 2020 16:37:19 +1000 Subject: [PATCH 642/933] notifications: prevent safari shrinkage --- pkg/interface/src/views/apps/notifications/notification.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/interface/src/views/apps/notifications/notification.tsx b/pkg/interface/src/views/apps/notifications/notification.tsx index 4ca022e18c..bbc460eec4 100644 --- a/pkg/interface/src/views/apps/notifications/notification.tsx +++ b/pkg/interface/src/views/apps/notifications/notification.tsx @@ -92,7 +92,7 @@ function NotificationWrapper(props: { const changeMuteDesc = isMuted ? "Unmute" : "Mute"; return ( - + {children} From a9d6811299fc520e4f46f4abdc626de536261a75 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Thu, 19 Nov 2020 16:44:33 +1000 Subject: [PATCH 643/933] glob: update to 0v4.fpa4r.s6dtc.h8tps.62jv0.qn0fj --- bin/solid.pill | 4 ++-- pkg/arvo/app/glob.hoon | 2 +- pkg/arvo/app/landscape/index.html | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index fb21f40388..77837f3f4b 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:685c6c22dd9b1165ba89d1a9b1bb4ded3727bdecc3ad5244c3f4888ff71f3477 -size 6316026 +oid sha256:f639b862842609c64aa387f8414f9f8bcf1db5d89ae3e54e64aa1b040f21f7e0 +size 6315993 diff --git a/pkg/arvo/app/glob.hoon b/pkg/arvo/app/glob.hoon index 5302e56b7d..472f938331 100644 --- a/pkg/arvo/app/glob.hoon +++ b/pkg/arvo/app/glob.hoon @@ -5,7 +5,7 @@ /- glob /+ default-agent, verb, dbug |% -++ hash 0v5.91i1u.1g535.t3de3.6c3ih.fanmv +++ hash 0v4.fpa4r.s6dtc.h8tps.62jv0.qn0fj +$ state-0 [%0 hash=@uv glob=(unit (each glob:glob tid=@ta))] +$ all-states $% state-0 diff --git a/pkg/arvo/app/landscape/index.html b/pkg/arvo/app/landscape/index.html index a493e415f7..a2a06dea17 100644 --- a/pkg/arvo/app/landscape/index.html +++ b/pkg/arvo/app/landscape/index.html @@ -24,6 +24,6 @@
- + From 1761f4efa3406d59c4f9265b3367a15273f8476d Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 19 Nov 2020 14:15:06 -0800 Subject: [PATCH 644/933] pill: solid --- bin/solid.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index e662f47214..bbbae340e7 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:680ebc2bb2fd224541b5aa6dbfda5a981df59089172410ddabc6b3f4b93d54c4 -size 6327612 +oid sha256:d8ac4b3bf78d7c8ef62f668bfe14b243cffe5784a97c87486e1ae31c4b58e1f6 +size 6312584 From 1833006b11d74552e45452789f0beb7a3fddcccb Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Thu, 19 Nov 2020 17:59:16 -0500 Subject: [PATCH 645/933] webterm: migrate to indigo-react --- pkg/interface/src/views/apps/term/app.js | 44 ++++++++++--------- .../src/views/apps/term/components/history.js | 17 ++++--- .../src/views/apps/term/components/input.js | 10 +++-- .../src/views/apps/term/components/line.js | 6 +-- .../src/views/apps/term/css/custom.css | 7 --- 5 files changed, 44 insertions(+), 40 deletions(-) diff --git a/pkg/interface/src/views/apps/term/app.js b/pkg/interface/src/views/apps/term/app.js index dcd374060e..42cc5a61cc 100644 --- a/pkg/interface/src/views/apps/term/app.js +++ b/pkg/interface/src/views/apps/term/app.js @@ -5,6 +5,8 @@ import Helmet from 'react-helmet'; import { History } from './components/history'; import { Input } from './components/input'; +import { Box, Col } from '@tlon/indigo-react'; + import Api from './api'; import Store from './store'; import Subscription from './subscription'; @@ -47,30 +49,30 @@ export default class TermApp extends Component { OS1 - Terminal -
{ return ( -
-
-
-
+ -
-
+ + ); }} /> -
+ ); } diff --git a/pkg/interface/src/views/apps/term/components/history.js b/pkg/interface/src/views/apps/term/components/history.js index 8638a018da..93eb0a0110 100644 --- a/pkg/interface/src/views/apps/term/components/history.js +++ b/pkg/interface/src/views/apps/term/components/history.js @@ -1,4 +1,5 @@ import React, { Component } from 'react'; +import { Box } from '@tlon/indigo-react'; import Line from './line'; @@ -9,16 +10,22 @@ export class History extends Component { render() { return ( -
-
+ {this.props.log.map((line, i) => { return ; })} -
-
+ + ); } } diff --git a/pkg/interface/src/views/apps/term/components/input.js b/pkg/interface/src/views/apps/term/components/input.js index a2f98b694f..695c4a80f1 100644 --- a/pkg/interface/src/views/apps/term/components/input.js +++ b/pkg/interface/src/views/apps/term/components/input.js @@ -1,7 +1,5 @@ import React, { Component } from 'react'; import { Row, Box, BaseInput } from '@tlon/indigo-react'; -import { cite } from '~/logic/lib/util'; -import { Spinner } from '~/views/components/Spinner'; export class Input extends Component { constructor(props) { @@ -85,15 +83,19 @@ export class Input extends Component { } return ( - + { @@ -59,7 +59,7 @@ export default React.memo(({line}) => { // render line // return ( - {text} diff --git a/pkg/interface/src/views/apps/term/css/custom.css b/pkg/interface/src/views/apps/term/css/custom.css index ab4f226b5d..b25bcdbd9f 100644 --- a/pkg/interface/src/views/apps/term/css/custom.css +++ b/pkg/interface/src/views/apps/term/css/custom.css @@ -14,10 +14,3 @@ input#term { 90% { opacity: 0; } 100% { opacity: 0; } } - -/* responsive */ -@media all and (max-width: 34.375em) { - .h-100-m40-s { - height: calc(100% - 40px); - } -} From 68f1b92f9e132cda7fb058b4a50f0c7c033bcaea Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 19 Nov 2020 16:00:52 -0800 Subject: [PATCH 646/933] pill: solid --- bin/solid.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index bbbae340e7..d9f17a0071 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d8ac4b3bf78d7c8ef62f668bfe14b243cffe5784a97c87486e1ae31c4b58e1f6 -size 6312584 +oid sha256:b4c57e17b805a20778646e1b3e9efb84d3dbfd12089fe1834e9e15f1f9c52389 +size 6419639 From 3d2b24e85e8a15939a949d98c49b815e7bb90136 Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Fri, 20 Nov 2020 07:47:04 +0100 Subject: [PATCH 647/933] build: update gcloud to use non-deprecated action --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bad482dd78..28d4b19b3d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -100,7 +100,7 @@ jobs: name: mars authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} - - uses: GoogleCloudPlatform/github-actions/setup-gcloud@0.2.0 + - uses: google-github-actions/setup-gcloud@v0.2.0 with: version: '290.0.1' service_account_key: ${{ secrets.GCS_SERVICE_ACCOUNT_KEY }} From 20dfb3681580d60bb2ffd7ebe7e4a2be797c20e7 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 19 Nov 2020 15:42:37 -0800 Subject: [PATCH 648/933] u3: adds |ut battery to jet cache keys --- pkg/urbit/include/noun/zave.h | 1 + pkg/urbit/jets/f/ut_crop.c | 12 +++++++----- pkg/urbit/jets/f/ut_fish.c | 14 ++++++++------ pkg/urbit/jets/f/ut_fuse.c | 12 +++++++----- pkg/urbit/jets/f/ut_mint.c | 14 +++++++------- pkg/urbit/jets/f/ut_mull.c | 19 ++++++++++--------- pkg/urbit/jets/f/ut_nest.c | 26 +++++++++++++------------- pkg/urbit/jets/f/ut_rest.c | 12 +++++++----- pkg/urbit/noun/zave.c | 5 +++++ 9 files changed, 65 insertions(+), 50 deletions(-) diff --git a/pkg/urbit/include/noun/zave.h b/pkg/urbit/include/noun/zave.h index ca3401065f..dd48befba4 100644 --- a/pkg/urbit/include/noun/zave.h +++ b/pkg/urbit/include/noun/zave.h @@ -18,6 +18,7 @@ u3_noun u3z_key_2(c3_m, u3_noun, u3_noun); u3_noun u3z_key_3(c3_m, u3_noun, u3_noun, u3_noun); u3_noun u3z_key_4(c3_m, u3_noun, u3_noun, u3_noun, u3_noun); + u3_noun u3z_key_5(c3_m, u3_noun, u3_noun, u3_noun, u3_noun, u3_noun); /* u3z_find*(): find in memo cache. Arguments retained */ diff --git a/pkg/urbit/jets/f/ut_crop.c b/pkg/urbit/jets/f/ut_crop.c index d7a3b6ca20..630a3a7816 100644 --- a/pkg/urbit/jets/f/ut_crop.c +++ b/pkg/urbit/jets/f/ut_crop.c @@ -6,16 +6,18 @@ u3_noun u3wfu_crop(u3_noun cor) { - u3_noun sut, ref, van; + u3_noun bat, sut, ref, van; - if ( (c3n == u3r_mean(cor, u3x_sam, &ref, u3x_con, &van, 0)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) + if ( (c3n == u3r_mean(cor, u3x_sam, &ref, u3x_con, &van, 0)) + || (u3_none == (bat = u3r_at(u3x_bat, van))) + || (u3_none == (sut = u3r_at(u3x_sam, van))) ) { return u3m_bail(c3__fail); } else { - c3_m fun_m = 141 + c3__crop + ((!!u3r_at(u3qfu_van_vet, van)) << 8); - u3_noun key = u3z_key_2(fun_m, sut, ref); + u3_weak vet = u3r_at(u3qfu_van_vet, van); + c3_m fun_m = 141 + c3__crop + ((!!vet) << 8); + u3_noun key = u3z_key_3(fun_m, bat, sut, ref); u3_weak pro = u3z_find(key); if ( u3_none != pro ) { diff --git a/pkg/urbit/jets/f/ut_fish.c b/pkg/urbit/jets/f/ut_fish.c index 3da56fa2f5..ebebe0a17c 100644 --- a/pkg/urbit/jets/f/ut_fish.c +++ b/pkg/urbit/jets/f/ut_fish.c @@ -6,17 +6,19 @@ u3_noun u3wfu_fish(u3_noun cor) { - u3_noun sut, axe, van; + u3_noun bat, sut, axe, van; - if ( (c3n == u3r_mean(cor, u3x_sam, &axe, u3x_con, &van, 0)) || - (c3n == u3ud(axe)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) + if ( (c3n == u3r_mean(cor, u3x_sam, &axe, u3x_con, &van, 0)) + || (c3n == u3ud(axe)) + || (u3_none == (bat = u3r_at(u3x_bat, van))) + || (u3_none == (sut = u3r_at(u3x_sam, van))) ) { return u3m_bail(c3__fail); } else { - c3_m fun_m = 141 + c3__fish + ((!!u3r_at(u3qfu_van_vet, van)) << 8); - u3_noun key = u3z_key_2(fun_m, sut, axe); + u3_weak vet = u3r_at(u3qfu_van_vet, van); + c3_m fun_m = 141 + c3__fish + ((!!vet) << 8); + u3_noun key = u3z_key_3(fun_m, bat, sut, axe); u3_weak pro = u3z_find(key); if ( u3_none != pro ) { diff --git a/pkg/urbit/jets/f/ut_fuse.c b/pkg/urbit/jets/f/ut_fuse.c index 36f720f9f4..9a9a3ffcb7 100644 --- a/pkg/urbit/jets/f/ut_fuse.c +++ b/pkg/urbit/jets/f/ut_fuse.c @@ -6,16 +6,18 @@ u3_noun u3wfu_fuse(u3_noun cor) { - u3_noun sut, ref, van; + u3_noun bat, sut, ref, van; - if ( (c3n == u3r_mean(cor, u3x_sam, &ref, u3x_con, &van, 0)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) + if ( (c3n == u3r_mean(cor, u3x_sam, &ref, u3x_con, &van, 0)) + || (u3_none == (bat = u3r_at(u3x_bat, van))) + || (u3_none == (sut = u3r_at(u3x_sam, van))) ) { return u3m_bail(c3__fail); } else { - c3_m fun_m = 141 + c3__fuse + ((!!u3r_at(u3qfu_van_vet, van)) << 8); - u3_noun key = u3z_key_2(fun_m, sut, ref); + u3_weak vet = u3r_at(u3qfu_van_vet, van); + c3_m fun_m = 141 + c3__fuse + ((!!vet) << 8); + u3_noun key = u3z_key_3(fun_m, bat, sut, ref); u3_weak pro = u3z_find(key); if ( u3_none != pro ) { diff --git a/pkg/urbit/jets/f/ut_mint.c b/pkg/urbit/jets/f/ut_mint.c index 05d35a084c..1ae4ce1e36 100644 --- a/pkg/urbit/jets/f/ut_mint.c +++ b/pkg/urbit/jets/f/ut_mint.c @@ -6,20 +6,20 @@ u3_noun u3wfu_mint(u3_noun cor) { - u3_noun sut, gol, gen, van; + u3_noun bat, sut, gol, gen, van; - if ( (c3n == u3r_mean(cor, u3x_sam_2, &gol, - u3x_sam_3, &gen, - u3x_con, &van, - 0)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) + if ( (c3n == u3r_mean(cor, u3x_sam_2, &gol, + u3x_sam_3, &gen, + u3x_con, &van, 0)) + || (u3_none == (bat = u3r_at(u3x_bat, van))) + || (u3_none == (sut = u3r_at(u3x_sam, van))) ) { return u3m_bail(c3__fail); } else { c3_m fun_m = 141 + c3__mint; u3_noun vrf = u3r_at(u3qfu_van_vrf, van); - u3_noun key = u3z_key_4(fun_m, vrf, sut, gol, gen); + u3_noun key = u3z_key_5(fun_m, bat, vrf, sut, gol, gen); u3_weak pro = u3z_find(key); if ( u3_none != pro ) { diff --git a/pkg/urbit/jets/f/ut_mull.c b/pkg/urbit/jets/f/ut_mull.c index aa03e72cfb..233574058e 100644 --- a/pkg/urbit/jets/f/ut_mull.c +++ b/pkg/urbit/jets/f/ut_mull.c @@ -6,20 +6,21 @@ u3_noun u3wfu_mull(u3_noun cor) { - u3_noun sut, gol, dox, gen, van; + u3_noun bat, sut, gol, dox, gen, van; - if ( (c3n == u3r_mean(cor, u3x_sam_2, &gol, - u3x_sam_6, &dox, - u3x_sam_7, &gen, - u3x_con, &van, - 0)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) + if ( (c3n == u3r_mean(cor, u3x_sam_2, &gol, + u3x_sam_6, &dox, + u3x_sam_7, &gen, + u3x_con, &van, 0)) + || (u3_none == (bat = u3r_at(u3x_bat, van))) + || (u3_none == (sut = u3r_at(u3x_sam, van))) ) { return u3m_bail(c3__fail); } else { - c3_m fun_m = 141 + c3__mull + ((!!u3r_at(u3qfu_van_vet, van)) << 8); - u3_noun key = u3z_key_4(fun_m, sut, gol, dox, gen); + u3_weak vet = u3r_at(u3qfu_van_vet, van); + c3_m fun_m = 141 + c3__mull + ((!!vet) << 8); + u3_noun key = u3z_key_5(fun_m, bat, sut, gol, dox, gen); u3_weak pro = u3z_find(key); if ( u3_none != pro ) { diff --git a/pkg/urbit/jets/f/ut_nest.c b/pkg/urbit/jets/f/ut_nest.c index 8a4fbe57d6..684f6b9731 100644 --- a/pkg/urbit/jets/f/ut_nest.c +++ b/pkg/urbit/jets/f/ut_nest.c @@ -7,24 +7,24 @@ u3_noun u3wfu_nest_dext(u3_noun dext_core) { u3_noun nest_in_core, nest_core; - u3_noun sut, ref, van, seg, reg, gil; + u3_noun bat, sut, ref, van, seg, reg, gil; - if ( (u3_none == (nest_in_core = u3r_at(3, dext_core))) || - (c3n == u3r_mean(nest_in_core, u3x_sam_2, &seg, - u3x_sam_6, ®, - u3x_sam_7, &gil, - 7, &nest_core, - 0)) || - (c3n == u3r_mean(nest_core, u3x_sam_3, &ref, - u3x_con, &van, - 0)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) + if ( (u3_none == (nest_in_core = u3r_at(3, dext_core))) + || (c3n == u3r_mean(nest_in_core, u3x_sam_2, &seg, + u3x_sam_6, ®, + u3x_sam_7, &gil, + u3x_con, &nest_core, 0)) + || (c3n == u3r_mean(nest_core, u3x_sam_3, &ref, + u3x_con, &van, 0)) + || (u3_none == (bat = u3r_at(u3x_bat, van))) + || (u3_none == (sut = u3r_at(u3x_sam, van))) ) { return u3m_bail(c3__fail); } else { - c3_m fun_m = 141 + c3__dext + ((!!u3r_at(u3qfu_van_vet, van)) << 8); - u3_noun key = u3z_key_2(fun_m, sut, ref); + u3_weak vet = u3r_at(u3qfu_van_vet, van); + c3_m fun_m = 141 + c3__dext + ((!!vet) << 8); + u3_noun key = u3z_key_3(fun_m, bat, sut, ref); u3_weak pro = u3z_find(key); if ( u3_none != pro ) { diff --git a/pkg/urbit/jets/f/ut_rest.c b/pkg/urbit/jets/f/ut_rest.c index 54ac351c31..b645bc61ac 100644 --- a/pkg/urbit/jets/f/ut_rest.c +++ b/pkg/urbit/jets/f/ut_rest.c @@ -6,16 +6,18 @@ u3_noun u3wfu_rest(u3_noun cor) { - u3_noun sut, leg, van; + u3_noun bat, sut, leg, van; - if ( (c3n == u3r_mean(cor, u3x_sam, &leg, u3x_con, &van, 0)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) + if ( (c3n == u3r_mean(cor, u3x_sam, &leg, u3x_con, &van, 0)) + || (u3_none == (bat = u3r_at(u3x_bat, van))) + || (u3_none == (sut = u3r_at(u3x_sam, van))) ) { return u3m_bail(c3__fail); } else { - c3_m fun_m = 141 + c3__rest + ((!!u3r_at(u3qfu_van_vet, van)) << 8); - u3_noun key = u3z_key_2(fun_m, sut, leg); + u3_weak vet = u3r_at(u3qfu_van_vet, van); + c3_m fun_m = 141 + c3__rest + ((!!vet) << 8); + u3_noun key = u3z_key_3(fun_m, bat, sut, leg); u3_weak pro = u3z_find(key); if ( u3_none != pro ) { diff --git a/pkg/urbit/noun/zave.c b/pkg/urbit/noun/zave.c index d0c5dbd082..ec42c89294 100644 --- a/pkg/urbit/noun/zave.c +++ b/pkg/urbit/noun/zave.c @@ -25,6 +25,11 @@ u3z_key_4(c3_m fun, u3_noun one, u3_noun two, u3_noun tri, u3_noun qua) { return u3nc(fun, u3nq(u3k(one), u3k(two), u3k(tri), u3k(qua))); } +u3_noun +u3z_key_5(c3_m fun, u3_noun one, u3_noun two, u3_noun tri, u3_noun qua, u3_noun qin) +{ + return u3nc(fun, u3nq(u3k(one), u3k(two), u3k(tri), u3nc(u3k(qua), u3k(qin)))); +} /* u3z_find(): find in memo cache. Arguments retained. */ From ab4fd4ba4b0706eb1a380b5780da65b94ecc7e05 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 19 Nov 2020 21:42:21 -0800 Subject: [PATCH 649/933] u3: moves |ut battery to the rightmost cache key position --- pkg/urbit/jets/f/ut_crop.c | 2 +- pkg/urbit/jets/f/ut_fish.c | 2 +- pkg/urbit/jets/f/ut_fuse.c | 2 +- pkg/urbit/jets/f/ut_mint.c | 2 +- pkg/urbit/jets/f/ut_mull.c | 2 +- pkg/urbit/jets/f/ut_nest.c | 2 +- pkg/urbit/jets/f/ut_rest.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/urbit/jets/f/ut_crop.c b/pkg/urbit/jets/f/ut_crop.c index 630a3a7816..68ea2beeab 100644 --- a/pkg/urbit/jets/f/ut_crop.c +++ b/pkg/urbit/jets/f/ut_crop.c @@ -17,7 +17,7 @@ u3wfu_crop(u3_noun cor) else { u3_weak vet = u3r_at(u3qfu_van_vet, van); c3_m fun_m = 141 + c3__crop + ((!!vet) << 8); - u3_noun key = u3z_key_3(fun_m, bat, sut, ref); + u3_noun key = u3z_key_3(fun_m, sut, ref, bat); u3_weak pro = u3z_find(key); if ( u3_none != pro ) { diff --git a/pkg/urbit/jets/f/ut_fish.c b/pkg/urbit/jets/f/ut_fish.c index ebebe0a17c..2feb98990e 100644 --- a/pkg/urbit/jets/f/ut_fish.c +++ b/pkg/urbit/jets/f/ut_fish.c @@ -18,7 +18,7 @@ u3wfu_fish(u3_noun cor) else { u3_weak vet = u3r_at(u3qfu_van_vet, van); c3_m fun_m = 141 + c3__fish + ((!!vet) << 8); - u3_noun key = u3z_key_3(fun_m, bat, sut, axe); + u3_noun key = u3z_key_3(fun_m, sut, axe, bat); u3_weak pro = u3z_find(key); if ( u3_none != pro ) { diff --git a/pkg/urbit/jets/f/ut_fuse.c b/pkg/urbit/jets/f/ut_fuse.c index 9a9a3ffcb7..06eaecb4b4 100644 --- a/pkg/urbit/jets/f/ut_fuse.c +++ b/pkg/urbit/jets/f/ut_fuse.c @@ -17,7 +17,7 @@ u3wfu_fuse(u3_noun cor) else { u3_weak vet = u3r_at(u3qfu_van_vet, van); c3_m fun_m = 141 + c3__fuse + ((!!vet) << 8); - u3_noun key = u3z_key_3(fun_m, bat, sut, ref); + u3_noun key = u3z_key_3(fun_m, sut, ref, bat); u3_weak pro = u3z_find(key); if ( u3_none != pro ) { diff --git a/pkg/urbit/jets/f/ut_mint.c b/pkg/urbit/jets/f/ut_mint.c index 1ae4ce1e36..005b3217c6 100644 --- a/pkg/urbit/jets/f/ut_mint.c +++ b/pkg/urbit/jets/f/ut_mint.c @@ -19,7 +19,7 @@ u3wfu_mint(u3_noun cor) else { c3_m fun_m = 141 + c3__mint; u3_noun vrf = u3r_at(u3qfu_van_vrf, van); - u3_noun key = u3z_key_5(fun_m, bat, vrf, sut, gol, gen); + u3_noun key = u3z_key_5(fun_m, vrf, sut, gol, gen, bat); u3_weak pro = u3z_find(key); if ( u3_none != pro ) { diff --git a/pkg/urbit/jets/f/ut_mull.c b/pkg/urbit/jets/f/ut_mull.c index 233574058e..c100b36587 100644 --- a/pkg/urbit/jets/f/ut_mull.c +++ b/pkg/urbit/jets/f/ut_mull.c @@ -20,7 +20,7 @@ u3wfu_mull(u3_noun cor) else { u3_weak vet = u3r_at(u3qfu_van_vet, van); c3_m fun_m = 141 + c3__mull + ((!!vet) << 8); - u3_noun key = u3z_key_5(fun_m, bat, sut, gol, dox, gen); + u3_noun key = u3z_key_5(fun_m, sut, gol, dox, gen, bat); u3_weak pro = u3z_find(key); if ( u3_none != pro ) { diff --git a/pkg/urbit/jets/f/ut_nest.c b/pkg/urbit/jets/f/ut_nest.c index 684f6b9731..27aa504f93 100644 --- a/pkg/urbit/jets/f/ut_nest.c +++ b/pkg/urbit/jets/f/ut_nest.c @@ -24,7 +24,7 @@ u3wfu_nest_dext(u3_noun dext_core) else { u3_weak vet = u3r_at(u3qfu_van_vet, van); c3_m fun_m = 141 + c3__dext + ((!!vet) << 8); - u3_noun key = u3z_key_3(fun_m, bat, sut, ref); + u3_noun key = u3z_key_3(fun_m, sut, ref, bat); u3_weak pro = u3z_find(key); if ( u3_none != pro ) { diff --git a/pkg/urbit/jets/f/ut_rest.c b/pkg/urbit/jets/f/ut_rest.c index b645bc61ac..c683a41559 100644 --- a/pkg/urbit/jets/f/ut_rest.c +++ b/pkg/urbit/jets/f/ut_rest.c @@ -17,7 +17,7 @@ u3wfu_rest(u3_noun cor) else { u3_weak vet = u3r_at(u3qfu_van_vet, van); c3_m fun_m = 141 + c3__rest + ((!!vet) << 8); - u3_noun key = u3z_key_3(fun_m, bat, sut, leg); + u3_noun key = u3z_key_3(fun_m, sut, leg, bat); u3_weak pro = u3z_find(key); if ( u3_none != pro ) { From 47224ab88f4721cd1f0b29698a0c135ab4d7e46f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 19 Nov 2020 15:43:27 -0800 Subject: [PATCH 650/933] u3: adds ghetto +mook replacement --- pkg/urbit/noun/manage.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/pkg/urbit/noun/manage.c b/pkg/urbit/noun/manage.c index 383304c2fa..57f697b7f9 100644 --- a/pkg/urbit/noun/manage.c +++ b/pkg/urbit/noun/manage.c @@ -1215,6 +1215,32 @@ u3m_soft(c3_w mil_w, // XX produce specific error motes instead of %2? // if ( 0 == u3A->roc ) { + + { + u3_noun tax = u3t(u3t(why)); + + u3m_p("mote", u3h(u3t(why))); + + while ( u3_nul != tax ) { + u3_noun dat, mot, val; + u3x_cell(tax, &dat, &tax); + + if ( c3y == u3r_cell(dat, &mot, &val) ) { + if ( c3__spot == mot ) { + u3m_p("tax", val); + } + else if ( (c3__mean == mot) + && (c3y == u3a_is_atom(val)) ) + { + u3m_p("men", val); + } + else { + u3m_p("mot", mot); + } + } + } + } + u3z(why); return u3nc(c3__fail, u3_nul); } From 53665a6172bbb2dae0ad41e1325aa10228544cd1 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 18 Nov 2020 18:10:46 -0800 Subject: [PATCH 651/933] u3: moves _n_swap() next to other stack ops --- pkg/urbit/noun/nock.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/pkg/urbit/noun/nock.c b/pkg/urbit/noun/nock.c index 72caad61bb..c06c61f069 100644 --- a/pkg/urbit/noun/nock.c +++ b/pkg/urbit/noun/nock.c @@ -1485,6 +1485,19 @@ _n_rewo(c3_y* buf, c3_w* ip_w) return one | (two << 8) | (tre << 16) | (qua << 24); } +/* _n_swap(): swap two items on the top of the stack, return pointer to top + */ +static inline u3_noun* +_n_swap(c3_ys mov, c3_ys off) +{ + u3_noun* top = _n_peek(off); + u3_noun* up = _n_peet(mov, off); + u3_noun tmp = *up; + *up = *top; + *top = tmp; + return top; +} + #ifdef VERBOSE_BYTECODE /* _n_print_byc(): print bytecode. used for debugging. */ @@ -1604,19 +1617,6 @@ u3n_find(u3_noun key, u3_noun fol) return pog_p; } -/* _n_swap(): swap two items on the top of the stack, return pointer to top - */ -static inline u3_noun* -_n_swap(c3_ys mov, c3_ys off) -{ - u3_noun* top = _n_peek(off); - u3_noun* up = _n_peet(mov, off); - u3_noun tmp = *up; - *up = *top; - *top = tmp; - return top; -} - /* _n_kick(): stop tracing noc and kick a u3j_site. */ static u3_weak From 99ccf8b4038f64c1b18fcde09049d1cf93b13716 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 18 Nov 2020 18:11:29 -0800 Subject: [PATCH 652/933] u3: adds dynamic hint bytecodes and implementation --- pkg/urbit/noun/nock.c | 171 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 148 insertions(+), 23 deletions(-) diff --git a/pkg/urbit/noun/nock.c b/pkg/urbit/noun/nock.c index c06c61f069..205279b2a0 100644 --- a/pkg/urbit/noun/nock.c +++ b/pkg/urbit/noun/nock.c @@ -475,22 +475,32 @@ _n_nock_on(u3_noun bus, u3_noun fol) #define SLIB 70 #define SLIS 71 #define SAVE 72 +// dynamic +#define HILT_FORE_BYTE 73 +#define HILT_FORE_SHORT 74 +#define HINT_FORE_BYTE 75 +#define HINT_FORE_SHORT 76 + +#define HILT_HIND_KEEP 77 +#define HILT_HIND_LOSE 78 +#define HINT_HIND_KEEP 79 +#define HINT_HIND_LOSE 80 // nock 10 -#define MUTH 73 -#define KUTH 74 -#define MUTT 75 -#define KUTT 76 -#define MUSM 77 -#define KUSM 78 -#define MUTB 79 -#define MUTS 80 -#define MITB 81 -#define MITS 82 -#define KUTB 83 -#define KUTS 84 -#define KITB 85 -#define KITS 86 -#define LAST 87 +#define MUTH 81 +#define KUTH 82 +#define MUTT 83 +#define KUTT 84 +#define MUSM 85 +#define KUSM 86 +#define MUTB 87 +#define MUTS 88 +#define MITB 89 +#define MITS 90 +#define KUTB 91 +#define KUTS 92 +#define KITB 93 +#define KITS 94 +#define LAST 95 /* _n_arg(): return the size (in bytes) of an opcode's argument */ @@ -605,6 +615,7 @@ _n_melt(u3_noun ops, c3_w* byc_w, c3_w* cal_w, case SAST: case SALT: case KICS: case TICS: case FISK: case FISL: case SUSH: case SANS: case LISL: case LISK: case SKIS: case SLIS: + case HILT_FORE_SHORT: case HINT_FORE_SHORT: c3_assert(0); //overflows break; @@ -625,6 +636,7 @@ _n_melt(u3_noun ops, c3_w* byc_w, c3_w* cal_w, case BUSH: case FIBK: case FIBL: case SANB: case LIBL: case LIBK: case KITB: case MITB: + case HILT_FORE_BYTE: case HINT_FORE_BYTE: a_w = (*lit_w)++; if ( a_w <= 0xFF ) { siz_y[i_w] = 2; @@ -856,6 +868,7 @@ _n_prog_asm(u3_noun ops, u3n_prog* pog_u, u3_noun sip) case LIBK: case LIBL: case BUSH: case SANB: case KITB: case MITB: + case HILT_FORE_BYTE: case HINT_FORE_BYTE: _n_prog_asm_inx(buf_y, &i_w, lit_s, cod); pog_u->lit_u.non[lit_s++] = u3k(u3t(op)); break; @@ -963,6 +976,7 @@ static char* opcode_names[] = { "balt", "salt", "skib", "skis", "slib", "slis", "save", + "hilt_fore", "hilt_hind", "hint_fore", "hint_hind", "muth", "kuth", "mutt", "kutt", "musm", "kusm", "mutb", "muts", "mitb", "mits", @@ -995,21 +1009,32 @@ static c3_w _n_comp(u3_noun*, u3_noun, c3_o, c3_o); static c3_w _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o los_o, c3_o tel_o) { + c3_w tot_w = 0; + if ( c3n == u3du(hif) ) { - // no currently recognized static hints - return _n_comp(ops, nef, los_o, tel_o); + u3_noun fen = u3_nul; + c3_w nef_w = _n_comp(&fen, nef, los_o, tel_o); + + ++tot_w; _n_emit(ops, u3nc(HILT_FORE_BYTE, u3nc(u3k(hif), u3k(nef)))); // overflows + ++tot_w; _n_emit(ops, u3nc(SBIN, nef_w + 1)); + tot_w += nef_w; _n_apen(ops, fen); + ++tot_w; _n_emit(ops, ( c3y == los_o ) ? HILT_HIND_LOSE : HILT_HIND_KEEP); // overflows } else { - c3_w tot_w = 0; u3_noun zep, hod; u3x_cell(hif, &zep, &hod); switch ( zep ) { - default: + default: { + u3_noun fen = u3_nul; + c3_w nef_w = _n_comp(&fen, nef, los_o, tel_o); + tot_w += _n_comp(ops, hod, c3n, c3n); - ++tot_w; _n_emit(ops, TOSS); - tot_w += _n_comp(ops, nef, los_o, tel_o); - break; + ++tot_w; _n_emit(ops, u3nc(HINT_FORE_BYTE, u3nc(u3k(zep), u3k(nef)))); // overflows + ++tot_w; _n_emit(ops, u3nc(SBIN, nef_w + 1)); + tot_w += nef_w; _n_apen(ops, fen); + ++tot_w; _n_emit(ops, ( c3y == los_o ) ? HINT_HIND_LOSE : HINT_HIND_KEEP); // overflows + } break; case c3__hunk: case c3__lose: @@ -1062,8 +1087,9 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o los_o, c3_o tel_o) break; } } - return tot_w; } + + return tot_w; } static c3_t @@ -1617,6 +1643,40 @@ u3n_find(u3_noun key, u3_noun fol) return pog_p; } +static c3_o +_n_hilt_fore(u3_noun lit, u3_noun bus, u3_noun* out) // transfer, retain, n/a +{ + fprintf(stderr, "hilt_fore\r\n"); + u3z(lit); + *out = u3_nul; + return c3y; +} + +static void +_n_hilt_hind(u3_noun tok, u3_noun pro) // transfer, retain +{ + fprintf(stderr, "hilt_hind\r\n"); + c3_assert( u3_nul == tok ); + u3z(tok); +} + +static c3_o +_n_hint_fore(u3_noun lit, u3_noun bus, u3_noun* clu) // transfer, retain, transfer +{ + fprintf(stderr, "hint_fore\r\n"); + u3z(lit); u3z(*clu); + *clu = u3_nul; + return c3y; +} + +static void +_n_hint_hind(u3_noun tok, u3_noun pro) // transfer, retain +{ + fprintf(stderr, "hint_hind\r\n"); + c3_assert( u3_nul == tok ); + u3z(tok); +} + /* _n_kick(): stop tracing noc and kick a u3j_site. */ static u3_weak @@ -1680,6 +1740,10 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) &&do_balt, &&do_salt, &&do_skib, &&do_skis, &&do_slib, &&do_slis, &&do_save, + &&do_hilt_fore_byte, &&do_hilt_fore_short, + &&do_hint_fore_byte, &&do_hint_fore_short, + &&do_hilt_hind_keep, &&do_hilt_hind_lose, + &&do_hint_hind_keep, &&do_hint_hind_lose, &&do_muth, &&do_kuth, &&do_mutt, &&do_kutt, &&do_musm, &&do_kusm, &&do_mutb, &&do_muts, &&do_mitb, &&do_mits, @@ -2270,6 +2334,67 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) u3z(o); BURN(); + do_hilt_fore_byte: + x = pog[ip_w++]; + goto hilt_fore_in; + + do_hilt_fore_short: + x = _n_resh(pog, &ip_w); + hilt_fore_in: + x = u3k(pog_u->lit_u.non[x]); + top = _n_peek(off); // bus + x = _n_hilt_fore(x, *top, &o); + _n_push(mov, off, o); + _n_swap(mov, off); // bus + _n_push(mov, off, x); // shortcircuit if c3n + BURN(); + + do_hint_fore_byte: + x = pog[ip_w++]; + goto hint_fore_in; + + do_hint_fore_short: + x = _n_resh(pog, &ip_w); + hint_fore_in: + x = u3k(pog_u->lit_u.non[x]); + o = _n_pep(mov, off); // clu + top = _n_peek(off); // bus + x = _n_hint_fore(x, *top, &o); + _n_push(mov, off, o); + _n_swap(mov, off); // bus + _n_push(mov, off, x); + BURN(); + + do_hilt_hind_keep: // [pro bus tok] + x = _n_pep(mov, off); // [bus tok] + _n_swap(mov, off); // [tok bus] + o = _n_pep(mov, off); // [bus] + _n_push(mov, off, x); // [pro bus] + _n_hilt_hind(o, x); + BURN(); + + do_hilt_hind_lose: // [pro tok] + top = _n_swap(mov, off); // [tok pro] + o = _n_pep(mov, off); // [pro] + top = _n_peek(off); + _n_hilt_hind(o, *top); + BURN(); + + do_hint_hind_keep: // [pro bus tok] + x = _n_pep(mov, off); // [bus tok] + _n_swap(mov, off); // [tok bus] + o = _n_pep(mov, off); // [bus] + _n_push(mov, off, x); // [pro bus] + _n_hint_hind(o, x); + BURN(); + + do_hint_hind_lose: // [pro tok] + top = _n_swap(mov, off); // [tok pro] + o = _n_pep(mov, off); // [pro] + top = _n_peek(off); + _n_hint_hind(o, *top); + BURN(); + do_kuth: x = _n_pep(mov, off); top = _n_swap(mov, off); From b046bbfd47a6ce94c18a41b360ce2a09af2205cf Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 19 Nov 2020 11:48:39 -0800 Subject: [PATCH 653/933] u3: refactors dynamic hint bytecodes, documents protocol --- pkg/urbit/noun/nock.c | 158 ++++++++++++++++++++++++++++-------------- 1 file changed, 105 insertions(+), 53 deletions(-) diff --git a/pkg/urbit/noun/nock.c b/pkg/urbit/noun/nock.c index 205279b2a0..70035e33c0 100644 --- a/pkg/urbit/noun/nock.c +++ b/pkg/urbit/noun/nock.c @@ -475,16 +475,16 @@ _n_nock_on(u3_noun bus, u3_noun fol) #define SLIB 70 #define SLIS 71 #define SAVE 72 -// dynamic -#define HILT_FORE_BYTE 73 -#define HILT_FORE_SHORT 74 -#define HINT_FORE_BYTE 75 -#define HINT_FORE_SHORT 76 - -#define HILT_HIND_KEEP 77 -#define HILT_HIND_LOSE 78 -#define HINT_HIND_KEEP 79 -#define HINT_HIND_LOSE 80 +// before formula +#define HILB 73 // atomic, byte +#define HILS 74 // atomic, short +#define HINB 75 // arbitrary, byte +#define HINS 76 // arbitrary, short +// after formula +#define HILK 77 // atomic, keep +#define HILL 78 // atomic, lose +#define HINK 79 // arbitrary, keep +#define HINL 80 // arbitrary, lose // nock 10 #define MUTH 81 #define KUTH 82 @@ -615,7 +615,7 @@ _n_melt(u3_noun ops, c3_w* byc_w, c3_w* cal_w, case SAST: case SALT: case KICS: case TICS: case FISK: case FISL: case SUSH: case SANS: case LISL: case LISK: case SKIS: case SLIS: - case HILT_FORE_SHORT: case HINT_FORE_SHORT: + case HILS: case HINS: c3_assert(0); //overflows break; @@ -636,7 +636,7 @@ _n_melt(u3_noun ops, c3_w* byc_w, c3_w* cal_w, case BUSH: case FIBK: case FIBL: case SANB: case LIBL: case LIBK: case KITB: case MITB: - case HILT_FORE_BYTE: case HINT_FORE_BYTE: + case HILB: case HINB: a_w = (*lit_w)++; if ( a_w <= 0xFF ) { siz_y[i_w] = 2; @@ -868,7 +868,7 @@ _n_prog_asm(u3_noun ops, u3n_prog* pog_u, u3_noun sip) case LIBK: case LIBL: case BUSH: case SANB: case KITB: case MITB: - case HILT_FORE_BYTE: case HINT_FORE_BYTE: + case HILB: case HINB: _n_prog_asm_inx(buf_y, &i_w, lit_s, cod); pog_u->lit_u.non[lit_s++] = u3k(u3t(op)); break; @@ -976,7 +976,8 @@ static char* opcode_names[] = { "balt", "salt", "skib", "skis", "slib", "slis", "save", - "hilt_fore", "hilt_hind", "hint_fore", "hint_hind", + "hilb", "hils", "hinb", "hins" + "hilk", "hill", "hink", "hinl" "muth", "kuth", "mutt", "kutt", "musm", "kusm", "mutb", "muts", "mitb", "mits", @@ -1012,13 +1013,28 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o los_o, c3_o tel_o) c3_w tot_w = 0; if ( c3n == u3du(hif) ) { - u3_noun fen = u3_nul; - c3_w nef_w = _n_comp(&fen, nef, los_o, tel_o); + // compile whitelisted atomic hints to dispatch protocol; + // compute and drop all others; + // + switch ( hif ) { + default: { + return _n_comp(ops, nef, los_o, tel_o); + } - ++tot_w; _n_emit(ops, u3nc(HILT_FORE_BYTE, u3nc(u3k(hif), u3k(nef)))); // overflows - ++tot_w; _n_emit(ops, u3nc(SBIN, nef_w + 1)); - tot_w += nef_w; _n_apen(ops, fen); - ++tot_w; _n_emit(ops, ( c3y == los_o ) ? HILT_HIND_LOSE : HILT_HIND_KEEP); // overflows + // no currently recognized static hints + // + case u3_none: { + u3_noun fen = u3_nul; + c3_w nef_w = _n_comp(&fen, nef, los_o, tel_o); + + // HILB overflows to HILS + // + ++tot_w; _n_emit(ops, u3nc(HILB, u3nc(u3k(hif), u3k(nef)))); + ++tot_w; _n_emit(ops, u3nc(SBIN, nef_w + 1)); + tot_w += nef_w; _n_apen(ops, fen); + ++tot_w; _n_emit(ops, ( c3y == los_o ) ? HILL : HILK); + } break; + } } else { u3_noun zep, hod; @@ -1026,14 +1042,31 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o los_o, c3_o tel_o) switch ( zep ) { default: { - u3_noun fen = u3_nul; - c3_w nef_w = _n_comp(&fen, nef, los_o, tel_o); + // compile whitelisted dynamic hints to dispatch protocol; + // compute and drop all others; + // + switch ( zep ) { + default: { + tot_w += _n_comp(ops, hod, c3n, c3n); + ++tot_w; _n_emit(ops, TOSS); + tot_w += _n_comp(ops, nef, los_o, tel_o); + } break; - tot_w += _n_comp(ops, hod, c3n, c3n); - ++tot_w; _n_emit(ops, u3nc(HINT_FORE_BYTE, u3nc(u3k(zep), u3k(nef)))); // overflows - ++tot_w; _n_emit(ops, u3nc(SBIN, nef_w + 1)); - tot_w += nef_w; _n_apen(ops, fen); - ++tot_w; _n_emit(ops, ( c3y == los_o ) ? HINT_HIND_LOSE : HINT_HIND_KEEP); // overflows + // no currently recognized dynamic hints + // + case u3_none: { + u3_noun fen = u3_nul; + c3_w nef_w = _n_comp(&fen, nef, los_o, tel_o); + + tot_w += _n_comp(ops, hod, c3n, c3n); + // HINB overflows to HINS + // + ++tot_w; _n_emit(ops, u3nc(HINB, u3nc(u3k(zep), u3k(nef)))); + ++tot_w; _n_emit(ops, u3nc(SBIN, nef_w + 1)); + tot_w += nef_w; _n_apen(ops, fen); + ++tot_w; _n_emit(ops, ( c3y == los_o ) ? HINL : HINK); + } break; + } } break; case c3__hunk: @@ -1643,36 +1676,57 @@ u3n_find(u3_noun key, u3_noun fol) return pog_p; } +/* _n_hilt_fore(): literal (atomic) dynamic hint, before formula evaluation. +** lit: hint atom. TRANSFER +** bus: subject. RETAIN +** out: token for _n_hilt_hind(); +** conventually, [lit] or [lit data]. ~ if unused. +** +** any hints herein must be whitelisted in _n_burn(). +*/ static c3_o -_n_hilt_fore(u3_noun lit, u3_noun bus, u3_noun* out) // transfer, retain, n/a +_n_hilt_fore(u3_atom lit, u3_noun bus, u3_noun* out) // transfer, retain, n/a { - fprintf(stderr, "hilt_fore\r\n"); u3z(lit); *out = u3_nul; return c3y; } +/* _n_hilt_hind(): literal (atomic) dynamic hint, after formula evaluation. +** tok: token from _n_hilt_fore(). TRANSFER +** pro: product of formula evaluation. RETAIN +*/ static void _n_hilt_hind(u3_noun tok, u3_noun pro) // transfer, retain { - fprintf(stderr, "hilt_hind\r\n"); c3_assert( u3_nul == tok ); u3z(tok); } +/* _n_hint_fore(): arbitrary dynamic hint, before formula evaluation +** hin: [hint-atom, formula]. TRANSFER +** bus: subject. RETAIN +** clu: product of the hint-formula. TRANSFER +** also, token for _n_hint_hind(); +** conventually, [hint-atom] or [hint-atom data]. ~ if unused. +** +** any hints herein must be whitelisted in _n_burn(). +*/ static c3_o -_n_hint_fore(u3_noun lit, u3_noun bus, u3_noun* clu) // transfer, retain, transfer +_n_hint_fore(u3_cell hin, u3_noun bus, u3_noun* clu) { - fprintf(stderr, "hint_fore\r\n"); - u3z(lit); u3z(*clu); + u3z(hin); u3z(*clu); *clu = u3_nul; return c3y; } +/* _n_hint_hind(): arbitrary dynamic hint, after formula evaluation. +** tok: token from _n_hint_fore(). TRANSFER +** pro: product of formula evaluation. RETAIN +*/ static void -_n_hint_hind(u3_noun tok, u3_noun pro) // transfer, retain +_n_hint_hind(u3_noun tok, u3_noun pro) { - fprintf(stderr, "hint_hind\r\n"); c3_assert( u3_nul == tok ); u3z(tok); } @@ -1740,10 +1794,8 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) &&do_balt, &&do_salt, &&do_skib, &&do_skis, &&do_slib, &&do_slis, &&do_save, - &&do_hilt_fore_byte, &&do_hilt_fore_short, - &&do_hint_fore_byte, &&do_hint_fore_short, - &&do_hilt_hind_keep, &&do_hilt_hind_lose, - &&do_hint_hind_keep, &&do_hint_hind_lose, + &&do_hilb, &&do_hils, &&do_hinb, &&do_hins, + &&do_hilk, &&do_hill, &&do_hink, &&do_hinl, &&do_muth, &&do_kuth, &&do_mutt, &&do_kutt, &&do_musm, &&do_kusm, &&do_mutb, &&do_muts, &&do_mitb, &&do_mits, @@ -2334,11 +2386,11 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) u3z(o); BURN(); - do_hilt_fore_byte: + do_hilb: x = pog[ip_w++]; goto hilt_fore_in; - do_hilt_fore_short: + do_hils: x = _n_resh(pog, &ip_w); hilt_fore_in: x = u3k(pog_u->lit_u.non[x]); @@ -2349,23 +2401,23 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) _n_push(mov, off, x); // shortcircuit if c3n BURN(); - do_hint_fore_byte: + do_hinb: x = pog[ip_w++]; goto hint_fore_in; - do_hint_fore_short: + do_hins: x = _n_resh(pog, &ip_w); - hint_fore_in: + hint_fore_in: // [clu bus] x = u3k(pog_u->lit_u.non[x]); - o = _n_pep(mov, off); // clu - top = _n_peek(off); // bus + o = _n_pep(mov, off); // [bus] + top = _n_peek(off); x = _n_hint_fore(x, *top, &o); - _n_push(mov, off, o); - _n_swap(mov, off); // bus - _n_push(mov, off, x); + _n_push(mov, off, o); // [tok bus] + _n_swap(mov, off); // [bus tok] + _n_push(mov, off, x); // [kip bus tok] BURN(); - do_hilt_hind_keep: // [pro bus tok] + do_hilk: // [pro bus tok] x = _n_pep(mov, off); // [bus tok] _n_swap(mov, off); // [tok bus] o = _n_pep(mov, off); // [bus] @@ -2373,14 +2425,14 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) _n_hilt_hind(o, x); BURN(); - do_hilt_hind_lose: // [pro tok] + do_hill: // [pro tok] top = _n_swap(mov, off); // [tok pro] o = _n_pep(mov, off); // [pro] top = _n_peek(off); _n_hilt_hind(o, *top); BURN(); - do_hint_hind_keep: // [pro bus tok] + do_hink: // [pro bus tok] x = _n_pep(mov, off); // [bus tok] _n_swap(mov, off); // [tok bus] o = _n_pep(mov, off); // [bus] @@ -2388,7 +2440,7 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) _n_hint_hind(o, x); BURN(); - do_hint_hind_lose: // [pro tok] + do_hinl: // [pro tok] top = _n_swap(mov, off); // [tok pro] o = _n_pep(mov, off); // [pro] top = _n_peek(off); From 446f551ab64731ca578bd841543d68366a8f921d Mon Sep 17 00:00:00 2001 From: Tyler Brown Cifu Shuster Date: Fri, 20 Nov 2020 08:37:57 -0800 Subject: [PATCH 654/933] groups: only prompt to delete on ownership Fixes #3965 --- .../views/landscape/components/GroupSettings/Personal.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/interface/src/views/landscape/components/GroupSettings/Personal.tsx b/pkg/interface/src/views/landscape/components/GroupSettings/Personal.tsx index 9b036ec45a..7d4838d2ab 100644 --- a/pkg/interface/src/views/landscape/components/GroupSettings/Personal.tsx +++ b/pkg/interface/src/views/landscape/components/GroupSettings/Personal.tsx @@ -34,10 +34,12 @@ function DeleteGroup(props: { const history = useHistory(); const onDelete = async () => { const name = props.association['group-path'].split('/').pop(); - if (prompt(`To confirm deleting this group, type ${name}`) === name) { - await props.api.contacts.delete(props.association["group-path"]); - history.push("/"); + if (props.owner) { + const shouldDelete = (prompt(`To confirm deleting this group, type ${name}`) === name); + if (!shouldDelete) return; } + await props.api.contacts.delete(props.association["group-path"]); + history.push("/"); }; const action = props.owner ? "Delete" : "Leave"; From 837abacb9cb5d37311ddcf0523588e41494bfedb Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Fri, 20 Nov 2020 11:01:24 -0600 Subject: [PATCH 655/933] observe-hook: add new thread to leave graphs upon removing a group --- pkg/arvo/app/observe-hook.hoon | 27 ++++++++++++++++++---- pkg/arvo/ted/group/leave-graph.hoon | 35 +++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 pkg/arvo/ted/group/leave-graph.hoon diff --git a/pkg/arvo/app/observe-hook.hoon b/pkg/arvo/app/observe-hook.hoon index 174b90b13c..e2ec831e9a 100644 --- a/pkg/arvo/app/observe-hook.hoon +++ b/pkg/arvo/app/observe-hook.hoon @@ -10,10 +10,13 @@ +$ card card:agent:gall +$ versioned-state $% state-0 + state-0 == :: +$ serial @uv +$ state-0 [%0 observers=(map serial observer:sur)] ++$ state-1 [%1 observers=(map serial observer:sur)] +:: ++ got-by-val |= [a=(map serial observer:sur) b=observer:sur] ^- serial @@ -24,7 +27,7 @@ -- :: %- agent:dbug -=| state-0 +=| state-1 =* state - :: ^- agent:gall @@ -35,8 +38,14 @@ ++ on-init |^ ^- (quip card _this) :_ this - :_ ~ - (act /inv-gra [%watch %invite-store /invitatory/graph %invite-accepted-graph]) + :~ %+ act + /inv-gra + [%watch %invite-store /invitatory/graph %invite-accepted-graph] + :: + %+ act + /grp-gra + [%watch %group-store /groups %group-leave-graph] + == :: ++ act |= [=wire =action:sur] @@ -56,7 +65,17 @@ ++ on-load |= old-vase=vase ^- (quip card _this) - `this(state !<(state-0 old-vase)) + =/ old-state !<(versioned-state old-vase) + ?- -.old-state + %1 `this(state old-state) + :: + %0 + =. this(state [%1 observers.old-state]) + %+ on-poke + %observe-action + !> ^- action:sur + [%watch %group-store /groups %group-leave-graph] + == :: ++ on-poke |= [=mark =vase] diff --git a/pkg/arvo/ted/group/leave-graph.hoon b/pkg/arvo/ted/group/leave-graph.hoon new file mode 100644 index 0000000000..3ea41e1adc --- /dev/null +++ b/pkg/arvo/ted/group/leave-graph.hoon @@ -0,0 +1,35 @@ +/- spider, grp=group-store, gra=graph-store, met=metadata-store +/+ strandio, res=resource +:: +=* strand strand:spider +=* poke-our poke-our:strandio +=* scry scry:strandio +:: +^- thread:spider +|= arg=vase +=/ m (strand ,vase) +^- form:m +=+ !<([=update:grp ~] arg) +?. ?=(%remove-group -.update) + (pure:m !>(~)) +:: +:: get graphs associated with group and archive them +=/ graphs=(list path) + %+ turn + %~ tap in + %~ key by + ^- associations:met + %+ scry + %noun + (weld /group (en-path:res resource.update)) + |= [g=group-path:met m=md-resource:met] + ^- path + app-path.m +|- +?~ groups + (pure:m !>(~)) +;< ~ bind:m + %+ poke-our %graph-store + !> ^- update:graph-store + [%archive-graph (de-path:res i.groups)] +$(groups t.groups) From 1a22a917c43ef9f76f3724061fcffe8a2b800e8e Mon Sep 17 00:00:00 2001 From: Tyler Brown Cifu Shuster Date: Tue, 27 Oct 2020 16:53:06 -0700 Subject: [PATCH 656/933] weather: changing API added new colors allow arbitrary location Fixes #2634 --- pkg/arvo/app/weather.hoon | 15 +- pkg/interface/src/logic/api/launch.ts | 4 +- .../apps/launch/components/tiles/weather.js | 178 ++++++++---------- 3 files changed, 91 insertions(+), 106 deletions(-) diff --git a/pkg/arvo/app/weather.hoon b/pkg/arvo/app/weather.hoon index 684956b151..31e0b00d27 100644 --- a/pkg/arvo/app/weather.hoon +++ b/pkg/arvo/app/weather.hoon @@ -83,7 +83,7 @@ ?. ?=(%s -.jon) [~ state] =/ str=@t +.jon - =/ req=request:http (request-darksky str) + =/ req=request:http (request-wttr str) =/ out *outbound-config:iris =/ lismov=(list card) [%pass /[(scot %da now.bol)] %arvo %i %request req out]~ @@ -102,11 +102,11 @@ ^- (list card) [%give %fact ~[/all] %json !>((frond:enjs:format %location jon))]~ :: -++ request-darksky +++ request-wttr |= location=@t ^- request:http - =/ base 'https://api.darksky.net/forecast/634639c10670c7376dc66b6692fe57ca/' - =/ url=@t (cat 3 (cat 3 base location) '?units=auto') + =/ base 'https://wttr.in/' + =/ url=@t (cat 3 (cat 3 base location) '?format=j1') =/ hed [['Accept' 'application/json']]~ [%'GET' url hed *(unit octs)] :: @@ -133,8 +133,9 @@ =/ jon=json %+ frond:enjs:format %weather %- pairs:enjs:format - :~ [%currently (~(got by p.u.ujon) 'currently')] - [%daily (~(got by p.u.ujon) 'daily')] + :~ [%current-condition (~(got by p.u.ujon) 'current_condition')] + [%weather (~(got by p.u.ujon) 'weather')] + [%nearest-area (~(got by p.u.ujon) 'nearest_area')] == :- [%give %fact ~[/all] %json !>(jon)]~ %= state @@ -146,7 +147,7 @@ |= [wir=wire err=(unit tang)] ^- (quip card _state) ?~ err - =/ req/request:http (request-darksky location) + =/ req/request:http (request-wttr location) =/ out *outbound-config:iris :_ state(timer `(add now.bol ~h3)) :~ [%pass /[(scot %da now.bol)] %arvo %i %request req out] diff --git a/pkg/interface/src/logic/api/launch.ts b/pkg/interface/src/logic/api/launch.ts index bbe49db730..ce0a09a1c0 100644 --- a/pkg/interface/src/logic/api/launch.ts +++ b/pkg/interface/src/logic/api/launch.ts @@ -18,8 +18,8 @@ export default class LaunchApi extends BaseApi { return this.launchAction({ 'change-is-shown': { name, isShown }}); } - weather(latlng: any) { - return this.action('weather', 'json', latlng); + weather(location: string) { + return this.action('weather', 'json', location); } private launchAction(data) { diff --git a/pkg/interface/src/views/apps/launch/components/tiles/weather.js b/pkg/interface/src/views/apps/launch/components/tiles/weather.js index b973e37292..9dd62c8090 100644 --- a/pkg/interface/src/views/apps/launch/components/tiles/weather.js +++ b/pkg/interface/src/views/apps/launch/components/tiles/weather.js @@ -1,14 +1,43 @@ import React from 'react'; import moment from 'moment'; import { Box, Icon, Text, BaseAnchor, BaseInput } from '@tlon/indigo-react'; +import ErrorBoundary from '~/views/components/ErrorBoundary'; import Tile from './tile'; +export const weatherStyleMap = { + Sunny: 'rgba(67, 169, 255, 0.4)', + PartlyCloudy: 'rgba(178, 211, 255, 0.33)', + Cloudy: 'rgba(136, 153, 176, 0.43)', + VeryCloudy: 'rgba(78, 90, 106, 0.43)', + Fog: 'rgba(100, 119, 128, 0.12)', + LightShowers: 'rgba(121, 148, 185, 0.33)', + LightSleetShowers: 'rgba(114, 130, 153, 0.33)', + LightSleet: 'rgba(155, 164, 177, 0.33)', + ThunderyShowers: 'rgba(53, 77, 103, 0.33)', + LightSnow: 'rgba(179, 182, 200, 0.33)', + HeavySnow: 'rgba(179, 182, 200, 0.33)', + LightRain: 'rgba(58, 79, 107, 0.33)', + HeavyShowers: 'rgba(36, 54, 77, 0.33)', + HeavyRain: 'rgba(5, 9, 13, 0.39)', + LightSnowShowers: 'rgba(174, 184, 198, 0.33)', + HeavySnowShowers: 'rgba(55, 74, 107, 0.33)', + ThunderyHeavyRain: 'rgba(45, 56, 66, 0.61)', + ThunderySnowShowers: 'rgba(40, 54, 79, 0.46)', + default: 'transparent' +}; + +const imperialCountries = [ + 'United States of America', + 'Myanmar', + 'Liberia', +]; + export default class WeatherTile extends React.Component { constructor(props) { super(props); this.state = { - latlong: '', + location: '', manualEntry: false, error: false }; @@ -17,89 +46,45 @@ export default class WeatherTile extends React.Component { // geolocation and manual input functions locationSubmit() { navigator.geolocation.getCurrentPosition((res) => { - const latlng = `${res.coords.latitude},${res.coords.longitude}`; + const location = `${res.coords.latitude},${res.coords.longitude}`; this.setState({ - latlng + location }, (err) => { console.log(err); }, { maximumAge: Infinity, timeout: 10000 }); - this.props.api.launch.weather(latlng); + this.props.api.launch.weather(location); this.setState({ manualEntry: !this.state.manualEntry }); }); } - manualLocationSubmit() { + manualLocationSubmit(event) { event.preventDefault(); - const gpsInput = document.getElementById('gps'); - const latlngNoSpace = gpsInput.value.replace(/\s+/g, ''); - const latlngParse = /-?[0-9]+(?:\.[0-9]*)?,-?[0-9]+(?:\.[0-9]*)?/g; - if (latlngParse.test(latlngNoSpace)) { - const latlng = latlngNoSpace; - this.setState({ latlng }, (err) => { + const location = document.getElementById('location').value; + this.setState({ location }, (err) => { console.log(err); }, { maximumAge: Infinity, timeout: 10000 }); - this.props.api.launch.weather(latlng); + this.props.api.launch.weather(location); this.setState({ manualEntry: !this.state.manualEntry }); - } else { - this.setState({ error: true }); - return false; - } } - // set appearance based on weather - setColors(data) { - let weatherStyle = { - bg: '', - text: '' - }; - switch (data.currently.icon) { - case 'clear-day': - weatherStyle = { bg: '#E9F5FF', text: '#333' }; - break; - case 'clear-night': - weatherStyle = { bg: '#14263C', text: '#fff' }; - break; - case 'rain': - weatherStyle = { bg: '#2E1611', text: '#fff' }; - break; - case 'snow': - weatherStyle = { bg: '#F9F9FB', text: '#333' }; - break; - case 'sleet': - weatherStyle = { bg: '#EFF1F3', text: '#333' }; - break; - case 'wind': - weatherStyle = { bg: '#F7FEF6', text: '#333' }; - break; - case 'fog': - weatherStyle = { bg: '#504D44', text: '#fff' }; - break; - case 'cloudy': - weatherStyle = { bg: '#EEF1F5', text: '#333' }; - break; - case 'partly-cloudy-day': - weatherStyle = { bg: '#F3F6FA', text: '#333' }; - break; - case 'partly-cloudy-night': - weatherStyle = { bg: '#283442', text: '#fff' }; - break; - default: - weatherStyle = { bg: 'white', text: 'black' }; - } - return weatherStyle; + // set appearance based on weather + colorFromCondition(data) { + let weatherDesc = data['current-condition'][0].weatherDesc[0].value; + return weatherStyleMap[weatherDesc] || weatherStyleMap.default; } + // all tile views - renderWrapper(child, - weatherStyle = { bg: 'white', text: 'black' } - ) { + renderWrapper(child, backgroundColor = 'white') { return ( - - {child} - + + + {child} + + ); } - renderManualEntry() { + renderManualEntry(data) { let secureCheck; let error; if (this.state.error === true) { @@ -114,6 +99,10 @@ export default class WeatherTile extends React.Component { ); } + let locationName; + if ('nearest-area' in data) { + locationName = data['nearest-area'][0].areaName[0].value; + } return this.renderWrapper( {secureCheck} - Please enter your{' '} - - latitude and longitude - - . + Please enter your location. + {locationName ? ` Current location is near ${locationName}.` : ''} {error} { if (e.key === 'Enter') { - e.preventDefault(); - this.manualLocationSubmit(e.target.value); + this.manualLocationSubmit(e); } }} /> @@ -171,7 +152,7 @@ export default class WeatherTile extends React.Component { fontSize='0' border='0' type="submit" - onClick={() => this.manualLocationSubmit()} + onClick={this.manualLocationSubmit.bind(this)} value="->" /> @@ -182,7 +163,6 @@ export default class WeatherTile extends React.Component { renderNoData() { return this.renderWrapper( 24) { @@ -220,6 +202,10 @@ export default class WeatherTile extends React.Component { ? `Sun sets in ${sunsetDiff}h` : `Sun rises in ${sunriseDiff}h`; + const temp = data['nearest-area'] && imperialCountries.includes(data['nearest-area'][0].country[0].value) + ? `${Math.round(c.temp_F)}℉` + : `${Math.round(c.temp_C)}℃`; + return this.renderWrapper( - - + + Weather this.setState({ manualEntry: !this.state.manualEntry }) @@ -248,24 +234,22 @@ export default class WeatherTile extends React.Component { display="flex" flexDirection="column" > - {c.summary} - {Math.round(c.temperature)}° - {nextSolarEvent} + {c.weatherDesc[0].value.replace(/([a-z])([A-Z])/g, '$1 $2')} + {temp} + {nextSolarEvent} - - , weatherStyle); + , bg); } render() { const data = this.props.weather ? this.props.weather : {}; if (this.state.manualEntry === true) { - return this.renderManualEntry(); + return this.renderManualEntry(data); } - if ('currently' in data && 'daily' in data) { - const weatherStyle = this.setColors(data); - return this.renderWithData(data, weatherStyle); + if ('current-condition' in data && 'weather' in data) { + return this.renderWithData(data); } if (this.props.location) { From ebd4c8d264054f09e756600033d812af7c54b623 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 20 Nov 2020 13:29:04 -0800 Subject: [PATCH 657/933] pill: solid --- bin/solid.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index 22c296b168..3f0b61b6ba 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f57a9431a104d1d26b379c6db37cc11d3747bf291d58399a6ce9cda9a3cb988d -size 6322424 +oid sha256:6f38fba85eb50a94c0e64fed57fb1f9005ff4f3f37ef7115554c9c15b0982d39 +size 6308842 From a479af197378596cd5ff10e2eab42b9a2d30f80c Mon Sep 17 00:00:00 2001 From: Tyler Brown Cifu Shuster Date: Fri, 20 Nov 2020 13:57:27 -0800 Subject: [PATCH 658/933] publish: styles preview Fixes https://github.com/urbit/landscape/issues/182 --- .../apps/publish/components/NotePreview.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/interface/src/views/apps/publish/components/NotePreview.tsx b/pkg/interface/src/views/apps/publish/components/NotePreview.tsx index 9a5ea8560c..d94e94cc82 100644 --- a/pkg/interface/src/views/apps/publish/components/NotePreview.tsx +++ b/pkg/interface/src/views/apps/publish/components/NotePreview.tsx @@ -1,12 +1,12 @@ import React from "react"; -import { Col, Box } from "@tlon/indigo-react"; -import { cite } from "~/logic/lib/util"; -import { Note } from "~/types/publish-update"; -import { Contact } from "~/types/contact-update"; -import ReactMarkdown from "react-markdown"; import moment from "moment"; import { Link } from "react-router-dom"; import styled from "styled-components"; +import ReactMarkdown from "react-markdown"; +import { Col, Box, Text } from "@tlon/indigo-react"; + +import { cite } from "~/logic/lib/util"; +import { Contact } from "~/types/contact-update"; import { GraphNode } from "~/types/graph-update"; import { getComments, @@ -62,8 +62,8 @@ export function NotePreview(props: NotePreviewProps) { return ( - {title} - + {title} + {date} - {commentDesc} + {commentDesc} {rev.valueOf() === 1 ? `1 Revision` : `${rev} Revisions`} From 6b8155145bc57455a597b64d693a528634aadad5 Mon Sep 17 00:00:00 2001 From: Tyler Brown Cifu Shuster Date: Fri, 20 Nov 2020 14:01:24 -0800 Subject: [PATCH 659/933] unwrap comments --- pkg/interface/src/views/apps/publish/components/NotePreview.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/interface/src/views/apps/publish/components/NotePreview.tsx b/pkg/interface/src/views/apps/publish/components/NotePreview.tsx index d94e94cc82..8e7da6ca81 100644 --- a/pkg/interface/src/views/apps/publish/components/NotePreview.tsx +++ b/pkg/interface/src/views/apps/publish/components/NotePreview.tsx @@ -82,7 +82,7 @@ export function NotePreview(props: NotePreviewProps) { {date} - {commentDesc} + {commentDesc} {rev.valueOf() === 1 ? `1 Revision` : `${rev} Revisions`} From a7ef000e811cd0cf6572370454f1e8d980cda745 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 20 Nov 2020 13:40:46 -0800 Subject: [PATCH 660/933] test: fixes +to-wain (no more trailing empty lines) --- pkg/arvo/tests/sys/zuse/format.hoon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/tests/sys/zuse/format.hoon b/pkg/arvo/tests/sys/zuse/format.hoon index 1ef96550f3..3ad678b392 100644 --- a/pkg/arvo/tests/sys/zuse/format.hoon +++ b/pkg/arvo/tests/sys/zuse/format.hoon @@ -18,12 +18,12 @@ :: empty string works fine :: %+ expect-eq - !> ~[''] + !> ~ !> (to-wain '') :: leading/trailing/consecutive newlines all work fine :: %+ expect-eq - !> ~['' 'hi' '' '' 'there' ''] + !> ~['' 'hi' '' '' 'there'] !> (to-wain '\0ahi\0a\0a\0athere\0a') == :: join a list of lines (cords) into a single cord From 28f000b312911a442da43975e3db1859e32db2b4 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 20 Nov 2020 15:21:50 -0800 Subject: [PATCH 661/933] nix: run tests against the latest arvo source --- default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/default.nix b/default.nix index 439899c3c4..52512891c3 100644 --- a/default.nix +++ b/default.nix @@ -134,6 +134,7 @@ let urbit-debug = urbit.override { enableDebug = true; }; urbit-tests = libLocal.testFakeShip { inherit herb; + inherit arvo; urbit = urbit-debug; pill = solid.lfs; From 5f160a233e2987d8a213c16f687336b884bfcd04 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 12 May 2020 11:20:24 -0700 Subject: [PATCH 662/933] hoon: removes utf32 hacks and \/ windowing from |re a tape is just a list of utf8 bytes, it's never save to split one at an arbitrary position. this is exactly what \/ windowing did, so i had hacked in to/from utf32 conversions to prevent splitting multi-byte characters. that is dumb and slow, so it's now gone. --- pkg/arvo/sys/hoon.hoon | 50 +----------------------------------------- 1 file changed, 1 insertion(+), 49 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 618b8adc09..6be34f1227 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -4948,43 +4948,8 @@ (weld ram(tac i.q.tac) ?~(t.q.tac voz (weld p.p.tac voz))) == :: - ++ ug :: horrible hack - |% - ++ ace :: strip ctrl chars - |= a=tape - ^- tape - ?~ a ~ - ?: |((lth i.a 32) =(127 `@`i.a)) - $(a t.a) - [i.a $(a t.a)] - :: - ++ act :: pretend tapes - |= tac=tank - ^- tank - ?- -.tac - %leaf [%leaf (hew p.tac)] - %plum tac :: XX consider - %palm :+ %palm - [(hew p.p.tac) (hew q.p.tac) (hew r.p.tac) (hew s.p.tac)] - (turn q.tac act) - %rose :+ %rose - [(hew p.p.tac) (hew q.p.tac) (hew r.p.tac)] - (turn q.tac act) - == - :: - ++ fix :: restore tapes - |= wol=wall - %+ turn wol - |=(a=tape (tufa `(list @c)``(list @)`a)) - :: - ++ hew :: pretend tape - |=(a=tape `tape``(list @)`(tuba (ace a))) - -- - :: ++ win |= {tab/@ edg/@} - =. tac (act:ug tac) - %- fix:ug =+ lug=`wall`~ |^ |- ^- wall ?- -.tac @@ -5028,20 +4993,7 @@ ++ rig |= hom/tape ^- wall - ?: (lte (lent hom) (sub edg tab)) - [(runt [tab ' '] hom) lug] - => .(tab (add tab 2), edg (sub edg 2)) - =+ mut=(trim (sub edg tab) hom) - :- (runt [(sub tab 2) ' '] ['\\' '/' (weld p.mut `_hom`['\\' '/' ~])]) - => .(hom q.mut) - |- - ?~ hom - :- %+ runt - [(sub tab 2) ' '] - ['\\' '/' (runt [(sub edg tab) ' '] ['\\' '/' ~])] - lug - => .(mut (trim (sub edg tab) hom)) - [(runt [tab ' '] p.mut) $(hom q.mut)] + [(runt [tab ' '] hom) lug] :: ++ wig |= hom/tape From c9db96382a722bb7c258d42c252c8f5ab92c0b33 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 12 May 2020 11:46:27 -0700 Subject: [PATCH 663/933] hoon: removes $plum from $tank --- pkg/arvo/lib/pprint.hoon | 8 ++++++-- pkg/arvo/sys/hoon.hoon | 3 --- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/arvo/lib/pprint.hoon b/pkg/arvo/lib/pprint.hoon index fcb2cf5184..1cf1d16ce6 100644 --- a/pkg/arvo/lib/pprint.hoon +++ b/pkg/arvo/lib/pprint.hoon @@ -117,14 +117,18 @@ ++ type-to-tank |= t=type ^- tank - [%plum (type-to-plum t)] + :+ %rose [~ ~ ~] + %+ turn (render-type t) + |=(=cord leaf+(trip cord)) :: :: Pretty-print a vase to a tank. :: ++ vase-to-tank |= v=vase ^- tank - [%plum (vase-to-plum v)] + :+ %rose [~ ~ ~] + %+ turn (render-vase v) + |=(=cord leaf+(trip cord)) :: :: Render an `axis`. :: diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 6be34f1227..83d0c45331 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -2026,7 +2026,6 @@ ++ tang (list tank) :: bottom-first error ++ tank $~ [%leaf ~] :: $% {$leaf p/tape} :: printing formats - {$plum p/plum} :: $: $palm :: backstep list p/{p/tape q/tape r/tape s/tape} :: q/(list tank) :: @@ -4936,7 +4935,6 @@ ^- tape ?- -.tac $leaf p.tac - $plum ~(flat plume p.tac) $palm ram(tac [%rose [p.p.tac (weld q.p.tac r.p.tac) s.p.tac] q.tac]) $rose %+ weld @@ -4954,7 +4952,6 @@ |^ |- ^- wall ?- -.tac $leaf (rig p.tac) - $plum (turn ~(tall plume p.tac) |=(=cord (trip cord))) $palm ?: fit (rig ram) From 25cea09fd15168887640ab46698587d908477aef Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 12 May 2020 13:23:45 -0700 Subject: [PATCH 664/933] hoon: refactors |re for clarity --- pkg/arvo/sys/hoon.hoon | 149 +++++++++++++++++++++++++++-------------- 1 file changed, 98 insertions(+), 51 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 83d0c45331..574c59c156 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -4929,82 +4929,129 @@ ?~ kids (cat 3 '(' (cat 3 sym ')')) [%sbrk [%tree fmt kids]] :: +:: |re: tank renderer +:: ++ re - |_ tac/tank + |_ tac=tank + :: +ram: render a tank to one line (flat) + :: ++ ram ^- tape ?- -.tac - $leaf p.tac - $palm ram(tac [%rose [p.p.tac (weld q.p.tac r.p.tac) s.p.tac] q.tac]) - $rose + %leaf p.tac + :: + :: flat %palm rendered as %rose with welded openers + :: + %palm + =* mid p.p.tac + =* for (weld q.p.tac r.p.tac) + =* end s.p.tac + ram(tac [%rose [mid for end] q.tac]) + :: + :: flat %rose rendered with open/mid/close + :: + %rose + =* mid p.p.tac + =* for q.p.tac + =* end r.p.tac + =* lit q.tac %+ weld - q.p.tac + for |- ^- tape - ?~ q.tac - r.p.tac - =+ voz=$(q.tac t.q.tac) - (weld ram(tac i.q.tac) ?~(t.q.tac voz (weld p.p.tac voz))) + ?~ lit + end + %+ weld + ram(tac i.lit) + =* voz $(lit t.lit) + ?~(t.lit voz (weld mid voz)) == + :: +win: render a tank to multiple lines (tall) + :: + :: indented by .tab, soft-wrapped at .edg :: ++ win - |= {tab/@ edg/@} - =+ lug=`wall`~ - |^ |- ^- wall + |= [tab=@ud edg=@ud] + :: output stack + :: + =| lug=wall + |^ ^- wall ?- -.tac - $leaf (rig p.tac) - $palm - ?: fit - (rig ram) - ?~ q.tac - (rig q.p.tac) - ?~ t.q.tac - (rig(tab (add 2 tab), lug $(tac i.q.tac)) q.p.tac) - => .(q.tac `(list tank)`q.tac) - =+ lyn=(mul 2 (lent q.tac)) - =+ ^= qyr - |- ^- wall - ?~ q.tac - lug - %= ^$ - tac i.q.tac - tab (add tab (sub lyn 2)) - lug $(q.tac t.q.tac, lyn (sub lyn 2)) - == - (wig(lug qyr) q.p.tac) + %leaf (rig p.tac) :: - $rose - ?: fit - (rig ram) + %palm + =/ hom ram + ?: (lte (lent hom) (sub edg tab)) + (rig hom) + :: + =* for q.p.tac + =* lit q.tac + ?~ lit + (rig for) + ?~ t.lit + =: tab (add 2 tab) + lug $(tac i.lit) + == + (rig for) + :: + => .(lit `(list tank)`lit) + =/ lyn (mul 2 (lent lit)) =. lug |- ^- wall - ?~ q.tac - ?:(=(~ r.p.tac) lug (rig r.p.tac)) - ^$(tac i.q.tac, lug $(q.tac t.q.tac), tab din) - ?: =(~ q.p.tac) - lug - (wig q.p.tac) + ?~ lit + lug + =/ nyl (sub lyn 2) + %= ^$ + tac i.lit + tab (add tab nyl) + lug $(lit t.lit, lyn nyl) + == + (wig for) + :: + %rose + =/ hom ram + ?: (lte (lent hom) (sub edg tab)) + (rig hom) + :: + =* for q.p.tac + =* end r.p.tac + =* lit q.tac + =. lug + |- ^- wall + ?~ lit + ?~(end lug (rig end)) + %= ^$ + tac i.lit + tab (mod (add 2 tab) (mul 2 (div edg 3))) + lug $(lit t.lit) + == + ?~(for lug (wig for)) == + :: +rig: indent tape and cons with output stack :: - ++ din (mod (add 2 tab) (mul 2 (div edg 3))) - ++ fit (lte (lent ram) (sub edg tab)) ++ rig - |= hom/tape + |= hom=tape ^- wall [(runt [tab ' '] hom) lug] + :: +wig: indent tape and cons with output stack + :: + :: joined with the top line if whitespace/indentation allow :: ++ wig - |= hom/tape + |= hom=tape ^- wall ?~ lug (rig hom) - =+ lin=(lent hom) - =+ wug=:(add 1 tab lin) + =/ wug :(add 1 tab (lent hom)) ?. =+ mir=i.lug - |- ?~ mir - | - ?|(=(0 wug) ?&(=(' ' i.mir) $(mir t.mir, wug (dec wug)))) + |- ^- ? + ?~ mir | + ?| =(0 wug) + ?&(=(' ' i.mir) $(mir t.mir, wug (dec wug))) + == (rig hom) :: ^ XX regular form? - [(runt [tab ' '] (weld hom `tape`[' ' (slag wug i.lug)])) t.lug] + :_ t.lug + %+ runt [tab ' '] + (weld hom `tape`[' ' (slag wug i.lug)]) -- -- ++ show :: XX deprecated! From aea0f571d70207c44f6f8cded9bb22a084c79cb8 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 12 May 2020 14:08:53 -0700 Subject: [PATCH 665/933] hoon: moves $plum and +plume to userspace --- nix/pkgs/pill/solid.sh | 2 + pkg/arvo/lib/plume.hoon | 420 +++++++++++++++++++++++++++++++++++ pkg/arvo/lib/pprint.hoon | 4 +- pkg/arvo/lib/xray.hoon | 1 + pkg/arvo/sur/plum.hoon | 51 +++++ pkg/arvo/sys/hoon.hoon | 467 --------------------------------------- 6 files changed, 477 insertions(+), 468 deletions(-) create mode 100644 pkg/arvo/lib/plume.hoon create mode 100644 pkg/arvo/sur/plum.hoon diff --git a/nix/pkgs/pill/solid.sh b/nix/pkgs/pill/solid.sh index 1e395f09f5..591a93e9ac 100644 --- a/nix/pkgs/pill/solid.sh +++ b/nix/pkgs/pill/solid.sh @@ -29,6 +29,7 @@ done cp $ARVO/app/lens.hoon ./pier/home/app/ cp $ARVO/app/dojo.hoon ./pier/home/app/ cp $ARVO/lib/base64.hoon ./pier/home/lib/ +cp $ARVO/lib/plume.hoon ./pier/home/lib/ cp $ARVO/lib/server.hoon ./pier/home/lib/ cp $ARVO/lib/sole.hoon ./pier/home/lib/ cp $ARVO/lib/xray.hoon ./pier/home/lib/ @@ -39,6 +40,7 @@ mkdir -p ./pier/home/mar/lens/ cp $ARVO/mar/lens/* ./pier/home/mar/lens/ cp $ARVO/sur/lens.hoon ./pier/home/sur/ +cp $ARVO/sur/plum.hoon ./pier/home/sur/ cp $ARVO/sur/sole.hoon ./pier/home/sur/ # Update +solid and its dependencies diff --git a/pkg/arvo/lib/plume.hoon b/pkg/arvo/lib/plume.hoon new file mode 100644 index 0000000000..63fba69c0f --- /dev/null +++ b/pkg/arvo/lib/plume.hoon @@ -0,0 +1,420 @@ +/- *plum +:: +:: This library includes `plume`, the actual pretty printing logic, +:: and a handful of utilities for constructing plums. +:: +:: Generally, you'll just use `plume` like this: +:: +:: ~(tall plume plum) :: Pretty print `plum` in tall mode. +:: ~(flat plume plum) :: Pretty print `plum` in wide mode. +:: +:: There is probably no reason to look at the utility routines unless +:: you are writing something to generate `plum`s. +:: +:: This is the pretty-printer. Use the `flat` arm to render a plum +:: into a single line and use the `tall` arm to get a nice multi-line +:: rendering that switches to wide mode if there's enough space. +:: +:: For details about how this works and what exactly it does in various +:: cases, take a look at the docs for `plum`, `plumfmt`, and at the +:: docs on the arms of this door. +:: +^? |% +++ plume + |_ =plum + :: + :: An line, indented by `indent` spaces. + :: + +$ line [indent=@ud text=tape] + :: + :: An sequence of indented lines. + :: + +$ block (list line) + :: + :: +flat: print as a single line + :: + ++ flat + ^- wain + text:linear + :: + :: +tall: print as multiple lines + :: + ++ tall + ^- wain + %+ turn window + |= line + (crip (runt [indent ' '] text)) + :: + :: +adjust: adjust lines to right + :: + ++ adjust + |= [tab=@ud =block] ^- ^block + (turn block |=([@ud tape] [(add tab +<-) +<+])) + :: + :: Prepend `n` spaces to a tape. + :: + ++ prepend-spaces + |= [n=@ t=tape] ^- tape + (runt [n ' '] t) + :: + :: +window: print as list of tabbed lines + :: + ++ window + ^- block + ~+ :: for random access + ?@ plum [0 (trip plum)]~ :: trivial text + ?- -.plum + :: + :: %para: Line-wrappable paragraph. This is a stub; it should + :: wrap text to 40 characters. + :: + %para + [0 +:linear]~ + :: + :: %sbrk: nested subexpression + :: + :: This is an opportunity to switch to wide mode. First, try + :: rendered in wide mode. If that's possible and the result + :: isn't too big, use that. Otherwise recurse into the subplum + :: without switching to wide mode. + :: + %sbrk + =/ sub kid.plum + ?+ sub + window(plum sub) + [%tree *] + =/ wideresult + ?~(wide.fmt.sub ~ [~ u=linear]) + ?: ?&(?=(^ wideresult) (lte length.u.wideresult 40)) + [0 text.u.wideresult]~ + window(plum sub) + == + :: + :: %tree: Try to render a text tree in tall mode. + :: + :: We want to render this in tall mode. First, verify that there + :: the plum has a tall render (if not, fall back to `linear` + :: formatting), then render all the subplums, and then render + :: them in one of three ways: + :: + :: - If the `plumfmt` contains an `indef` and that indef has + :: no prefix, then this is a variable-arity rune with a + :: terminator: Use vertical formatting. + :: + :: - If the `plumfmt` contains an `indef` and that indef DOES have + :: a prefix, then this is something that looks like a core: Use + :: `core-like` formatting. + :: + :: - Otherwise, this is a rune with a fixed number of arguments + :: Render the subplums using backstep indentation. + :: + :: There's also a special case where something has exactly one sub-plum. + :: where something has exactly one sub-block. For example, we + :: want this output: + :: + :: |- + :: foo + :: + %tree + ?~ tall.fmt.plum [0 text:linear]~ + =/ prelude (trip intro.u.tall.fmt.plum) + |^ =/ blocks (turn kids.plum |=(=^plum window(plum plum))) + =/ prelude (trip intro.u.tall.fmt.plum) + ?~ indef.u.tall.fmt.plum + ?: =(1 (lent blocks)) + [[0 prelude] (zing blocks)] + (backstep prelude blocks) + =/ prefix (trip sigil.u.indef.u.tall.fmt.plum) + =/ finale (trip final.u.indef.u.tall.fmt.plum) + ?~ blocks %+ weld + ?~(prelude ~ [0 prelude]~) + ?~(finale ~ [0 finale]~) + ?~ prefix (running prelude blocks finale) + (core-like prelude prefix blocks finale) + -- + == + :: + :: Render a plum in tall-mode using backstep indentation. Here, + :: we are rendering things that look something like this: + :: + :: :+ foo + :: bar + :: baz + :: + ++ backstep + |= [prelude=tape blocks=(list block)] + ^- block + %- zing + =/ nkids (lent blocks) + =/ idx 1 + |- ^- (list block) + ?~ blocks ~ + :_ $(blocks t.blocks, idx +(idx)) + ^- block + =/ indent (mul 2 (sub nkids idx)) + ?. =(1 idx) (adjust indent i.blocks) + (rune-inline-with-block prelude indent i.blocks) + :: + :: To make things look a bit nicer, we want to put the first + :: sub-block on the same line as the rune. We want this: + :: + :: :- foo + :: baz + :: + :: Instead of this: + :: + :: :- + :: foo + :: baz + :: + :: This handles the "foo" case. + :: + ++ rune-inline-with-block + |= [rune=tape indent=@ blk=block] + ^- block + =. indent (max indent (add 2 (lent rune))) + =. blk (adjust indent blk) + ?~ rune blk + ?~ blk [0 rune]~ + :_ t.blk + :- 0 + %+ weld rune + =/ spaces-btwn (sub indent.i.blk (lent rune)) + (prepend-spaces spaces-btwn text.i.blk) + :: + :: Render a tall hoon with running indentation. Here, we are + :: rendering things that look sopmething like: + :: + :: :~ foo + :: bar + :: baz + :: == + :: + :: So, there's basically three cases here: Either the prelude + :: is a rune, the prelude is empty, or prelude is some other + :: random-ass thing. + :: + :: - If there is no prelude, then just combine all of the + :: sub-blocks together unaltered. + :: - If it's a rune (two-characters wide), then combine the + :: rune and the first line into one line (separated by two + :: spaces) and indent the rest of the lines by four spaces. + :: - If the rune is some other random-ass thing (has a length + :: that isn't 0 or 2), then render the prelude alone on the + :: first line and then combine the sub-blocks together, + :: all indented by another two spaces. + :: + :: Regardless, if there's a finale, stick it on the end without + :: any indentation. + :: + ++ running + |= [prelude=tape blocks=(list block) finale=tape] + ^- block + =/ result=block (zing blocks) + =. result + ?+ (lent prelude) + [[0 prelude] (adjust 2 result)] :: unusual prelude + %0 :: empty prelude + result + %2 :: rune prelude + (rune-inline-with-block prelude 4 result) + == + ?~ finale result + (snoc result [0 finale]) + :: + :: This renders sub-blocks where each sub-block needs to be + :: prefixed by some tape. For example: + :: + :: |% + :: ++ foo + :: bar + :: ++ baz + :: qux + :: -- + :: + ++ core-like + |= [prelude=tape prefix=tape blocks=(list block) finale=tape] + ^- block + =/ clear (add 2 (lent prefix)) + =/ result + ^- block + %- zing + ^- (list block) + %+ turn blocks + |= blk=block + ^- block + ^+ +< + =* tab ?~(blk 0 (sub clear (min clear indent.i.blk))) + =. blk (adjust tab blk) + ?~ blk ~ + :_ t.blk + :- 0 + %+ weld prefix + (runt [(sub indent.i.blk (lent prefix)) ' '] text.i.blk) + =. result + ?~ finale result + (snoc result [0 finale]) + ?~ prelude result + [[0 prelude] result] + :: + :: +linear: Render a plum onto a single line, even if it only has a + :: wide form. + :: + ++ linear + ^- [length=@ud text=tape] + ~+ :: ~+ for random access + ?@ plum [(met 3 plum) (trip plum)] :: Just a cord. + ?- -.plum + :: + :: This is already in wide mode, so %sbrk nodes don't matter here. + :: + %sbrk + linear(plum kid.plum) + :: + :: %para: To write a wrappable text paragraph to a single line, + :: we just combine all the lines into one, interspersing single + :: spaces chars. + :: + %para + |- ^- [length=@ud text=tape] + ?~ lines.plum [0 ~] + =/ next $(lines.plum t.lines.plum) + =/ this [length=(met 3 i.lines.plum) text=(trip i.lines.plum)] + :- (add +(length.this) length.next) + (weld text.this `tape`[' ' text.next]) + :: + :: Render a text tree to a single line. + :: + %tree + |^ ^- [length=@ud text=tape] + ?~ wide.fmt.plum (force-wide window) + =/ body (render-body delimit.u.wide.fmt.plum kids.plum) + ?~ enclose.u.wide.fmt.plum body + (wrap-with-enclose u.enclose.u.wide.fmt.plum body) + :: + :: Given a list of subplums and a delimiter, render all the + :: subplums onto a single line, and combine them into a single + :: string by interspersing the delimiter. + :: + ++ render-body + |= [delimit=cord kids=(list ^plum)] + =/ stop (trip delimit) + |- ^- [length=@ud text=tape] + ?~ kids [0 ~] + =/ next $(kids t.kids) + =/ this linear(plum i.kids) + ?~ text.next this + :- :(add length.this (lent stop) length.next) + :(weld text.this stop text.next) + :: + :: Wrap a wide-form-rendered result with the `enclose` cords + :: from its `plumefmt`. + :: + ++ wrap-with-enclose + |= [clamps=(pair cord cord) body=[length=@ text=tape]] + ^- [length=@ud text=tape] + :: + =/ close [(trip -.clamps) (trip +.clamps)] + :- :(add length.body (lent -.close) (lent +.close)) + :(weld -.close text.body +.close) + :: + :: Given the result of rendering a plum in tall form, combine + :: all the lines into one by separating each by two spaces. + :: + ++ force-wide + |= render=(list [@ud text=tape]) + ^- [length=@ud text=tape] + :: + ?~ render [0 ~] + =/ next (force-wide t.render) + :- :(add (lent text.i.render) 2 length.next) + ?~(text.next text.i.render :(weld text.i.render " " text.next)) + -- + == + -- +:: +:: Convenience function to build a `plumfmt` for a rune with a fixed +:: number of parameters. +:: +++ fixed + |= rune=@ta + ^- plumfmt + [wide=`[' ' `[(cat 3 +< '(') ')']] tall=`[+< ~]] +:: +:: Same as `fixed` but only outputs in `tall` mode. +:: +++ tall-fixed + |= rune=cord + ^- (unit [cord (unit [cord cord])]) + `[rune ~] +:: +:: Convenience function to build a the `tall` part of a `plumfmt` for +:: a running-style rune (one that takes a variable number of parameters +:: and has a terminator). +:: +++ tall-running + |= [rune=cord sigil=cord term=cord] + ^- (unit [cord (unit [cord cord])]) + `[rune `[sigil term]] +:: +:: Convenience function for rendering a rune into a plum. This takes +:: a rune, an optional tall-form terminator, optionally a short-form (if +:: you don't supply a short-form, it'll just construct the standard +:: wide-form (e.g. "?~(x x ~)") for you, and a list of sub-plums. +:: +++ rune + |= $: rune=cord + term=(unit cord) + short=(unit [cord cord cord]) + kids=(list plum) + == + ^. plum + |^ :- %sbrk + :+ %tree + :- (rune-wide-form rune short) + ?~ term (tall-fixed rune) + (tall-running rune '' u.term) + kids + :: + :: If you just give this a rune, it'll build the standard wide-form. + :: Otherwise, it'll just use the one that you gave it. + :: + ++ rune-wide-form + |= [rune=cord short=(unit [fst=cord mid=cord lst=cord])] + ^- (unit (pair cord (unit [cord cord]))) + =* fst (cat 3 rune '(') + =* std `[' ' `[fst ')']] + ?~ short std + `[mid.u.short `[fst.u.short lst.u.short]] + -- +:: +:: Just a helper function for constructing a wide-form %tree plum. +:: +++ simple-wide + |= [init=cord sep=cord end=cord kids=(list plum)] + ^- plum + =/ fmt=plumfmt [wide=[~ sep [~ init end]] tall=~] + [%tree fmt kids] +:: +:: Convenience function that builds a plum for a subexpression. The +:: `%sbrk` tells the pretty-printer that this is a valid place to +:: switch from tall mode to wide mode. +:: +++ subtree + |= [p=plumfmt q=(list plum)] + ^- plum + [%sbrk [%tree p q]] +:: +:: Convenience for generating plums that look like s-expressions. Useful +:: for quickly getting decent-looking debug output. +:: +++ sexp + |= [sym=cord kids=(list plum)] + ^- plum + =/ head=cord (cat 3 '(' sym) + =/ headspc=cord (cat 3 head ' ') + =/ symcol=cord (cat 3 sym ':') + =/ fmt=plumfmt [[~ ' ' [~ headspc ')']] [~ symcol [~ '' '']]] + ?~ kids (cat 3 '(' (cat 3 sym ')')) + [%sbrk [%tree fmt kids]] +-- diff --git a/pkg/arvo/lib/pprint.hoon b/pkg/arvo/lib/pprint.hoon index 1cf1d16ce6..4535b772e4 100644 --- a/pkg/arvo/lib/pprint.hoon +++ b/pkg/arvo/lib/pprint.hoon @@ -1,4 +1,6 @@ -/+ libxray=xray +/- *plum +/+ *plume, + libxray=xray :: :: This code pretty-prints a variety of things using the `xray` and :: `plum` libraries: diff --git a/pkg/arvo/lib/xray.hoon b/pkg/arvo/lib/xray.hoon index b9d340255f..40d25e32ea 100644 --- a/pkg/arvo/lib/xray.hoon +++ b/pkg/arvo/lib/xray.hoon @@ -1,3 +1,4 @@ +/- *plum :: :: # Type Analysis :: diff --git a/pkg/arvo/sur/plum.hoon b/pkg/arvo/sur/plum.hoon new file mode 100644 index 0000000000..47d18c85d0 --- /dev/null +++ b/pkg/arvo/sur/plum.hoon @@ -0,0 +1,51 @@ +^? |% +:: +:: A `plum` is the intermediate representation for the pretty-printer. It +:: encodes hoon-shaped data with the least amount of structured needed +:: for formating. +:: +:: A `plum` is either a +:: +:: - `cord`: A simple cord +:: - `[%para *]`: A wrappable paragraph. +:: - `[%tree *]`: A formatted plum tree +:: - `[%sbrk *]`: An indication of a nested subexpression. +:: +:: The formatter will use the tall mode unless: +:: +:: - A plum has only a `wide` style. +:: - The plum is in `%sbrk` form and its subplum (`kid`), when +:: formatted in wide mode, can fit on a single line. +:: ++$ plum + $@ cord + $% [%para prefix=tile lines=(list @t)] + [%tree fmt=plumfmt kids=(list plum)] + [%sbrk kid=plum] + == +:: +:: A `plumfmt` is a description of how to render a `plum`. A `plumfmt` +:: must include a `wide`, a `tall`, or both. +:: +:: A `wide` is a description of how to render a plum in a single +:: line. The nested (`kids`) sub-plums will be interleaved with `delimit` +:: strings, and, if `enclose` is set, then the output will be enclosed +:: with `p.u.enclose` abnd `q.u.enclose`. +:: +:: For example, to build a plumfmt for string literals, we could write: +:: +:: [wide=[~ '' [~ '"' '"']] tall=~] +:: +:: A `tall` is a description of how to render a plum across multiple +:: lines. The output will be prefixed by `intro`, suffixed by +:: `final.u.indef`, and each subplum prefixed by `sigil.u.indef`. +:: +:: For example, to build a plumfmt for cores, we could write: +:: +:: [wide=~ tall=`['' `['++' '--']]] +:: ++$ plumfmt + $: wide=(unit [delimit=tile enclose=(unit (pair tile tile))]) + tall=(unit [intro=tile indef=(unit [sigil=tile final=tile])]) + == +-- diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 574c59c156..be48243378 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -1973,56 +1973,6 @@ :: cord +$ tint ?($r $g $b $c $m $y $k $w $~) :: text color -:: -:: A `plum` is the intermediate representation for the pretty-printer. It -:: encodes hoon-shaped data with the least amount of structured needed -:: for formating. -:: -:: A `plum` is either a -:: -:: - `cord`: A simple cord -:: - `[%para *]`: A wrappable paragraph. -:: - `[%tree *]`: A formatted plum tree -:: - `[%sbrk *]`: An indication of a nested subexpression. -:: -:: The formatter will use the tall mode unless: -:: -:: - A plum has only a `wide` style. -:: - The plum is in `%sbrk` form and its subplum (`kid`), when -:: formatted in wide mode, can fit on a single line. -:: -+$ plum - $@ cord - $% [%para prefix=tile lines=(list @t)] - [%tree fmt=plumfmt kids=(list plum)] - [%sbrk kid=plum] - == -:: -:: A `plumfmt` is a description of how to render a `plum`. A `plumfmt` -:: must include a `wide`, a `tall`, or both. -:: -:: A `wide` is a description of how to render a plum in a single -:: line. The nested (`kids`) sub-plums will be interleaved with `delimit` -:: strings, and, if `enclose` is set, then the output will be enclosed -:: with `p.u.enclose` abnd `q.u.enclose`. -:: -:: For example, to build a plumfmt for string literals, we could write: -:: -:: [wide=[~ '' [~ '"' '"']] tall=~] -:: -:: A `tall` is a description of how to render a plum across multiple -:: lines. The output will be prefixed by `intro`, suffixed by -:: `final.u.indef`, and each subplum prefixed by `sigil.u.indef`. -:: -:: For example, to build a plumfmt for cores, we could write: -:: -:: [wide=~ tall=`['' `['++' '--']]] -:: -+$ plumfmt - $: wide=(unit [delimit=tile enclose=(unit (pair tile tile))]) - tall=(unit [intro=tile indef=(unit [sigil=tile final=tile])]) - == -:: ++ tang (list tank) :: bottom-first error ++ tank $~ [%leaf ~] :: $% {$leaf p/tape} :: printing formats @@ -4512,423 +4462,6 @@ |= {{tab/@ edg/@} tac/tank} ^- wall (~(win re tac) tab edg) :: -:: This library includes `plume`, the actual pretty printing logic, -:: and a handful of utilities for constructing plums. -:: -:: Generally, you'll just use `plume` like this: -:: -:: ~(plume tall plum) :: Pretty print `plum` in tall mode. -:: ~(plume flat plum) :: Pretty print `plum` in wide mode. -:: -:: There is probably no reason to look at the utility routines unless -:: you are writing something to generate `plum`s. -:: -:: This is the pretty-printer. Use the `flat` arm to render a plum -:: into a single line and use the `tall` arm to get a nice multi-line -:: rendering that switches to wide mode if there's enough space. -:: -:: For details about how this works and what exactly it does in various -:: cases, take a look at the docs for `plum`, `plumfmt`, and at the -:: docs on the arms of this door. -:: -++ plume - |_ =plum - :: - :: An line, indented by `indent` spaces. - :: - +$ line [indent=@ud text=tape] - :: - :: An sequence of indented lines. - :: - +$ block (list line) - :: - :: +flat: print as a single line - :: - ++ flat - ^- wain - text:linear - :: - :: +tall: print as multiple lines - :: - ++ tall - ^- wain - %+ turn window - |= line - (crip (runt [indent ' '] text)) - :: - :: +adjust: adjust lines to right - :: - ++ adjust - |= [tab=@ud =block] ^- ^block - (turn block |=([@ud tape] [(add tab +<-) +<+])) - :: - :: Prepend `n` spaces to a tape. - :: - ++ prepend-spaces - |= [n=@ t=tape] ^- tape - (runt [n ' '] t) - :: - :: +window: print as list of tabbed lines - :: - ++ window - ^- block - ~+ :: for random access - ?@ plum [0 (trip plum)]~ :: trivial text - ?- -.plum - :: - :: %para: Line-wrappable paragraph. This is a stub; it should - :: wrap text to 40 characters. - :: - %para - [0 +:linear]~ - :: - :: %sbrk: nested subexpression - :: - :: This is an opportunity to switch to wide mode. First, try - :: rendered in wide mode. If that's possible and the result - :: isn't too big, use that. Otherwise recurse into the subplum - :: without switching to wide mode. - :: - %sbrk - =/ sub kid.plum - ?+ sub - window(plum sub) - [%tree *] - =/ wideresult - ?~(wide.fmt.sub ~ [~ u=linear]) - ?: ?&(?=(^ wideresult) (lte length.u.wideresult 40)) - [0 text.u.wideresult]~ - window(plum sub) - == - :: - :: %tree: Try to render a text tree in tall mode. - :: - :: We want to render this in tall mode. First, verify that there - :: the plum has a tall render (if not, fall back to `linear` - :: formatting), then render all the subplums, and then render - :: them in one of three ways: - :: - :: - If the `plumfmt` contains an `indef` and that indef has - :: no prefix, then this is a variable-arity rune with a - :: terminator: Use vertical formatting. - :: - :: - If the `plumfmt` contains an `indef` and that indef DOES have - :: a prefix, then this is something that looks like a core: Use - :: `core-like` formatting. - :: - :: - Otherwise, this is a rune with a fixed number of arguments - :: Render the subplums using backstep indentation. - :: - :: There's also a special case where something has exactly one sub-plum. - :: where something has exactly one sub-block. For example, we - :: want this output: - :: - :: |- - :: foo - :: - %tree - ?~ tall.fmt.plum [0 text:linear]~ - =/ prelude (trip intro.u.tall.fmt.plum) - |^ =/ blocks (turn kids.plum |=(=^plum window(plum plum))) - =/ prelude (trip intro.u.tall.fmt.plum) - ?~ indef.u.tall.fmt.plum - ?: =(1 (lent blocks)) - [[0 prelude] (zing blocks)] - (backstep prelude blocks) - =/ prefix (trip sigil.u.indef.u.tall.fmt.plum) - =/ finale (trip final.u.indef.u.tall.fmt.plum) - ?~ blocks %+ weld - ?~(prelude ~ [0 prelude]~) - ?~(finale ~ [0 finale]~) - ?~ prefix (running prelude blocks finale) - (core-like prelude prefix blocks finale) - -- - == - :: - :: Render a plum in tall-mode using backstep indentation. Here, - :: we are rendering things that look something like this: - :: - :: :+ foo - :: bar - :: baz - :: - ++ backstep - |= [prelude=tape blocks=(list block)] - ^- block - %- zing - =/ nkids (lent blocks) - =/ idx 1 - |- ^- (list block) - ?~ blocks ~ - :_ $(blocks t.blocks, idx +(idx)) - ^- block - =/ indent (mul 2 (sub nkids idx)) - ?. =(1 idx) (adjust indent i.blocks) - (rune-inline-with-block prelude indent i.blocks) - :: - :: To make things look a bit nicer, we want to put the first - :: sub-block on the same line as the rune. We want this: - :: - :: :- foo - :: baz - :: - :: Instead of this: - :: - :: :- - :: foo - :: baz - :: - :: This handles the "foo" case. - :: - ++ rune-inline-with-block - |= [rune=tape indent=@ blk=block] - ^- block - =. indent (max indent (add 2 (lent rune))) - =. blk (adjust indent blk) - ?~ rune blk - ?~ blk [0 rune]~ - :_ t.blk - :- 0 - %+ weld rune - =/ spaces-btwn (sub indent.i.blk (lent rune)) - (prepend-spaces spaces-btwn text.i.blk) - :: - :: Render a tall hoon with running indentation. Here, we are - :: rendering things that look sopmething like: - :: - :: :~ foo - :: bar - :: baz - :: == - :: - :: So, there's basically three cases here: Either the prelude - :: is a rune, the prelude is empty, or prelude is some other - :: random-ass thing. - :: - :: - If there is no prelude, then just combine all of the - :: sub-blocks together unaltered. - :: - If it's a rune (two-characters wide), then combine the - :: rune and the first line into one line (separated by two - :: spaces) and indent the rest of the lines by four spaces. - :: - If the rune is some other random-ass thing (has a length - :: that isn't 0 or 2), then render the prelude alone on the - :: first line and then combine the sub-blocks together, - :: all indented by another two spaces. - :: - :: Regardless, if there's a finale, stick it on the end without - :: any indentation. - :: - ++ running - |= [prelude=tape blocks=(list block) finale=tape] - ^- block - =/ result=block (zing blocks) - =. result - ?+ (lent prelude) - [[0 prelude] (adjust 2 result)] :: unusual prelude - %0 :: empty prelude - result - %2 :: rune prelude - (rune-inline-with-block prelude 4 result) - == - ?~ finale result - (snoc result [0 finale]) - :: - :: This renders sub-blocks where each sub-block needs to be - :: prefixed by some tape. For example: - :: - :: |% - :: ++ foo - :: bar - :: ++ baz - :: qux - :: -- - :: - ++ core-like - |= [prelude=tape prefix=tape blocks=(list block) finale=tape] - ^- block - =/ clear (add 2 (lent prefix)) - =/ result - ^- block - %- zing - ^- (list block) - %+ turn blocks - |= blk=block - ^- block - ^+ +< - =* tab ?~(blk 0 (sub clear (min clear indent.i.blk))) - =. blk (adjust tab blk) - ?~ blk ~ - :_ t.blk - :- 0 - %+ weld prefix - (runt [(sub indent.i.blk (lent prefix)) ' '] text.i.blk) - =. result - ?~ finale result - (snoc result [0 finale]) - ?~ prelude result - [[0 prelude] result] - :: - :: +linear: Render a plum onto a single line, even if it only has a - :: wide form. - :: - ++ linear - ^- [length=@ud text=tape] - ~+ :: ~+ for random access - ?@ plum [(met 3 plum) (trip plum)] :: Just a cord. - ?- -.plum - :: - :: This is already in wide mode, so %sbrk nodes don't matter here. - :: - %sbrk - linear(plum kid.plum) - :: - :: %para: To write a wrappable text paragraph to a single line, - :: we just combine all the lines into one, interspersing single - :: spaces chars. - :: - %para - |- ^- [length=@ud text=tape] - ?~ lines.plum [0 ~] - =/ next $(lines.plum t.lines.plum) - =/ this [length=(met 3 i.lines.plum) text=(trip i.lines.plum)] - :- (add +(length.this) length.next) - (weld text.this `tape`[' ' text.next]) - :: - :: Render a text tree to a single line. - :: - %tree - |^ ^- [length=@ud text=tape] - ?~ wide.fmt.plum (force-wide window) - =/ body (render-body delimit.u.wide.fmt.plum kids.plum) - ?~ enclose.u.wide.fmt.plum body - (wrap-with-enclose u.enclose.u.wide.fmt.plum body) - :: - :: Given a list of subplums and a delimiter, render all the - :: subplums onto a single line, and combine them into a single - :: string by interspersing the delimiter. - :: - ++ render-body - |= [delimit=cord kids=(list ^plum)] - =/ stop (trip delimit) - |- ^- [length=@ud text=tape] - ?~ kids [0 ~] - =/ next $(kids t.kids) - =/ this linear(plum i.kids) - ?~ text.next this - :- :(add length.this (lent stop) length.next) - :(weld text.this stop text.next) - :: - :: Wrap a wide-form-rendered result with the `enclose` cords - :: from its `plumefmt`. - :: - ++ wrap-with-enclose - |= [clamps=(pair cord cord) body=[length=@ text=tape]] - ^- [length=@ud text=tape] - :: - =/ close [(trip -.clamps) (trip +.clamps)] - :- :(add length.body (lent -.close) (lent +.close)) - :(weld -.close text.body +.close) - :: - :: Given the result of rendering a plum in tall form, combine - :: all the lines into one by separating each by two spaces. - :: - ++ force-wide - |= render=(list [@ud text=tape]) - ^- [length=@ud text=tape] - :: - ?~ render [0 ~] - =/ next (force-wide t.render) - :- :(add (lent text.i.render) 2 length.next) - ?~(text.next text.i.render :(weld text.i.render " " text.next)) - -- - == - -- -:: -:: Convenience function to build a `plumfmt` for a rune with a fixed -:: number of parameters. -:: -++ fixed - |= rune=@ta - ^- plumfmt - [wide=`[' ' `[(cat 3 +< '(') ')']] tall=`[+< ~]] -:: -:: Same as `fixed` but only outputs in `tall` mode. -:: -++ tall-fixed - |= rune=cord - ^- (unit [cord (unit [cord cord])]) - `[rune ~] -:: -:: Convenience function to build a the `tall` part of a `plumfmt` for -:: a running-style rune (one that takes a variable number of parameters -:: and has a terminator). -:: -++ tall-running - |= [rune=cord sigil=cord term=cord] - ^- (unit [cord (unit [cord cord])]) - `[rune `[sigil term]] -:: -:: Convenience function for rendering a rune into a plum. This takes -:: a rune, an optional tall-form terminator, optionally a short-form (if -:: you don't supply a short-form, it'll just construct the standard -:: wide-form (e.g. "?~(x x ~)") for you, and a list of sub-plums. -:: -++ rune - |= $: rune=cord - term=(unit cord) - short=(unit [cord cord cord]) - kids=(list plum) - == - ^. plum - |^ :- %sbrk - :+ %tree - :- (rune-wide-form rune short) - ?~ term (tall-fixed rune) - (tall-running rune '' u.term) - kids - :: - :: If you just give this a rune, it'll build the standard wide-form. - :: Otherwise, it'll just use the one that you gave it. - :: - ++ rune-wide-form - |= [rune=cord short=(unit [fst=cord mid=cord lst=cord])] - ^- (unit (pair cord (unit [cord cord]))) - =* fst (cat 3 rune '(') - =* std `[' ' `[fst ')']] - ?~ short std - `[mid.u.short `[fst.u.short lst.u.short]] - -- -:: -:: Just a helper function for constructing a wide-form %tree plum. -:: -++ simple-wide - |= [init=cord sep=cord end=cord kids=(list plum)] - ^- plum - =/ fmt=plumfmt [wide=[~ sep [~ init end]] tall=~] - [%tree fmt kids] -:: -:: Convenience function that builds a plum for a subexpression. The -:: `%sbrk` tells the pretty-printer that this is a valid place to -:: switch from tall mode to wide mode. -:: -++ subtree - |= [p=plumfmt q=(list plum)] - ^- plum - [%sbrk [%tree p q]] -:: -:: Convenience for generating plums that look like s-expressions. Useful -:: for quickly getting decent-looking debug output. -:: -++ sexp - |= [sym=cord kids=(list plum)] - ^- plum - =/ head=cord (cat 3 '(' sym) - =/ headspc=cord (cat 3 head ' ') - =/ symcol=cord (cat 3 sym ':') - =/ fmt=plumfmt [[~ ' ' [~ headspc ')']] [~ symcol [~ '' '']]] - ?~ kids (cat 3 '(' (cat 3 sym ')')) - [%sbrk [%tree fmt kids]] -:: :: |re: tank renderer :: ++ re From b1e3b0def2ef6e57b491c9b4804396aabde41c74 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 12 May 2020 15:33:41 -0700 Subject: [PATCH 666/933] hoon: moves $xray into userspace --- nix/pkgs/pill/solid.sh | 1 + pkg/arvo/lib/pprint.hoon | 2 +- pkg/arvo/lib/xray.hoon | 2 +- pkg/arvo/sur/xray.hoon | 176 +++++++++++++++++++++++++++++++++++++++ pkg/arvo/sys/hoon.hoon | 174 -------------------------------------- 5 files changed, 179 insertions(+), 176 deletions(-) create mode 100644 pkg/arvo/sur/xray.hoon diff --git a/nix/pkgs/pill/solid.sh b/nix/pkgs/pill/solid.sh index 591a93e9ac..e46aec7ac7 100644 --- a/nix/pkgs/pill/solid.sh +++ b/nix/pkgs/pill/solid.sh @@ -42,6 +42,7 @@ cp $ARVO/mar/lens/* ./pier/home/mar/lens/ cp $ARVO/sur/lens.hoon ./pier/home/sur/ cp $ARVO/sur/plum.hoon ./pier/home/sur/ cp $ARVO/sur/sole.hoon ./pier/home/sur/ +cp $ARVO/sur/xray.hoon ./pier/home/sur/ # Update +solid and its dependencies cp $ARVO/lib/pill.hoon ./pier/home/lib/ diff --git a/pkg/arvo/lib/pprint.hoon b/pkg/arvo/lib/pprint.hoon index 4535b772e4..7ea4264858 100644 --- a/pkg/arvo/lib/pprint.hoon +++ b/pkg/arvo/lib/pprint.hoon @@ -1,4 +1,4 @@ -/- *plum +/- *plum, *xray /+ *plume, libxray=xray :: diff --git a/pkg/arvo/lib/xray.hoon b/pkg/arvo/lib/xray.hoon index 40d25e32ea..bc67b0e05a 100644 --- a/pkg/arvo/lib/xray.hoon +++ b/pkg/arvo/lib/xray.hoon @@ -1,4 +1,4 @@ -/- *plum +/- *plum, *xray :: :: # Type Analysis :: diff --git a/pkg/arvo/sur/xray.hoon b/pkg/arvo/sur/xray.hoon new file mode 100644 index 0000000000..9faaad0196 --- /dev/null +++ b/pkg/arvo/sur/xray.hoon @@ -0,0 +1,176 @@ + +:: +:: These are the public types for the `xray` library. Analysing a type +:: yields an `ximage`, and everything else here is just some structure +:: within that. +:: +:: `ximage`s can be printed as specs (hoon syntax for types), and can +:: be used to pretty-print typed data. +:: +^? |% +:: +:: An `xtable` is a graph of types referenced by the top-level type, +:: and the `root` `key` points to the node which corresponds to the +:: type under analysis. +:: ++$ ximage [root=xkey =xtable] +:: +:: A `xkey` is just an identifier for a node in the xray graph. +:: ++$ xkey @ +:: +:: An `xtable` is the xray graph itself. It contains one node for for +:: the type that was analyzed and one node for every type referenced +:: within that type. +:: +:: The `next` field is the the next available xkey (used when inserting +:: new xrays), `xrays` maps keys to graph nodes and `type-map` gives +:: the xkey corresponding to a type. +:: +:: The `type-map` is basically just the reverse of the `xrays` map. It +:: doesn't contain any new information, but is needed for performance +:: reasons. +:: ++$ xtable [next=xkey xrays=(map xkey xray) =type=(map type xkey)] +:: +:: An `xray` is a node in the `ximage` graph. It contains everything +:: we know about a certain `type`. `key` is its identifier in the graph, +:: `type` is the type that it's an xray of, and `xdat` is the basic +:: information we derived about the type. The basic references to other +:: nodes are inside the `xdat` structure, though some of the other +:: fields may contain references as well. +:: +:: - `xshape` is some more information about the xshape of data within +:: a cell. +:: - `xrole` expands on `xshape`, adding further information about the +:: xrole that a node has within a fork. +:: - `pats` is used for printing data: we want to know if this type +:: can be printed as a list, as json, as a tape literal, etc. +:: - `recipes` contains information about how a type was +:: constructed. It's used to get much nicer output when printing types. +:: - `studs` contains "standards names". I actually don't know what this is. +:: - `helps` contains all the documentation about a type. +:: - `loop` indicates whether or not a node references itself. The list +:: type is cyclical, for example. This is used when printing an +:: `ximage`. +:: ++$ xray + $: =xkey + =type + xdat=(unit xdat) + xrole=(unit xrole) + pats=(unit xpat) + studs=(set stud) + recipes=(set recipe) + helps=(set help) + xshape=(unit xshape) + loop=(unit ?) + == +:: +:: - `%void` -- impossible to create. +:: - `%noun` -- could be any noun. +:: - `%atom` -- An atom of some aura, possibly constant +:: - `%cell` -- A cell with a head and a tail. +:: - `%core` -- A core, its garb, its context type, and the types of +:: each of its arms. +:: - `%face` -- A face on another type. +:: - `%fork` -- Could be one or more other types. +:: - `%pntr` -- This is an internal hack, it should never survive +:: analysis; ignore. +:: ++$ xdat + $@ ?(%noun %void) + $% [%atom =aura constant=(unit @)] + [%cell head=xkey tail=xkey] + [%core =garb xray=xkey batt=xbat] + [%face face=$@(term tune) xray=xkey] + [%fork =(set xkey)] + [%pntr xray=xkey] + == +:: +:: The basic xshape of a type: +:: +:: - `%void` -- impossible to create. +:: - `%noun` -- could be any noun. +:: - `%atom` -- always some type of atom; never a cell +:: - `%cell` -- always some type of cell; never an atom. +:: - `%junc` -- is a fork of a cell type and an atom type. +:: ++$ xshape ?(%void %noun %atom %cell %junc) +:: +:: A `xrole` is the of a type, including a more refined understanding +:: of what xrole it plays within a fork. +:: +:: Nodes referenced within a `xrole` often do not actually exist in the +:: original type, since we need to reorganize forks in order to make +:: them more coherent. +:: +:: - `%void` -- impossible to create. +:: - `%noun` -- could be any noun. +:: - `%atom` -- always some type of atom; never a cell +:: - `%constant` -- a cell type whose head is a constant atom. +:: - `%tall` -- a cell type whose head is an atom. +:: - `%wide` -- a cell type whose head is also a cell +:: - `%instance` -- a cell type whose head is a constant atom. +:: - `%option` -- a union of types which are all constant atoms. +:: - `%union` -- a union of types which are all instances (cells whose +:: head is a constant atom). +:: - `%junction` -- a union of an atom type and a cell type. +:: - `%conjunction` -- a union of two cell types, one of them %wide +:: and the other %tall. +:: - `%misjunction` -- any other union type. There's no efficient way +:: to tell which branch to take when analyzing a fork which is a +:: %misjunction, and the type is probably improperly constructed. +:: ++$ xrole + $@ $? %void %noun %atom %tall %wide == + $% [%constant =atom] + [%instance =atom] + [%option =(map atom xkey)] + [%union =(map atom xkey)] + [%junction flat=xkey deep=xkey] + [%conjunction wide=xkey tall=xkey] + [%misjunction one=xkey two=xkey] + == +:: +:: This is just a utility type, it encodes the "battery" structure +:: within a core. +:: +:: It's a map from chapter names to the documentation and arms within +:: that chapter. +:: ++$ xbat (map term (pair what (map term xkey))) +:: +:: A recipe tells us how a type was constructed. +:: +:: - `%direct` is a simple type like `term`, or `xray`. +:: - `%synthetic` is a constructed type, like `(list @)`. +:: ++$ recipe + $% [%direct =term] + [%synthetic =term =(list xkey)] + == +:: +:: A `xpat` is high-level information about the shape of a type. This +:: is used for printing data. +:: +:: This is fairly heuristic. [%a %b %c ~] is recognized as a `path`, +:: `[3 ~[4 5 6]]` is recognized as a list, etc. +:: +:: Most of the xpats have names that make their purpose obvious: +:: for example, the %tape xpat means that data of type type can be +:: printed as if it had the `tape` type. However, `%gear` and `%gate` +:: might not be entirely obvious. +:: +:: - The %gear xpat is any core with a cell subject. +:: - The %gate xpat is a core that looks like a gate. +:: ++$ xpat + $@ ?(%hoon %manx %json %nock %path %plum %skin %spec %tape %tour %type %vase) + $% [%gate sample=xkey product=xkey] + [%gear sample=xkey context=xkey batt=xbat] + [%list item=xkey] + [%tree item=xkey] + [%unit item=xkey] + == +-- diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index be48243378..2ee202d4a4 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -11425,180 +11425,6 @@ ~| %sell (~(deal us p.vax) q.vax) :: -:: These are the public types for the `xray` library. Analysing a type -:: yields an `ximage`, and everything else here is just some structure -:: within that. -:: -:: `ximage`s can be printed as specs (hoon syntax for types), and can -:: be used to pretty-print typed data. -:: -:: |% -:: -:: An `xtable` is a graph of types referenced by the top-level type, -:: and the `root` `key` points to the node which corresponds to the -:: type under analysis. -:: -+$ ximage [root=xkey =xtable] -:: -:: A `xkey` is just an identifier for a node in the xray graph. -:: -+$ xkey @ -:: -:: An `xtable` is the xray graph itself. It contains one node for for -:: the type that was analyzed and one node for every type referenced -:: within that type. -:: -:: The `next` field is the the next available xkey (used when inserting -:: new xrays), `xrays` maps keys to graph nodes and `type-map` gives -:: the xkey corresponding to a type. -:: -:: The `type-map` is basically just the reverse of the `xrays` map. It -:: doesn't contain any new information, but is needed for performance -:: reasons. -:: -+$ xtable [next=xkey xrays=(map xkey xray) =type=(map type xkey)] -:: -:: An `xray` is a node in the `ximage` graph. It contains everything -:: we know about a certain `type`. `key` is its identifier in the graph, -:: `type` is the type that it's an xray of, and `xdat` is the basic -:: information we derived about the type. The basic references to other -:: nodes are inside the `xdat` structure, though some of the other -:: fields may contain references as well. -:: -:: - `xshape` is some more information about the xshape of data within -:: a cell. -:: - `xrole` expands on `xshape`, adding further information about the -:: xrole that a node has within a fork. -:: - `pats` is used for printing data: we want to know if this type -:: can be printed as a list, as json, as a tape literal, etc. -:: - `recipes` contains information about how a type was -:: constructed. It's used to get much nicer output when printing types. -:: - `studs` contains "standards names". I actually don't know what this is. -:: - `helps` contains all the documentation about a type. -:: - `loop` indicates whether or not a node references itself. The list -:: type is cyclical, for example. This is used when printing an -:: `ximage`. -:: -+$ xray - $: =xkey - =type - xdat=(unit xdat) - xrole=(unit xrole) - pats=(unit xpat) - studs=(set stud) - recipes=(set recipe) - helps=(set help) - xshape=(unit xshape) - loop=(unit ?) - == -:: -:: - `%void` -- impossible to create. -:: - `%noun` -- could be any noun. -:: - `%atom` -- An atom of some aura, possibly constant -:: - `%cell` -- A cell with a head and a tail. -:: - `%core` -- A core, its garb, its context type, and the types of -:: each of its arms. -:: - `%face` -- A face on another type. -:: - `%fork` -- Could be one or more other types. -:: - `%pntr` -- This is an internal hack, it should never survive -:: analysis; ignore. -:: -+$ xdat - $@ ?(%noun %void) - $% [%atom =aura constant=(unit @)] - [%cell head=xkey tail=xkey] - [%core =garb xray=xkey batt=xbat] - [%face face=$@(term tune) xray=xkey] - [%fork =(set xkey)] - [%pntr xray=xkey] - == -:: -:: The basic xshape of a type: -:: -:: - `%void` -- impossible to create. -:: - `%noun` -- could be any noun. -:: - `%atom` -- always some type of atom; never a cell -:: - `%cell` -- always some type of cell; never an atom. -:: - `%junc` -- is a fork of a cell type and an atom type. -:: -+$ xshape ?(%void %noun %atom %cell %junc) -:: -:: A `xrole` is the of a type, including a more refined understanding -:: of what xrole it plays within a fork. -:: -:: Nodes referenced within a `xrole` often do not actually exist in the -:: original type, since we need to reorganize forks in order to make -:: them more coherent. -:: -:: - `%void` -- impossible to create. -:: - `%noun` -- could be any noun. -:: - `%atom` -- always some type of atom; never a cell -:: - `%constant` -- a cell type whose head is a constant atom. -:: - `%tall` -- a cell type whose head is an atom. -:: - `%wide` -- a cell type whose head is also a cell -:: - `%instance` -- a cell type whose head is a constant atom. -:: - `%option` -- a union of types which are all constant atoms. -:: - `%union` -- a union of types which are all instances (cells whose -:: head is a constant atom). -:: - `%junction` -- a union of an atom type and a cell type. -:: - `%conjunction` -- a union of two cell types, one of them %wide -:: and the other %tall. -:: - `%misjunction` -- any other union type. There's no efficient way -:: to tell which branch to take when analyzing a fork which is a -:: %misjunction, and the type is probably improperly constructed. -:: -+$ xrole - $@ $? %void %noun %atom %tall %wide == - $% [%constant =atom] - [%instance =atom] - [%option =(map atom xkey)] - [%union =(map atom xkey)] - [%junction flat=xkey deep=xkey] - [%conjunction wide=xkey tall=xkey] - [%misjunction one=xkey two=xkey] - == -:: -:: This is just a utility type, it encodes the "battery" structure -:: within a core. -:: -:: It's a map from chapter names to the documentation and arms within -:: that chapter. -:: -+$ xbat (map term (pair what (map term xkey))) -:: -:: A recipe tells us how a type was constructed. -:: -:: - `%direct` is a simple type like `term`, or `xray`. -:: - `%synthetic` is a constructed type, like `(list @)`. -:: -+$ recipe - $% [%direct =term] - [%synthetic =term =(list xkey)] - == -:: -:: A `xpat` is high-level information about the shape of a type. This -:: is used for printing data. -:: -:: This is fairly heuristic. [%a %b %c ~] is recognized as a `path`, -:: `[3 ~[4 5 6]]` is recognized as a list, etc. -:: -:: Most of the xpats have names that make their purpose obvious: -:: for example, the %tape xpat means that data of type type can be -:: printed as if it had the `tape` type. However, `%gear` and `%gate` -:: might not be entirely obvious. -:: -:: - The %gear xpat is any core with a cell subject. -:: - The %gate xpat is a core that looks like a gate. -:: -+$ xpat - $@ ?(%hoon %manx %json %nock %path %plum %skin %spec %tape %tour %type %vase) - $% [%gate sample=xkey product=xkey] - [%gear sample=xkey context=xkey batt=xbat] - [%list item=xkey] - [%tree item=xkey] - [%unit item=xkey] - == -:: :: Left-fold over a list. :: :: This is `roll`, but with explicit type parameters. From fb66dc10b50e366de348c82e26d7994f6b23df4d Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 12 May 2020 15:55:41 -0700 Subject: [PATCH 667/933] hoon: moves xray traversals to userspace --- pkg/arvo/lib/xray.hoon | 73 ++++++++++++++++++++++++++++++++++++++++++ pkg/arvo/sys/hoon.hoon | 73 ------------------------------------------ 2 files changed, 73 insertions(+), 73 deletions(-) diff --git a/pkg/arvo/lib/xray.hoon b/pkg/arvo/lib/xray.hoon index bc67b0e05a..8bbafecc15 100644 --- a/pkg/arvo/lib/xray.hoon +++ b/pkg/arvo/lib/xray.hoon @@ -1865,4 +1865,77 @@ (~(uni by q.q.i.chapters) $(chapters t.chapters)) :: -- +:: +:: Left-fold over a list. +:: +:: This is `roll`, but with explicit type parameters. +:: +++ fold + |* [state=mold elem=mold] + |= [[st=state xs=(list elem)] f=$-([state elem] state)] + ^- state + |- + ?~ xs st + $(xs t.xs, st (f st i.xs)) +:: +:: This is basically a `mapM` over a list using the State monad. +:: +:: Another way to think about this is that it is the same as `turn`, +:: except that a state variable `st` is threaded through the +:: execution. The list is processed from left to right. +:: +:: This is `spin`, but with explicit type parameters. +:: +++ traverse + |* [state=mold in=mold out=mold] + |= [[st=state xs=(list in)] f=$-([state in] [out state])] + ^- [(list out) state] + ?~ xs [~ st] + =^ r st (f st i.xs) + =^ rs st $(xs t.xs, st st) + [[r rs] st] +:: +:: `traverse` over a set. +:: +++ traverse-set + |* [state=mold input=mold out=mold] + |= [[st=state xs=(set input)] f=$-([state input] [out state])] + ^- [(set out) state] + :: + =^ elems st ((traverse state input out) [st ~(tap in xs)] f) + :_ st (~(gas in *(set out)) elems) +:: +:: `traverse` over a map, also passing the key to the folding function. +:: +++ traverse-map + |* [state=mold key=mold in=mold out=mold] + |= [[st=state dict=(map key in)] f=$-([state key in] [out state])] + ^- [(map key out) state] + :: + =^ pairs=(list (pair key out)) st + %+ (traverse state (pair key in) (pair key out)) + [st ~(tap by dict)] + |= [st=state k=key x=in] + ^- [(pair key out) state] + =^ v st (f st k x) + [[k v] st] + :: + :_ st + (~(gas by *(map key out)) pairs) +:: +:: Given a map, return its inverse: For each value, what are the set +:: of associated keys? +:: +++ reverse-map + |* [key=mold val=mold] + |= tbl=(map key val) + =/ init *(map val (set key)) + ^- _init + %+ (fold _init (pair key val)) + [init ~(tap by tbl)] + |= [acc=_init k=key v=val] + ^- _init + =/ mb-keys (~(get by acc) v) + =/ keys=(set key) ?~(mb-keys ~ u.mb-keys) + (~(put by acc) v (~(put in keys) k)) -- diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 2ee202d4a4..8314338b2b 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -11425,79 +11425,6 @@ ~| %sell (~(deal us p.vax) q.vax) :: -:: Left-fold over a list. -:: -:: This is `roll`, but with explicit type parameters. -:: -++ fold - |* [state=mold elem=mold] - |= [[st=state xs=(list elem)] f=$-([state elem] state)] - ^- state - |- - ?~ xs st - $(xs t.xs, st (f st i.xs)) -:: -:: This is basically a `mapM` over a list using the State monad. -:: -:: Another way to think about this is that it is the same as `turn`, -:: except that a state variable `st` is threaded through the -:: execution. The list is processed from left to right. -:: -:: This is `spin`, but with explicit type parameters. -:: -++ traverse - |* [state=mold in=mold out=mold] - |= [[st=state xs=(list in)] f=$-([state in] [out state])] - ^- [(list out) state] - ?~ xs [~ st] - =^ r st (f st i.xs) - =^ rs st $(xs t.xs, st st) - [[r rs] st] -:: -:: `traverse` over a set. -:: -++ traverse-set - |* [state=mold input=mold out=mold] - |= [[st=state xs=(set input)] f=$-([state input] [out state])] - ^- [(set out) state] - :: - =^ elems st ((traverse state input out) [st ~(tap in xs)] f) - :_ st (~(gas in *(set out)) elems) -:: -:: `traverse` over a map, also passing the key to the folding function. -:: -++ traverse-map - |* [state=mold key=mold in=mold out=mold] - |= [[st=state dict=(map key in)] f=$-([state key in] [out state])] - ^- [(map key out) state] - :: - =^ pairs=(list (pair key out)) st - %+ (traverse state (pair key in) (pair key out)) - [st ~(tap by dict)] - |= [st=state k=key x=in] - ^- [(pair key out) state] - =^ v st (f st k x) - [[k v] st] - :: - :_ st - (~(gas by *(map key out)) pairs) -:: -:: Given a map, return its inverse: For each value, what are the set -:: of associated keys? -:: -++ reverse-map - |* [key=mold val=mold] - |= tbl=(map key val) - =/ init *(map val (set key)) - ^- _init - %+ (fold _init (pair key val)) - [init ~(tap by tbl)] - |= [acc=_init k=key v=val] - ^- _init - =/ mb-keys (~(get by acc) v) - =/ keys=(set key) ?~(mb-keys ~ u.mb-keys) - (~(put by acc) v (~(put in keys) k)) -:: ++ json :: normal json value $@ ~ :: null $% {$a p/(list json)} :: array From f6f7d2fab40a74f3654de498673e92e298cff98f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 20 Nov 2020 14:07:53 -0800 Subject: [PATCH 668/933] hoon: modernizes $tank and surrounding declarations --- pkg/arvo/sys/hoon.hoon | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 8314338b2b..226c3e2e08 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -1973,24 +1973,29 @@ :: cord +$ tint ?($r $g $b $c $m $y $k $w $~) :: text color -++ tang (list tank) :: bottom-first error -++ tank $~ [%leaf ~] :: - $% {$leaf p/tape} :: printing formats - $: $palm :: backstep list - p/{p/tape q/tape r/tape s/tape} :: - q/(list tank) :: - == :: - $: $rose :: flat list - p/{p/tape q/tape r/tape} :: mid open close - q/(list tank) :: - == :: - == :: -++ tape (list @tD) :: utf8 string as list -++ tour (list @c) :: utf32 clusters -++ tarp {d/@ud h/@ud m/@ud s/@ud f/(list @ux)} :: parsed time -++ term @tas :: ascii symbol -++ wain (list cord) :: text lines -++ wall (list tape) :: text lines ++$ tang (list tank) :: bottom-first error +:: +:: $tank: formatted print tree +:: +:: %leaf: just a tape +:: %palm: backstep list +:: flat-mid, open, flat-open, flat-close +:: %rose: flat list +:: flat-mid, open, close +:: ++$ tank + $~ leaf/~ + $% [%leaf p=tape] + [%palm p=(qual tape tape tape tape) q=(list tank)] + [%rose p=(trel tape tape tape) q=(list tank)] + == +:: ++$ tape (list @tD) :: utf8 string as list ++$ tour (list @c) :: utf32 clusters ++$ tarp {d/@ud h/@ud m/@ud s/@ud f/(list @ux)} :: parsed time ++$ term @tas :: ascii symbol ++$ wain (list cord) :: text lines ++$ wall (list tape) :: text lines :: :::: 2p: serialization :: :: :: From 374f93d81237169a1df340ae239a9b6be823f8f2 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 12 May 2020 16:12:43 -0700 Subject: [PATCH 669/933] hoon: moves $json and styled-text molds back to %zuse --- pkg/arvo/sur/plum.hoon | 4 ++++ pkg/arvo/sys/hoon.hoon | 21 --------------------- pkg/arvo/sys/zuse.hoon | 19 +++++++++++++++++-- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/pkg/arvo/sur/plum.hoon b/pkg/arvo/sur/plum.hoon index 47d18c85d0..4b1d62f9a0 100644 --- a/pkg/arvo/sur/plum.hoon +++ b/pkg/arvo/sur/plum.hoon @@ -1,5 +1,9 @@ ^? |% :: ++$ tile :: XX: ?@(knot (pair styl knot)) + :: + cord +:: :: A `plum` is the intermediate representation for the pretty-printer. It :: encodes hoon-shaped data with the least amount of structured needed :: for formating. diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 226c3e2e08..ce4629246f 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -1952,7 +1952,6 @@ +$ char @t :: UTF8 byte +$ cord @t :: UTF8, LSB first +$ byts [wid=@ud dat=@] :: bytes, MSB first -+$ deco ?($bl $br $un $~) :: text decoration +$ date {{a/? y/@ud} m/@ud t/tarp} :: parsed date +$ knot @ta :: ASCII text +$ noun * :: any noun @@ -1962,17 +1961,6 @@ $: auth=@tas :: standards authority type=path :: standard label == :: -+$ stub (list (pair stye (list @c))) :: styled unicode -+$ stye (pair (set deco) (pair tint tint)) :: decos/bg/fg -+$ styl :: cascading style - %+ pair (unit deco) :: - (pair (unit tint) (unit tint)) :: -:: :: -+$ styx (list $@(@t (pair styl styx))) :: styled text -+$ tile :: XX: ?@(knot (pair styl knot)) - :: - cord -+$ tint ?($r $g $b $c $m $y $k $w $~) :: text color +$ tang (list tank) :: bottom-first error :: :: $tank: formatted print tree @@ -11430,15 +11418,6 @@ ~| %sell (~(deal us p.vax) q.vax) :: -++ json :: normal json value - $@ ~ :: null - $% {$a p/(list json)} :: array - {$b p/?} :: boolean - {$o p/(map @t json)} :: object - {$n p/@ta} :: number - {$s p/@t} :: string - == :: -:: :: +skol $-(type tank) using `duck`. :: ++ skol diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index 9662e1c93f..1e611159e9 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -72,6 +72,15 @@ :: +disc: a desk on a ship; can be used as a beak that varies with time :: +$ disc [=ship =desk] ++$ deco ?(~ $bl $br $un) :: text decoration ++$ json :: normal json value + $@ ~ :: null + $% [%a p=(list json)] :: array + [%b p=?] :: boolean + [%o p=(map @t json)] :: object + [%n p=@ta] :: number + [%s p=@t] :: string + == :: ++ life @ud :: ship key revision ++ rift @ud :: ship continuity ++ mime {p/mite q/octs} :: mimetyped data @@ -91,7 +100,14 @@ %- unit :: ~ ~: invalid (cask vase) :: marked cargo :: -++ turf (list @t) :: domain, tld first ++$ stub (list (pair stye (list @c))) :: styled unicode ++$ stye (pair (set deco) (pair tint tint)) :: decos/bg/fg ++$ styl %+ pair (unit deco) :: cascading style + (pair (unit tint) (unit tint)) :: ++$ styx (list $@(@t (pair styl styx))) :: styled text ++$ tint ?($r $g $b $c $m $y $k $w $~) :: text color +:: ++$ turf (list @t) :: domain, tld first :: :: :::: ++jstd :: json standards structures :: :::: @@ -1166,7 +1182,6 @@ {$sav p/path q/@} :: save to file {$url p/@t} :: activate url == :: - ++ deco ?(~ $bl $br $un) :: text decoration ++ dill-belt :: new belt $% {$aro p/?($d $l $r $u)} :: arrow key {$bac ~} :: true backspace From 947742ff730964f207238a0237d0f5b204995b09 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 20 Nov 2020 14:22:18 -0800 Subject: [PATCH 670/933] zuse: removes obselete structures $ares, $coop, and $disc --- pkg/arvo/sys/zuse.hoon | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index 1e611159e9..b38fa0015d 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -39,7 +39,6 @@ :: :: miscellaneous systems types ::+| -++ ares (unit {p/term q/(list tank)}) :: possible error :: +capped-queue: a +qeu with a maximum number of entries :: ++ capped-queue @@ -68,10 +67,6 @@ depth=_1 == :: -++ coop (unit ares) :: possible error -:: +disc: a desk on a ship; can be used as a beak that varies with time -:: -+$ disc [=ship =desk] +$ deco ?(~ $bl $br $un) :: text decoration +$ json :: normal json value $@ ~ :: null @@ -906,7 +901,6 @@ {$ud p/@ud} :: number == :: ++ cass {ud/@ud da/@da} :: cases for revision - ++ coop (unit ares) :: e2e ack ++ crew (set ship) :: permissions group ++ dict {src/path rul/real} :: effective permission ++ dome :: project state From eaa69ec27ad382e627f74ec3fe6927dd54b59d99 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 20 Nov 2020 14:28:49 -0800 Subject: [PATCH 671/933] zuse: modernizes syntax of top-level structures --- pkg/arvo/sys/zuse.hoon | 47 ++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index b38fa0015d..ff01739f34 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -42,7 +42,7 @@ :: +capped-queue: a +qeu with a maximum number of entries :: ++ capped-queue - |* item-type=mold + |$ [item-type] $: queue=(qeu item-type) size=@ud max-size=_64 @@ -53,19 +53,16 @@ :: :key-type to :val-type. Detailed docs for this type can be found there. :: ++ clock - |* $: :: key-type: mold of keys - :: - key-type=mold - :: val-type: mold of values - :: - val-type=mold - == - $: lookup=(map key-type [val=val-type fresh=@ud]) - queue=(qeu key-type) - size=@ud - max-size=_2.048 - depth=_1 - == + |$ :: key-type: mold of keys + :: val-type: mold of values + :: + [key-type val-type] + $: lookup=(map key-type [val=val-type fresh=@ud]) + queue=(qeu key-type) + size=@ud + max-size=_2.048 + depth=_1 + == :: +$ deco ?(~ $bl $br $un) :: text decoration +$ json :: normal json value @@ -76,20 +73,20 @@ [%n p=@ta] :: number [%s p=@t] :: string == :: -++ life @ud :: ship key revision -++ rift @ud :: ship continuity -++ mime {p/mite q/octs} :: mimetyped data -++ octs {p/@ud q/@} :: octet-stream -++ sock {p/ship q/ship} :: outgoing [our his] ++$ life @ud :: ship key revision ++$ rift @ud :: ship continuity ++$ mime (pair mite octs) :: mimetyped data ++$ octs (pair @ud cord) :: octet-stream ++$ sock (pair ship ship) :: outgoing [our his] ::+| :: -++ roof (room vase) :: namespace ++$ roof (room vase) :: namespace ++ room :: either namespace - |* vase/mold :: vase or maze - $- $: ref/* :: reference type - lyc/(unit (set ship)) :: leakset - car/term :: perspective - bem/beam :: path + |$ [vase] :: vase or maze + $- $: ref=* :: reference type + lyc=(unit (set ship)) :: leakset + car=term :: perspective + bem=beam :: path == :: %- unit :: ~: unknown %- unit :: ~ ~: invalid From a6a421608aa707c213803ae01881558025e870a0 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 20 Nov 2020 14:29:29 -0800 Subject: [PATCH 672/933] hoon: adds $cord to $tank --- pkg/arvo/sys/hoon.hoon | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index ce4629246f..f19b08b356 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -1965,6 +1965,7 @@ :: :: $tank: formatted print tree :: +:: just a cord, or :: %leaf: just a tape :: %palm: backstep list :: flat-mid, open, flat-open, flat-close @@ -1973,6 +1974,7 @@ :: +$ tank $~ leaf/~ + $@ cord $% [%leaf p=tape] [%palm p=(qual tape tape tape tape) q=(list tank)] [%rose p=(trel tape tape tape) q=(list tank)] @@ -4463,6 +4465,8 @@ :: ++ ram ^- tape + ?@ tac + (trip tac) ?- -.tac %leaf p.tac :: @@ -4501,6 +4505,8 @@ :: =| lug=wall |^ ^- wall + ?@ tac + (rig (trip tac)) ?- -.tac %leaf (rig p.tac) :: From 548440a85d96604ee22c4ac15d38f69452eba73d Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 20 Nov 2020 14:38:15 -0800 Subject: [PATCH 673/933] nix: trims trailing whitespace from solid pill builder --- nix/pkgs/pill/solid.sh | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/nix/pkgs/pill/solid.sh b/nix/pkgs/pill/solid.sh index e46aec7ac7..e405661591 100644 --- a/nix/pkgs/pill/solid.sh +++ b/nix/pkgs/pill/solid.sh @@ -26,27 +26,27 @@ done # Update :lens, :dojo and dependencies # FIXME: reduce this list -cp $ARVO/app/lens.hoon ./pier/home/app/ -cp $ARVO/app/dojo.hoon ./pier/home/app/ -cp $ARVO/lib/base64.hoon ./pier/home/lib/ -cp $ARVO/lib/plume.hoon ./pier/home/lib/ -cp $ARVO/lib/server.hoon ./pier/home/lib/ -cp $ARVO/lib/sole.hoon ./pier/home/lib/ -cp $ARVO/lib/xray.hoon ./pier/home/lib/ +cp $ARVO/app/lens.hoon ./pier/home/app/ +cp $ARVO/app/dojo.hoon ./pier/home/app/ +cp $ARVO/lib/base64.hoon ./pier/home/lib/ +cp $ARVO/lib/plume.hoon ./pier/home/lib/ +cp $ARVO/lib/server.hoon ./pier/home/lib/ +cp $ARVO/lib/sole.hoon ./pier/home/lib/ +cp $ARVO/lib/xray.hoon ./pier/home/lib/ cp $ARVO/lib/pprint.hoon ./pier/home/lib/ mkdir -p ./pier/home/mar/lens/ -cp $ARVO/mar/lens/* ./pier/home/mar/lens/ +cp $ARVO/mar/lens/* ./pier/home/mar/lens/ -cp $ARVO/sur/lens.hoon ./pier/home/sur/ -cp $ARVO/sur/plum.hoon ./pier/home/sur/ -cp $ARVO/sur/sole.hoon ./pier/home/sur/ -cp $ARVO/sur/xray.hoon ./pier/home/sur/ +cp $ARVO/sur/lens.hoon ./pier/home/sur/ +cp $ARVO/sur/plum.hoon ./pier/home/sur/ +cp $ARVO/sur/sole.hoon ./pier/home/sur/ +cp $ARVO/sur/xray.hoon ./pier/home/sur/ # Update +solid and its dependencies -cp $ARVO/lib/pill.hoon ./pier/home/lib/ -cp $ARVO/gen/solid.hoon ./pier/home/gen/ +cp $ARVO/lib/pill.hoon ./pier/home/lib/ +cp $ARVO/gen/solid.hoon ./pier/home/gen/ chmod -R u+rw ./pier/home/ From 37ba9cfc66638adaf70f4319e8f74994c18e3df9 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 20 Nov 2020 15:38:51 -0800 Subject: [PATCH 674/933] pill: solid --- bin/solid.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index bbbae340e7..7cbecc5b4b 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d8ac4b3bf78d7c8ef62f668bfe14b243cffe5784a97c87486e1ae31c4b58e1f6 -size 6312584 +oid sha256:d9a13b9dfa256559712b3d80c0de6cef74082c60de011cb9525a298f36fd0f13 +size 6296730 From 4ba66add90191385b7b88475b25c7900845e1231 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 20 Nov 2020 15:47:06 -0800 Subject: [PATCH 675/933] pill: solid --- bin/solid.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index bbbae340e7..dc14d7c5ae 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d8ac4b3bf78d7c8ef62f668bfe14b243cffe5784a97c87486e1ae31c4b58e1f6 -size 6312584 +oid sha256:a4f77095bac9b941c8c204adab5c727348e90f47e5a114890d6094d3d10b3fdf +size 6315214 From a928a63923ac774fadb6858c22eb0870dbcf2e64 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 20 Nov 2020 16:15:09 -0800 Subject: [PATCH 676/933] u3: fix accidental neologism in comments --- pkg/urbit/noun/nock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/noun/nock.c b/pkg/urbit/noun/nock.c index 70035e33c0..06aab9b986 100644 --- a/pkg/urbit/noun/nock.c +++ b/pkg/urbit/noun/nock.c @@ -1680,7 +1680,7 @@ u3n_find(u3_noun key, u3_noun fol) ** lit: hint atom. TRANSFER ** bus: subject. RETAIN ** out: token for _n_hilt_hind(); -** conventually, [lit] or [lit data]. ~ if unused. +** conventionally, [lit] or [lit data]. ~ if unused. ** ** any hints herein must be whitelisted in _n_burn(). */ @@ -1708,7 +1708,7 @@ _n_hilt_hind(u3_noun tok, u3_noun pro) // transfer, retain ** bus: subject. RETAIN ** clu: product of the hint-formula. TRANSFER ** also, token for _n_hint_hind(); -** conventually, [hint-atom] or [hint-atom data]. ~ if unused. +** conventionally, [hint-atom] or [hint-atom data]. ~ if unused. ** ** any hints herein must be whitelisted in _n_burn(). */ From 6750a9dc1c75486f24870d7aeeceaa156ded879c Mon Sep 17 00:00:00 2001 From: ryjm Date: Sat, 21 Nov 2020 16:46:29 -0500 Subject: [PATCH 677/933] landscape: fix link route breaking popover When you're on a link page, hitting the settings popover will trigger an error since the LinkResource matches the path. This makes it so that it only matches numerical indexes. --- pkg/interface/src/views/apps/links/LinkResource.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/interface/src/views/apps/links/LinkResource.tsx b/pkg/interface/src/views/apps/links/LinkResource.tsx index e269ac0122..5b81dcd6ef 100644 --- a/pkg/interface/src/views/apps/links/LinkResource.tsx +++ b/pkg/interface/src/views/apps/links/LinkResource.tsx @@ -95,7 +95,7 @@ export function LinkResource(props: LinkResourceProps) { }} /> { const index = bigInt(props.match.params.index); const editCommentId = props.match.params.commentId || null; From b114b0f1c186163270edc99dd6d872f77ab414e9 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 18 Nov 2020 23:44:28 -0800 Subject: [PATCH 678/933] arvo: filesystem --- pkg/arvo/gen/brass.hoon | 20 ++- pkg/arvo/gen/ivory.hoon | 14 +- pkg/arvo/gen/solid.hoon | 9 +- pkg/arvo/lib/pill.hoon | 44 ++++++ pkg/arvo/sys/arvo.hoon | 337 ++++++++++++++++++++++++++++++++++++---- 5 files changed, 386 insertions(+), 38 deletions(-) diff --git a/pkg/arvo/gen/brass.hoon b/pkg/arvo/gen/brass.hoon index 73de67153a..bae8f56654 100644 --- a/pkg/arvo/gen/brass.hoon +++ b/pkg/arvo/gen/brass.hoon @@ -8,8 +8,9 @@ :::: !: :- %say -|= $: {now/@da * bec/beak} - {~ try/_| ~} +|= $: [now=@da eny=@uvJ bec=beak] + arg=$@(~ [top=path ~]) + ~ == :: :: we're creating an event series E whose lifecycle can be computed @@ -153,7 +154,9 @@ :: :: sys: root path to boot system, `/~me/[desk]/now/sys` :: -=+ sys=`path`/(scot %p p.bec)/[q.bec]/(scot %da now)/sys +=/ sys=path + ?^ arg top.arg + /(scot %p p.bec)/[q.bec]/(scot %da now)/sys :: :: compiler-source: hoon source file producing compiler, `sys/hoon` :: @@ -186,6 +189,13 @@ == :: a pill is a 3-tuple of event-lists: [boot kernel userspace] :: +=/ bas=path (flop (tail (flop sys))) :+ boot-ova - (module-ova:pill sys) -[(file-ovum:pill (en-beam:format bec /)) ~] + :~ :~ //arvo + %what + [/sys/hoon hoon/compiler-source] + [/sys/arvo hoon/arvo-source] + == + (file-ovum2:pill bas) + == +[(file-ovum:pill bas) ~] diff --git a/pkg/arvo/gen/ivory.hoon b/pkg/arvo/gen/ivory.hoon index 36299409be..9a0d426a64 100644 --- a/pkg/arvo/gen/ivory.hoon +++ b/pkg/arvo/gen/ivory.hoon @@ -7,11 +7,15 @@ :::: !: :- %say -|= [[now=@da * bec=beak] *] +|= $: [now=@da eny=@uvJ bec=beak] + arg=$@(~ [top=path ~]) + ~ + == :- %noun :: sys: root path to boot system, `/~me/[desk]/now/sys` :: =/ sys=path + ?^ arg top.arg /(scot %p p.bec)/[q.bec]/(scot %da now)/sys :: compiler-source: hoon source file producing compiler, `sys/hoon` :: @@ -48,8 +52,12 @@ :: we include a static path for reproducibility. :: =/ zuse-ovo=ovum - :- /vane/zuse - [%veer %$ /sys/zuse/hoon .^(@ %cx (weld sys /zuse/hoon))] + :~ //arvo + %what + [/sys/hoon hoon/compiler-source] + [/sys/arvo hoon/arvo-source] + [/sys/zuse hoon/.^(@ %cx (weld sys /zuse/hoon))] + == :: installed: Arvo gate (formal instance) with %zuse installed :: :: The :zuse-ovo event occurs at a defaulted date for reproducibility. diff --git a/pkg/arvo/gen/solid.hoon b/pkg/arvo/gen/solid.hoon index 7a26757ef6..178177c58a 100644 --- a/pkg/arvo/gen/solid.hoon +++ b/pkg/arvo/gen/solid.hoon @@ -64,7 +64,14 @@ =/ installed =< q %^ spin - (module-ova:pill sys) + ^- (list ovum) + :~ :~ //arvo + %what + [/sys/hoon hoon/compiler-src] + [/sys/arvo hoon/arvo-src] + == + (file-ovum2:pill (flop (tail (flop sys)))) + == .*(0 arvo-formula) |= [ovo=ovum ken=*] [~ (slum ken [now ovo])] diff --git a/pkg/arvo/lib/pill.hoon b/pkg/arvo/lib/pill.hoon index 59d800aea2..453c5b2bdd 100644 --- a/pkg/arvo/lib/pill.hoon +++ b/pkg/arvo/lib/pill.hoon @@ -12,6 +12,7 @@ +$ unix-event %+ pair wire $% [%wack p=@] + [%what p=(list (pair path (cask)))] [%whom p=ship] [%boot ? $%($>(%fake task:able:jael) $>(%dawn task:able:jael))] unix-task @@ -116,4 +117,47 @@ |- ^- mode:clay ?~ all hav $(all t.all, hav ^$(tyl [p.i.all tyl])) +:: +:: +file-ovum2: electric boogaloo +:: +++ file-ovum2 |=(p=path `unix-event`[//arvo what/(user-files p)]) +:: +:: +user-files: all userspace hoon files +:: +++ user-files + |= bas=path + %. directories:file-ovum + |= sal=(list spur) + ^- (list (pair path (cask))) + :: + :: hav: all user files + :: + =| hav=(list (pair path (cask))) + |- ^+ hav + ?~ sal ~ + =. hav $(sal t.sal) + :: + :: tyl: spur + :: + =/ tyl i.sal + |- ^+ hav + :: + :: pax: full path at `tyl` + :: lon: directory at `tyl` + :: + =/ pax (weld bas (flop tyl)) + =/ lon .^(arch %cy pax) + =? hav ?=(^ fil.lon) + :: + :: install only hoon files for now + :: + ?. ?=([%hoon *] tyl) + hav + :_ hav + [(flop `path`t.tyl) hoon/.^(@t %cx pax)] + :: + =/ all ~(tap by dir.lon) + |- ^+ hav + ?~ all hav + $(all t.all, hav ^$(tyl [p.i.all tyl])) -- diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index 0c6eb81434..c8e3f3963e 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -102,6 +102,59 @@ (pair cord (each * (list mass))) +$ monk (each ship (pair @tas @ta)) +$ move [=duct =ball] +:: $node: fundamental hierarchical node +:: +:: XX s/b +arch +:: +++ node + =< |$ [item] + [fil=(unit item) dir=(map @ta $)] + :: + :: |de: node engine + :: + |% + ++ de + =| fat=(node) + |@ + :: + ++ get + |= pax=path + ^+ fat + ?~ pax fat + =/ kid (~(get by dir.fat) i.pax) + ?~ kid [~ ~] + $(fat u.kid, pax t.pax) + :: + ++ put + |* [pax=path dat=*] + => .(dat `_?>(?=(^ fil.fat) u.fil.fat)`dat) + ^+ fat + ?~ pax fat(fil `dat) + =/ kid (~(get by dir.fat) i.pax) + =/ new (fall kid fat(fil ~, dir ~)) + fat(dir (~(put by dir.fat) i.pax $(fat new, pax t.pax))) + :: + ++ gas + |= lit=(list (pair path _?>(?=(^ fil.fat) u.fil.fat))) + ^+ fat + ?~ lit fat + $(fat (put p.i.lit q.i.lit), lit t.lit) + :: + ++ tap + =| pax=path + =| out=(list (pair path _?>(?=(^ fil.fat) u.fil.fat))) + |- ^+ out + =? out ?=(^ fil.fat) :_(out [pax u.fil.fat]) + =/ dir ~(tap by dir.fat) + |- ^+ out + ?~ dir out + %= $ + dir t.dir + out ^$(pax (weld pax /[p.i.dir]), fat q.i.dir) + == + -- :: de + -- :: node +:: +$ ovum (pair wire curd) :: +$ scry-sample @@ -166,9 +219,13 @@ +$ debt $: :: run: list of worklists :: out: pending output + :: kel: kernel files + :: fil: pending files :: run=(list plan) out=(list ovum) + kel=(list (pair path (cask))) + fil=(list (pair path (cask))) == +$ germ [vane=term bars=(list duct)] +$ heir @@ -180,6 +237,7 @@ eny=@uvJ :: entropy lac=? :: laconic bit ver=vere :: runtime + fat=(node (cask)) :: zus=vase :: %zuse van=(map term vane) :: modules == @@ -317,11 +375,26 @@ => |% :: $card: tagged, untyped event :: $ovum: card with cause + :: $hoof: hoon source + :: $news: collated updates :: :: XX replace top-level structures :: +$ card (cask) +$ ovum [=wire =card] + +$ hoof @t + +$ news + $: :: sys: installs + replacements + :: use: non-system files + :: + sys=(map path (cask)) + use=(map path (cask)) + == + +$ seed [hun=(unit hoof) arv=hoof] + +$ sprig + $: zus=(unit hoof) + van=(list (cask hoof)) + == -- :: ~% %part ..part ~ @@ -356,6 +429,95 @@ :: +| %engines :: + :: |adapt + :: + ++ adapt + => |% + :: deep file as source + :: + ++ sole |=(a=(cask) `hoof`?>(?=([%hoon @t] a) q.a)) + -- + =* de de:node + |_ fat=(node (cask)) + :: + :: +group: collate changes + :: + ++ group + |= fal=(list (pair path (cask))) + =| del=news + |- ^+ del + ?~ fal del + :: classify files, ignoring unchanged + :: + =* pax p.i.fal + =* dat q.i.fal + =/ hav (~(get de fat) pax) + =? del |(?=(~ fil.hav) !=(u.fil.hav dat)) + ?: ?=([%sys *] pax) + del(sys (~(put by sys.del) pax dat)) + del(use (~(put by use.del) pax dat)) + $(fal t.fal) + :: +usurp: consider self-replacement + :: + ++ usurp + |= del=news + ^- (unit (pair seed (list (pair path (cask))))) + ~& usurp/(turn ~(tap by sys.del) head) + =/ hun (~(get by sys.del) /sys/hoon) + =/ arv (~(get by sys.del) /sys/arvo) + ?~ hun + ?~ arv ~ + `[`(sole u.arv) [/sys/arvo u.arv] ~] + =/ rav + ~| %usurp-hoon-no-arvo + ((bond |.((need fil:(~(get de fat) /sys/arvo)))) arv) + ~! rav + :+ ~ + [`(sole u.hun) (sole rav)] + [[/sys/arvo rav] [/sys/hoon u.hun] ~] + :: +adorn: augment capabilities + :: + ++ adorn + |= [del=news all=?] + ^- (pair sprig _fat) + :: zuse: shared library + :: + =^ zus fat + ?^ hav=(~(get by sys.del) /sys/zuse) + :- `(sole u.hav) + (~(put de fat) /sys/zuse u.hav) + :_ fat + ~| %adorn-no-zuse + ?.(all ~ `(sole (need fil:(~(get de fat) /sys/zuse)))) + :: kernel modules + :: + :: %zuse is the subject of the vanes; force all if we have a new %zuse + :: + =| nav=(map term hoof) + =? nav |(all ?=(^ zus)) + %- ~(gas by nav) + %+ turn + ~(tap by dir:(~(get de fat) /sys/vane)) + |=([name=@ta _fat] [`@tas`name (sole (need fil))]) + :: + =^ new fat + %^ spin + %+ skim ~(tap by sys.del) + |=([p=path *] ?=([%sys %vane @tas ~] p)) + fat + |= [[p=path q=(cask)] taf=_fat] + ^- (pair (cask hoof) _fat) + ?> ?=([%sys %vane @tas ~] p) + =* nam i.t.t.p + ?> ((sane %tas) nam) + [[`@tas`nam (sole q)] (~(put de taf) p q)] + :: + =; van + [[zus van] fat] + %+ sort ~(tap by (~(gas by nav) new)) + |=([[a=@tas *] [b=@tas *]] (aor a b)) + -- :: adapt + :: :: |me: dynamic analysis :: ++ me @@ -635,15 +797,22 @@ :: ++ le ~% %le ..le ~ - =| debt - =* nub - - =| $: :: gem: worklist metadata + =| $: :: run: list of worklists + :: out: pending output + :: gem: worklist metadata :: dud: propagate error - :: but: reboot gate + :: but: reboot signal :: + :: + run=(list plan) + out=(list ovum) gem=germ dud=(unit goof) - but=(unit $-(heir (trap ^))) + $= but %- unit + $: gat=$-(heir (trap ^)) + kel=(list (pair path (cask))) + fil=(list (pair path (cask))) + == == :: |_ [[pit=vase vil=vile] now=@da soul] @@ -656,7 +825,7 @@ ^- (each (pair (list ovum) soul) (trap ^)) ?~ but &/[(flop out) sol] - |/(u.but [%arvo-kelvin now [run out] sol]) + |/(gat.u.but [%arvo-kelvin now [run out [kel fil]:u.but] sol]) :: +poke: prepare a worklist-of-one from outside :: ++ poke @@ -672,7 +841,9 @@ =: run run.debt out out.debt == - this + :: apply remaining update + :: + (~(lod what:pith fil.debt) kel.debt) :: +emit: enqueue a worklist with source :: ++ emit @@ -882,6 +1053,7 @@ :: %lyra: upgrade kernel :: %trim: trim state, spam to all :: %vega: notify vanes post upgrade + :: %what: update from files :: %whey: produce $mass :: XX remove, scry :: %verb: toggle laconicity :: %veer: upgrade module @@ -890,6 +1062,7 @@ $% [%lyra hun=(unit @t) van=@t] [%trim p=@ud] [%vega ~] + [%what p=(list (pair path (cask)))] [%whey ~] [%verb p=(unit ?)] [%veer lal=@tas pax=path txt=@t] @@ -927,16 +1100,68 @@ == [%pass wire.ovum way &/vase] :: + :: |what: update engine + :: + :: +kel: (maybe) initiate a kernel update + :: +lod: continue with update after kernel +load + :: +mod: update the modules of the kernel + :: + ++ what + |_ fil=(list (pair path (cask))) + :: + ++ kel + ^+ ..pith + =/ del (~(group adapt fat) fil) + =/ tub (~(usurp adapt fat) del) + ?~ tub + (mod del |) + =/ pos=plan + [$/~ [*duct (gest [//arvo vega/~])] ~] + =/ gat (boot kel.ver [hun arv]:p.u.tub) + %_ ..pith + but `[gat q.u.tub fil] + run (weld run [pos ~]) + == + :: + ++ lod + |= kel=(list (pair path (cask))) + ^+ ..pith + =/ fat (~(gas de:node fat) kel) + %+ mod + (~(group adapt fat) fil) + %+ lien kel + |= [p=path *] + ?=([%sys ?(%arvo %hoon) *] p) + :: + ++ mod + |= [del=news all=?] + ^+ ..pith + =^ job=sprig fat (~(adorn adapt fat) del all) + =? zus ?=(^ zus.job) + $:(smit:va "zuse" pit /sys/zuse/hoon u.zus.job) + %- (wyrd kel.ver [zuse/;;(@ud q:(slap zus limb/%zuse)) ~]) + %= ..pith + van + %+ roll van.job + |= [[(cask hoof)] =_van] + ^+ van + =/ way (wilt p) + =/ nex (create:va zus way /sys/vane/[p]/hoon q) + =/ nav (~(get by van) way) + =? nex ?=(^ nav) (update:va vase.u.nav nex) + (~(put by van) way (settle:va nex)) + == + -- + :: ++ call |= =waif ^+ ..pith ?^ dud ~>(%mean.'pith: goof' !!) ?- -.waif - %lyra =/ pos=plan [$/~ [*duct (gest [//arvo vega/~])] ~] - %_ ..pith - but `(boot kel.ver [hun van]:waif) - run (weld run [pos ~]) - == + %lyra =; wat $(waif wat) + :+ %what [/sys/arvo hoon/van.waif] + ?~ hun.waif ~ + [[/sys/hoon hoon/u.hun.waif] ~] :: :: %trim: clear state :: @@ -947,20 +1172,14 @@ (~(run by van) |=(=vane vane(worm *worm))) (emit $/~ (spam /arvo !>(waif))) :: - %vega (emit $/~ (spam /arvo !>(waif))) + %vega (emit $/~ (spam /arvo !>(waif))) :: XX also out %verb ..pith(lac ?~(p.waif !lac u.p.waif)) :: - %veer ?: ?=(%$ lal.waif) - =. zus $:(smit:va "zuse" pit [pax txt]:waif) - %- (wyrd kel.ver [zuse/;;(@ud q:(slap zus limb/%zuse)) ~]) - ..pith - :: - :: - =/ nex (create:va zus [lal pax txt]:waif) - =/ nav (~(get by van) lal.waif) - =? nex ?=(^ nav) (update:va vase.u.nav nex) - ..pith(van (~(put by van) lal.waif (settle:va nex))) + %veer =/ pax + sys/?:(?=(%$ lal.waif) /zuse /vane/[(grow lal.waif)]) + $(waif what/[[pax hoon/txt.waif] ~]) :: + %what ~(kel what p.waif) %whey ..pith(out [[//arvo mass/whey] out]) == :: @@ -1134,6 +1353,34 @@ [%behn *] %b == :: +++ grow + |= way=term + ?+ way way + %a %ames + %b %behn + %c %clay + %d %dill + %e %eyre + %f %ford + %g %gall + %i %iris + %j %jael + == +:: +++ wilt + |= van=term + ?+ van van + %ames %a + %behn %b + %clay %c + %dill %d + %eyre %e + %ford %f + %gall %g + %iris %i + %jael %j + == +:: ++ is & -- => @@ -1247,6 +1494,7 @@ eny=(unit @) lac=? ver=vere :: XX unit + fat=(unit (node (cask))) bod=(unit (trap vase)) van=(map term (trap vase)) == @@ -1255,6 +1503,7 @@ $% $>(%verb waif:pith:le:part) $>(%veer waif:pith:le:part) $>(%wack wasp:pith:le:part) + $>(%what waif:pith:le:part) [%whom p=ship] $>(%wyrd wasp:pith:le:part) == @@ -1268,7 +1517,7 @@ ++ molt |= [now=@da foal] ^- (unit heir) - ?. &(?=(^ who) ?=(^ eny) ?=(^ bod)) + ?. &(?=(^ who) ?=(^ eny) ?=(^ fat) ?=(^ bod)) ~ =/ zus $:u.bod %- %+ wyrd kel.ver @@ -1279,7 +1528,8 @@ == =/ nav %- ~(run by van) |=(a=(trap vase) (settle:va:part (slym $:a zus))) - `[%arvo-kelvin now *debt [u.who u.eny lac ver zus nav]] + =/ sol [u.who u.eny lac ver u.fat zus nav] + `[%arvo-kelvin now *debt sol] -- :: =| foal @@ -1292,19 +1542,48 @@ |= [now=@da ovo=ovum] ^- ^ =/ gub + ~| [p.ovo p.q.ovo] ~> %mean.'arvo: bad grub' ;;(grub q.ovo) :: =. ..poke + |- ^+ ..poke ?- -.gub %verb ..poke(lac ?~(p.gub !lac u.p.gub)) :: - %veer ?: ?=(%$ lal.gub) - ..poke(bod `(mint pit [lal pax txt]:gub)) - =/ zus =<($ (need bod)) :: XX misparse - ..poke(van (~(put by van) lal.gub (mint zus [lal pax txt]:gub))) + %veer =/ pax + sys/?:(?=(%$ lal.gub) /zuse /vane/[(grow lal.gub)]) + $(q.ovo what/[[pax hoon/txt.gub] ~]) :: %wack ..poke(eny `p.gub) + :: + %what =/ taf (fall fat *(node (cask))) + =/ del (~(group adapt:part taf) p.gub) + =/ tub (~(usurp adapt:part taf) del) + ?: &(?=(^ dir.taf) ?=(^ tub)) + ~|(%larval-reboot !!) :: XX support + :: + :: require, and unconditionally adopt, initial kernel source + :: + =? taf =(~ dir.taf) :: XX TMI + ~| %larval-need-kernel + ?> ?=(^ tub) + (~(gas de:node taf) q.u.tub) + :: + =^ job taf [p q]:(~(adorn adapt:part taf) del |) + =? bod ?=(^ zus.job) + `(mint pit %$ /sys/zuse/hoon u.zus.job) + %= ..poke + fat `taf + van + %+ roll van.job + |= [[(cask hoof:part)] =_van] + ^+ van + ?> ?=(^ bod) + =/ way (wilt p) + (~(put by van) way (mint $:u.bod way /sys/vane/[p]/hoon q)) + == + :: %whom ..poke(who `p.gub) %wyrd =. ver p.gub %- %+ wyrd kel.ver From 37f26b55e29f66946d4c16ec10c4639c12231055 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 18 Nov 2020 23:45:48 -0800 Subject: [PATCH 679/933] pill: all --- bin/brass.pill | 4 ++-- bin/ivory.pill | 4 ++-- bin/solid.pill | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/brass.pill b/bin/brass.pill index b5f47de1bd..d8087aea44 100644 --- a/bin/brass.pill +++ b/bin/brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f4a6a782b2193a16dc10340e40787522ec34df50eb517fef849bc32b87a3e512 -size 4508418 +oid sha256:76b02d0d18b2e1827d09890ec2a05b525acf05c2a1861881ee2f1cb959e1d168 +size 4573429 diff --git a/bin/ivory.pill b/bin/ivory.pill index 40004edc42..b766ccecd2 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:db42476704efdbb5c2cbf81ea67f15603da5b848850b538081e7b108f969fa19 -size 1315294 +oid sha256:5411632d932318b08d223a80f8eeb3ab4191af5038d8179b249d8f5ee900348f +size 1935167 diff --git a/bin/solid.pill b/bin/solid.pill index af127b16b9..5c5e8a4b60 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5edb7587624d1bcc5e764bf525f5fae7817c44587be46effe1b749afb192f99d -size 6409061 +oid sha256:6195ada0b1b2d8d68a55f0faa9a1adf4e72fa32f4df4fed3923218ea95f0c947 +size 6535132 From 8616497c3681a97cbdc454427258c4476b6648ed Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 4 Nov 2020 22:51:49 -0800 Subject: [PATCH 680/933] vere: implements initial kelvin negotiation with %wyrd/%wend --- pkg/urbit/include/c/motes.h | 1 + pkg/urbit/include/vere/vere.h | 5 +- pkg/urbit/vere/io/hind.c | 8 ++ pkg/urbit/vere/lord.c | 1 + pkg/urbit/vere/pier.c | 226 ++++++++++++++++++++++++++++++++-- 5 files changed, 227 insertions(+), 14 deletions(-) diff --git a/pkg/urbit/include/c/motes.h b/pkg/urbit/include/c/motes.h index 6765024610..15320ea06b 100644 --- a/pkg/urbit/include/c/motes.h +++ b/pkg/urbit/include/c/motes.h @@ -1226,6 +1226,7 @@ # define c3__weak c3_s4('w','e','a','k') # define c3__web c3_s3('w','e','b') # define c3__wet c3_s3('w','e','t') +# define c3__wend c3_s4('w','e','n','d') # define c3__werp c3_s4('w','e','r','p') # define c3__west c3_s4('w','e','s','t') # define c3__what c3_s4('w','h','a','t') diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index de62a3fdd1..68374e590e 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -542,8 +542,9 @@ u3_psat_init = 0, // initialized u3_psat_boot = 1, // bootstrap u3_psat_play = 2, // replaying - u3_psat_work = 3, // working - u3_psat_done = 4 // shutting down + u3_psat_wyrd = 3, // versioning + u3_psat_work = 4, // working + u3_psat_done = 5 // shutting down } u3_psat; /* u3_boot: bootstrap event sequence diff --git a/pkg/urbit/vere/io/hind.c b/pkg/urbit/vere/io/hind.c index 37d090399e..b8b1577ee6 100644 --- a/pkg/urbit/vere/io/hind.c +++ b/pkg/urbit/vere/io/hind.c @@ -53,6 +53,14 @@ _hind_io_kick(u3_auto* car_u, u3_noun wir, u3_noun cad) ret_o = c3y; u3l_log("<<>>\n"); } break; + + // NB: startup explicitly handled in pier.c + // + // XX review arvo upgrade scenaria + // + case c3__wend: { + ret_o = c3y; + } break; } } diff --git a/pkg/urbit/vere/lord.c b/pkg/urbit/vere/lord.c index f148f1c690..394cb6c5e7 100644 --- a/pkg/urbit/vere/lord.c +++ b/pkg/urbit/vere/lord.c @@ -1090,6 +1090,7 @@ u3_lord_init(c3_c* pax_c, c3_w wag_w, c3_d key_d[4], u3_lord_cb cb_u) { u3_lord* god_u = c3_calloc(sizeof *god_u); god_u->liv_o = c3n; + god_u->pin_o = c3n; god_u->wag_w = wag_w; god_u->bin_c = u3_Host.wrk_c; // XX strcopy god_u->pax_c = pax_c; // XX strcopy diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index 41b48fc096..2130a540bf 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -285,7 +285,8 @@ _pier_on_lord_work_spin(void* ptr_v, u3_atom pin, c3_o del_o) { u3_pier* pir_u = ptr_v; - c3_assert( (u3_psat_work == pir_u->sat_e) + c3_assert( (u3_psat_wyrd == pir_u->sat_e) + || (u3_psat_work == pir_u->sat_e) || (u3_psat_done == pir_u->sat_e) ); u3_term_start_spinner(pin, del_o); @@ -298,7 +299,8 @@ _pier_on_lord_work_spun(void* ptr_v) { u3_pier* pir_u = ptr_v; - c3_assert( (u3_psat_work == pir_u->sat_e) + c3_assert( (u3_psat_wyrd == pir_u->sat_e) + || (u3_psat_work == pir_u->sat_e) || (u3_psat_done == pir_u->sat_e) ); u3_term_stop_spinner(); @@ -402,13 +404,14 @@ u3_pier_spin(u3_pier* pir_u) { // XX return c3n instead? // - c3_assert( (u3_psat_work == pir_u->sat_e) - || (u3_psat_done == pir_u->sat_e) ); + if ( u3_psat_work == pir_u->sat_e + || u3_psat_done == pir_u->sat_e ) + { + u3_work* wok_u = pir_u->wok_u; - u3_work* wok_u = pir_u->wok_u; - - if ( !uv_is_active((uv_handle_t*)&wok_u->idl_u) ) { - uv_idle_start(&wok_u->idl_u, _pier_work_idle_cb); + if ( !uv_is_active((uv_handle_t*)&wok_u->idl_u) ) { + uv_idle_start(&wok_u->idl_u, _pier_work_idle_cb); + } } } @@ -488,8 +491,7 @@ _pier_work_init(u3_pier* pir_u) { u3_work* wok_u; - c3_assert( (u3_psat_init == pir_u->sat_e) - || (u3_psat_play == pir_u->sat_e) ); + c3_assert( u3_psat_wyrd == pir_u->sat_e ); pir_u->sat_e = u3_psat_work; pir_u->wok_u = wok_u = c3_calloc(sizeof(*wok_u)); @@ -552,6 +554,206 @@ _pier_work_init(u3_pier* pir_u) _pier_work(wok_u); } +/* _pier_wyrd_good(): %wyrd version negotation succeeded. +*/ +static void +_pier_wyrd_good(u3_pier* pir_u, u3_ovum* egg_u, u3_gift* gif_u) +{ + // restore event callbacks + // + { + u3_lord* god_u = pir_u->god_u; + god_u->cb_u.work_done_f = _pier_on_lord_work_done; + god_u->cb_u.work_bail_f = _pier_on_lord_work_bail; + } + + // initialize i/o drivers + // + _pier_work_init(pir_u); + + // plan %wyrd effects + // + _pier_gift_plan(pir_u->wok_u, gif_u); + + // free %wyrd driver and ovum + // + { + u3_auto* car_u = egg_u->car_u; + u3_auto_done(egg_u); + c3_free(car_u); + } +} + +/* _pier_wyrd_fail(): %wyrd version negotation failed. +*/ +static void +_pier_wyrd_fail(u3_pier* pir_u, u3_ovum* egg_u, u3_noun lud) +{ + // XX version negotiation failed, print upgrade message + // + u3l_log("pier: version negotation failed\n\n"); + + // XX only print trace with -v ? + // + u3_auto_bail_slog(egg_u, lud); + + // free %wyrd driver and ovum + // + { + u3_auto* car_u = egg_u->car_u; + u3_auto_done(egg_u); + c3_free(car_u); + } + + u3_pier_bail(pir_u); +} + +// XX organizing version constants +// +#define VERE_NAME "vere" +#define VERE_MAJOR 0 +#define VERE_MINOR 10 +#define VERE_PATCH 9 +#define VERE_ZUSE 309 + +/* _pier_wyrd_aver(): check for %wend effect and version downgrade. RETAIN +*/ +static c3_o +_pier_wyrd_aver(u3_noun act) +{ + u3_noun fec, kel, ver; + + // XX review, %wend re: %wyrd optional? + // + while ( u3_nul != act ) { + u3x_cell(act, &fec, &act); + + if ( c3__wend == u3h(fec) ) { + kel = u3t(fec); + + // traverse $wynn, check for downgrades + // + while ( u3_nul != kel ) { + u3x_cell(kel, &ver, &kel); + + // check for %zuse downgrade + // + if ( (c3__zuse == u3h(ver)) + && (VERE_ZUSE != u3t(ver)) ) + { + return c3n; + } + + // XX in the future, send %wend to serf + // to also negotiate downgrade of nock/hoon/&c? + // (we don't want to have to filter effects) + // + } + } + } + + return c3y; +} + +/* _pier_on_lord_wyrd_done(): callback for successful %wyrd event. +*/ +static void +_pier_on_lord_wyrd_done(void* ptr_v, + u3_ovum* egg_u, + u3_fact* tac_u, + u3_gift* gif_u) +{ + u3_pier* pir_u = ptr_v; + + c3_assert( u3_psat_wyrd == pir_u->sat_e ); + + // arvo's side of version negotiation succeeded + // traverse [gif_y] and validate + // + if ( c3n == _pier_wyrd_aver(gif_u->act) ) { + u3_fact_free(tac_u); + u3_gift_free(gif_u); + + // XX messageing + // + u3l_log("pier: version negotiation failed; downgrade\n"); + _pier_wyrd_fail(pir_u, egg_u, u3_nul); + } + else { + // enqueue %wyrd event-log commit + // + u3_disk_plan(pir_u->log_u, tac_u); + + // finalize %wyrd success + // + _pier_wyrd_good(pir_u, egg_u, gif_u); + } +} + +/* _pier_on_lord_wyrd_bail(): callback for failed %wyrd event. +*/ +static void +_pier_on_lord_wyrd_bail(void* ptr_v, u3_ovum* egg_u, u3_noun lud) +{ + u3_pier* pir_u = ptr_v; + + c3_assert( u3_psat_wyrd == pir_u->sat_e ); + + // print %wyrd failure and exit + // + // XX check bail mote, retry on %intr, %meme, &c + // + _pier_wyrd_fail(pir_u, egg_u, lud); +} + +/* _pier_wyrd_init(): send %wyrd. +*/ +static void +_pier_wyrd_init(u3_pier* pir_u) +{ + u3_lord* god_u = pir_u->god_u; + + pir_u->sat_e = u3_psat_wyrd; + + u3l_log("vere: checking version compatiblity\n"); + + _pier_work_time(pir_u); + u3v_numb(); + + { + u3_noun ver = u3nq(u3i_string(VERE_NAME), VERE_MAJOR, VERE_MINOR, VERE_PATCH); + u3_noun kel = u3nl(u3nc(c3__zuse, VERE_ZUSE), // XX god_u->zus_w + // u3nc(c3__lull, PIER_LULL), // XX define + // u3nc(c3__arvo, god_u->arv_y), // XX from both king and serf? + u3nc(c3__hoon, god_u->hon_y), + u3nc(c3__nock, god_u->noc_y), + u3_none); + u3_noun wir = u3nc(c3__arvo, u3_nul); + u3_noun cad = u3nt(c3__wyrd, u3nc(u3k(u3A->sen), ver), kel); + + { + u3_auto* car_u = c3_calloc(sizeof(*car_u)); + u3_ovum* egg_u = u3_ovum_init(0, u3_blip, wir, cad); + u3_noun ovo; + + car_u->pir_u = pir_u; + car_u->nam_m = c3__wyrd; + + u3_auto_plan(car_u, egg_u); + + // instead of subscribing with u3_auto_peer(), + // we swizzle the [god_u] callbacks for full control + // + god_u->cb_u.work_done_f = _pier_on_lord_wyrd_done; + god_u->cb_u.work_bail_f = _pier_on_lord_wyrd_bail; + + c3_assert( u3_auto_next(car_u, &ovo) == egg_u ); + + u3_lord_work(god_u, egg_u, ovo); + } + } +} + /* _pier_play_plan(): enqueue events for replay. */ static void @@ -730,7 +932,7 @@ _pier_play(u3_play* pay_u) } else if ( pay_u->eve_d == log_u->dun_d ) { u3_lord_save(pir_u->god_u); - _pier_work_init(pir_u); + _pier_wyrd_init(pir_u); } } else { @@ -1188,7 +1390,7 @@ _pier_on_lord_live(void* ptr_v) _pier_play_init(pir_u, eve_d); } else { - _pier_work_init(pir_u); + _pier_wyrd_init(pir_u); } } } From 0f11505073e72ab9e739f17331a4c2b4dd37b238 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 4 Nov 2020 22:54:32 -0800 Subject: [PATCH 681/933] vere: simulate successful negotation (temporary, pending arvo) --- pkg/urbit/vere/pier.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index 2130a540bf..230ba3dc1a 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -557,7 +557,7 @@ _pier_work_init(u3_pier* pir_u) /* _pier_wyrd_good(): %wyrd version negotation succeeded. */ static void -_pier_wyrd_good(u3_pier* pir_u, u3_ovum* egg_u, u3_gift* gif_u) +_pier_wyrd_good(u3_pier* pir_u, u3_ovum* egg_u) { // restore event callbacks // @@ -571,10 +571,6 @@ _pier_wyrd_good(u3_pier* pir_u, u3_ovum* egg_u, u3_gift* gif_u) // _pier_work_init(pir_u); - // plan %wyrd effects - // - _pier_gift_plan(pir_u->wok_u, gif_u); - // free %wyrd driver and ovum // { @@ -674,7 +670,7 @@ _pier_on_lord_wyrd_done(void* ptr_v, u3_fact_free(tac_u); u3_gift_free(gif_u); - // XX messageing + // XX messaging, cli argument to bypass // u3l_log("pier: version negotiation failed; downgrade\n"); _pier_wyrd_fail(pir_u, egg_u, u3_nul); @@ -686,7 +682,11 @@ _pier_on_lord_wyrd_done(void* ptr_v, // finalize %wyrd success // - _pier_wyrd_good(pir_u, egg_u, gif_u); + _pier_wyrd_good(pir_u, egg_u); + + // plan %wyrd effects + // + _pier_gift_plan(pir_u->wok_u, gif_u); } } @@ -699,11 +699,22 @@ _pier_on_lord_wyrd_bail(void* ptr_v, u3_ovum* egg_u, u3_noun lud) c3_assert( u3_psat_wyrd == pir_u->sat_e ); + // XX add cli argument to bypass negotiation failure + // +#if 0 // print %wyrd failure and exit // // XX check bail mote, retry on %intr, %meme, &c // _pier_wyrd_fail(pir_u, egg_u, lud); +#else + // XX temporary hack to fake %wyrd success + // + { + _pier_wyrd_good(pir_u, egg_u); + u3z(lud); + } +#endif } /* _pier_wyrd_init(): send %wyrd. From 818490fea805d00bc0a9a6de2d1b97759249ae85 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sat, 21 Nov 2020 12:59:39 -0800 Subject: [PATCH 682/933] arvo: moves (placeholder) kelvin to an arm --- pkg/arvo/sys/arvo.hoon | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index c8e3f3963e..b260157259 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -22,6 +22,8 @@ |% +| %global :: +++ arvo %arvo-kelvin +:: :: $arch: fundamental node :: $beak: global context :: $beam: global name @@ -229,7 +231,7 @@ == +$ germ [vane=term bars=(list duct)] +$ heir - $% [%arvo-kelvin now=@da =debt =soul] + $% [_arvo now=@da =debt =soul] == +$ plan (pair germ (list move)) +$ soul @@ -825,7 +827,7 @@ ^- (each (pair (list ovum) soul) (trap ^)) ?~ but &/[(flop out) sol] - |/(gat.u.but [%arvo-kelvin now [run out [kel fil]:u.but] sol]) + |/(gat.u.but [arvo now [run out [kel fil]:u.but] sol]) :: +poke: prepare a worklist-of-one from outside :: ++ poke @@ -1209,7 +1211,7 @@ %- %+ wyrd kel.ver ^- (list (pair term @)) :~ hoon/hoon-version - arvo/%arvo-kelvin + arvo/arvo zuse/;;(@ q:(slap zus limb/%zuse)) == ..pith @@ -1409,7 +1411,7 @@ :: =. sol ?- -.hir - %arvo-kelvin soul.hir + _arvo soul.hir == :: clear compiler caches :: @@ -1418,7 +1420,7 @@ %- %+ wyrd kel.ver ^- (list (pair term @)) :~ hoon/hoon-version - arvo/%arvo-kelvin + arvo/arvo zuse/;;(@ q:(slap zus limb/%zuse)) == :: restore working state and resume @@ -1523,13 +1525,13 @@ %- %+ wyrd kel.ver ^- (list (pair term @)) :~ hoon/hoon-version - arvo/%arvo-kelvin + arvo/arvo zuse/;;(@ud q:(slap zus limb/%zuse)) == =/ nav %- ~(run by van) |=(a=(trap vase) (settle:va:part (slym $:a zus))) =/ sol [u.who u.eny lac ver u.fat zus nav] - `[%arvo-kelvin now *debt sol] + `[arvo now *debt sol] -- :: =| foal @@ -1589,7 +1591,7 @@ %- %+ wyrd kel.ver ^- (list (pair term @)) :* hoon/hoon-version - arvo/%arvo-kelvin + arvo/arvo ?~ bod ~ [zuse/;;(@ud q:(slap $:u.bod limb/%zuse)) ~] == From f6f0c1edd908fab0ba8e413c111256b56ece948c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 23 Nov 2020 15:49:19 -0800 Subject: [PATCH 683/933] pill: all --- bin/brass.pill | 4 ++-- bin/ivory.pill | 4 ++-- bin/solid.pill | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/brass.pill b/bin/brass.pill index b5f47de1bd..bc46561e69 100644 --- a/bin/brass.pill +++ b/bin/brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f4a6a782b2193a16dc10340e40787522ec34df50eb517fef849bc32b87a3e512 -size 4508418 +oid sha256:a0a913185fc286fed27b3a6297e6917c65db26e8798b54e2c98a5c2bbf847eb1 +size 4495580 diff --git a/bin/ivory.pill b/bin/ivory.pill index 40004edc42..6f7d84d580 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:db42476704efdbb5c2cbf81ea67f15603da5b848850b538081e7b108f969fa19 -size 1315294 +oid sha256:4fae6432f7fd049042ed0f26c606325cf05e46f8ebd2703e5d95c054b7f0a0c8 +size 1320607 diff --git a/bin/solid.pill b/bin/solid.pill index d9f17a0071..c0eda8b99f 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b4c57e17b805a20778646e1b3e9efb84d3dbfd12089fe1834e9e15f1f9c52389 -size 6419639 +oid sha256:f112c8ba5ed0248c39babb00ab8f8ae6bb949c8502820fec4f3468ebc0677eb0 +size 6324006 From 91e09d39588e852f7550773a96ff509c45782fbb Mon Sep 17 00:00:00 2001 From: Tyler Brown Cifu Shuster Date: Mon, 23 Nov 2020 19:55:13 -0800 Subject: [PATCH 684/933] weather: add remediation path, styling --- .../apps/launch/components/tiles/weather.js | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/pkg/interface/src/views/apps/launch/components/tiles/weather.js b/pkg/interface/src/views/apps/launch/components/tiles/weather.js index 9dd62c8090..099792935a 100644 --- a/pkg/interface/src/views/apps/launch/components/tiles/weather.js +++ b/pkg/interface/src/views/apps/launch/components/tiles/weather.js @@ -248,26 +248,42 @@ export default class WeatherTile extends React.Component { return this.renderManualEntry(data); } + if ('currently' in data) { // Old weather source + this.props.api.launch.weather(this.props.location); + } + if ('current-condition' in data && 'weather' in data) { return this.renderWithData(data); } if (this.props.location) { - return this.renderWrapper(( + return this.renderWrapper( - - Weather - - Loading, please check again later... + Weather + + Loading, please check again later... + + + Set new location{' '} + + this.setState({ manualEntry: !this.state.manualEntry }) + } + > + -> + - )); + ); } return this.renderNoData(); } From 036b2de7f254ac8107babf3d2af4cdde52d79bab Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 23 Nov 2020 22:42:56 -0800 Subject: [PATCH 685/933] zuse: change to ropsten --- pkg/arvo/sys/zuse.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index 05ff55434b..150c007d83 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -8007,7 +8007,7 @@ :: # constants :: :: contract addresses - ++ contracts mainnet-contracts + ++ contracts ropsten-contracts ++ mainnet-contracts |% :: azimuth: data contract From e20e7e3645cc7f5fb4be88011bee38e27eec91f5 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Mon, 23 Nov 2020 18:28:55 -0800 Subject: [PATCH 686/933] pill: change to ropsten --- bin/ivory.pill | 2 +- bin/solid.pill | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/ivory.pill b/bin/ivory.pill index 6f7d84d580..d6bc03c56d 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4fae6432f7fd049042ed0f26c606325cf05e46f8ebd2703e5d95c054b7f0a0c8 +oid sha256:20057d491e10d2ba0afce72833dd45e78b746fc3a33122337ad346f9addfca66 size 1320607 diff --git a/bin/solid.pill b/bin/solid.pill index c0eda8b99f..48315096a8 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f112c8ba5ed0248c39babb00ab8f8ae6bb949c8502820fec4f3468ebc0677eb0 -size 6324006 +oid sha256:1f7e5913134048073737c5ba380fabc9c3819a37038a1db8b657c9605d9e9bc9 +size 6324130 From 14b973071c76e6e7de58cb644ba17721b357e85c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 23 Nov 2020 23:26:30 -0800 Subject: [PATCH 687/933] pill: all --- bin/brass.pill | 4 ++-- bin/ivory.pill | 4 ++-- bin/solid.pill | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/brass.pill b/bin/brass.pill index bc46561e69..688e3fd074 100644 --- a/bin/brass.pill +++ b/bin/brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a0a913185fc286fed27b3a6297e6917c65db26e8798b54e2c98a5c2bbf847eb1 -size 4495580 +oid sha256:9942a8b27a470fa4992f0ec4be33d7246d84a407da4f766bb4327da07d458ca7 +size 4477237 diff --git a/bin/ivory.pill b/bin/ivory.pill index d6bc03c56d..8cdfa932dc 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:20057d491e10d2ba0afce72833dd45e78b746fc3a33122337ad346f9addfca66 -size 1320607 +oid sha256:92f96229ed78f7fe229f35be8145b4f14436800b7c4a0c68fb3e631eb6a3d993 +size 1305392 diff --git a/bin/solid.pill b/bin/solid.pill index 48315096a8..b3e2f7bb8d 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1f7e5913134048073737c5ba380fabc9c3819a37038a1db8b657c9605d9e9bc9 -size 6324130 +oid sha256:ae9cf9424cb0f4ce515d477646844dfdab57a2cbd1f3b1e2d65662cce1d09654 +size 6306749 From 1d644dc4705e81280184087039984aa3a65df5e9 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 27 Aug 2020 15:37:48 +0200 Subject: [PATCH 688/933] hoon: remove ^% It's completely unused. --- pkg/arvo/lib/language-server/complete.hoon | 1 - pkg/arvo/lib/language-server/rune-snippet.hoon | 4 ---- pkg/arvo/lib/pprint.hoon | 1 - pkg/arvo/sys/hoon.hoon | 5 ----- 4 files changed, 11 deletions(-) diff --git a/pkg/arvo/lib/language-server/complete.hoon b/pkg/arvo/lib/language-server/complete.hoon index a413203caa..1f01c86c7a 100644 --- a/pkg/arvo/lib/language-server/complete.hoon +++ b/pkg/arvo/lib/language-server/complete.hoon @@ -142,7 +142,6 @@ `['' (~(play ut sut) wing+t.p.gen)] :: [^ *] (both p.gen q.gen) - [%ktcn *] loop(gen p.gen) [%brcn *] (grow q.gen) [%brpt *] (grow q.gen) [%cnts *] diff --git a/pkg/arvo/lib/language-server/rune-snippet.hoon b/pkg/arvo/lib/language-server/rune-snippet.hoon index ed1dc1b8a9..b25e306bea 100644 --- a/pkg/arvo/lib/language-server/rune-snippet.hoon +++ b/pkg/arvo/lib/language-server/rune-snippet.hoon @@ -197,10 +197,6 @@ """ $\{1:iron-core} """ - :- '^%' - """ - $\{1:body} - """ :- '^.' """ $\{1:a} diff --git a/pkg/arvo/lib/pprint.hoon b/pkg/arvo/lib/pprint.hoon index f88f1d7777..51a0cd719b 100644 --- a/pkg/arvo/lib/pprint.hoon +++ b/pkg/arvo/lib/pprint.hoon @@ -372,7 +372,6 @@ [%dtts *] (rune '.=' ~ `['=(' spc ')'] (hoons ~[p q]:x)) [%dtwt *] (rune '.?' ~ ~ (hoons ~[p.x])) [%ktbr *] (rune '^|' ~ ~ (hoons ~[p.x])) - [%ktcn *] (rune '^%' ~ ~ (hoons ~[p]:x)) [%ktdt *] (rune '^.' ~ ~ (hoons ~[p q]:x)) [%ktls *] (rune '^+' ~ ~ (hoons ~[p q]:x)) [%kthp *] (rune '^-' ~ ~ ~[(spec p.x) (hn q.x)]) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 2eb2a9b6b9..d89d601fc9 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -6457,7 +6457,6 @@ {$dtwt p/hoon} :: .? nock 3 :: :::::: type conversion {$ktbr p/hoon} :: ^| contravariant - {$ktcn p/hoon} :: ^% enter test mode {$ktdt p/hoon q/hoon} :: ^. self-cast {$ktls p/hoon q/hoon} :: ^+ expression cast {$kthp p/spec q/hoon} :: ^- structure cast @@ -10087,7 +10086,6 @@ =+ tal=$(gen q.gen, gol %noun) [(nice (cell p.hed p.tal)) (cons q.hed q.tal)] :: - {$ktcn *} $(fab |, gen p.gen) {$brcn *} (grow %gold p.gen %dry [%$ 1] q.gen) {$brpt *} (grow %gold p.gen %wet [%$ 1] q.gen) :: @@ -10266,7 +10264,6 @@ =+ tal=$(gen q.gen, gol %noun) [(nice (cell p.hed p.tal)) (cell q.hed q.tal)] :: - {$ktcn *} $(fab |, gen p.gen) {$brcn *} (grow %gold p.gen %dry [%$ 1] q.gen) {$brpt *} (grow %gold p.gen %wet [%$ 1] q.gen) {$cnts *} (~(mull et p.gen q.gen) gol dox) @@ -10641,7 +10638,6 @@ ^- type ?- gen {^ *} (cell $(gen p.gen) $(gen q.gen)) - {$ktcn *} $(fab |, gen p.gen) {$brcn *} (core sut [p.gen %dry %gold] sut *seminoun q.gen) {$brpt *} (core sut [p.gen %wet %gold] sut *seminoun q.gen) {$cnts *} ~(play et p.gen q.gen) @@ -13260,7 +13256,6 @@ ['~' (rune sig %ktsg expa)] ['=' (rune tis %ktts expj)] ['?' (rune wut %ktwt expa)] - ['%' (rune cen %ktcn expa)] ['*' (rune tar %kttr exqa)] [':' (rune col %ktcl exqa)] == From 1a0b082de26915e972d84d2d4e2daf2049457d38 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 24 Nov 2020 00:18:23 -0800 Subject: [PATCH 689/933] hoon: WIP remove fab:ut --- pkg/arvo/sys/hoon.hoon | 43 ++++++++++++------------------------------ 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index d89d601fc9..63146db83d 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -7540,7 +7540,7 @@ nut=*(unit note) def=*(unit hoon) == - |_ {fab/? mod/spec} + |_ mod=spec :: ++ autoname :: derive name from spec @@ -8195,7 +8195,6 @@ %open open %rake rake == - =+ fab=`?`& |_ gen/hoon :: ++ grip @@ -8352,9 +8351,9 @@ ?- gen {~ *} [%cnts [[%& p.gen] ~] ~] :: - {$base *} ~(factory ax fab `spec`gen) - {$bust *} ~(example ax fab %base p.gen) - {$ktcl *} ~(factory ax fab p.gen) + {$base *} ~(factory ax `spec`gen) + {$bust *} ~(example ax %base p.gen) + {$ktcl *} ~(factory ax p.gen) {$dbug *} q.gen {$eror *} ~>(%slog.[0 leaf/p.gen] !!) :: @@ -8392,7 +8391,7 @@ [%$ ~] :: $ [[[%a ~] [%tsgl [%$ 3] [%limb %a]]] ~] :: a +.a :: - {$leaf *} ~(factory ax fab `spec`gen) + {$leaf *} ~(factory ax `spec`gen) {$limb *} [%cnts [p.gen ~] ~] {$tell *} [%cncl [%limb %noah] [%zpgr [%cltr p.gen]] ~] {$wing *} [%cnts p.gen ~] @@ -8456,7 +8455,7 @@ i.p.gen [i.p.gen $(p.gen t.p.gen)] :: - {$kttr *} [%ktsg ~(example ax fab p.gen)] + {$kttr *} [%ktsg ~(example ax p.gen)] {$cncb *} [%ktls [%wing p.gen] %cnts p.gen q.gen] {$cndt *} [%cncl q.gen [p.gen ~]] {$cnkt *} [%cncl p.gen q.gen r.gen s.gen ~] @@ -8489,7 +8488,7 @@ (turn r.gen |=({p/wing q/hoon} [p [%tsgr [%$ 3] q]])) :: {$ktdt *} [%ktls [%cncl p.gen q.gen ~] q.gen] - {$kthp *} [%ktls ~(example ax fab p.gen) q.gen] + {$kthp *} [%ktls ~(example ax p.gen) q.gen] {$ktts *} (grip(gen q.gen) p.gen) :: {$sgbr *} @@ -8607,10 +8606,10 @@ == :: :: {$mcmc *} :: ;; - [%cnhp ~(factory ax fab p.gen) q.gen] + [%cnhp ~(factory ax p.gen) q.gen] :: {$tsbr *} - [%tsls ~(example ax fab p.gen) q.gen] + [%tsls ~(example ax p.gen) q.gen] :: {$tstr *} :+ %tsgl @@ -8688,7 +8687,7 @@ :: {$wtpt *} [%wtcl [%wtts [%base %atom %$] p.gen] q.gen r.gen] {$wtsg *} [%wtcl [%wtts [%base %null] p.gen] q.gen r.gen] - {$wtts *} [%fits ~(example ax fab p.gen) q.gen] + {$wtts *} [%fits ~(example ax p.gen) q.gen] {$wtzp *} [%wtcl p.gen [%rock %f 1] [%rock %f 0]] {$zpgr *} [%cncl [%limb %onan] [%zpmc [%kttr [%bcmc %limb %abel]] p.gen] ~] @@ -8731,7 +8730,6 @@ %fan fan %rib rib %vet vet - %fab fab %blow blow %burp burp %busk busk @@ -8772,7 +8770,6 @@ =+ :* fan=*(set {type hoon}) rib=*(set {type type hoon}) vet=`?`& - fab=`?`& == =+ sut=`type`%noun |% @@ -8928,7 +8925,7 @@ %name (face term.skin $(skin skin.skin)) %over $(skin skin.skin, sut (~(play ut sut) %wing wing.skin)) %spec =/ yon $(skin skin.skin) - =/ hit (~(play ut sut) ~(example ax fab spec.skin)) + =/ hit (~(play ut sut) ~(example ax spec.skin)) ?> (~(nest ut hit) & yon) hit %wash =- $(ref (~(play ut ref) -)) @@ -9018,18 +9015,6 @@ == -- :: - ++ bleu - |= {gol/type gen/hoon} - ^- {type nock} - =+ pro=(mint gol gen) - =+ jon=(apex:musk bran q.pro) - ?: |(?=(~ jon) ?=($wait -.u.jon)) - ?: &(!fab vet) - ~& %bleu-fail - !! - [p.pro q.pro] - [p.pro %1 p.u.jon] - :: ++ blow |= {gol/type gen/hoon} ^- {type nock} @@ -9684,7 +9669,6 @@ [dox p.q] ?> ?=($wet -.q) :: ~_ (dunk(sut [%cell q.q.p p.p]) %fire-wet) - :: =. p.p ?:(fab p.p (redo(sut p.p) q.q.p)) =. p.p (redo(sut p.p) q.q.p) ?> ?| !vet (~(has in rib) [sut dox p.q]) @@ -9782,9 +9766,6 @@ :: produce lazy core generator for static execution :: |= [nym=(unit term) hud=poly dom=(map term tome)] - :: only one layer of fabrication analysis - :: - =. fab & ~+ ^- seminoun =+ %hemp-141 @@ -9861,7 +9842,7 @@ ~/ %chip |= {how/? gen/hoon} ^- type ?: ?=({$wtts *} gen) - (cool how q.gen (play ~(example ax fab p.gen))) + (cool how q.gen (play ~(example ax p.gen))) ?: ?=({$wthx *} gen) =+ (play %wing q.gen) ~> %slog.[0 [%leaf "chipping"]] From f8bf1f6d3c46aa826e07d18d757298e8c21fb847 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 24 Nov 2020 00:19:48 -0800 Subject: [PATCH 690/933] u3: WIP removes fab:ut --- pkg/urbit/include/jets/q.h | 4 +--- pkg/urbit/jets/f/ut_mint.c | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/urbit/include/jets/q.h b/pkg/urbit/include/jets/q.h index 7dd0c5ddcc..3f25452cae 100644 --- a/pkg/urbit/include/jets/q.h +++ b/pkg/urbit/include/jets/q.h @@ -262,8 +262,6 @@ # define u3qfu_van_fan 28 # define u3qfu_van_rib 58 -# define u3qfu_van_vrf 59 -# define u3qfu_van_vet 118 -# define u3qfu_van_fab 119 +# define u3qfu_van_vet 59 void u3qf_test(const c3_c*, u3_noun); diff --git a/pkg/urbit/jets/f/ut_mint.c b/pkg/urbit/jets/f/ut_mint.c index 005b3217c6..b3446f0e09 100644 --- a/pkg/urbit/jets/f/ut_mint.c +++ b/pkg/urbit/jets/f/ut_mint.c @@ -18,8 +18,8 @@ u3wfu_mint(u3_noun cor) } else { c3_m fun_m = 141 + c3__mint; - u3_noun vrf = u3r_at(u3qfu_van_vrf, van); - u3_noun key = u3z_key_5(fun_m, vrf, sut, gol, gen, bat); + u3_noun vet = u3r_at(u3qfu_van_vet, van); + u3_noun key = u3z_key_5(fun_m, vet, sut, gol, gen, bat); u3_weak pro = u3z_find(key); if ( u3_none != pro ) { From 319a940c88937b4ee98d38415199094627d58fbd Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Sun, 7 Jun 2020 15:03:46 +0200 Subject: [PATCH 691/933] bip32: adds network type option for xpub/priv --- pkg/arvo/lib/bip32.hoon | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/pkg/arvo/lib/bip32.hoon b/pkg/arvo/lib/bip32.hoon index 22a128e940..edd9a929de 100644 --- a/pkg/arvo/lib/bip32.hoon +++ b/pkg/arvo/lib/bip32.hoon @@ -67,9 +67,9 @@ ?> =(0 x) :: sanity check %. [d i p] =< set-metadata - =+ v=(scag 4 t) - ?: =("xprv" v) (from-private k c) - ?: =("xpub" v) (from-public k c) + =+ v=(swag [1 3] t) + ?: =("prv" v) (from-private k c) + ?: =("pub" v) (from-public k c) !! :: ++ set-metadata @@ -169,11 +169,13 @@ ++ fingerprint (cut 3 [16 4] identity) :: ++ prv-extended - %+ en-b58c-bip32 0x488.ade4 + |= network=?(%main %regtest %testnet) + %+ en-b58c-bip32 (version-bytes network %prv %.y) (build-extended private-key) :: ++ pub-extended - %+ en-b58c-bip32 0x488.b21e + |= network=?(%main %regtest %testnet) + %+ en-b58c-bip32 (version-bytes network %pub %.y) (build-extended public-key) :: ++ build-extended @@ -188,6 +190,7 @@ :: ++ en-b58c-bip32 |= [v=@ k=@] + %- en-base58:mimes:html (en-base58check [4 v] [74 k]) :: :: base58check @@ -196,7 +199,6 @@ :: v: version bytes :: d: data |= [v=byts d=byts] - %- en-base58:mimes:html =+ p=[(add wid.v wid.d) (can 3 ~[d v])] =- (can 3 ~[4^- p]) %^ rsh 3 28 @@ -213,4 +215,19 @@ ++ hash160 |= d=@ (ripemd-160:ripemd:crypto 32 (sha-256:sha d)) +:: +++ version-bytes + |= [network=?(%main %regtest %testnet) type=?(%pub %prv) bip32=?] + ^- @ux + |^ + ?- type + %pub ?:(bip32 xpub-key pay-to-pubkey) + %prv ?:(bip32 xprv-key private-key) + == + :: + ++ pay-to-pubkey ?:(=(network %main) 0x0 0x6f) + ++ private-key ?:(=(network %main) 0x80 0xef) + ++ xpub-key ?:(=(network %main) 0x488.b21e 0x435.87cf) + ++ xprv-key ?:(=(network %main) 0x488.ade4 0x435.8394) + -- -- From 16b7255f62a5c83b1d384f07d91e95bcc9a8b184 Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Sun, 7 Jun 2020 15:05:04 +0200 Subject: [PATCH 692/933] bip32: adds network option for bitcoin addresses --- pkg/arvo/lib/bip32.hoon | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/arvo/lib/bip32.hoon b/pkg/arvo/lib/bip32.hoon index edd9a929de..f34b942800 100644 --- a/pkg/arvo/lib/bip32.hoon +++ b/pkg/arvo/lib/bip32.hoon @@ -168,6 +168,16 @@ ++ identity (hash160 public-key) ++ fingerprint (cut 3 [16 4] identity) :: +++ address + |= network=?(%main %regtest %testnet) + ^- @uc + :: removes checksum + :: + %^ rsh 3 4 + %+ en-base58check + [4 (version-bytes network %pub %.n)] + [20 identity] +:: ++ prv-extended |= network=?(%main %regtest %testnet) %+ en-b58c-bip32 (version-bytes network %prv %.y) From be68b32d36e19b32ff1c5d31b53a29880f5b64ff Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Sun, 7 Jun 2020 15:07:42 +0200 Subject: [PATCH 693/933] tests: checks bip32 for xpub/xprv/pif/address --- pkg/arvo/tests/lib/bip32.hoon | 552 ++++++++++++++++++++++++++-------- 1 file changed, 434 insertions(+), 118 deletions(-) diff --git a/pkg/arvo/tests/lib/bip32.hoon b/pkg/arvo/tests/lib/bip32.hoon index 6045d989c8..9ffd912458 100644 --- a/pkg/arvo/tests/lib/bip32.hoon +++ b/pkg/arvo/tests/lib/bip32.hoon @@ -7,7 +7,18 @@ =, bip32 :: |% -+$ vector [mk=byts dp=tape id=@ux sk=@ux pk=@ux cc=@ux] ++$ vector + $: mk=byts + pf=@ux + dp=tape + ad=@uc + id=@ux + sk=@ux + pk=@ux + cc=@ux + xpub=tape + xprv=tape + == :: ++ test-vectors ^- tang @@ -20,149 +31,454 @@ (zing (turn vectors check-sk)) %+ category "chaincode" (zing (turn vectors check-cc)) + %+ category "fingerprint" + (zing (turn vectors check-pf)) + %+ category "address-from-xprv" + (zing (check-addr-xprv vectors)) + %+ category "address-from-xpub" + (zing (check-addr-xpub vectors)) + %+ category "extended-private" + (zing (turn vectors check-xprv)) + %+ category "extended-public" + (zing (turn vectors check-xpub)) == :: ++ check-id |= vector + =/ identity=@ux + =< identity + ?: =("m" dp) + (from-seed mk) + (derive-path:(from-seed mk) dp) %+ expect-eq !> id - !> `@ux`identity:(derive-path:(from-seed mk) dp) + !> identity :: ++ check-pk |= vector + =/ public-key=@ux + =< public-key + ?: =("m" dp) + (from-seed mk) + (derive-path:(from-seed mk) dp) %+ expect-eq !> pk - !> `@ux`public-key:(derive-path:(from-seed mk) dp) + !> public-key :: ++ check-sk |= vector + =/ private-key=@ux + =< private-key + ?: =("m" dp) + (from-seed mk) + (derive-path:(from-seed mk) dp) %+ expect-eq !> sk - !> `@ux`private-key:(derive-path:(from-seed mk) dp) + !> private-key :: ++ check-cc |= vector + =/ chain-code=@ux + =< chain-code + ?: =("m" dp) + (from-seed mk) + (derive-path:(from-seed mk) dp) %+ expect-eq !> cc - !> `@ux`chain-code:(derive-path:(from-seed mk) dp) + !> chain-code + :: + ++ check-pf + |= vector + =/ parent-fingerprint=@ux + =< fingerprint + ?: =("m" dp) + (from-seed mk) + (derive-path:(from-seed mk) dp) + %+ expect-eq + !> pf + !> parent-fingerprint + :: + ++ check-addr-xprv + |= vectors=(list vector) + ?> ?=(^ vectors) + =/ base=vector i.vectors + =/ tests=(list vector) t.vectors + |- ^- (list tang) + ?~ tests ~ + =* deriv i.tests + :_ %_ $ + tests t.tests + base ?:(=(dp.deriv "m") deriv base) + == + :: force success before starting second round of vectors + :: + ?: =(dp.deriv "m") *tang + =/ address=@uc + =< (address %main) + (derive-path:(from-extended xprv.base) dp.deriv) + %+ expect-eq + !> ad.deriv + !> address + :: + ++ check-addr-xpub + |= vectors=(list vector) + :: we can only derive non-hardened keys from an xpub key + :: e.g. from m/0'/1/2' to m/0'/1/2'/2/1000000000 + :: + ?> ?=([^ ^ ^ ^ *] vectors) + =/ base=vector i.t.t.t.vectors + =/ tests=(list vector) t.t.t.t.vectors + |- ^- (list tang) + ?~ tests ~ + =* deriv i.tests + :_ :: Second list of vectors has hardened paths. we skip those. + :: + $(tests ?:(=(dp.deriv "m") ~ t.tests), base base) + ?: =(dp.deriv "m") *tang + :: strips the hardened part of the path (at index=9) + :: m/0'/1/2'/2 + :: --------^ + :: + =. dp.deriv ['m' q:(trim 9 dp.deriv)] + =/ address=@uc + =< (address %main) + (derive-path:(from-extended xpub.base) dp.deriv) + %+ expect-eq + !> ad.deriv + !> address + :: + ++ check-xprv + |= vector + =/ extended-xprv=tape + =< (prv-extended %main) + ?: =("m" dp) + (from-seed mk) + (derive-path:(from-seed mk) dp) + %+ expect-eq + !> xprv + !> extended-xprv + :: + ++ check-xpub + |= vector + =/ extended-pub=tape + =< (pub-extended %main) + ?: =("m" dp) + (from-seed mk) + (derive-path:(from-seed mk) dp) + %+ expect-eq + !> xpub + !> extended-pub :: ++ vectors ^- (list vector) - :~ - :* - 16^0x1.0203.0405.0607.0809.0a0b.0c0d.0e0f - "m/0'" - 0x5c1b.d648.ed23.aa5f.d50b.a52b.2457.c11e.9e80.a6a7 - 0xedb2.e14f.9ee7.7d26.dd93.b4ec.ede8.d16e.d408.ce14.9b6c.d80b.0715.a2d9.11a0.afea - 0x3.5a78.4662.a4a2.0a65.bf6a.ab9a.e98a.6c06.8a81.c52e.4b03.2c0f.b540.0c70.6cfc.cc56 - 0x47fd.acbd.0f10.9704.3b78.c63c.20c3.4ef4.ed9a.111d.9800.47ad.1628.2c7a.e623.6141 - == - :: - :* - 16^0x1.0203.0405.0607.0809.0a0b.0c0d.0e0f - "m/0'/1" - 0xbef5.a2f9.a56a.94aa.b124.59f7.2ad9.cf8c.f19c.7bbe - 0x3c6c.b8d0.f6a2.64c9.1ea8.b503.0fad.aa8e.538b.020f.0a38.7421.a12d.e931.9dc9.3368 - 0x3.501e.454b.f007.51f2.4b1b.489a.a925.215d.66af.2234.e389.1c3b.21a5.2bed.b3cd.711c - 0x2a78.5763.1386.ba23.daca.c341.80dd.1983.734e.444f.dbf7.7404.1578.e9b6.adb3.7c19 - == - :: - :* - 16^0x1.0203.0405.0607.0809.0a0b.0c0d.0e0f - "m/0'/1/2'" - 0xee7a.b90c.de56.a8c0.e2bb.086a.c497.48b8.db9d.ce72 - 0xcbce.0d71.9ecf.7431.d88e.6a89.fa14.83e0.2e35.092a.f60c.042b.1df2.ff59.fa42.4dca - 0x3.57bf.e1e3.41d0.1c69.fe56.5430.9956.cbea.5168.22fb.a8a6.0174.3a01.2a78.96ee.8dc2 - 0x446.6b9c.c8e1.61e9.6640.9ca5.2986.c584.f07e.9dc8.1f73.5db6.83c3.ff6e.c7b1.503f - == - :: - :* - 16^0x1.0203.0405.0607.0809.0a0b.0c0d.0e0f - "m/0'/1/2'/2" - 0xd880.d7d8.9384.8509.a62d.8fb7.4e32.148d.ac68.412f - 0xf47.9245.fb19.a38a.1954.c5c7.c0eb.ab2f.9bdf.d96a.1756.3ef2.8a6a.4b1a.2a76.4ef4 - 0x2.e844.5082.a72f.29b7.5ca4.8748.a914.df60.622a.609c.acfc.e8ed.0e35.8045.6074.1d29 - 0xcfb7.1883.f016.76f5.87d0.23cc.53a3.5bc7.f88f.724b.1f8c.2892.ac12.75ac.822a.3edd - == - :: - :* - 16^0x1.0203.0405.0607.0809.0a0b.0c0d.0e0f - "m/0'/1/2'/2/1000000000" - 0xd69a.a102.255f.ed74.3782.78c7.8127.01ea.641f.df32 - 0x471b.76e3.89e5.28d6.de6d.8168.57e0.12c5.4550.51ca.d666.0850.e583.72a6.c3e6.e7c8 - 0x2.2a47.1424.da5e.6574.99d1.ff51.cb43.c474.81a0.3b1e.77f9.51fe.64ce.c9f5.a48f.7011 - 0xc783.e67b.921d.2beb.8f6b.389c.c646.d726.3b41.4570.1dad.d216.1548.a8b0.78e6.5e9e - == - :: - :* - 64^0xfffc.f9f6.f3f0.edea.e7e4.e1de.dbd8.d5d2. + :~ :* 16^0x1.0203.0405.0607.0809.0a0b.0c0d.0e0f + 0x3442.193e + "m" + 0c15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma + 0x3442.193e.1bb7.0916.e914.5521.72cd.4e2d.bc9d.f811 + :: + 0xe8f3.2e72.3dec.f405.1aef.ac8e.2c93.c9c5. + b214.3138.17cd.b01a.1494.b917.c843.6b35 + :: + 0x3.39a3.6013.3015.97da.ef41.fbe5.93a0.2cc5. + 13d0.b555.27ec.2df1.050e.2e8f.f49c.85c2 + :: + 0x873d.ff81.c02f.5256.23fd.1fe5.167e.ac3a. + 55a0.49de.3d31.4bb4.2ee2.27ff.ed37.d508 + :: + %+ weld + "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2g" + "Z29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8" + :: + %+ weld + "xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiC" + "hkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi" + == + :: + :* 16^0x1.0203.0405.0607.0809.0a0b.0c0d.0e0f + 0x5c1b.d648 + "m/0'" + 0c19Q2WoS5hSS6T8GjhK8KZLMgmWaq4neXrh + 0x5c1b.d648.ed23.aa5f.d50b.a52b.2457.c11e.9e80.a6a7 + :: + 0xedb2.e14f.9ee7.7d26.dd93.b4ec.ede8.d16e. + d408.ce14.9b6c.d80b.0715.a2d9.11a0.afea + :: + 0x3.5a78.4662.a4a2.0a65.bf6a.ab9a.e98a.6c06. + 8a81.c52e.4b03.2c0f.b540.0c70.6cfc.cc56 + :: + 0x47fd.acbd.0f10.9704.3b78.c63c.20c3.4ef4. + ed9a.111d.9800.47ad.1628.2c7a.e623.6141 + :: + %+ weld + "xpub68Gmy5EdvgibQVfPdqkBBCHxA5htiqg55crXYuXoQRKfDBFA1WEjWgP6" + "LHhwBZeNK1VTsfTFUHCdrfp1bgwQ9xv5ski8PX9rL2dZXvgGDnw" + :: + %+ weld + "xprv9uHRZZhk6KAJC1avXpDAp4MDc3sQKNxDiPvvkX8Br5ngLNv1TxvUxt4c" + "V1rGL5hj6KCesnDYUhd7oWgT11eZG7XnxHrnYeSvkzY7d2bhkJ7" + == + :: + :* 16^0x1.0203.0405.0607.0809.0a0b.0c0d.0e0f + 0xbef5.a2f9 + "m/0'/1" + 0c1JQheacLPdM5ySCkrZkV66G2ApAXe1mqLj + 0xbef5.a2f9.a56a.94aa.b124.59f7.2ad9.cf8c.f19c.7bbe + :: + 0x3c6c.b8d0.f6a2.64c9.1ea8.b503.0fad.aa8e. + 538b.020f.0a38.7421.a12d.e931.9dc9.3368 + :: + 0x3.501e.454b.f007.51f2.4b1b.489a.a925.215d. + 66af.2234.e389.1c3b.21a5.2bed.b3cd.711c + :: + 0x2a78.5763.1386.ba23.daca.c341.80dd.1983. + 734e.444f.dbf7.7404.1578.e9b6.adb3.7c19 + :: + %+ weld + "xpub6ASuArnXKPbfEwhqN6e3mwBcDTgzisQN1wXN9BJcM47sSikHjJf3UFHKk" + "NAWbWMiGj7Wf5uMash7SyYq527Hqck2AxYysAA7xmALppuCkwQ" + :: + %+ weld + "xprv9wTYmMFdV23N2TdNG573QoEsfRrWKQgWeibmLntzniatZvR9BmLnvSxqu5" + "3Kw1UmYPxLgboyZQaXwTCg8MSY3H2EU4pWcQDnRnrVA1xe8fs" + == + :: + :* 16^0x1.0203.0405.0607.0809.0a0b.0c0d.0e0f + 0xee7a.b90c + "m/0'/1/2'" + 0c1NjxqbA9aZWnh17q1UW3rB4EPu79wDXj7x + 0xee7a.b90c.de56.a8c0.e2bb.086a.c497.48b8.db9d.ce72 + :: + 0xcbce.0d71.9ecf.7431.d88e.6a89.fa14.83e0. + 2e35.092a.f60c.042b.1df2.ff59.fa42.4dca + :: + 0x3.57bf.e1e3.41d0.1c69.fe56.5430.9956.cbea. + 5168.22fb.a8a6.0174.3a01.2a78.96ee.8dc2 + :: + 0x446.6b9c.c8e1.61e9.6640.9ca5.2986.c584.f07e. + 9dc8.1f73.5db6.83c3.ff6e.c7b1.503f + :: + %+ weld + "xpub6D4BDPcP2GT577Vvch3R8wDkScZWzQzMMUm3PWbmWvVJrZwQY4VUNgqFJPM" + "M3No2dFDFGTsxxpG5uJh7n7epu4trkrX7x7DogT5Uv6fcLW5" + :: + %+ weld + "xprv9z4pot5VBttmtdRTWfWQmoH1taj2axGVzFqSb8C9xaxKymcFzXBDptWmT7F" + "wuEzG3ryjH4ktypQSAewRiNMjANTtpgP4mLTj34bhnZX7UiM" + == + :: + :* 16^0x1.0203.0405.0607.0809.0a0b.0c0d.0e0f + 0xd880.d7d8 + "m/0'/1/2'/2" + 0c1LjmJcdPnDHhNTUgrWyhLGnRDKxQjoxAgt + 0xd880.d7d8.9384.8509.a62d.8fb7.4e32.148d.ac68.412f + :: + 0xf47.9245.fb19.a38a.1954.c5c7.c0eb.ab2f. + 9bdf.d96a.1756.3ef2.8a6a.4b1a.2a76.4ef4 + :: + 0x2.e844.5082.a72f.29b7.5ca4.8748.a914.df60. + 622a.609c.acfc.e8ed.0e35.8045.6074.1d29 + :: + 0xcfb7.1883.f016.76f5.87d0.23cc.53a3.5bc7. + f88f.724b.1f8c.2892.ac12.75ac.822a.3edd + :: + %+ weld + "xpub6FHa3pjLCk84BayeJxFW2SP4XRrFd1JYnxeLeU8EqN3vDfZmbqBqaGJAyiL" + "jTAwm6ZLRQUMv1ZACTj37sR62cfN7fe5JnJ7dh8zL4fiyLHV" + :: + %+ weld + "xprvA2JDeKCSNNZky6uBCviVfJSKyQ1mDYahRjijr5idH2WwLsEd4Hsb2Tyh8Rf" + "QMuPh7f7RtyzTtdrbdqqsunu5Mm3wDvUAKRHSC34sJ7in334" + == + :: + :* 16^0x1.0203.0405.0607.0809.0a0b.0c0d.0e0f + 0xd69a.a102 + "m/0'/1/2'/2/1000000000" + 0c1LZiqrop2HGR4qrH1ULZPyBpU6AUP49Uam + 0xd69a.a102.255f.ed74.3782.78c7.8127.01ea.641f.df32 + :: + 0x471b.76e3.89e5.28d6.de6d.8168.57e0.12c5. + 4550.51ca.d666.0850.e583.72a6.c3e6.e7c8 + :: + 0x2.2a47.1424.da5e.6574.99d1.ff51.cb43.c474. + 81a0.3b1e.77f9.51fe.64ce.c9f5.a48f.7011 + :: + 0xc783.e67b.921d.2beb.8f6b.389c.c646.d726. + 3b41.4570.1dad.d216.1548.a8b0.78e6.5e9e + :: + %+ weld + "xpub6H1LXWLaKsWFhvm6RVpEL9P4KfRZSW7abD2ttkWP3SSQvnyA8FSVqNTEcYF" + "gJS2UaFcxupHiYkro49S8yGasTvXEYBVPamhGW6cFJodrTHy" + :: + %+ weld + "xprvA41z7zogVVwxVSgdKUHDy1SKmdb533PjDz7J6N6mV6uS3ze1ai8FHa8kmHS" + "cGpWmj4WggLyQjgPie1rFSruoUihUZREPSL39UNdE3BBDu76" + == + :: + :* 64^0xfffc.f9f6.f3f0.edea.e7e4.e1de.dbd8.d5d2. + cfcc.c9c6.c3c0.bdba.b7b4.b1ae.aba8.a5a2.9f9c.9996.9390.8d8a. + 8784.817e.7b78.7572.6f6c.6966.6360.5d5a.5754.514e.4b48.4542 + :: + 0xbd16.bee5 + "m" + 0c1JEoxevbLLG8cVqeoGKQiAwoWbNYSUyYjg + 0xbd16.bee5.3961.a47d.6ad8.88e2.9545.434a.89bd.fe95 + :: + 0x4b03.d6fc.3404.55b3.63f5.1020.ad3e.cca4. + f085.0280.cf43.6c70.c727.923f.6db4.6c3e + :: + 0x3.cbca.a9c9.8c87.7a26.977d.0082.5c95.6a23. + 8e8d.ddfb.d322.cce4.f74b.0b5b.d6ac.e4a7 + :: + 0x6049.9f80.1b89.6d83.179a.4374.aeb7.822a. + aeac.eaa0.db1f.85ee.3e90.4c4d.efbd.9689 + :: + %+ weld + "xpub661MyMwAqRbcFW31YEwpkMuc5THy2PSt5bDMsktWQcFF8syAmRUapSCGu8E" + "D9W6oDMSgv6Zz8idoc4a6mr8BDzTJY47LJhkJ8UB7WEGuduB" + :: + %+ weld + "xprv9s21ZrQH143K31xYSDQpPDxsXRTUcvj2iNHm5NUtrGiGG5e2DtALGdso3pG" + "z6ssrdK4PFmM8NSpSBHNqPqm55Qn3LqFtT2emdEXVYsCzC2U" + == + :: + :* 64^0xfffc.f9f6.f3f0.edea.e7e4.e1de.dbd8.d5d2. + cfcc.c9c6.c3c0.bdba.b7b4.b1ae.aba8.a5a2.9f9c.9996.9390.8d8a. + 8784.817e.7b78.7572.6f6c.6966.6360.5d5a.5754.514e.4b48.4542 + :: + 0x5a61.ff8e + "m/0" + 0c19EuDJdgfRkwCmRzbzVBHZWQG9QNWhftbZ + 0x5a61.ff8e.b7aa.ca30.10db.97eb.da76.1216.10b7.8096 + :: + 0xabe7.4a98.f6c7.eabe.e042.8f53.798f.0ab8. + aa1b.d378.7399.9041.703c.742f.15ac.7e1e + :: + 0x2.fc9e.5af0.ac8d.9b3c.ecfe.2a88.8e21.17ba. + 3d08.9d85.8588.6c9c.826b.6b22.a98d.12ea + :: + 0xf090.9aff.aa7e.e7ab.e5dd.4e10.0598.d4dc. + 53cd.709d.5a5c.2cac.40e7.412f.232f.7c9c + :: + %+ weld + "xpub69H7F5d8KSRgmmdJg2KhpAK8SR3DjMwAdkxj3ZuxV27CprR9LgpeyGmXUbC" + "6wb7ERfvrnKZjXoUmmDznezpbZb7ap6r1D3tgFxHmwMkQTPH" + :: + %+ weld + "xprv9vHkqa6EV4sPZHYqZznhT2NPtPCjKuDKGY38FBWLvgaDx45zo9WQRUT3dKY" + "njwih2yJD9mkrocEZXo1ex8G81dwSM1fwqWpWkeS3v86pgKt" + == + :: + :* 64^0xfffc.f9f6.f3f0.edea.e7e4.e1de.dbd8.d5d2. cfcc.c9c6.c3c0.bdba.b7b4.b1ae.aba8.a5a2. 9f9c.9996.9390.8d8a.8784.817e.7b78.7572. 6f6c.6966.6360.5d5a.5754.514e.4b48.4542 - "m/0" - 0x5a61.ff8e.b7aa.ca30.10db.97eb.da76.1216.10b7.8096 - 0xabe7.4a98.f6c7.eabe.e042.8f53.798f.0ab8. - aa1b.d378.7399.9041.703c.742f.15ac.7e1e - 0x2.fc9e.5af0.ac8d.9b3c.ecfe.2a88.8e21.17ba. - 3d08.9d85.8588.6c9c.826b.6b22.a98d.12ea - 0xf090.9aff.aa7e.e7ab.e5dd.4e10.0598.d4dc.53cd.709d.5a5c.2cac.40e7.412f.232f.7c9c - == - :: - :* - 64^0xfffc.f9f6.f3f0.edea.e7e4.e1de.dbd8.d5d2. - cfcc.c9c6.c3c0.bdba.b7b4.b1ae.aba8.a5a2. - 9f9c.9996.9390.8d8a.8784.817e.7b78.7572. - 6f6c.6966.6360.5d5a.5754.514e.4b48.4542 - "m/0/2147483647'" - 0xd8ab.4937.36da.02f1.1ed6.82f8.8339.e720.fb03.79d1 - 0x877c.779a.d968.7164.e9c2.f4f0.f4ff.0340. - 8143.9233.0693.ce95.a58f.e18f.d52e.6e93 - 0x3.c01e.7425.647b.defa.82b1.2d9b.ad5e.3e68. - 65be.e050.2694.b94c.a58b.666a.bc0a.5c3b - 0xbe17.a268.474a.6bb9.c61e.1d72.0cf6.215e.2a88.c540.6c4a.ee7b.3854.7f58.5c9a.37d9 - == - :: - :* - 64^0xfffc.f9f6.f3f0.edea.e7e4.e1de.dbd8.d5d2. - cfcc.c9c6.c3c0.bdba.b7b4.b1ae.aba8.a5a2. - 9f9c.9996.9390.8d8a.8784.817e.7b78.7572. - 6f6c.6966.6360.5d5a.5754.514e.4b48.4542 - "m/0/2147483647'/1" - 0x7841.2e3a.2296.a40d.e124.307b.6485.bd19.833e.2e34 - 0x704a.ddf5.44a0.6e5e.e4be.a370.9846.3c23. - 613d.a320.20d6.0450.6da8.c051.8e1d.a4b7 - 0x3.a7d1.d856.deb7.4c50.8e05.031f.9895.dab5. - 4626.251b.3806.e16b.4bd1.2e78.1a7d.f5b9 - 0xf366.f48f.1ea9.f2d1.d3fe.958c.95ca.84ea.18e4.c4dd.b936.6c33.6c92.7eb2.46fb.38cb - == - :: - :* - 64^0xfffc.f9f6.f3f0.edea.e7e4.e1de.dbd8.d5d2. - cfcc.c9c6.c3c0.bdba.b7b4.b1ae.aba8.a5a2. - 9f9c.9996.9390.8d8a.8784.817e.7b78.7572. - 6f6c.6966.6360.5d5a.5754.514e.4b48.4542 - "m/0/2147483647'/1/2147483646'" - 0x31a5.07b8.1559.3dfc.51ff.c724.5ae7.e5ae.e304.246e - 0xf1c7.c871.a54a.804a.fe32.8b4c.83a1.c33b. - 8e5f.f48f.5087.273f.04ef.a83b.247d.6a2d - 0x2.d2b3.6900.396c.9282.fa14.6285.6658.2f20. - 6a5d.d0bc.c8d5.e892.6118.06ca.fb03.01f0 - 0x6378.0703.0d55.d01f.9a0c.b3a7.8395.15d7.96bd.0770.6386.a6ed.df06.cc29.a65a.0e29 - == - :: - :* - 64^0xfffc.f9f6.f3f0.edea.e7e4.e1de.dbd8.d5d2. - cfcc.c9c6.c3c0.bdba.b7b4.b1ae.aba8.a5a2. - 9f9c.9996.9390.8d8a.8784.817e.7b78.7572. - 6f6c.6966.6360.5d5a.5754.514e.4b48.4542 - "m/0/2147483647'/1/2147483646'/2" - 0x2613.2fdb.e7bf.89cb.c64c.f8da.fa3f.9f88.b866.6220 - 0xbb7d.39bd.b83e.cf58.f2fd.82b6.d918.341c. - bef4.2866.1ef0.1ab9.7c28.a484.2125.ac23 - 0x2.4d90.2e1a.2fc7.a875.5ab5.b694.c575.fce7. - 42c4.8d9f.f192.e63d.f519.3e4c.7afe.1f9c - 0x9452.b549.be8c.ea3e.cb7a.84be.c10d.cfd9.4afe.4d12.9ebf.d3b3.cb58.eedf.394e.d271 - == - == + :: + 0xd8ab.4937 + "m/0/2147483647'" + 0c1Lke9bXGhn5VPrBuXgN12uGUphrttUErmk + 0xd8ab.4937.36da.02f1.1ed6.82f8.8339.e720.fb03.79d1 + :: + 0x877c.779a.d968.7164.e9c2.f4f0.f4ff.0340. + 8143.9233.0693.ce95.a58f.e18f.d52e.6e93 + :: + 0x3.c01e.7425.647b.defa.82b1.2d9b.ad5e.3e68. + 65be.e050.2694.b94c.a58b.666a.bc0a.5c3b + :: + 0xbe17.a268.474a.6bb9.c61e.1d72.0cf6.215e. + 2a88.c540.6c4a.ee7b.3854.7f58.5c9a.37d9 + :: + %+ weld + "xpub6ASAVgeehLbnwdqV6UKMHVzgqAG8Gr6riv3Fxxpj8ksbH9ebxaEyBLZ85y" + "SDhKiLDBrQSARLq1uNRts8RuJiHjaDMBU4Zn9h8LZNnBC5y4a" + :: + %+ weld + "xprv9wSp6B7kry3Vj9m1zSnLvN3xH8RdsPP1Mh7fAaR7aRLcQMKTR2vidYEeEg" + "2mUCTAwCd6vnxVrcjfy2kRgVsFawNzmjuHc2YmYRmagcEPdU9" + == + :: + :* 64^0xfffc.f9f6.f3f0.edea.e7e4.e1de.dbd8.d5d2. + cfcc.c9c6.c3c0.bdba.b7b4.b1ae.aba8.a5a2. + 9f9c.9996.9390.8d8a.8784.817e.7b78.7572. + 6f6c.6966.6360.5d5a.5754.514e.4b48.4542 + :: + 0x7841.2e3a + "m/0/2147483647'/1" + 0c1BxrAr2pHpeBheusmd6fHDP2tSLAUa3qsW + 0x7841.2e3a.2296.a40d.e124.307b.6485.bd19.833e.2e34 + :: + 0x704a.ddf5.44a0.6e5e.e4be.a370.9846.3c23. + 613d.a320.20d6.0450.6da8.c051.8e1d.a4b7 + :: + 0x3.a7d1.d856.deb7.4c50.8e05.031f.9895.dab5. + 4626.251b.3806.e16b.4bd1.2e78.1a7d.f5b9 + :: + 0xf366.f48f.1ea9.f2d1.d3fe.958c.95ca.84ea. + 18e4.c4dd.b936.6c33.6c92.7eb2.46fb.38cb + :: + %+ weld + "xpub6DF8uhdarytz3FWdA8TvFSvvAh8dP3283MY7p2V4SeE2wyWmG5mg5EwVvm" + "dMVCQcoNJxGoWaU9DCWh89LojfZ537wTfunKau47EL2dhHKon" + :: + %+ weld + "xprv9zFnWC6h2cLgpmSA46vutJzBcfJ8yaJGg8cX1e5StJh45BBciYTRXSd25U" + "EPVuesF9yog62tGAQtHjXajPPdbRCHuWS6T8XA2ECKADdw4Ef" + == + :: + :* 64^0xfffc.f9f6.f3f0.edea.e7e4.e1de.dbd8.d5d2. + cfcc.c9c6.c3c0.bdba.b7b4.b1ae.aba8.a5a2. + 9f9c.9996.9390.8d8a.8784.817e.7b78.7572. + 6f6c.6966.6360.5d5a.5754.514e.4b48.4542 + :: + 0x31a5.07b8 + "m/0/2147483647'/1/2147483646'" + 0c15XVotxCAV7sRx1PSCkQNsGw3W9jT9A94R + 0x31a5.07b8.1559.3dfc.51ff.c724.5ae7.e5ae.e304.246e + :: + 0xf1c7.c871.a54a.804a.fe32.8b4c.83a1.c33b. + 8e5f.f48f.5087.273f.04ef.a83b.247d.6a2d + :: + 0x2.d2b3.6900.396c.9282.fa14.6285.6658.2f20. + 6a5d.d0bc.c8d5.e892.6118.06ca.fb03.01f0 + :: + 0x6378.0703.0d55.d01f.9a0c.b3a7.8395.15d7. + 96bd.0770.6386.a6ed.df06.cc29.a65a.0e29 + :: + %+ weld + "xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZR" + "krgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL" + :: + %+ weld + "xprvA1RpRA33e1JQ7ifknakTFpgNXPmW2YvmhqLQYMmrj4xJXXWYpDPS3xz7iA" + "xn8L39njGVyuoseXzU6rcxFLJ8HFsTjSyQbLYnMpCqE2VbFWc" + == + :: + :* 64^0xfffc.f9f6.f3f0.edea.e7e4.e1de.dbd8.d5d2. + cfcc.c9c6.c3c0.bdba.b7b4.b1ae.aba8.a5a2. + 9f9c.9996.9390.8d8a.8784.817e.7b78.7572. + 6f6c.6966.6360.5d5a.5754.514e.4b48.4542 + :: + 0x2613.2fdb + "m/0/2147483647'/1/2147483646'/2" + 0c14UKfRV9ZPUp6ZC9PLhqbRtxdihW9em3xt + 0x2613.2fdb.e7bf.89cb.c64c.f8da.fa3f.9f88.b866.6220 + :: + 0xbb7d.39bd.b83e.cf58.f2fd.82b6.d918.341c. + bef4.2866.1ef0.1ab9.7c28.a484.2125.ac23 + :: + 0x2.4d90.2e1a.2fc7.a875.5ab5.b694.c575.fce7. + 42c4.8d9f.f192.e63d.f519.3e4c.7afe.1f9c + :: + 0x9452.b549.be8c.ea3e.cb7a.84be.c10d.cfd9. + 4afe.4d12.9ebf.d3b3.cb58.eedf.394e.d271 + :: + %+ weld + "xpub6FnCn6nSzZAw5Tw7cgR9bi15UV96gLZhjDstkXXxvCLsUXBGXPdSnLFbd" + "pq8p9HmGsApME5hQTZ3emM2rnY5agb9rXpVGyy3bdW6EEgAtqt" + :: + %+ weld + "xprvA2nrNbFZABcdryreWet9Ea4LvTJcGsqrMzxHx98MMrotbir7yrKCEXw7n" + "adnHM8Dq38EGfSh6dqA9QWTyefMLEcBYJUuekgW4BYPJcr9E7j" + == == -- -- From fb97528fd472ba402b8e29a485007a1f1db47385 Mon Sep 17 00:00:00 2001 From: fang Date: Sat, 21 Nov 2020 22:04:18 +0100 Subject: [PATCH 694/933] arvo: unflop the spur in scry No longer use reversed paths in sley-style peek handling. --- pkg/arvo/sys/arvo.hoon | 4 ++-- pkg/arvo/sys/vane/eyre.hoon | 6 +++--- pkg/arvo/sys/vane/gall.hoon | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index 7c28d9e595..10d02a301c 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -200,7 +200,7 @@ ?. ?=(^ ved) ~ =/ ron=@tas u.hyr =/ bed=beam - [[u.fal u.dyc (case p.u.ved)] (flop tyl)] + [[u.fal u.dyc (case p.u.ved)] tyl] =/ bop=(unit (unit (cask meta))) (sod ref ~ ron bed) ?~ bop ~ @@ -453,7 +453,7 @@ [%& p.bed] q.bed `coin`[%$ r.bed] - (flop s.bed) + s.bed == :: :: |spin:plow:va: move statefully diff --git a/pkg/arvo/sys/vane/eyre.hoon b/pkg/arvo/sys/vane/eyre.hoon index 758e7d410a..6643a0c426 100644 --- a/pkg/arvo/sys/vane/eyre.hoon +++ b/pkg/arvo/sys/vane/eyre.hoon @@ -644,7 +644,7 @@ ?- -.action %gen =/ bek=beak [our desk.generator.action da+now] - =/ sup=spur (flop path.generator.action) + =/ sup=spur path.generator.action =/ ski (scry [%141 %noun] ~ %ca bek sup) =/ cag=cage (need (need ski)) ?> =(%vase p.cag) @@ -768,7 +768,7 @@ ++ do-scry |= [care=term =desk =path] ^- (unit (unit cage)) - (scry [%141 %noun] ~ care [our desk da+now] (flop path)) + (scry [%141 %noun] ~ care [our desk da+now] path) :: ++ error-response |= [status=@ud =tape] @@ -1650,7 +1650,7 @@ =* desc=tape "from {(trip have)} to json" =/ tube=(unit tube:clay) =/ tuc=(unit (unit cage)) - (scry [%141 %noun] ~ %cc [our %home da+now] (flop /[have]/json)) + (scry [%141 %noun] ~ %cc [our %home da+now] /[have]/json) ?. ?=([~ ~ *] tuc) ~ `!<(tube:clay q.u.u.tuc) ?~ tube diff --git a/pkg/arvo/sys/vane/gall.hoon b/pkg/arvo/sys/vane/gall.hoon index aecfdcc5cf..8840909ba2 100644 --- a/pkg/arvo/sys/vane/gall.hoon +++ b/pkg/arvo/sys/vane/gall.hoon @@ -473,7 +473,7 @@ |= [dap=term =case:clay] ^- (each agent tang) =/ bek=beak [our %home case] - =/ sky (ski [%141 %noun] ~ %ca bek /hoon/[dap]/app) + =/ sky (ski [%141 %noun] ~ %ca bek /app/[dap]/hoon) ?~ sky |+[leaf+"gall: {} scry blocked"]~ ?~ u.sky |+[leaf+"gall: {} scry failed"]~ =/ =cage u.u.sky @@ -903,7 +903,7 @@ =/ =case:clay da+now =/ =mars:clay [p.cage mark]:deal =/ mars-path /[a.mars]/[b.mars] - =/ sky (ski [%141 %noun] ~ %cc [our %home case] (flop mars-path)) + =/ sky (ski [%141 %noun] ~ %cc [our %home case] mars-path) ?- sky ?(~ [~ ~]) =/ ror "gall: poke cast fail :{(trip dap)} {}" @@ -1114,7 +1114,7 @@ =/ =case:clay da+now =/ bek=beak [our %home case] =/ mars-path /[a.mars]/[b.mars] - =/ sky (ski [%141 %noun] ~ %cc bek (flop mars-path)) + =/ sky (ski [%141 %noun] ~ %cc bek mars-path) ?- sky ?(~ [~ ~]) %- (slog leaf+"watch-as fact conversion find-fail" >sky< ~) @@ -1278,7 +1278,7 @@ =/ tub=(unit tube:clay) ?: =(have want) `(bake same ^vase) =/ tuc=(unit (unit cage)) - (ski [%141 %noun] ~ %cc [our %home da+now] (flop /[have]/[want])) + (ski [%141 %noun] ~ %cc [our %home da+now] /[have]/[want]) ?. ?=([~ ~ *] tuc) ~ `!<(tube:clay q.u.u.tuc) ?~ tub From 79f698c3a96bc159c411979955ed8906d4724a39 Mon Sep 17 00:00:00 2001 From: fang Date: Tue, 24 Nov 2020 02:13:46 +0100 Subject: [PATCH 695/933] hoon: add +snip and +rear Helper functions for dealing with the ends of lists. --- pkg/arvo/sys/hoon.hoon | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 2eb2a9b6b9..a3dba7c0ee 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -644,6 +644,14 @@ ?~ a ~ [b $(a (dec a))] :: +++ rear :: last item of list + ~/ %rear + |* a=(list) + ^- _?>(?=(^ a) i.a) + ?> ?=(^ a) + ?: =(~ t.a) i.a ::NOTE avoiding tmi + $(a t.a) +:: ++ reel :: right fold ~/ %reel |* {a/(list) b/_=>(~ |=({* *} +<+))} @@ -709,6 +717,14 @@ ?: =(0 a) i.b $(b t.b, a (dec a)) :: +++ snip :: drop tail off list + ~/ %snip + |* a=(list) + ^+ a + ?~ a ~ + ?: =(~ t.a) ~ + [i.a $(a t.a)] +:: ++ sort !. :: quicksort ~/ %sort |* {a/(list) b/$-({* *} ?)} From 27d6fc759745cdaa8f48e6b52e87f228760d93b3 Mon Sep 17 00:00:00 2001 From: fang Date: Tue, 24 Nov 2020 02:20:36 +0100 Subject: [PATCH 696/933] zuse, clay, various: unflop the spur in beams Unflops the spur in +en-beam, +de-beam, and everything that calls either of those, or works with the consequences of their output. This includes clay's interface for mounting and unmounting, which now no longer expects the arguments to contain an old-style spur. --- pkg/arvo/app/dojo.hoon | 6 +++--- pkg/arvo/app/test.hoon | 2 +- pkg/arvo/gen/glass.hoon | 2 +- pkg/arvo/gen/hood/mount.hoon | 2 +- pkg/arvo/gen/metal.hoon | 2 +- pkg/arvo/gen/timers.hoon | 2 +- pkg/arvo/lib/strandio.hoon | 8 ++++---- pkg/arvo/sys/vane/clay.hoon | 4 ++-- pkg/arvo/sys/zuse.hoon | 4 ++-- pkg/arvo/ted/build-cast.hoon | 2 +- pkg/arvo/ted/build-mark.hoon | 2 +- pkg/arvo/ted/diff.hoon | 2 +- pkg/arvo/ted/test.hoon | 18 +++++++++--------- pkg/arvo/tests/sys/vane/eyre.hoon | 2 +- pkg/arvo/tests/sys/zuse/format.hoon | 2 +- 15 files changed, 30 insertions(+), 30 deletions(-) diff --git a/pkg/arvo/app/dojo.hoon b/pkg/arvo/app/dojo.hoon index 254e85b14e..31bb7a4dda 100644 --- a/pkg/arvo/app/dojo.hoon +++ b/pkg/arvo/app/dojo.hoon @@ -248,7 +248,7 @@ :: =? a &(?=(^ a) =('' i.a)) t.a - (fall (de-beam:format a) [`beak`[p q r]:dir (flop a)]) + (fall (de-beam:format a) [`beak`[p q r]:dir a]) =+ vez=hoon-parser (sear plex:vez (stag %clsg poor:vez)) :: @@ -591,7 +591,7 @@ %0 ~ %1 [[%rose [~ " " ~] (skol p.q.cay) ~] maar] %2 [[%rose [~ " " ~] (dy-show-type-noun p.q.cay) ~] maar] - ::%3 handled above + ::%3 handled above %4 ~ %5 [[%rose [~ " " ~] (xskol p.q.cay) ~] maar] == @@ -1014,7 +1014,7 @@ "/" ?:(=(%home q.dir) "=" (trip q.dir)) "/" ?:(=([%ud 0] r.dir) "=" (scow r.dir)) == - ?:(=(~ s.dir) "" (spud (flop s.dir))) + ?:(=(~ s.dir) "" (spud s.dir)) :: ++ he-prom :: send prompt %- he-diff diff --git a/pkg/arvo/app/test.hoon b/pkg/arvo/app/test.hoon index 06f695d255..9c931799e4 100644 --- a/pkg/arvo/app/test.hoon +++ b/pkg/arvo/app/test.hoon @@ -67,7 +67,7 @@ |- ^+ [fex this] ?~ daz [fex this] =/ dap-pax=path /app/[i.daz]/hoon - =/ dap-arch .^(arch cy+(en-beam now-beak (flop dap-pax))) + =/ dap-arch .^(arch cy+(en-beam now-beak dap-pax)) ?~ fil.dap-arch $(daz t.daz) =/ sing=card diff --git a/pkg/arvo/gen/glass.hoon b/pkg/arvo/gen/glass.hoon index c894275098..bdfc9fc628 100644 --- a/pkg/arvo/gen/glass.hoon +++ b/pkg/arvo/gen/glass.hoon @@ -116,7 +116,7 @@ :: pax: full path at `tyl` :: lon: directory at `tyl` :: - =/ pax (en-beam:format bec tyl) + =/ pax (en-beam:format bec (flop tyl)) =/ lon .^(arch %cy pax) =? hav ?=(^ fil.lon) :: diff --git a/pkg/arvo/gen/hood/mount.hoon b/pkg/arvo/gen/hood/mount.hoon index 4b014223c5..0a4c3c8a1c 100644 --- a/pkg/arvo/gen/hood/mount.hoon +++ b/pkg/arvo/gen/hood/mount.hoon @@ -12,6 +12,6 @@ == ?~ pot =+ bem=(need (de-beam:format pax)) - $(pot ~[?^(s.bem i.s.bem q.bem)]) + $(pot ~[?^(s.bem (rear s.bem) q.bem)]) :- %kiln-mount [pax v.pot] diff --git a/pkg/arvo/gen/metal.hoon b/pkg/arvo/gen/metal.hoon index e62dd279fd..80f21f0aa3 100644 --- a/pkg/arvo/gen/metal.hoon +++ b/pkg/arvo/gen/metal.hoon @@ -256,7 +256,7 @@ :: pax: full path at `tyl` :: lon: directory at `tyl` :: - =/ pax (en-beam:format bec tyl) + =/ pax (en-beam:format bec (flop tyl)) =/ lon .^(arch %cy pax) =? hav ?=(^ fil.lon) ?. ?=({$hoon *} tyl) diff --git a/pkg/arvo/gen/timers.hoon b/pkg/arvo/gen/timers.hoon index d448fd6ac0..b016fd41c7 100644 --- a/pkg/arvo/gen/timers.hoon +++ b/pkg/arvo/gen/timers.hoon @@ -5,5 +5,5 @@ [%tang >timers< ~] .^ (list [date=@da =duct]) %bx - (en-beam:format [p.bec %$ r.bec] /timers/debug) + (en-beam:format [p.bec %$ r.bec] /debug/timers) == diff --git a/pkg/arvo/lib/strandio.hoon b/pkg/arvo/lib/strandio.hoon index 80c4178a1e..6c65f4ac7a 100644 --- a/pkg/arvo/lib/strandio.hoon +++ b/pkg/arvo/lib/strandio.hoon @@ -424,7 +424,7 @@ =/ m (strand ,vase) ^- form:m ;< =riot:clay bind:m - (warp ship desk ~ %sing %a case (flop spur)) + (warp ship desk ~ %sing %a case spur) ?~ riot (strand-fail %build-file >arg< ~) ?> =(%vase p.r.u.riot) @@ -468,7 +468,7 @@ |= [[=ship =desk =case:clay] =spur] =* arg +< =/ m (strand ,cage) - ;< =riot:clay bind:m (warp ship desk ~ %sing %x case (flop spur)) + ;< =riot:clay bind:m (warp ship desk ~ %sing %x case spur) ?~ riot (strand-fail %read-file >arg< ~) (pure:m r.u.riot) @@ -476,14 +476,14 @@ ++ check-for-file |= [[=ship =desk =case:clay] =spur] =/ m (strand ,?) - ;< =riot:clay bind:m (warp ship desk ~ %sing %x case (flop spur)) + ;< =riot:clay bind:m (warp ship desk ~ %sing %x case spur) (pure:m ?=(^ riot)) :: ++ list-tree |= [[=ship =desk =case:clay] =spur] =* arg +< =/ m (strand ,(list path)) - ;< =riot:clay bind:m (warp ship desk ~ %sing %t case (flop spur)) + ;< =riot:clay bind:m (warp ship desk ~ %sing %t case spur) ?~ riot (strand-fail %list-tree >arg< ~) (pure:m !<((list path) q.r.u.riot)) diff --git a/pkg/arvo/sys/vane/clay.hoon b/pkg/arvo/sys/vane/clay.hoon index 190face4da..0b8a4c8370 100644 --- a/pkg/arvo/sys/vane/clay.hoon +++ b/pkg/arvo/sys/vane/clay.hoon @@ -2581,7 +2581,7 @@ =- ?~(- ~ `[nam (lent s.bem) (silt `(list path)`-)]) %+ skim can |= pax/path - &(=(p.bem our) =(q.bem syd) =((flop s.bem) (scag (lent s.bem) pax))) + &(=(p.bem our) =(q.bem syd) =(s.bem (scag (lent s.bem) pax))) :: :: Mount a beam to unix :: @@ -4069,7 +4069,7 @@ !! :: fire next in queue =^ mos ruf =/ den ((de our now ski hen ruf) our q.bem) - abet:(into:den (flop s.bem) all.req fis.req) + abet:(into:den s.bem all.req fis.req) [mos ..^$] :: %merg :: direct state up diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index 149f623a5c..7c8561c5d5 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -5515,7 +5515,7 @@ ++ en-beam :: beam to path |= bem/beam ^- path - [(scot %p p.bem) q.bem (scot r.bem) (flop s.bem)] + [(scot %p p.bem) q.bem (scot r.bem) s.bem] :: :: ++de-beam:format ++ de-beam :: parse path to beam |= pax/path @@ -5528,7 +5528,7 @@ %+ biff (slay i.t.t.pax) |= cis/coin ?. ?=({$$ case} cis) ~ - `(unit beam)`[~ [who dex `case`p.cis] (flop t.t.t.pax)] + `(unit beam)`[~ [who dex `case`p.cis] t.t.t.pax] :: ++ json-rn :: json to rn parser %+ knee *rn |. diff --git a/pkg/arvo/ted/build-cast.hoon b/pkg/arvo/ted/build-cast.hoon index 26ede6ff77..cf0a1c508d 100644 --- a/pkg/arvo/ted/build-cast.hoon +++ b/pkg/arvo/ted/build-cast.hoon @@ -8,6 +8,6 @@ =+ !<([pax=path ~] arg) ?~ bem=(de-beam:format pax) (strand-fail:strand %path-not-beam >pax< ~) -=/ =mars:clay [i.t i]:?>(?=([@ @ ~] s.u.bem) s.u.bem) +=/ =mars:clay [i i.t]:?>(?=([@ @ ~] s.u.bem) s.u.bem) ;< =tube:clay bind:m (build-cast:strandio -.u.bem mars) (pure:m !>(tube)) diff --git a/pkg/arvo/ted/build-mark.hoon b/pkg/arvo/ted/build-mark.hoon index bbb1e4ba28..a134c896fe 100644 --- a/pkg/arvo/ted/build-mark.hoon +++ b/pkg/arvo/ted/build-mark.hoon @@ -8,6 +8,6 @@ =+ !<([pax=path ~] arg) ?~ bem=(de-beam:format pax) (strand-fail:strand %path-not-beam >pax< ~) -=/ =mark (head s.u.bem) +=/ =mark (rear s.u.bem) ;< =dais:clay bind:m (build-mark:strandio -.u.bem mark) (pure:m !>(dais)) diff --git a/pkg/arvo/ted/diff.hoon b/pkg/arvo/ted/diff.hoon index cd9cdc796a..580416a4a7 100644 --- a/pkg/arvo/ted/diff.hoon +++ b/pkg/arvo/ted/diff.hoon @@ -23,7 +23,7 @@ ^- form:m =/ beam (need (de-beam:format path)) ;< =riot:clay bind:m - (warp:strandio p.beam q.beam ~ %sing %x r.beam (flop s.beam)) + (warp:strandio p.beam q.beam ~ %sing %x r.beam s.beam) ?~ riot (strand-fail:strandio %file-not-found >path< ~) (pure:m r.u.riot) diff --git a/pkg/arvo/ted/test.hoon b/pkg/arvo/ted/test.hoon index d9f428ea7f..a8ec7cb2d3 100644 --- a/pkg/arvo/ted/test.hoon +++ b/pkg/arvo/ted/test.hoon @@ -80,20 +80,20 @@ =* loop $ ?~ bez (pure:m fiz) - ;< hav=? bind:m (check-for-file:strandio -.i.bez hoon+s.i.bez) + ;< hav=? bind:m (check-for-file:strandio -.i.bez (snoc s.i.bez %hoon)) ?: hav - loop(bez t.bez, fiz (~(put in fiz) [i.bez(s hoon+s.i.bez) ~])) + loop(bez t.bez, fiz (~(put in fiz) [i.bez(s (snoc s.i.bez %hoon)) ~])) ;< fez=(list path) bind:m (list-tree:strandio i.bez) ?. =(~ fez) - =/ foz (turn fez |=(path [[-.i.bez (flop +<)] ~])) + =/ foz (turn fez |=(path [[-.i.bez +<] ~])) loop(bez t.bez, fiz (~(gas in fiz) foz)) ~| bad-test-beam+i.bez - =/ tex=term =-(?>(((sane %tas) -) -) (head s.i.bez)) - =/ xup=path (tail s.i.bez) - ;< hov=? bind:m (check-for-file:strandio i.bez(s hoon+xup)) + =/ tex=term =-(?>(((sane %tas) -) -) (rear s.i.bez)) + =/ xup=path (snip s.i.bez) + ;< hov=? bind:m (check-for-file:strandio i.bez(s (snoc xup %hoon))) ?. hov ~|(no-tests-at-path+i.bez !!) - loop(bez t.bez, fiz (~(put in fiz) [[-.i.bez hoon+xup] `tex])) + loop(bez t.bez, fiz (~(put in fiz) [[-.i.bez (snoc xup %hoon)] `tex])) -- ^- thread:spider |= arg=vase @@ -107,7 +107,7 @@ |- ^- form:m =* gather-tests $ ?^ fiz - ~> %slog.0^leaf+"test: building {(spud (flop s.beam.i.fiz))}" + ~> %slog.0^leaf+"test: building {(spud s.beam.i.fiz)}" ;< cor=vase bind:m (build-file:strandio beam.i.fiz) =/ arms=(list test-arm) (get-test-arms cor) =? arms ?=(^ test.i.fiz) @@ -116,7 +116,7 @@ ?: =(name.i.arms u.test.i.fiz) [i.arms]~ $(arms t.arms) - =. test-arms (~(put by test-arms) (flop (tail s.beam.i.fiz)) arms) + =. test-arms (~(put by test-arms) (snip s.beam.i.fiz) arms) gather-tests(fiz t.fiz) %- pure:m !> ^= ok %+ roll (resolve-test-paths test-arms) diff --git a/pkg/arvo/tests/sys/vane/eyre.hoon b/pkg/arvo/tests/sys/vane/eyre.hoon index dadaafb99a..e44f5297e0 100644 --- a/pkg/arvo/tests/sys/vane/eyre.hoon +++ b/pkg/arvo/tests/sys/vane/eyre.hoon @@ -2369,7 +2369,7 @@ ++ scry-provides-code ^- sley |= [* (unit (set monk)) =term =beam] ^- (unit (unit cage)) - ?: &(=(%ca term) =(/hoon/handler/gen s.beam)) + ?: &(=(%ca term) =(/gen/handler/hoon s.beam)) :+ ~ ~ vase+!>(!>(|=(* |=(* [[%404 ~] ~])))) ?: &(=(%cb term) =(/json s.beam)) diff --git a/pkg/arvo/tests/sys/zuse/format.hoon b/pkg/arvo/tests/sys/zuse/format.hoon index 3ad678b392..25d1918e99 100644 --- a/pkg/arvo/tests/sys/zuse/format.hoon +++ b/pkg/arvo/tests/sys/zuse/format.hoon @@ -85,7 +85,7 @@ :: path) :: ++ test-beam - =/ b=beam [[p=~zod q=%home r=[%ud p=12]] s=/hoon/zuse/sys] + =/ b=beam [[p=~zod q=%home r=[%ud p=12]] s=/sys/zuse/hoon] =/ p=path /~zod/home/12/sys/zuse/hoon ;: weld :: proper encode From 38d85876d643b178f110b1cc39bc82b5966a193c Mon Sep 17 00:00:00 2001 From: fang Date: Tue, 24 Nov 2020 16:07:49 +0100 Subject: [PATCH 697/933] zuse: make octs value @ again eaa69ec had reverted the change from c46061e. --- pkg/arvo/sys/zuse.hoon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index 7c8561c5d5..653db1a2f8 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -76,7 +76,7 @@ +$ life @ud :: ship key revision +$ rift @ud :: ship continuity +$ mime (pair mite octs) :: mimetyped data -+$ octs (pair @ud cord) :: octet-stream ++$ octs (pair @ud @) :: octet-stream +$ sock (pair ship ship) :: outgoing [our his] ::+| :: @@ -6491,7 +6491,7 @@ ++ apex :: top level =+ spa=;~(pose comt whit) %+ knee *manx |. ~+ - %+ ifix + %+ ifix [;~(plug (punt decl) (star spa)) (star spa)] ;~ pose %+ sear |=({a/marx b/marl c/mane} ?.(=(c n.a) ~ (some [a b]))) From 28afe74e7d1a5ae0d9d8685d1b4ceb38147d6e86 Mon Sep 17 00:00:00 2001 From: fang Date: Tue, 24 Nov 2020 16:18:21 +0100 Subject: [PATCH 698/933] pill: update --- bin/solid.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index b3e2f7bb8d..cbbd775bbb 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ae9cf9424cb0f4ce515d477646844dfdab57a2cbd1f3b1e2d65662cce1d09654 -size 6306749 +oid sha256:d89b2dd60b56680fb290f3782ab6137488a2df9e43db726199d9f8968db5831c +size 6314841 From 6f0b7f120ba8483e7c9683bdf35af9c83e18dd01 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sat, 21 Nov 2020 13:04:04 -0800 Subject: [PATCH 699/933] arvo: refines version negotation, requires filesystem to molt --- pkg/arvo/sys/arvo.hoon | 81 +++++++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 36 deletions(-) diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index b260157259..cf0f4b883e 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -239,7 +239,8 @@ eny=@uvJ :: entropy lac=? :: laconic bit ver=vere :: runtime - fat=(node (cask)) :: + lag=_| :: upgrade blocked + fat=(node (cask)) :: filesystem zus=vase :: %zuse van=(map term vane) :: modules == @@ -344,18 +345,22 @@ :: wyr: ~: runtime supports all required kelvins :: ^: runtime support is missing or lagging :: - =; wyr + =; wyr !. + ?~ wyr + same ~& wyrd=wyr - :: XX revise hint, crash - :: - :: ?^ wyr - :: ~> %wyrd.[p.u.wyr] - :: ~_ ?~ q.u.wyr - :: leaf/"missing" - :: leaf/"wyrd: %({(trip p.p.u.wyr)} {(scow %ud q.p.u.wyr)} {(scow %ud q.u.wyr)}" - :: !! - :: - same + ~_ :+ %rose + [" " ~ ~] + :~ =+ p.u.wyr + leaf/"%{(trip p)} %{(scow %ud q)} required;" + ?~ q.u.wyr + leaf/"runtime missing support" + leaf/"runtime only supports %{(scow %ud u.q.u.wyr)}" + == + ~> %mean.'arvo: upgrade blocked' + ~> %mean.'wyrd' + !! + :: |- ^- (unit (pair (pair term @ud) (unit @ud))) ?~ hav ~ :: @@ -369,7 +374,7 @@ :: ?- -.fel %| `[p.fel ~] - %& ?.((lte q.i.hav p.fel) `[i.hav `p.fel] $(hav t.hav)) + %& ?.((lte p.fel q.i.hav) `[i.hav `p.fel] $(hav t.hav)) == :: |part: arvo structures and engines :: @@ -464,7 +469,6 @@ ++ usurp |= del=news ^- (unit (pair seed (list (pair path (cask))))) - ~& usurp/(turn ~(tap by sys.del) head) =/ hun (~(get by sys.del) /sys/hoon) =/ arv (~(get by sys.del) /sys/arvo) ?~ hun @@ -1199,7 +1203,13 @@ :: :: %crud: forward error notification :: - %crud (emit $/~ [*duct hurl/[goof.buz (gest ovum.buz)]] ~) + %crud =? lag ?& ?=(%exit mote.goof.buz) + ?=(^ tang.goof.buz) + ?=(%leaf -.i.tang.goof.buz) :: XX ?@ + ?=(%wyrd (crip p.i.tang.goof.buz)) + == + ~&(%lagging &) + (emit $/~ [*duct hurl/[goof.buz (gest ovum.buz)]] ~) :: :: XX review :: @@ -1207,14 +1217,14 @@ :: :: %wyrd: check for runtime kelvin compatibility :: - %wyrd =. ver p.buz - %- %+ wyrd kel.ver - ^- (list (pair term @)) - :~ hoon/hoon-version - arvo/arvo - zuse/;;(@ q:(slap zus limb/%zuse)) - == - ..pith + %wyrd %- %+ wyrd kel.p.buz + ^- (list (pair term @)) + :~ hoon/hoon-version + arvo/arvo + zuse/;;(@ q:(slap zus limb/%zuse)) + == + =? lag !=(rev.ver rev.p.buz) ~&(%unlagging |) + ..pith(ver p.buz) == :: ++ spam @@ -1495,7 +1505,7 @@ who=(unit ship) eny=(unit @) lac=? - ver=vere :: XX unit + ver=(unit vere) fat=(unit (node (cask))) bod=(unit (trap vase)) van=(map term (trap vase)) @@ -1519,10 +1529,10 @@ ++ molt |= [now=@da foal] ^- (unit heir) - ?. &(?=(^ who) ?=(^ eny) ?=(^ fat) ?=(^ bod)) + ?. &(?=(^ who) ?=(^ eny) ?=(^ ver) ?=(^ fat) ?=(^ bod)) ~ =/ zus $:u.bod - %- %+ wyrd kel.ver + %- %+ wyrd kel.u.ver ^- (list (pair term @)) :~ hoon/hoon-version arvo/arvo @@ -1530,7 +1540,7 @@ == =/ nav %- ~(run by van) |=(a=(trap vase) (settle:va:part (slym $:a zus))) - =/ sol [u.who u.eny lac ver u.fat zus nav] + =/ sol [u.who u.eny lac u.ver | u.fat zus nav] `[arvo now *debt sol] -- :: @@ -1587,15 +1597,14 @@ == :: %whom ..poke(who `p.gub) - %wyrd =. ver p.gub - %- %+ wyrd kel.ver - ^- (list (pair term @)) - :* hoon/hoon-version - arvo/arvo - ?~ bod ~ - [zuse/;;(@ud q:(slap $:u.bod limb/%zuse)) ~] - == - ..poke + %wyrd %- %+ wyrd kel.p.gub + ^- (list (pair term @)) + :* hoon/hoon-version + arvo/arvo + ?~ bod ~ + [zuse/;;(@ud q:(slap $:u.bod limb/%zuse)) ~] + == + ..poke(ver `p.gub) == :: ?~ hir=(molt now fol) From 15192ebd5b50ff4821b251f3c39ea766818e759c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sat, 21 Nov 2020 13:48:54 -0800 Subject: [PATCH 700/933] vere: send %wyrd during boot --- pkg/urbit/vere/pier.c | 79 +++++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 32 deletions(-) diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index 230ba3dc1a..b28fc357f7 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -701,7 +701,7 @@ _pier_on_lord_wyrd_bail(void* ptr_v, u3_ovum* egg_u, u3_noun lud) // XX add cli argument to bypass negotiation failure // -#if 0 +#if 1 // print %wyrd failure and exit // // XX check bail mote, retry on %intr, %meme, &c @@ -717,51 +717,61 @@ _pier_on_lord_wyrd_bail(void* ptr_v, u3_ovum* egg_u, u3_noun lud) #endif } +/* _pier_wyrd_init(): construct %wyrd. +*/ +static u3_noun +_pier_wyrd_card(u3_pier* pir_u) +{ + u3_lord* god_u = pir_u->god_u; + + _pier_work_time(pir_u); + u3v_numb(); + + // XX god_u not necessarily available yet, refactor call sites + // + u3_noun ver = u3nq(u3i_string(VERE_NAME), VERE_MAJOR, VERE_MINOR, VERE_PATCH); + u3_noun kel = u3nl(u3nc(c3__zuse, VERE_ZUSE), // XX god_u->zus_w + // u3nc(c3__lull, PIER_LULL), // XX define + u3nc(c3__arvo, u3i_string("arvo-kelvin")), // XX from both king and serf? + u3nc(c3__hoon, 141), // god_u->hon_y + u3nc(c3__nock, 4), // god_u->noc_y + u3_none); + u3_noun wir = u3nc(c3__arvo, u3_nul); + return u3nt(c3__wyrd, u3nc(u3k(u3A->sen), ver), kel); +} + /* _pier_wyrd_init(): send %wyrd. */ static void _pier_wyrd_init(u3_pier* pir_u) { - u3_lord* god_u = pir_u->god_u; + u3_noun cad = _pier_wyrd_card(pir_u); + u3_noun wir = u3nc(c3__arvo, u3_nul); pir_u->sat_e = u3_psat_wyrd; u3l_log("vere: checking version compatiblity\n"); - _pier_work_time(pir_u); - u3v_numb(); - { - u3_noun ver = u3nq(u3i_string(VERE_NAME), VERE_MAJOR, VERE_MINOR, VERE_PATCH); - u3_noun kel = u3nl(u3nc(c3__zuse, VERE_ZUSE), // XX god_u->zus_w - // u3nc(c3__lull, PIER_LULL), // XX define - // u3nc(c3__arvo, god_u->arv_y), // XX from both king and serf? - u3nc(c3__hoon, god_u->hon_y), - u3nc(c3__nock, god_u->noc_y), - u3_none); - u3_noun wir = u3nc(c3__arvo, u3_nul); - u3_noun cad = u3nt(c3__wyrd, u3nc(u3k(u3A->sen), ver), kel); + u3_lord* god_u = pir_u->god_u; + u3_auto* car_u = c3_calloc(sizeof(*car_u)); + u3_ovum* egg_u = u3_ovum_init(0, u3_blip, wir, cad); + u3_noun ovo; - { - u3_auto* car_u = c3_calloc(sizeof(*car_u)); - u3_ovum* egg_u = u3_ovum_init(0, u3_blip, wir, cad); - u3_noun ovo; + car_u->pir_u = pir_u; + car_u->nam_m = c3__wyrd; - car_u->pir_u = pir_u; - car_u->nam_m = c3__wyrd; + u3_auto_plan(car_u, egg_u); - u3_auto_plan(car_u, egg_u); + // instead of subscribing with u3_auto_peer(), + // we swizzle the [god_u] callbacks for full control + // + god_u->cb_u.work_done_f = _pier_on_lord_wyrd_done; + god_u->cb_u.work_bail_f = _pier_on_lord_wyrd_bail; - // instead of subscribing with u3_auto_peer(), - // we swizzle the [god_u] callbacks for full control - // - god_u->cb_u.work_done_f = _pier_on_lord_wyrd_done; - god_u->cb_u.work_bail_f = _pier_on_lord_wyrd_bail; + c3_assert( u3_auto_next(car_u, &ovo) == egg_u ); - c3_assert( u3_auto_next(car_u, &ovo) == egg_u ); - - u3_lord_work(god_u, egg_u, ovo); - } + u3_lord_work(god_u, egg_u, ovo); } } @@ -1654,7 +1664,7 @@ _pier_pill_parse(u3_noun pil) /* _pier_boot_make(): construct boot sequence */ static u3_boot -_pier_boot_make(u3_noun who, u3_noun ven, u3_noun pil) +_pier_boot_make(u3_noun who, u3_noun wyr, u3_noun ven, u3_noun pil) { u3_boot bot_u = _pier_pill_parse(pil); // transfer @@ -1672,6 +1682,9 @@ _pier_boot_make(u3_noun who, u3_noun ven, u3_noun pil) wir = u3nt(u3_blip, c3__arvo, u3_nul); cad = u3nc(c3__whom, who); // transfer bot_u.mod = u3nc(u3nc(wir, cad), bot_u.mod); + + wir = u3nt(u3_blip, c3__arvo, u3_nul); + bot_u.mod = u3nc(u3nc(wir, wyr), bot_u.mod); } // prepend legacy boot event to the userspace sequence @@ -1702,7 +1715,7 @@ _pier_boot_plan(u3_pier* pir_u, u3_noun who, u3_noun ven, u3_noun pil) pir_u->fak_o = ( c3__fake == u3h(ven) ) ? c3y : c3n; u3r_chubs(0, 2, pir_u->who_d, who); - bot_u = _pier_boot_make(who, ven, pil); + bot_u = _pier_boot_make(who, _pier_wyrd_card(pir_u), ven, pil); pir_u->lif_w = u3qb_lent(bot_u.bot); } @@ -1784,6 +1797,8 @@ u3_pier_boot(c3_w wag_w, // config flags return 0; } + // XX must be called from on_lord_live + // if ( c3n == _pier_boot_plan(pir_u, who, ven, pil) ) { fprintf(stderr, "pier: boot plan fail\r\n"); // XX dispose From a2abf1c9927cfe3227db058ba0bd9c65c0bd0e0f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sat, 21 Nov 2020 14:23:05 -0800 Subject: [PATCH 701/933] arvo: moves |de out of +node, renames +node to +axal --- pkg/arvo/sys/arvo.hoon | 123 ++++++++++++++++++++--------------------- 1 file changed, 61 insertions(+), 62 deletions(-) diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index cf0f4b883e..4ae89ab595 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -24,7 +24,9 @@ :: ++ arvo %arvo-kelvin :: -:: $arch: fundamental node +:: $arch: node identity +:: $axal: fundamental node, recursive +:: $axil: fundamental node :: $beak: global context :: $beam: global name :: $bone: opaque duct handle @@ -37,7 +39,14 @@ :: $ship: network identity :: $sink: subscription :: -+$ arch [fil=(unit @uvI) dir=(map @ta ~)] ++$ arch (axil @uvI) +++ axal + |$ [item] + [fil=(unit item) dir=(map @ta $)] :: +++ axil + |$ [item] + [fil=(unit item) dir=(map @ta ~)] +:: +$ beam [beak s=path] +$ beak (trel ship desk case) +$ bone @ud @@ -104,59 +113,6 @@ (pair cord (each * (list mass))) +$ monk (each ship (pair @tas @ta)) +$ move [=duct =ball] -:: $node: fundamental hierarchical node -:: -:: XX s/b +arch -:: -++ node - =< |$ [item] - [fil=(unit item) dir=(map @ta $)] - :: - :: |de: node engine - :: - |% - ++ de - =| fat=(node) - |@ - :: - ++ get - |= pax=path - ^+ fat - ?~ pax fat - =/ kid (~(get by dir.fat) i.pax) - ?~ kid [~ ~] - $(fat u.kid, pax t.pax) - :: - ++ put - |* [pax=path dat=*] - => .(dat `_?>(?=(^ fil.fat) u.fil.fat)`dat) - ^+ fat - ?~ pax fat(fil `dat) - =/ kid (~(get by dir.fat) i.pax) - =/ new (fall kid fat(fil ~, dir ~)) - fat(dir (~(put by dir.fat) i.pax $(fat new, pax t.pax))) - :: - ++ gas - |= lit=(list (pair path _?>(?=(^ fil.fat) u.fil.fat))) - ^+ fat - ?~ lit fat - $(fat (put p.i.lit q.i.lit), lit t.lit) - :: - ++ tap - =| pax=path - =| out=(list (pair path _?>(?=(^ fil.fat) u.fil.fat))) - |- ^+ out - =? out ?=(^ fil.fat) :_(out [pax u.fil.fat]) - =/ dir ~(tap by dir.fat) - |- ^+ out - ?~ dir out - %= $ - dir t.dir - out ^$(pax (weld pax /[p.i.dir]), fat q.i.dir) - == - -- :: de - -- :: node -:: +$ ovum (pair wire curd) :: +$ scry-sample @@ -240,7 +196,7 @@ lac=? :: laconic bit ver=vere :: runtime lag=_| :: upgrade blocked - fat=(node (cask)) :: filesystem + fat=(axal (cask)) :: filesystem zus=vase :: %zuse van=(map term vane) :: modules == @@ -376,6 +332,50 @@ %| `[p.fel ~] %& ?.((lte p.fel q.i.hav) `[i.hav `p.fel] $(hav t.hav)) == +:: +:: |de: axal engine +:: +++ de + =| fat=(axal) + |@ + :: + ++ get + |= pax=path + ^+ fat + ?~ pax fat + =/ kid (~(get by dir.fat) i.pax) + ?~ kid [~ ~] + $(fat u.kid, pax t.pax) + :: + ++ put + |* [pax=path dat=*] + => .(dat `_?>(?=(^ fil.fat) u.fil.fat)`dat) + ^+ fat + ?~ pax fat(fil `dat) + =/ kid (~(get by dir.fat) i.pax) + =/ new (fall kid fat(fil ~, dir ~)) + fat(dir (~(put by dir.fat) i.pax $(fat new, pax t.pax))) + :: + ++ gas + |= lit=(list (pair path _?>(?=(^ fil.fat) u.fil.fat))) + ^+ fat + ?~ lit fat + $(fat (put p.i.lit q.i.lit), lit t.lit) + :: + ++ tap + =| pax=path + =| out=(list (pair path _?>(?=(^ fil.fat) u.fil.fat))) + |- ^+ out + =? out ?=(^ fil.fat) :_(out [pax u.fil.fat]) + =/ dir ~(tap by dir.fat) + |- ^+ out + ?~ dir out + %= $ + dir t.dir + out ^$(pax (weld pax /[p.i.dir]), fat q.i.dir) + == + -- +:: :: |part: arvo structures and engines :: ++ part @@ -444,8 +444,7 @@ :: ++ sole |=(a=(cask) `hoof`?>(?=([%hoon @t] a) q.a)) -- - =* de de:node - |_ fat=(node (cask)) + |_ fat=(axal (cask)) :: :: +group: collate changes :: @@ -1132,7 +1131,7 @@ ++ lod |= kel=(list (pair path (cask))) ^+ ..pith - =/ fat (~(gas de:node fat) kel) + =/ fat (~(gas de fat) kel) %+ mod (~(group adapt fat) fil) %+ lien kel @@ -1506,7 +1505,7 @@ eny=(unit @) lac=? ver=(unit vere) - fat=(unit (node (cask))) + fat=(unit (axal (cask))) bod=(unit (trap vase)) van=(map term (trap vase)) == @@ -1569,7 +1568,7 @@ :: %wack ..poke(eny `p.gub) :: - %what =/ taf (fall fat *(node (cask))) + %what =/ taf (fall fat *(axal (cask))) =/ del (~(group adapt:part taf) p.gub) =/ tub (~(usurp adapt:part taf) del) ?: &(?=(^ dir.taf) ?=(^ tub)) @@ -1580,7 +1579,7 @@ =? taf =(~ dir.taf) :: XX TMI ~| %larval-need-kernel ?> ?=(^ tub) - (~(gas de:node taf) q.u.tub) + (~(gas de taf) q.u.tub) :: =^ job taf [p q]:(~(adorn adapt:part taf) del |) =? bod ?=(^ zus.job) From 3ff083e9db9865ccbe7ab8fb1a82d7ff960d6815 Mon Sep 17 00:00:00 2001 From: fang Date: Tue, 24 Nov 2020 21:12:43 +0100 Subject: [PATCH 702/933] hoon: patch up +ax callsites Some were still passing in a value for fab, which is no longer used. --- bin/solid.pill | 4 ++-- pkg/arvo/sys/hoon.hoon | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index b3e2f7bb8d..00ea068787 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ae9cf9424cb0f4ce515d477646844dfdab57a2cbd1f3b1e2d65662cce1d09654 -size 6306749 +oid sha256:745f7676156a36853fa42c8d815daced86557dac15121db6824a05d0870453d0 +size 6333329 diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 63146db83d..0bca83e8e6 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -12865,7 +12865,7 @@ %+ sear |= [=(unit term) =spec] %+ bind - ~(autoname ax & spec) + ~(autoname ax spec) |= =term =* name ?~(unit term (cat 3 u.unit (cat 3 '-' term))) [%bcts name spec] @@ -12993,7 +12993,7 @@ :: |= =spec ^- (unit hoon) - %+ bind ~(autoname ax & spec) + %+ bind ~(autoname ax spec) |=(=term `hoon`[%ktts term %kttr spec]) wyde == @@ -13723,7 +13723,7 @@ %+ sear |= =spec ^- (unit skin) - %+ bind ~(autoname ax & spec) + %+ bind ~(autoname ax spec) |= =term [%name term %spec spec %base %noun] wyde From 28a7b3782e32c2acaa7386aecc986a245eaf755b Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Tue, 24 Nov 2020 15:36:46 -0500 Subject: [PATCH 703/933] publish: add loading spinner for notebooks Fixes #4008. --- .../apps/publish/components/NotebookRoutes.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pkg/interface/src/views/apps/publish/components/NotebookRoutes.tsx b/pkg/interface/src/views/apps/publish/components/NotebookRoutes.tsx index e95f4fa7ec..6bc662d141 100644 --- a/pkg/interface/src/views/apps/publish/components/NotebookRoutes.tsx +++ b/pkg/interface/src/views/apps/publish/components/NotebookRoutes.tsx @@ -1,7 +1,7 @@ import React, { useEffect } from "react"; import { RouteComponentProps, Route, Switch } from "react-router-dom"; import GlobalApi from "~/logic/api/global"; -import { +import { Association, Associations, Graphs, @@ -55,15 +55,18 @@ export function NotebookRoutes( ( - { + if (!graph) { + return
; + } + return - )} + baseUrl={baseUrl} />; + }} /> Date: Mon, 2 Nov 2020 10:27:11 -0800 Subject: [PATCH 704/933] landscape: use overlay sigils everywhere --- .../apps/chat/components/ChatMessage.tsx | 8 +-- .../src/views/apps/links/LinkResource.tsx | 2 + .../apps/links/components/comment-item.tsx | 70 +++++++++++++++++++ .../views/apps/links/components/link-item.js | 2 +- .../OverlaySigil.tsx} | 42 ++++++++--- .../ProfileOverlay.tsx} | 25 ++++++- 6 files changed, 132 insertions(+), 17 deletions(-) create mode 100644 pkg/interface/src/views/apps/links/components/comment-item.tsx rename pkg/interface/src/views/{apps/chat/components/overlay-sigil.js => components/OverlaySigil.tsx} (76%) rename pkg/interface/src/views/{apps/chat/components/profile-overlay.js => components/ProfileOverlay.tsx} (86%) diff --git a/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx b/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx index 4299d39bc6..80cb13128f 100644 --- a/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx +++ b/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx @@ -3,7 +3,7 @@ import moment from "moment"; import _ from "lodash"; import { Box, Row, Text, Rule } from "@tlon/indigo-react"; -import { OverlaySigil } from './overlay-sigil'; +import OverlaySigil from '~/views/components/OverlaySigil'; import { uxToHex, cite, writeText } from '~/logic/lib/util'; import { Envelope, IMessage } from "~/types/chat-update"; import { Group, Association, Contacts, LocalUpdateRemoteContentPolicy } from "~/types"; @@ -191,7 +191,7 @@ export class MessageWithSigil extends PureComponent { } = this.props; const datestamp = moment.unix(msg.when / 1000).format(DATESTAMP_FORMAT); - const contact = msg.author in contacts ? contacts[msg.author] : false; + const contact = msg.author in contacts ? contacts[msg.author] : undefined; const showNickname = !hideNicknames && contact && contact.nickname; const name = showNickname ? contact.nickname : cite(msg.author); const color = contact ? `#${uxToHex(contact.color)}` : this.isDark ? '#000000' :'#FFFFFF' @@ -224,7 +224,7 @@ export class MessageWithSigil extends PureComponent { api={api} className="fl pr3 v-top pt1" /> - + { }} title={`~${msg.author}`} >{name} - {timestamp} + {timestamp} {datestamp} diff --git a/pkg/interface/src/views/apps/links/LinkResource.tsx b/pkg/interface/src/views/apps/links/LinkResource.tsx index 5b81dcd6ef..d07ea41b84 100644 --- a/pkg/interface/src/views/apps/links/LinkResource.tsx +++ b/pkg/interface/src/views/apps/links/LinkResource.tsx @@ -136,6 +136,8 @@ export function LinkResource(props: LinkResourceProps) { editCommentId={editCommentId} history={props.history} baseUrl={`${resourceUrl}/${props.match.params.index}`} + association={association} + group={group} /> ); diff --git a/pkg/interface/src/views/apps/links/components/comment-item.tsx b/pkg/interface/src/views/apps/links/components/comment-item.tsx new file mode 100644 index 0000000000..1cff57bab9 --- /dev/null +++ b/pkg/interface/src/views/apps/links/components/comment-item.tsx @@ -0,0 +1,70 @@ +import React, { Component } from 'react'; +import { Sigil } from '~/logic/lib/sigil'; +import { cite } from '~/logic/lib/util'; +import moment from 'moment'; +import { Box, Text, Row } from '@tlon/indigo-react'; +import RichText from '~/views/components/RichText'; + +import OverlaySigil from '~/views/components/OverlaySigil'; + +export const CommentItem = (props) => { + const { + contact, + color, + hideAvatars, + hideNicknames, + api, + association, + group + } = props; + const content = props.post.contents[0].text; + const sigilClass = contact ? '' : 'mix-blend-diff'; + const timeSent = + moment.unix(props.post['time-sent'] / 1000).format('hh:mm a'); + + const showAvatar = props.avatar && !props.hideAvatars; + const showNickname = props.nickname && !props.hideNicknames; + const img = showAvatar + ? + : ; + + return ( + + + + + + {showNickname ? props.nickname : cite(props.post.author)} + + {timeSent} + + + + + + {content} + + + + + ); +} + diff --git a/pkg/interface/src/views/apps/links/components/link-item.js b/pkg/interface/src/views/apps/links/components/link-item.js index c0f755a5af..16fe5c59be 100644 --- a/pkg/interface/src/views/apps/links/components/link-item.js +++ b/pkg/interface/src/views/apps/links/components/link-item.js @@ -64,7 +64,7 @@ export const LinkItem = (props) => { {showNickname ? nickname : cite(author) } - {size} comments + {size} comment{size > 1 ? 's' : null} {(ourRole === 'admin' || node.post.author === window.ship) && ( api.graph.removeNodes(`~${ship}`, name, [node.post.index])}>Delete)} diff --git a/pkg/interface/src/views/apps/chat/components/overlay-sigil.js b/pkg/interface/src/views/components/OverlaySigil.tsx similarity index 76% rename from pkg/interface/src/views/apps/chat/components/overlay-sigil.js rename to pkg/interface/src/views/components/OverlaySigil.tsx index 6194b16310..05091de3a0 100644 --- a/pkg/interface/src/views/apps/chat/components/overlay-sigil.js +++ b/pkg/interface/src/views/components/OverlaySigil.tsx @@ -1,17 +1,42 @@ import React, { PureComponent } from 'react'; + import { Sigil } from '~/logic/lib/sigil'; +import { Contact, Association, Group } from '~/types'; + import { ProfileOverlay, OVERLAY_HEIGHT -} from './profile-overlay'; +} from './ProfileOverlay'; import { Box, BaseImage } from '@tlon/indigo-react'; -export class OverlaySigil extends PureComponent { - constructor() { - super(); +interface OverlaySigilProps { + ship: string; + contact?: Contact; + color: string; + sigilClass: string; + association: Association; + group: Group; + hideAvatars: boolean; + hideNicknames: boolean; + scrollWindow: HTMLElement; + history: any; + api: any; + className: string; +} + +interface OverlaySigilState { + clicked: boolean; + topSpace: number; + bottomSpace: number; +} + +export default class OverlaySigil extends PureComponent { + public containerRef: React.Ref; + + constructor(props) { + super(props); this.state = { clicked: false, - captured: false, topSpace: 0, bottomSpace: 0 }; @@ -21,17 +46,16 @@ export class OverlaySigil extends PureComponent { this.profileShow = this.profileShow.bind(this); this.profileHide = this.profileHide.bind(this); this.updateContainerOffset = this.updateContainerOffset.bind(this); - this.updateContainerInterval = null; } profileShow() { this.updateContainerOffset(); - this.setState({ profileClicked: true }); + this.setState({ clicked: true }); this.props.scrollWindow.addEventListener('scroll', this.updateContainerOffset); } profileHide() { - this.setState({ profileClicked: false }); + this.setState({ clicked: false }); this.props.scrollWindow.removeEventListener('scroll', this.updateContainerOffset, true); } @@ -77,7 +101,7 @@ export class OverlaySigil extends PureComponent { className={props.className} ref={this.containerRef} > - {state.profileClicked && ( + {state.clicked && ( { + public popoverRef: React.Ref; + + constructor(props) { + super(props); this.popoverRef = React.createRef(); this.onDocumentClick = this.onDocumentClick.bind(this); From 1bad1601736e86aa35bc15dc0228135042796ca5 Mon Sep 17 00:00:00 2001 From: Tyler Brown Cifu Shuster Date: Mon, 9 Nov 2020 20:30:34 -0800 Subject: [PATCH 705/933] links, publish: changing comments to new design --- .../apps/chat/components/ChatMessage.tsx | 1 - .../src/views/apps/links/LinkResource.tsx | 22 ++-- .../views/apps/links/components/LinkItem.tsx | 106 ++++++++++++++++++ .../apps/links/components/comment-item.tsx | 1 - .../views/apps/links/components/link-item.js | 76 ------------- .../views/apps/publish/components/Note.tsx | 2 +- .../{apps/publish => }/components/Author.tsx | 43 +++---- .../src/views/components/CommentItem.tsx | 12 +- .../src/views/components/Comments.tsx | 5 +- .../src/views/components/OverlaySigil.tsx | 4 +- .../src/views/components/ProfileOverlay.tsx | 3 +- 11 files changed, 157 insertions(+), 118 deletions(-) create mode 100644 pkg/interface/src/views/apps/links/components/LinkItem.tsx delete mode 100644 pkg/interface/src/views/apps/links/components/link-item.js rename pkg/interface/src/views/{apps/publish => }/components/Author.tsx (58%) diff --git a/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx b/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx index 80cb13128f..c325189981 100644 --- a/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx +++ b/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx @@ -215,7 +215,6 @@ export class MessageWithSigil extends PureComponent { contact={contact} color={color} sigilClass={sigilClass} - association={association} group={group} hideAvatars={hideAvatars} hideNicknames={hideNicknames} diff --git a/pkg/interface/src/views/apps/links/LinkResource.tsx b/pkg/interface/src/views/apps/links/LinkResource.tsx index d07ea41b84..161b3be305 100644 --- a/pkg/interface/src/views/apps/links/LinkResource.tsx +++ b/pkg/interface/src/views/apps/links/LinkResource.tsx @@ -6,10 +6,9 @@ import bigInt from 'big-integer'; import GlobalApi from "~/logic/api/global"; import { StoreState } from "~/logic/store/type"; import { uxToHex } from '~/logic/lib/util'; -import { Association, GraphNode } from "~/types"; import { RouteComponentProps } from "react-router-dom"; -import { LinkItem } from "./components/link-item"; +import { LinkItem } from "./components/LinkItem"; import { LinkSubmit } from "./components/link-submit"; import { LinkPreview } from "./components/link-preview"; import { Comments } from "~/views/components/comments"; @@ -77,14 +76,14 @@ export function LinkResource(props: LinkResourceProps) { const contact = contactDetails[node.post.author]; return ( @@ -115,13 +114,18 @@ export function LinkResource(props: LinkResourceProps) { return ( {"<- Back"} - { + const { + node, + resource, + hideAvatars, + hideNicknames, + remoteContentPolicy, + api, + group, + contacts, + ...rest + } = props; + + const URLparser = new RegExp( + /((?:([\w\d\.-]+)\:\/\/?){1}(?:(www)\.?){0,1}(((?:[\w\d-]+\.)*)([\w\d-]+\.[\w\d]+))){1}(?:\:(\d+)){0,1}((\/(?:(?:[^\/\s\?]+\/)*))(?:([^\?\/\s#]+?(?:.[^\?\s]+){0,1}){0,1}(?:\?([^\s#]+)){0,1})){0,1}(?:#([^#\s]+)){0,1}/ + ); + + const author = node.post.author; + const index = node.post.index.split('/').join('-'); + const size = node.children ? node.children.size : 0; + const contents = node.post.contents; + const hostname = URLparser.exec(contents[1].url) ? URLparser.exec(contents[1].url)[4] : null; + + const baseUrl = props.baseUrl || `/~404/${resource}`; + + const ourRole = group ? roleForShip(group, window.ship) : undefined; + const [ship, name] = resource.split('/'); + + return ( + + + {/* + + {size} comment{size > 1 ? 's' : null} + + {(ourRole === 'admin' || node.post.author === window.ship) + && ( api.graph.removeNodes(`~${ship}`, name, [node.post.index])}>Delete)} + */} + + + {contents[0].text} + {hostname} + + + + + + + + + + {node.children.size} + + + + + + ); +}; + diff --git a/pkg/interface/src/views/apps/links/components/comment-item.tsx b/pkg/interface/src/views/apps/links/components/comment-item.tsx index 1cff57bab9..7b534b589e 100644 --- a/pkg/interface/src/views/apps/links/components/comment-item.tsx +++ b/pkg/interface/src/views/apps/links/components/comment-item.tsx @@ -41,7 +41,6 @@ export const CommentItem = (props) => { contact={contact} color={color} sigilClass={sigilClass} - association={association} group={group} hideAvatars={hideAvatars} hideNicknames={hideNicknames} diff --git a/pkg/interface/src/views/apps/links/components/link-item.js b/pkg/interface/src/views/apps/links/components/link-item.js deleted file mode 100644 index 16fe5c59be..0000000000 --- a/pkg/interface/src/views/apps/links/components/link-item.js +++ /dev/null @@ -1,76 +0,0 @@ -import React from 'react'; -import { Row, Col, Anchor, Box, Text, BaseImage } from '@tlon/indigo-react'; - -import { Sigil } from '~/logic/lib/sigil'; -import { Link } from 'react-router-dom'; -import { cite } from '~/logic/lib/util'; - -import { roleForShip } from '~/logic/lib/group'; - -export const LinkItem = (props) => { - const { - node, - nickname, - avatar, - resource, - hideAvatars, - hideNicknames, - api, - group - } = props; - - const URLparser = new RegExp( - /((?:([\w\d\.-]+)\:\/\/?){1}(?:(www)\.?){0,1}(((?:[\w\d-]+\.)*)([\w\d-]+\.[\w\d]+))){1}(?:\:(\d+)){0,1}((\/(?:(?:[^\/\s\?]+\/)*))(?:([^\?\/\s#]+?(?:.[^\?\s]+){0,1}){0,1}(?:\?([^\s#]+)){0,1})){0,1}(?:#([^#\s]+)){0,1}/ - ); - - const author = node.post.author; - const index = node.post.index.split('/')[1]; - const size = node.children ? node.children.size : 0; - const contents = node.post.contents; - const hostname = URLparser.exec(contents[1].url) ? URLparser.exec(contents[1].url)[4] : null; - - const showAvatar = avatar && !hideAvatars; - const showNickname = nickname && !hideNicknames; - - const img = showAvatar - ? - : ; - - const baseUrl = props.baseUrl || `/~404/${resource}`; - - const ourRole = group ? roleForShip(group, window.ship) : undefined; - const [ship, name] = resource.split('/'); - - return ( - - {img} - - - {contents[0].text} - {hostname} ↗ - - - - {showNickname ? nickname : cite(author) } - - - {size} comment{size > 1 ? 's' : null} - - {(ourRole === 'admin' || node.post.author === window.ship) - && ( api.graph.removeNodes(`~${ship}`, name, [node.post.index])}>Delete)} - - - - ); -}; - diff --git a/pkg/interface/src/views/apps/publish/components/Note.tsx b/pkg/interface/src/views/apps/publish/components/Note.tsx index be309a7398..2577be717e 100644 --- a/pkg/interface/src/views/apps/publish/components/Note.tsx +++ b/pkg/interface/src/views/apps/publish/components/Note.tsx @@ -9,7 +9,7 @@ import { Comments } from "~/views/components/Comments"; import { NoteNavigation } from "./NoteNavigation"; import GlobalApi from "~/logic/api/global"; import { getLatestRevision, getComments } from '~/logic/lib/publish'; -import { Author } from "./Author"; +import Author from "~/views/components/Author"; import { Contacts, GraphNode, Graph, LocalUpdateRemoteContentPolicy } from "~/types"; interface NoteProps { diff --git a/pkg/interface/src/views/apps/publish/components/Author.tsx b/pkg/interface/src/views/components/Author.tsx similarity index 58% rename from pkg/interface/src/views/apps/publish/components/Author.tsx rename to pkg/interface/src/views/components/Author.tsx index d5b50ab353..6c48bedfb9 100644 --- a/pkg/interface/src/views/apps/publish/components/Author.tsx +++ b/pkg/interface/src/views/components/Author.tsx @@ -1,28 +1,32 @@ import React, {ReactNode} from "react"; import moment from "moment"; -import { Sigil } from "~/logic/lib/sigil" -import { uxToHex, cite } from "~/logic/lib/util"; -import { Contacts } from "~/types/contact-update"; import { Row, Box } from "@tlon/indigo-react"; +import { Sigil } from "~/logic/lib/sigil" +import { uxToHex, cite } from "~/logic/lib/util"; +import { Contacts, Rolodex } from "~/types/contact-update"; +import OverlaySigil from "./OverlaySigil"; +import { Group, Association, LocalUpdateRemoteContentPolicy } from "~/types"; + interface AuthorProps { - contacts: Contacts; + contacts: Rolodex; ship: string; date: number; showImage?: boolean; hideAvatars: boolean; hideNicknames: boolean; children?: ReactNode; + remoteContentPolicy: LocalUpdateRemoteContentPolicy; + group: Group; } -export function Author(props: AuthorProps) { - const { contacts, ship = '', date, showImage } = props; +export default function Author(props: AuthorProps) { + const { contacts, ship = '', date, showImage, hideAvatars, hideNicknames, remoteContentPolicy, group, api } = props; let contact = null; if (contacts) { contact = ship in contacts ? contacts[ship] : null; } const color = contact?.color ? `#${uxToHex(contact?.color)}` : "#000000"; - const showAvatar = !props.hideAvatars && contact?.avatar; const showNickname = !props.hideNicknames && contact?.nickname; const name = showNickname ? contact?.nickname : cite(ship); @@ -31,18 +35,19 @@ export function Author(props: AuthorProps) { {showImage && ( - {showAvatar ? ( - - ) : ( - - )} + )} {!disabled && ( diff --git a/pkg/interface/src/views/components/Comments.tsx b/pkg/interface/src/views/components/Comments.tsx index 2fb629f417..efc34390e0 100644 --- a/pkg/interface/src/views/components/Comments.tsx +++ b/pkg/interface/src/views/components/Comments.tsx @@ -9,7 +9,7 @@ import { FormikHelpers } from 'formik'; import { GraphNode } from '~/types/graph-update'; import { createPost, createBlankNodeWithChildPost } from '~/logic/api/graph'; import { getLatestCommentRevision } from '~/logic/lib/publish'; -import { LocalUpdateRemoteContentPolicy } from '~/types'; +import { LocalUpdateRemoteContentPolicy, Group } from '~/types'; import { scanForMentions } from '~/logic/lib/graph'; interface CommentsProps { @@ -23,10 +23,11 @@ interface CommentsProps { hideAvatars: boolean; hideNicknames: boolean; remoteContentPolicy: LocalUpdateRemoteContentPolicy; + group: Group; } export function Comments(props: CommentsProps) { - const { comments, ship, name, api, baseUrl, history} = props; + const { comments, ship, name, api, baseUrl, history, group } = props; const onSubmit = async ( { comment }, diff --git a/pkg/interface/src/views/components/OverlaySigil.tsx b/pkg/interface/src/views/components/OverlaySigil.tsx index 05091de3a0..34f28cc704 100644 --- a/pkg/interface/src/views/components/OverlaySigil.tsx +++ b/pkg/interface/src/views/components/OverlaySigil.tsx @@ -1,7 +1,7 @@ import React, { PureComponent } from 'react'; import { Sigil } from '~/logic/lib/sigil'; -import { Contact, Association, Group } from '~/types'; +import { Contact, Group } from '~/types'; import { ProfileOverlay, @@ -14,7 +14,6 @@ interface OverlaySigilProps { contact?: Contact; color: string; sigilClass: string; - association: Association; group: Group; hideAvatars: boolean; hideNicknames: boolean; @@ -108,7 +107,6 @@ export default class OverlaySigil extends PureComponent Date: Sun, 15 Nov 2020 18:53:41 -0800 Subject: [PATCH 706/933] links: added delete and copy actions --- .../apps/chat/components/ChatMessage.tsx | 1 + .../views/apps/links/components/LinkItem.tsx | 104 +++++++++++------- .../apps/links/components/comment-item.tsx | 69 ------------ .../apps/publish/components/NoteRoutes.tsx | 4 +- .../publish/components/NotebookRoutes.tsx | 2 +- pkg/interface/src/views/components/Author.tsx | 6 +- .../src/views/components/OverlaySigil.tsx | 71 +++++++----- .../src/views/components/ProfileOverlay.tsx | 27 +++-- 8 files changed, 139 insertions(+), 145 deletions(-) delete mode 100644 pkg/interface/src/views/apps/links/components/comment-item.tsx diff --git a/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx b/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx index c325189981..cf6891eee1 100644 --- a/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx +++ b/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx @@ -221,6 +221,7 @@ export class MessageWithSigil extends PureComponent { scrollWindow={scrollWindow} history={history} api={api} + bg="white" className="fl pr3 v-top pt1" /> diff --git a/pkg/interface/src/views/apps/links/components/LinkItem.tsx b/pkg/interface/src/views/apps/links/components/LinkItem.tsx index c809c2226a..67cfa9743a 100644 --- a/pkg/interface/src/views/apps/links/components/LinkItem.tsx +++ b/pkg/interface/src/views/apps/links/components/LinkItem.tsx @@ -1,14 +1,15 @@ -import React from 'react'; +import React, { useState } from 'react'; import { Link } from 'react-router-dom'; -import { Row, Col, Anchor, Box, Text, BaseImage, Icon } from '@tlon/indigo-react'; +import { Row, Col, Anchor, Box, Text, BaseImage, Icon, Action } from '@tlon/indigo-react'; import { Sigil } from '~/logic/lib/sigil'; -import { cite } from '~/logic/lib/util'; +import { writeText } from '~/logic/lib/util'; import Author from '~/views/components/Author'; import { roleForShip } from '~/logic/lib/group'; import { Contacts, GraphNode, Group, LocalUpdateRemoteContentPolicy, Rolodex } from '~/types'; import GlobalApi from '~/logic/api/global'; +import { Dropdown } from '~/views/components/Dropdown'; interface LinkItemProps { node: GraphNode; @@ -39,7 +40,7 @@ export const LinkItem = (props: LinkItemProps) => { ); const author = node.post.author; - const index = node.post.index.split('/').join('-'); + const index = node.post.index.split('/')[1]; const size = node.children ? node.children.size : 0; const contents = node.post.contents; const hostname = URLparser.exec(contents[1].url) ? URLparser.exec(contents[1].url)[4] : null; @@ -49,35 +50,44 @@ export const LinkItem = (props: LinkItemProps) => { const ourRole = group ? roleForShip(group, window.ship) : undefined; const [ship, name] = resource.split('/'); + const [locationText, setLocationText] = useState('Copy Link Location'); + + const copyLocation = () => { + setLocationText('Copied'); + writeText(contents[1].url); + setTimeout(() => { + setLocationText('Copy Link Location'); + }, 2000); + }; + + const deleteLink = () => { + if (confirm('Are you sure you want to delete this link?')) { + api.graph.removeNodes(`~${ship}`, name, [node.post.index]); + } + }; + return ( - - {/* - - {size} comment{size > 1 ? 's' : null} - - {(ourRole === 'admin' || node.post.author === window.ship) - && ( api.graph.removeNodes(`~${ship}`, name, [node.post.index])}>Delete)} - */} - - {contents[0].text} - {hostname} - - + + {contents[0].text} + {hostname} + + + { remoteContentPolicy={remoteContentPolicy} group={group} api={api} - > - - - + > + + + {node.children.size} - + + + + + + {locationText} + + {(ourRole === 'admin' || node.post.author === window.ship) && + + Delete Link + + } + + } + > + + - - ); + ); }; diff --git a/pkg/interface/src/views/apps/links/components/comment-item.tsx b/pkg/interface/src/views/apps/links/components/comment-item.tsx deleted file mode 100644 index 7b534b589e..0000000000 --- a/pkg/interface/src/views/apps/links/components/comment-item.tsx +++ /dev/null @@ -1,69 +0,0 @@ -import React, { Component } from 'react'; -import { Sigil } from '~/logic/lib/sigil'; -import { cite } from '~/logic/lib/util'; -import moment from 'moment'; -import { Box, Text, Row } from '@tlon/indigo-react'; -import RichText from '~/views/components/RichText'; - -import OverlaySigil from '~/views/components/OverlaySigil'; - -export const CommentItem = (props) => { - const { - contact, - color, - hideAvatars, - hideNicknames, - api, - association, - group - } = props; - const content = props.post.contents[0].text; - const sigilClass = contact ? '' : 'mix-blend-diff'; - const timeSent = - moment.unix(props.post['time-sent'] / 1000).format('hh:mm a'); - - const showAvatar = props.avatar && !props.hideAvatars; - const showNickname = props.nickname && !props.hideNicknames; - const img = showAvatar - ? - : ; - - return ( - - - - - - {showNickname ? props.nickname : cite(props.post.author)} - - {timeSent} - - - - - - {content} - - - - - ); -} - diff --git a/pkg/interface/src/views/apps/publish/components/NoteRoutes.tsx b/pkg/interface/src/views/apps/publish/components/NoteRoutes.tsx index c628ca4b94..843202e1fb 100644 --- a/pkg/interface/src/views/apps/publish/components/NoteRoutes.tsx +++ b/pkg/interface/src/views/apps/publish/components/NoteRoutes.tsx @@ -6,7 +6,7 @@ import { RouteComponentProps } from "react-router-dom"; import Note from "./Note"; import { EditPost } from "./EditPost"; -import { GraphNode, Graph, Contacts, LocalUpdateRemoteContentPolicy } from "~/types"; +import { GraphNode, Graph, Contacts, LocalUpdateRemoteContentPolicy, Group } from "~/types"; interface NoteRoutesProps { ship: string; @@ -24,8 +24,6 @@ interface NoteRoutesProps { } export function NoteRoutes(props: NoteRoutesProps & RouteComponentProps) { - const { ship, book, noteId } = props; - const baseUrl = props.baseUrl || '/~404'; const rootUrl = props.rootUrl || '/~404'; diff --git a/pkg/interface/src/views/apps/publish/components/NotebookRoutes.tsx b/pkg/interface/src/views/apps/publish/components/NotebookRoutes.tsx index e95f4fa7ec..926e2e555e 100644 --- a/pkg/interface/src/views/apps/publish/components/NotebookRoutes.tsx +++ b/pkg/interface/src/views/apps/publish/components/NotebookRoutes.tsx @@ -83,7 +83,7 @@ export function NotebookRoutes( path={relativePath("/note/:noteId")} render={(routeProps) => { const { noteId } = routeProps.match.params; - const noteIdNum = bigInt(noteId) + const noteIdNum = bigInt(noteId); if(!graph) { return
; diff --git a/pkg/interface/src/views/components/Author.tsx b/pkg/interface/src/views/components/Author.tsx index 6c48bedfb9..ad31f4b426 100644 --- a/pkg/interface/src/views/components/Author.tsx +++ b/pkg/interface/src/views/components/Author.tsx @@ -7,6 +7,7 @@ import { uxToHex, cite } from "~/logic/lib/util"; import { Contacts, Rolodex } from "~/types/contact-update"; import OverlaySigil from "./OverlaySigil"; import { Group, Association, LocalUpdateRemoteContentPolicy } from "~/types"; +import GlobalApi from "~/logic/api/global"; interface AuthorProps { contacts: Rolodex; @@ -18,11 +19,12 @@ interface AuthorProps { children?: ReactNode; remoteContentPolicy: LocalUpdateRemoteContentPolicy; group: Group; + api: GlobalApi; } export default function Author(props: AuthorProps) { const { contacts, ship = '', date, showImage, hideAvatars, hideNicknames, remoteContentPolicy, group, api } = props; - let contact = null; + let contact; if (contacts) { contact = ship in contacts ? contacts[ship] : null; } @@ -43,9 +45,9 @@ export default function Author(props: AuthorProps) { group={group} hideAvatars={hideAvatars} hideNicknames={hideNicknames} - scrollWindow={document.createElement('div')} history={history} api={api} + bg="white" className="fl v-top pt1" />
diff --git a/pkg/interface/src/views/components/OverlaySigil.tsx b/pkg/interface/src/views/components/OverlaySigil.tsx index 34f28cc704..c241cac2cd 100644 --- a/pkg/interface/src/views/components/OverlaySigil.tsx +++ b/pkg/interface/src/views/components/OverlaySigil.tsx @@ -7,17 +7,18 @@ import { ProfileOverlay, OVERLAY_HEIGHT } from './ProfileOverlay'; -import { Box, BaseImage } from '@tlon/indigo-react'; -interface OverlaySigilProps { +import { Box, BaseImage, ColProps } from '@tlon/indigo-react'; + +type OverlaySigilProps = ColProps & { ship: string; contact?: Contact; color: string; sigilClass: string; - group: Group; + group?: Group; hideAvatars: boolean; hideNicknames: boolean; - scrollWindow: HTMLElement; + scrollWindow?: HTMLElement; history: any; api: any; className: string; @@ -25,8 +26,8 @@ interface OverlaySigilProps { interface OverlaySigilState { clicked: boolean; - topSpace: number; - bottomSpace: number; + topSpace: number | 'auto'; + bottomSpace: number | 'auto'; } export default class OverlaySigil extends PureComponent { @@ -50,12 +51,12 @@ export default class OverlaySigil extends PureComponent + const { state } = this; + + const img = (contact && (contact.avatar !== null) && !hideAvatars) + ? : ; @@ -97,22 +115,23 @@ export default class OverlaySigil extends PureComponent {state.clicked && ( )} {img} diff --git a/pkg/interface/src/views/components/ProfileOverlay.tsx b/pkg/interface/src/views/components/ProfileOverlay.tsx index cb823a0191..c1d310af5a 100644 --- a/pkg/interface/src/views/components/ProfileOverlay.tsx +++ b/pkg/interface/src/views/components/ProfileOverlay.tsx @@ -4,17 +4,17 @@ import { Contact, Group } from '~/types'; import { cite } from '~/logic/lib/util'; import { Sigil } from '~/logic/lib/sigil'; -import { Box, Col, Button, Text, BaseImage } from '@tlon/indigo-react'; +import { Box, Col, Button, Text, BaseImage, ColProps } from '@tlon/indigo-react'; export const OVERLAY_HEIGHT = 250; -interface ProfileOverlayProps { +type ProfileOverlayProps = ColProps & { ship: string; contact?: Contact; color: string; - topSpace: number; - bottomSpace: number; - group: Group; + topSpace: number | 'auto'; + bottomSpace: number | 'auto'; + group?: Group; onDismiss(): void; hideAvatars: boolean; hideNicknames: boolean; @@ -53,7 +53,19 @@ export class ProfileOverlay extends PureComponent { } render() { - const { contact, ship, color, topSpace, bottomSpace, group, hideNicknames, hideAvatars, history } = this.props; + const { + contact, + ship, + color, + topSpace, + bottomSpace, + group = false, + hideNicknames, + hideAvatars, + history, + onDismiss, + ...rest + } = this.props; let top, bottom; if (topSpace < OVERLAY_HEIGHT / 2) { @@ -84,7 +96,7 @@ export class ProfileOverlay extends PureComponent { /* if (!group.hidden) { }*/ - const isHidden = group.hidden; + const isHidden = group ? group.hidden : false; return ( { zIndex='3' fontSize='0' style={containerStyle} + {...rest} > {img} From 61e0d35ca51589812129775a934949f9f3590ce6 Mon Sep 17 00:00:00 2001 From: Tyler Brown Cifu Shuster Date: Tue, 24 Nov 2020 14:13:03 -0800 Subject: [PATCH 707/933] landscape: update RemoteContent settings --- .../apps/chat/components/ChatMessage.tsx | 5 +++ .../src/views/apps/links/LinkResource.tsx | 9 ++--- .../views/apps/links/components/LinkItem.tsx | 36 ++++++++++++++----- .../src/views/components/RemoteContent.tsx | 30 ++++++++++++---- 4 files changed, 60 insertions(+), 20 deletions(-) diff --git a/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx b/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx index cf6891eee1..7c3ec900bb 100644 --- a/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx +++ b/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx @@ -279,6 +279,11 @@ export const MessageContent = ({ content, remoteContentPolicy, measure, fontSize }}} videoProps={{style: { maxWidth: '18rem' + } + }} + textProps={{style: { + fontSize: 'inherit', + textDecoration: 'underline' }}} /> diff --git a/pkg/interface/src/views/apps/links/LinkResource.tsx b/pkg/interface/src/views/apps/links/LinkResource.tsx index 161b3be305..8bbf18702c 100644 --- a/pkg/interface/src/views/apps/links/LinkResource.tsx +++ b/pkg/interface/src/views/apps/links/LinkResource.tsx @@ -1,5 +1,5 @@ import React, { useEffect } from "react"; -import { Box, Row, Col, Center, LoadingSpinner } from "@tlon/indigo-react"; +import { Box, Row, Col, Center, LoadingSpinner, Text } from "@tlon/indigo-react"; import { Switch, Route, Link } from "react-router-dom"; import bigInt from 'big-integer'; @@ -86,6 +86,7 @@ export function LinkResource(props: LinkResourceProps) { baseUrl={resourceUrl} group={group} api={api} + mb={3} /> ); })} @@ -112,8 +113,8 @@ export function LinkResource(props: LinkResourceProps) { const contact = contactDetails[node.post.author]; return ( - - {"<- Back"} + + {"<- Back"} { return ( - - {contents[0].text} - {hostname} - + + + + + {hostname} + + + + diff --git a/pkg/interface/src/views/components/RemoteContent.tsx b/pkg/interface/src/views/components/RemoteContent.tsx index 9c44f381cb..877e60d2f4 100644 --- a/pkg/interface/src/views/components/RemoteContent.tsx +++ b/pkg/interface/src/views/components/RemoteContent.tsx @@ -1,12 +1,13 @@ import React, { PureComponent, Fragment } from 'react'; import { LocalUpdateRemoteContentPolicy } from "~/types/local-update"; -import { BaseAnchor, BaseImage, Box, Button } from '@tlon/indigo-react'; +import { BaseAnchor, BaseImage, Box, Button, Text } from '@tlon/indigo-react'; import { hasProvider } from 'oembed-parser'; import EmbedContainer from 'react-oembed-container'; import { memoize } from 'lodash'; interface RemoteContentProps { url: string; + text?: string; remoteContentPolicy: LocalUpdateRemoteContentPolicy; unfold?: boolean; renderUrl?: boolean; @@ -14,6 +15,7 @@ interface RemoteContentProps { audioProps?: any; videoProps?: any; oembedProps?: any; + textProps?: any; style?: any; onLoad?(): void; } @@ -48,7 +50,8 @@ export default class RemoteContent extends PureComponent {}, ...props @@ -113,7 +119,9 @@ export default class RemoteContent extends PureComponent - {renderUrl ? this.wrapInLink(url) : null} + {renderUrl + ? this.wrapInLink({text || url}) + : null}
{childElement}); @@ -48,6 +48,7 @@ export default class Tile extends React.Component { bg={bg || "white"} color={props?.color || 'scales.black20'} boxShadow={boxShadow || '0 0 0px 1px inset'} + style={{ gridColumnStart }} > - + <> + Join Group @@ -103,6 +103,6 @@ export function JoinGroup(props: JoinGroupProps & RouteComponentProps) { - + ); } diff --git a/pkg/interface/src/views/landscape/components/NewGroup.tsx b/pkg/interface/src/views/landscape/components/NewGroup.tsx index 4ae36c924e..fd1989e1e5 100644 --- a/pkg/interface/src/views/landscape/components/NewGroup.tsx +++ b/pkg/interface/src/views/landscape/components/NewGroup.tsx @@ -78,8 +78,8 @@ export function NewGroup(props: NewGroupProps & RouteComponentProps) { ); return ( - - + <> + New Group @@ -112,6 +112,6 @@ export function NewGroup(props: NewGroupProps & RouteComponentProps) { - + ); } diff --git a/pkg/interface/src/views/landscape/index.tsx b/pkg/interface/src/views/landscape/index.tsx index 906fa31e9e..8ababc6743 100644 --- a/pkg/interface/src/views/landscape/index.tsx +++ b/pkg/interface/src/views/landscape/index.tsx @@ -12,6 +12,8 @@ import { NewGroup } from './components/NewGroup'; import { JoinGroup } from './components/JoinGroup'; import { cite } from '~/logic/lib/util'; +import { Body } from '../components/Body'; +import { Box } from '@tlon/indigo-react'; type LandscapeProps = StoreState & { @@ -95,12 +97,16 @@ export default class Landscape extends Component { { return ( - + + + + + ); }} /> @@ -115,13 +121,17 @@ export default class Landscape extends Component { const { ship, name } = routeProps.match.params; const autojoin = ship && name ? `${ship}/${name}` : null; return ( - + + + + + ); }} /> From ad8367974b456fb8ef34dad56f3015f7a5dd7bbf Mon Sep 17 00:00:00 2001 From: fang Date: Wed, 25 Nov 2020 01:41:29 +0100 Subject: [PATCH 734/933] arvo: allow %$ care in +sloy Similar to the fix made for desk in f714d90, now that we actually want to do so. --- pkg/arvo/sys/arvo.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index 5aa18b0642..34a5d6625d 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -235,7 +235,7 @@ =+ pux=((soft path) raw) ?~ pux ~ ?. ?=({@ @ @ @ *} u.pux) ~ - =+ :* hyr=(slaw %tas i.u.pux) + =+ :* hyr=?~(i.u.pux (some %$) (slaw %tas i.u.pux)) fal=(slaw %p i.t.u.pux) dyc=?~(i.t.t.u.pux (some %$) (slaw %tas i.t.t.u.pux)) ved=(slay i.t.t.t.u.pux) From fb33ff4f824af933eee58cc32fd1749174671c41 Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Wed, 25 Nov 2020 15:41:44 -0500 Subject: [PATCH 735/933] publish: replicate new links interface --- .../apps/publish/components/NotePreview.tsx | 122 +++++++++--------- .../apps/publish/components/Notebook.tsx | 43 +++--- .../apps/publish/components/NotebookPosts.tsx | 19 ++- pkg/interface/src/views/components/Author.tsx | 7 +- 4 files changed, 100 insertions(+), 91 deletions(-) diff --git a/pkg/interface/src/views/apps/publish/components/NotePreview.tsx b/pkg/interface/src/views/apps/publish/components/NotePreview.tsx index e63221c6db..0262545e0a 100644 --- a/pkg/interface/src/views/apps/publish/components/NotePreview.tsx +++ b/pkg/interface/src/views/apps/publish/components/NotePreview.tsx @@ -1,26 +1,29 @@ -import React from "react"; -import moment from "moment"; -import { Link } from "react-router-dom"; -import styled from "styled-components"; -import ReactMarkdown from "react-markdown"; -import { Col, Box, Text, Image } from "@tlon/indigo-react"; +import React from 'react'; +import { Link } from 'react-router-dom'; +import styled from 'styled-components'; +import { Col, Row, Box, Text, Icon, Image } from '@tlon/indigo-react'; -import { cite } from "~/logic/lib/util"; -import { Contact } from "~/types/contact-update"; -import { GraphNode } from "~/types/graph-update"; +import Author from '~/views/components/Author'; +import { GraphNode } from '~/types/graph-update'; +import { Contacts, Group } from '~/types'; import { getComments, getLatestRevision, - getSnippet, -} from "~/logic/lib/publish"; + getSnippet +} from '~/logic/lib/publish'; +import GlobalApi from '~/logic/api/global'; +import ReactMarkdown from 'react-markdown'; interface NotePreviewProps { host: string; book: string; node: GraphNode; - contact?: Contact; + hideAvatars?: boolean; hideNicknames?: boolean; baseUrl: string; + contacts: Contacts; + api: GlobalApi; + group: Group; } const WrappedBox = styled(Box)` @@ -28,29 +31,14 @@ const WrappedBox = styled(Box)` `; export function NotePreview(props: NotePreviewProps) { - const { node, contact } = props; + const { node, contacts, hideAvatars, hideNicknames, group } = props; const { post } = node; if (!post) { return null; } - let name = post?.author; - if (contact && !props.hideNicknames) { - name = contact.nickname.length > 0 ? contact.nickname : post?.author; - } - if (name === post?.author) { - name = cite(post?.author); - } - const numComments = getComments(node).children.size; - const commentDesc = - numComments === 0 - ? "No Comments" - : numComments === 1 - ? "1 Comment" - : `${numComments} Comments`; - const date = moment(post["time-sent"]).fromNow(); - const url = `${props.baseUrl}/note/${post.index.split("/")[1]}`; + const url = `${props.baseUrl}/note/${post.index.split('/')[1]}`; // stubbing pending notification-store const isRead = true; @@ -60,37 +48,53 @@ export function NotePreview(props: NotePreviewProps) { const snippet = getSnippet(body); return ( - - - {title} - + + + + {title} + - - }} - source={snippet} - /> - - - - - {name} - - - {date} - - {commentDesc} - {rev.valueOf() === 1 ? `1 Revision` : `${rev} Revisions`} + + }} + source={snippet} + /> + + + + + + + + + + + {numComments} + + - - + + ); } diff --git a/pkg/interface/src/views/apps/publish/components/Notebook.tsx b/pkg/interface/src/views/apps/publish/components/Notebook.tsx index ff342290b4..bc3e63cfbf 100644 --- a/pkg/interface/src/views/apps/publish/components/Notebook.tsx +++ b/pkg/interface/src/views/apps/publish/components/Notebook.tsx @@ -1,15 +1,11 @@ -import React, { PureComponent } from "react"; -import { Link, RouteComponentProps, Route, Switch } from "react-router-dom"; -import { NotebookPosts } from "./NotebookPosts"; -import { roleForShip } from "~/logic/lib/group"; -import { Box, Button, Text, Row, Col } from "@tlon/indigo-react"; -import { Groups } from "~/types/group-update"; -import { Contacts, Rolodex } from "~/types/contact-update"; -import GlobalApi from "~/logic/api/global"; -import styled from "styled-components"; -import { Associations, Graph, Association } from "~/types"; -import { deSig } from "~/logic/lib/util"; -import { StatelessAsyncButton } from "~/views/components/StatelessAsyncButton"; +import React from 'react'; +import { Link, RouteComponentProps } from 'react-router-dom'; +import { NotebookPosts } from './NotebookPosts'; +import { Box, Button, Text, Row, Col } from '@tlon/indigo-react'; +import { Groups } from '~/types/group-update'; +import { Contacts, Rolodex } from '~/types/contact-update'; +import GlobalApi from '~/logic/api/global'; +import { Associations, Graph, Association, LocalUpdateRemoteContentPolicy } from '~/types'; interface NotebookProps { api: GlobalApi; @@ -22,9 +18,9 @@ interface NotebookProps { contacts: Rolodex; groups: Groups; hideNicknames: boolean; + hideAvatars: boolean; baseUrl: string; rootUrl: string; - associations: Associations; } interface NotebookState { @@ -39,18 +35,20 @@ export function Notebook(props: NotebookProps & RouteComponentProps) { notebookContacts, groups, hideNicknames, + hideAvatars, association, - graph, + graph } = props; const { metadata } = association; - const group = groups[association?.["group-path"]]; - if (!group) return null; // Waitin on groups to populate + const group = groups[association?.['group-path']]; + if (!group) { + return null; // Waitin on groups to populate + } const relativePath = (p: string) => props.baseUrl + p; const contact = notebookContacts?.[ship]; - const role = group ? roleForShip(group, window.ship) : undefined; const isOwn = `~${window.ship}` === ship; const isWriter = @@ -65,13 +63,13 @@ export function Notebook(props: NotebookProps & RouteComponentProps) { {metadata?.title}
by - + {showNickname ? contact?.nickname : ship} {isWriter && ( - - @@ -82,9 +80,12 @@ export function Notebook(props: NotebookProps & RouteComponentProps) { graph={graph} host={ship} book={book} - contacts={!!notebookContacts ? notebookContacts : {}} + contacts={notebookContacts ? notebookContacts : {}} hideNicknames={hideNicknames} + hideAvatars={hideAvatars} baseUrl={props.baseUrl} + api={props.api} + group={group} /> ); diff --git a/pkg/interface/src/views/apps/publish/components/NotebookPosts.tsx b/pkg/interface/src/views/apps/publish/components/NotebookPosts.tsx index d44905a3b3..158b260292 100644 --- a/pkg/interface/src/views/apps/publish/components/NotebookPosts.tsx +++ b/pkg/interface/src/views/apps/publish/components/NotebookPosts.tsx @@ -1,15 +1,19 @@ -import React, { Component } from "react"; -import { Col } from "@tlon/indigo-react"; -import { NotePreview } from "./NotePreview"; -import { Contacts, Graph } from "~/types"; +import React from 'react'; +import { Col } from '@tlon/indigo-react'; +import { NotePreview } from './NotePreview'; +import { Contacts, Graph, Group } from '~/types'; +import GlobalApi from '~/logic/api/global'; interface NotebookPostsProps { contacts: Contacts; graph: Graph; host: string; book: string; - hideNicknames?: boolean; baseUrl: string; + hideAvatars?: boolean; + hideNicknames?: boolean; + api: GlobalApi; + group: Group; } export function NotebookPosts(props: NotebookPostsProps) { @@ -22,10 +26,11 @@ export function NotebookPosts(props: NotebookPostsProps) { key={date.toString()} host={props.host} book={props.book} - contact={props.contacts[node.post.author]} + contacts={props.contacts} node={node} - hideNicknames={props.hideNicknames} baseUrl={props.baseUrl} + api={props.api} + group={props.group} /> ) )} diff --git a/pkg/interface/src/views/components/Author.tsx b/pkg/interface/src/views/components/Author.tsx index 217d80d34e..b1b693134c 100644 --- a/pkg/interface/src/views/components/Author.tsx +++ b/pkg/interface/src/views/components/Author.tsx @@ -6,25 +6,24 @@ import { Sigil } from "~/logic/lib/sigil" import { uxToHex, cite } from "~/logic/lib/util"; import { Contacts, Rolodex } from "~/types/contact-update"; import OverlaySigil from "./OverlaySigil"; -import { Group, Association, LocalUpdateRemoteContentPolicy } from "~/types"; +import { Group, Association } from "~/types"; import GlobalApi from "~/logic/api/global"; import { useHistory } from "react-router-dom"; interface AuthorProps { - contacts: Rolodex; + contacts: Contacts; ship: string; date: number; showImage?: boolean; hideAvatars: boolean; hideNicknames: boolean; children?: ReactNode; - remoteContentPolicy: LocalUpdateRemoteContentPolicy; group: Group; api: GlobalApi; } export default function Author(props: AuthorProps) { - const { contacts, ship = '', date, showImage, hideAvatars, hideNicknames, remoteContentPolicy, group, api } = props; + const { contacts, ship = '', date, showImage, hideAvatars, hideNicknames, group, api } = props; const history = useHistory(); let contact; if (contacts) { From 160c35ce61f659a4825bd4960aacb00b39361d0f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 25 Nov 2020 13:35:15 -0800 Subject: [PATCH 736/933] pill: solid/ivory --- bin/ivory.pill | 4 ++-- bin/solid.pill | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/ivory.pill b/bin/ivory.pill index b766ccecd2..cacba3bfb2 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5411632d932318b08d223a80f8eeb3ab4191af5038d8179b249d8f5ee900348f -size 1935167 +oid sha256:d2afa3600c4825b19c7359aaa841979c1b8a250cf9a8035733e9f8ad6f6cda33 +size 1905061 diff --git a/bin/solid.pill b/bin/solid.pill index 5c5e8a4b60..bae42bad84 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6195ada0b1b2d8d68a55f0faa9a1adf4e72fa32f4df4fed3923218ea95f0c947 -size 6535132 +oid sha256:28578b9283cc8749b45628a7964dbe788020cb888bf08a7f94935d93f16bfdb5 +size 6484247 From 7259b2c1217b516f5de5277883976d0f6fa60a9e Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Wed, 25 Nov 2020 14:46:33 -0800 Subject: [PATCH 737/933] gall: rename fading styles --- bin/solid.pill | 4 ++-- pkg/arvo/gen/hood/doze.hoon | 2 +- pkg/arvo/lib/hood/drum.hoon | 2 +- pkg/arvo/sys/vane/gall.hoon | 20 ++++++++++---------- pkg/arvo/sys/zuse.hoon | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index 43e69bf942..d7f71a8022 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3df27a5311fa269bb605deeaa5e85f0b347bea3d54ba5b4d08cba47e7ff32b3b -size 6519283 +oid sha256:8b317605d1f3fb5eee5b9468acb321fd97912bc94e5e4ac992162596578c4e77 +size 6517517 diff --git a/pkg/arvo/gen/hood/doze.hoon b/pkg/arvo/gen/hood/doze.hoon index f70496b280..ceab5ab895 100644 --- a/pkg/arvo/gen/hood/doze.hoon +++ b/pkg/arvo/gen/hood/doze.hoon @@ -1,4 +1,4 @@ :- %say |= [^ [dap=term wake=$@(~ [%wake ~])] ~] -=/ mode ?@(wake %doze %wake) +=/ mode ?@(wake %idle %jolt) [%helm-pass %g %fade dap mode] diff --git a/pkg/arvo/lib/hood/drum.hoon b/pkg/arvo/lib/hood/drum.hoon index 3a0150243a..851bb55c5e 100644 --- a/pkg/arvo/lib/hood/drum.hoon +++ b/pkg/arvo/lib/hood/drum.hoon @@ -388,7 +388,7 @@ ?: (~(has in ray) [%home i.ruf]) $(ruf t.ruf) =/ wire [%drum %fade i.ruf ~] - =. this (se-emit %pass wire %arvo %g %fade i.ruf %gone) + =. this (se-emit %pass wire %arvo %g %fade i.ruf %slay) $(ruf t.ruf, fur (~(del by fur) i.ruf)) :: ++ se-adze :: update connections diff --git a/pkg/arvo/sys/vane/gall.hoon b/pkg/arvo/sys/vane/gall.hoon index 4a2cee2fa4..fb2f9eaf2e 100644 --- a/pkg/arvo/sys/vane/gall.hoon +++ b/pkg/arvo/sys/vane/gall.hoon @@ -1,4 +1,4 @@ -:: :: %gall, agent execution +!: :: %gall, agent execution !? 163 :: :::: @@ -891,18 +891,18 @@ :: +mo-fade: put app to sleep :: ++ mo-fade - |= [dap=term style=?(%gone %doze %wake)] + |= [dap=term style=?(%slay %idle %jolt)] ^+ mo-core =/ =routes [disclosing=~ attributing=our] =/ app (ap-abed:ap dap routes) =. mo-core ap-abet:(ap-fade:app style) =. mo-core ?- style - %gone mo-core(yokes.state (~(del by yokes.state) dap)) - %doze mo-core - %wake (mo-boot dap our %home) + %slay mo-core(yokes.state (~(del by yokes.state) dap)) + %idle mo-core + %jolt (mo-boot dap our %home) == - =? mo-core !?=(%wake style) (mo-subscribe-to-agent-builds now) + =? mo-core !?=(%jolt style) (mo-subscribe-to-agent-builds now) mo-core :: +mo-beak: assemble a beak for the specified agent. :: @@ -1133,15 +1133,15 @@ :: For %gone, remove all incoming and outgoing subscriptions. :: ++ ap-fade - |= style=?(%gone %doze %wake) + |= style=?(%slay %idle %jolt) ^+ ap-core ?- style - %doze + %jolt ap-core + %idle =. agent.current-agent |+on-save:ap-agent-core ap-core :: - %wake ap-core - %gone + %slay =/ out=(list [[=wire =ship =term] ? =path]) ~(tap by outbound.watches.current-agent) =/ inbound-paths=(set path) diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index f6ac7d37ac..8190de0770 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -1723,7 +1723,7 @@ [$deal p=sock q=term r=deal] :: full transmission [%goad force=? agent=(unit dude)] :: rebuild agent(s) [%sear =ship] :: clear pending queues - [%fade dap=term style=?(%gone %doze %wake)] :: put app to sleep + [%fade dap=term style=?(%slay %idle %jolt)] :: put app to sleep $>(%init vane-task) :: set owner $>(%trim vane-task) :: trim state $>(%vega vane-task) :: report upgrade From 6e1de24b23dd8173587a48186e9d277a278e9a78 Mon Sep 17 00:00:00 2001 From: Tyler Brown Cifu Shuster Date: Wed, 25 Nov 2020 15:09:58 -0800 Subject: [PATCH 738/933] groups: standardized dms, join, and create icons --- pkg/interface/src/views/components/leap/OmniboxResult.js | 2 +- .../src/views/landscape/components/GroupSwitcher.tsx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/interface/src/views/components/leap/OmniboxResult.js b/pkg/interface/src/views/components/leap/OmniboxResult.js index f6dccfbe0e..1d61c1a8a9 100644 --- a/pkg/interface/src/views/components/leap/OmniboxResult.js +++ b/pkg/interface/src/views/components/leap/OmniboxResult.js @@ -52,7 +52,7 @@ export class OmniboxResult extends Component { } else if (icon === 'profile') { graphic = ; } else if (icon === 'home') { - graphic = ; + graphic = ; } else if (icon === 'notifications') { graphic = ; } else { diff --git a/pkg/interface/src/views/landscape/components/GroupSwitcher.tsx b/pkg/interface/src/views/landscape/components/GroupSwitcher.tsx index f35414d000..d7601cf59d 100644 --- a/pkg/interface/src/views/landscape/components/GroupSwitcher.tsx +++ b/pkg/interface/src/views/landscape/components/GroupSwitcher.tsx @@ -118,7 +118,7 @@ export function GroupSwitcher(props: { mr={2} color="gray" display="block" - icon="Boot" + icon="Mail" /> DMs + Drafts } @@ -127,11 +127,11 @@ export function GroupSwitcher(props: { associations={props.associations} /> - + New Group - + Join Group {workspace.type === "group" && ( From e32a0bf5db6f2761a2b96ed1958722def044a490 Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Wed, 25 Nov 2020 18:26:44 -0500 Subject: [PATCH 739/933] launch: banner is dismissable --- pkg/interface/src/views/App.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/pkg/interface/src/views/App.js b/pkg/interface/src/views/App.js index d48db7ffab..88dda65259 100644 --- a/pkg/interface/src/views/App.js +++ b/pkg/interface/src/views/App.js @@ -14,7 +14,7 @@ import './css/fonts.css'; import light from './themes/light'; import dark from './themes/old-dark'; -import { Text, Anchor } from '@tlon/indigo-react'; +import { Text, Anchor, Row } from '@tlon/indigo-react'; import { Content } from './landscape/components/Content'; import StatusBar from './components/StatusBar'; @@ -27,6 +27,7 @@ import GlobalApi from '~/logic/api/global'; import { uxToHex } from '~/logic/lib/util'; import { foregroundFromBackground } from '~/logic/lib/sigil'; + const Root = styled.div` font-family: ${p => p.theme.fonts.sans}; height: 100%; @@ -130,6 +131,9 @@ class App extends React.Component { const notificationsCount = state.notificationsCount || 0; const doNotDisturb = state.doNotDisturb || false; + const showBanner = localStorage.getItem("2020BreachBanner") || "flex"; + let banner = null; + return ( @@ -138,7 +142,21 @@ class App extends React.Component { : null} - A network-wide breach is scheduled for early December 2020. Please visit urbit.org/breach for more information. + banner = e} + display={showBanner} + justifyContent="space-between" + width='100%' + p='2' + backgroundColor='yellow'> + + A network-wide breach is scheduled for early December 2020. Please visit urbit.org/breach for more information. + + { + banner.style.displaydisplay = "none"; + localStorage.setItem("2020BreachBanner", "none"); + }}>Dismiss + Date: Mon, 23 Nov 2020 13:06:50 -0800 Subject: [PATCH 740/933] arvo: scry reform --- pkg/arvo/sys/arvo.hoon | 173 +++++++++++++++++++++++++----------- pkg/arvo/sys/vane/ames.hoon | 14 ++- pkg/arvo/sys/vane/behn.hoon | 10 ++- pkg/arvo/sys/vane/clay.hoon | 20 +++-- pkg/arvo/sys/vane/dill.hoon | 13 ++- pkg/arvo/sys/vane/eyre.hoon | 11 ++- pkg/arvo/sys/vane/ford.hoon | 2 +- pkg/arvo/sys/vane/gall.hoon | 14 ++- pkg/arvo/sys/vane/iris.hoon | 11 ++- pkg/arvo/sys/vane/jael.hoon | 23 ++--- pkg/arvo/sys/zuse.hoon | 39 -------- 11 files changed, 199 insertions(+), 131 deletions(-) diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index 34a5d6625d..724943b838 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -35,7 +35,9 @@ :: +cask: marked data builder :: $desk: local workspace :: $dock: message target +:: $gang: infinite set of peers :: $mark: symbolic content type +:: +omen: namespace path and data :: $ship: network identity :: $sink: subscription :: @@ -47,8 +49,8 @@ |$ [item] [fil=(unit item) dir=(map @ta ~)] :: -+$ beam [beak s=path] +$ beak (trel ship desk case) ++$ beam [beak s=path] +$ bone @ud +$ case $% :: %da: date @@ -63,7 +65,9 @@ ++ cask |$ [a] (pair mark a) +$ desk @tas +$ dock (pair @p term) ++$ gang (unit (set ship)) +$ mark @tas +++ omen |$ [a] (pair path (cask a)) +$ ship @p +$ sink (trel bone ship path) :: @@ -90,7 +94,9 @@ :: $monk: general identity :: $move: cause and action :: $ovum: card with cause -:: $scry-sample: vane +scry argument +:: $roof: namespace +:: $rook: meta-namespace +:: +room: generic namespace :: $vane-sample: vane wrapper-gate aargument :: $sley: namespace function :: $slyd: super advanced @@ -115,10 +121,21 @@ +$ move [=duct =ball] +$ ovum (pair wire curd) :: -+$ scry-sample - [fur=(unit (set monk)) ren=@tas why=shop syd=desk lot=coin tyl=path] ++$ roof (room vase) :: namespace ++$ rook (room meta) :: meta-namespace +++ room :: either namespace + |$ [a] + $~ =>(~ |~(* ~)) + $- $: lyc=gang :: leakset + cyr=term :: perspective + bem=beam :: path + == :: + %- unit :: ~: unknown + %- unit :: ~ ~: invalid + (cask a) +:: +$ vane-sample - [our=ship now=@da eny=@uvJ ski=slyd] + [our=ship now=@da eny=@uvJ rof=rook] :: +$ sley $- [* (unit (set monk)) term beam] @@ -187,12 +204,13 @@ == +$ germ [vane=term bars=(list duct)] +$ heir - $% [_arvo now=@da =debt =soul] + $% [_arvo =debt =soul] == +$ plan (pair germ (list move)) +$ soul $: our=ship :: identity eny=@uvJ :: entropy + now=@da :: time lac=? :: laconic bit ver=vere :: runtime lag=_| :: upgrade blocked @@ -221,6 +239,30 @@ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: section 3bE, Arvo core :: :: +++ en-beam + |=(b=beam =*(s scot `path`[(s %p p.b) q.b (s r.b) s.b])) +:: +++ de-beam + |= p=path + ^- (unit beam) + ?. ?=([@ @ @ *] p) ~ + ?~ who=(slaw %p i.p) ~ + ?~ des=?~(i.t.p (some %$) (slaw %tas i.t.p)) ~ :: XX +sym ;~(pose low (easy %$)) + ?~ ved=(slay i.t.t.p) ~ + ?. ?=([%$ case] u.ved) ~ + `(unit beam)`[~ [`ship`u.who `desk`u.des `case`p.u.ved] t.t.t.p] +:: +++ en-sley + |= =roof + ^- sley + |= [typ=* fur=(unit (set monk)) ron=term bed=beam] + =/ lyc=gang + ?~ fur ~ + :- ~ + %- ~(gas in *(set ship)) + (murn ~(tap in u.fur) |=(m=monk ?-(-.m %| ~, %& `p.m))) + (roof lyc ron bed) +:: ++ sloy :: +sloy: adapter from old style scrys to new style scrys :: @@ -275,10 +317,7 @@ ~/ %sloy-light |= sod/slyd |= [ref=* ron=@tas fal=@p dyc=@tas ved=case tyl=path] - :: we do not flop tyl because tyl wouldn't have been flopped by +en-beam - :: - =/ bed=beam - [[fal dyc ved] tyl] + =/ bed=beam [[fal dyc ved] tyl] =/ bop=(unit (unit (cask meta))) (sod ref ~ ron bed) ?~ bop ~ @@ -701,16 +740,17 @@ :: |plow:va: operate in time and space :: ++ plow - |= [now=@da sky=slyd] + |= [now=@da rok=rook] |% :: +peek:plow:va: read from a local namespace :: ++ peek - |= [fur=(unit (set monk)) ren=@t bed=beam] + ^- rook + |= [lyc=gang cyr=term bem=beam] ^- (unit (unit (cask meta))) :: namespace reads receive no entropy :: - =/ sam=vane-sample [our now *@uvJ sky] + =/ sam=vane-sample [our now *@uvJ rok] =^ rig sac ~> %mean.'peek: activation failed' (~(slym wa sac) vax sam) @@ -718,16 +758,13 @@ ~> %mean.'peek: call failed' (~(slap wa sac) rig [%limb %scry]) :: - ;; (unit (unit (cask meta))) - %+ slum q.gat - ^- scry-sample - :* fur - ren - [%& p.bed] - q.bed - `coin`[%$ r.bed] - s.bed - == + =/ mas=[gang term beam] [lyc cyr bem] + :: + =^ pro sac (~(slym wa sac) gat mas) + ?~ q.pro ~ + ?~ +.q.pro [~ ~] + =^ dat sac (~(slot wa sac) 7 pro) + ``[(,mark -.q.dat) (,^ +.q.dat)] :: :: |spin:plow:va: move statefully :: @@ -735,7 +772,7 @@ |= [hen=duct eny=@uvJ dud=(unit goof)] =* duc [duc.vil hen] =* err [dud.vil dud] - =/ sam=vane-sample [our now eny sky] + =/ sam=vane-sample [our now eny rok] =^ rig sac ~> %mean.'spin: activation failed' (~(slym wa sac) vax sam) @@ -820,17 +857,18 @@ == == :: - |_ [[pit=vase vil=vile] now=@da soul] + |_ [[pit=vase vil=vile] soul] +* this . - sol +<+> + sol +<+ :: :: +abet: finalize loop :: ++ abet ^- (each (pair (list ovum) soul) (trap ^)) ?~ but + ^- [%& (pair (list ovum) soul)] &/[(flop out) sol] - |/(gat.u.but [arvo now [run out [kel fil]:u.but] sol]) + |/(gat.u.but [arvo [run out [kel fil]:u.but] sol]) :: +poke: prepare a worklist-of-one from outside :: ++ poke @@ -965,8 +1003,9 @@ %+ turn von =/ bem=beam [[our %home da+now] /whey] |= [lal=@tas =vane] - =/ met (need (need (peek ** ~ (rsh 3 5 lal) bem))) - lal^|+;;((list mass) q.q.met) + =/ met (peek ~ (rsh 3 5 lal) bem) + ?> &(?=(^ met) ?=(^ u.met)) :: XX make optional + lal^|+;;((list mass) q.q.u.u.met) :: :+ %caches %| %+ turn von @@ -979,20 +1018,20 @@ :: +peek: read from the entire namespace :: ++ peek - ^- slyd - |= [typ=* fur=(unit (set monk)) ron=term bed=beam] + ^- rook + |= [lyc=gang cyr=term bem=beam] ^- (unit (unit (cask meta))) :: - :: XX identity is defaulted to ship from beam + ?: ?=(%$ cyr) + (peek:pith lyc %$ bem) :: - => .(fur ?^(fur fur `[[%& p.bed] ~ ~])) :: XX vane and care are concatenated :: - =/ lal (end 3 1 ron) - =/ ren ;;(@t (rsh 3 1 ron)) + =/ lal (end 3 1 cyr) + =/ ren ;;(@t (rsh 3 1 cyr)) ?. (~(has by van) lal) ~ - (peek:(plow lal) fur ren bed) + (peek:(plow lal) lyc ren bem) :: +call: advance to target :: ++ call @@ -1188,6 +1227,20 @@ %whey ..pith(out [[//arvo mass/whey] out]) == :: + ++ peek + ^- roof + |= [lyc=gang car=term bem=beam] + ^- (unit (unit cage)) + ?. ?| =(our p.bem) + ?=(%$ q.bem) + =([%da now] p.r.bem) + == + ~ + ?+ s.bem ~ + [%whey ~] ``mass/!>(whey) + [%lag ~] ``noun/!>(lag) + == + :: ++ poke |= =ovum ^+ ..pith @@ -1435,7 +1488,7 @@ :: restore working state and resume :: =/ zef=(each (pair (list ovum) soul) (trap ^)) - loop:(~(jump le:part [pit vil] now.hir sol) debt.hir) + loop:(~(jump le:part [pit vil] sol) debt.hir) ?- -.zef %& [p.p.zef ..load(sol q.p.zef)] %| $:p.zef @@ -1444,30 +1497,44 @@ :: +peek: external inspect :: ++ peek :: +46 - |= {now/@da hap/path} - ^- (unit) - ?~ hap - [~ ~ hoon-version] + |= $: lyc=gang + $= nom + %+ each path + $% [%once cyr=term syd=desk tyl=spur] + [%beam cyr=term bem=beam] + == + == + ^- (unit (cask)) + =/ hap=(unit [pat=? cyr=term bem=beam]) + ?- nom + [%& *] ?~ p.nom ~ + ?~ bem=(de-beam t.p.nom) ~ + `[| i.p.nom u.bem] + :: + [%| %beam *] `[| cyr bem]:p.nom + :: + [%| %once *] `[& cyr.p.nom [our syd.p.nom da/now] tyl.p.nom] + == :: - =/ el ~(. le:part [pit vil] now sol) - ?: =(hap /whey) - ``whey:el - =/ rob - ((sloy peek:el) [[151 %noun] hap]) - ?~ rob ~ - ?~ u.rob ~ - [~ u.u.rob] + ?~ hap ~ + =/ pro (~(peek le:part [pit vil] sol) lyc [cyr bem]:u.hap) + ?: |(?=(~ pro) ?=(~ u.pro)) ~ + =/ dat=(cask) [p q.q]:u.u.pro + ?. pat.u.hap `dat + `[%omen [cyr.u.hap (en-beam bem.u.hap)] dat] :: :: +poke: external apply :: ++ poke :: +47 |= [now=@da ovo=ovum] ^- ^ - =. eny (shaz (cat 3 eny now)) :: XX review + =: eny.sol (shaz (cat 3 eny now)) :: XX review + now.sol now + == :: ~| poke+-.q.ovo =/ zef=(each (pair (list ovum) soul) (trap ^)) - loop:(~(poke le:part [pit vil] now sol) ovo) + loop:(~(poke le:part [pit vil] sol) ovo) ?- -.zef %& [p.p.zef ..poke(sol q.p.zef)] %| $:p.zef @@ -1539,8 +1606,8 @@ == =/ nav %- ~(run by van) |=(a=(trap vase) (settle:va:part (slym $:a zus))) - =/ sol [u.who u.eny lac u.ver | u.fat zus nav] - `[arvo now *debt sol] + :^ ~ arvo *debt + [u.who u.eny now lac u.ver | u.fat zus nav] -- :: =| foal diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index 0ebe2d09c1..fd0887de38 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -425,9 +425,10 @@ =< =* adult-gate . =| queued-events=(qeu queued-event) :: - |= [our=ship now=@da eny=@ scry-gate=sley] + |= [our=ship now=@da eny=@ rof=roof] =* larval-gate . =* adult-core (adult-gate +<) + =* scry-gate (en-sley rof) |% :: +call: handle request $task :: @@ -610,9 +611,10 @@ :: =< =| =ames-state -|= [our=ship now=@da eny=@ scry-gate=sley] +|= [our=ship now=@da eny=@ rof=roof] =* ames-gate . =* veb veb.bug.ames-state +=* scry-gate (en-sley rof) |% :: +call: handle request $task :: @@ -739,8 +741,14 @@ :: +scry: dereference namespace :: ++ scry - |= [fur=(unit (set monk)) ren=@tas why=shop syd=desk lot=coin tyl=path] + |= [lyc=gang cyr=term bem=beam] ^- (unit (unit cage)) + =* ren cyr + =* why=shop &/p.bem + =* syd q.bem + =* lot=coin $/r.bem + =* tyl s.bem + :: ::TODO don't special-case whey scry :: ?: &(=(%$ ren) =(tyl /whey)) diff --git a/pkg/arvo/sys/vane/behn.hoon b/pkg/arvo/sys/vane/behn.hoon index 6f1db751c4..9102766faf 100644 --- a/pkg/arvo/sys/vane/behn.hoon +++ b/pkg/arvo/sys/vane/behn.hoon @@ -254,7 +254,7 @@ :: =| behn-state =* state - -|= [our=ship now=@da eny=@uvJ ski=sley] +|= [our=ship now=@da eny=@uvJ rof=roof] =* behn-gate . ^? |% @@ -376,8 +376,14 @@ :: which might or might not show up in the product :: ++ scry - |= [fur=(unit (set monk)) ren=@tas why=shop syd=desk lot=coin tyl=path] + |= [lyc=gang cyr=term bem=beam] ^- (unit (unit cage)) + =* ren cyr + =* why=shop &/p.bem + =* syd q.bem + =* lot=coin $/r.bem + =* tyl s.bem + :: ::TODO don't special-case whey scry :: ?: &(=(ren %$) =(tyl /whey)) diff --git a/pkg/arvo/sys/vane/clay.hoon b/pkg/arvo/sys/vane/clay.hoon index 0b8a4c8370..eb7177c22b 100644 --- a/pkg/arvo/sys/vane/clay.hoon +++ b/pkg/arvo/sys/vane/clay.hoon @@ -3960,7 +3960,8 @@ $: ver=%5 :: vane version ruf=raft :: revision tree == :: -|= [our=ship now=@da eny=@uvJ ski=sley] :: current invocation +|= [our=ship now=@da eny=@uvJ rof=roof] :: current invocation +=* ski (en-sley rof) |% :: ++ call :: handle request |= $: hen=duct @@ -4537,8 +4538,14 @@ -- :: ++ scry :: inspect - |= {fur/(unit (set monk)) ren/@tas why/shop syd/desk lot/coin tyl/path} + |= [lyc=gang cyr=term bem=beam] ^- (unit (unit cage)) + =* ren cyr + =/ why=shop &/p.bem + =* syd q.bem + =/ lot=coin $/r.bem + =* tyl s.bem + :: ?. ?=(%& -.why) ~ =* his p.why ?: &(=(ren %$) =(tyl /whey)) @@ -4552,13 +4559,8 @@ =+ run=((soft care) ren) ?~ run [~ ~] ::TODO if it ever gets filled properly, pass in the full fur. - =/ for/(unit ship) - %- ~(rep in (fall fur ~)) - |= {m/monk s/(unit ship)} - ?^ s s - ?: ?=(%| -.m) ~ - ?: =(p.m his) ~ - `p.m + :: + =/ for/(unit ship) ?~(lyc ~ ?~(u.lyc ~ `n.u.lyc)) =/ den ((de our now ski [/scryduct ~] ruf) his syd) =/ result (mule |.(-:(aver:den for u.run u.luk tyl))) ?: ?=(%| -.result) diff --git a/pkg/arvo/sys/vane/dill.hoon b/pkg/arvo/sys/vane/dill.hoon index 58b2b50042..80917a7b26 100644 --- a/pkg/arvo/sys/vane/dill.hoon +++ b/pkg/arvo/sys/vane/dill.hoon @@ -94,7 +94,8 @@ :::::::: :: dill tiles -- =| all/axle -|= [our=ship now=@da eny=@uvJ ski=sley] :: current invocation +|= [our=ship now=@da eny=@uvJ rof=roof] :: current invocation +=* ski (en-sley rof) => ~% %dill ..is ~ |% ++ as :: per cause @@ -484,8 +485,16 @@ == :: ++ scry - |= {fur/(unit (set monk)) ren/@tas why/shop syd/desk lot/coin tyl/path} + |= [lyc=gang cyr=term bem=beam] ^- (unit (unit cage)) + =* ren cyr + =* why=shop &/p.bem + =* syd q.bem + =* lot=coin $/r.bem + =* tyl s.bem + :: + ?. ?=(%& -.why) ~ + =* his p.why ::TODO don't special-case whey scry :: ?: &(=(ren %$) =(tyl /whey)) diff --git a/pkg/arvo/sys/vane/eyre.hoon b/pkg/arvo/sys/vane/eyre.hoon index 6643a0c426..9a827f4b34 100644 --- a/pkg/arvo/sys/vane/eyre.hoon +++ b/pkg/arvo/sys/vane/eyre.hoon @@ -2110,7 +2110,8 @@ =| ax=axle :: a vane is activated with current date, entropy, and a namespace function :: -|= [our=ship now=@da eny=@uvJ scry-gate=sley] +|= [our=ship now=@da eny=@uvJ rof=roof] +=* scry-gate (en-sley rof) :: allow jets to be registered within this core :: ~% %http-server ..is ~ @@ -2619,8 +2620,14 @@ :: +scry: request a path in the urbit namespace :: ++ scry - |= [fur=(unit (set monk)) ren=@tas why=shop syd=desk lot=coin tyl=path] + |= [lyc=gang cyr=term bem=beam] ^- (unit (unit cage)) + =* ren cyr + =* why=shop &/p.bem + =* syd q.bem + =/ lot=coin $/r.bem + =* tyl s.bem + :: ?. ?=(%& -.why) ~ =* who p.why diff --git a/pkg/arvo/sys/vane/ford.hoon b/pkg/arvo/sys/vane/ford.hoon index 65567bff2f..74060a1f78 100644 --- a/pkg/arvo/sys/vane/ford.hoon +++ b/pkg/arvo/sys/vane/ford.hoon @@ -1,6 +1,6 @@ !: |= pit=vase -|= [our=ship now=@da eny=@uvJ ski=sley] +|= [our=ship now=@da eny=@uvJ rof=roof] |% ++ call |=(* ((slog leaf+"ford: gone (+call)" ~) `..^$)) ++ take |=(* ((slog leaf+"ford: gone (+take)" ~) `..^$)) diff --git a/pkg/arvo/sys/vane/gall.hoon b/pkg/arvo/sys/vane/gall.hoon index 8840909ba2..30f3718cd6 100644 --- a/pkg/arvo/sys/vane/gall.hoon +++ b/pkg/arvo/sys/vane/gall.hoon @@ -135,9 +135,10 @@ :: =< =* adult-gate . =| =spore - |= [our=ship now=@da eny=@uvJ ski=sley] + |= [our=ship now=@da eny=@uvJ rof=roof] =* pupal-gate . =* adult-core (adult-gate +<) + =* ski (en-sley rof) =< |% ++ call ^call ++ load ^load @@ -334,8 +335,9 @@ :: adult gall vane interface, for type compatibility with pupa :: =| state=state-7 -|= [our=ship now=@da eny=@uvJ ski=sley] +|= [our=ship now=@da eny=@uvJ rof=roof] =* gall-payload . +=* ski (en-sley rof) =< ~% %gall-wrap ..mo ~ |% ++ call ^call @@ -1717,8 +1719,14 @@ :: ++ scry ~/ %gall-scry - |= [fur=(unit (set monk)) care=term =shop dap=desk =coin =path] + |= [lyc=gang cyr=term bem=beam] ^- (unit (unit cage)) + =* care cyr + =/ =shop &/p.bem + =* dap q.bem + =/ =coin $/r.bem + =* path s.bem + :: ?. ?=(%.y -.shop) ~ =/ =ship p.shop diff --git a/pkg/arvo/sys/vane/iris.hoon b/pkg/arvo/sys/vane/iris.hoon index 0cc5de7bd3..384b20eec7 100644 --- a/pkg/arvo/sys/vane/iris.hoon +++ b/pkg/arvo/sys/vane/iris.hoon @@ -297,7 +297,8 @@ =| ax=axle :: a vane is activated with current date, entropy, and a namespace function :: -|= [our=ship now=@da eny=@uvJ scry-gate=sley] +|= [our=ship now=@da eny=@uvJ rof=roof] +=* scry-gate (en-sley rof) :: allow jets to be registered within this core :: ~% %http-client ..is ~ @@ -390,8 +391,14 @@ :: +scry: request a path in the urbit namespace :: ++ scry - |= {fur/(unit (set monk)) ren/@tas why/shop syd/desk lot/coin tyl/path} + |= [lyc=gang cyr=term bem=beam] ^- (unit (unit cage)) + =* ren cyr + =* why=shop &/p.bem + =* syd q.bem + =* lot=coin $/r.bem + =* tyl s.bem + :: ?. ?=(%& -.why) ~ =* his p.why ?: &(=(ren %$) =(tyl /whey)) diff --git a/pkg/arvo/sys/vane/jael.hoon b/pkg/arvo/sys/vane/jael.hoon index 401eb41abc..18873c214f 100644 --- a/pkg/arvo/sys/vane/jael.hoon +++ b/pkg/arvo/sys/vane/jael.hoon @@ -1003,7 +1003,7 @@ our=ship now=@da eny=@uvJ - ski=sley + rof=roof == ^? |% @@ -1040,21 +1040,14 @@ ..^$(lex new) :: :: ++scry ++ scry :: inspect - |= $: :: fur: event security - :: ren: access mode - :: why: owner - :: syd: desk (branch) - :: lot: case (version) - :: tyl: rest of path - :: - fur/(unit (set monk)) - ren/@tas - why/shop - syd/desk - lot/coin - tyl/spur - == + |= [lyc=gang cyr=term bem=beam] ^- (unit (unit cage)) + =* ren cyr + =* why=shop &/p.bem + =* syd q.bem + =* lot=coin $/r.bem + =* tyl s.bem + :: :: XX review for security, stability, cases other than now :: ?. =(lot [%$ %da now]) ~ diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index 653db1a2f8..6809f73081 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -78,27 +78,12 @@ +$ mime (pair mite octs) :: mimetyped data +$ octs (pair @ud @) :: octet-stream +$ sock (pair ship ship) :: outgoing [our his] -::+| -:: -+$ roof (room vase) :: namespace -++ room :: either namespace - |$ [vase] :: vase or maze - $- $: ref=* :: reference type - lyc=(unit (set ship)) :: leakset - car=term :: perspective - bem=beam :: path - == :: - %- unit :: ~: unknown - %- unit :: ~ ~: invalid - (cask vase) :: marked cargo -:: +$ stub (list (pair stye (list @c))) :: styled unicode +$ stye (pair (set deco) (pair tint tint)) :: decos/bg/fg +$ styl %+ pair (unit deco) :: cascading style (pair (unit tint) (unit tint)) :: +$ styx (list $@(@t (pair styl styx))) :: styled text +$ tint ?($r $g $b $c $m $y $k $w $~) :: text color -:: +$ turf (list @t) :: domain, tld first :: :: :::: ++jstd :: json standards structures @@ -6906,30 +6891,6 @@ :: :::: ++ wired ^? |% - :: - ++ auld :: ++auld:wired - |= sky/roof :: old style namespace - ^- slyt - |= {ref/* raw/*} - =+ pux=((soft path) raw) - ?~ pux ~ - ?. ?=({@ @ @ @ *} u.pux) ~ - =+ :* hyr=(slay i.u.pux) - fal=(slay i.t.u.pux) - dyc=(slay i.t.t.u.pux) - ved=(slay i.t.t.t.u.pux) - tyl=t.t.t.t.u.pux - == - ?. ?=({~ $$ $tas @} hyr) ~ - ?. ?=({~ $$ $p @} fal) ~ - ?. ?=({~ $$ $tas @} dyc) ~ - ?. ?=(^ ved) ~ - =+ ron=q.p.u.hyr - =+ bed=[[q.p.u.fal q.p.u.dyc (case p.u.ved)] (flop tyl)] - =+ bop=(sky ref ~ ron bed) - ?~ bop ~ - ?~ u.bop [~ ~] - [~ ~ +.q.u.u.bop] :: :: ++dray:wired ++ dray :: load tuple in path :: From 71fb3d66d822f44775c8841bec7adff113f0ba39 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 23 Nov 2020 18:05:15 -0800 Subject: [PATCH 741/933] vere: scry reform --- pkg/urbit/include/c/motes.h | 2 + pkg/urbit/include/vere/vere.h | 26 +++--------- pkg/urbit/noun/vortex.c | 4 +- pkg/urbit/vere/lord.c | 78 +++++++++++++++++------------------ pkg/urbit/vere/pier.c | 25 +---------- pkg/urbit/vere/ward.c | 6 +-- pkg/urbit/worker/serf.c | 42 ++----------------- 7 files changed, 51 insertions(+), 132 deletions(-) diff --git a/pkg/urbit/include/c/motes.h b/pkg/urbit/include/c/motes.h index 15320ea06b..57d67979c6 100644 --- a/pkg/urbit/include/c/motes.h +++ b/pkg/urbit/include/c/motes.h @@ -796,8 +796,10 @@ # define c3__off c3_s3('o','f','f') # define c3__ogre c3_s4('o','g','r','e') # define c3__old c3_s3('o','l','d') +# define c3__omen c3_s4('o','m','e','n') # define c3__on c3_s2('o','n') # define c3__onan c3_s4('o','n','a','n') +# define c3__once c3_s4('o','n','c','e') # define c3__one c3_s3('o','n','e') # define c3__only c3_s4('o','n','l','y') # define c3__oops c3_s4('o','o','p','s') diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index ccff01130f..66df7e4288 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -382,8 +382,7 @@ */ typedef enum { u3_pico_full = 0, - u3_pico_mine = 1, - u3_pico_last = 2 + u3_pico_once = 1 } u3_pico_type; /* u3_pico: proto-peek @@ -395,12 +394,8 @@ u3_noun gan; // leakset u3_pico_type typ_e; // type-tagged union { // - u3_noun ful; // full: /care/beam - struct { // mine: - c3_m car_m; // care - u3_noun pax; // /desk/case/path - } min_u; // - struct { // last: + u3_noun ful; // (each path [%beam term beam]) + struct { // once: c3_m car_m; // care u3_atom des; // desk u3_noun pax; // /path @@ -413,9 +408,8 @@ typedef struct _u3_peek { void* ptr_v; // context u3_peek_cb fun_f; // callback - u3_noun now; // XX - u3_noun gan; // leakset - u3_noun ful; // /care/beam + u3_pico_type typ_e; // type + u3_noun sam; // +peek sample } u3_peek; /* u3_writ_type: king->serf ipc message types @@ -1241,16 +1235,6 @@ void* ptr_v, u3_peek_cb fun_f); - /* u3_pier_peek_mine(): read namespace, injecting ship. - */ - void - u3_pier_peek_mine(u3_pier* pir_u, - u3_noun gan, - c3_m car_m, - u3_noun pax, - void* ptr_v, - u3_peek_cb fun_f); - /* u3_pier_peek_last(): read namespace, injecting ship and case. */ void diff --git a/pkg/urbit/noun/vortex.c b/pkg/urbit/noun/vortex.c index 63cbb25400..168334bdcd 100644 --- a/pkg/urbit/noun/vortex.c +++ b/pkg/urbit/noun/vortex.c @@ -191,11 +191,9 @@ _cv_time_bump(u3_reck* rec_u) /* u3v_peek(): query the reck namespace (protected). */ u3_noun -u3v_peek(u3_noun hap) +u3v_peek(u3_noun sam) { u3_noun fun = u3n_nock_on(u3k(u3A->roc), u3k(u3x_at(_CVX_PEEK, u3A->roc))); - u3_noun sam = u3nc(u3k(u3A->now), hap); - return u3n_slam_on(fun, sam); } diff --git a/pkg/urbit/vere/lord.c b/pkg/urbit/vere/lord.c index 394cb6c5e7..ba24e27fd0 100644 --- a/pkg/urbit/vere/lord.c +++ b/pkg/urbit/vere/lord.c @@ -35,7 +35,7 @@ [%meld ~] [%pack ~] == == - [%peek mil=@ now=@da lyc=gang pat=path] + [%peek mil=@ sam=*] :: gang (each path $%([%once @tas @tas path] [beam @tas beam])) [%play eve=@ lit=(list ?((pair @da ovum) *))] [%work mil=@ job=(pair @da ovum)] == @@ -99,9 +99,7 @@ _lord_writ_free(u3_writ* wit_u) } break; case u3_writ_peek: { - u3z(wit_u->pek_u->now); - u3z(wit_u->pek_u->gan); - u3z(wit_u->pek_u->ful); + u3z(wit_u->pek_u->sam); } break; case u3_writ_play: { @@ -371,9 +369,7 @@ _lord_plea_peek_bail(u3_lord* god_u, u3_peek* pek_u, u3_noun dud) pek_u->fun_f(pek_u->ptr_v, u3_nul); - u3z(pek_u->now); - u3z(pek_u->gan); - u3z(pek_u->ful); + u3z(pek_u->sam); c3_free(pek_u); } @@ -382,13 +378,25 @@ _lord_plea_peek_bail(u3_lord* god_u, u3_peek* pek_u, u3_noun dud) static void _lord_plea_peek_done(u3_lord* god_u, u3_peek* pek_u, u3_noun rep) { + // XX review + // + if ( (u3_pico_once == pek_u->typ_e) + && (u3_nul != rep) ) + { + u3_noun dat; + + if ( c3y == u3r_pq(u3t(rep), c3__omen, 0, &dat) ) { + u3k(dat); + u3z(rep); + rep = u3nc(u3_nul, dat); + } + } + // XX cache [dat] (unless last) // pek_u->fun_f(pek_u->ptr_v, rep); - u3z(pek_u->now); - u3z(pek_u->gan); - u3z(pek_u->ful); + u3z(pek_u->sam); c3_free(pek_u); } @@ -754,10 +762,9 @@ _lord_writ_make(u3_lord* god_u, u3_writ* wit_u) } break; case u3_writ_peek: { - msg = u3nc(c3__peek, u3nq(0, // XX support timeouts - u3k(wit_u->pek_u->now), - u3k(wit_u->pek_u->gan), - u3k(wit_u->pek_u->ful))); + // XX support timeouts, + // + msg = u3nc(c3__peek, u3nc(0, u3k(wit_u->pek_u->sam))); } break; case u3_writ_play: { @@ -862,39 +869,28 @@ u3_lord_peek(u3_lord* god_u, u3_pico* pic_u) wit_u->pek_u = c3_calloc(sizeof(*wit_u->pek_u)); wit_u->pek_u->ptr_v = pic_u->ptr_v; wit_u->pek_u->fun_f = pic_u->fun_f; - wit_u->pek_u->now = u3_time_in_tv(&wit_u->tim_u); - wit_u->pek_u->gan = u3k(pic_u->gan); + wit_u->pek_u->typ_e = pic_u->typ_e; // construct the full scry path // - switch ( pic_u->typ_e ) { - default: c3_assert(0); + { + u3_noun sam; + switch ( pic_u->typ_e ) { + default: c3_assert(0); - case u3_pico_full: { - wit_u->pek_u->ful = u3k(pic_u->ful); - } break; + case u3_pico_full: { + sam = u3k(pic_u->ful); + } break; - case u3_pico_mine: { - // XX cache - // - u3_pier* pir_u = god_u->cb_u.ptr_v; // XX do better - u3_noun our = u3dc("scot", 'p', u3i_chubs(2, pir_u->who_d)); - wit_u->pek_u->ful = u3nt(pic_u->min_u.car_m, our, u3k(pic_u->min_u.pax)); - } break; + case u3_pico_once: { + sam = u3nc(c3n, u3nq(c3__once, + pic_u->las_u.car_m, + u3k(pic_u->las_u.des), + u3k(pic_u->las_u.pax))); + } break; + } - case u3_pico_last: { - // XX cache - // - u3_pier* pir_u = god_u->cb_u.ptr_v; // XX do better - u3_noun our = u3dc("scot", 'p', u3i_chubs(2, pir_u->who_d)); - u3_noun cas = u3dc("scot", c3__da, u3k(wit_u->pek_u->now)); - - wit_u->pek_u->ful = u3nc(pic_u->las_u.car_m, - u3nq(our, - u3k(pic_u->las_u.des), - cas, - u3k(pic_u->las_u.pax))); - } break; + wit_u->pek_u->sam = u3nc(u3k(pic_u->gan), sam); } // XX cache check, unless last diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index 06b7c59a5b..0603a59c8d 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -436,29 +436,6 @@ u3_pier_peek(u3_pier* pir_u, _pier_peek_plan(pir_u, pic_u); } -/* u3_pier_peek_mine(): read namespace, injecting ship. -*/ -void -u3_pier_peek_mine(u3_pier* pir_u, - u3_noun gan, - c3_m car_m, - u3_noun pax, - void* ptr_v, - u3_peek_cb fun_f) -{ - u3_pico* pic_u = u3_pico_init(); - - pic_u->ptr_v = ptr_v; - pic_u->fun_f = fun_f; - pic_u->gan = gan; - // - pic_u->typ_e = u3_pico_mine; - pic_u->min_u.car_m = car_m; - pic_u->min_u.pax = pax; - - _pier_peek_plan(pir_u, pic_u); -} - /* u3_pier_peek_last(): read namespace, injecting ship and case. */ void @@ -476,7 +453,7 @@ u3_pier_peek_last(u3_pier* pir_u, pic_u->fun_f = fun_f; pic_u->gan = gan; // - pic_u->typ_e = u3_pico_last; + pic_u->typ_e = u3_pico_once; pic_u->las_u.car_m = car_m; pic_u->las_u.des = des; pic_u->las_u.pax = pax; diff --git a/pkg/urbit/vere/ward.c b/pkg/urbit/vere/ward.c index 7ff997deb5..f4db6badf7 100644 --- a/pkg/urbit/vere/ward.c +++ b/pkg/urbit/vere/ward.c @@ -191,11 +191,7 @@ u3_pico_free(u3_pico* pic_u) u3z(pic_u->ful); } break; - case u3_pico_mine: { - u3z(pic_u->min_u.pax); - } break; - - case u3_pico_last: { + case u3_pico_once: { u3z(pic_u->las_u.des); u3z(pic_u->las_u.pax); } break; diff --git a/pkg/urbit/worker/serf.c b/pkg/urbit/worker/serf.c index 6bfb771b68..7997d33f36 100644 --- a/pkg/urbit/worker/serf.c +++ b/pkg/urbit/worker/serf.c @@ -37,7 +37,7 @@ [%meld ~] [%pack ~] == == - [%peek mil=@ now=@da lyc=gang pat=path] + [%peek mil=@ sam=*] :: gang (each path $%([%once @tas @tas path] [beam @tas beam])) [%play eve=@ lit=(list ?((pair @da ovum) *))] [%work mil=@ job=(pair @da ovum)] == @@ -776,43 +776,17 @@ u3_serf_play(u3_serf* sef_u, c3_d eve_d, u3_noun lit) u3_noun u3_serf_peek(u3_serf* sef_u, c3_w mil_w, u3_noun sam) { - u3_noun wen, pat, pro; - - // stash the previous date and set current - // - // XX incomplete interface, arvo should track the date - // - wen = u3A->now; - - { - u3_noun now, lyc; - u3x_trel(sam, &now, &lyc, &pat); - u3A->now = u3k(now); - } - + u3_noun gon = u3m_soft(mil_w, u3v_peek, sam); + u3_noun pro; { u3_noun tag, dat; - - // XX incomplete interface, should pass [lyc] as well - // - u3_noun gon = u3m_soft(mil_w, u3v_peek, u3k(pat)); u3x_cell(gon, &tag, &dat); // read succeeded, produce result // if ( u3_blip == tag ) { - if ( u3_nul == dat ) { - pro = u3nc(c3__done, u3_nul); - } - else { - // prepend the %noun mark - // - // XX incomplete interface, should recv mark from arvo - // - pro = u3nq(c3__done, u3_nul, c3__noun, u3k(u3t(dat))); - } - + pro = u3nc(c3__done, u3k(dat)); u3z(gon); } // read failed, produce trace @@ -824,14 +798,6 @@ u3_serf_peek(u3_serf* sef_u, c3_w mil_w, u3_noun sam) } } - // restore the previous date - // - // XX incomplete interface, arvo should track the date - // - u3z(u3A->now); - u3A->now = wen; - - u3z(sam); return u3nc(c3__peek, pro); } From fe72283e08311d1f873a2404b71581fc65b63dd9 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 25 Nov 2020 14:10:05 -0800 Subject: [PATCH 742/933] pill: solid --- bin/solid.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index bae42bad84..d9870a983b 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:28578b9283cc8749b45628a7964dbe788020cb888bf08a7f94935d93f16bfdb5 -size 6484247 +oid sha256:4d2e41ef5b2a292a9dfd7e485d027441c9649f6e4f2bbf91ac776698a88fd151 +size 6384147 From e85f00f46b439fc76209569f5a51bf0c22b9b1bd Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 25 Nov 2020 15:54:48 -0800 Subject: [PATCH 743/933] arvo: only allow a single %whom --- pkg/arvo/sys/arvo.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index 724943b838..46bfd5fa0b 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -1662,7 +1662,7 @@ (~(put by van) way (mint $:u.bod way /sys/vane/[p]/hoon q)) == :: - %whom ..poke(who `p.gub) + %whom ..poke(who ~|(%whom-once ?>(?=(~ who) `p.gub))) %wyrd %- %+ wyrd kel.p.gub ^- (list (pair term @)) :* hoon/hoon-version From eaa77fae3ee8c25187445cca153b38d54184e57d Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 25 Nov 2020 15:55:07 -0800 Subject: [PATCH 744/933] arvo: require both hoon and arvo in initial larval filesystem --- pkg/arvo/sys/arvo.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index 46bfd5fa0b..f991baa5c3 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -1645,7 +1645,7 @@ :: =? taf =(~ dir.taf) :: XX TMI ~| %larval-need-kernel - ?> ?=(^ tub) + ?> &(?=(^ tub) ?=(^ hun.p.u.tub)) (~(gas de taf) q.u.tub) :: =^ job taf [p q]:(~(adorn adapt:part taf) del |) From e1dbd37b5c256d61eef442ed938ab50764dffa51 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 25 Nov 2020 16:48:44 -0800 Subject: [PATCH 745/933] arvo: remove old-style event routing --- pkg/arvo/sys/arvo.hoon | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index f991baa5c3..a12bfeb781 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -1128,11 +1128,10 @@ ++ gest |= =ovum ^- $>(%pass ball) - =^ way=term wire.ovum wire.ovum - :: - :: XX uncomment to restore previous routing - :: - :: =? way ?=(%$ way) (dint wire.ovum) + =^ way=term wire.ovum + ~| %gest-wire + ?> ?=(^ wire.ovum) + [(wilt i.wire.ovum) t.wire.ovum] :: :: %$: default, routed to arvo-proper as trivial vase :: @: route to vane XX remove %soft, clam via %zuse @@ -1404,19 +1403,6 @@ dud=(pal '=<($ (unit goof))') :: XX misparse == :: -++ dint :: input routing - |= hap=path ^- @tas - ?+ hap %$ - [%ames *] %a - [%boat *] %c - [%newt *] %a - [%sync *] %c - [%term *] %d - [%http-client *] %i - [%http-server *] %e - [%behn *] %b - == -:: ++ grow |= way=term ?+ way way From 03b89e7072ae91b8934eb2cb79595dca24d78b41 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Thu, 26 Nov 2020 10:58:54 +1000 Subject: [PATCH 746/933] notifications: fix note description render --- pkg/interface/src/views/apps/notifications/graph.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/interface/src/views/apps/notifications/graph.tsx b/pkg/interface/src/views/apps/notifications/graph.tsx index 64fc5c7fd2..02351e6455 100644 --- a/pkg/interface/src/views/apps/notifications/graph.tsx +++ b/pkg/interface/src/views/apps/notifications/graph.tsx @@ -44,7 +44,7 @@ function describeNotification(description: string, plural: boolean) { return `left ${pluralize("comment", plural)} on`; case "edit-comment": return `updated ${pluralize("comment", plural)} on`; - case "new-note": + case "note": return `posted ${pluralize("note", plural)} to`; case "edit-note": return `updated ${pluralize("note", plural)} in`; From 531f406222c15116c2ff4ccc6622f1eae4f2128f Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Wed, 25 Nov 2020 20:11:34 -0500 Subject: [PATCH 747/933] glob: update to 0v2.qmtv4.6j75q.g4ph5.5agd1.02hsd --- bin/solid.pill | 4 ++-- pkg/arvo/app/glob.hoon | 2 +- pkg/arvo/app/landscape/index.html | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index 77837f3f4b..da53eec279 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f639b862842609c64aa387f8414f9f8bcf1db5d89ae3e54e64aa1b040f21f7e0 -size 6315993 +oid sha256:4d0b09d1f033b59f626ae8727f5122db0dc03f86863f6b6b1ee02d9ec912d35e +size 6316479 diff --git a/pkg/arvo/app/glob.hoon b/pkg/arvo/app/glob.hoon index 472f938331..f3fa507cf5 100644 --- a/pkg/arvo/app/glob.hoon +++ b/pkg/arvo/app/glob.hoon @@ -5,7 +5,7 @@ /- glob /+ default-agent, verb, dbug |% -++ hash 0v4.fpa4r.s6dtc.h8tps.62jv0.qn0fj +++ hash 0v2.qmtv4.6j75q.g4ph5.5agd1.02hsd +$ state-0 [%0 hash=@uv glob=(unit (each glob:glob tid=@ta))] +$ all-states $% state-0 diff --git a/pkg/arvo/app/landscape/index.html b/pkg/arvo/app/landscape/index.html index a2a06dea17..f5e9281671 100644 --- a/pkg/arvo/app/landscape/index.html +++ b/pkg/arvo/app/landscape/index.html @@ -24,6 +24,6 @@
- + From 7e88db06d3c0934c8a6cfb2e5b580e9627f1ee7d Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Wed, 25 Nov 2020 20:15:50 -0500 Subject: [PATCH 748/933] landscape: fix dismiss --- pkg/interface/src/views/App.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/interface/src/views/App.js b/pkg/interface/src/views/App.js index 88dda65259..c44ed52914 100644 --- a/pkg/interface/src/views/App.js +++ b/pkg/interface/src/views/App.js @@ -153,7 +153,7 @@ class App extends React.Component { A network-wide breach is scheduled for early December 2020. Please visit urbit.org/breach for more information.
{ - banner.style.displaydisplay = "none"; + banner.style.display = "none"; localStorage.setItem("2020BreachBanner", "none"); }}>Dismiss From 959b585b384f66e54421f70f95d6d152077907bb Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Wed, 25 Nov 2020 20:19:24 -0500 Subject: [PATCH 749/933] glob: update to 0v5.0umdn.af5hq.bp84b.66eao.q0b98 --- pkg/arvo/app/glob.hoon | 2 +- pkg/arvo/app/landscape/index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/app/glob.hoon b/pkg/arvo/app/glob.hoon index f3fa507cf5..de1514d5a3 100644 --- a/pkg/arvo/app/glob.hoon +++ b/pkg/arvo/app/glob.hoon @@ -5,7 +5,7 @@ /- glob /+ default-agent, verb, dbug |% -++ hash 0v2.qmtv4.6j75q.g4ph5.5agd1.02hsd +++ hash 0v5.0umdn.af5hq.bp84b.66eao.q0b98 +$ state-0 [%0 hash=@uv glob=(unit (each glob:glob tid=@ta))] +$ all-states $% state-0 diff --git a/pkg/arvo/app/landscape/index.html b/pkg/arvo/app/landscape/index.html index f5e9281671..bd6b1828d2 100644 --- a/pkg/arvo/app/landscape/index.html +++ b/pkg/arvo/app/landscape/index.html @@ -24,6 +24,6 @@
- + From 4d5f1388f4a3c4a7f92847205813ffdec71af922 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 25 Nov 2020 18:57:41 -0800 Subject: [PATCH 750/933] arvo: fix hoon source reference in +boot re-compilation --- pkg/arvo/sys/arvo.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index a12bfeb781..fc65609771 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -1355,7 +1355,7 @@ [raw cop] =/ hot ~> %slog.[0 leaf+"vega: recompiling hoon %{<`@`nex>}"] - (road |.((slum cop [%noun hun]))) + (road |.((slum cop [%noun u.hun]))) [hot .*(0 +.hot)] :: extract the hoon core from the outer gate (+ride) :: From b8974d5338097653dd41da3a6c27d39e60eb9e8b Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 25 Nov 2020 19:03:05 -0800 Subject: [PATCH 751/933] arvo: improves faces in vane install/upgrade --- pkg/arvo/sys/arvo.hoon | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index fc65609771..4748243c36 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -1186,10 +1186,10 @@ %= ..pith van %+ roll van.job - |= [[(cask hoof)] =_van] + |= [[nam=term txt=hoof] =_van] ^+ van - =/ way (wilt p) - =/ nex (create:va zus way /sys/vane/[p]/hoon q) + =/ way (wilt nam) + =/ nex (create:va zus way /sys/vane/[nam]/hoon txt) =/ nav (~(get by van) way) =? nex ?=(^ nav) (update:va vase.u.nav nex) (~(put by van) way (settle:va nex)) From f851803d3c350c6bba1bd8c738bf605d66592789 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Thu, 26 Nov 2020 15:42:23 +1000 Subject: [PATCH 752/933] pull-hook: do not crash on dangling sync If the %kick handler of the inner-core crashes, then we never get to resubscribe, thus leaving a dangling entry in the state with no corresponding subscription. Updates the pull-hook-action pokes to not crash when given a dangling entry. --- pkg/arvo/lib/pull-hook.hoon | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/pkg/arvo/lib/pull-hook.hoon b/pkg/arvo/lib/pull-hook.hoon index cb3b5e6f73..3c5ef03b3b 100644 --- a/pkg/arvo/lib/pull-hook.hoon +++ b/pkg/arvo/lib/pull-hook.hoon @@ -304,33 +304,35 @@ =. tracking (~(put by tracking) resource ship) :_ state - ~[(watch-resource resource /)] + (watch-resource resource /) :: ++ remove |= =resource - :- ~[(leave-resource resource)] + :- (leave-resource resource) state(tracking (~(del by tracking) resource)) -- :: ++ leave-resource |= rid=resource - ^- card - =/ =ship - (~(got by tracking) rid) + ^- (list card) + =/ ship=(unit ship) + (~(get by tracking) rid) + ?~ ship ~ =/ =wire (make-wire pull+resource+(en-path:resource rid)) - [%pass wire %agent [ship push-hook-name.config] %leave ~] + [%pass wire %agent [u.ship push-hook-name.config] %leave ~]~ ++ watch-resource |= [rid=resource pax=path] - ^- card - =/ =ship - (~(got by tracking) rid) + ^- (list card) + =/ ship=(unit ship) + (~(get by tracking) rid) + ?~ ship ~ =/ =path (welp resource+(en-path:resource rid) pax) =/ =wire (make-wire pull+path) - [%pass wire %agent [ship push-hook-name.config] %watch path] + [%pass wire %agent [u.ship push-hook-name.config] %watch path]~ :: ++ make-wire |= =wire From f73a96ba904ec12f31cdd7f0dab209db1c7ee885 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Thu, 26 Nov 2020 16:09:14 +1000 Subject: [PATCH 753/933] pull-hook: backstop crashed kick handler Virtualises the kick handler for the inner door in lib/pull-hook, so that crashes in the handler do not cause a dangling resource with no subscription. Additionally, failed kicks now cause the sync to be dropped into a failed-kicks map in the state, where we attempt to recover from the failure in the on-load. --- pkg/arvo/lib/pull-hook.hoon | 101 +++++++++++++++++++++++++++++++----- 1 file changed, 89 insertions(+), 12 deletions(-) diff --git a/pkg/arvo/lib/pull-hook.hoon b/pkg/arvo/lib/pull-hook.hoon index 3c5ef03b3b..78566ad3c2 100644 --- a/pkg/arvo/lib/pull-hook.hoon +++ b/pkg/arvo/lib/pull-hook.hoon @@ -49,13 +49,21 @@ inner-state=vase == :: ++$ base-state-1 + $: base-state-0 + failed-kicks=(map resource ship) + == +:: +$ state-0 [%0 base-state-0] :: +$ state-1 [%1 base-state-0] :: ++$ state-2 [%2 base-state-1] +:: +$ versioned-state $% state-0 state-1 + state-2 == :: ++ default @@ -141,7 +149,7 @@ ++ agent |* =config |= =(pull-hook config) - =| state-1 + =| state-2 =* state - ^- agent:gall =< @@ -155,6 +163,7 @@ =^ cards pull-hook on-init:og [cards this] + :: ++ on-load |= =old=vase =/ old @@ -162,10 +171,16 @@ =| cards=(list card:agent:gall) |^ ?- -.old - %1 + %2 =^ og-cards pull-hook (on-load:og inner-state.old) - [(weld cards og-cards) this(state old)] + =. state old + =^ retry-cards state + retry-failed-kicks + :_ this + :(weld cards og-cards retry-cards) + :: + %1 $(old [%2 +.old ~]) :: %0 %_ $ @@ -175,6 +190,22 @@ (weld cards (missing-subscriptions tracking.old)) == == + :: + ++ retry-failed-kicks + =| acc-cards=(list card) + =/ failures=(list [rid=resource =ship]) + ~(tap by failed-kicks) + =. tracking + (~(uni by tracking) failed-kicks) + =. failed-kicks ~ + |- ^- (quip card _state) + ?~ failures + [acc-cards state] + =, failures + =^ crds state + (handle-kick:hc i) + $(failures t, acc-cards (weld acc-cards crds)) + :: ++ missing-subscriptions |= tracking=(map resource ship) ^- (list card:agent:gall) @@ -232,15 +263,9 @@ (de-path:resource t.t.t.t.wire) ?+ -.sign (on-agent:def wire sign) %kick - =/ pax=(unit path) - (on-pull-kick:og rid) - ?^ pax - :_ this - ~[(watch-resource:hc rid u.pax)] - =. tracking - (~(del by tracking) rid) - :_ this - ~[give-update] + =^ cards state + (handle-kick:hc rid src.bowl) + [cards this] :: %watch-ack ?~ p.sign @@ -286,6 +311,58 @@ -- |_ =bowl:gall +* og ~(. pull-hook bowl) + ++ mule-scry + |= [ref=* raw=*] + =/ pax=(unit path) + ((soft path) raw) + ?~ pax ~ + ?. ?=([@ @ @ @ *] u.pax) ~ + =/ ship + (slaw %p i.t.u.pax) + =/ ved + (slay i.t.t.t.u.pax) + =/ dat + ?~ ved now.bowl + =/ cas=(unit case) + ((soft case) p.u.ved) + ?~ cas now.bowl + ?: ?=(%da -.u.cas) + p.u.cas + now.bowl + :: catch bad gall scries early + ?: ?& =((end 3 1 i.u.pax) %g) + ?| !=(`our.bowl ship) + !=(dat now.bowl) + == + == + ~ + ``.^(* u.pax) + ++ handle-kick + |= [rid=resource =ship] + ^- (quip card _state) + =/ res=toon + (mock [|.((on-pull-kick:og rid)) %9 2 %0 1] mule-scry) + =/ pax=(unit path) + !< (unit path) + :- -:!>(*(unit path)) + ?:(?=(%0 -.res) p.res ~) + =? failed-kicks !?=(%0 -.res) + =/ tang + :+ leaf+"failed kick handler, please report" + leaf+"{} in {(trip dap.bowl)}" + ?: ?=(%2 -.res) + p.res + ?> ?=(%1 -.res) + (turn `(list *)`p.res (cork path smyt)) + %- (slog tang) + (~(put by failed-kicks) rid ship) + ?^ pax + :_ state + (watch-resource rid u.pax) + =. tracking + (~(del by tracking) rid) + :_ state + ~[give-update] :: ++ poke-hook-action |= =action From aba8bdc989a00e2efeb1a9b50363713c9bac7353 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 25 Nov 2020 19:32:18 -0800 Subject: [PATCH 754/933] arvo: moves tasks to top-level, restructures state --- pkg/arvo/sys/arvo.hoon | 376 ++++++++++++++++++++++------------------- 1 file changed, 199 insertions(+), 177 deletions(-) diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index 4748243c36..30e96e19a1 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -37,6 +37,7 @@ :: $dock: message target :: $gang: infinite set of peers :: $mark: symbolic content type +:: $mien: orientation :: +omen: namespace path and data :: $ship: network identity :: $sink: subscription @@ -67,6 +68,7 @@ +$ dock (pair @p term) +$ gang (unit (set ship)) +$ mark @tas ++$ mein [our=ship now=@da eny=@uvJ] ++ omen |$ [a] (pair path (cask a)) +$ ship @p +$ sink (trel bone ship path) @@ -182,6 +184,7 @@ +| %implementation :: :: $debt: ephemeral state +:: $grub: persistent state, larval stage :: $germ: worklist source and bar stack :: $heir: upgradeable state :: $plan: worklist @@ -189,6 +192,9 @@ :: $vane: kernel module :: $vere: runtime version :: $vile: reflexive constants +:: $waif: arvo task, from anywhere +:: $wasp: arvo task, from Outside +:: $wisp: arvo task, larval stage :: $wynn: kelvin stack :: +$ debt @@ -203,20 +209,52 @@ fil=(list (pair path (cask))) == +$ germ [vane=term bars=(list duct)] ++$ grub + $: :: who: identity once we know it + :: eny: entropy once we learn it + :: bod: %zuse once we receive it + :: + who=(unit ship) + eny=(unit @) + lac=? + ver=(unit vere) + fat=(unit (axal (cask))) + bod=(unit (trap vase)) + van=(map term (trap vase)) + == +$ heir - $% [_arvo =debt =soul] + $% [%grub _arvo =grub] + [_arvo =debt =soul] == +$ plan (pair germ (list move)) +$ soul - $: our=ship :: identity - eny=@uvJ :: entropy - now=@da :: time - lac=? :: laconic bit - ver=vere :: runtime - lag=_| :: upgrade blocked - fat=(axal (cask)) :: filesystem - zus=vase :: %zuse - van=(map term vane) :: modules + $: :: identity, time, entropy + :: fad: configuration + :: zen: Outside knowledge + :: mod: internal modules + :: + mein + $= fad + $: :: lac: not verbose + :: + lac=? + == + $= zen + $: :: ver: runtime version + :: lag: upgrade blocked + :: + ver=vere + lag=_| + == + $= mod + $: :: fat: filesystem + :: zus: %zuse + :: van: vanes + :: + fat=(axal (cask)) + zus=vase + van=(map term vane) + == == +$ vane [=vase =worm] +$ vere @@ -231,9 +269,41 @@ wir=type :: -:!>(*wire) dud=type :: -:!>(*(unit goof)) == +:: ++$ waif + :: %lyra: upgrade kernel + :: %trim: trim state, spam to all + :: %vega: notify vanes post upgrade + :: %what: update from files + :: %whey: produce $mass :: XX remove, scry + :: %verb: toggle laconicity + :: %veer: upgrade module + :: + $% [%lyra hun=(unit @t) van=@t] + [%trim p=@ud] + [%vega ~] + [%what p=(list (pair path (cask)))] + [%whey ~] + [%verb p=(unit ?)] + [%veer lal=@tas pax=path txt=@t] + == ++$ wasp + :: %crud: reroute $ovum with $goof + :: %wack: iterate entropy + :: %wyrd: check/record runtime kelvin stack + :: + $% [%crud =goof =ovum] + [%wack p=@uvJ] + [%wyrd p=vere] + == ++$ wisp + $% $>(?(%verb %veer %what) waif) + $>(?(%wack %wyrd) wasp) + [%whom p=ship] + == +$ wynn (list (pair term @ud)) --- -=> +-- => +:: ~% %hex ..ut ~ |% :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @@ -423,6 +493,7 @@ :: $ovum: card with cause :: $hoof: hoon source :: $news: collated updates + :: $oped: module updates :: :: XX replace top-level structures :: @@ -436,11 +507,11 @@ sys=(map path (cask)) use=(map path (cask)) == - +$ seed [hun=(unit hoof) arv=hoof] - +$ sprig + +$ oped $: zus=(unit hoof) van=(list (cask hoof)) == + +$ seed [hun=(unit hoof) arv=hoof] -- :: ~% %part ..part ~ @@ -523,7 +594,7 @@ :: ++ adorn |= [del=news all=?] - ^- (pair sprig _fat) + ^- (pair oped _fat) :: zuse: shared library :: =^ zus fat @@ -875,7 +946,7 @@ |= =ovum ^+ this ~> %mean.'arvo: poke crashed' - ~? !lac ["" %unix p.card.ovum wire.ovum now] + ~? !lac.fad ["" %unix p.card.ovum wire.ovum now] (poke:pith ovum) :: ++ jump @@ -912,7 +983,7 @@ |= =move ^+ this :: - ~? &(!lac ?=(^ dud)) %goof + ~? &(!lac.fad ?=(^ dud)) %goof :: ?- -.ball.move :: @@ -924,7 +995,7 @@ =* vane vane.note.ball.move =* task task.note.ball.move :: - ~? &(!lac !=(%$ vane.gem)) + ~? &(!lac.fad !=(%$ vane.gem)) :- (runt [(lent bars.gem) '|'] "") :^ %pass [vane.gem vane] ?: ?=(?(%deal %deal-gall) +>-.task) @@ -945,7 +1016,7 @@ =* vane vane.note.ball.move =* task task.note.ball.move :: - ~? !lac + ~? !lac.fad :- (runt [(lent bars.gem) '|'] "") [%slip vane.gem (symp +>-.task) duct] :: @@ -965,7 +1036,7 @@ ~| [%give duct.move (symp -.q.p.gift)] ?>(?=(^ wire) wire) :: - ~? &(!lac !=(%$ way) |(!=(%blit +>-.gift) !=(%d vane.gem))) + ~? &(!lac.fad !=(%$ way) |(!=(%blit +>-.gift) !=(%d vane.gem))) :- (runt [(lent bars.gem) '|'] "") :^ %give vane.gem ?: ?=(%unto +>-.gift) @@ -987,16 +1058,16 @@ :: ++ whey ^- mass - =; mod=(list mass) + =; sam=(list mass) :+ %arvo %| :~ hoon+&+pit - zuse+&+zus - vane+|+mod + zuse+&+zus.mod + vane+|+sam == :: =/ von %+ turn - (sort ~(tap by van) |=([[a=@tas *] [b=@tas *]] (aor a b))) + (sort ~(tap by van.mod) |=([[a=@tas *] [b=@tas *]] (aor a b))) |=([lal=@tas =vane] (cat 3 %vane- lal)^vane) :: :~ :+ %reports %| @@ -1029,7 +1100,7 @@ :: =/ lal (end 3 1 cyr) =/ ren ;;(@t (rsh 3 1 cyr)) - ?. (~(has by van) lal) + ?. (~(has by van.mod) lal) ~ (peek:(plow lal) lyc ren bem) :: +call: advance to target @@ -1074,7 +1145,7 @@ ^+ this =^ moz sac (~(refine-moves me sac vil) zom) - =. van (~(put by van) vane.gum [vax sac]) + =. van.mod (~(put by van.mod) vane.gum [vax sac]) (emit `plan`[`germ`gum `(list move)`moz]) :: +plow: operate on a vane, in time and space :: @@ -1083,48 +1154,13 @@ ~| [%plow-failed way] =/ =vane ~| [%missing-vane way] - (~(got by van) way) + (~(got by van.mod) way) (~(plow va [our vil vane]) now peek) :: :: |pith: operate on arvo internals :: ++ pith - => |% - :: $waif: arvo effect, from anywhere - :: $wasp: arvo effect, from Outside - :: - +$ waif - :: %lyra: upgrade kernel - :: %trim: trim state, spam to all - :: %vega: notify vanes post upgrade - :: %what: update from files - :: %whey: produce $mass :: XX remove, scry - :: %verb: toggle laconicity - :: %veer: upgrade module - :: NB: %warn removed - :: - $% [%lyra hun=(unit @t) van=@t] - [%trim p=@ud] - [%vega ~] - [%what p=(list (pair path (cask)))] - [%whey ~] - [%verb p=(unit ?)] - [%veer lal=@tas pax=path txt=@t] - == - :: - +$ wasp - :: %crud: reroute $ovum with $goof :: NB: different - :: %wack: iterate entropy - :: %wyrd: check/record runtime kelvin stack - :: - $% [%crud =goof =ovum] - [%wack p=@uvJ] - [%wyrd p=vere] - == - -- - :: |% - :: ++ gest |= =ovum ^- $>(%pass ball) @@ -1154,13 +1190,13 @@ :: ++ kel ^+ ..pith - =/ del (~(group adapt fat) fil) - =/ tub (~(usurp adapt fat) del) + =/ del (~(group adapt fat.mod.sol) fil) + =/ tub (~(usurp adapt fat.mod.sol) del) ?~ tub (mod del |) =/ pos=plan [$/~ [*duct (gest [//arvo vega/~])] ~] - =/ gat (boot kel.ver [hun arv]:p.u.tub) + =/ gat (boot kel.ver.zen [hun arv]:p.u.tub) %_ ..pith but `[gat q.u.tub fil] run (weld run [pos ~]) @@ -1169,9 +1205,9 @@ ++ lod |= kel=(list (pair path (cask))) ^+ ..pith - =/ fat (~(gas de fat) kel) + =. fat.mod.sol (~(gas de fat.mod.sol) kel) %+ mod - (~(group adapt fat) fil) + (~(group adapt fat.mod.sol) fil) %+ lien kel |= [p=path *] ?=([%sys ?(%arvo %hoon) *] p) @@ -1179,17 +1215,17 @@ ++ mod |= [del=news all=?] ^+ ..pith - =^ job=sprig fat (~(adorn adapt fat) del all) - =? zus ?=(^ zus.job) + =^ job=oped fat.mod.sol (~(adorn adapt fat.mod.sol) del all) + =? zus.mod.sol ?=(^ zus.job) $:(smit:va "zuse" pit /sys/zuse/hoon u.zus.job) - %- (wyrd kel.ver [zuse/;;(@ud q:(slap zus limb/%zuse)) ~]) + %- (wyrd kel.ver.zen [zuse/;;(@ud q:(slap zus.mod.sol limb/%zuse)) ~]) %= ..pith - van + van.mod %+ roll van.job - |= [[nam=term txt=hoof] =_van] + |= [[nam=term txt=hoof] van=_van.mod.sol] ^+ van =/ way (wilt nam) - =/ nex (create:va zus way /sys/vane/[nam]/hoon txt) + =/ nex (create:va zus.mod.sol way /sys/vane/[nam]/hoon txt) =/ nav (~(get by van) way) =? nex ?=(^ nav) (update:va vase.u.nav nex) (~(put by van) way (settle:va nex)) @@ -1211,12 +1247,12 @@ :: clears compiler caches if high-priority :: XX add separate $wasp if this should happen last :: - %trim =? van =(0 p.waif) - (~(run by van) |=(=vane vane(worm *worm))) + %trim =? van.mod =(0 p.waif) + (~(run by van.mod) |=(=vane vane(worm *worm))) (emit $/~ (spam /arvo !>(waif))) :: %vega (emit $/~ (spam /arvo !>(waif))) :: XX also out - %verb ..pith(lac ?~(p.waif !lac u.p.waif)) + %verb ..pith(lac.fad ?~(p.waif !lac.fad u.p.waif)) :: %veer =/ pax sys/?:(?=(%$ lal.waif) /zuse /vane/[(grow lal.waif)]) @@ -1236,8 +1272,9 @@ == ~ ?+ s.bem ~ - [%whey ~] ``mass/!>(whey) - [%lag ~] ``noun/!>(lag) + [%whey ~] ``mass/!>(whey) + [%zen %lag ~] ``noun/!>(lag.zen) + [%zen %vere ~] ``noun/!>(ver.zen) == :: ++ poke @@ -1254,11 +1291,11 @@ :: :: %crud: forward error notification :: - %crud =? lag ?& ?=(%exit mote.goof.buz) - ?=(^ tang.goof.buz) - ?=(%leaf -.i.tang.goof.buz) :: XX ?@ - ?=(%wyrd (crip p.i.tang.goof.buz)) - == + %crud =? lag.zen ?& ?=(%exit mote.goof.buz) + ?=(^ tang.goof.buz) + ?=(%leaf -.i.tang.goof.buz) :: XX ?@ + ?=(%wyrd (crip p.i.tang.goof.buz)) + == ~&(%lagging &) (emit $/~ [*duct hurl/[goof.buz (gest ovum.buz)]] ~) :: @@ -1272,17 +1309,17 @@ ^- (list (pair term @)) :~ hoon/hoon-version arvo/arvo - zuse/;;(@ q:(slap zus limb/%zuse)) + zuse/;;(@ q:(slap zus.mod limb/%zuse)) == - =? lag !=(rev.ver rev.p.buz) ~&(%unlagging |) - ..pith(ver p.buz) + =? lag.zen !=(rev.ver.zen rev.p.buz) ~&(%unlagging |) + ..pith(ver.zen p.buz) == :: ++ spam |= [=wire =vase] ^- (list move) %+ turn - %+ sort ~(tap by van) + %+ sort ~(tap by van.mod) |=([[a=@tas *] [b=@tas *]] (aor a b)) |=([way=term *] `move`[*duct %pass wire way `maze`&/vase]) :: @@ -1432,17 +1469,17 @@ == :: ++ is & --- -=> +-- => :: -:: persistent arvo state +:: cached reflexives :: -=/ pit=vase !>(..is) :: -=/ vil=vile (viol p.pit) :: cached reflexives -=| soul :: -=* sol - -:: arvo: structural interface core +=/ pit=vase !>(..is) +=/ vil=vile (viol p.pit) :: +:: arvo state, as a discriminable sample +:: +=| [_arvo soul] +=* sol -> |% :: :: +come: load incompatible @@ -1452,7 +1489,7 @@ :: +load: load compatible, notifying vanes :: ++ load :: +10 - |= hir=heir + |= hir=$<(%grub heir) ^- ^ ~| %load :: store persistent state @@ -1463,13 +1500,13 @@ == :: clear compiler caches :: - =. van (~(run by van) |=(=vane vane(worm *worm))) + =. van.mod (~(run by van.mod) |=(=vane vane(worm *worm))) :: - %- %+ wyrd kel.ver + %- %+ wyrd kel.ver.zen ^- (list (pair term @)) :~ hoon/hoon-version arvo/arvo - zuse/;;(@ q:(slap zus limb/%zuse)) + zuse/;;(@ q:(slap zus.mod limb/%zuse)) == :: restore working state and resume :: @@ -1529,8 +1566,8 @@ :: +wish: external compute :: ++ wish :: +22 - |= txt/@ - q:(slap zus (ream txt)) + |= txt=@ + q:(slap zus.mod (ream txt)) -- :: :: larval stage @@ -1546,32 +1583,6 @@ :: with +wish and vane installation with the %veer event. :: => |% - :: $foal: larval state - :: $grub: larval events - :: - +$ foal - $: :: who: identity once we know it - :: eny: entropy once we learn it - :: bod: %zuse once we receive it - :: - who=(unit ship) - eny=(unit @) - lac=? - ver=(unit vere) - fat=(unit (axal (cask))) - bod=(unit (trap vase)) - van=(map term (trap vase)) - == - +$ grub - $~ verb/~ - $% $>(%verb waif:pith:le:part) - $>(%veer waif:pith:le:part) - $>(%wack wasp:pith:le:part) - $>(%what waif:pith:le:part) - [%whom p=ship] - $>(%wyrd wasp:pith:le:part) - == - :: ++ mint |= [vax=vase lal=term pax=path txt=@t] ^- (trap vase) @@ -1579,7 +1590,7 @@ (smit:va:part cap vax pax txt) :: ++ molt - |= [now=@da foal] + |= [now=@da grub] ^- (unit heir) ?. &(?=(^ who) ?=(^ eny) ?=(^ ver) ?=(^ fat) ?=(^ bod)) ~ @@ -1593,73 +1604,84 @@ =/ nav %- ~(run by van) |=(a=(trap vase) (settle:va:part (slym $:a zus))) :^ ~ arvo *debt - [u.who u.eny now lac u.ver | u.fat zus nav] + [[u.who now u.eny] [lac] [u.ver |] u.fat zus nav] -- :: -=| foal -=* fol - +:: larval state, as a discriminable sample +:: +=| [%grub _arvo grub] +=* gub ->+ +:: |% ++ come ^come :: +4 -++ load ^load :: +10 +:: +++ load :: +10 + |= hir=heir + ?: ?=(%grub -.hir) + ~|(%larval-reboot !!) :: XX support + (^load hir) +:: ++ peek _~ :: +46 +:: ++ poke :: +47 |= [now=@da ovo=ovum] ^- ^ - =/ gub + =/ wip ~| [p.ovo p.q.ovo] - ~> %mean.'arvo: bad grub' - ;;(grub q.ovo) + ~> %mean.'arvo: bad wisp' + ;;(wisp q.ovo) :: =. ..poke |- ^+ ..poke - ?- -.gub - %verb ..poke(lac ?~(p.gub !lac u.p.gub)) + ?- -.wip + %verb ..poke(lac ?~(p.wip !lac u.p.wip)) :: - %veer =/ pax - sys/?:(?=(%$ lal.gub) /zuse /vane/[(grow lal.gub)]) - $(q.ovo what/[[pax hoon/txt.gub] ~]) + %veer =/ pax + sys/?:(?=(%$ lal.wip) /zuse /vane/[(grow lal.wip)]) + $(q.ovo what/[[pax hoon/txt.wip] ~]) :: - %wack ..poke(eny `p.gub) + %wack ..poke(eny `p.wip) :: - %what =/ taf (fall fat *(axal (cask))) - =/ del (~(group adapt:part taf) p.gub) - =/ tub (~(usurp adapt:part taf) del) - ?: &(?=(^ dir.taf) ?=(^ tub)) - ~|(%larval-reboot !!) :: XX support - :: - :: require, and unconditionally adopt, initial kernel source - :: - =? taf =(~ dir.taf) :: XX TMI - ~| %larval-need-kernel - ?> &(?=(^ tub) ?=(^ hun.p.u.tub)) - (~(gas de taf) q.u.tub) - :: - =^ job taf [p q]:(~(adorn adapt:part taf) del |) - =? bod ?=(^ zus.job) - `(mint pit %$ /sys/zuse/hoon u.zus.job) - %= ..poke - fat `taf - van - %+ roll van.job - |= [[(cask hoof:part)] =_van] - ^+ van - ?> ?=(^ bod) - =/ way (wilt p) - (~(put by van) way (mint $:u.bod way /sys/vane/[p]/hoon q)) - == + %what =/ taf (fall fat *(axal (cask))) + =/ del (~(group adapt:part taf) p.wip) + =/ tub (~(usurp adapt:part taf) del) + ?: &(?=(^ dir.taf) ?=(^ tub)) + ~|(%larval-reboot !!) :: XX support + :: + :: require, and unconditionally adopt, initial kernel source + :: + =? taf =(~ dir.taf) :: XX TMI + ~| %larval-need-kernel + ?> &(?=(^ tub) ?=(^ hun.p.u.tub)) + (~(gas de taf) q.u.tub) + :: + =^ job taf [p q]:(~(adorn adapt:part taf) del |) + =? bod ?=(^ zus.job) + `(mint pit %$ /sys/zuse/hoon u.zus.job) + %= ..poke + fat `taf + van + %+ roll van.job + |= [[(cask hoof:part)] =_van] + ^+ van + ?> ?=(^ bod) + =/ way (wilt p) + (~(put by van) way (mint $:u.bod way /sys/vane/[p]/hoon q)) + == :: - %whom ..poke(who ~|(%whom-once ?>(?=(~ who) `p.gub))) - %wyrd %- %+ wyrd kel.p.gub - ^- (list (pair term @)) - :* hoon/hoon-version - arvo/arvo - ?~ bod ~ - [zuse/;;(@ud q:(slap $:u.bod limb/%zuse)) ~] - == - ..poke(ver `p.gub) + %whom ..poke(who ~|(%whom-once ?>(?=(~ who) `p.wip))) + :: + %wyrd %- %+ wyrd kel.p.wip + ^- (list (pair term @)) + :* hoon/hoon-version + arvo/arvo + ?~ bod ~ + [zuse/;;(@ud q:(slap $:u.bod limb/%zuse)) ~] + == + ..poke(ver `p.wip) == :: - ?~ hir=(molt now fol) + ?~ hir=(molt now gub) [~ ..poke] :: :: upgrade once we've accumulated necessary state From f8b2beae3241f48869a09779eeb8e9e5b598f6b7 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 23 Nov 2020 22:58:15 -0800 Subject: [PATCH 755/933] arvo: adds some more explicit stack frames --- pkg/arvo/sys/arvo.hoon | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index 30e96e19a1..93d7570b74 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -826,12 +826,14 @@ ~> %mean.'peek: activation failed' (~(slym wa sac) vax sam) =^ gat sac - ~> %mean.'peek: call failed' + ~> %mean.'peek: pull failed' (~(slap wa sac) rig [%limb %scry]) :: =/ mas=[gang term beam] [lyc cyr bem] :: - =^ pro sac (~(slym wa sac) gat mas) + =^ pro sac + ~> %mean.'peek: call failed' + (~(slym wa sac) gat mas) ?~ q.pro ~ ?~ +.q.pro [~ ~] =^ dat sac (~(slot wa sac) 7 pro) @@ -1286,7 +1288,8 @@ ?. ?=(?(%crud %wack %wyrd) -.card.ovum) (emit $/~ [*duct (gest ovum)] ~) :: - =/ buz ;;(wasp card.ovum) + =/ buz ~> %mean.'pith: bad wasp' + ;;(wasp card.ovum) ?- -.buz :: :: %crud: forward error notification @@ -1329,8 +1332,9 @@ :: XX update clients to %pass to arvo, remove :: ?: ?=(?(%lyra %veer %verb %whey) -.card.ovum) + %- call ~> %mean.'xeno: bad waif' - (call ;;(waif:pith card.ovum)) + ;;(waif:pith card.ovum) :: :: XX uncomment to restore previous routing :: @@ -1618,7 +1622,7 @@ ++ load :: +10 |= hir=heir ?: ?=(%grub -.hir) - ~|(%larval-reboot !!) :: XX support + ~>(%mean.'arvo: larval reboot' !!) :: XX support (^load hir) :: ++ peek _~ :: +46 @@ -1646,7 +1650,7 @@ =/ del (~(group adapt:part taf) p.wip) =/ tub (~(usurp adapt:part taf) del) ?: &(?=(^ dir.taf) ?=(^ tub)) - ~|(%larval-reboot !!) :: XX support + ~>(%mean.'arvo: larval reboot' !!) :: XX support :: :: require, and unconditionally adopt, initial kernel source :: From b2eaa5e5b8b276400b05cd81a6f6372a05b46c92 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 23 Nov 2020 18:12:52 -0800 Subject: [PATCH 756/933] arvo: removes neo-arvo and obsolete pill generators --- pkg/arvo/gen/deep.hoon | 255 --------- pkg/arvo/gen/glass.hoon | 132 ----- pkg/arvo/gen/metal.hoon | 319 ------------ pkg/arvo/neo/arvo.hoon | 1090 --------------------------------------- 4 files changed, 1796 deletions(-) delete mode 100644 pkg/arvo/gen/deep.hoon delete mode 100644 pkg/arvo/gen/glass.hoon delete mode 100644 pkg/arvo/gen/metal.hoon delete mode 100644 pkg/arvo/neo/arvo.hoon diff --git a/pkg/arvo/gen/deep.hoon b/pkg/arvo/gen/deep.hoon deleted file mode 100644 index fcb1565a2e..0000000000 --- a/pkg/arvo/gen/deep.hoon +++ /dev/null @@ -1,255 +0,0 @@ -:- %say -|= $: {now/@da eny/@uvJ bec/beak} - * - == -:- %noun -=> -|% -:: fundamental hierarchical node XX s/b +arch -:: -++ node - =< |$ [item] - [fil=(unit item) dir=(map @ta $)] - :: - |% - ++ de - =| fat=(node) - |@ - :: - ++ get-node - |= pax=path - ^+ fat - ?~ pax fat - =/ kid (~(get by dir.fat) i.pax) - ?~ kid [~ ~] - $(fat u.kid, pax t.pax) - :: - ++ get - |= pax=path - ^+ fil.fat - fil:(get-node pax) - :: - ++ got - |= pax=path - (need (get pax)) - :: - ++ has - |= pax=path - ^- ? - !=(~ (get pax)) - :: - ++ put - |* [pax=path dat=*] - => .(dat `_?>(?=(^ fil.fat) u.fil.fat)`dat) - ^+ fat - ?~ pax fat(fil `dat) - =/ kid (~(get by dir.fat) i.pax) - =/ new (fall kid fat(fil ~, dir ~)) - fat(dir (~(put by dir.fat) i.pax $(fat new, pax t.pax))) - :: - ++ gas - |= lit=(list (pair path _?>(?=(^ fil.fat) u.fil.fat))) - ^+ fat - ?~ lit fat - $(fat (put p.i.lit q.i.lit), lit t.lit) - :: - ++ tap - =| pax=path - =| out=(list (pair path _?>(?=(^ fil.fat) u.fil.fat))) - |- ^+ out - =? out ?=(^ fil.fat) :_(out [pax u.fil.fat]) - =/ dir ~(tap by dir.fat) - |- ^+ out - ?~ dir out - %= $ - dir t.dir - out ^$(pax (weld pax /[p.i.dir]), fat q.i.dir) - == - -- :: de - -- :: node --- -=> -|% -+$ hoof @t :: hoon source file -+$ news - $: :: use: non-system files - :: new: new set - :: sys: installs + replacements - :: - use=(map path plum) - new=(set path) - sys=(map path plum) - == -+$ plum (cask) -+$ seed [hoon=(unit hoof) arvo=hoof] -+$ sprig - $: lull=(unit hoof) - zuse=(unit hoof) - vane=(list (pair term hoof)) - == -:: -++ wilt :: deep file as source - |= =plum - ^- hoof - ?>(?=([%hoon @t] plum) q.plum) -:: -++ adapt - =* de de:node - |_ fat=(node plum) - :: - :: +group: collate changes - :: - ++ group - |= fal=(list (pair path plum)) - =| del=news - |- ^+ del - ?~ fal - ~? !=(~ use.del) - [%what-use ~(tap in ~(key by use.del))] - ~? !=(~ new.del) - [%what-new ~(tap in new.del)] - ~? !=(~ sys.del) - [%what-sys ~(tap in ~(key by sys.del))] - del - :: - =* pax p.i.fal - =* dat q.i.fal - =/ old (~(get de fat) pax) - :: - :: ignore unchanged data - :: - ?: =(old `dat) - $(fal t.fal) - :: - :: classify as user, system install or replacement - :: - ?. ?=([%sys *] pax) - =. use.del (~(put by use.del) pax dat) - $(fal t.fal) - =? new.del ?=(~ old) - (~(put in new.del) pax) - =. sys.del (~(put by sys.del) pax dat) - $(fal t.fal) - :: +usurp: consider self-replacement - :: - ++ usurp - |= del=news - ^- (unit seed) - :: - :: when we get new hoon and arvo system files, - :: we assume they match what's running now - :: - =* adopt-new - |=(=path ?:((~(has in new.del) path) ~ (~(get by sys.del) path))) - :: - =/ hun (adopt-new /sys/hoon) - =/ arv (adopt-new /sys/arvo) - ?~ hun - ?~ arv ~ - :: - :: light reboot, arvo only - :: - ~& %light-reboot - ``(wilt u.arv) - :: - :: heavy reboot, hoon and arvo - :: - ~& %heavy-reboot - :+ ~ - `(wilt u.hun) - (wilt ?^(arv u.arv (~(got de fat) /sys/arvo))) - :: +adorn: augment capabilities - :: - ++ adorn - |= [del=news force=?] - ^- sprig - :: lull: shared structures - :: - =/ lull - ?^ lul=(~(get by sys.del) /sys/lull) - `(wilt u.lul) - ?.(force ~ `(wilt (~(got de fat) /sys/lull))) - :: - :: zuse: shared library - :: - :: %lull is the subject of %zuse; force %zuse if we have a new %lull - :: - =/ zuse - =. force ?=(^ lull) - ?^ zus=(~(get by sys.del) /sys/zuse) - `(wilt u.zus) - ?.(force ~ `(wilt (~(got de fat) /sys/zuse))) - :: - :+ lull - zuse - :: - :: kernel modules - :: - :: %zuse is the subject of the vanes; force all if we have a new %zuse - :: - =/ current=(list (pair term hoof)) - =. force ?=(^ zuse) - ?. force ~ - %+ turn - ~(tap by dir:(~(get-node de fat) /sys/vane)) - |=([name=@ta (node plum)] [`@tas`name (wilt (need fil))]) - :: - =/ updates=(list (pair term hoof)) - %+ turn - %+ skim - ~(tap by sys.del) - |=([=path *] ?=([%sys %vane @tas ~] path)) - |= [=path =plum] - ?> ?=([%sys %vane @tas ~] path) - =* name i.t.t.path - ?> ((sane %tas) name) - [`@tas`name (wilt plum)] - :: - %+ sort - %~ tap by - %- ~(gas by *(map term hoof)) - (weld current updates) - |=([[a=@tas *] [b=@tas *]] (aor a b)) - -- :: adapt -:: -++ what - |= fat=(node plum) - :: - |= fal=(list (pair path plum)) - =/ del (~(group adapt fat) fal) - =/ but (~(usurp adapt fat) del) - =/ job (~(adorn adapt fat) del force=?=(^ but)) - :: - :: adopt system changes - :: - =. fat (~(gas de:node fat) ~(tap by sys.del)) - :: - :: just adopt user changes, which have no systems impact - :: - :: XX or ignore? useful for bootstrap? - :: - =. fat (~(gas de:node fat) ~(tap by use.del)) - :: - [[but job] fat] --- -:: -=| fat=(node plum) -=^ one fat - %- (what fat) - :~ /sys/hoon^hoon+%a - /sys/arvo^hoon+%a - /sys/lull^hoon+%a - /sys/zuse^hoon+%a - /sys/vane/foo^hoon+%a - /sys/vane/bar^hoon+%a - /sys/vane/baz^hoon+%a - /app/dojo^hoon+%a - /lib/drum^hoon+%a - == -=^ two fat - %- (what fat) - :~ /sys/arvo^hoon+%b - /sys/lull^hoon+%b - /sys/vane/foo^hoon+%b - == -[one two fat] diff --git a/pkg/arvo/gen/glass.hoon b/pkg/arvo/gen/glass.hoon deleted file mode 100644 index bdfc9fc628..0000000000 --- a/pkg/arvo/gen/glass.hoon +++ /dev/null @@ -1,132 +0,0 @@ -:: Produce a glass pill -:: -:::: /hoon/glass/gen - :: -/? 310 -:: -:::: - :: -:- %say -|= $: {now/@da eny/@uvJ bec/beak} - * - == -=< [%noun ~] -=> |% - ++ wasp :: arvo effect - $% {$wack p/@uvJ} :: add entropy - {$what p/(list (pair path (pair term noun)))} :: reset reptile - {$whom p/@p} :: id and boot - == - -- -:: -:: deterministic test -:: -=. eny 0v0 -:: -:: build arvo with existing compiler -:: -|^ ^- * - :: - :: neo: root path to boot system, `/~me/[desk]/now/neo` - :: - =+ neo=`path`/(scot %p p.bec)/[q.bec]/(scot %da now)/neo - :: - :: arvo-source: hoon source file producing arvo kernel, `neo/arvo` - :: - =+ arvo-source=.^(@t %cx (welp neo /arvo/hoon)) - :: - :: arvo-twig: parsed arvo source - :: - ~& [%parsing `@p`(mug arvo-source)] - =+ arvo-twig=(ream arvo-source) - ~& %parsed - :: - :: arvo-kernel: a living urbit - :: - ~& [%compiling `@p`(mug arvo-twig)] - =+ arvo-kernel=+:(slap !>(..ream) arvo-twig) - ~& %compiled - :: - :: events: list of events to feed our urbit - :: - ~& %loading - =+ events=main-events - ~& [%loaded `@p`(mug events)] - :: - :: execute events - :: - =+ number=0 - |- ^- * - ?~ events arvo-kernel - ~& number+number - %= $ - events t.events - number +(number) - arvo-kernel .*(arvo-kernel(+< i.events) -.arvo-kernel) - == -:: -++ main-events - =. now ~2017.3.1 - =+ mov=main-moves - |- ^- (list (pair @da ovum)) - ?~ mov ~ - :- [now i.mov] - $(mov t.mov, now (add now (bex 48))) -:: -++ main-moves - ^- (list ovum) - :~ [[%$ ~] [%what boot-files]] - :: [[%$ ~] [%whom ~zod]] - == -++ boot-files - ^- (list (pair path (pair term noun))) - :: - :: userspace: - :: - :: /app %gall applications - :: /gen :dojo generators - :: /lib %ford libraries - :: /mar %ford marks - :: /sur %ford structures - :: /ren %ford renderers - :: /web %eyre web content - :: /sys system files - :: /neo new system files - :: - (user-files /neo ~) -:: -++ user-files :: userspace loading - |= :: sal: all spurs to load from - :: - sal/(list spur) - ^- (list (pair path (pair term noun))) - :: - :: hav: all user files - :: - =| hav/(list (pair path (pair term noun))) - |- ^+ hav - ?~ sal ~ - =. hav $(sal t.sal) - :: - :: tyl: spur - :: - =/ tyl i.sal - |- ^+ hav - :: - :: pax: full path at `tyl` - :: lon: directory at `tyl` - :: - =/ pax (en-beam:format bec (flop tyl)) - =/ lon .^(arch %cy pax) - =? hav ?=(^ fil.lon) - :: - :: install only hoon files for now - :: - ?. ?=({$hoon *} tyl) hav - :_(hav [(flop `path`t.tyl) [%hoon .^(@t %cx pax)]]) - :: - =/ all ~(tap by dir.lon) - |- ^+ hav - ?~ all hav - $(all t.all, hav ^$(tyl [p.i.all tyl])) --- diff --git a/pkg/arvo/gen/metal.hoon b/pkg/arvo/gen/metal.hoon deleted file mode 100644 index 80f21f0aa3..0000000000 --- a/pkg/arvo/gen/metal.hoon +++ /dev/null @@ -1,319 +0,0 @@ -:: Produce a metal pill -:: -:::: /hoon/metal/gen - :: -/? 310 -:: -:::: - !: -:- %say -|= $: {now/@da * bec/beak} - {{who/@p ~} try/_| ~} - == -:: -:: we're creating an event series E whose lifecycle can be computed -:: with the urbit lifecycle formula L, `[2 [0 3] [0 2]]`. that is: -:: if E is the list of events processed by a computer in its life, -:: its final state is S, where S is nock(E L). -:: -:: in practice, the first five nouns in E are: two boot formulas, -:: a hoon compiler as a nock formula, the same compiler as source, -:: and the arvo kernel as source. -:: -:: after the first five special events, we enter an iterative -:: sequence of regular events which continues for the rest of the -:: computer's life. during this sequence, each state is a function -:: that, passed the next event, produces the next state. -:: -:: each event is a `[date wire type data]` tuple, where `date` is a -:: 128-bit Urbit date; `wire` is an opaque path which output can -:: match to track causality; `type` is a symbol describing the type -:: of input; and `data` is input data specific to `type`. -:: -:: in real life we don't actually run the lifecycle loop, -:: since real life is updated incrementally and also cares -:: about things like output. we couple to the internal -:: structure of the state machine and work directly with -:: the underlying arvo engine. -:: -:: this arvo core, which is at `+7` (Lisp `cddr`) of the state -:: function (see its public interface in `sys/arvo`), gives us -:: extra features, like output, which are relevant to running -:: a real-life urbit vm, but don't affect the formal definition. -:: -:: so a real-life urbit interpreter is coupled to the shape of -:: the arvo core. it becomes very hard to change this shape. -:: fortunately, it is not a very complex interface. -:: -:- %noun -:: -:: boot-one: lifecycle formula -:: -=+ ^= boot-one - :: - :: event 1 is the lifecycle formula which computes the final - :: state from the full event sequence. - :: - :: the formal urbit state is always just a gate (function) - :: which, passed the next event, produces the next state. - :: - => [boot-formula=* full-sequence=*] - != :: - :: first we use the boot formula (event 1) to set up - :: the pair of state function and main sequence. the boot - :: formula peels off the first n (currently 3) events - :: to set up the lifecycle loop. - :: - =+ [state-gate main-sequence]=.*(full-sequence boot-formula) - :: - :: in this lifecycle loop, we replace the state function - :: with its product, called on the next event, until - :: we run out of events. - :: - |- ?@ main-sequence - state-gate - %= $ - main-sequence +.main-sequence - state-gate .*(state-gate [%9 2 %10 [6 %1 -.main-sequence] %0 1]) - == -:: -:: boot-two: startup formula -:: -=+ ^= boot-two - :: - :: event 2 is the startup formula, which verifies the compiler - :: and starts the main lifecycle. - :: - => :* :: event 3: a formula producing the hoon compiler - :: - compiler-formula=** - :: - :: event 4: hoon compiler source, compiling to event 2 - :: - compiler-source=*@t - :: - :: event 5: arvo kernel source - :: - arvo-source=*@t - :: - :: events 6..n: main sequence with normal semantics - :: - main-sequence=** - == - != :_ main-sequence - :: - :: activate the compiler gate. the product of this formula - :: is smaller than the formula. so you might think we should - :: save the gate itself rather than the formula producing it. - :: but we have to run the formula at runtime, to register jets. - :: - :: as always, we have to use raw nock as we have no type. - :: the gate is in fact ++ride. - :: - ~> %slog.[0 leaf+"1-b"] - =+ ^= compiler-gate - .*(0 compiler-formula) - :: - :: compile the compiler source, producing (pair span nock). - :: the compiler ignores its input so we use a trivial span. - :: - ~> %slog.[0 leaf+"1-c"] - =+ ^= compiler-tool - .*(compiler-gate [%9 2 %10 [6 %1 [%noun compiler-source]] %0 1]) - :: - :: switch to the second-generation compiler. we want to be - :: able to generate matching reflection nouns even if the - :: language changes -- the first-generation formula will - :: generate last-generation spans for `!>`, etc. - :: - ~> %slog.[0 leaf+"1-d"] - =. compiler-gate .*(0 +:compiler-tool) - :: - :: get the span (type) of the kernel core, which is the context - :: of the compiler gate. we just compiled the compiler, - :: so we know the span (type) of the compiler gate. its - :: context is at tree address `+>` (ie, `+7` or Lisp `cddr`). - :: we use the compiler again to infer this trivial program. - :: - ~> %slog.[0 leaf+"1-e"] - =+ ^= kernel-span - -:.*(compiler-gate [%9 2 %10 [6 %1 [-.compiler-tool '+>']] %0 1]) - :: - :: compile the arvo source against the kernel core. - :: - ~> %slog.[0 leaf+"1-f"] - =+ ^= kernel-tool - .*(compiler-gate [%9 2 %10 [6 %1 [kernel-span arvo-source]] %0 1]) - :: - :: create the arvo kernel, whose subject is the kernel core. - :: - ~> %slog.[0 leaf+"1-g"] - .*(+>:compiler-gate +:kernel-tool) -:: -:: sys: root path to boot system, `/~me/[desk]/now/sys` -:: -=+ sys=`path`/(scot %p p.bec)/[q.bec]/(scot %da now)/sys -:: -:: compiler-source: hoon source file producing compiler, `sys/hoon` -:: -=+ compiler-source=.^(@t %cx (welp sys /hoon/hoon)) -:: -:: compiler-twig: compiler as hoon expression -:: -~& %metal-parsing -=+ compiler-twig=(ream compiler-source) -~& %metal-parsed -:: -:: compiler-formula: compiler as nock formula -:: -~& %metal-compiling -=+ compiler-formula=q:(~(mint ut %noun) %noun compiler-twig) -~& %metal-compiled -:: -:: arvo-source: hoon source file producing arvo kernel, `sys/arvo` -:: -=+ arvo-source=.^(@t %cx (welp sys /arvo/hoon)) -:: -:: main-moves: installation actions -:: -=+ ^= main-moves - |^ ^- (list ovum) - :~ :: - :: configure identity - :: - [[%name (scot %p who) ~] [%veal who]] - :: - :: sys/zuse: standard library - :: - (vent %$ /zuse) - :: - :: sys/vane/ames: network - :: - (vent %a /vane/ames) - :: - :: sys/vane/behn: timer - :: - (vent %b /vane/behn) - :: - :: sys/vane/clay: revision control - :: - (vent %c /vane/clay) - :: - :: sys/vane/dill: console - :: - (vent %d /vane/dill) - :: - :: sys/vane/eyre: web - :: - (vent %e /vane/eyre) - :: - :: sys/vane/gall: applications - :: - (vent %g /vane/gall) - :: - :: sys/vane/jael: security - :: - (vent %j /vane/jael) - :: - :: legacy boot event - :: - [[%$ %term '1' ~] [%boot %sith who `@uw`who &]] - :: - :: userspace: - :: - :: /app %gall applications - :: /gen :dojo generators - :: /lib %ford libraries - :: /mar %ford marks - :: /sur %ford structures - :: /ren %ford renderers - :: /web %eyre web content - :: /sys system files - :: - (user /app /gen /lib /mar /ren /sec /sur /sys /web ~) - == - :: :: - ++ user :: userspace loading - |= :: sal: all spurs to load from - :: - sal/(list spur) - ^- ovum - :: - :: hav: all user files - :: - =; hav ~& user-files+(lent hav) - [[%$ %sync ~] [%into %$ & hav]] - =| hav/mode:clay - |- ^+ hav - ?~ sal ~ - =. hav $(sal t.sal) - :: - :: tyl: spur - :: - =/ tyl i.sal - |- ^+ hav - :: - :: pax: full path at `tyl` - :: lon: directory at `tyl` - :: - =/ pax (en-beam:format bec (flop tyl)) - =/ lon .^(arch %cy pax) - =? hav ?=(^ fil.lon) - ?. ?=({$hoon *} tyl) - :: - :: install only hoon files for now - :: - hav - :: - :: cot: file as plain-text octet-stream - :: - =; cot [[(flop `path`tyl) `[/text/plain cot]] hav] - ^- octs - ?- tyl - {$hoon *} - =/ dat .^(@t %cx pax) - [(met 3 dat) dat] - == - =/ all ~(tap by dir.lon) - |- ^- mode:clay - ?~ all hav - $(all t.all, hav ^$(tyl [p.i.all tyl])) - :: - ++ vent - |= {abr/term den/path} - =+ pax=(weld sys den) - =+ txt=.^(@ %cx (welp pax /hoon)) - `ovum`[[%vane den] [%veer abr pax txt]] - -- -:: -:: main-events: full events with advancing times -:: -=. now ~2017.3.1 -=+ ^= main-events - |- ^- (list (pair @da ovum)) - ?~ main-moves ~ - :- [now i.main-moves] - $(main-moves t.main-moves, now (add now (bex 48))) -:: -~? try - ~& %metal-testing - =+ ^= yop - ^- @p - %- mug - .* :* boot-one - boot-two - compiler-formula - compiler-source - arvo-source - main-events - == - [2 [0 3] [0 2]] - [%metal-tested yop] -:: -:* boot-one - boot-two - compiler-formula - compiler-source - arvo-source - main-events -== diff --git a/pkg/arvo/neo/arvo.hoon b/pkg/arvo/neo/arvo.hoon deleted file mode 100644 index 78fb6bc72b..0000000000 --- a/pkg/arvo/neo/arvo.hoon +++ /dev/null @@ -1,1090 +0,0 @@ -!: :: /sys/arvo -:: :: %reference/2 -:: %arvo: arvo microkernel. -:: -=< :: this lifecycle wrapper makes the arvo door - :: (multi-armed core) look like a gate (function - :: or single-armed core), to fit urbit's formal - :: lifecycle function. a practical interpreter - :: can ignore it. - :: - |= {now/@da ovo/ovum} - ~> %slog.[0 leaf+"arvo-event"] - .(+> +:(poke now ovo)) -=> -:: :: :: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: (1) public molds -:: :: :: -|% -++ arms (map chip dope) :: stated identity -++ bait :: analysis state - $: now/@da :: date - eny/@uvJ :: entropy - sky/roof :: namespace - == :: -++ beam {{p/ship q/desk r/case} s/path} :: global name -++ beak {p/ship q/desk r/case} :: garnish with beak -++ card {p/@tas q/*} :: tagged event -++ case :: version - $% {$da p/@da} :: date - {$tas p/@tas} :: label - {$ud p/@ud} :: sequence - == :: -++ cask |*(a/mold (pair mark a)) :: global data -++ cave (cask maze) :: marked untyped vase -++ chip :: standard identity - $? $giv :: given name - $fam :: surname - $had :: fictitious name - $mid :: middle name - $gen :: generational suffix - == :: -++ desk @tas :: ship desk case spur -++ dope (pair @tas @t) :: term/unicode pair -++ duct (list wire) :: causal history -++ mark @tas :: content type -++ maze {p/* q/*} :: untyped vase -++ mill (each vase milt) :: vase+metavase -++ milt {p/* q/*} :: metavase -++ ovum (pair wire card) :: input or output -++ plum (pair term noun) :: deep file -++ ruby @pG :: 64-bit passcode -++ roof (room vase) :: namespace -++ rook (room maze) :: meta-namespace -++ room :: either namespace - |* vase/mold :: vase or maze - $- $: lyc/(unit (set ship)) :: leakset - car/term :: perspective - bem/beam :: path - == :: - %- unit :: ~: unknown - %- unit :: ~ ~: invalid - (cask vase) :: marked cargo -:: :: -++ ship @p :: network identity -++ vane :: kernel module - |* $: task/mold :: ->$ in request - gift/mold :: <-$ out result - sign/mold :: $<- in result - note/mold :: $-> out request - soul/mold :: current state - seed/mold :: prior state - == :: - =* move :: - $% {$give p/gift} :: return - {$pass p/path q/note} :: invoke - == :: - $_ =| soul :: active state - ^? |% :: - ++ load |~(seed +>) :: restore - ++ stay *soul :: preserve - ++ plow :: work in time - |_ $: now/@da :: date - eny/@e :: entropy - sky/roof :: namespace - == :: - ++ doze *(unit @da) :: awake when - ++ peek roof :: local namespace - ++ spin :: work on state - |_ $: hen/duct :: cause stack - moz/(list move) :: moves, inverted - == :: - ++ call |~(task +>) :: forward effect - ++ take |~({wire sign} +>) :: backward effect - -- :: - -- :: - -- :: -++ wire path :: cause --- => -:: :: :: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: (2) state molds -:: :: :: -|% -++ evil :: evolvable state - |* {type/_type hoon/_hoon vase/_vase} :: injected molds - |% :: - ++ ball :: arvo vane move - $% {$give p/mill} :: vane "return" - {$pass p/wire q/(pair term mill)} :: vane "call" - == :: - ++ mall :: any arvo version - $? {$293 mast} :: kelvin 293, current - == :: - ++ mast :: system state - $: $= gut :: abdomen - $: run/(list move) :: worklist - out/(list ovum) :: unix output - but/(unit seed) :: reboot - == :: - $= hax :: thorax - $: sac/worm :: compiler cache - == :: - $= bug :: insect brain - $: noc/@ta :: process nonce - ver/(qual @tas @ud @ud @ud) :: vendor/version - == :: - $= mal :: mammal brain - $: off/? :: not yet booted - lac/_| :: not verbose - eny/@uvJ :: 512-bit entropy - lul/vase :: %lull, vane models - zus/vase :: %zuse, user lib - van/(map term vase) :: vanes - == :: - $= rep :: reptile brain - $: orb/@p :: ship - nym/arms :: name information - roy/(map @ud ruby) :: start secrets - fat/(map path (pair term noun)) :: boot filesystem - == == :: - ++ mill (each vase maze) :: vase or metavase - ++ move (pair duct ball) :: vane move - ++ worm :: compiler cache - $: nes/(set ^) :: ++nest - pay/(map (pair type hoon) type) :: ++play - mit/(map (pair type hoon) (pair type nock)) :: ++mint - == :: - -- :: -++ hoof @t :: hoon source file -++ live (evil) :: modern molds -++ seed (pair (unit hoof) hoof) :: hoon/arvo boot src -++ vile (evil typo hoon vise) :: old molds -++ wasp :: arvo effect - $% {$wack p/@uvJ} :: add entropy - {$what p/(list (pair path (pair term noun)))} :: reset reptile files - {$whim p/arms} :: reset arms - {$wise p/(map @ud ruby)} :: reset secrets - {$whom p/@p} :: set identity; boot - == :: --- => -:: :: :: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: (3) engines -:: :: :: -|% -:: :: ++le -++ le :: deep engine - =+ [now=*@da *mall:live] - =* :: - :: sys: system state - :: - sys -> - |% - :: :: ++abet:le - ++ abet :: complete cycle - ^- {(each (list ovum) seed) _sys} - ?^ but.gut - [[%| u.but.gut] sys] - [[%& (flop out.gut)] sys(out.gut ~)] - :: :: ++boot:le - ++ boot :: reboot - |= $: :: hyn: optional hoon.hoon source - :: ars: arvo.hoon source - :: - hyn/(unit @t) - ars/@t - == - ^- {* *} - ?~ hyn - :: hon: hoon kernel as a vase - :: are: arvo kernel as a vase - :: arc: arvo core as a vase - :: lod: load gate on arvo core - :: - =/ hon !>(..ride) - ~& [%compile-arvo `@p`(mug p.hon) `@p`(mug ars)] - =* are (slap hon (ream ars)) - =* arc (slot 7 are) - =* lod (slap arc [%limb %load]) - (^ q:(slam lod !>([now sys]))) - :: - :: compile the hoon.hoon source with the current compiler - :: - ~& [%hoon-compile `@p`(mug u.hyn)] - =+ raw=(ride %noun u.hyn) - :: - :: activate the new compiler gate - :: - =+ cop=.*(0 +.raw) - :: - :: find the hoon version number of the new kernel - :: - =+ nex=(@ .*(cop q:(~(mint ut p.raw) %noun [%limb %hoon]))) - ?> |(=(nex hoon) =(+(nex) hoon)) - :: - :: if we're upgrading language versions, recompile the compiler - :: - => ?: =(nex hoon) - [hot=`*`raw .] - ~& [%hoon-compile-upgrade nex] - =+ hot=.*(cop(+< [%noun u.hyn]) -.cop) - .(cop .*(0 +.hot)) - :: - :: extract the hoon core from the outer gate - :: - =+ hoc=.*(cop [0 7]) - :: - :: compute the span of the hoon.hoon core - :: - =+ hyp=-:.*(cop(+< [-.hot '+>']) -.cop) - :: - :: compile arvo - :: - ~& [%compile-arvo `@p`(mug hyp) `@p`(mug ars)] - =+ rav=.*(cop(+< [hyp ars]) -.cop) - :: - :: create the arvo kernel - :: - =+ arv=.*(hoc +.rav) - :: - :: extract the arvo core from the outer gate - :: - =+ voc=.*(arv [0 7]) - :: - :: compute the span of the arvo.hoon core - :: - =+ vip=-:.*(cop(+< [-.rav '+>']) -.cop) - :: - :: entry gate: ++load for the normal case, ++come for upgrade - :: - =+ gat=.*(voc +:.*(cop(+< [vip ?:(=(nex hoon) 'load' 'come')]) -.cop)) - :: - :: sample: [date system-state] - :: - =+ sam=[now sys] - :: - :: call into the new kernel - :: - (^ .*(gat(+< sam) -.gat)) - :: :: ++call:le - ++ call :: forward to vane - |= {hen/duct way/term hil/mill} - ^+ +> - (call:(spin way hen) hil) - :: :: ++doze:le - ++ doze :: next wakeup by vane - |= way/term - ^- (unit @da) - doze:(plow way) - :: :: ++emit:le - ++ emit :: emit move - |= mov/move:live - +>(run.gut [mov run.gut]) - :: :: ++grow:le - ++ grow :: hardcoded prefixes - |= lay/term - ^- term - ?+ lay !! - $a %ames - $b %behn - $c %clay - $d %dill - $e %eyre - $f %ford - $g %gall - $j %jael - == - :: :: ++loop:le - ++ loop :: main loop - ^+ . - :: done if stack is empty - :: - ?~ run.gut . - :: - :: mov: top move on stack - :: - =/ mov `move:live`i.run.gut - :: - :: pop top move off stack - :: - => .(run.gut t.run.gut) - :: - :: interpret top move - :: - ~& [%brhp -.q.mov] - ?- -.q.mov - :: - :: %give: return move - :: - $give - :: - :: the duct can't be empty - :: - ?> ?=(^ p.mov) - :: - :: tea: top wire on duct - :: nex: rest of duct - :: - =/ tea i.p.mov - =* nex t.p.mov - :: - :: route gift by wire - :: - ?. ?=({$$ *} tea) - :: - :: the caller was another vane - :: - ?> ?=({@tas *} tea) - (take nex i.tea t.tea p.q.mov) - :: - :: the caller was arvo itself - :: - ?: ?=({$unix $~} t.tea) - :: - :: the caller was unix i/o - :: - (unix nex (wile p.q.mov)) - ?> ?=({$arvo $~} t.tea) - :: - :: the caller was boot logic - :: - (warp nex ;;(wasp (wile p.q.mov))) - :: - :: %pass: forward move - :: - $pass - :: tea: proximate cause of action - :: hen: ultimate cause of action - :: way: target - :: hil: event data - :: - =* tea p.q.mov - =* hen p.mov - =* way p.q.q.mov - =* hil q.q.q.mov - (call [tea hen] way hil) - == - :: :: ++pike:le - ++ pike :: event to %pass - |= $: :: way: event route - :: now: date - :: ovo: input ovum - :: - way/@tas - now/@da - ovo/ovum - == - ^+ +> - :: print event if in verbose mode - :: - ~? &(!lac.mal !=(%belt -.q.ovo)) [%unix -.q.ovo p.ovo] - :: - :: vax: card as vase - :: - =^ vax +> (open q.ovo) - :: - :: hen: fundamental cause (unix input channel) - :: tea: local cause (unix i/o) - :: mov: action (pass into event route) - :: - =* hen `duct`[p.ovo ~] - =* tea `wire`[%$ %unix ~] - =* mov `move:live`[hen %pass tea way %& vax] - :: - :: push move on stack, and work. - :: - loop:(emit mov) - :: :: ++open:le - ++ open :: input card to move - |= fav/card - ^- {vase _+>} - ?< off.mal - :: - :: gat: mold for correct unix task - :: vax: molded card - :: - =^ gat sac.hax (~(slap wa sac.hax) zus.mal [%limb %unix-task]) - =/ vax (slam gat [%noun fav]) - ~| [%le-open -.fav] - ?> =(fav q.vax) - [vax +>.$] - :: :: ++peek:le - ++ peek :: namespace - |= $: :: lyc: other ships result may leak to - :: cyr: general perspective, eg %cx - :: bem: name - :: - lyc/(unit (set ship)) - cyr/term - bem/beam - == - ^- (unit (unit cave)) - :: - :: way: vane to look in - :: car: perspective within vane - :: - =* way (grow (end 3 1 cyr)) - =* car (rsh 3 1 cyr) - (peek:(plow(eny.mal `@`0) way) lyc car bem) - :: :: ++plow:le - ++ plow :: plowing vane - |= way/term - (va-plow:(va-amid:va way) now eny.mal peek) - :: :: ++poke:le - ++ poke :: event from unix - |= $: :: ovo: event - :: - ovo/ovum - == - ^+ +> - ~& [%poke -.ovo] - ~| [%poke -.ovo] - ?+ -.q.ovo !! - :: - :: unix input, send to vane - :: - $belt (pike %dill now ovo) - $blew (pike %dill now ovo) - $born (pike %eyre now ovo) - $hail (pike %dill now ovo) - $hear (pike %ames now ovo) - $hook (pike %dill now ovo) - $into (pike %clay now ovo) - $they (pike %eyre now ovo) - $this (pike %eyre now ovo) - $thus (pike %eyre now ovo) - $wake (pike %behn now ovo) - :: - ?($wack $what $whom $whim $wise) - =/ wap ;;(wasp q.ovo) - =* tea `wire`[%$ %arvo ~] - =* hen `duct`[tea [p.ovo ~]] - =* mov `move:live`[hen %give %& !>(wap)] - loop:(emit mov) - == - :: :: ++spin:le - ++ spin :: spinning vane - |= {way/term hen/duct} - (spin:(plow way) hen) - :: - ++ take - |= {hen/duct way/term tea/wire hil/mill} - ^+ +> - =< loop - (take:(spin way hen) tea hil) - :: :: ++unix:le - ++ unix :: return to unix - |= {hen/duct fav/card} - ^+ +> - ?> ?=({* $~} hen) - loop(out.gut [[i.hen fav] out.gut]) - :: :: ++va:le - ++ va :: vane engine - |_ $: :: way: vane name, eg `%ames` - :: vax: vane, or vane builder if `off.mal` - :: - way/term - vax/vase - == - :: :: ++va-abet:va:le - ++ va-abet :: resolve - ^+ ..va - ..va(van.mal (~(put by van.mal) way vax)) - :: :: ++va-amid:va:le - ++ va-amid :: load existing - |= way/term - ^+ +> - ?< off.mal - +>(way way, vax (~(got by van.mal) way)) - :: :: ++va-abut:va:le - ++ va-apex :: boot / reboot - |= $: way/term - src/hoof - == - ^+ +> - =. ^way way - =/ bun (~(get by van.mal) way) - ?~ bun - (va-create src) - (va-update(vax u.bun) src) - :: :: ++va-plow:va:le - ++ va-plow :: context awareness - |= $: :: now: date - :: eny: 512-bit entropy - :: sky: meta-typed namespace - :: - now/@da - eny/@uvJ - sky/rook - == - :: kys: user-typed namespace vase - :: sam: core sample - :: wok: plowing vase - :: - =* kys `vase`[-:!>(*roof) sky] - =* sam (slop !>(now) (slop !>(eny) kys)) - =^ wok sac.hax (~(open wa sac.hax) vax %plow %& sam) - |% - :: :: ++doze:va-plow:va:le - ++ doze :: next wakeup - ^- (unit @da) - =^ pro sac.hax (~(slap wa sac.hax) wok [%limb %doze]) - =. sac.hax (~(neat wa sac.hax) -:!>(*(unit @da)) %& pro) - ((unit @da) q.pro) - :: :: ++peek:va-plow:va:le - ++ peek :: internal peek - |= $: :: lyc: set of output ships - :: car: local perspective - :: bem: true path - :: - lyc/(unit (set ship)) - car/term - bem/beam - == - ^- (unit (unit cave)) - :: - :: yeb: namespace input - :: pro: namespace output - :: - =/ yeb !>([lyc car bem]) - =^ pro sac.hax (~(call wa sac.hax) wok %peek %& yeb) - =. sac.hax (~(neat wa sac.hax) -:!>([*mark *vase]) %& pro) - :: - :: detect unit cases - :: - ?~ q.pro ~ - ?~ +.q.pro [~ ~] - :: - :: dat: vase of [mark vase] - :: - =^ dat sac.hax (~(slot wa sac.hax) 7 pro) - ``[(mark -.q.dat) (^ +.q.dat)] - :: :: ++spin:va-plow:va:le - ++ spin :: causal action - |= hen/duct - :: - :: fox: spinning vase - :: - =* sam !>([hen *(list move:live)]) - =^ fox sac.hax (~(open wa sac.hax) vax %spin %& sam) - |% - :: :: ++abet:spin:va-plow: - ++ abet :: integrate - ^+ ..va - :: - :: vom: vase of (list move) - :: moz: actual output list (inverted order) - :: zax: new vase core - :: - =^ vom sac.hax (~(slot wa sac.hax) 13 fox) - =^ moz sac.hax (~(refine-moves me sac.hax) vom) - =^ zax sac.hax (~(slot wa sac.hax) 31 fox) - %= va-abet - vax zax - run.gut - %+ weld - %+ turn (flop moz) - |= mov/move:live - ?. ?=($pass -.q.mov) mov - :: - :: append vane label to pass return address - :: - mov(p.q [way p.q.mov]) - run.gut - == - :: :: ++call:spin:va-plow: - ++ call :: pass forward - |= $: :: hil: logical argument - :: - hil/mill - == - ^+ ..va - =^ nex sac.hax (~(call wa sac.hax) fox %cnhp hil) - abet(fox nex) - :: :: ++take:spin:va-plow: - ++ take :: pass backward - |= $: :: tea: return address - :: hil: logical result - :: - tea/wire - hil/mill - == - ^+ ..va - :: yet: return address as vase - :: sam: whole sample as mill - :: - =/ yet !>(tea) - =/ sam ^- mill - ?- -.hil - %& [%& (slop yet p.hil)] - %| [%| [[%cell p.yet p.p.hil] [q.yet q.p.hil]]] - == - =^ nex sac.hax (~(call wa sac.hax) fox %take sam) - abet(fox nex) - -- - -- - :: :: ++va-create:va:le - ++ va-create :: compile new vase - |= src/hoof - ^+ +> - :: no existing vase; compile new vase - :: - ~& [%vase-compile way `@p`(mug src)] - =. vax (slap zus.mal (ream src)) - ?: off.mal - +> - :: initialize vane - :: - va-settle - :: :: ++va-settle:va:le - ++ va-settle :: initialize with ship - ^+ . - .(vax (slam vax !>(orb.rep))) - :: :: ++va-update - ++ va-update :: replace existing - |= src/hoof - ^+ +> - ?: off.mal - :: replacing unbooted, weird but ok - :: - (va-create src) - :: - :: out: saved state from old vane - :: - =+ out=(slap vax [%limb %stay]) - :: - :: replace `vax` with new empty vane - :: - =. +>.$ (va-create src) - :: - :: initialize new vane with old state - :: - +>.$(vax (slam (slap vax [%limb %come]) out)) - -- - :: :: ++warp:le - ++ warp :: arvo effect - |= {hen/duct wap/wasp} - ^+ +> - ~& [%warp -.wap] - ?- -.wap - $wack +>(eny.mal (mix (shaz (mix now eny.mal)) (shaz p.wap))) - $what (what hen p.wap) - $whim +>(nym.rep p.wap) - $wise +>(roy.rep p.wap) - $whom (whom hen p.wap) - == - :: :: ++whom:le - ++ whom :: initialize ship - |= {hen/duct our/@p} - ^+ +> - :: initialization only happens once - :: - ?> =(& off.mal) - :: - :: continue working after initialization - :: - =< loop - :: - :: set all flags - :: - =: orb.rep our - off.mal | - == - :: - :: activate all vanes - :: - =. van.mal - %- ~(run by van.mal) - |=(vase (slam +< !>(our))) - :: - :: send vanes `[%boot ~]` card, in alphabetical order - :: - =/ fal (sort (turn ~(tap by van.mal) |=({term *} +<-)) aor) - |- ^+ +>.^$ - ?~ fal +>.^$ - =. +>.^$ $(fal t.fal) - (emit [hen %pass [%$ %arvo ~] i.fal %& !>([%boot ~])]) - :: :: ++wile:le - ++ wile :: mill as card - |= hil/mill - ^- card - =. sac.hax (~(neat wa sac.hax) -:!>(*card) hil) - ?- -.hil - %| ;;(card q.p.hil) - %& ;;(card q.p.hil) - == - :: :: ++wilt:le - ++ wilt :: deep file as source - |= pet/plum - ^- hoof - ?>(?=({$hoon @tas} pet) +.pet) - :: :: ++wise:le - ++ wine :: load/reload vane - |= {way/term src/hoof} - ^+ +> - va-abet:(va-apex:va way src) - :: :: ++what:le - ++ what :: write deep storage - |= {hen/duct fal/(list (pair path plum))} - ^+ +> - :: dev: collated `fal` - :: - =/ dev - =| $= dev - $: :: use: non-system files - :: new: new set - :: del: installs + replacements - :: - use/(map path plum) - new/(set path) - del/(map path plum) - == - |- ^+ dev - ?~ fal dev - :: - :: pax: path of this file - :: pet: value of this file - :: - =+ [pax pet]=[p q]:i.fal - => .(fal t.fal) - :: - :: old: current value in deep storage - :: - =+ old=(~(get by fat.rep) pax) - :: - :: ignore unchanged data - :: - ?: =(old `pet) $ - :: - :: classify as user, system install or replacement - :: - ?. ?=({$neo *} pax) - $(use.dev (~(put by use.dev) pax pet)) - =? new.dev - =(~ old) - (~(put in new.dev) pax) - $(del.dev (~(put by del.dev) pax pet)) - :: - :: print new entries - :: - ~? !=(~ use.dev) - [%what-old (turn ~(tap by use.dev) |=({path *} +<-))] - ~? !=(~ new.dev) - [%what-new ~(tap in new.dev)] - ~? !=(~ use.dev) - [%what-del (turn ~(tap by del.dev) |=({path *} +<-))] - :: - :: just adopt user changes, which have no systems impact - :: - =. fat.rep (~(uni by fat.rep) use.dev) - :: - :: but: kernel reboot operation, if any - :: - =/ but - ^- (unit seed) - :: - :: when we get new hoon and arvo system files, - :: we assume they match what's running now - :: - =/ hun ?: (~(has in new.dev) /neo/hoon) ~ - (~(get by del.dev) /neo/hoon) - =/ arv ?: (~(has in new.dev) /neo/arvo) ~ - (~(get by del.dev) /neo/hoon) - ?~ hun - ?~ arv ~ - :: - :: light reboot, arvo only - :: - ~& %light-reboot - `[~ (wilt u.arv)] - :: - :: heavy reboot, hoon and arvo - :: - ~& %heavy-reboot - `[`(wilt u.hun) (wilt ?^(arv u.arv (~(got by fat.rep) /neo/arvo)))] - ?^ but - :: stop working and set up reboot - :: - ~& %reboot - %= +>.$ - :: set boot hook for termination - :: - but.gut ?>(=(~ but.gut) but) - :: - :: finish write *after* reboot, not now, so that new code - :: can use the new kernel - :: - run.gut :_ run.gut - `move:live`[hen %give %& !>([%what ~(tap by del.dev)])] - :: - :: delete kernel source file from deep - :: storage, so that install causes vane upgrade, - :: and *does not* cause repeat kernel upgrade. - :: - fat.rep ?~ p.u.but - fat.rep - (~(del by fat.rep) /neo/hoon) - == - :: keep working after vane upgrades - :: - =< loop - :: - :: job: plan for upgrading - :: - =/ job - ^- $: lul/(unit hoof) - zus/(unit hoof) - vat/(list (pair term hoof)) - == - =< [lul zus ~(tap by van)] - :: - :: lul: shared structures - :: zus: shared library - :: - =/ lul (bind (~(get by del.dev) /neo/lull) wilt) - =/ zus (bind (~(get by del.dev) /neo/zuse) wilt) - :: - :: %lull is the subject of %zuse; if we have a new %lull, - :: but no new %zuse, get the running % - :: - =. zus ?^(zus zus ?~(lul ~ `(wilt (~(got by fat.rep) /neo/zuse)))) - :: - :: van: all vane upgrades, as [initial name source] - :: - =/ van - :: zyr: all system file replacements - :: van: accumulated upgrades - :: - =/ zyr ~(tap by del.dev) - =| van/(map @tas hoof) - |- ^+ van - ?^ zyr - :: mor: process rest of `zyr` - :: - =/ mor $(zyr t.zyr) - ?. ?=({$neo $van @tas $~} p.i.zyr) - :: - :: ignore anything that isn't a vane - :: - mor - :: replaced vane in `/neo/vane/*/[nam]` - :: - =* nam `term`i.t.t.p.i.zyr - ~& [%new-vane nam `path`p.i.zyr `@p`(mug q.i.zyr)] - (~(put in mor) nam (wilt q.i.zyr)) - :: - :: if this is a new install after a heavy reboot, - :: or if we've adjusted %zuse or %lull, reboot all - :: running vanes - :: - ?. |((~(has in new.dev) /neo/hoon) ?=(^ zus)) van - :: - :: all running vanes - :: - %- ~(gas by van) - %+ skip - ^- (list (pair term hoof)) - %+ turn ~(tap by van.mal) - |= {way/term vax/vase} - [way (wilt (~(got by fat.rep) [%neo %van way ~]))] - |= {way/term src/hoof} - (~(has by van) way) - . - :: upgrade %lull, vane shared structures - :: - => ?~ lul.job . - %= . - lul.mal ~& [%lull-boot `@p`(mug u.lul.job)] - (slap !>(..arms) (ream u.lul.job)) - == - :: upgrade %zuse, vane shared libraries - :: - => ?~ zus.job . - %= . - zus.mal ~& [%zuse-boot `@p`(mug u.zus.job)] - (slap lul.mal (ream u.zus.job)) - == - :: upgrade all indicated vanes - :: - |- ^+ +>.^$ - ?~ vat.job +>.^$ - ~& [%vane-boot p.i.vat.job `@p`(mug q.i.vat.job)] - $(vat.job t.vat.job, +>.^$ (wine i.vat.job)) - -- -:: :: ++me -++ me :: dynamic analysis - :: sac: compiler cache - :: - |_ sac/worm - :: :: ++refine-moves:me - ++ refine-moves :: move list from vase - |= vax/vase - ^- {(list move:live) worm} - ?: =(~ q.vax) [~ sac] - =^ hed sac (~(slot wa sac) 2 vax) - =^ tal sac (~(slot wa sac) 3 vax) - =^ mov sac (refine-move hed) - =^ moz sac $(vax tal) - [[mov moz] sac] - :: :: ++refine-move:me - ++ refine-move :: move from vase - |= vax/vase - ^- {move:live worm} - :: - :: den: ++duct vase - :: yat: card vase - :: - =^ hip sac (~(nell wa sac) p.vax) - ?> hip - =^ den sac (~(slot wa sac) 2 vax) - =^ yat sac (~(slot wa sac) 3 vax) - =. sac (~(neat wa sac) -:!>(*duct) %& den) - ?> hip - =^ del sac (refine-ball yat) - [[(duct q.den) del] sac] - :: :: ++refine-ball:me - ++ refine-ball :: ball from vase - |= vax/vase - ^- {ball:live worm} - :: - :: specialize span to actual card stem - :: - =^ hex sac (~(sped wa sac) vax) - ?+ -.q.hex ~|(%bad-move !!) - $give - =. sac (~(neat wa sac) -:!>([%give *card]) %& hex) - :: - :: yed: vase containing card - :: hil: card as mill - :: - =^ yed sac (~(slot wa sac) 3 hex) - =^ hil sac (refine-card yed) - [[%give hil] sac] - :: - $pass - =. sac (~(neat wa sac) -:!>([%pass *path *term *card]) %& hex) - :: - :: yed: vase containing card - :: hil: card as mill - :: - =^ yed sac (~(slot wa sac) 15 hex) - =^ hil sac (refine-card yed) - [[%pass (path +6:p.hex) (term +14:p.hex) hil] sac] - == - :: :: ++refine-card:me - ++ refine-card :: card from vase - |= vax/vase - ^- (pair mill worm) - :: - :: specialize span to actual card data - :: - =^ hex sac (~(sped wa sac) vax) - =^ hip sac (~(nell wa sac) p.hex) - ?> hip - ?. ?=($meta -.q.hex) - :: - :: for an non-meta card, the mill is the vase - :: - [[%& hex] sac] - :: - :: tiv: vase of vase of card - :: typ: vase of span - :: - =^ tiv sac (~(slot wa sac) 3 hex) - =^ hip sac (~(nell wa sac) p.tiv) - ?> hip - =^ typ sac (~(slot wa sac) 2 tiv) - =. sac (~(neat wa sac) -:!>(*type) %& hex) - :: - :: support for meta-meta-cards has been removed - :: - [[%| (^ q.tiv)] sac] - -- :: me --- -:: :: :: -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: (4) interface -:: :: :: -=| sys/mall:live -|% -:: :: ++come -++ come :: load old-hoon, +11 - |= {now/@da old/mall:vile} - :: - :: if typed, would produce `{(list ovum) _+>}` - :: - ^- {* *} - :: trivial when arvo models don't change - :: - (load now old) -:: :: ++keep -++ keep :: timeout, +4 - |= {now/@da pax/path} - ^- (unit @da) - :: - :: XX: change interface to specify vane, not path - :: XX: rename "keep" to "doze" - :: way: vane of timeout - :: - ?> ?=({$$ @tas $~} pax) - =* way i.t.pax - (~(doze le now sys) way) -:: :: ++load -++ load :: load current, +86 - |= {now/@da new/mall:live} - :: - :: if typed, would produce `{(list ovum) _+>}` - :: - ^- {* *} - (poke(sys new) now *ovum) -:: :: ++peek -++ peek :: inspect, 87 - |= {now/@da pax/path} - ^- (unit *) - :: - :: XX: adapt external users to modern (unit (unit cage)) - :: - ?. ?=({@ta @ta @ta @ta *} pax) ~ - :: - :: lyc: access control, `[~ ~]` gets anything - :: cyr: perspective - :: bec: path head, `[ship desk case]` - :: tyl: path tail - :: nut: peek result - :: - =/ lyc `(unit (set ship))`[~ ~] - =/ cyr ?>(((sane %tas) i.pax) `@tas`i.pax) - =/ bec ^- beak - :+ (slav %p i.t.pax) - (slav %tas i.t.t.pax) - ;;(case (slay i.t.t.t.pax)) - =* tyl t.t.t.t.pax - =/ nut (~(peek le now sys) lyc cyr bec tyl) - ?~ nut ~ - ?~ u.nut ~ - [~ +.q.u.u.nut] -:: :: ++poke -++ poke :: apply, 42 - |= {now/@da ovo/ovum} - :: - :: if typed, would produce `{(list ovum) _+>}` - :: - ^- {* *} - :: - :: iterate entropy, it can't hurt - :: - =. eny.mal.sys (mix (shaz now) eny.mal.sys) - :: - :: produce a new state, and either output or a reboot - :: - =^ new sys - =< abet - :: - :: as a hack for reboots, an empty ovum is a no-op - :: - ?: =(*ovum ovo) - ~(loop le now sys) - (~(poke le now sys) ovo) - ?- -.new - :: - :: no reboot; produce output and current core - :: - %& [`(list ovum)`p.new +>.$] - :: - :: reboot; produce loop result from new kernel - :: - %| ~(boot le now sys) - == -:: :: ++wish -++ wish :: compute, 20 - |= src/hoof - q:(slap ?:(off.mal.sys !>(+>) zus.mal.sys) (ream src)) --- From 90d4cfec05942197e616edcc033f84c75f1c6aca Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 25 Nov 2020 23:33:41 -0800 Subject: [PATCH 757/933] pill: solid --- bin/solid.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index d9870a983b..0ea27f4664 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4d2e41ef5b2a292a9dfd7e485d027441c9649f6e4f2bbf91ac776698a88fd151 -size 6384147 +oid sha256:409ce99890b3ed822c377c494efa214cac71197b5e3bf662012121664e6d5bb6 +size 6303130 From fc30df740144b0cd1f9e79c92256d03e3fa184d0 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 24 Nov 2020 23:48:54 -0800 Subject: [PATCH 758/933] hoon: adds new +mug (as +gum) --- pkg/arvo/sys/hoon.hoon | 17 +++++++++++ pkg/arvo/tests/sys/hoon/hashes.hoon | 44 +++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 30a82a510e..8e091aada5 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -1081,6 +1081,23 @@ =+ ham=(mix (rsh 0 31 haz) (end 0 31 haz)) ?.(=(0 ham) ham $(syd +(syd))) -- +++ gum + ~/ %gum + |= a=* + |^ ?@ a (mum 0xcafe.babe 0x7fff a) + =/ b (cat 5 $(a -.a) $(a +.a)) + (mum 0xdead.beef 0xfffe b) + :: + ++ mum + |= [syd=@uxF fal=@F key=@] + =/ wyd (met 3 key) + =| i=@ud + |- ^- @F + ?: =(8 i) fal + =/ haz=@F (muk syd wyd key) + =/ ham=@F (mix (rsh 0 31 haz) (end 0 31 haz)) + ?.(=(0 ham) ham $(i +(i), syd +(syd))) + -- :: :: :::: 2f: noun ordering :: :: :: diff --git a/pkg/arvo/tests/sys/hoon/hashes.hoon b/pkg/arvo/tests/sys/hoon/hashes.hoon index c9c8d9332b..0a0e44b9c9 100644 --- a/pkg/arvo/tests/sys/hoon/hashes.hoon +++ b/pkg/arvo/tests/sys/hoon/hashes.hoon @@ -53,6 +53,50 @@ !> 0x2ad3.9968 !> (mug [(dec (bex 128)) 1]) == +:: +++ test-gum + ;: weld + %+ expect-eq + !> 0x4d44.1035 + !> (gum 'Hello, world!') + :: + %+ expect-eq + !> 0x79ff.04e8 + !> (gum 0) + :: + %+ expect-eq + !> 0x715c.2a60 + !> (gum 1) + :: + %+ expect-eq + !> 0x64df.da5c + !> (gum (crip (reap 28 'x'))) + :: + %+ expect-eq + !> 0x192f.5588 + !> (gum [0 0]) + :: + %+ expect-eq + !> 0x6b32.ec46 + !> (gum [1 1]) + :: + %+ expect-eq + !> 0x2ef.fe10 + !> (gum [2 2]) + :: + %+ expect-eq + !> 0x3a81.1aec + !> (gum [1 2 3]) + :: + %+ expect-eq + !> 0x7ce.fb7f + !> (gum [0 (bex 32)]) + :: + %+ expect-eq + !> 0x2aa0.6bfc + !> (gum [(dec (bex 128)) 1]) + == +:: :: SHA tests :: For references see FIPS180-4 and related test vectors :: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf From 09782dcba13b0e61a197733bf3ce07a26709f3f9 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 25 Nov 2020 00:42:37 -0800 Subject: [PATCH 759/933] u3: adds new +mug (as u3r_gum_*) --- pkg/urbit/include/noun/retrieve.h | 16 +++++++ pkg/urbit/noun/retrieve.c | 72 +++++++++++++++++++++++++++++++ pkg/urbit/tests/mug_tests.c | 70 ++++++++++++++++++++++++++++++ 3 files changed, 158 insertions(+) diff --git a/pkg/urbit/include/noun/retrieve.h b/pkg/urbit/include/noun/retrieve.h index d3cfd429ca..6590f55351 100644 --- a/pkg/urbit/include/noun/retrieve.h +++ b/pkg/urbit/include/noun/retrieve.h @@ -34,6 +34,22 @@ c3_o u3r_mean(u3_noun a, ...); + /* u3r_gum_both(): Join two mugs. + */ + c3_l + u3r_gum_both(c3_l lef_l, c3_l rit_l); + + /* u3r_gum_bytes(): Compute the mug of `buf`, `len`, LSW first. + */ + c3_l + u3r_gum_bytes(const c3_y *buf_y, + c3_w len_w); + + /* u3r_gum_c(): Compute the mug of `a`, LSB first. + */ + c3_l + u3r_gum_c(const c3_c* a_c); + /* u3r_mug_bytes(): Compute the mug of `buf`, `len`, LSW first. */ c3_w diff --git a/pkg/urbit/noun/retrieve.c b/pkg/urbit/noun/retrieve.c index 25b4b747eb..f60c2d8d51 100644 --- a/pkg/urbit/noun/retrieve.c +++ b/pkg/urbit/noun/retrieve.c @@ -1479,6 +1479,78 @@ u3r_tape(u3_noun a) return a_y; } +/* u3r_gum_both(): Join two mugs. +*/ +c3_l +u3r_gum_both(c3_l lef_l, c3_l rit_l) +{ + c3_y len_y = 4 + ((c3_bits_word(rit_l) + 0x7) >> 3); + c3_w syd_w = 0xdeadbeef; + c3_w i_w = 0; + c3_y buf_y[8]; + + buf_y[0] = lef_l & 0xff; + buf_y[1] = (lef_l >> 8) & 0xff; + buf_y[2] = (lef_l >> 16) & 0xff; + buf_y[3] = (lef_l >> 24) & 0xff; + buf_y[4] = rit_l & 0xff; + buf_y[5] = (rit_l >> 8) & 0xff; + buf_y[6] = (rit_l >> 16) & 0xff; + buf_y[7] = (rit_l >> 24) & 0xff; + + while ( i_w < 8 ) { + c3_w haz_w; + c3_l ham_l; + + MurmurHash3_x86_32(buf_y, len_y, syd_w, &haz_w); + ham_l = (haz_w >> 31) ^ (haz_w & 0x7fffffff); + + if ( 0 == ham_l ) { + syd_w++; i_w++; + } + else { + return ham_l; + } + } + + return 0xfffe; +} + +/* u3r_gum_bytes(): Compute the mug of `buf`, `len`, LSW first. +*/ +c3_l +u3r_gum_bytes(const c3_y *buf_y, + c3_w len_w) +{ + c3_w syd_w = 0xcafebabe; + c3_w i_w = 0; + + while ( i_w < 8 ) { + c3_w haz_w; + c3_l ham_l; + + MurmurHash3_x86_32(buf_y, len_w, syd_w, &haz_w); + ham_l = (haz_w >> 31) ^ (haz_w & 0x7fffffff); + + if ( 0 == ham_l ) { + syd_w++; i_w++; + } + else { + return ham_l; + } + } + + return 0x7fff; +} + +/* u3r_gum_c(): Compute the mug of `a`, LSB first. +*/ +c3_l +u3r_gum_c(const c3_c* a_c) +{ + return u3r_gum_bytes((c3_y*)a_c, strlen(a_c)); +} + /* u3r_mug_bytes(): Compute the mug of `buf`, `len`, LSW first. */ c3_w diff --git a/pkg/urbit/tests/mug_tests.c b/pkg/urbit/tests/mug_tests.c index b279cd6f74..9ae99ad278 100644 --- a/pkg/urbit/tests/mug_tests.c +++ b/pkg/urbit/tests/mug_tests.c @@ -192,6 +192,71 @@ _test_mug(void) return ret_i; } +/* _test_mug(): spot check u3r_mug hashes. +*/ +static c3_i +_test_gum(void) +{ + c3_i ret_i = 1; + + if ( 0x4d441035 != u3r_gum_c("Hello, world!") ) { + fprintf(stderr, "fail (a)\r\n"); + ret_i = 0; + } + + if ( 0x79ff04e8 != u3r_mug_bytes(0, 0) ) { + fprintf(stderr, "fail (c)\r\n"); + ret_i = 0; + } + + { + c3_y byt_y[1] = {1}; + + if ( 0x715c2a60 != u3r_mug_bytes(byt_y, 1) ) { + fprintf(stderr, "fail (c)\r\n"); + ret_i = 0; + } + + byt_y[0] = 2; + + if ( 0x718b9468 != u3r_mug_bytes(byt_y, 1) ) { + fprintf(stderr, "fail (c)\r\n"); + ret_i = 0; + } + } + + { + if ( 0x64dfda5c != u3r_gum_c("xxxxxxxxxxxxxxxxxxxxxxxxxxxx") ) { + fprintf(stderr, "fail (d)\r\n"); + ret_i = 0; + } + } + + // [0 0] + // + if ( 0x192f5588 != u3r_gum_both(0x79ff04e8, 0x79ff04e8) ) { + fprintf(stderr, "fail (e)\r\n"); + ret_i = 0; + } + + // [1 1] + // + if ( 0x6b32ec46 != u3r_gum_both(0x715c2a60, 0x715c2a60) ) { + fprintf(stderr, "fail (f)\r\n"); + ret_i = 0; + } + + // [2 2] + // + if ( 0x2effe10 != u3r_gum_both(0x718b9468, 0x718b9468) ) { + fprintf(stderr, "fail (f)\r\n"); + ret_i = 0; + } + + return ret_i; +} + + /* main(): run all test cases. */ int @@ -204,6 +269,11 @@ main(int argc, char* argv[]) exit(1); } + if ( !_test_gum() ) { + fprintf(stderr, "test_mug: failed\r\n"); + exit(1); + } + // GC // u3m_grab(u3_none); From 58ca8859efc7b4236279bf7c77b832143c160dfc Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 25 Nov 2020 02:19:14 -0800 Subject: [PATCH 760/933] pill: brass --- bin/brass.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/brass.pill b/bin/brass.pill index 688e3fd074..4439670b4b 100644 --- a/bin/brass.pill +++ b/bin/brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9942a8b27a470fa4992f0ec4be33d7246d84a407da4f766bb4327da07d458ca7 -size 4477237 +oid sha256:9edb49d4d3c63f486342f9fec514de13262ccd79de8d1dd392d856168dc01ad6 +size 4908430 From cd3918b852839ee13fee9b7cac94d54401ad0464 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 25 Nov 2020 02:00:32 -0800 Subject: [PATCH 761/933] hoon: switches to new +mug --- pkg/arvo/sys/hoon.hoon | 12 ------- pkg/arvo/tests/sys/hoon/hashes.hoon | 51 ++++++----------------------- 2 files changed, 10 insertions(+), 53 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 8e091aada5..dc6e03820a 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -1071,18 +1071,6 @@ :: ++ mug :: mug with murmur3 ~/ %mug - |= a/* - |^ (trim ?@(a a (mix $(a -.a) (mix 0x7fff.ffff $(a +.a))))) - ++ trim :: 31-bit nonzero - |= key/@ - =+ syd=0xcafe.babe - |- ^- @ - =+ haz=(muk syd (met 3 key) key) - =+ ham=(mix (rsh 0 31 haz) (end 0 31 haz)) - ?.(=(0 ham) ham $(syd +(syd))) - -- -++ gum - ~/ %gum |= a=* |^ ?@ a (mum 0xcafe.babe 0x7fff a) =/ b (cat 5 $(a -.a) $(a +.a)) diff --git a/pkg/arvo/tests/sys/hoon/hashes.hoon b/pkg/arvo/tests/sys/hoon/hashes.hoon index 0a0e44b9c9..ef9ec855e7 100644 --- a/pkg/arvo/tests/sys/hoon/hashes.hoon +++ b/pkg/arvo/tests/sys/hoon/hashes.hoon @@ -33,68 +33,37 @@ !> 0x79ff.04e8 !> (mug 0) :: + %+ expect-eq + !> 0x715c.2a60 + !> (mug 1) + :: %+ expect-eq !> 0x64df.da5c !> (mug (crip (reap 28 'x'))) :: %+ expect-eq - !> 0x389c.a03a + !> 0x192f.5588 !> (mug [0 0]) :: %+ expect-eq - !> 0x389c.a03a + !> 0x6b32.ec46 !> (mug [1 1]) :: - %+ expect-eq - !> 0x5258.a6c0 - !> (mug [0 (bex 32)]) - :: - %+ expect-eq - !> 0x2ad3.9968 - !> (mug [(dec (bex 128)) 1]) - == -:: -++ test-gum - ;: weld - %+ expect-eq - !> 0x4d44.1035 - !> (gum 'Hello, world!') - :: - %+ expect-eq - !> 0x79ff.04e8 - !> (gum 0) - :: - %+ expect-eq - !> 0x715c.2a60 - !> (gum 1) - :: - %+ expect-eq - !> 0x64df.da5c - !> (gum (crip (reap 28 'x'))) - :: - %+ expect-eq - !> 0x192f.5588 - !> (gum [0 0]) - :: - %+ expect-eq - !> 0x6b32.ec46 - !> (gum [1 1]) - :: %+ expect-eq !> 0x2ef.fe10 - !> (gum [2 2]) + !> (mug [2 2]) :: %+ expect-eq !> 0x3a81.1aec - !> (gum [1 2 3]) + !> (mug [1 2 3]) :: %+ expect-eq !> 0x7ce.fb7f - !> (gum [0 (bex 32)]) + !> (mug [0 (bex 32)]) :: %+ expect-eq !> 0x2aa0.6bfc - !> (gum [(dec (bex 128)) 1]) + !> (mug [(dec (bex 128)) 1]) == :: :: SHA tests From 5b2d6958618cf478dd9ceff50beb20784f3c09d1 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 25 Nov 2020 02:00:47 -0800 Subject: [PATCH 762/933] arvo: temporary, build +brass out of /not-sys --- pkg/arvo/gen/brass.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/arvo/gen/brass.hoon b/pkg/arvo/gen/brass.hoon index 73de67153a..c045be92d7 100644 --- a/pkg/arvo/gen/brass.hoon +++ b/pkg/arvo/gen/brass.hoon @@ -157,7 +157,7 @@ :: :: compiler-source: hoon source file producing compiler, `sys/hoon` :: -=+ compiler-source=.^(@t %cx (welp sys /hoon/hoon)) +=+ compiler-source=.^(@t %cx /(scot %p p.bec)/[q.bec]/(scot %da now)/not-sys/hoon/hoon) :: :: compiler-twig: compiler as hoon expression :: From e853474ce03872539a8dcfe784ddc57fb10f4581 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 25 Nov 2020 02:18:33 -0800 Subject: [PATCH 763/933] u3: switches to new +mug --- pkg/urbit/include/noun/retrieve.h | 57 +++---------- pkg/urbit/noun/retrieve.c | 72 ++++------------ pkg/urbit/tests/mug_tests.c | 133 +++++++++++------------------- 3 files changed, 76 insertions(+), 186 deletions(-) diff --git a/pkg/urbit/include/noun/retrieve.h b/pkg/urbit/include/noun/retrieve.h index 6590f55351..de4f645ec7 100644 --- a/pkg/urbit/include/noun/retrieve.h +++ b/pkg/urbit/include/noun/retrieve.h @@ -34,68 +34,37 @@ c3_o u3r_mean(u3_noun a, ...); - /* u3r_gum_both(): Join two mugs. + /* u3r_mug_both(): Join two mugs. */ c3_l - u3r_gum_both(c3_l lef_l, c3_l rit_l); - - /* u3r_gum_bytes(): Compute the mug of `buf`, `len`, LSW first. - */ - c3_l - u3r_gum_bytes(const c3_y *buf_y, - c3_w len_w); - - /* u3r_gum_c(): Compute the mug of `a`, LSB first. - */ - c3_l - u3r_gum_c(const c3_c* a_c); + u3r_mug_both(c3_w lef_w, c3_w rit_w); /* u3r_mug_bytes(): Compute the mug of `buf`, `len`, LSW first. */ - c3_w + c3_l u3r_mug_bytes(const c3_y *buf_y, c3_w len_w); - /* u3r_mug_chub(): Compute the mug of `num`, LSW first. + /* u3r_mug_c(): Compute the mug of `a`, LSB first. */ - c3_w - u3r_mug_chub(c3_d num_d); - - /* u3r_mug_string(): Compute the mug of `a`, LSB first. - */ - c3_w - u3r_mug_string(const c3_c *a_c); - - /* u3r_mug_words(): 31-bit nonzero MurmurHash3 on raw words. - */ - c3_w - u3r_mug_words(const c3_w* key_w, c3_w len_w); - - /* u3r_mug_both(): Join two mugs. - */ - c3_w - u3r_mug_both(c3_w lef_w, c3_w rit_w); + c3_l + u3r_mug_c(const c3_c *a_c); /* u3r_mug_cell(): Compute the mug of the cell `[hed tel]`. */ - c3_w + c3_l u3r_mug_cell(u3_noun hed, u3_noun tel); - /* u3r_mug_trel(): Compute the mug of `[a b c]`. + /* u3r_mug_chub(): Compute the mug of `num`, LSW first. */ - c3_w - u3r_mug_trel(u3_noun a, - u3_noun b, - u3_noun c); + c3_l + u3r_mug_chub(c3_d num_d); - /* u3r_mug_qual(): Compute the mug of `[a b c d]`. + /* u3r_mug_words(): 31-bit nonzero MurmurHash3 on raw words. */ - c3_w - u3r_mug_qual(u3_noun a, - u3_noun b, - u3_noun c, - u3_noun d); + c3_l + u3r_mug_words(const c3_w* key_w, c3_w len_w); /* u3r_mug(): statefully mug a noun with 31-bit murmur3. */ diff --git a/pkg/urbit/noun/retrieve.c b/pkg/urbit/noun/retrieve.c index f60c2d8d51..a279aa20e7 100644 --- a/pkg/urbit/noun/retrieve.c +++ b/pkg/urbit/noun/retrieve.c @@ -1479,10 +1479,10 @@ u3r_tape(u3_noun a) return a_y; } -/* u3r_gum_both(): Join two mugs. +/* u3r_mug_both(): Join two mugs. */ c3_l -u3r_gum_both(c3_l lef_l, c3_l rit_l) +u3r_mug_both(c3_l lef_l, c3_l rit_l) { c3_y len_y = 4 + ((c3_bits_word(rit_l) + 0x7) >> 3); c3_w syd_w = 0xdeadbeef; @@ -1516,10 +1516,10 @@ u3r_gum_both(c3_l lef_l, c3_l rit_l) return 0xfffe; } -/* u3r_gum_bytes(): Compute the mug of `buf`, `len`, LSW first. +/* u3r_mug_bytes(): Compute the mug of `buf`, `len`, LSW first. */ c3_l -u3r_gum_bytes(const c3_y *buf_y, +u3r_mug_bytes(const c3_y *buf_y, c3_w len_w) { c3_w syd_w = 0xcafebabe; @@ -1543,40 +1543,29 @@ u3r_gum_bytes(const c3_y *buf_y, return 0x7fff; } -/* u3r_gum_c(): Compute the mug of `a`, LSB first. +/* u3r_mug_c(): Compute the mug of `a`, LSB first. */ c3_l -u3r_gum_c(const c3_c* a_c) +u3r_mug_c(const c3_c* a_c) { - return u3r_gum_bytes((c3_y*)a_c, strlen(a_c)); + return u3r_mug_bytes((c3_y*)a_c, strlen(a_c)); } -/* u3r_mug_bytes(): Compute the mug of `buf`, `len`, LSW first. +/* u3r_mug_cell(): Compute the mug of the cell `[hed tel]`. */ -c3_w -u3r_mug_bytes(const c3_y *buf_y, - c3_w len_w) +c3_l +u3r_mug_cell(u3_noun hed, + u3_noun tel) { - c3_w syd_w = 0xcafebabe; - c3_w ham_w = 0; + c3_w lus_w = u3r_mug(hed); + c3_w biq_w = u3r_mug(tel); - while ( 1 ) { - c3_w haz_w; - MurmurHash3_x86_32(buf_y, len_w, syd_w, &haz_w); - ham_w = (haz_w >> 31) ^ (haz_w & 0x7fffffff); - - if ( 0 == ham_w ) { - syd_w++; - } - else { - return ham_w; - } - } + return u3r_mug_both(lus_w, biq_w); } /* u3r_mug_chub(): Compute the mug of `num`, LSW first. */ -c3_w +c3_l u3r_mug_chub(c3_d num_d) { c3_w buf_w[2]; @@ -1587,17 +1576,9 @@ u3r_mug_chub(c3_d num_d) return u3r_mug_words(buf_w, 2); } -/* u3r_mug_string(): Compute the mug of `a`, LSB first. -*/ -c3_w -u3r_mug_string(const c3_c *a_c) -{ - return u3r_mug_bytes((c3_y*)a_c, strlen(a_c)); -} - /* u3r_mug_words(): 31-bit nonzero MurmurHash3 on raw words. */ -c3_w +c3_l u3r_mug_words(const c3_w* key_w, c3_w len_w) { c3_w byt_w; @@ -1627,27 +1608,6 @@ u3r_mug_words(const c3_w* key_w, c3_w len_w) return u3r_mug_bytes((c3_y*)key_w, byt_w); } -/* u3r_mug_both(): Join two mugs. -*/ -c3_w -u3r_mug_both(c3_w lef_w, c3_w rit_w) -{ - c3_w ham_w = lef_w ^ (0x7fffffff ^ rit_w); - return u3r_mug_words(&ham_w, 1); -} - -/* u3r_mug_cell(): Compute the mug of the cell `[hed tel]`. -*/ -c3_w -u3r_mug_cell(u3_noun hed, - u3_noun tel) -{ - c3_w lus_w = u3r_mug(hed); - c3_w biq_w = u3r_mug(tel); - - return u3r_mug_both(lus_w, biq_w); -} - /* _cr_mug: stack frame for recording cell traversal ** !mug == head-frame */ diff --git a/pkg/urbit/tests/mug_tests.c b/pkg/urbit/tests/mug_tests.c index 9ae99ad278..532b8e27a4 100644 --- a/pkg/urbit/tests/mug_tests.c +++ b/pkg/urbit/tests/mug_tests.c @@ -16,7 +16,7 @@ _test_mug(void) { c3_i ret_i = 1; - if ( 0x4d441035 != u3r_mug_string("Hello, world!") ) { + if ( 0x4d441035 != u3r_mug_c("Hello, world!") ) { fprintf(stderr, "fail (a)\r\n"); ret_i = 0; } @@ -32,36 +32,67 @@ _test_mug(void) u3z(a); } - if ( 0x79ff04e8 != u3r_mug_bytes(0, 0) ) { - fprintf(stderr, "fail (c)\r\n"); + { + c3_y byt_y[1]; + + if ( 0x79ff04e8 != u3r_mug_bytes(0, 0) ) { + fprintf(stderr, "fail (c) (0)\r\n"); + ret_i = 0; + } + + byt_y[0] = 1; + + if ( 0x715c2a60 != u3r_mug_bytes(byt_y, 1) ) { + fprintf(stderr, "fail (c) (1)\r\n"); + ret_i = 0; + } + + byt_y[0] = 2; + + if ( 0x718b9468 != u3r_mug_bytes(byt_y, 1) ) { + fprintf(stderr, "fail (c) (2)\r\n"); + ret_i = 0; + } + } + + if ( 0x3a811aec != u3r_mug_both(0x715c2a60, u3r_mug_cell(2, 3)) ) { + fprintf(stderr, "fail (d)\r\n"); ret_i = 0; } + + { + if ( 0x192f5588 != u3r_mug_cell(0, 0) ) { + fprintf(stderr, "fail (e) (1)\r\n"); + ret_i = 0; + } + + if ( 0x6b32ec46 != u3r_mug_cell(1, 1) ) { + fprintf(stderr, "fail (e) (2)\r\n"); + ret_i = 0; + } + + if ( 0x2effe10 != u3r_mug_cell(2, 2) ) { + fprintf(stderr, "fail (e) (3)\r\n"); + ret_i = 0; + } + } + { u3_noun a = u3i_string("xxxxxxxxxxxxxxxxxxxxxxxxxxxx"); if ( 0x64dfda5c != u3r_mug(a) ) { - fprintf(stderr, "fail (d)\r\n"); + fprintf(stderr, "fail (f)\r\n"); ret_i = 0; } u3z(a); } - if ( 0x389ca03a != u3r_mug_cell(0, 0) ) { - fprintf(stderr, "fail (e)\r\n"); - ret_i = 0; - } - - if ( 0x389ca03a != u3r_mug_cell(1, 1) ) { - fprintf(stderr, "fail (f)\r\n"); - ret_i = 0; - } - { u3_noun a = u3qc_bex(32); - if ( 0x5258a6c0 != u3r_mug_cell(0, a) ) { + if ( 0x7cefb7f != u3r_mug_cell(0, a) ) { fprintf(stderr, "fail (g)\r\n"); ret_i = 0; } @@ -72,7 +103,7 @@ _test_mug(void) { u3_noun a = u3ka_dec(u3qc_bex(128)); - if ( 0x2ad39968 != u3r_mug_cell(a, 1) ) { + if ( 0x2aa06bfc != u3r_mug_cell(a, 1) ) { fprintf(stderr, "fail (h)\r\n"); ret_i = 0; } @@ -192,71 +223,6 @@ _test_mug(void) return ret_i; } -/* _test_mug(): spot check u3r_mug hashes. -*/ -static c3_i -_test_gum(void) -{ - c3_i ret_i = 1; - - if ( 0x4d441035 != u3r_gum_c("Hello, world!") ) { - fprintf(stderr, "fail (a)\r\n"); - ret_i = 0; - } - - if ( 0x79ff04e8 != u3r_mug_bytes(0, 0) ) { - fprintf(stderr, "fail (c)\r\n"); - ret_i = 0; - } - - { - c3_y byt_y[1] = {1}; - - if ( 0x715c2a60 != u3r_mug_bytes(byt_y, 1) ) { - fprintf(stderr, "fail (c)\r\n"); - ret_i = 0; - } - - byt_y[0] = 2; - - if ( 0x718b9468 != u3r_mug_bytes(byt_y, 1) ) { - fprintf(stderr, "fail (c)\r\n"); - ret_i = 0; - } - } - - { - if ( 0x64dfda5c != u3r_gum_c("xxxxxxxxxxxxxxxxxxxxxxxxxxxx") ) { - fprintf(stderr, "fail (d)\r\n"); - ret_i = 0; - } - } - - // [0 0] - // - if ( 0x192f5588 != u3r_gum_both(0x79ff04e8, 0x79ff04e8) ) { - fprintf(stderr, "fail (e)\r\n"); - ret_i = 0; - } - - // [1 1] - // - if ( 0x6b32ec46 != u3r_gum_both(0x715c2a60, 0x715c2a60) ) { - fprintf(stderr, "fail (f)\r\n"); - ret_i = 0; - } - - // [2 2] - // - if ( 0x2effe10 != u3r_gum_both(0x718b9468, 0x718b9468) ) { - fprintf(stderr, "fail (f)\r\n"); - ret_i = 0; - } - - return ret_i; -} - - /* main(): run all test cases. */ int @@ -269,11 +235,6 @@ main(int argc, char* argv[]) exit(1); } - if ( !_test_gum() ) { - fprintf(stderr, "test_mug: failed\r\n"); - exit(1); - } - // GC // u3m_grab(u3_none); From 833f5f4b77fd1c15999bda2cbb8a2292eb04746f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 25 Nov 2020 02:20:23 -0800 Subject: [PATCH 764/933] Revert "arvo: temporary, build +brass out of /not-sys" This reverts commit 44b4dc0e33e92b624466141216a3885b691a1859. --- pkg/arvo/gen/brass.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/arvo/gen/brass.hoon b/pkg/arvo/gen/brass.hoon index c045be92d7..73de67153a 100644 --- a/pkg/arvo/gen/brass.hoon +++ b/pkg/arvo/gen/brass.hoon @@ -157,7 +157,7 @@ :: :: compiler-source: hoon source file producing compiler, `sys/hoon` :: -=+ compiler-source=.^(@t %cx /(scot %p p.bec)/[q.bec]/(scot %da now)/not-sys/hoon/hoon) +=+ compiler-source=.^(@t %cx (welp sys /hoon/hoon)) :: :: compiler-twig: compiler as hoon expression :: From 68ed7d095c11c78a115c605617d4bb582e482a4e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 25 Nov 2020 02:22:15 -0800 Subject: [PATCH 765/933] pill: all --- bin/brass.pill | 4 ++-- bin/ivory.pill | 4 ++-- bin/solid.pill | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/brass.pill b/bin/brass.pill index 4439670b4b..f5a4ea75e0 100644 --- a/bin/brass.pill +++ b/bin/brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9edb49d4d3c63f486342f9fec514de13262ccd79de8d1dd392d856168dc01ad6 -size 4908430 +oid sha256:e9cac913c7119105341875d99f26b49424b130091cf1da7b574bd13f499363d6 +size 4478131 diff --git a/bin/ivory.pill b/bin/ivory.pill index 8cdfa932dc..46ac504af2 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:92f96229ed78f7fe229f35be8145b4f14436800b7c4a0c68fb3e631eb6a3d993 -size 1305392 +oid sha256:7ab441674094e09a424117dca8e9d057b231712e053d11346eb162170640d5e5 +size 1305511 diff --git a/bin/solid.pill b/bin/solid.pill index b3e2f7bb8d..c1f884af4f 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ae9cf9424cb0f4ce515d477646844dfdab57a2cbd1f3b1e2d65662cce1d09654 -size 6306749 +oid sha256:4675d723f059fb8f66e1a2cb2afa6da93c43ad72a21cacb69defb3ec338491df +size 6307678 From c6b5f76367f7c65ea8c8ba5829d6f25b21fb14cc Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 26 Nov 2020 01:05:13 -0800 Subject: [PATCH 766/933] ur: updates +mug --- pkg/urbit/ur/hashcons.c | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/pkg/urbit/ur/hashcons.c b/pkg/urbit/ur/hashcons.c index 71f2568f9a..8339a53010 100644 --- a/pkg/urbit/ur/hashcons.c +++ b/pkg/urbit/ur/hashcons.c @@ -338,20 +338,23 @@ ur_mug ur_mug_bytes(const uint8_t *byt, uint64_t len) { uint32_t seed = 0xcafebabe; - ur_mug mug; + uint8_t i = 0; - while ( 1 ) { + while ( i < 8 ) { + ur_mug mug; uint32_t raw; MurmurHash3_x86_32(byt, len, seed, &raw); mug = (raw >> 31) ^ ( ur_mask_31(raw) ); if ( 0 == mug ) { - seed++; + seed++; i++; } else { return mug; } } + + return (ur_mug)0x7fff; } ur_mug @@ -387,9 +390,35 @@ ur_mug64(uint64_t x) ur_mug ur_mug_both(ur_mug hed, ur_mug tal) { - // XX not correct per u3r_mug, but necessary to avoid collisions - // - return ur_mug32(hed ^ (0x7fffffff ^ ur_mug32(tal))); + uint32_t seed = 0xdeadbeef; + uint8_t len = 4 + ur_bloq_up3(ur_met0_32(tal)); + uint8_t i = 0; + uint8_t byt[8] = { + ur_mask_8(hed >> 0), + ur_mask_8(hed >> 8), + ur_mask_8(hed >> 16), + ur_mask_8(hed >> 24), + ur_mask_8(tal >> 0), + ur_mask_8(tal >> 8), + ur_mask_8(tal >> 16), + ur_mask_8(tal >> 24) + }; + + while ( i < 8 ) { + ur_mug mug; + uint32_t raw; + MurmurHash3_x86_32(byt, len, seed, &raw); + mug = (raw >> 31) ^ ( ur_mask_31(raw) ); + + if ( 0 == mug ) { + seed++; i++; + } + else { + return mug; + } + } + + return (ur_mug)0xfffe; } ur_mug From 76a39f734772d034c811a1494c9b38716b495e61 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 26 Nov 2020 01:24:44 -0800 Subject: [PATCH 767/933] pill: brass --- bin/brass.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/brass.pill b/bin/brass.pill index d8087aea44..d9c5344f5c 100644 --- a/bin/brass.pill +++ b/bin/brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:76b02d0d18b2e1827d09890ec2a05b525acf05c2a1861881ee2f1cb959e1d168 -size 4573429 +oid sha256:6af0391d08541a0a10b28b9ed57d3ee0c4a95f03bb5d283589346fa232deb9e3 +size 4925677 From 698710250d9b8e15da01def6968c21f09956dcdf Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 26 Nov 2020 01:46:28 -0800 Subject: [PATCH 768/933] arvo: temporary, removes initial kernel source from +brass --- pkg/arvo/gen/brass.hoon | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pkg/arvo/gen/brass.hoon b/pkg/arvo/gen/brass.hoon index fb64a16030..0db748c08a 100644 --- a/pkg/arvo/gen/brass.hoon +++ b/pkg/arvo/gen/brass.hoon @@ -191,11 +191,6 @@ :: =/ bas=path (flop (tail (flop sys))) :+ boot-ova - :~ :~ //arvo - %what - [/sys/hoon hoon/compiler-source] - [/sys/arvo hoon/arvo-source] - == - (file-ovum2:pill bas) + :~ (file-ovum2:pill bas) == [(file-ovum:pill bas) ~] From bbc8e13e00e993045448da047c17a2a820e901a3 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 26 Nov 2020 01:46:55 -0800 Subject: [PATCH 769/933] pill: brass --- bin/brass.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/brass.pill b/bin/brass.pill index d9c5344f5c..267e781c82 100644 --- a/bin/brass.pill +++ b/bin/brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6af0391d08541a0a10b28b9ed57d3ee0c4a95f03bb5d283589346fa232deb9e3 -size 4925677 +oid sha256:a1c19f83b0af9471b9a5b4a5681e194368703a3b97808cf622cb838a3c356bdc +size 4925527 From a7a94e5b9cd4783cfa8e1c1488b9d5cff583cc9a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 26 Nov 2020 02:02:53 -0800 Subject: [PATCH 770/933] Revert "arvo: temporary, removes initial kernel source from +brass" This reverts commit 698710250d9b8e15da01def6968c21f09956dcdf. --- pkg/arvo/gen/brass.hoon | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/arvo/gen/brass.hoon b/pkg/arvo/gen/brass.hoon index 41ddce4f6b..bae8f56654 100644 --- a/pkg/arvo/gen/brass.hoon +++ b/pkg/arvo/gen/brass.hoon @@ -191,6 +191,11 @@ :: =/ bas=path (flop (tail (flop sys))) :+ boot-ova - :~ (file-ovum2:pill bas) + :~ :~ //arvo + %what + [/sys/hoon hoon/compiler-source] + [/sys/arvo hoon/arvo-source] + == + (file-ovum2:pill bas) == [(file-ovum:pill bas) ~] From 7a55cb39ed5c531df8df02d6ff1e80f34e8c01b9 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 26 Nov 2020 02:14:08 -0800 Subject: [PATCH 771/933] pill: all --- bin/brass.pill | 4 ++-- bin/ivory.pill | 4 ++-- bin/solid.pill | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/brass.pill b/bin/brass.pill index 267e781c82..13ad961271 100644 --- a/bin/brass.pill +++ b/bin/brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a1c19f83b0af9471b9a5b4a5681e194368703a3b97808cf622cb838a3c356bdc -size 4925527 +oid sha256:d83b7a0878cdcba73a63769ad12896bf4f9d90ca662d79f19ae90e6be074d032 +size 4494462 diff --git a/bin/ivory.pill b/bin/ivory.pill index cacba3bfb2..0c5b8d3d3d 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d2afa3600c4825b19c7359aaa841979c1b8a250cf9a8035733e9f8ad6f6cda33 -size 1905061 +oid sha256:d58f536429741585da358a8c2af8b2b631be1357887c9d4aae1d8a1cf31c3514 +size 1730073 diff --git a/bin/solid.pill b/bin/solid.pill index 0ea27f4664..7395f857d1 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:409ce99890b3ed822c377c494efa214cac71197b5e3bf662012121664e6d5bb6 -size 6303130 +oid sha256:0f6837ba8638026250669887992c1974aac62ef6365ede9920b03fac1ad39e59 +size 6303496 From 194e8ae4404d6f4fbfa5c6afe7932a7c922977c1 Mon Sep 17 00:00:00 2001 From: fang Date: Wed, 25 Nov 2020 16:49:17 +0100 Subject: [PATCH 772/933] hoon: remove += and +- arm syntax --- pkg/arvo/lib/bip32.hoon | 2 +- pkg/arvo/lib/primitive-rsa.hoon | 2 +- pkg/arvo/sur/asn1.hoon | 4 ++-- pkg/arvo/sur/keygen.hoon | 18 +++++++++--------- pkg/arvo/sys/hoon.hoon | 11 ++++------- pkg/arvo/sys/zuse.hoon | 16 ++++++++-------- pkg/arvo/ted/graph/restore.hoon | 4 ++-- 7 files changed, 27 insertions(+), 30 deletions(-) diff --git a/pkg/arvo/lib/bip32.hoon b/pkg/arvo/lib/bip32.hoon index f34b942800..527cb1558d 100644 --- a/pkg/arvo/lib/bip32.hoon +++ b/pkg/arvo/lib/bip32.hoon @@ -18,7 +18,7 @@ :: pif: parent fingerprint (4 bytes) |_ [prv=@ pub=point.ecc cad=@ dep=@ud ind=@ud pif=@] :: -+= keyc [key=@ cai=@] :: prv/pub key + chain code ++$ keyc [key=@ cai=@] :: prv/pub key + chain code :: :: elliptic curve operations and values :: diff --git a/pkg/arvo/lib/primitive-rsa.hoon b/pkg/arvo/lib/primitive-rsa.hoon index 98a4e03c82..599a9b9fa5 100644 --- a/pkg/arvo/lib/primitive-rsa.hoon +++ b/pkg/arvo/lib/primitive-rsa.hoon @@ -5,7 +5,7 @@ |% :: +key:rsa: rsa public or private key :: -+= key ++$ key $: :: pub: public parameters (n=modulus, e=pub-exponent) :: pub=[n=@ux e=@ux] diff --git a/pkg/arvo/sur/asn1.hoon b/pkg/arvo/sur/asn1.hoon index 980bf05948..348c07ebe3 100644 --- a/pkg/arvo/sur/asn1.hoon +++ b/pkg/arvo/sur/asn1.hoon @@ -9,14 +9,14 @@ :: :: Note that *explicit* implies *constructed* (ie, bit 5 is set in DER). :: -+= bespoke ++$ bespoke :: imp: & is implicit, | is explicit :: tag: 5 bits for the custom tag number :: [imp=? tag=@ud] :: +spec:asn1: minimal representations of basic ASN.1 types :: -+= spec ++$ spec $% :: %int: arbitrary-sized, unsigned integers :: :: Unsigned integers, represented as having a positive sign. diff --git a/pkg/arvo/sur/keygen.hoon b/pkg/arvo/sur/keygen.hoon index bae3f5a937..f897eee4ad 100644 --- a/pkg/arvo/sur/keygen.hoon +++ b/pkg/arvo/sur/keygen.hoon @@ -1,9 +1,9 @@ |% -+= revision @ud -+= nodetype tape -+= mnemonic tape ++$ revision @ud ++$ nodetype tape ++$ mnemonic tape :: -+= vault ++$ vault $: ownership=node voting=node management=node @@ -12,12 +12,12 @@ network=uode == :: -+= node [type=nodetype seed=mnemonic keys=wallet] -+= uode [revi=revision seed=@ux keys=edkeys] ++$ node [type=nodetype seed=mnemonic keys=wallet] ++$ uode [revi=revision seed=@ux keys=edkeys] :: -+= wallet [keys=[public=@ux private=@ux] addr=@ux chain=@ux] ++$ wallet [keys=[public=@ux private=@ux] addr=@ux chain=@ux] :: -+= edkeys [auth=keypair crypt=keypair] ++$ edkeys [auth=keypair crypt=keypair] :: -+= keypair [public=@ux secret=@ux] ++$ keypair [public=@ux secret=@ux] -- diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 391f2398ff..87e300cc25 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -12642,11 +12642,11 @@ :: (stag %code (ifix [tic tic] (calf tic))) :: - :: ++arm, +-arm, +$arm, +*arm, ++arm:core, ... + :: ++arm, +$arm, +*arm, ++arm:core, ... :: %+ stag %code ;~ plug - lus ;~(pose lus hep buc tar) + lus ;~(pose lus buc tar) low (star ;~(pose nud low hep col)) == :: @@ -13375,10 +13375,7 @@ ++ boog !: :: core arms %+ knee [p=*term q=*hoon] |. ~+ ;~ pose - ;~ pfix ;~ pose - (jest '++') - (jest '+-') :: XX deprecated - == + ;~ pfix (jest '++') ;~ plug ;~(pfix gap ;~(pose (cold %$ buc) sym)) ;~(pfix gap loaf) @@ -13388,7 +13385,7 @@ %+ cook |= {b/term d/spec} [b [%ktcl [%name b d]]] - ;~ pfix ;~(pose (jest '+=') (jest '+$')) + ;~ pfix (jest '+$') ;~ plug ;~(pfix gap sym) ;~(pfix gap loan) diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index 6809f73081..329fc76590 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -121,7 +121,7 @@ ++ address @ux :: event location :: - += event-id [block=@ud log=@ud] + +$ event-id [block=@ud log=@ud] :: ++ events (set event-id) -- @@ -161,7 +161,7 @@ == == :: - += dnses [pri=@t sec=@t ter=@t] + +$ dnses [pri=@t sec=@t ter=@t] :: ++ diff-azimuth $% [%point who=@p dif=diff-point] @@ -1575,7 +1575,7 @@ :: Used on both the proxy (ward) and upstream sides for :: sending/receiving proxied-request notifications. :: - += prox + +$ prox $: :: por: tcp port :: por=@ud @@ -1970,7 +1970,7 @@ :: +$ seed [who=ship lyf=life key=ring sig=(unit oath:pki)] :: - += task :: in request ->$ + +$ task :: in request ->$ $~ [%vega ~] :: $% [%dawn dawn-event] :: boot from keys [%fake =ship] :: fake boot @@ -4218,9 +4218,9 @@ as-octs=as-octs:mimes:html ~% %secp +< ~ |% - += jacobian [x=@ y=@ z=@] :: jacobian point - += point [x=@ y=@] :: curve point - += domain + +$ jacobian [x=@ y=@ z=@] :: jacobian point + +$ point [x=@ y=@] :: curve point + +$ domain $: p=@ :: prime modulo a=@ :: y^2=x^3+ax+b b=@ :: @@ -4695,7 +4695,7 @@ :: :: structures :: - += argon-type ?(%d %i %id %u) + +$ argon-type ?(%d %i %id %u) :: :: shorthands :: diff --git a/pkg/arvo/ted/graph/restore.hoon b/pkg/arvo/ted/graph/restore.hoon index 96e570081c..5ed59534fd 100644 --- a/pkg/arvo/ted/graph/restore.hoon +++ b/pkg/arvo/ted/graph/restore.hoon @@ -1,7 +1,7 @@ /- spider, graph=graph-store, *metadata-store, *group, group-store /+ strandio, resource, graph-view => -|% +|% ++ strand strand:spider ++ poke poke:strandio ++ poke-our poke-our:strandio @@ -11,7 +11,7 @@ |= arg=vase =/ m (strand ,vase) ^- form:m -+= !< +=+ !< [[rid=resource title=@t description=@t group=resource module=@t ~] ~] arg ;< =bowl:spider bind:m get-bowl:strandio From a6e7af38d519cc15d88c2534b1074d5f778558c8 Mon Sep 17 00:00:00 2001 From: fang Date: Wed, 25 Nov 2020 20:39:13 +0100 Subject: [PATCH 773/933] various: move away from $constant type syntax --- pkg/arvo/app/dojo.hoon | 240 +- pkg/arvo/gen/acme/domain-validation.hoon | 2 +- pkg/arvo/gen/cat.hoon | 2 +- pkg/arvo/gen/frontpage.hoon | 2 +- pkg/arvo/gen/help.hoon | 2 +- pkg/arvo/gen/hood/init-oauth2.hoon | 2 +- pkg/arvo/gen/hood/init-oauth2/google.hoon | 2 +- pkg/arvo/gen/hood/merge.hoon | 4 +- pkg/arvo/gen/hood/moon-breach.hoon | 4 +- pkg/arvo/gen/hood/moon-cycle-keys.hoon | 4 +- pkg/arvo/gen/hood/moon.hoon | 4 +- pkg/arvo/gen/hood/private.hoon | 2 +- pkg/arvo/gen/hood/public.hoon | 2 +- pkg/arvo/gen/ls.hoon | 2 +- pkg/arvo/lib/contact-json.hoon | 2 +- pkg/arvo/lib/cram.hoon | 22 +- pkg/arvo/lib/elem-to-react-json.hoon | 2 +- pkg/arvo/lib/generators.hoon | 2 +- pkg/arvo/lib/graph-store.hoon | 6 +- pkg/arvo/lib/group-store.hoon | 6 +- pkg/arvo/lib/hood/drum.hoon | 174 +- pkg/arvo/lib/hood/kiln.hoon | 26 +- pkg/arvo/lib/jose.hoon | 12 +- pkg/arvo/lib/language-server/easy-print.hoon | 166 +- pkg/arvo/lib/metadata-json.hoon | 2 +- pkg/arvo/lib/pill.hoon | 6 +- pkg/arvo/lib/show-dir.hoon | 2 +- pkg/arvo/lib/sole.hoon | 46 +- pkg/arvo/lib/soto.hoon | 26 +- pkg/arvo/lib/urb-split.hoon | 4 +- pkg/arvo/mar/dill/belt.hoon | 22 +- pkg/arvo/mar/dill/blit.hoon | 8 +- pkg/arvo/mar/html.hoon | 2 +- pkg/arvo/mar/json/rpc/response.hoon | 2 +- pkg/arvo/mar/snip.hoon | 6 +- pkg/arvo/mar/sole/effect.hoon | 26 +- pkg/arvo/mar/xml.hoon | 2 +- pkg/arvo/sur/kyev.hoon | 8 +- pkg/arvo/sur/lens.hoon | 46 +- pkg/arvo/sur/rw-security.hoon | 8 +- pkg/arvo/sur/sole.hoon | 56 +- pkg/arvo/sys/arvo.hoon | 2 +- pkg/arvo/sys/hoon.hoon | 2108 +++++++++--------- pkg/arvo/sys/vane/clay.hoon | 98 +- pkg/arvo/sys/vane/dill.hoon | 68 +- pkg/arvo/sys/vane/jael.hoon | 18 +- pkg/arvo/sys/zuse.hoon | 398 ++-- 47 files changed, 1828 insertions(+), 1828 deletions(-) diff --git a/pkg/arvo/app/dojo.hoon b/pkg/arvo/app/dojo.hoon index 31bb7a4dda..413e55da87 100644 --- a/pkg/arvo/app/dojo.hoon +++ b/pkg/arvo/app/dojo.hoon @@ -12,7 +12,7 @@ => |% :: external structures ++ id @tasession :: session id ++ house :: all state - $: $6 + $: %6 egg/@u :: command count hoc/(map id session) :: conversations acl/(set ship) :: remote access whitelist @@ -42,20 +42,20 @@ == :: ++ dojo-command :: $^ (pair dojo-sink dojo-source) :: route value - {$brev p/term} :: unbind variable + {%brev p/term} :: unbind variable :: ++ dojo-sink :: - $% {$flat p/path} :: atom to unix - {$pill p/path} :: noun to unix pill - :: {$tree p/path} :: noun to unix tree - {$file p/beam} :: save to clay - $: $http :: http outbound - p/?($post $put) + $% {%flat p/path} :: atom to unix + {%pill p/path} :: noun to unix pill + :: {%tree p/path} :: noun to unix tree + {%file p/beam} :: save to clay + $: %http :: http outbound + p/?(%post %put) r/@t == - {$poke p/goal} :: poke app - {$show p/?($0 $1 $2 $3 $4 $5)} :: val/type/hoon/xray - {$verb p/term} :: store variable + {%poke p/goal} :: poke app + {%show p/?(%0 %1 %2 %3 %4 %5)} :: val/type/hoon/xray + {%verb p/term} :: store variable == :: ++ dojo-source :: construction node $: p/@ud :: assembly index @@ -63,15 +63,15 @@ == :: ++ dojo-build :: one arvo step $~ [%ex *hoon] - $% {$ur p/@t} :: http GET request - {$ge p/dojo-model} :: generator - {$te p/term q/(list dojo-source)} :: thread - {$dv p/path} :: core from source - {$ex p/hoon} :: hoon expression - {$sa p/mark} :: example mark value - {$as p/mark q/dojo-source} :: simple transmute - {$do p/hoon q/dojo-source} :: gate apply - {$tu p/(list dojo-source)} :: tuple + $% {%ur p/@t} :: http GET request + {%ge p/dojo-model} :: generator + {%te p/term q/(list dojo-source)} :: thread + {%dv p/path} :: core from source + {%ex p/hoon} :: hoon expression + {%sa p/mark} :: example mark value + {%as p/mark q/dojo-source} :: simple transmute + {%do p/hoon q/dojo-source} :: gate apply + {%tu p/(list dojo-source)} :: tuple == :: ++ dojo-model :: data construction $: p/dojo-server :: core source @@ -183,7 +183,7 @@ ;~(plug (cold %pill dot) (most fas sym)) ;~(plug (cold %http lus) (stag %post parse-url)) ;~(plug (cold %http hep) (stag %put parse-url)) - (stag %show (cook $?($1 $2 $3 $4 $5) (cook lent (stun [1 5] wut)))) + (stag %show (cook $?(%1 %2 %3 %4 %5) (cook lent (stun [1 5] wut)))) == :: ++ parse-cables @@ -382,7 +382,7 @@ ^+ [mad +>] ?@ -.mad [mad +>.$] =. q.mad - ?+(-.p.mad q.mad $http [0 %as %mime q.mad]) + ?+(-.p.mad q.mad %http [0 %as %mime q.mad]) =^ src +>.$ (dy-init-source q.mad) [mad(q src) +>.$] :: @@ -406,15 +406,15 @@ |= bul/dojo-build ^+ [bul +>] ?- -.bul - $ex [bul +>.$] - $dv [bul +>.$] - $sa [bul +>.$] - $as =^(mor +>.$ (dy-init-source q.bul) [bul(q mor) +>.$]) - $do =^(mor +>.$ (dy-init-source q.bul) [bul(q mor) +>.$]) - $ge =^(mod +>.$ (dy-init-model p.bul) [[%ge mod] +>.$]) - $te =^(mod +>.$ (dy-init-ordered q.bul) [bul(q mod) +>.$]) - $ur [bul +>.$] - $tu =^(dof +>.$ (dy-init-ordered p.bul) [[%tu dof] +>.$]) + %ex [bul +>.$] + %dv [bul +>.$] + %sa [bul +>.$] + %as =^(mor +>.$ (dy-init-source q.bul) [bul(q mor) +>.$]) + %do =^(mor +>.$ (dy-init-source q.bul) [bul(q mor) +>.$]) + %ge =^(mod +>.$ (dy-init-model p.bul) [[%ge mod] +>.$]) + %te =^(mod +>.$ (dy-init-ordered q.bul) [bul(q mod) +>.$]) + %ur [bul +>.$] + %tu =^(dof +>.$ (dy-init-ordered p.bul) [[%tu dof] +>.$]) == :: ++ dy-init-model :: ++dojo-model @@ -476,7 +476,7 @@ ?> ?=(^ per) ?: ?| ?=(^ q.q.cag) =((lent buf.say) q.q.cag) - !&(?=($del -.u.per) =(+(p.u.per) (lent buf.say))) + !&(?=(%del -.u.per) =(+(p.u.per) (lent buf.say))) == dy-abet(per ~) (dy-errd(per ~) per q.q.cag) @@ -503,40 +503,40 @@ ^+ +> :: XX needs filter :: - ?: ?=({$show $3} -.mad) + ?: ?=({%show %3} -.mad) (dy-rash %tan (dy-show-source q.mad) ~) - ?: ?=($brev -.mad) + ?: ?=(%brev -.mad) =. var (~(del by var) p.mad) =< dy-amok ?+ p.mad . - $?($eny $now $our) !! - $lib .(lib ~) - $sur .(sur ~) - $dir .(dir [[our.hid %home ud+0] /]) + $?(%eny %now %our) !! + %lib .(lib ~) + %sur .(sur ~) + %dir .(dir [[our.hid %home ud+0] /]) == =+ cay=(~(got by rez) p.q.mad) ?- -.p.mad - $verb + %verb =. var (~(put by var) p.p.mad cay) ~| bad-set+[p.p.mad p.q.cay] =< dy-amok ?+ p.p.mad . - $eny ~|(%entropy-is-eternal !!) - $now ~|(%time-is-immutable !!) - $our ~|(%self-is-immutable !!) - $lib + %eny ~|(%entropy-is-eternal !!) + %now ~|(%time-is-immutable !!) + %our ~|(%self-is-immutable !!) + %lib %_ . lib ((dy-cast (list cable:clay) !>(*(list cable:clay))) q.cay) == :: - $sur + %sur %_ . sur ((dy-cast (list cable:clay) !>(*(list cable:clay))) q.cay) == :: - $dir =+ ^= pax ^- path + %dir =+ ^= pax ^- path =+ pax=((dy-cast path !>(*path)) q.cay) ?: ?=(~ pax) ~[(scot %p our.hid) %home '0'] ?: ?=({@ ~} pax) ~[i.pax %home '0'] @@ -547,7 +547,7 @@ rose+[" " `~]^~[leaf+"=%" (smyt (en-beam:format he-beak s.dir))] == :: - $poke + %poke %- he-card(poy ~) :* %pass /poke @@ -557,22 +557,22 @@ cay == :: - $file + %file %- he-card(poy ~) :* %pass /file %arvo %c %info (foal:space:userlib (en-beam:format p.p.mad) cay) == :: - $flat + %flat ?^ q.q.cay (dy-rash %tan [%leaf "not an atom"]~) (dy-rash %sav p.p.mad q.q.cay) :: - $pill + %pill (dy-rash %sag p.p.mad q.q.cay) :: - $http - ?> ?=($mime p.cay) + %http + ?> ?=(%mime p.cay) =+ mim=;;(mime q.q.cay) %+ dy-request /show :* ?:(=(%put p.p.mad) %'PUT' %'POST') @@ -581,7 +581,7 @@ `q.mim == :: - $show + %show |^ (prnt cay note) ++ prnt ?: (gte p.p.mad 4) dy-xprint @@ -609,8 +609,8 @@ %+ dy-rash %tan %- welp :_ tan ?+ p.cay [(xsell q.cay)]~ - $tang ;;(tang q.q.cay) - $httr + %tang ;;(tang q.q.cay) + %httr =+ hit=;;(httr:eyre q.q.cay) =- (flop (turn `wall`- |=(a/tape leaf+(dash:us a '' ~)))) :- "HTTP {}" @@ -627,8 +627,8 @@ %+ dy-rash %tan %- welp :_ tan ?+ p.cay [(sell q.cay)]~ - $tang ;;(tang q.q.cay) - $httr + %tang ;;(tang q.q.cay) + %httr =+ hit=;;(httr:eyre q.q.cay) =- (flop (turn `wall`- |=(a/tape leaf+(dash:us a '' ~)))) :- "HTTP {}" @@ -640,22 +640,22 @@ ++ dy-show-type-noun |= a/type ^- tank =- >[-]< - |- ^- $? $% {$atom @tas (unit @)} - {$cell _$ _$} - {$face $@(term tune) _$} - {$fork (set _$)} - {$hold _$ hoon} + |- ^- $? $% {%atom @tas (unit @)} + {%cell _$ _$} + {%face $@(term tune) _$} + {%fork (set _$)} + {%hold _$ hoon} == wain :: "<|core|>" - $?($noun $void) + $?(%noun %void) == ?+ a a - {$face ^} a(q $(a q.a)) - {$cell ^} a(p $(a p.a), q $(a q.a)) - {$fork *} a(p (silt (turn ~(tap in p.a) |=(b/type ^$(a b))))) - {$hint *} !! - {$core ^} `wain`/core - {$hold *} a(p $(a p.a)) + {%face ^} a(q $(a q.a)) + {%cell ^} a(p $(a p.a), q $(a q.a)) + {%fork *} a(p (silt (turn ~(tap in p.a) |=(b/type ^$(a b))))) + {%hint *} !! + {%core ^} `wain`/core + {%hold *} a(p $(a p.a)) == :: :: XX needs filter @@ -669,13 +669,13 @@ ;: jank-bucwut hoon $^ {dy-shown dy-shown} - $% {$ur cord} - {$sa mark} - {$as mark dy-shown} - {$do hoon dy-shown} - {$te term (list dy-shown)} - {$ge path (list dy-shown) (map term (unit dy-shown))} - {$dv path} + $% {%ur cord} + {%sa mark} + {%as mark dy-shown} + {%do hoon dy-shown} + {%te term (list dy-shown)} + {%ge path (list dy-shown) (map term (unit dy-shown))} + {%dv path} == == :: @@ -685,20 +685,20 @@ =+ `{@ bil/dojo-build}`a |- ^- dy-shown ?- -.bil - $?($ur $dv $sa) bil - $ex ?. ?=({$cltr *} p.bil) p.bil + $?(%ur %dv %sa) bil + %ex ?. ?=({%cltr *} p.bil) p.bil |- ^- hoon ?~ p.p.bil !! ?~ t.p.p.bil i.p.p.bil [i.p.p.bil $(p.p.bil t.p.p.bil)] - $tu ?~ p.bil !! + %tu ?~ p.bil !! |- ?~ t.p.bil ^$(bil q.i.p.bil) [^$(bil q.i.p.bil) $(p.bil t.p.bil)] - $as bil(q $(bil q.q.bil)) - $do bil(q $(bil q.q.bil)) - $te bil(q (turn q.bil ..$)) - $ge :+ %ge q.p.p.bil + %as bil(q $(bil q.q.bil)) + %do bil(q $(bil q.q.bil)) + %te bil(q (turn q.bil ..$)) + %ge :+ %ge q.p.p.bil [(turn p.q.p.bil ..$) (~(run by q.q.p.bil) (lift ..$))] == :: @@ -720,10 +720,10 @@ ++ dy-type :: sole action |= act/sole-action ?- -.dat.act - $det (dy-edit +.dat.act) - $ret (dy-done (tufa buf.say)) - $clr dy-stop - $tab +>+> + %det (dy-edit +.dat.act) + %ret (dy-done (tufa buf.say)) + %clr dy-stop + %tab +>+> == :: ++ dy-cage |=(num/@ud (~(got by rez) num)) :: known cage @@ -897,13 +897,13 @@ ++ dy-hoon-var =+ ^= ope |= gen/hoon ^- hoon - ?: ?=(?($sggl $sggr) -.gen) + ?: ?=(?(%sggl %sggr) -.gen) $(gen q.gen) =+ ~(open ap gen) ?.(=(gen -) $(gen -) gen) |= gen/hoon ^- (unit cage) =. gen (ope gen) - ?: ?=({$cnts {@ ~} ~} gen) + ?: ?=({%cnts {@ ~} ~} gen) (~(get by var) i.p.gen) ~ :: +dy-mere: execute hoon and complete construction step @@ -1036,7 +1036,7 @@ ++ he-unto :: result from agent |= {way/wire cit/sign:agent:gall} ^+ +> - ?. ?=($poke-ack -.cit) + ?. ?=(%poke-ack -.cit) ~& [%strange-unto cit] +> ?~ p.cit @@ -1087,8 +1087,8 @@ %. [%httr !>((to-httr:iris response-header.response full-file.response))] =+ dye=~(. dy u.poy(pux ~)) ?+ way !! - {$hand ~} dy-hand:dye - {$show ~} dy-show:dye + {%hand ~} dy-hand:dye + {%show ~} dy-show:dye == :: ++ he-lens @@ -1096,7 +1096,7 @@ ^+ +> =/ source=dojo-source =| num/@ - =- ?. ?=($send-api -.sink.com) :: XX num is incorrect + =- ?. ?=(%send-api -.sink.com) :: XX num is incorrect sor :- 0 :+ %as `mark`(cat 3 api.sink.com '-poke') @@ -1112,12 +1112,12 @@ |- ^- dojo-source :- num ?- -.source.com - $data [%ex %sand %t data.source.com] - $dojo + %data [%ex %sand %t data.source.com] + %dojo %+ rash command.source.com (ifix [(punt gap) (punt gap)] parse-build:he-parser) :: - $clay + %clay :- %ex ^- hoon :+ %dtkt @@ -1127,9 +1127,9 @@ %+ rash pax.source.com rood:(vang | /(scot %p our.hid)/home/(scot %da now.hid)) :: - $url [%ur (crip (en-purl:html url.source.com))] - $api !! - $get-api + %url [%ur (crip (en-purl:html url.source.com))] + %api !! + %get-api :- %ex ^- hoon :+ %dtkt @@ -1142,24 +1142,24 @@ (turn endpoint.source.com |=(a/@t [%sand %ta a])) == :: - $listen-api !! - $export !! - $import !! - $export-all !! - $import-all !! - $as + %listen-api !! + %export !! + %import !! + %export-all !! + %import-all !! + %as :* %as mar.source.com $(num +(num), source.com next.source.com) == :: - $hoon + %hoon :* %do %+ rash code.source.com tall:(vang | /(scot %p our.hid)/home/(scot %da now.hid)) $(num +(num), source.com next.source.com) == :: - $tuple + %tuple :- %tu |- ^- (list dojo-source) ?~ next.source.com @@ -1170,15 +1170,15 @@ == =+ |- ^- sink/dojo-sink ?- -.sink.com - $stdout [%show %0] - $output-file $(sink.com [%command (cat 3 '@' pax.sink.com)]) - $output-pill $(sink.com [%command (cat 3 '.' pax.sink.com)]) - $output-clay [%file (need (de-beam:format pax.sink.com))] - $url [%http %post (crip (en-purl:html url.sink.com))] - $to-api !! - $send-api [%poke our.hid api.sink.com] - $command (rash command.sink.com parse-sink:he-parser) - $app [%poke our.hid app.sink.com] + %stdout [%show %0] + %output-file $(sink.com [%command (cat 3 '@' pax.sink.com)]) + %output-pill $(sink.com [%command (cat 3 '.' pax.sink.com)]) + %output-clay [%file (need (de-beam:format pax.sink.com))] + %url [%http %post (crip (en-purl:html url.sink.com))] + %to-api !! + %send-api [%poke our.hid api.sink.com] + %command (rash command.sink.com parse-sink:he-parser) + %app [%poke our.hid app.sink.com] == (he-plan sink source) :: @@ -1192,7 +1192,7 @@ :: ~& [%his-clock ler.cal] :: ~& [%our-clock ven.say] =^ dat say (~(transceive sole say) cal) - ?. ?& ?=($del -.dat) + ?. ?& ?=(%del -.dat) =(+(p.dat) (lent buf.say)) == +>.$ @@ -1436,10 +1436,10 @@ ?^ poy he-pine:(~(dy-type dy u.poy) act) ?- -.dat.act - $det (he-stir +.dat.act) - $ret (he-done (tufa buf.say)) - $clr he-pine(buf "") - $tab (he-tab +.dat.act) + %det (he-stir +.dat.act) + %ret (he-done (tufa buf.say)) + %clr he-pine(buf "") + %tab (he-tab +.dat.act) == :: ++ he-lame :: handle error diff --git a/pkg/arvo/gen/acme/domain-validation.hoon b/pkg/arvo/gen/acme/domain-validation.hoon index 477317e810..998fa9c7f6 100644 --- a/pkg/arvo/gen/acme/domain-validation.hoon +++ b/pkg/arvo/gen/acme/domain-validation.hoon @@ -1,6 +1,6 @@ :: :acme domain validation request handler :: -|= [[now=@da eny=@ bek=beak] $~ $~] +|= [[now=@da eny=@ bek=beak] ~ ~] |= [authorized=? =request:http] ^- simple-payload:http =/ url=(unit (pair pork:eyre quay:eyre)) diff --git a/pkg/arvo/gen/cat.hoon b/pkg/arvo/gen/cat.hoon index 04051b129c..142da21578 100644 --- a/pkg/arvo/gen/cat.hoon +++ b/pkg/arvo/gen/cat.hoon @@ -8,7 +8,7 @@ :::: :: :- %say -|= {^ {arg/(list path)} vane/?($g $c)} +|= {^ {arg/(list path)} vane/?(%g %c)} =- tang+(flop `tang`(zing -)) %+ turn arg |= pax/path diff --git a/pkg/arvo/gen/frontpage.hoon b/pkg/arvo/gen/frontpage.hoon index 342a2b370c..5e3203f6fe 100644 --- a/pkg/arvo/gen/frontpage.hoon +++ b/pkg/arvo/gen/frontpage.hoon @@ -2,7 +2,7 @@ :: :: outer gate is a standard generator :: -|= [[now=@da eny=@ bek=beak] $~ $~] +|= [[now=@da eny=@ bek=beak] ~ ~] :: :: :- %build |= [authorized=? request:http] diff --git a/pkg/arvo/gen/help.hoon b/pkg/arvo/gen/help.hoon index 7846ab5ae5..858886039f 100644 --- a/pkg/arvo/gen/help.hoon +++ b/pkg/arvo/gen/help.hoon @@ -22,7 +22,7 @@ [%palm [" {(reap tab ' ')}" ``~] leaf+p.c leaf+q.c ~] :- ?- b ~ "/" :: XX !! maybe? - {$hood ^} "|{(path-heps t.b)}" + {%hood ^} "|{(path-heps t.b)}" ^ "+{(path-heps b)}" :: XX deal with :graph-store|foo == =/ c (to-wain:format a) diff --git a/pkg/arvo/gen/hood/init-oauth2.hoon b/pkg/arvo/gen/hood/init-oauth2.hoon index 093ffd840c..8251083f2e 100644 --- a/pkg/arvo/gen/hood/init-oauth2.hoon +++ b/pkg/arvo/gen/hood/init-oauth2.hoon @@ -14,7 +14,7 @@ {arg/$@(~ {dom/path ~})} ~ == -^- (sole-result:sole {$write-sec-atom p/host:eyre q/@}) +^- (sole-result:sole {%write-sec-atom p/host:eyre q/@}) =- ?~ arg - (fun.q.q [%& dom.arg]) %+ prompt diff --git a/pkg/arvo/gen/hood/init-oauth2/google.hoon b/pkg/arvo/gen/hood/init-oauth2/google.hoon index 02343b21de..6fcdc1d21e 100644 --- a/pkg/arvo/gen/hood/init-oauth2/google.hoon +++ b/pkg/arvo/gen/hood/init-oauth2/google.hoon @@ -16,7 +16,7 @@ {arg/$@(~ {jon/json ~})} ~ == -^- (sole-result:sole {$write-sec-atom p/host:eyre q/@}) +^- (sole-result:sole {%write-sec-atom p/host:eyre q/@}) %+ print leaf+"Accepting credentials for https://*.googleapis.com" =+ hot=[%& /com/googleapis] =- ?~ arg - diff --git a/pkg/arvo/gen/hood/merge.hoon b/pkg/arvo/gen/hood/merge.hoon index 98ae0e057c..95ef41657c 100644 --- a/pkg/arvo/gen/hood/merge.hoon +++ b/pkg/arvo/gen/hood/merge.hoon @@ -15,11 +15,11 @@ :: :- %say |= $: {now/@da eny/@uvJ bek/beak} - {arg/{?(~ sorc {syd/$@(desk beaky) sorc})} cas/case gem/?(germ $auto)} + {arg/{?(~ sorc {syd/$@(desk beaky) sorc})} cas/case gem/?(germ %auto)} == =* our p.bek |^ :- %kiln-merge - ^- $@(~ {syd/desk her/ship sud/desk cas/case gem/?(germ $auto)}) + ^- $@(~ {syd/desk her/ship sud/desk cas/case gem/?(germ %auto)}) ?- arg ~ ((slog (turn help-text |=(=@t leaf+(trip t)))) ~) {@ @ ~} diff --git a/pkg/arvo/gen/hood/moon-breach.hoon b/pkg/arvo/gen/hood/moon-breach.hoon index 64f81a467e..536dc651c5 100644 --- a/pkg/arvo/gen/hood/moon-breach.hoon +++ b/pkg/arvo/gen/hood/moon-breach.hoon @@ -16,9 +16,9 @@ ^- (unit [=ship =udiff:point:able:jael]) =* our p.bec =/ ran (clan:title our) -?: ?=({?($earl $pawn)} ran) +?: ?=({?(%earl %pawn)} ran) %- %- slog :_ ~ - leaf+"can't manage a moon from a {?:(?=($earl ran) "moon" "comet")}" + leaf+"can't manage a moon from a {?:(?=(%earl ran) "moon" "comet")}" ~ =/ seg=ship (sein:title our now mon) ?. =(our seg) diff --git a/pkg/arvo/gen/hood/moon-cycle-keys.hoon b/pkg/arvo/gen/hood/moon-cycle-keys.hoon index 38ca3d3643..5f8f12493f 100644 --- a/pkg/arvo/gen/hood/moon-cycle-keys.hoon +++ b/pkg/arvo/gen/hood/moon-cycle-keys.hoon @@ -17,9 +17,9 @@ ^- (unit [=ship =udiff:point:able:jael]) =* our p.bec =/ ran (clan:title our) -?: ?=({?($earl $pawn)} ran) +?: ?=({?(%earl %pawn)} ran) %- %- slog :_ ~ - leaf+"can't manage a moon from a {?:(?=($earl ran) "moon" "comet")}" + leaf+"can't manage a moon from a {?:(?=(%earl ran) "moon" "comet")}" ~ =/ seg=ship (sein:title our now mon) ?. =(our seg) diff --git a/pkg/arvo/gen/hood/moon.hoon b/pkg/arvo/gen/hood/moon.hoon index 98b79033ad..df32937210 100644 --- a/pkg/arvo/gen/hood/moon.hoon +++ b/pkg/arvo/gen/hood/moon.hoon @@ -16,9 +16,9 @@ ^- (unit [=ship =udiff:point:able:jael]) =* our p.bec =/ ran (clan:title our) -?: ?=({?($earl $pawn)} ran) +?: ?=({?(%earl %pawn)} ran) %- %- slog :_ ~ - leaf+"can't create a moon from a {?:(?=($earl ran) "moon" "comet")}" + leaf+"can't create a moon from a {?:(?=(%earl ran) "moon" "comet")}" ~ =/ mon=ship ?^ arg diff --git a/pkg/arvo/gen/hood/private.hoon b/pkg/arvo/gen/hood/private.hoon index bcfe62ff48..c60d0f4555 100644 --- a/pkg/arvo/gen/hood/private.hoon +++ b/pkg/arvo/gen/hood/private.hoon @@ -4,7 +4,7 @@ :: :- %say |= $: {now/@da eny/@uvJ bec/beak} - {arg/{des/desk may/?($~ {pax/path $~})} $~} + {arg/{des/desk may/?(~ {pax/path ~})} ~} == :- %kiln-permission [des ?~(may / pax.may) |]:arg diff --git a/pkg/arvo/gen/hood/public.hoon b/pkg/arvo/gen/hood/public.hoon index eea1bcba71..831d52b696 100644 --- a/pkg/arvo/gen/hood/public.hoon +++ b/pkg/arvo/gen/hood/public.hoon @@ -4,7 +4,7 @@ :: :- %say |= $: {now/@da eny/@uvJ bec/beak} - {arg/{des/desk may/?($~ {pax/path $~})} $~} + {arg/{des/desk may/?(~ {pax/path ~})} ~} == :- %kiln-permission [des ?~(may / pax.may) &]:arg diff --git a/pkg/arvo/gen/ls.hoon b/pkg/arvo/gen/ls.hoon index c691be6e1a..a3954cae3d 100644 --- a/pkg/arvo/gen/ls.hoon +++ b/pkg/arvo/gen/ls.hoon @@ -9,6 +9,6 @@ :: ~& % :- %say -|= {^ {arg/path ~} vane/?($g $c)} +|= {^ {arg/path ~} vane/?(%g %c)} =+ lon=.^(arch (cat 3 vane %y) arg) tang+[?~(dir.lon leaf+"~" (show-dir vane arg dir.lon))]~ diff --git a/pkg/arvo/lib/contact-json.hoon b/pkg/arvo/lib/contact-json.hoon index c12d62b157..4891cdbc64 100644 --- a/pkg/arvo/lib/contact-json.hoon +++ b/pkg/arvo/lib/contact-json.hoon @@ -3,7 +3,7 @@ |% ++ nu :: parse number as hex |= jon/json - ?> ?=({$s *} jon) + ?> ?=({%s *} jon) (rash p.jon hex) :: ++ hook-update-to-json diff --git a/pkg/arvo/lib/cram.hoon b/pkg/arvo/lib/cram.hoon index ebed968649..3c41eae362 100644 --- a/pkg/arvo/lib/cram.hoon +++ b/pkg/arvo/lib/cram.hoon @@ -6,7 +6,7 @@ ?: =(gen ^gen) ~|([%cram-dynamic -.gen] !!) $(gen gen) :: - $xray [~ (single (shut gen))] + %xray [~ (single (shut gen))] ^ [(malt (frontmatter p.gen)) (single (shut q.gen))] == :: @@ -21,28 +21,28 @@ ++ shut :: as xml constant |= gen/hoon ^- marl ?+ -.gen ~|([%bad-xml -.gen] !!) - $dbug $(gen q.gen) + %dbug $(gen q.gen) :: - $xray + %xray [[n.g.p.gen (turn a.g.p.gen shut-mart)] $(gen [%mcts c.p.gen])]~ :: - $mcts + %mcts ?~ p.gen ~ =- (weld - $(p.gen t.p.gen)) ?^ -.i.p.gen $(gen [%xray i.p.gen]) ~| [%shut-tuna -.i.p.gen] ?+ -.i.p.gen !! - $manx ?>(?=($xray -.p.i.p.gen) $(gen p.i.p.gen)) - $marl ?>(?=($mcts -.p.i.p.gen) $(gen p.i.p.gen)) + %manx ?>(?=(%xray -.p.i.p.gen) $(gen p.i.p.gen)) + %marl ?>(?=(%mcts -.p.i.p.gen) $(gen p.i.p.gen)) == == :: :: ++ frontmatter :: parse ~[[%foo 1] [%bar ~s2]] |= gen/hoon ^- (list {term dime}) - ?: ?=({$bust $null} gen) ~ - ?: ?=($dbug -.gen) $(gen q.gen) - ?. ?=($clsg -.gen) ~|([%bad-frontmatter -.gen] !!) + ?: ?=({%bust %null} gen) ~ + ?: ?=(%dbug -.gen) $(gen q.gen) + ?. ?=(%clsg -.gen) ~|([%bad-frontmatter -.gen] !!) %+ turn p.gen |= gen/hoon ?. ?=(^ -.gen) @@ -55,7 +55,7 @@ :: ++ as-dime :: %foo ~.foo 0vbar etc |= gen/hoon ^- dime - ?: ?=($dbug -.gen) $(gen q.gen) - ?. ?=({?($rock $sand) @ @} gen) ~|([%bad-literal gen] !!) + ?: ?=(%dbug -.gen) $(gen q.gen) + ?. ?=({?(%rock %sand) @ @} gen) ~|([%bad-literal gen] !!) +.gen -- diff --git a/pkg/arvo/lib/elem-to-react-json.hoon b/pkg/arvo/lib/elem-to-react-json.hoon index da742e1bf4..cad7f25a39 100644 --- a/pkg/arvo/lib/elem-to-react-json.hoon +++ b/pkg/arvo/lib/elem-to-react-json.hoon @@ -28,7 +28,7 @@ :: special handling for
foo
++ urb-codemirror :: render code blocks |= src/manx ^- manx - ?> ?=({{$pre *} _;/(**) ~} src) + ?> ?=({{%pre *} _;/(**) ~} src) ;codemirror(value "{v.i.a.g.i.c.src}"); :: ++ elem-to-react-json :: serialize DOM as json diff --git a/pkg/arvo/lib/generators.hoon b/pkg/arvo/lib/generators.hoon index 082d229ba0..8b8042e177 100644 --- a/pkg/arvo/lib/generators.hoon +++ b/pkg/arvo/lib/generators.hoon @@ -27,7 +27,7 @@ |* {sef/rule fun/$-(* *)} :: |= txt/sole-input :: =+ vex=(sef [0 0] txt) :: - ?: |(!=((lent txt) q.p.vex) ?=($~ q.vex)) :: + ?: |(!=((lent txt) q.p.vex) ?=(~ q.vex)) :: q.p.vex :: (fun p.u.q.vex) :: -- diff --git a/pkg/arvo/lib/graph-store.hoon b/pkg/arvo/lib/graph-store.hoon index a6055bb105..037565a7d8 100644 --- a/pkg/arvo/lib/graph-store.hoon +++ b/pkg/arvo/lib/graph-store.hoon @@ -8,7 +8,7 @@ :: NOTE: move these functions to zuse ++ nu :: parse number as hex |= jon/json - ?> ?=({$s *} jon) + ?> ?=({%s *} jon) (rash p.jon hex) :: ++ re :: recursive reparsers @@ -319,7 +319,7 @@ ++ post %- ot :~ [%author (su ;~(pfix sig fed:ag))] - [%index index] + [%index index] [%time-sent di] [%contents (ar content)] [%hash (mu nu)] @@ -375,7 +375,7 @@ ++ uid %- ot :~ [%resource dejs:res] - [%index index] + [%index index] == :: ++ index (su ;~(pfix fas (more fas dem))) diff --git a/pkg/arvo/lib/group-store.hoon b/pkg/arvo/lib/group-store.hoon index 56e663301f..117b82ecbe 100644 --- a/pkg/arvo/lib/group-store.hoon +++ b/pkg/arvo/lib/group-store.hoon @@ -295,7 +295,7 @@ |= [a=(map @t json) b=$-(@t @t)] ^+ a =- (malt -) - |- + |- ^- (list [@t json]) ?~ a ~ :- [(b p.n.a) q.n.a] @@ -306,9 +306,9 @@ ++ of |* wer/(pole {cord fist}) |= jon/json - ?> ?=({$o {@ *} $~ $~} jon) + ?> ?=({%o {@ *} ~ ~} jon) |- - ?- wer + ?- wer :: {{key/@t wit/*} t/*} {{key/@t *} t/*} => .(wer [[* wit] *]=wer) diff --git a/pkg/arvo/lib/hood/drum.hoon b/pkg/arvo/lib/hood/drum.hoon index 84ddfa0f78..540ad5ca4f 100644 --- a/pkg/arvo/lib/hood/drum.hoon +++ b/pkg/arvo/lib/hood/drum.hoon @@ -458,12 +458,12 @@ ++ se-belt :: handle input |= bet/dill-belt:dill ^+ +> - ?: ?=({?($cru $hey $rez $yow) *} bet) :: target-agnostic + ?: ?=({?(%cru %hey %rez %yow) *} bet) :: target-agnostic ?- bet - {$cru *} (se-dump:(se-text (trip p.bet)) q.bet) - {$hey *} +>(mir [0 ~]) :: refresh - {$rez *} +>(edg (dec p.bet)) :: resize window - {$yow *} ~&([%no-yow -.bet] +>) + {%cru *} (se-dump:(se-text (trip p.bet)) q.bet) + {%hey *} +>(mir [0 ~]) :: refresh + {%rez *} +>(edg (dec p.bet)) :: resize window + {%yow *} ~&([%no-yow -.bet] +>) == =+ gul=se-agon ?: |(?=(~ gul) (se-aint u.gul)) @@ -651,21 +651,21 @@ ++ ta-id (cat 3 'drum_' (scot %p our.hid)) :: per-ship duct id :: ++ ta-aro :: hear arrow - |= key/?($d $l $r $u) + |= key/?(%d %l %r %u) ^+ +> =. ris ~ ?- key - $d ?. =(num.hit pos.hit) + %d ?. =(num.hit pos.hit) (ta-mov +(pos.hit)) ?: =(0 (lent buf.say.inp)) ta-bel (ta-hom:ta-nex %set ~) - $l ?: =(0 pos.inp) ta-bel + %l ?: =(0 pos.inp) ta-bel +>(pos.inp (dec pos.inp)) - $r ?: =((lent buf.say.inp) pos.inp) + %r ?: =((lent buf.say.inp) pos.inp) ta-bel +>(pos.inp +(pos.inp)) - $u ?:(=(0 pos.hit) ta-bel (ta-mov (dec pos.hit))) + %u ?:(=(0 pos.hit) ta-bel (ta-mov (dec pos.hit))) == :: ++ ta-bel :: beep @@ -674,16 +674,16 @@ ++ ta-belt :: handle input |= bet/dill-belt:dill ^+ +> - ?< ?=({?($cru $hey $rez $yow) *} bet) :: target-specific + ?< ?=({?(%cru %hey %rez %yow) *} bet) :: target-specific =. blt [q.blt `bet] :: remember belt ?- bet - {$aro *} (ta-aro p.bet) - {$bac *} ta-bac - {$ctl *} (ta-ctl p.bet) - {$del *} ta-del - {$met *} (ta-met p.bet) - {$ret *} ta-ret - {$txt *} (ta-txt p.bet) + {%aro *} (ta-aro p.bet) + {%bac *} ta-bac + {%ctl *} (ta-ctl p.bet) + {%del *} ta-del + {%met *} (ta-met p.bet) + {%ret *} ta-ret + {%txt *} (ta-txt p.bet) == :: ++ ta-det :: send edit @@ -709,48 +709,48 @@ ++ ta-ctl :: hear control |= key/@ud ^+ +> - =. ris ?.(?=(?($g $r) key) ~ ris) + =. ris ?.(?=(?(%g %r) key) ~ ris) ?+ key ta-bel - $a +>(pos.inp 0) - $b (ta-aro %l) - $c ta-bel - $d ?^ buf.say.inp + %a +>(pos.inp 0) + %b (ta-aro %l) + %c ta-bel + %d ?^ buf.say.inp ta-del ?: (~(has in (deft-fish our.hid)) gyl) +>(..ta (se-blit qit+~)) :: quit pier +>(..ta (se-klin gyl)) :: unlink app - $e +>(pos.inp (lent buf.say.inp)) - $f (ta-aro %r) - $g ?~ ris ta-bel + %e +>(pos.inp (lent buf.say.inp)) + %f (ta-aro %r) + %g ?~ ris ta-bel (ta-hom(pos.hit num.hit, ris ~) [%set ~]) - $i ta-tab - $k =+ len=(lent buf.say.inp) + %i ta-tab + %k =+ len=(lent buf.say.inp) ?: =(pos.inp len) ta-bel (ta-kil %r [pos.inp (sub len pos.inp)]) - $l +>(..ta (se-blit %clr ~)) - $n (ta-aro %d) - $p (ta-aro %u) - $r ?~ ris + %l +>(..ta (se-blit %clr ~)) + %n (ta-aro %d) + %p (ta-aro %u) + %r ?~ ris +>(ris `[pos.hit ~]) ?: =(0 pos.u.ris) ta-bel (ta-ser ~) - $t =+ len=(lent buf.say.inp) + %t =+ len=(lent buf.say.inp) ?: |(=(0 pos.inp) (lth len 2)) ta-bel =+ sop=(sub pos.inp ?:(=(len pos.inp) 2 1)) (ta-hom (rep:edit [sop 2] (flop (swag [sop 2] buf.say.inp)))) - $u ?: =(0 pos.inp) + %u ?: =(0 pos.inp) ta-bel (ta-kil %l [0 pos.inp]) - $v ta-bel - $w ?: =(0 pos.inp) + %v ta-bel + %w ?: =(0 pos.inp) ta-bel =+ sop=(ta-pos %l %ace pos.inp) (ta-kil %l [(sub pos.inp sop) sop]) - $x +>(..ta se-anon) - $y ?: =(0 num.kil) + %x +>(..ta se-anon) + %y ?: =(0 num.kil) ta-bel (ta-hom (cat:edit pos.inp ta-yan)) == @@ -773,23 +773,23 @@ |= fec/sole-effect ^+ +> ?- fec - {$bel *} ta-bel - {$blk *} +> - {$clr *} +>(..ta (se-blit fec)) - {$det *} (ta-got +.fec) - {$err *} (ta-err p.fec) - {$klr *} +>(..ta (se-blit %klr (make:klr p.fec))) - {$mor *} |- ^+ +>.^$ + {%bel *} ta-bel + {%blk *} +> + {%clr *} +>(..ta (se-blit fec)) + {%det *} (ta-got +.fec) + {%err *} (ta-err p.fec) + {%klr *} +>(..ta (se-blit %klr (make:klr p.fec))) + {%mor *} |- ^+ +>.^$ ?~ p.fec +>.^$ $(p.fec t.p.fec, +>.^$ ^$(fec i.p.fec)) - {$nex *} ta-nex - {$pro *} (ta-pro +.fec) - {$tab *} +>(..ta (se-tab p.fec)) - {$tan *} +>(..ta (se-dump p.fec)) - {$sag *} +>(..ta (se-blit fec)) - {$sav *} +>(..ta (se-blit fec)) - {$txt *} +>(..ta (se-text p.fec)) - {$url *} +>(..ta (se-blit fec)) + {%nex *} ta-nex + {%pro *} (ta-pro +.fec) + {%tab *} +>(..ta (se-tab p.fec)) + {%tan *} +>(..ta (se-dump p.fec)) + {%sag *} +>(..ta (se-blit fec)) + {%sav *} +>(..ta (se-blit fec)) + {%txt *} +>(..ta (se-text p.fec)) + {%url *} +>(..ta (se-blit fec)) == :: ++ ta-dog :: change cursor @@ -800,19 +800,19 @@ %+ min len |- ^- @ud ?- ted - {$del *} ?:((gth pos.inp p.ted) (dec pos.inp) pos.inp) - {$ins *} ?:((gte pos.inp p.ted) +(pos.inp) pos.inp) - {$mor *} |- ^- @ud + {%del *} ?:((gth pos.inp p.ted) (dec pos.inp) pos.inp) + {%ins *} ?:((gte pos.inp p.ted) +(pos.inp) pos.inp) + {%mor *} |- ^- @ud ?~ p.ted pos.inp $(p.ted t.p.ted, pos.inp ^$(ted i.p.ted)) - {$nop *} pos.inp - {$set *} len + {%nop *} pos.inp + {%set *} len == == :: ++ ta-off :: reset buffer offset |= ted/sole-edit - =? off (any:edit ted |=(a/sole-edit ?=($set -.a))) 0 + =? off (any:edit ted |=(a/sole-edit ?=(%set -.a))) 0 +> :: ++ ta-got :: apply change @@ -827,13 +827,13 @@ (ta-dog(say.inp (~(commit sole say.inp) ted)) ted) :: ++ ta-jump :: buffer pos - |= {dir/?($l $r) til/?($ace $edg $wrd) pos/@ud} + |= {dir/?(%l %r) til/?(%ace %edg %wrd) pos/@ud} ^- @ud - %- ?:(?=($l dir) sub add) + %- ?:(?=(%l dir) sub add) [pos (ta-pos dir til pos)] :: ++ ta-kil :: kill selection - |= {dir/?($l $r) sel/{@ @}} + |= {dir/?(%l %r) sel/{@ @}} ^+ +> =+ buf=(swag sel buf.say.inp) %. (cut:edit sel) @@ -841,8 +841,8 @@ kil ?. ?& ?=(^ old.kil) ?=(^ p.blt) - ?| ?=({$ctl ?($k $u $w)} u.p.blt) - ?=({$met ?($d $bac)} u.p.blt) + ?| ?=({%ctl ?(%k %u %w)} u.p.blt) + ?=({%met ?(%d %bac)} u.p.blt) == == %= kil :: prepend num +(num.kil) @@ -853,8 +853,8 @@ pos num.kil old :_ t.old.kil ?- dir - $l (welp buf i.old.kil) - $r (welp i.old.kil buf) + %l (welp buf i.old.kil) + %r (welp i.old.kil buf) == == == :: @@ -863,22 +863,22 @@ ^+ +> =. ris ~ ?+ key ta-bel - $dot ?. &(?=(^ old.hit) ?=(^ i.old.hit)) :: last "arg" from hist + %dot ?. &(?=(^ old.hit) ?=(^ i.old.hit)) :: last "arg" from hist ta-bel =+ old=`(list @c)`i.old.hit =+ sop=(ta-jump(buf.say.inp old) %l %ace (lent old)) (ta-hom (cat:edit pos.inp (slag sop old))) :: - $bac ?: =(0 pos.inp) :: kill left-word + %bac ?: =(0 pos.inp) :: kill left-word ta-bel =+ sop=(ta-pos %l %edg pos.inp) (ta-kil %l [(sub pos.inp sop) sop]) :: - $b ?: =(0 pos.inp) :: jump left-word + %b ?: =(0 pos.inp) :: jump left-word ta-bel +>(pos.inp (ta-jump %l %edg pos.inp)) :: - $c ?: =(pos.inp (lent buf.say.inp)) :: capitalize + %c ?: =(pos.inp (lent buf.say.inp)) :: capitalize ta-bel =+ sop=(ta-jump %r %wrd pos.inp) %- ta-hom(pos.inp (ta-jump %r %edg sop)) @@ -886,20 +886,20 @@ ^- (list @c) ^- (list @) :: XX unicode (cuss `tape``(list @)`(swag [sop 1] buf.say.inp)) :: - $d ?: =(pos.inp (lent buf.say.inp)) :: kill right-word + %d ?: =(pos.inp (lent buf.say.inp)) :: kill right-word ta-bel (ta-kil %r [pos.inp (ta-pos %r %edg pos.inp)]) :: - $f ?: =(pos.inp (lent buf.say.inp)) :: jump right-word + %f ?: =(pos.inp (lent buf.say.inp)) :: jump right-word ta-bel +>(pos.inp (ta-jump %r %edg pos.inp)) :: - $r %- ta-hom(lay.hit (~(put by lay.hit) pos.hit ~)) + %r %- ta-hom(lay.hit (~(put by lay.hit) pos.hit ~)) :- %set :: revert hist edit ?: =(pos.hit num.hit) ~ (snag (sub num.hit +(pos.hit)) old.hit) :: - $t =+ a=(ta-jump %r %edg pos.inp) :: transpose words + %t =+ a=(ta-jump %r %edg pos.inp) :: transpose words =+ b=(ta-jump %l %edg a) =+ c=(ta-jump %l %edg b) ?: =(b c) @@ -912,10 +912,10 @@ (rep:edit prev (swag next buf.say.inp)) == :: - ?($u $l) :: upper/lower case + ?(%u %l) :: upper/lower case ?: =(pos.inp (lent buf.say.inp)) ta-bel - =+ case=?:(?=($u key) cuss cass) + =+ case=?:(?=(%u key) cuss cass) =+ sop=(ta-jump %r %wrd pos.inp) =+ sel=[sop (ta-pos %r %edg sop)] %- ta-hom @@ -923,10 +923,10 @@ ^- (list @c) ^- (list @) :: XX unicode (case `tape``(list @)`(swag sel buf.say.inp)) :: - $y ?. ?& ?=(^ old.kil) :: rotate & yank + %y ?. ?& ?=(^ old.kil) :: rotate & yank ?=(^ p.blt) - ?| ?=({$ctl $y} u.p.blt) - ?=({$met $y} u.p.blt) + ?| ?=({%ctl %y} u.p.blt) + ?=({%met %y} u.p.blt) == == ta-bel =+ las=(lent ta-yan) @@ -961,14 +961,14 @@ == :: ++ ta-pos :: buffer pos offset - |= {dir/?($l $r) til/?($ace $edg $wrd) pos/@ud} + |= {dir/?(%l %r) til/?(%ace %edg %wrd) pos/@ud} ^- @ud - %- ?- til $ace ace:offset - $edg edg:offset - $wrd wrd:offset + %- ?- til %ace ace:offset + %edg edg:offset + %wrd wrd:offset == - ?- dir $l (flop (scag pos buf.say.inp)) - $r (slag pos buf.say.inp) + ?- dir %l (flop (scag pos buf.say.inp)) + %r (slag pos buf.say.inp) == :: ++ ta-pro :: set prompt @@ -978,7 +978,7 @@ %_ pom cad ;: welp - ?. ?=($earl (clan:title p.gyl)) + ?. ?=(%earl (clan:title p.gyl)) (cite:title p.gyl) (scow %p p.gyl) :: @@ -1065,7 +1065,7 @@ ++ any :: matches? |= {a/sole-edit b/$-(sole-edit ?)} ^- ? - ?. ?=($mor -.a) (b a) + ?. ?=(%mor -.a) (b a) (lien p.a |=(c/sole-edit ^$(a c))) -- ++ offset :: calculate offsets diff --git a/pkg/arvo/lib/hood/kiln.hoon b/pkg/arvo/lib/hood/kiln.hoon index be04366c7a..fc4572cdb3 100644 --- a/pkg/arvo/lib/hood/kiln.hoon +++ b/pkg/arvo/lib/hood/kiln.hoon @@ -271,7 +271,7 @@ =. ..abet (render-ket "OTA cancelled (1), retrying" ~) (poke-internal `[ship desk]:u.ota) =. ..abet (render-ket "downloading OTA update" ~) - =? aeon.u.ota ?=($w p.p.u.p.sign-arvo) + =? aeon.u.ota ?=(%w p.p.u.p.sign-arvo) ud:;;(cass:clay q.q.r.u.p.sign-arvo) %: emit %pass (make-wire /download) %arvo %c @@ -598,7 +598,7 @@ (render "on sync" sud her syd) ~ start-sync - =. let ?. ?=($w p.p.u.rot) let ud:;;(cass:clay q.q.r.u.rot) + =. let ?. ?=(%w p.p.u.rot) let ud:;;(cass:clay q.q.r.u.rot) =/ =wire /kiln/sync/merg/[syd]/(scot %p her)/[sud] :: germ: merge mode for sync merges :: @@ -648,7 +648,7 @@ q.p.mes == :: - $no-ali-disc + %no-ali-disc :~ (render "sync activated" sud her syd) leaf+"note: blank desk {} on {}" == @@ -685,7 +685,7 @@ (blab [%pass /kiln/[syd] %arvo %c [%merg syd her sud cas gem]] ~) :: ++ fancy-merge :: send to self - |= {syd/desk her/@p sud/desk gem/?($auto germ)} + |= {syd/desk her/@p sud/desk gem/?(%auto germ)} ^+ +> =/ =cage [%kiln-merge !>([syd her sud cas gem])] %- blab :_ ~ @@ -694,9 +694,9 @@ ++ spam ::|=(tang ((slog +<) ..spam)) |*(* +>(..work (^spam +<))) ++ merge - |= {her/@p sud/@tas cas/case gim/?($auto germ)} + |= {her/@p sud/@tas cas/case gim/?(%auto germ)} ^+ +> - ?. ?=($auto gim) + ?. ?=(%auto gim) perform(auto |, gem gim, her her, cas cas, sud sud) ?: =(0 ud:.^(cass:clay %cw /(scot %p our)/[syd]/(scot %da now))) => $(gim %init) @@ -786,27 +786,27 @@ ?+ gem (spam leaf+"strange auto" >gem< ~) :: - $init + %init =+ :- "auto merge failed on strategy %init" "I'm out of ideas" lose:(spam leaf+-< leaf+-> [>p.p.are< q.p.are]) :: - $fine - ?. ?=($bad-fine-merge p.p.are) + %fine + ?. ?=(%bad-fine-merge p.p.are) =+ "auto merge failed on strategy %fine" lose:(spam leaf+- >p.p.are< q.p.are) => (spam leaf+"%fine merge failed, trying %meet" ~) perform(gem %meet) :: - $meet - ?. ?=($meet-conflict p.p.are) + %meet + ?. ?=(%meet-conflict p.p.are) =+ "auto merge failed on strategy %meet" lose:(spam leaf+- >p.p.are< q.p.are) => (spam leaf+"%meet merge failed, trying %mate" ~) perform(gem %mate) :: - $mate - ?. ?=($mate-conflict p.p.are) + %mate + ?. ?=(%mate-conflict p.p.are) =+ "auto merge failed on strategy %mate" lose:(spam leaf+- >p.p.are< q.p.are) => .(gem %meld) diff --git a/pkg/arvo/lib/jose.hoon b/pkg/arvo/lib/jose.hoon index f1e4226ffe..200a367d62 100644 --- a/pkg/arvo/lib/jose.hoon +++ b/pkg/arvo/lib/jose.hoon @@ -38,7 +38,7 @@ ^- tape ?~ val (weld "null" rez) ?- -.val - $a + %a :- '[' =. rez [']' rez] !. @@ -47,9 +47,9 @@ ?~ t.p.val ^$(val i.p.val) ^$(val i.p.val, rez [',' $(p.val t.p.val)]) :: - $b (weld ?:(p.val "true" "false") rez) - $n (weld (trip p.val) rez) - $s + %b (weld ?:(p.val "true" "false") rez) + %n (weld (trip p.val) rez) + %s :- '"' =. rez ['"' rez] =+ viz=(trip p.val) @@ -57,11 +57,11 @@ |- ^- tape ?~ viz rez =+ hed=(jesc i.viz) - ?: ?=({@ $~} hed) + ?: ?=({@ ~} hed) [i.hed $(viz t.viz)] (weld hed $(viz t.viz)) :: - $o + %o :- '{' =. rez ['}' rez] =/ viz diff --git a/pkg/arvo/lib/language-server/easy-print.hoon b/pkg/arvo/lib/language-server/easy-print.hoon index 1a24152754..f278bf433e 100644 --- a/pkg/arvo/lib/language-server/easy-print.hoon +++ b/pkg/arvo/lib/language-server/easy-print.hoon @@ -3,25 +3,25 @@ => |% ++ cape {p/(map @ud wine) q/wine} ++ wine - $@ $? $noun - $path - $type - $void - $wall - $wool - $yarn + $@ $? %noun + %path + %type + %void + %wall + %wool + %yarn == - $% {$mato p/term} - {$gate p/hoon q/type r/wine} - {$core p/(list @ta) q/wine} - {$face p/term q/wine} - {$list p/term q/wine} - {$pear p/term q/@} - {$bcwt p/(list wine)} - {$plot p/(list wine)} - {$stop p/@ud} - {$tree p/term q/wine} - {$unit p/term q/wine} + $% {%mato p/term} + {%gate p/hoon q/type r/wine} + {%core p/(list @ta) q/wine} + {%face p/term q/wine} + {%list p/term q/wine} + {%pear p/term q/@} + {%bcwt p/(list wine)} + {%plot p/(list wine)} + {%stop p/@ud} + {%tree p/term q/wine} + {%unit p/term q/wine} == -- |_ sut/type @@ -59,15 +59,15 @@ ++ $ ^- {tank (set @ud)} ?- q.ham - $noun :_(gid [%leaf '*' ~]) - $path :_(gid [%leaf '/' ~]) - $type :_(gid [%leaf '#' 't' ~]) - $void :_(gid [%leaf '#' '!' ~]) - $wool :_(gid [%leaf '*' '"' '"' ~]) - $wall :_(gid [%leaf '*' '\'' '\'' ~]) - $yarn :_(gid [%leaf '"' '"' ~]) - {$mato *} :_(gid [%leaf '@' (trip p.q.ham)]) - {$gate *} + %noun :_(gid [%leaf '*' ~]) + %path :_(gid [%leaf '/' ~]) + %type :_(gid [%leaf '#' 't' ~]) + %void :_(gid [%leaf '#' '!' ~]) + %wool :_(gid [%leaf '*' '"' '"' ~]) + %wall :_(gid [%leaf '*' '\'' '\'' ~]) + %yarn :_(gid [%leaf '"' '"' ~]) + {%mato *} :_(gid [%leaf '@' (trip p.q.ham)]) + {%gate *} =^ sam gid ?. ?=([%plot * * *] r.q.ham) ?: ?=(%plot -.r.q.ham) @@ -92,7 +92,7 @@ == ~ :: - {$core *} + {%core *} =^ sam gid ?. ?=([%plot * * ~] q.q.ham) `gid @@ -114,26 +114,26 @@ [[%leaf (rip 3 i.p.q.ham)] $(p.q.ham t.p.q.ham)] ~ :: - {$face *} + {%face *} =^ cox gid $(q.ham q.q.ham) :_(gid [%palm [['=' ~] ~ ~ ~] [%leaf (trip p.q.ham)] cox ~]) :: - {$list *} + {%list *} =^ cox gid $(q.ham q.q.ham) :_(gid [%rose [" " (weld (trip p.q.ham) "(") ")"] cox ~]) :: - {$bcwt *} + {%bcwt *} =^ coz gid (many p.q.ham) :_(gid [%rose [[' ' ~] ['?' '(' ~] [')' ~]] coz]) :: - {$plot *} + {%plot *} =^ coz gid (many p.q.ham) :_(gid [%rose [[' ' ~] ['[' ~] [']' ~]] coz]) :: - {$pear *} + {%pear *} :_(gid [%leaf '$' ~(rend co [%$ p.q.ham q.q.ham])]) :: - {$stop *} + {%stop *} =+ num=~(rend co [%$ %ud p.q.ham]) ?: (~(has in gid) p.q.ham) :_(gid [%leaf '#' num]) @@ -144,11 +144,11 @@ == :_(gid [%palm [['.' ~] ~ ~ ~] [%leaf ['^' '#' num]] cox ~]) :: - {$tree *} + {%tree *} =^ cox gid $(q.ham q.q.ham) :_(gid [%rose [" " (weld (trip p.q.ham) "(") ")"] cox ~]) :: - {$unit *} + {%unit *} =^ cox gid $(q.ham q.q.ham) :_(gid [%rose [" " (weld (trip p.q.ham) "(") ")"] cox ~]) == @@ -163,7 +163,7 @@ =| gil/(set {@ud *}) |- ^- (unit tank) ?- q.ham - $noun + %noun %= $ q.ham ?: ?=(@ lum) @@ -173,7 +173,7 @@ [%noun ?:(?=(@ +.lum) [[%mato %$] ~] $(lum +.lum))] == :: - $path + %path :- ~ :+ %rose [['/' ~] ['/' ~] ~] @@ -183,7 +183,7 @@ ?> ?=(@ -.lum) [[%leaf (rip 3 -.lum)] $(lum +.lum)] :: - $type + %type =+ tyr=|.((dial dole)) =+ vol=tyr(sut lum) =+ cis=;;(tank .*(vol [%9 2 %0 1])) @@ -191,7 +191,7 @@ [~ ~ ~ ~] [[%leaf '#' 't' '/' ~] cis ~] :: - $wall + %wall :- ~ :+ %rose [[' ' ~] ['<' '|' ~] ['|' '>' ~]] @@ -200,7 +200,7 @@ ?@ lum !! [[%leaf (trip ;;(@ -.lum))] $(lum +.lum)] :: - $wool + %wool :- ~ :+ %rose [[' ' ~] ['<' '<' ~] ['>' '>' ~]] @@ -209,28 +209,28 @@ ?@ lum !! [(need ^$(q.ham %yarn, lum -.lum)) $(lum +.lum)] :: - $yarn + %yarn [~ %leaf (dash (tape lum) '"' "\{")] :: - $void + %void ~ :: - {$mato *} + {%mato *} ?. ?=(@ lum) ~ :+ ~ %leaf ?+ (rash p.q.ham ;~(sfix (cook crip (star low)) (star hig))) ~(rend co [%$ p.q.ham lum]) - $$ ~(rend co [%$ %ud lum]) - $t (dash (rip 3 lum) '\'' ~) - $tas ['%' ?.(=(0 lum) (rip 3 lum) ['$' ~])] + %$ ~(rend co [%$ %ud lum]) + %t (dash (rip 3 lum) '\'' ~) + %tas ['%' ?.(=(0 lum) (rip 3 lum) ['$' ~])] == :: - {$gate *} + {%gate *} !! :: - {$core *} + {%core *} :: XX needs rethinking for core metal :: ?. ?=(^ lum) ~ :: => .(lum `*`lum) @@ -244,13 +244,13 @@ :: ?~(mur ~ [~ [[%leaf (rip 3 i.p.q.ham)] u.mur]]) [~ (dial ham)] :: - {$face *} + {%face *} =+ wal=$(q.ham q.q.ham) ?~ wal ~ [~ %palm [['=' ~] ~ ~ ~] [%leaf (trip p.q.ham)] u.wal ~] :: - {$list *} + {%list *} ?: =(~ lum) [~ %leaf '~' ~] =- ?~ tok @@ -265,7 +265,7 @@ ~ [~ u.for u.aft] :: - {$bcwt *} + {%bcwt *} |- ^- (unit tank) ?~ p.q.ham ~ @@ -274,7 +274,7 @@ $(p.q.ham t.p.q.ham) wal :: - {$plot *} + {%plot *} =- ?~ tok ~ [~ %rose [[' ' ~] ['[' ~] [']' ~]] u.tok] @@ -295,25 +295,25 @@ ~ [~ u.gim u.myd] :: - {$pear *} + {%pear *} ?. =(lum q.q.ham) ~ =. p.q.ham (rash p.q.ham ;~(sfix (cook crip (star low)) (star hig))) =+ fox=$(q.ham [%mato p.q.ham]) - ?> ?=({~ $leaf ^} fox) - ?: ?=(?($n $tas) p.q.ham) + ?> ?=({~ %leaf ^} fox) + ?: ?=(?(%n %tas) p.q.ham) fox [~ %leaf '%' p.u.fox] :: - {$stop *} + {%stop *} ?: (~(has in gil) [p.q.ham lum]) ~ =+ kep=(~(get by p.ham) p.q.ham) ?~ kep ~|([%stop-loss p.q.ham] !!) $(gil (~(put in gil) [p.q.ham lum]), q.ham u.kep) :: - {$tree *} + {%tree *} =- ?~ tok ~ [~ %rose [[' ' ~] ['{' ~] ['}' ~]] u.tok] @@ -332,7 +332,7 @@ ~ $(lum l.lum, tuk [u.tim u.rol]) :: - {$unit *} + {%unit *} ?@ lum ?.(=(~ lum) ~ [~ %leaf '~' ~]) ?. =(~ -.lum) @@ -346,15 +346,15 @@ ++ doge |= ham/cape =- ?+ woz woz - {$list * {$mato $'ta'}} %path - {$list * {$mato $'t'}} %wall - {$list * {$mato $'tD'}} %yarn - {$list * $yarn} %wool + {%list * {%mato %'ta'}} %path + {%list * {%mato %'t'}} %wall + {%list * {%mato %'tD'}} %yarn + {%list * %yarn} %wool == ^= woz ^- wine - ?. ?=({$stop *} q.ham) - ?: ?& ?= {$bcwt {$pear $n $0} {$plot {$pear $n $0} {$face *} ~} ~} + ?. ?=({%stop *} q.ham) + ?: ?& ?= {%bcwt {%pear %n %0} {%plot {%pear %n %0} {%face *} ~} ~} q.ham =(1 (met 3 p.i.t.p.i.t.p.q.ham)) == @@ -364,13 +364,13 @@ ?~ may q.ham =+ nul=[%pear %n 0] - ?. ?& ?=({$bcwt *} u.may) + ?. ?& ?=({%bcwt *} u.may) ?=({* * ~} p.u.may) |(=(nul i.p.u.may) =(nul i.t.p.u.may)) == q.ham =+ din=?:(=(nul i.p.u.may) i.t.p.u.may i.p.u.may) - ?: ?& ?=({$plot {$face *} {$face * $stop *} ~} din) + ?: ?& ?=({%plot {%face *} {%face * %stop *} ~} din) =(p.q.ham p.q.i.t.p.din) =(1 (met 3 p.i.p.din)) =(1 (met 3 p.i.t.p.din)) @@ -378,10 +378,10 @@ :+ %list (cat 3 p.i.p.din p.i.t.p.din) q.i.p.din - ?: ?& ?= $: $plot - {$face *} - {$face * $stop *} - {{$face * $stop *} ~} + ?: ?& ?= $: %plot + {%face *} + {%face * %stop *} + {{%face * %stop *} ~} == din =(p.q.ham p.q.i.t.p.din) @@ -410,17 +410,17 @@ ?: (~(meet ut sut) -:!>(*type)) [dex %type] ?- sut - $noun [dex sut] - $void [dex sut] - {$atom *} [dex ?~(q.sut [%mato p.sut] [%pear p.sut u.q.sut])] - {$cell *} + %noun [dex sut] + %void [dex sut] + {%atom *} [dex ?~(q.sut [%mato p.sut] [%pear p.sut u.q.sut])] + {%cell *} =+ hin=$(sut p.sut) =+ yon=$(dex p.hin, sut q.sut) :- p.yon :- %plot - ?:(?=({$plot *} q.yon) [q.hin p.q.yon] [q.hin q.yon ~]) + ?:(?=({%plot *} q.yon) [q.hin p.q.yon] [q.hin q.yon ~]) :: - {$core *} + {%core *} ?: ?=([[%$ * [[%$ @ *] ~ ~]] ~ ~] q.r.q.sut) =/ dad $(sut p.sut) :- p.dad @@ -429,7 +429,7 @@ =+ yad=$(sut p.sut) :- p.yad =+ ^= doy ^- {p/(list @ta) q/wine} - ?: ?=({$core *} q.yad) + ?: ?=({%core *} q.yad) [p.q.yad q.q.yad] [~ q.yad] :- %core @@ -441,7 +441,7 @@ %- ~(rep by (~(run by q.r.q.sut) |=(tome ~(wyt by q.+<)))) |=([[@ a=@u] b=@u] (add a b)) %^ cat 3 - ?-(r.p.q.sut $gold '.', $iron '|', $lead '?', $zinc '&') + ?-(r.p.q.sut %gold '.', %iron '|', %lead '?', %zinc '&') =+ gum=(mug q.r.q.sut) %+ can 3 :~ [1 (add 'a' (mod gum 26))] @@ -449,14 +449,14 @@ [1 (add 'a' (mod (div gum 676) 26))] == :: - {$hint *} + {%hint *} $(sut q.sut) :: - {$face *} + {%face *} =+ yad=$(sut q.sut) ?^(p.sut yad [p.yad [%face p.sut q.yad]]) :: - {$fork *} + {%fork *} =+ yed=(sort ~(tap in p.sut) aor) =- [p [%bcwt q]] |- ^- {p/{p/(map type @) q/(map @ wine)} q/(list wine)} @@ -466,7 +466,7 @@ =+ dis=^$(dex p.mor, sut i.yed) [p.dis q.dis q.mor] :: - {$hold *} + {%hold *} =+ hey=(~(get by p.dex) sut) ?^ hey [dex [%stop u.hey]] diff --git a/pkg/arvo/lib/metadata-json.hoon b/pkg/arvo/lib/metadata-json.hoon index 7197ab4dcc..b35eeb7c01 100644 --- a/pkg/arvo/lib/metadata-json.hoon +++ b/pkg/arvo/lib/metadata-json.hoon @@ -48,7 +48,7 @@ :: ++ nu |= jon=json - ?> ?=({$s *} jon) + ?> ?=({%s *} jon) (rash p.jon hex) :: ++ metadata diff --git a/pkg/arvo/lib/pill.hoon b/pkg/arvo/lib/pill.hoon index 453c5b2bdd..917fadeb05 100644 --- a/pkg/arvo/lib/pill.hoon +++ b/pkg/arvo/lib/pill.hoon @@ -88,7 +88,7 @@ =? hav ?=(^ fil.lon) :: XX this whitelist needs to be reviewed :: - ?. ?= ?($css $hoon $html $js $json $md $png $txt $udon $umd) + ?. ?= ?(%css %hoon %html %js %json %md %png %txt %udon %umd) -.tyl :: :: install only files with whitelisted marks @@ -101,11 +101,11 @@ =; cot [[(flop `path`tyl) `[/text/plain cot]] hav] ^- octs ?- tyl - {$json *} + {%json *} =/ dat .^(json %cx pax) (as-octt:mimes:html (en-json:html dat)) :: - {$txt *} + {%txt *} =/ dat .^(wain %cx pax) (as-octs:mimes:html (of-wain:format dat)) :: diff --git a/pkg/arvo/lib/show-dir.hoon b/pkg/arvo/lib/show-dir.hoon index 8154df0e8c..c6812ab58c 100644 --- a/pkg/arvo/lib/show-dir.hoon +++ b/pkg/arvo/lib/show-dir.hoon @@ -3,7 +3,7 @@ :::: /hoon/show-dir/lib :: /? 310 -|= {vane/?($g $c) pax/path des/(map @t ~)} +|= {vane/?(%g %c) pax/path des/(map @t ~)} ^- tank :+ %rose [" " `~] %+ turn (sort ~(tap by des) aor) diff --git a/pkg/arvo/lib/sole.hoon b/pkg/arvo/lib/sole.hoon index 91ffe3c3e0..8129e16c07 100644 --- a/pkg/arvo/lib/sole.hoon +++ b/pkg/arvo/lib/sole.hoon @@ -11,14 +11,14 @@ |= ted/sole-edit ^+ +> ?- -.ted - $del +>.$(buf (weld (scag p.ted buf) (slag +(p.ted) buf))) - $ins +>.$(buf (weld (scag p.ted buf) `_buf`[q.ted (slag p.ted buf)])) - $mor |- ^+ +>.^$ + %del +>.$(buf (weld (scag p.ted buf) (slag +(p.ted) buf))) + %ins +>.$(buf (weld (scag p.ted buf) `_buf`[q.ted (slag p.ted buf)])) + %mor |- ^+ +>.^$ ?~ p.ted +>.^$ $(p.ted t.p.ted, +>.^$ ^$(ted i.p.ted)) - $nop +>.$ - $set +>.$(buf p.ted) + %nop +>.$ + %set +>.$(buf p.ted) == :: :::: @@ -34,33 +34,33 @@ |= {sin/sole-edit dex/sole-edit} ~| [%transmute sin dex] ^- sole-edit - ?: ?=($mor -.sin) + ?: ?=(%mor -.sin) |- ^- sole-edit ?~ p.sin dex $(p.sin t.p.sin, dex ^$(sin i.p.sin)) :: - ?: ?=($mor -.dex) + ?: ?=(%mor -.dex) :- %mor |- ^- (list sole-edit) ?~ p.dex ~ [^$(dex i.p.dex) $(p.dex t.p.dex)] :: - ?: |(?=($nop -.sin) ?=($nop -.dex)) dex - ?: ?=($set -.sin) [%nop ~] - ?: ?=($set -.dex) dex + ?: |(?=(%nop -.sin) ?=(%nop -.dex)) dex + ?: ?=(%set -.sin) [%nop ~] + ?: ?=(%set -.dex) dex :: ?- -.sin - $del + %del ?- -.dex - $del ?: =(p.sin p.dex) [%nop ~] + %del ?: =(p.sin p.dex) [%nop ~] ?:((lth p.sin p.dex) dex(p (dec p.dex)) dex) - $ins ?:((lth p.sin p.dex) dex(p (dec p.dex)) dex) + %ins ?:((lth p.sin p.dex) dex(p (dec p.dex)) dex) == :: - $ins + %ins ?- -.dex - $del ?:((lte p.sin p.dex) dex(p +(p.dex)) dex) - $ins ?: =(p.sin p.dex) + %del ?:((lte p.sin p.dex) dex(p +(p.dex)) dex) + %ins ?: =(p.sin p.dex) ?:((lth q.sin q.dex) dex dex(p +(p.dex))) ?:((lte p.sin p.dex) dex(p +(p.dex)) dex) == @@ -81,18 +81,18 @@ ++ inverse :: relative inverse |= ted/sole-edit ^- sole-edit - =. ted ?.(?=({$mor * ~} ted) ted i.p.ted) + =. ted ?.(?=({%mor * ~} ted) ted i.p.ted) ?- -.ted - $del [%ins p.ted (snag p.ted buf)] - $ins [%del p.ted] - $mor :- %mor + %del [%ins p.ted (snag p.ted buf)] + %ins [%del p.ted] + %mor :- %mor %- flop |- ^- (list sole-edit) ?~ p.ted ~ :- ^$(ted i.p.ted) $(p.ted t.p.ted, +>.^$ (apply i.p.ted)) - $nop [%nop ~] - $set [%set buf] + %nop [%nop ~] + %set [%set buf] == :: ++ receive :: naturalize event @@ -134,6 +134,6 @@ ++ transpose :: adjust position |= pos/@ud =+ dat=(transmute [%mor leg] [%ins pos `@c`0]) - ?> ?=($ins -.dat) + ?> ?=(%ins -.dat) p.dat -- diff --git a/pkg/arvo/lib/soto.hoon b/pkg/arvo/lib/soto.hoon index ef39e79ced..f82751169a 100644 --- a/pkg/arvo/lib/soto.hoon +++ b/pkg/arvo/lib/soto.hoon @@ -39,17 +39,17 @@ =, enjs:format ?+ -.sef ~|(unsupported-effect+-.sef !!) - $mor [%a (turn p.sef |=(a/sole-effect ^$(sef a)))] - $err (frond %hop (numb p.sef)) - $txt (frond %txt (tape p.sef)) - $tan (frond %tan (tape (wush 160 p.sef))) - $det (frond %det json:~(grow mar-sole-change +.sef)) + %mor [%a (turn p.sef |=(a/sole-effect ^$(sef a)))] + %err (frond %hop (numb p.sef)) + %txt (frond %txt (tape p.sef)) + %tan (frond %tan (tape (wush 160 p.sef))) + %det (frond %det json:~(grow mar-sole-change +.sef)) :: - $pro + %pro %+ frond %pro (pairs vis+b+vis.sef tag+s+tag.sef cad+(tape (purge cad.sef)) ~) :: - $tab + %tab :- %a %+ turn p.sef |= [=cord =^tank] @@ -59,7 +59,7 @@ info+(tape ~(ram re tank)) == :: - ?($bel $clr $nex) + ?(%bel %clr %nex) (frond %act %s -.sef) == ++ mar-sole-change @@ -72,11 +72,11 @@ =,(cha (pairs ted+(edi ted) ler+a+~[(numb own.ler) (numb his.ler)] ~)) |= det=sole-edit ?- -.det - $nop [%s 'nop'] - $mor [%a (turn p.det ..$)] - $del (frond %del (numb p.det)) - $set (frond %set (tape (tufa p.det))) - $ins (frond %ins (pairs at+(numb p.det) cha+s+(tuft q.det) ~)) + %nop [%s 'nop'] + %mor [%a (turn p.det ..$)] + %del (frond %del (numb p.det)) + %set (frond %set (tape (tufa p.det))) + %ins (frond %ins (pairs at+(numb p.det) cha+s+(tuft q.det) ~)) == -- -- diff --git a/pkg/arvo/lib/urb-split.hoon b/pkg/arvo/lib/urb-split.hoon index 3a3871ad0a..c6fae485c9 100644 --- a/pkg/arvo/lib/urb-split.hoon +++ b/pkg/arvo/lib/urb-split.hoon @@ -4,7 +4,7 @@ /? 310 |= {dep/@uvH urb/manx} ^- {hed/{@uvh marl} bod/{@uvH marl}} ~| [%malformed-urb urb] :: XX types -?> ?=({{$html ~} {{$head ~} *} {{$body ~} *} ~} urb) -=+ `{{$html ~} {{$head ~} hed/marl} {{$body ~} bod/marl} ~}`urb +?> ?=({{%html ~} {{%head ~} *} {{%body ~} *} ~} urb) +=+ `{{%html ~} {{%head ~} hed/marl} {{%body ~} bod/marl} ~}`urb :- [dep hed] :: Assume all dependencies are hard [0v0 bod] diff --git a/pkg/arvo/mar/dill/belt.hoon b/pkg/arvo/mar/dill/belt.hoon index 05a2ddb9d3..1a4c68d32a 100644 --- a/pkg/arvo/mar/dill/belt.hoon +++ b/pkg/arvo/mar/dill/belt.hoon @@ -24,7 +24,7 @@ :: %. jon => jo %- ot :: :~ mod+(cu silt (ar (su (perk ~[%ctrl %shift %alt %meta])))) :: :- %key -:: %+ cu |*(a/$%({$str @t} {$act @}) ?+(-.a a $str +.a)) +:: %+ cu |*(a/$%({%str @t} {%act @}) ?+(-.a a %str +.a)) :: =- (of [str+so act+(su (perk -)) ~]) :: :~ %ctrl %shift %alt %meta %entr %esc %caps %uncap :: %pgup %pgdn %home %end %baxp %del %ins @@ -33,7 +33,7 @@ ++ kyev |= kev/^kyev ^- dill-belt:dill ~| dill-belt-incomplete+kev - ?: ?=({$act ?($ctrl $shift $alt $meta)} q.kev) + ?: ?=({%act ?(%ctrl %shift %alt %meta)} q.kev) [%txt ~] :: ignore =+ mod=(~(del in p.kev) %shift) ?^ mod @@ -45,19 +45,19 @@ =+ cha=(tuba (trip q.kev)) ?> ?=({@ ~} cha) :: of a single character ?+ mod !! :: modified by one buckykey - {$ctrl ~ ~} [%ctl i.cha] - {$alt ~ ~} [%met i.cha] + {%ctrl ~ ~} [%ctl i.cha] + {%alt ~ ~} [%met i.cha] == ?@ q.kev [%txt (tuba (trip q.kev))] ?+ +.q.kev !! - $del [%del ~] - $baxp [%bac ~] - $entr [%ret ~] - $up [%aro %u] - $down [%aro %d] - $left [%aro %l] - $right [%aro %r] + %del [%del ~] + %baxp [%bac ~] + %entr [%ret ~] + %up [%aro %u] + %down [%aro %d] + %left [%aro %l] + %right [%aro %r] == :: %yow, %rez? :: ++ noun dill-belt:dill :: clam from %noun diff --git a/pkg/arvo/mar/dill/blit.hoon b/pkg/arvo/mar/dill/blit.hoon index 2dc0acd7a8..61b02d43ce 100644 --- a/pkg/arvo/mar/dill/blit.hoon +++ b/pkg/arvo/mar/dill/blit.hoon @@ -18,10 +18,10 @@ ++ json ^- ^json ?+ -.dib ~|(unsupported-blit+-.dib !!) - $mor [%a (turn p.dib |=(a/dill-blit:dill json(dib a)))] - $hop (frond %hop (numb p.dib)) - ?($pro $out) (frond -.dib (tape (tufa p.dib))) - ?($bel $clr) (frond %act %s -.dib) + %mor [%a (turn p.dib |=(a/dill-blit:dill json(dib a)))] + %hop (frond %hop (numb p.dib)) + ?(%pro %out) (frond -.dib (tape (tufa p.dib))) + ?(%bel %clr) (frond %act %s -.dib) == -- -- diff --git a/pkg/arvo/mar/html.hoon b/pkg/arvo/mar/html.hoon index c6aeef3bc0..c0b7ef0049 100644 --- a/pkg/arvo/mar/html.hoon +++ b/pkg/arvo/mar/html.hoon @@ -17,7 +17,7 @@ ++ grab ^? |% :: convert from ++ noun @t :: clam from %noun - ++ mime |=({p/mite q/octs} q.q) :: retrieve form $mime + ++ mime |=({p/mite q/octs} q.q) :: retrieve form %mime -- ++ grad %mime -- diff --git a/pkg/arvo/mar/json/rpc/response.hoon b/pkg/arvo/mar/json/rpc/response.hoon index 9f91469d0e..8aa1c5a75a 100644 --- a/pkg/arvo/mar/json/rpc/response.hoon +++ b/pkg/arvo/mar/json/rpc/response.hoon @@ -15,7 +15,7 @@ |= hit/httr:eyre ^- response ~| hit - ?: ?=($2 (div p.hit 100)) + ?: ?=(%2 (div p.hit 100)) =, html %- json ?~ r.hit diff --git a/pkg/arvo/mar/snip.hoon b/pkg/arvo/mar/snip.hoon index e6eb3225ee..1ee006d88b 100644 --- a/pkg/arvo/mar/snip.hoon +++ b/pkg/arvo/mar/snip.hoon @@ -9,8 +9,8 @@ =| met/marl |= a/marl ^- {hed/marl tal/marl} ?~ a [~ ~] - ?. ?=($h1 n.g.i.a) - ?: ?=($meta n.g.i.a) + ?. ?=(%h1 n.g.i.a) + ?: ?=(%meta n.g.i.a) $(a t.a, met [i.a met]) =+ had=$(a c.i.a) ?^ -.had had @@ -57,6 +57,6 @@ -- -- ++ grab |% :: convert from - ++ noun {marl marl} :: clam from $noun + ++ noun {marl marl} :: clam from %noun ++ elem |=(a/manx (hedtal +.a)) -- -- diff --git a/pkg/arvo/mar/sole/effect.hoon b/pkg/arvo/mar/sole/effect.hoon index edf4f64571..2fadc36360 100644 --- a/pkg/arvo/mar/sole/effect.hoon +++ b/pkg/arvo/mar/sole/effect.hoon @@ -21,11 +21,11 @@ =,(cha (pairs ted+(edi ted) ler+a+~[(numb own.ler) (numb his.ler)] ~)) |= det/sole-edit ?- -.det - $nop [%s 'nop'] - $mor [%a (turn p.det ..$)] - $del (frond %del (numb p.det)) - $set (frond %set (tape (tufa p.det))) - $ins (frond %ins (pairs at+(numb p.det) cha+s+(tuft q.det) ~)) + %nop [%s 'nop'] + %mor [%a (turn p.det ..$)] + %del (frond %del (numb p.det)) + %set (frond %set (tape (tufa p.det))) + %ins (frond %ins (pairs at+(numb p.det) cha+s+(tuft q.det) ~)) == -- -- @@ -56,17 +56,17 @@ ^- ^json ?+ -.sef ~|(unsupported-effect+-.sef !!) - $mor [%a (turn p.sef |=(a/sole-effect json(sef a)))] - $err (frond %hop (numb p.sef)) - $txt (frond %txt (tape p.sef)) - $tan (frond %tan (tape (wush 160 p.sef))) - $det (frond %det json:~(grow mar-sole-change +.sef)) + %mor [%a (turn p.sef |=(a/sole-effect json(sef a)))] + %err (frond %hop (numb p.sef)) + %txt (frond %txt (tape p.sef)) + %tan (frond %tan (tape (wush 160 p.sef))) + %det (frond %det json:~(grow mar-sole-change +.sef)) :: - $pro + %pro %+ frond %pro (pairs vis+b+vis.sef tag+s+tag.sef cad+(tape (purge cad.sef)) ~) :: - $tab + %tab :- %a %+ turn p.sef |= [=cord =^tank] @@ -76,7 +76,7 @@ info+(tape ~(ram re tank)) == :: - ?($bel $clr $nex) + ?(%bel %clr %nex) (frond %act %s -.sef) == -- diff --git a/pkg/arvo/mar/xml.hoon b/pkg/arvo/mar/xml.hoon index 01ac140fbf..70dea7b9c8 100644 --- a/pkg/arvo/mar/xml.hoon +++ b/pkg/arvo/mar/xml.hoon @@ -17,5 +17,5 @@ -- :: ++ grab |% :: convert from ++ noun @t :: clam from %noun - ++ mime |=({p/mite q/octs} q.q) :: retrieve form $mime + ++ mime |=({p/mite q/octs} q.q) :: retrieve form %mime -- -- diff --git a/pkg/arvo/sur/kyev.hoon b/pkg/arvo/sur/kyev.hoon index 5b464fc5e8..4d41f85901 100644 --- a/pkg/arvo/sur/kyev.hoon +++ b/pkg/arvo/sur/kyev.hoon @@ -3,9 +3,9 @@ :::: /hoon/kyev/sur :: /? 310 -=- {p/(set ?($ctrl $shift $alt $meta)) q/$@(cord {$act speck})} +=- {p/(set ?(%ctrl %shift %alt %meta)) q/$@(cord {%act speck})} ^= speck -$? $ctrl $shift $alt $meta $entr $esc $caps $uncap - $pgup $pgdn $home $end $baxp $del $ins - $up $down $left $right +$? %ctrl %shift %alt %meta %entr %esc %caps %uncap + %pgup %pgdn %home %end %baxp %del %ins + %up %down %left %right == diff --git a/pkg/arvo/sur/lens.hoon b/pkg/arvo/sur/lens.hoon index 0c75afa8c7..08f3656404 100644 --- a/pkg/arvo/sur/lens.hoon +++ b/pkg/arvo/sur/lens.hoon @@ -5,30 +5,30 @@ sink/sink == ++ source - $% {$data data/@} - {$dojo command/@t} - {$clay pax/@t} - {$url url/purl:eyre} - {$api api/term command/@t} - {$get-api api/term endpoint/(list @t)} - {$as mar/mark next/source} :: can't be at the - {$hoon code/@t next/source} :: end since they - {$tuple next/(list source)} :: don't bunt well - {$listen-api api/term event/term} - {$export app/@t} - {$import app/@t base64-jam/@t} - {$export-all ~} - {$import-all base64-jam/@t} + $% {%data data/@} + {%dojo command/@t} + {%clay pax/@t} + {%url url/purl:eyre} + {%api api/term command/@t} + {%get-api api/term endpoint/(list @t)} + {%as mar/mark next/source} :: can't be at the + {%hoon code/@t next/source} :: end since they + {%tuple next/(list source)} :: don't bunt well + {%listen-api api/term event/term} + {%export app/@t} + {%import app/@t base64-jam/@t} + {%export-all ~} + {%import-all base64-jam/@t} == ++ sink - $% {$stdout ~} - {$output-file pax/@t} - {$output-pill pax/@t} - {$output-clay pax/path} - {$url url/purl:eyre} - {$to-api api/term command/@t} - {$send-api api/term endpoint/(list @t)} - {$command command/@t} - {$app app/term} + $% {%stdout ~} + {%output-file pax/@t} + {%output-pill pax/@t} + {%output-clay pax/path} + {%url url/purl:eyre} + {%to-api api/term command/@t} + {%send-api api/term endpoint/(list @t)} + {%command command/@t} + {%app app/term} == -- diff --git a/pkg/arvo/sur/rw-security.hoon b/pkg/arvo/sur/rw-security.hoon index 477370c001..ad8ad5715b 100644 --- a/pkg/arvo/sur/rw-security.hoon +++ b/pkg/arvo/sur/rw-security.hoon @@ -1,8 +1,8 @@ |% +$ rw-security - $? $channel :: black r, black w - $village :: white r, white w - $journal :: black r, white w - $mailbox :: white r, black w + $? %channel :: black r, black w + %village :: white r, white w + %journal :: black r, white w + %mailbox :: white r, black w == -- diff --git a/pkg/arvo/sur/sole.hoon b/pkg/arvo/sur/sole.hoon index 0254e5701a..67a8f2c746 100644 --- a/pkg/arvo/sur/sole.hoon +++ b/pkg/arvo/sur/sole.hoon @@ -6,11 +6,11 @@ ++ sole-action :: sole to app $: id=@ta :: duct id $= dat - $% :: {$abo ~} :: reset interaction - {$det sole-change} :: command line edit - {$ret ~} :: submit and clear - {$clr ~} :: exit context - {$tab pos/@ud} :: tab complete + $% :: {%abo ~} :: reset interaction + {%det sole-change} :: command line edit + {%ret ~} :: submit and clear + {%clr ~} :: exit context + {%tab pos/@ud} :: tab complete == :: == ++ sole-buffer (list @c) :: command state @@ -21,29 +21,29 @@ == :: ++ sole-clock {own/@ud his/@ud} :: vector clock ++ sole-edit :: shared state change - $% {$del p/@ud} :: delete one at - {$ins p/@ud q/@c} :: insert at - {$mor p/(list sole-edit)} :: combination - {$nop ~} :: no-op - {$set p/sole-buffer} :: discontinuity + $% {%del p/@ud} :: delete one at + {%ins p/@ud q/@c} :: insert at + {%mor p/(list sole-edit)} :: combination + {%nop ~} :: no-op + {%set p/sole-buffer} :: discontinuity == :: ++ sole-effect :: app to sole - $% {$bel ~} :: beep - {$blk p/@ud q/@c} :: blink+match char at - {$clr ~} :: clear screen - {$det sole-change} :: edit command - {$err p/@ud} :: error point - {$klr p/styx} :: styled text line - {$mor p/(list sole-effect)} :: multiple effects - {$nex ~} :: save clear command - {$pro sole-prompt} :: set prompt - {$sag p/path q/*} :: save to jamfile - {$sav p/path q/@} :: save to file - {$tab p/(list {=cord =tank})} :: tab-complete list - {$tan p/(list tank)} :: classic tank - :: {$taq p/tanq} :: modern tank - {$txt p/tape} :: text line - {$url p/@t} :: activate url + $% {%bel ~} :: beep + {%blk p/@ud q/@c} :: blink+match char at + {%clr ~} :: clear screen + {%det sole-change} :: edit command + {%err p/@ud} :: error point + {%klr p/styx} :: styled text line + {%mor p/(list sole-effect)} :: multiple effects + {%nex ~} :: save clear command + {%pro sole-prompt} :: set prompt + {%sag p/path q/*} :: save to jamfile + {%sav p/path q/@} :: save to file + {%tab p/(list {=cord =tank})} :: tab-complete list + {%tan p/(list tank)} :: classic tank + :: {%taq p/tanq} :: modern tank + {%txt p/tape} :: text line + {%url p/@t} :: activate url == :: ++ sole-command :: command state $: pos/@ud :: cursor position @@ -77,8 +77,8 @@ (pair sole-prompt (sole-dialog out)) :: ask and continue :: :: ++ sole-gen :: XX virtual type - $% {$say $-((sole-args) (cask))} :: direct noun - {$ask $-((sole-args) (sole-product (cask)))} :: dialog + $% {%say $-((sole-args) (cask))} :: direct noun + {%ask $-((sole-args) (sole-product (cask)))} :: dialog == :: ++ sole-args :: generator arguments |* _[* *] :: diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index 93d7570b74..a1724271de 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -1068,7 +1068,7 @@ == :: =/ von - %+ turn + %+ turn (sort ~(tap by van.mod) |=([[a=@tas *] [b=@tas *]] (aor a b))) |=([lal=@tas =vane] (cat 3 %vane- lal)^vane) :: diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 87e300cc25..c0e5a01dff 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -192,11 +192,11 @@ :: tests whether an `a` is in the head or tail of a noun. produces %2 if it :: is within the head, or %3 if it is within the tail. |= a=@ - ^- ?($2 $3) + ^- ?(%2 %3) ?- a - $2 %2 - $3 %3 - ?($0 $1) !! + %2 %2 + %3 %3 + ?(%0 %1) !! * $(a (div a 2)) == :: @@ -224,9 +224,9 @@ :: a composed axis ^- @ ?- b - $1 a - $2 (mul a 2) - $3 +((mul a 2)) + %1 a + %2 (mul a 2) + %3 +((mul a 2)) * (add (mod b 2) (mul $(b (div b 2)) 2)) == :: :: @@ -1054,20 +1054,20 @@ =/ tlen (dis len 3) =. h1 ?+ tlen h1 :: fallthrough switch - $3 =. k1 (mix k1 (lsh 0 16 (snag 2 tail))) + %3 =. k1 (mix k1 (lsh 0 16 (snag 2 tail))) =. k1 (mix k1 (lsh 0 8 (snag 1 tail))) =. k1 (mix k1 (snag 0 tail)) =. k1 (sit (mul k1 c1)) =. k1 (rol 0 15 k1) =. k1 (sit (mul k1 c2)) (mix h1 k1) - $2 =. k1 (mix k1 (lsh 0 8 (snag 1 tail))) + %2 =. k1 (mix k1 (lsh 0 8 (snag 1 tail))) =. k1 (mix k1 (snag 0 tail)) =. k1 (sit (mul k1 c1)) =. k1 (rol 0 15 k1) =. k1 (sit (mul k1 c2)) (mix h1 k1) - $1 =. k1 (mix k1 (snag 0 tail)) + %1 =. k1 (mix k1 (snag 0 tail)) =. k1 (sit (mul k1 c1)) =. k1 (rol 0 15 k1) =. k1 (sit (mul k1 c2)) @@ -2085,23 +2085,23 @@ ++ fn :: float, infinity, or NaN :: s=sign, e=exponent, a=arithmetic form :: (-1)^s * a * 2^e - $% {$f s/? e/@s a/@u} - {$i s/?} - {$n ~} + $% {%f s/? e/@s a/@u} + {%i s/?} + {%n ~} == :: ++ dn :: decimal float, infinity, or NaN :: (-1)^s * a * 10^e - $% {$d s/? e/@s a/@u} - {$i s/?} - {$n ~} + $% {%d s/? e/@s a/@u} + {%i s/?} + {%n ~} == :: ++ rn :: parsed decimal float :: - $% {$d a/? b/{c/@ {d/@ e/@} f/? i/@}} - {$i a/?} - {$n ~} + $% {%d a/? b/{c/@ {d/@ e/@} f/? i/@}} + {%i a/?} + {%n ~} == -- => :: :: @@ -2235,7 +2235,7 @@ :: :: ++ fl :: arb. precision fp - =/ {{p/@u v/@s w/@u} r/$?($n $u $d $z $a) d/$?($d $f $i)} + =/ {{p/@u v/@s w/@u} r/$?(%n %u %d %z %a) d/$?(%d %f %i)} [[113 -16.494 32.765] %n %d] :: p=precision: number of bits in arithmetic form; must be at least 2 :: v=min exponent: minimum value of e @@ -2254,9 +2254,9 @@ ++ rau |= {a/{e/@s a/@u} t/?} ^- fn ?- r - $z (lug %fl a t) $d (lug %fl a t) - $a (lug %ce a t) $u (lug %ce a t) - $n (lug %ne a t) + %z (lug %fl a t) %d (lug %fl a t) + %a (lug %ce a t) %u (lug %ce a t) + %n (lug %ne a t) == :: ++ add :: add; exact if e @@ -2271,9 +2271,9 @@ =+ ^= x %+ sum:si e.b (sun:si mb) :: highest exp for b ?: =((cmp:si w x) --1) :: don't need to add ?- r - $z (lug %fl a &) $d (lug %fl a &) - $a (lug %lg a &) $u (lug %lg a &) - $n (lug %na a &) + %z (lug %fl a &) %d (lug %fl a &) + %a (lug %lg a &) %u (lug %lg a &) + %n (lug %na a &) == (rou [e.b (^add (lsh 0 (abs:si q) a.a) a.b)]) :: @@ -2288,9 +2288,9 @@ =+ ^= x %+ sum:si e.b (sun:si +(mb)) ?: &(!e =((cmp:si w x) --1)) ?- r - $z (lug %sm a &) $d (lug %sm a &) - $a (lug %ce a &) $u (lug %ce a &) - $n (lug %nt a &) + %z (lug %sm a &) %d (lug %sm a &) + %a (lug %ce a &) %u (lug %ce a &) + %n (lug %nt a &) == =+ j=(lsh 0 (abs:si q) a.a) |- ?. (gte j a.b) @@ -2370,11 +2370,11 @@ :: ++ lug ~/ %lug - |= {t/$?($fl $ce $sm $lg $ne $na $nt) a/{e/@s a/@u} s/?} ^- fn + |= {t/$?(%fl %ce %sm %lg %ne %na %nt) a/{e/@s a/@u} s/?} ^- fn ?< =(a.a 0) =- ?. =(den %f) - :: flush denormals - ?. ?=({$f *} -) - + ?. ?=({%f *} -) - ?: =((met 0 ->+>) prc) - [%f & zer] :: =+ m=(met 0 a.a) @@ -2389,38 +2389,38 @@ ?~ a.a ?< =(den %i) ?- t - $fl [%f & zer] - $sm [%f & zer] - $ce [%f & spd] - $lg [%f & spd] - $ne ?: s [%f & ?:((lte b (bex (dec q))) zer spd)] + %fl [%f & zer] + %sm [%f & zer] + %ce [%f & spd] + %lg [%f & spd] + %ne ?: s [%f & ?:((lte b (bex (dec q))) zer spd)] [%f & ?:((^lth b (bex (dec q))) zer spd)] - $nt ?: s [%f & ?:((lte b (bex (dec q))) zer spd)] + %nt ?: s [%f & ?:((lte b (bex (dec q))) zer spd)] [%f & ?:((^lth b (bex (dec q))) zer spd)] - $na [%f & ?:((^lth b (bex (dec q))) zer spd)] + %na [%f & ?:((^lth b (bex (dec q))) zer spd)] == :: =. a (xpd a) :: =. a ?- t - $fl a - $lg a(a +(a.a)) - $sm ?. &(=(b 0) s) a + %fl a + %lg a(a +(a.a)) + %sm ?. &(=(b 0) s) a ?: &(=(e.a emn) !=(den %i)) a(a (dec a.a)) =+ y=(dec (^mul a.a 2)) ?. (lte (met 0 y) prc) a(a (dec a.a)) [(dif:si e.a --1) y] - $ce ?: &(=(b 0) s) a a(a +(a.a)) - $ne ?~ b a + %ce ?: &(=(b 0) s) a a(a +(a.a)) + %ne ?~ b a =+ y=(bex (dec q)) ?: &(=(b y) s) :: round halfs to even ?~ (dis a.a 1) a a(a +(a.a)) ?: (^lth b y) a a(a +(a.a)) - $na ?~ b a + %na ?~ b a =+ y=(bex (dec q)) ?: (^lth b y) a a(a +(a.a)) - $nt ?~ b a + %nt ?~ b a =+ y=(bex (dec q)) ?: =(b y) ?: s a a(a +(a.a)) ?: (^lth b y) a a(a +(a.a)) @@ -2495,22 +2495,22 @@ ?: &(=(z i) =((dis y 1) 0)) [%f & --0 y] ?: (^lth z i) [%f & --0 y] [%f & --0 +(y)] :: - ++ ned :: require ?=({$f *} a) - |= {a/fn} ^- {$f s/? e/@s a/@u} - ?: ?=({$f *} a) a + ++ ned :: require ?=({%f *} a) + |= {a/fn} ^- {%f s/? e/@s a/@u} + ?: ?=({%f *} a) a ~_ leaf+"need-float" !! :: ++ shf :: a * 2^b; no rounding |= {a/fn b/@s} - ?: |(?=({$n *} a) ?=({$i *} a)) a + ?: |(?=({%n *} a) ?=({%i *} a)) a a(e (sum:si e.a b)) :: ++ fli :: flip sign |= {a/fn} ^- fn - ?-(-.a $f a(s !s.a), $i a(s !s.a), $n a) + ?-(-.a %f a(s !s.a), %i a(s !s.a), %n a) :: - ++ swr ?+(r r $d %u, $u %d) :: flipped rounding + ++ swr ?+(r r %d %u, %u %d) :: flipped rounding ++ prc ?>((gth p 1) p) :: force >= 2 precision ++ den d :: denorm+flush+inf exp ++ emn v :: minimum exponent @@ -2524,32 +2524,32 @@ |% ++ rou :: round |= {a/fn} ^- fn - ?. ?=({$f *} a) a + ?. ?=({%f *} a) a ?~ a.a [%f s.a zer] ?: s.a (^rou +>.a) =.(r swr (fli (^rou +>.a))) :: ++ syn :: get sign |= {a/fn} ^- ? - ?-(-.a $f s.a, $i s.a, $n &) + ?-(-.a %f s.a, %i s.a, %n &) :: ++ abs :: absolute value |= {a/fn} ^- fn - ?: ?=({$f *} a) [%f & e.a a.a] - ?: ?=({$i *} a) [%i &] [%n ~] + ?: ?=({%f *} a) [%f & e.a a.a] + ?: ?=({%i *} a) [%i &] [%n ~] :: ++ add :: add |= {a/fn b/fn} ^- fn - ?: |(?=({$n *} a) ?=({$n *} b)) [%n ~] - ?: |(?=({$i *} a) ?=({$i *} b)) - ?: &(?=({$i *} a) ?=({$i *} b)) + ?: |(?=({%n *} a) ?=({%n *} b)) [%n ~] + ?: |(?=({%i *} a) ?=({%i *} b)) + ?: &(?=({%i *} a) ?=({%i *} b)) ?: =(a b) a [%n ~] - ?: ?=({$i *} a) a b + ?: ?=({%i *} a) a b ?: |(=(a.a 0) =(a.b 0)) ?. &(=(a.a 0) =(a.b 0)) %- rou ?~(a.a b a) [%f ?:(=(r %d) &(s.a s.b) |(s.a s.b)) zer] %- |= {a/fn} - ?. ?=({$f *} a) a + ?. ?=({%f *} a) a ?. =(a.a 0) a [%f !=(r %d) zer] ?: =(s.a s.b) @@ -2560,16 +2560,16 @@ :: ++ ead :: exact add |= {a/fn b/fn} ^- fn - ?: |(?=({$n *} a) ?=({$n *} b)) [%n ~] - ?: |(?=({$i *} a) ?=({$i *} b)) - ?: &(?=({$i *} a) ?=({$i *} b)) + ?: |(?=({%n *} a) ?=({%n *} b)) [%n ~] + ?: |(?=({%i *} a) ?=({%i *} b)) + ?: &(?=({%i *} a) ?=({%i *} b)) ?: =(a b) a [%n ~] - ?: ?=({$i *} a) a b + ?: ?=({%i *} a) a b ?: |(=(a.a 0) =(a.b 0)) ?. &(=(a.a 0) =(a.b 0)) ?~(a.a b a) [%f ?:(=(r %d) &(s.a s.b) |(s.a s.b)) zer] %- |= {a/fn} - ?. ?=({$f *} a) a + ?. ?=({%f *} a) a ?. =(a.a 0) a [%f !=(r %d) zer] ?: =(s.a s.b) @@ -2583,12 +2583,12 @@ :: ++ mul :: multiply |= {a/fn b/fn} ^- fn - ?: |(?=({$n *} a) ?=({$n *} b)) [%n ~] - ?: ?=({$i *} a) - ?: ?=({$i *} b) + ?: |(?=({%n *} a) ?=({%n *} b)) [%n ~] + ?: ?=({%i *} a) + ?: ?=({%i *} b) [%i =(s.a s.b)] ?: =(a.b 0) [%n ~] [%i =(s.a s.b)] - ?: ?=({$i *} b) + ?: ?=({%i *} b) ?: =(a.a 0) [%n ~] [%i =(s.a s.b)] ?: |(=(a.a 0) =(a.b 0)) [%f =(s.a s.b) zer] ?: =(s.a s.b) (^mul +>.a +>.b) @@ -2596,22 +2596,22 @@ :: ++ emu :: exact multiply |= {a/fn b/fn} ^- fn - ?: |(?=({$n *} a) ?=({$n *} b)) [%n ~] - ?: ?=({$i *} a) - ?: ?=({$i *} b) + ?: |(?=({%n *} a) ?=({%n *} b)) [%n ~] + ?: ?=({%i *} a) + ?: ?=({%i *} b) [%i =(s.a s.b)] ?: =(a.b 0) [%n ~] [%i =(s.a s.b)] - ?: ?=({$i *} b) + ?: ?=({%i *} b) ?: =(a.a 0) [%n ~] [%i =(s.a s.b)] ?: |(=(a.a 0) =(a.b 0)) [%f =(s.a s.b) zer] [%f =(s.a s.b) (sum:si e.a e.b) (^^mul a.a a.b)] :: ++ div :: divide |= {a/fn b/fn} ^- fn - ?: |(?=({$n *} a) ?=({$n *} b)) [%n ~] - ?: ?=({$i *} a) - ?: ?=({$i *} b) [%n ~] [%i =(s.a s.b)] - ?: ?=({$i *} b) [%f =(s.a s.b) zer] + ?: |(?=({%n *} a) ?=({%n *} b)) [%n ~] + ?: ?=({%i *} a) + ?: ?=({%i *} b) [%n ~] [%i =(s.a s.b)] + ?: ?=({%i *} b) [%f =(s.a s.b) zer] ?: =(a.a 0) ?: =(a.b 0) [%n ~] [%f =(s.a s.b) zer] ?: =(a.b 0) [%i =(s.a s.b)] ?: =(s.a s.b) (^div +>.a +>.b) @@ -2623,8 +2623,8 @@ :: ++ sqt :: square root |= {a/fn} ^- fn - ?: ?=({$n *} a) [%n ~] - ?: ?=({$i *} a) ?:(s.a a [%n ~]) + ?: ?=({%n *} a) [%n ~] + ?: ?=({%i *} a) ?:(s.a a [%n ~]) ?~ a.a [%f s.a zer] ?: s.a (^sqt +>.a) [%n ~] :: @@ -2644,9 +2644,9 @@ :: comparisons return ~ in the event of a NaN ++ lth :: less-than |= {a/fn b/fn} ^- (unit ?) - ?: |(?=({$n *} a) ?=({$n *} b)) ~ :- ~ + ?: |(?=({%n *} a) ?=({%n *} b)) ~ :- ~ ?: =(a b) | - ?: ?=({$i *} a) !s.a ?: ?=({$i *} b) s.b + ?: ?=({%i *} a) !s.a ?: ?=({%i *} b) s.b ?: |(=(a.a 0) =(a.b 0)) ?: &(=(a.a 0) =(a.b 0)) | ?: =(a.a 0) s.b !s.a @@ -2659,9 +2659,9 @@ :: ++ equ :: equal |= {a/fn b/fn} ^- (unit ?) - ?: |(?=({$n *} a) ?=({$n *} b)) ~ :- ~ + ?: |(?=({%n *} a) ?=({%n *} b)) ~ :- ~ ?: =(a b) & - ?: |(?=({$i *} a) ?=({$i *} b)) | + ?: |(?=({%i *} a) ?=({%i *} b)) | ?: |(=(a.a 0) =(a.b 0)) ?: &(=(a.a 0) =(a.b 0)) & | ?: |(=(e.a e.b) !=(s.a s.b)) | @@ -2675,15 +2675,15 @@ :: ++ drg :: float to decimal |= {a/fn} ^- dn - ?: ?=({$n *} a) [%n ~] - ?: ?=({$i *} a) [%i s.a] + ?: ?=({%n *} a) [%n ~] + ?: ?=({%i *} a) [%i s.a] ?~ a.a [%d s.a --0 0] [%d s.a (^drg +>.a)] :: ++ grd :: decimal to float |= {a/dn} ^- fn - ?: ?=({$n *} a) [%n ~] - ?: ?=({$i *} a) [%i s.a] + ?: ?=({%n *} a) [%n ~] + ?: ?=({%i *} a) [%i s.a] => .(r %n) =+ q=(abs:si e.a) ?: (syn:si e.a) @@ -2693,20 +2693,20 @@ ++ toi :: round to integer @s |= {a/fn} ^- (unit @s) =+ b=(toj a) - ?. ?=({$f *} b) ~ :- ~ + ?. ?=({%f *} b) ~ :- ~ =+ c=(^^mul (bex (abs:si e.b)) a.b) (new:si s.b c) :: ++ toj :: round to integer fn |= {a/fn} ^- fn - ?. ?=({$f *} a) a + ?. ?=({%f *} a) a ?~ a.a [%f s.a zer] ?: s.a (^toj +>.a) =.(r swr (fli (^toj +>.a))) -- :: ++ ff :: ieee 754 format fp - |_ {{w/@u p/@u b/@s} r/$?($n $u $d $z $a)} + |_ {{w/@u p/@u b/@s} r/$?(%n %u %d %z %a)} :: this core has no use outside of the functionality :: provided to ++rd, ++rs, ++rq, and ++rh :: @@ -2737,10 +2737,10 @@ :: ++ bif :: fn to @r no rounding |= {a/fn} ^- @r - ?: ?=({$i *} a) + ?: ?=({%i *} a) =+ q=(lsh 0 p (fil 0 w 1)) ?: s.a q (^add q sb) - ?: ?=({$n *} a) (lsh 0 (dec p) (fil 0 +(w) 1)) + ?: ?=({%n *} a) (lsh 0 (dec p) (fil 0 +(w) 1)) ?~ a.a ?: s.a `@r`0 sb =+ ma=(met 0 a.a) ?. =(ma +(p)) @@ -2817,7 +2817,7 @@ ++ rd :: double precision fp ^| ~% %rd +> ~ - |_ r/$?($n $u $d $z) + |_ r/$?(%n %u %d %z) :: round to nearest, round up, round down, round to zero :: ++ ma @@ -2895,7 +2895,7 @@ ++ rs :: single precision fp ~% %rs +> ~ ^| - |_ r/$?($n $u $d $z) + |_ r/$?(%n %u %d %z) :: round to nearest, round up, round down, round to zero :: ++ ma @@ -2974,7 +2974,7 @@ ++ rq :: quad precision fp ~% %rq +> ~ ^| - |_ r/$?($n $u $d $z) + |_ r/$?(%n %u %d %z) :: round to nearest, round up, round down, round to zero :: ++ ma @@ -3053,7 +3053,7 @@ ++ rh :: half precision fp ~% %rh +> ~ ^| - |_ r/$?($n $u $d $z) + |_ r/$?(%n %u %d %z) :: round to nearest, round up, round down, round to zero :: ++ ma @@ -3998,9 +3998,9 @@ :::: 3g: molds and mold builders :: ++ coin $~ [%$ %ud 0] :: print format - $% {$$ p/dime} :: - {$blob p/*} :: - {$many p/(list coin)} :: + $% {%$ p/dime} :: + {%blob p/*} :: + {%many p/(list coin)} :: == :: ++ dime {p/@ta q/@} :: ++ edge {p/hair q/(unit {p/* q/nail})} :: parsing output @@ -4016,13 +4016,13 @@ ++ pint {p/{p/@ q/@} q/{p/@ q/@}} :: line+column range ++ rule _|:($:nail $:edge) :: parsing rule ++ spot {p/path q/pint} :: range in file -++ tone $% {$0 product/*} :: success - {$1 block/*} :: single block - {$2 trace/(list {@ta *})} :: error report +++ tone $% {%0 product/*} :: success + {%1 block/*} :: single block + {%2 trace/(list {@ta *})} :: error report == :: -++ toon $% {$0 p/*} :: success - {$1 p/*} :: block - {$2 p/(list tank)} :: stack trace +++ toon $% {%0 p/*} :: success + {%1 p/*} :: block + {%2 p/(list tank)} :: stack trace == :: ++ wonk =+ veq=$:edge :: product from edge |@ ++ $ ?~(q.veq !! p.u.q.veq) :: @@ -4331,10 +4331,10 @@ %+ turn ^- (list {p/@ q/@}) ?+ b !! - $1 [[0 7] ~] - $2 [[8 6] [0 5] ~] - $3 [[16 6] [8 6] [0 4] ~] - $4 [[24 6] [16 6] [8 6] [0 3] ~] + %1 [[0 7] ~] + %2 [[8 6] [0 5] ~] + %3 [[16 6] [8 6] [0 4] ~] + %4 [[24 6] [16 6] [8 6] [0 3] ~] == |=({p/@ q/@} [q (cut 0 [p q] a)]) ?> =((tuft c) (end 3 b a)) @@ -4404,8 +4404,8 @@ $(b t.b, c [i.b c]) ?~ t.b [b ~] ?- i.t.b - $'~' $(b t.t.b, c ['~' c]) - $'-' $(b t.t.b, c ['_' c]) + %'~' $(b t.t.b, c ['~' c]) + %'-' $(b t.t.b, c ['_' c]) @ [b ~] == :: @@ -4438,8 +4438,8 @@ ?: &((gte b '0') (lte b '9')) 48 ?>(&((gte b 'a') (lte b 'z')) 87) == - $'.' ['.' $(a c)] - $'~' ['~' $(a c)] + %'.' ['.' $(a c)] + %'~' ['~' $(a c)] == :: ++ wood :: cord escape @@ -4467,9 +4467,9 @@ =+ f=(rsh 2 e c) [(add ?:((lte f 9) 48 87) f) $(c (end 2 e c))] :: - $' ' ['.' d] - $'.' ['~' '.' d] - $'~' ['~' '~' d] + %' ' ['.' d] + %'.' ['~' '.' d] + %'~' ['~' '~' d] == :: :::: 4c: tank printer @@ -4616,40 +4616,40 @@ {s/~ c/*} [%leaf '\'' (weld (mesc (tape +.vem)) `tape`['\'' ~])] :: - {s/$a c/@} [%leaf (mesc (trip c.vem))] - {s/$b c/*} (shop c.vem |=(a/@ ~(rub at a))) - {s/{$c p/@} c/*} + {s/%a c/@} [%leaf (mesc (trip c.vem))] + {s/%b c/*} (shop c.vem |=(a/@ ~(rub at a))) + {s/{%c p/@} c/*} :+ %palm [['.' ~] ['-' ~] ~ ~] [[%leaf (mesc (trip p.s.vem))] $(vem c.vem) ~] :: - {s/$d c/*} (shop c.vem |=(a/@ ~(rud at a))) - {s/$k c/*} (tank c.vem) - {s/$h c/*} + {s/%d c/*} (shop c.vem |=(a/@ ~(rud at a))) + {s/%k c/*} (tank c.vem) + {s/%h c/*} :+ %rose [['/' ~] ['/' ~] ~] =+ yol=((list @ta) c.vem) (turn yol |=(a/@ta [%leaf (trip a)])) :: - {s/$l c/*} (shol c.vem) - {s/$o c/*} + {s/%l c/*} (shol c.vem) + {s/%o c/*} %= $ vem :- [%m '%h::[%d %d].[%d %d]>'] [-.c.vem +<-.c.vem +<+.c.vem +>-.c.vem +>+.c.vem ~] == :: - {s/$p c/*} (shop c.vem |=(a/@ ~(rup at a))) - {s/$q c/*} (shop c.vem |=(a/@ ~(r at a))) - {s/$r c/*} $(vem [[%r ' ' '{' '}'] c.vem]) - {s/$t c/*} (shop c.vem |=(a/@ ~(rt at a))) - {s/$v c/*} (shop c.vem |=(a/@ ~(ruv at a))) - {s/$x c/*} (shop c.vem |=(a/@ ~(rux at a))) - {s/{$m p/@} c/*} (shep p.s.vem c.vem) - {s/{$r p/@} c/*} + {s/%p c/*} (shop c.vem |=(a/@ ~(rup at a))) + {s/%q c/*} (shop c.vem |=(a/@ ~(r at a))) + {s/%r c/*} $(vem [[%r ' ' '{' '}'] c.vem]) + {s/%t c/*} (shop c.vem |=(a/@ ~(rt at a))) + {s/%v c/*} (shop c.vem |=(a/@ ~(ruv at a))) + {s/%x c/*} (shop c.vem |=(a/@ ~(rux at a))) + {s/{%m p/@} c/*} (shep p.s.vem c.vem) + {s/{%r p/@} c/*} $(vem [[%r ' ' (cut 3 [0 1] p.s.vem) (cut 3 [1 1] p.s.vem)] c.vem]) :: - {s/{$r p/@ q/@ r/@} c/*} + {s/{%r p/@ q/@ r/@} c/*} :+ %rose :* p=(mesc (trip p.s.vem)) q=(mesc (trip q.s.vem)) @@ -4660,7 +4660,7 @@ ~ [^$(vem -.c.vem) $(c.vem +.c.vem)] :: - {s/$z c/*} $(vem [[%r %$ %$ %$] c.vem]) + {s/%z c/*} $(vem [[%r %$ %$ %$] c.vem]) * !! == ++ shep @@ -4703,7 +4703,7 @@ ?+ -.lim (show '#') ~ (show '$') c/@ (show c.lim) - {%& $1} (show '.') + {%& %1} (show '.') {%& c/@} [%leaf '+' ~(rud at c.lim)] :: @@ -5746,16 +5746,16 @@ (cook |=(det/date `dime`[%da (year det)]) when) :: %+ cook - |= {a/(list {p/?($d $h $m $s) q/@}) b/(list @)} + |= {a/(list {p/?(%d %h %m %s) q/@}) b/(list @)} =+ rop=`tarp`[0 0 0 0 b] |- ^- dime ?~ a [%dr (yule rop)] ?- p.i.a - $d $(a t.a, d.rop (add q.i.a d.rop)) - $h $(a t.a, h.rop (add q.i.a h.rop)) - $m $(a t.a, m.rop (add q.i.a m.rop)) - $s $(a t.a, s.rop (add q.i.a s.rop)) + %d $(a t.a, d.rop (add q.i.a d.rop)) + %h $(a t.a, h.rop (add q.i.a h.rop)) + %m $(a t.a, m.rop (add q.i.a m.rop)) + %s $(a t.a, s.rop (add q.i.a s.rop)) == ;~ plug %+ most @@ -5849,7 +5849,7 @@ ++ royl-cell |= rn ^- dn - ?. ?=({$d *} +<) +< + ?. ?=({%d *} +<) +< =+ ^= h (dif:si (new:si f.b i.b) (sun:si d.b)) [%d a h (add (mul c.b (pow 10 d.b)) e.b)] @@ -5931,7 +5931,7 @@ :: slow fallback case to the full slay :: =+ con=(slay txt) - ?.(&(?=({~ $$ @ @} con) =(p.p.u.con mod)) ~ [~ q.p.u.con]) + ?.(&(?=({~ %$ @ @} con) =(p.p.u.con mod)) ~ [~ q.p.u.con]) :: %da (rush txt ;~(pfix sig (cook year when:so))) @@ -6152,7 +6152,7 @@ ++ mock |= [[sub=* fol=*] gul=$-(^ (unit (unit)))] (mook (mink [sub fol] gul)) -:: +mook: convert $tone to $toon, rendering stack frames +:: +mook: convert %tone to %toon, rendering stack frames :: ++ mook |= ton=tone @@ -6287,13 +6287,13 @@ +$ atom @ :: just an atom +$ aura @ta :: atom format +$ base :: base mold - $@ $? $noun :: any noun - $cell :: any cell - $flag :: loobean - $null :: ~ == 0 - $void :: empty set + $@ $? %noun :: any noun + %cell :: any cell + %flag :: loobean + %null :: ~ == 0 + %void :: empty set == :: - {$atom p/aura} :: atom + {%atom p/aura} :: atom :: +$ woof $@(@ {~ p/hoon}) :: simple embed +$ chum $? lef/term :: jet name @@ -6307,8 +6307,8 @@ == :: +$ garb (trel (unit term) poly vair) :: core +$ poly ?(%wet %dry) :: polarity -+$ foot $% {$dry p/hoon} :: dry arm, geometric - {$wet p/hoon} :: wet arm, generic ++$ foot $% {%dry p/hoon} :: dry arm, geometric + {%wet p/hoon} :: wet arm, generic == :: +$ link :: lexical segment $% [%chat p/term] :: |chapter @@ -6342,36 +6342,36 @@ +$ port (each palo (pair type nock)) :: successful match +$ spec :: structure definition $~ [%base %null] :: - $% {$base p/base} :: base type - {$dbug p/spot q/spec} :: set debug - {$leaf p/term q/@} :: constant atom - {$like p/wing q/(list wing)} :: reference - {$loop p/term} :: hygienic reference - {$made p/(pair term (list term)) q/spec} :: annotate synthetic - {$make p/hoon q/(list spec)} :: composed spec - {$name p/term q/spec} :: annotate simple - {$over p/wing q/spec} :: relative to subject + $% {%base p/base} :: base type + {%dbug p/spot q/spec} :: set debug + {%leaf p/term q/@} :: constant atom + {%like p/wing q/(list wing)} :: reference + {%loop p/term} :: hygienic reference + {%made p/(pair term (list term)) q/spec} :: annotate synthetic + {%make p/hoon q/(list spec)} :: composed spec + {%name p/term q/spec} :: annotate simple + {%over p/wing q/spec} :: relative to subject :: :: - {$bcgr p/spec q/spec} :: $>, filter: require - {$bcbc p/spec q/(map term spec)} :: $$, recursion - {$bcbr p/spec q/hoon} :: $|, verify - {$bccb p/hoon} :: $_, example - {$bccl p/{i/spec t/(list spec)}} :: $:, tuple - {$bccn p/{i/spec t/(list spec)}} :: $%, head pick - {$bcdt p/spec q/(map term spec)} :: $., read-write core - {$bcgl p/spec q/spec} :: $<, filter: exclude - {$bchp p/spec q/spec} :: $-, function core - {$bckt p/spec q/spec} :: $^, cons pick - {$bcls p/stud q/spec} :: $+, standard - {$bcfs p/spec q/(map term spec)} :: $/, write-only core - {$bcmc p/hoon} :: $;, manual - {$bcpm p/spec q/hoon} :: $&, repair - {$bcsg p/hoon q/spec} :: $~, default - {$bctc p/spec q/(map term spec)} :: $`, read-only core - {$bcts p/skin q/spec} :: $=, name - {$bcpt p/spec q/spec} :: $@, atom pick - {$bcwt p/{i/spec t/(list spec)}} :: $?, full pick - {$bczp p/spec q/(map term spec)} :: $!, opaque core + {%bcgr p/spec q/spec} :: $>, filter: require + {%bcbc p/spec q/(map term spec)} :: $$, recursion + {%bcbr p/spec q/hoon} :: $|, verify + {%bccb p/hoon} :: $_, example + {%bccl p/{i/spec t/(list spec)}} :: $:, tuple + {%bccn p/{i/spec t/(list spec)}} :: $%, head pick + {%bcdt p/spec q/(map term spec)} :: $., read-write core + {%bcgl p/spec q/spec} :: $<, filter: exclude + {%bchp p/spec q/spec} :: $-, function core + {%bckt p/spec q/spec} :: $^, cons pick + {%bcls p/stud q/spec} :: $+, standard + {%bcfs p/spec q/(map term spec)} :: $/, write-only core + {%bcmc p/hoon} :: $;, manual + {%bcpm p/spec q/hoon} :: $&, repair + {%bcsg p/hoon q/spec} :: $~, default + {%bctc p/spec q/(map term spec)} :: $`, read-only core + {%bcts p/skin q/spec} :: $=, name + {%bcpt p/spec q/spec} :: $@, atom pick + {%bcwt p/{i/spec t/(list spec)}} :: $?, full pick + {%bczp p/spec q/(map term spec)} :: $!, opaque core == :: +$ tent :: model builder $% {%| p/wing q/tent r/(list spec)} :: ~(p q r...) @@ -6412,7 +6412,7 @@ +$ tuna :: maybe interpolation $~ [[%$ ~] ~] $^ manx - $: ?($tape $manx $marl $call) + $: ?(%tape %manx %marl %call) p/hoon == -- :: @@ -6420,173 +6420,173 @@ $~ [%zpzp ~] $^ {p/hoon q/hoon} :: $% :: - {$$ p/axis} :: simple leg + {%$ p/axis} :: simple leg :: :: - {$base p/base} :: base spec - {$bust p/base} :: bunt base - {$dbug p/spot q/hoon} :: debug info in trace - {$eror p/tape} :: assembly error - {$hand p/type q/nock} :: premade result - {$note p/note q/hoon} :: annotate - {$fits p/hoon q/wing} :: underlying ?= - {$knit p/(list woof)} :: assemble string - {$leaf p/(pair term @)} :: symbol spec - {$limb p/term} :: take limb - {$lost p/hoon} :: not to be taken - {$rock p/term q/*} :: fixed constant - {$sand p/term q/*} :: unfixed constant - {$tell p/(list hoon)} :: render as tape - {$tune p/$@(term tune)} :: minimal face - {$wing p/wing} :: take wing - {$yell p/(list hoon)} :: render as tank - {$xray p/manx:hoot} :: ;foo; templating + {%base p/base} :: base spec + {%bust p/base} :: bunt base + {%dbug p/spot q/hoon} :: debug info in trace + {%eror p/tape} :: assembly error + {%hand p/type q/nock} :: premade result + {%note p/note q/hoon} :: annotate + {%fits p/hoon q/wing} :: underlying ?= + {%knit p/(list woof)} :: assemble string + {%leaf p/(pair term @)} :: symbol spec + {%limb p/term} :: take limb + {%lost p/hoon} :: not to be taken + {%rock p/term q/*} :: fixed constant + {%sand p/term q/*} :: unfixed constant + {%tell p/(list hoon)} :: render as tape + {%tune p/$@(term tune)} :: minimal face + {%wing p/wing} :: take wing + {%yell p/(list hoon)} :: render as tank + {%xray p/manx:hoot} :: ;foo; templating :: :::::: cores - {$brbc sample/(lest term) body/spec} :: |$ - {$brcb p/spec q/alas r/(map term tome)} :: |_ - {$brcl p/hoon q/hoon} :: |: - {$brcn p/(unit term) q/(map term tome)} :: |% - {$brdt p/hoon} :: |. - {$brkt p/hoon q/(map term tome)} :: |^ - {$brhp p/hoon} :: |- - {$brsg p/spec q/hoon} :: |~ - {$brtr p/spec q/hoon} :: |* - {$brts p/spec q/hoon} :: |= - {$brpt p/(unit term) q/(map term tome)} :: |@ - {$brwt p/hoon} :: |? + {%brbc sample/(lest term) body/spec} :: |$ + {%brcb p/spec q/alas r/(map term tome)} :: |_ + {%brcl p/hoon q/hoon} :: |: + {%brcn p/(unit term) q/(map term tome)} :: |% + {%brdt p/hoon} :: |. + {%brkt p/hoon q/(map term tome)} :: |^ + {%brhp p/hoon} :: |- + {%brsg p/spec q/hoon} :: |~ + {%brtr p/spec q/hoon} :: |* + {%brts p/spec q/hoon} :: |= + {%brpt p/(unit term) q/(map term tome)} :: |@ + {%brwt p/hoon} :: |? :: :::::: tuples - {$clcb p/hoon q/hoon} :: :_ [q p] - {$clkt p/hoon q/hoon r/hoon s/hoon} :: :^ [p q r s] - {$clhp p/hoon q/hoon} :: :- [p q] - {$clls p/hoon q/hoon r/hoon} :: :+ [p q r] - {$clsg p/(list hoon)} :: :~ [p ~] - {$cltr p/(list hoon)} :: :* p as a tuple + {%clcb p/hoon q/hoon} :: :_ [q p] + {%clkt p/hoon q/hoon r/hoon s/hoon} :: :^ [p q r s] + {%clhp p/hoon q/hoon} :: :- [p q] + {%clls p/hoon q/hoon r/hoon} :: :+ [p q r] + {%clsg p/(list hoon)} :: :~ [p ~] + {%cltr p/(list hoon)} :: :* p as a tuple :: :::::: invocations - {$cncb p/wing q/(list (pair wing hoon))} :: %_ - {$cndt p/hoon q/hoon} :: %. - {$cnhp p/hoon q/hoon} :: %- - {$cncl p/hoon q/(list hoon)} :: %: - {$cntr p/wing q/hoon r/(list (pair wing hoon))} :: %* - {$cnkt p/hoon q/hoon r/hoon s/hoon} :: %^ - {$cnls p/hoon q/hoon r/hoon} :: %+ - {$cnsg p/wing q/hoon r/(list hoon)} :: %~ - {$cnts p/wing q/(list (pair wing hoon))} :: %= + {%cncb p/wing q/(list (pair wing hoon))} :: %_ + {%cndt p/hoon q/hoon} :: %. + {%cnhp p/hoon q/hoon} :: %- + {%cncl p/hoon q/(list hoon)} :: %: + {%cntr p/wing q/hoon r/(list (pair wing hoon))} :: %* + {%cnkt p/hoon q/hoon r/hoon s/hoon} :: %^ + {%cnls p/hoon q/hoon r/hoon} :: %+ + {%cnsg p/wing q/hoon r/(list hoon)} :: %~ + {%cnts p/wing q/(list (pair wing hoon))} :: %= :: :::::: nock - {$dtkt p/spec q/hoon} :: .^ nock 11 - {$dtls p/hoon} :: .+ nock 4 - {$dttr p/hoon q/hoon} :: .* nock 2 - {$dtts p/hoon q/hoon} :: .= nock 5 - {$dtwt p/hoon} :: .? nock 3 + {%dtkt p/spec q/hoon} :: .^ nock 11 + {%dtls p/hoon} :: .+ nock 4 + {%dttr p/hoon q/hoon} :: .* nock 2 + {%dtts p/hoon q/hoon} :: .= nock 5 + {%dtwt p/hoon} :: .? nock 3 :: :::::: type conversion - {$ktbr p/hoon} :: ^| contravariant - {$ktcn p/hoon} :: ^% enter test mode - {$ktdt p/hoon q/hoon} :: ^. self-cast - {$ktls p/hoon q/hoon} :: ^+ expression cast - {$kthp p/spec q/hoon} :: ^- structure cast - {$ktpm p/hoon} :: ^& covariant - {$ktsg p/hoon} :: ^~ constant - {$ktts p/skin q/hoon} :: ^= label - {$ktwt p/hoon} :: ^? bivariant - {$kttr p/spec} :: ^* example - {$ktcl p/spec} :: ^: filter + {%ktbr p/hoon} :: ^| contravariant + {%ktcn p/hoon} :: ^% enter test mode + {%ktdt p/hoon q/hoon} :: ^. self-cast + {%ktls p/hoon q/hoon} :: ^+ expression cast + {%kthp p/spec q/hoon} :: ^- structure cast + {%ktpm p/hoon} :: ^& covariant + {%ktsg p/hoon} :: ^~ constant + {%ktts p/skin q/hoon} :: ^= label + {%ktwt p/hoon} :: ^? bivariant + {%kttr p/spec} :: ^* example + {%ktcl p/spec} :: ^: filter :: :::::: hints - {$sgbr p/hoon q/hoon} :: ~| sell on trace - {$sgcb p/hoon q/hoon} :: ~_ tank on trace - {$sgcn p/chum q/hoon r/tyre s/hoon} :: ~% general jet hint - {$sgfs p/chum q/hoon} :: ~/ function j-hint - {$sggl p/$@(term {p/term q/hoon}) q/hoon} :: ~< backward hint - {$sggr p/$@(term {p/term q/hoon}) q/hoon} :: ~> forward hint - {$sgbc p/term q/hoon} :: ~$ profiler hit - {$sgls p/@ q/hoon} :: ~+ cache/memoize - {$sgpm p/@ud q/hoon r/hoon} :: ~& printf/priority - {$sgts p/hoon q/hoon} :: ~= don't duplicate - {$sgwt p/@ud q/hoon r/hoon s/hoon} :: ~? tested printf - {$sgzp p/hoon q/hoon} :: ~! type on trace + {%sgbr p/hoon q/hoon} :: ~| sell on trace + {%sgcb p/hoon q/hoon} :: ~_ tank on trace + {%sgcn p/chum q/hoon r/tyre s/hoon} :: ~% general jet hint + {%sgfs p/chum q/hoon} :: ~/ function j-hint + {%sggl p/$@(term {p/term q/hoon}) q/hoon} :: ~< backward hint + {%sggr p/$@(term {p/term q/hoon}) q/hoon} :: ~> forward hint + {%sgbc p/term q/hoon} :: ~$ profiler hit + {%sgls p/@ q/hoon} :: ~+ cache/memoize + {%sgpm p/@ud q/hoon r/hoon} :: ~& printf/priority + {%sgts p/hoon q/hoon} :: ~= don't duplicate + {%sgwt p/@ud q/hoon r/hoon s/hoon} :: ~? tested printf + {%sgzp p/hoon q/hoon} :: ~! type on trace :: :::::: miscellaneous - {$mcts p/marl:hoot} :: ;= list templating - {$mccl p/hoon q/(list hoon)} :: ;: binary to nary - {$mcfs p/hoon} :: ;/ [%$ [%$ p ~] ~] - {$mcgl p/spec q/hoon r/hoon s/hoon} :: ;< bind - {$mcsg p/hoon q/(list hoon)} :: ;~ kleisli arrow - {$mcmc p/spec q/hoon} :: ;; normalize + {%mcts p/marl:hoot} :: ;= list templating + {%mccl p/hoon q/(list hoon)} :: ;: binary to nary + {%mcfs p/hoon} :: ;/ [%$ [%$ p ~] ~] + {%mcgl p/spec q/hoon r/hoon s/hoon} :: ;< bind + {%mcsg p/hoon q/(list hoon)} :: ;~ kleisli arrow + {%mcmc p/spec q/hoon} :: ;; normalize :: :::::: compositions - {$tsbr p/spec q/hoon} :: =| push bunt - {$tscl p/(list (pair wing hoon)) q/hoon} :: =: q w/ p changes - {$tsfs p/skin q/hoon r/hoon} :: =/ typed variable - {$tsmc p/skin q/hoon r/hoon} :: =; =/(q p r) - {$tsdt p/wing q/hoon r/hoon} :: =. r with p as q - {$tswt p/wing q/hoon r/hoon s/hoon} :: =? conditional =. - {$tsgl p/hoon q/hoon} :: =< =>(q p) - {$tshp p/hoon q/hoon} :: =- =+(q p) - {$tsgr p/hoon q/hoon} :: => q w/subject p - {$tskt p/skin q/wing r/hoon s/hoon} :: =^ state machine - {$tsls p/hoon q/hoon} :: =+ q w/[p subject] - {$tssg p/(list hoon)} :: =~ hoon stack - {$tstr p/(pair term (unit spec)) q/hoon r/hoon} :: =* new style - {$tscm p/hoon q/hoon} :: =, overload p in q + {%tsbr p/spec q/hoon} :: =| push bunt + {%tscl p/(list (pair wing hoon)) q/hoon} :: =: q w/ p changes + {%tsfs p/skin q/hoon r/hoon} :: =/ typed variable + {%tsmc p/skin q/hoon r/hoon} :: =; =/(q p r) + {%tsdt p/wing q/hoon r/hoon} :: =. r with p as q + {%tswt p/wing q/hoon r/hoon s/hoon} :: =? conditional =. + {%tsgl p/hoon q/hoon} :: =< =>(q p) + {%tshp p/hoon q/hoon} :: =- =+(q p) + {%tsgr p/hoon q/hoon} :: => q w/subject p + {%tskt p/skin q/wing r/hoon s/hoon} :: =^ state machine + {%tsls p/hoon q/hoon} :: =+ q w/[p subject] + {%tssg p/(list hoon)} :: =~ hoon stack + {%tstr p/(pair term (unit spec)) q/hoon r/hoon} :: =* new style + {%tscm p/hoon q/hoon} :: =, overload p in q :: :::::: conditionals - {$wtbr p/(list hoon)} :: ?| loobean or - {$wthp p/wing q/(list (pair spec hoon))} :: ?- pick case in q - {$wtcl p/hoon q/hoon r/hoon} :: ?: if/then/else - {$wtdt p/hoon q/hoon r/hoon} :: ?. ?:(p r q) - {$wtkt p/wing q/hoon r/hoon} :: ?^ if p is a cell - {$wtgl p/hoon q/hoon} :: ?< ?:(p !! q) - {$wtgr p/hoon q/hoon} :: ?> ?:(p q !!) - {$wtls p/wing q/hoon r/(list (pair spec hoon))} :: ?+ ?- w/default - {$wtpm p/(list hoon)} :: ?& loobean and - {$wtpt p/wing q/hoon r/hoon} :: ?@ if p is atom - {$wtsg p/wing q/hoon r/hoon} :: ?~ if p is null - {$wthx p/skin q/wing} :: ?# if q matches p - {$wtts p/spec q/wing} :: ?= if q matches p - {$wtzp p/hoon} :: ?! loobean not + {%wtbr p/(list hoon)} :: ?| loobean or + {%wthp p/wing q/(list (pair spec hoon))} :: ?- pick case in q + {%wtcl p/hoon q/hoon r/hoon} :: ?: if/then/else + {%wtdt p/hoon q/hoon r/hoon} :: ?. ?:(p r q) + {%wtkt p/wing q/hoon r/hoon} :: ?^ if p is a cell + {%wtgl p/hoon q/hoon} :: ?< ?:(p !! q) + {%wtgr p/hoon q/hoon} :: ?> ?:(p q !!) + {%wtls p/wing q/hoon r/(list (pair spec hoon))} :: ?+ ?- w/default + {%wtpm p/(list hoon)} :: ?& loobean and + {%wtpt p/wing q/hoon r/hoon} :: ?@ if p is atom + {%wtsg p/wing q/hoon r/hoon} :: ?~ if p is null + {%wthx p/skin q/wing} :: ?# if q matches p + {%wtts p/spec q/wing} :: ?= if q matches p + {%wtzp p/hoon} :: ?! loobean not :: :::::: special - {$zpcm p/hoon q/hoon} :: !, - {$zpgr p/hoon} :: !> - {$zpgl p/spec q/hoon} :: !< - {$zpmc p/hoon q/hoon} :: !; - {$zpts p/hoon} :: != - {$zppt p/(list wing) q/hoon r/hoon} :: !@ - {$zpwt p/$@(p/@ {p/@ q/@}) q/hoon} :: !? - {$zpzp ~} :: !! + {%zpcm p/hoon q/hoon} :: !, + {%zpgr p/hoon} :: !> + {%zpgl p/spec q/hoon} :: !< + {%zpmc p/hoon q/hoon} :: !; + {%zpts p/hoon} :: != + {%zppt p/(list wing) q/hoon r/hoon} :: !@ + {%zpwt p/$@(p/@ {p/@ q/@}) q/hoon} :: !? + {%zpzp ~} :: !! == :: +$ tyre (list {p/term q/hoon}) :: +$ tyke (list (unit hoon)) :: :: :::::: virtual nock +$ nock $^ {p/nock q/nock} :: autocons - $% {$1 p/*} :: constant - {$2 p/nock q/nock} :: compose - {$3 p/nock} :: cell test - {$4 p/nock} :: increment - {$5 p/nock q/nock} :: equality test - {$6 p/nock q/nock r/nock} :: if, then, else - {$7 p/nock q/nock} :: serial compose - {$8 p/nock q/nock} :: push onto subject - {$9 p/@ q/nock} :: select arm and fire - {$10 p/{p/@ q/nock} q/nock} :: edit - {$11 p/$@(@ {p/@ q/nock}) q/nock} :: hint - {$12 p/nock q/nock} :: grab data from sky - {$0 p/@} :: axis select + $% {%1 p/*} :: constant + {%2 p/nock q/nock} :: compose + {%3 p/nock} :: cell test + {%4 p/nock} :: increment + {%5 p/nock q/nock} :: equality test + {%6 p/nock q/nock r/nock} :: if, then, else + {%7 p/nock q/nock} :: serial compose + {%8 p/nock q/nock} :: push onto subject + {%9 p/@ q/nock} :: select arm and fire + {%10 p/{p/@ q/nock} q/nock} :: edit + {%11 p/$@(@ {p/@ q/nock}) q/nock} :: hint + {%12 p/nock q/nock} :: grab data from sky + {%0 p/@} :: axis select == :: +$ note :: type annotation - $% {$help p/help} :: documentation - {$know p/stud} :: global standard - {$made p/term q/(unit (list wing))} :: structure + $% {%help p/help} :: documentation + {%know p/stud} :: global standard + {%made p/term q/(unit (list wing))} :: structure == :: +$ type $~ %noun :: - $@ $? $noun :: any nouns - $void :: no noun + $@ $? %noun :: any nouns + %void :: no noun == :: - $% {$atom p/term q/(unit @)} :: atom / constant - {$cell p/type q/type} :: ordered pair - {$core p/type q/coil} :: object - {$face p/$@(term tune) q/type} :: namespace - {$fork p/(set type)} :: union - {$hint p/(pair type note) q/type} :: annotation - {$hold p/type q/hoon} :: lazy evaluation + $% {%atom p/term q/(unit @)} :: atom / constant + {%cell p/type q/type} :: ordered pair + {%core p/type q/coil} :: object + {%face p/$@(term tune) q/type} :: namespace + {%fork p/(set type)} :: union + {%hint p/(pair type note) q/type} :: annotation + {%hold p/type q/hoon} :: lazy evaluation == :: +$ tony :: ++tone done right - $% {$0 p/tine q/*} :: success - {$1 p/(set)} :: blocks - {$2 p/(list {@ta *})} :: error ~_s + $% {%0 p/tine q/*} :: success + {%1 p/(set)} :: blocks + {%2 p/(list {@ta *})} :: error ~_s == :: +$ tine :: partial noun $@ ~ :: open @@ -6602,8 +6602,8 @@ +$ typo type :: old type +$ vase {p/type q/*} :: type-value pair +$ vise {p/typo q/*} :: old vase -+$ vial ?($read $rite $both $free) :: co/contra/in/bi -+$ vair ?($gold $iron $lead $zinc) :: in/contra/bi/co ++$ vial ?(%read %rite %both %free) :: co/contra/in/bi ++$ vair ?(%gold %iron %lead %zinc) :: in/contra/bi/co +$ vein (list (unit axis)) :: search trace +$ sect (list pica) :: paragraph +$ whit :: @@ -6779,7 +6779,7 @@ ~ :: 0; fragment :: - {$0 b/@} + {%0 b/@} :: if bad axis, stop :: ?: =(0 b.fol) ~ @@ -6789,14 +6789,14 @@ :: :: 1; constant :: - {$1 b/*} + {%1 b/*} :: constant is complete :: [full/~ b.fol] :: :: 2; recursion :: - {$2 b/* c/*} + {%2 b/* c/*} :: require complete formula :: %+ require @@ -6818,7 +6818,7 @@ :: :: 3; probe :: - {$3 b/*} + {%3 b/*} %+ require $(fol b.fol) |= :: fig: probe input @@ -6830,7 +6830,7 @@ :: :: 4; increment :: - {$4 b/*} + {%4 b/*} %+ require $(fol b.fol) |= :: fig: increment input @@ -6842,7 +6842,7 @@ :: :: 5; compare :: - {$5 b/* c/*} + {%5 b/* c/*} %+ require $(fol b.fol) |= :: hed: left input @@ -6857,7 +6857,7 @@ :: :: 6; if-then-else :: - {$6 b/* c/* d/*} + {%6 b/* c/* d/*} :: semantic expansion :: %+ require @@ -6875,7 +6875,7 @@ :: :: 7; composition :: - {$7 b/* c/*} + {%7 b/* c/*} :: one: input :: =+ one=$(fol b.fol) @@ -6888,7 +6888,7 @@ :: :: 8; introduction :: - {$8 b/* c/*} + {%8 b/* c/*} :: one: input :: =+ one=$(fol b.fol) @@ -6901,7 +6901,7 @@ :: :: 9; invocation :: - {$9 b/* c/*} + {%9 b/* c/*} :: semantic expansion :: ?^ b.fol ~ @@ -6935,7 +6935,7 @@ :: :: 10; edit :: - {$10 {b/@ c/*} d/*} + {%10 {b/@ c/*} d/*} :: tar: target of edit :: =+ tar=$(fol d.fol) @@ -6952,14 +6952,14 @@ :: :: 11; static hint :: - {$11 @ c/*} + {%11 @ c/*} :: ignore hint :: $(fol c.fol) :: :: 11; dynamic hint :: - {$11 {b/* c/*} d/*} + {%11 {b/* c/*} d/*} :: noy: dynamic hint :: =+ noy=$(fol c.fol) @@ -6968,7 +6968,7 @@ ?~ noy ~ :: if hint is a fully computed trace :: - ?: &(?=($spot b.fol) ?=([[%full ~] *] noy)) + ?: &(?=(%spot b.fol) ?=([[%full ~] *] noy)) :: compute within trace :: ~_((show %o +.noy) $(fol d.fol)) @@ -7002,7 +7002,7 @@ tal/seminoun == ^- seminoun - ?. ?& &(?=($full -.mask.hed) ?=($full -.mask.tal)) + ?. ?& &(?=(%full -.mask.hed) ?=(%full -.mask.tal)) =(=(~ blocks.mask.hed) =(~ blocks.mask.tal)) == :: default merge @@ -7024,8 +7024,8 @@ |= bus/seminoun ^- seminoun ?- -.mask.bus - $full bus - $lazy :: fragment 1 is the whole thing + %full bus + %lazy :: fragment 1 is the whole thing :: ?: =(1 fragment.mask.bus) :: blocked; we can't get fragment 1 while compiling it @@ -7043,7 +7043,7 @@ :: else use value :: [[%full ~] u.-] - $half :: recursive descent + %half :: recursive descent :: %+ combine $(bus [left.mask.bus -.data.bus]) @@ -7169,10 +7169,10 @@ :: suppress laziness :: =/ bus/seminoun (complete noy) - ?< ?=($lazy -.mask.bus) + ?< ?=(%lazy -.mask.bus) :: if partial block, squash blocks and stop :: - ?: ?=($half -.mask.bus) [full/(squash mask.bus) ~] + ?: ?=(%half -.mask.bus) [full/(squash mask.bus) ~] :: if full block, propagate block :: ?: ?=(^ blocks.mask.bus) [mask.bus ~] @@ -7186,9 +7186,9 @@ |= tyn/stencil ^- (set block) ?- -.tyn - $lazy $(tyn -:(complete tyn ~)) - $full blocks.tyn - $half (~(uni in $(tyn left.tyn)) $(tyn rite.tyn)) + %lazy $(tyn -:(complete tyn ~)) + %full blocks.tyn + %half (~(uni in $(tyn left.tyn)) $(tyn rite.tyn)) == -- :: @@ -7235,28 +7235,28 @@ yed t.yed lez ?: =(%void i.yed) lez - ?: ?=({$fork *} i.yed) (~(uni in lez) p.i.yed) + ?: ?=({%fork *} i.yed) (~(uni in lez) p.i.yed) (~(put in lez) i.yed) == :: ++ cove :: extract [0 *] axis |= nug/nock ?- nug - {$0 *} p.nug - {$11 *} $(nug q.nug) + {%0 *} p.nug + {%11 *} $(nug q.nug) * ~_(leaf+"cove" !!) == ++ comb :: combine two formulas ~/ %comb |= {mal/nock buz/nock} ^- nock - ?: ?&(?=({$0 *} mal) !=(0 p.mal)) - ?: ?&(?=({$0 *} buz) !=(0 p.buz)) + ?: ?&(?=({%0 *} mal) !=(0 p.mal)) + ?: ?&(?=({%0 *} buz) !=(0 p.buz)) [%0 (peg p.mal p.buz)] - ?: ?=({$2 {$0 *} {$0 *}} buz) + ?: ?=({%2 {%0 *} {%0 *}} buz) [%2 [%0 (peg p.mal p.p.buz)] [%0 (peg p.mal p.q.buz)]] [%7 mal buz] - ?: ?=({^ {$0 $1}} mal) + ?: ?=({^ {%0 %1}} mal) [%8 p.mal buz] ?: =([%0 %1] buz) mal @@ -7267,8 +7267,8 @@ |= {pex/nock yom/nock woq/nock} ^- nock ?- pex - {$1 $0} yom - {$1 $1} woq + {%1 %0} yom + {%1 %1} woq * [%6 pex yom woq] == :: @@ -7282,7 +7282,7 @@ :: ?: ?&(=(+(p.vur) p.sed) =((div p.vur 2) (div p.sed 2))) :: [%0 (div p.vur 2)] :: [vur sed] - ?: ?=({{$1 *} {$1 *}} +<) + ?: ?=({{%1 *} {%1 *}} +<) [%1 p.vur p.sed] [vur sed] :: @@ -7319,12 +7319,12 @@ ?: =([%0 0] bos) nif ?: =([%0 0] nif) bos ?- bos - {$1 $1} bos - {$1 $0} nif + {%1 %1} bos + {%1 %0} nif * ?- nif - {$1 $1} nif - {$1 $0} bos + {%1 %1} nif + {%1 %0} bos * [%6 bos nif [%1 1]] == == @@ -7343,12 +7343,12 @@ ?: =([%0 0] bos) nif ?: =([%0 0] nif) bos ?- bos - {$1 $1} nif - {$1 $0} bos + {%1 %1} nif + {%1 %0} bos * ?- nif - {$1 $1} bos - {$1 $0} nif + {%1 %1} bos + {%1 %0} nif * [%6 bos [%1 0] nif] == == @@ -7423,12 +7423,12 @@ ~ ?:(rad [%rock p.lot] [%sand p.lot]) :: - $blob + %blob ?: rad [%rock %$ p.lot] ?@(p.lot [%sand %$ p.lot] [$(p.lot -.p.lot) $(p.lot +.p.lot)]) :: - $many + %many [%cltr (turn p.lot |=(a/coin ^$(lot a)))] == :: @@ -7569,36 +7569,36 @@ :: |- ^- (unit term) ?- -.mod - $base ?.(?=([%atom *] p.mod) ~ ?:(=(%$ p.p.mod) `%atom `p.p.mod)) - $dbug $(mod q.mod) - $leaf `p.mod - $loop `p.mod - $like ?~(p.mod ~ ?^(i.p.mod ?:(?=(%& -.i.p.mod) ~ q.i.p.mod) `i.p.mod)) - $make ~(name ap p.mod) - $made $(mod q.mod) - $over $(mod q.mod) - $name $(mod q.mod) + %base ?.(?=([%atom *] p.mod) ~ ?:(=(%$ p.p.mod) `%atom `p.p.mod)) + %dbug $(mod q.mod) + %leaf `p.mod + %loop `p.mod + %like ?~(p.mod ~ ?^(i.p.mod ?:(?=(%& -.i.p.mod) ~ q.i.p.mod) `i.p.mod)) + %make ~(name ap p.mod) + %made $(mod q.mod) + %over $(mod q.mod) + %name $(mod q.mod) :: - $bcbc $(mod p.mod) - $bcbr $(mod p.mod) - $bccb ~(name ap p.mod) - $bccl $(mod i.p.mod) - $bccn $(mod i.p.mod) - $bcdt ~ - $bcgl $(mod q.mod) - $bcgr $(mod q.mod) - $bchp $(mod p.mod) - $bckt $(mod q.mod) - $bcls $(mod q.mod) - $bcfs ~ - $bcmc ~(name ap p.mod) - $bcpm $(mod p.mod) - $bcsg $(mod q.mod) - $bctc ~ - $bcts $(mod q.mod) - $bcpt $(mod q.mod) - $bcwt $(mod i.p.mod) - $bczp ~ + %bcbc $(mod p.mod) + %bcbr $(mod p.mod) + %bccb ~(name ap p.mod) + %bccl $(mod i.p.mod) + %bccn $(mod i.p.mod) + %bcdt ~ + %bcgl $(mod q.mod) + %bcgr $(mod q.mod) + %bchp $(mod p.mod) + %bckt $(mod q.mod) + %bcls $(mod q.mod) + %bcfs ~ + %bcmc ~(name ap p.mod) + %bcpm $(mod p.mod) + %bcsg $(mod q.mod) + %bctc ~ + %bcts $(mod q.mod) + %bcpt $(mod q.mod) + %bcwt $(mod i.p.mod) + %bczp ~ == ++ hint |= not/note @@ -7676,30 +7676,30 @@ |= bas/base ?- bas :: - {$atom *} + {%atom *} :: we may want sped :: [%sand p.bas ?:(=(%da p.bas) ~2000.1.1 0)] :: - $noun + %noun :: raw nock produces noun type :: =+([%rock %$ 0] [%ktls [%dttr - - [%rock %$ 1]] -]) :: - $cell + %cell :: reduce to pair of nouns :: =+($(bas %noun) [- -]) :: - $flag + %flag :: comparison produces boolean type :: =+([%rock %$ 0] [%ktls [%dtts - -] -]) :: - $null + %null [%rock %n 0] :: - $void + %void [%zpzp ~] == :: @@ -7758,8 +7758,8 @@ ~+ |- ^- hoon ?- mod - {$base *} ?:(=(%void p.mod) [%rock %n 0] (basal p.mod)) - {$bcbc *} :: track hygienic recursion points lexically + {%base *} ?:(=(%void p.mod) [%rock %n 0] (basal p.mod)) + {%bcbc *} :: track hygienic recursion points lexically :: %= $ mod p.mod @@ -7767,49 +7767,49 @@ :: (~(put by ^+(cox (~(uni by cox) q.mod))) %$ p.mod) == - {$dbug *} [%dbug p.mod $(mod q.mod)] - {$leaf *} [%rock p.mod q.mod] - {$loop *} ~|([%loop p.mod] $(mod (~(got by cox) p.mod))) - {$like *} $(mod bcmc/(unreel p.mod q.mod)) - {$made *} $(mod q.mod) - {$make *} $(mod bcmc/(unfold p.mod q.mod)) - {$name *} $(mod q.mod) - {$over *} $(hay p.mod, mod q.mod) + {%dbug *} [%dbug p.mod $(mod q.mod)] + {%leaf *} [%rock p.mod q.mod] + {%loop *} ~|([%loop p.mod] $(mod (~(got by cox) p.mod))) + {%like *} $(mod bcmc/(unreel p.mod q.mod)) + {%made *} $(mod q.mod) + {%make *} $(mod bcmc/(unfold p.mod q.mod)) + {%name *} $(mod q.mod) + {%over *} $(hay p.mod, mod q.mod) :: - {$bcbr *} $(mod p.mod) - {$bccb *} [%rock %n 0] - {$bccl *} |- ^- hoon + {%bcbr *} $(mod p.mod) + {%bccb *} [%rock %n 0] + {%bccl *} |- ^- hoon ?~ t.p.mod ^$(mod i.p.mod) :- ^$(mod i.p.mod) $(i.p.mod i.t.p.mod, t.p.mod t.t.p.mod) - {$bccn *} :: use last entry + {%bccn *} :: use last entry :: |- ^- hoon ?~ t.p.mod ^$(mod i.p.mod) $(i.p.mod i.t.p.mod, t.p.mod t.t.p.mod) - {$bchp *} :: see under %bccb + {%bchp *} :: see under %bccb :: [%rock %n 0] - {$bcgl *} $(mod q.mod) - {$bcgr *} $(mod q.mod) - {$bckt *} $(mod q.mod) - {$bcls *} $(mod q.mod) - {$bcmc *} :: borrow sample + {%bcgl *} $(mod q.mod) + {%bcgr *} $(mod q.mod) + {%bckt *} $(mod q.mod) + {%bcls *} $(mod q.mod) + {%bcmc *} :: borrow sample :: [%tsgl [%$ 6] p.mod] - {$bcpm *} $(mod p.mod) - {$bcsg *} [%kthp q.mod p.mod] - {$bcts *} [%ktts p.mod $(mod q.mod)] - {$bcpt *} $(mod p.mod) - {$bcwt *} :: use last entry + {%bcpm *} $(mod p.mod) + {%bcsg *} [%kthp q.mod p.mod] + {%bcts *} [%ktts p.mod $(mod q.mod)] + {%bcpt *} $(mod p.mod) + {%bcwt *} :: use last entry :: |- ^- hoon ?~ t.p.mod ^$(mod i.p.mod) $(i.p.mod i.t.p.mod, t.p.mod t.t.p.mod) - {$bcdt *} [%rock %n 0] - {$bcfs *} [%rock %n 0] - {$bctc *} [%rock %n 0] - {$bczp *} [%rock %n 0] + {%bcdt *} [%rock %n 0] + {%bcfs *} [%rock %n 0] + {%bctc *} [%rock %n 0] + {%bczp *} [%rock %n 0] == :: ++ example @@ -7824,32 +7824,32 @@ spore ~(relative analyze:(descend 3) 2) :: - {$base *} (decorate (basal p.mod)) - {$dbug *} example(mod q.mod, bug [p.mod bug]) - {$leaf *} (decorate [%rock p.mod q.mod]) - {$like *} example(mod bcmc/(unreel p.mod q.mod)) - {$loop *} [%limb p.mod] - {$made *} example(mod q.mod, nut `made/[p.p.mod `(pieces q.p.mod)]) - {$make *} example(mod bcmc/(unfold p.mod q.mod)) - {$name *} example(mod q.mod, nut `made/[p.mod ~]) - {$over *} example(hay p.mod, mod q.mod) + {%base *} (decorate (basal p.mod)) + {%dbug *} example(mod q.mod, bug [p.mod bug]) + {%leaf *} (decorate [%rock p.mod q.mod]) + {%like *} example(mod bcmc/(unreel p.mod q.mod)) + {%loop *} [%limb p.mod] + {%made *} example(mod q.mod, nut `made/[p.p.mod `(pieces q.p.mod)]) + {%make *} example(mod bcmc/(unfold p.mod q.mod)) + {%name *} example(mod q.mod, nut `made/[p.mod ~]) + {%over *} example(hay p.mod, mod q.mod) :: - {$bccb *} (decorate (home p.mod)) - {$bccl *} %- decorate + {%bccb *} (decorate (home p.mod)) + {%bccl *} %- decorate |- ^- hoon ?~ t.p.mod example:clear(mod i.p.mod) :- example:clear(mod i.p.mod) example:clear(i.p.mod i.t.p.mod, t.p.mod t.t.p.mod) - {$bchp *} (decorate (function:clear p.mod q.mod)) - {$bcmc *} (decorate (home [%tsgl [%limb %$] p.mod])) - {$bcsg *} [%ktls example(mod q.mod) (home p.mod)] - {$bcls *} (decorate example(mod q.mod)) - {$bcts *} (decorate [%ktts p.mod example:clear(mod q.mod)]) - {$bcdt *} (decorate (home (interface %gold p.mod q.mod))) - {$bcfs *} (decorate (home (interface %iron p.mod q.mod))) - {$bczp *} (decorate (home (interface %lead p.mod q.mod))) - {$bctc *} (decorate (home (interface %zinc p.mod q.mod))) + {%bchp *} (decorate (function:clear p.mod q.mod)) + {%bcmc *} (decorate (home [%tsgl [%limb %$] p.mod])) + {%bcsg *} [%ktls example(mod q.mod) (home p.mod)] + {%bcls *} (decorate example(mod q.mod)) + {%bcts *} (decorate [%ktts p.mod example:clear(mod q.mod)]) + {%bcdt *} (decorate (home (interface %gold p.mod q.mod))) + {%bcfs *} (decorate (home (interface %iron p.mod q.mod))) + {%bczp *} (decorate (home (interface %lead p.mod q.mod))) + {%bctc *} (decorate (home (interface %zinc p.mod q.mod))) == :: ++ factory @@ -7858,8 +7858,8 @@ ^- hoon :: process annotations outside construct, to catch default :: - ?: ?=($dbug -.mod) factory(mod q.mod, bug [p.mod bug]) - ?: ?=($bcsg -.mod) factory(mod q.mod, def `[%kthp q.mod p.mod]) + ?: ?=(%dbug -.mod) factory(mod q.mod, bug [p.mod bug]) + ?: ?=(%bcsg -.mod) factory(mod q.mod, def `[%kthp q.mod p.mod]) ^- hoon :: if we recognize an indirection :: @@ -7899,13 +7899,13 @@ [%cnls [%limb %ruth] [%sand %ta p.bas] fetch] [%wtpt fetch-wing fetch [%zpzp ~]] :: - $cell + %cell :+ %ktls example =+ fetch-wing :- [%wing [[%& %2] -]] [%wing [[%& %3] -]] :: - $flag + %flag :^ %wtcl [%dtts [%rock %$ &] [%$ axe]] [%rock %f &] @@ -7913,15 +7913,15 @@ [%dtts [%rock %$ |] [%$ axe]] [%rock %f |] :: - $noun + %noun fetch :: - $null + %null :+ %wtgr [%dtts [%bust %noun] [%$ axe]] [%rock %n ~] ::: - $void + %void [%zpzp ~] == ++ clear @@ -8003,17 +8003,17 @@ :: :: base :: - {$base *} + {%base *} (decorate (basic:clear p.mod)) :: :: debug :: - {$dbug *} + {%dbug *} relative(mod q.mod, bug [p.mod bug]) :: :: constant :: - {$leaf *} + {%leaf *} %- decorate :+ %wtgr [%dtts fetch [%rock %$ q.mod]] @@ -8021,37 +8021,37 @@ :: :: composite :: - {$make *} + {%make *} relative(mod bcmc/(unfold p.mod q.mod)) :: :: indirect :: - {$like *} + {%like *} relative(mod bcmc/(unreel p.mod q.mod)) :: :: loop :: - {$loop *} + {%loop *} (decorate [%cnhp [%limb p.mod] fetch]) :: :: simple named structure :: - {$name *} + {%name *} relative(mod q.mod, nut `made/[p.mod ~]) :: :: synthetic named structure :: - {$made *} + {%made *} relative(mod q.mod, nut `made/[p.p.mod `(pieces q.p.mod)]) :: :: subjective :: - {$over *} + {%over *} relative(hay p.mod, mod q.mod) :: :: recursive, $$ :: - {$bcbc *} + {%bcbc *} :: :: apply semantically :: @@ -8067,7 +8067,7 @@ :: :: normalize, $& :: - {$bcpm *} + {%bcpm *} :: push the raw result :: :+ %tsls relative(mod p.mod) @@ -8096,7 +8096,7 @@ :: :: verify, $| :: - {$bcbr *} + {%bcbr *} ^- hoon :: push the raw product :: @@ -8114,17 +8114,17 @@ :: :: special, $_ :: - {$bccb *} + {%bccb *} (decorate (home p.mod)) :: :: switch, $% :: - {$bccn *} + {%bccn *} (decorate (switch i.p.mod t.p.mod)) :: :: tuple, $: :: - {$bccl *} + {%bccl *} %- decorate |- ^- hoon ?~ t.p.mod @@ -8138,7 +8138,7 @@ :: :: exclude, $< :: - {$bcgl *} + {%bcgl *} :+ %tsls relative:clear(mod q.mod) :+ %wtgl @@ -8147,7 +8147,7 @@ :: :: require, $> :: - {$bcgr *} + {%bcgr *} :+ %tsls relative:clear(mod q.mod) :+ %wtgr @@ -8156,7 +8156,7 @@ :: :: function :: - {$bchp *} + {%bchp *} %- decorate =/ fun (function:clear p.mod q.mod) ?^ def @@ -8165,7 +8165,7 @@ :: :: bridge, $^ :: - {$bckt *} + {%bckt *} %- decorate :^ %wtcl [%dtwt fetch(axe (peg axe 2))] @@ -8174,38 +8174,38 @@ :: :: synthesis, $; :: - {$bcmc *} + {%bcmc *} (decorate [%cncl (home p.mod) fetch ~]) :: :: default :: - {$bcsg *} + {%bcsg *} relative(mod q.mod, def `[%kthp q.mod p.mod]) :: :: choice, $? :: - {$bcwt *} + {%bcwt *} (decorate (choice i.p.mod t.p.mod)) :: :: name, $= :: - {$bcts *} + {%bcts *} [%ktts p.mod relative(mod q.mod)] :: :: branch, $@ :: - {$bcpt *} + {%bcpt *} %- decorate :^ %wtcl [%dtwt fetch] relative:clear(mod q.mod) relative:clear(mod p.mod) :: - {$bcls *} relative(mod q.mod) - {$bcdt *} (decorate (home (interface %gold p.mod q.mod))) - {$bcfs *} (decorate (home (interface %iron p.mod q.mod))) - {$bczp *} (decorate (home (interface %lead p.mod q.mod))) - {$bctc *} (decorate (home (interface %zinc p.mod q.mod))) + {%bcls *} relative(mod q.mod) + {%bcdt *} (decorate (home (interface %gold p.mod q.mod))) + {%bcfs *} (decorate (home (interface %iron p.mod q.mod))) + {%bczp *} (decorate (home (interface %lead p.mod q.mod))) + {%bctc *} (decorate (home (interface %zinc p.mod q.mod))) == -- -- @@ -8274,25 +8274,25 @@ ++ name |- ^- (unit term) ?+ gen ~ - {$wing *} ?~ p.gen ~ + {%wing *} ?~ p.gen ~ ?^ i.p.gen ?:(?=(%& -.i.p.gen) ~ q.i.p.gen) `i.p.gen - {$limb *} `p.gen - {$dbug *} $(gen ~(open ap gen)) - {$tsgl *} $(gen ~(open ap gen)) - {$tsgr *} $(gen q.gen) + {%limb *} `p.gen + {%dbug *} $(gen ~(open ap gen)) + {%tsgl *} $(gen ~(open ap gen)) + {%tsgr *} $(gen q.gen) == :: ++ feck |- ^- (unit term) ?- gen - {$sand $tas @} [~ q.gen] - {$dbug *} $(gen q.gen) + {%sand %tas @} [~ q.gen] + {%dbug *} $(gen q.gen) * ~ == :: - :: not used at present; see comment at $csng in ++open + :: not used at present; see comment at %csng in ++open :::: ::++ hail :: |= axe/axis @@ -8306,12 +8306,12 @@ |- ^- (unit (pair hoon hoon)) ?+ gen ~ {^ *} `[p.gen q.gen] - {$dbug *} $(gen q.gen) - {$clcb *} `[q.gen p.gen] - {$clhp *} `[p.gen q.gen] - {$clkt *} `[p.gen %clls q.gen r.gen s.gen] - {$clsg *} ?~(p.gen ~ `[i.p.gen %clsg t.p.gen]) - {$cltr *} ?~ p.gen ~ + {%dbug *} $(gen q.gen) + {%clcb *} `[q.gen p.gen] + {%clhp *} `[p.gen q.gen] + {%clkt *} `[p.gen %clls q.gen r.gen s.gen] + {%clsg *} ?~(p.gen ~ `[i.p.gen %clsg t.p.gen]) + {%cltr *} ?~ p.gen ~ ?~(t.p.gen $(gen i.p.gen) `[i.p.gen %cltr t.p.gen]) == :::: @@ -8374,13 +8374,13 @@ ?- gen {~ *} [%cnts [[%& p.gen] ~] ~] :: - {$base *} ~(factory ax fab `spec`gen) - {$bust *} ~(example ax fab %base p.gen) - {$ktcl *} ~(factory ax fab p.gen) - {$dbug *} q.gen - {$eror *} ~>(%slog.[0 leaf/p.gen] !!) + {%base *} ~(factory ax fab `spec`gen) + {%bust *} ~(example ax fab %base p.gen) + {%ktcl *} ~(factory ax fab p.gen) + {%dbug *} q.gen + {%eror *} ~>(%slog.[0 leaf/p.gen] !!) :: - {$knit *} :: + {%knit *} :: :+ %tsgr [%ktts %v %$ 1] :: => v=. :- %brhp :: |- :+ %ktls :: ^+ @@ -8414,21 +8414,21 @@ [%$ ~] :: $ [[[%a ~] [%tsgl [%$ 3] [%limb %a]]] ~] :: a +.a :: - {$leaf *} ~(factory ax fab `spec`gen) - {$limb *} [%cnts [p.gen ~] ~] - {$tell *} [%cncl [%limb %noah] [%zpgr [%cltr p.gen]] ~] - {$wing *} [%cnts p.gen ~] - {$yell *} [%cncl [%limb %cain] [%zpgr [%cltr p.gen]] ~] - {$note *} q.gen + {%leaf *} ~(factory ax fab `spec`gen) + {%limb *} [%cnts [p.gen ~] ~] + {%tell *} [%cncl [%limb %noah] [%zpgr [%cltr p.gen]] ~] + {%wing *} [%cnts p.gen ~] + {%yell *} [%cncl [%limb %cain] [%zpgr [%cltr p.gen]] ~] + {%note *} q.gen :: - {$brbc *} =- ?~ - !! + {%brbc *} =- ?~ - !! [%brtr [%bccl -] [%ktcl body.gen]] %+ turn `(list term)`sample.gen |= =term ^- spec =/ tar [%base %noun] [%bcts term [%bcsg tar [%bchp tar tar]]] - {$brcb *} :+ %tsls [%kttr p.gen] + {%brcb *} :+ %tsls [%kttr p.gen] :+ %brcn ~ %- ~(run by r.gen) |= =tome @@ -8437,11 +8437,11 @@ |= =hoon ?~ q.gen hoon [%tstr [p.i.q.gen ~] q.i.q.gen $(q.gen t.q.gen)] - {$brcl *} [%tsls p.gen [%brdt q.gen]] - {$brdt *} :+ %brcn ~ + {%brcl *} [%tsls p.gen [%brdt q.gen]] + {%brdt *} :+ %brcn ~ =- [[%$ ~ -] ~ ~] (~(put by *(map term hoon)) %$ p.gen) - {$brkt *} :+ %tsgl [%limb %$] + {%brkt *} :+ %tsgl [%limb %$] :+ %brcn ~ =+ zil=(~(get by q.gen) %$) ?~ zil @@ -8449,28 +8449,28 @@ [*what [[%$ p.gen] ~ ~]] %+ ~(put by q.gen) %$ [p.u.zil (~(put by q.u.zil) %$ p.gen)] - {$brhp *} [%tsgl [%limb %$] [%brdt p.gen]] - {$brsg *} [%ktbr [%brts p.gen q.gen]] - {$brtr *} :+ %tsls [%kttr p.gen] + {%brhp *} [%tsgl [%limb %$] [%brdt p.gen]] + {%brsg *} [%ktbr [%brts p.gen q.gen]] + {%brtr *} :+ %tsls [%kttr p.gen] :+ %brpt ~ =- [[%$ ~ -] ~ ~] (~(put by *(map term hoon)) %$ q.gen) - {$brts *} :+ %brcb p.gen + {%brts *} :+ %brcb p.gen =- [~ [[%$ ~ -] ~ ~]] (~(put by *(map term hoon)) %$ q.gen) - {$brwt *} [%ktwt %brdt p.gen] + {%brwt *} [%ktwt %brdt p.gen] :: - {$clkt *} [p.gen q.gen r.gen s.gen] - {$clls *} [p.gen q.gen r.gen] - {$clcb *} [q.gen p.gen] - {$clhp *} [p.gen q.gen] - {$clsg *} + {%clkt *} [p.gen q.gen r.gen s.gen] + {%clls *} [p.gen q.gen r.gen] + {%clcb *} [q.gen p.gen] + {%clhp *} [p.gen q.gen] + {%clsg *} |- ^- hoon ?~ p.gen [%rock %n ~] [i.p.gen $(p.gen t.p.gen)] :: - {$cltr *} + {%cltr *} |- ^- hoon ?~ p.gen [%zpzp ~] @@ -8478,17 +8478,17 @@ i.p.gen [i.p.gen $(p.gen t.p.gen)] :: - {$kttr *} [%ktsg ~(example ax fab p.gen)] - {$cncb *} [%ktls [%wing p.gen] %cnts p.gen q.gen] - {$cndt *} [%cncl q.gen [p.gen ~]] - {$cnkt *} [%cncl p.gen q.gen r.gen s.gen ~] - {$cnls *} [%cncl p.gen q.gen r.gen ~] - {$cnhp *} [%cncl p.gen q.gen ~] + {%kttr *} [%ktsg ~(example ax fab p.gen)] + {%cncb *} [%ktls [%wing p.gen] %cnts p.gen q.gen] + {%cndt *} [%cncl q.gen [p.gen ~]] + {%cnkt *} [%cncl p.gen q.gen r.gen s.gen ~] + {%cnls *} [%cncl p.gen q.gen r.gen ~] + {%cnhp *} [%cncl p.gen q.gen ~] :: this probably should work, but doesn't :: - :: {$cncl *} [%cntr [%$ ~] p.gen [[[[%& 6] ~] [%cltr q.gen]] ~]] - {$cncl *} [%cnsg [%$ ~] p.gen q.gen] - {$cnsg *} + :: {%cncl *} [%cntr [%$ ~] p.gen [[[[%& 6] ~] [%cltr q.gen]] ~]] + {%cncl *} [%cnsg [%$ ~] p.gen q.gen] + {%cnsg *} :: this complex matching system is a leftover from the old :: "electroplating" era. %cnsg should be removed and replaced :: with the commented-out %cncl above. but something is broken. @@ -8501,7 +8501,7 @@ :- [[[%| 0 ~] [%& (peg axe 2)] ~] i.r.gen] $(axe (peg axe 3), r.gen t.r.gen) :: - {$cntr *} + {%cntr *} ?: =(~ r.gen) [%tsgr q.gen [%wing p.gen]] :+ %tsls @@ -8510,11 +8510,11 @@ (weld p.gen `wing`[[%& 2] ~]) (turn r.gen |=({p/wing q/hoon} [p [%tsgr [%$ 3] q]])) :: - {$ktdt *} [%ktls [%cncl p.gen q.gen ~] q.gen] - {$kthp *} [%ktls ~(example ax fab p.gen) q.gen] - {$ktts *} (grip(gen q.gen) p.gen) + {%ktdt *} [%ktls [%cncl p.gen q.gen ~] q.gen] + {%kthp *} [%ktls ~(example ax fab p.gen) q.gen] + {%ktts *} (grip(gen q.gen) p.gen) :: - {$sgbr *} + {%sgbr *} :+ %sggr :- %mean =+ fek=~(feck ap p.gen) @@ -8522,8 +8522,8 @@ [%brdt [%cncl [%limb %cain] [%zpgr [%tsgr [%$ 3] p.gen]] ~]] q.gen :: - {$sgcb *} [%sggr [%mean [%brdt p.gen]] q.gen] - {$sgcn *} + {%sgcb *} [%sggr [%mean [%brdt p.gen]] q.gen] + {%sgcn *} :+ %sggl :- %fast :- %clls @@ -8537,31 +8537,31 @@ [[[%rock %$ p.i.r.gen] [%zpts q.i.r.gen]] $(r.gen t.r.gen)] s.gen :: - {$sgfs *} [%sgcn p.gen [%$ 7] ~ q.gen] - {$sggl *} [%tsgl [%sggr p.gen [%$ 1]] q.gen] - {$sgbc *} [%sggr [%live [%rock %$ p.gen]] q.gen] - {$sgls *} [%sggr [%memo %rock %$ p.gen] q.gen] - {$sgpm *} + {%sgfs *} [%sgcn p.gen [%$ 7] ~ q.gen] + {%sggl *} [%tsgl [%sggr p.gen [%$ 1]] q.gen] + {%sgbc *} [%sggr [%live [%rock %$ p.gen]] q.gen] + {%sgls *} [%sggr [%memo %rock %$ p.gen] q.gen] + {%sgpm *} :+ %sggr [%slog [%sand %$ p.gen] [%cncl [%limb %cain] [%zpgr q.gen] ~]] r.gen :: - {$sgts *} [%sggr [%germ p.gen] q.gen] - {$sgwt *} + {%sgts *} [%sggr [%germ p.gen] q.gen] + {%sgwt *} :+ %tsls [%wtdt q.gen [%bust %null] [[%bust %null] r.gen]] :^ %wtsg [%& 2]~ [%tsgr [%$ 3] s.gen] [%sgpm p.gen [%$ 5] [%tsgr [%$ 3] s.gen]] :: - {$mcts *} + {%mcts *} |- ?~ p.gen [%bust %null] ?- -.i.p.gen ^ [[%xray i.p.gen] $(p.gen t.p.gen)] - $manx [p.i.p.gen $(p.gen t.p.gen)] - $tape [[%mcfs p.i.p.gen] $(p.gen t.p.gen)] - $call [%cncl p.i.p.gen [$(p.gen t.p.gen)]~] - $marl =- [%cndt [p.i.p.gen $(p.gen t.p.gen)] -] + %manx [p.i.p.gen $(p.gen t.p.gen)] + %tape [[%mcfs p.i.p.gen] $(p.gen t.p.gen)] + %call [%cncl p.i.p.gen [$(p.gen t.p.gen)]~] + %marl =- [%cndt [p.i.p.gen $(p.gen t.p.gen)] -] ^- hoon :+ %tsbr [%base %cell] :+ %brpt ~ @@ -8576,7 +8576,7 @@ [%cnts sug [[[[%& 3] ~] [%cnts [%$ ~] [[sug [%$ 25]] ~]]] ~]] == :: - {$mccl *} + {%mccl *} ?- q.gen ~ [%zpzp ~] {* ~} i.q.gen @@ -8592,8 +8592,8 @@ == == :: - {$mcfs *} =+(zoy=[%rock %ta %$] [%clsg [zoy [%clsg [zoy p.gen] ~]] ~]) - {$mcgl *} + {%mcfs *} =+(zoy=[%rock %ta %$] [%clsg [zoy [%clsg [zoy p.gen] ~]] ~]) + {%mcgl *} :^ %cnls :+ %cnhp q.gen @@ -8603,7 +8603,7 @@ p.gen s.gen :: - {$mcsg *} :: ;~ + {%mcsg *} :: ;~ |- ^- hoon ?- q.gen ~ ~_(leaf+"open-mcsg" !!) @@ -8628,30 +8628,30 @@ [[[[%| 0 ~] [%& 6] ~] [%limb %c]] ~] :: == :: :: - {$mcmc *} :: ;; + {%mcmc *} :: ;; [%cnhp ~(factory ax fab p.gen) q.gen] :: - {$tsbr *} + {%tsbr *} [%tsls ~(example ax fab p.gen) q.gen] :: - {$tstr *} + {%tstr *} :+ %tsgl r.gen [%tune [[p.p.gen ~ ?~(q.p.gen q.gen [%kthp u.q.p.gen q.gen])] ~ ~] ~] :: - {$tscl *} + {%tscl *} [%tsgr [%cncb [[%& 1] ~] p.gen] q.gen] :: - {$tsfs *} + {%tsfs *} [%tsls [%ktts p.gen q.gen] r.gen] :: - {$tsmc *} [%tsfs p.gen r.gen q.gen] - {$tsdt *} + {%tsmc *} [%tsfs p.gen r.gen q.gen] + {%tsdt *} [%tsgr [%cncb [[%& 1] ~] [[p.gen q.gen] ~]] r.gen] - {$tswt *} :: =? + {%tswt *} :: =? [%tsdt p.gen [%wtcl q.gen r.gen [%wing p.gen]] s.gen] :: - {$tskt *} :: =^ + {%tskt *} :: =^ =+ wuy=(weld q.gen `wing`[%v ~]) :: :+ %tsgr [%ktts %v %$ 1] :: => v=. :+ %tsls [%ktts %a %tsgr [%limb %v] r.gen] :: =+ a==>(v \r.gen) @@ -8661,25 +8661,25 @@ [%limb %v] s.gen :: - {$tsgl *} [%tsgr q.gen p.gen] - {$tsls *} [%tsgr [p.gen [%$ 1]] q.gen] - {$tshp *} [%tsls q.gen p.gen] - {$tssg *} + {%tsgl *} [%tsgr q.gen p.gen] + {%tsls *} [%tsgr [p.gen [%$ 1]] q.gen] + {%tshp *} [%tsls q.gen p.gen] + {%tssg *} |- ^- hoon ?~ p.gen [%$ 1] ?~ t.p.gen i.p.gen [%tsgr i.p.gen $(p.gen t.p.gen)] :: - {$wtbr *} + {%wtbr *} |- ?~(p.gen [%rock %f 1] [%wtcl i.p.gen [%rock %f 0] $(p.gen t.p.gen)]) :: - {$wtdt *} [%wtcl p.gen r.gen q.gen] - {$wtgl *} [%wtcl p.gen [%zpzp ~] q.gen] - {$wtgr *} [%wtcl p.gen q.gen [%zpzp ~]] - {$wtkt *} [%wtcl [%wtts [%base %atom %$] p.gen] r.gen q.gen] + {%wtdt *} [%wtcl p.gen r.gen q.gen] + {%wtgl *} [%wtcl p.gen [%zpzp ~] q.gen] + {%wtgr *} [%wtcl p.gen q.gen [%zpzp ~]] + {%wtkt *} [%wtcl [%wtts [%base %atom %$] p.gen] r.gen q.gen] :: - {$wthp *} + {%wthp *} |- ?~ q.gen [%lost [%wing p.gen]] @@ -8688,14 +8688,14 @@ q.i.q.gen $(q.gen t.q.gen) :: - {$wtls *} + {%wtls *} [%wthp p.gen (weld r.gen `_r.gen`[[[%base %noun] q.gen] ~])] :: - {$wtpm *} + {%wtpm *} |- ?~(p.gen [%rock %f 0] [%wtcl i.p.gen $(p.gen t.p.gen) [%rock %f 1]]) :: - {$xray *} + {%xray *} |^ :- [(open-mane n.g.p.gen) %clsg (turn a.g.p.gen open-mart)] [%mcts c.p.gen] :: @@ -8708,14 +8708,14 @@ [(open-mane n) %knit v] -- :: - {$wtpt *} [%wtcl [%wtts [%base %atom %$] p.gen] q.gen r.gen] - {$wtsg *} [%wtcl [%wtts [%base %null] p.gen] q.gen r.gen] - {$wtts *} [%fits ~(example ax fab p.gen) q.gen] - {$wtzp *} [%wtcl p.gen [%rock %f 1] [%rock %f 0]] - {$zpgr *} + {%wtpt *} [%wtcl [%wtts [%base %atom %$] p.gen] q.gen r.gen] + {%wtsg *} [%wtcl [%wtts [%base %null] p.gen] q.gen r.gen] + {%wtts *} [%fits ~(example ax fab p.gen) q.gen] + {%wtzp *} [%wtcl p.gen [%rock %f 1] [%rock %f 0]] + {%zpgr *} [%cncl [%limb %onan] [%zpmc [%kttr [%bcmc %limb %abel]] p.gen] ~] :: - {$zpwt *} + {%zpwt *} ?: ?: ?=(@ p.gen) (lte hoon-version p.gen) &((lte hoon-version p.p.gen) (gte hoon-version q.p.gen)) @@ -8730,10 +8730,10 @@ ^- (unit wing) ?+ gen ~ {~ *} `[[%& p.gen] ~] - {$limb *} `[p.gen ~] - {$wing *} `p.gen - {$cnts * ~} `p.gen - {$dbug *} reek(gen q.gen) + {%limb *} `[p.gen ~] + {%wing *} `p.gen + {%cnts * ~} `p.gen + {%dbug *} reek(gen q.gen) == ++ rusk ^- term @@ -9045,7 +9045,7 @@ ^- {type nock} =+ pro=(mint gol gen) =+ jon=(apex:musk bran q.pro) - ?: |(?=(~ jon) ?=($wait -.u.jon)) + ?: |(?=(~ jon) ?=(%wait -.u.jon)) ?: &(!fab vet) ~& %bleu-fail !! @@ -9057,7 +9057,7 @@ ^- {type nock} =+ pro=(mint gol gen) =+ jon=(apex:musk bran q.pro) - ?: |(?=(~ jon) ?=($wait -.u.jon)) + ?: |(?=(~ jon) ?=(%wait -.u.jon)) [p.pro q.pro] [p.pro %1 p.u.jon] :: @@ -9066,17 +9066,17 @@ =+ gil=*(set type) |- ~+ ^- seminoun:musk ?- sut - $noun [full/[~ ~ ~] ~] - $void [full/[~ ~ ~] ~] - {$atom *} ?~(q.sut [full/[~ ~ ~] ~] [full/~ u.q.sut]) - {$cell *} (combine:musk $(sut p.sut) $(sut q.sut)) - {$core *} %+ combine:musk + %noun [full/[~ ~ ~] ~] + %void [full/[~ ~ ~] ~] + {%atom *} ?~(q.sut [full/[~ ~ ~] ~] [full/~ u.q.sut]) + {%cell *} (combine:musk $(sut p.sut) $(sut q.sut)) + {%core *} %+ combine:musk p.r.q.sut $(sut p.sut) - {$face *} $(sut repo) - {$fork *} [full/[~ ~ ~] ~] - {$hint *} $(sut repo) - {$hold *} ?: (~(has in gil) sut) + {%face *} $(sut repo) + {%fork *} [full/[~ ~ ~] ~] + {%hint *} $(sut repo) + {%hold *} ?: (~(has in gil) sut) [full/[~ ~ ~] ~] $(sut repo, gil (~(put in gil) sut)) == @@ -9132,42 +9132,42 @@ ?: =(%void ref) sut ?- sut - {$atom *} + {%atom *} ?+ ref sint - {$atom *} ?^ q.sut + {%atom *} ?^ q.sut ?^(q.ref ?:(=(q.ref q.sut) %void sut) %void) ?^(q.ref sut %void) - {$cell *} sut + {%cell *} sut == :: - {$cell *} + {%cell *} ?+ ref sint - {$atom *} sut - {$cell *} ?. (nest(sut p.ref) | p.sut) sut + {%atom *} sut + {%cell *} ?. (nest(sut p.ref) | p.sut) sut (cell p.sut dext(sut q.sut, ref q.ref)) == :: - {$core *} ?:(?=(?({$atom *} {$cell *}) ref) sut sint) - {$face *} (face p.sut dext(sut q.sut)) - {$fork *} (fork (turn ~(tap in p.sut) |=(type dext(sut +<)))) - {$hint *} (hint p.sut dext(sut q.sut)) - {$hold *} ?< (~(has in bix) [sut ref]) + {%core *} ?:(?=(?({%atom *} {%cell *}) ref) sut sint) + {%face *} (face p.sut dext(sut q.sut)) + {%fork *} (fork (turn ~(tap in p.sut) |=(type dext(sut +<)))) + {%hint *} (hint p.sut dext(sut q.sut)) + {%hold *} ?< (~(has in bix) [sut ref]) dext(sut repo, bix (~(put in bix) [sut ref])) - $noun dext(sut repo) - $void %void + %noun dext(sut repo) + %void %void == :: ++ sint ^- type ?+ ref !! - {$core *} sut - {$face *} dext(ref repo(sut ref)) - {$fork *} =+ yed=~(tap in p.ref) + {%core *} sut + {%face *} dext(ref repo(sut ref)) + {%fork *} =+ yed=~(tap in p.ref) |- ^- type ?~ yed sut $(yed t.yed, sut dext(ref i.yed)) - {$hint *} dext(ref repo(sut ref)) - {$hold *} dext(ref repo(sut ref)) + {%hint *} dext(ref repo(sut ref)) + {%hold *} dext(ref repo(sut ref)) == -- :: @@ -9562,10 +9562,10 @@ ++ $ ^- pony ?- sut - $void ~ - $noun stop - {$atom *} stop - {$cell *} + %void ~ + %noun stop + {%atom *} stop + {%cell *} ?~ q.heg here =+ taf=$(axe (peg axe 2), sut p.sut) ?~ taf ~ @@ -9573,7 +9573,7 @@ taf $(axe (peg axe 3), p.heg p.p.taf, sut q.sut) :: - {$core *} + {%core *} ?~ q.heg here =^ zem p.heg =+ zem=(loot u.q.heg q.r.q.sut) @@ -9593,10 +9593,10 @@ ?: con.pec $(sut p.sut, axe (peg axe 3)) $(sut (peek(sut p.sut) way 2), axe (peg axe 6)) :: - {$hint *} + {%hint *} $(sut repo) :: - {$face *} + {%face *} ?: ?=(~ q.heg) here(sut q.sut) =* zot p.sut ?@ zot @@ -9634,14 +9634,14 @@ [%| %| p.vat (comb (comb [%0 axe] q.tiv) q.vat)] -- :: - {$fork *} + {%fork *} =+ wiz=(turn ~(tap in p.sut) |=(a/type ^$(sut a))) ?~ wiz ~ |- ^- pony ?~ t.wiz i.wiz (twin i.wiz $(wiz t.wiz)) :: - {$hold *} + {%hold *} ?: (~(has in gil) sut) ~ $(gil (~(put in gil) sut), sut repo) @@ -9687,24 +9687,24 @@ ++ fire |= hag/(list {p/type q/foot}) ^- type - ?: ?=({{* {$wet ~ $1}} ~} hag) + ?: ?=({{* {%wet ~ %1}} ~} hag) p.i.hag %- fork %+ turn hag.$ |= {p/type q/foot} - ?. ?=({$core *} p) + ?. ?=({%core *} p) ~_ (dunk %fire-type) ~_ leaf+"expected-fork-to-be-core" ~_ (dunk(sut p) %fork-type) ~>(%mean.'fire-core' !!) :- %hold =+ dox=[%core q.q.p q.p(r.p %gold)] - ?: ?=($dry -.q) + ?: ?=(%dry -.q) :: ~_ (dunk(sut [%cell q.q.p p.p]) %fire-dry) ?> ?|(!vet (nest(sut q.q.p) & p.p)) [dox p.q] - ?> ?=($wet -.q) + ?> ?=(%wet -.q) :: ~_ (dunk(sut [%cell q.q.p p.p]) %fire-wet) :: =. p.p ?:(fab p.p (redo(sut p.p) q.q.p)) =. p.p (redo(sut p.p) q.q.p) @@ -9720,23 +9720,23 @@ =+ vot=*(set type) |- ^- nock ?- sut - $void [%1 1] - $noun [%1 0] - {$atom *} ?~ q.sut + %void [%1 1] + %noun [%1 0] + {%atom *} ?~ q.sut (flip [%3 %0 axe]) [%5 [%1 u.q.sut] [%0 axe]] - {$cell *} + {%cell *} %+ flan [%3 %0 axe] (flan $(sut p.sut, axe (peg axe 2)) $(sut q.sut, axe (peg axe 3))) :: - {$core *} ~>(%mean.'fish-core' !!) - {$face *} $(sut q.sut) - {$fork *} =+ yed=~(tap in p.sut) + {%core *} ~>(%mean.'fish-core' !!) + {%face *} $(sut q.sut) + {%fork *} =+ yed=~(tap in p.sut) |- ^- nock ?~(yed [%1 1] (flor ^$(sut i.yed) $(yed t.yed))) - {$hint *} $(sut q.sut) - {$hold *} + {%hint *} $(sut q.sut) + {%hold *} ?: (~(has in vot) sut) ~>(%mean.'fish-loop' !!) => %=(. vot (~(put in vot) sut)) @@ -9751,9 +9751,9 @@ ?: ?|(=(sut ref) =(%noun ref)) sut ?- sut - {$atom *} + {%atom *} ?- ref - {$atom *} =+ foc=?:((fitz p.ref p.sut) p.sut p.ref) + {%atom *} =+ foc=?:((fitz p.ref p.sut) p.sut p.ref) ?^ q.sut ?^ q.ref ?: =(q.sut q.ref) @@ -9761,26 +9761,26 @@ %void [%atom foc q.sut] [%atom foc q.ref] - {$cell *} %void + {%cell *} %void * $(sut ref, ref sut) == - {$cell *} + {%cell *} ?- ref - {$cell *} (cell $(sut p.sut, ref p.ref) $(sut q.sut, ref q.ref)) + {%cell *} (cell $(sut p.sut, ref p.ref) $(sut q.sut, ref q.ref)) * $(sut ref, ref sut) == :: - {$core *} $(sut repo) - {$face *} (face p.sut $(sut q.sut)) - {$fork *} (fork (turn ~(tap in p.sut) |=(type ^$(sut +<)))) - {$hint *} (hint p.sut $(sut q.sut)) - {$hold *} + {%core *} $(sut repo) + {%face *} (face p.sut $(sut q.sut)) + {%fork *} (fork (turn ~(tap in p.sut) |=(type ^$(sut +<)))) + {%hint *} (hint p.sut $(sut q.sut)) + {%hold *} ?: (~(has in bix) [sut ref]) ~>(%mean.'fuse-loop' !!) $(sut repo, bix (~(put in bix) [sut ref])) :: - $noun ref - $void %void + %noun ref + %void %void == :: ++ gain @@ -9796,8 +9796,8 @@ ~+ =+ %hemp-141 ?- hud - $dry q:(mint gol gen) - $wet q:(mint(vet |) gol gen) + %dry q:(mint gol gen) + %wet q:(mint(vet |) gol gen) == :: ++ laze @@ -9882,9 +9882,9 @@ ++ chip ~/ %chip |= {how/? gen/hoon} ^- type - ?: ?=({$wtts *} gen) + ?: ?=({%wtts *} gen) (cool how q.gen (play ~(example ax fab p.gen))) - ?: ?=({$wthx *} gen) + ?: ?=({%wthx *} gen) =+ (play %wing q.gen) ~> %slog.[0 [%leaf "chipping"]] ?: how @@ -9893,9 +9893,9 @@ - ~(gain ar - p.gen) ~(lose ar - p.gen) - ?: ?&(how ?=({$wtpm *} gen)) + ?: ?&(how ?=({%wtpm *} gen)) |-(?~(p.gen sut $(p.gen t.p.gen, sut ^$(gen i.p.gen)))) - ?: ?&(!how ?=({$wtbr *} gen)) + ?: ?&(!how ?=({%wtbr *} gen)) |-(?~(p.gen sut $(p.gen t.p.gen, sut ^$(gen i.p.gen)))) =+ neg=~(open ap gen) ?:(=(neg gen) sut $(gen neg)) @@ -9909,8 +9909,8 @@ :: this seems wrong but it's actually right :: ?- hud - $dry (mull %noun dox q.n.dab) - $wet ~ + %dry (mull %noun dox q.n.dab) + %wet ~ == ?- dab {* ~ ~} dov @@ -10097,8 +10097,8 @@ ^- {p/type q/nock} ::~& %pure-mint |^ ^- {p/type q/nock} - ?: ?&(=(%void sut) !?=({$dbug *} gen)) - ?. |(!vet ?=({$lost *} gen) ?=({$zpzp *} gen)) + ?: ?&(=(%void sut) !?=({%dbug *} gen)) + ?. |(!vet ?=({%lost *} gen) ?=({%zpzp *} gen)) ~>(%mean.'mint-vain' !!) [%void %0 0] ?- gen @@ -10108,45 +10108,45 @@ =+ tal=$(gen q.gen, gol %noun) [(nice (cell p.hed p.tal)) (cons q.hed q.tal)] :: - {$ktcn *} $(fab |, gen p.gen) - {$brcn *} (grow %gold p.gen %dry [%$ 1] q.gen) - {$brpt *} (grow %gold p.gen %wet [%$ 1] q.gen) + {%ktcn *} $(fab |, gen p.gen) + {%brcn *} (grow %gold p.gen %dry [%$ 1] q.gen) + {%brpt *} (grow %gold p.gen %wet [%$ 1] q.gen) :: - {$cnts *} (~(mint et p.gen q.gen) gol) + {%cnts *} (~(mint et p.gen q.gen) gol) :: - {$dtkt *} + {%dtkt *} =+ nef=$(gen [%kttr p.gen]) [p.nef [%12 [%1 %151 p.nef] q:$(gen q.gen, gol %noun)]] :: - {$dtls *} [(nice [%atom %$ ~]) [%4 q:$(gen p.gen, gol [%atom %$ ~])]] - {$sand *} [(nice (play gen)) [%1 q.gen]] - {$rock *} [(nice (play gen)) [%1 q.gen]] + {%dtls *} [(nice [%atom %$ ~]) [%4 q:$(gen p.gen, gol [%atom %$ ~])]] + {%sand *} [(nice (play gen)) [%1 q.gen]] + {%rock *} [(nice (play gen)) [%1 q.gen]] :: - {$dttr *} + {%dttr *} [(nice %noun) [%2 q:$(gen p.gen, gol %noun) q:$(gen q.gen, gol %noun)]] :: - {$dtts *} + {%dtts *} =+ [one two]=[$(gen p.gen, gol %noun) $(gen q.gen, gol %noun)] [(nice bool) [%5 q:$(gen p.gen, gol %noun) q:$(gen q.gen, gol %noun)]] :: - {$dtwt *} [(nice bool) [%3 q:$(gen p.gen, gol %noun)]] - {$hand *} [p.gen q.gen] - {$ktbr *} =+(vat=$(gen p.gen) [(nice (wrap(sut p.vat) %iron)) q.vat]) + {%dtwt *} [(nice bool) [%3 q:$(gen p.gen, gol %noun)]] + {%hand *} [p.gen q.gen] + {%ktbr *} =+(vat=$(gen p.gen) [(nice (wrap(sut p.vat) %iron)) q.vat]) :: - {$ktls *} + {%ktls *} =+(hif=(nice (play p.gen)) [hif q:$(gen q.gen, gol hif)]) :: - {$ktpm *} =+(vat=$(gen p.gen) [(nice (wrap(sut p.vat) %zinc)) q.vat]) - {$ktsg *} (blow gol p.gen) - {$tune *} [(face p.gen sut) [%0 %1]] - {$ktwt *} =+(vat=$(gen p.gen) [(nice (wrap(sut p.vat) %lead)) q.vat]) + {%ktpm *} =+(vat=$(gen p.gen) [(nice (wrap(sut p.vat) %zinc)) q.vat]) + {%ktsg *} (blow gol p.gen) + {%tune *} [(face p.gen sut) [%0 %1]] + {%ktwt *} =+(vat=$(gen p.gen) [(nice (wrap(sut p.vat) %lead)) q.vat]) :: - {$note *} + {%note *} =+ hum=$(gen q.gen) [(hint [sut p.gen] p.hum) q.hum] :: - {$sgzp *} ~_(duck(sut (play p.gen)) $(gen q.gen)) - {$sggr *} + {%sgzp *} ~_(duck(sut (play p.gen)) $(gen q.gen)) + {%sggr *} =+ hum=$(gen q.gen) :: ?: &(huz !?=(%|(@ [?(%sgcn %sgls) ^]) p.gen)) :: hum @@ -10158,15 +10158,15 @@ == q.hum :: - {$tsgr *} + {%tsgr *} =+ fid=$(gen p.gen, gol %noun) =+ dov=$(sut p.fid, gen q.gen) [p.dov (comb q.fid q.dov)] :: - {$tscm *} + {%tscm *} $(gen q.gen, sut (busk p.gen)) :: - {$wtcl *} + {%wtcl *} =+ nor=$(gen p.gen, gol bool) =+ fex=(gain p.gen) =+ wux=(lose p.gen) @@ -10178,14 +10178,14 @@ =+ ran=$(sut wux, gen r.gen) [(fork p.hiq p.ran ~) (cond duy q.hiq q.ran)] :: - {$wthx *} + {%wthx *} :- (nice bool) =+ fid=(find %read [[%& 1] q.gen]) ~> %mean.'mint-fragment' ?> &(?=(%& -.fid) ?=(%& -.q.p.fid)) (~(fish ar `type`p.q.p.fid `skin`p.gen) (tend p.p.fid)) :: - {$fits *} + {%fits *} :- (nice bool) =+ ref=(play p.gen) =+ fid=(find %read q.gen) @@ -10199,24 +10199,24 @@ %| [%7 q.p.fid (fish(sut ref) 1)] == :: - {$dbug *} + {%dbug *} ~_ (show %o p.gen) =+ hum=$(gen q.gen) [p.hum [%11 [%spot %1 p.gen] q.hum]] :: - {$zpcm *} [(nice (play p.gen)) [%1 q.gen]] :: XX validate! - {$lost *} + {%zpcm *} [(nice (play p.gen)) [%1 q.gen]] :: XX validate! + {%lost *} ?: vet ~_ (dunk(sut (play p.gen)) 'lost') ~>(%mean.'mint-lost' !!) [%void [%0 0]] :: - {$zpmc *} + {%zpmc *} =+ vos=$(gol %noun, gen q.gen) =+ ref=p:$(gol %noun, gen p.gen) [(nice (cell ref p.vos)) (cons [%1 burp(sut p.vos)] q.vos)] :: - {$zpgl *} + {%zpgl *} =/ typ (nice (play [%kttr p.gen])) =/ val =< q @@ -10233,10 +10233,10 @@ == [typ val] :: - {$zpts *} [(nice %noun) [%1 q:$(vet |, gen p.gen)]] - {$zppt *} ?:((feel p.gen) $(gen q.gen) $(gen r.gen)) + {%zpts *} [(nice %noun) [%1 q:$(vet |, gen p.gen)]] + {%zppt *} ?:((feel p.gen) $(gen q.gen) $(gen r.gen)) :: - {$zpzp ~} [%void [%0 0]] + {%zpzp ~} [%void [%0 0]] * =+ doz=~(open ap gen) ?: =(doz gen) @@ -10263,15 +10263,15 @@ =+ gil=*(set type) |- ^- ? ?- sut - {$atom *} | - {$cell *} |($(sut p.sut) $(sut q.sut)) - {$core *} $(sut p.sut) - {$face *} $(sut q.sut) - {$fork *} (levy ~(tap in p.sut) |=(type ^$(sut +<))) - {$hint *} $(sut q.sut) - {$hold *} |((~(has in gil) sut) $(gil (~(put in gil) sut), sut repo)) - $noun | - $void & + {%atom *} | + {%cell *} |($(sut p.sut) $(sut q.sut)) + {%core *} $(sut p.sut) + {%face *} $(sut q.sut) + {%fork *} (levy ~(tap in p.sut) |=(type ^$(sut +<))) + {%hint *} $(sut q.sut) + {%hold *} |((~(has in gil) sut) $(gil (~(put in gil) sut), sut repo)) + %noun | + %void & == :: ++ mull @@ -10287,56 +10287,56 @@ =+ tal=$(gen q.gen, gol %noun) [(nice (cell p.hed p.tal)) (cell q.hed q.tal)] :: - {$ktcn *} $(fab |, gen p.gen) - {$brcn *} (grow %gold p.gen %dry [%$ 1] q.gen) - {$brpt *} (grow %gold p.gen %wet [%$ 1] q.gen) - {$cnts *} (~(mull et p.gen q.gen) gol dox) - {$dtkt *} =+($(gen q.gen, gol %noun) $(gen [%kttr p.gen])) - {$dtls *} =+($(gen p.gen, gol [%atom %$ ~]) (beth [%atom %$ ~])) - {$sand *} (beth (play gen)) - {$rock *} (beth (play gen)) + {%ktcn *} $(fab |, gen p.gen) + {%brcn *} (grow %gold p.gen %dry [%$ 1] q.gen) + {%brpt *} (grow %gold p.gen %wet [%$ 1] q.gen) + {%cnts *} (~(mull et p.gen q.gen) gol dox) + {%dtkt *} =+($(gen q.gen, gol %noun) $(gen [%kttr p.gen])) + {%dtls *} =+($(gen p.gen, gol [%atom %$ ~]) (beth [%atom %$ ~])) + {%sand *} (beth (play gen)) + {%rock *} (beth (play gen)) :: - {$dttr *} + {%dttr *} =+([$(gen p.gen, gol %noun) $(gen q.gen, gol %noun)] (beth %noun)) :: - {$dtts *} + {%dtts *} =+([$(gen p.gen, gol %noun) $(gen q.gen, gol %noun)] (beth bool)) :: - {$dtwt *} =+($(gen p.gen, gol %noun) (beth bool)) :: XX =| - {$hand *} [p.gen p.gen] - {$ktbr *} + {%dtwt *} =+($(gen p.gen, gol %noun) (beth bool)) :: XX =| + {%hand *} [p.gen p.gen] + {%ktbr *} =+(vat=$(gen p.gen) [(wrap(sut p.vat) %iron) (wrap(sut q.vat) %iron)]) :: - {$ktls *} + {%ktls *} =+ hif=[p=(nice (play p.gen)) q=(play(sut dox) p.gen)] =+($(gen q.gen, gol p.hif) hif) :: - {$ktpm *} + {%ktpm *} =+(vat=$(gen p.gen) [(wrap(sut p.vat) %zinc) (wrap(sut q.vat) %zinc)]) :: - {$tune *} + {%tune *} [(face p.gen sut) (face p.gen dox)] :: - {$ktwt *} + {%ktwt *} =+(vat=$(gen p.gen) [(wrap(sut p.vat) %lead) (wrap(sut q.vat) %lead)]) :: - {$note *} + {%note *} =+ vat=$(gen q.gen) [(hint [sut p.gen] p.vat) (hint [dox p.gen] q.vat)] :: - {$ktsg *} $(gen p.gen) - {$sgzp *} ~_(duck(sut (play p.gen)) $(gen q.gen)) - {$sggr *} $(gen q.gen) - {$tsgr *} + {%ktsg *} $(gen p.gen) + {%sgzp *} ~_(duck(sut (play p.gen)) $(gen q.gen)) + {%sggr *} $(gen q.gen) + {%tsgr *} =+ lem=$(gen p.gen, gol %noun) $(gen q.gen, sut p.lem, dox q.lem) :: - {$tscm *} + {%tscm *} =/ boc (busk p.gen) =/ nuf (busk(sut dox) p.gen) $(gen q.gen, sut boc, dox nuf) :: - {$wtcl *} + {%wtcl *} =+ nor=$(gen p.gen, gol bool) =+ ^= hiq ^- {p/type q/type} =+ fex=[p=(gain p.gen) q=(gain(sut dox) p.gen)] @@ -10360,7 +10360,7 @@ $(sut p.wux, dox q.wux, gen r.gen) [(nice (fork p.hiq p.ran ~)) (fork q.hiq q.ran ~)] :: - {$fits *} + {%fits *} =+ waz=[p=(play p.gen) q=(play(sut dox) p.gen)] =+ ^= syx :- p=(cove q:(mint %noun [%wing q.gen])) q=(cove q:(mint(sut dox) %noun [%wing q.gen])) @@ -10369,7 +10369,7 @@ ~>(%mean.'mull-bonk-a' !!) (beth bool) :: - {$wthx *} + {%wthx *} ~> %mean.'mull-bonk-x' =+ :- =+ (find %read [[%& 1] q.gen]) ?> &(?=(%& -.-) ?=(%& -.q.p.-)) @@ -10381,25 +10381,25 @@ ?> (nest(sut type.old) & type.new) (beth bool) :: - {$dbug *} ~_((show %o p.gen) $(gen q.gen)) - {$zpcm *} [(nice (play p.gen)) (play(sut dox) p.gen)] - {$lost *} + {%dbug *} ~_((show %o p.gen) $(gen q.gen)) + {%zpcm *} [(nice (play p.gen)) (play(sut dox) p.gen)] + {%lost *} ?: vet :: ~_ (dunk(sut (play p.gen)) 'also') ~>(%mean.'mull-skip' !!) (beth %void) :: - {$zpts *} (beth %noun) + {%zpts *} (beth %noun) :: - {$zpmc *} + {%zpmc *} =+ vos=$(gol %noun, gen q.gen) :: XX validate! [(nice (cell (play p.gen) p.vos)) (cell (play(sut dox) p.gen) q.vos)] :: - {$zpgl *} + {%zpgl *} :: XX is this right? (beth (play [%kttr p.gen])) :: - {$zppt *} + {%zppt *} =+ [(feel p.gen) (feel(sut dox) p.gen)] ?. =(-< ->) ~>(%mean.'mull-bonk-f' !!) @@ -10407,7 +10407,7 @@ $(gen q.gen) $(gen r.gen) :: - {$zpzp *} (beth %void) + {%zpzp *} (beth %void) * =+ doz=~(open ap gen) ?: =(doz gen) @@ -10456,16 +10456,16 @@ ?: =(ref sut) (nest(sut %void) | sut) ?- sut - $void & - $noun (nest(sut %void) | ref) - {$atom *} sint - {$cell *} sint - {$core *} sint(sut [%cell %noun %noun]) - {$fork *} %+ levy ~(tap in p.sut) + %void & + %noun (nest(sut %void) | ref) + {%atom *} sint + {%cell *} sint + {%core *} sint(sut [%cell %noun %noun]) + {%fork *} %+ levy ~(tap in p.sut) |=(type dext(sut +<)) - {$face *} dext(sut q.sut) - {$hint *} dext(sut q.sut) - {$hold *} =+ (~(gas in *(set type)) `(list type)`[sut ref ~]) + {%face *} dext(sut q.sut) + {%hint *} dext(sut q.sut) + {%hold *} =+ (~(gas in *(set type)) `(list type)`[sut ref ~]) ?: (~(has in gil) -) & %= dext @@ -10474,12 +10474,12 @@ == == ++ sint ?+ ref dext(sut ref, ref sut) - {$atom *} ?. ?=({$atom *} sut) & + {%atom *} ?. ?=({%atom *} sut) & ?& ?=(^ q.ref) ?=(^ q.sut) !=(q.ref q.sut) == - {$cell *} ?. ?=({$cell *} sut) & + {%cell *} ?. ?=({%cell *} sut) & ?| dext(sut p.sut, ref p.ref) dext(sut q.sut, ref q.ref) == == @@ -10542,17 +10542,17 @@ !! ?: =(sut ref) & ?- sut - $void sint - $noun & - {$atom *} ?. ?=({$atom *} ref) sint + %void sint + %noun & + {%atom *} ?. ?=({%atom *} ref) sint ?& (fitz p.sut p.ref) |(?=(~ q.sut) =(q.sut q.ref)) == - {$cell *} ?. ?=({$cell *} ref) sint + {%cell *} ?. ?=({%cell *} ref) sint ?& dext(sut p.sut, ref p.ref, seg ~, reg ~) dext(sut q.sut, ref q.ref, seg ~, reg ~) == - {$core *} ?. ?=({$core *} ref) sint + {%core *} ?. ?=({%core *} ref) sint ?: =(q.sut q.ref) dext(sut p.sut, ref p.ref) ?& =(q.p.q.sut q.p.q.ref) :: same wet/dry meet(sut q.q.sut, ref p.sut) @@ -10567,11 +10567,11 @@ ref ref(p q.q.ref, r.p.q %gold) == == == - {$face *} dext(sut q.sut) - {$fork *} ?. ?=(?({$atom *} $noun {$cell *} {$core *}) ref) sint + {%face *} dext(sut q.sut) + {%fork *} ?. ?=(?({%atom *} %noun {%cell *} {%core *}) ref) sint (lien ~(tap in p.sut) |=(type dext(tel |, sut +<))) - {$hint *} dext(sut q.sut) - {$hold *} ?: (~(has in seg) sut) | + {%hint *} dext(sut q.sut) + {%hold *} ?: (~(has in seg) sut) | ?: (~(has in gil) [sut ref]) & %= dext sut repo @@ -10583,15 +10583,15 @@ ++ sint ^- ? ?- ref - $noun | - $void & - {$atom *} | - {$cell *} | - {$core *} dext(ref repo(sut ref)) - {$face *} dext(ref q.ref) - {$fork *} (levy ~(tap in p.ref) |=(type dext(ref +<))) - {$hint *} dext(ref q.ref) - {$hold *} ?: (~(has in reg) ref) & + %noun | + %void & + {%atom *} | + {%cell *} | + {%core *} dext(ref repo(sut ref)) + {%face *} dext(ref q.ref) + {%fork *} (levy ~(tap in p.ref) |=(type dext(ref +<))) + {%hint *} dext(ref q.ref) + {%hold *} ?: (~(has in reg) ref) & ?: (~(has in gil) [sut ref]) & %= dext ref repo(sut ref) @@ -10602,7 +10602,7 @@ :: ++ peek ~/ %peek - |= {way/?($read $rite $both $free) axe/axis} + |= {way/?(%read %rite %both %free) axe/axis} ^- type ?: =(1 axe) sut @@ -10610,9 +10610,9 @@ =+ gil=*(set type) |- ^- type ?- sut - {$atom *} %void - {$cell *} ?:(=(2 now) ^$(sut p.sut, axe lat) ^$(sut q.sut, axe lat)) - {$core *} + {%atom *} %void + {%cell *} ?:(=(2 now) ^$(sut p.sut, axe lat) ^$(sut q.sut, axe lat)) + {%core *} ?. =(3 now) %noun =+ pec=(peel way r.p.q.sut) =/ tow @@ -10633,26 +10633,26 @@ ?.(con.pec %noun ^$(sut p.sut, axe 3)) == :: - {$fork *} (fork (turn ~(tap in p.sut) |=(type ^$(sut +<)))) - {$hold *} + {%fork *} (fork (turn ~(tap in p.sut) |=(type ^$(sut +<)))) + {%hold *} ?: (~(has in gil) sut) %void $(gil (~(put in gil) sut), sut repo) :: - $void %void - $noun %noun + %void %void + %noun %noun * $(sut repo) == :: ++ peel - |= {way/vial met/?($gold $iron $lead $zinc)} + |= {way/vial met/?(%gold %iron %lead %zinc)} ^- {sam/? con/?} - ?: ?=($gold met) [& &] + ?: ?=(%gold met) [& &] ?- way - $both [| |] - $free [& &] - $read [?=($zinc met) |] - $rite [?=($iron met) |] + %both [| |] + %free [& &] + %read [?=(%zinc met) |] + %rite [?=(%iron met) |] == :: ++ play @@ -10662,50 +10662,50 @@ ^- type ?- gen {^ *} (cell $(gen p.gen) $(gen q.gen)) - {$ktcn *} $(fab |, gen p.gen) - {$brcn *} (core sut [p.gen %dry %gold] sut *seminoun q.gen) - {$brpt *} (core sut [p.gen %wet %gold] sut *seminoun q.gen) - {$cnts *} ~(play et p.gen q.gen) - {$dtkt *} $(gen [%kttr p.gen]) - {$dtls *} [%atom %$ ~] - {$rock *} |- ^- type + {%ktcn *} $(fab |, gen p.gen) + {%brcn *} (core sut [p.gen %dry %gold] sut *seminoun q.gen) + {%brpt *} (core sut [p.gen %wet %gold] sut *seminoun q.gen) + {%cnts *} ~(play et p.gen q.gen) + {%dtkt *} $(gen [%kttr p.gen]) + {%dtls *} [%atom %$ ~] + {%rock *} |- ^- type ?@ q.gen [%atom p.gen `q.gen] [%cell $(q.gen -.q.gen) $(q.gen +.q.gen)] - {$sand *} ?@ q.gen + {%sand *} ?@ q.gen ?: =(%n p.gen) ?>(=(0 q.gen) [%atom p.gen `q.gen]) ?: =(%f p.gen) ?>((lte q.gen 1) bool) [%atom p.gen ~] $(-.gen %rock) - {$tune *} (face p.gen sut) - {$dttr *} %noun - {$dtts *} bool - {$dtwt *} bool - {$hand *} p.gen - {$ktbr *} (wrap(sut $(gen p.gen)) %iron) - {$ktls *} $(gen p.gen) - {$ktpm *} (wrap(sut $(gen p.gen)) %zinc) - {$ktsg *} $(gen p.gen) - {$ktwt *} (wrap(sut $(gen p.gen)) %lead) - {$note *} (hint [sut p.gen] $(gen q.gen)) - {$sgzp *} ~_(duck(sut ^$(gen p.gen)) $(gen q.gen)) - {$sggr *} $(gen q.gen) - {$tsgr *} $(gen q.gen, sut $(gen p.gen)) - {$tscm *} $(gen q.gen, sut (busk p.gen)) - {$wtcl *} =+ [fex=(gain p.gen) wux=(lose p.gen)] + {%tune *} (face p.gen sut) + {%dttr *} %noun + {%dtts *} bool + {%dtwt *} bool + {%hand *} p.gen + {%ktbr *} (wrap(sut $(gen p.gen)) %iron) + {%ktls *} $(gen p.gen) + {%ktpm *} (wrap(sut $(gen p.gen)) %zinc) + {%ktsg *} $(gen p.gen) + {%ktwt *} (wrap(sut $(gen p.gen)) %lead) + {%note *} (hint [sut p.gen] $(gen q.gen)) + {%sgzp *} ~_(duck(sut ^$(gen p.gen)) $(gen q.gen)) + {%sggr *} $(gen q.gen) + {%tsgr *} $(gen q.gen, sut $(gen p.gen)) + {%tscm *} $(gen q.gen, sut (busk p.gen)) + {%wtcl *} =+ [fex=(gain p.gen) wux=(lose p.gen)] %- fork :~ ?:(=(%void fex) %void $(sut fex, gen q.gen)) ?:(=(%void wux) %void $(sut wux, gen r.gen)) == - {$fits *} bool - {$wthx *} bool - {$dbug *} ~_((show %o p.gen) $(gen q.gen)) - {$zpcm *} $(gen p.gen) - {$lost *} %void - {$zpmc *} (cell $(gen p.gen) $(gen q.gen)) - {$zpgl *} (play [%kttr p.gen]) - {$zpts *} %noun - {$zppt *} ?:((feel p.gen) $(gen q.gen) $(gen r.gen)) - {$zpzp *} %void + {%fits *} bool + {%wthx *} bool + {%dbug *} ~_((show %o p.gen) $(gen q.gen)) + {%zpcm *} $(gen p.gen) + {%lost *} %void + {%zpmc *} (cell $(gen p.gen) $(gen q.gen)) + {%zpgl *} (play [%kttr p.gen]) + {%zpts *} %noun + {%zppt *} ?:((feel p.gen) $(gen q.gen) $(gen r.gen)) + {%zpzp *} %void * =+ doz=~(open ap gen) ?: =(doz gen) ~_ (show [%c 'hoon'] [%q gen]) @@ -10794,22 +10794,22 @@ :: check for trivial cases :: ?: ?| =(sut ref) - ?=(?($noun $void {?($atom $core) *}) ref) + ?=(?(%noun %void {?(%atom %core) *}) ref) == done :: ~_ (dunk 'redo: dext: sut') :: ~_ (dunk(sut ref) 'redo: dext: ref') ?- sut - ?($noun $void {?($atom $core) *}) + ?(%noun %void {?(%atom %core) *}) :: reduce reference and reassemble leaf :: done:(sint &) :: - {$cell *} + {%cell *} :: reduce reference to match subject :: => (sint &) - ?> ?=({$cell *} sut) + ?> ?=({%cell *} sut) :: leaf with possible recursive descent :: %= done @@ -10826,26 +10826,26 @@ dext(sut q.sut, ref (peek(sut ref) %free 3)) == :: - {$face *} + {%face *} :: push face on subject stack, and descend :: dext(hos [p.sut hos], sut q.sut) :: - {$hint *} + {%hint *} :: work through hint :: (hint p.sut dext(sut q.sut)) :: - {$fork *} + {%fork *} :: reconstruct each case in fork :: (fork (turn ~(tap in p.sut) |=(type dext(sut +<)))) :: - {$hold *} + {%hold *} :: reduce to hard :: => (sint |) - ?> ?=({$hold *} sut) + ?> ?=({%hold *} sut) ?: (~(has in fan) [p.sut q.sut]) :: repo loop; redo depends on its own product :: @@ -10894,8 +10894,8 @@ :: ~> %slog.[0 (dunk(sut =>(- ref)) 'sint: pro')] :: - ?+ ref . - {$hint *} $(ref q.ref) - {$face *} + {%hint *} $(ref q.ref) + {%face *} :: extend all stacks in set :: %= $ @@ -10903,7 +10903,7 @@ wec (~(run in wec) |=((list tool) [p.ref +<])) == :: - {$fork *} + {%fork *} :: reconstruct all relevant cases :: =- :: ~> %slog.[0 (dunk 'fork: sut')] @@ -10924,7 +10924,7 @@ =/ dis ^$(ref i.moy) [(~(uni in p.mor) wec.dis) [ref.dis q.mor]] :: - {$hold *} + {%hold *} ?. hod . $(ref repo(sut ref)) == @@ -10933,11 +10933,11 @@ ++ repo ^- type ?- sut - {$core *} [%cell %noun p.sut] - {$face *} q.sut - {$hint *} q.sut - {$hold *} (rest [[p.sut q.sut] ~]) - $noun (fork [%atom %$ ~] [%cell %noun %noun] ~) + {%core *} [%cell %noun p.sut] + {%face *} q.sut + {%hint *} q.sut + {%hold *} (rest [[p.sut q.sut] ~]) + %noun (fork [%atom %$ ~] [%cell %noun %noun] ~) * ~>(%mean.'repo-fltt' !!) == :: @@ -10963,10 +10963,10 @@ ?~ i.vit |- ^- type ?+ sut ^$(vit t.vit) - {$face *} (face p.sut ^$(vit t.vit, sut q.sut)) - {$hint *} (hint p.sut ^$(sut q.sut)) - {$fork *} (fork (turn ~(tap in p.sut) |=(type ^$(sut +<)))) - {$hold *} $(sut repo) + {%face *} (face p.sut ^$(vit t.vit, sut q.sut)) + {%hint *} (hint p.sut ^$(sut q.sut)) + {%fork *} (fork (turn ~(tap in p.sut) |=(type ^$(sut +<)))) + {%hold *} $(sut repo) == =+ vil=*(set type) |- ^- type @@ -10974,19 +10974,19 @@ ^$(vit t.vit) =+ [now lat]=(cap u.i.vit)^(mas u.i.vit) ?- sut - $noun $(sut [%cell %noun %noun]) - $void %void - {$atom *} %void - {$cell *} ?: =(2 now) + %noun $(sut [%cell %noun %noun]) + %void %void + {%atom *} %void + {%cell *} ?: =(2 now) (cell $(sut p.sut, u.i.vit lat) q.sut) (cell p.sut $(sut q.sut, u.i.vit lat)) - {$core *} ?: =(2 now) + {%core *} ?: =(2 now) $(sut repo) (core $(sut p.sut, u.i.vit lat) q.sut) - {$face *} (face p.sut $(sut q.sut)) - {$fork *} (fork (turn ~(tap in p.sut) |=(type ^$(sut +<)))) - {$hint *} (hint p.sut $(sut q.sut)) - {$hold *} ?: (~(has in vil) sut) + {%face *} (face p.sut $(sut q.sut)) + {%fork *} (fork (turn ~(tap in p.sut) |=(type ^$(sut +<)))) + {%hint *} (hint p.sut $(sut q.sut)) + {%hold *} ?: (~(has in vil) sut) %void $(sut repo, vil (~(put in vil) sut)) == @@ -11018,40 +11018,40 @@ :: ++ wrap ~/ %wrap - |= yoz/?($lead $iron $zinc) + |= yoz/?(%lead %iron %zinc) ~_ leaf+"wrap" ^- type ?+ sut sut - {$cell *} (cell $(sut p.sut) $(sut q.sut)) - {$core *} ?>(|(=(%gold r.p.q.sut) =(%lead yoz)) sut(r.p.q yoz)) - {$face *} (face p.sut $(sut q.sut)) - {$fork *} (fork (turn ~(tap in p.sut) |=(type ^$(sut +<)))) - {$hint *} (hint p.sut $(sut q.sut)) - {$hold *} $(sut repo) + {%cell *} (cell $(sut p.sut) $(sut q.sut)) + {%core *} ?>(|(=(%gold r.p.q.sut) =(%lead yoz)) sut(r.p.q yoz)) + {%face *} (face p.sut $(sut q.sut)) + {%fork *} (fork (turn ~(tap in p.sut) |=(type ^$(sut +<)))) + {%hint *} (hint p.sut $(sut q.sut)) + {%hold *} $(sut repo) == -- ++ us :: prettyprinter => |% ++ cape {p/(map @ud wine) q/wine} :: ++ wine :: - $@ $? $noun :: - $path :: - $type :: - $void :: - $wall :: - $wool :: - $yarn :: + $@ $? %noun :: + %path :: + %type :: + %void :: + %wall :: + %wool :: + %yarn :: == :: - $% {$mato p/term} :: - {$core p/(list @ta) q/wine} :: - {$face p/term q/wine} :: - {$list p/term q/wine} :: - {$pear p/term q/@} :: - {$bcwt p/(list wine)} :: - {$plot p/(list wine)} :: - {$stop p/@ud} :: - {$tree p/term q/wine} :: - {$unit p/term q/wine} :: + $% {%mato p/term} :: + {%core p/(list @ta) q/wine} :: + {%face p/term q/wine} :: + {%list p/term q/wine} :: + {%pear p/term q/@} :: + {%bcwt p/(list wine)} :: + {%plot p/(list wine)} :: + {%stop p/@ud} :: + {%tree p/term q/wine} :: + {%unit p/term q/wine} :: == :: -- |_ sut/type @@ -11088,15 +11088,15 @@ ++ $ ^- {tank (set @ud)} ?- q.ham - $noun :_(gid [%leaf '*' ~]) - $path :_(gid [%leaf '/' ~]) - $type :_(gid [%leaf '#' 't' ~]) - $void :_(gid [%leaf '#' '!' ~]) - $wool :_(gid [%leaf '*' '"' '"' ~]) - $wall :_(gid [%leaf '*' '\'' '\'' ~]) - $yarn :_(gid [%leaf '"' '"' ~]) - {$mato *} :_(gid [%leaf '@' (trip p.q.ham)]) - {$core *} + %noun :_(gid [%leaf '*' ~]) + %path :_(gid [%leaf '/' ~]) + %type :_(gid [%leaf '#' 't' ~]) + %void :_(gid [%leaf '#' '!' ~]) + %wool :_(gid [%leaf '*' '"' '"' ~]) + %wall :_(gid [%leaf '*' '\'' '\'' ~]) + %yarn :_(gid [%leaf '"' '"' ~]) + {%mato *} :_(gid [%leaf '@' (trip p.q.ham)]) + {%core *} =^ cox gid $(q.ham q.q.ham) :_ gid :+ %rose @@ -11105,26 +11105,26 @@ ?~ p.q.ham [cox ~] [[%leaf (rip 3 i.p.q.ham)] $(p.q.ham t.p.q.ham)] :: - {$face *} + {%face *} =^ cox gid $(q.ham q.q.ham) :_(gid [%palm [['=' ~] ~ ~ ~] [%leaf (trip p.q.ham)] cox ~]) :: - {$list *} + {%list *} =^ cox gid $(q.ham q.q.ham) :_(gid [%rose [" " (weld (trip p.q.ham) "(") ")"] cox ~]) :: - {$bcwt *} + {%bcwt *} =^ coz gid (many p.q.ham) :_(gid [%rose [[' ' ~] ['?' '(' ~] [')' ~]] coz]) :: - {$plot *} + {%plot *} =^ coz gid (many p.q.ham) :_(gid [%rose [[' ' ~] ['[' ~] [']' ~]] coz]) :: - {$pear *} + {%pear *} :_(gid [%leaf '%' ~(rend co [%$ p.q.ham q.q.ham])]) :: - {$stop *} + {%stop *} =+ num=~(rend co [%$ %ud p.q.ham]) ?: (~(has in gid) p.q.ham) :_(gid [%leaf '#' num]) @@ -11135,11 +11135,11 @@ == :_(gid [%palm [['.' ~] ~ ~ ~] [%leaf ['^' '#' num]] cox ~]) :: - {$tree *} + {%tree *} =^ cox gid $(q.ham q.q.ham) :_(gid [%rose [" " (weld (trip p.q.ham) "(") ")"] cox ~]) :: - {$unit *} + {%unit *} =^ cox gid $(q.ham q.q.ham) :_(gid [%rose [" " (weld (trip p.q.ham) "(") ")"] cox ~]) == @@ -11154,7 +11154,7 @@ =| gil/(set {@ud *}) |- ^- (unit tank) ?- q.ham - $noun + %noun %= $ q.ham ?: ?=(@ lum) @@ -11164,7 +11164,7 @@ [%noun ?:(?=(@ +.lum) [[%mato %$] ~] $(lum +.lum))] == :: - $path + %path :- ~ :+ %rose [['/' ~] ['/' ~] ~] @@ -11174,7 +11174,7 @@ ?> ?=(@ -.lum) [[%leaf (rip 3 -.lum)] $(lum +.lum)] :: - $type + %type =+ tyr=|.((dial dole)) =+ vol=tyr(sut lum) =+ cis=;;(tank .*(vol [%9 2 %0 1])) @@ -11182,7 +11182,7 @@ [~ ~ ~ ~] [[%leaf '#' 't' '/' ~] cis ~] :: - $wall + %wall :- ~ :+ %rose [[' ' ~] ['<' '|' ~] ['|' '>' ~]] @@ -11191,7 +11191,7 @@ ?@ lum !! [[%leaf (trip ;;(@ -.lum))] $(lum +.lum)] :: - $wool + %wool :- ~ :+ %rose [[' ' ~] ['<' '<' ~] ['>' '>' ~]] @@ -11200,25 +11200,25 @@ ?@ lum !! [(need ^$(q.ham %yarn, lum -.lum)) $(lum +.lum)] :: - $yarn + %yarn [~ %leaf (dash (tape lum) '"' "\{")] :: - $void + %void ~ :: - {$mato *} + {%mato *} ?. ?=(@ lum) ~ :+ ~ %leaf ?+ (rash p.q.ham ;~(sfix (cook crip (star low)) (star hig))) ~(rend co [%$ p.q.ham lum]) - $$ ~(rend co [%$ %ud lum]) - $t (dash (rip 3 lum) '\'' ~) - $tas ['%' ?.(=(0 lum) (rip 3 lum) ['$' ~])] + %$ ~(rend co [%$ %ud lum]) + %t (dash (rip 3 lum) '\'' ~) + %tas ['%' ?.(=(0 lum) (rip 3 lum) ['$' ~])] == :: - {$core *} + {%core *} :: XX needs rethinking for core metal :: ?. ?=(^ lum) ~ :: => .(lum `*`lum) @@ -11232,13 +11232,13 @@ :: ?~(mur ~ [~ [[%leaf (rip 3 i.p.q.ham)] u.mur]]) [~ (dial ham)] :: - {$face *} + {%face *} =+ wal=$(q.ham q.q.ham) ?~ wal ~ [~ %palm [['=' ~] ~ ~ ~] [%leaf (trip p.q.ham)] u.wal ~] :: - {$list *} + {%list *} ?: =(~ lum) [~ %leaf '~' ~] =- ?~ tok @@ -11253,7 +11253,7 @@ ~ [~ u.for u.aft] :: - {$bcwt *} + {%bcwt *} |- ^- (unit tank) ?~ p.q.ham ~ @@ -11262,7 +11262,7 @@ $(p.q.ham t.p.q.ham) wal :: - {$plot *} + {%plot *} =- ?~ tok ~ [~ %rose [[' ' ~] ['[' ~] [']' ~]] u.tok] @@ -11283,25 +11283,25 @@ ~ [~ u.gim u.myd] :: - {$pear *} + {%pear *} ?. =(lum q.q.ham) ~ =. p.q.ham (rash p.q.ham ;~(sfix (cook crip (star low)) (star hig))) =+ fox=$(q.ham [%mato p.q.ham]) - ?> ?=({~ $leaf ^} fox) - ?: ?=(?($n $tas) p.q.ham) + ?> ?=({~ %leaf ^} fox) + ?: ?=(?(%n %tas) p.q.ham) fox [~ %leaf '%' p.u.fox] :: - {$stop *} + {%stop *} ?: (~(has in gil) [p.q.ham lum]) ~ =+ kep=(~(get by p.ham) p.q.ham) ?~ kep ~|([%stop-loss p.q.ham] !!) $(gil (~(put in gil) [p.q.ham lum]), q.ham u.kep) :: - {$tree *} + {%tree *} =- ?~ tok ~ [~ %rose [[' ' ~] ['{' ~] ['}' ~]] u.tok] @@ -11320,7 +11320,7 @@ ~ $(lum l.lum, tuk [u.tim u.rol]) :: - {$unit *} + {%unit *} ?@ lum ?.(=(~ lum) ~ [~ %leaf '~' ~]) ?. =(~ -.lum) @@ -11334,15 +11334,15 @@ ++ doge |= ham/cape =- ?+ woz woz - {$list * {$mato $'ta'}} %path - {$list * {$mato $'t'}} %wall - {$list * {$mato $'tD'}} %yarn - {$list * $yarn} %wool + {%list * {%mato %'ta'}} %path + {%list * {%mato %'t'}} %wall + {%list * {%mato %'tD'}} %yarn + {%list * %yarn} %wool == ^= woz ^- wine - ?. ?=({$stop *} q.ham) - ?: ?& ?= {$bcwt {$pear $n $0} {$plot {$pear $n $0} {$face *} ~} ~} + ?. ?=({%stop *} q.ham) + ?: ?& ?= {%bcwt {%pear %n %0} {%plot {%pear %n %0} {%face *} ~} ~} q.ham =(1 (met 3 p.i.t.p.i.t.p.q.ham)) == @@ -11352,13 +11352,13 @@ ?~ may q.ham =+ nul=[%pear %n 0] - ?. ?& ?=({$bcwt *} u.may) + ?. ?& ?=({%bcwt *} u.may) ?=({* * ~} p.u.may) |(=(nul i.p.u.may) =(nul i.t.p.u.may)) == q.ham =+ din=?:(=(nul i.p.u.may) i.t.p.u.may i.p.u.may) - ?: ?& ?=({$plot {$face *} {$face * $stop *} ~} din) + ?: ?& ?=({%plot {%face *} {%face * %stop *} ~} din) =(p.q.ham p.q.i.t.p.din) =(1 (met 3 p.i.p.din)) =(1 (met 3 p.i.t.p.din)) @@ -11366,10 +11366,10 @@ :+ %list (cat 3 p.i.p.din p.i.t.p.din) q.i.p.din - ?: ?& ?= $: $plot - {$face *} - {$face * $stop *} - {{$face * $stop *} ~} + ?: ?& ?= $: %plot + {%face *} + {%face * %stop *} + {{%face * %stop *} ~} == din =(p.q.ham p.q.i.t.p.din) @@ -11398,21 +11398,21 @@ ?: (~(meet ut sut) -:!>(*type)) [dex %type] ?- sut - $noun [dex sut] - $void [dex sut] - {$atom *} [dex ?~(q.sut [%mato p.sut] [%pear p.sut u.q.sut])] - {$cell *} + %noun [dex sut] + %void [dex sut] + {%atom *} [dex ?~(q.sut [%mato p.sut] [%pear p.sut u.q.sut])] + {%cell *} =+ hin=$(sut p.sut) =+ yon=$(dex p.hin, sut q.sut) :- p.yon :- %plot - ?:(?=({$plot *} q.yon) [q.hin p.q.yon] [q.hin q.yon ~]) + ?:(?=({%plot *} q.yon) [q.hin p.q.yon] [q.hin q.yon ~]) :: - {$core *} + {%core *} =+ yad=$(sut p.sut) :- p.yad =+ ^= doy ^- {p/(list @ta) q/wine} - ?: ?=({$core *} q.yad) + ?: ?=({%core *} q.yad) [p.q.yad q.q.yad] [~ q.yad] :- %core @@ -11424,7 +11424,7 @@ %- ~(rep by (~(run by q.r.q.sut) |=(tome ~(wyt by q.+<)))) |=([[@ a=@u] b=@u] (add a b)) %^ cat 3 - ?-(r.p.q.sut $gold '.', $iron '|', $lead '?', $zinc '&') + ?-(r.p.q.sut %gold '.', %iron '|', %lead '?', %zinc '&') =+ gum=(mug q.r.q.sut) %+ can 3 :~ [1 (add 'a' (mod gum 26))] @@ -11432,14 +11432,14 @@ [1 (add 'a' (mod (div gum 676) 26))] == :: - {$hint *} + {%hint *} $(sut q.sut) :: - {$face *} + {%face *} =+ yad=$(sut q.sut) ?^(p.sut yad [p.yad [%face p.sut q.yad]]) :: - {$fork *} + {%fork *} =+ yed=(sort ~(tap in p.sut) aor) =- [p [%bcwt q]] |- ^- {p/{p/(map type @) q/(map @ wine)} q/(list wine)} @@ -11449,7 +11449,7 @@ =+ dis=^$(dex p.mor, sut i.yed) [p.dis q.dis q.mor] :: - {$hold *} + {%hold *} =+ hey=(~(get by p.dex) sut) ?^ hey [dex [%stop u.hey]] @@ -11563,9 +11563,9 @@ |= {cog/@tas typ/type} ^- ? ?+ typ | - {$hold *} $(typ ~(repo ut typ)) - {$hint *} $(typ ~(repo ut typ)) - {$core *} + {%hold *} $(typ ~(repo ut typ)) + {%hint *} $(typ ~(repo ut typ)) + {%core *} |- ^- ? ?~ q.r.q.typ | ?| (~(has by q.q.n.q.r.q.typ) cog) @@ -11578,9 +11578,9 @@ |= typ/type ^- (list term) ?+ typ ~ - {$hold *} $(typ ~(repo ut typ)) - {$hint *} $(typ ~(repo ut typ)) - {$core *} + {%hold *} $(typ ~(repo ut typ)) + {%hint *} $(typ ~(repo ut typ)) + {%core *} %- zing %+ turn ~(tap by q.r.q.typ) |= {* b/tome} @@ -11643,7 +11643,7 @@ (stag %sand (stag %tas (cold %$ buc))) (stag %sand (stag %t qut)) %+ cook - |=(a/coin [%sand ?:(?=({~ $tas *} a) %tas %ta) ~(rent co a)]) + |=(a/coin [%sand ?:(?=({~ %tas *} a) %tas %ta) ~(rent co a)]) nuck:so == ++ limp %+ cook @@ -11767,13 +11767,13 @@ :: ++ plex :: reparse static path |= gen/hoon ^- (unit path) - ?: ?=({$dbug *} gen) :: unwrap $dbug + ?: ?=({%dbug *} gen) :: unwrap %dbug $(gen q.gen) - ?. ?=({$clsg *} gen) ~ :: require :~ hoon + ?. ?=({%clsg *} gen) ~ :: require :~ hoon %+ reel p.gen :: build using elements |= {a/hoon b/_`(unit path)`[~ u=/]} :: starting from just / ?~ b ~ - ?. ?=({$sand ?($ta $tas) @} a) ~ :: /foo constants + ?. ?=({%sand ?(%ta %tas) @} a) ~ :: /foo constants `[q.a u.b] :: ++ phax @@ -12010,8 +12010,8 @@ == :: ++ en-class - |= a/(list {$class p/term}) - ^- (unit {$class tape}) + |= a/(list {%class p/term}) + ^- (unit {%class tape}) ?~ a ~ %- some :- %class @@ -12076,7 +12076,7 @@ ::REVIEW is there a better way to do this? ++ hopefully-quote :: prefer "quote" form %+ cook |=(a/(list beer:hoot) a) - %+ cook |=(a/hoon ?:(?=($knit -.a) p.a [~ a]~)) + %+ cook |=(a/hoon ?:(?=(%knit -.a) p.a [~ a]~)) wide :: ++ script-style-tail :: unescaped tall tail @@ -12127,48 +12127,48 @@ ++ colm @ud :: column ++ tarp marl:hoot :: node or generator ++ mite :: context - $? $down :: outer embed - $lunt :: unordered list - $lime :: list item - $lord :: ordered list - $poem :: verse - $bloc :: blockquote - $head :: heading + $? %down :: outer embed + %lunt :: unordered list + %lime :: list item + %lord :: ordered list + %poem :: verse + %bloc :: blockquote + %head :: heading == :: ++ trig :: line style $: col/@ud :: start column sty/trig-style :: style == :: ++ trig-style :: type of parsed line - $% $: $end :: terminator - $? $done :: end of input - $stet :: == end of markdown - $dent :: outdent + $% $: %end :: terminator + $? %done :: end of input + %stet :: == end of markdown + %dent :: outdent == == :: - $: $one :: leaf node - $? $rule :: --- horz rule - $fens :: ``` code fence - $expr :: ;sail expression + $: %one :: leaf node + $? %rule :: --- horz rule + %fens :: ``` code fence + %expr :: ;sail expression == == :: - {$new p/trig-new} :: open container - {$old $text} :: anything else + {%new p/trig-new} :: open container + {%old %text} :: anything else == :: ++ trig-new :: start a - $? $lite :: + line item - $lint :: - line item - $head :: # heading - $bloc :: > block-quote - $poem :: [ ]{8} poem + $? %lite :: + line item + %lint :: - line item + %head :: # heading + %bloc :: > block-quote + %poem :: [ ]{8} poem == :: ++ graf :: paragraph element - $% {$bold p/(list graf)} :: *bold* - {$talc p/(list graf)} :: _italics_ - {$quod p/(list graf)} :: "double quote" - {$code p/tape} :: code literal - {$text p/tape} :: text symbol - {$link p/(list graf) q/tape} :: URL - {$mage p/tape q/tape} :: image - {$expr p/tuna:hoot} :: interpolated hoon + $% {%bold p/(list graf)} :: *bold* + {%talc p/(list graf)} :: _italics_ + {%quod p/(list graf)} :: "double quote" + {%code p/tape} :: code literal + {%text p/tape} :: text symbol + {%link p/(list graf) q/tape} :: URL + {%mage p/tape q/tape} :: image + {%expr p/tuna:hoot} :: interpolated hoon == -- =< (non-empty:parse |=(nail `(like tarp)`~($ main +<))) @@ -12219,13 +12219,13 @@ :: ++ cur-indent ?- p.cur - $down 2 - $head 0 - $lunt 0 - $lime 2 - $lord 0 - $poem 8 - $bloc 2 + %down 2 + %head 0 + %lunt 0 + %lime 2 + %lord 0 + %poem 8 + %bloc 2 == :: ++ back :: column retreat @@ -12246,15 +12246,15 @@ :: ++ cur-to-tarp :: item to tarp ^- tarp - ?: ?=(?($down $head $expr) p.cur) + ?: ?=(?(%down %head %expr) p.cur) (flop q.cur) =- [[- ~] (flop q.cur)]~ ?- p.cur - $lunt %ul - $lord %ol - $lime %li - $poem %div ::REVIEW actual container element? - $bloc %blockquote + %lunt %ul + %lord %ol + %lime %li + %poem %div ::REVIEW actual container element? + %bloc %blockquote == :: ++ close-item ^+ . :: complete and pop @@ -12285,14 +12285,14 @@ :: :: trim trailing spaces |- ^- tape - ?: ?=({$' ' *} lin) + ?: ?=({%' ' *} lin) $(lin t.lin) (flop lin) :: =/ eat-newline/nail [[+(p.loc) 1] t.txt] =/ saw look(+<.$ eat-newline) :: - ?: ?=({~ @ $end ?($stet $dent)} saw) :: stop on == or dedent + ?: ?=({~ @ %end ?(%stet %dent)} saw) :: stop on == or dedent [[lin `~] +<.^$] [[lin ~] eat-newline] :: @@ -12315,7 +12315,7 @@ ?~ par . :: :: if block is verse - ?: ?=($poem p.cur) + ?: ?=(%poem p.cur) :: :: add break between stanzas =. q.cur ?~(q.cur q.cur [[[%br ~] ~] q.cur]) @@ -12340,7 +12340,7 @@ :: :: either a one-line header or a paragraph %. [p.u.par yex] - ?: ?=($head p.cur) + ?: ?=(%head p.cur) (full head:parse) (full para:parse) :: @@ -12350,7 +12350,7 @@ ..$(err `p.vex) :: :: finish tag if it's a header - =< ?:(?=($head p.cur) close-item ..$) + =< ?:(?=(%head p.cur) close-item ..$) :: :: save good result, clear buffer ..$(par ~, q.cur (weld p.u.q.vex q.cur)) @@ -12377,13 +12377,13 @@ => .(saw u.saw) :: :: if end of input, complete - ?: ?=($end -.sty.saw) + ?: ?=(%end -.sty.saw) ..$(q.loc col.saw) :: =. ind ?~(out.ind [col.saw col.saw] ind) :: init indents :: ?: ?| ?=(~ par) :: if after a paragraph or - ?& ?=(?($down $lime $bloc) p.cur) :: unspaced new container + ?& ?=(?(%down %lime %bloc) p.cur) :: unspaced new container |(!=(%old -.sty.saw) (gth col.saw inr.ind)) == == => .(..$ close-par) @@ -12393,8 +12393,8 @@ :: =^ col-ok sty.saw ?+ (sub col.saw inr.ind) [| sty.saw] :: columns advanced - $0 [& sty.saw] - $8 [& %new %poem] + %0 [& sty.saw] + %8 [& %new %poem] == ?. col-ok ~? verbose [%columns-advanced col.saw inr.ind] @@ -12404,17 +12404,17 @@ :: :: unless adding a matching item, close lists =. ..$ - ?: ?| &(?=($lunt p.cur) !?=($lint +.sty.saw)) - &(?=($lord p.cur) !?=($lite +.sty.saw)) + ?: ?| &(?=(%lunt p.cur) !?=(%lint +.sty.saw)) + &(?=(%lord p.cur) !?=(%lite +.sty.saw)) == close-item ..$ :: =< line(par `[loc ~]) ^+ ..$ :: continue with para ?- -.sty.saw - $one (read-one +.sty.saw) :: parse leaves - $new (open-item p.sty.saw) :: open containers - $old ..$ :: just text + %one (read-one +.sty.saw) :: parse leaves + %new (open-item p.sty.saw) :: open containers + %old ..$ :: just text == :: :: @@ -12425,16 +12425,16 @@ ?- p.cur :: :: can't(/directly) contain text - ?($lord $lunt) ~|(bad-leaf-container+p.cur !!) + ?(%lord %lunt) ~|(bad-leaf-container+p.cur !!) :: :: only one line in a header - $head | + %head | :: :: indented literals need to end with a blank line - $poem (gte col.saw inr.ind) + %poem (gte col.saw inr.ind) :: :: text tarps must continue aligned - ?($down $lunt $lime $lord $bloc) =(col.saw inr.ind) + ?(%down %lunt %lime %lord %bloc) =(col.saw inr.ind) == ~? verbose bad-block-structure+[p.cur inr.ind col.saw] ..$(err `[p.loc col.saw]) @@ -12458,11 +12458,11 @@ == :: ++ read-one :: read %one item - |= sty/?($expr $rule $fens) ^+ +> + |= sty/?(%expr %rule %fens) ^+ +> ?- sty - $expr (parse-block expr:parse) - $rule (parse-block hrul:parse) - $fens (parse-block (fens:parse inr.ind)) + %expr (parse-block expr:parse) + %rule (parse-block hrul:parse) + %fens (parse-block (fens:parse inr.ind)) == :: ++ open-item :: enter list/quote @@ -12471,11 +12471,11 @@ |% ++ apex ^+ . :: open container ?- saw - $poem (push %poem) :: verse literal - $head (push %head) :: heading - $bloc (entr %bloc) :: blockquote line - $lint (lent %lunt) :: unordered list - $lite (lent %lord) :: ordered list + %poem (push %poem) :: verse literal + %head (push %head) :: heading + %bloc (entr %bloc) :: blockquote line + %lint (lent %lunt) :: unordered list + %lite (lent %lord) :: ordered list == :: ++ push :: push context @@ -12495,7 +12495,7 @@ (push typ) :: ++ lent :: list entry - |= ord/?($lord $lunt) + |= ord/?(%lord %lunt) ^+ +> => ?:(=(ord p.cur) +>.$ (push ord)) :: push list if new (entr %lime) @@ -12725,14 +12725,14 @@ ++ main ^- tarp ?~ gaf ~ - ?. ?=($text -.i.gaf) + ?. ?=(%text -.i.gaf) (weld (item i.gaf) $(gaf t.gaf)) :: :: fip: accumulate text blocks =/ fip/(list tape) [p.i.gaf]~ |- ^- tarp ?~ t.gaf [;/((zing (flop fip))) ~] - ?. ?=($text -.i.t.gaf) + ?. ?=(%text -.i.t.gaf) [;/((zing (flop fip))) ^$(gaf t.gaf)] $(gaf t.gaf, fip :_(fip p.i.t.gaf)) :: @@ -12740,12 +12740,12 @@ |= nex/graf ^- tarp ::CHECK can be tuna:hoot? ?- -.nex - $text !! :: handled separately - $expr [p.nex]~ - $bold [[%b ~] ^$(gaf p.nex)]~ - $talc [[%i ~] ^$(gaf p.nex)]~ - $code [[%code ~] ;/(p.nex) ~]~ - $quod :: + %text !! :: handled separately + %expr [p.nex]~ + %bold [[%b ~] ^$(gaf p.nex)]~ + %talc [[%i ~] ^$(gaf p.nex)]~ + %code [[%code ~] ;/(p.nex) ~]~ + %quod :: :: smart quotes %= ^$ gaf @@ -12753,8 +12753,8 @@ %+ weld p.nex `(list graf)`[%text (tufa ~-~201d. ~)]~ == - $link [[%a [%href q.nex] ~] ^$(gaf p.nex)]~ - $mage [[%img [%src q.nex] ?~(p.nex ~ [%alt p.nex]~)] ~]~ + %link [[%a [%href q.nex] ~] ^$(gaf p.nex)]~ + %mage [[%img [%src q.nex] ?~(p.nex ~ [%alt p.nex]~)] ~]~ == -- :: @@ -12825,7 +12825,7 @@ %+ weld ^- tape ?- i.a - {{$$ {$$ *} ~} ~} :: text node contents + {{%$ {%$ *} ~} ~} :: text node contents (murn v.i.a.g.i.a |=(a/beer:hoot ?^(a ~ (some a)))) {^ *} $(a c.i.a) :: concatenate children {@ *} ~ :: ignore interpolation @@ -12864,7 +12864,7 @@ (stag %leaf (stag %f (cold & pam))) (stag %leaf (stag %f (cold | bar))) (stag %leaf (stag %t qut)) - (stag %leaf (sear |=(a/coin ?:(?=($$ -.a) (some +.a) ~)) nuck:so)) + (stag %leaf (sear |=(a/coin ?:(?=(%$ -.a) (some +.a) ~)) nuck:so)) == == == @@ -12950,7 +12950,7 @@ :: (stag %leaf (stag %tas (cold %$ buc))) (stag %leaf (stag %t qut)) - (stag %leaf (sear |=(a/coin ?:(?=($$ -.a) (some +.a) ~)) nuck:so)) + (stag %leaf (sear |=(a/coin ?:(?=(%$ -.a) (some +.a) ~)) nuck:so)) == == rump @@ -13691,10 +13691,10 @@ ++ lang :: lung sample $: ros/hoon $= vil - $% {$tis p/hoon} - {$col p/hoon} - {$ket p/hoon} - {$lit p/(list (pair wing hoon))} + $% {%tis p/hoon} + {%col p/hoon} + {%ket p/hoon} + {%lit p/(list (pair wing hoon))} == == :: @@ -13704,10 +13704,10 @@ |: $:lang ^- (unit hoon) ?- -.vil - $col ?:(=([%base %flag] ros) ~ [~ %tsgl ros p.vil]) - $lit (bind ~(reek ap ros) |=(hyp/wing [%cnts hyp p.vil])) - $ket [~ ros p.vil] - $tis =+ rud=~(flay ap ros) + %col ?:(=([%base %flag] ros) ~ [~ %tsgl ros p.vil]) + %lit (bind ~(reek ap ros) |=(hyp/wing [%cnts hyp p.vil])) + %ket [~ ros p.vil] + %tis =+ rud=~(flay ap ros) ?~(rud ~ `[%ktts u.rud p.vil]) == :: @@ -14001,7 +14001,7 @@ ++ mane $@(@tas {@tas @tas}) :: XML name+space ++ manx $~([[%$ ~] ~] {g/marx c/marl}) :: dynamic XML node ++ marl (list manx) :: XML node list -++ mars {t/{n/$$ a/{i/{n/$$ v/tape} t/~}} c/~} :: XML cdata +++ mars {t/{n/%$ a/{i/{n/%$ v/tape} t/~}} c/~} :: XML cdata ++ mart (list {n/mane v/tape}) :: XML attributes ++ marx $~([%$ ~] {n/mane a/mart}) :: dynamic XML tag ++ mite (list @ta) :: mime type @@ -14046,13 +14046,13 @@ ++ pi-mope :: add sample |= {mot/term mon/moan} ?+ mot mon - $fun mon(fun +(fun.mon)) - $noc mon(noc +(noc.mon)) - $glu mon(glu +(glu.mon)) - $mal mon(mal +(mal.mon)) - $far mon(far +(far.mon)) - $coy mon(coy +(coy.mon)) - $euq mon(euq +(euq.mon)) + %fun mon(fun +(fun.mon)) + %noc mon(noc +(noc.mon)) + %glu mon(glu +(glu.mon)) + %mal mon(mal +(mal.mon)) + %far mon(far +(far.mon)) + %coy mon(coy +(coy.mon)) + %euq mon(euq +(euq.mon)) == ++ pi-moth :: count sample |= mon/moan ^- @ud diff --git a/pkg/arvo/sys/vane/clay.hoon b/pkg/arvo/sys/vane/clay.hoon index eb7177c22b..74a51c9847 100644 --- a/pkg/arvo/sys/vane/clay.hoon +++ b/pkg/arvo/sys/vane/clay.hoon @@ -50,7 +50,7 @@ :: gets file contents, %y gets a directory listing, and %z gets a recursive :: hash of the file contents and children. :: -:: ++ care ?($d $p $t $u $v $w $x $y $z) +:: ++ care ?(%d %p %t %u %v %w %x %y %z) :: :: Keeps track of subscribers. :: @@ -1123,7 +1123,7 @@ |= [lim=@da lok=case] ^- (unit aeon) ?- -.lok - $da + %da ?: (gth p.lok lim) ~ |- ^- (unit aeon) ?: =(0 let.dom) [~ 0] :: avoid underflow @@ -1136,8 +1136,8 @@ [~ let.dom] $(let.dom (dec let.dom)) :: - $tas (~(get by lab.dom) p.lok) - $ud ?:((gth p.lok let.dom) ~ [~ p.lok]) + %tas (~(get by lab.dom) p.lok) + %ud ?:((gth p.lok let.dom) ~ [~ p.lok]) == :: ++ blas @@ -1250,8 +1250,8 @@ =; won/(unit wove) (fall won wov) =* rov rove.wov ?- -.rov - $sing ~ - $next + %sing ~ + %next =+ aey=(case-to-aeon case.mood.rov) ?~ aey ~ %- ~(rep in ~(key by qyx)) @@ -1260,7 +1260,7 @@ ?. =(for.wov for.haw) ~ =* hav rove.haw =- ?:(- `haw ~) - ?& ?=($next -.hav) + ?& ?=(%next -.hav) =(mood.hav mood.rov(case case.mood.hav)) :: :: only a match if this request is before @@ -1269,7 +1269,7 @@ ?~(hay | (lte u.hay u.aey)) == :: - $mult + %mult =+ aey=(case-to-aeon case.mool.rov) ?~ aey ~ %- ~(rep in ~(key by qyx)) @@ -1278,7 +1278,7 @@ ?. =(for.wov for.haw) ~ =* hav rove.haw =- ?:(- `haw ~) - ?& ?=($mult -.hav) + ?& ?=(%mult -.hav) =(mool.hav mool.rov(case case.mool.hav)) :: :: only a match if this request is before @@ -1292,7 +1292,7 @@ == == :: - $many + %many =+ aey=(case-to-aeon from.moat.rov) ?~ aey ~ %- ~(rep in ~(key by qyx)) @@ -1301,7 +1301,7 @@ ?. =(for.wov for.haw) ~ =* hav rove.haw =- ?:(- `haw ~) - ?& ?=($many -.hav) + ?& ?=(%many -.hav) =(hav rov(from.moat from.moat.hav)) :: :: only a match if this request is before @@ -2612,9 +2612,9 @@ %+ roll =- ~(tap in -) ?- -.rit - $r who:(fall red.rit *rule) - $w who:(fall wit.rit *rule) - $rw (~(uni in who:(fall red.rit *rule)) who:(fall wit.rit *rule)) + %r who:(fall red.rit *rule) + %w who:(fall wit.rit *rule) + %rw (~(uni in who:(fall red.rit *rule)) who:(fall wit.rit *rule)) == |= {w/whom s/(set @ta)} ?: |(?=(%& -.w) (~(has by cez) p.w)) s @@ -2636,9 +2636,9 @@ (emit hen %give %done ~) :: ?- -.rit - $r wake(per (put-perm per pax red.rit)) - $w wake(pew (put-perm pew pax wit.rit)) - $rw wake(per (put-perm per pax red.rit), pew (put-perm pew pax wit.rit)) + %r wake(per (put-perm per pax red.rit)) + %w wake(pew (put-perm pew pax wit.rit)) + %rw wake(per (put-perm per pax red.rit), pew (put-perm pew pax wit.rit)) == :: ++ put-perm @@ -2730,7 +2730,7 @@ :: %_ wake haw.u.ref - ?. ?=($sing -.rav) haw.u.ref + ?. ?=(%sing -.rav) haw.u.ref (~(put by haw.u.ref) mood.rav ~) == |^ @@ -2747,20 +2747,20 @@ |= =rand ^- (unit cage) ?- p.p.rand - $a ~| %no-big-ford-builds-across-network-for-now !! - $b ~| %i-guess-you-ought-to-build-your-own-marks !! - $c ~| %casts-should-be-compiled-on-your-own-ship !! - $d ~| %totally-temporary-error-please-replace-me !! - $p ~| %requesting-foreign-permissions-is-invalid !! - $r ~| %no-cages-please-they-are-just-way-too-big !! - $s ~| %please-dont-get-your-takos-over-a-network !! - $t ~| %requesting-foreign-directory-is-vaporware !! - $u ~| %prolly-poor-idea-to-get-rang-over-network !! - $v ~| %weird-shouldnt-get-v-request-from-network !! - $z `(validate-z r.rand) - $w `(validate-w r.rand) - $x (validate-x [p.p q.p q r]:rand) - $y `[p.r.rand !>(;;(arch q.r.rand))] + %a ~| %no-big-ford-builds-across-network-for-now !! + %b ~| %i-guess-you-ought-to-build-your-own-marks !! + %c ~| %casts-should-be-compiled-on-your-own-ship !! + %d ~| %totally-temporary-error-please-replace-me !! + %p ~| %requesting-foreign-permissions-is-invalid !! + %r ~| %no-cages-please-they-are-just-way-too-big !! + %s ~| %please-dont-get-your-takos-over-a-network !! + %t ~| %requesting-foreign-directory-is-vaporware !! + %u ~| %prolly-poor-idea-to-get-rang-over-network !! + %v ~| %weird-shouldnt-get-v-request-from-network !! + %z `(validate-z r.rand) + %w `(validate-w r.rand) + %x (validate-x [p.p q.p q r]:rand) + %y `[p.r.rand !>(;;(arch q.r.rand))] == :: :: Make sure the incoming data is a %w response @@ -2770,9 +2770,9 @@ ^- cage :- p.page ?+ p.page ~| %strange-w-over-nextwork !! - $cass !>(;;(cass q.page)) - $null [[%atom %n ~] ~] - $nako !>(~|([%molding [&1 &2 &3]:q.page] ;;(nako q.page))) + %cass !>(;;(cass q.page)) + %null [[%atom %n ~] ~] + %nako !>(~|([%molding [&1 &2 &3]:q.page] ;;(nako q.page))) == :: :: Make sure that incoming data is of the mark it claims to be. @@ -3378,8 +3378,8 @@ |= a/lobe => (lobe-to-blob a) ?- - - $delta p.q - $direct p.q + %delta p.q + %direct p.q == :: :: Checks whether two pieces of data (either cages or lobes) are the same. @@ -3491,8 +3491,8 @@ far =+ gar=(lobe-to-blob lob) ?- -.gar - $direct (~(put in far) lob) - $delta (~(put in $(lob q.q.gar)) lob) + %direct (~(put in far) lob) + %delta (~(put in $(lob q.q.gar)) lob) == :: :: Probably can get rid of the cache checks because they happen in @@ -3587,10 +3587,10 @@ ?+ car (allowed-by who pax per.red) :: - $p + %p =(who our) :: - ?($y $z) + ?(%y %z) =+ tak=(~(get by hit.dom) yon) ?~ tak | =+ yak=(tako-to-yaki u.tak) @@ -3600,7 +3600,7 @@ |= {p/path s/(set path)} ?. =(pax (scag len p)) s %- ~(put in s) - ?: ?=($z car) p + ?: ?=(%z car) p (scag +(len) p) == :: @@ -3766,7 +3766,7 @@ :: ++ read-v |= {yon/aeon pax/path} - ^- (unit (unit {$dome (hypo dome:clay)})) + ^- (unit (unit {%dome (hypo dome:clay)})) ?: (lth yon let.dom) :* ~ ~ %dome -:!>(*dome:clay) ^- dome:clay @@ -3822,17 +3822,17 @@ =+ mar=(lobe-to-mark u.lob) :: should convert any lobe to cage :: - ?. ?=($hoon mar) + ?. ?=(%hoon mar) [~ ~ %| u.lob] :^ ~ ~ %& :+ mar [%atom %t ~] |- ^- @t :: (urge cord) would be faster =+ bol=(lobe-to-blob u.lob) - ?: ?=($direct -.bol) + ?: ?=(%direct -.bol) ;;(@t q.q.bol) - ?> ?=($delta -.bol) + ?> ?=(%delta -.bol) =+ txt=$(u.lob q.q.bol) - ?> ?=($txt-diff p.r.bol) + ?> ?=(%txt-diff p.r.bol) =+ dif=;;((urge cord) q.r.bol) =, format =+ pac=(of-wain (lurk:differ (to-wain (cat 3 txt '\0a')) dif)) @@ -3844,7 +3844,7 @@ :: ++ read-y |= {yon/aeon pax/path} - ^- (unit (unit {$arch (hypo arch)})) + ^- (unit (unit {%arch (hypo arch)})) ?: =(0 yon) ``[%arch -:!>(*arch) *arch] =+ tak=(~(get by hit.dom) yon) @@ -3872,7 +3872,7 @@ :: ++ read-z |= {yon/aeon pax/path} - ^- (unit (unit {$uvi (hypo @uvI)})) + ^- (unit (unit {%uvi (hypo @uvI)})) ?: =(0 yon) ``uvi+[-:!>(*@uvI) *@uvI] =+ tak=(~(get by hit.dom) yon) diff --git a/pkg/arvo/sys/vane/dill.hoon b/pkg/arvo/sys/vane/dill.hoon index 80917a7b26..d5c3a2b8ad 100644 --- a/pkg/arvo/sys/vane/dill.hoon +++ b/pkg/arvo/sys/vane/dill.hoon @@ -28,7 +28,7 @@ -- => :: |% :: protocol outward ++ mess :: - $% {$dill-belt p/(hypo dill-belt)} :: + $% {%dill-belt p/(hypo dill-belt)} :: == :: ++ move {p/duct q/(wind note gift:able)} :: local move ++ note :: out request $-> @@ -109,21 +109,21 @@ |= kyz/task:able ^+ +> ?+ -.kyz ~& [%strange-kiss -.kyz] +> - $flow +> - $harm +> - $hail (send %hey ~) - $belt (send `dill-belt`p.kyz) - $text (from %out (tuba p.kyz)) - $crud :: (send `dill-belt`[%cru p.kyz q.kyz]) + %flow +> + %harm +> + %hail (send %hey ~) + %belt (send `dill-belt`p.kyz) + %text (from %out (tuba p.kyz)) + %crud :: (send `dill-belt`[%cru p.kyz q.kyz]) (crud p.kyz q.kyz) - $blew (send %rez p.p.kyz q.p.kyz) - $heft (dump %whey ~) - $lyra (dump kyz) - $meld (dump kyz) - $pack (dump kyz) - $crop (dump trim+p.kyz) - $veer (dump kyz) - $verb (dump kyz) + %blew (send %rez p.p.kyz q.p.kyz) + %heft (dump %whey ~) + %lyra (dump kyz) + %meld (dump kyz) + %pack (dump kyz) + %crop (dump trim+p.kyz) + %veer (dump kyz) + %verb (dump kyz) == :: ++ crud @@ -170,28 +170,28 @@ ++ from :: receive blit |= bit/dill-blit ^+ +> - ?: ?=($mor -.bit) + ?: ?=(%mor -.bit) |- ^+ +>.^$ ?~ p.bit +>.^$ $(p.bit t.p.bit, +>.^$ ^$(bit i.p.bit)) - ?: ?=($out -.bit) + ?: ?=(%out -.bit) %+ done %blit :~ [%lin p.bit] [%mor ~] see [%hop pos] == - ?: ?=($klr -.bit) + ?: ?=(%klr -.bit) %+ done %blit :~ [%klr p.bit] [%mor ~] see [%hop pos] == - ?: ?=($pro -.bit) + ?: ?=(%pro -.bit) =. see [%lin p.bit] (done %blit [see [%hop pos] ~]) - ?: ?=($pom -.bit) + ?: ?=(%pom -.bit) ::NOTE treat "styled prompt" without style as plain prompt, :: to allow rendering by older runtimes ::TODO remove me once v0.10.9+ has high/guaranteed adoption @@ -200,9 +200,9 @@ $(bit [%pro (zing (turn p.bit tail))]) =. see [%klr p.bit] (done %blit [see [%hop pos] ~]) - ?: ?=($hop -.bit) + ?: ?=(%hop -.bit) (done(pos p.bit) %blit [bit ~]) - ?: ?=($qit -.bit) + ?: ?=(%qit -.bit) (dump %logo ~) (done %blit [bit ~]) :: XX move @@ -223,7 +223,7 @@ =/ can (clan:title our) =. tem ~ =. +> (pass / %g %conf ram) - =? +> ?=(?($earl $duke $king) can) + =? +> ?=(?(%earl %duke %king) can) (ota (sein our) %kids) :: make kids desk publicly readable, so syncs work. :: @@ -269,36 +269,36 @@ :: +>(moz :_(moz [hen %give +.sih])) :: - {$g $onto *} + {%g %onto *} :: ~& [%take-gall-onto +>.sih] ?- -.+>.sih %| (crud %onto p.p.+>.sih) %& (done %blit [%lin (tuba "{}")]~) == :: - {$g $unto *} + {%g %unto *} :: ~& [%take-gall-unto +>.sih] ?- -.+>.sih - $poke-ack ?~(p.p.+>.sih +>.$ (crud %coup u.p.p.+>.sih)) - $kick peer - $watch-ack ?~ p.p.+>.sih + %poke-ack ?~(p.p.+>.sih +>.$ (crud %coup u.p.p.+>.sih)) + %kick peer + %watch-ack ?~ p.p.+>.sih +>.$ (dump:(crud %reap u.p.p.+>.sih) %logo ~) - $fact (from ;;(dill-blit q:`vase`+>+>.sih)) + %fact (from ;;(dill-blit q:`vase`+>+>.sih)) == :: - {$c $note *} + {%c %note *} (from %out (tuba p.sih ' ' ~(ram re q.sih))) :: - {?($b $c) $writ *} + {?(%b %c) %writ *} init :: - {?($b %c) $mere *} + {?(%b %c) %mere *} ?: ?=(%& -.p.sih) mere (mean >%dill-mere-fail< >p.p.p.sih< q.p.p.sih) :: - {$d $blit *} + {%d %blit *} (done +.sih) == -- @@ -414,7 +414,7 @@ :: without .dog :: ++ axle-1 - $: $1 + $: %1 hey/(unit duct) dug/(map duct axon-3) lit/? diff --git a/pkg/arvo/sys/vane/jael.hoon b/pkg/arvo/sys/vane/jael.hoon index 18873c214f..258192b5c4 100644 --- a/pkg/arvo/sys/vane/jael.hoon +++ b/pkg/arvo/sys/vane/jael.hoon @@ -268,7 +268,7 @@ ?- -.tac :: :: boot from keys - :: $: $dawn + :: $: %dawn :: =seed :: spon=ship :: czar=(map ship [=rift =life =pass]) @@ -433,9 +433,9 @@ (sources:~(feel su hen our now pki etn) [whos source]:tac) :: :: cancel all trackers from duct - :: {$nuke whos=(set ship)} + :: {%nuke whos=(set ship)} :: - $nuke + %nuke =/ ships=(list ship) %~ tap in %- ~(int in whos.tac) @@ -522,13 +522,13 @@ +>.$ :: :: watch private keys - :: {$private-keys $~} + :: {%private-keys ~} :: %private-keys (curd abet:~(private-keys ~(feed su hen our now pki etn) hen)) :: :: authenticated remote request - :: {$west p/ship q/path r/*} + :: {%west p/ship q/path r/*} :: %plea =* her ship.tac @@ -592,20 +592,20 @@ :: [%g %unto *] ?- +>-.hin - $kick ~|([%jael-unexpected-quit tea hin] !!) - $poke-ack + %kick ~|([%jael-unexpected-quit tea hin] !!) + %poke-ack ?~ p.p.+>.hin +>.$ %- (slog leaf+"jael-bad-coup" u.p.p.+>.hin) +>.$ :: - $watch-ack + %watch-ack ?~ p.p.+>.hin +>.$ %- (slog u.p.p.+>.hin) ~|([%jael-unexpected-reap tea hin] +>.$) :: - $fact + %fact ?> ?=([@ *] tea) =* app i.tea =/ =peer-sign ;;(peer-sign q.q.cage.p.+>.hin) diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index 329fc76590..91a6f35782 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -64,7 +64,7 @@ depth=_1 == :: -+$ deco ?(~ $bl $br $un) :: text decoration ++$ deco ?(~ %bl %br %un) :: text decoration +$ json :: normal json value $@ ~ :: null $% [%a p=(list json)] :: array @@ -83,7 +83,7 @@ +$ styl %+ pair (unit deco) :: cascading style (pair (unit tint) (unit tint)) :: +$ styx (list $@(@t (pair styl styx))) :: styled text -+$ tint ?($r $g $b $c $m $y $k $w $~) :: text color ++$ tint ?(%r %g %b %c %m %y %k %w %~) :: text color +$ turf (list @t) :: domain, tld first :: :: :::: ++jstd :: json standards structures @@ -812,45 +812,45 @@ |% ++ gift :: out result <-$ $% [%boon payload=*] :: ames response - {$croz rus/(map desk {r/regs w/regs})} :: rules for group - {$cruz cez/(map @ta crew)} :: permission groups - {$dirk p/@tas} :: mark mount dirty - {$ergo p/@tas q/mode} :: version update - {$hill p/(list @tas)} :: mount points + {%croz rus/(map desk {r/regs w/regs})} :: rules for group + {%cruz cez/(map @ta crew)} :: permission groups + {%dirk p/@tas} :: mark mount dirty + {%ergo p/@tas q/mode} :: version update + {%hill p/(list @tas)} :: mount points [%done error=(unit error:ames)] :: ames message (n)ack - {$mere p/(each (set path) (pair term tang))} :: merge result - {$note p/@tD q/tank} :: debug message - {$ogre p/@tas} :: delete mount point - {$rule red/dict wit/dict} :: node r+w permissions - {$writ p/riot} :: response - {$wris p/{$da p/@da} q/(set (pair care path))} :: many changes + {%mere p/(each (set path) (pair term tang))} :: merge result + {%note p/@tD q/tank} :: debug message + {%ogre p/@tas} :: delete mount point + {%rule red/dict wit/dict} :: node r+w permissions + {%writ p/riot} :: response + {%wris p/{%da p/@da} q/(set (pair care path))} :: many changes == :: ++ task :: in request ->$ $~ [%vega ~] :: - $% {$boat ~} :: pier rebooted - {$cred nom/@ta cew/crew} :: set permission group - {$crew ~} :: permission groups - {$crow nom/@ta} :: group usage + $% {%boat ~} :: pier rebooted + {%cred nom/@ta cew/crew} :: set permission group + {%crew ~} :: permission groups + {%crow nom/@ta} :: group usage $>(%crud vane-task) :: error with trace - {$drop des/desk} :: cancel pending merge - {$info des/desk dit/nori} :: internal edit + {%drop des/desk} :: cancel pending merge + {%info des/desk dit/nori} :: internal edit $>(%init vane-task) :: report install - {$into des/desk all/? fis/mode} :: external edit - $: $merg :: merge desks + {%into des/desk all/? fis/mode} :: external edit + $: %merg :: merge desks des/desk :: target her/@p dem/desk cas/case :: source how/germ :: method == :: - {$mont pot/term bem/beam} :: mount to unix - {$dirk des/desk} :: mark mount dirty - {$ogre pot/$@(desk beam)} :: delete mount point - {$park des/desk yok/yoki ran/rang} :: synchronous commit - {$perm des/desk pax/path rit/rite} :: change permissions - {$pork ~} :: resume commit + {%mont pot/term bem/beam} :: mount to unix + {%dirk des/desk} :: mark mount dirty + {%ogre pot/$@(desk beam)} :: delete mount point + {%park des/desk yok/yoki ran/rang} :: synchronous commit + {%perm des/desk pax/path rit/rite} :: change permissions + {%pork ~} :: resume commit $>(%trim vane-task) :: trim state $>(%vega vane-task) :: report upgrade - {$warp wer/ship rif/riff} :: internal file req - {$werp who/ship wer/ship rif/riff-any} :: external file req + {%warp wer/ship rif/riff} :: internal file req + {%werp who/ship wer/ship rif/riff-any} :: external file req $>(%plea vane-task) :: ames request == :: -- ::able @@ -866,8 +866,8 @@ ++ beam {{p/ship q/desk r/case} s/path} :: global name ++ beak {p/ship q/desk r/case} :: path prefix ++ blob :: fs blob - $% {$delta p/lobe q/{p/mark q/lobe} r/page} :: delta on q - {$direct p/lobe q/page} :: immediate + $% {%delta p/lobe q/{p/mark q/lobe} r/page} :: delta on q + {%direct p/lobe q/page} :: immediate == :: :: +cable: a reference to something on the filesystem :: face: the face to wrap around the imported file @@ -876,11 +876,11 @@ $: face=(unit term) file-path=term == - ++ care ?($a $b $c $d $p $r $s $t $u $v $w $x $y $z) :: clay submode + ++ care ?(%a %b %c %d %p %r %s %t %u %v %w %x %y %z) :: clay submode ++ case :: ship desk case spur - $% {$da p/@da} :: date - {$tas p/@tas} :: label - {$ud p/@ud} :: number + $% {%da p/@da} :: date + {%tas p/@tas} :: label + {%ud p/@ud} :: number == :: ++ cass {ud/@ud da/@da} :: cases for revision ++ crew (set ship) :: permissions group @@ -907,15 +907,15 @@ ++ lobe @uvI :: blob ref ++ maki {p/@ta q/@ta r/@ta s/path} :: ++ miso :: ankh delta - $% {$del ~} :: delete - {$ins p/cage} :: insert - {$dif p/cage} :: mutate from diff - {$mut p/cage} :: mutate from raw + $% {%del ~} :: delete + {%ins p/cage} :: insert + {%dif p/cage} :: mutate from diff + {%mut p/cage} :: mutate from raw == :: ++ misu :: computed delta - $% {$del ~} :: delete - {$ins p/cage} :: insert - {$dif p/lobe q/cage} :: mutate from diff + $% {%del ~} :: delete + {%ins p/cage} :: insert + {%dif p/lobe q/cage} :: mutate from diff == :: ++ mizu {p/@u q/(map @ud tako) r/rang} :: new state ++ moar {p/@ud q/@ud} :: normal change range @@ -950,7 +950,7 @@ [%many track=? =moat] :: track range == :: ++ real :: resolved permissions - $: mod/?($black $white) :: + $: mod/?(%black %white) :: who/(pair (set ship) (map @ta crew)) :: == :: ++ regs (map path rule) :: rules for paths @@ -959,12 +959,12 @@ $^ [[%1 ~] riff] riff ++ rite :: new permissions - $% {$r red/(unit rule)} :: for read - {$w wit/(unit rule)} :: for write - {$rw red/(unit rule) wit/(unit rule)} :: for read and write + $% {%r red/(unit rule)} :: for read + {%w wit/(unit rule)} :: for write + {%rw red/(unit rule) wit/(unit rule)} :: for read and write == :: ++ riot (unit rant) :: response+complete - ++ rule {mod/?($black $white) who/(set whom)} :: node permission + ++ rule {mod/?(%black %white) who/(set whom)} :: node permission ++ rump {p/care q/case r/@tas s/path} :: relative path ++ saba {p/ship q/@tas r/moar s/dome} :: patch+merge ++ soba (list {p/path q/miso}) :: delta @@ -1092,45 +1092,45 @@ ++ able ^? |% ++ gift :: out result <-$ - $% {$bbye ~} :: reset prompt - {$blit p/(list blit)} :: terminal output - {$burl p/@t} :: activate url - {$init p/@p} :: set owner - {$logo ~} :: logout + $% {%bbye ~} :: reset prompt + {%blit p/(list blit)} :: terminal output + {%burl p/@t} :: activate url + {%init p/@p} :: set owner + {%logo ~} :: logout [%lyra hoon=(unit @t) arvo=@t] :: upgrade kernel - {$meld ~} :: unify memory - {$pack ~} :: compact memory - {$trim p/@ud} :: trim kernel state - {$veer p/@ta q/path r/@t} :: install vane - {$verb ~} :: verbose mode + {%meld ~} :: unify memory + {%pack ~} :: compact memory + {%trim p/@ud} :: trim kernel state + {%veer p/@ta q/path r/@t} :: install vane + {%verb ~} :: verbose mode [%whey ~] :: memory report == :: ++ task :: in request ->$ $~ [%vega ~] :: - $% {$belt p/belt} :: terminal input - {$blew p/blew} :: terminal config - {$boot lit/? p/*} :: weird %dill boot - {$crop p/@ud} :: trim kernel state + $% {%belt p/belt} :: terminal input + {%blew p/blew} :: terminal config + {%boot lit/? p/*} :: weird %dill boot + {%crop p/@ud} :: trim kernel state $>(%crud vane-task) :: error with trace [%flee session=~] :: unwatch session - {$flog p/flog} :: wrapped error - {$flow p/@tas q/(list gill:gall)} :: terminal config - {$hail ~} :: terminal refresh - {$heft ~} :: memory report - {$hook ~} :: this term hung up - {$harm ~} :: all terms hung up + {%flog p/flog} :: wrapped error + {%flow p/@tas q/(list gill:gall)} :: terminal config + {%hail ~} :: terminal refresh + {%heft ~} :: memory report + {%hook ~} :: this term hung up + {%harm ~} :: all terms hung up $>(%init vane-task) :: after gall ready [%lyra hoon=(unit @t) arvo=@t] :: upgrade kernel - {$meld ~} :: unify memory - {$noop ~} :: no operation - {$pack ~} :: compact memory - {$talk p/tank} :: - {$text p/tape} :: - {$veer p/@ta q/path r/@t} :: install vane + {%meld ~} :: unify memory + {%noop ~} :: no operation + {%pack ~} :: compact memory + {%talk p/tank} :: + {%text p/tape} :: + {%veer p/@ta q/path r/@t} :: install vane [%view session=~] :: watch session blits $>(%trim vane-task) :: trim state $>(%vega vane-task) :: report upgrade - {$verb ~} :: verbose mode + {%verb ~} :: verbose mode [%knob tag=term level=?(%hush %soft %loud)] :: error verbosity == :: -- ::able @@ -1139,62 +1139,62 @@ :: ++ blew {p/@ud q/@ud} :: columns rows ++ belt :: old belt - $% {$aro p/?($d $l $r $u)} :: arrow key - {$bac ~} :: true backspace - {$ctl p/@c} :: control-key - {$del ~} :: true delete - {$met p/@c} :: meta-key - {$ret ~} :: return - {$txt p/(list @c)} :: utf32 text + $% {%aro p/?(%d %l %r %u)} :: arrow key + {%bac ~} :: true backspace + {%ctl p/@c} :: control-key + {%del ~} :: true delete + {%met p/@c} :: meta-key + {%ret ~} :: return + {%txt p/(list @c)} :: utf32 text == :: ++ blit :: old blit - $% {$bel ~} :: make a noise - {$clr ~} :: clear the screen - {$hop p/@ud} :: set cursor position + $% {%bel ~} :: make a noise + {%clr ~} :: clear the screen + {%hop p/@ud} :: set cursor position [%klr p=stub] :: set styled line - {$lin p/(list @c)} :: set current line - {$mor ~} :: newline - {$sag p/path q/*} :: save to jamfile - {$sav p/path q/@} :: save to file - {$url p/@t} :: activate url + {%lin p/(list @c)} :: set current line + {%mor ~} :: newline + {%sag p/path q/*} :: save to jamfile + {%sav p/path q/@} :: save to file + {%url p/@t} :: activate url == :: ++ dill-belt :: new belt - $% {$aro p/?($d $l $r $u)} :: arrow key - {$bac ~} :: true backspace - {$cru p/@tas q/(list tank)} :: echo error - {$ctl p/@} :: control-key - {$del ~} :: true delete - {$hey ~} :: refresh - {$met p/@} :: meta-key - {$ret ~} :: return - {$rez p/@ud q/@ud} :: resize, cols, rows - {$txt p/(list @c)} :: utf32 text - {$yow p/gill:gall} :: connect to app + $% {%aro p/?(%d %l %r %u)} :: arrow key + {%bac ~} :: true backspace + {%cru p/@tas q/(list tank)} :: echo error + {%ctl p/@} :: control-key + {%del ~} :: true delete + {%hey ~} :: refresh + {%met p/@} :: meta-key + {%ret ~} :: return + {%rez p/@ud q/@ud} :: resize, cols, rows + {%txt p/(list @c)} :: utf32 text + {%yow p/gill:gall} :: connect to app == :: ++ dill-blit :: new blit - $% {$bel ~} :: make a noise - {$clr ~} :: clear the screen - {$hop p/@ud} :: set cursor position - {$klr p/stub} :: styled text - {$mor p/(list dill-blit)} :: multiple blits - {$pom p/stub} :: styled prompt - {$pro p/(list @c)} :: show as cursor+line - {$qit ~} :: close console - {$out p/(list @c)} :: send output line - {$sag p/path q/*} :: save to jamfile - {$sav p/path q/@} :: save to file - {$url p/@t} :: activate url + $% {%bel ~} :: make a noise + {%clr ~} :: clear the screen + {%hop p/@ud} :: set cursor position + {%klr p/stub} :: styled text + {%mor p/(list dill-blit)} :: multiple blits + {%pom p/stub} :: styled prompt + {%pro p/(list @c)} :: show as cursor+line + {%qit ~} :: close console + {%out p/(list @c)} :: send output line + {%sag p/path q/*} :: save to jamfile + {%sav p/path q/@} :: save to file + {%url p/@t} :: activate url == :: ++ flog :: sent to %dill - $% {$crop p/@ud} :: trim kernel state - {$crud p/@tas q/(list tank)} :: - {$heft ~} :: + $% {%crop p/@ud} :: trim kernel state + {%crud p/@tas q/(list tank)} :: + {%heft ~} :: [%lyra hoon=(unit @t) arvo=@t] :: upgrade kernel - {$meld ~} :: unify memory - {$pack ~} :: compact memory - {$text p/tape} :: - {$veer p/@ta q/path r/@t} :: install vane - {$verb ~} :: verbose mode + {%meld ~} :: unify memory + {%pack ~} :: compact memory + {%text p/tape} :: + {%veer p/@ta q/path r/@t} :: install vane + {%verb ~} :: verbose mode == :: -- ::dill :: :::: @@ -1546,8 +1546,8 @@ ++ hate {p/purl q/@p r/moth} :: semi-cooked request ++ hiss {p/purl q/moth} :: outbound request ++ host (each turf @if) :: http host - ++ hoke %+ each {$localhost ~} :: local host - ?($.0.0.0.0 $.127.0.0.1) :: + ++ hoke %+ each {%localhost ~} :: local host + ?(%.0.0.0.0 %.127.0.0.1) :: ++ httq :: raw http request $: p/meth :: method q/@t :: unparsed url @@ -1558,14 +1558,14 @@ ++ math (map @t (list @t)) :: semiparsed headers ++ mess (list {p/@t q/@t}) :: raw http headers ++ meth :: http methods - $? $conn :: CONNECT - $delt :: DELETE - $get :: GET - $head :: HEAD - $opts :: OPTIONS - $post :: POST - $put :: PUT - $trac :: TRACE + $? %conn :: CONNECT + %delt :: DELETE + %get :: GET + %head :: HEAD + %opts :: OPTIONS + %post :: POST + %put :: PUT + %trac :: TRACE == :: ++ moth {p/meth q/math r/(unit octs)} :: http operation ++ oryx @t :: CSRF secret @@ -1714,7 +1714,7 @@ ++ task :: incoming request $~ [%vega ~] :: $% [%conf dap=term] :: start agent - [$deal p=sock q=term r=deal] :: full transmission + [%deal p=sock q=term r=deal] :: full transmission [%goad force=? agent=(unit dude)] :: rebuild agent(s) [%sear =ship] :: clear pending queues $>(%init vane-task) :: set owner @@ -2191,19 +2191,19 @@ == ++ note-arvo :: out request $-> $~ [%b %wake ~] - $% {$a task:able:ames} - {$b task:able:behn} - {$c task:able:clay} - {$d task:able:dill} + $% {%a task:able:ames} + {%b task:able:behn} + {%c task:able:clay} + {%d task:able:dill} [%e task:able:eyre] - {$g task:able:gall} + {%g task:able:gall} [%i task:able:iris] - {$j task:able:jael} - {@tas $meta vase} + {%j task:able:jael} + {@tas %meta vase} == ++ sign-arvo :: in result $<- - $% {$a gift:able:ames} - $: $b + $% {%a gift:able:ames} + $: %b $% gift:able:behn $>(%wris gift:able:clay) $>(%writ gift:able:clay) @@ -2211,12 +2211,12 @@ $>(%unto gift:able:gall) == == - {$c gift:able:clay} - {$d gift:able:dill} + {%c gift:able:clay} + {%d gift:able:dill} [%e gift:able:eyre] - {$g gift:able:gall} + {%g gift:able:gall} [%i gift:able:iris] - {$j gift:able:jael} + {%j gift:able:jael} == :: $unix-task: input from unix :: @@ -5512,7 +5512,7 @@ |= dex/desk %+ biff (slay i.t.t.pax) |= cis/coin - ?. ?=({$$ case} cis) ~ + ?. ?=({%$ case} cis) ~ `(unit beam)`[~ [who dex `case`p.cis] t.t.t.pax] :: ++ json-rn :: json to rn parser @@ -5611,7 +5611,7 @@ ++ ar :: array as list |* wit/fist |= jon/json ^- (list _(wit *json)) - ?> ?=({$a *} jon) + ?> ?=({%a *} jon) (turn p.jon wit) :: :: ++as:dejs:format ++ as :: array as set @@ -5621,7 +5621,7 @@ ++ at :: array as tuple |* wil/(pole fist) |= jon/json - ?> ?=({$a *} jon) + ?> ?=({%a *} jon) ((at-raw wil) p.jon) :: :: ++at-raw:dejs:format ++ at-raw :: array as tuple @@ -5637,10 +5637,10 @@ == :: :: ++bo:dejs:format ++ bo :: boolean - |=(jon/json ?>(?=({$b *} jon) p.jon)) + |=(jon/json ?>(?=({%b *} jon) p.jon)) :: :: ++bu:dejs:format ++ bu :: boolean not - |=(jon/json ?>(?=({$b *} jon) !p.jon)) + |=(jon/json ?>(?=({%b *} jon) !p.jon)) :: :: ++ci:dejs:format ++ ci :: maybe transform |* {poq/gate wit/fist} @@ -5671,16 +5671,16 @@ :: :: ++ni:dejs:format ++ ni :: number as integer |= jon/json - ?> ?=({$n *} jon) + ?> ?=({%n *} jon) (rash p.jon dem) :: :: ++no:dejs:format ++ no :: number as cord - |=(jon/json ?>(?=({$n *} jon) p.jon)) + |=(jon/json ?>(?=({%n *} jon) p.jon)) :: :: ++of:dejs:format ++ of :: object as frond |* wer/(pole {cord fist}) |= jon/json - ?> ?=({$o {@ *} $~ $~} jon) + ?> ?=({%o {@ *} ~ ~} jon) |- ?- wer :: mint-vain on empty :: {{key/@t wit/*} t/*} @@ -5695,7 +5695,7 @@ ++ ot :: object as tuple |* wer/(pole {cord fist}) |= jon/json - ?> ?=({$o *} jon) + ?> ?=({%o *} jon) ((ot-raw wer) p.jon) :: :: ++ot-raw:dejs:format ++ ot-raw :: object as tuple @@ -5712,7 +5712,7 @@ ++ ou :: object of units |* wer/(pole {cord fist}) |= jon/json - ?> ?=({$o *} jon) + ?> ?=({%o *} jon) ((ou-raw wer) p.jon) :: :: ++ou-raw:dejs:format ++ ou-raw :: object of units @@ -5729,7 +5729,7 @@ ++ om :: object as map |* wit/fist |= jon/json - ?> ?=({$o *} jon) + ?> ?=({%o *} jon) (~(run by p.jon) wit) :: :: ++op:dejs:format ++ op :: parse keys of map @@ -5750,7 +5750,7 @@ (cu |*(* [pre +<]) wit) :: :: ++sa:dejs:format ++ sa :: string as tape - |=(jon/json ?>(?=({$s *} jon) (trip p.jon))) + |=(jon/json ?>(?=({%s *} jon) (trip p.jon))) :: :: ++se:dejs:format ++ se :: string as aura |= aur=@tas @@ -5758,12 +5758,12 @@ ?>(?=([%s *] jon) (slav aur p.jon)) :: :: ++so:dejs:format ++ so :: string as cord - |=(jon/json ?>(?=({$s *} jon) p.jon)) + |=(jon/json ?>(?=({%s *} jon) p.jon)) :: :: ++su:dejs:format ++ su :: parse string |* sab/rule |= jon/json ^+ (wonk *sab) - ?> ?=({$s *} jon) + ?> ?=({%s *} jon) (rash p.jon sab) :: :: ++uf:dejs:format ++ uf :: unit fall @@ -5823,7 +5823,7 @@ ++ ar :: array as list |* wit/fist |= jon/json - ?. ?=({$a *} jon) ~ + ?. ?=({%a *} jon) ~ %- zl |- ?~ p.jon ~ @@ -5832,7 +5832,7 @@ ++ at :: array as tuple |* wil/(pole fist) |= jon/json - ?. ?=({$a *} jon) ~ + ?. ?=({%a *} jon) ~ ?. =((lent wil) (lent p.jon)) ~ =+ raw=((at-raw wil) p.jon) ?.((za raw) ~ (some (zp raw))) @@ -5845,10 +5845,10 @@ ((at-raw +.wil) ?~(jol ~ t.jol)) :: ++ bo :: boolean - |=(jon/json ?.(?=({$b *} jon) ~ [~ u=p.jon])) + |=(jon/json ?.(?=({%b *} jon) ~ [~ u=p.jon])) :: ++ bu :: boolean not - |=(jon/json ?.(?=({$b *} jon) ~ [~ u=!p.jon])) + |=(jon/json ?.(?=({%b *} jon) ~ [~ u=!p.jon])) :: ++ ci :: maybe transform |* {poq/gate wit/fist} @@ -5862,7 +5862,7 @@ :: ++ da :: UTC date |= jon/json - ?. ?=({$s *} jon) ~ + ?. ?=({%s *} jon) ~ (bind (stud:chrono:userlib p.jon) |=(a/date (year a))) :: ++ di :: millisecond date @@ -5884,18 +5884,18 @@ :: ++ ni :: number as integer |= jon/json - ?. ?=({$n *} jon) ~ + ?. ?=({%n *} jon) ~ (rush p.jon dem) :: ++ no :: number as cord |= jon/json - ?. ?=({$n *} jon) ~ + ?. ?=({%n *} jon) ~ (some p.jon) :: ++ of :: object as frond |* wer/(pole {cord fist}) |= jon/json - ?. ?=({$o {@ *} ~ ~} jon) ~ + ?. ?=({%o {@ *} ~ ~} jon) ~ |- ?~ wer ~ ?: =(-.-.wer p.n.p.jon) @@ -5905,7 +5905,7 @@ ++ ot :: object as tuple |* wer/(pole {cord fist}) |= jon/json - ?. ?=({$o *} jon) ~ + ?. ?=({%o *} jon) ~ =+ raw=((ot-raw wer) p.jon) ?.((za raw) ~ (some (zp raw))) :: @@ -5919,7 +5919,7 @@ ++ om :: object as map |* wit/fist |= jon/json - ?. ?=({$o *} jon) ~ + ?. ?=({%o *} jon) ~ (zm (~(run by p.jon) wit)) :: ++ op :: parse keys of map @@ -5943,16 +5943,16 @@ :: ++ sa :: string as tape |= jon/json - ?.(?=({$s *} jon) ~ (some (trip p.jon))) + ?.(?=({%s *} jon) ~ (some (trip p.jon))) :: ++ so :: string as cord |= jon/json - ?.(?=({$s *} jon) ~ (some p.jon)) + ?.(?=({%s *} jon) ~ (some p.jon)) :: ++ su :: parse string |* sab/rule |= jon/json - ?. ?=({$s *} jon) ~ + ?. ?=({%s *} jon) ~ (rush p.jon sab) :: ++ ul |=(jon/json ?~(jon (some ~) ~)) :: null @@ -6254,7 +6254,7 @@ ^- tape ?~ val (weld "null" rez) ?- -.val - $a + %a :- '[' =. rez [']' rez] !. @@ -6263,9 +6263,9 @@ ?~ t.p.val ^$(val i.p.val) ^$(val i.p.val, rez [',' $(p.val t.p.val)]) :: - $b (weld ?:(p.val "true" "false") rez) - $n (weld (trip p.val) rez) - $s + %b (weld ?:(p.val "true" "false") rez) + %n (weld (trip p.val) rez) + %s :- '"' =. rez ['"' rez] =+ viz=(trip p.val) @@ -6277,7 +6277,7 @@ [i.hed $(viz t.viz)] (weld hed $(viz t.viz)) :: - $o + %o :- '{' =. rez ['}' rez] =+ viz=~(tap by p.val) @@ -6293,9 +6293,9 @@ =+ utf=|=(a/@ ['\\' 'u' ((x-co 4):co a)]) |= a/@ ^- tape ?+ a ?:((gth a 0x1f) [a ~] (utf a)) - $10 "\\n" - $34 "\\\"" - $92 "\\\\" + %10 "\\n" + %34 "\\\"" + %92 "\\\\" == -- ::en-json :: :: ++de-json:html @@ -6404,7 +6404,7 @@ ++ apex :: top level |= {mex/manx rez/tape} ^- tape - ?: ?=({$$ {{$$ *} ~}} g.mex) + ?: ?=({%$ {{%$ *} ~}} g.mex) (escp v.i.a.g.mex rez) =+ man=`mane`n.g.mex =. unq |(unq =(%script man) =(%style man)) @@ -6441,11 +6441,11 @@ %= $ xet t.xet rez ?- i.xet - $34 ['&' 'q' 'u' 'o' 't' ';' rez] - $38 ['&' 'a' 'm' 'p' ';' rez] - $39 ['&' '#' '3' '9' ';' rez] - $60 ['&' 'l' 't' ';' rez] - $62 ['&' 'g' 't' ';' rez] + %34 ['&' 'q' 'u' 'o' 't' ';' rez] + %38 ['&' 'a' 'm' 'p' ';' rez] + %39 ['&' '#' '3' '9' ';' rez] + %60 ['&' 'l' 't' ';' rez] + %62 ['&' 'g' 't' ';' rez] * [i.xet rez] == == @@ -6901,7 +6901,7 @@ => .(b `,(tup -.a +.a)`b) ?~ +.a [(scot -.a b) ~] [(scot -.a -.b) `,(paf +.a)`(..$ +.a +.b)] - :- paf=|*(a/(pole) ?~(a $~ {(odo:raid ,-.a(. %ta)) ,(..$ +.a)})) + :- paf=|*(a/(pole) ?~(a ,~ {(odo:raid ,-.a(. %ta)) ,(..$ +.a)})) ^= tup |* {a/@tas b/(pole @tas)} =+ c=(odo:raid a) @@ -6921,9 +6921,9 @@ |= b/* =- a(, (- b)) :: preserve face ?+ a @ - $c @c $da @da $dr @dr $f @f $if @if $is @is $p @p - $u @u $uc @uc $ub @ub $ui @ui $ux @ux $uv @uv $uw @uw - $s @s $t @t $ta @ta $tas @tas + %c @c %da @da %dr @dr %f @f %if @if %is @is %p @p + %u @u %uc @uc %ub @ub %ui @ui %ux @ux %uv @uv %uw @uw + %s @s %t @t %ta @ta %tas @tas == :: :: :: ++read:wired :: ++ read :: parse odored path @@ -6974,11 +6974,11 @@ ^- ship =/ mir (clan who) ?- mir - $czar who - $king (end 3 1 who) - $duke (end 4 1 who) - $earl (end 5 1 who) - $pawn (end 4 1 who) + %czar who + %king (end 3 1 who) + %duke (end 4 1 who) + %earl (end 5 1 who) + %pawn (end 4 1 who) == -- |% @@ -7012,7 +7012,7 @@ |= [our=ship who=ship] ^- ? ?| =(our who) - &(?=($earl (clan who)) =(our (^sein who))) + &(?=(%earl (clan who)) =(our (^sein who))) == -- ::title :: :: @@ -7653,10 +7653,10 @@ ^+ =+ [*date u=unit] *{(u _[a y]) (u _m) (u _d.t) (u _+.t) ~} :~ - |-(?~(b ~ ?.(?=($y -.i.b) $(b t.b) `+.i.b))) - |-(?~(b ~ ?.(?=($m -.i.b) $(b t.b) `+.i.b))) - |-(?~(b ~ ?.(?=($d -.i.b) $(b t.b) `+.i.b))) - |-(?~(b ~ ?.(?=($t -.i.b) $(b t.b) `+.i.b))) + |-(?~(b ~ ?.(?=(%y -.i.b) $(b t.b) `+.i.b))) + |-(?~(b ~ ?.(?=(%m -.i.b) $(b t.b) `+.i.b))) + |-(?~(b ~ ?.(?=(%d -.i.b) $(b t.b) `+.i.b))) + |-(?~(b ~ ?.(?=(%t -.i.b) $(b t.b) `+.i.b))) == |% :: :: ++snug:stud:chrono: From 2545282d5e6c368565fdc7deee5a6b91ea78502a Mon Sep 17 00:00:00 2001 From: fang Date: Wed, 25 Nov 2020 21:18:13 +0100 Subject: [PATCH 774/933] hoon: remove $constant type syntax --- pkg/arvo/sys/hoon.hoon | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index c0e5a01dff..a116076ec6 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -12844,18 +12844,7 @@ :- ',' ;~(pfix com (stag %bcmc wide)) :- '$' - ;~ pose - ;~ pfix buc - ;~ pose - :: XX all three deprecated - :: - (stag %leaf (stag %tas (cold %$ buc))) - (stag %leaf (stag %t qut)) - (stag %leaf (sear |=(a/coin ?:(?=($$ -.a) (some +.a) ~)) nuck:so)) - == - == - (stag %like (most col rope)) - == + (stag %like (most col rope)) :- '%' ;~ pose ;~ pfix cen From 44fb0cc19d758bea337cc3fdeff0af86e392f9e1 Mon Sep 17 00:00:00 2001 From: fang Date: Wed, 25 Nov 2020 21:22:55 +0100 Subject: [PATCH 775/933] various: move away from face/type syntax In favor of face=type. --- pkg/arvo/app/chat-cli.hoon | 2 +- pkg/arvo/app/dojo.hoon | 230 +- pkg/arvo/app/weather.hoon | 2 +- pkg/arvo/gen/cat.hoon | 4 +- pkg/arvo/gen/code.hoon | 2 +- pkg/arvo/gen/hello.hoon | 2 +- pkg/arvo/gen/help.hoon | 22 +- pkg/arvo/gen/hood/autocommit.hoon | 4 +- pkg/arvo/gen/hood/breload.hoon | 4 +- pkg/arvo/gen/hood/commit.hoon | 4 +- pkg/arvo/gen/hood/cp.hoon | 2 +- pkg/arvo/gen/hood/exit.hoon | 2 +- pkg/arvo/gen/hood/hi.hoon | 2 +- pkg/arvo/gen/hood/init-oauth2.hoon | 12 +- pkg/arvo/gen/hood/init-oauth2/google.hoon | 10 +- pkg/arvo/gen/hood/label.hoon | 4 +- pkg/arvo/gen/hood/link.hoon | 4 +- pkg/arvo/gen/hood/mass.hoon | 4 +- pkg/arvo/gen/hood/merge.hoon | 14 +- pkg/arvo/gen/hood/mount.hoon | 4 +- pkg/arvo/gen/hood/mv.hoon | 2 +- pkg/arvo/gen/hood/pack.hoon | 4 +- pkg/arvo/gen/hood/ping.hoon | 4 +- pkg/arvo/gen/hood/private.hoon | 4 +- pkg/arvo/gen/hood/public.hoon | 4 +- pkg/arvo/gen/hood/rc.hoon | 4 +- pkg/arvo/gen/hood/reboot.hoon | 4 +- pkg/arvo/gen/hood/reload-desk.hoon | 4 +- pkg/arvo/gen/hood/reload.hoon | 4 +- pkg/arvo/gen/hood/reset.hoon | 4 +- pkg/arvo/gen/hood/rm.hoon | 2 +- pkg/arvo/gen/hood/schedule.hoon | 2 +- pkg/arvo/gen/hood/start.hoon | 4 +- pkg/arvo/gen/hood/sync.hoon | 4 +- pkg/arvo/gen/hood/syncs.hoon | 2 +- pkg/arvo/gen/hood/track.hoon | 4 +- pkg/arvo/gen/hood/unlink.hoon | 4 +- pkg/arvo/gen/hood/unmount.hoon | 4 +- pkg/arvo/gen/hood/unsync.hoon | 4 +- pkg/arvo/gen/hood/verb.hoon | 2 +- pkg/arvo/gen/key.hoon | 2 +- pkg/arvo/gen/ls.hoon | 2 +- pkg/arvo/lib/chat-store.hoon | 4 +- pkg/arvo/lib/contact-json.hoon | 2 +- pkg/arvo/lib/cram.hoon | 14 +- pkg/arvo/lib/der.hoon | 2 +- pkg/arvo/lib/elem-to-react-json.hoon | 10 +- pkg/arvo/lib/frontmatter.hoon | 14 +- pkg/arvo/lib/generators.hoon | 14 +- pkg/arvo/lib/graph-store.hoon | 6 +- pkg/arvo/lib/group-json.hoon | 2 +- pkg/arvo/lib/group-store.hoon | 8 +- pkg/arvo/lib/hood/drum.hoon | 230 +- pkg/arvo/lib/hood/helm.hoon | 20 +- pkg/arvo/lib/hood/kiln.hoon | 70 +- pkg/arvo/lib/invite-json.hoon | 2 +- pkg/arvo/lib/jose.hoon | 2 +- pkg/arvo/lib/language-server/complete.hoon | 2 +- pkg/arvo/lib/language-server/easy-print.hoon | 50 +- pkg/arvo/lib/old-phon.hoon | 32 +- pkg/arvo/lib/pill.hoon | 4 +- pkg/arvo/lib/pprint.hoon | 2 +- pkg/arvo/lib/pretty-file.hoon | 8 +- pkg/arvo/lib/primitive-rsa.hoon | 2 +- pkg/arvo/lib/ring.hoon | 2 +- pkg/arvo/lib/show-dir.hoon | 8 +- pkg/arvo/lib/sole.hoon | 14 +- pkg/arvo/lib/soto.hoon | 2 +- pkg/arvo/lib/test/runner.hoon | 2 +- pkg/arvo/lib/time-to-id.hoon | 2 +- pkg/arvo/lib/tree.hoon | 14 +- pkg/arvo/lib/urb-split.hoon | 4 +- pkg/arvo/lib/xray.hoon | 2 +- pkg/arvo/mar/atom.hoon | 2 +- pkg/arvo/mar/css.hoon | 4 +- pkg/arvo/mar/dill/belt.hoon | 6 +- pkg/arvo/mar/dill/blit.hoon | 4 +- pkg/arvo/mar/elem.hoon | 2 +- pkg/arvo/mar/front.hoon | 4 +- pkg/arvo/mar/helm-hi.hoon | 2 +- pkg/arvo/mar/hoon.hoon | 4 +- pkg/arvo/mar/htm.hoon | 2 +- pkg/arvo/mar/html.hoon | 4 +- pkg/arvo/mar/httr.hoon | 2 +- pkg/arvo/mar/hymn.hoon | 2 +- pkg/arvo/mar/jam.hoon | 2 +- pkg/arvo/mar/js.hoon | 4 +- pkg/arvo/mar/json.hoon | 4 +- pkg/arvo/mar/json/rpc/response.hoon | 2 +- pkg/arvo/mar/lens/command.hoon | 6 +- pkg/arvo/mar/map.hoon | 4 +- pkg/arvo/mar/md.hoon | 2 +- pkg/arvo/mar/mime.hoon | 4 +- pkg/arvo/mar/noun.hoon | 2 +- pkg/arvo/mar/path.hoon | 2 +- pkg/arvo/mar/png.hoon | 4 +- pkg/arvo/mar/purl.hoon | 2 +- pkg/arvo/mar/ships.hoon | 2 +- pkg/arvo/mar/snip.hoon | 16 +- pkg/arvo/mar/sole/action.hoon | 14 +- pkg/arvo/mar/sole/effect.hoon | 16 +- pkg/arvo/mar/tang.hoon | 6 +- pkg/arvo/mar/txt-diff.hoon | 2 +- pkg/arvo/mar/txt.hoon | 58 +- pkg/arvo/mar/udon.hoon | 2 +- pkg/arvo/mar/umd.hoon | 2 +- pkg/arvo/mar/urb.hoon | 2 +- pkg/arvo/mar/urbit.hoon | 2 +- pkg/arvo/mar/xml.hoon | 4 +- pkg/arvo/sur/kyev.hoon | 2 +- pkg/arvo/sur/lens.hoon | 46 +- pkg/arvo/sur/sole.hoon | 64 +- pkg/arvo/sur/urb.hoon | 2 +- pkg/arvo/sys/arvo.hoon | 10 +- pkg/arvo/sys/hoon.hoon | 2556 +++++++++--------- pkg/arvo/sys/vane/clay.hoon | 322 +-- pkg/arvo/sys/vane/dill.hoon | 94 +- pkg/arvo/sys/vane/eyre.hoon | 8 +- pkg/arvo/sys/vane/jael.hoon | 36 +- pkg/arvo/sys/zuse.hoon | 1062 ++++---- 120 files changed, 2681 insertions(+), 2681 deletions(-) diff --git a/pkg/arvo/app/chat-cli.hoon b/pkg/arvo/app/chat-cli.hoon index d5cef88237..830424815f 100644 --- a/pkg/arvo/app/chat-cli.hoon +++ b/pkg/arvo/app/chat-cli.hoon @@ -1269,7 +1269,7 @@ ?:(p.timez add sub) =+ dat=(yore when) =/ t - |= a/@ + |= a=@ %+ weld ?:((lth a 10) "0" ~) (scow %ud a) diff --git a/pkg/arvo/app/dojo.hoon b/pkg/arvo/app/dojo.hoon index 413e55da87..af6af8bb73 100644 --- a/pkg/arvo/app/dojo.hoon +++ b/pkg/arvo/app/dojo.hoon @@ -13,14 +13,14 @@ ++ id @tasession :: session id ++ house :: all state $: %6 - egg/@u :: command count - hoc/(map id session) :: conversations - acl/(set ship) :: remote access whitelist + egg=@u :: command count + hoc=(map id session) :: conversations + acl=(set ship) :: remote access whitelist == :: ++ session :: per conversation - $: say/sole-share :: command-line state - dir/beam :: active path - poy/(unit dojo-project) :: working + $: say=sole-share :: command-line state + dir=beam :: active path + poy=(unit dojo-project) :: working $: :: sur: structure imports :: sur=(list cable:clay) @@ -28,75 +28,75 @@ :: lib=(list cable:clay) == - var/(map term cage) :: variable state - old/(set term) :: used TLVs - buf/tape :: multiline buffer + var=(map term cage) :: variable state + old=(set term) :: used TLVs + buf=tape :: multiline buffer == :: ++ monkey :: per conversation - $: say/sole-share :: command-line state - dir/beam :: active path - poy/(unit dojo-project) :: working - var/(map term cage) :: variable state - old/(set term) :: used TLVs - buf/tape :: multiline buffer + $: say=sole-share :: command-line state + dir=beam :: active path + poy=(unit dojo-project) :: working + var=(map term cage) :: variable state + old=(set term) :: used TLVs + buf=tape :: multiline buffer == :: ++ dojo-command :: $^ (pair dojo-sink dojo-source) :: route value - {%brev p/term} :: unbind variable + {%brev p=term} :: unbind variable :: ++ dojo-sink :: - $% {%flat p/path} :: atom to unix - {%pill p/path} :: noun to unix pill - :: {%tree p/path} :: noun to unix tree - {%file p/beam} :: save to clay + $% {%flat p=path} :: atom to unix + {%pill p=path} :: noun to unix pill + :: {%tree p=path} :: noun to unix tree + {%file p=beam} :: save to clay $: %http :: http outbound - p/?(%post %put) - r/@t + p=?(%post %put) + r=@t == - {%poke p/goal} :: poke app - {%show p/?(%0 %1 %2 %3 %4 %5)} :: val/type/hoon/xray - {%verb p/term} :: store variable + {%poke p=goal} :: poke app + {%show p=?(%0 %1 %2 %3 %4 %5)} :: val=type=hoon=xray + {%verb p=term} :: store variable == :: ++ dojo-source :: construction node - $: p/@ud :: assembly index - q/dojo-build :: general build + $: p=@ud :: assembly index + q=dojo-build :: general build == :: ++ dojo-build :: one arvo step $~ [%ex *hoon] - $% {%ur p/@t} :: http GET request - {%ge p/dojo-model} :: generator - {%te p/term q/(list dojo-source)} :: thread - {%dv p/path} :: core from source - {%ex p/hoon} :: hoon expression - {%sa p/mark} :: example mark value - {%as p/mark q/dojo-source} :: simple transmute - {%do p/hoon q/dojo-source} :: gate apply - {%tu p/(list dojo-source)} :: tuple + $% {%ur p=@t} :: http GET request + {%ge p=dojo-model} :: generator + {%te p=term q=(list dojo-source)} :: thread + {%dv p=path} :: core from source + {%ex p=hoon} :: hoon expression + {%sa p=mark} :: example mark value + {%as p=mark q=dojo-source} :: simple transmute + {%do p=hoon q=dojo-source} :: gate apply + {%tu p=(list dojo-source)} :: tuple == :: ++ dojo-model :: data construction - $: p/dojo-server :: core source - q/dojo-config :: configuration + $: p=dojo-server :: core source + q=dojo-config :: configuration == :: ++ dojo-server :: numbered device - $: p/@ud :: assembly index - q/path :: gate path + $: p=@ud :: assembly index + q=path :: gate path == :: ++ dojo-config :: configuration - $: p/(list dojo-source) :: by order - q/(map term (unit dojo-source)) :: by keyword + $: p=(list dojo-source) :: by order + q=(map term (unit dojo-source)) :: by keyword == :: ++ dojo-project :: construction state - $: mad/dojo-command :: operation - num/@ud :: number of tasks - cud/(unit dojo-source) :: now solving - pux/(unit path) :: working - pro/(unit vase) :: prompting loop - per/(unit sole-edit) :: pending reverse - job/(map @ud dojo-build) :: problems - rez/(map @ud cage) :: results + $: mad=dojo-command :: operation + num=@ud :: number of tasks + cud=(unit dojo-source) :: now solving + pux=(unit path) :: working + pro=(unit vase) :: prompting loop + per=(unit sole-edit) :: pending reverse + job=(map @ud dojo-build) :: problems + rez=(map @ud cage) :: results == :: - ++ bead {p/(set beam) q/cage} :: computed result - ++ goal {p/ship q/term} :: flat application + ++ bead {p=(set beam) q=cage} :: computed result + ++ goal {p=ship q=term} :: flat application -- => |% @@ -130,7 +130,7 @@ ++ parse-variable |* [sym=rule src=rule] %+ cook - |= {a/term b/(unit dojo-source)} + |= {a=term b=(unit dojo-source)} ^- dojo-command ?~(b [%brev a] [[%verb a] u.b]) ;~(plug sym (punt src)) @@ -146,7 +146,7 @@ :: ;~ pfix col %+ cook - |= {a/goal b/$^(dojo-model dojo-source)} + |= {a=goal b=$^(dojo-model dojo-source)} ?@ -.b [[%poke a] b] (to-command a b) ;~ plug @@ -224,7 +224,7 @@ == :: ++ parse-goal - %+ cook |=(a/goal a) + %+ cook |=(a=goal a) ;~ pose ;~ plug ;~(pfix sig fed:ag) @@ -316,7 +316,7 @@ ++ xsell `$-(vase tank)`vase-to-tank:pprint :: ++ he :: per session - |_ {hid/bowl:gall =id moz/(list card:agent:gall) session} + |_ {hid=bowl:gall =id moz=(list card:agent:gall) session} :: ++ he-beam ^- beam @@ -363,22 +363,22 @@ [%pass u.pux %arvo %c %warp ship desk ~] :: ++ dy-errd :: reject change, abet - |= {rev/(unit sole-edit) err/@u} + |= {rev=(unit sole-edit) err=@u} ^+ +>+> (he-errd(poy `+>+<) rev err) :: ++ dy-diff :: send effects, abet - |= fec/sole-effect + |= fec=sole-effect ^+ +>+> (he-diff(poy `+>+<) fec) :: ++ dy-rash :: send effects, amok - |= fec/sole-effect + |= fec=sole-effect ^+ +>+> (he-diff(poy ~) fec) :: ++ dy-init-command :: ++dojo-command - |= mad/dojo-command + |= mad=dojo-command ^+ [mad +>] ?@ -.mad [mad +>.$] =. q.mad @@ -387,7 +387,7 @@ [mad(q src) +>.$] :: ++ dy-init-source :: ++dojo-source - |= src/dojo-source + |= src=dojo-source ^+ [src +>] =^ bul +> (dy-init-build q.src) =: p.src num @@ -396,14 +396,14 @@ [src +>.$(num +(num), job (~(put by job) -.src +.src))] :: ++ dy-init-source-unit :: (unit dojo-source) - |= urc/(unit dojo-source) + |= urc=(unit dojo-source) ^+ [urc +>] ?~ urc [~ +>] =^ src +> (dy-init-source u.urc) [`src +>.$] :: ++ dy-init-build :: ++dojo-build - |= bul/dojo-build + |= bul=dojo-build ^+ [bul +>] ?- -.bul %ex [bul +>.$] @@ -418,26 +418,26 @@ == :: ++ dy-init-model :: ++dojo-model - |= mol/dojo-model + |= mol=dojo-model ^+ [mol +>] =^ one +>.$ (dy-init-server p.mol) =^ two +>.$ (dy-init-config q.mol) [[one two] +>.$] :: ++ dy-init-server :: ++dojo-server - |= srv/dojo-server + |= srv=dojo-server =. p.srv num [srv +>.$(num +(num), job (~(put by job) num [%dv [%gen q.srv]]))] :: ++ dy-init-config :: prepare config - |= cig/dojo-config + |= cig=dojo-config ^+ [cig +>] =^ ord +>.$ (dy-init-ordered p.cig) =^ key +>.$ (dy-init-named q.cig) [[ord key] +>.$] :: ++ dy-init-ordered :: (list dojo-source) - |= ord/(list dojo-source) + |= ord=(list dojo-source) ^+ [ord +>] ?~ ord [~ +>.$] =^ fir +>.$ (dy-init-source i.ord) @@ -445,7 +445,7 @@ [[fir mor] +>.$] :: ++ dy-init-named :: (map @tas dojo-src) - |= key/(map term (unit dojo-source)) + |= key=(map term (unit dojo-source)) ^+ [key +>.$] ?~ key [~ +>.$] =^ top +>.$ (dy-init-source-unit q.n.key) @@ -458,20 +458,20 @@ =^(dam . (dy-init-command mad) +(mad dam)) :: ++ dy-hand :: complete step - |= cag/cage + |= cag=cage ^+ +>+> ?> ?=(^ cud) (dy-step(cud ~, rez (~(put by rez) p.u.cud cag)) +(p.u.cud)) :: ++ dy-meal :: vase to cage - |= vax/vase + |= vax=vase ?. &(?=(@ -.q.vax) ((sane %tas) -.q.vax)) ~& %dy-meal-cage (dy-rash %bel ~) (dy-hand -.q.vax (slot 3 vax)) :: ++ dy-made-edit :: sole edit - |= cag/cage + |= cag=cage ^+ +>+> ?> ?=(^ per) ?: ?| ?=(^ q.q.cag) @@ -482,7 +482,7 @@ (dy-errd(per ~) per q.q.cag) :: ++ dy-done :: dialog submit - |= txt/tape + |= txt=tape ?: |(?=(^ per) ?=(^ pux) ?=(~ pro)) ~& %dy-no-prompt (dy-diff %bel ~) @@ -493,8 +493,8 @@ (dy-made-dial %noun p.res) :: ++ dy-cast - |* {typ/_* bun/vase} - |= a/vase ^- typ + |* {typ=_* bun=vase} + |= a=vase ^- typ ~| [p.bun p.a] ?> (~(nest ut p.bun) & p.a) ;;(typ q.a) @@ -600,22 +600,22 @@ -- == :: - ++ dy-show |=(cay/cage (dy-print cay ~)) + ++ dy-show |=(cay=cage (dy-print cay ~)) :: :: Print a value (given as a cage) and a note (given as a tang). :: ++ dy-xprint - |= {cay/cage tan/tang} + |= {cay=cage tan=tang} %+ dy-rash %tan %- welp :_ tan ?+ p.cay [(xsell q.cay)]~ %tang ;;(tang q.q.cay) %httr =+ hit=;;(httr:eyre q.q.cay) - =- (flop (turn `wall`- |=(a/tape leaf+(dash:us a '' ~)))) + =- (flop (turn `wall`- |=(a=tape leaf+(dash:us a '' ~)))) :- "HTTP {}" %+ weld - (turn q.hit |=({a/@t b/@t} "{(trip a)}: {(trip b)}")) + (turn q.hit |=({a=@t b=@t} "{(trip a)}: {(trip b)}")) :- i="" t=(turn `wain`?~(r.hit ~ (to-wain:format q.u.r.hit)) trip) == @@ -623,22 +623,22 @@ :: Print a value (given as a cage) and a note (given as a tang). :: ++ dy-print - |= {cay/cage tan/tang} + |= {cay=cage tan=tang} %+ dy-rash %tan %- welp :_ tan ?+ p.cay [(sell q.cay)]~ %tang ;;(tang q.q.cay) %httr =+ hit=;;(httr:eyre q.q.cay) - =- (flop (turn `wall`- |=(a/tape leaf+(dash:us a '' ~)))) + =- (flop (turn `wall`- |=(a=tape leaf+(dash:us a '' ~)))) :- "HTTP {}" %+ weld - (turn q.hit |=({a/@t b/@t} "{(trip a)}: {(trip b)}")) + (turn q.hit |=({a=@t b=@t} "{(trip a)}: {(trip b)}")) :- i="" t=(turn `wain`?~(r.hit ~ (to-wain:format q.u.r.hit)) trip) == ++ dy-show-type-noun - |= a/type ^- tank + |= a=type ^- tank =- >[-]< |- ^- $? $% {%atom @tas (unit @)} {%cell _$ _$} @@ -652,7 +652,7 @@ ?+ a a {%face ^} a(q $(a q.a)) {%cell ^} a(p $(a p.a), q $(a q.a)) - {%fork *} a(p (silt (turn ~(tap in p.a) |=(b/type ^$(a b))))) + {%fork *} a(p (silt (turn ~(tap in p.a) |=(b=type ^$(a b))))) {%hint *} !! {%core ^} `wain`/core {%hold *} a(p $(a p.a)) @@ -680,9 +680,9 @@ == :: ++ dy-show-source - |= a/dojo-source ^- tank + |= a=dojo-source ^- tank =- >[-]< - =+ `{@ bil/dojo-build}`a + =+ `{@ bil=dojo-build}`a |- ^- dy-shown ?- -.bil $?(%ur %dv %sa) bil @@ -703,7 +703,7 @@ == :: ++ dy-edit :: handle edit - |= cal/sole-change + |= cal=sole-change ^+ +>+> =^ dat say (~(transceive sole say) cal) ?: |(?=(^ per) ?=(^ pux) ?=(~ pro)) @@ -718,7 +718,7 @@ (dy-made-edit %noun p.res) :: ++ dy-type :: sole action - |= act/sole-action + |= act=sole-action ?- -.dat.act %det (dy-edit +.dat.act) %ret (dy-done (tufa buf.say)) @@ -726,10 +726,10 @@ %tab +>+> == :: - ++ dy-cage |=(num/@ud (~(got by rez) num)) :: known cage - ++ dy-vase |=(num/@ud q:(dy-cage num)) :: known vase + ++ dy-cage |=(num=@ud (~(got by rez) num)) :: known cage + ++ dy-vase |=(num=@ud q:(dy-cage num)) :: known vase ++ dy-sore - |= src/(list dojo-source) + |= src=(list dojo-source) ^- vase ?~ src !>(~) @@ -810,7 +810,7 @@ (slam gat sam) :: ++ dy-made-dial :: dialog product - |= cag/cage + |= cag=cage ^+ +>+> ?. ?=(^ q.q.cag) (dy-errd ~ q.q.cag) @@ -832,11 +832,11 @@ == :: ++ dy-made-gent :: generator product - |= cag/cage + |= cag=cage (dy-meal q.cag) :: ++ dy-made-noun :: generator product - |= cag/cage + |= cag=cage (dy-hand %noun q.cag) :: ++ dy-wool-poke @@ -896,12 +896,12 @@ :: ++ dy-hoon-var =+ ^= ope - |= gen/hoon ^- hoon + |= gen=hoon ^- hoon ?: ?=(?(%sggl %sggr) -.gen) $(gen q.gen) =+ ~(open ap gen) ?.(=(gen -) $(gen -) gen) - |= gen/hoon ^- (unit cage) + |= gen=hoon ^- (unit cage) =. gen (ope gen) ?: ?=({%cnts {@ ~} ~} gen) (~(get by var) i.p.gen) @@ -933,7 +933,7 @@ (slap sut hoon) :: ++ dy-step :: advance project - |= nex/@ud + |= nex=@ud ^+ +>+> ?> ?=(~ cud) ?: =(nex num) @@ -944,19 +944,19 @@ -- :: ++ he-dope - |= txt/tape :: + |= txt=tape :: ^- (each (unit (each dojo-command tape)) hair) :: prefix+result =+ len=+((lent txt)) :: line length =. txt (weld buf `tape`(weld txt "\0a")) :: =+ vex=((full parse-command-line:he-parser) [1 1] txt) ?: =(q.p.vex len) :: matched to line end [%& ~] :: - ?: =(p.p.vex +((lent (skim txt |=(a/@ =(10 a)))))) :: parsed all lines + ?: =(p.p.vex +((lent (skim txt |=(a=@ =(10 a)))))) :: parsed all lines [%& ~ ?~(q.vex [%| txt] [%& p.u.q.vex])] :: new buffer+complete [%| p.p.vex (dec q.p.vex)] :: syntax error :: ++ he-duke :: ++he-dope variant - |= txt/tape + |= txt=tape ^- (each (unit (each dojo-command tape)) @ud) =+ foy=(he-dope txt) ?- -.foy @@ -975,7 +975,7 @@ %_(+> moz [card moz]) :: ++ he-diff :: emit update - |= fec/sole-effect + |= fec=sole-effect ^+ +> (he-card %give %fact ~[/sole/[id]] %sole-effect !>(fec)) :: @@ -984,7 +984,7 @@ ?~(poy . ~(dy-stop dy u.poy)) :: ++ he-peer :: subscribe to - |= pax/path + |= pax=path ?>(=(~ pax) he-prom) :: ++ he-pine :: restore prompt @@ -993,7 +993,7 @@ he-prom:he-pone :: ++ he-errd :: reject update - |= {rev/(unit sole-edit) err/@u} ^+ +> + |= {rev=(unit sole-edit) err=@u} ^+ +> =+ red=(fall rev [%nop ~]) :: required for error location sync =^ lic say (~(transmit sole say) red) (he-diff %mor [%det lic] [%err err] ~) @@ -1034,7 +1034,7 @@ == :: ++ he-unto :: result from agent - |= {way/wire cit/sign:agent:gall} + |= {way=wire cit=sign:agent:gall} ^+ +> ?. ?=(%poke-ack -.cit) ~& [%strange-unto cit] @@ -1092,10 +1092,10 @@ == :: ++ he-lens - |= com/command:lens + |= com=command:lens ^+ +> =/ source=dojo-source - =| num/@ + =| num=@ =- ?. ?=(%send-api -.sink.com) :: XX num is incorrect sor :- 0 @@ -1139,7 +1139,7 @@ [%sand %ta (scot %p our.hid)] [%sand %tas api.source.com] [%sand %ta (scot %da now.hid)] - (turn endpoint.source.com |=(a/@t [%sand %ta a])) + (turn endpoint.source.com |=(a=@t [%sand %ta a])) == :: %listen-api !! @@ -1168,7 +1168,7 @@ :- ^$(source.com i.next.source.com) $(next.source.com t.next.source.com) == - =+ |- ^- sink/dojo-sink + =+ |- ^- sink=dojo-sink ?- -.sink.com %stdout [%show %0] %output-file $(sink.com [%command (cat 3 '@' pax.sink.com)]) @@ -1183,11 +1183,11 @@ (he-plan sink source) :: ++ he-like :: accept line - |= buf/(list @c) + |= buf=(list @c) =(%& -:(he-dope (tufa buf))) :: ++ he-stir :: apply change - |= cal/sole-change + |= cal=sole-change ^+ +> :: ~& [%his-clock ler.cal] :: ~& [%our-clock ven.say] @@ -1203,13 +1203,13 @@ (he-errd `dat q.p.foy) :: ++ he-plan :: execute command - |= mad/dojo-command + |= mad=dojo-command ^+ +> ?> ?=(~ poy) he-pine:(dy-step:~(dy-init dy %*(. *dojo-project mad mad)) 0) :: ++ he-done :: parse command - |= txt/tape + |= txt=tape ^+ +> ?~ txt =< he-prom(buf ~) @@ -1431,7 +1431,7 @@ -- :: ++ he-type :: apply input - |= act/sole-action + |= act=sole-action ^+ +> ?^ poy he-pine:(~(dy-type dy u.poy) act) @@ -1443,7 +1443,7 @@ == :: ++ he-lame :: handle error - |= {wut/term why/tang} + |= {wut=term why=tang} ^+ +> %- (slog (flop `tang`[>%dojo-lame wut< why])) ?^ poy @@ -1460,10 +1460,10 @@ :: ^- cage :- %noun - =+ sloop=|=({a/vase b/vase} ?:(=(*vase a) b ?:(=(*vase b) a (slop a b)))) + =+ sloop=|=({a=vase b=vase} ?:(=(*vase a) b ?:(=(*vase b) a (slop a b)))) %+ sloop %- ~(rep by var) - |= {{a/term @ b/vase} c/vase} ^- vase + |= {{a=term @ b=vase} c=vase} ^- vase (sloop b(p face+[a p.b]) c) !>([our=our now=now eny=eny]:hid) -- diff --git a/pkg/arvo/app/weather.hoon b/pkg/arvo/app/weather.hoon index 684956b151..12d812af7b 100644 --- a/pkg/arvo/app/weather.hoon +++ b/pkg/arvo/app/weather.hoon @@ -146,7 +146,7 @@ |= [wir=wire err=(unit tang)] ^- (quip card _state) ?~ err - =/ req/request:http (request-darksky location) + =/ req=request:http (request-darksky location) =/ out *outbound-config:iris :_ state(timer `(add now.bol ~h3)) :~ [%pass /[(scot %da now.bol)] %arvo %i %request req out] diff --git a/pkg/arvo/gen/cat.hoon b/pkg/arvo/gen/cat.hoon index 142da21578..c9b53de8f3 100644 --- a/pkg/arvo/gen/cat.hoon +++ b/pkg/arvo/gen/cat.hoon @@ -8,10 +8,10 @@ :::: :: :- %say -|= {^ {arg/(list path)} vane/?(%g %c)} +|= {^ {arg=(list path)} vane=?(%g %c)} =- tang+(flop `tang`(zing -)) %+ turn arg -|= pax/path +|= pax=path ^- tang =+ ark=.^(arch (cat 3 vane %y) pax) ?^ fil.ark diff --git a/pkg/arvo/gen/code.hoon b/pkg/arvo/gen/code.hoon index 973197041c..4f8c054038 100644 --- a/pkg/arvo/gen/code.hoon +++ b/pkg/arvo/gen/code.hoon @@ -3,7 +3,7 @@ :::: /hoon/code/gen :: :- %say -|= $: {now/@da eny/@uvJ bec/beak} +|= $: {now=@da eny=@uvJ bec=beak} ~ ~ == diff --git a/pkg/arvo/gen/hello.hoon b/pkg/arvo/gen/hello.hoon index b2a75750e9..68065d0f78 100644 --- a/pkg/arvo/gen/hello.hoon +++ b/pkg/arvo/gen/hello.hoon @@ -8,6 +8,6 @@ :::: :: :- %say -|= {^ {{txt/@tas ~} ~}} +|= {^ {{txt=@tas ~} ~}} :- %noun (crip (weld "hello, " (trip txt))) diff --git a/pkg/arvo/gen/help.hoon b/pkg/arvo/gen/help.hoon index 858886039f..28a17c77b8 100644 --- a/pkg/arvo/gen/help.hoon +++ b/pkg/arvo/gen/help.hoon @@ -8,7 +8,7 @@ :: |% ++ path-heps - |= a/path ^- tape + |= a=path ^- tape ?~ a "" |- ^- tape %+ welp (trip i.a) @@ -16,8 +16,8 @@ ['-' $(a t.a)] :: ++ rend - |= {a/@thoon b/path} ^- tank - =; c/(pair tape tape) + |= {a=@thoon b=path} ^- tank + =; c=(pair tape tape) =/ tab (sub 10 (mod (lent "{p.c} ") 10)) [%palm [" {(reap tab ' ')}" ``~] leaf+p.c leaf+q.c ~] :- ?- b @@ -32,17 +32,17 @@ (trip i.c) :: ++ read-at - |= {len/@u pax/path} - |= {nam/@t ark/arch} ^- (unit {@t path}) + |= {len=@u pax=path} + |= {nam=@t ark=arch} ^- (unit {@t path}) ?. (~(has by dir.ark) %hoon) ~ %+ bind (file:space:userlib (welp pax /[nam]/hoon)) - |= a/* ^- {cord path} + |= a=* ^- {cord path} [;;(@t a) (welp (slag len pax) /[nam])] -- :: :- %say -|= {{now/time @ our/ship ^} typ/$@(~ {p/term ~}) ~} -=/ pax/path /(scot %p our)/home/(scot %da now)/gen :: XX hardcoded +|= {{now=time @ our=ship ^} typ=$@(~ {p=term ~}) ~} +=/ pax=path /(scot %p our)/home/(scot %da now)/gen :: XX hardcoded =+ len=(lent pax) =. pax ?~(typ pax (welp pax /[p.typ])) :- %tang %- flop ^- tang @@ -53,12 +53,12 @@ (drop (bind red rend)) |- ^- tang =+ =< arl=~(tap by (~(urn by dir.ark) .)) - |=({a/@t ~} .^(arch cy+(welp pax /[a]))) + |=({a=@t ~} .^(arch cy+(welp pax /[a]))) %+ welp - =/ dir/(list {@ path}) + =/ dir=(list {@ path}) (murn arl (read-at len pax)) `tang`(turn (sort dir aor) rend) %- zing ^- (list tang) %+ turn (sort arl aor) -|= {a/@t b/arch} +|= {a=@t b=arch} ^$(pax (welp pax /[a]), ark b) diff --git a/pkg/arvo/gen/hood/autocommit.hoon b/pkg/arvo/gen/hood/autocommit.hoon index 03da63afbc..01bbe5b234 100644 --- a/pkg/arvo/gen/hood/autocommit.hoon +++ b/pkg/arvo/gen/hood/autocommit.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now/@da eny/@uvJ bec/beak} - {mon/term ~} +|= $: {now=@da eny=@uvJ bec=beak} + {mon=term ~} ~ == :- %kiln-commit diff --git a/pkg/arvo/gen/hood/breload.hoon b/pkg/arvo/gen/hood/breload.hoon index 68a04d791f..8b087e65fe 100644 --- a/pkg/arvo/gen/hood/breload.hoon +++ b/pkg/arvo/gen/hood/breload.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now/@da eny/@uvJ bec/beak} - {arg/(list term) ~} +|= $: {now=@da eny=@uvJ bec=beak} + {arg=(list term) ~} == :+ %helm-reload-desk %base arg diff --git a/pkg/arvo/gen/hood/commit.hoon b/pkg/arvo/gen/hood/commit.hoon index 8964e06315..cbe0c1016d 100644 --- a/pkg/arvo/gen/hood/commit.hoon +++ b/pkg/arvo/gen/hood/commit.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now/@da eny/@uvJ bec/beak} - {mon/term ~} +|= $: {now=@da eny=@uvJ bec=beak} + {mon=term ~} auto=_| == :- %kiln-commit diff --git a/pkg/arvo/gen/hood/cp.hoon b/pkg/arvo/gen/hood/cp.hoon index 9185d0d9a6..0e7d2f9090 100644 --- a/pkg/arvo/gen/hood/cp.hoon +++ b/pkg/arvo/gen/hood/cp.hoon @@ -5,7 +5,7 @@ /? 310 :- %say =, space:userlib -|= {^ {input/path output/path ~} ~} +|= {^ {input=path output=path ~} ~} :- %kiln-info ?. =(-:(flop input) -:(flop output)) ["Can't move to a different mark" ~] diff --git a/pkg/arvo/gen/hood/exit.hoon b/pkg/arvo/gen/hood/exit.hoon index 3c40a42e49..92a4dfb8d4 100644 --- a/pkg/arvo/gen/hood/exit.hoon +++ b/pkg/arvo/gen/hood/exit.hoon @@ -9,7 +9,7 @@ :: =, sole :- %say -|= $: {now/@da eny/@ bec/beak} +|= $: {now=@da eny=@ bec=beak} {~ ~} == ~& %drum-exit diff --git a/pkg/arvo/gen/hood/hi.hoon b/pkg/arvo/gen/hood/hi.hoon index 09c5237767..7530f6069e 100644 --- a/pkg/arvo/gen/hood/hi.hoon +++ b/pkg/arvo/gen/hood/hi.hoon @@ -4,4 +4,4 @@ :: /? 310 :- %say -|=({^ {who/ship mez/$@(~ {a/tape ~})} ~} helm-send-hi+[who ?~(mez ~ `a.mez)]) +|=({^ {who=ship mez=$@(~ {a=tape ~})} ~} helm-send-hi+[who ?~(mez ~ `a.mez)]) diff --git a/pkg/arvo/gen/hood/init-oauth2.hoon b/pkg/arvo/gen/hood/init-oauth2.hoon index 8251083f2e..8fc9fb9bf3 100644 --- a/pkg/arvo/gen/hood/init-oauth2.hoon +++ b/pkg/arvo/gen/hood/init-oauth2.hoon @@ -10,26 +10,26 @@ :: =, generators :- %ask -|= $: {now/@da eny/@uvJ bec/beak} - {arg/$@(~ {dom/path ~})} +|= $: {now=@da eny=@uvJ bec=beak} + {arg=$@(~ {dom=path ~})} ~ == -^- (sole-result:sole {%write-sec-atom p/host:eyre q/@}) +^- (sole-result:sole {%write-sec-atom p=host:eyre q=@}) =- ?~ arg - (fun.q.q [%& dom.arg]) %+ prompt [%& %oauth-hostname "api hostname: https://"] %+ parse thos:de-purl:html -|= hot/host:eyre +|= hot=host:eyre ?: ?=(%| -.hot) ~|(%ips-unsupported !!) %+ prompt [%& %oauth-client "client id: "] %+ parse (boss 256 (star prn)) -|= cid/@t +|= cid=@t %+ prompt [%& %oauth-secret "client secret: "] %+ parse (boss 256 (star prn)) -|= cis/@t +|= cis=@t %+ produce %write-sec-atom :: XX typed pair [hot (of-wain:format cid cis ~)] diff --git a/pkg/arvo/gen/hood/init-oauth2/google.hoon b/pkg/arvo/gen/hood/init-oauth2/google.hoon index 6fcdc1d21e..e95e022df6 100644 --- a/pkg/arvo/gen/hood/init-oauth2/google.hoon +++ b/pkg/arvo/gen/hood/init-oauth2/google.hoon @@ -12,11 +12,11 @@ =, html =, format :- %ask -|= $: {now/@da eny/@uvJ bec/beak} - {arg/$@(~ {jon/json ~})} +|= $: {now=@da eny=@uvJ bec=beak} + {arg=$@(~ {jon=json ~})} ~ == -^- (sole-result:sole {%write-sec-atom p/host:eyre q/@}) +^- (sole-result:sole {%write-sec-atom p=host:eyre q=@}) %+ print leaf+"Accepting credentials for https://*.googleapis.com" =+ hot=[%& /com/googleapis] =- ?~ arg - @@ -24,9 +24,9 @@ %+ prompt [%& %oauth-json "json credentials: "] %+ parse apex:de-json -|= jon/json +|= jon=json =+ ~| bad-json+jon - =- `{cid/@t cis/@t}`(need (rep jon)) + =- `{cid=@t cis=@t}`(need (rep jon)) rep=(ot web+(ot 'client_id'^so 'client_secret'^so ~) ~):dejs-soft:format %+ produce %write-sec-atom :: XX typed pair [hot (of-wain:format cid cis ~)] diff --git a/pkg/arvo/gen/hood/label.hoon b/pkg/arvo/gen/hood/label.hoon index 5b8bcd4187..a0550b8b6f 100644 --- a/pkg/arvo/gen/hood/label.hoon +++ b/pkg/arvo/gen/hood/label.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now/@da eny/@uvJ bec/beak} - {arg/{syd/desk lab/@tas ~} ~} +|= $: {now=@da eny=@uvJ bec=beak} + {arg={syd=desk lab=@tas ~} ~} == :- %kiln-label [syd lab]:arg diff --git a/pkg/arvo/gen/hood/link.hoon b/pkg/arvo/gen/hood/link.hoon index c185600ac6..5d64ca4f87 100644 --- a/pkg/arvo/gen/hood/link.hoon +++ b/pkg/arvo/gen/hood/link.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now/@da eny/@uvJ byk/beak} - {arg/$?({dap/term ~} {who/ship dap/term ~}) ~} +|= $: {now=@da eny=@uvJ byk=beak} + {arg=$?({dap=term ~} {who=ship dap=term ~}) ~} == :- %drum-link ?~ +.arg diff --git a/pkg/arvo/gen/hood/mass.hoon b/pkg/arvo/gen/hood/mass.hoon index 98459565b8..032ef5f987 100644 --- a/pkg/arvo/gen/hood/mass.hoon +++ b/pkg/arvo/gen/hood/mass.hoon @@ -7,7 +7,7 @@ :::: :: :- %say -|= $: {now/@da eny/@uvJ bec/beak} - {arg/~ ~} +|= $: {now=@da eny=@uvJ bec=beak} + {arg=~ ~} == [%helm-mass ~] diff --git a/pkg/arvo/gen/hood/merge.hoon b/pkg/arvo/gen/hood/merge.hoon index 95ef41657c..c8ff7bb994 100644 --- a/pkg/arvo/gen/hood/merge.hoon +++ b/pkg/arvo/gen/hood/merge.hoon @@ -8,18 +8,18 @@ :: |% ++ beaky {knot knot knot ~} -++ sorc ?({bek/beaky ~} {her/@p sud/@tas ~}) +++ sorc ?({bek=beaky ~} {her=@p sud=@tas ~}) -- :: :::: :: :- %say -|= $: {now/@da eny/@uvJ bek/beak} - {arg/{?(~ sorc {syd/$@(desk beaky) sorc})} cas/case gem/?(germ %auto)} +|= $: {now=@da eny=@uvJ bek=beak} + {arg={?(~ sorc {syd=$@(desk beaky) sorc})} cas=case gem=?(germ %auto)} == =* our p.bek |^ :- %kiln-merge - ^- $@(~ {syd/desk her/ship sud/desk cas/case gem/?(germ %auto)}) + ^- $@(~ {syd=desk her=ship sud=desk cas=case gem=?(germ %auto)}) ?- arg ~ ((slog (turn help-text |=(=@t leaf+(trip t)))) ~) {@ @ ~} @@ -37,10 +37,10 @@ :- (pars-src syd.arg) =+((pars bek.arg) [who dez (opt-case caz) gem]) == -++ opt-case |=(a/case ?:(=(*case cas) a cas)) :: override -++ pars |=(a/beaky `{{who/ship dez/desk caz/case} *}`(need (de-beam:format a))) +++ opt-case |=(a=case ?:(=(*case cas) a cas)) :: override +++ pars |=(a=beaky `{{who=ship dez=desk caz=case} *}`(need (de-beam:format a))) ++ pars-src - |= syd/$@(desk beaky) + |= syd=$@(desk beaky) ?@ syd syd =+ (pars syd) ~| [%into-foreign who `path`syd] diff --git a/pkg/arvo/gen/hood/mount.hoon b/pkg/arvo/gen/hood/mount.hoon index 0a4c3c8a1c..d0bfae650f 100644 --- a/pkg/arvo/gen/hood/mount.hoon +++ b/pkg/arvo/gen/hood/mount.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now/@da eny/@uvJ bec/beak} - {{pax/path pot/$@(~ {v/@tas ~})} ~} +|= $: {now=@da eny=@uvJ bec=beak} + {{pax=path pot=$@(~ {v=@tas ~})} ~} == ?~ pot =+ bem=(need (de-beam:format pax)) diff --git a/pkg/arvo/gen/hood/mv.hoon b/pkg/arvo/gen/hood/mv.hoon index 01339e8b09..282c3cb216 100644 --- a/pkg/arvo/gen/hood/mv.hoon +++ b/pkg/arvo/gen/hood/mv.hoon @@ -5,7 +5,7 @@ /? 310 =, space:userlib :- %say -|= {^ {input/path output/path ~} ~} +|= {^ {input=path output=path ~} ~} :- %kiln-info ?. =(-:(flop input) -:(flop output)) ["Can't move to a different mark" ~] diff --git a/pkg/arvo/gen/hood/pack.hoon b/pkg/arvo/gen/hood/pack.hoon index a6038b98c2..0e043a05f8 100644 --- a/pkg/arvo/gen/hood/pack.hoon +++ b/pkg/arvo/gen/hood/pack.hoon @@ -7,7 +7,7 @@ :::: :: :- %say -|= $: {now/@da eny/@uvJ bec/beak} - {arg/~ ~} +|= $: {now=@da eny=@uvJ bec=beak} + {arg=~ ~} == [%helm-pack ~] diff --git a/pkg/arvo/gen/hood/ping.hoon b/pkg/arvo/gen/hood/ping.hoon index 1064a98a4a..da3c2298f7 100644 --- a/pkg/arvo/gen/hood/ping.hoon +++ b/pkg/arvo/gen/hood/ping.hoon @@ -4,8 +4,8 @@ :: /? 310 :- %say -|= $: {now/@da eny/@ bec/beak} - {{exp/@ud ~} ~} +|= $: {now=@da eny=@ bec=beak} + {{exp=@ud ~} ~} == =+ rab=(~(raw og eny) (bex exp)) ~& [%random-bytes (met 3 rab) `@p`(mug rab)] diff --git a/pkg/arvo/gen/hood/private.hoon b/pkg/arvo/gen/hood/private.hoon index c60d0f4555..87a4f2b3e0 100644 --- a/pkg/arvo/gen/hood/private.hoon +++ b/pkg/arvo/gen/hood/private.hoon @@ -3,8 +3,8 @@ :::: /gen/hood/private/hoon :: :- %say -|= $: {now/@da eny/@uvJ bec/beak} - {arg/{des/desk may/?(~ {pax/path ~})} ~} +|= $: {now=@da eny=@uvJ bec=beak} + {arg={des=desk may=?(~ {pax=path ~})} ~} == :- %kiln-permission [des ?~(may / pax.may) |]:arg diff --git a/pkg/arvo/gen/hood/public.hoon b/pkg/arvo/gen/hood/public.hoon index 831d52b696..973272df4f 100644 --- a/pkg/arvo/gen/hood/public.hoon +++ b/pkg/arvo/gen/hood/public.hoon @@ -3,8 +3,8 @@ :::: /gen/hood/public/hoon :: :- %say -|= $: {now/@da eny/@uvJ bec/beak} - {arg/{des/desk may/?(~ {pax/path ~})} ~} +|= $: {now=@da eny=@uvJ bec=beak} + {arg={des=desk may=?(~ {pax=path ~})} ~} == :- %kiln-permission [des ?~(may / pax.may) &]:arg diff --git a/pkg/arvo/gen/hood/rc.hoon b/pkg/arvo/gen/hood/rc.hoon index 12102e3fe4..3c03fa0ea0 100644 --- a/pkg/arvo/gen/hood/rc.hoon +++ b/pkg/arvo/gen/hood/rc.hoon @@ -7,7 +7,7 @@ :::: :: :- %say -|= $: {now/@da eny/@uvJ bec/beak} - {arg/~ ~} +|= $: {now=@da eny=@uvJ bec=beak} + {arg=~ ~} == [%helm-reload ~[%c]] diff --git a/pkg/arvo/gen/hood/reboot.hoon b/pkg/arvo/gen/hood/reboot.hoon index f9afb0a3c7..30468bcddd 100644 --- a/pkg/arvo/gen/hood/reboot.hoon +++ b/pkg/arvo/gen/hood/reboot.hoon @@ -7,7 +7,7 @@ :::: :: :- %say -|= $: {now/@da eny/@uvJ bec/beak} - {arg/~ ~} +|= $: {now=@da eny=@uvJ bec=beak} + {arg=~ ~} == [%helm-reload ~[%z %a %b %c %d %e %g %i %j]] diff --git a/pkg/arvo/gen/hood/reload-desk.hoon b/pkg/arvo/gen/hood/reload-desk.hoon index e6543f5cf3..eb152dd75b 100644 --- a/pkg/arvo/gen/hood/reload-desk.hoon +++ b/pkg/arvo/gen/hood/reload-desk.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now/@da eny/@uvJ bec/beak} - {arg/{desk (list term)} ~} +|= $: {now=@da eny=@uvJ bec=beak} + {arg={desk (list term)} ~} == :- %helm-reload-desk arg diff --git a/pkg/arvo/gen/hood/reload.hoon b/pkg/arvo/gen/hood/reload.hoon index 72ecb0a47c..10207233e3 100644 --- a/pkg/arvo/gen/hood/reload.hoon +++ b/pkg/arvo/gen/hood/reload.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now/@da eny/@uvJ bec/beak} - {arg/(list term) ~} +|= $: {now=@da eny=@uvJ bec=beak} + {arg=(list term) ~} == :- %helm-reload arg diff --git a/pkg/arvo/gen/hood/reset.hoon b/pkg/arvo/gen/hood/reset.hoon index 7989b03b4d..d063e9747c 100644 --- a/pkg/arvo/gen/hood/reset.hoon +++ b/pkg/arvo/gen/hood/reset.hoon @@ -7,7 +7,7 @@ :::: :: :- %say -|= $: {now/@da eny/@uvJ bec/beak} - {arg/~ ~} +|= $: {now=@da eny=@uvJ bec=beak} + {arg=~ ~} == [%helm-reset ~] diff --git a/pkg/arvo/gen/hood/rm.hoon b/pkg/arvo/gen/hood/rm.hoon index 0b4f2a94ea..fce64a1ecb 100644 --- a/pkg/arvo/gen/hood/rm.hoon +++ b/pkg/arvo/gen/hood/rm.hoon @@ -4,4 +4,4 @@ :: /? 310 :- %say -|=({^ {input/path ~} ~} kiln-rm+input) +|=({^ {input=path ~} ~} kiln-rm+input) diff --git a/pkg/arvo/gen/hood/schedule.hoon b/pkg/arvo/gen/hood/schedule.hoon index c2c2360924..3e71dad53f 100644 --- a/pkg/arvo/gen/hood/schedule.hoon +++ b/pkg/arvo/gen/hood/schedule.hoon @@ -4,4 +4,4 @@ :: /? 310 :- %say -|=({^ {where/path tym/@da eve/@t ~} ~} kiln-schedule+[where tym eve]) +|=({^ {where=path tym=@da eve=@t ~} ~} kiln-schedule+[where tym eve]) diff --git a/pkg/arvo/gen/hood/start.hoon b/pkg/arvo/gen/hood/start.hoon index f2e3d9f325..db3fcc93ac 100644 --- a/pkg/arvo/gen/hood/start.hoon +++ b/pkg/arvo/gen/hood/start.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now/@da eny/@uvJ bec/beak} - {arg/{@ $@(~ {@ ~})} ~} +|= $: {now=@da eny=@uvJ bec=beak} + {arg={@ $@(~ {@ ~})} ~} == :- %drum-start ?> ((sane %tas) -.arg) diff --git a/pkg/arvo/gen/hood/sync.hoon b/pkg/arvo/gen/hood/sync.hoon index b6cf91ab12..251f30f843 100644 --- a/pkg/arvo/gen/hood/sync.hoon +++ b/pkg/arvo/gen/hood/sync.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now/@da eny/@uvJ bec/beak} - {arg/{syd/@tas her/@p sud/@tas ~} ~} +|= $: {now=@da eny=@uvJ bec=beak} + {arg={syd=@tas her=@p sud=@tas ~} ~} == :- %kiln-sync [syd her sud]:arg diff --git a/pkg/arvo/gen/hood/syncs.hoon b/pkg/arvo/gen/hood/syncs.hoon index 67abee089b..3c707f5a61 100644 --- a/pkg/arvo/gen/hood/syncs.hoon +++ b/pkg/arvo/gen/hood/syncs.hoon @@ -7,5 +7,5 @@ :::: :: :- %say -|= {{now/@da eny/@uvJ bec/beak} ~ ~} +|= {{now=@da eny=@uvJ bec=beak} ~ ~} [%kiln-syncs ~] diff --git a/pkg/arvo/gen/hood/track.hoon b/pkg/arvo/gen/hood/track.hoon index 235e11f411..0bb77aa044 100644 --- a/pkg/arvo/gen/hood/track.hoon +++ b/pkg/arvo/gen/hood/track.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now/@da eny/@uvJ bec/beak} - {arg/{syd/@tas her/@p sud/@tas ~} ~} +|= $: {now=@da eny=@uvJ bec=beak} + {arg={syd=@tas her=@p sud=@tas ~} ~} == :- %kiln-track [syd her sud]:arg diff --git a/pkg/arvo/gen/hood/unlink.hoon b/pkg/arvo/gen/hood/unlink.hoon index f758e145fb..f21aa729df 100644 --- a/pkg/arvo/gen/hood/unlink.hoon +++ b/pkg/arvo/gen/hood/unlink.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now/@da eny/@uvJ byk/beak} - {arg/$?({dap/term ~} {who/ship dap/term ~}) ~} +|= $: {now=@da eny=@uvJ byk=beak} + {arg=$?({dap=term ~} {who=ship dap=term ~}) ~} == :- %drum-unlink ?~ +.arg diff --git a/pkg/arvo/gen/hood/unmount.hoon b/pkg/arvo/gen/hood/unmount.hoon index e91f557559..98c32b4602 100644 --- a/pkg/arvo/gen/hood/unmount.hoon +++ b/pkg/arvo/gen/hood/unmount.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now/@da eny/@uvJ bec/beak} - {{mon/$@(term {knot path}) ~} ~} +|= $: {now=@da eny=@uvJ bec=beak} + {{mon=$@(term {knot path}) ~} ~} == :- %kiln-unmount mon diff --git a/pkg/arvo/gen/hood/unsync.hoon b/pkg/arvo/gen/hood/unsync.hoon index a867b9b3ba..19611053e1 100644 --- a/pkg/arvo/gen/hood/unsync.hoon +++ b/pkg/arvo/gen/hood/unsync.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now/@da eny/@uvJ bec/beak} - {arg/{syd/@tas her/@p sud/@tas ~} ~} +|= $: {now=@da eny=@uvJ bec=beak} + {arg={syd=@tas her=@p sud=@tas ~} ~} == :- %kiln-unsync [syd her sud]:arg diff --git a/pkg/arvo/gen/hood/verb.hoon b/pkg/arvo/gen/hood/verb.hoon index 84ff92637f..b4bf423384 100644 --- a/pkg/arvo/gen/hood/verb.hoon +++ b/pkg/arvo/gen/hood/verb.hoon @@ -9,7 +9,7 @@ :: =, sole :- %say -|= $: {now/@da eny/@ bec/beak} +|= $: {now=@da eny=@ bec=beak} {~ ~} == ~& %helm-verb diff --git a/pkg/arvo/gen/key.hoon b/pkg/arvo/gen/key.hoon index c3f1b62848..6bdcb2f3a3 100644 --- a/pkg/arvo/gen/key.hoon +++ b/pkg/arvo/gen/key.hoon @@ -12,7 +12,7 @@ %+ print leaf+"generating keys for {(scow %p who)}, life #{(scow %ud life)}" %+ prompt [%| %pope-pass "passphrase: "] %+ parse (boss 256 (star prn)) -|= fra/@t +|= fra=@t =/ bur (shaz (add who (shaz fra))) =/ cub (pit:nu:crub:crypto 512 bur) :: diff --git a/pkg/arvo/gen/ls.hoon b/pkg/arvo/gen/ls.hoon index a3954cae3d..c851a00344 100644 --- a/pkg/arvo/gen/ls.hoon +++ b/pkg/arvo/gen/ls.hoon @@ -9,6 +9,6 @@ :: ~& % :- %say -|= {^ {arg/path ~} vane/?(%g %c)} +|= {^ {arg=path ~} vane=?(%g %c)} =+ lon=.^(arch (cat 3 vane %y) arg) tang+[?~(dir.lon leaf+"~" (show-dir vane arg dir.lon))]~ diff --git a/pkg/arvo/lib/chat-store.hoon b/pkg/arvo/lib/chat-store.hoon index 3b40c6c054..63cb2d688e 100644 --- a/pkg/arvo/lib/chat-store.hoon +++ b/pkg/arvo/lib/chat-store.hoon @@ -168,8 +168,8 @@ (cu (cury slav %uv) so) :: ++ re :: recursive reparsers - |* {gar/* sef/_|.(fist:dejs-soft:format)} - |= jon/json + |* {gar=* sef=_|.(fist:dejs-soft:format)} + |= jon=json ^- (unit _gar) =- ~! gar ~! (need -) - ((sef) jon) diff --git a/pkg/arvo/lib/contact-json.hoon b/pkg/arvo/lib/contact-json.hoon index 4891cdbc64..d3c04d4163 100644 --- a/pkg/arvo/lib/contact-json.hoon +++ b/pkg/arvo/lib/contact-json.hoon @@ -2,7 +2,7 @@ /+ base64, group-store, resource |% ++ nu :: parse number as hex - |= jon/json + |= jon=json ?> ?=({%s *} jon) (rash p.jon hex) :: diff --git a/pkg/arvo/lib/cram.hoon b/pkg/arvo/lib/cram.hoon index 3c41eae362..bc35fbb041 100644 --- a/pkg/arvo/lib/cram.hoon +++ b/pkg/arvo/lib/cram.hoon @@ -1,6 +1,6 @@ |% ++ static :: freeze .mdh hoon subset - |= gen/hoon ^- {inf/(map term dime) elm/manx} + |= gen=hoon ^- {inf=(map term dime) elm=manx} ?+ -.gen =/ gen ~(open ap gen) ?: =(gen ^gen) ~|([%cram-dynamic -.gen] !!) @@ -11,15 +11,15 @@ == :: ++ single :: unwrap one-elem marl - |= xml/marl ^- manx + |= xml=marl ^- manx ?: ?=({* ~} xml) i.xml ~|(%many-elems !!) :: ++ shut-mart :: xml attrs - |=({n/mane v/(list beer:hoot)} [n (turn v |=(a/beer:hoot ?^(a !! a)))]) + |=({n=mane v=(list beer:hoot)} [n (turn v |=(a=beer:hoot ?^(a !! a)))]) :: ++ shut :: as xml constant - |= gen/hoon ^- marl + |= gen=hoon ^- marl ?+ -.gen ~|([%bad-xml -.gen] !!) %dbug $(gen q.gen) :: @@ -39,12 +39,12 @@ :: :: ++ frontmatter :: parse ~[[%foo 1] [%bar ~s2]] - |= gen/hoon ^- (list {term dime}) + |= gen=hoon ^- (list {term dime}) ?: ?=({%bust %null} gen) ~ ?: ?=(%dbug -.gen) $(gen q.gen) ?. ?=(%clsg -.gen) ~|([%bad-frontmatter -.gen] !!) %+ turn p.gen - |= gen/hoon + |= gen=hoon ?. ?=(^ -.gen) =/ gen ~(open ap gen) ?: =(gen ^gen) ~|([%bad-frontmatter-elem -.gen] !!) @@ -54,7 +54,7 @@ [q.hed (as-dime q.gen)] :: ++ as-dime :: %foo ~.foo 0vbar etc - |= gen/hoon ^- dime + |= gen=hoon ^- dime ?: ?=(%dbug -.gen) $(gen q.gen) ?. ?=({?(%rock %sand) @ @} gen) ~|([%bad-literal gen] !!) +.gen diff --git a/pkg/arvo/lib/der.hoon b/pkg/arvo/lib/der.hoon index f20c32d349..9b3876b403 100644 --- a/pkg/arvo/lib/der.hoon +++ b/pkg/arvo/lib/der.hoon @@ -175,7 +175,7 @@ :: advance until :: ++ till - |= tub/nail + |= tub=nail ^- (like (list @D)) ?~ q.tub (fail tub) diff --git a/pkg/arvo/lib/elem-to-react-json.hoon b/pkg/arvo/lib/elem-to-react-json.hoon index cad7f25a39..c7e40d243f 100644 --- a/pkg/arvo/lib/elem-to-react-json.hoon +++ b/pkg/arvo/lib/elem-to-react-json.hoon @@ -9,7 +9,7 @@ ~+ ^- (map term cord) %- molt ^- (list (pair term cord)) :- [%class 'className'] - =- (rash - (more next (cook |=(a/tape [(crip (cass a)) (crip a)]) (star alf)))) + =- (rash - (more next (cook |=(a=tape [(crip (cass a)) (crip a)]) (star alf)))) ''' accept acceptCharset accessKey action allowFullScreen allowTransparency alt async autoComplete autoFocus autoPlay cellPadding cellSpacing charSet checked @@ -27,12 +27,12 @@ :: :: special handling for
foo
++ urb-codemirror :: render code blocks - |= src/manx ^- manx + |= src=manx ^- manx ?> ?=({{%pre *} _;/(**) ~} src) ;codemirror(value "{v.i.a.g.i.c.src}"); :: ++ elem-to-react-json :: serialize DOM as json - |= src/manx ^- json + |= src=manx ^- json ?: ?=(_;/(**) src) (tape:enjs v.i.a.g.src) =+ atr=(molt `(list (pair mane tape))`a.g.src) @@ -42,14 +42,14 @@ c+a+(turn c.src ..$) gn+s+(mane-to-cord n.g.src) =< ga+(pairs:enjs (turn a.g.src .)) - |= {a/mane b/tape} ^- {cord json} + |= {a=mane b=tape} ^- {cord json} :_ (tape:enjs b) ?^ a (mane-to-cord a) (~(gut by react-attrs) a a) == :: ++ mane-to-cord :: namespaced xml names - |=(a/mane `cord`?@(a a (rap 3 -.a ':' +.a ~))) + |=(a=mane `cord`?@(a a (rap 3 -.a ':' +.a ~))) -- :: :::: diff --git a/pkg/arvo/lib/frontmatter.hoon b/pkg/arvo/lib/frontmatter.hoon index 8fb7009b6e..dbde019064 100644 --- a/pkg/arvo/lib/frontmatter.hoon +++ b/pkg/arvo/lib/frontmatter.hoon @@ -6,19 +6,19 @@ =, format |% ++ atr-lines - |= atr/(map cord cord) - %+ turn (sort ~(tap by atr) |=({{a/@ @} {b/@ @}} (aor a b))) - |= {k/cord v/cord} + |= atr=(map cord cord) + %+ turn (sort ~(tap by atr) |=({{a=@ @} {b=@ @}} (aor a b))) + |= {k=cord v=cord} (rap 3 k ': ' v ~) :: ++ atr-key ;~(sfix (star ;~(less col prn)) col ace) ++ print - |= {atr/(map cord cord) src/wain} + |= {atr=(map cord cord) src=wain} ?~ atr src ['---' (welp (atr-lines atr) '---' src)] ++ parse - =| atr/(map cord cord) - |= wan/wain ^+ [atr mud=''] + =| atr=(map cord cord) + |= wan=wain ^+ [atr mud=''] ?~ wan [~ ''] ?^ (rush i.wan (star ace)) $(wan t.wan) @@ -30,6 +30,6 @@ $(wan t.wan) =- $(wan t.wan, atr (~(put by atr) (crip key) (crip val))) ~| malformed-attribute+i.t.wan - ^- {key/tape ^ val/tape} + ^- {key=tape ^ val=tape} +>:(atr-key 1^1 (trip i.t.wan)) -- diff --git a/pkg/arvo/lib/generators.hoon b/pkg/arvo/lib/generators.hoon index 8b8042e177..5bdc9301d9 100644 --- a/pkg/arvo/lib/generators.hoon +++ b/pkg/arvo/lib/generators.hoon @@ -2,21 +2,21 @@ =, sole |% ++ produce :: construct result - |* pro/* :: + |* pro=* :: [p=*(list tank) q=[%& p=[~ u=pro]]] :: :: :: ++ print :: add output tank - |* {tan/tank res/(sole-result)} :: + |* {tan=tank res=(sole-result)} :: ?@ res res :: [p=[i=tan t=p.res] q=q.res] :: :: :: ++ prompt :: construct prompt - |* {pom/sole-prompt mor/(sole-dialog)} :: + |* {pom=sole-prompt mor=(sole-dialog)} :: [p=*(list tank) q=[%| p=pom q=mor]] :: :: :: ++ curl :: fetch url - =| usr/knot :: - |* {pul/_purl:eyre fun/$-(httr:eyre *)} :: + =| usr=knot :: + |* {pul=_purl:eyre fun=$-(httr:eyre *)} :: :- p=*(list tank) :: q=[%| p=`usr q=[pul %get ~ ~] r=fun] :: :: :: @@ -24,8 +24,8 @@ [p=*(list tank) q=[%& ~]] :: :: :: ++ parse :: parse by rule - |* {sef/rule fun/$-(* *)} :: - |= txt/sole-input :: + |* {sef=rule fun=$-(* *)} :: + |= txt=sole-input :: =+ vex=(sef [0 0] txt) :: ?: |(!=((lent txt) q.p.vex) ?=(~ q.vex)) :: q.p.vex :: diff --git a/pkg/arvo/lib/graph-store.hoon b/pkg/arvo/lib/graph-store.hoon index 037565a7d8..4e54caf4e8 100644 --- a/pkg/arvo/lib/graph-store.hoon +++ b/pkg/arvo/lib/graph-store.hoon @@ -7,13 +7,13 @@ |% :: NOTE: move these functions to zuse ++ nu :: parse number as hex - |= jon/json + |= jon=json ?> ?=({%s *} jon) (rash p.jon hex) :: ++ re :: recursive reparsers - |* {gar/* sef/_|.(fist:dejs-soft:format)} - |= jon/json + |* {gar=* sef=_|.(fist:dejs-soft:format)} + |= jon=json ^- (unit _gar) =- ~! gar ~! (need -) - ((sef) jon) diff --git a/pkg/arvo/lib/group-json.hoon b/pkg/arvo/lib/group-json.hoon index da42dbc18a..5000624e4c 100644 --- a/pkg/arvo/lib/group-json.hoon +++ b/pkg/arvo/lib/group-json.hoon @@ -12,7 +12,7 @@ (set-to-array group ship:enjs:format) :: ++ set-to-array - |* {a/(set) b/$-(* json)} + |* {a=(set) b=$-(* json)} ^- json [%a (turn ~(tap in a) b)] -- diff --git a/pkg/arvo/lib/group-store.hoon b/pkg/arvo/lib/group-store.hoon index 117b82ecbe..790f3e9712 100644 --- a/pkg/arvo/lib/group-store.hoon +++ b/pkg/arvo/lib/group-store.hoon @@ -304,13 +304,13 @@ $(a r.a) :: ++ of - |* wer/(pole {cord fist}) - |= jon/json + |* wer=(pole {cord fist}) + |= jon=json ?> ?=({%o {@ *} ~ ~} jon) |- ?- wer - :: {{key/@t wit/*} t/*} - {{key/@t *} t/*} + :: {{key=@t wit=*} t=*} + {{key=@t *} t=*} => .(wer [[* wit] *]=wer) ?: =(key.wer (enkebab p.n.p.jon)) [key.wer ~|(val+q.n.p.jon (wit.wer q.n.p.jon))] diff --git a/pkg/arvo/lib/hood/drum.hoon b/pkg/arvo/lib/hood/drum.hoon index 540ad5ca4f..bd791c3405 100644 --- a/pkg/arvo/lib/hood/drum.hoon +++ b/pkg/arvo/lib/hood/drum.hoon @@ -5,49 +5,49 @@ +$ state [%2 pith-2] :: ++ pith-2 :: - $: eel/(set gill:gall) :: connect to - ray/(set well:gall) :: - fur/(map dude:gall (unit server)) :: servers - bin/(map bone source) :: terminals + $: eel=(set gill:gall) :: connect to + ray=(set well:gall) :: + fur=(map dude:gall (unit server)) :: servers + bin=(map bone source) :: terminals == :: :: :: ++ server :: running server - $: syd/desk :: app identity - cas/case :: boot case + $: syd=desk :: app identity + cas=case :: boot case == :: ++ kill :: kill ring - $: pos/@ud :: ring position - num/@ud :: number of entries - max/_60 :: max entries - old/(list (list @c)) :: entries proper + $: pos=@ud :: ring position + num=@ud :: number of entries + max=_60 :: max entries + old=(list (list @c)) :: entries proper == :: ++ source :: input device - $: edg/_80 :: terminal columns - off/@ud :: window offset - kil/kill :: kill buffer - inx/@ud :: ring index - fug/(map gill:gall (unit target)) :: connections - mir/(pair @ud stub) :: mirrored terminal + $: edg=_80 :: terminal columns + off=@ud :: window offset + kil=kill :: kill buffer + inx=@ud :: ring index + fug=(map gill:gall (unit target)) :: connections + mir=(pair @ud stub) :: mirrored terminal == :: ++ history :: past input - $: pos/@ud :: input position - num/@ud :: number of entries - lay/(map @ud (list @c)) :: editing overlay - old/(list (list @c)) :: entries proper + $: pos=@ud :: input position + num=@ud :: number of entries + lay=(map @ud (list @c)) :: editing overlay + old=(list (list @c)) :: entries proper == :: ++ search :: reverse-i-search - $: pos/@ud :: search position - str/(list @c) :: search string + $: pos=@ud :: search position + str=(list @c) :: search string == :: ++ target :: application target $: $= blt :: curr & prev belts %+ pair (unit dill-belt:dill) (unit dill-belt:dill) - ris/(unit search) :: reverse-i-search - hit/history :: all past input - pom/sole-prompt :: static prompt - inp/sole-command :: input state + ris=(unit search) :: reverse-i-search + hit=history :: all past input + pom=sole-prompt :: static prompt + inp=sole-command :: input state == :: -- :: :: :: @@ -144,14 +144,14 @@ +$ any-state ^any-state :: proxy ++ on-init se-abet:this(eel (deft-fish our.hid)) ++ diff-sole-effect-phat :: app event - |= {way/wire fec/sole-effect} + |= {way=wire fec=sole-effect} =< se-abet =< se-view =+ gyl=(de-gill way) ?: (se-aint gyl) +>.$ (se-diff gyl fec) :: ++ peer :: - |= pax/path + |= pax=path ~| [%drum-unauthorized our+our.hid src+src.hid] :: ourself ?> (team:title our.hid src.hid) :: or our own moon =< se-abet =< se-view @@ -169,26 +169,26 @@ [~ sat] :: ++ poke-dill-belt :: terminal event - |= bet/dill-belt:dill + |= bet=dill-belt:dill =< se-abet =< se-view (se-belt bet) :: ++ poke-dill-blit :: terminal output - |= bit/dill-blit:dill + |= bit=dill-blit:dill se-abet:(se-blit-sys bit) :: ++ poke-start :: start app - |= wel/well:gall + |= wel=well:gall =< se-abet =< se-view (se-born & wel) :: ++ poke-link :: connect app - |= gyl/gill:gall + |= gyl=gill:gall =< se-abet =< se-view (se-link gyl) :: ++ poke-unlink :: disconnect app - |= gyl/gill:gall + |= gyl=gill:gall =< se-abet =< se-view (se-drop:(se-pull gyl) & gyl) :: @@ -197,7 +197,7 @@ se-abet:(se-blit-sys `dill-blit:dill`[%qit ~]) :: ++ poke-put :: write file - |= {pax/path txt/@} + |= {pax=path txt=@} se-abet:(se-blit-sys [%sav pax txt]) :: :: ++ poke @@ -256,7 +256,7 @@ ..on-load :: ++ reap-phat :: ack connect - |= {way/wire saw/(unit tang)} + |= {way=wire saw=(unit tang)} =< se-abet =< se-view =+ gyl=(de-gill way) ?~ saw @@ -273,7 +273,7 @@ +>.sign-arvo :: ++ take-coup-phat :: ack poke - |= {way/wire saw/(unit tang)} + |= {way=wire saw=(unit tang)} =< se-abet =< se-view ?~ saw +> =+ gyl=(de-gill way) @@ -283,11 +283,11 @@ >[%drum-coup-fail src.hid gyl]< :: ++ take-onto :: ack start - |= {way/wire saw/(each suss:gall tang)} + |= {way=wire saw=(each suss:gall tang)} =< se-abet =< se-view ?> ?=({@ @ ~} way) ?> (~(has by fur) i.t.way) - =/ wel/well:gall [i.way i.t.way] + =/ wel=well:gall [i.way i.t.way] ?- saw {%| *} (se-dump p.saw) {%& *} ?> =(q.wel p.p.saw) @@ -311,7 +311,7 @@ == :: ++ quit-phat :: - |= way/wire + |= way=wire =< se-abet =< se-view =+ gyl=(de-gill way) ~& [%drum-quit src.hid gyl] @@ -396,7 +396,7 @@ ?: =(b %dojo) %.y (aor a b) =< .(con +>) - |: $:{gil/gill:gall con/_.} ^+ con + |: $:{gil=gill:gall con=_.} ^+ con =. +>.$ con ?: (~(has by fug) gil) +>.$ @@ -408,7 +408,7 @@ ^+ . %- ~(rep by bin) =< .(con +>) - |: $:{{ost/bone dev/source} con/_.} ^+ con + |: $:{{ost=bone dev=source} con=_.} ^+ con =+ xeno=se-subze-local:%_(con ost ost, dev dev) xeno(ost ost.con, dev dev.con, bin (~(put by bin) ost dev.xeno)) :: @@ -416,21 +416,21 @@ ^+ . %- ~(rep by fug) =< .(con +>) - |: $:{{gil/gill:gall *} con/_.} ^+ con + |: $:{{gil=gill:gall *} con=_.} ^+ con =. +>.$ con ?: (~(has in eel) gil) +>.$ (se-nuke gil) :: ++ se-aint :: ignore result - |= gyl/gill:gall + |= gyl=gill:gall ^- ? ?. (~(has by bin) ost) & =+ gyr=(~(get by fug) gyl) |(?=(~ gyr) ?=(~ u.gyr)) :: ++ se-alas :: recalculate index - |= gyl/gill:gall + |= gyl=gill:gall =+ [xin=0 wag=se-amor] |- ^+ +>.^$ ?~ wag +>.^$(inx 0) @@ -440,7 +440,7 @@ ++ se-amor :: live targets ^- (list gill:gall) %+ skim ~(tap in eel) - |=(a/gill:gall ?=({~ ~ *} (~(get by fug) a))) + |=(a=gill:gall ?=({~ ~ *} (~(get by fug) a))) :: ++ se-anon :: rotate index =+ wag=se-amor @@ -456,7 +456,7 @@ `(snag inx `(list gill:gall)`wag) :: ++ se-belt :: handle input - |= bet/dill-belt:dill + |= bet=dill-belt:dill ^+ +> ?: ?=({?(%cru %hey %rez %yow) *} bet) :: target-agnostic ?- bet @@ -482,7 +482,7 @@ == :: ++ se-drop :: disconnect - |= {pej/? gyl/gill:gall} + |= {pej=? gyl=gill:gall} ^+ +> =+ lag=se-agon ?. (~(has by fug) gyl) +>.$ @@ -497,7 +497,7 @@ +>.$ :: ++ se-tab :: print tab completions - |= tl/(list {=cord =tank}) + |= tl=(list {=cord =tank}) ^+ +> =/ lots (gth (lent tl) 10) =/ long @@ -526,10 +526,10 @@ leaf+tape :: ++ se-dump :: print tanks - |= tac/(list tank) + |= tac=(list tank) ^+ +> - =/ wol/wall - (zing (turn (flop tac) |=(a/tank (~(win re a) [0 edg])))) + =/ wol=wall + (zing (turn (flop tac) |=(a=tank (~(win re a) [0 edg])))) |- ^+ +>.^$ ?~ wol +>.^$ ?. ((sane %t) (crip i.wol)) :: XX upstream validation @@ -538,35 +538,35 @@ $(wol t.wol, +>.^$ (se-blit %out (tuba i.wol))) :: ++ se-join :: confirm connection - |= gyl/gill:gall + |= gyl=gill:gall ^+ +> =. +> (se-text "[linked to {}]") ?> ?=(~ (~(got by fug) gyl)) (se-alas(fug (~(put by fug) gyl `*target)) gyl) :: ++ se-nuke :: teardown connection - |= gyl/gill:gall + |= gyl=gill:gall ^+ +> (se-drop:(se-pull gyl) & gyl) :: ++ se-klin :: disconnect app - |= gyl/gill:gall + |= gyl=gill:gall +>(eel (~(del in eel) gyl)) :: ++ se-link :: connect to app - |= gyl/gill:gall + |= gyl=gill:gall +>(eel (~(put in eel) gyl)) :: ++ se-blit :: give output - |= bil/dill-blit:dill + |= bil=dill-blit:dill +>(biz [bil biz]) :: ++ se-blit-sys :: output to system - |= bil/dill-blit:dill ^+ +> + |= bil=dill-blit:dill ^+ +> (se-emit %give %fact ~[/drum] %dill-blit !>(bil)) :: ++ se-show :: show buffer, raw - |= lin/(pair @ud stub) + |= lin=(pair @ud stub) ^+ +> ?: =(mir lin) +> =. +> ?:(=(p.mir p.lin) +> (se-blit %hop p.lin)) @@ -574,7 +574,7 @@ +>(mir lin) :: ++ se-just :: adjusted buffer - |= {pom/stub lin/(pair @ud (list @c))} + |= {pom=stub lin=(pair @ud (list @c))} ^+ +> =/ pol (lent-char:klr pom) =/ pos (add pol p.lin) @@ -604,7 +604,7 @@ %_(+> moz [+< moz]) :: ++ se-text :: return text - |= txt/tape + |= txt=tape ^+ +> ?. ((sane %t) (crip txt)) :: XX upstream validation ~& bad-text+<`*`txt> @@ -612,46 +612,46 @@ (se-blit %out (tuba txt)) :: ++ se-poke :: send a poke - |= {gyl/gill:gall par/cage} + |= {gyl=gill:gall par=cage} (se-emit %pass (en-gill gyl) %agent gyl %poke par) :: ++ se-peer :: send a peer - |= gyl/gill:gall + |= gyl=gill:gall =/ =path /sole/(cat 3 'drum_' (scot %p our.hid)) %- se-emit(fug (~(put by fug) gyl ~)) [%pass (en-gill gyl) %agent gyl %watch path] :: ++ se-pull :: cancel subscription - |= gyl/gill:gall + |= gyl=gill:gall (se-emit %pass (en-gill gyl) %agent gyl %leave ~) :: ++ se-tame :: switch connection - |= gyl/gill:gall + |= gyl=gill:gall ^+ ta ~(. ta gyl (need (~(got by fug) gyl))) :: ++ se-diff :: receive results - |= {gyl/gill:gall fec/sole-effect} + |= {gyl=gill:gall fec=sole-effect} ^+ +> ta-abet:(ta-fec:(se-tame gyl) fec) :: ++ ta :: per target - |_ {gyl/gill:gall target} :: app and state + |_ {gyl=gill:gall target} :: app and state ++ ta-abet :: resolve ^+ ..ta ..ta(fug (~(put by fug) gyl ``target`+<+)) :: - ++ ta-poke |=(a/cage +>(..ta (se-poke gyl a))) :: poke gyl + ++ ta-poke |=(a=cage +>(..ta (se-poke gyl a))) :: poke gyl :: ++ ta-act :: send action - |= act/sole-action + |= act=sole-action ^+ +> (ta-poke %sole-action !>(act)) :: ++ ta-id (cat 3 'drum_' (scot %p our.hid)) :: per-ship duct id :: ++ ta-aro :: hear arrow - |= key/?(%d %l %r %u) + |= key=?(%d %l %r %u) ^+ +> =. ris ~ ?- key @@ -672,7 +672,7 @@ .(..ta (se-blit %bel ~), q.blt ~) :: forget belt :: ++ ta-belt :: handle input - |= bet/dill-belt:dill + |= bet=dill-belt:dill ^+ +> ?< ?=({?(%cru %hey %rez %yow) *} bet) :: target-specific =. blt [q.blt `bet] :: remember belt @@ -687,7 +687,7 @@ == :: ++ ta-det :: send edit - |= ted/sole-edit + |= ted=sole-edit ^+ +> %^ ta-act ta-id @@ -707,7 +707,7 @@ (ta-hom %del (dec pos.inp)) :: ++ ta-ctl :: hear control - |= key/@ud + |= key=@ud ^+ +> =. ris ?.(?=(?(%g %r) key) ~ ris) ?+ key ta-bel @@ -762,15 +762,15 @@ (ta-hom %del pos.inp) :: ++ ta-erl :: hear local error - |= pos/@ud + |= pos=@ud ta-bel(pos.inp (min pos (lent buf.say.inp))) :: ++ ta-err :: hear remote error - |= pos/@ud + |= pos=@ud (ta-erl (~(transpose sole say.inp) pos)) :: ++ ta-fec :: apply effect - |= fec/sole-effect + |= fec=sole-effect ^+ +> ?- fec {%bel *} ta-bel @@ -793,7 +793,7 @@ == :: ++ ta-dog :: change cursor - |= ted/sole-edit + |= ted=sole-edit %_ +> pos.inp =+ len=(lent buf.say.inp) @@ -811,29 +811,29 @@ == :: ++ ta-off :: reset buffer offset - |= ted/sole-edit - =? off (any:edit ted |=(a/sole-edit ?=(%set -.a))) 0 + |= ted=sole-edit + =? off (any:edit ted |=(a=sole-edit ?=(%set -.a))) 0 +> :: ++ ta-got :: apply change - |= cal/sole-change + |= cal=sole-change =^ ted say.inp (~(receive sole say.inp) cal) (ta-dog:(ta-off ted.cal) ted) :: ++ ta-hom :: local edit - |= ted/sole-edit + |= ted=sole-edit ^+ +> =. +> (ta-det:(ta-off ted) ted) (ta-dog(say.inp (~(commit sole say.inp) ted)) ted) :: ++ ta-jump :: buffer pos - |= {dir/?(%l %r) til/?(%ace %edg %wrd) pos/@ud} + |= {dir=?(%l %r) til=?(%ace %edg %wrd) pos=@ud} ^- @ud %- ?:(?=(%l dir) sub add) [pos (ta-pos dir til pos)] :: ++ ta-kil :: kill selection - |= {dir/?(%l %r) sel/{@ @}} + |= {dir=?(%l %r) sel={@ @}} ^+ +> =+ buf=(swag sel buf.say.inp) %. (cut:edit sel) @@ -859,7 +859,7 @@ == :: ++ ta-met :: meta key - |= key/@ud + |= key=@ud ^+ +> =. ris ~ ?+ key ta-bel @@ -935,7 +935,7 @@ == :: ++ ta-mov :: move in history - |= sop/@ud + |= sop=@ud ^+ +> ?: =(sop pos.hit) +> %- %= ta-hom @@ -961,7 +961,7 @@ == :: ++ ta-pos :: buffer pos offset - |= {dir/?(%l %r) til/?(%ace %edg %wrd) pos/@ud} + |= {dir=?(%l %r) til=?(%ace %edg %wrd) pos=@ud} ^- @ud %- ?- til %ace ace:offset %edg edg:offset @@ -972,7 +972,7 @@ == :: ++ ta-pro :: set prompt - |= pom/sole-prompt + |= pom=sole-prompt %_ +> pom %_ pom @@ -996,7 +996,7 @@ (ta-act ta-id %tab pos.inp) :: ++ ta-ser :: reverse search - |= ext/(list @c) + |= ext=(list @c) ^+ +> ?: |(?=(~ ris) =(0 pos.u.ris)) ta-bel @@ -1013,15 +1013,15 @@ (ta-mov(str.u.ris tot, pos.u.ris u.sup) (dec u.sup)) :: ++ ta-txt :: hear text - |= txt/(list @c) + |= txt=(list @c) ^+ +> ?^ ris (ta-ser txt) (ta-hom (cat:edit pos.inp txt)) :: ++ ta-vew :: computed prompt - ^- {pom/stub lin/(pair @ud (list @c))} - =; vew/(pair (list @c) styx) + ^- {pom=stub lin=(pair @ud (list @c))} + =; vew=(pair (list @c) styx) [(make:klr q.vew) pos.inp p.vew] ?: vis.pom :- buf.say.inp :: default prompt @@ -1040,7 +1040,7 @@ ++ edit :: produce sole-edits |% ++ cat :: mass insert - |= {pos/@ud txt/(list @c)} + |= {pos=@ud txt=(list @c)} ^- sole-edit :- %mor |- ^- (list sole-edit) @@ -1048,7 +1048,7 @@ [[%ins pos i.txt] $(pos +(pos), txt t.txt)] :: ++ cut :: mass delete - |= {pos/@ud num/@ud} + |= {pos=@ud num=@ud} ^- sole-edit :- %mor |- ^- (list sole-edit) @@ -1056,30 +1056,30 @@ [[%del pos] $(num (dec num))] :: ++ rep :: mass replace - |= {{pos/@ud num/@ud} txt/(list @c)} + |= {{pos=@ud num=@ud} txt=(list @c)} ^- sole-edit :~ %mor (cut pos num) (cat pos txt) == ++ any :: matches? - |= {a/sole-edit b/$-(sole-edit ?)} + |= {a=sole-edit b=$-(sole-edit ?)} ^- ? ?. ?=(%mor -.a) (b a) - (lien p.a |=(c/sole-edit ^$(a c))) + (lien p.a |=(c=sole-edit ^$(a c))) -- ++ offset :: calculate offsets |% ++ alnm :: alpha-numeric - |= a/@ ^- ? + |= a=@ ^- ? ?| &((gte a '0') (lte a '9')) &((gte a 'A') (lte a 'Z')) &((gte a 'a') (lte a 'z')) == :: ++ ace :: next whitespace - |= a/(list @) - =| {b/_| i/@ud} + |= a=(list @) + =| {b=_| i=@ud} |- ^- @ud ?~ a i =/ c !=(32 i.a) @@ -1088,8 +1088,8 @@ $(i +(i), a t.a) :: ++ edg :: next word boundary - |= a/(list @) - =| {b/_| i/@ud} + |= a=(list @) + =| {b=_| i=@ud} |- ^- @ud ?~ a i =/ c (alnm i.a) @@ -1098,8 +1098,8 @@ $(i +(i), a t.a) :: ++ wrd :: next or current word - |= a/(list @) - =| i/@ud + |= a=(list @) + =| i=@ud |- ^- @ud ?: |(?=(~ a) (alnm i.a)) i $(i +(i), a t.a) @@ -1109,22 +1109,22 @@ =, dill |% ++ make :: stub from styx - |= a/styx ^- stub - =| b/stye + |= a=styx ^- stub + =| b=stye %+ reel |- ^- stub %- zing %+ turn a - |= a/$@(@t (pair styl styx)) + |= a=$@(@t (pair styl styx)) ?@ a [b (tuba (trip a))]~ ^$(a q.a, b (styd p.a b)) :: - |= {a/(pair stye (list @c)) b/stub} + |= {a=(pair stye (list @c)) b=stub} ?~ b [a ~] ?. =(p.a p.i.b) [a b] [[p.a (weld q.a q.i.b)] t.b] :: ++ styd :: stye from styl - |= {a/styl b/stye} ^+ b :: with inheritance + |= {a=styl b=stye} ^+ b :: with inheritance :+ ?~ p.a p.b ?~ u.p.a ~ (~(put in p.b) u.p.a) @@ -1132,18 +1132,18 @@ (fall q.q.a q.q.b) :: ++ lent-char - |= a/stub ^- @ + |= a=stub ^- @ (roll (lnts-char a) add) :: ++ lnts-char :: stub pair tail lengths - |= a/stub ^- (list @) + |= a=stub ^- (list @) %+ turn a - |= a/(pair stye (list @c)) + |= a=(pair stye (list @c)) (lent q.a) :: ++ brek :: index + incl-len of - |= {a/@ b/(list @)} :: stub pair w/ idx a - =| {c/@ i/@} + |= {a=@ b=(list @)} :: stub pair w= idx a + =| {c=@ i=@} |- ^- (unit (pair @ @)) ?~ b ~ =. c (add c i.b) @@ -1152,7 +1152,7 @@ $(i +(i), b t.b) :: ++ slag :: slag stub, keep stye - |= {a/@ b/stub} + |= {a=@ b=stub} ^- stub =+ c=(lnts-char b) =+ i=(brek a c) @@ -1165,7 +1165,7 @@ (^slag (sub (snag p.u.i c) (sub q.u.i a)) q.n) :: ++ scag :: scag stub, keep stye - |= {a/@ b/stub} + |= {a=@ b=stub} ^- stub =+ c=(lnts-char b) =+ i=(brek a c) @@ -1179,7 +1179,7 @@ (^scag (sub (snag p.u.i c) (sub q.u.i a)) q.n) :: ++ swag :: swag stub, keep stye - |= {{a/@ b/@} c/stub} + |= {{a=@ b=@} c=stub} (scag b (slag a c)) -- -- diff --git a/pkg/arvo/lib/hood/helm.hoon b/pkg/arvo/lib/hood/helm.hoon index 9c80595238..ec75f37f57 100644 --- a/pkg/arvo/lib/hood/helm.hoon +++ b/pkg/arvo/lib/hood/helm.hoon @@ -122,7 +122,7 @@ == :: ++ poke-send-hi - |= {her/ship mes/(unit tape)} =< abet + |= {her=ship mes=(unit tape)} =< abet %- emit :* %pass /helm/hi/(scot %p her) %agent [her %hood] %poke @@ -131,7 +131,7 @@ :: :: ++ poke-hi - |= mes/@t + |= mes=@t ~| %poke-hi-fail ?: =(%fail mes) ~& %poke-hi-fail @@ -139,32 +139,32 @@ abet:(flog %text "< {}: {(trip mes)}") :: ++ poke-atom - |= ato/@ + |= ato=@ =+ len=(scow %ud (met 3 ato)) =+ gum=(scow %p (mug ato)) =< abet (flog %text "< {}: atom: {len} bytes, mug {gum}") :: ++ coup-hi - |= {pax/path cop/(unit tang)} =< abet + |= {pax=path cop=(unit tang)} =< abet ?> ?=({@t ~} pax) (flog %text "hi {(trip i.pax)} {?~(cop "" "un")}successful") :: -++ poke-reload |=(all/(list term) (poke-reload-desk %home all)) +++ poke-reload |=(all=(list term) (poke-reload-desk %home all)) ++ poke-reload-desk :: reload vanes - |: $:{syd/desk all/(list term)} =< abet + |: $:{syd=desk all=(list term)} =< abet %- emil %+ turn all =+ top=`path`/(scot %p our.bowl)/[syd]/(scot %da now.bowl) - =/ van/(list {term ~}) + =/ van=(list {term ~}) :- zus=[%zuse ~] ~(tap by dir:.^(arch %cy (welp top /sys/vane))) - |= nam/@tas + |= nam=@tas =. nam ?. =(1 (met 3 nam)) nam - =/ zaz/(list {p/knot ~}) - (skim van |=({a/term ~} =(nam (end 3 1 a)))) + =/ zaz=(list {p=knot ~}) + (skim van |=({a=term ~} =(nam (end 3 1 a)))) ?> ?=({{@ ~} ~} zaz) `term`p.i.zaz =+ tip=(end 3 1 nam) diff --git a/pkg/arvo/lib/hood/kiln.hoon b/pkg/arvo/lib/hood/kiln.hoon index fc4572cdb3..35efe26c59 100644 --- a/pkg/arvo/lib/hood/kiln.hoon +++ b/pkg/arvo/lib/hood/kiln.hoon @@ -73,7 +73,7 @@ ?~(+< +> $(+< t.+<, +> (emit i.+<))) :: ++ render - |= {mez/tape sud/desk who/ship syd/desk} + |= {mez=tape sud=desk who=ship syd=desk} :^ %palm [" " ~ ~ ~] leaf+(weld "kiln: " mez) ~[leaf+"from {}" leaf+"on {}" leaf+"to {}"] :: @@ -113,7 +113,7 @@ ``noun+!>(ota) :: ++ poke-commit - |= [mon/kiln-commit auto=?] + |= [mon=kiln-commit auto=?] =< abet =. +>.$ (emit %pass /commit %arvo %c [%dirk mon]) ?. auto @@ -124,7 +124,7 @@ (emit %pass way.commit-timer %arvo %b [%wait nex.commit-timer]) :: ++ poke-autocommit - |= [mon/kiln-commit auto=?] + |= [mon=kiln-commit auto=?] =< abet =. +>.$ (emit %pass /commit %arvo %c [%dirk mon]) ?. auto @@ -147,7 +147,7 @@ abet:(emit %pass /mount %arvo %c [%mont pot u.bem]) :: ++ poke-unmount - |= mon/kiln-unmount + |= mon=kiln-unmount ?^ mon =+ bem=(de-beam mon) ?~ bem @@ -157,7 +157,7 @@ abet:(emit %pass /unmount-point %arvo %c [%ogre mon]) :: ++ poke-track :: - |= hos/kiln-sync + |= hos=kiln-sync ?: (~(has by syn) hos) abet:(spam (render "already tracking" [sud her syd]:hos) ~) abet:abet:start-track:(auto hos) @@ -337,7 +337,7 @@ -- :: ++ poke-sync :: - |= hos/kiln-sync + |= hos=kiln-sync ?: (~(has by syn) hos) abet:(spam (render "already syncing" [sud her syd]:hos) ~) abet:abet:start-sync:(auto hos) @@ -361,10 +361,10 @@ ?: =(0 ~(wyt by syn)) [%leaf "no other syncs configured"]~ %+ turn ~(tap in ~(key by syn)) - |=(a/kiln-sync (render "sync configured" [sud her syd]:a)) + |=(a=kiln-sync (render "sync configured" [sud her syd]:a)) :: ++ poke-unsync :: - |= hus/kiln-unsync + |= hus=kiln-unsync ?. (~(has by syn) hus) abet:(spam (render "not syncing" [sud her syd]:hus) ~) %* . abet:abet:stop:(auto hus) @@ -381,13 +381,13 @@ abet:(emit %pass /cancel %arvo %c [%drop a]) :: ++ poke-info - |= {mez/tape tor/(unit toro)} + |= {mez=tape tor=(unit toro)} ?~ tor abet:(spam leaf+mez ~) abet:(emit:(spam leaf+mez ~) %pass /kiln %arvo %c [%info u.tor]) :: ++ poke-rm - |= a/path + |= a=path =+ b=.^(arch %cy a) ?~ fil.b =+ ~[leaf+"No such file:" leaf+"{}"] @@ -395,19 +395,19 @@ (poke-info "removed" `(fray a)) :: ++ poke-label - |= {syd/desk lab/@tas} + |= {syd=desk lab=@tas} =+ pax=/(scot %p our)/[syd]/[lab] (poke-info "labeled {(spud pax)}" `[syd %| lab]) :: ++ poke-schedule - |= {where/path tym/@da eve/@t} + |= {where=path tym=@da eve=@t} =. where (welp where /sched) %+ poke-info "scheduled" =+ old=;;((map @da cord) (fall (file where) ~)) `(foal where %sched !>((~(put by old) tym eve))) :: ++ poke-permission - |= {syd/desk pax/path pub/?} + |= {syd=desk pax=path pub=?} =< abet %- emit =/ =rite [%r ~ ?:(pub %black %white) ~] @@ -447,7 +447,7 @@ abet:(emit %pass /kiln %arvo %g %sear ship) :: ++ done - |= {way/wire saw/(unit error:ames)} + |= {way=wire saw=(unit error:ames)} ~? ?=(^ saw) [%kiln-nack u.saw] abet :: @@ -481,24 +481,24 @@ ?>(?=(%mere +<.sign-arvo) +>.sign-arvo) == == -++ take |=(way/wire ?>(?=({@ ~} way) (work i.way))) :: general handler +++ take |=(way=wire ?>(?=({@ ~} way) (work i.way))) :: general handler ++ take-mere :: - |= {way/wire are/(each (set path) (pair term tang))} + |= {way=wire are=(each (set path) (pair term tang))} abet:abet:(mere:(take way) are) :: ++ take-coup-fancy :: - |= {way/wire saw/(unit tang)} + |= {way=wire saw=(unit tang)} abet:abet:(coup-fancy:(take way) saw) :: ++ take-coup-spam :: - |= {way/wire saw/(unit tang)} + |= {way=wire saw=(unit tang)} ~? ?=(^ saw) [%kiln-spam-lame u.saw] abet :: ++ take-mere-sync :: - |= {way/wire mes/(each (set path) (pair term tang))} + |= {way=wire mes=(each (set path) (pair term tang))} ?> ?=({@ @ @ *} way) - =/ hos/kiln-sync + =/ hos=kiln-sync :* syd=(slav %tas i.way) her=(slav %p i.t.way) sud=(slav %tas i.t.t.way) @@ -508,9 +508,9 @@ abet:abet:(mere:(auto hos) mes) :: ++ take-writ-find-ship :: - |= {way/wire rot/riot} + |= {way=wire rot=riot} ?> ?=({@ @ @ *} way) - =/ hos/kiln-sync + =/ hos=kiln-sync :* syd=(slav %tas i.way) her=(slav %p i.t.way) sud=(slav %tas i.t.t.way) @@ -520,9 +520,9 @@ abet:abet:(take-find-ship:(auto hos) rot) :: ++ take-writ-sync :: - |= {way/wire rot/riot} + |= {way=wire rot=riot} ?> ?=({@ @ @ *} way) - =/ hos/kiln-sync + =/ hos=kiln-sync :* syd=(slav %tas i.way) her=(slav %p i.t.way) sud=(slav %tas i.t.t.way) @@ -546,7 +546,7 @@ :: :: ++ spam - |= mes/(list tank) + |= mes=(list tank) ((slog mes) ..spam) :: ++ auto @@ -557,7 +557,7 @@ ..auto(syn (~(put by syn) [syd her sud] let)) :: ++ blab - |= new/(list card:agent:gall) + |= new=(list card:agent:gall) ^+ +> +>.$(moz (welp new moz)) :: @@ -658,7 +658,7 @@ -- :: ++ work :: state machine - |= syd/desk + |= syd=desk =/ ,per-desk %+ ~(gut by rem) syd =+ *per-desk @@ -668,7 +668,7 @@ ..work(rem (~(put by rem) syd auto gem her sud cas)) :: ++ blab - |= new/(list card:agent:gall) + |= new=(list card:agent:gall) ^+ +> +>.$(moz (welp new moz)) :: @@ -685,7 +685,7 @@ (blab [%pass /kiln/[syd] %arvo %c [%merg syd her sud cas gem]] ~) :: ++ fancy-merge :: send to self - |= {syd/desk her/@p sud/desk gem/?(%auto germ)} + |= {syd=desk her=@p sud=desk gem=?(%auto germ)} ^+ +> =/ =cage [%kiln-merge !>([syd her sud cas gem])] %- blab :_ ~ @@ -694,7 +694,7 @@ ++ spam ::|=(tang ((slog +<) ..spam)) |*(* +>(..work (^spam +<))) ++ merge - |= {her/@p sud/@tas cas/case gim/?(%auto germ)} + |= {her=@p sud=@tas cas=case gim=?(%auto germ)} ^+ +> ?. ?=(%auto gim) perform(auto |, gem gim, her her, cas cas, sud sud) @@ -705,7 +705,7 @@ .(auto &) :: ++ coup-fancy - |= saw/(unit tang) + |= saw=(unit tang) ?~ saw +> =+ :- "failed to set up conflict resolution scratch space" @@ -713,7 +713,7 @@ lose:(spam leaf+-< leaf+-> u.saw) :: ++ mere - |= are/(each (set path) (pair term tang)) + |= are=(each (set path) (pair term tang)) ^+ +> ?: =(%meld gem) ?: ?=(%& -.are) @@ -824,11 +824,11 @@ == :: ++ tape-to-tanks - |= a/tape ^- (list tank) - (scan a (more (just '\0a') (cook |=(a/tape leaf+a) (star prn)))) + |= a=tape ^- (list tank) + (scan a (more (just '\0a') (cook |=(a=tape leaf+a) (star prn)))) :: ++ tanks-if-any - |= {a/tape b/(list path) c/tape} ^- (list tank) + |= {a=tape b=(list path) c=tape} ^- (list tank) ?: =(~ b) ~ (welp (tape-to-tanks "\0a{c}{a}") >b< ~) -- diff --git a/pkg/arvo/lib/invite-json.hoon b/pkg/arvo/lib/invite-json.hoon index 7faac97d06..3d38ca168b 100644 --- a/pkg/arvo/lib/invite-json.hoon +++ b/pkg/arvo/lib/invite-json.hoon @@ -1,7 +1,7 @@ /- *invite-store /+ resource |% -++ slan |=(mod/@tas |=(txt/@ta (need (slaw mod txt)))) +++ slan |=(mod=@tas |=(txt=@ta (need (slaw mod txt)))) :: ++ seri ::: serial =, dejs:format diff --git a/pkg/arvo/lib/jose.hoon b/pkg/arvo/lib/jose.hoon index 200a367d62..d8be0b5484 100644 --- a/pkg/arvo/lib/jose.hoon +++ b/pkg/arvo/lib/jose.hoon @@ -34,7 +34,7 @@ :: :: ++apex:en-json:html ++ apex =, en-json:html - |= {val/json sor/$-(^ ?) rez/tape} + |= {val=json sor=$-(^ ?) rez=tape} ^- tape ?~ val (weld "null" rez) ?- -.val diff --git a/pkg/arvo/lib/language-server/complete.hoon b/pkg/arvo/lib/language-server/complete.hoon index a413203caa..19f95bfc2e 100644 --- a/pkg/arvo/lib/language-server/complete.hoon +++ b/pkg/arvo/lib/language-server/complete.hoon @@ -9,7 +9,7 @@ :: Like +rose except also produces line number :: ++ lily - |* {los/tape sab/rule} + |* {los=tape sab=rule} =+ vex=(sab [[1 1] los]) ?~ q.vex [%| p=p.vex(q (dec q.p.vex))] diff --git a/pkg/arvo/lib/language-server/easy-print.hoon b/pkg/arvo/lib/language-server/easy-print.hoon index f278bf433e..0f523492be 100644 --- a/pkg/arvo/lib/language-server/easy-print.hoon +++ b/pkg/arvo/lib/language-server/easy-print.hoon @@ -1,7 +1,7 @@ :: Fast type printing that's easy on the eyes or your money back :: => |% - ++ cape {p/(map @ud wine) q/wine} + ++ cape {p=(map @ud wine) q=wine} ++ wine $@ $? %noun %path @@ -11,22 +11,22 @@ %wool %yarn == - $% {%mato p/term} - {%gate p/hoon q/type r/wine} - {%core p/(list @ta) q/wine} - {%face p/term q/wine} - {%list p/term q/wine} - {%pear p/term q/@} - {%bcwt p/(list wine)} - {%plot p/(list wine)} - {%stop p/@ud} - {%tree p/term q/wine} - {%unit p/term q/wine} + $% {%mato p=term} + {%gate p=hoon q=type r=wine} + {%core p=(list @ta) q=wine} + {%face p=term q=wine} + {%list p=term q=wine} + {%pear p=term q=@} + {%bcwt p=(list wine)} + {%plot p=(list wine)} + {%stop p=@ud} + {%tree p=term q=wine} + {%unit p=term q=wine} == -- -|_ sut/type +|_ sut=type ++ dash - |= {mil/tape lim/char lam/tape} + |= {mil=tape lim=char lam=tape} ^- tape =/ esc (~(gas in *(set @tD)) lam) :- lim @@ -41,15 +41,15 @@ [i.mil $(mil t.mil)] ['\\' ~(x ne (rsh 2 1 i.mil)) ~(x ne (end 2 1 i.mil)) $(mil t.mil)] :: -++ deal |=(lum/* (dish dole lum)) +++ deal |=(lum=* (dish dole lum)) ++ dial - |= ham/cape + |= ham=cape =+ gid=*(set @ud) =| top-level=? :: don't need circumfix punctuation =< `tank`-:$ |% ++ many - |= haz/(list wine) + |= haz=(list wine) ^- {(list tank) (set @ud)} ?~ haz [~ gid] =^ mor gid $(haz t.haz) @@ -155,12 +155,12 @@ -- :: ++ dish !: - |= {ham/cape lum/*} ^- tank + |= {ham=cape lum=*} ^- tank ~| [%dish-h ?@(q.ham q.ham -.q.ham)] ~| [%lump lum] ~| [%ham ham] %- need - =| gil/(set {@ud *}) + =| gil=(set {@ud *}) |- ^- (unit tank) ?- q.ham %noun @@ -322,7 +322,7 @@ |- ^- (unit (list tank)) ?: =(~ lum) [~ tuk] - ?. ?=({n/* l/* r/*} lum) + ?. ?=({n=* l=* r=*} lum) ~ =+ rol=$(lum r.lum) ?~ rol @@ -344,7 +344,7 @@ == :: ++ doge - |= ham/cape + |= ham=cape =- ?+ woz woz {%list * {%mato %'ta'}} %path {%list * {%mato %'t'}} %wall @@ -403,10 +403,10 @@ =+ gil=*(set type) =+ dex=[p=*(map type @) q=*(map @ wine)] =< [q.p q] - |- ^- {p/{p/(map type @) q/(map @ wine)} q/wine} + |- ^- {p={p=(map type @) q=(map @ wine)} q=wine} =- [p.tez (doge q.p.tez q.tez)] ^= tez - ^- {p/{p/(map type @) q/(map @ wine)} q/wine} + ^- {p={p=(map type @) q=(map @ wine)} q=wine} ?: (~(meet ut sut) -:!>(*type)) [dex %type] ?- sut @@ -428,7 +428,7 @@ [%gate q.n.q.q.n.q.r.q.sut sut(r.p.q %gold) q.dad] =+ yad=$(sut p.sut) :- p.yad - =+ ^= doy ^- {p/(list @ta) q/wine} + =+ ^= doy ^- {p=(list @ta) q=wine} ?: ?=({%core *} q.yad) [p.q.yad q.q.yad] [~ q.yad] @@ -459,7 +459,7 @@ {%fork *} =+ yed=(sort ~(tap in p.sut) aor) =- [p [%bcwt q]] - |- ^- {p/{p/(map type @) q/(map @ wine)} q/(list wine)} + |- ^- {p={p=(map type @) q=(map @ wine)} q=(list wine)} ?~ yed [dex ~] =+ mor=$(yed t.yed) diff --git a/pkg/arvo/lib/old-phon.hoon b/pkg/arvo/lib/old-phon.hoon index fe378856d4..1f6521424e 100644 --- a/pkg/arvo/lib/old-phon.hoon +++ b/pkg/arvo/lib/old-phon.hoon @@ -45,19 +45,19 @@ /lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes' |% ++ ins ::~/ %ins :: parse prefix - |= a/@tas + |= a=@tas =+ b=0 |- ^- (unit @) ?:(=(256 b) ~ ?:(=(a (tos b)) [~ b] $(b +(b)))) ++ ind ::~/ %ind :: parse suffix - |= a/@tas + |= a=@tas =+ b=0 |- ^- (unit @) ?:(=(256 b) ~ ?:(=(a (tod b)) [~ b] $(b +(b)))) ++ tos ::~/ %tos :: fetch prefix - |=(a/@ ?>((lth a 256) (cut 3 [(mul 3 a) 3] sis))) + |=(a=@ ?>((lth a 256) (cut 3 [(mul 3 a) 3] sis))) ++ tod ::~/ %tod :: fetch suffix - |=(a/@ ?>((lth a 256) (cut 3 [(mul 3 a) 3] dex))) + |=(a=@ ?>((lth a 256) (cut 3 [(mul 3 a) 3] dex))) -- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: section 2eL, formatting (path) :: @@ -66,11 +66,11 @@ |% ++ hif (boss 256 ;~(plug tip tiq (easy ~))) ++ huf %+ cook - |=({a/@ b/@} (wred:un ~(zug mu ~(zag mu [a b])))) + |=({a=@ b=@} (wred:un ~(zug mu ~(zag mu [a b])))) ;~(plug hif ;~(pfix hep hif)) ++ hyf (bass 0x1.0000.0000 ;~(plug huf ;~(pfix hep huf) (easy ~))) - ++ tip (sear |=(a/@ (ins:po a)) til) - ++ tiq (sear |=(a/@ (ind:po a)) til) + ++ tip (sear |=(a=@ (ins:po a)) til) + ++ tiq (sear |=(a=@ (ind:po a)) til) ++ til (boss 256 (stun [3 3] low)) -- ++ ag @@ -87,7 +87,7 @@ -- :: ++ mu - |_ {top/@ bot/@} + |_ {top=@ bot=@} ++ zag [p=(end 4 1 (add top bot)) q=bot] ++ zig [p=(end 4 1 (add top (sub 0x1.0000 bot))) q=bot] ++ zug (mix (lsh 4 1 top) bot) @@ -98,7 +98,7 @@ ++ un :: =(x (wred (wren x))) |% ++ wren :: conceal structure - |= pyn/@ ^- @ + |= pyn=@ ^- @ =+ len=(met 3 pyn) ?: =(0 len) 0 @@ -115,7 +115,7 @@ [[1 mog] $(mig mog)] :: ++ wred :: restore structure - |= cry/@ ^- @ + |= cry=@ ^- @ =+ len=(met 3 cry) ?: =(0 len) 0 @@ -131,11 +131,11 @@ =+ mog=(cut 3 [len 1] cry) [[1 :(mix mig (end 3 1 len) (zyrt mog))] $(mig mog)] :: - ++ xafo |=({a/@ b/@} +((mod (add (dec b) a) 255))) - ++ xaro |=({a/@ b/@} +((mod (add (dec b) (sub 255 (mod a 255))) 255))) + ++ xafo |=({a=@ b=@} +((mod (add (dec b) a) 255))) + ++ xaro |=({a=@ b=@} +((mod (add (dec b) (sub 255 (mod a 255))) 255))) :: ++ zaft :: forward 255-sbox - |= a/@D + |= a=@D =+ ^= b 0xcc.75bc.86c8.2fb1.9a42.f0b3.79a0.92ca.21f6.1e41.cde5.fcc0. 7e85.51ae.1005.c72d.1246.07e8.7c64.a914.8d69.d9f4.59c2.8038. @@ -151,7 +151,7 @@ (cut 3 [(dec a) 1] b) :: ++ zart :: reverse 255-sbox - |= a/@D + |= a=@D =+ ^= b 0x68.4f07.ea1c.73c9.75c2.efc8.d559.5125.f621.a7a8.8591.5613. dd52.40eb.65a2.60b7.4bcb.1123.ceb0.1bd6.3c84.2906.b164.19b3. @@ -167,7 +167,7 @@ (cut 3 [(dec a) 1] b) :: ++ zyft :: forward 256-sbox - |= a/@D + |= a=@D =+ ^= b 0xbb49.b71f.b881.b402.17e4.6b86.69b5.1647.115f.dddb.7ca5. 8371.4bd5.19a9.b092.605d.0d9b.e030.a0cc.78ba.5706.4d2d. @@ -184,7 +184,7 @@ (cut 3 [a 1] b) :: ++ zyrt :: reverse 256-sbox - |= a/@D + |= a=@D =+ ^= b 0x9fc8.2753.6e02.8fcf.8b35.2b20.5598.7caa.c9a9.30b0.9b48. 47ce.6371.80f6.407d.00dd.0aa5.ed10.ecb7.0f5a.5c3a.e605. diff --git a/pkg/arvo/lib/pill.hoon b/pkg/arvo/lib/pill.hoon index 917fadeb05..d1425fbc62 100644 --- a/pkg/arvo/lib/pill.hoon +++ b/pkg/arvo/lib/pill.hoon @@ -61,14 +61,14 @@ %. directories |= :: sal: all spurs to load from :: - sal/(list spur) + sal=(list spur) ^- unix-event :: :: hav: all user files :: =; hav ~& user-files+(lent hav) [/c/sync [%into %$ & hav]] - =| hav/mode:clay + =| hav=mode:clay |- ^+ hav ?~ sal ~ =. hav $(sal t.sal) diff --git a/pkg/arvo/lib/pprint.hoon b/pkg/arvo/lib/pprint.hoon index f88f1d7777..ed27f15d77 100644 --- a/pkg/arvo/lib/pprint.hoon +++ b/pkg/arvo/lib/pprint.hoon @@ -157,7 +157,7 @@ limb ?- -.limb %& (axis-to-cord p.limb) - :: {%| p/@ud q/(unit term) ] + :: {%| p=@ud q=(unit term) ] %| (crip (runt [0 p.limb] ?~(q.limb "," (trip u.q.limb)))) == :: diff --git a/pkg/arvo/lib/pretty-file.hoon b/pkg/arvo/lib/pretty-file.hoon index e35ff1f7c8..e5abe9e617 100644 --- a/pkg/arvo/lib/pretty-file.hoon +++ b/pkg/arvo/lib/pretty-file.hoon @@ -7,7 +7,7 @@ =< pretty-file |% ++ pretty-noun - |= pri/* ^- tank + |= pri=* ^- tank ?~ pri leaf+"~" ?@ pri @@ -20,11 +20,11 @@ [| ^$(pri -.pri) ^$(pri +.pri) ~] [+< - +>]:[^$(pri -.pri) $(pri +.pri)] :: -++ vale-cord |=(a/cord `?`(levy (trip a) |=(b/@ |((gte b 32) =(10 b))))) +++ vale-cord |=(a=cord `?`(levy (trip a) |=(b=@ |((gte b 32) =(10 b))))) :: -++ wain-to-tang |=(a/wain (turn a |=(b/cord leaf+(trip b)))) +++ wain-to-tang |=(a=wain (turn a |=(b=cord leaf+(trip b)))) ++ pretty-file - |= fyl/* ^- tang + |= fyl=* ^- tang =+ `(unit wain)`?@(fyl `(to-wain:format fyl) ((soft wain) fyl)) ?^ - (wain-to-tang u) [(pretty-noun fyl)]~ diff --git a/pkg/arvo/lib/primitive-rsa.hoon b/pkg/arvo/lib/primitive-rsa.hoon index 599a9b9fa5..45ae40ff64 100644 --- a/pkg/arvo/lib/primitive-rsa.hoon +++ b/pkg/arvo/lib/primitive-rsa.hoon @@ -39,7 +39,7 @@ =/ e :(con 1 (lsh 0 (dec a) 1) (~(raw og c) a)) :: XX what algorithm is this modular remainder check? :: - ?: ?& (levy b |=(f/@ !=(1 (mod e f)))) + ?: ?& (levy b |=(f=@ !=(1 (mod e f)))) (pram:number e) == e diff --git a/pkg/arvo/lib/ring.hoon b/pkg/arvo/lib/ring.hoon index b51b584186..e1f5949414 100644 --- a/pkg/arvo/lib/ring.hoon +++ b/pkg/arvo/lib/ring.hoon @@ -319,7 +319,7 @@ :: +seed-to-private-key-scalar: keyfile form to scalar we can multiply with :: ++ seed-to-private-key-scalar - |= sk/@I ^- @udscalar + |= sk=@I ^- @udscalar ?: (gth (met 3 sk) 32) !! =+ h=(shal (rsh 0 3 b:ed:crypto) sk) %+ add diff --git a/pkg/arvo/lib/show-dir.hoon b/pkg/arvo/lib/show-dir.hoon index c6812ab58c..32814641a9 100644 --- a/pkg/arvo/lib/show-dir.hoon +++ b/pkg/arvo/lib/show-dir.hoon @@ -3,15 +3,15 @@ :::: /hoon/show-dir/lib :: /? 310 -|= {vane/?(%g %c) pax/path des/(map @t ~)} +|= {vane=?(%g %c) pax=path des=(map @t ~)} ^- tank :+ %rose [" " `~] %+ turn (sort ~(tap by des) aor) -|= {kid/@ta ~} +|= {kid=@ta ~} =+ paf=`path`/[kid] =- :+ %rose ["/" ~ ?:(dir "/" ~)] - (turn paf |=(a/knot leaf+(trip a))) -|- ^- {dir/? paf/path} + (turn paf |=(a=knot leaf+(trip a))) +|- ^- {dir=? paf=path} =+ arf=.^(arch (cat 3 vane %y) (weld pax paf)) ?^ fil.arf [| paf] diff --git a/pkg/arvo/lib/sole.hoon b/pkg/arvo/lib/sole.hoon index 8129e16c07..8abde25676 100644 --- a/pkg/arvo/lib/sole.hoon +++ b/pkg/arvo/lib/sole.hoon @@ -8,7 +8,7 @@ |_ sole-share :: shared-state engine ++ abet +< ++ apply - |= ted/sole-edit + |= ted=sole-edit ^+ +> ?- -.ted %del +>.$(buf (weld (scag p.ted buf) (slag +(p.ted) buf))) @@ -31,7 +31,7 @@ :: (apply:(apply b) y) :: ++ transmute :: dex as after sin - |= {sin/sole-edit dex/sole-edit} + |= {sin=sole-edit dex=sole-edit} ~| [%transmute sin dex] ^- sole-edit ?: ?=(%mor -.sin) @@ -67,7 +67,7 @@ == :: ++ commit :: local change - |= ted/sole-edit + |= ted=sole-edit ^- sole-share abet:(apply(own.ven +(own.ven), leg [ted leg]) ted) :: @@ -79,7 +79,7 @@ :: =(+> (apply:(apply a) (inverse a))) :: ++ inverse :: relative inverse - |= ted/sole-edit + |= ted=sole-edit ^- sole-edit =. ted ?.(?=({%mor * ~} ted) ted i.p.ted) ?- -.ted @@ -110,7 +110,7 @@ [dat abet:(apply(his.ven +(his.ven)) dat)] :: ++ remit :: conditional accept - |= {cal/sole-change ask/$-((list @c) ?)} + |= {cal=sole-change ask=$-((list @c) ?)} ^- {(unit sole-change) sole-share} =+ old=buf =^ dat +>+<.$ (receive cal) @@ -120,7 +120,7 @@ [`lic +>+<.$] :: ++ transmit :: outgoing change - |= ted/sole-edit + |= ted=sole-edit ^- {sole-change sole-share} [[[his.ven own.ven] (sham buf) ted] (commit ted)] :: @@ -132,7 +132,7 @@ [(inverse(buf old) dat) +>+<.$] :: ++ transpose :: adjust position - |= pos/@ud + |= pos=@ud =+ dat=(transmute [%mor leg] [%ins pos `@c`0]) ?> ?=(%ins -.dat) p.dat diff --git a/pkg/arvo/lib/soto.hoon b/pkg/arvo/lib/soto.hoon index f82751169a..6077c6c4f1 100644 --- a/pkg/arvo/lib/soto.hoon +++ b/pkg/arvo/lib/soto.hoon @@ -39,7 +39,7 @@ =, enjs:format ?+ -.sef ~|(unsupported-effect+-.sef !!) - %mor [%a (turn p.sef |=(a/sole-effect ^$(sef a)))] + %mor [%a (turn p.sef |=(a=sole-effect ^$(sef a)))] %err (frond %hop (numb p.sef)) %txt (frond %txt (tape p.sef)) %tan (frond %tan (tape (wush 160 p.sef))) diff --git a/pkg/arvo/lib/test/runner.hoon b/pkg/arvo/lib/test/runner.hoon index 75d6d2d5f6..9156432c9e 100644 --- a/pkg/arvo/lib/test/runner.hoon +++ b/pkg/arvo/lib/test/runner.hoon @@ -31,7 +31,7 @@ `tang`[[%leaf (weld "FAILED " name)] ~] ::TODO indent :: %+ turn p:run - :: |= {i/tape} + :: |= {i=tape} :: ^- tank :: [%leaf (weld " " i)] p.run diff --git a/pkg/arvo/lib/time-to-id.hoon b/pkg/arvo/lib/time-to-id.hoon index 0311b67b2d..ce20406502 100644 --- a/pkg/arvo/lib/time-to-id.hoon +++ b/pkg/arvo/lib/time-to-id.hoon @@ -6,5 +6,5 @@ :: :::: ~fyr :: -|= a/time ^- tape +|= a=time ^- tape ['c' (s-co:co f:(yell a))] diff --git a/pkg/arvo/lib/tree.hoon b/pkg/arvo/lib/tree.hoon index 33226b8089..961db72915 100644 --- a/pkg/arvo/lib/tree.hoon +++ b/pkg/arvo/lib/tree.hoon @@ -5,9 +5,9 @@ :: |% ++ getall :: search in manx - |= tag/(list mane) - |= ele/manx ^- marl - ?: (lien tag |=(a/mane =(a n.g.ele))) + |= tag=(list mane) + |= ele=manx ^- marl + ?: (lien tag |=(a=mane =(a n.g.ele))) ~[ele] (zing (turn c.ele ..$)) :: @@ -19,14 +19,14 @@ |% ++ noun $@(term {noun noun}) :: shadow :: improper list of possible entry points - ++ grove $@(term {gap/@ sealed/noun pending/grove}) + ++ grove $@(term {gap=@ sealed=noun pending=grove}) ++ apex ;~(plug sym (star ;~(plug delim sym))) ++ delim ;~(pose (cold 0 dot) (cook lent (plus cab))) - ++ to-noun |=(a/grove ?@(a a [sealed.a $(a pending.a)])) + ++ to-noun |=(a=grove ?@(a a [sealed.a $(a pending.a)])) ++ build-grove - |= {a/grove b/(list {p/@u q/term})} ^- grove + |= {a=grove b=(list {p=@u q=term})} ^- grove %+ roll b =< .(acc a) - |= {{gap/@u v/term} acc/grove} ^- grove + |= {{gap=@u v=term} acc=grove} ^- grove ?@ acc [gap acc v] ?: (gth gap gap.acc) [gap (to-noun acc) v] acc(pending $(acc pending.acc)) diff --git a/pkg/arvo/lib/urb-split.hoon b/pkg/arvo/lib/urb-split.hoon index c6fae485c9..0163d37a5e 100644 --- a/pkg/arvo/lib/urb-split.hoon +++ b/pkg/arvo/lib/urb-split.hoon @@ -2,9 +2,9 @@ :::: /hoon/urb-split/lib :: /? 310 -|= {dep/@uvH urb/manx} ^- {hed/{@uvh marl} bod/{@uvH marl}} +|= {dep=@uvH urb=manx} ^- {hed={@uvh marl} bod={@uvH marl}} ~| [%malformed-urb urb] :: XX types ?> ?=({{%html ~} {{%head ~} *} {{%body ~} *} ~} urb) -=+ `{{%html ~} {{%head ~} hed/marl} {{%body ~} bod/marl} ~}`urb +=+ `{{%html ~} {{%head ~} hed=marl} {{%body ~} bod=marl} ~}`urb :- [dep hed] :: Assume all dependencies are hard [0v0 bod] diff --git a/pkg/arvo/lib/xray.hoon b/pkg/arvo/lib/xray.hoon index 6c65021013..4f952cfb2b 100644 --- a/pkg/arvo/lib/xray.hoon +++ b/pkg/arvo/lib/xray.hoon @@ -1844,7 +1844,7 @@ ++ synthetic |= number=@ud ^- @tas - =/ alf/(list term) + =/ alf=(list term) ^~ :~ %alf %bet %gim %dal %hej %vav %zay %het %tet %yod %kaf %lam %mem %nun %sam %ayn %pej %sad %qof %res %sin %tav diff --git a/pkg/arvo/mar/atom.hoon b/pkg/arvo/mar/atom.hoon index a8927ee689..4f90046221 100644 --- a/pkg/arvo/mar/atom.hoon +++ b/pkg/arvo/mar/atom.hoon @@ -6,7 +6,7 @@ :::: A minimal atom mark :: =, mimes:html -|_ ato/@ +|_ ato=@ ++ grab |% ++ noun @ ++ mime |=([* p=octs] q.p) diff --git a/pkg/arvo/mar/css.hoon b/pkg/arvo/mar/css.hoon index 39e9bc9450..91e8173ba3 100644 --- a/pkg/arvo/mar/css.hoon +++ b/pkg/arvo/mar/css.hoon @@ -4,7 +4,7 @@ /? 310 =, eyre =, mimes:html -|_ mud/@t +|_ mud=@t ++ grow :: convert to |% ++ mime [/text/css (as-octs mud)] :: convert to %mime ++ elem ;style :: convert to %hymn @@ -14,7 +14,7 @@ -- ++ grab |% :: convert from - ++ mime |=({p/mite q/octs} (@t q.q)) + ++ mime |=({p=mite q=octs} (@t q.q)) ++ noun @t :: clam from %noun -- ++ grad %mime diff --git a/pkg/arvo/mar/dill/belt.hoon b/pkg/arvo/mar/dill/belt.hoon index 1a4c68d32a..de3a8d4ca8 100644 --- a/pkg/arvo/mar/dill/belt.hoon +++ b/pkg/arvo/mar/dill/belt.hoon @@ -18,20 +18,20 @@ |% ++ json =< (cork . kyev) - |= jon/^json ^- ^kyev + |= jon=^json ^- ^kyev !! :: %- need :: %. jon => jo %- ot :: :~ mod+(cu silt (ar (su (perk ~[%ctrl %shift %alt %meta])))) :: :- %key -:: %+ cu |*(a/$%({%str @t} {%act @}) ?+(-.a a %str +.a)) +:: %+ cu |*(a=$%({%str @t} {%act @}) ?+(-.a a %str +.a)) :: =- (of [str+so act+(su (perk -)) ~]) :: :~ %ctrl %shift %alt %meta %entr %esc %caps %uncap :: %pgup %pgdn %home %end %baxp %del %ins :: %up %down %left %right :: == == ++ kyev - |= kev/^kyev ^- dill-belt:dill + |= kev=^kyev ^- dill-belt:dill ~| dill-belt-incomplete+kev ?: ?=({%act ?(%ctrl %shift %alt %meta)} q.kev) [%txt ~] :: ignore diff --git a/pkg/arvo/mar/dill/blit.hoon b/pkg/arvo/mar/dill/blit.hoon index 61b02d43ce..77e5cecf47 100644 --- a/pkg/arvo/mar/dill/blit.hoon +++ b/pkg/arvo/mar/dill/blit.hoon @@ -5,7 +5,7 @@ /- sole =, sole =, enjs:format -|_ dib/dill-blit:dill +|_ dib=dill-blit:dill ++ grad %noun :: ++ grab :: convert from @@ -18,7 +18,7 @@ ++ json ^- ^json ?+ -.dib ~|(unsupported-blit+-.dib !!) - %mor [%a (turn p.dib |=(a/dill-blit:dill json(dib a)))] + %mor [%a (turn p.dib |=(a=dill-blit:dill json(dib a)))] %hop (frond %hop (numb p.dib)) ?(%pro %out) (frond -.dib (tape (tufa p.dib))) ?(%bel %clr) (frond %act %s -.dib) diff --git a/pkg/arvo/mar/elem.hoon b/pkg/arvo/mar/elem.hoon index b8fb3a7fd7..c7533ad908 100644 --- a/pkg/arvo/mar/elem.hoon +++ b/pkg/arvo/mar/elem.hoon @@ -4,7 +4,7 @@ /? 310 =, mimes:html =, html -|_ own/manx +|_ own=manx :: ++ grad %mime ++ grow :: convert to diff --git a/pkg/arvo/mar/front.hoon b/pkg/arvo/mar/front.hoon index c0e61be06b..c3f2edc5c9 100644 --- a/pkg/arvo/mar/front.hoon +++ b/pkg/arvo/mar/front.hoon @@ -5,7 +5,7 @@ :: :::: :: -|_ all/(map knot cord) +|_ all=(map knot cord) :: ++ grad %noun ++ grow :: convert to @@ -14,7 +14,7 @@ ++ json :- %o %- ~(run by all) - |=(a/cord s+a) + |=(a=cord s+a) -- ++ grab |% :: convert from ++ noun (map knot cord) :: clam from %noun diff --git a/pkg/arvo/mar/helm-hi.hoon b/pkg/arvo/mar/helm-hi.hoon index 940c91cfe1..85c617f615 100644 --- a/pkg/arvo/mar/helm-hi.hoon +++ b/pkg/arvo/mar/helm-hi.hoon @@ -4,7 +4,7 @@ /? 310 =, mimes:html =, format -|_ txt/cord +|_ txt=cord :: ++ grad %mime ++ grab :: convert from diff --git a/pkg/arvo/mar/hoon.hoon b/pkg/arvo/mar/hoon.hoon index cd582f8a7b..a1df60fdcc 100644 --- a/pkg/arvo/mar/hoon.hoon +++ b/pkg/arvo/mar/hoon.hoon @@ -3,7 +3,7 @@ /? 310 :: =, eyre -|_ own/@t +|_ own=@t :: ++ grow :: convert to |% @@ -41,7 +41,7 @@ -- ++ grab |% :: convert from - ++ mime |=({p/mite q/octs} q.q) + ++ mime |=({p=mite q=octs} q.q) ++ noun @t :: clam from %noun ++ txt of-wain:format -- diff --git a/pkg/arvo/mar/htm.hoon b/pkg/arvo/mar/htm.hoon index 98f2ab819c..a40a432dd1 100644 --- a/pkg/arvo/mar/htm.hoon +++ b/pkg/arvo/mar/htm.hoon @@ -2,7 +2,7 @@ :::: /hoon/htm/mar :: /? 310 -|_ own/manx +|_ own=manx :: ++ grad %noun ++ grow :: convert to diff --git a/pkg/arvo/mar/html.hoon b/pkg/arvo/mar/html.hoon index c0b7ef0049..0782defad4 100644 --- a/pkg/arvo/mar/html.hoon +++ b/pkg/arvo/mar/html.hoon @@ -7,7 +7,7 @@ :: =, html ^| -|_ htm/@t +|_ htm=@t ++ grow :: convert to ^? |% :: @@ -17,7 +17,7 @@ ++ grab ^? |% :: convert from ++ noun @t :: clam from %noun - ++ mime |=({p/mite q/octs} q.q) :: retrieve form %mime + ++ mime |=({p=mite q=octs} q.q) :: retrieve form %mime -- ++ grad %mime -- diff --git a/pkg/arvo/mar/httr.hoon b/pkg/arvo/mar/httr.hoon index f9ae1fb0a4..bbac8f9907 100644 --- a/pkg/arvo/mar/httr.hoon +++ b/pkg/arvo/mar/httr.hoon @@ -6,7 +6,7 @@ =, eyre =, format =, html -|_ hit/httr +|_ hit=httr ++ grad %noun ++ grow |% ++ wall (turn wain trip) ++ wain (to-wain cord) diff --git a/pkg/arvo/mar/hymn.hoon b/pkg/arvo/mar/hymn.hoon index a56e3a0cf0..d8ad099697 100644 --- a/pkg/arvo/mar/hymn.hoon +++ b/pkg/arvo/mar/hymn.hoon @@ -4,7 +4,7 @@ /? 310 =, mimes:html =, html -|_ own/manx +|_ own=manx :: ++ grad %mime ++ grow :: convert to diff --git a/pkg/arvo/mar/jam.hoon b/pkg/arvo/mar/jam.hoon index a8faf6fbb5..672941f275 100644 --- a/pkg/arvo/mar/jam.hoon +++ b/pkg/arvo/mar/jam.hoon @@ -4,7 +4,7 @@ /? 310 :: =, mimes:html -|_ mud/@ +|_ mud=@ ++ grow |% ++ mime [/application/octet-stream (as-octs mud)] diff --git a/pkg/arvo/mar/js.hoon b/pkg/arvo/mar/js.hoon index 1c997c7ada..3a293b15e4 100644 --- a/pkg/arvo/mar/js.hoon +++ b/pkg/arvo/mar/js.hoon @@ -4,7 +4,7 @@ /? 310 :: =, eyre -|_ mud/@ +|_ mud=@ ++ grow |% ++ mime [/application/javascript (as-octs:mimes:html (@t mud))] @@ -15,7 +15,7 @@ -- ++ grab |% :: convert from - ++ mime |=({p/mite q/octs} (@t q.q)) + ++ mime |=({p=mite q=octs} (@t q.q)) ++ noun cord :: clam from %noun -- ++ grad %mime diff --git a/pkg/arvo/mar/json.hoon b/pkg/arvo/mar/json.hoon index 967b60868d..80d090d12a 100644 --- a/pkg/arvo/mar/json.hoon +++ b/pkg/arvo/mar/json.hoon @@ -8,7 +8,7 @@ =, eyre =, format =, html -|_ jon/json +|_ jon=json :: ++ grow :: convert to |% @@ -17,7 +17,7 @@ -- ++ grab |% :: convert from - ++ mime |=({p/mite q/octs} (fall (rush (@t q.q) apex:de-json) *json)) + ++ mime |=({p=mite q=octs} (fall (rush (@t q.q) apex:de-json) *json)) ++ noun json :: clam from %noun ++ numb numb:enjs ++ time time:enjs diff --git a/pkg/arvo/mar/json/rpc/response.hoon b/pkg/arvo/mar/json/rpc/response.hoon index 8aa1c5a75a..df82433a9d 100644 --- a/pkg/arvo/mar/json/rpc/response.hoon +++ b/pkg/arvo/mar/json/rpc/response.hoon @@ -12,7 +12,7 @@ |% ++ noun response :: from noun ++ httr :: from httr - |= hit/httr:eyre + |= hit=httr:eyre ^- response ~| hit ?: ?=(%2 (div p.hit 100)) diff --git a/pkg/arvo/mar/lens/command.hoon b/pkg/arvo/mar/lens/command.hoon index 3f29fc8336..1e70b360db 100644 --- a/pkg/arvo/mar/lens/command.hoon +++ b/pkg/arvo/mar/lens/command.hoon @@ -1,5 +1,5 @@ /- lens -|_ com/command:lens +|_ com=command:lens ++ grad %noun ++ grow |% @@ -9,7 +9,7 @@ |% ++ noun command:lens ++ json - |= jon/^json + |= jon=^json ^- command:lens ~| jon=jon %- need @@ -22,7 +22,7 @@ |% ++ source ^- $-(^^json (unit source:lens)) - |= jon/^^json + |= jon=^^json =+ tuple=%.(jon (ar source)) ?^ tuple `[%tuple u.tuple] diff --git a/pkg/arvo/mar/map.hoon b/pkg/arvo/mar/map.hoon index 2ef7c206dc..a943ec82dc 100644 --- a/pkg/arvo/mar/map.hoon +++ b/pkg/arvo/mar/map.hoon @@ -4,14 +4,14 @@ /? 310 :: =, eyre -|_ mud/@ +|_ mud=@ ++ grow |% ++ mime [/application/octet-stream (as-octs:mimes:html (@t mud))] -- ++ grab |% :: convert from - ++ mime |=({p/mite q/octs} (@t q.q)) + ++ mime |=({p=mite q=octs} (@t q.q)) ++ noun cord :: clam from %noun -- ++ grad %mime diff --git a/pkg/arvo/mar/md.hoon b/pkg/arvo/mar/md.hoon index ab1629ed42..4f790f8182 100644 --- a/pkg/arvo/mar/md.hoon +++ b/pkg/arvo/mar/md.hoon @@ -5,7 +5,7 @@ :: =, format =, mimes:html -|_ txt/wain +|_ txt=wain :: ++ grab :: convert from |% diff --git a/pkg/arvo/mar/mime.hoon b/pkg/arvo/mar/mime.hoon index f5b1850a00..aca3f53c78 100644 --- a/pkg/arvo/mar/mime.hoon +++ b/pkg/arvo/mar/mime.hoon @@ -4,7 +4,7 @@ /? 310 :: ^| -|_ own/mime +|_ own=mime ++ grow ^? |% @@ -16,7 +16,7 @@ |% +$ noun mime :: clam from %noun ++ tape - |=(a/_"" [/application/x-urb-unknown (as-octt:mimes:html a)]) + |=(a=_"" [/application/x-urb-unknown (as-octt:mimes:html a)]) -- ++ grad ^? diff --git a/pkg/arvo/mar/noun.hoon b/pkg/arvo/mar/noun.hoon index 906ab54329..fb07674981 100644 --- a/pkg/arvo/mar/noun.hoon +++ b/pkg/arvo/mar/noun.hoon @@ -4,7 +4,7 @@ /? 310 !: :::: A minimal noun mark -|_ non/* +|_ non=* ++ grab |% ++ noun * -- diff --git a/pkg/arvo/mar/path.hoon b/pkg/arvo/mar/path.hoon index d3952babb5..2196ba95a5 100644 --- a/pkg/arvo/mar/path.hoon +++ b/pkg/arvo/mar/path.hoon @@ -1,4 +1,4 @@ -|_ pax/path +|_ pax=path ++ grad %noun ++ grow |% diff --git a/pkg/arvo/mar/png.hoon b/pkg/arvo/mar/png.hoon index 4bc5b6b3d9..e891a65716 100644 --- a/pkg/arvo/mar/png.hoon +++ b/pkg/arvo/mar/png.hoon @@ -1,11 +1,11 @@ -|_ dat/@t +|_ dat=@t ++ grow |% ++ mime [/image/png (as-octs:mimes:html dat)] -- ++ grab |% - ++ mime |=({p/mite q/octs} q.q) + ++ mime |=({p=mite q=octs} q.q) ++ noun @t -- ++ grad %mime diff --git a/pkg/arvo/mar/purl.hoon b/pkg/arvo/mar/purl.hoon index 148ef1d742..3fb39fa69d 100644 --- a/pkg/arvo/mar/purl.hoon +++ b/pkg/arvo/mar/purl.hoon @@ -3,7 +3,7 @@ :: /? 310 =, eyre -|_ url/purl +|_ url=purl ++ grad %noun :: ++ grow diff --git a/pkg/arvo/mar/ships.hoon b/pkg/arvo/mar/ships.hoon index affc890b9f..09dd594cc3 100644 --- a/pkg/arvo/mar/ships.hoon +++ b/pkg/arvo/mar/ships.hoon @@ -3,7 +3,7 @@ :: /? 310 =, format -|_ all/(list ship) +|_ all=(list ship) ++ grab |% ++ noun (list ship) ++ json (ar (su fed:ag)):dejs diff --git a/pkg/arvo/mar/snip.hoon b/pkg/arvo/mar/snip.hoon index 1ee006d88b..23ffa186d5 100644 --- a/pkg/arvo/mar/snip.hoon +++ b/pkg/arvo/mar/snip.hoon @@ -6,8 +6,8 @@ |% ++ words 1 ++ hedtal - =| met/marl - |= a/marl ^- {hed/marl tal/marl} + =| met=marl + |= a=marl ^- {hed=marl tal=marl} ?~ a [~ ~] ?. ?=(%h1 n.g.i.a) ?: ?=(%meta n.g.i.a) @@ -18,19 +18,19 @@ [c.i.a (weld (flop met) (limit words t.a))] :: ++ limit - |= {lim/@u mal/marl} + |= {lim=@u mal=marl} =< res - |- ^- {rem/@u res/marl} + |- ^- {rem=@u res=marl} ?~ mal [lim ~] ?~ lim [0 ~] - =/ {lam/@u hed/manx} + =/ {lam=@u hed=manx} ?: ?=(_;/(**) i.mal) [lim ;/(tay)]:(deword lim v.i.a.g.i.mal) [rem ele(c res)]:[ele=i.mal $(mal c.i.mal)] [rem - res]:[hed $(lim lam, mal t.mal)] :: ++ deword - |= {lim/@u tay/tape} ^- {lim/@u tay/tape} + |= {lim=@u tay=tape} ^- {lim=@u tay=tape} ?~ tay [lim tay] ?~ lim [0 ~] =+ wer=(dot 1^1 tay) @@ -42,7 +42,7 @@ :: :: =, mimes:html -|_ {hed/marl tal/marl} +|_ {hed=marl tal=marl} ++ grad %mime :: ++ grow :: convert to @@ -58,5 +58,5 @@ -- ++ grab |% :: convert from ++ noun {marl marl} :: clam from %noun - ++ elem |=(a/manx (hedtal +.a)) + ++ elem |=(a=manx (hedtal +.a)) -- -- diff --git a/pkg/arvo/mar/sole/action.hoon b/pkg/arvo/mar/sole/action.hoon index 58c87cbe74..46ac2fec63 100644 --- a/pkg/arvo/mar/sole/action.hoon +++ b/pkg/arvo/mar/sole/action.hoon @@ -17,22 +17,22 @@ ++ grab :: convert from |% ++ json - |= jon/^json ^- sole-action + |= jon=^json ^- sole-action %- need %. jon => [dejs-soft:format ..sole-action] |^ (ot id+so dat+(fo %ret (of det+change tab+ni ~)) ~) ++ fo - |* {a/term b/fist} - |=(c/json ?.(=([%s a] c) (b c) (some [a ~]))) + |* {a=term b=fist} + |=(c=json ?.(=([%s a] c) (b c) (some [a ~]))) :: ++ ra - |* {a/{term fist} b/fist} - |= c/json %. c + |* {a={term fist} b=fist} + |= c=json %. c ?.(=(%a -.c) b (pe -.a (ar +.a))) :: ++ ke :: callbacks - |* {gar/* sef/(trap fist)} - |= jon/json ^- (unit _gar) + |* {gar=* sef=(trap fist)} + |= jon=json ^- (unit _gar) =- ~! gar ~! (need -) - ((sef) jon) :: diff --git a/pkg/arvo/mar/sole/effect.hoon b/pkg/arvo/mar/sole/effect.hoon index 2fadc36360..bf7e899603 100644 --- a/pkg/arvo/mar/sole/effect.hoon +++ b/pkg/arvo/mar/sole/effect.hoon @@ -12,14 +12,14 @@ =, format |% ++ mar-sole-change :: XX dependency - |_ cha/sole-change + |_ cha=sole-change ++ grow |% ++ json ^- ^json =, enjs =; edi =,(cha (pairs ted+(edi ted) ler+a+~[(numb own.ler) (numb his.ler)] ~)) - |= det/sole-edit + |= det=sole-edit ?- -.det %nop [%s 'nop'] %mor [%a (turn p.det ..$)] @@ -30,18 +30,18 @@ -- -- ++ wush - |= {wid/@u tan/tang} + |= {wid=@u tan=tang} ^- tape - (of-wall (turn (flop tan) |=(a/tank (of-wall (wash 0^wid a))))) + (of-wall (turn (flop tan) |=(a=tank (of-wall (wash 0^wid a))))) :: ++ purge :: discard ++styx style - |= a/styx ^- tape + |= a=styx ^- tape %- zing %+ turn a - |= a/_?>(?=(^ a) i.a) + |= a=_?>(?=(^ a) i.a) ?@(a (trip a) ^$(a q.a)) -- :: -|_ sef/sole-effect +|_ sef=sole-effect :: ++ grad %noun ++ grab :: convert from @@ -56,7 +56,7 @@ ^- ^json ?+ -.sef ~|(unsupported-effect+-.sef !!) - %mor [%a (turn p.sef |=(a/sole-effect json(sef a)))] + %mor [%a (turn p.sef |=(a=sole-effect json(sef a)))] %err (frond %hop (numb p.sef)) %txt (frond %txt (tape p.sef)) %tan (frond %tan (tape (wush 160 p.sef))) diff --git a/pkg/arvo/mar/tang.hoon b/pkg/arvo/mar/tang.hoon index 6847515430..279a4b304d 100644 --- a/pkg/arvo/mar/tang.hoon +++ b/pkg/arvo/mar/tang.hoon @@ -4,7 +4,7 @@ /? 310 :: =, format -|_ tan/(list tank) +|_ tan=(list tank) ++ grad %noun ++ grow |% @@ -12,11 +12,11 @@ ++ elem =- ;pre:code:"{(of-wall -)}" ^- wall %- zing ^- (list wall) - (turn (flop tan) |=(a/tank (wash 0^160 a))) + (turn (flop tan) |=(a=tank (wash 0^160 a))) -- ++ grab :: convert from |% ++ noun (list ^tank) :: clam from %noun - ++ tank |=(a/^tank [a]~) + ++ tank |=(a=^tank [a]~) -- -- diff --git a/pkg/arvo/mar/txt-diff.hoon b/pkg/arvo/mar/txt-diff.hoon index 5471acc16a..2c9a500dcf 100644 --- a/pkg/arvo/mar/txt-diff.hoon +++ b/pkg/arvo/mar/txt-diff.hoon @@ -2,7 +2,7 @@ :::: /hoon/txt-diff/mar :: /? 310 -|_ txt-diff/(urge:clay cord) +|_ txt-diff=(urge:clay cord) :: ++ grad %noun ++ grow diff --git a/pkg/arvo/mar/txt.hoon b/pkg/arvo/mar/txt.hoon index 20ca73547b..b90762dfd0 100644 --- a/pkg/arvo/mar/txt.hoon +++ b/pkg/arvo/mar/txt.hoon @@ -7,7 +7,7 @@ =, differ =, format =, mimes:html -|_ txt/wain +|_ txt=wain :: ++ grab :: convert from |% @@ -24,18 +24,18 @@ |% ++ form %txt-diff ++ diff - |= tyt/wain + |= tyt=wain ^- (urge cord) (lusk txt tyt (loss txt tyt)) :: ++ pact - |= dif/(urge cord) + |= dif=(urge cord) ~| [%pacting dif] ^- wain (lurk txt dif) :: ++ join - |= {ali/(urge cord) bob/(urge cord)} + |= {ali=(urge cord) bob=(urge cord)} ^- (unit (urge cord)) |^ =. ali (clean ali) @@ -49,20 +49,20 @@ %& ?: =(p.i.ali p.i.bob) %+ bind $(ali t.ali, bob t.bob) - |=(cud/(urge cord) [i.ali cud]) + |=(cud=(urge cord) [i.ali cud]) ?: (gth p.i.ali p.i.bob) %+ bind $(p.i.ali (sub p.i.ali p.i.bob), bob t.bob) - |=(cud/(urge cord) [i.bob cud]) + |=(cud=(urge cord) [i.bob cud]) %+ bind $(ali t.ali, p.i.bob (sub p.i.bob p.i.ali)) - |=(cud/(urge cord) [i.ali cud]) + |=(cud=(urge cord) [i.ali cud]) :: %| ?: =(p.i.ali (lent p.i.bob)) %+ bind $(ali t.ali, bob t.bob) - |=(cud/(urge cord) [i.bob cud]) + |=(cud=(urge cord) [i.bob cud]) ?: (gth p.i.ali (lent p.i.bob)) %+ bind $(p.i.ali (sub p.i.ali (lent p.i.bob)), bob t.bob) - |=(cud/(urge cord) [i.bob cud]) + |=(cud=(urge cord) [i.bob cud]) ~ == :: @@ -72,20 +72,20 @@ ?. =(i.ali i.bob) ~ %+ bind $(ali t.ali, bob t.bob) - |=(cud/(urge cord) [i.ali cud]) + |=(cud=(urge cord) [i.ali cud]) :: %& ?: =(p.i.bob (lent p.i.ali)) %+ bind $(ali t.ali, bob t.bob) - |=(cud/(urge cord) [i.ali cud]) + |=(cud=(urge cord) [i.ali cud]) ?: (gth p.i.bob (lent p.i.ali)) %+ bind $(ali t.ali, p.i.bob (sub p.i.bob (lent p.i.ali))) - |=(cud/(urge cord) [i.ali cud]) + |=(cud=(urge cord) [i.ali cud]) ~ == == ++ clean :: clean - |= wig/(urge cord) + |= wig=(urge cord) ^- (urge cord) ?~ wig ~ ?~ t.wig wig @@ -99,8 +99,8 @@ -- :: ++ mash - |= $: {als/ship ald/desk ali/(urge cord)} - {bos/ship bod/desk bob/(urge cord)} + |= $: {als=ship ald=desk ali=(urge cord)} + {bos=ship bod=desk bob=(urge cord)} == ^- (urge cord) |^ @@ -124,7 +124,7 @@ [i.bob $(ali t.ali, bob t.bob)] ?: (gth p.i.ali (lent p.i.bob)) [i.bob $(p.i.ali (sub p.i.ali (lent p.i.bob)), bob t.bob)] - =/ {fic/(unce cord) ali/(urge cord) bob/(urge cord)} + =/ {fic=(unce cord) ali=(urge cord) bob=(urge cord)} (resolve ali bob) [fic $(ali ali, bob bob)] :: ~ :: here, alice is good for a while, but not for the whole @@ -133,7 +133,7 @@ %| ?- -.i.bob %| - =/ {fic/(unce cord) ali/(urge cord) bob/(urge cord)} + =/ {fic=(unce cord) ali=(urge cord) bob=(urge cord)} (resolve ali bob) [fic $(ali ali, bob bob)] :: @@ -142,16 +142,16 @@ [i.ali $(ali t.ali, bob t.bob)] ?: (gth p.i.bob (lent p.i.ali)) [i.ali $(ali t.ali, p.i.bob (sub p.i.bob (lent p.i.ali)))] - =/ {fic/(unce cord) ali/(urge cord) bob/(urge cord)} + =/ {fic=(unce cord) ali=(urge cord) bob=(urge cord)} (resolve ali bob) [fic $(ali ali, bob bob)] == == :: ++ annotate :: annotate conflict - |= $: ali/(list @t) - bob/(list @t) - bas/(list @t) + |= $: ali=(list @t) + bob=(list @t) + bas=(list @t) == ^- (list @t) %- zing @@ -179,7 +179,7 @@ ~ :: ++ clean :: clean - |= wig/(urge cord) + |= wig=(urge cord) ^- (urge cord) ?~ wig ~ ?~ t.wig wig @@ -192,15 +192,15 @@ [i.wig $(wig t.wig)] :: ++ resolve - |= {ali/(urge cord) bob/(urge cord)} - ^- {fic/{%| p/(list cord) q/(list cord)} ali/(urge cord) bob/(urge cord)} + |= {ali=(urge cord) bob=(urge cord)} + ^- {fic={%| p=(list cord) q=(list cord)} ali=(urge cord) bob=(urge cord)} =- [[%| bac (annotate alc boc bac)] ali bob] - |- ^- $: $: bac/(list cord) - alc/(list cord) - boc/(list cord) + |- ^- $: $: bac=(list cord) + alc=(list cord) + boc=(list cord) == - ali/(urge cord) - bob/(urge cord) + ali=(urge cord) + bob=(urge cord) == ?~ ali [[~ ~ ~] ali bob] ?~ bob [[~ ~ ~] ali bob] diff --git a/pkg/arvo/mar/udon.hoon b/pkg/arvo/mar/udon.hoon index 13afb40764..cfd6014ff9 100644 --- a/pkg/arvo/mar/udon.hoon +++ b/pkg/arvo/mar/udon.hoon @@ -3,7 +3,7 @@ :: /+ cram :: -|_ mud/@t +|_ mud=@t ++ grow |% ++ mime [/text/x-unmark (as-octs:mimes:html mud)] diff --git a/pkg/arvo/mar/umd.hoon b/pkg/arvo/mar/umd.hoon index 195ad5489a..268622d411 100644 --- a/pkg/arvo/mar/umd.hoon +++ b/pkg/arvo/mar/umd.hoon @@ -3,7 +3,7 @@ :: /+ cram :: -|_ mud/@t +|_ mud=@t ++ grow |% ++ mime [/text/x-unmark (as-octs:mimes:html mud)] diff --git a/pkg/arvo/mar/urb.hoon b/pkg/arvo/mar/urb.hoon index a579ee01fd..85686ad6ef 100644 --- a/pkg/arvo/mar/urb.hoon +++ b/pkg/arvo/mar/urb.hoon @@ -4,7 +4,7 @@ /? 310 =, mimes:html =, html -|_ own/manx +|_ own=manx :: ++ grad %mime ++ grow :: convert to diff --git a/pkg/arvo/mar/urbit.hoon b/pkg/arvo/mar/urbit.hoon index 9b7bb4e1cc..8d2c3c6587 100644 --- a/pkg/arvo/mar/urbit.hoon +++ b/pkg/arvo/mar/urbit.hoon @@ -4,7 +4,7 @@ /? 310 :::: A minimal urbit mark :: -|_ her/@p +|_ her=@p ++ grab |% ++ noun @p diff --git a/pkg/arvo/mar/xml.hoon b/pkg/arvo/mar/xml.hoon index 70dea7b9c8..cc1b39adab 100644 --- a/pkg/arvo/mar/xml.hoon +++ b/pkg/arvo/mar/xml.hoon @@ -7,7 +7,7 @@ :: =, mimes:html =, html -|_ xml/@t +|_ xml=@t :: ++ grad %mime ++ grow :: convert to @@ -17,5 +17,5 @@ -- :: ++ grab |% :: convert from ++ noun @t :: clam from %noun - ++ mime |=({p/mite q/octs} q.q) :: retrieve form %mime + ++ mime |=({p=mite q=octs} q.q) :: retrieve form %mime -- -- diff --git a/pkg/arvo/sur/kyev.hoon b/pkg/arvo/sur/kyev.hoon index 4d41f85901..22186c73f5 100644 --- a/pkg/arvo/sur/kyev.hoon +++ b/pkg/arvo/sur/kyev.hoon @@ -3,7 +3,7 @@ :::: /hoon/kyev/sur :: /? 310 -=- {p/(set ?(%ctrl %shift %alt %meta)) q/$@(cord {%act speck})} +=- {p=(set ?(%ctrl %shift %alt %meta)) q=$@(cord {%act speck})} ^= speck $? %ctrl %shift %alt %meta %entr %esc %caps %uncap %pgup %pgdn %home %end %baxp %del %ins diff --git a/pkg/arvo/sur/lens.hoon b/pkg/arvo/sur/lens.hoon index 08f3656404..0866797e88 100644 --- a/pkg/arvo/sur/lens.hoon +++ b/pkg/arvo/sur/lens.hoon @@ -1,34 +1,34 @@ ^? |% ++ command - $: source/source - sink/sink + $: source=source + sink=sink == ++ source - $% {%data data/@} - {%dojo command/@t} - {%clay pax/@t} - {%url url/purl:eyre} - {%api api/term command/@t} - {%get-api api/term endpoint/(list @t)} - {%as mar/mark next/source} :: can't be at the - {%hoon code/@t next/source} :: end since they - {%tuple next/(list source)} :: don't bunt well - {%listen-api api/term event/term} - {%export app/@t} - {%import app/@t base64-jam/@t} + $% {%data data=@} + {%dojo command=@t} + {%clay pax=@t} + {%url url=purl:eyre} + {%api api=term command=@t} + {%get-api api=term endpoint=(list @t)} + {%as mar=mark next=source} :: can't be at the + {%hoon code=@t next=source} :: end since they + {%tuple next=(list source)} :: don't bunt well + {%listen-api api=term event=term} + {%export app=@t} + {%import app=@t base64-jam=@t} {%export-all ~} - {%import-all base64-jam/@t} + {%import-all base64-jam=@t} == ++ sink $% {%stdout ~} - {%output-file pax/@t} - {%output-pill pax/@t} - {%output-clay pax/path} - {%url url/purl:eyre} - {%to-api api/term command/@t} - {%send-api api/term endpoint/(list @t)} - {%command command/@t} - {%app app/term} + {%output-file pax=@t} + {%output-pill pax=@t} + {%output-clay pax=path} + {%url url=purl:eyre} + {%to-api api=term command=@t} + {%send-api api=term endpoint=(list @t)} + {%command command=@t} + {%app app=term} == -- diff --git a/pkg/arvo/sur/sole.hoon b/pkg/arvo/sur/sole.hoon index 67a8f2c746..733b55bbfe 100644 --- a/pkg/arvo/sur/sole.hoon +++ b/pkg/arvo/sur/sole.hoon @@ -10,68 +10,68 @@ {%det sole-change} :: command line edit {%ret ~} :: submit and clear {%clr ~} :: exit context - {%tab pos/@ud} :: tab complete + {%tab pos=@ud} :: tab complete == :: == ++ sole-buffer (list @c) :: command state ++ sole-change :: network change - $: ler/sole-clock :: destination clock - haw/@uvH :: source hash - ted/sole-edit :: state change + $: ler=sole-clock :: destination clock + haw=@uvH :: source hash + ted=sole-edit :: state change == :: -++ sole-clock {own/@ud his/@ud} :: vector clock +++ sole-clock {own=@ud his=@ud} :: vector clock ++ sole-edit :: shared state change - $% {%del p/@ud} :: delete one at - {%ins p/@ud q/@c} :: insert at - {%mor p/(list sole-edit)} :: combination + $% {%del p=@ud} :: delete one at + {%ins p=@ud q=@c} :: insert at + {%mor p=(list sole-edit)} :: combination {%nop ~} :: no-op - {%set p/sole-buffer} :: discontinuity + {%set p=sole-buffer} :: discontinuity == :: ++ sole-effect :: app to sole $% {%bel ~} :: beep - {%blk p/@ud q/@c} :: blink+match char at + {%blk p=@ud q=@c} :: blink+match char at {%clr ~} :: clear screen {%det sole-change} :: edit command - {%err p/@ud} :: error point - {%klr p/styx} :: styled text line - {%mor p/(list sole-effect)} :: multiple effects + {%err p=@ud} :: error point + {%klr p=styx} :: styled text line + {%mor p=(list sole-effect)} :: multiple effects {%nex ~} :: save clear command {%pro sole-prompt} :: set prompt - {%sag p/path q/*} :: save to jamfile - {%sav p/path q/@} :: save to file - {%tab p/(list {=cord =tank})} :: tab-complete list - {%tan p/(list tank)} :: classic tank - :: {%taq p/tanq} :: modern tank - {%txt p/tape} :: text line - {%url p/@t} :: activate url + {%sag p=path q=*} :: save to jamfile + {%sav p=path q=@} :: save to file + {%tab p=(list {=cord =tank})} :: tab-complete list + {%tan p=(list tank)} :: classic tank + :: {%taq p=tanq} :: modern tank + {%txt p=tape} :: text line + {%url p=@t} :: activate url == :: ++ sole-command :: command state - $: pos/@ud :: cursor position - say/sole-share :: cursor + $: pos=@ud :: cursor position + say=sole-share :: cursor == :: ++ sole-prompt :: prompt definition - $: vis/? :: command visible - tag/term :: history mode - cad/styx :: caption + $: vis=? :: command visible + tag=term :: history mode + cad=styx :: caption == :: ++ sole-share :: symmetric state - $: ven/sole-clock :: our vector clock - leg/(list sole-edit) :: unmerged edits - buf/sole-buffer :: sole state + $: ven=sole-clock :: our vector clock + leg=(list sole-edit) :: unmerged edits + buf=sole-buffer :: sole state == :: :: :: :: :: ++ sole-dialog :: standard dialog - |* out/$-(* *) :: output structure + |* out=$-(* *) :: output structure $-(sole-input (sole-result out)) :: output function :: :: ++ sole-input tape :: prompt input ++ sole-result :: conditional result - |* out/$-(* *) :: output structure + |* out=$-(* *) :: output structure $@(@ud (sole-product out)) :: error position :: :: ++ sole-product :: success result - |* out/$-(* *) :: + |* out=$-(* *) :: %+ pair (list tank) :: %+ each (unit out) :: ~ is abort (pair sole-prompt (sole-dialog out)) :: ask and continue @@ -82,7 +82,7 @@ == :: ++ sole-args :: generator arguments |* _[* *] :: - {{now/@da eny/@uvJ bek/beak} {,+<- ,+<+}} :: + {{now=@da eny=@uvJ bek=beak} {,+<- ,+<+}} :: :: :: :: :: -- diff --git a/pkg/arvo/sur/urb.hoon b/pkg/arvo/sur/urb.hoon index 67d20129fb..dfd87e1c39 100644 --- a/pkg/arvo/sur/urb.hoon +++ b/pkg/arvo/sur/urb.hoon @@ -2,4 +2,4 @@ :: :::: /hoon/urb/sur :: -{hed/{dep/@uvH ele/marl} bod/{dep/@uvH ele/marl}} +{hed={dep=@uvH ele=marl} bod={dep=@uvH ele=marl}} diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index a1724271de..d5cdce34ab 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -341,9 +341,9 @@ :: !: ~/ %sloy - |= sod/slyd + |= sod=slyd ^- slyt - |= {ref/* raw/*} + |= {ref=* raw=*} =+ pux=((soft path) raw) ?~ pux ~ ?. ?=({@ @ @ @ *} u.pux) ~ @@ -385,7 +385,7 @@ :: ++ sloy-light ~/ %sloy-light - |= sod/slyd + |= sod=slyd |= [ref=* ron=@tas fal=@p dyc=@tas ved=case tyl=path] =/ bed=beam [[fal dyc ved] tyl] =/ bop=(unit (unit (cask meta))) @@ -1435,9 +1435,9 @@ |. ;;(^ (slum lod heir)) :: ++ viol :: vane tools - |= but/type + |= but=type ^- vile - =+ pal=|=(a/@t ^-(type (~(play ut but) (vice a)))) + =+ pal=|=(a=@t ^-(type (~(play ut but) (vice a)))) :* typ=(pal '$:type') duc=(pal '$:duct') wir=(pal '$:wire') diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index a116076ec6..4b56f5cd1f 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -233,28 +233,28 @@ :::: 2n: functional hacks :: :: :: :: -++ aftr |*(a/$-(* *) |*(b/$-(* *) (pair b a))) :: pair after -++ cork |*({a/$-(* *) b/$-(* *)} (corl b a)) :: compose forward +++ aftr |*(a=$-(* *) |*(b=$-(* *) (pair b a))) :: pair after +++ cork |*({a=$-(* *) b=$-(* *)} (corl b a)) :: compose forward ++ corl :: compose backwards - |* {a/$-(* *) b/$-(* *)} + |* {a=$-(* *) b=$-(* *)} =< +:|.((a (b))) :: type check =+ c=+<.b |@ ++ $ (a (b c)) -- :: ++ cury :: curry left - |* {a/$-(^ *) b/*} + |* {a=$-(^ *) b=*} =+ c=+<+.a |@ ++ $ (a b c) -- :: ++ curr :: curry right - |* {a/$-(^ *) c/*} + |* {a=$-(^ *) c=*} =+ b=+<+.a |@ ++ $ (a b c) -- :: -++ fore |*(a/$-(* *) |*(b/$-(* *) (pair a b))) :: pair before +++ fore |*(a=$-(* *) |*(b=$-(* *) (pair a b))) :: pair before :: ++ head |*(^ ,:+<-) :: get head ++ same |*(* +<) :: identity @@ -318,7 +318,7 @@ :: :: mold generator: produces a mold of a null-terminated list of the :: homogeneous type {a} with at least one element. - [i/item t/(list item)] + [i=item t=(list item)] :: ++ mold :: normalizing gate @@ -430,51 +430,51 @@ :: fall, flit, lift, mate, need, some :: :: ++ biff :: apply - |* {a/(unit) b/$-(* (unit))} + |* {a=(unit) b=$-(* (unit))} ?~ a ~ (b u.a) :: ++ bind :: argue - |* {a/(unit) b/gate} + |* {a=(unit) b=gate} ?~ a ~ [~ u=(b u.a)] :: ++ bond :: replace - |* a/(trap) - |* b/(unit) + |* a=(trap) + |* b=(unit) ?~ b $:a u.b :: ++ both :: all the above - |* {a/(unit) b/(unit)} + |* {a=(unit) b=(unit)} ?~ a ~ ?~ b ~ [~ u=[u.a u.b]] :: ++ clap :: combine - |* {a/(unit) b/(unit) c/_=>(~ |=(^ +<-))} + |* {a=(unit) b=(unit) c=_=>(~ |=(^ +<-))} ?~ a b ?~ b a [~ u=(c u.a u.b)] :: ++ clef :: compose - |* {a/(unit) b/(unit) c/_=>(~ |=(^ `+<-))} + |* {a=(unit) b=(unit) c=_=>(~ |=(^ `+<-))} ?~ a ~ ?~ b ~ (c u.a u.b) :: ++ drop :: enlist - |* a/(unit) + |* a=(unit) ?~ a ~ [i=u.a t=~] :: ++ fall :: default - |* {a/(unit) b/*} + |* {a=(unit) b=*} ?~(a b u.a) :: ++ flit :: make filter - |* a/$-(* ?) - |* b/* + |* a=$-(* ?) + |* b=* ?.((a b) ~ [~ u=b]) :: ++ hunt :: first of units @@ -488,24 +488,24 @@ ?:((ord u.a u.b) a b) :: ++ lift :: lift mold (fmap) - |* a/mold :: flipped - |* b/(unit) :: curried + |* a=mold :: flipped + |* b=(unit) :: curried (bind b a) :: bind :: ++ mate :: choose - |* {a/(unit) b/(unit)} + |* {a=(unit) b=(unit)} ?~ b a ?~ a b ?.(=(u.a u.b) ~>(%mean.'mate' !!) a) :: ++ need :: demand ~/ %need - |* a/(unit) + |* a=(unit) ?~ a ~>(%mean.'need' !!) u.a :: ++ some :: lift (pure) - |* a/* + |* a=* [~ u=a] :: :::: 2b: list logic :: @@ -515,14 +515,14 @@ :: +snoc: append an element to the end of a list :: ++ snoc - |* [a/(list) b/*] + |* [a=(list) b=*] (weld a ^+(a [b]~)) :: ++ fand :: all indices ~/ %fand - |= {nedl/(list) hstk/(list)} - =| i/@ud - =| fnd/(list @ud) + |= {nedl=(list) hstk=(list)} + =| i=@ud + =| fnd=(list @ud) |- ^+ fnd =+ [n=nedl h=hstk] |- @@ -536,8 +536,8 @@ :: ++ find :: first index ~/ %find - |= {nedl/(list) hstk/(list)} - =| i/@ud + |= {nedl=(list) hstk=(list)} + =| i=@ud |- ^- (unit @ud) =+ [n=nedl h=hstk] |- @@ -551,7 +551,7 @@ :: ++ flop :: reverse ~/ %flop - |* a/(list) + |* a=(list) => .(a (homo a)) ^+ a =+ b=`_a`~ @@ -560,13 +560,13 @@ $(a t.a, b [i.a b]) :: ++ gulf :: range inclusive - |= {a/@ b/@} + |= {a=@ b=@} ?> (lte a b) |- ^- (list @) ?:(=(a +(b)) ~ [a $(a +(a))]) :: ++ homo :: homogenize - |* a/(list) + |* a=(list) ^+ =< $ |@ ++ $ ?:(*? ~ [i=(snag 0 a) t=$]) -- @@ -592,7 +592,7 @@ :: ++ lent :: length ~/ %lent - |= a/(list) + |= a=(list) ^- @ =+ b=0 |- @@ -601,7 +601,7 @@ :: ++ levy ~/ %levy :: all of - |* {a/(list) b/$-(* ?)} + |* {a=(list) b=$-(* ?)} |- ^- ? ?~ a & ?. (b i.a) | @@ -609,14 +609,14 @@ :: ++ lien :: some of ~/ %lien - |* {a/(list) b/$-(* ?)} + |* {a=(list) b=$-(* ?)} |- ^- ? ?~ a | ?: (b i.a) & $(a t.a) :: ++ limo :: listify - |* a/* + |* a=* ^+ =< $ |@ ++ $ ?~(a ~ ?:(*? [i=-.a t=$] $(a +.a))) -- @@ -624,7 +624,7 @@ :: ++ murn :: maybe transform ~/ %murn - |* {a/(list) b/$-(* (unit))} + |* {a=(list) b=$-(* (unit))} => .(a (homo a)) |- ^- (list _?>(?=(^ a) (need (b i.a)))) ?~ a ~ @@ -634,12 +634,12 @@ :: ++ oust :: remove ~/ %oust - |* {{a/@ b/@} c/(list)} + |* {{a=@ b=@} c=(list)} (weld (scag +<-< c) (slag (add +<-< +<->) c)) :: ++ reap :: replicate ~/ %reap - |* {a/@ b/*} + |* {a=@ b=*} |- ^- (list _b) ?~ a ~ [b $(a (dec a))] @@ -654,7 +654,7 @@ :: ++ reel :: right fold ~/ %reel - |* {a/(list) b/_=>(~ |=({* *} +<+))} + |* {a=(list) b=_=>(~ |=({* *} +<+))} |- ^+ ,.+<+.b ?~ a +<+.b @@ -662,7 +662,7 @@ :: ++ roll :: left fold ~/ %roll - |* {a/(list) b/_=>(~ |=({* *} +<+))} + |* {a=(list) b=_=>(~ |=({* *} +<+))} |- ^+ ,.+<+.b ?~ a +<+.b @@ -670,14 +670,14 @@ :: ++ scag :: prefix ~/ %scag - |* {a/@ b/(list)} + |* {a=@ b=(list)} |- ^+ b ?: |(?=(~ b) =(0 a)) ~ [i.b $(b t.b, a (dec a))] :: ++ skid :: separate ~/ %skid - |* {a/(list) b/$-(* ?)} + |* {a=(list) b=$-(* ?)} |- ^+ [p=a q=a] ?~ a [~ ~] =+ c=$(a t.a) @@ -685,7 +685,7 @@ :: ++ skim :: only ~/ %skim - |* {a/(list) b/$-(* ?)} + |* {a=(list) b=$-(* ?)} |- ^+ a ?~ a ~ @@ -693,7 +693,7 @@ :: ++ skip :: except ~/ %skip - |* {a/(list) b/$-(* ?)} + |* {a=(list) b=$-(* ?)} |- ^+ a ?~ a ~ @@ -701,7 +701,7 @@ :: ++ slag :: suffix ~/ %slag - |* {a/@ b/(list)} + |* {a=@ b=(list)} |- ^+ b ?: =(0 a) b ?~ b ~ @@ -709,7 +709,7 @@ :: ++ snag :: index ~/ %snag - |* {a/@ b/(list)} + |* {a=@ b=(list)} |- ^+ ?>(?=(^ b) i.b) ?~ b ~_ leaf+"snag-fail" @@ -727,7 +727,7 @@ :: ++ sort !. :: quicksort ~/ %sort - |* {a/(list) b/$-({* *} ?)} + |* {a=(list) b=$-({* *} ?)} => .(a ^.(homo a)) |- ^+ a ?~ a ~ @@ -763,7 +763,7 @@ p:(spin a +<+.b b) :: ++ swag :: slice - |* {{a/@ b/@} c/(list)} + |* {{a=@ b=@} c=(list)} (scag +<-> (slag +<-< c)) :: +turn: transform each value of list :a using the function :b :: @@ -778,7 +778,7 @@ :: ++ weld :: concatenate ~/ %weld - |* {a/(list) b/(list)} + |* {a=(list) b=(list)} => .(a ^.(homo a), b ^.(homo b)) |- ^+ b ?~ a b @@ -821,35 +821,35 @@ :: ++ bex :: binary exponent ~/ %bex - |= a/@ + |= a=@ ^- @ ?: =(0 a) 1 (mul 2 $(a (dec a))) :: ++ can :: assemble ~/ %can - |= {a/bloq b/(list {p/@u q/@})} + |= {a=bloq b=(list {p=@u q=@})} ^- @ ?~ b 0 (add (end a p.i.b q.i.b) (lsh a p.i.b $(b t.b))) :: ++ cat :: concatenate ~/ %cat - |= {a/bloq b/@ c/@} + |= {a=bloq b=@ c=@} (add (lsh a (met a b) c) b) :: ++ cut :: slice ~/ %cut - |= {a/bloq {b/@u c/@u} d/@} + |= {a=bloq {b=@u c=@u} d=@} (end a c (rsh a b d)) :: ++ end :: tail ~/ %end - |= {a/bloq b/@u c/@} + |= {a=bloq b=@u c=@} (mod c (bex (mul (bex a) b))) :: ++ fil :: fill bloqstream - |= {a/bloq b/@u c/@} + |= {a=bloq b=@u c=@} =+ n=0 =+ d=c |- ^- @ @@ -859,12 +859,12 @@ :: ++ lsh :: left-shift ~/ %lsh - |= {a/bloq b/@u c/@} + |= {a=bloq b=@u c=@} (mul (bex (mul (bex a) b)) c) :: ++ met :: measure ~/ %met - |= {a/bloq b/@} + |= {a=bloq b=@} ^- @ =+ c=0 |- @@ -873,7 +873,7 @@ :: ++ rap :: assemble nonzero ~/ %rap - |= {a/bloq b/(list @)} + |= {a=bloq b=(list @)} ^- @ =+ ~ ::REMOVEME jet dashboard bump ?~ b 0 @@ -881,7 +881,7 @@ :: ++ rep :: assemble single ~/ %rep - |= {a/bloq b/(list @)} + |= {a=bloq b=(list @)} ^- @ =+ c=0 |- @@ -928,26 +928,26 @@ :: ++ rsh :: right-shift ~/ %rsh - |= {a/bloq b/@u c/@} + |= {a=bloq b=@u c=@} (div c (bex (mul (bex a) b))) :: ++ swp :: naive rev bloq order ~/ %swp - |= {a/bloq b/@} + |= {a=bloq b=@} (rep a (flop (rip a b))) :: ++ xeb :: binary logarithm ~/ %xeb - |= a/@ + |= a=@ ^- @ (met 0 a) :: ++ fe :: modulo bloq - |_ a/bloq + |_ a=bloq ++ dif :: difference - |=({b/@ c/@} (sit (sub (add out (sit b)) (sit c)))) - ++ inv |=(b/@ (sub (dec out) (sit b))) :: inverse - ++ net |= b/@ ^- @ :: flip byte endianness + |=({b=@ c=@} (sit (sub (add out (sit b)) (sit c)))) + ++ inv |=(b=@ (sub (dec out) (sit b))) :: inverse + ++ net |= b=@ ^- @ :: flip byte endianness => .(b (sit b)) ?: (lte a 3) b @@ -956,18 +956,18 @@ (lsh c 1 $(a c, b (cut c [0 1] b))) $(a c, b (cut c [1 1] b)) ++ out (bex (bex a)) :: mod value - ++ rol |= {b/bloq c/@ d/@} ^- @ :: roll left + ++ rol |= {b=bloq c=@ d=@} ^- @ :: roll left =+ e=(sit d) =+ f=(bex (sub a b)) =+ g=(mod c f) (sit (con (lsh b g e) (rsh b (sub f g) e))) - ++ ror |= {b/bloq c/@ d/@} ^- @ :: roll right + ++ ror |= {b=bloq c=@ d=@} ^- @ :: roll right =+ e=(sit d) =+ f=(bex (sub a b)) =+ g=(mod c f) (sit (con (rsh b g e) (lsh b (sub f g) e))) - ++ sum |=({b/@ c/@} (sit (add b c))) :: wrapping add - ++ sit |=(b/@ (end a 1 b)) :: enforce modulo + ++ sum |=({b=@ c=@} (sit (add b c))) :: wrapping add + ++ sit |=(b=@ (end a 1 b)) :: enforce modulo -- :: :: :::: 2d: bit logic :: @@ -975,7 +975,7 @@ :: ++ con :: binary or ~/ %con - |= {a/@ b/@} + |= {a=@ b=@} =+ [c=0 d=0] |- ^- @ ?: ?&(=(0 a) =(0 b)) d @@ -992,8 +992,8 @@ :: ++ dis :: binary and ~/ %dis - |= {a/@ b/@} - =| {c/@ d/@} + |= {a=@ b=@} + =| {c=@ d=@} |- ^- @ ?: ?|(=(0 a) =(0 b)) d %= $ @@ -1009,7 +1009,7 @@ :: ++ mix :: binary xor ~/ %mix - |= {a/@ b/@} + |= {a=@ b=@} ^- @ =+ [c=0 d=0] |- @@ -1021,7 +1021,7 @@ d (add d (lsh 0 c =((end 0 1 a) (end 0 1 b)))) == :: -++ not |= {a/bloq b/@ c/@} :: binary not (sized) +++ not |= {a=bloq b=@ c=@} :: binary not (sized) (mix c (dec (bex (mul b (bex a))))) :: :: :::: 2e: insecure hashing :: @@ -1076,7 +1076,7 @@ =. h1 (mix h1 len) |^ (fmix32 h1) ++ fmix32 - |= h/@ + |= h=@ =. h (mix h (rsh 0 16 h)) =. h (sit (mul h 0x85eb.ca6b)) =. h (mix h (rsh 0 13 h)) @@ -1113,7 +1113,7 @@ :: ++ aor ~/ %aor - |= {a/* b/*} + |= {a=* b=*} ^- ? ?: =(a b) & ?. ?=(@ a) @@ -1133,7 +1133,7 @@ :: ++ dor ~/ %dor - |= {a/* b/*} + |= {a=* b=*} ^- ? ?: =(a b) & ?. ?=(@ a) @@ -1149,7 +1149,7 @@ :: ++ gor ~/ %gor - |= {a/* b/*} + |= {a=* b=*} ^- ? =+ [c=(mug a) d=(mug b)] ?: =(c d) @@ -1161,7 +1161,7 @@ :: ++ mor ~/ %mor - |= {a/* b/*} + |= {a=* b=*} ^- ? =+ [c=(mug (mug a)) d=(mug (mug b))] ?: =(c d) @@ -1174,7 +1174,7 @@ :: ++ pow :: unsigned exponent ~/ %pow - |= {a/@ b/@} + |= {a=@ b=@} ?: =(b 0) 1 |- ?: =(b 1) a =+ c=$(b (div b 2)) @@ -1183,7 +1183,7 @@ :: ++ sqt :: unsigned sqrt/rem ~/ %sqt - |= a/@ ^- {p/@ q/@} + |= a=@ ^- {p=@ q=@} ?~ a [0 0] =+ [q=(div (dec (xeb a)) 2) r=0] =- [-.b (sub a +.b)] @@ -1203,11 +1203,11 @@ :: ++ in :: set engine ~/ %in - =| a/(tree) :: (set) + =| a=(tree) :: (set) |@ ++ all :: logical AND ~/ %all - |* b/$-(* ?) + |* b=$-(* ?) |- ^- ? ?~ a & @@ -1215,7 +1215,7 @@ :: ++ any :: logical OR ~/ %any - |* b/$-(* ?) + |* b=$-(* ?) |- ^- ? ?~ a | @@ -1224,7 +1224,7 @@ ++ apt :: check correctness =< $ ~/ %apt - =| {l/(unit) r/(unit)} + =| {l=(unit) r=(unit)} |. ^- ? ?~ a & ?& ?~(l & (gor n.a u.l)) @@ -1235,7 +1235,7 @@ :: ++ bif :: splits a by b ~/ %bif - |* b/* + |* b=* ^+ [l=a r=a] =< + |- ^+ a @@ -1253,7 +1253,7 @@ :: ++ del :: b without any a ~/ %del - |* b/* + |* b=* |- ^+ a ?~ a ~ @@ -1289,7 +1289,7 @@ -- :: ++ dig :: axis of a in b - |= b/* + |= b=* =+ c=1 |- ^- (unit @) ?~ a ~ @@ -1300,7 +1300,7 @@ :: ++ gas :: concatenate ~/ %gas - |= b/(list _?>(?=(^ a) n.a)) + |= b=(list _?>(?=(^ a) n.a)) |- ^+ a ?~ b a @@ -1355,7 +1355,7 @@ :: ++ put :: puts b in a, sorted ~/ %put - |* b/* + |* b=* |- ^+ a ?~ a [b ~ ~] @@ -1375,14 +1375,14 @@ :: ++ rep :: reduce to product ~/ %rep - |* b/_=>(~ |=({* *} +<+)) + |* b=_=>(~ |=({* *} +<+)) |- ?~ a +<+.b $(a r.a, +<+.b $(a l.a, +<+.b (b n.a +<+.b))) :: ++ run :: apply gate to values ~/ %run - |* b/gate + |* b=gate =+ c=`(set _?>(?=(^ a) (b n.a)))`~ |- ?~ a c =. c (~(put in c) (b n.a)) @@ -1432,12 +1432,12 @@ :: ++ by :: map engine ~/ %by - =| a/(tree (pair)) :: (map) + =| a=(tree (pair)) :: (map) =* node ?>(?=(^ a) n.a) |@ ++ all :: logical AND ~/ %all - |* b/$-(* ?) + |* b=$-(* ?) |- ^- ? ?~ a & @@ -1445,7 +1445,7 @@ :: ++ any :: logical OR ~/ %any - |* b/$-(* ?) + |* b=$-(* ?) |- ^- ? ?~ a | @@ -1453,7 +1453,7 @@ :: ++ bif :: splits a by b ~/ %bif - |* {b/* c/*} + |* {b=* c=*} ^+ [l=a r=a] =< + |- ^+ a @@ -1473,7 +1473,7 @@ :: ++ del :: delete at key b ~/ %del - |* b/* + |* b=* |- ^+ a ?~ a ~ @@ -1509,7 +1509,7 @@ -- :: ++ dig :: axis of b key - |= b/* + |= b=* =+ c=1 |- ^- (unit @) ?~ a ~ @@ -1521,7 +1521,7 @@ ++ apt :: check correctness =< $ ~/ %apt - =| {l/(unit) r/(unit)} + =| {l=(unit) r=(unit)} |. ^- ? ?~ a & ?& ?~(l & &((gor p.n.a u.l) !=(p.n.a u.l))) @@ -1534,7 +1534,7 @@ :: ++ gas :: concatenate ~/ %gas - |* b/(list {p/* q/*}) + |* b=(list {p=* q=*}) => .(b `(list _?>(?=(^ a) n.a))`b) |- ^+ a ?~ b @@ -1555,7 +1555,7 @@ $(a r.a) :: ++ got :: need value by key - |* b/* + |* b=* (need (get b)) :: ++ gut :: fall value by key @@ -1564,7 +1564,7 @@ :: ++ has :: key existence check ~/ %has - |* b/* + |* b=* !=(~ (get b)) :: ++ int :: intersection @@ -1606,14 +1606,14 @@ a(r $(a r.a)) :: ++ mar :: add with validation - |* {b/* c/(unit *)} + |* {b=* c=(unit *)} ?~ c (del b) (put b u.c) :: ++ put :: adds key-value pair ~/ %put - |* {b/* c/*} + |* {b=* c=*} |- ^+ a ?~ a [[b c] ~ ~] @@ -1635,13 +1635,13 @@ :: ++ rep :: reduce to product ~/ %rep - |* b/_=>(~ |=({* *} +<+)) + |* b=_=>(~ |=({* *} +<+)) |- ?~ a +<+.b $(a r.a, +<+.b $(a l.a, +<+.b (b n.a +<+.b))) :: ++ rib :: transform + product - |* {b/* c/gate} + |* {b=* c=gate} |- ^+ [b a] ?~ a [b ~] =+ d=(c n.a b) @@ -1652,13 +1652,13 @@ :: ++ run :: apply gate to values ~/ %run - |* b/gate + |* b=gate |- ?~ a a [n=[p=p.n.a q=(b q.n.a)] l=$(a l.a) r=$(a r.a)] :: ++ rut :: apply gate to nodes - |* b/gate + |* b=gate |- ?~ a a [n=[p=p.n.a q=(b p.n.a q.n.a)] l=$(a l.a) r=$(a r.a)] @@ -1697,7 +1697,7 @@ =+ b=a |@ ++ $ - |= meg/$-({_p:node _q:node _q:node} _q:node) + |= meg=$-({_p:node _q:node _q:node} _q:node) |- ^+ a ?~ b a @@ -1719,7 +1719,7 @@ :: ++ urn :: apply gate to nodes ~/ %urn - |* b/$-({* *} *) + |* b=$-({* *} *) |- ?~ a ~ a(n n.a(q (b p.n.a q.n.a)), l $(a l.a), r $(a r.a)) @@ -1749,23 +1749,23 @@ :: :: :: ++ ja :: jar engine - =| a/(tree (pair * (list))) :: (jar) + =| a=(tree (pair * (list))) :: (jar) |@ ++ get :: gets list by key - |* b/* + |* b=* =+ c=(~(get by a) b) ?~(c ~ u.c) :: ++ add :: adds key-list pair - |* {b/* c/*} + |* {b=* c=*} =+ d=(get b) (~(put by a) b [c d]) -- ++ ju :: jug engine - =| a/(tree (pair * (tree))) :: (jug) + =| a=(tree (pair * (tree))) :: (jug) |@ ++ del :: del key-set pair - |* {b/* c/*} + |* {b=* c=*} ^+ a =+ d=(get b) =+ e=(~(del in d) c) @@ -1774,7 +1774,7 @@ (~(put by a) b e) :: ++ gas :: concatenate - |* b/(list {p/* q/*}) + |* b=(list {p=* q=*}) => .(b `(list _?>(?=({{* ^} ^} a) [p=p q=n.q]:n.a))`b) |- ^+ a ?~ b @@ -1782,17 +1782,17 @@ $(b t.b, a (put p.i.b q.i.b)) :: ++ get :: gets set by key - |* b/* + |* b=* =+ c=(~(get by a) b) ?~(c ~ u.c) :: ++ has :: existence check - |* {b/* c/*} + |* {b=* c=*} ^- ? (~(has in (get b)) c) :: ++ put :: add key-set pair - |* {b/* c/*} + |* {b=* c=*} ^+ a =+ d=(get b) (~(put by a) b (~(put in d) c)) @@ -1802,7 +1802,7 @@ :: :: :: ++ to :: queue engine - =| a/(tree) :: (qeu) + =| a=(tree) :: (qeu) |@ ++ apt :: check correctness |- ^- ? @@ -1826,7 +1826,7 @@ +((max $(a l.a) $(a r.a))) :: ++ gas :: insert list to que - |= b/(list _?>(?=(^ a) n.a)) + |= b=(list _?>(?=(^ a) n.a)) |- ^+ a ?~(b a $(b t.b, a (put i.b))) :: @@ -1858,7 +1858,7 @@ bal(n.a p.b, l.a q.b) :: ++ put :: insert new tail - |* b/* + |* b=* |- ^+ a ?~ a [b ~ ~] @@ -1903,15 +1903,15 @@ :: :: :: ++ malt :: map from list - |* a/(list) - (molt `(list {p/_-<.a q/_->.a})`a) + |* a=(list) + (molt `(list {p=_-<.a q=_->.a})`a) :: ++ molt :: map from pair list - |* a/(list (pair)) :: ^- =,(i.-.a (map _p _q)) - (~(gas by `(tree {p/_p.i.-.a q/_q.i.-.a})`~) a) + |* a=(list (pair)) :: ^- =,(i.-.a (map _p _q)) + (~(gas by `(tree {p=_p.i.-.a q=_q.i.-.a})`~) a) :: ++ silt :: set from list - |* a/(list) :: ^- (set _i.-.a) + |* a=(list) :: ^- (set _i.-.a) =+ b=*(tree _?>(?=(^ a) i.a)) (~(gas in b) a) :: :: @@ -1931,24 +1931,24 @@ |% :: :: ++ le :: construct list - |* a/(list) + |* a=(list) ^+ =< $ |@ ++ $ ?:(*? ~ [i=(snag 0 a) t=$]) -- a :: :: ++ my :: construct map - |* a/(list (pair)) + |* a=(list (pair)) => .(a ^+((le a) a)) (~(gas by `(map _p.i.-.a _q.i.-.a)`~) a) :: :: ++ si :: construct set - |* a/(list) + |* a=(list) => .(a ^+((le a) a)) (~(gas in `(set _i.-.a)`~) a) :: :: ++ snag :: index - |* {a/@ b/(list)} + |* {a=@ b=(list)} ?~ b ~_ leaf+"snag-fail" !! @@ -1956,7 +1956,7 @@ $(b t.b, a (dec a)) :: :: ++ weld :: concatenate - |* {a/(list) b/(list)} + |* {a=(list) b=(list)} => .(a ^+((le a) a), b ^+((le b) b)) =+ 42 |- @@ -1973,7 +1973,7 @@ +$ char @t :: UTF8 byte +$ cord @t :: UTF8, LSB first +$ byts [wid=@ud dat=@] :: bytes, MSB first -+$ date {{a/? y/@ud} m/@ud t/tarp} :: parsed date ++$ date {{a=? y=@ud} m=@ud t=tarp} :: parsed date +$ knot @ta :: ASCII text +$ noun * :: any noun +$ path (list knot) :: like unix path @@ -2003,7 +2003,7 @@ :: +$ tape (list @tD) :: utf8 string as list +$ tour (list @c) :: utf32 clusters -+$ tarp {d/@ud h/@ud m/@ud s/@ud f/(list @ux)} :: parsed time ++$ tarp {d=@ud h=@ud m=@ud s=@ud f=(list @ux)} :: parsed time +$ term @tas :: ascii symbol +$ wain (list cord) :: text lines +$ wall (list tape) :: text lines @@ -2013,12 +2013,12 @@ :: ++ cue :: unpack ~/ %cue - |= a/@ + |= a=@ ^- * =+ b=0 =+ m=`(map @ *)`~ =< q - |- ^- {p/@ q/* r/(map @ *)} + |- ^- {p=@ q=* r=(map @ *)} ?: =(0 (cut 0 [b 1] a)) =+ c=(rub +(b) a) [+(p.c) q.c (~(put by m) b q.c)] @@ -2033,12 +2033,12 @@ :: ++ jam :: pack ~/ %jam - |= a/* + |= a=* ^- @ =+ b=0 =+ m=`(map * @)`~ =< q - |- ^- {p/@ q/@ r/(map * @)} + |- ^- {p=@ q=@ r=(map * @)} =+ c=(~(get by m) a) ?~ c => .(m (~(put by m) a b)) @@ -2057,8 +2057,8 @@ :: ++ mat :: length-encode ~/ %mat - |= a/@ - ^- {p/@ q/@} + |= a=@ + ^- {p=@ q=@} ?: =(0 a) [1 1] =+ b=(met 0 a) @@ -2068,8 +2068,8 @@ :: ++ rub :: length-decode ~/ %rub - |= {a/@ b/@} - ^- {p/@ q/@} + |= {a=@ b=@} + ^- {p=@ q=@} =+ ^= c =+ [c=0 m=(met 0 b)] |- ?< (gth c m) @@ -2085,22 +2085,22 @@ ++ fn :: float, infinity, or NaN :: s=sign, e=exponent, a=arithmetic form :: (-1)^s * a * 2^e - $% {%f s/? e/@s a/@u} - {%i s/?} + $% {%f s=? e=@s a=@u} + {%i s=?} {%n ~} == :: ++ dn :: decimal float, infinity, or NaN :: (-1)^s * a * 10^e - $% {%d s/? e/@s a/@u} - {%i s/?} + $% {%d s=? e=@s a=@u} + {%i s=?} {%n ~} == :: ++ rn :: parsed decimal float :: - $% {%d a/? b/{c/@ {d/@ e/@} f/? i/@}} - {%i a/?} + $% {%d a=? b={c=@ {d=@ e=@} f=? i=@}} + {%i a=?} {%n ~} == -- => @@ -2127,11 +2127,11 @@ :: :: :: ++ egcd :: schneier's egcd - |= {a/@ b/@} + |= {a=@ b=@} =+ si =+ [c=(sun a) d=(sun b)] =+ [u=[c=(sun 1) d=--0] v=[c=--0 d=(sun 1)]] - |- ^- {d/@ u/@s v/@s} + |- ^- {d=@ u=@s v=@s} ?: =(--0 c) [(abs d) d.u d.v] :: ?> ?& =(c (sum (pro (sun a) c.u) (pro (sun b) c.v))) @@ -2147,13 +2147,13 @@ :: ++ fo :: modulo prime ^| - |_ a/@ + |_ a=@ ++ dif - |= {b/@ c/@} + |= {b=@ c=@} (sit (sub (add a b) (sit c))) :: ++ exp - |= {b/@ c/@} + |= {b=@ c=@} ?: =(0 b) 1 =+ d=$(b (rsh 0 1 b)) @@ -2161,44 +2161,44 @@ ?:(=(0 (end 0 1 b)) e (pro c e)) :: ++ fra - |= {b/@ c/@} + |= {b=@ c=@} (pro b (inv c)) :: ++ inv - |= b/@ + |= b=@ =+ c=(dul:si u:(egcd b a) a) c :: ++ pro - |= {b/@ c/@} + |= {b=@ c=@} (sit (mul b c)) :: ++ sit - |= b/@ + |= b=@ (mod b a) :: ++ sum - |= {b/@ c/@} + |= {b=@ c=@} (sit (add b c)) -- :: ++ si :: signed integer ^? |% - ++ abs |=(a/@s (add (end 0 1 a) (rsh 0 1 a))) :: absolute value - ++ dif |= {a/@s b/@s} :: subtraction + ++ abs |=(a=@s (add (end 0 1 a) (rsh 0 1 a))) :: absolute value + ++ dif |= {a=@s b=@s} :: subtraction (sum a (new !(syn b) (abs b))) - ++ dul |= {a/@s b/@} :: modulus + ++ dul |= {a=@s b=@} :: modulus =+(c=(old a) ?:(-.c (mod +.c b) (sub b +.c))) - ++ fra |= {a/@s b/@s} :: divide + ++ fra |= {a=@s b=@s} :: divide (new =(0 (mix (syn a) (syn b))) (div (abs a) (abs b))) - ++ new |= {a/? b/@} :: [sign value] to @s + ++ new |= {a=? b=@} :: [sign value] to @s `@s`?:(a (mul 2 b) ?:(=(0 b) 0 +((mul 2 (dec b))))) - ++ old |=(a/@s [(syn a) (abs a)]) :: [sign value] - ++ pro |= {a/@s b/@s} :: multiplication + ++ old |=(a=@s [(syn a) (abs a)]) :: [sign value] + ++ pro |= {a=@s b=@s} :: multiplication (new =(0 (mix (syn a) (syn b))) (mul (abs a) (abs b))) - ++ rem |=({a/@s b/@s} (dif a (pro b (fra a b)))) :: remainder - ++ sum |= {a/@s b/@s} :: addition + ++ rem |=({a=@s b=@s} (dif a (pro b (fra a b)))) :: remainder + ++ sum |= {a=@s b=@s} :: addition =+ [c=(old a) d=(old b)] ?: -.c ?: -.d @@ -2211,9 +2211,9 @@ (new | (sub +.c +.d)) (new & (sub +.d +.c)) (new | (add +.c +.d)) - ++ sun |=(a/@u (mul 2 a)) :: @u to @s - ++ syn |=(a/@s =(0 (end 0 1 a))) :: sign test - ++ cmp |= {a/@s b/@s} :: compare + ++ sun |=(a=@u (mul 2 a)) :: @u to @s + ++ syn |=(a=@s =(0 (end 0 1 a))) :: sign test + ++ cmp |= {a=@s b=@s} :: compare ^- @s ?: =(a b) --0 @@ -2235,7 +2235,7 @@ :: :: ++ fl :: arb. precision fp - =/ {{p/@u v/@s w/@u} r/$?(%n %u %d %z %a) d/$?(%d %f %i)} + =/ {{p=@u v=@s w=@u} r=$?(%n %u %d %z %a) d=$?(%d %f %i)} [[113 -16.494 32.765] %n %d] :: p=precision: number of bits in arithmetic form; must be at least 2 :: v=min exponent: minimum value of e @@ -2245,14 +2245,14 @@ :: infinite exponent range => ~% %cofl +> ~ - :: internal functions; mostly operating on {e/@s a/@u}, in other words + :: internal functions; mostly operating on {e=@s a=@u}, in other words :: positive numbers. many of these error out if a=0. |% ++ rou - |= {a/{e/@s a/@u}} ^- fn (rau a &) + |= {a={e=@s a=@u}} ^- fn (rau a &) :: ++ rau - |= {a/{e/@s a/@u} t/?} ^- fn + |= {a={e=@s a=@u} t=?} ^- fn ?- r %z (lug %fl a t) %d (lug %fl a t) %a (lug %ce a t) %u (lug %ce a t) @@ -2260,7 +2260,7 @@ == :: ++ add :: add; exact if e - |= {a/{e/@s a/@u} b/{e/@s a/@u} e/?} ^- fn + |= {a={e=@s a=@u} b={e=@s a=@u} e=?} ^- fn =+ q=(dif:si e.a e.b) |- ?. (syn:si q) $(b a, a b, q +(q)) :: a has larger exp ?: e @@ -2278,7 +2278,7 @@ (rou [e.b (^add (lsh 0 (abs:si q) a.a) a.b)]) :: ++ sub :: subtract; exact if e - |= {a/{e/@s a/@u} b/{e/@s a/@u} e/?} ^- fn + |= {a={e=@s a=@u} b={e=@s a=@u} e=?} ^- fn =+ q=(dif:si e.a e.b) |- ?. (syn:si q) (fli $(b a, a b, q +(q), r swr)) @@ -2300,11 +2300,11 @@ ?: e [%f & e.b i] (rou [e.b i]) :: ++ mul :: multiply - |= {a/{e/@s a/@u} b/{e/@s a/@u}} ^- fn + |= {a={e=@s a=@u} b={e=@s a=@u}} ^- fn (rou (sum:si e.a e.b) (^mul a.a a.b)) :: ++ div :: divide - |= {a/{e/@s a/@u} b/{e/@s a/@u}} ^- fn + |= {a={e=@s a=@u} b={e=@s a=@u}} ^- fn =+ [ma=(met 0 a.a) mb=(met 0 a.b)] =+ v=(dif:si (sun:si ma) (sun:si +((^add mb prc)))) =. a ?: (syn:si v) a @@ -2313,7 +2313,7 @@ (rau [j p.q] =(q.q 0)) :: ++ sqt :: square root - |= {a/{e/@s a/@u}} ^- fn + |= {a={e=@s a=@u}} ^- fn =. a =+ [w=(met 0 a.a) x=(^mul +(prc) 2)] =+ ?:((^lth w x) (^sub x w) 0) @@ -2324,7 +2324,7 @@ (rau [z p.y] =(q.y 0)) :: ++ lth :: less-than - |= {a/{e/@s a/@u} b/{e/@s a/@u}} ^- ? + |= {a={e=@s a=@u} b={e=@s a=@u}} ^- ? ?: =(e.a e.b) (^lth a.a a.b) =+ c=(cmp:si (ibl a) (ibl b)) ?: =(c -1) & ?: =(c --1) | @@ -2333,7 +2333,7 @@ (^lth (lsh 0 (abs:si (dif:si e.a e.b)) a.a) a.b) :: ++ equ :: equals - |= {a/{e/@s a/@u} b/{e/@s a/@u}} ^- ? + |= {a={e=@s a=@u} b={e=@s a=@u}} ^- ? ?. =((ibl a) (ibl b)) | ?: =((cmp:si e.a e.b) -1) =((lsh 0 (abs:si (dif:si e.a e.b)) a.b) a.a) @@ -2341,19 +2341,19 @@ :: :: integer binary logarithm: 2^ibl(a) <= |a| < 2^(ibl(a)+1) ++ ibl - |= {a/{e/@s a/@u}} ^- @s + |= {a={e=@s a=@u}} ^- @s (sum:si (sun:si (dec (met 0 a.a))) e.a) :: :: change to a representation where a.a is odd :: every fn has a unique representation of this kind ++ uni - |= {a/{e/@s a/@u}} + |= {a={e=@s a=@u}} |- ?: =((end 0 1 a.a) 1) a $(a.a (rsh 0 1 a.a), e.a (sum:si e.a --1)) :: :: expands to either full precision or to denormalized ++ xpd - |= {a/{e/@s a/@u}} + |= {a={e=@s a=@u}} =+ ma=(met 0 a.a) ?: (gte ma prc) a =+ ?: =(den %i) (^sub prc ma) @@ -2370,7 +2370,7 @@ :: ++ lug ~/ %lug - |= {t/$?(%fl %ce %sm %lg %ne %na %nt) a/{e/@s a/@u} s/?} ^- fn + |= {t=$?(%fl %ce %sm %lg %ne %na %nt) a={e=@s a=@u} s=?} ^- fn ?< =(a.a 0) =- ?. =(den %f) - :: flush denormals @@ -2435,7 +2435,7 @@ :: ++ drg :: dragon4; get ~/ %drg :: printable decimal; - |= {a/{e/@s a/@u}} ^- {@s @u} :: guaranteed accurate + |= {a={e=@s a=@u}} ^- {@s @u} :: guaranteed accurate ?< =(a.a 0) :: for rounded floats =. a (xpd a) =+ r=(lsh 0 ?:((syn:si e.a) (abs:si e.a) 0) a.a) @@ -2484,7 +2484,7 @@ [k o] :: ++ toj :: round to integer - |= {a/{e/@s a/@u}} ^- fn + |= {a={e=@s a=@u}} ^- fn ?. =((cmp:si e.a --0) -1) [%f & a] =+ x=(abs:si e.a) =+ y=(rsh 0 x a.a) @@ -2496,18 +2496,18 @@ ?: (^lth z i) [%f & --0 y] [%f & --0 +(y)] :: ++ ned :: require ?=({%f *} a) - |= {a/fn} ^- {%f s/? e/@s a/@u} + |= {a=fn} ^- {%f s=? e=@s a=@u} ?: ?=({%f *} a) a ~_ leaf+"need-float" !! :: ++ shf :: a * 2^b; no rounding - |= {a/fn b/@s} + |= {a=fn b=@s} ?: |(?=({%n *} a) ?=({%i *} a)) a a(e (sum:si e.a b)) :: ++ fli :: flip sign - |= {a/fn} ^- fn + |= {a=fn} ^- fn ?-(-.a %f a(s !s.a), %i a(s !s.a), %n a) :: ++ swr ?+(r r %d %u, %u %d) :: flipped rounding @@ -2523,23 +2523,23 @@ -- |% ++ rou :: round - |= {a/fn} ^- fn + |= {a=fn} ^- fn ?. ?=({%f *} a) a ?~ a.a [%f s.a zer] ?: s.a (^rou +>.a) =.(r swr (fli (^rou +>.a))) :: ++ syn :: get sign - |= {a/fn} ^- ? + |= {a=fn} ^- ? ?-(-.a %f s.a, %i s.a, %n &) :: ++ abs :: absolute value - |= {a/fn} ^- fn + |= {a=fn} ^- fn ?: ?=({%f *} a) [%f & e.a a.a] ?: ?=({%i *} a) [%i &] [%n ~] :: ++ add :: add - |= {a/fn b/fn} ^- fn + |= {a=fn b=fn} ^- fn ?: |(?=({%n *} a) ?=({%n *} b)) [%n ~] ?: |(?=({%i *} a) ?=({%i *} b)) ?: &(?=({%i *} a) ?=({%i *} b)) @@ -2548,7 +2548,7 @@ ?: |(=(a.a 0) =(a.b 0)) ?. &(=(a.a 0) =(a.b 0)) %- rou ?~(a.a b a) [%f ?:(=(r %d) &(s.a s.b) |(s.a s.b)) zer] - %- |= {a/fn} + %- |= {a=fn} ?. ?=({%f *} a) a ?. =(a.a 0) a [%f !=(r %d) zer] @@ -2559,7 +2559,7 @@ (^sub +>.b +>.a |) :: ++ ead :: exact add - |= {a/fn b/fn} ^- fn + |= {a=fn b=fn} ^- fn ?: |(?=({%n *} a) ?=({%n *} b)) [%n ~] ?: |(?=({%i *} a) ?=({%i *} b)) ?: &(?=({%i *} a) ?=({%i *} b)) @@ -2568,7 +2568,7 @@ ?: |(=(a.a 0) =(a.b 0)) ?. &(=(a.a 0) =(a.b 0)) ?~(a.a b a) [%f ?:(=(r %d) &(s.a s.b) |(s.a s.b)) zer] - %- |= {a/fn} + %- |= {a=fn} ?. ?=({%f *} a) a ?. =(a.a 0) a [%f !=(r %d) zer] @@ -2579,10 +2579,10 @@ (^sub +>.b +>.a &) :: ++ sub :: subtract - |= {a/fn b/fn} ^- fn (add a (fli b)) + |= {a=fn b=fn} ^- fn (add a (fli b)) :: ++ mul :: multiply - |= {a/fn b/fn} ^- fn + |= {a=fn b=fn} ^- fn ?: |(?=({%n *} a) ?=({%n *} b)) [%n ~] ?: ?=({%i *} a) ?: ?=({%i *} b) @@ -2595,7 +2595,7 @@ =.(r swr (fli (^mul +>.a +>.b))) :: ++ emu :: exact multiply - |= {a/fn b/fn} ^- fn + |= {a=fn b=fn} ^- fn ?: |(?=({%n *} a) ?=({%n *} b)) [%n ~] ?: ?=({%i *} a) ?: ?=({%i *} b) @@ -2607,7 +2607,7 @@ [%f =(s.a s.b) (sum:si e.a e.b) (^^mul a.a a.b)] :: ++ div :: divide - |= {a/fn b/fn} ^- fn + |= {a=fn b=fn} ^- fn ?: |(?=({%n *} a) ?=({%n *} b)) [%n ~] ?: ?=({%i *} a) ?: ?=({%i *} b) [%n ~] [%i =(s.a s.b)] @@ -2618,32 +2618,32 @@ =.(r swr (fli (^div +>.a +>.b))) :: ++ fma :: fused multiply-add - |= {a/fn b/fn c/fn} ^- fn :: (a * b) + c + |= {a=fn b=fn c=fn} ^- fn :: (a * b) + c (add (emu a b) c) :: ++ sqt :: square root - |= {a/fn} ^- fn + |= {a=fn} ^- fn ?: ?=({%n *} a) [%n ~] ?: ?=({%i *} a) ?:(s.a a [%n ~]) ?~ a.a [%f s.a zer] ?: s.a (^sqt +>.a) [%n ~] :: ++ inv :: inverse - |= {a/fn} ^- fn + |= {a=fn} ^- fn (div [%f & --0 1] a) :: ++ sun :: uns integer to float - |= {a/@u} ^- fn + |= {a=@u} ^- fn (rou [%f & --0 a]) :: ++ san :: sgn integer to float - |= {a/@s} ^- fn + |= {a=@s} ^- fn =+ b=(old:si a) (rou [%f -.b --0 +.b]) :: :: comparisons return ~ in the event of a NaN ++ lth :: less-than - |= {a/fn b/fn} ^- (unit ?) + |= {a=fn b=fn} ^- (unit ?) ?: |(?=({%n *} a) ?=({%n *} b)) ~ :- ~ ?: =(a b) | ?: ?=({%i *} a) !s.a ?: ?=({%i *} b) s.b @@ -2654,11 +2654,11 @@ ?: s.a (^lth +>.a +>.b) (^lth +>.b +>.a) :: ++ lte :: less-equal - |= {a/fn b/fn} ^- (unit ?) - %+ bind (lth b a) |= a/? !a + |= {a=fn b=fn} ^- (unit ?) + %+ bind (lth b a) |= a=? !a :: ++ equ :: equal - |= {a/fn b/fn} ^- (unit ?) + |= {a=fn b=fn} ^- (unit ?) ?: |(?=({%n *} a) ?=({%n *} b)) ~ :- ~ ?: =(a b) & ?: |(?=({%i *} a) ?=({%i *} b)) | @@ -2668,20 +2668,20 @@ (^equ +>.a +>.b) :: ++ gte :: greater-equal - |= {a/fn b/fn} ^- (unit ?) (lte b a) + |= {a=fn b=fn} ^- (unit ?) (lte b a) :: ++ gth :: greater-than - |= {a/fn b/fn} ^- (unit ?) (lth b a) + |= {a=fn b=fn} ^- (unit ?) (lth b a) :: ++ drg :: float to decimal - |= {a/fn} ^- dn + |= {a=fn} ^- dn ?: ?=({%n *} a) [%n ~] ?: ?=({%i *} a) [%i s.a] ?~ a.a [%d s.a --0 0] [%d s.a (^drg +>.a)] :: ++ grd :: decimal to float - |= {a/dn} ^- fn + |= {a=dn} ^- fn ?: ?=({%n *} a) [%n ~] ?: ?=({%i *} a) [%i s.a] => .(r %n) @@ -2691,14 +2691,14 @@ (div [%f s.a --0 a.a] [%f & (sun:si q) (pow 5 q)]) :: ++ toi :: round to integer @s - |= {a/fn} ^- (unit @s) + |= {a=fn} ^- (unit @s) =+ b=(toj a) ?. ?=({%f *} b) ~ :- ~ =+ c=(^^mul (bex (abs:si e.b)) a.b) (new:si s.b c) :: ++ toj :: round to integer fn - |= {a/fn} ^- fn + |= {a=fn} ^- fn ?. ?=({%f *} a) a ?~ a.a [%f s.a zer] ?: s.a (^toj +>.a) @@ -2706,7 +2706,7 @@ -- :: ++ ff :: ieee 754 format fp - |_ {{w/@u p/@u b/@s} r/$?(%n %u %d %z %a)} + |_ {{w=@u p=@u b=@s} r=$?(%n %u %d %z %a)} :: this core has no use outside of the functionality :: provided to ++rd, ++rs, ++rq, and ++rh :: @@ -2722,7 +2722,7 @@ %*(. fl p +(p), v me, w (^sub (bex w) 3), d %d, r r) :: ++ sea :: @r to fn - |= {a/@r} ^- fn + |= {a=@r} ^- fn =+ [f=(cut 0 [0 p] a) e=(cut 0 [p w] a)] =+ s=(sig a) ?: =(e 0) @@ -2733,10 +2733,10 @@ =+ r=(^add f (bex p)) [%f s q r] :: - ++ bit |= {a/fn} (bif (rou:pa a)) :: fn to @r w+ rounding + ++ bit |= {a=fn} (bif (rou:pa a)) :: fn to @r w+ rounding :: ++ bif :: fn to @r no rounding - |= {a/fn} ^- @r + |= {a=fn} ^- @r ?: ?=({%i *} a) =+ q=(lsh 0 p (fil 0 w 1)) ?: s.a q (^add q sb) @@ -2752,394 +2752,394 @@ ?: s.a r (^add r sb) :: ++ sig :: get sign - |= {a/@r} ^- ? + |= {a=@r} ^- ? =(0 (cut 0 [(^add p w) 1] a)) :: ++ exp :: get exponent - |= {a/@r} ^- @s + |= {a=@r} ^- @s (dif:si (sun:si (cut 0 [p w] a)) b) :: ++ add :: add - |= {a/@r b/@r} + |= {a=@r b=@r} (bif (add:pa (sea a) (sea b))) :: ++ sub :: subtract - |= {a/@r b/@r} + |= {a=@r b=@r} (bif (sub:pa (sea a) (sea b))) :: ++ mul :: multiply - |= {a/@r b/@r} + |= {a=@r b=@r} (bif (mul:pa (sea a) (sea b))) :: ++ div :: divide - |= {a/@r b/@r} + |= {a=@r b=@r} (bif (div:pa (sea a) (sea b))) :: ++ fma :: fused multiply-add - |= {a/@r b/@r c/@r} + |= {a=@r b=@r c=@r} (bif (fma:pa (sea a) (sea b) (sea c))) :: ++ sqt :: square root - |= {a/@r} + |= {a=@r} (bif (sqt:pa (sea a))) :: ++ lth :: less-than - |= {a/@r b/@r} (fall (lth:pa (sea a) (sea b)) |) + |= {a=@r b=@r} (fall (lth:pa (sea a) (sea b)) |) ++ lte :: less-equals - |= {a/@r b/@r} (fall (lte:pa (sea a) (sea b)) |) + |= {a=@r b=@r} (fall (lte:pa (sea a) (sea b)) |) ++ equ :: equals - |= {a/@r b/@r} (fall (equ:pa (sea a) (sea b)) |) + |= {a=@r b=@r} (fall (equ:pa (sea a) (sea b)) |) ++ gte :: greater-equals - |= {a/@r b/@r} (fall (gte:pa (sea a) (sea b)) |) + |= {a=@r b=@r} (fall (gte:pa (sea a) (sea b)) |) ++ gth :: greater-than - |= {a/@r b/@r} (fall (gth:pa (sea a) (sea b)) |) + |= {a=@r b=@r} (fall (gth:pa (sea a) (sea b)) |) ++ sun :: uns integer to @r - |= {a/@u} (bit [%f & --0 a]) + |= {a=@u} (bit [%f & --0 a]) ++ san :: signed integer to @r - |= {a/@s} (bit [%f (syn:si a) --0 (abs:si a)]) + |= {a=@s} (bit [%f (syn:si a) --0 (abs:si a)]) ++ toi :: round to integer - |= {a/@r} (toi:pa (sea a)) + |= {a=@r} (toi:pa (sea a)) ++ drg :: @r to decimal float - |= {a/@r} (drg:pa (sea a)) + |= {a=@r} (drg:pa (sea a)) ++ grd :: decimal float to @r - |= {a/dn} (bif (grd:pa a)) + |= {a=dn} (bif (grd:pa a)) -- :: -++ rlyd |= a/@rd ^- dn (drg:rd a) :: prep @rd for print -++ rlys |= a/@rs ^- dn (drg:rs a) :: prep @rs for print -++ rlyh |= a/@rh ^- dn (drg:rh a) :: prep @rh for print -++ rlyq |= a/@rq ^- dn (drg:rq a) :: prep @rq for print -++ ryld |= a/dn ^- @rd (grd:rd a) :: finish parsing @rd -++ ryls |= a/dn ^- @rs (grd:rs a) :: finish parsing @rs -++ rylh |= a/dn ^- @rh (grd:rh a) :: finish parsing @rh -++ rylq |= a/dn ^- @rq (grd:rq a) :: finish parsing @rq +++ rlyd |= a=@rd ^- dn (drg:rd a) :: prep @rd for print +++ rlys |= a=@rs ^- dn (drg:rs a) :: prep @rs for print +++ rlyh |= a=@rh ^- dn (drg:rh a) :: prep @rh for print +++ rlyq |= a=@rq ^- dn (drg:rq a) :: prep @rq for print +++ ryld |= a=dn ^- @rd (grd:rd a) :: finish parsing @rd +++ ryls |= a=dn ^- @rs (grd:rs a) :: finish parsing @rs +++ rylh |= a=dn ^- @rh (grd:rh a) :: finish parsing @rh +++ rylq |= a=dn ^- @rq (grd:rq a) :: finish parsing @rq :: ++ rd :: double precision fp ^| ~% %rd +> ~ - |_ r/$?(%n %u %d %z) + |_ r=$?(%n %u %d %z) :: round to nearest, round up, round down, round to zero :: ++ ma %*(. ff w 11, p 52, b --1.023, r r) :: ++ sea :: @rd to fn - |= {a/@rd} (sea:ma a) + |= {a=@rd} (sea:ma a) :: ++ bit :: fn to @rd - |= {a/fn} ^- @rd (bit:ma a) + |= {a=fn} ^- @rd (bit:ma a) :: ++ add ~/ %add :: add - |= {a/@rd b/@rd} ^- @rd + |= {a=@rd b=@rd} ^- @rd ~_ leaf+"rd-fail" (add:ma a b) :: ++ sub ~/ %sub :: subtract - |= {a/@rd b/@rd} ^- @rd + |= {a=@rd b=@rd} ^- @rd ~_ leaf+"rd-fail" (sub:ma a b) :: ++ mul ~/ %mul :: multiply - |= {a/@rd b/@rd} ^- @rd + |= {a=@rd b=@rd} ^- @rd ~_ leaf+"rd-fail" (mul:ma a b) :: ++ div ~/ %div :: divide - |= {a/@rd b/@rd} ^- @rd + |= {a=@rd b=@rd} ^- @rd ~_ leaf+"rd-fail" (div:ma a b) :: ++ fma ~/ %fma :: fused multiply-add - |= {a/@rd b/@rd c/@rd} ^- @rd + |= {a=@rd b=@rd c=@rd} ^- @rd ~_ leaf+"rd-fail" (fma:ma a b c) :: ++ sqt ~/ %sqt :: square root - |= {a/@rd} ^- @rd ~_ leaf+"rd-fail" + |= {a=@rd} ^- @rd ~_ leaf+"rd-fail" (sqt:ma a) :: ++ lth ~/ %lth :: less-than - |= {a/@rd b/@rd} + |= {a=@rd b=@rd} ~_ leaf+"rd-fail" (lth:ma a b) :: ++ lte ~/ %lte :: less-equals - |= {a/@rd b/@rd} + |= {a=@rd b=@rd} ~_ leaf+"rd-fail" (lte:ma a b) :: ++ equ ~/ %equ :: equals - |= {a/@rd b/@rd} + |= {a=@rd b=@rd} ~_ leaf+"rd-fail" (equ:ma a b) :: ++ gte ~/ %gte :: greater-equals - |= {a/@rd b/@rd} + |= {a=@rd b=@rd} ~_ leaf+"rd-fail" (gte:ma a b) :: ++ gth ~/ %gth :: greater-than - |= {a/@rd b/@rd} + |= {a=@rd b=@rd} ~_ leaf+"rd-fail" (gth:ma a b) :: - ++ sun |= {a/@u} ^- @rd (sun:ma a) :: uns integer to @rd - ++ san |= {a/@s} ^- @rd (san:ma a) :: sgn integer to @rd - ++ sig |= {a/@rd} ^- ? (sig:ma a) :: get sign - ++ exp |= {a/@rd} ^- @s (exp:ma a) :: get exponent - ++ toi |= {a/@rd} ^- (unit @s) (toi:ma a) :: round to integer - ++ drg |= {a/@rd} ^- dn (drg:ma a) :: @rd to decimal float - ++ grd |= {a/dn} ^- @rd (grd:ma a) :: decimal float to @rd + ++ sun |= {a=@u} ^- @rd (sun:ma a) :: uns integer to @rd + ++ san |= {a=@s} ^- @rd (san:ma a) :: sgn integer to @rd + ++ sig |= {a=@rd} ^- ? (sig:ma a) :: get sign + ++ exp |= {a=@rd} ^- @s (exp:ma a) :: get exponent + ++ toi |= {a=@rd} ^- (unit @s) (toi:ma a) :: round to integer + ++ drg |= {a=@rd} ^- dn (drg:ma a) :: @rd to decimal float + ++ grd |= {a=dn} ^- @rd (grd:ma a) :: decimal float to @rd -- :: ++ rs :: single precision fp ~% %rs +> ~ ^| - |_ r/$?(%n %u %d %z) + |_ r=$?(%n %u %d %z) :: round to nearest, round up, round down, round to zero :: ++ ma %*(. ff w 8, p 23, b --127, r r) :: ++ sea :: @rs to fn - |= {a/@rs} (sea:ma a) + |= {a=@rs} (sea:ma a) :: ++ bit :: fn to @rs - |= {a/fn} ^- @rs (bit:ma a) + |= {a=fn} ^- @rs (bit:ma a) :: ++ add ~/ %add :: add - |= {a/@rs b/@rs} ^- @rs + |= {a=@rs b=@rs} ^- @rs ~_ leaf+"rs-fail" (add:ma a b) :: ++ sub ~/ %sub :: subtract - |= {a/@rs b/@rs} ^- @rs + |= {a=@rs b=@rs} ^- @rs ~_ leaf+"rs-fail" (sub:ma a b) :: ++ mul ~/ %mul :: multiply - |= {a/@rs b/@rs} ^- @rs + |= {a=@rs b=@rs} ^- @rs ~_ leaf+"rs-fail" (mul:ma a b) :: ++ div ~/ %div :: divide - |= {a/@rs b/@rs} ^- @rs + |= {a=@rs b=@rs} ^- @rs ~_ leaf+"rs-fail" (div:ma a b) :: ++ fma ~/ %fma :: fused multiply-add - |= {a/@rs b/@rs c/@rs} ^- @rs + |= {a=@rs b=@rs c=@rs} ^- @rs ~_ leaf+"rs-fail" (fma:ma a b c) :: ++ sqt ~/ %sqt :: square root - |= {a/@rs} ^- @rs + |= {a=@rs} ^- @rs ~_ leaf+"rs-fail" (sqt:ma a) :: ++ lth ~/ %lth :: less-than - |= {a/@rs b/@rs} + |= {a=@rs b=@rs} ~_ leaf+"rs-fail" (lth:ma a b) :: ++ lte ~/ %lte :: less-equals - |= {a/@rs b/@rs} + |= {a=@rs b=@rs} ~_ leaf+"rs-fail" (lte:ma a b) :: ++ equ ~/ %equ :: equals - |= {a/@rs b/@rs} + |= {a=@rs b=@rs} ~_ leaf+"rs-fail" (equ:ma a b) :: ++ gte ~/ %gte :: greater-equals - |= {a/@rs b/@rs} + |= {a=@rs b=@rs} ~_ leaf+"rs-fail" (gte:ma a b) :: ++ gth ~/ %gth :: greater-than - |= {a/@rs b/@rs} + |= {a=@rs b=@rs} ~_ leaf+"rs-fail" (gth:ma a b) :: - ++ sun |= {a/@u} ^- @rs (sun:ma a) :: uns integer to @rs - ++ san |= {a/@s} ^- @rs (san:ma a) :: sgn integer to @rs - ++ sig |= {a/@rs} ^- ? (sig:ma a) :: get sign - ++ exp |= {a/@rs} ^- @s (exp:ma a) :: get exponent - ++ toi |= {a/@rs} ^- (unit @s) (toi:ma a) :: round to integer - ++ drg |= {a/@rs} ^- dn (drg:ma a) :: @rs to decimal float - ++ grd |= {a/dn} ^- @rs (grd:ma a) :: decimal float to @rs + ++ sun |= {a=@u} ^- @rs (sun:ma a) :: uns integer to @rs + ++ san |= {a=@s} ^- @rs (san:ma a) :: sgn integer to @rs + ++ sig |= {a=@rs} ^- ? (sig:ma a) :: get sign + ++ exp |= {a=@rs} ^- @s (exp:ma a) :: get exponent + ++ toi |= {a=@rs} ^- (unit @s) (toi:ma a) :: round to integer + ++ drg |= {a=@rs} ^- dn (drg:ma a) :: @rs to decimal float + ++ grd |= {a=dn} ^- @rs (grd:ma a) :: decimal float to @rs -- :: ++ rq :: quad precision fp ~% %rq +> ~ ^| - |_ r/$?(%n %u %d %z) + |_ r=$?(%n %u %d %z) :: round to nearest, round up, round down, round to zero :: ++ ma %*(. ff w 15, p 112, b --16.383, r r) :: ++ sea :: @rq to fn - |= {a/@rq} (sea:ma a) + |= {a=@rq} (sea:ma a) :: ++ bit :: fn to @rq - |= {a/fn} ^- @rq (bit:ma a) + |= {a=fn} ^- @rq (bit:ma a) :: ++ add ~/ %add :: add - |= {a/@rq b/@rq} ^- @rq + |= {a=@rq b=@rq} ^- @rq ~_ leaf+"rq-fail" (add:ma a b) :: ++ sub ~/ %sub :: subtract - |= {a/@rq b/@rq} ^- @rq + |= {a=@rq b=@rq} ^- @rq ~_ leaf+"rq-fail" (sub:ma a b) :: ++ mul ~/ %mul :: multiply - |= {a/@rq b/@rq} ^- @rq + |= {a=@rq b=@rq} ^- @rq ~_ leaf+"rq-fail" (mul:ma a b) :: ++ div ~/ %div :: divide - |= {a/@rq b/@rq} ^- @rq + |= {a=@rq b=@rq} ^- @rq ~_ leaf+"rq-fail" (div:ma a b) :: ++ fma ~/ %fma :: fused multiply-add - |= {a/@rq b/@rq c/@rq} ^- @rq + |= {a=@rq b=@rq c=@rq} ^- @rq ~_ leaf+"rq-fail" (fma:ma a b c) :: ++ sqt ~/ %sqt :: square root - |= {a/@rq} ^- @rq + |= {a=@rq} ^- @rq ~_ leaf+"rq-fail" (sqt:ma a) :: ++ lth ~/ %lth :: less-than - |= {a/@rq b/@rq} + |= {a=@rq b=@rq} ~_ leaf+"rq-fail" (lth:ma a b) :: ++ lte ~/ %lte :: less-equals - |= {a/@rq b/@rq} + |= {a=@rq b=@rq} ~_ leaf+"rq-fail" (lte:ma a b) :: ++ equ ~/ %equ :: equals - |= {a/@rq b/@rq} + |= {a=@rq b=@rq} ~_ leaf+"rq-fail" (equ:ma a b) :: ++ gte ~/ %gte :: greater-equals - |= {a/@rq b/@rq} + |= {a=@rq b=@rq} ~_ leaf+"rq-fail" (gte:ma a b) :: ++ gth ~/ %gth :: greater-than - |= {a/@rq b/@rq} + |= {a=@rq b=@rq} ~_ leaf+"rq-fail" (gth:ma a b) :: - ++ sun |= {a/@u} ^- @rq (sun:ma a) :: uns integer to @rq - ++ san |= {a/@s} ^- @rq (san:ma a) :: sgn integer to @rq - ++ sig |= {a/@rq} ^- ? (sig:ma a) :: get sign - ++ exp |= {a/@rq} ^- @s (exp:ma a) :: get exponent - ++ toi |= {a/@rq} ^- (unit @s) (toi:ma a) :: round to integer - ++ drg |= {a/@rq} ^- dn (drg:ma a) :: @rq to decimal float - ++ grd |= {a/dn} ^- @rq (grd:ma a) :: decimal float to @rq + ++ sun |= {a=@u} ^- @rq (sun:ma a) :: uns integer to @rq + ++ san |= {a=@s} ^- @rq (san:ma a) :: sgn integer to @rq + ++ sig |= {a=@rq} ^- ? (sig:ma a) :: get sign + ++ exp |= {a=@rq} ^- @s (exp:ma a) :: get exponent + ++ toi |= {a=@rq} ^- (unit @s) (toi:ma a) :: round to integer + ++ drg |= {a=@rq} ^- dn (drg:ma a) :: @rq to decimal float + ++ grd |= {a=dn} ^- @rq (grd:ma a) :: decimal float to @rq -- :: ++ rh :: half precision fp ~% %rh +> ~ ^| - |_ r/$?(%n %u %d %z) + |_ r=$?(%n %u %d %z) :: round to nearest, round up, round down, round to zero :: ++ ma %*(. ff w 5, p 10, b --15, r r) :: ++ sea :: @rh to fn - |= {a/@rh} (sea:ma a) + |= {a=@rh} (sea:ma a) :: ++ bit :: fn to @rh - |= {a/fn} ^- @rh (bit:ma a) + |= {a=fn} ^- @rh (bit:ma a) :: ++ add ~/ %add :: add - |= {a/@rh b/@rh} ^- @rh + |= {a=@rh b=@rh} ^- @rh ~_ leaf+"rh-fail" (add:ma a b) :: ++ sub ~/ %sub :: subtract - |= {a/@rh b/@rh} ^- @rh + |= {a=@rh b=@rh} ^- @rh ~_ leaf+"rh-fail" (sub:ma a b) :: ++ mul ~/ %mul :: multiply - |= {a/@rh b/@rh} ^- @rh + |= {a=@rh b=@rh} ^- @rh ~_ leaf+"rh-fail" (mul:ma a b) :: ++ div ~/ %div :: divide - |= {a/@rh b/@rh} ^- @rh + |= {a=@rh b=@rh} ^- @rh ~_ leaf+"rh-fail" (div:ma a b) :: ++ fma ~/ %fma :: fused multiply-add - |= {a/@rh b/@rh c/@rh} ^- @rh + |= {a=@rh b=@rh c=@rh} ^- @rh ~_ leaf+"rh-fail" (fma:ma a b c) :: ++ sqt ~/ %sqt :: square root - |= {a/@rh} ^- @rh + |= {a=@rh} ^- @rh ~_ leaf+"rh-fail" (sqt:ma a) :: ++ lth ~/ %lth :: less-than - |= {a/@rh b/@rh} + |= {a=@rh b=@rh} ~_ leaf+"rh-fail" (lth:ma a b) :: ++ lte ~/ %lte :: less-equals - |= {a/@rh b/@rh} + |= {a=@rh b=@rh} ~_ leaf+"rh-fail" (lte:ma a b) :: ++ equ ~/ %equ :: equals - |= {a/@rh b/@rh} + |= {a=@rh b=@rh} ~_ leaf+"rh-fail" (equ:ma a b) :: ++ gte ~/ %gte :: greater-equals - |= {a/@rh b/@rh} + |= {a=@rh b=@rh} ~_ leaf+"rh-fail" (gte:ma a b) :: ++ gth ~/ %gth :: greater-than - |= {a/@rh b/@rh} + |= {a=@rh b=@rh} ~_ leaf+"rh-fail" (gth:ma a b) :: ++ tos :: @rh to @rs - |= {a/@rh} (bit:rs (sea a)) + |= {a=@rh} (bit:rs (sea a)) :: ++ fos :: @rs to @rh - |= {a/@rs} (bit (sea:rs a)) + |= {a=@rs} (bit (sea:rs a)) :: - ++ sun |= {a/@u} ^- @rh (sun:ma a) :: uns integer to @rh - ++ san |= {a/@s} ^- @rh (san:ma a) :: sgn integer to @rh - ++ sig |= {a/@rh} ^- ? (sig:ma a) :: get sign - ++ exp |= {a/@rh} ^- @s (exp:ma a) :: get exponent - ++ toi |= {a/@rh} ^- (unit @s) (toi:ma a) :: round to integer - ++ drg |= {a/@rh} ^- dn (drg:ma a) :: @rh to decimal float - ++ grd |= {a/dn} ^- @rh (grd:ma a) :: decimal float to @rh + ++ sun |= {a=@u} ^- @rh (sun:ma a) :: uns integer to @rh + ++ san |= {a=@s} ^- @rh (san:ma a) :: sgn integer to @rh + ++ sig |= {a=@rh} ^- ? (sig:ma a) :: get sign + ++ exp |= {a=@rh} ^- @s (exp:ma a) :: get exponent + ++ toi |= {a=@rh} ^- (unit @s) (toi:ma a) :: round to integer + ++ drg |= {a=@rh} ^- dn (drg:ma a) :: @rh to decimal float + ++ grd |= {a=dn} ^- @rh (grd:ma a) :: decimal float to @rh -- :: 3c: urbit time :: :::: :: :: year, yore, yell, yule, yall, yawn, yelp, yo :: :: ++ year :: date to @d - |= det/date + |= det=date ^- @da =+ ^= yer ?: a.det @@ -3149,7 +3149,7 @@ (yule day h.t.det m.t.det s.t.det f.t.det) :: ++ yore :: @d to date - |= now/@da + |= now=@da ^- date =+ rip=(yell now) =+ ger=(yall d.rip) @@ -3159,7 +3159,7 @@ [m.ger d.ger h.rip m.rip s.rip f.rip] :: ++ yell :: tarp from @d - |= now/@d + |= now=@d ^- tarp =+ sec=(rsh 6 1 now) =+ ^= fan @@ -3178,7 +3178,7 @@ [day hor mit sec fan] :: ++ yule :: time atom - |= rip/tarp + |= rip=tarp ^- @d =+ ^= sec ;: add (mul d.rip day:yo) @@ -3195,8 +3195,8 @@ (con (lsh 6 1 sec) fac) :: ++ yall :: day / to day of year - |= day/@ud - ^- {y/@ud m/@ud d/@ud} + |= day=@ud + ^- {y=@ud m=@ud d=@ud} =+ [era=0 cet=0 lep=*?] => .(era (div day era:yo), day (mod day era:yo)) => ^+ . @@ -3205,21 +3205,21 @@ => .(lep |, cet 1, day (sub day +(cet:yo))) .(cet (add cet (div day cet:yo)), day (mod day cet:yo)) =+ yer=(add (mul 400 era) (mul 100 cet)) - |- ^- {y/@ud m/@ud d/@ud} + |- ^- {y=@ud m=@ud d=@ud} =+ dis=?:(lep 366 365) ?. (lth day dis) =+ ner=+(yer) $(yer ner, day (sub day dis), lep =(0 (end 0 2 ner))) - |- ^- {y/@ud m/@ud d/@ud} + |- ^- {y=@ud m=@ud d=@ud} =+ [mot=0 cah=?:(lep moy:yo moh:yo)] - |- ^- {y/@ud m/@ud d/@ud} + |- ^- {y=@ud m=@ud d=@ud} =+ zis=(snag mot cah) ?: (lth day zis) [yer +(mot) +(day)] $(mot +(mot), day (sub day zis)) :: ++ yawn :: days since Jesus - |= {yer/@ud mot/@ud day/@ud} + |= {yer=@ud mot=@ud day=@ud} ^- @ud => .(mot (dec mot), day (dec day)) => ^+ . @@ -3244,7 +3244,7 @@ (add day (mul (div yer 400) (add 1 (mul 4 36.524)))) :: ++ yelp :: leap year - |= yer/@ud ^- ? + |= yer=@ud ^- ? &(=(0 (mod yer 4)) |(!=(0 (mod yer 100)) =(0 (mod yer 400)))) :: ++ yo :: time constants @@ -3263,33 +3263,33 @@ :::: 3d: SHA hash family :: :: :: :: -++ shad |=(ruz/@ (shax (shax ruz))) :: double sha-256 +++ shad |=(ruz=@ (shax (shax ruz))) :: double sha-256 ++ shaf :: half sha-256 - |= {sal/@ ruz/@} + |= {sal=@ ruz=@} =+ haz=(shas sal ruz) (mix (end 7 1 haz) (rsh 7 1 haz)) :: ++ sham :: 128bit noun hash - |= yux/* ^- @uvH ^- @ + |= yux=* ^- @uvH ^- @ ?@ yux (shaf %mash yux) (shaf %sham (jam yux)) :: ++ shas :: salted hash ~/ %shas - |= {sal/@ ruz/@} + |= {sal=@ ruz=@} (shax (mix sal (shax ruz))) :: ++ shax :: sha-256 ~/ %shax - |= ruz/@ ^- @ + |= ruz=@ ^- @ (shay [(met 3 ruz) ruz]) :: ++ shay :: sha-256 with length ~/ %shay - |= {len/@u ruz/@} ^- @ + |= {len=@u ruz=@} ^- @ => .(ruz (cut 3 [0 len] ruz)) - =+ [few==>(fe .(a 5)) wac=|=({a/@ b/@} (cut 5 [a 1] b))] + =+ [few==>(fe .(a 5)) wac=|=({a=@ b=@} (cut 5 [a 1] b))] =+ [sum=sum.few ror=ror.few net=net.few inv=inv.few] =+ ral=(lsh 0 3 len) =+ ^= ful @@ -3372,18 +3372,18 @@ $(j +(j), a (sum q n), b a, c b, d c, e (sum d q), f e, g f, h g) :: ++ shaw :: hash to nbits - |= {sal/@ len/@ ruz/@} + |= {sal=@ len=@ ruz=@} (~(raw og (shas sal (mix len ruz))) len) :: ++ shaz :: sha-512 - |= ruz/@ ^- @ + |= ruz=@ ^- @ (shal [(met 3 ruz) ruz]) :: ++ shal :: sha-512 with length ~/ %shal - |= {len/@ ruz/@} ^- @ + |= {len=@ ruz=@} ^- @ => .(ruz (cut 3 [0 len] ruz)) - =+ [few==>(fe .(a 6)) wac=|=({a/@ b/@} (cut 6 [a 1] b))] + =+ [few==>(fe .(a 6)) wac=|=({a=@ b=@} (cut 6 [a 1] b))] =+ [sum=sum.few ror=ror.few net=net.few inv=inv.few] =+ ral=(lsh 0 3 len) =+ ^= ful @@ -3492,8 +3492,8 @@ $(j +(j), a (sum q n), b a, c b, d c, e (sum d q), f e, g f, h g) :: ++ shan :: sha-1 (deprecated) - |= ruz/@ - =+ [few==>(fe .(a 5)) wac=|=({a/@ b/@} (cut 5 [a 1] b))] + |= ruz=@ + =+ [few==>(fe .(a 5)) wac=|=({a=@ b=@} (cut 5 [a 1] b))] =+ [sum=sum.few ror=ror.few rol=rol.few net=net.few inv=inv.few] =+ ral=(lsh 0 3 (met 3 ruz)) =+ ^= ful @@ -3559,22 +3559,22 @@ :: ++ og :: shax-powered rng ~/ %og - |_ a/@ + |_ a=@ ++ rad :: random in range - |= b/@ ^- @ + |= b=@ ^- @ ~_ leaf+"rad-zero" ?< =(0 b) =+ c=(raw (met 0 b)) ?:((lth c b) c $(a +(a))) :: ++ rads :: random continuation - |= b/@ + |= b=@ =+ r=(rad b) [r +>.$(a (shas %og-s (mix a r)))] :: ++ raw :: random bits ~/ %raw - |= b/@ ^- @ + |= b=@ ^- @ %+ can 0 =+ c=(shas %og-a (mix b a)) @@ -3587,7 +3587,7 @@ [[256 d] $(c d, b (sub b 256))] :: ++ raws :: random bits - |= b/@ :: continuation + |= b=@ :: continuation =+ r=(raw b) [r +>.$(a (shas %og-s (mix a r)))] -- @@ -3596,7 +3596,7 @@ ~% %sha ..sha ~ => |% ++ flin |=(a=@ (swp 3 a)) :: flip input - ++ flim |=(byts [wid (rev 3 wid dat)]) :: flip input w/ length + ++ flim |=(byts [wid (rev 3 wid dat)]) :: flip input w= length ++ flip |=(w=@u (cury (cury rev 3) w)) :: flip output of size ++ meet |=(a=@ [(met 3 a) a]) :: measure input size -- @@ -3617,7 +3617,7 @@ ~/ %sha1 |= byts ^- @ - =+ [few==>(fe .(a 5)) wac=|=({a/@ b/@} (cut 5 [a 1] b))] + =+ [few==>(fe .(a 5)) wac=|=({a=@ b=@} (cut 5 [a 1] b))] =+ [sum=sum.few ror=ror.few rol=rol.few net=net.few inv=inv.few] =+ ral=(lsh 0 3 wid) =+ ^= ful @@ -3693,7 +3693,7 @@ ++ un :: =(x (wred (wren x))) |% ++ wren :: conceal structure - |= pyn/@ ^- @ + |= pyn=@ ^- @ =+ len=(met 3 pyn) ?: =(0 len) 0 @@ -3710,7 +3710,7 @@ [[1 mog] $(mig mog)] :: ++ wred :: restore structure - |= cry/@ ^- @ + |= cry=@ ^- @ =+ len=(met 3 cry) ?: =(0 len) 0 @@ -3726,11 +3726,11 @@ =+ mog=(cut 3 [len 1] cry) [[1 :(mix mig (end 3 1 len) (zyrt mog))] $(mig mog)] :: - ++ xafo |=({a/@ b/@} +((mod (add (dec b) a) 255))) - ++ xaro |=({a/@ b/@} +((mod (add (dec b) (sub 255 (mod a 255))) 255))) + ++ xafo |=({a=@ b=@} +((mod (add (dec b) a) 255))) + ++ xaro |=({a=@ b=@} +((mod (add (dec b) (sub 255 (mod a 255))) 255))) :: ++ zaft :: forward 255-sbox - |= a/@D + |= a=@D =+ ^= b 0xcc.75bc.86c8.2fb1.9a42.f0b3.79a0.92ca.21f6.1e41.cde5.fcc0. 7e85.51ae.1005.c72d.1246.07e8.7c64.a914.8d69.d9f4.59c2.8038. @@ -3746,7 +3746,7 @@ (cut 3 [(dec a) 1] b) :: ++ zart :: reverse 255-sbox - |= a/@D + |= a=@D =+ ^= b 0x68.4f07.ea1c.73c9.75c2.efc8.d559.5125.f621.a7a8.8591.5613. dd52.40eb.65a2.60b7.4bcb.1123.ceb0.1bd6.3c84.2906.b164.19b3. @@ -3762,7 +3762,7 @@ (cut 3 [(dec a) 1] b) :: ++ zyft :: forward 256-sbox - |= a/@D + |= a=@D =+ ^= b 0xbb49.b71f.b881.b402.17e4.6b86.69b5.1647.115f.dddb.7ca5. 8371.4bd5.19a9.b092.605d.0d9b.e030.a0cc.78ba.5706.4d2d. @@ -3779,7 +3779,7 @@ (cut 3 [a 1] b) :: ++ zyrt :: reverse 256-sbox - |= a/@D + |= a=@D =+ ^= b 0x9fc8.2753.6e02.8fcf.8b35.2b20.5598.7caa.c9a9.30b0.9b48. 47ce.6371.80f6.407d.00dd.0aa5.ed10.ecb7.0f5a.5c3a.e605. @@ -3811,7 +3811,7 @@ :: ++ fein ~/ %fein - |= pyn/@ ^- @ + |= pyn=@ ^- @ ?: &((gte pyn 0x1.0000) (lte pyn 0xffff.ffff)) (add 0x1.0000 (feis (sub pyn 0x1.0000))) ?: &((gte pyn 0x1.0000.0000) (lte pyn 0xffff.ffff.ffff.ffff)) @@ -3827,7 +3827,7 @@ :: ++ fynd ~/ %fynd - |= cry/@ ^- @ + |= cry=@ ^- @ ?: &((gte cry 0x1.0000) (lte cry 0xffff.ffff)) (add 0x1.0000 (tail (sub cry 0x1.0000))) ?: &((gte cry 0x1.0000.0000) (lte cry 0xffff.ffff.ffff.ffff)) @@ -3998,31 +3998,31 @@ :::: 3g: molds and mold builders :: ++ coin $~ [%$ %ud 0] :: print format - $% {%$ p/dime} :: - {%blob p/*} :: - {%many p/(list coin)} :: + $% {%$ p=dime} :: + {%blob p=*} :: + {%many p=(list coin)} :: == :: -++ dime {p/@ta q/@} :: -++ edge {p/hair q/(unit {p/* q/nail})} :: parsing output -++ hair {p/@ud q/@ud} :: parsing trace -++ like |* a/$-(* *) :: generic edge +++ dime {p=@ta q=@} :: +++ edge {p=hair q=(unit {p=* q=nail})} :: parsing output +++ hair {p=@ud q=@ud} :: parsing trace +++ like |* a=$-(* *) :: generic edge |: b=`*`[(hair) ~] :: :- p=(hair -.b) :: ^= q :: ?@ +.b ~ :: :- ~ :: u=[p=(a +>-.b) q=[p=(hair -.b) q=(tape +.b)]] :: -++ nail {p/hair q/tape} :: parsing input -++ pint {p/{p/@ q/@} q/{p/@ q/@}} :: line+column range +++ nail {p=hair q=tape} :: parsing input +++ pint {p={p=@ q=@} q={p=@ q=@}} :: line+column range ++ rule _|:($:nail $:edge) :: parsing rule -++ spot {p/path q/pint} :: range in file -++ tone $% {%0 product/*} :: success - {%1 block/*} :: single block - {%2 trace/(list {@ta *})} :: error report +++ spot {p=path q=pint} :: range in file +++ tone $% {%0 product=*} :: success + {%1 block=*} :: single block + {%2 trace=(list {@ta *})} :: error report == :: -++ toon $% {%0 p/*} :: success - {%1 p/*} :: block - {%2 p/(list tank)} :: stack trace +++ toon $% {%0 p=*} :: success + {%1 p=*} :: block + {%2 p=(list tank)} :: stack trace == :: ++ wonk =+ veq=$:edge :: product from edge |@ ++ $ ?~(q.veq !! p.u.q.veq) :: @@ -4096,40 +4096,40 @@ /lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes' |% ++ ins ~/ %ins :: parse prefix - |= a/@tas + |= a=@tas =+ b=0 |- ^- (unit @) ?:(=(256 b) ~ ?:(=(a (tos b)) [~ b] $(b +(b)))) ++ ind ~/ %ind :: parse suffix - |= a/@tas + |= a=@tas =+ b=0 |- ^- (unit @) ?:(=(256 b) ~ ?:(=(a (tod b)) [~ b] $(b +(b)))) ++ tos ~/ %tos :: fetch prefix - |=(a/@ ?>((lth a 256) (cut 3 [(mul 3 a) 3] sis))) + |=(a=@ ?>((lth a 256) (cut 3 [(mul 3 a) 3] sis))) ++ tod ~/ %tod :: fetch suffix - |=(a/@ ?>((lth a 256) (cut 3 [(mul 3 a) 3] dex))) + |=(a=@ ?>((lth a 256) (cut 3 [(mul 3 a) 3] dex))) -- :: ++ fa :: base58check =+ key='123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' - =/ yek/@ux ~+ + =/ yek=@ux ~+ =- yek:(roll (rip 3 key) -) =+ [a=*char b=*@ yek=`@ux`(fil 3 256 0xff)] |. [+(b) (mix yek (lsh 3 `@u`a (~(inv fe 3) b)))] |% - ++ cha |=(a/char `(unit @uF)`=+(b=(cut 3 [`@`a 1] yek) ?:(=(b 0xff) ~ `b))) + ++ cha |=(a=char `(unit @uF)`=+(b=(cut 3 [`@`a 1] yek) ?:(=(b 0xff) ~ `b))) ++ tok - |= a/@ux ^- @ux + |= a=@ux ^- @ux =+ b=(pad a) =- (~(net fe 5) (end 3 4 (shay 32 -))) (shay (add b (met 3 a)) (lsh 3 b (swp 3 a))) :: - ++ pad |=(a/@ =+(b=(met 3 a) ?:((gte b 21) 0 (sub 21 b)))) - ++ enc |=(a/@ux `@ux`(mix (lsh 3 4 a) (tok a))) + ++ pad |=(a=@ =+(b=(met 3 a) ?:((gte b 21) 0 (sub 21 b)))) + ++ enc |=(a=@ux `@ux`(mix (lsh 3 4 a) (tok a))) ++ den - |= a/@ux ^- (unit @ux) + |= a=@ux ^- (unit @ux) =+ b=(rsh 3 4 a) ?. =((tok b) (end 3 4 a)) ~ @@ -4139,7 +4139,7 @@ :::: 4b: text processing :: ++ at :: basic printing - |_ a/@ + |_ a=@ ++ r ?: ?& (gte (met 3 a) 2) |- @@ -4160,10 +4160,10 @@ ++ rt `tape`['\'' (weld (mesc (trip a)) `tape`['\'' ~])] ++ rta rt ++ rtam `tape`['%' (trip a)] - ++ rub `tape`['0' 'b' (rum 2 ~ |=(b/@ (add '0' b)))] - ++ rud (rum 10 ~ |=(b/@ (add '0' b))) + ++ rub `tape`['0' 'b' (rum 2 ~ |=(b=@ (add '0' b)))] + ++ rud (rum 10 ~ |=(b=@ (add '0' b))) ++ rum - |= {b/@ c/tape d/$-(@ @)} + |= {b=@ c=tape d=$-(@ @)} ^- tape ?: =(0 a) [(d 0) c] @@ -4207,29 +4207,29 @@ %^ rum 64 ~ - |= b/@ + |= b=@ ?: =(63 b) '+' ?: =(62 b) '-' ?:((lth b 26) (add 65 b) ?:((lth b 52) (add 71 b) (sub b 4))) :: - ++ rux `tape`['0' 'x' (rum 16 ~ |=(b/@ (add b ?:((lth b 10) 48 87))))] + ++ rux `tape`['0' 'x' (rum 16 ~ |=(b=@ (add b ?:((lth b 10) 48 87))))] -- ++ cass :: lowercase - |= vib/tape + |= vib=tape ^- tape - (turn vib |=(a/@ ?.(&((gte a 'A') (lte a 'Z')) a (add 32 a)))) + (turn vib |=(a=@ ?.(&((gte a 'A') (lte a 'Z')) a (add 32 a)))) :: ++ cuss :: uppercase - |= vib/tape + |= vib=tape ^- tape - (turn vib |=(a/@ ?.(&((gte a 'a') (lte a 'z')) a (sub a 32)))) + (turn vib |=(a=@ ?.(&((gte a 'a') (lte a 'z')) a (sub a 32)))) :: -++ crip |=(a/tape `@t`(rap 3 a)) :: tape to cord +++ crip |=(a=tape `@t`(rap 3 a)) :: tape to cord :: ++ mesc :: ctrl code escape - |= vib/tape + |= vib=tape ^- tape ?~ vib ~ @@ -4240,19 +4240,19 @@ [i.vib $(vib t.vib)] :: ++ runt :: prepend repeatedly - |= {{a/@ b/@} c/tape} + |= {{a=@ b=@} c=tape} ^- tape ?: =(0 a) c [b $(a (dec a))] :: ++ sand :: atom sanity - |= a/@ta + |= a=@ta (flit (sane a)) :: ++ sane :: atom sanity - |= a/@ta - |= b/@ ^- ? + |= a=@ta + |= b=@ ^- ? ?. =(%t (end 3 1 a)) :: XX more and better sanity :: @@ -4288,15 +4288,15 @@ == :: ++ ruth :: biblical sanity - |= {a/@ta b/*} + |= {a=@ta b=*} ^- @ ?^ b !! :: ?. ((sane a) b) !! b :: ++ trim :: tape split - |= {a/@ b/tape} - ^- {p/tape q/tape} + |= {a=@ b=tape} + ^- {p=tape q=tape} ?~ b [~ ~] ?: =(0 a) @@ -4306,13 +4306,13 @@ :: ++ trip :: cord to tape ~/ %trip - |= a/@ ^- tape + |= a=@ ^- tape ?: =(0 (met 3 a)) ~ [^-(@ta (end 3 1 a)) $(a (rsh 3 1 a))] :: ++ teff :: length utf8 - |= a/@t ^- @ + |= a=@t ^- @ =+ b=(end 3 1 a) ?: =(0 b) ?>(=(`@`0 a) 0) @@ -4320,7 +4320,7 @@ ?:((lte b 127) 1 ?:((lte b 223) 2 ?:((lte b 239) 3 4))) :: ++ taft :: utf8 to utf32 - |= a/@t + |= a=@t ^- @c %+ rap 5 |- ^- (list @c) @@ -4329,30 +4329,30 @@ =+ ^= c %+ can 0 %+ turn - ^- (list {p/@ q/@}) + ^- (list {p=@ q=@}) ?+ b !! %1 [[0 7] ~] %2 [[8 6] [0 5] ~] %3 [[16 6] [8 6] [0 4] ~] %4 [[24 6] [16 6] [8 6] [0 3] ~] == - |=({p/@ q/@} [q (cut 0 [p q] a)]) + |=({p=@ q=@} [q (cut 0 [p q] a)]) ?> =((tuft c) (end 3 b a)) [c $(a (rsh 3 b a))] :: ++ tuba :: utf8 to utf32 tape - |= a/tape + |= a=tape ^- (list @c) (rip 5 (taft (rap 3 a))) :: XX horrible :: ++ tufa :: utf32 to utf8 tape - |= a/(list @c) + |= a=(list @c) ^- tape ?~ a "" (weld (rip 3 (tuft i.a)) $(a t.a)) :: ++ tuft :: utf32 to utf8 text - |= a/@c + |= a=@c ^- @t %+ rap 3 |- ^- (list @) @@ -4381,7 +4381,7 @@ == :: ++ wack :: knot escape - |= a/@ta + |= a=@ta ^- @ta =+ b=(rip 3 a) %+ rap 3 @@ -4393,12 +4393,12 @@ [i.b $(b t.b)] :: ++ wick :: knot unescape - |= a/@ + |= a=@ ^- (unit @ta) =+ b=(rip 3 a) =- ?^(b ~ (some (rap 3 (flop c)))) - =| c/tape - |- ^- {b/tape c/tape} + =| c=tape + |- ^- {b=tape c=tape} ?~ b [~ c] ?. =('~' i.b) $(b t.b, c [i.b c]) @@ -4410,7 +4410,7 @@ == :: ++ woad :: cord unescape - |= a/@ta + |= a=@ta ^- @t %+ rap 3 |- ^- (list @) @@ -4426,7 +4426,7 @@ ?+ b =- (weld (rip 3 (tuft p.d)) $(a q.d)) ^= d =+ d=0 - |- ^- {p/@ q/@} + |- ^- {p=@ q=@} ?: =('.' b) [d c] ?< =(0 c) @@ -4443,7 +4443,7 @@ == :: ++ wood :: cord escape - |= a/@t + |= a=@t ^- @ta %+ rap 3 |- ^- (list @) @@ -4475,7 +4475,7 @@ :::: 4c: tank printer :: ++ wash :: render tank at width - |= {{tab/@ edg/@} tac/tank} ^- wall + |= {{tab=@ edg=@} tac=tank} ^- wall (~(win re tac) tab edg) :: :: |re: tank renderer @@ -4608,48 +4608,48 @@ -- -- ++ show :: XX deprecated! - |= vem/* + |= vem=* |^ ^- tank ?: ?=(@ vem) [%leaf (mesc (trip vem))] ?- vem - {s/~ c/*} + {s=~ c=*} [%leaf '\'' (weld (mesc (tape +.vem)) `tape`['\'' ~])] :: - {s/%a c/@} [%leaf (mesc (trip c.vem))] - {s/%b c/*} (shop c.vem |=(a/@ ~(rub at a))) - {s/{%c p/@} c/*} + {s=%a c=@} [%leaf (mesc (trip c.vem))] + {s=%b c=*} (shop c.vem |=(a=@ ~(rub at a))) + {s={%c p=@} c=*} :+ %palm [['.' ~] ['-' ~] ~ ~] [[%leaf (mesc (trip p.s.vem))] $(vem c.vem) ~] :: - {s/%d c/*} (shop c.vem |=(a/@ ~(rud at a))) - {s/%k c/*} (tank c.vem) - {s/%h c/*} + {s=%d c=*} (shop c.vem |=(a=@ ~(rud at a))) + {s=%k c=*} (tank c.vem) + {s=%h c=*} :+ %rose [['/' ~] ['/' ~] ~] =+ yol=((list @ta) c.vem) - (turn yol |=(a/@ta [%leaf (trip a)])) + (turn yol |=(a=@ta [%leaf (trip a)])) :: - {s/%l c/*} (shol c.vem) - {s/%o c/*} + {s=%l c=*} (shol c.vem) + {s=%o c=*} %= $ vem :- [%m '%h::[%d %d].[%d %d]>'] [-.c.vem +<-.c.vem +<+.c.vem +>-.c.vem +>+.c.vem ~] == :: - {s/%p c/*} (shop c.vem |=(a/@ ~(rup at a))) - {s/%q c/*} (shop c.vem |=(a/@ ~(r at a))) - {s/%r c/*} $(vem [[%r ' ' '{' '}'] c.vem]) - {s/%t c/*} (shop c.vem |=(a/@ ~(rt at a))) - {s/%v c/*} (shop c.vem |=(a/@ ~(ruv at a))) - {s/%x c/*} (shop c.vem |=(a/@ ~(rux at a))) - {s/{%m p/@} c/*} (shep p.s.vem c.vem) - {s/{%r p/@} c/*} + {s=%p c=*} (shop c.vem |=(a=@ ~(rup at a))) + {s=%q c=*} (shop c.vem |=(a=@ ~(r at a))) + {s=%r c=*} $(vem [[%r ' ' '{' '}'] c.vem]) + {s=%t c=*} (shop c.vem |=(a=@ ~(rt at a))) + {s=%v c=*} (shop c.vem |=(a=@ ~(ruv at a))) + {s=%x c=*} (shop c.vem |=(a=@ ~(rux at a))) + {s={%m p=@} c=*} (shep p.s.vem c.vem) + {s={%r p=@} c=*} $(vem [[%r ' ' (cut 3 [0 1] p.s.vem) (cut 3 [1 1] p.s.vem)] c.vem]) :: - {s/{%r p/@ q/@ r/@} c/*} + {s={%r p=@ q=@ r=@} c=*} :+ %rose :* p=(mesc (trip p.s.vem)) q=(mesc (trip q.s.vem)) @@ -4660,11 +4660,11 @@ ~ [^$(vem -.c.vem) $(c.vem +.c.vem)] :: - {s/%z c/*} $(vem [[%r %$ %$ %$] c.vem]) + {s=%z c=*} $(vem [[%r %$ %$ %$] c.vem]) * !! == ++ shep - |= {fom/@ gar/*} + |= {fom=@ gar=*} ^- tank =+ l=(met 3 fom) =+ i=0 @@ -4681,7 +4681,7 @@ (weld ~(ram re (show d -.gar)) $(i (add 2 i), gar +.gar)) :: ++ shop - |= {aug/* vel/$-(a/@ tape)} + |= {aug=* vel=$-(a=@ tape)} ^- tank ?: ?=(@ aug) [%leaf (vel aug)] @@ -4694,7 +4694,7 @@ [^$(aug -.aug) $(aug +.aug)] :: ++ shol - |= lim/* + |= lim=* :+ %rose [['.' ~] ~ ~] |- ^- (list tank) @@ -4702,26 +4702,26 @@ :_ $(lim +.lim) ?+ -.lim (show '#') ~ (show '$') - c/@ (show c.lim) + c=@ (show c.lim) {%& %1} (show '.') - {%& c/@} + {%& c=@} [%leaf '+' ~(rud at c.lim)] :: {%| @ ~} (show ',') - {%| n/@ ~ c/@} + {%| n=@ ~ c=@} [%leaf (weld (reap n.lim '^') ?~(c.lim "$" (trip c.lim)))] == -- :: :::: 4d: parsing (tracing) :: -++ last |= {zyc/hair naz/hair} :: farther trace +++ last |= {zyc=hair naz=hair} :: farther trace ^- hair ?: =(p.zyc p.naz) ?:((gth q.zyc q.naz) zyc naz) ?:((gth p.zyc p.naz) zyc naz) :: -++ lust |= {weq/char naz/hair} :: detect newline +++ lust |= {weq=char naz=hair} :: detect newline ^- hair ?:(=(`@`10 weq) [+(p.naz) 1] [p.naz +(q.naz)]) :: @@ -4729,11 +4729,11 @@ :: ++ bend :: conditional comp ~/ %bend - =+ raq=|*({a/* b/*} [~ u=[a b]]) + =+ raq=|*({a=* b=*} [~ u=[a b]]) |@ ++ $ ~/ %fun - |* {vex/edge sab/rule} + |* {vex=edge sab=rule} ?~ q.vex vex =+ yit=(sab q.u.q.vex) @@ -4748,11 +4748,11 @@ :: ++ comp ~/ %comp - =+ raq=|*({a/* b/*} [a b]) :: arbitrary compose + =+ raq=|*({a=* b=*} [a b]) :: arbitrary compose |@ ++ $ ~/ %fun - |* {vex/edge sab/rule} + |* {vex=edge sab=rule} ~! +< ?~ q.vex vex @@ -4763,16 +4763,16 @@ [p=yur q=[~ u=[p=(raq p.u.q.vex p.u.q.yit) q=q.u.q.yit]]] -- :: -++ fail |=(tub/nail [p=p.tub q=~]) :: never parse +++ fail |=(tub=nail [p=p.tub q=~]) :: never parse ++ glue :: add rule ~/ %glue - |* bus/rule + |* bus=rule ~/ %fun - |* {vex/edge sab/rule} + |* {vex=edge sab=rule} (plug vex ;~(pfix bus sab)) :: ++ less :: no first and second - |* {vex/edge sab/rule} + |* {vex=edge sab=rule} ?~ q.vex =+ roq=(sab) [p=(last p.vex p.roq) q=q.roq] @@ -4780,13 +4780,13 @@ :: ++ pfix :: discard first rule ~/ %pfix - |* sam={vex/edge sab/rule} + |* sam={vex=edge sab=rule} %. sam - (comp |*({a/* b/*} b)) + (comp |*({a=* b=*} b)) :: ++ plug :: first then second ~/ %plug - |* {vex/edge sab/rule} + |* {vex=edge sab=rule} ?~ q.vex vex =+ yit=(sab q.u.q.vex) @@ -4797,14 +4797,14 @@ :: ++ pose :: first or second ~/ %pose - |* {vex/edge sab/rule} + |* {vex=edge sab=rule} ?~ q.vex =+ roq=(sab) [p=(last p.vex p.roq) q=q.roq] vex :: ++ simu :: first and second - |* {vex/edge sab/rule} + |* {vex=edge sab=rule} ?~ q.vex vex =+ roq=(sab) @@ -4812,35 +4812,35 @@ :: ++ sfix :: discard second rule ~/ %sfix - |* sam={vex/edge sab/rule} + |* sam={vex=edge sab=rule} %. sam - (comp |*({a/* b/*} a)) + (comp |*({a=* b=*} a)) :: :::: 4f: parsing (rule builders) :: ++ bass :: leftmost base - |* {wuc/@ tyd/rule} + |* {wuc=@ tyd=rule} %+ cook - |= waq/(list @) + |= waq=(list @) %+ roll waq - =|({p/@ q/@} |.((add p (mul wuc q)))) + =|({p=@ q=@} |.((add p (mul wuc q)))) tyd :: ++ boss :: rightmost base - |* {wuc/@ tyd/rule} + |* {wuc=@ tyd=rule} %+ cook - |= waq/(list @) + |= waq=(list @) %+ reel waq - =|({p/@ q/@} |.((add p (mul wuc q)))) + =|({p=@ q=@} |.((add p (mul wuc q)))) tyd :: ++ cold :: replace w+ constant ~/ %cold - |* {cus/* sef/rule} + |* {cus=* sef=rule} ~/ %fun - |= tub/nail + |= tub=nail =+ vex=(sef tub) ?~ q.vex vex @@ -4848,9 +4848,9 @@ :: ++ cook :: apply gate ~/ %cook - |* {poq/gate sef/rule} + |* {poq=gate sef=rule} ~/ %fun - |= tub/nail + |= tub=nail =+ vex=(sef tub) ?~ q.vex vex @@ -4858,41 +4858,41 @@ :: ++ easy :: always parse ~/ %easy - |* huf/* + |* huf=* ~/ %fun - |= tub/nail + |= tub=nail ^- (like _huf) [p=p.tub q=[~ u=[p=huf q=tub]]] :: ++ fuss - |= {sic/@t non/@t} + |= {sic=@t non=@t} ;~(pose (cold %& (jest sic)) (cold %| (jest non))) :: ++ full :: has to fully parse - |* sef/rule - |= tub/nail + |* sef=rule + |= tub=nail =+ vex=(sef tub) ?~(q.vex vex ?:(=(~ q.q.u.q.vex) vex [p=p.vex q=~])) :: ++ funk :: add to tape first - |* {pre/tape sef/rule} - |= tub/nail + |* {pre=tape sef=rule} + |= tub=nail (sef p.tub (weld pre q.tub)) :: ++ here :: place-based apply ~/ %here - =+ [hez=|=({a/pint b/*} [a b]) sef=*rule] + =+ [hez=|=({a=pint b=*} [a b]) sef=*rule] |@ ++ $ ~/ %fun - |= tub/nail + |= tub=nail =+ vex=(sef tub) ?~ q.vex vex [p=p.vex q=[~ u=[p=(hez [p.tub p.q.u.q.vex] p.u.q.vex) q=q.u.q.vex]]] -- :: -++ inde |* sef/rule :: indentation block +++ inde |* sef=rule :: indentation block |= nail ^+ (sef) =+ [har tap]=[p q]:+< =+ lev=(fil 3 (dec q.har) ' ') @@ -4912,15 +4912,15 @@ (welp [`@t`10 (trip lev)] $(res +.res)) :: ++ ifix - |* {fel/{rule rule} hof/rule} + |* {fel={rule rule} hof=rule} ~! +< ~! +<:-.fel ~! +<:+.fel ;~(pfix -.fel ;~(sfix hof +.fel)) :: ++ jest :: match a cord - |= daf/@t - |= tub/nail + |= daf=@t + |= tub=nail =+ fad=daf |- ^- (like @t) ?: =(`@`0 daf) @@ -4931,9 +4931,9 @@ :: ++ just :: XX redundant, jest ~/ %just :: match a char - |= daf/char + |= daf=char ~/ %fun - |= tub/nail + |= tub=nail ^- (like char) ?~ q.tub (fail tub) @@ -4942,35 +4942,35 @@ (next tub) :: ++ knee :: callbacks - =| {gar/* sef/_|.(*rule)} + =| {gar=* sef=_|.(*rule)} |@ ++ $ - |= tub/nail + |= tub=nail ^- (like _gar) ((sef) tub) -- :: ++ mask :: match char in set ~/ %mask - |= bud/(list char) + |= bud=(list char) ~/ %fun - |= tub/nail + |= tub=nail ^- (like char) ?~ q.tub (fail tub) - ?. (lien bud |=(a/char =(i.q.tub a))) + ?. (lien bud |=(a=char =(i.q.tub a))) (fail tub) (next tub) :: ++ more :: separated, * - |* {bus/rule fel/rule} + |* {bus=rule fel=rule} ;~(pose (most bus fel) (easy ~)) :: ++ most :: separated, + - |* {bus/rule fel/rule} + |* {bus=rule fel=rule} ;~(plug fel (star ;~(pfix bus fel))) :: ++ next :: consume a char - |= tub/nail + |= tub=nail ^- (like char) ?~ q.tub (fail tub) @@ -4978,7 +4978,7 @@ [zac [~ i.q.tub [zac t.q.tub]]] :: ++ perk :: parse cube fork - |* a/(pole @tas) + |* a=(pole @tas) ?~ a fail ;~ pose (cold -.a (jest -.a)) @@ -4986,16 +4986,16 @@ == :: ++ pick :: rule for ++each - |* {a/rule b/rule} + |* {a=rule b=rule} ;~ pose (stag %& a) (stag %| b) == -++ plus |*(fel/rule ;~(plug fel (star fel))) :: -++ punt |*({a/rule} ;~(pose (stag ~ a) (easy ~))) :: +++ plus |*(fel=rule ;~(plug fel (star fel))) :: +++ punt |*({a=rule} ;~(pose (stag ~ a) (easy ~))) :: ++ sear :: conditional cook - |* {pyq/$-(* (unit)) sef/rule} - |= tub/nail + |* {pyq=$-(* (unit)) sef=rule} + |= tub=nail =+ vex=(sef tub) ?~ q.vex vex @@ -5006,9 +5006,9 @@ :: ++ shim :: match char in range ~/ %shim - |= {les/@ mos/@} + |= {les=@ mos=@} ~/ %fun - |= tub/nail + |= tub=nail ^- (like char) ?~ q.tub (fail tub) @@ -5018,16 +5018,16 @@ :: ++ stag :: add a label ~/ %stag - |* {gob/* sef/rule} + |* {gob=* sef=rule} ~/ %fun - |= tub/nail + |= tub=nail =+ vex=(sef tub) ?~ q.vex vex [p=p.vex q=[~ u=[p=[gob p.u.q.vex] q=q.u.q.vex]]] :: ++ stet :: - |* leh/(list {?(@ {@ @}) rule}) + |* leh=(list {?(@ {@ @}) rule}) |- ?~ leh ~ @@ -5035,9 +5035,9 @@ :: ++ stew :: switch by first char ~/ %stew - |* leh/(list {p/?(@ {@ @}) q/rule}) :: char+range keys + |* leh=(list {p=?(@ {@ @}) q=rule}) :: char+range keys =+ ^= wor :: range complete lth - |= {ort/?(@ {@ @}) wan/?(@ {@ @})} + |= {ort=?(@ {@ @}) wan=?(@ {@ @})} ?@ ort ?@(wan (lth ort wan) (lth ort -.wan)) ?@(wan (lth +.ort wan) (lth +.ort -.wan)) @@ -5062,7 +5062,7 @@ [n.yal l.yal nuc] [n.nuc [n.yal l.yal l.nuc] r.nuc] ~% %fun ..^$ ~ - |= tub/nail + |= tub=nail ?~ q.tub (fail tub) |- @@ -5078,13 +5078,13 @@ $(hel r.hel) :: ++ slug :: - |* raq/_=>(~ |*({a/* b/*} [a b])) - |* {bus/rule fel/rule} + |* raq=_=>(~ |*({a=* b=*} [a b])) + |* {bus=rule fel=rule} ;~((comp raq) fel (stir +<+.raq raq ;~(pfix bus fel))) :: ++ star :: 0 or more times - |* fel/rule - (stir `(list _(wonk *fel))`~ |*({a/* b/*} [a b]) fel) + |* fel=rule + (stir `(list _(wonk *fel))`~ |*({a=* b=*} [a b]) fel) :: ++ stir ~/ %stir @@ -5115,8 +5115,8 @@ :: ++ stun :: parse several times ~/ %stun - |* {lig/{@ @} fel/rule} - |= tub/nail + |* {lig={@ @} fel=rule} + |= tub=nail ^- (like (list _(wonk (fel)))) ?: =(0 +.lig) [p.tub [~ ~ tub]] @@ -5136,19 +5136,19 @@ :: :::: 4g: parsing (outside caller) :: -++ rash |*({naf/@ sab/rule} (scan (trip naf) sab)) -++ rose |* {los/tape sab/rule} +++ rash |*({naf=@ sab=rule} (scan (trip naf) sab)) +++ rose |* {los=tape sab=rule} =+ vex=(sab [[1 1] los]) =+ len=(lent los) ?. =(+(len) q.p.vex) [%| p=(dec q.p.vex)] ?~ q.vex [%& p=~] [%& p=[~ u=p.u.q.vex]] -++ rush |*({naf/@ sab/rule} (rust (trip naf) sab)) -++ rust |* {los/tape sab/rule} +++ rush |*({naf=@ sab=rule} (rust (trip naf) sab)) +++ rust |* {los=tape sab=rule} =+ vex=((full sab) [[1 1] los]) ?~(q.vex ~ [~ u=p.u.q.vex]) -++ scan |* {los/tape sab/rule} +++ scan |* {los=tape sab=rule} =+ vex=((full sab) [[1 1] los]) ?~ q.vex ~_ (show [%m '{%d %d}'] p.p.vex q.p.vex ~) @@ -5218,10 +5218,10 @@ ++ alp ;~(pose low hig nud hep) :: alphanumeric and - ++ bet ;~(pose (cold 2 hep) (cold 3 lus)) :: axis syntax - + ++ bin (bass 2 (most gon but)) :: binary to atom -++ but (cook |=(a/@ (sub a '0')) (shim '0' '1')) :: binary digit -++ cit (cook |=(a/@ (sub a '0')) (shim '0' '7')) :: octal digit +++ but (cook |=(a=@ (sub a '0')) (shim '0' '1')) :: binary digit +++ cit (cook |=(a=@ (sub a '0')) (shim '0' '7')) :: octal digit ++ dem (bass 10 (most gon dit)) :: decimal to atom -++ dit (cook |=(a/@ (sub a '0')) (shim '0' '9')) :: decimal digit +++ dit (cook |=(a=@ (sub a '0')) (shim '0' '9')) :: decimal digit ++ dog ;~(plug dot gay) :: . number separator ++ dof ;~(plug hep gay) :: - @q separator ++ doh ;~(plug ;~(plug hep hep) gay) :: -- phon separator @@ -5242,11 +5242,11 @@ ++ hig (shim 'A' 'Z') :: uppercase ++ hit ;~ pose :: hex digits dit - (cook |=(a/char (sub a 87)) (shim 'a' 'f')) - (cook |=(a/char (sub a 55)) (shim 'A' 'F')) + (cook |=(a=char (sub a 87)) (shim 'a' 'f')) + (cook |=(a=char (sub a 55)) (shim 'A' 'F')) == ++ iny :: indentation block - |* sef/rule + |* sef=rule |= nail ^+ (sef) =+ [har tap]=[p q]:+< =+ lev=(fil 3 (dec q.har) ' ') @@ -5267,7 +5267,7 @@ :: ++ low (shim 'a' 'z') :: lowercase ++ mes %+ cook :: hexbyte - |=({a/@ b/@} (add (mul 16 a) b)) + |=({a=@ b=@} (add (mul 16 a) b)) ;~(plug hit hit) ++ nix (boss 256 (star ;~(pose aln cab))) :: ++ nud (shim '0' '9') :: numeric @@ -5295,18 +5295,18 @@ ++ soz ;~(plug soq soq soq) :: delimiting ''' ++ sym :: symbol %+ cook - |=(a/tape (rap 3 ^-((list @) a))) + |=(a=tape (rap 3 ^-((list @) a))) ;~(plug low (star ;~(pose nud low hep))) :: ++ mixed-case-symbol %+ cook - |=(a/tape (rap 3 ^-((list @) a))) + |=(a=tape (rap 3 ^-((list @) a))) ;~(plug alf (star alp)) :: -++ ven ;~ (comp |=({a/@ b/@} (peg a b))) :: +>- axis syntax +++ ven ;~ (comp |=({a=@ b=@} (peg a b))) :: +>- axis syntax bet =+ hom=`?`| - |= tub/nail + |= tub=nail ^- (like @) =+ vex=?:(hom (bet tub) (gul tub)) ?~ q.vex @@ -5317,9 +5317,9 @@ == ++ vit :: base64 digit ;~ pose - (cook |=(a/@ (sub a 65)) (shim 'A' 'Z')) - (cook |=(a/@ (sub a 71)) (shim 'a' 'z')) - (cook |=(a/@ (add a 4)) (shim '0' '9')) + (cook |=(a=@ (sub a 65)) (shim 'A' 'Z')) + (cook |=(a=@ (sub a 71)) (shim 'a' 'z')) + (cook |=(a=@ (add a 4)) (shim '0' '9')) (cold 62 (just '-')) (cold 63 (just '+')) == @@ -5334,9 +5334,9 @@ ++ ab |% ++ bix (bass 16 (stun [2 2] six)) - ++ fem (sear |=(a/@ (cha:fa a)) aln) + ++ fem (sear |=(a=@ (cha:fa a)) aln) ++ haf (bass 256 ;~(plug tep tiq (easy ~))) - ++ hef %+ sear |=(a/@ ?:(=(a 0) ~ (some a))) + ++ hef %+ sear |=(a=@ ?:(=(a 0) ~ (some a))) %+ bass 256 ;~(plug tip tiq (easy ~)) ++ hif (bass 256 ;~(plug tip tiq (easy ~))) @@ -5352,37 +5352,37 @@ ++ qib (bass 2 (stun [4 4] sib)) ++ qix (bass 16 (stun [4 4] six)) ++ seb (cold 1 (just '1')) - ++ sed (cook |=(a/@ (sub a '0')) (shim '1' '9')) + ++ sed (cook |=(a=@ (sub a '0')) (shim '1' '9')) ++ sev ;~(pose sed sov) ++ sew ;~(pose sed sow) ++ sex ;~(pose sed sox) - ++ sib (cook |=(a/@ (sub a '0')) (shim '0' '1')) - ++ sid (cook |=(a/@ (sub a '0')) (shim '0' '9')) + ++ sib (cook |=(a=@ (sub a '0')) (shim '0' '1')) + ++ sid (cook |=(a=@ (sub a '0')) (shim '0' '9')) ++ siv ;~(pose sid sov) ++ siw ;~(pose sid sow) ++ six ;~(pose sid sox) - ++ sov (cook |=(a/@ (sub a 87)) (shim 'a' 'v')) + ++ sov (cook |=(a=@ (sub a 87)) (shim 'a' 'v')) ++ sow ;~ pose - (cook |=(a/@ (sub a 87)) (shim 'a' 'z')) - (cook |=(a/@ (sub a 29)) (shim 'A' 'Z')) + (cook |=(a=@ (sub a 87)) (shim 'a' 'z')) + (cook |=(a=@ (sub a 29)) (shim 'A' 'Z')) (cold 62 (just '-')) (cold 63 (just '~')) == - ++ sox (cook |=(a/@ (sub a 87)) (shim 'a' 'f')) + ++ sox (cook |=(a=@ (sub a 87)) (shim 'a' 'f')) ++ ted (bass 10 ;~(plug sed (stun [0 2] sid))) - ++ tep (sear |=(a/@ ?:(=(a 'doz') ~ (ins:po a))) til) - ++ tip (sear |=(a/@ (ins:po a)) til) - ++ tiq (sear |=(a/@ (ind:po a)) til) + ++ tep (sear |=(a=@ ?:(=(a 'doz') ~ (ins:po a))) til) + ++ tip (sear |=(a=@ (ins:po a)) til) + ++ tiq (sear |=(a=@ (ind:po a)) til) ++ tid (bass 10 (stun [3 3] sid)) ++ til (boss 256 (stun [3 3] low)) ++ urs %+ cook - |=(a/tape (rap 3 ^-((list @) a))) + |=(a=tape (rap 3 ^-((list @) a))) (star ;~(pose nud low hep dot sig cab)) ++ urt %+ cook - |=(a/tape (rap 3 ^-((list @) a))) + |=(a=tape (rap 3 ^-((list @) a))) (star ;~(pose nud low hep dot sig)) ++ urx %+ cook - |=(a/tape (rap 3 ^-((list @) a))) + |=(a=tape (rap 3 ^-((list @) a))) %- star ;~ pose nud @@ -5397,7 +5397,7 @@ -- ++ ag |% - ++ ape |*(fel/rule ;~(pose (cold 0 (just '0')) fel)) + ++ ape |*(fel=rule ;~(pose (cold 0 (just '0')) fel)) ++ bay (ape (bass 16 ;~(plug qeb:ab (star ;~(pfix dog qib:ab))))) ++ bip =+ tod=(ape qex:ab) (bass 0x1.0000 ;~(plug tod (stun [7 7] ;~(pfix dog tod)))) @@ -5428,7 +5428,7 @@ ++ mot ;~ pose ;~ pfix (just '1') - (cook |=(a/@ (add 10 (sub a '0'))) (shim '0' '2')) + (cook |=(a=@ (add 10 (sub a '0'))) (shim '0' '2')) == sed:ab == @@ -5437,13 +5437,13 @@ ++ wiz (ape (bass 0x4000.0000 ;~(plug pew:ab (star ;~(pfix dog piw:ab))))) -- ++ mu - |_ {top/@ bot/@} + |_ {top=@ bot=@} ++ zag [p=(end 4 1 (add top bot)) q=bot] ++ zig [p=(end 4 1 (add top (sub 0x1.0000 bot))) q=bot] ++ zug (mix (lsh 4 1 top) bot) -- ++ ne - |_ tig/@ + |_ tig=@ ++ c (cut 3 [tig 1] key:fa) ++ d (add tig '0') ++ x ?:((gte tig 10) (add tig 87) d) @@ -5743,10 +5743,10 @@ ++ crub ~+ ;~ pose - (cook |=(det/date `dime`[%da (year det)]) when) + (cook |=(det=date `dime`[%da (year det)]) when) :: %+ cook - |= {a/(list {p/?(%d %h %m %s) q/@}) b/(list @)} + |= {a=(list {p=?(%d %h %m %s) q=@}) b=(list @)} =+ rop=`tarp`[0 0 0 0 b] |- ^- dime ?~ a @@ -5775,11 +5775,11 @@ ;~(pfix hep (stag %c (cook taft urx:ab))) == ++ nuck - ~/ %nuck |= a/nail %. a + ~/ %nuck |= a=nail %. a %+ knee *coin |. ~+ %- stew ^. stet ^. limo - :~ :- ['a' 'z'] (cook |=(a/@ta [%$ %tas a]) sym) + :~ :- ['a' 'z'] (cook |=(a=@ta [%$ %tas a]) sym) :- ['0' '9'] (stag %$ bisk) :- '-' (stag %$ tash) :- '.' ;~(pfix dot perd) @@ -5787,7 +5787,7 @@ == ++ nusk ~+ - :(sear |=(a/@ta (rush a nuck)) wick urt:ab) + :(sear |=(a=@ta (rush a nuck)) wick urt:ab) ++ perd ~+ ;~ pose @@ -5857,13 +5857,13 @@ ++ tash ~+ =+ ^= neg - |= {syn/? mol/dime} ^- dime + |= {syn=? mol=dime} ^- dime ?> =('u' (end 3 1 p.mol)) [(cat 3 's' (rsh 3 1 p.mol)) (new:si syn q.mol)] ;~ pfix hep ;~ pose - (cook |=(a/dime (neg | a)) bisk) - ;~(pfix hep (cook |=(a/dime (neg & a)) bisk)) + (cook |=(a=dime (neg | a)) bisk) + ;~(pfix hep (cook |=(a=dime (neg & a)) bisk)) == == :: @@ -5884,7 +5884,7 @@ ~+ ;~ plug %+ cook - |=({a/@ b/?} [b a]) + |=({a=@ b=?} [b a]) ;~(plug dim:ag ;~(pose (cold | hep) (easy &))) ;~(pfix dot mot:ag) :: month ;~(pfix dot dip:ag) :: day @@ -5917,15 +5917,15 @@ :: ++ scot ~/ %scot - |=(mol/dime ~(rent co %$ mol)) + |=(mol=dime ~(rent co %$ mol)) ++ scow ~/ %scow - |=(mol/dime ~(rend co %$ mol)) -++ slat |=(mod/@tas |=(txt/@ta (slaw mod txt))) -++ slav |=({mod/@tas txt/@ta} (need (slaw mod txt))) + |=(mol=dime ~(rend co %$ mol)) +++ slat |=(mod=@tas |=(txt=@ta (slaw mod txt))) +++ slav |=({mod=@tas txt=@ta} (need (slaw mod txt))) ++ slaw ~/ %slaw - |= {mod/@tas txt/@ta} + |= {mod=@tas txt=@ta} ^- (unit @) ?+ mod :: slow fallback case to the full slay @@ -5956,7 +5956,7 @@ == :: ++ slay - |= txt/@ta ^- (unit coin) + |= txt=@ta ^- (unit coin) =+ ^= vex ?: (gth 0x7fff.ffff txt) :: XX petty cache ~+ ((full nuck:so) [[1 1] (trip txt)]) @@ -5966,15 +5966,15 @@ [~ p.u.q.vex] :: ++ smyt :: pretty print path - |= bon/path ^- tank + |= bon=path ^- tank :+ %rose [['/' ~] ['/' ~] ~] - (turn bon |=(a/@ [%leaf (trip a)])) + (turn bon |=(a=@ [%leaf (trip a)])) :: -++ spat |=(pax/path (crip (spud pax))) :: render path to cord -++ spud |=(pax/path ~(ram re (smyt pax))) :: render path to tape +++ spat |=(pax=path (crip (spud pax))) :: render path to cord +++ spud |=(pax=path ~(ram re (smyt pax))) :: render path to tape ++ stab :: parse cord to path =+ fel=;~(pfix fas (more fas urs:ab)) - |=(zep/@t `path`(rash zep fel)) + |=(zep=@t `path`(rash zep fel)) :: :::: 4n: virtualization :: @@ -6293,42 +6293,42 @@ %null :: ~ == 0 %void :: empty set == :: - {%atom p/aura} :: atom + {%atom p=aura} :: atom :: -+$ woof $@(@ {~ p/hoon}) :: simple embed -+$ chum $? lef/term :: jet name - {std/term kel/@} :: kelvin version - {ven/term pro/term kel/@} :: vendor and product - {ven/term pro/term ver/@ kel/@} :: all of the above ++$ woof $@(@ {~ p=hoon}) :: simple embed ++$ chum $? lef=term :: jet name + {std=term kel=@} :: kelvin version + {ven=term pro=term kel=@} :: vendor and product + {ven=term pro=term ver=@ kel=@} :: all of the above == :: -+$ coil $: p/garb :: name, wet/dry, vary - q/type :: context - r/(pair seminoun (map term tome)) :: chapters ++$ coil $: p=garb :: name, wet=dry, vary + q=type :: context + r=(pair seminoun (map term tome)) :: chapters == :: +$ garb (trel (unit term) poly vair) :: core +$ poly ?(%wet %dry) :: polarity -+$ foot $% {%dry p/hoon} :: dry arm, geometric - {%wet p/hoon} :: wet arm, generic ++$ foot $% {%dry p=hoon} :: dry arm, geometric + {%wet p=hoon} :: wet arm, generic == :: +$ link :: lexical segment - $% [%chat p/term] :: |chapter - [%cone p/aura q/atom] :: %constant - [%frag p/term] :: .leg - [%funk p/term] :: +arm + $% [%chat p=term] :: |chapter + [%cone p=aura q=atom] :: %constant + [%frag p=term] :: .leg + [%funk p=term] :: +arm == :: +$ crib [summary=cord details=(list sect)] :: +$ help [links=(list link) =crib] :: documentation +$ limb $@ term :: wing element - $% {%& p/axis} :: by geometry - {%| p/@ud q/(unit term)} :: by name + $% {%& p=axis} :: by geometry + {%| p=@ud q=(unit term)} :: by name == :: :: XX more and better sanity :: +$ null ~ :: null, nil, etc +$ onyx (list (pair type foot)) :: arm activation +$ opal :: limb match - $% {%& p/type} :: leg - {%| p/axis q/(set {p/type q/foot})} :: arm + $% {%& p=type} :: leg + {%| p=axis q=(set {p=type q=foot})} :: arm == :: +$ pica (pair ? cord) :: & prose, | code +$ palo (pair vein opal) :: wing trace, match @@ -6342,44 +6342,44 @@ +$ port (each palo (pair type nock)) :: successful match +$ spec :: structure definition $~ [%base %null] :: - $% {%base p/base} :: base type - {%dbug p/spot q/spec} :: set debug - {%leaf p/term q/@} :: constant atom - {%like p/wing q/(list wing)} :: reference - {%loop p/term} :: hygienic reference - {%made p/(pair term (list term)) q/spec} :: annotate synthetic - {%make p/hoon q/(list spec)} :: composed spec - {%name p/term q/spec} :: annotate simple - {%over p/wing q/spec} :: relative to subject + $% {%base p=base} :: base type + {%dbug p=spot q=spec} :: set debug + {%leaf p=term q=@} :: constant atom + {%like p=wing q=(list wing)} :: reference + {%loop p=term} :: hygienic reference + {%made p=(pair term (list term)) q=spec} :: annotate synthetic + {%make p=hoon q=(list spec)} :: composed spec + {%name p=term q=spec} :: annotate simple + {%over p=wing q=spec} :: relative to subject :: :: - {%bcgr p/spec q/spec} :: $>, filter: require - {%bcbc p/spec q/(map term spec)} :: $$, recursion - {%bcbr p/spec q/hoon} :: $|, verify - {%bccb p/hoon} :: $_, example - {%bccl p/{i/spec t/(list spec)}} :: $:, tuple - {%bccn p/{i/spec t/(list spec)}} :: $%, head pick - {%bcdt p/spec q/(map term spec)} :: $., read-write core - {%bcgl p/spec q/spec} :: $<, filter: exclude - {%bchp p/spec q/spec} :: $-, function core - {%bckt p/spec q/spec} :: $^, cons pick - {%bcls p/stud q/spec} :: $+, standard - {%bcfs p/spec q/(map term spec)} :: $/, write-only core - {%bcmc p/hoon} :: $;, manual - {%bcpm p/spec q/hoon} :: $&, repair - {%bcsg p/hoon q/spec} :: $~, default - {%bctc p/spec q/(map term spec)} :: $`, read-only core - {%bcts p/skin q/spec} :: $=, name - {%bcpt p/spec q/spec} :: $@, atom pick - {%bcwt p/{i/spec t/(list spec)}} :: $?, full pick - {%bczp p/spec q/(map term spec)} :: $!, opaque core + {%bcgr p=spec q=spec} :: $>, filter: require + {%bcbc p=spec q=(map term spec)} :: $$, recursion + {%bcbr p=spec q=hoon} :: $|, verify + {%bccb p=hoon} :: $_, example + {%bccl p={i=spec t=(list spec)}} :: $:, tuple + {%bccn p={i=spec t=(list spec)}} :: $%, head pick + {%bcdt p=spec q=(map term spec)} :: $., read-write core + {%bcgl p=spec q=spec} :: $<, filter: exclude + {%bchp p=spec q=spec} :: $-, function core + {%bckt p=spec q=spec} :: $^, cons pick + {%bcls p=stud q=spec} :: $+, standard + {%bcfs p=spec q=(map term spec)} :: $/, write-only core + {%bcmc p=hoon} :: $;, manual + {%bcpm p=spec q=hoon} :: $&, repair + {%bcsg p=hoon q=spec} :: $~, default + {%bctc p=spec q=(map term spec)} :: $`, read-only core + {%bcts p=skin q=spec} :: $=, name + {%bcpt p=spec q=spec} :: $@, atom pick + {%bcwt p={i=spec t=(list spec)}} :: $?, full pick + {%bczp p=spec q=(map term spec)} :: $!, opaque core == :: +$ tent :: model builder - $% {%| p/wing q/tent r/(list spec)} :: ~(p q r...) - {%& p/(list wing)} :: a.b:c.d + $% {%| p=wing q=tent r=(list spec)} :: ~(p q r...) + {%& p=(list wing)} :: a.b:c.d == :: +$ tiki :: test case - $% {%& p/(unit term) q/wing} :: simple wing - {%| p/(unit term) q/hoon} :: named wing + $% {%& p=(unit term) q=wing} :: simple wing + {%| p=(unit term) q=hoon} :: named wing == :: +$ skin :: texture $@ =term :: name/~[term %none] @@ -6401,223 +6401,223 @@ (pair tope tope) :: cell ++ hoot :: hoon tools |% - +$ beer $@(char {~ p/hoon}) :: simple embed + +$ beer $@(char {~ p=hoon}) :: simple embed +$ mane $@(@tas {@tas @tas}) :: XML name+space - +$ manx $~([[%$ ~] ~] {g/marx c/marl}) :: dynamic XML node + +$ manx $~([[%$ ~] ~] {g=marx c=marl}) :: dynamic XML node +$ marl (list tuna) :: dynamic XML nodes - +$ mart (list {n/mane v/(list beer)}) :: dynamic XML attrs - +$ marx $~([%$ ~] {n/mane a/mart}) :: dynamic XML tag + +$ mart (list {n=mane v=(list beer)}) :: dynamic XML attrs + +$ marx $~([%$ ~] {n=mane a=mart}) :: dynamic XML tag +$ mare (each manx marl) :: node or nodes +$ maru (each tuna marl) :: interp or nodes +$ tuna :: maybe interpolation $~ [[%$ ~] ~] $^ manx $: ?(%tape %manx %marl %call) - p/hoon + p=hoon == -- :: +$ hoon :: $~ [%zpzp ~] - $^ {p/hoon q/hoon} :: + $^ {p=hoon q=hoon} :: $% :: - {%$ p/axis} :: simple leg + {%$ p=axis} :: simple leg :: :: - {%base p/base} :: base spec - {%bust p/base} :: bunt base - {%dbug p/spot q/hoon} :: debug info in trace - {%eror p/tape} :: assembly error - {%hand p/type q/nock} :: premade result - {%note p/note q/hoon} :: annotate - {%fits p/hoon q/wing} :: underlying ?= - {%knit p/(list woof)} :: assemble string - {%leaf p/(pair term @)} :: symbol spec - {%limb p/term} :: take limb - {%lost p/hoon} :: not to be taken - {%rock p/term q/*} :: fixed constant - {%sand p/term q/*} :: unfixed constant - {%tell p/(list hoon)} :: render as tape - {%tune p/$@(term tune)} :: minimal face - {%wing p/wing} :: take wing - {%yell p/(list hoon)} :: render as tank - {%xray p/manx:hoot} :: ;foo; templating + {%base p=base} :: base spec + {%bust p=base} :: bunt base + {%dbug p=spot q=hoon} :: debug info in trace + {%eror p=tape} :: assembly error + {%hand p=type q=nock} :: premade result + {%note p=note q=hoon} :: annotate + {%fits p=hoon q=wing} :: underlying ?= + {%knit p=(list woof)} :: assemble string + {%leaf p=(pair term @)} :: symbol spec + {%limb p=term} :: take limb + {%lost p=hoon} :: not to be taken + {%rock p=term q=*} :: fixed constant + {%sand p=term q=*} :: unfixed constant + {%tell p=(list hoon)} :: render as tape + {%tune p=$@(term tune)} :: minimal face + {%wing p=wing} :: take wing + {%yell p=(list hoon)} :: render as tank + {%xray p=manx:hoot} :: ;foo; templating :: :::::: cores - {%brbc sample/(lest term) body/spec} :: |$ - {%brcb p/spec q/alas r/(map term tome)} :: |_ - {%brcl p/hoon q/hoon} :: |: - {%brcn p/(unit term) q/(map term tome)} :: |% - {%brdt p/hoon} :: |. - {%brkt p/hoon q/(map term tome)} :: |^ - {%brhp p/hoon} :: |- - {%brsg p/spec q/hoon} :: |~ - {%brtr p/spec q/hoon} :: |* - {%brts p/spec q/hoon} :: |= - {%brpt p/(unit term) q/(map term tome)} :: |@ - {%brwt p/hoon} :: |? + {%brbc sample=(lest term) body=spec} :: |$ + {%brcb p=spec q=alas r=(map term tome)} :: |_ + {%brcl p=hoon q=hoon} :: |: + {%brcn p=(unit term) q=(map term tome)} :: |% + {%brdt p=hoon} :: |. + {%brkt p=hoon q=(map term tome)} :: |^ + {%brhp p=hoon} :: |- + {%brsg p=spec q=hoon} :: |~ + {%brtr p=spec q=hoon} :: |* + {%brts p=spec q=hoon} :: |= + {%brpt p=(unit term) q=(map term tome)} :: |@ + {%brwt p=hoon} :: |? :: :::::: tuples - {%clcb p/hoon q/hoon} :: :_ [q p] - {%clkt p/hoon q/hoon r/hoon s/hoon} :: :^ [p q r s] - {%clhp p/hoon q/hoon} :: :- [p q] - {%clls p/hoon q/hoon r/hoon} :: :+ [p q r] - {%clsg p/(list hoon)} :: :~ [p ~] - {%cltr p/(list hoon)} :: :* p as a tuple + {%clcb p=hoon q=hoon} :: :_ [q p] + {%clkt p=hoon q=hoon r=hoon s=hoon} :: :^ [p q r s] + {%clhp p=hoon q=hoon} :: :- [p q] + {%clls p=hoon q=hoon r=hoon} :: :+ [p q r] + {%clsg p=(list hoon)} :: :~ [p ~] + {%cltr p=(list hoon)} :: :* p as a tuple :: :::::: invocations - {%cncb p/wing q/(list (pair wing hoon))} :: %_ - {%cndt p/hoon q/hoon} :: %. - {%cnhp p/hoon q/hoon} :: %- - {%cncl p/hoon q/(list hoon)} :: %: - {%cntr p/wing q/hoon r/(list (pair wing hoon))} :: %* - {%cnkt p/hoon q/hoon r/hoon s/hoon} :: %^ - {%cnls p/hoon q/hoon r/hoon} :: %+ - {%cnsg p/wing q/hoon r/(list hoon)} :: %~ - {%cnts p/wing q/(list (pair wing hoon))} :: %= + {%cncb p=wing q=(list (pair wing hoon))} :: %_ + {%cndt p=hoon q=hoon} :: %. + {%cnhp p=hoon q=hoon} :: %- + {%cncl p=hoon q=(list hoon)} :: %: + {%cntr p=wing q=hoon r=(list (pair wing hoon))} :: %* + {%cnkt p=hoon q=hoon r=hoon s=hoon} :: %^ + {%cnls p=hoon q=hoon r=hoon} :: %+ + {%cnsg p=wing q=hoon r=(list hoon)} :: %~ + {%cnts p=wing q=(list (pair wing hoon))} :: %= :: :::::: nock - {%dtkt p/spec q/hoon} :: .^ nock 11 - {%dtls p/hoon} :: .+ nock 4 - {%dttr p/hoon q/hoon} :: .* nock 2 - {%dtts p/hoon q/hoon} :: .= nock 5 - {%dtwt p/hoon} :: .? nock 3 + {%dtkt p=spec q=hoon} :: .^ nock 11 + {%dtls p=hoon} :: .+ nock 4 + {%dttr p=hoon q=hoon} :: .* nock 2 + {%dtts p=hoon q=hoon} :: .= nock 5 + {%dtwt p=hoon} :: .? nock 3 :: :::::: type conversion - {%ktbr p/hoon} :: ^| contravariant - {%ktcn p/hoon} :: ^% enter test mode - {%ktdt p/hoon q/hoon} :: ^. self-cast - {%ktls p/hoon q/hoon} :: ^+ expression cast - {%kthp p/spec q/hoon} :: ^- structure cast - {%ktpm p/hoon} :: ^& covariant - {%ktsg p/hoon} :: ^~ constant - {%ktts p/skin q/hoon} :: ^= label - {%ktwt p/hoon} :: ^? bivariant - {%kttr p/spec} :: ^* example - {%ktcl p/spec} :: ^: filter + {%ktbr p=hoon} :: ^| contravariant + {%ktcn p=hoon} :: ^% enter test mode + {%ktdt p=hoon q=hoon} :: ^. self-cast + {%ktls p=hoon q=hoon} :: ^+ expression cast + {%kthp p=spec q=hoon} :: ^- structure cast + {%ktpm p=hoon} :: ^& covariant + {%ktsg p=hoon} :: ^~ constant + {%ktts p=skin q=hoon} :: ^= label + {%ktwt p=hoon} :: ^? bivariant + {%kttr p=spec} :: ^* example + {%ktcl p=spec} :: ^: filter :: :::::: hints - {%sgbr p/hoon q/hoon} :: ~| sell on trace - {%sgcb p/hoon q/hoon} :: ~_ tank on trace - {%sgcn p/chum q/hoon r/tyre s/hoon} :: ~% general jet hint - {%sgfs p/chum q/hoon} :: ~/ function j-hint - {%sggl p/$@(term {p/term q/hoon}) q/hoon} :: ~< backward hint - {%sggr p/$@(term {p/term q/hoon}) q/hoon} :: ~> forward hint - {%sgbc p/term q/hoon} :: ~$ profiler hit - {%sgls p/@ q/hoon} :: ~+ cache/memoize - {%sgpm p/@ud q/hoon r/hoon} :: ~& printf/priority - {%sgts p/hoon q/hoon} :: ~= don't duplicate - {%sgwt p/@ud q/hoon r/hoon s/hoon} :: ~? tested printf - {%sgzp p/hoon q/hoon} :: ~! type on trace + {%sgbr p=hoon q=hoon} :: ~| sell on trace + {%sgcb p=hoon q=hoon} :: ~_ tank on trace + {%sgcn p=chum q=hoon r=tyre s=hoon} :: ~% general jet hint + {%sgfs p=chum q=hoon} :: ~/ function j-hint + {%sggl p=$@(term {p=term q=hoon}) q=hoon} :: ~< backward hint + {%sggr p=$@(term {p=term q=hoon}) q=hoon} :: ~> forward hint + {%sgbc p=term q=hoon} :: ~$ profiler hit + {%sgls p=@ q=hoon} :: ~+ cache=memoize + {%sgpm p=@ud q=hoon r=hoon} :: ~& printf=priority + {%sgts p=hoon q=hoon} :: ~= don't duplicate + {%sgwt p=@ud q=hoon r=hoon s=hoon} :: ~? tested printf + {%sgzp p=hoon q=hoon} :: ~! type on trace :: :::::: miscellaneous - {%mcts p/marl:hoot} :: ;= list templating - {%mccl p/hoon q/(list hoon)} :: ;: binary to nary - {%mcfs p/hoon} :: ;/ [%$ [%$ p ~] ~] - {%mcgl p/spec q/hoon r/hoon s/hoon} :: ;< bind - {%mcsg p/hoon q/(list hoon)} :: ;~ kleisli arrow - {%mcmc p/spec q/hoon} :: ;; normalize + {%mcts p=marl:hoot} :: ;= list templating + {%mccl p=hoon q=(list hoon)} :: ;: binary to nary + {%mcfs p=hoon} :: ;/ [%$ [%$ p ~] ~] + {%mcgl p=spec q=hoon r=hoon s=hoon} :: ;< bind + {%mcsg p=hoon q=(list hoon)} :: ;~ kleisli arrow + {%mcmc p=spec q=hoon} :: ;; normalize :: :::::: compositions - {%tsbr p/spec q/hoon} :: =| push bunt - {%tscl p/(list (pair wing hoon)) q/hoon} :: =: q w/ p changes - {%tsfs p/skin q/hoon r/hoon} :: =/ typed variable - {%tsmc p/skin q/hoon r/hoon} :: =; =/(q p r) - {%tsdt p/wing q/hoon r/hoon} :: =. r with p as q - {%tswt p/wing q/hoon r/hoon s/hoon} :: =? conditional =. - {%tsgl p/hoon q/hoon} :: =< =>(q p) - {%tshp p/hoon q/hoon} :: =- =+(q p) - {%tsgr p/hoon q/hoon} :: => q w/subject p - {%tskt p/skin q/wing r/hoon s/hoon} :: =^ state machine - {%tsls p/hoon q/hoon} :: =+ q w/[p subject] - {%tssg p/(list hoon)} :: =~ hoon stack - {%tstr p/(pair term (unit spec)) q/hoon r/hoon} :: =* new style - {%tscm p/hoon q/hoon} :: =, overload p in q + {%tsbr p=spec q=hoon} :: =| push bunt + {%tscl p=(list (pair wing hoon)) q=hoon} :: =: q w= p changes + {%tsfs p=skin q=hoon r=hoon} :: =/ typed variable + {%tsmc p=skin q=hoon r=hoon} :: =; =/(q p r) + {%tsdt p=wing q=hoon r=hoon} :: =. r with p as q + {%tswt p=wing q=hoon r=hoon s=hoon} :: =? conditional =. + {%tsgl p=hoon q=hoon} :: =< =>(q p) + {%tshp p=hoon q=hoon} :: =- =+(q p) + {%tsgr p=hoon q=hoon} :: => q w=subject p + {%tskt p=skin q=wing r=hoon s=hoon} :: =^ state machine + {%tsls p=hoon q=hoon} :: =+ q w=[p subject] + {%tssg p=(list hoon)} :: =~ hoon stack + {%tstr p=(pair term (unit spec)) q=hoon r=hoon} :: =* new style + {%tscm p=hoon q=hoon} :: =, overload p in q :: :::::: conditionals - {%wtbr p/(list hoon)} :: ?| loobean or - {%wthp p/wing q/(list (pair spec hoon))} :: ?- pick case in q - {%wtcl p/hoon q/hoon r/hoon} :: ?: if/then/else - {%wtdt p/hoon q/hoon r/hoon} :: ?. ?:(p r q) - {%wtkt p/wing q/hoon r/hoon} :: ?^ if p is a cell - {%wtgl p/hoon q/hoon} :: ?< ?:(p !! q) - {%wtgr p/hoon q/hoon} :: ?> ?:(p q !!) - {%wtls p/wing q/hoon r/(list (pair spec hoon))} :: ?+ ?- w/default - {%wtpm p/(list hoon)} :: ?& loobean and - {%wtpt p/wing q/hoon r/hoon} :: ?@ if p is atom - {%wtsg p/wing q/hoon r/hoon} :: ?~ if p is null - {%wthx p/skin q/wing} :: ?# if q matches p - {%wtts p/spec q/wing} :: ?= if q matches p - {%wtzp p/hoon} :: ?! loobean not + {%wtbr p=(list hoon)} :: ?| loobean or + {%wthp p=wing q=(list (pair spec hoon))} :: ?- pick case in q + {%wtcl p=hoon q=hoon r=hoon} :: ?: if=then=else + {%wtdt p=hoon q=hoon r=hoon} :: ?. ?:(p r q) + {%wtkt p=wing q=hoon r=hoon} :: ?^ if p is a cell + {%wtgl p=hoon q=hoon} :: ?< ?:(p !! q) + {%wtgr p=hoon q=hoon} :: ?> ?:(p q !!) + {%wtls p=wing q=hoon r=(list (pair spec hoon))} :: ?+ ?- w=default + {%wtpm p=(list hoon)} :: ?& loobean and + {%wtpt p=wing q=hoon r=hoon} :: ?@ if p is atom + {%wtsg p=wing q=hoon r=hoon} :: ?~ if p is null + {%wthx p=skin q=wing} :: ?# if q matches p + {%wtts p=spec q=wing} :: ?= if q matches p + {%wtzp p=hoon} :: ?! loobean not :: :::::: special - {%zpcm p/hoon q/hoon} :: !, - {%zpgr p/hoon} :: !> - {%zpgl p/spec q/hoon} :: !< - {%zpmc p/hoon q/hoon} :: !; - {%zpts p/hoon} :: != - {%zppt p/(list wing) q/hoon r/hoon} :: !@ - {%zpwt p/$@(p/@ {p/@ q/@}) q/hoon} :: !? + {%zpcm p=hoon q=hoon} :: !, + {%zpgr p=hoon} :: !> + {%zpgl p=spec q=hoon} :: !< + {%zpmc p=hoon q=hoon} :: !; + {%zpts p=hoon} :: != + {%zppt p=(list wing) q=hoon r=hoon} :: !@ + {%zpwt p=$@(p=@ {p=@ q=@}) q=hoon} :: !? {%zpzp ~} :: !! == :: -+$ tyre (list {p/term q/hoon}) :: ++$ tyre (list {p=term q=hoon}) :: +$ tyke (list (unit hoon)) :: :: :::::: virtual nock -+$ nock $^ {p/nock q/nock} :: autocons - $% {%1 p/*} :: constant - {%2 p/nock q/nock} :: compose - {%3 p/nock} :: cell test - {%4 p/nock} :: increment - {%5 p/nock q/nock} :: equality test - {%6 p/nock q/nock r/nock} :: if, then, else - {%7 p/nock q/nock} :: serial compose - {%8 p/nock q/nock} :: push onto subject - {%9 p/@ q/nock} :: select arm and fire - {%10 p/{p/@ q/nock} q/nock} :: edit - {%11 p/$@(@ {p/@ q/nock}) q/nock} :: hint - {%12 p/nock q/nock} :: grab data from sky - {%0 p/@} :: axis select ++$ nock $^ {p=nock q=nock} :: autocons + $% {%1 p=*} :: constant + {%2 p=nock q=nock} :: compose + {%3 p=nock} :: cell test + {%4 p=nock} :: increment + {%5 p=nock q=nock} :: equality test + {%6 p=nock q=nock r=nock} :: if, then, else + {%7 p=nock q=nock} :: serial compose + {%8 p=nock q=nock} :: push onto subject + {%9 p=@ q=nock} :: select arm and fire + {%10 p={p=@ q=nock} q=nock} :: edit + {%11 p=$@(@ {p=@ q=nock}) q=nock} :: hint + {%12 p=nock q=nock} :: grab data from sky + {%0 p=@} :: axis select == :: +$ note :: type annotation - $% {%help p/help} :: documentation - {%know p/stud} :: global standard - {%made p/term q/(unit (list wing))} :: structure + $% {%help p=help} :: documentation + {%know p=stud} :: global standard + {%made p=term q=(unit (list wing))} :: structure == :: +$ type $~ %noun :: $@ $? %noun :: any nouns %void :: no noun == :: - $% {%atom p/term q/(unit @)} :: atom / constant - {%cell p/type q/type} :: ordered pair - {%core p/type q/coil} :: object - {%face p/$@(term tune) q/type} :: namespace - {%fork p/(set type)} :: union - {%hint p/(pair type note) q/type} :: annotation - {%hold p/type q/hoon} :: lazy evaluation + $% {%atom p=term q=(unit @)} :: atom / constant + {%cell p=type q=type} :: ordered pair + {%core p=type q=coil} :: object + {%face p=$@(term tune) q=type} :: namespace + {%fork p=(set type)} :: union + {%hint p=(pair type note) q=type} :: annotation + {%hold p=type q=hoon} :: lazy evaluation == :: +$ tony :: ++tone done right - $% {%0 p/tine q/*} :: success - {%1 p/(set)} :: blocks - {%2 p/(list {@ta *})} :: error ~_s + $% {%0 p=tine q=*} :: success + {%1 p=(set)} :: blocks + {%2 p=(list {@ta *})} :: error ~_s == :: +$ tine :: partial noun $@ ~ :: open - $% {%& p/tine q/tine} :: half-blocked - {%| p/(set)} :: fully blocked + $% {%& p=tine q=tine} :: half-blocked + {%| p=(set)} :: fully blocked == :: +$ tool $@(term tune) :: type decoration +$ tune :: complex $~ [~ ~] :: - $: p/(map term (unit hoon)) :: aliases - q/(list hoon) :: bridges + $: p=(map term (unit hoon)) :: aliases + q=(list hoon) :: bridges == :: +$ typo type :: old type -+$ vase {p/type q/*} :: type-value pair -+$ vise {p/typo q/*} :: old vase ++$ vase {p=type q=*} :: type-value pair ++$ vise {p=typo q=*} :: old vase +$ vial ?(%read %rite %both %free) :: co/contra/in/bi +$ vair ?(%gold %iron %lead %zinc) :: in/contra/bi/co +$ vein (list (unit axis)) :: search trace +$ sect (list pica) :: paragraph +$ whit :: - $: lab/(unit term) :: label - boy/(unit (pair cord (list sect))) :: body - def/(map term (pair cord (list sect))) :: definitions - use/(set term) :: defs used + $: lab=(unit term) :: label + boy=(unit (pair cord (list sect))) :: body + def=(map term (pair cord (list sect))) :: definitions + use=(set term) :: defs used == :: +$ what (unit (pair cord (list sect))) :: help slogan/section +$ wing (list limb) :: search path +$ worm :: compiler cache - $: nes/(set ^) :: ++nest - pay/(map (pair type hoon) type) :: ++play - mit/(map (pair type hoon) (pair type nock)) :: ++mint + $: nes=(set ^) :: ++nest + pay=(map (pair type hoon) type) :: ++play + mit=(map (pair type hoon) (pair type nock)) :: ++mint == :: :: :: +block: abstract identity of resource awaited @@ -6641,7 +6641,7 @@ :: partial noun; blocked subtrees are ~ :: $~ [[%full ~] ~] - {mask/stencil data/noun} + {mask=stencil data=noun} :: :: +stencil: noun knowledge map :: @@ -6657,7 +6657,7 @@ :: :: %lazy: noun can be generated from virtual subtree :: - [%lazy fragment/axis resolve/thunk] + [%lazy fragment=axis resolve=thunk] == :: ++ output @@ -6667,32 +6667,32 @@ $% :: :: %done: output is complete :: - [%done p/noun] + [%done p=noun] :: :: %wait: output is waiting for resources :: - [%wait p/(list block)] + [%wait p=(list block)] == :: profiling ++ doss - $: mon/moan :: sample count - hit/(map term @ud) :: hit points - cut/(map path hump) :: cut points + $: mon=moan :: sample count + hit=(map term @ud) :: hit points + cut=(map path hump) :: cut points == ++ moan :: sample metric - $: fun/@ud :: samples in C - noc/@ud :: samples in nock - glu/@ud :: samples in glue - mal/@ud :: samples in alloc - far/@ud :: samples in frag - coy/@ud :: samples in copy - euq/@ud :: samples in equal + $: fun=@ud :: samples in C + noc=@ud :: samples in nock + glu=@ud :: samples in glue + mal=@ud :: samples in alloc + far=@ud :: samples in frag + coy=@ud :: samples in copy + euq=@ud :: samples in equal == :: :: ++ hump - $: mon/moan :: sample count - out/(map path @ud) :: calls out of - inn/(map path @ud) :: calls into + $: mon=moan :: sample count + out=(map path @ud) :: calls out of + inn=(map path @ud) :: calls into == -- :: :: @@ -6723,7 +6723,7 @@ :: |= $: :: noy: raw result :: - noy/result + noy=result == ^- output :: propagate stop @@ -6747,8 +6747,8 @@ |= $: :: bus: subject, a partial noun :: fol: formula, a complete noun :: - bus/seminoun - fol/noun + bus=seminoun + fol=noun == :: interpreter loop :: @@ -6779,7 +6779,7 @@ ~ :: 0; fragment :: - {%0 b/@} + {%0 b=@} :: if bad axis, stop :: ?: =(0 b.fol) ~ @@ -6789,14 +6789,14 @@ :: :: 1; constant :: - {%1 b/*} + {%1 b=*} :: constant is complete :: [full/~ b.fol] :: :: 2; recursion :: - {%2 b/* c/*} + {%2 b=* c=*} :: require complete formula :: %+ require @@ -6805,7 +6805,7 @@ $(fol c.fol) |= :: ryf: next formula :: - ryf/noun + ryf=noun :: lub: next subject :: =+ lub=^$(fol b.fol) @@ -6818,53 +6818,53 @@ :: :: 3; probe :: - {%3 b/*} + {%3 b=*} %+ require $(fol b.fol) |= :: fig: probe input :: - fig/noun + fig=noun :: yes if cell, no if atom :: [full/~ .?(fig)] :: :: 4; increment :: - {%4 b/*} + {%4 b=*} %+ require $(fol b.fol) |= :: fig: increment input :: - fig/noun + fig=noun :: stop for cells, increment for atoms :: ?^(fig ~ [full/~ +(fig)]) :: :: 5; compare :: - {%5 b/* c/*} + {%5 b=* c=*} %+ require $(fol b.fol) |= :: hed: left input :: - hed/noun + hed=noun %+ require ^$(fol c.fol) |= :: tal: right input :: - tal/noun + tal=noun [full/~ =(hed tal)] :: :: 6; if-then-else :: - {%6 b/* c/* d/*} + {%6 b=* c=* d=*} :: semantic expansion :: %+ require $(fol b.fol) |= :: fig: boolean :: - fig/noun + fig=noun :: apply proper booleans :: ?: =(& fig) ^$(fol c.fol) @@ -6875,7 +6875,7 @@ :: :: 7; composition :: - {%7 b/* c/*} + {%7 b=* c=*} :: one: input :: =+ one=$(fol b.fol) @@ -6888,7 +6888,7 @@ :: :: 8; introduction :: - {%8 b/* c/*} + {%8 b=* c=*} :: one: input :: =+ one=$(fol b.fol) @@ -6901,7 +6901,7 @@ :: :: 9; invocation :: - {%9 b/* c/*} + {%9 b=* c=*} :: semantic expansion :: ?^ b.fol ~ @@ -6935,7 +6935,7 @@ :: :: 10; edit :: - {%10 {b/@ c/*} d/*} + {%10 {b=@ c=*} d=*} :: tar: target of edit :: =+ tar=$(fol d.fol) @@ -6952,14 +6952,14 @@ :: :: 11; static hint :: - {%11 @ c/*} + {%11 @ c=*} :: ignore hint :: $(fol c.fol) :: :: 11; dynamic hint :: - {%11 {b/* c/*} d/*} + {%11 {b=* c=*} d=*} :: noy: dynamic hint :: =+ noy=$(fol c.fol) @@ -6983,8 +6983,8 @@ |= $: :: bus: subject, a partial noun :: fol: formula, a complete noun :: - bus/seminoun - fol/noun + bus=seminoun + fol=noun == ~+ ^- output @@ -6998,8 +6998,8 @@ |= $: :: hed: head of pair :: tal: tail of pair :: - hed/seminoun - tal/seminoun + hed=seminoun + tal=seminoun == ^- seminoun ?. ?& &(?=(%full -.mask.hed) ?=(%full -.mask.tal)) @@ -7021,7 +7021,7 @@ ++ complete :: complete any laziness :: - |= bus/seminoun + |= bus=seminoun ^- seminoun ?- -.mask.bus %full bus @@ -7056,8 +7056,8 @@ |= $: :: axe: tree address of subtree :: bus: partial noun :: - axe/axis - bus/seminoun + axe=axis + bus=seminoun == ^- result :: 1 is the root @@ -7098,9 +7098,9 @@ :: lit: (little) seminoun to insert within big at axe :: big: seminoun to mutate :: - axe/@ - lit/seminoun - big/seminoun + axe=@ + lit=seminoun + big=seminoun == ^- result :: stop on zero axis @@ -7159,8 +7159,8 @@ ++ require :: require complete intermediate step :: - |= $: noy/result - yen/$-(* result) + |= $: noy=result + yen=$-(* result) == ^- result :: propagate stop @@ -7168,7 +7168,7 @@ ?~ noy ~ :: suppress laziness :: - =/ bus/seminoun (complete noy) + =/ bus=seminoun (complete noy) ?< ?=(%lazy -.mask.bus) :: if partial block, squash blocks and stop :: @@ -7183,7 +7183,7 @@ ++ squash :: convert stencil to block set :: - |= tyn/stencil + |= tyn=stencil ^- (set block) ?- -.tyn %lazy $(tyn -:(complete tyn ~)) @@ -7197,18 +7197,18 @@ ++ bool `type`(fork [%atom %f `0] [%atom %f `1] ~) :: make loobean ++ cell :: make %cell type ~/ %cell - |= {hed/type tal/type} + |= {hed=type tal=type} ^- type ?:(=(%void hed) %void ?:(=(%void tal) %void [%cell hed tal])) :: ++ core :: make %core type ~/ %core - |= {pac/type con/coil} + |= {pac=type con=coil} ^- type ?:(=(%void pac) %void [%core pac con]) :: ++ hint - |= {p/(pair type note) q/type} + |= {p=(pair type note) q=type} ^- type ?: =(%void q) %void ?: =(%noun q) %noun @@ -7216,7 +7216,7 @@ :: ++ face :: make %face type ~/ %face - |= {giz/$@(term tune) der/type} + |= {giz=$@(term tune) der=type} ^- type ?: =(%void der) %void @@ -7224,8 +7224,8 @@ :: ++ fork :: make %fork type ~/ %fork - |= yed/(list type) - =| lez/(set type) + |= yed=(list type) + =| lez=(set type) |- ^- type ?~ yed ?~ lez %void @@ -7240,7 +7240,7 @@ == :: ++ cove :: extract [0 *] axis - |= nug/nock + |= nug=nock ?- nug {%0 *} p.nug {%11 *} $(nug q.nug) @@ -7248,7 +7248,7 @@ == ++ comb :: combine two formulas ~/ %comb - |= {mal/nock buz/nock} + |= {mal=nock buz=nock} ^- nock ?: ?&(?=({%0 *} mal) !=(0 p.mal)) ?: ?&(?=({%0 *} buz) !=(0 p.buz)) @@ -7264,7 +7264,7 @@ :: ++ cond :: ?: compile ~/ %cond - |= {pex/nock yom/nock woq/nock} + |= {pex=nock yom=nock woq=nock} ^- nock ?- pex {%1 %0} yom @@ -7274,7 +7274,7 @@ :: ++ cons :: make formula cell ~/ %cons - |= {vur/nock sed/nock} + |= {vur=nock sed=nock} ^- nock :: this optimization can remove crashes which are essential :: @@ -7288,9 +7288,9 @@ :: ++ fitz :: odor compatibility ~/ %fitz - |= {yaz/term wix/term} + |= {yaz=term wix=term} =+ ^= fiz - |= mot/@ta ^- {p/@ q/@ta} + |= mot=@ta ^- {p=@ q=@ta} =+ len=(met 3 mot) ?: =(0 len) [0 %$] @@ -7313,7 +7313,7 @@ :: ++ flan :: loobean & ~/ %flan - |= {bos/nock nif/nock} + |= {bos=nock nif=nock} ^- nock ?: =(bos nif) bos ?: =([%0 0] bos) nif @@ -7331,13 +7331,13 @@ :: ++ flip :: loobean negation ~/ %flip - |= dyr/nock + |= dyr=nock ?: =([%0 0] dyr) dyr [%6 dyr [%1 1] [%1 0]] :: ++ flor :: loobean | ~/ %flor - |= {bos/nock nif/nock} + |= {bos=nock nif=nock} ^- nock ?: =(bos nif) bos ?: =([%0 0] bos) nif @@ -7417,8 +7417,8 @@ -- :: ++ jock - |= rad/? - |= lot/coin ^- hoon + |= rad=? + |= lot=coin ^- hoon ?- -.lot ~ ?:(rad [%rock p.lot] [%sand p.lot]) @@ -7429,14 +7429,14 @@ ?@(p.lot [%sand %$ p.lot] [$(p.lot -.p.lot) $(p.lot +.p.lot)]) :: %many - [%cltr (turn p.lot |=(a/coin ^$(lot a)))] + [%cltr (turn p.lot |=(a=coin ^$(lot a)))] == :: ++ look ~/ %look - |= {cog/term dab/(map term hoon)} + |= {cog=term dab=(map term hoon)} =+ axe=1 - |- ^- (unit {p/axis q/hoon}) + |- ^- (unit {p=axis q=hoon}) ?- dab ~ ~ :: @@ -7467,9 +7467,9 @@ :: ++ loot ~/ %loot - |= {cog/term dom/(map term tome)} + |= {cog=term dom=(map term tome)} =+ axe=1 - |- ^- (unit {p/axis q/hoon}) + |- ^- (unit {p=axis q=hoon}) ?- dom ~ ~ :: @@ -7501,27 +7501,27 @@ :::: 5b: macro expansion :: ++ ah :: tiki engine - |_ tik/tiki + |_ tik=tiki ++ blue - |= gen/hoon + |= gen=hoon ^- hoon ?. &(?=(%| -.tik) ?=(~ p.tik)) gen [%tsgr [%$ 3] gen] :: ++ teal - |= mod/spec + |= mod=spec ^- spec ?: ?=(%& -.tik) mod [%over [%& 3]~ mod] :: ++ tele - |= syn/skin + |= syn=skin ^- skin ?: ?=(%& -.tik) syn [%over [%& 3]~ syn] :: ++ gray - |= gen/hoon + |= gen=hoon ^- hoon ?- -.tik %& ?~(p.tik gen [%tstr [u.p.tik ~] [%wing q.tik] gen]) @@ -7535,17 +7535,17 @@ %| [[%& 2] ~] == :: - ++ wthp |= opt/(list (pair spec hoon)) + ++ wthp |= opt=(list (pair spec hoon)) %+ gray %wthp - [puce (turn opt |=({a/spec b/hoon} [a (blue b)]))] - ++ wtkt |=({sic/hoon non/hoon} (gray [%wtkt puce (blue sic) (blue non)])) - ++ wtls |= {gen/hoon opt/(list (pair spec hoon))} + [puce (turn opt |=({a=spec b=hoon} [a (blue b)]))] + ++ wtkt |=({sic=hoon non=hoon} (gray [%wtkt puce (blue sic) (blue non)])) + ++ wtls |= {gen=hoon opt=(list (pair spec hoon))} %+ gray %wtls - [puce (blue gen) (turn opt |=({a/spec b/hoon} [a (blue b)]))] - ++ wtpt |=({sic/hoon non/hoon} (gray [%wtpt puce (blue sic) (blue non)])) - ++ wtsg |=({sic/hoon non/hoon} (gray [%wtsg puce (blue sic) (blue non)])) - ++ wthx |=(syn/skin (gray [%wthx (tele syn) puce])) - ++ wtts |=(mod/spec (gray [%wtts (teal mod) puce])) + [puce (blue gen) (turn opt |=({a=spec b=hoon} [a (blue b)]))] + ++ wtpt |=({sic=hoon non=hoon} (gray [%wtpt puce (blue sic) (blue non)])) + ++ wtsg |=({sic=hoon non=hoon} (gray [%wtsg puce (blue sic) (blue non)])) + ++ wthx |=(syn=skin (gray [%wthx (tele syn) puce])) + ++ wtts |=(mod=spec (gray [%wtts (teal mod) puce])) -- :: ++ ax @@ -7562,7 +7562,7 @@ nut=*(unit note) def=*(unit hoon) == - |_ {fab/? mod/spec} + |_ {fab=? mod=spec} :: ++ autoname :: derive name from spec @@ -7601,14 +7601,14 @@ %bczp ~ == ++ hint - |= not/note + |= not=note ^+ +> ?>(?=(~ nut) +>.$(nut `not)) :: ++ function :: construct a function example :: - |= {fun/spec arg/spec} + |= {fun=spec arg=spec} ^- hoon :: minimal context as subject :: @@ -7628,7 +7628,7 @@ ++ interface :: construct a core example :: - |= {variance/vair payload/spec arms/(map term spec)} + |= {variance=vair payload=spec arms=(map term spec)} ^- hoon :: attach proper variance control :: @@ -7656,7 +7656,7 @@ ++ home :: express a hoon against the original subject :: - |= gen/hoon + |= gen=hoon ^- hoon =/ ,wing ?: =(1 dom) @@ -7673,7 +7673,7 @@ ++ basal :: example base case :: - |= bas/base + |= bas=base ?- bas :: {%atom *} @@ -7704,25 +7704,25 @@ == :: ++ unfold - |= [fun/hoon arg/(list spec)] + |= [fun=hoon arg=(list spec)] ^- hoon [%cncl fun (turn arg |=(spec ktcl/+<))] :: ++ unreel - |= [one/wing res/(list wing)] + |= [one=wing res=(list wing)] ^- hoon ?~(res [%wing one] [%tsgl [%wing one] $(one i.res, res t.res)]) :: ++ descend :: record an axis to original subject :: - |= axe/axis + |= axe=axis +>(dom (peg axe dom)) :: ++ decorate :: apply documentation to expression :: - |= gen/hoon + |= gen=hoon ^- hoon =- ?~(nut - [%note u.nut -]) ^- hoon @@ -7885,10 +7885,10 @@ :: |_ $: :: axe: axis to fragment :: - axe/axis + axe=axis == ++ basic - |= bas/base + |= bas=base ^- hoon ?- bas {%atom *} @@ -7945,8 +7945,8 @@ |= $: :: one: first option :: rep: other options :: - one/spec - rep/(list spec) + one=spec + rep=(list spec) == ^- hoon :: if no other choices, construct head @@ -7969,8 +7969,8 @@ |= $: :: one: first format :: two: more formats :: - one/spec - rep/(list spec) + one=spec + rep=(list spec) == |- ^- hoon :: if no other choices, construct head @@ -7978,7 +7978,7 @@ ?~ rep relative:clear(mod one) :: fin: loop completion :: - =/ fin/hoon $(one i.rep, rep t.rep) + =/ fin=hoon $(one i.rep, rep t.rep) :: interrogate this instance :: :^ %wtcl @@ -8218,11 +8218,11 @@ %rake rake == =+ fab=`?`& - |_ gen/hoon + |_ gen=hoon :: ++ grip |= =skin - =| rel/wing + =| rel=wing |- ^- hoon ?- skin @ @@ -8295,8 +8295,8 @@ :: not used at present; see comment at %csng in ++open :::: ::++ hail -:: |= axe/axis -:: =| air/(list (pair wing hoon)) +:: |= axe=axis +:: =| air=(list (pair wing hoon)) :: |- ^+ air :: =+ hav=half :: ?~ hav [[[[%| 0 ~] [%& axe] ~] gen] air] @@ -8378,7 +8378,7 @@ {%bust *} ~(example ax fab %base p.gen) {%ktcl *} ~(factory ax fab p.gen) {%dbug *} q.gen - {%eror *} ~>(%slog.[0 leaf/p.gen] !!) + {%eror *} ~>(%slog.[0 leaf=p.gen] !!) :: {%knit *} :: :+ %tsgr [%ktts %v %$ 1] :: => v=. @@ -8508,7 +8508,7 @@ q.gen :+ %cnts (weld p.gen `wing`[[%& 2] ~]) - (turn r.gen |=({p/wing q/hoon} [p [%tsgr [%$ 3] q]])) + (turn r.gen |=({p=wing q=hoon} [p [%tsgr [%$ 3] q]])) :: {%ktdt *} [%ktls [%cncl p.gen q.gen ~] q.gen] {%kthp *} [%ktls ~(example ax fab p.gen) q.gen] @@ -8700,11 +8700,11 @@ [%mcts c.p.gen] :: ++ open-mane - |= a/mane:hoot + |= a=mane:hoot ?@(a [%rock %tas a] [[%rock %tas -.a] [%rock %tas +.a]]) :: ++ open-mart - |= {n/mane:hoot v/(list beer:hoot)} + |= {n=mane:hoot v=(list beer:hoot)} [(open-mane n) %knit v] -- :: @@ -8799,7 +8799,7 @@ =+ sut=`type`%noun |% ++ clip - |= ref/type + |= ref=type ?> ?|(!vet (nest(sut ref) & sut)) ref :: @@ -9041,7 +9041,7 @@ -- :: ++ bleu - |= {gol/type gen/hoon} + |= {gol=type gen=hoon} ^- {type nock} =+ pro=(mint gol gen) =+ jon=(apex:musk bran q.pro) @@ -9053,7 +9053,7 @@ [p.pro %1 p.u.jon] :: ++ blow - |= {gol/type gen/hoon} + |= {gol=type gen=hoon} ^- {type nock} =+ pro=(mint gol gen) =+ jon=(apex:musk bran q.pro) @@ -9106,19 +9106,19 @@ :: ++ busk ~/ %busk - |= gen/hoon + |= gen=hoon ^- type [%face [~ [gen ~]] sut] :: ++ buss ~/ %buss - |= {cog/term gen/hoon} + |= {cog=term gen=hoon} ^- type [%face [[[cog ~ gen] ~ ~] ~] sut] :: ++ crop ~/ %crop - |= ref/type + |= ref=type =+ bix=*(set {type type}) =< dext |% @@ -9172,26 +9172,26 @@ -- :: ++ cool - |= {pol/? hyp/wing ref/type} + |= {pol=? hyp=wing ref=type} ^- type =+ fid=(find %both hyp) ?- -.fid %| sut %& =< q %+ take p.p.fid - |=(a/type ?:(pol (fuse(sut a) ref) (crop(sut a) ref))) + |=(a=type ?:(pol (fuse(sut a) ref) (crop(sut a) ref))) == :: ++ duck ^-(tank ~(duck us sut)) ++ dune |.(duck) ++ dunk - |= paz/term ^- tank + |= paz=term ^- tank :+ %palm [['.' ~] ['-' ~] ~ ~] [[%leaf (mesc (trip paz))] duck ~] :: ++ elbo - |= {lop/palo rig/(list (pair wing hoon))} + |= {lop=palo rig=(list (pair wing hoon))} ^- type ?: ?=(%& -.q.lop) |- ^- type @@ -9216,10 +9216,10 @@ == :: ++ ergo - |= {lop/palo rig/(list (pair wing hoon))} + |= {lop=palo rig=(list (pair wing hoon))} ^- (pair type nock) =+ axe=(tend p.lop) - =| hej/(list (pair axis nock)) + =| hej=(list (pair axis nock)) ?: ?=(%& -.q.lop) =- [p.- (hike axe q.-)] |- ^- (pair type (list (pair axis nock))) @@ -9246,7 +9246,7 @@ == :: ++ endo - |= {lop/(pair palo palo) dox/type rig/(list (pair wing hoon))} + |= {lop=(pair palo palo) dox=type rig=(list (pair wing hoon))} ^- (pair type type) ?: ?=(%& -.q.p.lop) ?> ?=(%& -.q.q.lop) @@ -9289,16 +9289,16 @@ ++ bath * :: leg match type ++ claw * :: arm match type ++ form |*({* *} p=+<-) :: attach build state - ++ skin |*(p/* p) :: reveal build state - ++ meat |*(p/* p) :: remove build state + ++ skin |*(p=* p) :: reveal build state + ++ meat |*(p=* p) :: remove build state -- ++ make :: for mint |% ++ bath type :: leg match type ++ claw onyx :: arm ++ form |*({* *} [p=+<- q=+<+]) :: - ++ skin |*({p/* q/*} q) :: unwrap baggage - ++ meat |*({p/* q/*} p) :: unwrap filling + ++ skin |*({p=* q=*} q) :: unwrap baggage + ++ meat |*({p=* q=*} p) :: unwrap filling -- -- ++ def @@ -9334,23 +9334,23 @@ ++ make => (def make:arc) |% - ++ halp |~ a/hoon + ++ halp |~ a=hoon ^- fleg (mint %noun a) ++ vant - |% ++ trep |: $:{a/type b/wing c/type} + |% ++ trep |: $:{a=type b=wing c=type} ^- {axis type} (tack(sut a) b c) - ++ tasp |: $:{a/(pair axis type) b/fleg c/foat} + ++ tasp |: $:{a=(pair axis type) b=fleg c=foat} ^- foat [q.a [[p.a (skin b)] (skin c)]] ++ tyle |:($:foat +<) -- ++ vunt - |% ++ trep |: $:{a/claw b/wing c/bath} + |% ++ trep |: $:{a=claw b=wing c=bath} ^- (pair axis claw) (toss b c a) - ++ tasp |: $:{a/(pair axis claw) b/fleg c/fult} + ++ tasp |: $:{a=(pair axis claw) b=fleg c=fult} ^- fult [q.a [[p.a (skin b)] (skin c)]] ++ tyle |: $:fult @@ -9381,7 +9381,7 @@ =+ rame |@ ++ $ => +< - |: $:{rum/clom rig/(list (pair wing hoon))} + |: $:{rum=clom rig=(list (pair wing hoon))} ^- foat %- tyle |- ^- ceut @@ -9398,16 +9398,16 @@ => inc |% ++ echo - |: $:{rum/bath rig/(list (pair wing hoon))} + |: $:{rum=bath rig=(list (pair wing hoon))} (ecbo rum rig) :: ++ ecmo - |: $:{hag/claw rig/(list (pair wing hoon))} + |: $:{hag=claw rig=(list (pair wing hoon))} (eclo hag rig) -- -- :: ++ etco - |= {lop/palo rig/(list (pair wing hoon))} + |= {lop=palo rig=(list (pair wing hoon))} ^- (pair type nock) =+ cin=(oc (bin:ad make:lib:ad)) =. rig (flop rig) :: XX this unbreaks, void order in devulc @@ -9419,7 +9419,7 @@ (ecmo:cin ~(tap in q.q.lop) rig) :: ++ et - |_ {hyp/wing rig/(list (pair wing hoon))} + |_ {hyp=wing rig=(list (pair wing hoon))} :: ++ play ^- type @@ -9428,7 +9428,7 @@ (elbo p.lug rig) :: ++ mint - |= gol/type + |= gol=type ^- (pair type nock) =+ lug=(find %read hyp) ?: ?=(%| -.lug) ~>(%mean.'hoon' ?>(?=(~ rig) p.lug)) @@ -9436,7 +9436,7 @@ (etco p.lug rig) :: ++ mull - |= {gol/type dox/type} + |= {gol=type dox=type} ^- {type type} =+ lug=[p=(find %read hyp) q=(find(sut dox) %read hyp)] ?: ?=(%| -.p.lug) @@ -9449,26 +9449,26 @@ :: ++ epla ~/ %epla - |= {hyp/wing rig/(list (pair wing hoon))} + |= {hyp=wing rig=(list (pair wing hoon))} ^- type ~(play et hyp rig) :: ++ emin ~/ %emin - |= {gol/type hyp/wing rig/(list (pair wing hoon))} + |= {gol=type hyp=wing rig=(list (pair wing hoon))} ^- (pair type nock) (~(mint et hyp rig) gol) :: ++ emul ~/ %emul - |= {gol/type dox/type hyp/wing rig/(list (pair wing hoon))} + |= {gol=type dox=type hyp=wing rig=(list (pair wing hoon))} ^- (pair type type) (~(mull et hyp rig) gol dox) :: ++ felt !! :: :: ++ feel :: detect existence - |= rot/(list wing) + |= rot=(list wing) ^- ? =. rot (flop rot) |- ^- ? @@ -9490,11 +9490,11 @@ :: ++ fond ~/ %fond - |= {way/vial hyp/wing} + |= {way=vial hyp=wing} => |% ++ pony :: raw match $@ ~ :: void - %+ each :: natural/abnormal + %+ each :: natural=abnormal palo :: arm or leg %+ each :: abnormal @ud :: unmatched @@ -9527,14 +9527,14 @@ == ?: ?=(%& -.heg) [%& [`p.heg lon] %& (peek way p.heg)] - =| gil/(set type) + =| gil=(set type) =< $ |% ++ here ?: =(0 p.heg) [%& [~ `axe lon] %& sut] [%| %& (dec p.heg)] ++ lose [%| %& p.heg] ++ stop ?~(q.heg here lose) - ++ twin |= {hax/pony yor/pony} + ++ twin |= {hax=pony yor=pony} ^- pony ~_ leaf+"find-fork" ?: =(hax yor) hax @@ -9626,7 +9626,7 @@ ?~ fid ~ ?: ?=({%| %& *} fid) $(q.zot t.q.zot, p.heg p.p.fid) - =/ vat/(pair type nock) + =/ vat=(pair type nock) ?- -.fid %& (fine %& p.fid) %| (fine %| p.p.fid) @@ -9635,7 +9635,7 @@ -- :: {%fork *} - =+ wiz=(turn ~(tap in p.sut) |=(a/type ^$(sut a))) + =+ wiz=(turn ~(tap in p.sut) |=(a=type ^$(sut a))) ?~ wiz ~ |- ^- pony ?~ t.wiz i.wiz @@ -9651,7 +9651,7 @@ :: ++ find ~/ %find - |= {way/vial hyp/wing} + |= {way=vial hyp=wing} ^- port ~_ (show [%c %find] %l hyp) =- ?@ - !! @@ -9665,7 +9665,7 @@ :: ++ fund ~/ %fund - |= {way/vial gen/hoon} + |= {way=vial gen=hoon} ^- port =+ hup=~(reek ap gen) ?~ hup @@ -9674,7 +9674,7 @@ :: ++ fine ~/ %fine - |= tor/port + |= tor=port ^- (pair type nock) ?- -.tor %| p.tor @@ -9685,14 +9685,14 @@ == == :: ++ fire - |= hag/(list {p/type q/foot}) + |= hag=(list {p=type q=foot}) ^- type ?: ?=({{* {%wet ~ %1}} ~} hag) p.i.hag %- fork %+ turn hag.$ - |= {p/type q/foot} + |= {p=type q=foot} ?. ?=({%core *} p) ~_ (dunk %fire-type) ~_ leaf+"expected-fork-to-be-core" @@ -9716,7 +9716,7 @@ :: ++ fish ~/ %fish - |= axe/axis + |= axe=axis =+ vot=*(set type) |- ^- nock ?- sut @@ -9745,7 +9745,7 @@ :: ++ fuse ~/ %fuse - |= ref/type + |= ref=type =+ bix=*(set {type type}) |- ^- type ?: ?|(=(sut ref) =(%noun ref)) @@ -9785,13 +9785,13 @@ :: ++ gain ~/ %gain - |= gen/hoon ^- type + |= gen=hoon ^- type (chip & gen) :: ++ hemp :: generate formula from foot :: - |= [hud/poly gol/type gen/hoon] + |= [hud=poly gol=type gen=hoon] ^- nock ~+ =+ %hemp-141 @@ -9812,20 +9812,20 @@ =+ %hemp-141 :: tal: map from battery axis to foot :: - =; tal/(map @ud hoon) + =; tal=(map @ud hoon) :: produce lazy battery :: :_ ~ :+ %lazy 1 - |= axe/@ud + |= axe=@ud ^- (unit noun) %+ bind (~(get by tal) axe) - |= gen/hoon + |= gen=hoon %. [hud %noun gen] hemp(sut (core sut [nym hud %gold] sut [[%lazy 1 ..^$] ~] dom)) :: %- ~(gas by *(map @ud hoon)) - =| yeb/(list (pair @ud hoon)) + =| yeb=(list (pair @ud hoon)) =+ axe=1 |^ ?- dom ~ yeb @@ -9849,7 +9849,7 @@ yeb (chapter(axe (peg axe 2)) q.q.n.dom) == == == ++ chapter - |= dab/(map term hoon) + |= dab=(map term hoon) ^+ yeb ?- dab ~ yeb @@ -9876,12 +9876,12 @@ :: ++ lose ~/ %lose - |= gen/hoon ^- type + |= gen=hoon ^- type (chip | gen) :: ++ chip ~/ %chip - |= {how/? gen/hoon} ^- type + |= {how=? gen=hoon} ^- type ?: ?=({%wtts *} gen) (cool how q.gen (play ~(example ax fab p.gen))) ?: ?=({%wthx *} gen) @@ -9901,7 +9901,7 @@ ?:(=(neg gen) sut $(gen neg)) :: ++ bake - |= [dox/type hud/poly dab/(map term hoon)] + |= [dox=type hud=poly dab=(map term hoon)] ^- * ?: ?=(~ dab) ~ @@ -9920,7 +9920,7 @@ == :: ++ balk - |= [dox/type hud/poly dom/(map term tome)] + |= [dox=type hud=poly dom=(map term tome)] ^- * ?: ?=(~ dom) ~ @@ -9945,7 +9945,7 @@ ++ mine :: mint all chapters and feet in a core :: - |= [gol/type mel/vair nym/(unit term) hud/poly dom/(map term tome)] + |= [gol=type mel=vair nym=(unit term) hud=poly dom=(map term tome)] ^- (pair type nock) |^ =/ log (chapters-check (core-check gol)) @@ -9957,8 +9957,8 @@ |- ^- ?(~ ^) ?: ?=(~ dom) ~ - =/ dov/?(~ ^) - =/ dab/(map term hoon) q.q.n.dom + =/ dov=?(~ ^) + =/ dab=(map term hoon) q.q.n.dom =/ dag (arms-check dab (get-arms dog p.n.dom)) |- ^- ?(~ ^) ?: ?=(~ dab) @@ -10047,7 +10047,7 @@ |= [dog=(unit (map term tome)) nam=term] ^- (unit (map term hoon)) %+ bind dog - |= a/(map term tome) + |= a=(map term tome) ~_ leaf+"unexpcted-chapter.{(trip nam)}" q:(~(got by a) nam) :: check we have the expected number of arms @@ -10093,10 +10093,10 @@ :: ++ mint ~/ %mint - |= {gol/type gen/hoon} - ^- {p/type q/nock} + |= {gol=type gen=hoon} + ^- {p=type q=nock} ::~& %pure-mint - |^ ^- {p/type q/nock} + |^ ^- {p=type q=nock} ?: ?&(=(%void sut) !?=({%dbug *} gen)) ?. |(!vet ?=({%lost *} gen) ?=({%zpzp *} gen)) ~>(%mean.'mint-vain' !!) @@ -10246,14 +10246,14 @@ == :: ++ nice - |= typ/type + |= typ=type ~_ leaf+"mint-nice" ?> ?|(!vet (nest(sut gol) & typ)) typ :: ++ grow - |= {mel/vair nym/(unit term) hud/poly ruf/hoon dom/(map term tome)} - ^- {p/type q/nock} + |= {mel=vair nym=(unit term) hud=poly ruf=hoon dom=(map term tome)} + ^- {p=type q=nock} =+ dan=^$(gen ruf, gol %noun) =+ pul=(mine gol mel nym hud dom) [(nice p.pul) (cons q.pul q.dan)] @@ -10276,8 +10276,8 @@ :: ++ mull ~/ %mull - |= {gol/type dox/type gen/hoon} - |^ ^- {p/type q/type} + |= {gol=type dox=type gen=hoon} + |^ ^- {p=type q=type} ?: =(%void sut) ~>(%mean.'mull-none' !!) ?- gen @@ -10338,7 +10338,7 @@ :: {%wtcl *} =+ nor=$(gen p.gen, gol bool) - =+ ^= hiq ^- {p/type q/type} + =+ ^= hiq ^- {p=type q=type} =+ fex=[p=(gain p.gen) q=(gain(sut dox) p.gen)] ?: =(%void p.fex) :- %void @@ -10348,7 +10348,7 @@ ?: =(%void q.fex) ~>(%mean.'mull-bonk-b' !!) $(sut p.fex, dox q.fex, gen q.gen) - =+ ^= ran ^- {p/type q/type} + =+ ^= ran ^- {p=type q=type} =+ wux=[p=(lose p.gen) q=(lose(sut dox) p.gen)] ?: =(%void p.wux) :- %void @@ -10417,11 +10417,11 @@ == :: ++ beth - |= typ/type + |= typ=type [(nice typ) typ] :: ++ nice - |= typ/type + |= typ=type :: ~_ (dunk(sut gol) 'need') :: ~_ (dunk(sut typ) 'have') ~_ leaf+"mull-nice" @@ -10429,25 +10429,25 @@ typ :: ++ grow - |= {mel/vair nym/(unit term) hud/poly ruf/hoon dom/(map term tome)} + |= {mel=vair nym=(unit term) hud=poly ruf=hoon dom=(map term tome)} :: make al ~_ leaf+"mull-grow" - ^- {p/type q/type} + ^- {p=type q=type} =+ dan=^$(gen ruf, gol %noun) =+ yaz=(mile(sut p.dan) q.dan mel nym hud dom) [(nice p.yaz) q.yaz] -- - ++ meet |=(ref/type &((nest | ref) (nest(sut ref) | sut))) + ++ meet |=(ref=type &((nest | ref) (nest(sut ref) | sut))) :: :: ++ miss :: nonintersection |= $: :: ref: symmetric type :: - ref/type + ref=type == :: intersection of sut and ref is empty :: ^- ? - =| gil/(set (set type)) + =| gil=(set (set type)) =< dext |% ++ dext @@ -10484,19 +10484,19 @@ dext(sut q.sut, ref q.ref) == == -- - ++ mite |=(ref/type |((nest | ref) (nest(sut ref) & sut))) + ++ mite |=(ref=type |((nest | ref) (nest(sut ref) & sut))) ++ nest ~/ %nest - |= {tel/? ref/type} - =| $: seg/(set type) :: degenerate sut - reg/(set type) :: degenerate ref - gil/(set {p/type q/type}) :: assume nest + |= {tel=? ref=type} + =| $: seg=(set type) :: degenerate sut + reg=(set type) :: degenerate ref + gil=(set {p=type q=type}) :: assume nest == =< dext ~% %nest-in ..$ ~ |% ++ deem - |= {mel/vair ram/vair} + |= {mel=vair ram=vair} ^- ? ?. |(=(mel ram) =(%lead mel) =(%gold ram)) | ?- mel @@ -10507,8 +10507,8 @@ == :: ++ deep - |= $: dom/(map term tome) - vim/(map term tome) + |= $: dom=(map term tome) + vim=(map term tome) == ^- ? ?: ?=(~ dom) =(vim ~) @@ -10602,7 +10602,7 @@ :: ++ peek ~/ %peek - |= {way/?(%read %rite %both %free) axe/axis} + |= {way=?(%read %rite %both %free) axe=axis} ^- type ?: =(1 axe) sut @@ -10645,8 +10645,8 @@ == :: ++ peel - |= {way/vial met/?(%gold %iron %lead %zinc)} - ^- {sam/? con/?} + |= {way=vial met=?(%gold %iron %lead %zinc)} + ^- {sam=? con=?} ?: ?=(%gold met) [& &] ?- way %both [| |] @@ -10658,7 +10658,7 @@ ++ play ~/ %play => .(vet |) - |= gen/hoon + |= gen=hoon ^- type ?- gen {^ *} (cell $(gen p.gen) $(gen q.gen)) @@ -10717,7 +10717,7 @@ ++ redo :: refurbish faces |= $: :: ref: raw payload :: - ref/type + ref=type == :: :type: subject refurbished to reference namespace :: @@ -10726,9 +10726,9 @@ :: wec: reference tool stack set :: gil: repetition set :: - =| hos/(list tool) - =/ wec/(set (list tool)) [~ ~ ~] - =| gil/(set (pair type type)) + =| hos=(list tool) + =/ wec=(set (list tool)) [~ ~ ~] + =| gil=(set (pair type type)) =< :: errors imply subject/reference mismatch :: ~| %redo-match @@ -10768,8 +10768,8 @@ :: almost always 0. brute force is fine. :: =/ lip - =| lup/(unit @ud) - =| lip/@ud + =| lup=(unit @ud) + =| lip=@ud |- ^- @ud ?: |((gth lip p.len) (gth lip q.len)) (fall lup 0) @@ -10884,7 +10884,7 @@ ++ sint :: reduce by reference |= $: :: hod: expand holds :: - hod/? + hod=? == :: ::.: reference with face/fork/hold reduced :: @@ -10943,18 +10943,18 @@ :: ++ rest ~/ %rest - |= leg/(list {p/type q/hoon}) + |= leg=(list {p=type q=hoon}) ^- type - ?: (lien leg |=({p/type q/hoon} (~(has in fan) [p q]))) + ?: (lien leg |=({p=type q=hoon} (~(has in fan) [p q]))) ~>(%mean.'rest-loop' !!) => .(fan (~(gas in fan) leg)) %- fork %~ tap in %- ~(gas in *(set type)) - (turn leg |=({p/type q/hoon} (play(sut p) q))) + (turn leg |=({p=type q=hoon} (play(sut p) q))) :: ++ take - |= {vit/vein duz/$-(type type)} + |= {vit=vein duz=$-(type type)} ^- (pair axis type) :- (tend vit) =. vit (flop vit) @@ -10992,24 +10992,24 @@ == :: ++ tack - |= {hyp/wing mur/type} + |= {hyp=wing mur=type} ~_ (show [%c %tack] %l hyp) =+ fid=(find %rite hyp) ?> ?=(%& -.fid) (take p.p.fid |=(type mur)) :: ++ tend - |= vit/vein + |= vit=vein ^- axis ?~(vit 1 (peg $(vit t.vit) ?~(i.vit 1 u.i.vit))) :: ++ toss ~/ %toss - |= {hyp/wing mur/type men/(list {p/type q/foot})} - ^- {p/axis q/(list {p/type q/foot})} + |= {hyp=wing mur=type men=(list {p=type q=foot})} + ^- {p=axis q=(list {p=type q=foot})} =- [(need p.wib) q.wib] ^= wib - |- ^- {p/(unit axis) q/(list {p/type q/foot})} + |- ^- {p=(unit axis) q=(list {p=type q=foot})} ?~ men [*(unit axis) ~] =+ geq=(tack(sut p.i.men) hyp mur) @@ -11018,7 +11018,7 @@ :: ++ wrap ~/ %wrap - |= yoz/?(%lead %iron %zinc) + |= yoz=?(%lead %iron %zinc) ~_ leaf+"wrap" ^- type ?+ sut sut @@ -11032,7 +11032,7 @@ -- ++ us :: prettyprinter => |% - ++ cape {p/(map @ud wine) q/wine} :: + ++ cape {p=(map @ud wine) q=wine} :: ++ wine :: $@ $? %noun :: %path :: @@ -11042,21 +11042,21 @@ %wool :: %yarn :: == :: - $% {%mato p/term} :: - {%core p/(list @ta) q/wine} :: - {%face p/term q/wine} :: - {%list p/term q/wine} :: - {%pear p/term q/@} :: - {%bcwt p/(list wine)} :: - {%plot p/(list wine)} :: - {%stop p/@ud} :: - {%tree p/term q/wine} :: - {%unit p/term q/wine} :: + $% {%mato p=term} :: + {%core p=(list @ta) q=wine} :: + {%face p=term q=wine} :: + {%list p=term q=wine} :: + {%pear p=term q=@} :: + {%bcwt p=(list wine)} :: + {%plot p=(list wine)} :: + {%stop p=@ud} :: + {%tree p=term q=wine} :: + {%unit p=term q=wine} :: == :: -- - |_ sut/type + |_ sut=type ++ dash - |= {mil/tape lim/char lam/tape} + |= {mil=tape lim=char lam=tape} ^- tape =/ esc (~(gas in *(set @tD)) lam) :- lim @@ -11071,14 +11071,14 @@ [i.mil $(mil t.mil)] ['\\' ~(x ne (rsh 2 1 i.mil)) ~(x ne (end 2 1 i.mil)) $(mil t.mil)] :: - ++ deal |=(lum/* (dish dole lum)) + ++ deal |=(lum=* (dish dole lum)) ++ dial - |= ham/cape + |= ham=cape =+ gid=*(set @ud) =< `tank`-:$ |% ++ many - |= haz/(list wine) + |= haz=(list wine) ^- {(list tank) (set @ud)} ?~ haz [~ gid] =^ mor gid $(haz t.haz) @@ -11146,12 +11146,12 @@ -- :: ++ dish !: - |= {ham/cape lum/*} ^- tank + |= {ham=cape lum=*} ^- tank ~| [%dish-h ?@(q.ham q.ham -.q.ham)] ~| [%lump lum] ~| [%ham ham] %- need - =| gil/(set {@ud *}) + =| gil=(set {@ud *}) |- ^- (unit tank) ?- q.ham %noun @@ -11310,7 +11310,7 @@ |- ^- (unit (list tank)) ?: =(~ lum) [~ tuk] - ?. ?=({n/* l/* r/*} lum) + ?. ?=({n=* l=* r=*} lum) ~ =+ rol=$(lum r.lum) ?~ rol @@ -11332,7 +11332,7 @@ == :: ++ doge - |= ham/cape + |= ham=cape =- ?+ woz woz {%list * {%mato %'ta'}} %path {%list * {%mato %'t'}} %wall @@ -11391,10 +11391,10 @@ =+ gil=*(set type) =+ dex=[p=*(map type @) q=*(map @ wine)] =< [q.p q] - |- ^- {p/{p/(map type @) q/(map @ wine)} q/wine} + |- ^- {p={p=(map type @) q=(map @ wine)} q=wine} =- [p.tez (doge q.p.tez q.tez)] ^= tez - ^- {p/{p/(map type @) q/(map @ wine)} q/wine} + ^- {p={p=(map type @) q=(map @ wine)} q=wine} ?: (~(meet ut sut) -:!>(*type)) [dex %type] ?- sut @@ -11411,7 +11411,7 @@ {%core *} =+ yad=$(sut p.sut) :- p.yad - =+ ^= doy ^- {p/(list @ta) q/wine} + =+ ^= doy ^- {p=(list @ta) q=wine} ?: ?=({%core *} q.yad) [p.q.yad q.q.yad] [~ q.yad] @@ -11442,7 +11442,7 @@ {%fork *} =+ yed=(sort ~(tap in p.sut) aor) =- [p [%bcwt q]] - |- ^- {p/{p/(map type @) q/(map @ wine)} q/(list wine)} + |- ^- {p={p=(map type @) q=(map @ wine)} q=(list wine)} ?~ yed [dex ~] =+ mor=$(yed t.yed) @@ -11473,17 +11473,17 @@ (~(nest ut a) & b) :: ++ text :: tape pretty-print - |= vax/vase ^- tape + |= vax=vase ^- tape ~(ram re (sell vax)) :: -++ seem |=(toy/typo `type`toy) :: promote typo -++ seer |=(vix/vise `vase`vix) :: promote vise +++ seem |=(toy=typo `type`toy) :: promote typo +++ seer |=(vix=vise `vase`vix) :: promote vise :: :: +sell Pretty-print a vase to a tank using `deal`. :: ++ sell ~/ %sell - |= vax/vase + |= vax=vase ^- tank ~| %sell (~(deal us p.vax) q.vax) @@ -11491,12 +11491,12 @@ :: +skol $-(type tank) using `duck`. :: ++ skol - |= typ/type + |= typ=type ^- tank ~(duck ut typ) :: ++ slam :: slam a gate - |= {gat/vase sam/vase} ^- vase + |= {gat=vase sam=vase} ^- vase =+ :- ^= typ ^- type [%cell p.gat p.sam] ^= gen ^- hoon @@ -11517,17 +11517,17 @@ (~(fond ut typ) way ~[cog]) :: ++ slap - |= {vax/vase gen/hoon} ^- vase :: untyped vase .* + |= {vax=vase gen=hoon} ^- vase :: untyped vase .* =+ gun=(~(mint ut p.vax) %noun gen) [p.gun .*(q.vax q.gun)] :: ++ slog :: deify printf - =| pri/@ :: priority level - |= a/tang ^+ same :: .= ~&(%a 1) + =| pri=@ :: priority level + |= a=tang ^+ same :: .= ~&(%a 1) ?~(a same ~>(%slog.[pri i.a] $(a t.a))) :: ((slog ~[>%a<]) 1) :: :: ++ mean :: crash with trace - |= a/tang + |= a=tang ^+ !! ?~ a !! ~_(i.a $(a t.a)) @@ -11542,7 +11542,7 @@ == :: ++ slew :: get axis in vase - |= {axe/@ vax/vase} ^- (unit vase) + |= {axe=@ vax=vase} ^- (unit vase) ?. |- ^- ? ?: =(1 axe) & ?. ?=(^ q.vax) | @@ -11551,16 +11551,16 @@ `[(~(peek ut p.vax) %free axe) .*(q.vax [0 axe])] :: ++ slim :: identical to seer? - |= old/vise ^- vase + |= old=vise ^- vase old :: ++ slit :: type of slam - |= {gat/type sam/type} + |= {gat=type sam=type} ?> (~(nest ut (~(peek ut gat) %free 6)) & sam) (~(play ut [%cell gat sam]) [%cnsg [%$ ~] [%$ 2] [%$ 3] ~]) :: ++ slob :: superficial arm - |= {cog/@tas typ/type} + |= {cog=@tas typ=type} ^- ? ?+ typ | {%hold *} $(typ ~(repo ut typ)) @@ -11575,7 +11575,7 @@ == :: ++ sloe :: get arms in core - |= typ/type + |= typ=type ^- (list term) ?+ typ ~ {%hold *} $(typ ~(repo ut typ)) @@ -11583,27 +11583,27 @@ {%core *} %- zing %+ turn ~(tap by q.r.q.typ) - |= {* b/tome} + |= {* b=tome} %+ turn ~(tap by q.b) - |= {a/term *} + |= {a=term *} a == :: ++ slop :: cons two vases - |= {hed/vase tal/vase} + |= {hed=vase tal=vase} ^- vase [[%cell p.hed p.tal] [q.hed q.tal]] :: ++ slot :: got axis in vase - |= {axe/@ vax/vase} ^- vase + |= {axe=@ vax=vase} ^- vase [(~(peek ut p.vax) %free axe) .*(q.vax [0 axe])] :: ++ slym :: slam w+o sample-type - |= {gat/vase sam/*} ^- vase + |= {gat=vase sam=*} ^- vase (slap gat(+<.q sam) [%limb %$]) :: ++ sped :: reconstruct type - |= vax/vase + |= vax=vase ^- vase :_ q.vax ?@ q.vax (~(fuse ut p.vax) [%atom %$ ~]) @@ -11616,25 +11616,25 @@ :::: 5d: parser :: ++ vang :: set ++vast params - |= {bug/? wer/path} :: bug: debug mode + |= {bug=? wer=path} :: bug: debug mode %*(. vast bug bug, wer wer) :: wer: where we are :: ++ vast :: main parsing core =+ [bug=`?`| wer=*path] |% ++ gash %+ cook :: parse path - |= a/(list tyke) ^- tyke + |= a=(list tyke) ^- tyke ?~(a ~ (weld i.a $(a t.a))) (more fas limp) ++ gasp ;~ pose :: parse =path= etc. %+ cook - |=({a/tyke b/tyke c/tyke} :(weld a b c)) + |=({a=tyke b=tyke c=tyke} :(weld a b c)) ;~ plug - (cook |=(a/(list) (turn a |=(b/* ~))) (star tis)) - (cook |=(a/hoon [[~ a] ~]) hasp) - (cook |=(a/(list) (turn a |=(b/* ~))) (star tis)) + (cook |=(a=(list) (turn a |=(b=* ~))) (star tis)) + (cook |=(a=hoon [[~ a] ~]) hasp) + (cook |=(a=(list) (turn a |=(b=* ~))) (star tis)) == - (cook |=(a/(list) (turn a |=(b/* ~))) (plus tis)) + (cook |=(a=(list) (turn a |=(b=* ~))) (plus tis)) == ++ glam ~+((glue ace)) ++ hasp ;~ pose :: path element @@ -11643,19 +11643,19 @@ (stag %sand (stag %tas (cold %$ buc))) (stag %sand (stag %t qut)) %+ cook - |=(a/coin [%sand ?:(?=({~ %tas *} a) %tas %ta) ~(rent co a)]) + |=(a=coin [%sand ?:(?=({~ %tas *} a) %tas %ta) ~(rent co a)]) nuck:so == ++ limp %+ cook - |= {a/(list) b/tyke} + |= {a=(list) b=tyke} ?~ a b $(a t.a, b [`[%sand %tas %$] b]) ;~(plug (star fas) gasp) ++ mota %+ cook - |=({a/tape b/tape} (rap 3 (weld a b))) + |=({a=tape b=tape} (rap 3 (weld a b))) ;~(plug (star low) (star hig)) ++ glom - |= {wit/whit taw/whit} + |= {wit=whit taw=whit} ^- whit :* ?~(lab.wit lab.taw lab.wit) ?~(boy.wit boy.taw boy.wit) @@ -11683,10 +11683,10 @@ :: ++ apse ;~ pose - %+ cook |=({a/term b/cord} %*(. *whit def (my [a b ~] ~))) + %+ cook |=({a=term b=cord} %*(. *whit def (my [a b ~] ~))) (exit fine) :: - %+ cook |=(a/cord %*(. *whit boy `[a ~])) + %+ cook |=(a=cord %*(. *whit boy `[a ~])) (exit line) :: (easy *whit) @@ -11694,13 +11694,13 @@ :: :: ++ beer - |= $: lab/(unit term) - boy/(unit (pair cord (list sect))) - def/(list (pair (pair term cord) (list sect))) + |= $: lab=(unit term) + boy=(unit (pair cord (list sect))) + def=(list (pair (pair term cord) (list sect))) == ^- whit =; def [lab boy (malt def) ~] - (turn def |=({{a/term b/cord} c/(list sect)} [a [b c]])) + (turn def |=({{a=term b=cord} c=(list sect)} [a [b c]])) :: :: ++ body @@ -11734,20 +11734,20 @@ :: exit: :: to end of line, not consuming following space. :: ++ step ;~(plug ace ace) - ++ into |*(bod/rule (indo ;~(pfix step bod))) + ++ into |*(bod=rule (indo ;~(pfix step bod))) :: ++ indo - |* bod/rule + |* bod=rule ;~(pfix col gar ;~(sfix bod (just `@`10) (punt gap))) :: ++ exit - |* bod/rule + |* bod=rule ;~(pfix (star ace) col gal step bod) :: :: fill: full definition :: ++ fill - %+ cook |=({{a/term b/cord} c/(list sect) (unit ~)} [a b c]) + %+ cook |=({{a=term b=cord} c=(list sect) (unit ~)} [a b c]) ;~ plug (into fine) (rant ;~(pfix step text)) @@ -11757,7 +11757,7 @@ :: rant: series of sections. :: ++ rant - |* sec/rule + |* sec=rule %- star ;~ pfix (indo null) @@ -11766,20 +11766,20 @@ -- :: ++ plex :: reparse static path - |= gen/hoon ^- (unit path) + |= gen=hoon ^- (unit path) ?: ?=({%dbug *} gen) :: unwrap %dbug $(gen q.gen) ?. ?=({%clsg *} gen) ~ :: require :~ hoon %+ reel p.gen :: build using elements - |= {a/hoon b/_`(unit path)`[~ u=/]} :: starting from just / + |= {a=hoon b=_`(unit path)`[~ u=/]} :: starting from just / ?~ b ~ ?. ?=({%sand ?(%ta %tas) @} a) ~ :: /foo constants `[q.a u.b] :: ++ phax - |= ruw/(list (list woof)) + |= ruw=(list (list woof)) =+ [yun=*(list hoon) cah=*(list @)] - =+ wod=|=({a/tape b/(list hoon)} ^+(b ?~(a b [[%mcfs %knit (flop a)] b]))) + =+ wod=|=({a=tape b=(list hoon)} ^+(b ?~(a b [[%mcfs %knit (flop a)] b]))) |- ^+ yun ?~ ruw (flop (wod cah yun)) @@ -11789,16 +11789,16 @@ $(i.ruw t.i.ruw, cah ~, yun [p.i.i.ruw (wod cah yun)]) :: ++ posh - |= {pre/(unit tyke) pof/(unit {p/@ud q/tyke})} + |= {pre=(unit tyke) pof=(unit {p=@ud q=tyke})} ^- (unit (list hoon)) =- ?^(- - ~&(%posh-fail -)) =+ wom=(poof wer) %+ biff ?~ pre `u=wom %+ bind (poon wom u.pre) - |= moz/(list hoon) + |= moz=(list hoon) ?~(pof moz (weld moz (slag (lent u.pre) wom))) - |= yez/(list hoon) + |= yez=(list hoon) ?~ pof `yez =+ zey=(flop yez) =+ [moz=(scag p.u.pof zey) gul=(slag p.u.pof zey)] @@ -11806,12 +11806,12 @@ ?~(zom ~ `(weld (flop gul) u.zom)) :: ++ poof :: path -> (list hoon) - |=(pax/path ^-((list hoon) (turn pax |=(a/@ta [%sand %ta a])))) + |=(pax=path ^-((list hoon) (turn pax |=(a=@ta [%sand %ta a])))) :: :: tyke is =foo== as ~[~ `foo ~ ~] :: interpolate '=' path components ++ poon :: try to replace '='s - |= {pag/(list hoon) goo/tyke} :: default to pag + |= {pag=(list hoon) goo=tyke} :: default to pag ^- (unit (list hoon)) :: for null goo's ?~ goo `~ :: keep empty goo %+ both :: otherwise head comes @@ -11827,13 +11827,13 @@ :: ++ porc ;~ plug - (cook |=(a/(list) (lent a)) (star cen)) + (cook |=(a=(list) (lent a)) (star cen)) ;~(pfix fas gash) == :: ++ rump %+ sear - |= {a/wing b/(unit hoon)} ^- (unit hoon) + |= {a=wing b=(unit hoon)} ^- (unit hoon) ?~(b [~ %wing a] ?.(?=({@ ~} a) ~ [~ [%rock %tas i.a] u.b])) ;~(plug rope ;~(pose (stag ~ wede) (easy ~))) :: @@ -11844,7 +11844,7 @@ :: ++ rupl %+ cook - |= {a/? b/(list hoon) c/?} + |= {a=? b=(list hoon) c=?} ?: a ?: c [%clsg [%clsg b] ~] @@ -11871,12 +11871,12 @@ :: :: ++ sail :: xml template - |= in-tall-form/? =| lin/? + |= in-tall-form=? =| lin=? |% :: ++ apex :: product hoon %+ cook - |= tum/(each manx:hoot marl:hoot) ^- hoon + |= tum=(each manx:hoot marl:hoot) ^- hoon ?- -.tum %& [%xray p.tum] %| [%mcts p.tum] @@ -11887,7 +11887,7 @@ ;~(pfix mic ?:(in-tall-form tall-top wide-top)) :: ++ inline-embed :: brace interpolation - %+ cook |=(a/tuna:hoot a) + %+ cook |=(a=tuna:hoot a) ;~ pose ;~(pfix mic bracketed-elem(in-tall-form |)) ;~(plug tuna-mode sump) @@ -11895,7 +11895,7 @@ == :: ++ script-or-style :: script or style - %+ cook |=(a/marx:hoot a) + %+ cook |=(a=marx:hoot a) ;~ plug ;~(pose (jest %script) (jest %style)) wide-attrs @@ -11925,43 +11925,43 @@ == :: ++ wide-attrs :: wide attributes - %+ cook |=(a/(unit mart:hoot) (fall a ~)) + %+ cook |=(a=(unit mart:hoot) (fall a ~)) %- punt %+ ifix [pal par] %+ more (jest ', ') ;~((glue ace) a-mane hopefully-quote) :: ++ wide-tail :: wide elements - %+ cook |=(a/marl:hoot a) + %+ cook |=(a=marl:hoot a) ;~(pose ;~(pfix col wrapped-elems) (cold ~ mic) (easy ~)) :: ++ wide-elems :: wide elements - %+ cook |=(a/marl:hoot a) + %+ cook |=(a=marl:hoot a) %+ cook join-tops (star ;~(pfix ace wide-inner-top)) :: ++ wide-paren-elems :: wide flow - %+ cook |=(a/marl:hoot a) + %+ cook |=(a=marl:hoot a) %+ cook join-tops (ifix [pal par] (more ace wide-inner-top)) :: ::+| :: ++ drop-top - |= a/(each tuna:hoot marl:hoot) ^- marl:hoot + |= a=(each tuna:hoot marl:hoot) ^- marl:hoot ?- -.a %& [p.a]~ %| p.a == :: ++ join-tops - |= a/(list (each tuna:hoot marl:hoot)) ^- marl:hoot + |= a=(list (each tuna:hoot marl:hoot)) ^- marl:hoot (zing (turn a drop-top)) :: ::+| :: ++ wide-quote :: wide quote - %+ cook |=(a/marl:hoot a) + %+ cook |=(a=marl:hoot a) ;~ pose ;~ less (jest '"""') (ifix [doq doq] (cook collapse-chars quote-innards)) @@ -11973,7 +11973,7 @@ == :: ++ quote-innards :: wide+tall flow - %+ cook |=(a/(list $@(@ tuna:hoot)) a) + %+ cook |=(a=(list $@(@ tuna:hoot)) a) %- star ;~ pose ;~(pfix bas ;~(pose (mask "-+*%;\{") bas doq bix:ab)) @@ -11987,7 +11987,7 @@ ;~(plug tag-head wide-elems) :: ++ wrapped-elems :: wrapped tuna - %+ cook |=(a/marl:hoot a) + %+ cook |=(a=marl:hoot a) ;~ pose wide-paren-elems (cook |=(@t `marl`[;/((trip +<))]~) qut) @@ -11998,7 +11998,7 @@ :: ++ a-mane :: mane as hoon %+ cook - |= {a/@tas b/(unit @tas)} + |= {a=@tas b=(unit @tas)} ?~(b a [a u.b]) ;~ plug mixed-case-symbol @@ -12010,7 +12010,7 @@ == :: ++ en-class - |= a/(list {%class p/term}) + |= a=(list {%class p=term}) ^- (unit {%class tape}) ?~ a ~ %- some @@ -12022,14 +12022,14 @@ :: ++ tag-head :: tag head %+ cook - |= {a/mane:hoot b/mart:hoot c/mart:hoot} + |= {a=mane:hoot b=mart:hoot c=mart:hoot} ^- marx:hoot [a (weld b c)] ;~ plug a-mane :: %+ cook - |= a/(list (unit {term (list beer:hoot)})) + |= a=(list (unit {term (list beer:hoot)})) ^- (list {term (list beer:hoot)}) :: discard nulls (murn a same) @@ -12066,7 +12066,7 @@ :: ++ tall-elem :: tall preface %+ cook - |= {a/{p/mane:hoot q/mart:hoot} b/mart:hoot c/marl:hoot} + |= {a={p=mane:hoot q=mart:hoot} b=mart:hoot c=marl:hoot} ^- manx:hoot [[p.a (weld q.a b)] c] ;~(plug tag-head tall-attrs tall-tail) @@ -12075,16 +12075,16 @@ :: ::REVIEW is there a better way to do this? ++ hopefully-quote :: prefer "quote" form - %+ cook |=(a/(list beer:hoot) a) - %+ cook |=(a/hoon ?:(?=(%knit -.a) p.a [~ a]~)) + %+ cook |=(a=(list beer:hoot) a) + %+ cook |=(a=hoon ?:(?=(%knit -.a) p.a [~ a]~)) wide :: ++ script-style-tail :: unescaped tall tail - %+ cook |=(a/marl:hoot a) + %+ cook |=(a=marl:hoot a) %+ ifix [gap ;~(plug gap duz)] %+ most gap ;~ pfix mic - %+ cook |=(a/tape ;/(a)) + %+ cook |=(a=tape ;/(a)) ;~ pose ;~(pfix ace (star prn)) (easy "\0a") @@ -12093,7 +12093,7 @@ :: ++ tall-tail :: tall tail ?> in-tall-form - %+ cook |=(a/marl:hoot a) + %+ cook |=(a=marl:hoot a) ;~ pose (cold ~ mic) ;~(pfix col wrapped-elems(in-tall-form |)) @@ -12107,9 +12107,9 @@ (most gap ;~(pose top-level (stag %| cram))) :: ++ collapse-chars :: group consec chars - |= reb/(list $@(@ tuna:hoot)) + |= reb=(list $@(@ tuna:hoot)) ^- marl:hoot - =| {sim/(list @) tuz/marl:hoot} + =| {sim=(list @) tuz=marl:hoot} |- ^- marl:hoot ?~ reb =. sim @@ -12136,8 +12136,8 @@ %head :: heading == :: ++ trig :: line style - $: col/@ud :: start column - sty/trig-style :: style + $: col=@ud :: start column + sty=trig-style :: style == :: ++ trig-style :: type of parsed line $% $: %end :: terminator @@ -12150,7 +12150,7 @@ %fens :: ``` code fence %expr :: ;sail expression == == :: - {%new p/trig-new} :: open container + {%new p=trig-new} :: open container {%old %text} :: anything else == :: ++ trig-new :: start a @@ -12161,14 +12161,14 @@ %poem :: [ ]{8} poem == :: ++ graf :: paragraph element - $% {%bold p/(list graf)} :: *bold* - {%talc p/(list graf)} :: _italics_ - {%quod p/(list graf)} :: "double quote" - {%code p/tape} :: code literal - {%text p/tape} :: text symbol - {%link p/(list graf) q/tape} :: URL - {%mage p/tape q/tape} :: image - {%expr p/tuna:hoot} :: interpolated hoon + $% {%bold p=(list graf)} :: *bold* + {%talc p=(list graf)} :: _italics_ + {%quod p=(list graf)} :: "double quote" + {%code p=tape} :: code literal + {%text p=tape} :: text symbol + {%link p=(list graf) q=tape} :: URL + {%mage p=tape q=tape} :: image + {%expr p=tuna:hoot} :: interpolated hoon == -- =< (non-empty:parse |=(nail `(like tarp)`~($ main +<))) @@ -12190,12 +12190,12 @@ :: [loc txt]: parsing state :: =/ verbose & - =| err/(unit hair) - =| ind/{out/@ud inr/@ud} - =| hac/(list item) - =/ cur/item [%down ~] - =| par/(unit (pair hair wall)) - |_ {loc/hair txt/tape} + =| err=(unit hair) + =| ind={out=@ud inr=@ud} + =| hac=(list item) + =/ cur=item [%down ~] + =| par=(unit (pair hair wall)) + |_ {loc=hair txt=tape} :: ++ $ :: resolve ^- (like tarp) @@ -12229,12 +12229,12 @@ == :: ++ back :: column retreat - |= luc/@ud + |= luc=@ud ^+ +> ?: (gte luc inr.ind) +> :: :: nex: next backward step that terminates this context - =/ nex/@ud cur-indent :: REVIEW code and poem blocks are + =/ nex=@ud cur-indent :: REVIEW code and poem blocks are :: handled elsewhere ?: (gth nex (sub inr.ind luc)) :: @@ -12265,7 +12265,7 @@ == :: ++ read-line :: capture raw line - =| lin/tape + =| lin=tape |- ^+ [[lin *(unit _err)] +<.^$] :: parsed tape and halt/error :: :: no unterminated lines @@ -12289,7 +12289,7 @@ $(lin t.lin) (flop lin) :: - =/ eat-newline/nail [[+(p.loc) 1] t.txt] + =/ eat-newline=nail [[+(p.loc) 1] t.txt] =/ saw look(+<.$ eat-newline) :: ?: ?=({~ @ %end ?(%stet %dent)} saw) :: stop on == or dedent @@ -12299,7 +12299,7 @@ ++ look :: inspect line ^- (unit trig) %+ bind (wonk (look:parse loc txt)) - |= a/trig ^+ a + |= a=trig ^+ a :: :: treat a non-terminator as a terminator :: if it's outdented @@ -12329,14 +12329,14 @@ ;/("{+<}\0a") :: :: yex: block recomposed, with newlines - =/ yex/tape + =/ yex=tape %- zing %+ turn (flop q.u.par) - |= a/tape + |= a=tape (runt [(dec inr.ind) ' '] "{a}\0a") :: :: vex: parse of paragraph - =/ vex/(like tarp) + =/ vex=(like tarp) :: :: either a one-line header or a paragraph %. [p.u.par yex] @@ -12368,7 +12368,7 @@ ?~ saw :: :: break section - =^ a/{tape fin/(unit _err)} +<.$ read-line + =^ a={tape fin=(unit _err)} +<.$ read-line ?^ fin.a ..$(err u.fin.a) =>(close-par line) @@ -12440,13 +12440,13 @@ ..$(err `[p.loc col.saw]) :: :: accept line and maybe continue - =^ a/{lin/tape fin/(unit _err)} +<.$ read-line + =^ a={lin=tape fin=(unit _err)} +<.$ read-line =. par par(q.u [lin.a q.u.par]) ?^ fin.a ..$(err u.fin.a) line ++ parse-block :: execute parser - |= fel/$-(nail (like tarp)) ^+ +> - =/ vex/(like tarp) (fel loc txt) + |= fel=$-(nail (like tarp)) ^+ +> + =/ vex=(like tarp) (fel loc txt) ?~ q.vex ~? verbose [%parse-block txt] +>.$(err `p.vex) @@ -12458,7 +12458,7 @@ == :: ++ read-one :: read %one item - |= sty/?(%expr %rule %fens) ^+ +> + |= sty=?(%expr %rule %fens) ^+ +> ?- sty %expr (parse-block expr:parse) %rule (parse-block hrul:parse) @@ -12466,7 +12466,7 @@ == :: ++ open-item :: enter list/quote - |= saw/trig-new + |= saw=trig-new =< +>.$:apex |% ++ apex ^+ . :: open container @@ -12482,7 +12482,7 @@ |=(mite +>(hac [cur hac], cur [+< ~])) :: ++ entr :: enter container - |= typ/mite + |= typ=mite ^+ +> :: :: indent by 2 @@ -12495,7 +12495,7 @@ (push typ) :: ++ lent :: list entry - |= ord/?(%lord %lunt) + |= ord=?(%lord %lunt) ^+ +> => ?:(=(ord p.cur) +>.$ (push ord)) :: push list if new (entr %lime) @@ -12505,10 +12505,10 @@ ++ parse :: individual parsers |% ++ look :: classify line - %+ cook |=(a/(unit trig) a) + %+ cook |=(a=(unit trig) a) ;~ pfix (star ace) %+ here :: report indent - |=({a/pint b/?(~ trig-style)} ?~(b ~ `[q.p.a b])) + |=({a=pint b=?(~ trig-style)} ?~(b ~ `[q.p.a b])) ;~ pose (cold ~ (just `@`10)) :: blank line :: @@ -12537,7 +12537,7 @@ ;~(less tem prn) == ++ cash :: escaped fence - |* tem/rule + |* tem=rule %- echo %- star ;~ pose @@ -12550,14 +12550,14 @@ |* $: :: fex: primary parser :: sab: secondary parser :: - fex/rule - sab/rule + fex=rule + sab=rule == - |= {loc/hair txt/tape} + |= {loc=hair txt=tape} ^+ *sab :: :: vex: fenced span - =/ vex/(like tape) (fex loc txt) + =/ vex=(like tape) (fex loc txt) ?~ q.vex vex :: :: hav: reparse full fenced text @@ -12572,14 +12572,14 @@ :: ::REVIEW surely there is a less hacky "first or after space" solution ++ easy-sol :: parse start of line - |* a/* - |= b/nail + |* a=* + |= b=nail ?: =(1 q.p.b) ((easy a) b) (fail b) :: ++ echo :: hoon literal - |* sab/rule - |= {loc/hair txt/tape} + |* sab=rule + |= {loc=hair txt=tape} ^- (like tape) :: :: vex: result of parsing wide hoon @@ -12596,8 +12596,8 @@ [i.txt $(txt +.txt)] :: ++ non-empty - |* a/rule - |= tub/nail ^+ (a) + |* a=rule + |= tub=nail ^+ (a) =/ vex (a tub) ~! vex ?~ q.vex vex @@ -12608,7 +12608,7 @@ ++ word :: tarp parser %+ knee *(list graf) |. ~+ %+ cook - |= a/$%(graf [%list (list graf)]) + |= a=$%(graf [%list (list graf)]) ^- (list graf) ?:(?=(%list -.a) +.a [a ~]) ;~ pose @@ -12718,7 +12718,7 @@ =- (cook - werk) :: :: collect raw tarp into xml tags - |= gaf/(list graf) + |= gaf=(list graf) ^- tarp =< main |% @@ -12729,7 +12729,7 @@ (weld (item i.gaf) $(gaf t.gaf)) :: :: fip: accumulate text blocks - =/ fip/(list tape) [p.i.gaf]~ + =/ fip=(list tape) [p.i.gaf]~ |- ^- tarp ?~ t.gaf [;/((zing (flop fip))) ~] ?. ?=(%text -.i.t.gaf) @@ -12737,7 +12737,7 @@ $(gaf t.gaf, fip :_(fip p.i.t.gaf)) :: ++ item - |= nex/graf + |= nex=graf ^- tarp ::CHECK can be tuna:hoot? ?- -.nex %text !! :: handled separately @@ -12766,15 +12766,15 @@ ;~(plug tic tic tic (just '\0a')) :: ++ fens - |= col/@u ~+ + |= col=@u ~+ =/ ind (stun [(dec col) (dec col)] ace) =/ ind-tics ;~(plug ind tics) - %+ cook |=(txt/tape `tarp`[[%pre ~] ;/(txt) ~]~) + %+ cook |=(txt=tape `tarp`[[%pre ~] ;/(txt) ~]~) :: :: leading outdent is ok since container may :: have already been parsed and consumed %+ ifix [;~(plug (star ace) tics) ind-tics] - %^ stir "" |=({a/tape b/tape} "{a}\0a{b}") + %^ stir "" |=({a=tape b=tape} "{a}\0a{b}") ;~ pose %+ ifix [ind (just '\0a')] ;~(less tics (star prn)) @@ -12784,7 +12784,7 @@ :: ++ para :: paragraph %+ cook - |=(a/tarp ?~(a ~ [[%p ~] a]~)) + |=(a=tarp ?~(a ~ [[%p ~] a]~)) ;~(pfix (punt whit) down) :: ++ expr :: expression @@ -12798,7 +12798,7 @@ :: ++ head :: parse heading %+ cook - |= {haxes/tape kids/tarp} ^- tarp + |= {haxes=tape kids=tarp} ^- tarp =/ tag (crip 'h' <(lent haxes)>) :: e.g. ### -> %h3 =/ id (contents-to-id kids) [[tag [%id id]~] kids]~ @@ -12806,8 +12806,8 @@ ;~(pfix (star ace) ;~((glue whit) (stun [1 6] hax) down)) :: ++ contents-to-id :: # text into elem id - |= a/(list tuna:hoot) ^- tape - =; raw/tape + |= a=(list tuna:hoot) ^- tape + =; raw=tape %+ turn raw |= @tD ^- @tD @@ -12826,7 +12826,7 @@ ^- tape ?- i.a {{%$ {%$ *} ~} ~} :: text node contents - (murn v.i.a.g.i.a |=(a/beer:hoot ?^(a ~ (some a)))) + (murn v.i.a.g.i.a |=(a=beer:hoot ?^(a ~ (some a)))) {^ *} $(a c.i.a) :: concatenate children {@ *} ~ :: ignore interpolation == @@ -12853,7 +12853,7 @@ (stag %leaf (stag %f (cold & pam))) (stag %leaf (stag %f (cold | bar))) (stag %leaf (stag %t qut)) - (stag %leaf (sear |=(a/coin ?:(?=(%$ -.a) (some +.a) ~)) nuck:so)) + (stag %leaf (sear |=(a=coin ?:(?=(%$ -.a) (some +.a) ~)) nuck:so)) == == == @@ -12939,7 +12939,7 @@ :: (stag %leaf (stag %tas (cold %$ buc))) (stag %leaf (stag %t qut)) - (stag %leaf (sear |=(a/coin ?:(?=(%$ -.a) (some +.a) ~)) nuck:so)) + (stag %leaf (sear |=(a=coin ?:(?=(%$ -.a) (some +.a) ~)) nuck:so)) == == rump @@ -12947,18 +12947,18 @@ :- '%' ;~ pfix cen ;~ pose - (stag %clsg (sear |~({a/@ud b/tyke} (posh ~ ~ a b)) porc)) + (stag %clsg (sear |~({a=@ud b=tyke} (posh ~ ~ a b)) porc)) (stag %rock (stag %tas (cold %$ buc))) (stag %rock (stag %f (cold & pam))) (stag %rock (stag %f (cold | bar))) (stag %rock (stag %t qut)) (cook (jock &) nuck:so) - (stag %clsg (sear |=(a/(list) (posh ~ ~ (lent a) ~)) (star cen))) + (stag %clsg (sear |=(a=(list) (posh ~ ~ (lent a) ~)) (star cen))) == == :- '&' ;~ pose - (cook |=(a/wing [%cnts a ~]) rope) + (cook |=(a=wing [%cnts a ~]) rope) (stag %wtpm ;~(pfix pam (ifix [pal par] (most ace wide)))) ;~(plug (stag %rock (stag %f (cold & pam))) wede) (stag %sand (stag %f (cold & pam))) @@ -12981,32 +12981,32 @@ (stag %dtls ;~(pfix lus (ifix [pal par] wide))) :: %+ cook - |= a/(list (list woof)) + |= a=(list (list woof)) :- %mcfs [%knit |-(^-((list woof) ?~(a ~ (weld i.a $(a t.a)))))] (most dog ;~(pfix lus soil)) :: - (cook |=(a/wing [%cnts a ~]) rope) + (cook |=(a=wing [%cnts a ~]) rope) == :- '-' ;~ pose (stag %sand tash:so) :: %+ cook - |= a/(list (list woof)) + |= a=(list (list woof)) [%clsg (phax a)] (most dog ;~(pfix hep soil)) :: - (cook |=(a/wing [%cnts a ~]) rope) + (cook |=(a=wing [%cnts a ~]) rope) == :- '.' ;~ pose (cook (jock |) ;~(pfix dot perd:so)) - (cook |=(a/wing [%cnts a ~]) rope) + (cook |=(a=wing [%cnts a ~]) rope) == :- ['0' '9'] %+ cook - |= {a/dime b/(unit hoon)} + |= {a=dime b=(unit hoon)} ?~(b [%sand a] [[%rock a] u.b]) ;~(plug bisk:so (punt wede)) :- ':' @@ -13049,26 +13049,26 @@ ;~ pfix tic ;~ pose %+ cook - |=({a/@ta b/hoon} [%ktls [%sand a 0] [%ktls [%sand %$ 0] b]]) + |=({a=@ta b=hoon} [%ktls [%sand a 0] [%ktls [%sand %$ 0] b]]) ;~(pfix pat ;~(plug mota ;~(pfix tic wide))) ;~ pfix tar (stag %kthp (stag [%base %noun] ;~(pfix tic wide))) == (stag %kthp ;~(plug wyde ;~(pfix tic wide))) (stag %ktls ;~(pfix lus ;~(plug wide ;~(pfix tic wide)))) - (cook |=(a/hoon [[%rock %n ~] a]) wide) + (cook |=(a=hoon [[%rock %n ~] a]) wide) == == :- '"' %+ cook - |= a/(list (list woof)) + |= a=(list (list woof)) [%knit |-(^-((list woof) ?~(a ~ (weld i.a $(a t.a)))))] (most dog soil) :- ['a' 'z'] rump :- '|' ;~ pose - (cook |=(a/wing [%cnts a ~]) rope) + (cook |=(a=wing [%cnts a ~]) rope) (stag %wtbr ;~(pfix bar (ifix [pal par] (most ace wide)))) ;~(plug (stag %rock (stag %f (cold | bar))) wede) (stag %sand (stag %f (cold | bar))) @@ -13123,7 +13123,7 @@ == ++ sump (ifix [kel ker] (stag %cltr (most ace wide))) ++ norm :: rune regular form - |= tol/? + |= tol=? |% ++ structure %- stew @@ -13154,25 +13154,25 @@ ^. stet ^. limo :~ :- '^' %+ cook - |= [%cnkt a/hoon b/spec c/spec d/spec] + |= [%cnkt a=hoon b=spec c=spec d=spec] [%make a b c d ~] (rune ket %cnkt exqy) :: :- '+' %+ cook - |= [%cnls a/hoon b/spec c/spec] + |= [%cnls a=hoon b=spec c=spec] [%make a b c ~] (rune lus %cnls exqx) :: :- '-' %+ cook - |= [%cnhp a/hoon b/spec] + |= [%cnhp a=hoon b=spec] [%make a b ~] (rune hep %cnhp exqd) :: :- ':' %+ cook - |= [%cncl a/hoon b/(list spec)] + |= [%cncl a=hoon b=(list spec)] [%make a b] (rune col %cncl exqz) == @@ -13372,7 +13372,7 @@ == :: %+ cook - |= {b/term d/spec} + |= {b=term d=spec} [b [%ktcl [%name b d]]] ;~ pfix (jest '+$') ;~ plug @@ -13503,16 +13503,16 @@ ;~(pfix dif (stag hil (stag tuq (toad har)))) -- ++ runq :: wide or tall if tol - |* [wid/rule tal/rule] :: else wide + |* [wid=rule tal=rule] :: else wide ?. tol wid ;~(pose wid tal) :: ++ glop ~+((glue mash)) :: separated by space ++ gunk ~+((glue muck)) :: separated list - ++ butt |* zor/rule :: closing == if tall + ++ butt |* zor=rule :: closing == if tall ?:(tol ;~(sfix zor ;~(plug gap duz)) zor) - ++ ulva |* zor/rule :: closing -- and tall + ++ ulva |* zor=rule :: closing -- and tall ?.(tol fail ;~(sfix zor ;~(plug gap dun))) ++ hank (most muck loaf) :: gapped hoons ++ hunk (most muck loan) :: gapped specs @@ -13524,7 +13524,7 @@ ++ muck ?:(tol gap ace) :: general separator ++ teak %+ knee *tiki |. ~+ :: wing or hoon =+ ^= gub - |= {a/term b/$%({%& p/wing} {%| p/hoon})} + |= {a=term b=$%({%& p=wing} {%| p=hoon})} ^- tiki ?-(-.b %& [%& [~ a] p.b], %| [%| [~ a] p.b]) =+ ^= wyp @@ -13607,25 +13607,25 @@ :: :: tiki expansion for %wt runes :: - ++ txhp |. %+ cook |= {a/tiki b/(list (pair spec hoon))} + ++ txhp |. %+ cook |= {a=tiki b=(list (pair spec hoon))} (~(wthp ah a) b) (butt ;~(gunk teak ruck)) - ++ tkkt |. %+ cook |= {a/tiki b/hoon c/hoon} + ++ tkkt |. %+ cook |= {a=tiki b=hoon c=hoon} (~(wtkt ah a) b c) ;~(gunk teak loaf loaf) - ++ txls |. %+ cook |= {a/tiki b/hoon c/(list (pair spec hoon))} + ++ txls |. %+ cook |= {a=tiki b=hoon c=(list (pair spec hoon))} (~(wtls ah a) b c) (butt ;~(gunk teak loaf ruck)) - ++ tkvt |. %+ cook |= {a/tiki b/hoon c/hoon} + ++ tkvt |. %+ cook |= {a=tiki b=hoon c=hoon} (~(wtpt ah a) b c) ;~(gunk teak loaf loaf) - ++ tksg |. %+ cook |= {a/tiki b/hoon c/hoon} + ++ tksg |. %+ cook |= {a=tiki b=hoon c=hoon} (~(wtsg ah a) b c) ;~(gunk teak loaf loaf) - ++ txts |. %+ cook |= {a/spec b/tiki} + ++ txts |. %+ cook |= {a=spec b=tiki} (~(wtts ah b) a) ;~(gunk loan teak) - ++ txhx |. %+ cook |= {a/skin b/tiki} + ++ txhx |. %+ cook |= {a=skin b=tiki} (~(wthx ah b) a) ;~(gunk lore teak) :: @@ -13667,7 +13667,7 @@ ;~(pfix cen sym) ;~(pfix dot ;~(pose wide ;~(pfix muck loaf))) == - ++ bony (cook |=(a/(list) (lent a)) (plus tis)) :: base 1 =en count + ++ bony (cook |=(a=(list) (lent a)) (plus tis)) :: base 1 =en count ++ bonz :: term-labelled hoons ;~ pose (cold ~ sig) @@ -13678,12 +13678,12 @@ -- :: ++ lang :: lung sample - $: ros/hoon + $: ros=hoon $= vil - $% {%tis p/hoon} - {%col p/hoon} - {%ket p/hoon} - {%lit p/(list (pair wing hoon))} + $% {%tis p=hoon} + {%col p=hoon} + {%ket p=hoon} + {%lit p=(list (pair wing hoon))} == == :: @@ -13694,7 +13694,7 @@ ^- (unit hoon) ?- -.vil %col ?:(=([%base %flag] ros) ~ [~ %tsgl ros p.vil]) - %lit (bind ~(reek ap ros) |=(hyp/wing [%cnts hyp p.vil])) + %lit (bind ~(reek ap ros) |=(hyp=wing [%cnts hyp p.vil])) %ket [~ ros p.vil] %tis =+ rud=~(flay ap ros) ?~(rud ~ `[%ktts u.rud p.vil]) @@ -13729,20 +13729,20 @@ ++ rope :: wing form %+ knee *wing |. ~+ - %+ (slug |=({a/limb b/wing} [a b])) + %+ (slug |=({a=limb b=wing} [a b])) dot ;~ pose (cold [%| 0 ~] com) %+ cook - |=({a/(list) b/term} ?~(a b [%| (lent a) `b])) + |=({a=(list) b=term} ?~(a b [%| (lent a) `b])) ;~(plug (star ket) ;~(pose sym (cold %$ buc))) :: %+ cook - |=(a/axis [%& a]) + |=(a=axis [%& a]) ;~ pose ;~(pfix lus dim:ag) - ;~(pfix pam (cook |=(a/@ ?:(=(0 a) 0 (mul 2 +($(a (dec a)))))) dim:ag)) - ;~(pfix bar (cook |=(a/@ ?:(=(0 a) 1 +((mul 2 $(a (dec a)))))) dim:ag)) + ;~(pfix pam (cook |=(a=@ ?:(=(0 a) 0 (mul 2 +($(a (dec a)))))) dim:ag)) + ;~(pfix bar (cook |=(a=@ ?:(=(0 a) 1 +((mul 2 $(a (dec a)))))) dim:ag)) ven (cold 1 dot) == @@ -13793,54 +13793,54 @@ %+ knee *spec |.(~+((wert ;~(pose structure:(norm |) scad)))) ++ wart - |* zor/rule + |* zor=rule %+ here - |= {a/pint b/hoon} + |= {a=pint b=hoon} ?:(bug [%dbug [wer a] b] b) zor ++ wert - |* zor/rule + |* zor=rule %+ here - |= {a/pint b/spec} + |= {a=pint b=spec} ?:(bug [%dbug [wer a] b] b) zor -- :: ++ vest ~/ %vest - |= tub/nail + |= tub=nail ^- (like hoon) %. tub %- full (ifix [gay gay] tall:vast) :: ++ vice - |= txt/@ta + |= txt=@ta ^- hoon (rash txt wide:vast) :: ++ make :: compile cord to nock - |= txt/@ + |= txt=@ q:(~(mint ut %noun) %noun (ream txt)) :: ++ rain :: parse with % path - |= {bon/path txt/@} + |= {bon=path txt=@} ^- hoon =+ vaz=vast ~| bon (scan (trip txt) (full (ifix [gay gay] tall:vaz(wer bon)))) :: ++ ream :: parse cord to hoon - |= txt/@ + |= txt=@ ^- hoon (rash txt vest) :: ++ reck :: parse hoon file - |= bon/path + |= bon=path (rain bon .^(@t %cx (weld bon `path`[%hoon ~]))) :: ++ ride :: end-to-end compiler - |= {typ/type txt/@} + |= {typ=type txt=@} ^- (pair type nock) ~> %slog.[0 leaf/"ride: parsing"] =/ gen (ream txt) @@ -13852,9 +13852,9 @@ :: ++ wa :: cached compile |_ worm - ++ nell |=(ref/type (nest [%cell %noun %noun] ref)) :: nest in cell + ++ nell |=(ref=type (nest [%cell %noun %noun] ref)) :: nest in cell ++ nest :: nest:ut, cached - |= {sut/type ref/type} + |= {sut=type ref=type} ^- {? worm} ?: (~(has in nes) [sut ref]) [& +>+<] ?. (~(nest ut sut) | ref) @@ -13869,13 +13869,13 @@ [& +>+<(nes (~(put in nes) [sut ref]))] :: ++ call :: call gate - |= {vax/vase nam/term som/(each vase ^)} + |= {vax=vase nam=term som=(each vase ^)} ^- {vase worm} =^ duf +>+<.$ (open vax nam som) (slap duf [%limb %$]) :: ++ open :: assemble door - |= {vax/vase nam/term som/(each vase ^)} + |= {vax=vase nam=term som=(each vase ^)} ^- {vase worm} =* key [%cncb [[%& 2] ~] [[[%& 6] ~] [%$ 3]] ~] =^ dor +>+<.$ (slap vax [%limb nam]) @@ -13889,7 +13889,7 @@ [[p.dor q.dor(+6 +7.som)] +>+<.$] :: ++ neat :: type compliance - |= {typ/type som/(each vase ^)} + |= {typ=type som=(each vase ^)} ^- worm =^ hip +>+<.$ ?- -.som @@ -13900,10 +13900,10 @@ +>+<.$ :: ++ nets :: typeless nest - |= {sut/* ref/*} + |= {sut=* ref=*} ^- {? worm} ?: (~(has in nes) [sut ref]) [& +>+<] - =+ gat=|=({a/type b/type} (~(nest ut a) | b)) + =+ gat=|=({a=type b=type} (~(nest ut a) | b)) ?. (? (slum gat [sut ref])) ~& %nets-failed =+ tag=`*`skol @@ -13918,7 +13918,7 @@ :: +play: +play:ut, cached :: ++ play - |= {sut/type gen/hoon} + |= {sut=type gen=hoon} ^- {type worm} =+ old=(~(get by pay) [sut gen]) ?^ old [u.old +>+<.$] @@ -13927,7 +13927,7 @@ :: +mint: +mint:ut to noun, cached :: ++ mint - |= {sut/type gen/hoon} + |= {sut=type gen=hoon} ^- {(pair type nock) worm} =+ old=(~(get by mit) [sut gen]) ?^ old [u.old +>+<.$] @@ -13944,26 +13944,26 @@ :: +slap: +slap:ut, cached :: ++ slap - |= {vax/vase gen/hoon} + |= {vax=vase gen=hoon} ^- {vase worm} =^ gun +>+< (mint p.vax gen) [[p.gun .*(q.vax q.gun)] +>+<.$] :: +slot: +slot:ut, cached :: ++ slot - |= {axe/@ vax/vase} + |= {axe=@ vax=vase} ^- {vase worm} =^ gun +>+< (mint p.vax [%$ axe]) [[p.gun .*(q.vax [0 axe])] +>+<.$] :: +slym: +slym:ut, cached :: ++ slym - |= {gat/vase sam/*} + |= {gat=vase sam=*} ^- [vase worm] (slap gat(+<.q sam) [%limb %$]) :: ++ sped :: specialize vase - |= vax/vase + |= vax=vase ^- {vase worm} =+ ^= gen ^- hoon ?@ q.vax [%wtts [%base [%atom %$]] [%& 1]~] @@ -13973,13 +13973,13 @@ [[typ q.vax] +>+<.$] :: ++ spot :: slot then sped - |= {axe/@ vax/vase} + |= {axe=@ vax=vase} ^- {vase worm} =^ xav +>+< (slot axe vax) (sped xav) :: ++ stop :: sped then slot - |= {axe/@ vax/vase} + |= {axe=@ vax=vase} ^- {vase worm} =^ xav +>+< (sped vax) (slot axe xav) @@ -13988,13 +13988,13 @@ :::: 5f: molds and mold builders :: ++ mane $@(@tas {@tas @tas}) :: XML name+space -++ manx $~([[%$ ~] ~] {g/marx c/marl}) :: dynamic XML node +++ manx $~([[%$ ~] ~] {g=marx c=marl}) :: dynamic XML node ++ marl (list manx) :: XML node list -++ mars {t/{n/%$ a/{i/{n/%$ v/tape} t/~}} c/~} :: XML cdata -++ mart (list {n/mane v/tape}) :: XML attributes -++ marx $~([%$ ~] {n/mane a/mart}) :: dynamic XML tag +++ mars {t={n=%$ a={i={n=%$ v=tape} t=~}} c=~} :: XML cdata +++ mart (list {n=mane v=tape}) :: XML attributes +++ marx $~([%$ ~] {n=mane a=mart}) :: dynamic XML tag ++ mite (list @ta) :: mime type -++ monk (each ship {p/@tas q/@ta}) :: general identity +++ monk (each ship {p=@tas q=@ta}) :: general identity ++ pass @ :: public key ++ ring @ :: private key ++ ship @p :: network identity @@ -14006,14 +14006,14 @@ :: :: ++ pi-heck - |= {nam/@tas day/doss} + |= {nam=@tas day=doss} ^- doss =+ lam=(~(get by hit.day) nam) day(hit (~(put by hit.day) nam ?~(lam 1 +(u.lam)))) :: ++ pi-noon :: sample trace - |= {mot/term paz/(list path) day/doss} - =| lax/(unit path) + |= {mot=term paz=(list path) day=doss} + =| lax=(unit path) |- ^- doss ?~ paz day(mon (pi-mope mot mon.day)) %= $ @@ -14033,7 +14033,7 @@ (~(put by inn.hup) u.nax ?~(hag 1 +(u.hag))) == ++ pi-mope :: add sample - |= {mot/term mon/moan} + |= {mot=term mon=moan} ?+ mot mon %fun mon(fun +(fun.mon)) %noc mon(noc +(noc.mon)) @@ -14044,11 +14044,11 @@ %euq mon(euq +(euq.mon)) == ++ pi-moth :: count sample - |= mon/moan ^- @ud + |= mon=moan ^- @ud :(add fun.mon noc.mon glu.mon mal.mon far.mon coy.mon euq.mon) :: ++ pi-mumm :: print sample - |= mon/moan ^- tape + |= mon=moan ^- tape =+ tot=(pi-moth mon) ;: welp ^- tape @@ -14081,7 +14081,7 @@ == :: ++ pi-tell :: produce dump - |= day/doss + |= day=doss ^- (list tape) ?: =(day *doss) ~ =+ tot=(pi-moth mon.day) @@ -14090,9 +14090,9 @@ :: %+ turn %+ sort ~(tap by hit.day) - |= {a/{* @} b/{* @}} + |= {a={* @} b={* @}} (lth +.a +.b) - |= {nam/term num/@ud} + |= {nam=term num=@ud} :(welp (trip nam) ": " (scow %ud num)) ["" ~] :: @@ -14100,9 +14100,9 @@ ^- (list (list tape)) %+ turn %+ sort ~(tap by cut.day) - |= {one/(pair path hump) two/(pair path hump)} + |= {one=(pair path hump) two=(pair path hump)} (gth (pi-moth mon.q.one) (pi-moth mon.q.two)) - |= {pax/path hup/hump} + |= {pax=path hup=hump} =+ ott=(pi-moth mon.hup) ;: welp [(welp "label: " (spud pax)) ~] @@ -14113,8 +14113,8 @@ :- "into:" %+ turn %+ sort ~(tap by out.hup) - |=({{* a/@ud} {* b/@ud}} (gth a b)) - |= {pax/path num/@ud} + |=({{* a=@ud} {* b=@ud}} (gth a b)) + |= {pax=path num=@ud} ^- tape :(welp " " (spud pax) ": " (scow %ud num)) :: @@ -14122,8 +14122,8 @@ :- "from:" %+ turn %+ sort ~(tap by inn.hup) - |=({{* a/@ud} {* b/@ud}} (gth a b)) - |= {pax/path num/@ud} + |=({{* a=@ud} {* b=@ud}} (gth a b)) + |= {pax=path num=@ud} ^- tape :(welp " " (spud pax) ": " (scow %ud num)) :: diff --git a/pkg/arvo/sys/vane/clay.hoon b/pkg/arvo/sys/vane/clay.hoon index 74a51c9847..b1e46c2e48 100644 --- a/pkg/arvo/sys/vane/clay.hoon +++ b/pkg/arvo/sys/vane/clay.hoon @@ -9,7 +9,7 @@ :: worth noting that many of the clay-related structures are defined in zuse. :: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -|= pit/vase +|= pit=vase =, clay => |% +$ aeon @ud :: version number @@ -21,8 +21,8 @@ :: +$ ankh :: expanded node $~ [~ ~] - $: fil/(unit {p/lobe q/cage}) :: file - dir/(map @ta ankh) :: folders + $: fil=(unit {p=lobe q=cage}) :: file + dir=(map @ta ankh) :: folders == :: :: :: Part of ++mery, representing the set of changes between the mergebase and @@ -36,10 +36,10 @@ :: -- `old` is the set of files in the mergebase and not in the new desk. :: +$ cane - $: new/(map path lobe) - cal/(map path lobe) - can/(map path cage) - old/(map path ~) + $: new=(map path lobe) + cal=(map path lobe) + can=(map path cage) + old=(map path ~) == :: :: Type of request. @@ -65,10 +65,10 @@ :: local changes), possible merge state (for incoming merges), and permissions. :: ++ dojo - $: qyx/cult :: subscribers - dom/dome :: desk state - per/regs :: read perms per path - pew/regs :: write perms per path + $: qyx=cult :: subscribers + dom=dome :: desk state + per=regs :: read perms per path + pew=regs :: write perms per path == :: :: Desk state. @@ -83,13 +83,13 @@ :: Whenever you give an `%ergo`, you must update this. :: ++ dome - $: ank/ankh :: state - let/aeon :: top id - hit/(map aeon tako) :: versions by id - lab/(map @tas aeon) :: labels - mim/(map path mime) :: mime cache - fod/ford-cache :: ford cache - fer/(unit reef-cache) :: reef cache + $: ank=ankh :: state + let=aeon :: top id + hit=(map aeon tako) :: versions by id + lab=(map @tas aeon) :: labels + mim=(map path mime) :: mime cache + fod=ford-cache :: ford cache + fer=(unit reef-cache) :: reef cache == :: :: :: Commit state. @@ -102,11 +102,11 @@ :: -- `mut` is the diffs between `muc` and the original files. :: ++ dork :: diff work - $: del/(list path) :: deletes - ink/(list (pair path cage)) :: hoon inserts - ins/(list (pair path cage)) :: inserts - dif/(list (trel path lobe cage)) :: changes - mut/(list (trel path lobe cage)) :: mutations + $: del=(list path) :: deletes + ink=(list (pair path cage)) :: hoon inserts + ins=(list (pair path cage)) :: inserts + dif=(list (trel path lobe cage)) :: changes + mut=(list (trel path lobe cage)) :: mutations == :: :: :: Over-the-wire backfill request @@ -139,10 +139,10 @@ :: of all new commits and data. :: ++ nako :: subscription state - $: gar/(map aeon tako) :: new ids - let/aeon :: next id - lar/(set yaki) :: new commits - bar/(set plop) :: new content + $: gar=(map aeon tako) :: new ids + let=aeon :: next id + lar=(set yaki) :: new commits + bar=(set plop) :: new content == :: :: :: Formal vane state. @@ -173,8 +173,8 @@ :: Maps of commit hashes to commits and content hashes to content. :: ++ rang :: - $: hut/(map tako yaki) :: - lat/(map lobe blob) :: + $: hut=(map tako yaki) :: + lat=(map lobe blob) :: == :: :: :: Unvalidated response to a request. @@ -182,9 +182,9 @@ :: Like a ++rant, but with a page of data rather than a cage of it. :: ++ rand :: unvalidated rant - $: p/{p/care q/case r/@tas} :: clade release book - q/path :: spur - r/page :: data + $: p={p=care q=case r=@tas} :: clade release book + q=path :: spur + r=page :: data == :: :: :: Generic desk state. @@ -202,12 +202,12 @@ :: exclusively in `++ze`, we describe it there. :: ++ rede :: universal project - $: lim/@da :: complete to - ref/(unit rind) :: outgoing requests - qyx/cult :: subscribers - dom/dome :: revision state - per/regs :: read perms per path - pew/regs :: write perms per path + $: lim=@da :: complete to + ref=(unit rind) :: outgoing requests + qyx=cult :: subscribers + dom=dome :: revision state + per=regs :: read perms per path + pew=regs :: write perms per path == :: :: :: Foreign request manager. @@ -251,8 +251,8 @@ :: `hun` is the duct to dill, and `dos` is a collection of our desks. :: ++ room :: fs per ship - $: hun/duct :: terminal duct - dos/(map desk dojo) :: native desk + $: hun=duct :: terminal duct + dos=(map desk dojo) :: native desk == :: :: :: Stored request. @@ -280,7 +280,7 @@ $: rus=(map desk rede) :: neighbor desks == :: -++ move {p/duct q/(wind note gift:able)} :: local move +++ move {p=duct q=(wind note gift:able)} :: local move ++ note :: out request $-> $~ [%b %wait *@da] :: $% $: %a :: to %ames @@ -1023,11 +1023,11 @@ :: Handle `%sing` requests :: ++ aver - |= {for/(unit ship) mun/mood} + |= {for=(unit ship) mun=mood} ^- [(unit (unit (each cage lobe))) ford-cache] =+ ezy=?~(ref ~ (~(get by haw.u.ref) mun)) ?^ ezy - :_(fod.dom.red `(bind u.ezy |=(a/cage [%& a]))) + :_(fod.dom.red `(bind u.ezy |=(a=cage [%& a]))) ?: ?=([%s [%ud *] %late *] mun) :_ fod.dom.red ^- (unit (unit (each cage lobe))) @@ -1043,13 +1043,13 @@ :: Queue a move. :: ++ emit - |= mof/move + |= mof=move %_(+> mow [mof mow]) :: :: Queue a list of moves :: ++ emil - |= mof/(list move) + |= mof=(list move) %_(+> mow (weld (flop mof) mow)) :: :: Produce either null or a result along a subscription. @@ -1057,7 +1057,7 @@ :: Producing null means subscription has been completed or cancelled. :: ++ balk - |= {hen/duct cay/(unit (each cage lobe)) mun/mood} + |= {hen=duct cay=(unit (each cage lobe)) mun=mood} ^+ +> ?~ cay (blub hen) (blab hen mun u.cay) @@ -1065,13 +1065,13 @@ :: Set timer. :: ++ bait - |= {hen/duct tym/@da} + |= {hen=duct tym=@da} (emit hen %pass /tyme/(scot %p her)/[syd] %b %wait tym) :: :: Cancel timer. :: ++ best - |= {hen/duct tym/@da} + |= {hen=duct tym=@da} (emit hen %pass /tyme/(scot %p her)/[syd] %b %rest tym) :: :: Give subscription result. @@ -1141,14 +1141,14 @@ == :: ++ blas - |= {hen/duct das/(set mood)} + |= {hen=duct das=(set mood)} ^+ +> ?> ?=(^ das) :: translate the case to a date :: =/ cas [%da (case-to-date case.n.das)] =/ res - (~(run in `(set mood)`das) |=(m/mood [care.m path.m])) + (~(run in `(set mood)`das) |=(m=mood [care.m path.m])) =/ gift [%wris cas res] ?: ?=(^ ref) (emit hen %slip %b %drip !>(gift)) @@ -1168,7 +1168,7 @@ :: Tell subscriber that subscription is done. :: ++ blub - |= hen/duct + |= hen=duct ?: ?=(^ ref) (emit hen %slip %b %drip !>([%writ ~])) (emit hen %give %writ ~) @@ -1180,8 +1180,8 @@ :: in `subs`. :: ++ duct-lift - |* send/_|=({duct *} ..duct-lift) - |= {a/(set duct) arg/_+<+.send} ^+ ..duct-lift + |* send=_|=({duct *} ..duct-lift) + |= {a=(set duct) arg=_+<+.send} ^+ ..duct-lift =+ all=~(tap by a) |- ^+ ..duct-lift ?~ all ..duct-lift @@ -1245,9 +1245,9 @@ :: all get filled at once. :: ++ dedupe :: find existing alias - |= wov/wove + |= wov=wove ^- wove - =; won/(unit wove) (fall won wov) + =; won=(unit wove) (fall won wov) =* rov rove.wov ?- -.rov %sing ~ @@ -1255,7 +1255,7 @@ =+ aey=(case-to-aeon case.mood.rov) ?~ aey ~ %- ~(rep in ~(key by qyx)) - |= {haw/wove res/(unit wove)} + |= {haw=wove res=(unit wove)} ?^ res res ?. =(for.wov for.haw) ~ =* hav rove.haw @@ -1273,7 +1273,7 @@ =+ aey=(case-to-aeon case.mool.rov) ?~ aey ~ %- ~(rep in ~(key by qyx)) - |= {haw/wove res/(unit wove)} + |= {haw=wove res=(unit wove)} ?^ res res ?. =(for.wov for.haw) ~ =* hav rove.haw @@ -1296,7 +1296,7 @@ =+ aey=(case-to-aeon from.moat.rov) ?~ aey ~ %- ~(rep in ~(key by qyx)) - |= {haw/wove res/(unit wove)} + |= {haw=wove res=(unit wove)} ?^ res res ?. =(for.wov for.haw) ~ =* hav rove.haw @@ -1722,7 +1722,7 @@ == == outer-loop(dels t.dels) - :: Add/change + :: Add=change :: =/ cans=(list [=path =lobe =cage]) ~(tap by changes) |- ^+ [ankh ford-cache.ford-args] @@ -2572,15 +2572,15 @@ :: Output is a map of mount points to {length-of-mounted-path set-of-paths}. :: ++ must-ergo - |= [our=ship syd=desk mon=(map term beam) can/(list path)] + |= [our=ship syd=desk mon=(map term beam) can=(list path)] ^- (map term (pair @ud (set path))) %- malt ^- (list (trel term @ud (set path))) %+ murn ~(tap by mon) - |= {nam/term bem/beam} + |= {nam=term bem=beam} ^- (unit (trel term @ud (set path))) =- ?~(- ~ `[nam (lent s.bem) (silt `(list path)`-)]) %+ skim can - |= pax/path + |= pax=path &(=(p.bem our) =(q.bem syd) =(s.bem (scag (lent s.bem) pax))) :: :: Mount a beam to unix @@ -2606,9 +2606,9 @@ :: Set permissions for a node. :: ++ perm - |= {pax/path rit/rite} + |= {pax=path rit=rite} ^+ +> - =/ mis/(set @ta) + =/ mis=(set @ta) %+ roll =- ~(tap in -) ?- -.rit @@ -2616,7 +2616,7 @@ %w who:(fall wit.rit *rule) %rw (~(uni in who:(fall red.rit *rule)) who:(fall wit.rit *rule)) == - |= {w/whom s/(set @ta)} + |= {w=whom s=(set @ta)} ?: |(?=(%& -.w) (~(has by cez) p.w)) s (~(put in s) p.w) ?^ mis @@ -2626,7 +2626,7 @@ +>.$ =- (emit hen %give %done `[%perm-fail [%leaf "No such group(s): {-}"]~]) %+ roll ~(tap in `(set @ta)`mis) - |= {g/@ta t/tape} + |= {g=@ta t=tape} ?~ t (trip g) :(weld t ", " (trip g)) :: TODO remove this nasty hack @@ -2642,23 +2642,23 @@ == :: ++ put-perm - |= {pes/regs pax/path new/(unit rule)} + |= {pes=regs pax=path new=(unit rule)} ?~ new (~(del by pes) pax) (~(put by pes) pax u.new) :: :: Remove a group from all rules. :: ++ forget-crew - |= nom/@ta + |= nom=@ta %= +> per (forget-crew-in nom per) pew (forget-crew-in nom pew) == :: ++ forget-crew-in - |= {nom/@ta pes/regs} + |= {nom=@ta pes=regs} %- ~(run by pes) - |= r/rule + |= r=rule r(who (~(del in who.r) |+nom)) :: :: Cancel a request. @@ -2668,10 +2668,10 @@ :: ++ cancel-request :: release request ^+ ..cancel-request - =^ wos/(list wove) qyx - :_ (~(run by qyx) |=(a/(set duct) (~(del in a) hen))) + =^ wos=(list wove) qyx + :_ (~(run by qyx) |=(a=(set duct) (~(del in a) hen))) %- ~(rep by qyx) - |= {{a/wove b/(set duct)} c/(list wove)} + |= {{a=wove b=(set duct)} c=(list wove)} ?.((~(has in b) hen) c [a c]) :: ?~ ref @@ -3019,7 +3019,7 @@ +>.$ :: ++ rave-to-rove - |= rav/rave + |= rav=rave ^- rove ?- -.rav %sing rav @@ -3029,7 +3029,7 @@ == :: ++ rove-to-rave - |= rov/rove + |= rov=rove ^- rave ?- -.rov %sing rov @@ -3259,7 +3259,7 @@ :: :: know about file in cach :: - ++ know |=({(pair care path) c/cach} ?=(^ c)) + ++ know |=({(pair care path) c=cach} ?=(^ c)) :: :: fill in the blanks :: @@ -3375,7 +3375,7 @@ ++ lobe-to-blob ~(got by lat.ran) ++ tako-to-yaki ~(got by hut.ran) ++ lobe-to-mark - |= a/lobe + |= a=lobe => (lobe-to-blob a) ?- - %delta p.q @@ -3385,7 +3385,7 @@ :: Checks whether two pieces of data (either cages or lobes) are the same. :: ++ equivalent-data - |= {one/(each cage lobe) two/(each cage lobe)} + |= {one=(each cage lobe) two=(each cage lobe)} ^- ? ?: ?=(%& -.one) ?: ?=(%& -.two) @@ -3398,7 +3398,7 @@ :: Gets a map of the data at the given path and all children of it. :: ++ lobes-at-path - |= {for/(unit ship) yon/aeon pax/path} + |= {for=(unit ship) yon=aeon pax=path} ^- (map path lobe) ?: =(0 yon) ~ :: we use %z for the check because it looks at all child paths. @@ -3409,7 +3409,7 @@ =< q %- aeon-to-yaki yon - |= {p/path q/lobe} + |= {p=path q=lobe} ?| ?=(~ pax) ?& !?=(~ p) =(-.pax -.p) @@ -3434,7 +3434,7 @@ :: Traverse parentage and find all ancestor hashes :: ++ reachable-takos :: reachable - |= p/tako + |= p=tako ^- (set tako) ~+ =| s=(set tako) @@ -3477,15 +3477,15 @@ :: already in `b`. :: ++ new-lobes :: object hash set - |= {b/(set lobe) a/(set tako)} :: that aren't in b + |= {b=(set lobe) a=(set tako)} :: that aren't in b ^- (set lobe) %+ roll ~(tap in a) - |= {tak/tako bar/(set lobe)} + |= {tak=tako bar=(set lobe)} ^- (set lobe) =+ yak=(tako-to-yaki tak) %+ roll ~(tap by q.yak) =< .(far bar) - |= {{path lob/lobe} far/(set lobe)} + |= {{path lob=lobe} far=(set lobe)} ^- (set lobe) ?~ (~(has in b) lob) :: don't need far @@ -3559,30 +3559,30 @@ :: we default to fully private (empty whitelist). :: ++ read-p - |= pax/path + |= pax=path ^- (unit (unit (each cage lobe))) =- [~ ~ %& %noun !>(-)] :- (read-p-in pax per.red) (read-p-in pax pew.red) :: ++ read-p-in - |= {pax/path pes/regs} + |= {pax=path pes=regs} ^- dict - =/ rul/(unit rule) (~(get by pes) pax) + =/ rul=(unit rule) (~(get by pes) pax) ?^ rul :+ pax mod.u.rul %- ~(rep in who.u.rul) - |= {w/whom out/(pair (set ship) (map @ta crew))} + |= {w=whom out=(pair (set ship) (map @ta crew))} ?: ?=({%& @p} w) [(~(put in p.out) +.w) q.out] - =/ cru/(unit crew) (~(get by cez.ruf) +.w) + =/ cru=(unit crew) (~(get by cez.ruf) +.w) ?~ cru out [p.out (~(put by q.out) +.w u.cru)] ?~ pax [/ %white ~ ~] $(pax (scag (dec (lent pax)) `path`pax)) :: ++ may-read - |= {who/ship car/care yon/aeon pax/path} + |= {who=ship car=care yon=aeon pax=path} ^- ? ?+ car (allowed-by who pax per.red) @@ -3595,9 +3595,9 @@ ?~ tak | =+ yak=(tako-to-yaki u.tak) =+ len=(lent pax) - =- (levy ~(tap in -) |=(p/path (allowed-by who p per.red))) + =- (levy ~(tap in -) |=(p=path (allowed-by who p per.red))) %+ roll ~(tap in (~(del in ~(key by q.yak)) pax)) - |= {p/path s/(set path)} + |= {p=path s=(set path)} ?. =(pax (scag len p)) s %- ~(put in s) ?: ?=(%z car) p @@ -3605,18 +3605,18 @@ == :: ++ may-write - |= {w/ship p/path} + |= {w=ship p=path} (allowed-by w p pew.red) :: ++ allowed-by - |= {who/ship pax/path pes/regs} + |= {who=ship pax=path pes=regs} ^- ? - =/ rul/real rul:(read-p-in pax pes) + =/ rul=real rul:(read-p-in pax pes) =/ in-list/? ?| (~(has in p.who.rul) who) :: %- ~(rep by q.who.rul) - |= {{@ta cru/crew} out/_|} + |= {{@ta cru=crew} out=_|} ?: out & (~(has in cru) who) == @@ -3629,12 +3629,12 @@ |= [=yaki pax=path] ^- @uvI =+ len=(lent pax) - =/ descendants/(list (pair path lobe)) + =/ descendants=(list (pair path lobe)) %+ turn %+ skim ~(tap by (~(del by q.yaki) pax)) - |= {paf/path lob/lobe} + |= {paf=path lob=lobe} =(pax (scag len paf)) - |= {paf/path lob/lobe} + |= {paf=path lob=lobe} [(slag len paf) lob] =+ us=(~(get by q.yaki) pax) ?: &(?=(~ descendants) ?=(~ us)) @@ -3765,15 +3765,15 @@ :: of the data is legit. We also never send the mime cache over the wire. :: ++ read-v - |= {yon/aeon pax/path} + |= {yon=aeon pax=path} ^- (unit (unit {%dome (hypo dome:clay)})) ?: (lth yon let.dom) :* ~ ~ %dome -:!>(*dome:clay) ^- dome:clay :* ank=`[[%ank-in-old-v-not-implemented *ankh] ~ ~] let=yon - hit=(molt (skim ~(tap by hit.dom) |=({p/@ud *} (lte p yon)))) - lab=(molt (skim ~(tap by lab.dom) |=({* p/@ud} (lte p yon)))) + hit=(molt (skim ~(tap by hit.dom) |=({p=@ud *} (lte p yon)))) + lab=(molt (skim ~(tap by lab.dom) |=({* p=@ud} (lte p yon)))) == == ?: (gth yon let.dom) ~ @@ -3784,7 +3784,7 @@ :: For the %da case, we give just the canonical timestamp of the revision. :: ++ read-w - |= cas/case + |= cas=case ^- (unit (unit (each cage lobe))) =+ aey=(case-to-aeon cas) ?~ aey ~ @@ -3814,7 +3814,7 @@ :- ~ %+ bind fil.ank:(descend-path:(zu ank.dom) pax) - |=(a/{p/lobe q/cage} [%& q.a]) + |=(a={p=lobe q=cage} [%& q.a]) =+ yak=(tako-to-yaki u.tak) =+ lob=(~(get by q.yak) pax) ?~ lob @@ -3843,7 +3843,7 @@ :: Gets an arch (directory listing) at a node. :: ++ read-y - |= {yon/aeon pax/path} + |= {yon=aeon pax=path} ^- (unit (unit {%arch (hypo arch)})) ?: =(0 yon) ``[%arch -:!>(*arch) *arch] @@ -3862,16 +3862,16 @@ %+ turn ^- (list (pair path lobe)) %+ skim ~(tap by (~(del by q.yak) pax)) - |= {paf/path lob/lobe} + |= {paf=path lob=lobe} =(pax (scag len paf)) - |= {paf/path lob/lobe} + |= {paf=path lob=lobe} =+ pat=(slag len paf) [?>(?=(^ pat) i.pat) ~] :: :: Gets a recursive hash of a node and all its children. :: ++ read-z - |= {yon/aeon pax/path} + |= {yon=aeon pax=path} ^- (unit (unit {%uvi (hypo @uvI)})) ?: =(0 yon) ``uvi+[-:!>(*@uvI) *@uvI] @@ -3917,26 +3917,26 @@ %s :_(fod (bind (read-s yon path.mun) (lift |=(a=cage [%& a])))) %t :_(fod (bind (read-t yon path.mun) (lift |=(a=cage [%& a])))) %u :_(fod (read-u yon path.mun)) - %v :_(fod (bind (read-v yon path.mun) (lift |=(a/cage [%& a])))) + %v :_(fod (bind (read-v yon path.mun) (lift |=(a=cage [%& a])))) %w :_(fod (read-w case.mun)) %x :_(fod (read-x yon path.mun)) - %y :_(fod (bind (read-y yon path.mun) (lift |=(a/cage [%& a])))) - %z :_(fod (bind (read-z yon path.mun) (lift |=(a/cage [%& a])))) + %y :_(fod (bind (read-y yon path.mun) (lift |=(a=cage [%& a])))) + %z :_(fod (bind (read-z yon path.mun) (lift |=(a=cage [%& a])))) == :: Traverse an ankh. :: ++ zu :: filesystem - |= ank/ankh :: filesystem state - =| ram/path :: reverse path into + |= ank=ankh :: filesystem state + =| ram=path :: reverse path into |% ++ descend :: descend - |= lol/@ta + |= lol=@ta ^+ +> =+ you=(~(get by dir.ank) lol) +>.$(ram [lol ram], ank ?~(you [~ ~] u.you)) :: ++ descend-path :: descend recursively - |= way/path + |= way=path ^+ +> ?~(way +> $(way t.way, +> (descend i.way))) -- @@ -3990,7 +3990,7 @@ ?~ cew.req (~(del by cez.ruf) nom.req) (~(put by cez.ruf) nom.req cew.req) :: wake all desks, a request may have been affected. - =| mos/(list move) + =| mos=(list move) =/ des ~(tap in ~(key by dos.rom.ruf)) |- ?~ des [[[hen %give %done ~] mos] ..^^$] @@ -4006,7 +4006,7 @@ :: %crow =/ des ~(tap by dos.rom.ruf) - =| rus/(map desk {r/regs w/regs}) + =| rus=(map desk {r=regs w=regs}) |^ ?~ des [[hen %give %croz rus]~ ..^^$] =+ per=(filter-rules per.q.i.des) @@ -4016,11 +4016,11 @@ $(des t.des) :: ++ filter-rules - |= pes/regs + |= pes=regs ^+ pes =- (~(gas in *regs) -) %+ skim ~(tap by pes) - |= {p/path r/rule} + |= {p=path r=rule} (~(has in who.r) |+nom.req) -- :: @@ -4061,7 +4061,7 @@ =+ bem=(~(get by mon.ruf) des.req) ?: &(?=(~ bem) !=(%$ des.req)) ~|([%bad-mount-point-from-unix des.req] !!) - =/ bem/beam + =/ bem=beam ?^ bem u.bem [[our %home %ud 1] ~] @@ -4116,7 +4116,7 @@ == %+ turn (skim ~(tap by mon.ruf) (corl (cury test pot) tail)) - |= {pon/term bem/beam} + |= {pon=term bem=beam} [u.hez.ruf %give %ogre pon] :: %park @@ -4459,28 +4459,28 @@ == +$ rung-3 rus=(map desk rede-3) +$ rede-3 - $: lim/@da - ref/(unit rind-3) - qyx/cult-3 - dom/dome - per/regs - pew/regs + $: lim=@da + ref=(unit rind-3) + qyx=cult-3 + dom=dome + per=regs + pew=regs == +$ rind-3 - $: nix/@ud - bom/(map @ud {p/duct q/rave}) - fod/(map duct @ud) - haw/(map mood (unit cage)) + $: nix=@ud + bom=(map @ud {p=duct q=rave}) + fod=(map duct @ud) + haw=(map mood (unit cage)) == +$ room-3 - $: hun/duct - dos/(map desk dojo-3) + $: hun=duct + dos=(map desk dojo-3) == ++ dojo-3 - $: qyx/cult-3 - dom/dome - per/regs - pew/regs + $: qyx=cult-3 + dom=dome + per=regs + pew=regs == +$ cult-3 (jug wove-3 duct) +$ wove-3 [for=(unit ship) =rove] @@ -4496,38 +4496,38 @@ act=active-write-2 :: active write == :: +$ room-2 - $: hun/duct :: terminal duct - dos/(map desk dojo-2) :: native desk + $: hun=duct :: terminal duct + dos=(map desk dojo-2) :: native desk == :: +$ dojo-2 - $: qyx/cult-3 :: subscribers - dom/dome-2 :: desk state - per/regs :: read perms per path - pew/regs :: write perms per path + $: qyx=cult-3 :: subscribers + dom=dome-2 :: desk state + per=regs :: read perms per path + pew=regs :: write perms per path == +$ dome-2 - $: ank/ankh :: state - let/aeon :: top id - hit/(map aeon tako) :: versions by id - lab/(map @tas aeon) :: labels - mim/(map path mime) :: mime cache + $: ank=ankh :: state + let=aeon :: top id + hit=(map aeon tako) :: versions by id + lab=(map @tas aeon) :: labels + mim=(map path mime) :: mime cache == :: +$ rung-2 rus=(map desk rede-2) +$ rede-2 - $: lim/@da :: complete to - ref/(unit rind-2) :: outgoing requests - qyx/cult-3 :: subscribers - dom/dome-2 :: revision state - per/regs :: read perms per path - pew/regs :: write perms per path + $: lim=@da :: complete to + ref=(unit rind-2) :: outgoing requests + qyx=cult-3 :: subscribers + dom=dome-2 :: revision state + per=regs :: read perms per path + pew=regs :: write perms per path == :: +$ rind-2 - $: nix/@ud :: request index - bom/(map @ud {p/duct q/rave}) :: outstanding - fod/(map duct @ud) :: current requests - haw/(map mood (unit cage)) :: simple cache - pud/update-qeu-2 :: active updates - pur/request-map-2 :: active requests + $: nix=@ud :: request index + bom=(map @ud {p=duct q=rave}) :: outstanding + fod=(map duct @ud) :: current requests + haw=(map mood (unit cage)) :: simple cache + pud=update-qeu-2 :: active updates + pur=request-map-2 :: active requests == :: +$ request-map-2 (map inx=@ud [=rand eval-form=*]) +$ update-qeu-2 @@ -4560,7 +4560,7 @@ ?~ run [~ ~] ::TODO if it ever gets filled properly, pass in the full fur. :: - =/ for/(unit ship) ?~(lyc ~ ?~(u.lyc ~ `n.u.lyc)) + =/ for=(unit ship) ?~(lyc ~ ?~(u.lyc ~ `n.u.lyc)) =/ den ((de our now ski [/scryduct ~] ruf) his syd) =/ result (mule |.(-:(aver:den for u.run u.luk tyl))) ?: ?=(%| -.result) diff --git a/pkg/arvo/sys/vane/dill.hoon b/pkg/arvo/sys/vane/dill.hoon index d5c3a2b8ad..b6d444f679 100644 --- a/pkg/arvo/sys/vane/dill.hoon +++ b/pkg/arvo/sys/vane/dill.hoon @@ -1,7 +1,7 @@ !: :: dill (4d), terminal handling :: -|= pit/vase +|= pit=vase =, dill => |% :: interface tiles ++ gill (pair ship term) :: general contact @@ -9,28 +9,28 @@ => |% :: console protocol ++ axle :: $: %4 ::TODO replace ducts with session ids :: - hey/(unit duct) :: default duct - dug/(map duct axon) :: conversations + hey=(unit duct) :: default duct + dug=(map duct axon) :: conversations eye=(jug duct duct) :: outside listeners - lit/? :: boot in lite mode + lit=? :: boot in lite mode $= veb :: vane verbosities $~ (~(put by *(map @tas log-level)) %hole %soft) :: quiet packet crashes (map @tas log-level) :: == :: ++ axon :: dill per duct - $: ram/term :: console program - tem/(unit (list dill-belt)) :: pending, reverse - wid/_80 :: terminal width - pos/@ud :: cursor position + $: ram=term :: console program + tem=(unit (list dill-belt)) :: pending, reverse + wid=_80 :: terminal width + pos=@ud :: cursor position see=$%([%lin (list @c)] [%klr stub]) :: current line == :: +$ log-level ?(%hush %soft %loud) :: none, line, full -- => :: |% :: protocol outward ++ mess :: - $% {%dill-belt p/(hypo dill-belt)} :: + $% {%dill-belt p=(hypo dill-belt)} :: == :: -++ move {p/duct q/(wind note gift:able)} :: local move +++ move {p=duct q=(wind note gift:able)} :: local move ++ note :: out request $-> $~ [%d %verb ~] :: $% $: %c :: @@ -93,20 +93,20 @@ == == :: :::::::: :: dill tiles -- -=| all/axle +=| all=axle |= [our=ship now=@da eny=@uvJ rof=roof] :: current invocation =* ski (en-sley rof) => ~% %dill ..is ~ |% ++ as :: per cause - =| moz/(list move) + =| moz=(list move) |_ [hen=duct axon] ++ abet :: resolve ^- {(list move) axle} [(flop moz) all(dug (~(put by dug.all) hen +<+))] :: ++ call :: receive input - |= kyz/task:able + |= kyz=task:able ^+ +> ?+ -.kyz ~& [%strange-kiss -.kyz] +> %flow +> @@ -127,7 +127,7 @@ == :: ++ crud - |= {err/@tas tac/(list tank)} + |= {err=@tas tac=(list tank)} :: unknown errors default to %loud :: =/ lev=log-level (~(gut by veb.all) err %loud) @@ -147,12 +147,12 @@ $(wall t.wall, +>.^$ (from %out (tuba i.wall))) :: ++ dump :: pass down to hey - |= git/gift:able + |= git=gift:able ?> ?=(^ hey.all) +>(moz [[u.hey.all %give git] moz]) :: ++ done :: return gift - |= git/gift:able + |= git=gift:able =- +>.$(moz (weld - moz)) %+ turn :- hen @@ -168,7 +168,7 @@ +>(moz :_(moz [hen %pass wire note])) :: ++ from :: receive blit - |= bit/dill-blit + |= bit=dill-blit ^+ +> ?: ?=(%mor -.bit) |- ^+ +>.^$ @@ -235,12 +235,12 @@ $(myt t.myt, +>+ (send i.myt)) :: ++ into :: preinitialize - |= gyl/(list gill) - =. tem `(turn gyl |=(a/gill [%yow a])) + |= gyl=(list gill) + =. tem `(turn gyl |=(a=gill [%yow a])) (pass / [%c %warp our %home `[%sing %y [%ud 1] /]]) :: ++ send :: send action - |= bet/dill-belt + |= bet=dill-belt ^+ +> ?^ tem +>(tem `[bet u.tem]) @@ -253,7 +253,7 @@ (deal / [%watch /drum]) :: ++ show :: permit reads on desk - |= des/desk + |= des=desk (pass /show [%c %perm des / r+`[%black ~]]) :: ++ ota @@ -261,7 +261,7 @@ (deal /sync %poke %kiln-ota !>(`syn)) :: ++ take :: receive - |= {tea/wire sih/sign} + |= {tea=wire sih=sign} ^+ +> ?- sih [%j %init *] @@ -304,7 +304,7 @@ -- :: ++ ax :: make ++as - |= hen/duct + |= hen=duct ^- (unit _as) =/ nux (~(get by dug.all) hen) ?~ nux ~ @@ -415,18 +415,18 @@ :: ++ axle-1 $: %1 - hey/(unit duct) - dug/(map duct axon-3) - lit/? + hey=(unit duct) + dug=(map duct axon-3) + lit=? $= hef - $: a/(unit mass) - b/(unit mass) - c/(unit mass) - e/(unit mass) - f/(unit mass) - g/(unit mass) - i/(unit mass) - j/(unit mass) + $: a=(unit mass) + b=(unit mass) + c=(unit mass) + e=(unit mass) + f=(unit mass) + g=(unit mass) + i=(unit mass) + j=(unit mass) == $= veb $~ (~(put by *(map @tas log-level)) %hole %soft) @@ -435,19 +435,19 @@ :: ++ axle-2 $: %2 - hey/(unit duct) - dug/(map duct axon-3) - lit/? - dog/_| + hey=(unit duct) + dug=(map duct axon-3) + lit=? + dog=_| $= hef - $: a/(unit mass) - b/(unit mass) - c/(unit mass) - e/(unit mass) - f/(unit mass) - g/(unit mass) - i/(unit mass) - j/(unit mass) + $: a=(unit mass) + b=(unit mass) + c=(unit mass) + e=(unit mass) + f=(unit mass) + g=(unit mass) + i=(unit mass) + j=(unit mass) == $= veb $~ (~(put by *(map @tas log-level)) %hole %soft) @@ -528,7 +528,7 @@ ++ stay all :: ++ take :: process move - |= {tea/wire hen/duct dud/(unit goof) hin/(hypo sign)} + |= {tea=wire hen=duct dud=(unit goof) hin=(hypo sign)} ^+ [*(list move) ..^$] ?^ dud ~|(%dill-take-dud (mean tang.u.dud)) diff --git a/pkg/arvo/sys/vane/eyre.hoon b/pkg/arvo/sys/vane/eyre.hoon index 9a827f4b34..dd0262a473 100644 --- a/pkg/arvo/sys/vane/eyre.hoon +++ b/pkg/arvo/sys/vane/eyre.hoon @@ -419,9 +419,9 @@ :: +render-tang-to-marl: renders a tang and adds
tags between each line :: ++ render-tang-to-marl - |= {wid/@u tan/tang} + |= {wid=@u tan=tang} ^- marl - =/ raw=(list tape) (zing (turn tan |=(a/tank (wash 0^wid a)))) + =/ raw=(list tape) (zing (turn tan |=(a=tank (wash 0^wid a)))) :: |- ^- marl ?~ raw ~ @@ -429,7 +429,7 @@ :: +render-tang-to-wall: renders tang as text lines :: ++ render-tang-to-wall - |= {wid/@u tan/tang} + |= {wid=@u tan=tang} ^- wall (zing (turn tan |=(a=tank (wash 0^wid a)))) :: +wall-to-octs: text to binary output @@ -2267,7 +2267,7 @@ :: %turf =* domains domains.server-state.ax - =/ mod/(set turf) + =/ mod=(set turf) ?: ?=(%put action.http-rule.task) (~(put in domains) turf.http-rule.task) (~(del in domains) turf.http-rule.task) diff --git a/pkg/arvo/sys/vane/jael.hoon b/pkg/arvo/sys/vane/jael.hoon index 258192b5c4..fbc189b225 100644 --- a/pkg/arvo/sys/vane/jael.hoon +++ b/pkg/arvo/sys/vane/jael.hoon @@ -15,7 +15,7 @@ :: - scry namespace :: - task for converting invites to tickets :: -|= pit/vase +|= pit=vase =, pki:jael =, able:jael =, crypto @@ -198,7 +198,7 @@ :: arvo issues: should be merged with the top-level :: vane interface when that gets cleaned up a bit. :: - =| moz/(list move) + =| moz=(list move) =| $: $: :: our: identity :: now: current time :: eny: unique entropy @@ -252,7 +252,7 @@ (^sein:title who) :: :: ++saxo:of ++ saxo :: sponsorship chain - |= who/ship + |= who=ship ^- (list ship) =/ dad (sein who) [who ?:(=(who dad) ~ $(who dad))] @@ -261,8 +261,8 @@ |= $: :: hen: event cause :: tac: event data :: - hen/duct - tac/task + hen=duct + tac=task == ^+ +> ?- -.tac @@ -528,7 +528,7 @@ (curd abet:~(private-keys ~(feed su hen our now pki etn) hen)) :: :: authenticated remote request - :: {%west p/ship q/path r/*} + :: {%west p=ship q=path r=*} :: %plea =* her ship.tac @@ -615,9 +615,9 @@ == :: :: ++curd:of ++ curd :: relative moves - |= $: moz/(list move) - pki/state-pki-1 - etn/state-eth-node + |= $: moz=(list move) + pki=state-pki-1 + etn=state-eth-node == +>(pki pki, etn etn, moz (weld (flop moz) ^moz)) -- @@ -656,7 +656,7 @@ +>.$(moz [move moz]) :: ++ exec :: mass gift - |= {yen/(set duct) cad/card} + |= {yen=(set duct) cad=card} =/ noy ~(tap in yen) |- ^+ this-su ?~ noy this-su @@ -758,7 +758,7 @@ ++ feed |_ :: hen: subscription source :: - hen/duct + hen=duct :: :: Handle subscription to public-keys :: @@ -993,7 +993,7 @@ :: :: lex: all durable %jael state :: -=| lex/state-1 +=| lex=state-1 |= $: :: :: our: identity :: now: current time @@ -1012,9 +1012,9 @@ |= $: :: hen: cause of this event :: hic: event data :: - hen/duct + hen=duct dud=(unit goof) - hic/(hypo (hobo task:able)) + hic=(hypo (hobo task:able)) == ^- [(list move) _..^$] ?^ dud @@ -1029,7 +1029,7 @@ |= $: :: old: previous state :: :: old/* - old/any-state + old=any-state == ^+ ..^$ =/ new=state-1 @@ -1252,10 +1252,10 @@ :: hen: cause :: hin: result :: - tea/wire - hen/duct + tea=wire + hen=duct dud=(unit goof) - hin/(hypo sign) + hin=(hypo sign) == ^- [(list move) _..^$] ?^ dud diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index 91a6f35782..31b8c7d7d1 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -175,8 +175,8 @@ [%spawned who=@p] :: Spawned [%keys =life =pass] :: ChangedKeys [%continuity new=@ud] :: BrokeContinuity - [%sponsor new=[has=? who=@p]] :: EscapeAcc/LostSpons - [%escape new=(unit @p)] :: EscapeReq/Can + [%sponsor new=[has=? who=@p]] :: EscapeAcc=LostSpons + [%escape new=(unit @p)] :: EscapeReq=Can [%management-proxy new=address] :: ChangedManagementPro [%voting-proxy new=address] :: ChangedVotingProxy [%spawn-proxy new=address] :: ChangedSpawnProxy @@ -471,14 +471,14 @@ ++ acru $_ ^? :: asym cryptosuite |% :: opaque object ++ as ^? :: asym ops - |% ++ seal |~({a/pass b/@} *@) :: encrypt to a - ++ sign |~(a/@ *@) :: certify as us - ++ sure |~(a/@ *(unit @)) :: authenticate from us - ++ tear |~({a/pass b/@} *(unit @)) :: accept from a + |% ++ seal |~({a=pass b=@} *@) :: encrypt to a + ++ sign |~(a=@ *@) :: certify as us + ++ sure |~(a=@ *(unit @)) :: authenticate from us + ++ tear |~({a=pass b=@} *(unit @)) :: accept from a -- ::as :: - ++ de |~({a/@ b/@} *(unit @)) :: symmetric de, soft - ++ dy |~({a/@ b/@} *@) :: symmetric de, hard - ++ en |~({a/@ b/@} *@) :: symmetric en + ++ de |~({a=@ b=@} *(unit @)) :: symmetric de, soft + ++ dy |~({a=@ b=@} *@) :: symmetric de, hard + ++ en |~({a=@ b=@} *@) :: symmetric en ++ ex ^? :: export |% ++ fig *@uvH :: fingerprint ++ pac *@uvG :: default passcode @@ -486,9 +486,9 @@ ++ sec *ring :: private key -- ::ex :: ++ nu ^? :: reconstructors - |% ++ pit |~({a/@ b/@} ^?(..nu)) :: from [width seed] - ++ nol |~(a/ring ^?(..nu)) :: from ring - ++ com |~(a/pass ^?(..nu)) :: from pass + |% ++ pit |~({a=@ b=@} ^?(..nu)) :: from [width seed] + ++ nol |~(a=ring ^?(..nu)) :: from ring + ++ com |~(a=pass ^?(..nu)) :: from pass -- ::nu :: -- ::acru :: :: $address: opaque atomic transport address to or from unix @@ -812,45 +812,45 @@ |% ++ gift :: out result <-$ $% [%boon payload=*] :: ames response - {%croz rus/(map desk {r/regs w/regs})} :: rules for group - {%cruz cez/(map @ta crew)} :: permission groups - {%dirk p/@tas} :: mark mount dirty - {%ergo p/@tas q/mode} :: version update - {%hill p/(list @tas)} :: mount points + {%croz rus=(map desk {r=regs w=regs})} :: rules for group + {%cruz cez=(map @ta crew)} :: permission groups + {%dirk p=@tas} :: mark mount dirty + {%ergo p=@tas q=mode} :: version update + {%hill p=(list @tas)} :: mount points [%done error=(unit error:ames)] :: ames message (n)ack - {%mere p/(each (set path) (pair term tang))} :: merge result - {%note p/@tD q/tank} :: debug message - {%ogre p/@tas} :: delete mount point - {%rule red/dict wit/dict} :: node r+w permissions - {%writ p/riot} :: response - {%wris p/{%da p/@da} q/(set (pair care path))} :: many changes + {%mere p=(each (set path) (pair term tang))} :: merge result + {%note p=@tD q=tank} :: debug message + {%ogre p=@tas} :: delete mount point + {%rule red=dict wit=dict} :: node r+w permissions + {%writ p=riot} :: response + {%wris p={%da p=@da} q=(set (pair care path))} :: many changes == :: ++ task :: in request ->$ $~ [%vega ~] :: $% {%boat ~} :: pier rebooted - {%cred nom/@ta cew/crew} :: set permission group + {%cred nom=@ta cew=crew} :: set permission group {%crew ~} :: permission groups - {%crow nom/@ta} :: group usage + {%crow nom=@ta} :: group usage $>(%crud vane-task) :: error with trace - {%drop des/desk} :: cancel pending merge - {%info des/desk dit/nori} :: internal edit + {%drop des=desk} :: cancel pending merge + {%info des=desk dit=nori} :: internal edit $>(%init vane-task) :: report install - {%into des/desk all/? fis/mode} :: external edit + {%into des=desk all=? fis=mode} :: external edit $: %merg :: merge desks - des/desk :: target - her/@p dem/desk cas/case :: source - how/germ :: method + des=desk :: target + her=@p dem=desk cas=case :: source + how=germ :: method == :: - {%mont pot/term bem/beam} :: mount to unix - {%dirk des/desk} :: mark mount dirty - {%ogre pot/$@(desk beam)} :: delete mount point - {%park des/desk yok/yoki ran/rang} :: synchronous commit - {%perm des/desk pax/path rit/rite} :: change permissions + {%mont pot=term bem=beam} :: mount to unix + {%dirk des=desk} :: mark mount dirty + {%ogre pot=$@(desk beam)} :: delete mount point + {%park des=desk yok=yoki ran=rang} :: synchronous commit + {%perm des=desk pax=path rit=rite} :: change permissions {%pork ~} :: resume commit $>(%trim vane-task) :: trim state $>(%vega vane-task) :: report upgrade - {%warp wer/ship rif/riff} :: internal file req - {%werp who/ship wer/ship rif/riff-any} :: external file req + {%warp wer=ship rif=riff} :: internal file req + {%werp who=ship wer=ship rif=riff-any} :: external file req $>(%plea vane-task) :: ames request == :: -- ::able @@ -860,14 +860,14 @@ ++ aeon @ud :: version number ++ ankh :: fs node (new) $~ [~ ~] - $: fil/(unit {p/lobe q/cage}) :: file - dir/(map @ta ankh) :: folders + $: fil=(unit {p=lobe q=cage}) :: file + dir=(map @ta ankh) :: folders == :: - ++ beam {{p/ship q/desk r/case} s/path} :: global name - ++ beak {p/ship q/desk r/case} :: path prefix + ++ beam {{p=ship q=desk r=case} s=path} :: global name + ++ beak {p=ship q=desk r=case} :: path prefix ++ blob :: fs blob - $% {%delta p/lobe q/{p/mark q/lobe} r/page} :: delta on q - {%direct p/lobe q/page} :: immediate + $% {%delta p=lobe q={p=mark q=lobe} r=page} :: delta on q + {%direct p=lobe q=page} :: immediate == :: :: +cable: a reference to something on the filesystem :: face: the face to wrap around the imported file @@ -878,18 +878,18 @@ == ++ care ?(%a %b %c %d %p %r %s %t %u %v %w %x %y %z) :: clay submode ++ case :: ship desk case spur - $% {%da p/@da} :: date - {%tas p/@tas} :: label - {%ud p/@ud} :: number + $% {%da p=@da} :: date + {%tas p=@tas} :: label + {%ud p=@ud} :: number == :: - ++ cass {ud/@ud da/@da} :: cases for revision + ++ cass {ud=@ud da=@da} :: cases for revision ++ crew (set ship) :: permissions group - ++ dict {src/path rul/real} :: effective permission + ++ dict {src=path rul=real} :: effective permission ++ dome :: project state - $: ank/ankh :: state - let/@ud :: top id - hit/(map @ud tako) :: changes by id - lab/(map @tas @ud) :: labels + $: ank=ankh :: state + let=@ud :: top id + hit=(map @ud tako) :: changes by id + lab=(map @tas @ud) :: labels == :: ++ germ :: merge style $? %init :: new desk @@ -905,43 +905,43 @@ %meet-that :: hers if conflict == :: ++ lobe @uvI :: blob ref - ++ maki {p/@ta q/@ta r/@ta s/path} :: + ++ maki {p=@ta q=@ta r=@ta s=path} :: ++ miso :: ankh delta $% {%del ~} :: delete - {%ins p/cage} :: insert - {%dif p/cage} :: mutate from diff - {%mut p/cage} :: mutate from raw + {%ins p=cage} :: insert + {%dif p=cage} :: mutate from diff + {%mut p=cage} :: mutate from raw == :: ++ misu :: computed delta $% {%del ~} :: delete - {%ins p/cage} :: insert - {%dif p/lobe q/cage} :: mutate from diff + {%ins p=cage} :: insert + {%dif p=lobe q=cage} :: mutate from diff == :: - ++ mizu {p/@u q/(map @ud tako) r/rang} :: new state - ++ moar {p/@ud q/@ud} :: normal change range + ++ mizu {p=@u q=(map @ud tako) r=rang} :: new state + ++ moar {p=@ud q=@ud} :: normal change range +$ moat [from=case to=case =path] :: change range ++ mode (list {path (unit mime)}) :: external files +$ mood [=care =case =path] :: request in desk +$ mool [=case paths=(set (pair care path))] :: requests in desk ++ nori :: repository action - $% {%& p/soba} :: delta - {%| p/@tas} :: label + $% {%& p=soba} :: delta + {%| p=@tas} :: label == :: ++ nuri :: repository action - $% {%& p/suba} :: delta - {%| p/@tas} :: label + $% {%& p=suba} :: delta + {%| p=@tas} :: label == :: ++ open $-(path vase) :: get prelude ++ page (cask *) :: untyped cage ++ plop blob :: unvalidated blob ++ rang :: repository - $: hut/(map tako yaki) :: changes - lat/(map lobe blob) :: data + $: hut=(map tako yaki) :: changes + lat=(map lobe blob) :: data == :: ++ rant :: response to request - $: p/{p/care q/case r/desk} :: clade release book - q/path :: spur - r/cage :: data + $: p={p=care q=case r=desk} :: clade release book + q=path :: spur + r=cage :: data == :: ++ rave :: general request $% [%sing =mood] :: single request @@ -950,8 +950,8 @@ [%many track=? =moat] :: track range == :: ++ real :: resolved permissions - $: mod/?(%black %white) :: - who/(pair (set ship) (map @ta crew)) :: + $: mod=?(%black %white) :: + who=(pair (set ship) (map @ta crew)) :: == :: ++ regs (map path rule) :: rules for paths +$ riff [p=desk q=(unit rave)] :: request+desist @@ -959,35 +959,35 @@ $^ [[%1 ~] riff] riff ++ rite :: new permissions - $% {%r red/(unit rule)} :: for read - {%w wit/(unit rule)} :: for write - {%rw red/(unit rule) wit/(unit rule)} :: for read and write + $% {%r red=(unit rule)} :: for read + {%w wit=(unit rule)} :: for write + {%rw red=(unit rule) wit=(unit rule)} :: for read and write == :: ++ riot (unit rant) :: response+complete - ++ rule {mod/?(%black %white) who/(set whom)} :: node permission - ++ rump {p/care q/case r/@tas s/path} :: relative path - ++ saba {p/ship q/@tas r/moar s/dome} :: patch+merge - ++ soba (list {p/path q/miso}) :: delta - ++ suba (list {p/path q/misu}) :: delta + ++ rule {mod=?(%black %white) who=(set whom)} :: node permission + ++ rump {p=care q=case r=@tas s=path} :: relative path + ++ saba {p=ship q=@tas r=moar s=dome} :: patch+merge + ++ soba (list {p=path q=miso}) :: delta + ++ suba (list {p=path q=misu}) :: delta ++ tako @ :: yaki ref - ++ toro {p/@ta q/nori} :: general change + ++ toro {p=@ta q=nori} :: general change ++ unce :: change part - |* a/mold :: - $% {%& p/@ud} :: skip[copy] - {%| p/(list a) q/(list a)} :: p -> q[chunk] + |* a=mold :: + $% {%& p=@ud} :: skip[copy] + {%| p=(list a) q=(list a)} :: p -> q[chunk] == :: - ++ urge |*(a/mold (list (unce a))) :: list change + ++ urge |*(a=mold (list (unce a))) :: list change ++ whom (each ship @ta) :: ship or named crew ++ yoki (each yuki yaki) :: commit ++ yuki :: proto-commit - $: p/(list tako) :: parents - q/(map path (each page lobe)) :: namespace + $: p=(list tako) :: parents + q=(map path (each page lobe)) :: namespace == :: ++ yaki :: commit - $: p/(list tako) :: parents - q/(map path lobe) :: namespace - r/tako :: self-reference - t/@da :: date + $: p=(list tako) :: parents + q=(map path lobe) :: namespace + r=tako :: self-reference + t=@da :: date == :: :: :: +page-to-lobe: hash a page to get a lobe. @@ -997,7 +997,7 @@ :: +make-yaki: make commit out of a list of parents, content, and date. :: ++ make-yaki - |= {p/(list tako) q/(map path lobe) t/@da} + |= {p=(list tako) q=(map path lobe) t=@da} ^- yaki =+ ^= has %^ cat 7 (sham [%yaki (roll p add) q t]) @@ -1093,28 +1093,28 @@ |% ++ gift :: out result <-$ $% {%bbye ~} :: reset prompt - {%blit p/(list blit)} :: terminal output - {%burl p/@t} :: activate url - {%init p/@p} :: set owner + {%blit p=(list blit)} :: terminal output + {%burl p=@t} :: activate url + {%init p=@p} :: set owner {%logo ~} :: logout [%lyra hoon=(unit @t) arvo=@t] :: upgrade kernel {%meld ~} :: unify memory {%pack ~} :: compact memory - {%trim p/@ud} :: trim kernel state - {%veer p/@ta q/path r/@t} :: install vane + {%trim p=@ud} :: trim kernel state + {%veer p=@ta q=path r=@t} :: install vane {%verb ~} :: verbose mode [%whey ~] :: memory report == :: ++ task :: in request ->$ $~ [%vega ~] :: - $% {%belt p/belt} :: terminal input - {%blew p/blew} :: terminal config - {%boot lit/? p/*} :: weird %dill boot - {%crop p/@ud} :: trim kernel state + $% {%belt p=belt} :: terminal input + {%blew p=blew} :: terminal config + {%boot lit=? p=*} :: weird %dill boot + {%crop p=@ud} :: trim kernel state $>(%crud vane-task) :: error with trace [%flee session=~] :: unwatch session - {%flog p/flog} :: wrapped error - {%flow p/@tas q/(list gill:gall)} :: terminal config + {%flog p=flog} :: wrapped error + {%flow p=@tas q=(list gill:gall)} :: terminal config {%hail ~} :: terminal refresh {%heft ~} :: memory report {%hook ~} :: this term hung up @@ -1124,9 +1124,9 @@ {%meld ~} :: unify memory {%noop ~} :: no operation {%pack ~} :: compact memory - {%talk p/tank} :: - {%text p/tape} :: - {%veer p/@ta q/path r/@t} :: install vane + {%talk p=tank} :: + {%text p=tape} :: + {%veer p=@ta q=path r=@t} :: install vane [%view session=~] :: watch session blits $>(%trim vane-task) :: trim state $>(%vega vane-task) :: report upgrade @@ -1137,63 +1137,63 @@ :: :::: :: (1d2) :: - ++ blew {p/@ud q/@ud} :: columns rows + ++ blew {p=@ud q=@ud} :: columns rows ++ belt :: old belt - $% {%aro p/?(%d %l %r %u)} :: arrow key + $% {%aro p=?(%d %l %r %u)} :: arrow key {%bac ~} :: true backspace - {%ctl p/@c} :: control-key + {%ctl p=@c} :: control-key {%del ~} :: true delete - {%met p/@c} :: meta-key + {%met p=@c} :: meta-key {%ret ~} :: return - {%txt p/(list @c)} :: utf32 text + {%txt p=(list @c)} :: utf32 text == :: ++ blit :: old blit $% {%bel ~} :: make a noise {%clr ~} :: clear the screen - {%hop p/@ud} :: set cursor position + {%hop p=@ud} :: set cursor position [%klr p=stub] :: set styled line - {%lin p/(list @c)} :: set current line + {%lin p=(list @c)} :: set current line {%mor ~} :: newline - {%sag p/path q/*} :: save to jamfile - {%sav p/path q/@} :: save to file - {%url p/@t} :: activate url + {%sag p=path q=*} :: save to jamfile + {%sav p=path q=@} :: save to file + {%url p=@t} :: activate url == :: ++ dill-belt :: new belt - $% {%aro p/?(%d %l %r %u)} :: arrow key + $% {%aro p=?(%d %l %r %u)} :: arrow key {%bac ~} :: true backspace - {%cru p/@tas q/(list tank)} :: echo error - {%ctl p/@} :: control-key + {%cru p=@tas q=(list tank)} :: echo error + {%ctl p=@} :: control-key {%del ~} :: true delete {%hey ~} :: refresh - {%met p/@} :: meta-key + {%met p=@} :: meta-key {%ret ~} :: return - {%rez p/@ud q/@ud} :: resize, cols, rows - {%txt p/(list @c)} :: utf32 text - {%yow p/gill:gall} :: connect to app + {%rez p=@ud q=@ud} :: resize, cols, rows + {%txt p=(list @c)} :: utf32 text + {%yow p=gill:gall} :: connect to app == :: ++ dill-blit :: new blit $% {%bel ~} :: make a noise {%clr ~} :: clear the screen - {%hop p/@ud} :: set cursor position - {%klr p/stub} :: styled text - {%mor p/(list dill-blit)} :: multiple blits - {%pom p/stub} :: styled prompt - {%pro p/(list @c)} :: show as cursor+line + {%hop p=@ud} :: set cursor position + {%klr p=stub} :: styled text + {%mor p=(list dill-blit)} :: multiple blits + {%pom p=stub} :: styled prompt + {%pro p=(list @c)} :: show as cursor+line {%qit ~} :: close console - {%out p/(list @c)} :: send output line - {%sag p/path q/*} :: save to jamfile - {%sav p/path q/@} :: save to file - {%url p/@t} :: activate url + {%out p=(list @c)} :: send output line + {%sag p=path q=*} :: save to jamfile + {%sav p=path q=@} :: save to file + {%url p=@t} :: activate url == :: ++ flog :: sent to %dill - $% {%crop p/@ud} :: trim kernel state - {%crud p/@tas q/(list tank)} :: + $% {%crop p=@ud} :: trim kernel state + {%crud p=@tas q=(list tank)} :: {%heft ~} :: [%lyra hoon=(unit @t) arvo=@t] :: upgrade kernel {%meld ~} :: unify memory {%pack ~} :: compact memory - {%text p/tape} :: - {%veer p/@ta q/path r/@t} :: install vane + {%text p=tape} :: + {%veer p=@ta q=path r=@t} :: install vane {%verb ~} :: verbose mode == :: -- ::dill @@ -1529,34 +1529,34 @@ == :: ++ cred :: credential - $: hut/hart :: client host - aut/(jug @tas @t) :: client identities - orx/oryx :: CSRF secret - acl/(unit @t) :: accept-language - cip/(each @if @is) :: client IP - cum/(map @tas *) :: custom dirt + $: hut=hart :: client host + aut=(jug @tas @t) :: client identities + orx=oryx :: CSRF secret + acl=(unit @t) :: accept-language + cip=(each @if @is) :: client IP + cum=(map @tas *) :: custom dirt == :: ++ epic :: FCGI parameters - $: qix/(map @t @t) :: query - ced/cred :: client credentials - bem/beam :: original path + $: qix=(map @t @t) :: query + ced=cred :: client credentials + bem=beam :: original path == :: :: - ++ hart {p/? q/(unit @ud) r/host} :: http sec+port+host - ++ hate {p/purl q/@p r/moth} :: semi-cooked request - ++ hiss {p/purl q/moth} :: outbound request + ++ hart {p=? q=(unit @ud) r=host} :: http sec+port+host + ++ hate {p=purl q=@p r=moth} :: semi-cooked request + ++ hiss {p=purl q=moth} :: outbound request ++ host (each turf @if) :: http host ++ hoke %+ each {%localhost ~} :: local host ?(%.0.0.0.0 %.127.0.0.1) :: ++ httq :: raw http request - $: p/meth :: method - q/@t :: unparsed url - r/(list {p/@t q/@t}) :: headers - s/(unit octs) :: body + $: p=meth :: method + q=@t :: unparsed url + r=(list {p=@t q=@t}) :: headers + s=(unit octs) :: body == :: - ++ httr {p/@ud q/mess r/(unit octs)} :: raw http response + ++ httr {p=@ud q=mess r=(unit octs)} :: raw http response ++ math (map @t (list @t)) :: semiparsed headers - ++ mess (list {p/@t q/@t}) :: raw http headers + ++ mess (list {p=@t q=@t}) :: raw http headers ++ meth :: http methods $? %conn :: CONNECT %delt :: DELETE @@ -1567,9 +1567,9 @@ %put :: PUT %trac :: TRACE == :: - ++ moth {p/meth q/math r/(unit octs)} :: http operation + ++ moth {p=meth q=math r=(unit octs)} :: http operation ++ oryx @t :: CSRF secret - ++ pork {p/(unit @ta) q/(list @t)} :: fully parsed url + ++ pork {p=(unit @ta) q=(list @t)} :: fully parsed url :: +prox: proxy notification :: :: Used on both the proxy (ward) and upstream sides for @@ -1587,12 +1587,12 @@ non=@uvJ == ++ purf (pair purl (unit @t)) :: url with fragment - ++ purl {p/hart q/pork r/quay} :: parsed url - ++ quay (list {p/@t q/@t}) :: parsed url query - ++ quer |-($@(~ {p/@t q/@t t/$})) :: query tree + ++ purl {p=hart q=pork r=quay} :: parsed url + ++ quay (list {p=@t q=@t}) :: parsed url query + ++ quer |-($@(~ {p=@t q=@t t=$})) :: query tree ++ quri :: request-uri - $% {%& p/purl} :: absolute - {%| p/pork q/quay} :: relative + $% {%& p=purl} :: absolute + {%| p=pork q=quay} :: relative == :: :: +reserved: check if an ipv4 address is in a reserved range :: @@ -1692,7 +1692,7 @@ ++ het (bass 16 (stun [1 4] six:ab)) -- :: - ++ rout {p/(list host) q/path r/oryx s/path} :: http route (new) + ++ rout {p=(list host) q=path r=oryx s=path} :: http route (new) ++ user knot :: username -- ::eyre :: :::: @@ -2162,7 +2162,7 @@ :: lost information that the old life had. :: ++ hand @uvH :: 128-bit hash - ++ mind {who/ship lyf/life} :: key identifier + ++ mind {who=ship lyf=life} :: key identifier ++ name (pair @ta @t) :: ascii / unicode ++ oath @ :: signature -- :: pki @@ -2280,41 +2280,41 @@ |% :: :: ++fu:number ++ fu :: modulo (mul p q) - |= a/{p/@ q/@} + |= a={p=@ q=@} =+ b=?:(=([0 0] a) 0 (~(inv fo p.a) (~(sit fo p.a) q.a))) |% :: :: ++dif:fu:number ++ dif :: subtract - |= {c/{@ @} d/{@ @}} + |= {c={@ @} d={@ @}} [(~(dif fo p.a) -.c -.d) (~(dif fo q.a) +.c +.d)] :: :: ++exp:fu:number ++ exp :: exponent - |= {c/@ d/{@ @}} + |= {c=@ d={@ @}} :- (~(exp fo p.a) (mod c (dec p.a)) -.d) (~(exp fo q.a) (mod c (dec q.a)) +.d) :: :: ++out:fu:number ++ out :: garner's formula - |= c/{@ @} + |= c={@ @} %+ add +.c %+ mul q.a %+ ~(pro fo p.a) b (~(dif fo p.a) -.c (~(sit fo p.a) +.c)) :: :: ++pro:fu:number ++ pro :: multiply - |= {c/{@ @} d/{@ @}} + |= {c={@ @} d={@ @}} [(~(pro fo p.a) -.c -.d) (~(pro fo q.a) +.c +.d)] :: :: ++sum:fu:number ++ sum :: add - |= {c/{@ @} d/{@ @}} + |= {c={@ @} d={@ @}} [(~(sum fo p.a) -.c -.d) (~(sum fo q.a) +.c +.d)] :: :: ++sit:fu:number ++ sit :: represent - |= c/@ + |= c=@ [(mod c p.a) (mod c q.a)] -- ::fu :: :: ++pram:number ++ pram :: rabin-miller - |= a/@ ^- ? + |= a=@ ^- ? ?: ?| =(0 (end 0 1 a)) =(1 a) =+ b=1 @@ -2326,7 +2326,7 @@ | =+ ^= b =+ [s=(dec a) t=0] - |- ^- {s/@ t/@} + |- ^- {s=@ t=@} ?: =(0 (end 0 1 s)) $(s (rsh 0 1 s), t +(t)) [s t] @@ -2350,19 +2350,19 @@ == :: :: ++ramp:number ++ ramp :: make r-m prime - |= {a/@ b/(list @) c/@} ^- @ux :: {bits snags seed} + |= {a=@ b=(list @) c=@} ^- @ux :: {bits snags seed} => .(c (shas %ramp c)) =+ d=*@ |- ?: =((mul 100 a) d) ~|(%ar-ramp !!) =+ e=(~(raw og c) a) - ?: &((levy b |=(f/@ !=(1 (mod e f)))) (pram e)) + ?: &((levy b |=(f=@ !=(1 (mod e f)))) (pram e)) e $(c +(c), d (shax d)) :: :: ++curt:number ++ curt :: curve25519 - |= {a/@ b/@} + |= {a=@ b=@} => %= . + => + @@ -2372,20 +2372,20 @@ |% :: :: ++cla:curt:number ++ cla :: - |= raw/@ + |= raw=@ =+ low=(dis 248 (cut 3 [0 1] raw)) =+ hih=(con 64 (dis 127 (cut 3 [31 1] raw))) =+ mid=(cut 3 [1 30] raw) (can 3 [[1 low] [30 mid] [1 hih] ~]) :: :: ++sqr:curt:number ++ sqr :: - |=(a/@ (mul a a)) + |=(a=@ (mul a a)) :: :: ++inv:curt:number ++ inv :: - |=(a/@ (~(exp fo q) (sub q 2) a)) + |=(a=@ (~(exp fo q) (sub q 2) a)) :: :: ++cad:curt:number ++ cad :: - |= {n/{x/@ z/@} m/{x/@ z/@} d/{x/@ z/@}} + |= {n={x=@ z=@} m={x=@ z=@} d={x=@ z=@}} =+ ^= xx ;: mul 4 z.d %- sqr %- abs:si @@ -2403,7 +2403,7 @@ [(sit.fq xx) (sit.fq zz)] :: :: ++cub:curt:number ++ cub :: - |= {x/@ z/@} + |= {x=@ z=@} =+ ^= xx %+ mul %- sqr %- abs:si @@ -2430,19 +2430,19 @@ $(i (dec i), r (cad r s one), s (cub s)) :: :: ++ga:number ++ ga :: GF (bex p.a) - |= a/{p/@ q/@ r/@} :: dim poly gen + |= a={p=@ q=@ r=@} :: dim poly gen =+ si=(bex p.a) =+ ma=(dec si) => |% :: :: ++dif:ga:number ++ dif :: add and sub - |= {b/@ c/@} + |= {b=@ c=@} ~| [%dif-ga a] ?> &((lth b si) (lth c si)) (mix b c) :: :: ++dub:ga:number ++ dub :: mul by x - |= b/@ + |= b=@ ~| [%dub-ga a] ?> (lth b si) ?: =(1 (cut 0 [(dec p.a) 1] b)) @@ -2450,7 +2450,7 @@ (lsh 0 1 b) :: :: ++pro:ga:number ++ pro :: slow multiply - |= {b/@ c/@} + |= {b=@ c=@} ?: =(0 b) 0 ?: =(1 (dis 1 b)) @@ -2459,7 +2459,7 @@ :: :: ++toe:ga:number ++ toe :: exp+log tables =+ ^= nu - |= {b/@ c/@} + |= {b=@ c=@} ^- (map @ @) =+ d=*(map @ @) |- @@ -2471,7 +2471,7 @@ == =+ [p=(nu 0 (bex p.a)) q=(nu ma ma)] =+ [b=1 c=0] - |- ^- {p/(map @ @) q/(map @ @)} + |- ^- {p=(map @ @) q=(map @ @)} ?: =(ma c) [(~(put by p) c b) q] %= $ @@ -2482,18 +2482,18 @@ == :: :: ++sit:ga:number ++ sit :: reduce - |= b/@ + |= b=@ (mod b (bex p.a)) -- :: =+ toe |% :: :: ++fra:ga:number ++ fra :: divide - |= {b/@ c/@} + |= {b=@ c=@} (pro b (inv c)) :: :: ++inv:ga:number ++ inv :: invert - |= b/@ + |= b=@ ~| [%inv-ga a] =+ c=(~(get by q) b) ?~ c !! @@ -2501,7 +2501,7 @@ (need d) :: :: ++pow:ga:number ++ pow :: exponent - |= {b/@ c/@} + |= {b=@ c=@} =+ [d=1 e=c f=0] |- ?: =(p.a f) @@ -2511,7 +2511,7 @@ $(e (pro e e), f +(f)) :: :: ++pro:ga:number ++ pro :: multiply - |= {b/@ c/@} + |= {b=@ c=@} ~| [%pro-ga a] =+ d=(~(get by q) b) ?~ d 0 @@ -2536,16 +2536,16 @@ |% :: :: ++ahem:aes:crypto ++ ahem :: kernel state - |= {nnk/@ nnb/@ nnr/@} + |= {nnk=@ nnb=@ nnr=@} => =+ => [gr=(ga 8 0x11b 3) few==>(fe .(a 5))] [pro=pro.gr dif=dif.gr pow=pow.gr ror=ror.few] => |% :: ++ cipa $_ ^? :: AES params |% - ++ co *{p/@ q/@ r/@ s/@} :: column coefficients - ++ ix |~(a/@ *@) :: key index - ++ ro *{p/@ q/@ r/@ s/@} :: row shifts + ++ co *{p=@ q=@ r=@ s=@} :: column coefficients + ++ ix |~(a=@ *@) :: key index + ++ ro *{p=@ q=@ r=@ s=@} :: row shifts ++ su *@ :: s-box -- ::cipa -- :: @@ -2559,7 +2559,7 @@ [0x2 0x3 1 1] :: :: ++ix:pen:ahem:aes: ++ ix :: key index - |~(a/@ a) + |~(a=@ a) :: :: ++ro:pen:ahem:aes: ++ ro :: row shifts [0 1 2 3] @@ -2591,7 +2591,7 @@ [0xe 0xb 0xd 0x9] :: :: ++ix:pin:ahem:aes: ++ ix :: key index - |~(a/@ (sub nnr a)) + |~(a=@ (sub nnr a)) :: :: ++ro:pin:ahem:aes: ++ ro :: row shifts [0 3 2 1] @@ -2616,7 +2616,7 @@ -- :: :: ++mcol:ahem:aes: ++ mcol :: - |= {a/(list @) b/{p/@ q/@ r/@ s/@}} + |= {a=(list @) b={p=@ q=@ r=@ s=@}} ^- (list @) =+ c=[p=*@ q=*@ r=*@ s=*@] |- ^- (list @) @@ -2634,11 +2634,11 @@ [[p.c r.b] [q.c s.b] [r.c p.b] [s.c q.b]] [[p.c q.b] [q.c r.b] [r.c s.b] [s.c p.b]] == - |= {a/{@ @} b/{@ @} c/{@ @} d/{@ @}} + |= {a={@ @} b={@ @} c={@ @} d={@ @}} :(dif (pro a) (pro b) (pro c) (pro d)) :: :: ++pode:ahem:aes: ++ pode :: explode to block - |= {a/bloq b/@ c/@} ^- (list @) + |= {a=bloq b=@ c=@} ^- (list @) =+ d=(rip a c) =+ m=(met a c) |- @@ -2647,13 +2647,13 @@ $(m +(m), d (weld d (limo [0 ~]))) :: :: ++sube:ahem:aes: ++ sube :: s-box word - |= {a/@ b/@} ^- @ - (rep 3 (turn (pode 3 4 a) |=(c/@ (cut 3 [c 1] b)))) + |= {a=@ b=@} ^- @ + (rep 3 (turn (pode 3 4 a) |=(c=@ (cut 3 [c 1] b)))) -- :: |% :: :: ++be:ahem:aes:crypto ++ be :: block cipher - |= {a/? b/@ c/@H} ^- @uxH + |= {a=? b=@ c=@H} ^- @uxH ~| %be-aesc => %= . + @@ -2661,18 +2661,18 @@ |% :: :: ++ankh:be:ahem:aes: ++ ankh :: - |= {a/cipa b/@ c/@} + |= {a=cipa b=@ c=@} (pode 5 nnb (cut 5 [(mul (ix.a b) nnb) nnb] c)) :: :: ++sark:be:ahem:aes: ++ sark :: - |= {c/(list @) d/(list @)} + |= {c=(list @) d=(list @)} ^- (list @) ?~ c ~ ?~ d !! [(mix i.c i.d) $(c t.c, d t.d)] :: :: ++srow:be:ahem:aes: ++ srow :: - |= {a/cipa b/(list @)} ^- (list @) + |= {a=cipa b=(list @)} ^- (list @) =+ [c=0 d=~ e=ro.a] |- ?: =(c nnb) @@ -2681,11 +2681,11 @@ %+ rep 3 %+ turn (limo [0 p.e] [1 q.e] [2 r.e] [3 s.e] ~) - |= {f/@ g/@} + |= {f=@ g=@} (cut 3 [f 1] (snag (mod (add g c) nnb) b)) :: :: ++subs:be:ahem:aes: ++ subs :: - |= {a/cipa b/(list @)} ^- (list @) + |= {a=cipa b=(list @)} ^- (list @) ?~ b ~ [(sube i.b su.a) $(b t.b)] -- @@ -2705,7 +2705,7 @@ (rep 5 e) :: :: ++ex:ahem:aes:crypto ++ ex :: key expand - |= a/@I ^- @ + |= a=@I ^- @ =+ [b=a c=0 d=su:pen i=nnk] |- ?: =(i (mul nnb +(nnr))) @@ -2723,7 +2723,7 @@ $(i +(i)) :: :: ++ix:ahem:aes:crypto ++ ix :: key expand, inv - |= a/@ ^- @ + |= a=@ ^- @ =+ [i=1 j=*@ b=*@ c=co:pin] |- ?: =(nnr i) @@ -2744,11 +2744,11 @@ :: :: ++ecba:aes:crypto ++ ecba :: AES-128 ECB ~% %ecba +> ~ - |_ key/@H + |_ key=@H :: :: ++en:ecba:aes:crypto ++ en :: encrypt ~/ %en - |= blk/@H ^- @uxH + |= blk=@H ^- @uxH =+ (ahem 4 4 10) =: key (~(net fe 7) key) @@ -2759,7 +2759,7 @@ :: :: ++de:ecba:aes:crypto ++ de :: decrypt ~/ %de - |= blk/@H ^- @uxH + |= blk=@H ^- @uxH =+ (ahem 4 4 10) =: key (~(net fe 7) key) @@ -2771,11 +2771,11 @@ :: :: ++ecbb:aes:crypto ++ ecbb :: AES-192 ECB ~% %ecbb +> ~ - |_ key/@I + |_ key=@I :: :: ++en:ecbb:aes:crypto ++ en :: encrypt ~/ %en - |= blk/@H ^- @uxH + |= blk=@H ^- @uxH =+ (ahem 6 4 12) =: key (rsh 6 1 (~(net fe 8) key)) @@ -2786,7 +2786,7 @@ :: :: ++de:ecbb:aes:crypto ++ de :: decrypt ~/ %de - |= blk/@H ^- @uxH + |= blk=@H ^- @uxH =+ (ahem 6 4 12) =: key (rsh 6 1 (~(net fe 8) key)) @@ -2798,11 +2798,11 @@ :: :: ++ecbc:aes:crypto ++ ecbc :: AES-256 ECB ~% %ecbc +> ~ - |_ key/@I + |_ key=@I :: :: ++en:ecbc:aes:crypto ++ en :: encrypt ~/ %en - |= blk/@H ^- @uxH + |= blk=@H ^- @uxH =+ (ahem 8 4 14) =: key (~(net fe 8) key) @@ -2813,7 +2813,7 @@ :: :: ++de:ecbc:aes:crypto ++ de :: decrypt ~/ %de - |= blk/@H ^- @uxH + |= blk=@H ^- @uxH =+ (ahem 8 4 14) =: key (~(net fe 8) key) @@ -2825,13 +2825,13 @@ :: :: ++cbca:aes:crypto ++ cbca :: AES-128 CBC ~% %cbca +> ~ - |_ {key/@H prv/@H} + |_ {key=@H prv=@H} :: :: ++en:cbca:aes:crypto ++ en :: encrypt ~/ %en - |= txt/@ ^- @ux + |= txt=@ ^- @ux =+ pts=?:(=(txt 0) `(list @)`~[0] (flop (rip 7 txt))) - =| cts/(list @) + =| cts=(list @) %+ rep 7 :: logically, flop twice here |- ^- (list @) @@ -2846,9 +2846,9 @@ :: :: ++de:cbca:aes:crypto ++ de :: decrypt ~/ %de - |= txt/@ ^- @ux + |= txt=@ ^- @ux =+ cts=?:(=(txt 0) `(list @)`~[0] (flop (rip 7 txt))) - =| pts/(list @) + =| pts=(list @) %+ rep 7 :: logically, flop twice here |- ^- (list @) @@ -2864,13 +2864,13 @@ :: :: ++cbcb:aes:crypto ++ cbcb :: AES-192 CBC ~% %cbcb +> ~ - |_ {key/@I prv/@H} + |_ {key=@I prv=@H} :: :: ++en:cbcb:aes:crypto ++ en :: encrypt ~/ %en - |= txt/@ ^- @ux + |= txt=@ ^- @ux =+ pts=?:(=(txt 0) `(list @)`~[0] (flop (rip 7 txt))) - =| cts/(list @) + =| cts=(list @) %+ rep 7 :: logically, flop twice here |- ^- (list @) @@ -2885,9 +2885,9 @@ :: :: ++de:cbcb:aes:crypto ++ de :: decrypt ~/ %de - |= txt/@ ^- @ux + |= txt=@ ^- @ux =+ cts=?:(=(txt 0) `(list @)`~[0] (flop (rip 7 txt))) - =| pts/(list @) + =| pts=(list @) %+ rep 7 :: logically, flop twice here |- ^- (list @) @@ -2903,13 +2903,13 @@ :: :: ++cbcc:aes:crypto ++ cbcc :: AES-256 CBC ~% %cbcc +> ~ - |_ {key/@I prv/@H} + |_ {key=@I prv=@H} :: :: ++en:cbcc:aes:crypto ++ en :: encrypt ~/ %en - |= txt/@ ^- @ux + |= txt=@ ^- @ux =+ pts=?:(=(txt 0) `(list @)`~[0] (flop (rip 7 txt))) - =| cts/(list @) + =| cts=(list @) %+ rep 7 :: logically, flop twice here |- ^- (list @) @@ -2924,9 +2924,9 @@ :: :: ++de:cbcc:aes:crypto ++ de :: decrypt ~/ %de - |= txt/@ ^- @ux + |= txt=@ ^- @ux =+ cts=?:(=(txt 0) `(list @)`~[0] (flop (rip 7 txt))) - =| pts/(list @) + =| pts=(list @) %+ rep 7 :: logically, flop twice here |- ^- (list @) @@ -2941,7 +2941,7 @@ -- ::cbcc :: :: ++inc:aes:crypto ++ inc :: inc. low bloq - |= {mod/bloq ctr/@H} + |= {mod=bloq ctr=@H} ^- @uxH =+ bqs=(rip mod ctr) ?~ bqs 0x1 @@ -2950,11 +2950,11 @@ :: :: ++ctra:aes:crypto ++ ctra :: AES-128 CTR ~% %ctra +> ~ - |_ {key/@H mod/bloq len/@ ctr/@H} + |_ {key=@H mod=bloq len=@ ctr=@H} :: :: ++en:ctra:aes:crypto ++ en :: encrypt ~/ %en - |= txt/@ + |= txt=@ ^- @ux =/ encrypt ~(en ecba key) =/ blocks (add (div len 16) ?:(=((^mod len 16) 0) 0 1)) @@ -2977,11 +2977,11 @@ :: :: ++ctrb:aes:crypto ++ ctrb :: AES-192 CTR ~% %ctrb +> ~ - |_ {key/@I mod/bloq len/@ ctr/@H} + |_ {key=@I mod=bloq len=@ ctr=@H} :: :: ++en:ctrb:aes:crypto ++ en ~/ %en - |= txt/@ + |= txt=@ ^- @ux =/ encrypt ~(en ecbb key) =/ blocks (add (div len 16) ?:(=((^mod len 16) 0) 0 1)) @@ -3004,11 +3004,11 @@ :: :: ++ctrc:aes:crypto ++ ctrc :: AES-256 CTR ~% %ctrc +> ~ - |_ {key/@I mod/bloq len/@ ctr/@H} + |_ {key=@I mod=bloq len=@ ctr=@H} :: :: ++en:ctrc:aes:crypto ++ en :: encrypt ~/ %en - |= txt/@ + |= txt=@ ^- @ux =/ encrypt ~(en ecbc key) =/ blocks (add (div len 16) ?:(=((^mod len 16) 0) 0 1)) @@ -3032,7 +3032,7 @@ ++ doub :: double 128-bit |= :: string mod finite :: - str/@H + str=@H :: :: field (see spec) :: @@ -3043,7 +3043,7 @@ (mix 0x87 (lsh 0 1 str)) :: :: ++mpad:aes:crypto ++ mpad :: - |= {oct/@ txt/@} + |= {oct=@ txt=@} :: :: pad message to multiple of 128 bits :: by appending 1, then 0s @@ -3056,7 +3056,7 @@ (lsh 3 (sub 15 pad) (mix 0x80 (lsh 3 1 txt))) :: :: ++suba:aes:crypto ++ suba :: AES-128 subkeys - |= key/@H + |= key=@H =+ l=(~(en ecba key) 0) =+ k1=(doub l) =+ k2=(doub k1) @@ -3064,7 +3064,7 @@ [k1 k2] :: :: ++subb:aes:crypto ++ subb :: AES-192 subkeys - |= key/@I + |= key=@I =+ l=(~(en ecbb key) 0) =+ k1=(doub l) =+ k2=(doub k1) @@ -3072,7 +3072,7 @@ [k1 k2] :: :: ++subc:aes:crypto ++ subc :: AES-256 subkeys - |= key/@I + |= key=@I =+ l=(~(en ecbc key) 0) =+ k1=(doub l) =+ k2=(doub k1) @@ -3081,7 +3081,7 @@ :: :: ++maca:aes:crypto ++ maca :: AES-128 CMAC ~/ %maca - |= {key/@H oct/(unit @) txt/@} + |= {key=@H oct=(unit @) txt=@} ^- @ux =+ [sub=(suba key) len=?~(oct (met 3 txt) u.oct)] =+ ^= pdt @@ -3101,7 +3101,7 @@ :: :: ++macb:aes:crypto ++ macb :: AES-192 CMAC ~/ %macb - |= {key/@I oct/(unit @) txt/@} + |= {key=@I oct=(unit @) txt=@} ^- @ux =+ [sub=(subb key) len=?~(oct (met 3 txt) u.oct)] =+ ^= pdt @@ -3121,7 +3121,7 @@ :: :: ++macc:aes:crypto ++ macc :: AES-256 CMAC ~/ %macc - |= {key/@I oct/(unit @) txt/@} + |= {key=@I oct=(unit @) txt=@} ^- @ux =+ [sub=(subc key) len=?~(oct (met 3 txt) u.oct)] =+ ^= pdt @@ -3192,11 +3192,11 @@ :: :: ++siva:aes:crypto ++ siva :: AES-128 SIV ~% %siva +> ~ - |_ {key/@I vec/(list @)} + |_ {key=@I vec=(list @)} :: :: ++en:siva:aes:crypto ++ en :: encrypt ~/ %en - |= txt/@ + |= txt=@ ^- (trel @uxH @ud @ux) =+ [k1=(rsh 7 1 key) k2=(end 7 1 key)] =+ iv=(s2va k1 (weld vec (limo ~[txt]))) @@ -3209,7 +3209,7 @@ :: :: ++de:siva:aes:crypto ++ de :: decrypt ~/ %de - |= {iv/@H len/@ txt/@} + |= {iv=@H len=@ txt=@} ^- (unit @ux) =+ [k1=(rsh 7 1 key) k2=(end 7 1 key)] =* hib (dis iv 0xffff.ffff.ffff.ffff.7fff.ffff.7fff.ffff) @@ -3222,11 +3222,11 @@ :: :: ++sivb:aes:crypto ++ sivb :: AES-192 SIV ~% %sivb +> ~ - |_ {key/@J vec/(list @)} + |_ {key=@J vec=(list @)} :: :: ++en:sivb:aes:crypto ++ en :: encrypt ~/ %en - |= txt/@ + |= txt=@ ^- (trel @uxH @ud @ux) =+ [k1=(rsh 6 3 key) k2=(end 6 3 key)] =+ iv=(s2vb k1 (weld vec (limo ~[txt]))) @@ -3238,7 +3238,7 @@ :: :: ++de:sivb:aes:crypto ++ de :: decrypt ~/ %de - |= {iv/@H len/@ txt/@} + |= {iv=@H len=@ txt=@} ^- (unit @ux) =+ [k1=(rsh 6 3 key) k2=(end 6 3 key)] =* hib (dis iv 0xffff.ffff.ffff.ffff.7fff.ffff.7fff.ffff) @@ -3251,11 +3251,11 @@ :: :: ++sivc:aes:crypto ++ sivc :: AES-256 SIV ~% %sivc +> ~ - |_ {key/@J vec/(list @)} + |_ {key=@J vec=(list @)} :: :: ++en:sivc:aes:crypto ++ en :: encrypt ~/ %en - |= txt/@ + |= txt=@ ^- (trel @uxH @ud @ux) =+ [k1=(rsh 8 1 key) k2=(end 8 1 key)] =+ iv=(s2vc k1 (weld vec (limo ~[txt]))) @@ -3268,7 +3268,7 @@ :: :: ++de:sivc:aes:crypto ++ de :: decrypt ~/ %de - |= {iv/@H len/@ txt/@} + |= {iv=@H len=@ txt=@} ^- (unit @ux) =+ [k1=(rsh 8 1 key) k2=(end 8 1 key)] =* hib (dis iv 0xffff.ffff.ffff.ffff.7fff.ffff.7fff.ffff) @@ -3297,10 +3297,10 @@ |% :: :: ++norm:ed:crypto ++ norm :: - |=(x/@ ?:(=(0 (mod x 2)) x (sub q x))) + |=(x=@ ?:(=(0 (mod x 2)) x (sub q x))) :: :: ++xrec:ed:crypto ++ xrec :: recover x-coord - |= y/@ ^- @ + |= y=@ ^- @ =+ ^= xx %+ mul (dif.fq (mul y y) 1) (inv.fq +(:(mul d y y))) @@ -3310,7 +3310,7 @@ (norm x) :: :: ++ward:ed:crypto ++ ward :: edwards multiply - |= {pp/{@ @} qq/{@ @}} ^- {@ @} + |= {pp={@ @} qq={@ @}} ^- {@ @} =+ dp=:(pro.fq d -.pp -.qq +.pp +.qq) =+ ^= xt %+ pro.fq @@ -3327,7 +3327,7 @@ [xt yt] :: :: ++scam:ed:crypto ++ scam :: scalar multiply - |= {pp/{@ @} e/@} ^- {@ @} + |= {pp={@ @} e=@} ^- {@ @} ?: =(0 e) [0 1] =+ qq=$(e (div e 2)) @@ -3337,11 +3337,11 @@ qq :: :: ++etch:ed:crypto ++ etch :: encode point - |= pp/{@ @} ^- @ + |= pp={@ @} ^- @ (can 0 ~[[(sub b 1) +.pp] [1 (dis 1 -.pp)]]) :: :: ++curv:ed:crypto ++ curv :: point on curve? - |= {x/@ y/@} ^- ? + |= {x=@ y=@} ^- ? .= 0 %+ dif.fq %+ sum.fq @@ -3350,7 +3350,7 @@ (sum.fq 1 :(pro.fq d x x y y)) :: :: ++deco:ed:crypto ++ deco :: decode point - |= s/@ ^- (unit {@ @}) + |= s=@ ^- (unit {@ @}) =+ y=(cut 0 [0 (dec b)] s) =+ si=(cut 0 [(dec b) 1] s) =+ x=(xrec y) @@ -3422,7 +3422,7 @@ :: :: ++puck:ed:crypto ++ puck :: public key ~/ %puck - |= sk/@I ^- @ + |= sk=@I ^- @ ?: (gth (met 3 sk) 32) !! =+ h=(shal (rsh 0 3 b) sk) =+ ^= a @@ -3433,13 +3433,13 @@ (etch aa) :: :: ++suck:ed:crypto ++ suck :: keypair from seed - |= se/@I ^- @uJ + |= se=@I ^- @uJ =+ pu=(puck se) (can 0 ~[[b se] [b pu]]) :: :: ++shar:ed:crypto ++ shar :: curve25519 secret ~/ %shar - |= {pub/@ sek/@} + |= {pub=@ sek=@} ^- @ux =+ exp=(shal (rsh 0 3 b) (suck sek)) =. exp (dis exp (can 0 ~[[3 0] [251 (fil 0 251 1)]])) @@ -3450,7 +3450,7 @@ :: :: ++sign:ed:crypto ++ sign :: certify ~/ %sign - |= {m/@ se/@} ^- @ + |= {m=@ se=@} ^- @ =+ sk=(suck se) =+ pk=(cut 0 [b b] sk) =+ h=(shal (rsh 0 3 b) sk) @@ -3480,7 +3480,7 @@ :: :: ++veri:ed:crypto ++ veri :: validate ~/ %veri - |= {s/@ m/@ pk/@} ^- ? + |= {s=@ m=@ pk=@} ^- ? ?: (gth (div b 4) (met 3 s)) | ?: (gth (div b 8) (met 3 pk)) | =+ cb=(rsh 0 3 b) @@ -3501,19 +3501,19 @@ |% :: :: ++sal:scr:crypto ++ sal :: salsa20 hash - |= {x/@ r/@} :: with r rounds + |= {x=@ r=@} :: with r rounds ?> =((mod r 2) 0) :: =+ few==>(fe .(a 5)) =+ ^= rot - |= {a/@ b/@} + |= {a=@ b=@} (mix (end 5 1 (lsh 0 a b)) (rsh 0 (sub 32 a) b)) =+ ^= lea - |= {a/@ b/@} + |= {a=@ b=@} (net:few (sum:few (net:few a) (net:few b))) => |% :: :: ++qr:sal:scr:crypto ++ qr :: quarterround - |= y/{@ @ @ @ ~} + |= y={@ @ @ @ ~} =+ zb=(mix &2.y (rot 7 (sum:few &1.y &4.y))) =+ zc=(mix &3.y (rot 9 (sum:few zb &1.y))) =+ zd=(mix &4.y (rot 13 (sum:few zc zb))) @@ -3521,7 +3521,7 @@ ~[za zb zc zd] :: :: ++rr:sal:scr:crypto ++ rr :: rowround - |= {y/(list @)} + |= {y=(list @)} =+ za=(qr ~[&1.y &2.y &3.y &4.y]) =+ zb=(qr ~[&6.y &7.y &8.y &5.y]) =+ zc=(qr ~[&11.y &12.y &9.y &10.y]) @@ -3533,7 +3533,7 @@ &2.zd &3.zd &4.zd &1.zd == :: :: ++cr:sal:scr:crypto ++ cr :: columnround - |= {x/(list @)} + |= {x=(list @)} =+ ya=(qr ~[&1.x &5.x &9.x &13.x]) =+ yb=(qr ~[&6.x &10.x &14.x &2.x]) =+ yc=(qr ~[&11.x &15.x &3.x &7.x]) @@ -3545,11 +3545,11 @@ &4.ya &3.yb &2.yc &1.yd == :: :: ++dr:sal:scr:crypto ++ dr :: doubleround - |= {x/(list @)} + |= {x=(list @)} (rr (cr x)) :: :: ++al:sal:scr:crypto ++ al :: add two lists - |= {a/(list @) b/(list @)} + |= {a=(list @) b=(list @)} |- ^- (list @) ?~ a ~ ?~ b ~ [i=(sum:few -.a -.b) t=$(a +.a, b +.b)] @@ -3561,7 +3561,7 @@ (rep 5 (al xw ow)) :: :: ++rpp:scr:crypto ++ rpp :: rip+filler blocks - |= {a/bloq b/@ c/@} + |= {a=bloq b=@ c=@} =+ q=(rip a c) =+ w=(lent q) ?. =(w b) @@ -3570,23 +3570,23 @@ q :: :: ++bls:scr:crypto ++ bls :: split to sublists - |= {a/@ b/(list @)} + |= {a=@ b=(list @)} ?> =((mod (lent b) a) 0) |- ^- (list (list @)) ?~ b ~ [i=(scag a `(list @)`b) t=$(b (slag a `(list @)`b))] :: :: ++slb:scr:crypto ++ slb :: - |= {a/(list (list @))} + |= {a=(list (list @))} |- ^- (list @) ?~ a ~ (weld `(list @)`-.a $(a +.a)) :: :: ++sbm:scr:crypto ++ sbm :: scryptBlockMix - |= {r/@ b/(list @)} + |= {r=@ b=(list @)} ?> =((lent b) (mul 2 r)) =+ [x=(snag (dec (mul 2 r)) b) c=0] - =| {ya/(list @) yb/(list @)} + =| {ya=(list @) yb=(list @)} |- ^- (list @) ?~ b (flop (weld yb ya)) =. x (sal (mix x -.b) 8) @@ -3595,7 +3595,7 @@ $(c +(c), b +.b, yb [i=x t=yb]) :: :: ++srm:scr:crypto ++ srm :: scryptROMix - |= {r/@ b/(list @) n/@} + |= {r=@ b=(list @) n=@} ?> ?& =((lent b) (mul 2 r)) =(n (bex (dec (xeb n)))) (lth n (bex (mul r 16))) @@ -3617,11 +3617,11 @@ $(x (sbm r w), c +(c)) :: :: ++hmc:scr:crypto ++ hmc :: HMAC-SHA-256 - |= {k/@ t/@} + |= {k=@ t=@} (hml k (met 3 k) t (met 3 t)) :: :: ++hml:scr:crypto ++ hml :: w+length - |= {k/@ kl/@ t/@ tl/@} + |= {k=@ kl=@ t=@ tl=@} => .(k (end 3 kl k), t (end 3 tl t)) =+ b=64 =? k (gth kl b) (shay kl k) @@ -3632,12 +3632,12 @@ :: :: ++pbk:scr:crypto ++ pbk :: PBKDF2-HMAC-SHA256 ~/ %pbk - |= {p/@ s/@ c/@ d/@} + |= {p=@ s=@ c=@ d=@} (pbl p (met 3 p) s (met 3 s) c d) :: :: ++pbl:scr:crypto ++ pbl :: w+length ~/ %pbl - |= {p/@ pl/@ s/@ sl/@ c/@ d/@} + |= {p=@ pl=@ s=@ sl=@ c=@ d=@} => .(p (end 3 pl p), s (end 3 sl s)) =+ h=32 :: @@ -3665,13 +3665,13 @@ :: :: ++hsh:scr:crypto ++ hsh :: scrypt ~/ %hsh - |= {p/@ s/@ n/@ r/@ z/@ d/@} + |= {p=@ s=@ n=@ r=@ z=@ d=@} (hsl p (met 3 p) s (met 3 s) n r z d) :: :: ++hsl:scr:crypto ++ hsl :: w+length ~/ %hsl - |= {p/@ pl/@ s/@ sl/@ n/@ r/@ z/@ d/@} - =| v/(list (list @)) + |= {p=@ pl=@ s=@ sl=@ n=@ r=@ z=@ d=@} + =| v=(list (list @)) => .(p (end 3 pl p), s (end 3 sl s)) =+ u=(mul (mul 128 r) z) :: @@ -3687,17 +3687,17 @@ == =+ ^= b =+ (rpp 3 u (pbl p pl s sl 1 u)) %+ turn (bls (mul 128 r) -) - |=(a/(list @) (rpp 9 (mul 2 r) (rep 3 a))) + |=(a=(list @) (rpp 9 (mul 2 r) (rep 3 a))) ?> =((lent b) z) =+ ^= q =+ |- ?~ b (flop v) $(b +.b, v [i=(srm r -.b n) t=v]) %+ turn `(list (list @))`- - |=(a/(list @) (rpp 3 (mul 128 r) (rep 9 a))) + |=(a=(list @) (rpp 3 (mul 128 r) (rep 9 a))) (pbl p pl (rep 3 (slb q)) u 1 d) :: :: ++ypt:scr:crypto ++ ypt :: 256bit {salt pass} - |= {s/@ p/@} + |= {s=@ p=@} ^- @ (hsh p s 16.384 8 1 256) -- ::scr @@ -3706,7 +3706,7 @@ :: :::: ++ crub !: ^- acru - =| {pub/{cry/@ sgn/@} sek/(unit {cry/@ sgn/@})} + =| {pub={cry=@ sgn=@} sek=(unit {cry=@ sgn=@})} |% :: :: ++as:crub:crypto ++ as :: @@ -3721,12 +3721,12 @@ ++ sure :: |= txt=@ ^- (unit @ux) - =+ ;;({sig/@ msg/@} (cue txt)) + =+ ;;({sig=@ msg=@} (cue txt)) ?. (veri:ed sig msg sgn.pub) ~ (some msg) :: :: ++seal:as:crub: ++ seal :: - |= {bpk/pass msg/@} + |= {bpk=pass msg=@} ^- @ux ?~ sek ~| %pubkey-only !! ?> =('b' (end 3 1 bpk)) @@ -3736,33 +3736,33 @@ (jam (~(en siva:aes shar ~) smsg)) :: :: ++tear:as:crub: ++ tear :: - |= {bpk/pass txt/@} + |= {bpk=pass txt=@} ^- (unit @ux) ?~ sek ~| %pubkey-only !! ?> =('b' (end 3 1 bpk)) =+ pk=(rsh 8 1 (rsh 3 1 bpk)) =+ shar=(shax (shar:ed pk cry.u.sek)) - =+ ;;({iv/@ len/@ cph/@} (cue txt)) + =+ ;;({iv=@ len=@ cph=@} (cue txt)) =+ try=(~(de siva:aes shar ~) iv len cph) ?~ try ~ (sure:as:(com:nu:crub bpk) u.try) -- ::as :: :: ++de:crub:crypto ++ de :: decrypt - |= {key/@J txt/@} + |= {key=@J txt=@} ^- (unit @ux) - =+ ;;({iv/@ len/@ cph/@} (cue txt)) + =+ ;;({iv=@ len=@ cph=@} (cue txt)) %^ ~(de sivc:aes (shaz key) ~) iv len cph :: :: ++dy:crub:crypto ++ dy :: need decrypt - |= {key/@J cph/@} + |= {key=@J cph=@} (need (de key cph)) :: :: ++en:crub:crypto ++ en :: encrypt - |= {key/@J msg/@} + |= {key=@J msg=@} ^- @ux (jam (~(en sivc:aes (shaz key) ~) msg)) :: :: ++ex:crub:crypto @@ -3792,21 +3792,21 @@ |% :: :: ++pit:nu:crub:crypto ++ pit :: create keypair - |= {w/@ seed/@} + |= {w=@ seed=@} =+ wid=(add (div w 8) ?:(=((mod w 8) 0) 0 1)) =+ bits=(shal wid seed) =+ [c=(rsh 8 1 bits) s=(end 8 1 bits)] ..nu(pub [cry=(puck:ed c) sgn=(puck:ed s)], sek `[cry=c sgn=s]) :: :: ++nol:nu:crub:crypto ++ nol :: activate secret - |= a/ring + |= a=ring =+ [mag=(end 3 1 a) bod=(rsh 3 1 a)] ~| %not-crub-seckey ?> =('B' mag) =+ [c=(rsh 8 1 bod) s=(end 8 1 bod)] ..nu(pub [cry=(puck:ed c) sgn=(puck:ed s)], sek `[cry=c sgn=s]) :: :: ++com:nu:crub:crypto ++ com :: activate public - |= a/pass + |= a=pass =+ [mag=(end 3 1 a) bod=(rsh 3 1 a)] ~| %not-crub-pubkey ?> =('b' mag) ..nu(pub [cry=(rsh 8 1 bod) sgn=(end 8 1 bod)], sek ~) @@ -3823,7 +3823,7 @@ |% :: :: ++trub:test:crypto ++ trub :: test crub - |= msg/@t + |= msg=@t :: :: make acru cores :: @@ -5426,7 +5426,7 @@ |% :: :: ++drop-list:unity ++ drop-list :: collapse unit list - |* lut/(list (unit)) + |* lut=(list (unit)) ?. |- ^- ? ?~(lut & ?~(i.lut | $(lut t.lut))) ~ @@ -5436,8 +5436,8 @@ [i=u:+.i.lut t=$(lut t.lut)] :: :: ++drop-map:unity ++ drop-map :: collapse unit map - |* lum/(map term (unit)) - ?: (~(rep by lum) |=({{@ a/(unit)} b/_|} |(b ?=(~ a)))) + |* lum=(map term (unit)) + ?: (~(rep by lum) |=({{@ a=(unit)} b=_|} |(b ?=(~ a)))) ~ (some (~(run by lum) need)) :: :: ++drop-pole:unity @@ -5494,24 +5494,24 @@ (rap 3 (join '\0a' tez)) :: :: ++of-wall:format ++ of-wall :: line list to tape - |= a/wall ^- tape + |= a=wall ^- tape ?~(a ~ "{i.a}\0a{$(a t.a)}") :: :: ++en-beam:format ++ en-beam :: beam to path - |= bem/beam + |= bem=beam ^- path [(scot %p p.bem) q.bem (scot r.bem) s.bem] :: :: ++de-beam:format ++ de-beam :: parse path to beam - |= pax/path + |= pax=path ^- (unit beam) ?. ?=({* * * *} pax) ~ %+ biff (slaw %p i.pax) - |= who/ship + |= who=ship %+ biff (slaw %tas i.t.pax) - |= dex/desk + |= dex=desk %+ biff (slay i.t.t.pax) - |= cis/coin + |= cis=coin ?. ?=({%$ case} cis) ~ `(unit beam)`[~ [who dex `case`p.cis] t.t.t.pax] :: @@ -5552,32 +5552,32 @@ |% :: :: ++frond:enjs:format ++ frond :: object from k-v pair - |= {p/@t q/json} + |= {p=@t q=json} ^- json [%o [[p q] ~ ~]] :: :: ++pairs:enjs:format ++ pairs :: object from k-v list - |= a/(list {p/@t q/json}) + |= a=(list {p=@t q=json}) ^- json [%o (~(gas by *(map @t json)) a)] :: :: ++tape:enjs:format ++ tape :: string from tape - |= a/^tape + |= a=^tape ^- json [%s (crip a)] :: :: ++wall:enjs:format ++ wall :: string from wall - |= a/^wall + |= a=^wall ^- json (tape (of-wall a)) :: :: ++ship:enjs:format ++ ship :: string from ship - |= a/^ship + |= a=^ship ^- json (tape (slag 1 (scow %p a))) :: :: ++numb:enjs:format ++ numb :: number from unsigned - |= a/@u + |= a=@u ^- json :- %n ?: =(0 a) '0' @@ -5587,7 +5587,7 @@ ?:(=(0 a) ~ [(add '0' (mod a 10)) $(a (div a 10))]) :: :: ++time:enjs:format ++ time :: ms timestamp - |= a/^time + |= a=^time =- (numb (div (mul - 1.000) ~s1)) (add (div ~s1 2.000) (sub a ~1970.1.1)) :: :: ++path:enjs:format @@ -5609,8 +5609,8 @@ |% :: :: ++ar:dejs:format ++ ar :: array as list - |* wit/fist - |= jon/json ^- (list _(wit *json)) + |* wit=fist + |= jon=json ^- (list _(wit *json)) ?> ?=({%a *} jon) (turn p.jon wit) :: :: ++as:dejs:format @@ -5619,72 +5619,72 @@ (cu ~(gas in *(set _$:a)) (ar a)) :: :: ++at:dejs:format ++ at :: array as tuple - |* wil/(pole fist) - |= jon/json + |* wil=(pole fist) + |= jon=json ?> ?=({%a *} jon) ((at-raw wil) p.jon) :: :: ++at-raw:dejs:format ++ at-raw :: array as tuple - |* wil/(pole fist) - |= jol/(list json) + |* wil=(pole fist) + |= jol=(list json) ?~ jol !! ?- wil :: mint-vain on empty - :: {wit/* t/*} - {* t/*} + :: {wit=* t=*} + {* t=*} => .(wil [wit *]=wil) ?~ t.wil ?^(t.jol !! (wit.wil i.jol)) [(wit.wil i.jol) ((at-raw t.wil) t.jol)] == :: :: ++bo:dejs:format ++ bo :: boolean - |=(jon/json ?>(?=({%b *} jon) p.jon)) + |=(jon=json ?>(?=({%b *} jon) p.jon)) :: :: ++bu:dejs:format ++ bu :: boolean not - |=(jon/json ?>(?=({%b *} jon) !p.jon)) + |=(jon=json ?>(?=({%b *} jon) !p.jon)) :: :: ++ci:dejs:format ++ ci :: maybe transform - |* {poq/gate wit/fist} - |= jon/json + |* {poq=gate wit=fist} + |= jon=json (need (poq (wit jon))) :: :: ++cu:dejs:format ++ cu :: transform - |* {poq/gate wit/fist} - |= jon/json + |* {poq=gate wit=fist} + |= jon=json (poq (wit jon)) :: :: ++di:dejs:format ++ di :: millisecond date %+ cu - |= a/@u ^- @da + |= a=@u ^- @da (add ~1970.1.1 (div (mul ~s1 a) 1.000)) ni :: :: ++mu:dejs:format ++ mu :: true unit - |* wit/fist - |= jon/json + |* wit=fist + |= jon=json ?~(jon ~ (some (wit jon))) :: :: ++ne:dejs:format ++ ne :: number as real - |= jon/json + |= jon=json ^- @rd ?> ?=([%n *] jon) (rash p.jon (cook ryld (cook royl-cell:^so json-rn))) :: :: ++ni:dejs:format ++ ni :: number as integer - |= jon/json + |= jon=json ?> ?=({%n *} jon) (rash p.jon dem) :: :: ++no:dejs:format ++ no :: number as cord - |=(jon/json ?>(?=({%n *} jon) p.jon)) + |=(jon=json ?>(?=({%n *} jon) p.jon)) :: :: ++of:dejs:format ++ of :: object as frond - |* wer/(pole {cord fist}) - |= jon/json + |* wer=(pole {cord fist}) + |= jon=json ?> ?=({%o {@ *} ~ ~} jon) |- ?- wer :: mint-vain on empty - :: {{key/@t wit/*} t/*} - {{key/@t *} t/*} + :: {{key=@t wit=*} t=*} + {{key=@t *} t=*} => .(wer [[* wit] *]=wer) ?: =(key.wer p.n.p.jon) [key.wer ~|(key+key.wer (wit.wer q.n.p.jon))] @@ -5693,52 +5693,52 @@ == :: :: ++ot:dejs:format ++ ot :: object as tuple - |* wer/(pole {cord fist}) - |= jon/json + |* wer=(pole {cord fist}) + |= jon=json ?> ?=({%o *} jon) ((ot-raw wer) p.jon) :: :: ++ot-raw:dejs:format ++ ot-raw :: object as tuple - |* wer/(pole {cord fist}) - |= jom/(map @t json) + |* wer=(pole {cord fist}) + |= jom=(map @t json) ?- wer :: mint-vain on empty - :: {{key/@t wit/*} t/*} - {{key/@t *} t/*} + :: {{key=@t wit=*} t=*} + {{key=@t *} t=*} => .(wer [[* wit] *]=wer) =/ ten ~|(key+key.wer (wit.wer (~(got by jom) key.wer))) ?~(t.wer ten [ten ((ot-raw t.wer) jom)]) == :: ++ ou :: object of units - |* wer/(pole {cord fist}) - |= jon/json + |* wer=(pole {cord fist}) + |= jon=json ?> ?=({%o *} jon) ((ou-raw wer) p.jon) :: :: ++ou-raw:dejs:format ++ ou-raw :: object of units - |* wer/(pole {cord fist}) - |= jom/(map @t json) + |* wer=(pole {cord fist}) + |= jom=(map @t json) ?- wer :: mint-vain on empty - :: {{key/@t wit/*} t/*} - {{key/@t *} t/*} + :: {{key=@t wit=*} t=*} + {{key=@t *} t=*} => .(wer [[* wit] *]=wer) =/ ten ~|(key+key.wer (wit.wer (~(get by jom) key.wer))) ?~(t.wer ten [ten ((ou-raw t.wer) jom)]) == :: :: ++om:dejs:format ++ om :: object as map - |* wit/fist - |= jon/json + |* wit=fist + |= jon=json ?> ?=({%o *} jon) (~(run by p.jon) wit) :: :: ++op:dejs:format ++ op :: parse keys of map - |* {fel/rule wit/fist} - |= jon/json ^- (map _(wonk *fel) _*wit) + |* {fel=rule wit=fist} + |= jon=json ^- (map _(wonk *fel) _*wit) =/ jom ((om wit) jon) %- malt %+ turn ~(tap by jom) - |* {a/cord b/*} + |* {a=cord b=*} => .(+< [a b]=+<) [(rash a fel) b] :: :: ++pa:dejs:format @@ -5746,11 +5746,11 @@ (su ;~(pfix fas (more fas urs:ab))) :: :: ++pe:dejs:format ++ pe :: prefix - |* {pre/* wit/fist} + |* {pre=* wit=fist} (cu |*(* [pre +<]) wit) :: :: ++sa:dejs:format ++ sa :: string as tape - |=(jon/json ?>(?=({%s *} jon) (trip p.jon))) + |=(jon=json ?>(?=({%s *} jon) (trip p.jon))) :: :: ++se:dejs:format ++ se :: string as aura |= aur=@tas @@ -5758,35 +5758,35 @@ ?>(?=([%s *] jon) (slav aur p.jon)) :: :: ++so:dejs:format ++ so :: string as cord - |=(jon/json ?>(?=({%s *} jon) p.jon)) + |=(jon=json ?>(?=({%s *} jon) p.jon)) :: :: ++su:dejs:format ++ su :: parse string - |* sab/rule - |= jon/json ^+ (wonk *sab) + |* sab=rule + |= jon=json ^+ (wonk *sab) ?> ?=({%s *} jon) (rash p.jon sab) :: :: ++uf:dejs:format ++ uf :: unit fall - |* [def/* wit/fist] - |= jon/(unit json) + |* [def=* wit=fist] + |= jon=(unit json) ?~(jon def (wit u.jon)) :: :: ++un:dejs:format ++ un :: unit need - |* wit/fist - |= jon/(unit json) + |* wit=fist + |= jon=(unit json) (wit (need jon)) :: :: ++ul:dejs:format ++ ul :: null - |=(jon/json ?~(jon ~ !!)) + |=(jon=json ?~(jon ~ !!)) :: ++ za :: full unit pole - |* pod/(pole (unit)) + |* pod=(pole (unit)) ?~ pod & ?~ -.pod | (za +.pod) :: ++ zl :: collapse unit list - |* lut/(list (unit)) + |* lut=(list (unit)) ?. |- ^- ? ?~(lut & ?~(i.lut | $(lut t.lut))) ~ @@ -5796,15 +5796,15 @@ [i=u:+.i.lut t=$(lut t.lut)] :: ++ zp :: unit tuple - |* but/(pole (unit)) + |* but=(pole (unit)) ?~ but !! ?~ +.but u:->.but [u:->.but (zp +.but)] :: ++ zm :: collapse unit map - |* lum/(map term (unit)) - ?: (~(rep by lum) |=({{@ a/(unit)} b/_|} |(b ?=(~ a)))) + |* lum=(map term (unit)) + ?: (~(rep by lum) |=({{@ a=(unit)} b=_|} |(b ?=(~ a)))) ~ (some (~(run by lum) need)) -- ::dejs @@ -5821,8 +5821,8 @@ :: |% ++ ar :: array as list - |* wit/fist - |= jon/json + |* wit=fist + |= jon=json ?. ?=({%a *} jon) ~ %- zl |- @@ -5830,71 +5830,71 @@ [i=(wit i.p.jon) t=$(p.jon t.p.jon)] :: ++ at :: array as tuple - |* wil/(pole fist) - |= jon/json + |* wil=(pole fist) + |= jon=json ?. ?=({%a *} jon) ~ ?. =((lent wil) (lent p.jon)) ~ =+ raw=((at-raw wil) p.jon) ?.((za raw) ~ (some (zp raw))) :: ++ at-raw :: array as tuple - |* wil/(pole fist) - |= jol/(list json) + |* wil=(pole fist) + |= jol=(list json) ?~ wil ~ :- ?~(jol ~ (-.wil i.jol)) ((at-raw +.wil) ?~(jol ~ t.jol)) :: ++ bo :: boolean - |=(jon/json ?.(?=({%b *} jon) ~ [~ u=p.jon])) + |=(jon=json ?.(?=({%b *} jon) ~ [~ u=p.jon])) :: ++ bu :: boolean not - |=(jon/json ?.(?=({%b *} jon) ~ [~ u=!p.jon])) + |=(jon=json ?.(?=({%b *} jon) ~ [~ u=!p.jon])) :: ++ ci :: maybe transform - |* {poq/gate wit/fist} - |= jon/json + |* {poq=gate wit=fist} + |= jon=json (biff (wit jon) poq) :: ++ cu :: transform - |* {poq/gate wit/fist} - |= jon/json + |* {poq=gate wit=fist} + |= jon=json (bind (wit jon) poq) :: ++ da :: UTC date - |= jon/json + |= jon=json ?. ?=({%s *} jon) ~ - (bind (stud:chrono:userlib p.jon) |=(a/date (year a))) + (bind (stud:chrono:userlib p.jon) |=(a=date (year a))) :: ++ di :: millisecond date %+ cu - |= a/@u ^- @da + |= a=@u ^- @da (add ~1970.1.1 (div (mul ~s1 a) 1.000)) ni :: ++ mu :: true unit - |* wit/fist - |= jon/json + |* wit=fist + |= jon=json ?~(jon (some ~) (bind (wit jon) some)) :: ++ ne :: number as real - |= jon/json + |= jon=json ^- (unit @rd) ?. ?=([%n *] jon) ~ (rush p.jon (cook ryld (cook royl-cell:^so json-rn))) :: ++ ni :: number as integer - |= jon/json + |= jon=json ?. ?=({%n *} jon) ~ (rush p.jon dem) :: ++ no :: number as cord - |= jon/json + |= jon=json ?. ?=({%n *} jon) ~ (some p.jon) :: ++ of :: object as frond - |* wer/(pole {cord fist}) - |= jon/json + |* wer=(pole {cord fist}) + |= jon=json ?. ?=({%o {@ *} ~ ~} jon) ~ |- ?~ wer ~ @@ -5903,67 +5903,67 @@ ((of +.wer) jon) :: ++ ot :: object as tuple - |* wer/(pole {cord fist}) - |= jon/json + |* wer=(pole {cord fist}) + |= jon=json ?. ?=({%o *} jon) ~ =+ raw=((ot-raw wer) p.jon) ?.((za raw) ~ (some (zp raw))) :: ++ ot-raw :: object as tuple - |* wer/(pole {cord fist}) - |= jom/(map @t json) + |* wer=(pole {cord fist}) + |= jom=(map @t json) ?~ wer ~ =+ ten=(~(get by jom) -.-.wer) [?~(ten ~ (+.-.wer u.ten)) ((ot-raw +.wer) jom)] :: ++ om :: object as map - |* wit/fist - |= jon/json + |* wit=fist + |= jon=json ?. ?=({%o *} jon) ~ (zm (~(run by p.jon) wit)) :: ++ op :: parse keys of map - |* {fel/rule wit/fist} + |* {fel=rule wit=fist} %+ cu - |= a/(list (pair _(wonk *fel) _(need *wit))) + |= a=(list (pair _(wonk *fel) _(need *wit))) (my:nl a) %- ci :_ (om wit) - |= a/(map cord _(need *wit)) + |= a=(map cord _(need *wit)) ^- (unit (list _[(wonk *fel) (need *wit)])) %- zl %+ turn ~(tap by a) - |= {a/cord b/_(need *wit)} + |= {a=cord b=_(need *wit)} =+ nit=(rush a fel) ?~ nit ~ (some [u.nit b]) :: ++ pe :: prefix - |* {pre/* wit/fist} + |* {pre=* wit=fist} (cu |*(* [pre +<]) wit) :: ++ sa :: string as tape - |= jon/json + |= jon=json ?.(?=({%s *} jon) ~ (some (trip p.jon))) :: ++ so :: string as cord - |= jon/json + |= jon=json ?.(?=({%s *} jon) ~ (some p.jon)) :: ++ su :: parse string - |* sab/rule - |= jon/json + |* sab=rule + |= jon=json ?. ?=({%s *} jon) ~ (rush p.jon sab) :: - ++ ul |=(jon/json ?~(jon (some ~) ~)) :: null + ++ ul |=(jon=json ?~(jon (some ~) ~)) :: null ++ za :: full unit pole - |* pod/(pole (unit)) + |* pod=(pole (unit)) ?~ pod & ?~ -.pod | (za +.pod) :: ++ zl :: collapse unit list - |* lut/(list (unit)) + |* lut=(list (unit)) ?. |- ^- ? ?~(lut & ?~(i.lut | $(lut t.lut))) ~ @@ -5973,15 +5973,15 @@ [i=u:+.i.lut t=$(lut t.lut)] :: ++ zp :: unit tuple - |* but/(pole (unit)) + |* but=(pole (unit)) ?~ but !! ?~ +.but u:->.but [u:->.but (zp +.but)] :: ++ zm :: collapse unit map - |* lum/(map term (unit)) - ?: (~(rep by lum) |=({{@ a/(unit)} b/_|} |(b ?=(~ a)))) + |* lum=(map term (unit)) + ?: (~(rep by lum) |=({{@ a=(unit)} b=_|} |(b ?=(~ a)))) ~ (some (~(run by lum) need)) -- ::dejs-soft @@ -5995,7 +5995,7 @@ |% :: :: ++berk:differ ++ berk :: invert diff patch - |* bur/(urge) + |* bur=(urge) |- ^+ bur ?~ bur ~ :_ $(bur t.bur) @@ -6006,7 +6006,7 @@ :: :: ++loss:differ ++ loss :: longest subsequence ~% %loss ..is ~ - |* {hel/(list) hev/(list)} + |* {hel=(list) hev=(list)} |- ^+ hev =+ ^= sev =+ [inx=0 sev=*(map _i.-.hev (list @ud))] @@ -6018,7 +6018,7 @@ inx +(inx) sev (~(put by sev) i.hev [inx ?~(guy ~ u.guy)]) == - =| gox/{p/@ud q/(map @ud {p/@ud q/_hev})} + =| gox={p=@ud q=(map @ud {p=@ud q=_hev})} =< abet =< main |% @@ -6029,19 +6029,19 @@ (flop q:(need (~(get by q.gox) (dec p.gox)))) :: :: ++hink:loss:differ ++ hink :: extend fits top - |= {inx/@ud goy/@ud} ^- ? + |= {inx=@ud goy=@ud} ^- ? ?| =(p.gox inx) (lth goy p:(need (~(get by q.gox) inx))) == :: :: ++lonk:loss:differ ++ lonk :: extend fits bottom - |= {inx/@ud goy/@ud} ^- ? + |= {inx=@ud goy=@ud} ^- ? ?| =(0 inx) (gth goy p:(need (~(get by q.gox) (dec inx)))) == :: :: ++luna:loss:differ ++ luna :: extend - |= {inx/@ud goy/@ud} + |= {inx=@ud goy=@ud} ^+ +> %_ +>.$ gox @@ -6053,10 +6053,10 @@ == :: :: ++merg:loss:differ ++ merg :: merge all matches - |= gay/(list @ud) + |= gay=(list @ud) ^+ +> =+ ^= zes - =+ [inx=0 zes=*(list {p/@ud q/@ud})] + =+ [inx=0 zes=*(list {p=@ud q=@ud})] |- ^+ zes ?: |(?=(~ gay) (gth inx p.gox)) zes ?. (lonk inx i.gay) $(gay t.gay) @@ -6074,7 +6074,7 @@ -- :: :: :: ++lurk:differ ++ lurk :: apply list patch - |* {hel/(list) rug/(urge)} + |* {hel=(list) rug=(urge)} ^+ hel =+ war=`_hel`~ |- ^+ hel @@ -6099,9 +6099,9 @@ == :: :: ++lusk:differ ++ lusk :: lcs to list patch - |* {hel/(list) hev/(list) lcs/(list)} + |* {hel=(list) hev=(list) lcs=(list)} =+ ^= rag - ^- {$%({%& p/@ud} {%| p/_lcs q/_lcs})} + ^- {$%({%& p=@ud} {%| p=_lcs q=_lcs})} [%& 0] => .(rag [p=rag q=*(list _rag)]) =< abet =< main @@ -6112,7 +6112,7 @@ (flop q.rag) :: :: ++done:lusk:differ ++ done :: - |= new/_p.rag + |= new=_p.rag ^+ rag ?- -.p.rag %| ?- -.new @@ -6158,15 +6158,15 @@ |% :: :: ++as-octs:mimes:html ++ as-octs :: atom to octstream - |= tam/@ ^- octs + |= tam=@ ^- octs [(met 3 tam) tam] :: :: ++as-octt:mimes:html ++ as-octt :: tape to octstream - |= tep/tape ^- octs + |= tep=tape ^- octs (as-octs (rap 3 tep)) :: :: ++en-mite:mimes:html ++ en-mite :: mime type to text - |= myn/mite + |= myn=mite %- crip |- ^- tape ?~ myn ~ @@ -6196,7 +6196,7 @@ -- :: :: ++en-base64:mimes: ++ en-base64 :: encode base64 - |= tig/@ + |= tig=@ ^- tape =+ poc=(~(dif fo 3) 0 (met 3 tig)) =+ pad=(lsh 3 poc (swp 3 tig)) @@ -6211,14 +6211,14 @@ (weld (flop (slag poc sif)) (reap poc '=')) :: :: ++de-base64:mimes: ++ de-base64 :: decode base64 - =- |=(a/cord (rash a fel)) - =< fel=(cook |~(a/@ `@t`(swp 3 a)) (bass 64 .)) + =- |=(a=cord (rash a fel)) + =< fel=(cook |~(a=@ `@t`(swp 3 a)) (bass 64 .)) =- (cook welp ;~(plug (plus siw) (stun 0^2 (cold %0 tis)))) ^= siw ;~ pose - (cook |=(a/@ (sub a 'A')) (shim 'A' 'Z')) - (cook |=(a/@ (sub a 'G')) (shim 'a' 'z')) - (cook |=(a/@ (add a 4)) (shim '0' '9')) + (cook |=(a=@ (sub a 'A')) (shim 'A' 'Z')) + (cook |=(a=@ (sub a 'G')) (shim 'a' 'z')) + (cook |=(a=@ (add a 4)) (shim '0' '9')) (cold 62 (just '+')) (cold 63 (just '/')) == @@ -6247,10 +6247,10 @@ -- ::mimes :: :: ++en-json:html ++ en-json :: print json - |^ |=(val/json (apex val "")) + |^ |=(val=json (apex val "")) :: :: ++apex:en-json:html ++ apex - |= {val/json rez/tape} + |= {val=json rez=tape} ^- tape ?~ val (weld "null" rez) ?- -.val @@ -6290,8 +6290,8 @@ == :: :: ++jesc:en-json:html ++ jesc :: escaped - =+ utf=|=(a/@ ['\\' 'u' ((x-co 4):co a)]) - |= a/@ ^- tape + =+ utf=|=(a=@ ['\\' 'u' ((x-co 4):co a)]) + |= a=@ ^- tape ?+ a ?:((gth a 0x1f) [a ~] (utf a)) %10 "\\n" %34 "\\\"" @@ -6300,7 +6300,7 @@ -- ::en-json :: :: ++de-json:html ++ de-json :: parse JSON - =< |=(a/cord `(unit json)`(rush a apex)) + =< |=(a=cord `(unit json)`(rush a apex)) |% :: :: ++abox:de-json:html ++ abox :: array @@ -6314,7 +6314,7 @@ (cold ~ (jest 'null')) (stag %b bool) (stag %s stri) - (cook |=(s/tape [%n p=(rap 3 s)]) numb) + (cook |=(s=tape [%n p=(rap 3 s)]) numb) abox obox == @@ -6354,7 +6354,7 @@ ;~(pose ;~(less doq bas prn) esca) :: :: ++mayb:de-json:html ++ mayb :: optional - |*(bus/rule ;~(pose bus (easy ~))) + |*(bus=rule ;~(pose bus (easy ~))) :: :: ++numb:de-json:html ++ numb :: number ;~ (comp twel) @@ -6378,8 +6378,8 @@ ;~(plug ;~(sfix (wish stri) (wish col)) apex) :: :: ++piec:de-json:html ++ piec :: listify - |* bus/rule - (cook |=(a/@ [a ~]) bus) + |* bus=rule + (cook |=(a=@ [a ~]) bus) :: :: ++stri:de-json:html ++ stri :: string (cook crip (ifix [doq doq] (star jcha))) @@ -6391,18 +6391,18 @@ (star (mask [`@`9 `@`10 `@`13 ' ' ~])) :: :: ++twel:de-json:html ++ twel :: tape weld - |=({a/tape b/tape} (weld a b)) + |=({a=tape b=tape} (weld a b)) :: :: ++wish:de-json:html ++ wish :: with whitespace - |*(sef/rule ;~(pfix spac sef)) + |*(sef=rule ;~(pfix spac sef)) -- ::de-json :: :: ++en-xml:html ++ en-xml :: xml printer - =< |=(a/manx `tape`(apex a ~)) + =< |=(a=manx `tape`(apex a ~)) |_ _[unq=`?`| cot=`?`|] :: :: ++apex:en-xml:html ++ apex :: top level - |= {mex/manx rez/tape} + |= {mex=manx rez=tape} ^- tape ?: ?=({%$ {{%$ *} ~}} g.mex) (escp v.i.a.g.mex rez) @@ -6413,14 +6413,14 @@ :- '<' %+ welp tam =- ?~(att rez [' ' (attr att rez)]) - ^- rez/tape + ^- rez=tape ?: &(?=(~ c.mex) |(cot ?^(man | (clot man)))) [' ' '/' '>' rez] :- '>' (many c.mex :(weld "" rez)) :: :: ++attr:en-xml:html ++ attr :: attributes to tape - |= {tat/mart rez/tape} + |= {tat=mart rez=tape} ^- tape ?~ tat rez =. rez $(tat t.tat) @@ -6431,7 +6431,7 @@ == :: :: ++escp:en-xml:html ++ escp :: escape for xml - |= {tex/tape rez/tape} + |= {tex=tape rez=tape} ?: unq (weld tex rez) =+ xet=`tape`(flop tex) @@ -6451,13 +6451,13 @@ == :: :: ++many:en-xml:html ++ many :: nodelist to tape - |= {lix/(list manx) rez/tape} + |= {lix=(list manx) rez=tape} |- ^- tape ?~ lix rez (apex i.lix $(lix t.lix)) :: :: ++name:en-xml:html ++ name :: name to tape - |= man/mane ^- tape + |= man=mane ^- tape ?@ man (trip man) (weld (trip -.man) `tape`[':' (trip +.man)]) :: :: ++clot:en-xml:html @@ -6470,8 +6470,8 @@ -- ::en-xml :: :: ++de-xml:html ++ de-xml :: xml parser - =< |=(a/cord (rush a apex)) - |_ ent/_`(map term @t)`[[%apos '\''] ~ ~] + =< |=(a=cord (rush a apex)) + |_ ent=_`(map term @t)`[[%apos '\''] ~ ~] :: :: ++apex:de-xml:html ++ apex :: top level =+ spa=;~(pose comt whit) @@ -6479,7 +6479,7 @@ %+ ifix [;~(plug (punt decl) (star spa)) (star spa)] ;~ pose - %+ sear |=({a/marx b/marl c/mane} ?.(=(c n.a) ~ (some [a b]))) + %+ sear |=({a=marx b=marl c=mane} ?.(=(c n.a) ~ (some [a b]))) ;~(plug head many tail) empt == @@ -6506,14 +6506,14 @@ :: :: ++cdat:de-xml:html ++ cdat :: CDATA section %+ cook - |=(a/tape ^-(mars ;/(a))) + |=(a=tape ^-(mars ;/(a))) %+ ifix [(jest '')] %- star ;~(less (jest ']]>') next) :: :: ++chrd:de-xml:html ++ chrd :: character data - %+ cook |=(a/tape ^-(mars ;/(a))) + %+ cook |=(a=tape ^-(mars ;/(a))) (plus ;~(less doq ;~(pose (just `@`10) escp))) :: :: ++comt:de-xml:html ++ comt :: comments @@ -6539,7 +6539,7 @@ =+ def=^+(ent (my:nl [%gt '>'] [%lt '<'] [%amp '&'] [%quot '"'] ~)) %+ sear ~(get by (~(uni by def) ent)) (cook crip ;~(plug alf (stun 1^31 aln))) - %+ cook |=(a/@c ?:((gth a 0x10.ffff) '�' (tuft a))) + %+ cook |=(a=@c ?:((gth a 0x10.ffff) '�' (tuft a))) =< ;~(pfix hax ;~(pose - +)) :- (bass 10 (stun 1^8 dit)) (bass 16 ;~(pfix (mask "xX") (stun 1^8 hit))) @@ -6572,12 +6572,12 @@ -- ::de-xml :: :: ++en-urlt:html ++ en-urlt :: url encode - |= tep/tape + |= tep=tape ^- tape %- zing %+ turn tep - |= tap/char - =+ xen=|=(tig/@ ?:((gte tig 10) (add tig 55) (add tig '0'))) + |= tap=char + =+ xen=|=(tig=@ ?:((gte tig 10) (add tig 55) (add tig '0'))) ?: ?| &((gte tap 'a') (lte tap 'z')) &((gte tap 'A') (lte tap 'Z')) &((gte tap '0') (lte tap '9')) @@ -6590,7 +6590,7 @@ ['%' (xen (rsh 0 4 tap)) (xen (end 0 4 tap)) ~] :: :: ++de-urlt:html ++ de-urlt :: url decode - |= tep/tape + |= tep=tape ^- (unit tape) ?~ tep [~ ~] ?: =('%' i.tep) @@ -6604,11 +6604,11 @@ ?~(nex ~ [~ i.tep u.nex]) :: :: ++en-purl:html ++ en-purl :: print purl - =< |=(pul/purl `tape`(apex %& pul)) + =< |=(pul=purl `tape`(apex %& pul)) |% :: :: ++apex:en-purl:html ++ apex :: - |= qur/quri ^- tape + |= qur=quri ^- tape ?- -.qur %& (weld (head p.p.qur) `tape`$(qur [%| +.p.qur])) %| ['/' (weld (body p.qur) (tail q.qur))] @@ -6619,7 +6619,7 @@ (weld (apex %& p) ?~(q "" `tape`['#' (trip u.q)])) :: :: ++body:en-purl:html ++ body :: - |= pok/pork ^- tape + |= pok=pork ^- tape ?~ q.pok ~ |- =+ seg=(en-urlt (trip i.q.pok)) @@ -6628,7 +6628,7 @@ (welp seg '/' $(q.pok t.q.pok)) :: :: ++head:en-purl:html ++ head :: - |= har/hart + |= har=hart ^- tape ;: weld ?:(&(p.har !?=(hoke r.har)) "https://" "http://") @@ -6645,7 +6645,7 @@ == :: :: ++tail:en-purl:html ++ tail :: - |= kay/quay + |= kay=quay ^- tape ?: =(~ kay) ~ :- '?' @@ -6659,27 +6659,27 @@ -- :: :: :: ++de-purl:html ++ de-purl :: url+header parser - =< |=(a/cord `(unit purl)`(rush a auri)) + =< |=(a=cord `(unit purl)`(rush a auri)) |% :: :: ++deft:de-purl:html ++ deft :: parse url extension - |= rax/(list @t) + |= rax=(list @t) |- ^- pork ?~ rax [~ ~] ?^ t.rax [p.pok [ire q.pok]]:[pok=$(rax t.rax) ire=i.rax] - =/ raf/(like term) + =/ raf=(like term) %- ;~ sfix %+ sear - |=(a/@ ((sand %ta) (crip (flop (trip a))))) - (cook |=(a/tape (rap 3 ^-((list @) a))) (star aln)) + |=(a=@ ((sand %ta) (crip (flop (trip a))))) + (cook |=(a=tape (rap 3 ^-((list @) a))) (star aln)) dot == [1^1 (flop (trip i.rax))] ?~ q.raf [~ [i.rax ~]] - =+ `{ext/term {@ @} fyl/tape}`u.q.raf + =+ `{ext=term {@ @} fyl=tape}`u.q.raf :- `ext ?:(=(~ fyl) ~ [(crip (flop fyl)) ~]) :: :: ++apat:de-purl:html @@ -6688,7 +6688,7 @@ ;~(pfix fas (more fas smeg)) :: :: ++aurf:de-purl:html ++ aurf :: 2396 with fragment - %+ cook |~(a/purf a) + %+ cook |~(a=purf a) ;~(plug auri (punt ;~(pfix hax (cook crip (star pque))))) :: :: ++auri:de-purl:html ++ auri :: 2396 URL @@ -6699,8 +6699,8 @@ :: :: ++auru:de-purl:html ++ auru :: 2396 with maybe user %+ cook - |= $: a/{p/? q/(unit user) r/{(unit @ud) host}} - b/{pork quay} + |= $: a={p=? q=(unit user) r={(unit @ud) host}} + b={pork quay} == ^- (pair (unit user) purl) [q.a [[p.a r.a] b]] @@ -6720,9 +6720,9 @@ :: :: ++dlab:de-purl:html ++ dlab :: 2396 domainlabel %+ sear - |= a/@ta + |= a=@ta ?.(=('-' (rsh 3 (dec (met 3 a)) a)) [~ u=a] ~) - %+ cook |=(a/tape (crip (cass a))) + %+ cook |=(a=tape (crip (cass a))) ;~(plug aln (star alp)) :: :: ++fque:de-purl:html ++ fque :: normal query field @@ -6765,7 +6765,7 @@ == :: :: ++scem:de-purl:html ++ scem :: 2396 scheme - %+ cook |=(a/tape (crip (cass a))) + %+ cook |=(a=tape (crip (cass a))) ;~(plug alf (star ;~(pose aln lus hep dot))) :: :: ++smeg:de-purl:html ++ smeg :: 2396 segment @@ -6792,7 +6792,7 @@ ;~ pose %+ stag %& %+ sear :: LL parser weak here - |= a/(list @t) + |= a=(list @t) =+ b=(flop a) ?> ?=(^ b) =+ c=(end 3 1 i.b) @@ -6823,13 +6823,13 @@ :: funky query :: %+ cook - |=(a/tape [[%$ (crip a)] ~]) + |=(a=tape [[%$ (crip a)] ~]) (star pque) == :: :: ++zest:de-purl:html ++ zest :: 2616 request-uri ;~ pose - (stag %& (cook |=(a/purl a) auri)) + (stag %& (cook |=(a=purl a) auri)) (stag %| ;~(plug apat yque)) == -- ::de-purl @@ -6853,7 +6853,7 @@ :: MOVEME :: :: ++fuel:html ++ fuel :: parse urbit fcgi - |= {bem/beam ced/noun:cred quy/quer} + |= {bem=beam ced=noun:cred quy=quer} ^- epic =+ qix=|-(`quay`?~(quy quy [[p q]:quy $(quy t.quy)])) [(malt qix) ;;(cred ced) bem] @@ -6897,13 +6897,13 @@ :: .= ~[p=~.ack q=~.~sarnel r=~..y] :: (dray ~[p=%tas q=%p r=%f] %ack ~sarnel &) :: - =- |* {a/{@tas (pole @tas)} b/*} ^- (paf a) + =- |* {a={@tas (pole @tas)} b=*} ^- (paf a) => .(b `,(tup -.a +.a)`b) ?~ +.a [(scot -.a b) ~] [(scot -.a -.b) `,(paf +.a)`(..$ +.a +.b)] - :- paf=|*(a/(pole) ?~(a ,~ {(odo:raid ,-.a(. %ta)) ,(..$ +.a)})) + :- paf=|*(a=(pole) ?~(a ,~ {(odo:raid ,-.a(. %ta)) ,(..$ +.a)})) ^= tup - |* {a/@tas b/(pole @tas)} + |* {a=@tas b=(pole @tas)} =+ c=(odo:raid a) ?~(b c {c (..$ ,-.b ,+.b)}) :: :: ++raid:wired @@ -6912,13 +6912,13 @@ :: .= [p=%ack q=~sarnel r=&] :: (raid /ack/~sarnel+.y p=%tas q=%p r=%f ~) :: - =- |* {a/path b/{@tas (pole @tas)}} + =- |* {a=path b={@tas (pole @tas)}} =* fog (odo -.b) ?~ +.b `fog`(slav -.b -.a) [`fog`(slav -.b -.a) (..$ +.a +.b)] ^= odo - |* a/@tas - |= b/* + |* a=@tas + |= b=* =- a(, (- b)) :: preserve face ?+ a @ %c @c %da @da %dr @dr %f @f %if @if %is @is %p @p @@ -6927,9 +6927,9 @@ == :: :: :: ++read:wired :: ++ read :: parse odored path -:: =< |*({a/path b/{@tas (pole @tas)}} ((+> b) a)) -:: |* b/{@tas (pole @tas)} -:: |= a/path +:: =< |*({a=path b={@tas (pole @tas)}} ((+> b) a)) +:: |* b={@tas (pole @tas)} +:: |= a=path :: ?~ a ~ :: =+ hed=(slaw -.b i.a) :: =* fog (odo:raid -.b) @@ -6984,7 +6984,7 @@ |% :: :: ++cite:title ++ cite :: render ship - |= who/@p + |= who=@p ^- tape =+ kind=(clan who) =+ name=(scow %p who) @@ -7019,10 +7019,10 @@ :::: ++milly :: (2k) milliseconds :: :::: ++ milly ^| - |_ now/@da + |_ now=@da :: :: ++around:milly ++ around :: relative msec - |= wen/@da + |= wen=@da ^- @tas ?: =(wen now) %now ?: (gth wen now) @@ -7030,21 +7030,21 @@ (cat 3 '-' $(now wen, wen now)) :: ++ about :: ++about:milly - |= wun/(unit @da) :: unit relative msec + |= wun=(unit @da) :: unit relative msec ^- @tas ?~(wun %no (around u.wun)) :: :: ++mill:milly ++ mill :: msec diff - |= one/@dr + |= one=@dr ^- @tas ?: =(`@`0 one) '0ms' (cat 3 (scot %ud (msec one)) %ms) :: :: ++msec:milly ++ msec :: @dr to @ud ms - |=(a/@dr `@ud`(div a (div ~s1 1.000))) + |=(a=@dr `@ud`(div a (div ~s1 1.000))) :: :: ++mull:milly ++ mull :: unit msec diff - |= une/(unit @dr) + |= une=(unit @dr) ^- @tas ?~(une %no (mill u.une)) -- @@ -7588,7 +7588,7 @@ (mul timestamp ~s1) :: :: ++dawn:chrono: ++ dawn :: Jan 1 weekday - |= yer/@ud + |= yer=@ud =+ yet=(sub yer 1) %- mod :_ 7 ;: add @@ -7599,14 +7599,14 @@ == :: :: ++daws:chrono: ++ daws :: date weekday - |= yed/date + |= yed=date %- mod :_ 7 %+ add (dawn y.yed) (sub (yawn [y.yed m.yed d.t.yed]) (yawn y.yed 1 1)) :: :: ++deal:chrono: ++ deal :: to leap sec time - |= yer/@da + |= yer=@da =+ n=0 =+ yud=(yore yer) |- ^- date @@ -7619,7 +7619,7 @@ $(n +(n)) :: :: ++lead:chrono: ++ lead :: from leap sec time - |= ley/date + |= ley=date =+ ler=(year ley) =+ n=0 |- ^- @da @@ -7635,20 +7635,20 @@ $(n +(n)) :: :: ++dust:chrono: ++ dust :: print UTC format - |= yed/date + |= yed=date ^- tape =+ wey=(daws yed) =/ num (d-co:co 1) :: print as decimal without dots - =/ pik |=({n/@u t/wall} `tape`(scag 3 (snag n t))) + =/ pik |=({n=@u t=wall} `tape`(scag 3 (snag n t))) :: "{(pik wey wik:yu)}, ". "{(num d.t.yed)} {(pik (dec m.yed) mon:yu)} {(num y.yed)} ". "{(num h.t.yed)}:{(num m.t.yed)}:{(num s.t.yed)} +0000" :: :: ++stud:chrono: ++ stud :: parse UTC format - =< |= a/cord :: expose parsers + =< |= a=cord :: expose parsers %+ biff (rush a (more sepa elem)) - |= b/(list _(wonk *elem)) ^- (unit date) + |= b=(list _(wonk *elem)) ^- (unit date) =- ?.((za:dejs:format -) ~ (some (zp:dejs:format -))) ^+ =+ [*date u=unit] *{(u _[a y]) (u _m) (u _d.t) (u _+.t) ~} @@ -7661,8 +7661,8 @@ |% :: :: ++snug:stud:chrono: ++ snug :: position in list - |= a/(list tape) - |= b/tape + |= a=(list tape) + |= b=tape =+ [pos=1 len=(lent b)] |- ^- (unit @u) ?~ a ~ @@ -7689,7 +7689,7 @@ (bass 10 (stun 1^2 dit)) :: :: ++t:stud:chrono: ++ t :: hours:minutes:secs - %+ cook |=({h/@u @ m/@u @ s/@u} ~[h m s]) + %+ cook |=({h=@u @ m=@u @ s=@u} ~[h m s]) ;~(plug d col d col d) :: :: XX day of week is currently unchecked, and @@ -7706,7 +7706,7 @@ -- :: :: :: ++unt:chrono:userlib ++ unt :: Urbit to Unix time - |= a/@ + |= a=@ (div (sub a ~1970.1.1) ~s1) :: :: ++yu:chrono:userlib ++ yu :: UTC format constants @@ -7764,32 +7764,32 @@ |% :: :: ++feel:space:userlib ++ feel :: simple file write - |= {pax/path val/cage} + |= {pax=path val=cage} ^- miso =+ dir=.^(arch %cy pax) ?~ fil.dir [%ins val] [%mut val] :: :: ++file:space:userlib ++ file :: simple file load - |= pax/path + |= pax=path ^- (unit) =+ dir=.^(arch %cy pax) ?~(fil.dir ~ [~ .^(* %cx pax)]) :: :: ++foal:space:userlib ++ foal :: high-level write - |= {pax/path val/cage} + |= {pax=path val=cage} ^- toro ?> ?=({* * * *} pax) [i.t.pax [%& [[[t.t.t.pax (feel pax val)] ~]]]] :: :: ++fray:space:userlib ++ fray :: high-level delete - |= pax/path + |= pax=path ^- toro ?> ?=({* * * *} pax) [i.t.pax [%& [[[t.t.t.pax [%del ~]] ~]]]] :: :: ++furl:space:userlib ++ furl :: unify changes - |= {one/toro two/toro} + |= {one=toro two=toro} ^- toro ~| %furl ?> ?& =(p.one p.two) :: same path @@ -7805,11 +7805,11 @@ :: :: ++lune:unix:userlib ++ lune :: cord by unix line ~% %lune ..is ~ - |= txt/@t + |= txt=@t ?~ txt ^- (list @t) ~ =+ [byt=(rip 3 txt) len=(met 3 txt)] - =| {lin/(list @t) off/@} + =| {lin=(list @t) off=@} ^- (list @t) %- flop |- ^+ lin @@ -7828,11 +7828,11 @@ :: :: ++nule:unix:userlib ++ nule :: lines to unix cord ~% %nule ..is ~ - |= lin/(list @t) + |= lin=(list @t) ^- @t %+ can 3 %+ turn lin - |= t/@t + |= t=@t [+((met 3 t)) (cat 3 t 10)] -- :: :: @@ -7845,7 +7845,7 @@ |% :: :: ++parsf:scanf: ++ parsf :: make parser from: - |* a/(pole _;/(*{$^(rule tape)})) :: ;"chars{rule}chars" + |* a=(pole _;/(*{$^(rule tape)})) :: ;"chars{rule}chars" =- (cook - (boil (norm a))) |* (list) ?~ +< ~ @@ -8597,7 +8597,7 @@ :: if no reference needed, just put the data. ?. =(t hol) (weld nes t) :: calculate byte offset of data we need to reference. - =/ ofs/@ud + =/ ofs=@ud =- (div - 2) :: two hex digits per byte. %+ add led :: count head, and %- lent %- zing :: count all tail data From ebe0feed50d580a708578bf8ee52a1f73fc3ac5e Mon Sep 17 00:00:00 2001 From: fang Date: Thu, 26 Nov 2020 12:03:41 +0100 Subject: [PATCH 776/933] hoon: remove face/type syntax --- pkg/arvo/sys/hoon.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 4b56f5cd1f..0b187e285d 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -12909,7 +12909,7 @@ == :- ['a' 'z'] ;~ pose - (stag %bcts ;~(plug sym ;~(pfix ;~(pose fas tis) wyde))) + (stag %bcts ;~(plug sym ;~(pfix tis wyde))) (stag %like (most col rope)) == == From a539d986a7db71b96eaf61c50e0816b0a9431d0c Mon Sep 17 00:00:00 2001 From: fang Date: Thu, 26 Nov 2020 15:09:31 +0100 Subject: [PATCH 777/933] various: move away from {type} syntax In favor of [type] syntax. Turns a bunch of ++ into +$ along the way. --- pkg/arvo/app/dojo.hoon | 146 +- pkg/arvo/gen/cat.hoon | 4 +- pkg/arvo/gen/code.hoon | 2 +- pkg/arvo/gen/deco.hoon | 4 +- pkg/arvo/gen/hello.hoon | 2 +- pkg/arvo/gen/help.hoon | 18 +- pkg/arvo/gen/hood/autocommit.hoon | 4 +- pkg/arvo/gen/hood/breload.hoon | 4 +- pkg/arvo/gen/hood/commit.hoon | 4 +- pkg/arvo/gen/hood/cp.hoon | 2 +- pkg/arvo/gen/hood/exit.hoon | 4 +- pkg/arvo/gen/hood/hi.hoon | 2 +- pkg/arvo/gen/hood/init-oauth2.hoon | 6 +- pkg/arvo/gen/hood/init-oauth2/google.hoon | 8 +- pkg/arvo/gen/hood/label.hoon | 4 +- pkg/arvo/gen/hood/link.hoon | 4 +- pkg/arvo/gen/hood/mass.hoon | 4 +- pkg/arvo/gen/hood/merge.hoon | 20 +- pkg/arvo/gen/hood/moon-breach.hoon | 2 +- pkg/arvo/gen/hood/moon-cycle-keys.hoon | 2 +- pkg/arvo/gen/hood/moon.hoon | 2 +- pkg/arvo/gen/hood/mount.hoon | 4 +- pkg/arvo/gen/hood/mv.hoon | 2 +- pkg/arvo/gen/hood/pack.hoon | 4 +- pkg/arvo/gen/hood/ping.hoon | 4 +- pkg/arvo/gen/hood/private.hoon | 4 +- pkg/arvo/gen/hood/public.hoon | 4 +- pkg/arvo/gen/hood/rc.hoon | 4 +- pkg/arvo/gen/hood/reboot.hoon | 4 +- pkg/arvo/gen/hood/reload-desk.hoon | 4 +- pkg/arvo/gen/hood/reload.hoon | 4 +- pkg/arvo/gen/hood/reset.hoon | 4 +- pkg/arvo/gen/hood/rm.hoon | 2 +- pkg/arvo/gen/hood/schedule.hoon | 2 +- pkg/arvo/gen/hood/start.hoon | 4 +- pkg/arvo/gen/hood/sync.hoon | 4 +- pkg/arvo/gen/hood/syncs.hoon | 2 +- pkg/arvo/gen/hood/track.hoon | 4 +- pkg/arvo/gen/hood/unlink.hoon | 4 +- pkg/arvo/gen/hood/unmount.hoon | 4 +- pkg/arvo/gen/hood/unsync.hoon | 4 +- pkg/arvo/gen/hood/verb.hoon | 4 +- pkg/arvo/gen/ls.hoon | 2 +- pkg/arvo/lib/chat-store.hoon | 2 +- pkg/arvo/lib/contact-json.hoon | 2 +- pkg/arvo/lib/cram.hoon | 12 +- pkg/arvo/lib/elem-to-react-json.hoon | 4 +- pkg/arvo/lib/frontmatter.hoon | 8 +- pkg/arvo/lib/generators.hoon | 8 +- pkg/arvo/lib/graph-store.hoon | 4 +- pkg/arvo/lib/group-json.hoon | 2 +- pkg/arvo/lib/group-store.hoon | 8 +- pkg/arvo/lib/hood/drum.hoon | 144 +- pkg/arvo/lib/hood/helm.hoon | 16 +- pkg/arvo/lib/hood/kiln.hoon | 38 +- pkg/arvo/lib/jose.hoon | 4 +- pkg/arvo/lib/language-server/complete.hoon | 2 +- pkg/arvo/lib/language-server/easy-print.hoon | 136 +- pkg/arvo/lib/metadata-json.hoon | 2 +- pkg/arvo/lib/old-phon.hoon | 16 +- pkg/arvo/lib/pill.hoon | 4 +- pkg/arvo/lib/pprint.hoon | 2 +- pkg/arvo/lib/pretty-file.hoon | 2 +- pkg/arvo/lib/show-dir.hoon | 8 +- pkg/arvo/lib/sole.hoon | 14 +- pkg/arvo/lib/test/runner.hoon | 2 +- pkg/arvo/lib/tree.hoon | 8 +- pkg/arvo/lib/urb-split.hoon | 6 +- pkg/arvo/lib/xray.hoon | 6 +- pkg/arvo/mar/css.hoon | 2 +- pkg/arvo/mar/dill/belt.hoon | 10 +- pkg/arvo/mar/drum-put.hoon | 4 +- pkg/arvo/mar/hoon.hoon | 2 +- pkg/arvo/mar/html.hoon | 2 +- pkg/arvo/mar/js.hoon | 2 +- pkg/arvo/mar/json.hoon | 2 +- pkg/arvo/mar/map.hoon | 2 +- pkg/arvo/mar/mime.hoon | 2 +- pkg/arvo/mar/png.hoon | 2 +- pkg/arvo/mar/snip.hoon | 14 +- pkg/arvo/mar/sole/action.hoon | 6 +- pkg/arvo/mar/sole/effect.hoon | 2 +- pkg/arvo/mar/txt.hoon | 16 +- pkg/arvo/mar/xml.hoon | 2 +- pkg/arvo/sur/kyev.hoon | 4 +- pkg/arvo/sur/lens.hoon | 46 +- pkg/arvo/sur/sole.hoon | 82 +- pkg/arvo/sur/urb.hoon | 2 +- pkg/arvo/sys/arvo.hoon | 4 +- pkg/arvo/sys/hoon.hoon | 2840 +++++++++--------- pkg/arvo/sys/vane/clay.hoon | 146 +- pkg/arvo/sys/vane/dill.hoon | 36 +- pkg/arvo/sys/vane/eyre.hoon | 4 +- pkg/arvo/sys/vane/jael.hoon | 10 +- pkg/arvo/sys/zuse.hoon | 878 +++--- 95 files changed, 2453 insertions(+), 2455 deletions(-) diff --git a/pkg/arvo/app/dojo.hoon b/pkg/arvo/app/dojo.hoon index af6af8bb73..49a1ff3248 100644 --- a/pkg/arvo/app/dojo.hoon +++ b/pkg/arvo/app/dojo.hoon @@ -10,14 +10,14 @@ :::: :: :::: :: :: :: => |% :: external structures - ++ id @tasession :: session id - ++ house :: all state + +$ id @tasession :: session id + +$ house :: all state $: %6 egg=@u :: command count hoc=(map id session) :: conversations acl=(set ship) :: remote access whitelist == :: - ++ session :: per conversation + +$ session :: per conversation $: say=sole-share :: command-line state dir=beam :: active path poy=(unit dojo-project) :: working @@ -32,7 +32,7 @@ old=(set term) :: used TLVs buf=tape :: multiline buffer == :: - ++ monkey :: per conversation + +$ monkey :: per conversation $: say=sole-share :: command-line state dir=beam :: active path poy=(unit dojo-project) :: working @@ -40,52 +40,52 @@ old=(set term) :: used TLVs buf=tape :: multiline buffer == :: - ++ dojo-command :: + +$ dojo-command :: $^ (pair dojo-sink dojo-source) :: route value - {%brev p=term} :: unbind variable + [%brev p=term] :: unbind variable :: - ++ dojo-sink :: - $% {%flat p=path} :: atom to unix - {%pill p=path} :: noun to unix pill - :: {%tree p=path} :: noun to unix tree - {%file p=beam} :: save to clay + +$ dojo-sink :: + $% [%flat p=path] :: atom to unix + [%pill p=path] :: noun to unix pill + :: [%tree p=path] :: noun to unix tree + [%file p=beam] :: save to clay $: %http :: http outbound p=?(%post %put) r=@t == - {%poke p=goal} :: poke app - {%show p=?(%0 %1 %2 %3 %4 %5)} :: val=type=hoon=xray - {%verb p=term} :: store variable + [%poke p=goal] :: poke app + [%show p=?(%0 %1 %2 %3 %4 %5)] :: val=type=hoon=xray + [%verb p=term] :: store variable == :: - ++ dojo-source :: construction node + +$ dojo-source :: construction node $: p=@ud :: assembly index q=dojo-build :: general build == :: - ++ dojo-build :: one arvo step + +$ dojo-build :: one arvo step $~ [%ex *hoon] - $% {%ur p=@t} :: http GET request - {%ge p=dojo-model} :: generator - {%te p=term q=(list dojo-source)} :: thread - {%dv p=path} :: core from source - {%ex p=hoon} :: hoon expression - {%sa p=mark} :: example mark value - {%as p=mark q=dojo-source} :: simple transmute - {%do p=hoon q=dojo-source} :: gate apply - {%tu p=(list dojo-source)} :: tuple + $% [%ur p=@t] :: http GET request + [%ge p=dojo-model] :: generator + [%te p=term q=(list dojo-source)] :: thread + [%dv p=path] :: core from source + [%ex p=hoon] :: hoon expression + [%sa p=mark] :: example mark value + [%as p=mark q=dojo-source] :: simple transmute + [%do p=hoon q=dojo-source] :: gate apply + [%tu p=(list dojo-source)] :: tuple == :: - ++ dojo-model :: data construction + +$ dojo-model :: data construction $: p=dojo-server :: core source q=dojo-config :: configuration == :: - ++ dojo-server :: numbered device + +$ dojo-server :: numbered device $: p=@ud :: assembly index q=path :: gate path == :: - ++ dojo-config :: configuration + +$ dojo-config :: configuration $: p=(list dojo-source) :: by order q=(map term (unit dojo-source)) :: by keyword == :: - ++ dojo-project :: construction state + +$ dojo-project :: construction state $: mad=dojo-command :: operation num=@ud :: number of tasks cud=(unit dojo-source) :: now solving @@ -95,8 +95,8 @@ job=(map @ud dojo-build) :: problems rez=(map @ud cage) :: results == :: - ++ bead {p=(set beam) q=cage} :: computed result - ++ goal {p=ship q=term} :: flat application + +$ bead [p=(set beam) q=cage] :: computed result + +$ goal [p=ship q=term] :: flat application -- => |% @@ -130,7 +130,7 @@ ++ parse-variable |* [sym=rule src=rule] %+ cook - |= {a=term b=(unit dojo-source)} + |= [a=term b=(unit dojo-source)] ^- dojo-command ?~(b [%brev a] [[%verb a] u.b]) ;~(plug sym (punt src)) @@ -146,7 +146,7 @@ :: ;~ pfix col %+ cook - |= {a=goal b=$^(dojo-model dojo-source)} + |= [a=goal b=$^(dojo-model dojo-source)] ?@ -.b [[%poke a] b] (to-command a b) ;~ plug @@ -316,7 +316,7 @@ ++ xsell `$-(vase tank)`vase-to-tank:pprint :: ++ he :: per session - |_ {hid=bowl:gall =id moz=(list card:agent:gall) session} + |_ [hid=bowl:gall =id moz=(list card:agent:gall) session] :: ++ he-beam ^- beam @@ -363,7 +363,7 @@ [%pass u.pux %arvo %c %warp ship desk ~] :: ++ dy-errd :: reject change, abet - |= {rev=(unit sole-edit) err=@u} + |= [rev=(unit sole-edit) err=@u] ^+ +>+> (he-errd(poy `+>+<) rev err) :: @@ -493,7 +493,7 @@ (dy-made-dial %noun p.res) :: ++ dy-cast - |* {typ=_* bun=vase} + |* [typ=_* bun=vase] |= a=vase ^- typ ~| [p.bun p.a] ?> (~(nest ut p.bun) & p.a) @@ -503,7 +503,7 @@ ^+ +> :: XX needs filter :: - ?: ?=({%show %3} -.mad) + ?: ?=([%show %3] -.mad) (dy-rash %tan (dy-show-source q.mad) ~) ?: ?=(%brev -.mad) =. var (~(del by var) p.mad) @@ -539,8 +539,8 @@ %dir =+ ^= pax ^- path =+ pax=((dy-cast path !>(*path)) q.cay) ?: ?=(~ pax) ~[(scot %p our.hid) %home '0'] - ?: ?=({@ ~} pax) ~[i.pax %home '0'] - ?: ?=({@ @ ~} pax) ~[i.pax i.t.pax '0'] + ?: ?=([@ ~] pax) ~[i.pax %home '0'] + ?: ?=([@ @ ~] pax) ~[i.pax i.t.pax '0'] pax =. dir (need (de-beam:format pax)) =- +>(..dy (he-diff %tan - ~)) @@ -605,7 +605,7 @@ :: Print a value (given as a cage) and a note (given as a tang). :: ++ dy-xprint - |= {cay=cage tan=tang} + |= [cay=cage tan=tang] %+ dy-rash %tan %- welp :_ tan ?+ p.cay [(xsell q.cay)]~ @@ -615,7 +615,7 @@ =- (flop (turn `wall`- |=(a=tape leaf+(dash:us a '' ~)))) :- "HTTP {}" %+ weld - (turn q.hit |=({a=@t b=@t} "{(trip a)}: {(trip b)}")) + (turn q.hit |=([a=@t b=@t] "{(trip a)}: {(trip b)}")) :- i="" t=(turn `wain`?~(r.hit ~ (to-wain:format q.u.r.hit)) trip) == @@ -623,7 +623,7 @@ :: Print a value (given as a cage) and a note (given as a tang). :: ++ dy-print - |= {cay=cage tan=tang} + |= [cay=cage tan=tang] %+ dy-rash %tan %- welp :_ tan ?+ p.cay [(sell q.cay)]~ @@ -633,29 +633,29 @@ =- (flop (turn `wall`- |=(a=tape leaf+(dash:us a '' ~)))) :- "HTTP {}" %+ weld - (turn q.hit |=({a=@t b=@t} "{(trip a)}: {(trip b)}")) + (turn q.hit |=([a=@t b=@t] "{(trip a)}: {(trip b)}")) :- i="" t=(turn `wain`?~(r.hit ~ (to-wain:format q.u.r.hit)) trip) == ++ dy-show-type-noun |= a=type ^- tank =- >[-]< - |- ^- $? $% {%atom @tas (unit @)} - {%cell _$ _$} - {%face $@(term tune) _$} - {%fork (set _$)} - {%hold _$ hoon} + |- ^- $? $% [%atom @tas (unit @)] + [%cell _$ _$] + [%face $@(term tune) _$] + [%fork (set _$)] + [%hold _$ hoon] == wain :: "<|core|>" $?(%noun %void) == ?+ a a - {%face ^} a(q $(a q.a)) - {%cell ^} a(p $(a p.a), q $(a q.a)) - {%fork *} a(p (silt (turn ~(tap in p.a) |=(b=type ^$(a b))))) - {%hint *} !! - {%core ^} `wain`/core - {%hold *} a(p $(a p.a)) + [%face ^] a(q $(a q.a)) + [%cell ^] a(p $(a p.a), q $(a q.a)) + [%fork *] a(p (silt (turn ~(tap in p.a) |=(b=type ^$(a b))))) + [%hint *] !! + [%core ^] `wain`/core + [%hold *] a(p $(a p.a)) == :: :: XX needs filter @@ -668,25 +668,25 @@ ::$? hoon ;: jank-bucwut hoon - $^ {dy-shown dy-shown} - $% {%ur cord} - {%sa mark} - {%as mark dy-shown} - {%do hoon dy-shown} - {%te term (list dy-shown)} - {%ge path (list dy-shown) (map term (unit dy-shown))} - {%dv path} + $^ [dy-shown dy-shown] + $% [%ur cord] + [%sa mark] + [%as mark dy-shown] + [%do hoon dy-shown] + [%te term (list dy-shown)] + [%ge path (list dy-shown) (map term (unit dy-shown))] + [%dv path] == == :: ++ dy-show-source |= a=dojo-source ^- tank =- >[-]< - =+ `{@ bil=dojo-build}`a + =+ `[@ bil=dojo-build]`a |- ^- dy-shown ?- -.bil $?(%ur %dv %sa) bil - %ex ?. ?=({%cltr *} p.bil) p.bil + %ex ?. ?=([%cltr *] p.bil) p.bil |- ^- hoon ?~ p.p.bil !! ?~ t.p.p.bil i.p.p.bil @@ -742,7 +742,7 @@ ?. (~(nest ut [%cell [%atom %$ ~] %noun]) | p.q.cay) :: naked generator; takes one argument :: - ?. &(?=({* ~} p.cig) ?=(~ q.cig)) + ?. &(?=([* ~] p.cig) ?=(~ q.cig)) ~|(%one-argument !!) =/ res (mule |.((slam q.cay (dy-vase p.i.p.cig)))) ?: ?=(%| -.res) @@ -903,7 +903,7 @@ ?.(=(gen -) $(gen -) gen) |= gen=hoon ^- (unit cage) =. gen (ope gen) - ?: ?=({%cnts {@ ~} ~} gen) + ?: ?=([%cnts [@ ~] ~] gen) (~(get by var) i.p.gen) ~ :: +dy-mere: execute hoon and complete construction step @@ -993,7 +993,7 @@ he-prom:he-pone :: ++ he-errd :: reject update - |= {rev=(unit sole-edit) err=@u} ^+ +> + |= [rev=(unit sole-edit) err=@u] ^+ +> =+ red=(fall rev [%nop ~]) :: required for error location sync =^ lic say (~(transmit sole say) red) (he-diff %mor [%det lic] [%err err] ~) @@ -1034,7 +1034,7 @@ == :: ++ he-unto :: result from agent - |= {way=wire cit=sign:agent:gall} + |= [way=wire cit=sign:agent:gall] ^+ +> ?. ?=(%poke-ack -.cit) ~& [%strange-unto cit] @@ -1087,8 +1087,8 @@ %. [%httr !>((to-httr:iris response-header.response full-file.response))] =+ dye=~(. dy u.poy(pux ~)) ?+ way !! - {%hand ~} dy-hand:dye - {%show ~} dy-show:dye + [%hand ~] dy-hand:dye + [%show ~] dy-show:dye == :: ++ he-lens @@ -1443,7 +1443,7 @@ == :: ++ he-lame :: handle error - |= {wut=term why=tang} + |= [wut=term why=tang] ^+ +> %- (slog (flop `tang`[>%dojo-lame wut< why])) ?^ poy @@ -1460,10 +1460,10 @@ :: ^- cage :- %noun - =+ sloop=|=({a=vase b=vase} ?:(=(*vase a) b ?:(=(*vase b) a (slop a b)))) + =+ sloop=|=([a=vase b=vase] ?:(=(*vase a) b ?:(=(*vase b) a (slop a b)))) %+ sloop %- ~(rep by var) - |= {{a=term @ b=vase} c=vase} ^- vase + |= [[a=term @ b=vase] c=vase] ^- vase (sloop b(p face+[a p.b]) c) !>([our=our now=now eny=eny]:hid) -- diff --git a/pkg/arvo/gen/cat.hoon b/pkg/arvo/gen/cat.hoon index c9b53de8f3..01a407cac9 100644 --- a/pkg/arvo/gen/cat.hoon +++ b/pkg/arvo/gen/cat.hoon @@ -8,7 +8,7 @@ :::: :: :- %say -|= {^ {arg=(list path)} vane=?(%g %c)} +|= [^ [arg=(list path)] vane=?(%g %c)] =- tang+(flop `tang`(zing -)) %+ turn arg |= pax=path @@ -22,7 +22,7 @@ ~ [rose+[" " `~]^~[leaf+"~" (smyt pax)]]~ :: - {{@t ~} ~ ~} + [[@t ~] ~ ~] $(pax (welp pax /[p.n.dir.ark])) :: * diff --git a/pkg/arvo/gen/code.hoon b/pkg/arvo/gen/code.hoon index 4f8c054038..73c044f999 100644 --- a/pkg/arvo/gen/code.hoon +++ b/pkg/arvo/gen/code.hoon @@ -3,7 +3,7 @@ :::: /hoon/code/gen :: :- %say -|= $: {now=@da eny=@uvJ bec=beak} +|= $: [now=@da eny=@uvJ bec=beak] ~ ~ == diff --git a/pkg/arvo/gen/deco.hoon b/pkg/arvo/gen/deco.hoon index 02494f77ca..9af8d13e5a 100644 --- a/pkg/arvo/gen/deco.hoon +++ b/pkg/arvo/gen/deco.hoon @@ -37,8 +37,8 @@ :: with {a}. use this convention only for one-liners, etc. :: :: the file below is a medium-sized generator, built around -:: a typical two-core structure. the cores are labeled {%arch} -:: (structures) and {%work} (productions). this is canonical. +:: a typical two-core structure. the cores are labeled [%arch} +:: (structures) and [%work} (productions). this is canonical. :: :: this code is written to display the variety of formatting :: options the parser allows. a specific convention should pick diff --git a/pkg/arvo/gen/hello.hoon b/pkg/arvo/gen/hello.hoon index 68065d0f78..e5f5a5cd8c 100644 --- a/pkg/arvo/gen/hello.hoon +++ b/pkg/arvo/gen/hello.hoon @@ -8,6 +8,6 @@ :::: :: :- %say -|= {^ {{txt=@tas ~} ~}} +|= [^ [[txt=@tas ~] ~]] :- %noun (crip (weld "hello, " (trip txt))) diff --git a/pkg/arvo/gen/help.hoon b/pkg/arvo/gen/help.hoon index 28a17c77b8..2116568b08 100644 --- a/pkg/arvo/gen/help.hoon +++ b/pkg/arvo/gen/help.hoon @@ -16,13 +16,13 @@ ['-' $(a t.a)] :: ++ rend - |= {a=@thoon b=path} ^- tank + |= [a=@thoon b=path] ^- tank =; c=(pair tape tape) =/ tab (sub 10 (mod (lent "{p.c} ") 10)) [%palm [" {(reap tab ' ')}" ``~] leaf+p.c leaf+q.c ~] :- ?- b ~ "/" :: XX !! maybe? - {%hood ^} "|{(path-heps t.b)}" + [%hood ^] "|{(path-heps t.b)}" ^ "+{(path-heps b)}" :: XX deal with :graph-store|foo == =/ c (to-wain:format a) @@ -32,16 +32,16 @@ (trip i.c) :: ++ read-at - |= {len=@u pax=path} - |= {nam=@t ark=arch} ^- (unit {@t path}) + |= [len=@u pax=path] + |= [nam=@t ark=arch] ^- (unit [@t path]) ?. (~(has by dir.ark) %hoon) ~ %+ bind (file:space:userlib (welp pax /[nam]/hoon)) - |= a=* ^- {cord path} + |= a=* ^- [cord path] [;;(@t a) (welp (slag len pax) /[nam])] -- :: :- %say -|= {{now=time @ our=ship ^} typ=$@(~ {p=term ~}) ~} +|= [[now=time @ our=ship ^] typ=$@(~ [p=term ~]) ~] =/ pax=path /(scot %p our)/home/(scot %da now)/gen :: XX hardcoded =+ len=(lent pax) =. pax ?~(typ pax (welp pax /[p.typ])) @@ -53,12 +53,12 @@ (drop (bind red rend)) |- ^- tang =+ =< arl=~(tap by (~(urn by dir.ark) .)) - |=({a=@t ~} .^(arch cy+(welp pax /[a]))) + |=([a=@t ~] .^(arch cy+(welp pax /[a]))) %+ welp - =/ dir=(list {@ path}) + =/ dir=(list [@ path]) (murn arl (read-at len pax)) `tang`(turn (sort dir aor) rend) %- zing ^- (list tang) %+ turn (sort arl aor) -|= {a=@t b=arch} +|= [a=@t b=arch] ^$(pax (welp pax /[a]), ark b) diff --git a/pkg/arvo/gen/hood/autocommit.hoon b/pkg/arvo/gen/hood/autocommit.hoon index 01bbe5b234..c01a22997c 100644 --- a/pkg/arvo/gen/hood/autocommit.hoon +++ b/pkg/arvo/gen/hood/autocommit.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now=@da eny=@uvJ bec=beak} - {mon=term ~} +|= $: [now=@da eny=@uvJ bec=beak] + [mon=term ~] ~ == :- %kiln-commit diff --git a/pkg/arvo/gen/hood/breload.hoon b/pkg/arvo/gen/hood/breload.hoon index 8b087e65fe..5b9df1d724 100644 --- a/pkg/arvo/gen/hood/breload.hoon +++ b/pkg/arvo/gen/hood/breload.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now=@da eny=@uvJ bec=beak} - {arg=(list term) ~} +|= $: [now=@da eny=@uvJ bec=beak] + [arg=(list term) ~] == :+ %helm-reload-desk %base arg diff --git a/pkg/arvo/gen/hood/commit.hoon b/pkg/arvo/gen/hood/commit.hoon index cbe0c1016d..3c1ac5c458 100644 --- a/pkg/arvo/gen/hood/commit.hoon +++ b/pkg/arvo/gen/hood/commit.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now=@da eny=@uvJ bec=beak} - {mon=term ~} +|= $: [now=@da eny=@uvJ bec=beak] + [mon=term ~] auto=_| == :- %kiln-commit diff --git a/pkg/arvo/gen/hood/cp.hoon b/pkg/arvo/gen/hood/cp.hoon index 0e7d2f9090..d4a0444a84 100644 --- a/pkg/arvo/gen/hood/cp.hoon +++ b/pkg/arvo/gen/hood/cp.hoon @@ -5,7 +5,7 @@ /? 310 :- %say =, space:userlib -|= {^ {input=path output=path ~} ~} +|= [^ [input=path output=path ~] ~] :- %kiln-info ?. =(-:(flop input) -:(flop output)) ["Can't move to a different mark" ~] diff --git a/pkg/arvo/gen/hood/exit.hoon b/pkg/arvo/gen/hood/exit.hoon index 92a4dfb8d4..20233a4ce5 100644 --- a/pkg/arvo/gen/hood/exit.hoon +++ b/pkg/arvo/gen/hood/exit.hoon @@ -9,8 +9,8 @@ :: =, sole :- %say -|= $: {now=@da eny=@ bec=beak} - {~ ~} +|= $: [now=@da eny=@ bec=beak] + [~ ~] == ~& %drum-exit [%drum-exit ~] diff --git a/pkg/arvo/gen/hood/hi.hoon b/pkg/arvo/gen/hood/hi.hoon index 7530f6069e..ce1c263548 100644 --- a/pkg/arvo/gen/hood/hi.hoon +++ b/pkg/arvo/gen/hood/hi.hoon @@ -4,4 +4,4 @@ :: /? 310 :- %say -|=({^ {who=ship mez=$@(~ {a=tape ~})} ~} helm-send-hi+[who ?~(mez ~ `a.mez)]) +|=([^ [who=ship mez=$@(~ [a=tape ~])] ~] helm-send-hi+[who ?~(mez ~ `a.mez)]) diff --git a/pkg/arvo/gen/hood/init-oauth2.hoon b/pkg/arvo/gen/hood/init-oauth2.hoon index 8fc9fb9bf3..770ebff0ff 100644 --- a/pkg/arvo/gen/hood/init-oauth2.hoon +++ b/pkg/arvo/gen/hood/init-oauth2.hoon @@ -10,11 +10,11 @@ :: =, generators :- %ask -|= $: {now=@da eny=@uvJ bec=beak} - {arg=$@(~ {dom=path ~})} +|= $: [now=@da eny=@uvJ bec=beak] + [arg=$@(~ [dom=path ~])] ~ == -^- (sole-result:sole {%write-sec-atom p=host:eyre q=@}) +^- (sole-result:sole [%write-sec-atom p=host:eyre q=@]) =- ?~ arg - (fun.q.q [%& dom.arg]) %+ prompt diff --git a/pkg/arvo/gen/hood/init-oauth2/google.hoon b/pkg/arvo/gen/hood/init-oauth2/google.hoon index e95e022df6..ca3b4de3a9 100644 --- a/pkg/arvo/gen/hood/init-oauth2/google.hoon +++ b/pkg/arvo/gen/hood/init-oauth2/google.hoon @@ -12,11 +12,11 @@ =, html =, format :- %ask -|= $: {now=@da eny=@uvJ bec=beak} - {arg=$@(~ {jon=json ~})} +|= $: [now=@da eny=@uvJ bec=beak] + [arg=$@(~ [jon=json ~])] ~ == -^- (sole-result:sole {%write-sec-atom p=host:eyre q=@}) +^- (sole-result:sole [%write-sec-atom p=host:eyre q=@]) %+ print leaf+"Accepting credentials for https://*.googleapis.com" =+ hot=[%& /com/googleapis] =- ?~ arg - @@ -26,7 +26,7 @@ %+ parse apex:de-json |= jon=json =+ ~| bad-json+jon - =- `{cid=@t cis=@t}`(need (rep jon)) + =- `[cid=@t cis=@t]`(need (rep jon)) rep=(ot web+(ot 'client_id'^so 'client_secret'^so ~) ~):dejs-soft:format %+ produce %write-sec-atom :: XX typed pair [hot (of-wain:format cid cis ~)] diff --git a/pkg/arvo/gen/hood/label.hoon b/pkg/arvo/gen/hood/label.hoon index a0550b8b6f..6be85cb88e 100644 --- a/pkg/arvo/gen/hood/label.hoon +++ b/pkg/arvo/gen/hood/label.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now=@da eny=@uvJ bec=beak} - {arg={syd=desk lab=@tas ~} ~} +|= $: [now=@da eny=@uvJ bec=beak] + [arg=[syd=desk lab=@tas ~] ~] == :- %kiln-label [syd lab]:arg diff --git a/pkg/arvo/gen/hood/link.hoon b/pkg/arvo/gen/hood/link.hoon index 5d64ca4f87..5fe183279b 100644 --- a/pkg/arvo/gen/hood/link.hoon +++ b/pkg/arvo/gen/hood/link.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now=@da eny=@uvJ byk=beak} - {arg=$?({dap=term ~} {who=ship dap=term ~}) ~} +|= $: [now=@da eny=@uvJ byk=beak] + [arg=$?([dap=term ~] [who=ship dap=term ~]) ~] == :- %drum-link ?~ +.arg diff --git a/pkg/arvo/gen/hood/mass.hoon b/pkg/arvo/gen/hood/mass.hoon index 032ef5f987..b086df2de3 100644 --- a/pkg/arvo/gen/hood/mass.hoon +++ b/pkg/arvo/gen/hood/mass.hoon @@ -7,7 +7,7 @@ :::: :: :- %say -|= $: {now=@da eny=@uvJ bec=beak} - {arg=~ ~} +|= $: [now=@da eny=@uvJ bec=beak] + [arg=~ ~] == [%helm-mass ~] diff --git a/pkg/arvo/gen/hood/merge.hoon b/pkg/arvo/gen/hood/merge.hoon index c8ff7bb994..eb4d1de084 100644 --- a/pkg/arvo/gen/hood/merge.hoon +++ b/pkg/arvo/gen/hood/merge.hoon @@ -7,38 +7,38 @@ =, clay :: |% -++ beaky {knot knot knot ~} -++ sorc ?({bek=beaky ~} {her=@p sud=@tas ~}) ++$ beaky [knot knot knot ~] ++$ sorc ?([bek=beaky ~] [her=@p sud=@tas ~]) -- :: :::: :: :- %say -|= $: {now=@da eny=@uvJ bek=beak} - {arg={?(~ sorc {syd=$@(desk beaky) sorc})} cas=case gem=?(germ %auto)} +|= $: [now=@da eny=@uvJ bek=beak] + [arg=[?(~ sorc [syd=$@(desk beaky) sorc])] cas=case gem=?(germ %auto)] == =* our p.bek |^ :- %kiln-merge - ^- $@(~ {syd=desk her=ship sud=desk cas=case gem=?(germ %auto)}) + ^- $@(~ [syd=desk her=ship sud=desk cas=case gem=?(germ %auto)]) ?- arg ~ ((slog (turn help-text |=(=@t leaf+(trip t)))) ~) - {@ @ ~} + [@ @ ~] =+(arg [sud ?.(=(our her) her (sein:title p.bek now her)) sud (opt-case da+now) gem]) :: - {^ ~} + [^ ~] =+ (pars bek.arg) [dez ?.(=(our who) who (sein:title p.bek now who)) dez (opt-case caz) gem] :: - {* @ @ ~} + [* @ @ ~] :- (pars-src syd.arg) =+(arg [her sud (opt-case da+now) gem]) :: - {* ^ ~} + [* ^ ~] :- (pars-src syd.arg) =+((pars bek.arg) [who dez (opt-case caz) gem]) == ++ opt-case |=(a=case ?:(=(*case cas) a cas)) :: override -++ pars |=(a=beaky `{{who=ship dez=desk caz=case} *}`(need (de-beam:format a))) +++ pars |=(a=beaky `[[who=ship dez=desk caz=case] *]`(need (de-beam:format a))) ++ pars-src |= syd=$@(desk beaky) ?@ syd syd diff --git a/pkg/arvo/gen/hood/moon-breach.hoon b/pkg/arvo/gen/hood/moon-breach.hoon index 536dc651c5..0b60e8c8bb 100644 --- a/pkg/arvo/gen/hood/moon-breach.hoon +++ b/pkg/arvo/gen/hood/moon-breach.hoon @@ -16,7 +16,7 @@ ^- (unit [=ship =udiff:point:able:jael]) =* our p.bec =/ ran (clan:title our) -?: ?=({?(%earl %pawn)} ran) +?: ?=([?(%earl %pawn)] ran) %- %- slog :_ ~ leaf+"can't manage a moon from a {?:(?=(%earl ran) "moon" "comet")}" ~ diff --git a/pkg/arvo/gen/hood/moon-cycle-keys.hoon b/pkg/arvo/gen/hood/moon-cycle-keys.hoon index 5f8f12493f..74c938d2f5 100644 --- a/pkg/arvo/gen/hood/moon-cycle-keys.hoon +++ b/pkg/arvo/gen/hood/moon-cycle-keys.hoon @@ -17,7 +17,7 @@ ^- (unit [=ship =udiff:point:able:jael]) =* our p.bec =/ ran (clan:title our) -?: ?=({?(%earl %pawn)} ran) +?: ?=([?(%earl %pawn)] ran) %- %- slog :_ ~ leaf+"can't manage a moon from a {?:(?=(%earl ran) "moon" "comet")}" ~ diff --git a/pkg/arvo/gen/hood/moon.hoon b/pkg/arvo/gen/hood/moon.hoon index df32937210..9520b8b182 100644 --- a/pkg/arvo/gen/hood/moon.hoon +++ b/pkg/arvo/gen/hood/moon.hoon @@ -16,7 +16,7 @@ ^- (unit [=ship =udiff:point:able:jael]) =* our p.bec =/ ran (clan:title our) -?: ?=({?(%earl %pawn)} ran) +?: ?=([?(%earl %pawn)] ran) %- %- slog :_ ~ leaf+"can't create a moon from a {?:(?=(%earl ran) "moon" "comet")}" ~ diff --git a/pkg/arvo/gen/hood/mount.hoon b/pkg/arvo/gen/hood/mount.hoon index d0bfae650f..85f0292070 100644 --- a/pkg/arvo/gen/hood/mount.hoon +++ b/pkg/arvo/gen/hood/mount.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now=@da eny=@uvJ bec=beak} - {{pax=path pot=$@(~ {v=@tas ~})} ~} +|= $: [now=@da eny=@uvJ bec=beak] + [[pax=path pot=$@(~ [v=@tas ~])] ~] == ?~ pot =+ bem=(need (de-beam:format pax)) diff --git a/pkg/arvo/gen/hood/mv.hoon b/pkg/arvo/gen/hood/mv.hoon index 282c3cb216..2a0f5a671e 100644 --- a/pkg/arvo/gen/hood/mv.hoon +++ b/pkg/arvo/gen/hood/mv.hoon @@ -5,7 +5,7 @@ /? 310 =, space:userlib :- %say -|= {^ {input=path output=path ~} ~} +|= [^ [input=path output=path ~] ~] :- %kiln-info ?. =(-:(flop input) -:(flop output)) ["Can't move to a different mark" ~] diff --git a/pkg/arvo/gen/hood/pack.hoon b/pkg/arvo/gen/hood/pack.hoon index 0e043a05f8..732d872ba1 100644 --- a/pkg/arvo/gen/hood/pack.hoon +++ b/pkg/arvo/gen/hood/pack.hoon @@ -7,7 +7,7 @@ :::: :: :- %say -|= $: {now=@da eny=@uvJ bec=beak} - {arg=~ ~} +|= $: [now=@da eny=@uvJ bec=beak] + [arg=~ ~] == [%helm-pack ~] diff --git a/pkg/arvo/gen/hood/ping.hoon b/pkg/arvo/gen/hood/ping.hoon index da3c2298f7..2b66e97e47 100644 --- a/pkg/arvo/gen/hood/ping.hoon +++ b/pkg/arvo/gen/hood/ping.hoon @@ -4,8 +4,8 @@ :: /? 310 :- %say -|= $: {now=@da eny=@ bec=beak} - {{exp=@ud ~} ~} +|= $: [now=@da eny=@ bec=beak] + [[exp=@ud ~] ~] == =+ rab=(~(raw og eny) (bex exp)) ~& [%random-bytes (met 3 rab) `@p`(mug rab)] diff --git a/pkg/arvo/gen/hood/private.hoon b/pkg/arvo/gen/hood/private.hoon index 87a4f2b3e0..8258d1a90f 100644 --- a/pkg/arvo/gen/hood/private.hoon +++ b/pkg/arvo/gen/hood/private.hoon @@ -3,8 +3,8 @@ :::: /gen/hood/private/hoon :: :- %say -|= $: {now=@da eny=@uvJ bec=beak} - {arg={des=desk may=?(~ {pax=path ~})} ~} +|= $: [now=@da eny=@uvJ bec=beak] + [arg=[des=desk may=?(~ [pax=path ~])] ~] == :- %kiln-permission [des ?~(may / pax.may) |]:arg diff --git a/pkg/arvo/gen/hood/public.hoon b/pkg/arvo/gen/hood/public.hoon index 973272df4f..f513caf085 100644 --- a/pkg/arvo/gen/hood/public.hoon +++ b/pkg/arvo/gen/hood/public.hoon @@ -3,8 +3,8 @@ :::: /gen/hood/public/hoon :: :- %say -|= $: {now=@da eny=@uvJ bec=beak} - {arg={des=desk may=?(~ {pax=path ~})} ~} +|= $: [now=@da eny=@uvJ bec=beak] + [arg=[des=desk may=?(~ [pax=path ~])] ~] == :- %kiln-permission [des ?~(may / pax.may) &]:arg diff --git a/pkg/arvo/gen/hood/rc.hoon b/pkg/arvo/gen/hood/rc.hoon index 3c03fa0ea0..feaed17ab4 100644 --- a/pkg/arvo/gen/hood/rc.hoon +++ b/pkg/arvo/gen/hood/rc.hoon @@ -7,7 +7,7 @@ :::: :: :- %say -|= $: {now=@da eny=@uvJ bec=beak} - {arg=~ ~} +|= $: [now=@da eny=@uvJ bec=beak] + [arg=~ ~] == [%helm-reload ~[%c]] diff --git a/pkg/arvo/gen/hood/reboot.hoon b/pkg/arvo/gen/hood/reboot.hoon index 30468bcddd..aa48d85cb3 100644 --- a/pkg/arvo/gen/hood/reboot.hoon +++ b/pkg/arvo/gen/hood/reboot.hoon @@ -7,7 +7,7 @@ :::: :: :- %say -|= $: {now=@da eny=@uvJ bec=beak} - {arg=~ ~} +|= $: [now=@da eny=@uvJ bec=beak] + [arg=~ ~] == [%helm-reload ~[%z %a %b %c %d %e %g %i %j]] diff --git a/pkg/arvo/gen/hood/reload-desk.hoon b/pkg/arvo/gen/hood/reload-desk.hoon index eb152dd75b..c242a2da17 100644 --- a/pkg/arvo/gen/hood/reload-desk.hoon +++ b/pkg/arvo/gen/hood/reload-desk.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now=@da eny=@uvJ bec=beak} - {arg={desk (list term)} ~} +|= $: [now=@da eny=@uvJ bec=beak] + [arg=[desk (list term)] ~] == :- %helm-reload-desk arg diff --git a/pkg/arvo/gen/hood/reload.hoon b/pkg/arvo/gen/hood/reload.hoon index 10207233e3..d22ea1b523 100644 --- a/pkg/arvo/gen/hood/reload.hoon +++ b/pkg/arvo/gen/hood/reload.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now=@da eny=@uvJ bec=beak} - {arg=(list term) ~} +|= $: [now=@da eny=@uvJ bec=beak] + [arg=(list term) ~] == :- %helm-reload arg diff --git a/pkg/arvo/gen/hood/reset.hoon b/pkg/arvo/gen/hood/reset.hoon index d063e9747c..0e15ce59fa 100644 --- a/pkg/arvo/gen/hood/reset.hoon +++ b/pkg/arvo/gen/hood/reset.hoon @@ -7,7 +7,7 @@ :::: :: :- %say -|= $: {now=@da eny=@uvJ bec=beak} - {arg=~ ~} +|= $: [now=@da eny=@uvJ bec=beak] + [arg=~ ~] == [%helm-reset ~] diff --git a/pkg/arvo/gen/hood/rm.hoon b/pkg/arvo/gen/hood/rm.hoon index fce64a1ecb..a60a6f2b2b 100644 --- a/pkg/arvo/gen/hood/rm.hoon +++ b/pkg/arvo/gen/hood/rm.hoon @@ -4,4 +4,4 @@ :: /? 310 :- %say -|=({^ {input=path ~} ~} kiln-rm+input) +|=([^ [input=path ~] ~] kiln-rm+input) diff --git a/pkg/arvo/gen/hood/schedule.hoon b/pkg/arvo/gen/hood/schedule.hoon index 3e71dad53f..281b7ec64e 100644 --- a/pkg/arvo/gen/hood/schedule.hoon +++ b/pkg/arvo/gen/hood/schedule.hoon @@ -4,4 +4,4 @@ :: /? 310 :- %say -|=({^ {where=path tym=@da eve=@t ~} ~} kiln-schedule+[where tym eve]) +|=([^ [where=path tym=@da eve=@t ~] ~] kiln-schedule+[where tym eve]) diff --git a/pkg/arvo/gen/hood/start.hoon b/pkg/arvo/gen/hood/start.hoon index db3fcc93ac..2949d00443 100644 --- a/pkg/arvo/gen/hood/start.hoon +++ b/pkg/arvo/gen/hood/start.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now=@da eny=@uvJ bec=beak} - {arg={@ $@(~ {@ ~})} ~} +|= $: [now=@da eny=@uvJ bec=beak] + [arg=[@ $@(~ [@ ~])] ~] == :- %drum-start ?> ((sane %tas) -.arg) diff --git a/pkg/arvo/gen/hood/sync.hoon b/pkg/arvo/gen/hood/sync.hoon index 251f30f843..702165ae57 100644 --- a/pkg/arvo/gen/hood/sync.hoon +++ b/pkg/arvo/gen/hood/sync.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now=@da eny=@uvJ bec=beak} - {arg={syd=@tas her=@p sud=@tas ~} ~} +|= $: [now=@da eny=@uvJ bec=beak] + [arg=[syd=@tas her=@p sud=@tas ~] ~] == :- %kiln-sync [syd her sud]:arg diff --git a/pkg/arvo/gen/hood/syncs.hoon b/pkg/arvo/gen/hood/syncs.hoon index 3c707f5a61..6e90e36445 100644 --- a/pkg/arvo/gen/hood/syncs.hoon +++ b/pkg/arvo/gen/hood/syncs.hoon @@ -7,5 +7,5 @@ :::: :: :- %say -|= {{now=@da eny=@uvJ bec=beak} ~ ~} +|= [[now=@da eny=@uvJ bec=beak] ~ ~] [%kiln-syncs ~] diff --git a/pkg/arvo/gen/hood/track.hoon b/pkg/arvo/gen/hood/track.hoon index 0bb77aa044..49c77771f8 100644 --- a/pkg/arvo/gen/hood/track.hoon +++ b/pkg/arvo/gen/hood/track.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now=@da eny=@uvJ bec=beak} - {arg={syd=@tas her=@p sud=@tas ~} ~} +|= $: [now=@da eny=@uvJ bec=beak] + [arg=[syd=@tas her=@p sud=@tas ~] ~] == :- %kiln-track [syd her sud]:arg diff --git a/pkg/arvo/gen/hood/unlink.hoon b/pkg/arvo/gen/hood/unlink.hoon index f21aa729df..d7bc509b00 100644 --- a/pkg/arvo/gen/hood/unlink.hoon +++ b/pkg/arvo/gen/hood/unlink.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now=@da eny=@uvJ byk=beak} - {arg=$?({dap=term ~} {who=ship dap=term ~}) ~} +|= $: [now=@da eny=@uvJ byk=beak] + [arg=$?([dap=term ~] [who=ship dap=term ~]) ~] == :- %drum-unlink ?~ +.arg diff --git a/pkg/arvo/gen/hood/unmount.hoon b/pkg/arvo/gen/hood/unmount.hoon index 98c32b4602..9219053d71 100644 --- a/pkg/arvo/gen/hood/unmount.hoon +++ b/pkg/arvo/gen/hood/unmount.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now=@da eny=@uvJ bec=beak} - {{mon=$@(term {knot path}) ~} ~} +|= $: [now=@da eny=@uvJ bec=beak] + [[mon=$@(term [knot path]) ~] ~] == :- %kiln-unmount mon diff --git a/pkg/arvo/gen/hood/unsync.hoon b/pkg/arvo/gen/hood/unsync.hoon index 19611053e1..4ab9e0d84c 100644 --- a/pkg/arvo/gen/hood/unsync.hoon +++ b/pkg/arvo/gen/hood/unsync.hoon @@ -7,8 +7,8 @@ :::: :: :- %say -|= $: {now=@da eny=@uvJ bec=beak} - {arg={syd=@tas her=@p sud=@tas ~} ~} +|= $: [now=@da eny=@uvJ bec=beak] + [arg=[syd=@tas her=@p sud=@tas ~] ~] == :- %kiln-unsync [syd her sud]:arg diff --git a/pkg/arvo/gen/hood/verb.hoon b/pkg/arvo/gen/hood/verb.hoon index b4bf423384..a83597150d 100644 --- a/pkg/arvo/gen/hood/verb.hoon +++ b/pkg/arvo/gen/hood/verb.hoon @@ -9,8 +9,8 @@ :: =, sole :- %say -|= $: {now=@da eny=@ bec=beak} - {~ ~} +|= $: [now=@da eny=@ bec=beak] + [~ ~] == ~& %helm-verb [%helm-verb ~] diff --git a/pkg/arvo/gen/ls.hoon b/pkg/arvo/gen/ls.hoon index c851a00344..676522bd28 100644 --- a/pkg/arvo/gen/ls.hoon +++ b/pkg/arvo/gen/ls.hoon @@ -9,6 +9,6 @@ :: ~& % :- %say -|= {^ {arg=path ~} vane=?(%g %c)} +|= [^ [arg=path ~] vane=?(%g %c)] =+ lon=.^(arch (cat 3 vane %y) arg) tang+[?~(dir.lon leaf+"~" (show-dir vane arg dir.lon))]~ diff --git a/pkg/arvo/lib/chat-store.hoon b/pkg/arvo/lib/chat-store.hoon index 63cb2d688e..694531ea61 100644 --- a/pkg/arvo/lib/chat-store.hoon +++ b/pkg/arvo/lib/chat-store.hoon @@ -168,7 +168,7 @@ (cu (cury slav %uv) so) :: ++ re :: recursive reparsers - |* {gar=* sef=_|.(fist:dejs-soft:format)} + |* [gar=* sef=_|.(fist:dejs-soft:format)] |= jon=json ^- (unit _gar) =- ~! gar ~! (need -) - diff --git a/pkg/arvo/lib/contact-json.hoon b/pkg/arvo/lib/contact-json.hoon index d3c04d4163..b96040652e 100644 --- a/pkg/arvo/lib/contact-json.hoon +++ b/pkg/arvo/lib/contact-json.hoon @@ -3,7 +3,7 @@ |% ++ nu :: parse number as hex |= jon=json - ?> ?=({%s *} jon) + ?> ?=([%s *] jon) (rash p.jon hex) :: ++ hook-update-to-json diff --git a/pkg/arvo/lib/cram.hoon b/pkg/arvo/lib/cram.hoon index bc35fbb041..dbec8f7b41 100644 --- a/pkg/arvo/lib/cram.hoon +++ b/pkg/arvo/lib/cram.hoon @@ -1,6 +1,6 @@ |% ++ static :: freeze .mdh hoon subset - |= gen=hoon ^- {inf=(map term dime) elm=manx} + |= gen=hoon ^- [inf=(map term dime) elm=manx] ?+ -.gen =/ gen ~(open ap gen) ?: =(gen ^gen) ~|([%cram-dynamic -.gen] !!) @@ -12,11 +12,11 @@ :: ++ single :: unwrap one-elem marl |= xml=marl ^- manx - ?: ?=({* ~} xml) i.xml + ?: ?=([* ~] xml) i.xml ~|(%many-elems !!) :: ++ shut-mart :: xml attrs - |=({n=mane v=(list beer:hoot)} [n (turn v |=(a=beer:hoot ?^(a !! a)))]) + |=([n=mane v=(list beer:hoot)] [n (turn v |=(a=beer:hoot ?^(a !! a)))]) :: ++ shut :: as xml constant |= gen=hoon ^- marl @@ -39,8 +39,8 @@ :: :: ++ frontmatter :: parse ~[[%foo 1] [%bar ~s2]] - |= gen=hoon ^- (list {term dime}) - ?: ?=({%bust %null} gen) ~ + |= gen=hoon ^- (list [term dime]) + ?: ?=([%bust %null] gen) ~ ?: ?=(%dbug -.gen) $(gen q.gen) ?. ?=(%clsg -.gen) ~|([%bad-frontmatter -.gen] !!) %+ turn p.gen @@ -56,6 +56,6 @@ ++ as-dime :: %foo ~.foo 0vbar etc |= gen=hoon ^- dime ?: ?=(%dbug -.gen) $(gen q.gen) - ?. ?=({?(%rock %sand) @ @} gen) ~|([%bad-literal gen] !!) + ?. ?=([?(%rock %sand) @ @] gen) ~|([%bad-literal gen] !!) +.gen -- diff --git a/pkg/arvo/lib/elem-to-react-json.hoon b/pkg/arvo/lib/elem-to-react-json.hoon index c7e40d243f..77b4b1ca26 100644 --- a/pkg/arvo/lib/elem-to-react-json.hoon +++ b/pkg/arvo/lib/elem-to-react-json.hoon @@ -28,7 +28,7 @@ :: special handling for
foo
++ urb-codemirror :: render code blocks |= src=manx ^- manx - ?> ?=({{%pre *} _;/(**) ~} src) + ?> ?=([[%pre *] _;/(**) ~] src) ;codemirror(value "{v.i.a.g.i.c.src}"); :: ++ elem-to-react-json :: serialize DOM as json @@ -42,7 +42,7 @@ c+a+(turn c.src ..$) gn+s+(mane-to-cord n.g.src) =< ga+(pairs:enjs (turn a.g.src .)) - |= {a=mane b=tape} ^- {cord json} + |= [a=mane b=tape] ^- [cord json] :_ (tape:enjs b) ?^ a (mane-to-cord a) (~(gut by react-attrs) a a) diff --git a/pkg/arvo/lib/frontmatter.hoon b/pkg/arvo/lib/frontmatter.hoon index dbde019064..f74f18d106 100644 --- a/pkg/arvo/lib/frontmatter.hoon +++ b/pkg/arvo/lib/frontmatter.hoon @@ -7,13 +7,13 @@ |% ++ atr-lines |= atr=(map cord cord) - %+ turn (sort ~(tap by atr) |=({{a=@ @} {b=@ @}} (aor a b))) - |= {k=cord v=cord} + %+ turn (sort ~(tap by atr) |=([[a=@ @] [b=@ @]] (aor a b))) + |= [k=cord v=cord] (rap 3 k ': ' v ~) :: ++ atr-key ;~(sfix (star ;~(less col prn)) col ace) ++ print - |= {atr=(map cord cord) src=wain} + |= [atr=(map cord cord) src=wain] ?~ atr src ['---' (welp (atr-lines atr) '---' src)] ++ parse @@ -30,6 +30,6 @@ $(wan t.wan) =- $(wan t.wan, atr (~(put by atr) (crip key) (crip val))) ~| malformed-attribute+i.t.wan - ^- {key=tape ^ val=tape} + ^- [key=tape ^ val=tape] +>:(atr-key 1^1 (trip i.t.wan)) -- diff --git a/pkg/arvo/lib/generators.hoon b/pkg/arvo/lib/generators.hoon index 5bdc9301d9..13585ab68e 100644 --- a/pkg/arvo/lib/generators.hoon +++ b/pkg/arvo/lib/generators.hoon @@ -6,17 +6,17 @@ [p=*(list tank) q=[%& p=[~ u=pro]]] :: :: :: ++ print :: add output tank - |* {tan=tank res=(sole-result)} :: + |* [tan=tank res=(sole-result)] :: ?@ res res :: [p=[i=tan t=p.res] q=q.res] :: :: :: ++ prompt :: construct prompt - |* {pom=sole-prompt mor=(sole-dialog)} :: + |* [pom=sole-prompt mor=(sole-dialog)] :: [p=*(list tank) q=[%| p=pom q=mor]] :: :: :: ++ curl :: fetch url =| usr=knot :: - |* {pul=_purl:eyre fun=$-(httr:eyre *)} :: + |* [pul=_purl:eyre fun=$-(httr:eyre *)] :: :- p=*(list tank) :: q=[%| p=`usr q=[pul %get ~ ~] r=fun] :: :: :: @@ -24,7 +24,7 @@ [p=*(list tank) q=[%& ~]] :: :: :: ++ parse :: parse by rule - |* {sef=rule fun=$-(* *)} :: + |* [sef=rule fun=$-(* *)] :: |= txt=sole-input :: =+ vex=(sef [0 0] txt) :: ?: |(!=((lent txt) q.p.vex) ?=(~ q.vex)) :: diff --git a/pkg/arvo/lib/graph-store.hoon b/pkg/arvo/lib/graph-store.hoon index 4e54caf4e8..3b64e9b8c7 100644 --- a/pkg/arvo/lib/graph-store.hoon +++ b/pkg/arvo/lib/graph-store.hoon @@ -8,11 +8,11 @@ :: NOTE: move these functions to zuse ++ nu :: parse number as hex |= jon=json - ?> ?=({%s *} jon) + ?> ?=([%s *] jon) (rash p.jon hex) :: ++ re :: recursive reparsers - |* {gar=* sef=_|.(fist:dejs-soft:format)} + |* [gar=* sef=_|.(fist:dejs-soft:format)] |= jon=json ^- (unit _gar) =- ~! gar ~! (need -) - diff --git a/pkg/arvo/lib/group-json.hoon b/pkg/arvo/lib/group-json.hoon index 5000624e4c..fe52ba0a08 100644 --- a/pkg/arvo/lib/group-json.hoon +++ b/pkg/arvo/lib/group-json.hoon @@ -12,7 +12,7 @@ (set-to-array group ship:enjs:format) :: ++ set-to-array - |* {a=(set) b=$-(* json)} + |* [a=(set) b=$-(* json)] ^- json [%a (turn ~(tap in a) b)] -- diff --git a/pkg/arvo/lib/group-store.hoon b/pkg/arvo/lib/group-store.hoon index 790f3e9712..bf7be51619 100644 --- a/pkg/arvo/lib/group-store.hoon +++ b/pkg/arvo/lib/group-store.hoon @@ -304,13 +304,13 @@ $(a r.a) :: ++ of - |* wer=(pole {cord fist}) + |* wer=(pole [cord fist]) |= jon=json - ?> ?=({%o {@ *} ~ ~} jon) + ?> ?=([%o [@ *] ~ ~] jon) |- ?- wer - :: {{key=@t wit=*} t=*} - {{key=@t *} t=*} + :: {{key=@t wit=*} t=*] + [[key=@t *] t=*] => .(wer [[* wit] *]=wer) ?: =(key.wer (enkebab p.n.p.jon)) [key.wer ~|(val+q.n.p.jon (wit.wer q.n.p.jon))] diff --git a/pkg/arvo/lib/hood/drum.hoon b/pkg/arvo/lib/hood/drum.hoon index bd791c3405..1ccd069ba0 100644 --- a/pkg/arvo/lib/hood/drum.hoon +++ b/pkg/arvo/lib/hood/drum.hoon @@ -144,7 +144,7 @@ +$ any-state ^any-state :: proxy ++ on-init se-abet:this(eel (deft-fish our.hid)) ++ diff-sole-effect-phat :: app event - |= {way=wire fec=sole-effect} + |= [way=wire fec=sole-effect] =< se-abet =< se-view =+ gyl=(de-gill way) ?: (se-aint gyl) +>.$ @@ -197,7 +197,7 @@ se-abet:(se-blit-sys `dill-blit:dill`[%qit ~]) :: ++ poke-put :: write file - |= {pax=path txt=@} + |= [pax=path txt=@] se-abet:(se-blit-sys [%sav pax txt]) :: :: ++ poke @@ -256,7 +256,7 @@ ..on-load :: ++ reap-phat :: ack connect - |= {way=wire saw=(unit tang)} + |= [way=wire saw=(unit tang)] =< se-abet =< se-view =+ gyl=(de-gill way) ?~ saw @@ -273,7 +273,7 @@ +>.sign-arvo :: ++ take-coup-phat :: ack poke - |= {way=wire saw=(unit tang)} + |= [way=wire saw=(unit tang)] =< se-abet =< se-view ?~ saw +> =+ gyl=(de-gill way) @@ -283,14 +283,14 @@ >[%drum-coup-fail src.hid gyl]< :: ++ take-onto :: ack start - |= {way=wire saw=(each suss:gall tang)} + |= [way=wire saw=(each suss:gall tang)] =< se-abet =< se-view - ?> ?=({@ @ ~} way) + ?> ?=([@ @ ~] way) ?> (~(has by fur) i.t.way) =/ wel=well:gall [i.way i.t.way] ?- saw - {%| *} (se-dump p.saw) - {%& *} ?> =(q.wel p.p.saw) + [%| *] (se-dump p.saw) + [%& *] ?> =(q.wel p.p.saw) :: =. +>.$ (se-text "live {}") +>.$(fur (~(put by fur) q.wel `[p.wel %da r.p.saw])) == @@ -396,7 +396,7 @@ ?: =(b %dojo) %.y (aor a b) =< .(con +>) - |: $:{gil=gill:gall con=_.} ^+ con + |: $:,[gil=gill:gall con=_.] ^+ con =. +>.$ con ?: (~(has by fug) gil) +>.$ @@ -408,7 +408,7 @@ ^+ . %- ~(rep by bin) =< .(con +>) - |: $:{{ost=bone dev=source} con=_.} ^+ con + |: $:,[[ost=bone dev=source] con=_.] ^+ con =+ xeno=se-subze-local:%_(con ost ost, dev dev) xeno(ost ost.con, dev dev.con, bin (~(put by bin) ost dev.xeno)) :: @@ -416,7 +416,7 @@ ^+ . %- ~(rep by fug) =< .(con +>) - |: $:{{gil=gill:gall *} con=_.} ^+ con + |: $:,[[gil=gill:gall *] con=_.] ^+ con =. +>.$ con ?: (~(has in eel) gil) +>.$ @@ -440,7 +440,7 @@ ++ se-amor :: live targets ^- (list gill:gall) %+ skim ~(tap in eel) - |=(a=gill:gall ?=({~ ~ *} (~(get by fug) a))) + |=(a=gill:gall ?=([~ ~ *] (~(get by fug) a))) :: ++ se-anon :: rotate index =+ wag=se-amor @@ -458,12 +458,12 @@ ++ se-belt :: handle input |= bet=dill-belt:dill ^+ +> - ?: ?=({?(%cru %hey %rez %yow) *} bet) :: target-agnostic + ?: ?=([?(%cru %hey %rez %yow) *] bet) :: target-agnostic ?- bet - {%cru *} (se-dump:(se-text (trip p.bet)) q.bet) - {%hey *} +>(mir [0 ~]) :: refresh - {%rez *} +>(edg (dec p.bet)) :: resize window - {%yow *} ~&([%no-yow -.bet] +>) + [%cru *] (se-dump:(se-text (trip p.bet)) q.bet) + [%hey *] +>(mir [0 ~]) :: refresh + [%rez *] +>(edg (dec p.bet)) :: resize window + [%yow *] ~&([%no-yow -.bet] +>) == =+ gul=se-agon ?: |(?=(~ gul) (se-aint u.gul)) @@ -482,7 +482,7 @@ == :: ++ se-drop :: disconnect - |= {pej=? gyl=gill:gall} + |= [pej=? gyl=gill:gall] ^+ +> =+ lag=se-agon ?. (~(has by fug) gyl) +>.$ @@ -497,7 +497,7 @@ +>.$ :: ++ se-tab :: print tab completions - |= tl=(list {=cord =tank}) + |= tl=(list [=cord =tank]) ^+ +> =/ lots (gth (lent tl) 10) =/ long @@ -574,7 +574,7 @@ +>(mir lin) :: ++ se-just :: adjusted buffer - |= {pom=stub lin=(pair @ud (list @c))} + |= [pom=stub lin=(pair @ud (list @c))] ^+ +> =/ pol (lent-char:klr pom) =/ pos (add pol p.lin) @@ -612,7 +612,7 @@ (se-blit %out (tuba txt)) :: ++ se-poke :: send a poke - |= {gyl=gill:gall par=cage} + |= [gyl=gill:gall par=cage] (se-emit %pass (en-gill gyl) %agent gyl %poke par) :: ++ se-peer :: send a peer @@ -631,12 +631,12 @@ ~(. ta gyl (need (~(got by fug) gyl))) :: ++ se-diff :: receive results - |= {gyl=gill:gall fec=sole-effect} + |= [gyl=gill:gall fec=sole-effect] ^+ +> ta-abet:(ta-fec:(se-tame gyl) fec) :: ++ ta :: per target - |_ {gyl=gill:gall target} :: app and state + |_ [gyl=gill:gall target] :: app and state ++ ta-abet :: resolve ^+ ..ta ..ta(fug (~(put by fug) gyl ``target`+<+)) @@ -674,16 +674,16 @@ ++ ta-belt :: handle input |= bet=dill-belt:dill ^+ +> - ?< ?=({?(%cru %hey %rez %yow) *} bet) :: target-specific + ?< ?=([?(%cru %hey %rez %yow) *] bet) :: target-specific =. blt [q.blt `bet] :: remember belt ?- bet - {%aro *} (ta-aro p.bet) - {%bac *} ta-bac - {%ctl *} (ta-ctl p.bet) - {%del *} ta-del - {%met *} (ta-met p.bet) - {%ret *} ta-ret - {%txt *} (ta-txt p.bet) + [%aro *] (ta-aro p.bet) + [%bac *] ta-bac + [%ctl *] (ta-ctl p.bet) + [%del *] ta-del + [%met *] (ta-met p.bet) + [%ret *] ta-ret + [%txt *] (ta-txt p.bet) == :: ++ ta-det :: send edit @@ -773,23 +773,23 @@ |= fec=sole-effect ^+ +> ?- fec - {%bel *} ta-bel - {%blk *} +> - {%clr *} +>(..ta (se-blit fec)) - {%det *} (ta-got +.fec) - {%err *} (ta-err p.fec) - {%klr *} +>(..ta (se-blit %klr (make:klr p.fec))) - {%mor *} |- ^+ +>.^$ + [%bel *] ta-bel + [%blk *] +> + [%clr *] +>(..ta (se-blit fec)) + [%det *] (ta-got +.fec) + [%err *] (ta-err p.fec) + [%klr *] +>(..ta (se-blit %klr (make:klr p.fec))) + [%mor *] |- ^+ +>.^$ ?~ p.fec +>.^$ $(p.fec t.p.fec, +>.^$ ^$(fec i.p.fec)) - {%nex *} ta-nex - {%pro *} (ta-pro +.fec) - {%tab *} +>(..ta (se-tab p.fec)) - {%tan *} +>(..ta (se-dump p.fec)) - {%sag *} +>(..ta (se-blit fec)) - {%sav *} +>(..ta (se-blit fec)) - {%txt *} +>(..ta (se-text p.fec)) - {%url *} +>(..ta (se-blit fec)) + [%nex *] ta-nex + [%pro *] (ta-pro +.fec) + [%tab *] +>(..ta (se-tab p.fec)) + [%tan *] +>(..ta (se-dump p.fec)) + [%sag *] +>(..ta (se-blit fec)) + [%sav *] +>(..ta (se-blit fec)) + [%txt *] +>(..ta (se-text p.fec)) + [%url *] +>(..ta (se-blit fec)) == :: ++ ta-dog :: change cursor @@ -800,13 +800,13 @@ %+ min len |- ^- @ud ?- ted - {%del *} ?:((gth pos.inp p.ted) (dec pos.inp) pos.inp) - {%ins *} ?:((gte pos.inp p.ted) +(pos.inp) pos.inp) - {%mor *} |- ^- @ud + [%del *] ?:((gth pos.inp p.ted) (dec pos.inp) pos.inp) + [%ins *] ?:((gte pos.inp p.ted) +(pos.inp) pos.inp) + [%mor *] |- ^- @ud ?~ p.ted pos.inp $(p.ted t.p.ted, pos.inp ^$(ted i.p.ted)) - {%nop *} pos.inp - {%set *} len + [%nop *] pos.inp + [%set *] len == == :: @@ -827,13 +827,13 @@ (ta-dog(say.inp (~(commit sole say.inp) ted)) ted) :: ++ ta-jump :: buffer pos - |= {dir=?(%l %r) til=?(%ace %edg %wrd) pos=@ud} + |= [dir=?(%l %r) til=?(%ace %edg %wrd) pos=@ud] ^- @ud %- ?:(?=(%l dir) sub add) [pos (ta-pos dir til pos)] :: ++ ta-kil :: kill selection - |= {dir=?(%l %r) sel={@ @}} + |= [dir=?(%l %r) sel=[@ @]] ^+ +> =+ buf=(swag sel buf.say.inp) %. (cut:edit sel) @@ -841,8 +841,8 @@ kil ?. ?& ?=(^ old.kil) ?=(^ p.blt) - ?| ?=({%ctl ?(%k %u %w)} u.p.blt) - ?=({%met ?(%d %bac)} u.p.blt) + ?| ?=([%ctl ?(%k %u %w)] u.p.blt) + ?=([%met ?(%d %bac)] u.p.blt) == == %= kil :: prepend num +(num.kil) @@ -925,8 +925,8 @@ :: %y ?. ?& ?=(^ old.kil) :: rotate & yank ?=(^ p.blt) - ?| ?=({%ctl %y} u.p.blt) - ?=({%met %y} u.p.blt) + ?| ?=([%ctl %y] u.p.blt) + ?=([%met %y] u.p.blt) == == ta-bel =+ las=(lent ta-yan) @@ -961,7 +961,7 @@ == :: ++ ta-pos :: buffer pos offset - |= {dir=?(%l %r) til=?(%ace %edg %wrd) pos=@ud} + |= [dir=?(%l %r) til=?(%ace %edg %wrd) pos=@ud] ^- @ud %- ?- til %ace ace:offset %edg edg:offset @@ -1020,7 +1020,7 @@ (ta-hom (cat:edit pos.inp txt)) :: ++ ta-vew :: computed prompt - ^- {pom=stub lin=(pair @ud (list @c))} + ^- [pom=stub lin=(pair @ud (list @c))] =; vew=(pair (list @c) styx) [(make:klr q.vew) pos.inp p.vew] ?: vis.pom @@ -1040,7 +1040,7 @@ ++ edit :: produce sole-edits |% ++ cat :: mass insert - |= {pos=@ud txt=(list @c)} + |= [pos=@ud txt=(list @c)] ^- sole-edit :- %mor |- ^- (list sole-edit) @@ -1048,7 +1048,7 @@ [[%ins pos i.txt] $(pos +(pos), txt t.txt)] :: ++ cut :: mass delete - |= {pos=@ud num=@ud} + |= [pos=@ud num=@ud] ^- sole-edit :- %mor |- ^- (list sole-edit) @@ -1056,14 +1056,14 @@ [[%del pos] $(num (dec num))] :: ++ rep :: mass replace - |= {{pos=@ud num=@ud} txt=(list @c)} + |= [[pos=@ud num=@ud] txt=(list @c)] ^- sole-edit :~ %mor (cut pos num) (cat pos txt) == ++ any :: matches? - |= {a=sole-edit b=$-(sole-edit ?)} + |= [a=sole-edit b=$-(sole-edit ?)] ^- ? ?. ?=(%mor -.a) (b a) (lien p.a |=(c=sole-edit ^$(a c))) @@ -1079,7 +1079,7 @@ :: ++ ace :: next whitespace |= a=(list @) - =| {b=_| i=@ud} + =| [b=_| i=@ud] |- ^- @ud ?~ a i =/ c !=(32 i.a) @@ -1089,7 +1089,7 @@ :: ++ edg :: next word boundary |= a=(list @) - =| {b=_| i=@ud} + =| [b=_| i=@ud] |- ^- @ud ?~ a i =/ c (alnm i.a) @@ -1118,13 +1118,13 @@ ?@ a [b (tuba (trip a))]~ ^$(a q.a, b (styd p.a b)) :: - |= {a=(pair stye (list @c)) b=stub} + |= [a=(pair stye (list @c)) b=stub] ?~ b [a ~] ?. =(p.a p.i.b) [a b] [[p.a (weld q.a q.i.b)] t.b] :: ++ styd :: stye from styl - |= {a=styl b=stye} ^+ b :: with inheritance + |= [a=styl b=stye] ^+ b :: with inheritance :+ ?~ p.a p.b ?~ u.p.a ~ (~(put in p.b) u.p.a) @@ -1142,8 +1142,8 @@ (lent q.a) :: ++ brek :: index + incl-len of - |= {a=@ b=(list @)} :: stub pair w= idx a - =| {c=@ i=@} + |= [a=@ b=(list @)] :: stub pair w= idx a + =| [c=@ i=@] |- ^- (unit (pair @ @)) ?~ b ~ =. c (add c i.b) @@ -1152,7 +1152,7 @@ $(i +(i), b t.b) :: ++ slag :: slag stub, keep stye - |= {a=@ b=stub} + |= [a=@ b=stub] ^- stub =+ c=(lnts-char b) =+ i=(brek a c) @@ -1165,7 +1165,7 @@ (^slag (sub (snag p.u.i c) (sub q.u.i a)) q.n) :: ++ scag :: scag stub, keep stye - |= {a=@ b=stub} + |= [a=@ b=stub] ^- stub =+ c=(lnts-char b) =+ i=(brek a c) @@ -1179,7 +1179,7 @@ (^scag (sub (snag p.u.i c) (sub q.u.i a)) q.n) :: ++ swag :: swag stub, keep stye - |= {{a=@ b=@} c=stub} + |= [[a=@ b=@] c=stub] (scag b (slag a c)) -- -- diff --git a/pkg/arvo/lib/hood/helm.hoon b/pkg/arvo/lib/hood/helm.hoon index ec75f37f57..ed8dad104d 100644 --- a/pkg/arvo/lib/hood/helm.hoon +++ b/pkg/arvo/lib/hood/helm.hoon @@ -122,7 +122,7 @@ == :: ++ poke-send-hi - |= {her=ship mes=(unit tape)} =< abet + |= [her=ship mes=(unit tape)] =< abet %- emit :* %pass /helm/hi/(scot %p her) %agent [her %hood] %poke @@ -146,26 +146,26 @@ (flog %text "< {}: atom: {len} bytes, mug {gum}") :: ++ coup-hi - |= {pax=path cop=(unit tang)} =< abet - ?> ?=({@t ~} pax) + |= [pax=path cop=(unit tang)] =< abet + ?> ?=([@t ~] pax) (flog %text "hi {(trip i.pax)} {?~(cop "" "un")}successful") :: ++ poke-reload |=(all=(list term) (poke-reload-desk %home all)) ++ poke-reload-desk :: reload vanes - |: $:{syd=desk all=(list term)} =< abet + |: $:,[syd=desk all=(list term)] =< abet %- emil %+ turn all =+ top=`path`/(scot %p our.bowl)/[syd]/(scot %da now.bowl) - =/ van=(list {term ~}) + =/ van=(list [term ~]) :- zus=[%zuse ~] ~(tap by dir:.^(arch %cy (welp top /sys/vane))) |= nam=@tas =. nam ?. =(1 (met 3 nam)) nam - =/ zaz=(list {p=knot ~}) - (skim van |=({a=term ~} =(nam (end 3 1 a)))) - ?> ?=({{@ ~} ~} zaz) + =/ zaz=(list [p=knot ~]) + (skim van |=([a=term ~] =(nam (end 3 1 a)))) + ?> ?=([[@ ~] ~] zaz) `term`p.i.zaz =+ tip=(end 3 1 nam) =+ zus==('z' tip) diff --git a/pkg/arvo/lib/hood/kiln.hoon b/pkg/arvo/lib/hood/kiln.hoon index 35efe26c59..32cd8a3767 100644 --- a/pkg/arvo/lib/hood/kiln.hoon +++ b/pkg/arvo/lib/hood/kiln.hoon @@ -73,7 +73,7 @@ ?~(+< +> $(+< t.+<, +> (emit i.+<))) :: ++ render - |= {mez=tape sud=desk who=ship syd=desk} + |= [mez=tape sud=desk who=ship syd=desk] :^ %palm [" " ~ ~ ~] leaf+(weld "kiln: " mez) ~[leaf+"from {}" leaf+"on {}" leaf+"to {}"] :: @@ -381,7 +381,7 @@ abet:(emit %pass /cancel %arvo %c [%drop a]) :: ++ poke-info - |= {mez=tape tor=(unit toro)} + |= [mez=tape tor=(unit toro)] ?~ tor abet:(spam leaf+mez ~) abet:(emit:(spam leaf+mez ~) %pass /kiln %arvo %c [%info u.tor]) @@ -395,19 +395,19 @@ (poke-info "removed" `(fray a)) :: ++ poke-label - |= {syd=desk lab=@tas} + |= [syd=desk lab=@tas] =+ pax=/(scot %p our)/[syd]/[lab] (poke-info "labeled {(spud pax)}" `[syd %| lab]) :: ++ poke-schedule - |= {where=path tym=@da eve=@t} + |= [where=path tym=@da eve=@t] =. where (welp where /sched) %+ poke-info "scheduled" =+ old=;;((map @da cord) (fall (file where) ~)) `(foal where %sched !>((~(put by old) tym eve))) :: ++ poke-permission - |= {syd=desk pax=path pub=?} + |= [syd=desk pax=path pub=?] =< abet %- emit =/ =rite [%r ~ ?:(pub %black %white) ~] @@ -447,7 +447,7 @@ abet:(emit %pass /kiln %arvo %g %sear ship) :: ++ done - |= {way=wire saw=(unit error:ames)} + |= [way=wire saw=(unit error:ames)] ~? ?=(^ saw) [%kiln-nack u.saw] abet :: @@ -481,23 +481,23 @@ ?>(?=(%mere +<.sign-arvo) +>.sign-arvo) == == -++ take |=(way=wire ?>(?=({@ ~} way) (work i.way))) :: general handler +++ take |=(way=wire ?>(?=([@ ~] way) (work i.way))) :: general handler ++ take-mere :: - |= {way=wire are=(each (set path) (pair term tang))} + |= [way=wire are=(each (set path) (pair term tang))] abet:abet:(mere:(take way) are) :: ++ take-coup-fancy :: - |= {way=wire saw=(unit tang)} + |= [way=wire saw=(unit tang)] abet:abet:(coup-fancy:(take way) saw) :: ++ take-coup-spam :: - |= {way=wire saw=(unit tang)} + |= [way=wire saw=(unit tang)] ~? ?=(^ saw) [%kiln-spam-lame u.saw] abet :: ++ take-mere-sync :: - |= {way=wire mes=(each (set path) (pair term tang))} - ?> ?=({@ @ @ *} way) + |= [way=wire mes=(each (set path) (pair term tang))] + ?> ?=([@ @ @ *] way) =/ hos=kiln-sync :* syd=(slav %tas i.way) her=(slav %p i.t.way) @@ -508,8 +508,8 @@ abet:abet:(mere:(auto hos) mes) :: ++ take-writ-find-ship :: - |= {way=wire rot=riot} - ?> ?=({@ @ @ *} way) + |= [way=wire rot=riot] + ?> ?=([@ @ @ *] way) =/ hos=kiln-sync :* syd=(slav %tas i.way) her=(slav %p i.t.way) @@ -520,8 +520,8 @@ abet:abet:(take-find-ship:(auto hos) rot) :: ++ take-writ-sync :: - |= {way=wire rot=riot} - ?> ?=({@ @ @ *} way) + |= [way=wire rot=riot] + ?> ?=([@ @ @ *] way) =/ hos=kiln-sync :* syd=(slav %tas i.way) her=(slav %p i.t.way) @@ -685,7 +685,7 @@ (blab [%pass /kiln/[syd] %arvo %c [%merg syd her sud cas gem]] ~) :: ++ fancy-merge :: send to self - |= {syd=desk her=@p sud=desk gem=?(%auto germ)} + |= [syd=desk her=@p sud=desk gem=?(%auto germ)] ^+ +> =/ =cage [%kiln-merge !>([syd her sud cas gem])] %- blab :_ ~ @@ -694,7 +694,7 @@ ++ spam ::|=(tang ((slog +<) ..spam)) |*(* +>(..work (^spam +<))) ++ merge - |= {her=@p sud=@tas cas=case gim=?(%auto germ)} + |= [her=@p sud=@tas cas=case gim=?(%auto germ)] ^+ +> ?. ?=(%auto gim) perform(auto |, gem gim, her her, cas cas, sud sud) @@ -828,7 +828,7 @@ (scan a (more (just '\0a') (cook |=(a=tape leaf+a) (star prn)))) :: ++ tanks-if-any - |= {a=tape b=(list path) c=tape} ^- (list tank) + |= [a=tape b=(list path) c=tape] ^- (list tank) ?: =(~ b) ~ (welp (tape-to-tanks "\0a{c}{a}") >b< ~) -- diff --git a/pkg/arvo/lib/jose.hoon b/pkg/arvo/lib/jose.hoon index d8be0b5484..bafe4bf6ab 100644 --- a/pkg/arvo/lib/jose.hoon +++ b/pkg/arvo/lib/jose.hoon @@ -34,7 +34,7 @@ :: :: ++apex:en-json:html ++ apex =, en-json:html - |= {val=json sor=$-(^ ?) rez=tape} + |= [val=json sor=$-(^ ?) rez=tape] ^- tape ?~ val (weld "null" rez) ?- -.val @@ -57,7 +57,7 @@ |- ^- tape ?~ viz rez =+ hed=(jesc i.viz) - ?: ?=({@ ~} hed) + ?: ?=([@ ~] hed) [i.hed $(viz t.viz)] (weld hed $(viz t.viz)) :: diff --git a/pkg/arvo/lib/language-server/complete.hoon b/pkg/arvo/lib/language-server/complete.hoon index 19f95bfc2e..d64d6827ae 100644 --- a/pkg/arvo/lib/language-server/complete.hoon +++ b/pkg/arvo/lib/language-server/complete.hoon @@ -9,7 +9,7 @@ :: Like +rose except also produces line number :: ++ lily - |* {los=tape sab=rule} + |* [los=tape sab=rule] =+ vex=(sab [[1 1] los]) ?~ q.vex [%| p=p.vex(q (dec q.p.vex))] diff --git a/pkg/arvo/lib/language-server/easy-print.hoon b/pkg/arvo/lib/language-server/easy-print.hoon index 0f523492be..cc4ecd1565 100644 --- a/pkg/arvo/lib/language-server/easy-print.hoon +++ b/pkg/arvo/lib/language-server/easy-print.hoon @@ -1,8 +1,8 @@ :: Fast type printing that's easy on the eyes or your money back :: => |% - ++ cape {p=(map @ud wine) q=wine} - ++ wine + +$ cape [p=(map @ud wine) q=wine] + +$ wine $@ $? %noun %path %type @@ -11,22 +11,22 @@ %wool %yarn == - $% {%mato p=term} - {%gate p=hoon q=type r=wine} - {%core p=(list @ta) q=wine} - {%face p=term q=wine} - {%list p=term q=wine} - {%pear p=term q=@} - {%bcwt p=(list wine)} - {%plot p=(list wine)} - {%stop p=@ud} - {%tree p=term q=wine} - {%unit p=term q=wine} + $% [%mato p=term] + [%gate p=hoon q=type r=wine] + [%core p=(list @ta) q=wine] + [%face p=term q=wine] + [%list p=term q=wine] + [%pear p=term q=@] + [%bcwt p=(list wine)] + [%plot p=(list wine)] + [%stop p=@ud] + [%tree p=term q=wine] + [%unit p=term q=wine] == -- |_ sut=type ++ dash - |= {mil=tape lim=char lam=tape} + |= [mil=tape lim=char lam=tape] ^- tape =/ esc (~(gas in *(set @tD)) lam) :- lim @@ -50,14 +50,14 @@ |% ++ many |= haz=(list wine) - ^- {(list tank) (set @ud)} + ^- [(list tank) (set @ud)] ?~ haz [~ gid] =^ mor gid $(haz t.haz) =^ dis gid ^$(q.ham i.haz) [[dis mor] gid] :: ++ $ - ^- {tank (set @ud)} + ^- [tank (set @ud)] ?- q.ham %noun :_(gid [%leaf '*' ~]) %path :_(gid [%leaf '/' ~]) @@ -66,8 +66,8 @@ %wool :_(gid [%leaf '*' '"' '"' ~]) %wall :_(gid [%leaf '*' '\'' '\'' ~]) %yarn :_(gid [%leaf '"' '"' ~]) - {%mato *} :_(gid [%leaf '@' (trip p.q.ham)]) - {%gate *} + [%mato *] :_(gid [%leaf '@' (trip p.q.ham)]) + [%gate *] =^ sam gid ?. ?=([%plot * * *] r.q.ham) ?: ?=(%plot -.r.q.ham) @@ -92,7 +92,7 @@ == ~ :: - {%core *} + [%core *] =^ sam gid ?. ?=([%plot * * ~] q.q.ham) `gid @@ -114,26 +114,26 @@ [[%leaf (rip 3 i.p.q.ham)] $(p.q.ham t.p.q.ham)] ~ :: - {%face *} + [%face *] =^ cox gid $(q.ham q.q.ham) :_(gid [%palm [['=' ~] ~ ~ ~] [%leaf (trip p.q.ham)] cox ~]) :: - {%list *} + [%list *] =^ cox gid $(q.ham q.q.ham) :_(gid [%rose [" " (weld (trip p.q.ham) "(") ")"] cox ~]) :: - {%bcwt *} + [%bcwt *] =^ coz gid (many p.q.ham) :_(gid [%rose [[' ' ~] ['?' '(' ~] [')' ~]] coz]) :: - {%plot *} + [%plot *] =^ coz gid (many p.q.ham) :_(gid [%rose [[' ' ~] ['[' ~] [']' ~]] coz]) :: - {%pear *} + [%pear *] :_(gid [%leaf '$' ~(rend co [%$ p.q.ham q.q.ham])]) :: - {%stop *} + [%stop *] =+ num=~(rend co [%$ %ud p.q.ham]) ?: (~(has in gid) p.q.ham) :_(gid [%leaf '#' num]) @@ -144,23 +144,23 @@ == :_(gid [%palm [['.' ~] ~ ~ ~] [%leaf ['^' '#' num]] cox ~]) :: - {%tree *} + [%tree *] =^ cox gid $(q.ham q.q.ham) :_(gid [%rose [" " (weld (trip p.q.ham) "(") ")"] cox ~]) :: - {%unit *} + [%unit *] =^ cox gid $(q.ham q.q.ham) :_(gid [%rose [" " (weld (trip p.q.ham) "(") ")"] cox ~]) == -- :: ++ dish !: - |= {ham=cape lum=*} ^- tank + |= [ham=cape lum=*] ^- tank ~| [%dish-h ?@(q.ham q.ham -.q.ham)] ~| [%lump lum] ~| [%ham ham] %- need - =| gil=(set {@ud *}) + =| gil=(set [@ud *]) |- ^- (unit tank) ?- q.ham %noun @@ -215,7 +215,7 @@ %void ~ :: - {%mato *} + [%mato *] ?. ?=(@ lum) ~ :+ ~ @@ -227,10 +227,10 @@ %tas ['%' ?.(=(0 lum) (rip 3 lum) ['$' ~])] == :: - {%gate *} + [%gate *] !! :: - {%core *} + [%core *] :: XX needs rethinking for core metal :: ?. ?=(^ lum) ~ :: => .(lum `*`lum) @@ -244,13 +244,13 @@ :: ?~(mur ~ [~ [[%leaf (rip 3 i.p.q.ham)] u.mur]]) [~ (dial ham)] :: - {%face *} + [%face *] =+ wal=$(q.ham q.q.ham) ?~ wal ~ [~ %palm [['=' ~] ~ ~ ~] [%leaf (trip p.q.ham)] u.wal ~] :: - {%list *} + [%list *] ?: =(~ lum) [~ %leaf '~' ~] =- ?~ tok @@ -265,7 +265,7 @@ ~ [~ u.for u.aft] :: - {%bcwt *} + [%bcwt *] |- ^- (unit tank) ?~ p.q.ham ~ @@ -274,7 +274,7 @@ $(p.q.ham t.p.q.ham) wal :: - {%plot *} + [%plot *] =- ?~ tok ~ [~ %rose [[' ' ~] ['[' ~] [']' ~]] u.tok] @@ -282,7 +282,7 @@ |- ^- (unit (list tank)) ?~ p.q.ham ~ - ?: ?=({* ~} p.q.ham) + ?: ?=([* ~] p.q.ham) =+ wal=^$(q.ham i.p.q.ham) ?~(wal ~ [~ [u.wal ~]]) ?@ lum @@ -295,25 +295,25 @@ ~ [~ u.gim u.myd] :: - {%pear *} + [%pear *] ?. =(lum q.q.ham) ~ =. p.q.ham (rash p.q.ham ;~(sfix (cook crip (star low)) (star hig))) =+ fox=$(q.ham [%mato p.q.ham]) - ?> ?=({~ %leaf ^} fox) + ?> ?=([~ %leaf ^] fox) ?: ?=(?(%n %tas) p.q.ham) fox [~ %leaf '%' p.u.fox] :: - {%stop *} + [%stop *] ?: (~(has in gil) [p.q.ham lum]) ~ =+ kep=(~(get by p.ham) p.q.ham) ?~ kep ~|([%stop-loss p.q.ham] !!) $(gil (~(put in gil) [p.q.ham lum]), q.ham u.kep) :: - {%tree *} + [%tree *] =- ?~ tok ~ [~ %rose [[' ' ~] ['{' ~] ['}' ~]] u.tok] @@ -322,7 +322,7 @@ |- ^- (unit (list tank)) ?: =(~ lum) [~ tuk] - ?. ?=({n=* l=* r=*} lum) + ?. ?=([n=* l=* r=*] lum) ~ =+ rol=$(lum r.lum) ?~ rol @@ -332,7 +332,7 @@ ~ $(lum l.lum, tuk [u.tim u.rol]) :: - {%unit *} + [%unit *] ?@ lum ?.(=(~ lum) ~ [~ %leaf '~' ~]) ?. =(~ -.lum) @@ -346,15 +346,15 @@ ++ doge |= ham=cape =- ?+ woz woz - {%list * {%mato %'ta'}} %path - {%list * {%mato %'t'}} %wall - {%list * {%mato %'tD'}} %yarn - {%list * %yarn} %wool + [%list * [%mato %'ta']] %path + [%list * [%mato %'t']] %wall + [%list * [%mato %'tD']] %yarn + [%list * %yarn] %wool == ^= woz ^- wine - ?. ?=({%stop *} q.ham) - ?: ?& ?= {%bcwt {%pear %n %0} {%plot {%pear %n %0} {%face *} ~} ~} + ?. ?=([%stop *] q.ham) + ?: ?& ?= [%bcwt [%pear %n %0] [%plot [%pear %n %0] [%face *] ~] ~] q.ham =(1 (met 3 p.i.t.p.i.t.p.q.ham)) == @@ -364,13 +364,13 @@ ?~ may q.ham =+ nul=[%pear %n 0] - ?. ?& ?=({%bcwt *} u.may) - ?=({* * ~} p.u.may) + ?. ?& ?=([%bcwt *] u.may) + ?=([* * ~] p.u.may) |(=(nul i.p.u.may) =(nul i.t.p.u.may)) == q.ham =+ din=?:(=(nul i.p.u.may) i.t.p.u.may i.p.u.may) - ?: ?& ?=({%plot {%face *} {%face * %stop *} ~} din) + ?: ?& ?=([%plot [%face *] [%face * %stop *] ~] din) =(p.q.ham p.q.i.t.p.din) =(1 (met 3 p.i.p.din)) =(1 (met 3 p.i.t.p.din)) @@ -379,9 +379,9 @@ (cat 3 p.i.p.din p.i.t.p.din) q.i.p.din ?: ?& ?= $: %plot - {%face *} - {%face * %stop *} - {{%face * %stop *} ~} + [%face *] + [%face * %stop *] + [[%face * %stop *] ~] == din =(p.q.ham p.q.i.t.p.din) @@ -403,24 +403,24 @@ =+ gil=*(set type) =+ dex=[p=*(map type @) q=*(map @ wine)] =< [q.p q] - |- ^- {p={p=(map type @) q=(map @ wine)} q=wine} + |- ^- [p=[p=(map type @) q=(map @ wine)] q=wine] =- [p.tez (doge q.p.tez q.tez)] ^= tez - ^- {p={p=(map type @) q=(map @ wine)} q=wine} + ^- [p=[p=(map type @) q=(map @ wine)] q=wine] ?: (~(meet ut sut) -:!>(*type)) [dex %type] ?- sut %noun [dex sut] %void [dex sut] - {%atom *} [dex ?~(q.sut [%mato p.sut] [%pear p.sut u.q.sut])] - {%cell *} + [%atom *] [dex ?~(q.sut [%mato p.sut] [%pear p.sut u.q.sut])] + [%cell *] =+ hin=$(sut p.sut) =+ yon=$(dex p.hin, sut q.sut) :- p.yon :- %plot - ?:(?=({%plot *} q.yon) [q.hin p.q.yon] [q.hin q.yon ~]) + ?:(?=([%plot *] q.yon) [q.hin p.q.yon] [q.hin q.yon ~]) :: - {%core *} + [%core *] ?: ?=([[%$ * [[%$ @ *] ~ ~]] ~ ~] q.r.q.sut) =/ dad $(sut p.sut) :- p.dad @@ -428,8 +428,8 @@ [%gate q.n.q.q.n.q.r.q.sut sut(r.p.q %gold) q.dad] =+ yad=$(sut p.sut) :- p.yad - =+ ^= doy ^- {p=(list @ta) q=wine} - ?: ?=({%core *} q.yad) + =+ ^= doy ^- [p=(list @ta) q=wine] + ?: ?=([%core *] q.yad) [p.q.yad q.q.yad] [~ q.yad] :- %core @@ -449,24 +449,24 @@ [1 (add 'a' (mod (div gum 676) 26))] == :: - {%hint *} + [%hint *] $(sut q.sut) :: - {%face *} + [%face *] =+ yad=$(sut q.sut) ?^(p.sut yad [p.yad [%face p.sut q.yad]]) :: - {%fork *} + [%fork *] =+ yed=(sort ~(tap in p.sut) aor) =- [p [%bcwt q]] - |- ^- {p={p=(map type @) q=(map @ wine)} q=(list wine)} + |- ^- [p=[p=(map type @) q=(map @ wine)] q=(list wine)] ?~ yed [dex ~] =+ mor=$(yed t.yed) =+ dis=^$(dex p.mor, sut i.yed) [p.dis q.dis q.mor] :: - {%hold *} + [%hold *] =+ hey=(~(get by p.dex) sut) ?^ hey [dex [%stop u.hey]] diff --git a/pkg/arvo/lib/metadata-json.hoon b/pkg/arvo/lib/metadata-json.hoon index b35eeb7c01..82a65c8fd0 100644 --- a/pkg/arvo/lib/metadata-json.hoon +++ b/pkg/arvo/lib/metadata-json.hoon @@ -48,7 +48,7 @@ :: ++ nu |= jon=json - ?> ?=({%s *} jon) + ?> ?=([%s *] jon) (rash p.jon hex) :: ++ metadata diff --git a/pkg/arvo/lib/old-phon.hoon b/pkg/arvo/lib/old-phon.hoon index 1f6521424e..2db8670dc3 100644 --- a/pkg/arvo/lib/old-phon.hoon +++ b/pkg/arvo/lib/old-phon.hoon @@ -66,7 +66,7 @@ |% ++ hif (boss 256 ;~(plug tip tiq (easy ~))) ++ huf %+ cook - |=({a=@ b=@} (wred:un ~(zug mu ~(zag mu [a b])))) + |=([a=@ b=@] (wred:un ~(zug mu ~(zag mu [a b])))) ;~(plug hif ;~(pfix hep hif)) ++ hyf (bass 0x1.0000.0000 ;~(plug huf ;~(pfix hep huf) (easy ~))) ++ tip (sear |=(a=@ (ins:po a)) til) @@ -87,7 +87,7 @@ -- :: ++ mu - |_ {top=@ bot=@} + |_ [top=@ bot=@] ++ zag [p=(end 4 1 (add top bot)) q=bot] ++ zig [p=(end 4 1 (add top (sub 0x1.0000 bot))) q=bot] ++ zug (mix (lsh 4 1 top) bot) @@ -105,9 +105,9 @@ => .(len (dec len)) =+ mig=(zaft (xafo len (cut 3 [len 1] pyn))) %+ can 3 - %- flop ^- (list {@ @}) + %- flop ^- (list [@ @]) :- [1 mig] - |- ^- (list {@ @}) + |- ^- (list [@ @]) ?: =(0 len) ~ => .(len (dec len)) @@ -122,17 +122,17 @@ => .(len (dec len)) =+ mig=(cut 3 [len 1] cry) %+ can 3 - %- flop ^- (list {@ @}) + %- flop ^- (list [@ @]) :- [1 (xaro len (zart mig))] - |- ^- (list {@ @}) + |- ^- (list [@ @]) ?: =(0 len) ~ => .(len (dec len)) =+ mog=(cut 3 [len 1] cry) [[1 :(mix mig (end 3 1 len) (zyrt mog))] $(mig mog)] :: - ++ xafo |=({a=@ b=@} +((mod (add (dec b) a) 255))) - ++ xaro |=({a=@ b=@} +((mod (add (dec b) (sub 255 (mod a 255))) 255))) + ++ xafo |=([a=@ b=@] +((mod (add (dec b) a) 255))) + ++ xaro |=([a=@ b=@] +((mod (add (dec b) (sub 255 (mod a 255))) 255))) :: ++ zaft :: forward 255-sbox |= a=@D diff --git a/pkg/arvo/lib/pill.hoon b/pkg/arvo/lib/pill.hoon index d1425fbc62..634310db70 100644 --- a/pkg/arvo/lib/pill.hoon +++ b/pkg/arvo/lib/pill.hoon @@ -101,11 +101,11 @@ =; cot [[(flop `path`tyl) `[/text/plain cot]] hav] ^- octs ?- tyl - {%json *} + [%json *] =/ dat .^(json %cx pax) (as-octt:mimes:html (en-json:html dat)) :: - {%txt *} + [%txt *] =/ dat .^(wain %cx pax) (as-octs:mimes:html (of-wain:format dat)) :: diff --git a/pkg/arvo/lib/pprint.hoon b/pkg/arvo/lib/pprint.hoon index ed27f15d77..9957891d5d 100644 --- a/pkg/arvo/lib/pprint.hoon +++ b/pkg/arvo/lib/pprint.hoon @@ -157,7 +157,7 @@ limb ?- -.limb %& (axis-to-cord p.limb) - :: {%| p=@ud q=(unit term) ] + :: [%| p=@ud q=(unit term) ] %| (crip (runt [0 p.limb] ?~(q.limb "," (trip u.q.limb)))) == :: diff --git a/pkg/arvo/lib/pretty-file.hoon b/pkg/arvo/lib/pretty-file.hoon index e5abe9e617..5375338091 100644 --- a/pkg/arvo/lib/pretty-file.hoon +++ b/pkg/arvo/lib/pretty-file.hoon @@ -13,7 +13,7 @@ ?@ pri leaf+?:(((sane %tas) pri) <`@tas`pri> ) =< rose+[" " ?:(- "~[" "[") "]"]^+ - |- ^- {? (list tank)} + |- ^- [? (list tank)] ?~ +.pri [& ^$(pri -.pri) ~] ?@ +.pri diff --git a/pkg/arvo/lib/show-dir.hoon b/pkg/arvo/lib/show-dir.hoon index 32814641a9..bc73b9942a 100644 --- a/pkg/arvo/lib/show-dir.hoon +++ b/pkg/arvo/lib/show-dir.hoon @@ -3,20 +3,20 @@ :::: /hoon/show-dir/lib :: /? 310 -|= {vane=?(%g %c) pax=path des=(map @t ~)} +|= [vane=?(%g %c) pax=path des=(map @t ~)] ^- tank :+ %rose [" " `~] %+ turn (sort ~(tap by des) aor) -|= {kid=@ta ~} +|= [kid=@ta ~] =+ paf=`path`/[kid] =- :+ %rose ["/" ~ ?:(dir "/" ~)] (turn paf |=(a=knot leaf+(trip a))) -|- ^- {dir=? paf=path} +|- ^- [dir=? paf=path] =+ arf=.^(arch (cat 3 vane %y) (weld pax paf)) ?^ fil.arf [| paf] ?~ dir.arf [& paf] :: !! -?. ?=({^ ~ ~} dir.arf) +?. ?=([^ ~ ~] dir.arf) [& paf] $(paf (welp paf /[p.n.dir.arf])) diff --git a/pkg/arvo/lib/sole.hoon b/pkg/arvo/lib/sole.hoon index 8abde25676..66684668a6 100644 --- a/pkg/arvo/lib/sole.hoon +++ b/pkg/arvo/lib/sole.hoon @@ -31,7 +31,7 @@ :: (apply:(apply b) y) :: ++ transmute :: dex as after sin - |= {sin=sole-edit dex=sole-edit} + |= [sin=sole-edit dex=sole-edit] ~| [%transmute sin dex] ^- sole-edit ?: ?=(%mor -.sin) @@ -81,7 +81,7 @@ ++ inverse :: relative inverse |= ted=sole-edit ^- sole-edit - =. ted ?.(?=({%mor * ~} ted) ted i.p.ted) + =. ted ?.(?=([%mor * ~] ted) ted i.p.ted) ?- -.ted %del [%ins p.ted (snag p.ted buf)] %ins [%del p.ted] @@ -97,7 +97,7 @@ :: ++ receive :: naturalize event |= sole-change - ^- {sole-edit sole-share} + ^- [sole-edit sole-share] ?. &(=(his.ler his.ven) (lte own.ler own.ven)) ~| [%receive-sync his+[his.ler his.ven] own+[own.ler own.ven]] !! @@ -110,8 +110,8 @@ [dat abet:(apply(his.ven +(his.ven)) dat)] :: ++ remit :: conditional accept - |= {cal=sole-change ask=$-((list @c) ?)} - ^- {(unit sole-change) sole-share} + |= [cal=sole-change ask=$-((list @c) ?)] + ^- [(unit sole-change) sole-share] =+ old=buf =^ dat +>+<.$ (receive cal) ?: (ask buf) @@ -121,12 +121,12 @@ :: ++ transmit :: outgoing change |= ted=sole-edit - ^- {sole-change sole-share} + ^- [sole-change sole-share] [[[his.ven own.ven] (sham buf) ted] (commit ted)] :: ++ transceive :: receive and invert |= sole-change - ^- {sole-edit sole-share} + ^- [sole-edit sole-share] =+ old=buf =^ dat +>+<.$ (receive +<.$) [(inverse(buf old) dat) +>+<.$] diff --git a/pkg/arvo/lib/test/runner.hoon b/pkg/arvo/lib/test/runner.hoon index 9156432c9e..2f1e708df7 100644 --- a/pkg/arvo/lib/test/runner.hoon +++ b/pkg/arvo/lib/test/runner.hoon @@ -31,7 +31,7 @@ `tang`[[%leaf (weld "FAILED " name)] ~] ::TODO indent :: %+ turn p:run - :: |= {i=tape} + :: |= [i=tape] :: ^- tank :: [%leaf (weld " " i)] p.run diff --git a/pkg/arvo/lib/tree.hoon b/pkg/arvo/lib/tree.hoon index 961db72915..2d0d1174fa 100644 --- a/pkg/arvo/lib/tree.hoon +++ b/pkg/arvo/lib/tree.hoon @@ -17,16 +17,16 @@ ++ read-schem :: decode gapped noun =< (cook to-noun (cook build-grove apex)) |% - ++ noun $@(term {noun noun}) :: shadow + ++ noun $@(term [noun noun]) :: shadow :: improper list of possible entry points - ++ grove $@(term {gap=@ sealed=noun pending=grove}) + ++ grove $@(term [gap=@ sealed=noun pending=grove]) ++ apex ;~(plug sym (star ;~(plug delim sym))) ++ delim ;~(pose (cold 0 dot) (cook lent (plus cab))) ++ to-noun |=(a=grove ?@(a a [sealed.a $(a pending.a)])) ++ build-grove - |= {a=grove b=(list {p=@u q=term})} ^- grove + |= [a=grove b=(list [p=@u q=term])] ^- grove %+ roll b =< .(acc a) - |= {{gap=@u v=term} acc=grove} ^- grove + |= [[gap=@u v=term] acc=grove] ^- grove ?@ acc [gap acc v] ?: (gth gap gap.acc) [gap (to-noun acc) v] acc(pending $(acc pending.acc)) diff --git a/pkg/arvo/lib/urb-split.hoon b/pkg/arvo/lib/urb-split.hoon index 0163d37a5e..1393577101 100644 --- a/pkg/arvo/lib/urb-split.hoon +++ b/pkg/arvo/lib/urb-split.hoon @@ -2,9 +2,9 @@ :::: /hoon/urb-split/lib :: /? 310 -|= {dep=@uvH urb=manx} ^- {hed={@uvh marl} bod={@uvH marl}} +|= [dep=@uvH urb=manx] ^- [hed=[@uvh marl] bod=[@uvH marl]] ~| [%malformed-urb urb] :: XX types -?> ?=({{%html ~} {{%head ~} *} {{%body ~} *} ~} urb) -=+ `{{%html ~} {{%head ~} hed=marl} {{%body ~} bod=marl} ~}`urb +?> ?=([[%html ~] [[%head ~] *] [[%body ~] *] ~] urb) +=+ `[[%html ~] [[%head ~] hed=marl] [[%body ~] bod=marl] ~]`urb :- [dep hed] :: Assume all dependencies are hard [0v0 bod] diff --git a/pkg/arvo/lib/xray.hoon b/pkg/arvo/lib/xray.hoon index 4f952cfb2b..2e6e2f32f4 100644 --- a/pkg/arvo/lib/xray.hoon +++ b/pkg/arvo/lib/xray.hoon @@ -1319,7 +1319,7 @@ :: =^ i=xkey st ^- [xkey xtable] - %+ (fold {xkey xtable} xkey) + %+ (fold ,[xkey xtable] xkey) [[void st] ~(tap in fork)] |= [[k=xkey tbl=xtable] branch=xkey] ^- [xkey xtable] @@ -1417,8 +1417,8 @@ :: coherent `xrole` (where possible, otherwise a %misjunction). :: :: This often needs to restructure things. For example, if we are - :: combining `{{~ ~} {%a ~}}` and `{{~ ~} {%b ~}}`, we should produce - :: `{{~ ~} ?%({%a ~} {%b ~})}`. + :: combining `[[~ ~] [%a ~]]` and `[[~ ~] [%b ~]]`, we should produce + :: `[[~ ~] ?%([%a ~] [%b ~])]`. :: :: This is a massive switch on the xroles of the two arguments. This :: is *very* easy to get wrong, so I structured things this in a diff --git a/pkg/arvo/mar/css.hoon b/pkg/arvo/mar/css.hoon index 91e8173ba3..c4810b2118 100644 --- a/pkg/arvo/mar/css.hoon +++ b/pkg/arvo/mar/css.hoon @@ -14,7 +14,7 @@ -- ++ grab |% :: convert from - ++ mime |=({p=mite q=octs} (@t q.q)) + ++ mime |=([p=mite q=octs] (@t q.q)) ++ noun @t :: clam from %noun -- ++ grad %mime diff --git a/pkg/arvo/mar/dill/belt.hoon b/pkg/arvo/mar/dill/belt.hoon index de3a8d4ca8..8ff233eb38 100644 --- a/pkg/arvo/mar/dill/belt.hoon +++ b/pkg/arvo/mar/dill/belt.hoon @@ -24,7 +24,7 @@ :: %. jon => jo %- ot :: :~ mod+(cu silt (ar (su (perk ~[%ctrl %shift %alt %meta])))) :: :- %key -:: %+ cu |*(a=$%({%str @t} {%act @}) ?+(-.a a %str +.a)) +:: %+ cu |*(a=$%([%str @t} [%act @}) ?+(-.a a %str +.a)) :: =- (of [str+so act+(su (perk -)) ~]) :: :~ %ctrl %shift %alt %meta %entr %esc %caps %uncap :: %pgup %pgdn %home %end %baxp %del %ins @@ -33,7 +33,7 @@ ++ kyev |= kev=^kyev ^- dill-belt:dill ~| dill-belt-incomplete+kev - ?: ?=({%act ?(%ctrl %shift %alt %meta)} q.kev) + ?: ?=([%act ?(%ctrl %shift %alt %meta)] q.kev) [%txt ~] :: ignore =+ mod=(~(del in p.kev) %shift) ?^ mod @@ -43,10 +43,10 @@ q.kev (con 96 q.kev) :: ctrl key decoding =+ cha=(tuba (trip q.kev)) - ?> ?=({@ ~} cha) :: of a single character + ?> ?=([@ ~] cha) :: of a single character ?+ mod !! :: modified by one buckykey - {%ctrl ~ ~} [%ctl i.cha] - {%alt ~ ~} [%met i.cha] + [%ctrl ~ ~] [%ctl i.cha] + [%alt ~ ~] [%met i.cha] == ?@ q.kev [%txt (tuba (trip q.kev))] diff --git a/pkg/arvo/mar/drum-put.hoon b/pkg/arvo/mar/drum-put.hoon index 956c3f4b14..29b6a10c34 100644 --- a/pkg/arvo/mar/drum-put.hoon +++ b/pkg/arvo/mar/drum-put.hoon @@ -2,7 +2,7 @@ :::: /hoon/do-claim/womb/mar :: /? 310 -|_ {path @} +|_ [path @] :: ++ grad %noun ++ grow @@ -11,6 +11,6 @@ -- ++ grab :: convert from |% - ++ noun {path @} :: clam from %noun + ++ noun [path @] :: clam from %noun -- -- diff --git a/pkg/arvo/mar/hoon.hoon b/pkg/arvo/mar/hoon.hoon index a1df60fdcc..b6f590649b 100644 --- a/pkg/arvo/mar/hoon.hoon +++ b/pkg/arvo/mar/hoon.hoon @@ -41,7 +41,7 @@ -- ++ grab |% :: convert from - ++ mime |=({p=mite q=octs} q.q) + ++ mime |=([p=mite q=octs] q.q) ++ noun @t :: clam from %noun ++ txt of-wain:format -- diff --git a/pkg/arvo/mar/html.hoon b/pkg/arvo/mar/html.hoon index 0782defad4..4e161fae16 100644 --- a/pkg/arvo/mar/html.hoon +++ b/pkg/arvo/mar/html.hoon @@ -17,7 +17,7 @@ ++ grab ^? |% :: convert from ++ noun @t :: clam from %noun - ++ mime |=({p=mite q=octs} q.q) :: retrieve form %mime + ++ mime |=([p=mite q=octs] q.q) :: retrieve form %mime -- ++ grad %mime -- diff --git a/pkg/arvo/mar/js.hoon b/pkg/arvo/mar/js.hoon index 3a293b15e4..e8fbe7701a 100644 --- a/pkg/arvo/mar/js.hoon +++ b/pkg/arvo/mar/js.hoon @@ -15,7 +15,7 @@ -- ++ grab |% :: convert from - ++ mime |=({p=mite q=octs} (@t q.q)) + ++ mime |=([p=mite q=octs] (@t q.q)) ++ noun cord :: clam from %noun -- ++ grad %mime diff --git a/pkg/arvo/mar/json.hoon b/pkg/arvo/mar/json.hoon index 80d090d12a..506b708350 100644 --- a/pkg/arvo/mar/json.hoon +++ b/pkg/arvo/mar/json.hoon @@ -17,7 +17,7 @@ -- ++ grab |% :: convert from - ++ mime |=({p=mite q=octs} (fall (rush (@t q.q) apex:de-json) *json)) + ++ mime |=([p=mite q=octs] (fall (rush (@t q.q) apex:de-json) *json)) ++ noun json :: clam from %noun ++ numb numb:enjs ++ time time:enjs diff --git a/pkg/arvo/mar/map.hoon b/pkg/arvo/mar/map.hoon index a943ec82dc..e5d61eeef3 100644 --- a/pkg/arvo/mar/map.hoon +++ b/pkg/arvo/mar/map.hoon @@ -11,7 +11,7 @@ -- ++ grab |% :: convert from - ++ mime |=({p=mite q=octs} (@t q.q)) + ++ mime |=([p=mite q=octs] (@t q.q)) ++ noun cord :: clam from %noun -- ++ grad %mime diff --git a/pkg/arvo/mar/mime.hoon b/pkg/arvo/mar/mime.hoon index aca3f53c78..87e920250b 100644 --- a/pkg/arvo/mar/mime.hoon +++ b/pkg/arvo/mar/mime.hoon @@ -24,6 +24,6 @@ ++ form %mime ++ diff |=(mime +<) ++ pact |=(mime +<) - ++ join |=({mime mime} `(unit mime)`~) + ++ join |=([mime mime] `(unit mime)`~) -- -- diff --git a/pkg/arvo/mar/png.hoon b/pkg/arvo/mar/png.hoon index e891a65716..e68e502cd1 100644 --- a/pkg/arvo/mar/png.hoon +++ b/pkg/arvo/mar/png.hoon @@ -5,7 +5,7 @@ -- ++ grab |% - ++ mime |=({p=mite q=octs} q.q) + ++ mime |=([p=mite q=octs] q.q) ++ noun @t -- ++ grad %mime diff --git a/pkg/arvo/mar/snip.hoon b/pkg/arvo/mar/snip.hoon index 23ffa186d5..86041dc16e 100644 --- a/pkg/arvo/mar/snip.hoon +++ b/pkg/arvo/mar/snip.hoon @@ -7,7 +7,7 @@ ++ words 1 ++ hedtal =| met=marl - |= a=marl ^- {hed=marl tal=marl} + |= a=marl ^- [hed=marl tal=marl] ?~ a [~ ~] ?. ?=(%h1 n.g.i.a) ?: ?=(%meta n.g.i.a) @@ -18,19 +18,19 @@ [c.i.a (weld (flop met) (limit words t.a))] :: ++ limit - |= {lim=@u mal=marl} + |= [lim=@u mal=marl] =< res - |- ^- {rem=@u res=marl} + |- ^- [rem=@u res=marl] ?~ mal [lim ~] ?~ lim [0 ~] - =/ {lam=@u hed=manx} + =/ [lam=@u hed=manx] ?: ?=(_;/(**) i.mal) [lim ;/(tay)]:(deword lim v.i.a.g.i.mal) [rem ele(c res)]:[ele=i.mal $(mal c.i.mal)] [rem - res]:[hed $(lim lam, mal t.mal)] :: ++ deword - |= {lim=@u tay=tape} ^- {lim=@u tay=tape} + |= [lim=@u tay=tape] ^- [lim=@u tay=tape] ?~ tay [lim tay] ?~ lim [0 ~] =+ wer=(dot 1^1 tay) @@ -42,7 +42,7 @@ :: :: =, mimes:html -|_ {hed=marl tal=marl} +|_ [hed=marl tal=marl] ++ grad %mime :: ++ grow :: convert to @@ -57,6 +57,6 @@ -- -- ++ grab |% :: convert from - ++ noun {marl marl} :: clam from %noun + ++ noun [marl marl] :: clam from %noun ++ elem |=(a=manx (hedtal +.a)) -- -- diff --git a/pkg/arvo/mar/sole/action.hoon b/pkg/arvo/mar/sole/action.hoon index 46ac2fec63..149ef5ef16 100644 --- a/pkg/arvo/mar/sole/action.hoon +++ b/pkg/arvo/mar/sole/action.hoon @@ -22,16 +22,16 @@ => [dejs-soft:format ..sole-action] |^ (ot id+so dat+(fo %ret (of det+change tab+ni ~)) ~) ++ fo - |* {a=term b=fist} + |* [a=term b=fist] |=(c=json ?.(=([%s a] c) (b c) (some [a ~]))) :: ++ ra - |* {a={term fist} b=fist} + |* [a=[term fist] b=fist] |= c=json %. c ?.(=(%a -.c) b (pe -.a (ar +.a))) :: ++ ke :: callbacks - |* {gar=* sef=(trap fist)} + |* [gar=* sef=(trap fist)] |= jon=json ^- (unit _gar) =- ~! gar ~! (need -) - ((sef) jon) diff --git a/pkg/arvo/mar/sole/effect.hoon b/pkg/arvo/mar/sole/effect.hoon index bf7e899603..925a278dfe 100644 --- a/pkg/arvo/mar/sole/effect.hoon +++ b/pkg/arvo/mar/sole/effect.hoon @@ -30,7 +30,7 @@ -- -- ++ wush - |= {wid=@u tan=tang} + |= [wid=@u tan=tang] ^- tape (of-wall (turn (flop tan) |=(a=tank (of-wall (wash 0^wid a))))) :: diff --git a/pkg/arvo/mar/txt.hoon b/pkg/arvo/mar/txt.hoon index b90762dfd0..1c349b1822 100644 --- a/pkg/arvo/mar/txt.hoon +++ b/pkg/arvo/mar/txt.hoon @@ -35,7 +35,7 @@ (lurk txt dif) :: ++ join - |= {ali=(urge cord) bob=(urge cord)} + |= [ali=(urge cord) bob=(urge cord)] ^- (unit (urge cord)) |^ =. ali (clean ali) @@ -99,8 +99,8 @@ -- :: ++ mash - |= $: {als=ship ald=desk ali=(urge cord)} - {bos=ship bod=desk bob=(urge cord)} + |= $: [als=ship ald=desk ali=(urge cord)] + [bos=ship bod=desk bob=(urge cord)] == ^- (urge cord) |^ @@ -124,7 +124,7 @@ [i.bob $(ali t.ali, bob t.bob)] ?: (gth p.i.ali (lent p.i.bob)) [i.bob $(p.i.ali (sub p.i.ali (lent p.i.bob)), bob t.bob)] - =/ {fic=(unce cord) ali=(urge cord) bob=(urge cord)} + =/ [fic=(unce cord) ali=(urge cord) bob=(urge cord)] (resolve ali bob) [fic $(ali ali, bob bob)] :: ~ :: here, alice is good for a while, but not for the whole @@ -133,7 +133,7 @@ %| ?- -.i.bob %| - =/ {fic=(unce cord) ali=(urge cord) bob=(urge cord)} + =/ [fic=(unce cord) ali=(urge cord) bob=(urge cord)] (resolve ali bob) [fic $(ali ali, bob bob)] :: @@ -142,7 +142,7 @@ [i.ali $(ali t.ali, bob t.bob)] ?: (gth p.i.bob (lent p.i.ali)) [i.ali $(ali t.ali, p.i.bob (sub p.i.bob (lent p.i.ali)))] - =/ {fic=(unce cord) ali=(urge cord) bob=(urge cord)} + =/ [fic=(unce cord) ali=(urge cord) bob=(urge cord)] (resolve ali bob) [fic $(ali ali, bob bob)] == @@ -192,8 +192,8 @@ [i.wig $(wig t.wig)] :: ++ resolve - |= {ali=(urge cord) bob=(urge cord)} - ^- {fic={%| p=(list cord) q=(list cord)} ali=(urge cord) bob=(urge cord)} + |= [ali=(urge cord) bob=(urge cord)] + ^- [fic=[%| p=(list cord) q=(list cord)] ali=(urge cord) bob=(urge cord)] =- [[%| bac (annotate alc boc bac)] ali bob] |- ^- $: $: bac=(list cord) alc=(list cord) diff --git a/pkg/arvo/mar/xml.hoon b/pkg/arvo/mar/xml.hoon index cc1b39adab..6d52d80242 100644 --- a/pkg/arvo/mar/xml.hoon +++ b/pkg/arvo/mar/xml.hoon @@ -17,5 +17,5 @@ -- :: ++ grab |% :: convert from ++ noun @t :: clam from %noun - ++ mime |=({p=mite q=octs} q.q) :: retrieve form %mime + ++ mime |=([p=mite q=octs] q.q) :: retrieve form %mime -- -- diff --git a/pkg/arvo/sur/kyev.hoon b/pkg/arvo/sur/kyev.hoon index 22186c73f5..8281963f92 100644 --- a/pkg/arvo/sur/kyev.hoon +++ b/pkg/arvo/sur/kyev.hoon @@ -3,8 +3,8 @@ :::: /hoon/kyev/sur :: /? 310 -=- {p=(set ?(%ctrl %shift %alt %meta)) q=$@(cord {%act speck})} -^= speck +=; speck + ,[p=(set ?(%ctrl %shift %alt %meta)) q=$@(cord [%act speck])] $? %ctrl %shift %alt %meta %entr %esc %caps %uncap %pgup %pgdn %home %end %baxp %del %ins %up %down %left %right diff --git a/pkg/arvo/sur/lens.hoon b/pkg/arvo/sur/lens.hoon index 0866797e88..e5f4bae4d4 100644 --- a/pkg/arvo/sur/lens.hoon +++ b/pkg/arvo/sur/lens.hoon @@ -5,30 +5,30 @@ sink=sink == ++ source - $% {%data data=@} - {%dojo command=@t} - {%clay pax=@t} - {%url url=purl:eyre} - {%api api=term command=@t} - {%get-api api=term endpoint=(list @t)} - {%as mar=mark next=source} :: can't be at the - {%hoon code=@t next=source} :: end since they - {%tuple next=(list source)} :: don't bunt well - {%listen-api api=term event=term} - {%export app=@t} - {%import app=@t base64-jam=@t} - {%export-all ~} - {%import-all base64-jam=@t} + $% [%data data=@] + [%dojo command=@t] + [%clay pax=@t] + [%url url=purl:eyre] + [%api api=term command=@t] + [%get-api api=term endpoint=(list @t)] + [%as mar=mark next=source] :: can't be at the + [%hoon code=@t next=source] :: end since they + [%tuple next=(list source)] :: don't bunt well + [%listen-api api=term event=term] + [%export app=@t] + [%import app=@t base64-jam=@t] + [%export-all ~] + [%import-all base64-jam=@t] == ++ sink - $% {%stdout ~} - {%output-file pax=@t} - {%output-pill pax=@t} - {%output-clay pax=path} - {%url url=purl:eyre} - {%to-api api=term command=@t} - {%send-api api=term endpoint=(list @t)} - {%command command=@t} - {%app app=term} + $% [%stdout ~] + [%output-file pax=@t] + [%output-pill pax=@t] + [%output-clay pax=path] + [%url url=purl:eyre] + [%to-api api=term command=@t] + [%send-api api=term endpoint=(list @t)] + [%command command=@t] + [%app app=term] == -- diff --git a/pkg/arvo/sur/sole.hoon b/pkg/arvo/sur/sole.hoon index 733b55bbfe..fa21c96ee2 100644 --- a/pkg/arvo/sur/sole.hoon +++ b/pkg/arvo/sur/sole.hoon @@ -3,58 +3,58 @@ :: ^? |% -++ sole-action :: sole to app ++$ sole-action :: sole to app $: id=@ta :: duct id $= dat - $% :: {%abo ~} :: reset interaction - {%det sole-change} :: command line edit - {%ret ~} :: submit and clear - {%clr ~} :: exit context - {%tab pos=@ud} :: tab complete + $% :: [%abo ~] :: reset interaction + [%det sole-change] :: command line edit + [%ret ~] :: submit and clear + [%clr ~] :: exit context + [%tab pos=@ud] :: tab complete == :: == -++ sole-buffer (list @c) :: command state -++ sole-change :: network change ++$ sole-buffer (list @c) :: command state ++$ sole-change :: network change $: ler=sole-clock :: destination clock haw=@uvH :: source hash ted=sole-edit :: state change == :: -++ sole-clock {own=@ud his=@ud} :: vector clock -++ sole-edit :: shared state change - $% {%del p=@ud} :: delete one at - {%ins p=@ud q=@c} :: insert at - {%mor p=(list sole-edit)} :: combination - {%nop ~} :: no-op - {%set p=sole-buffer} :: discontinuity ++$ sole-clock [own=@ud his=@ud] :: vector clock ++$ sole-edit :: shared state change + $% [%del p=@ud] :: delete one at + [%ins p=@ud q=@c] :: insert at + [%mor p=(list sole-edit)] :: combination + [%nop ~] :: no-op + [%set p=sole-buffer] :: discontinuity == :: -++ sole-effect :: app to sole - $% {%bel ~} :: beep - {%blk p=@ud q=@c} :: blink+match char at - {%clr ~} :: clear screen - {%det sole-change} :: edit command - {%err p=@ud} :: error point - {%klr p=styx} :: styled text line - {%mor p=(list sole-effect)} :: multiple effects - {%nex ~} :: save clear command - {%pro sole-prompt} :: set prompt - {%sag p=path q=*} :: save to jamfile - {%sav p=path q=@} :: save to file - {%tab p=(list {=cord =tank})} :: tab-complete list - {%tan p=(list tank)} :: classic tank - :: {%taq p=tanq} :: modern tank - {%txt p=tape} :: text line - {%url p=@t} :: activate url ++$ sole-effect :: app to sole + $% [%bel ~] :: beep + [%blk p=@ud q=@c] :: blink+match char at + [%clr ~] :: clear screen + [%det sole-change] :: edit command + [%err p=@ud] :: error point + [%klr p=styx] :: styled text line + [%mor p=(list sole-effect)] :: multiple effects + [%nex ~] :: save clear command + [%pro sole-prompt] :: set prompt + [%sag p=path q=*] :: save to jamfile + [%sav p=path q=@] :: save to file + [%tab p=(list [=cord =tank])] :: tab-complete list + [%tan p=(list tank)] :: classic tank + :: [%taq p=tanq] :: modern tank + [%txt p=tape] :: text line + [%url p=@t] :: activate url == :: -++ sole-command :: command state ++$ sole-command :: command state $: pos=@ud :: cursor position say=sole-share :: cursor == :: -++ sole-prompt :: prompt definition ++$ sole-prompt :: prompt definition $: vis=? :: command visible tag=term :: history mode cad=styx :: caption == :: -++ sole-share :: symmetric state ++$ sole-share :: symmetric state $: ven=sole-clock :: our vector clock leg=(list sole-edit) :: unmerged edits buf=sole-buffer :: sole state @@ -65,7 +65,7 @@ |* out=$-(* *) :: output structure $-(sole-input (sole-result out)) :: output function :: :: -++ sole-input tape :: prompt input ++$ sole-input tape :: prompt input ++ sole-result :: conditional result |* out=$-(* *) :: output structure $@(@ud (sole-product out)) :: error position @@ -76,13 +76,11 @@ %+ each (unit out) :: ~ is abort (pair sole-prompt (sole-dialog out)) :: ask and continue :: :: -++ sole-gen :: XX virtual type - $% {%say $-((sole-args) (cask))} :: direct noun - {%ask $-((sole-args) (sole-product (cask)))} :: dialog ++$ sole-gen :: XX virtual type + $% [%say $-((sole-args) (cask))] :: direct noun + [%ask $-((sole-args) (sole-product (cask)))] :: dialog == :: ++ sole-args :: generator arguments |* _[* *] :: - {{now=@da eny=@uvJ bek=beak} {,+<- ,+<+}} :: -:: :: -:: :: + ,[[now=@da eny=@uvJ bek=beak] [,+<- ,+<+]] :: -- diff --git a/pkg/arvo/sur/urb.hoon b/pkg/arvo/sur/urb.hoon index dfd87e1c39..9107bf306e 100644 --- a/pkg/arvo/sur/urb.hoon +++ b/pkg/arvo/sur/urb.hoon @@ -2,4 +2,4 @@ :: :::: /hoon/urb/sur :: -{hed={dep=@uvH ele=marl} bod={dep=@uvH ele=marl}} +[hed=[dep=@uvH ele=marl] bod=[dep=@uvH ele=marl]] diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index d5cdce34ab..7296a354d7 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -343,10 +343,10 @@ ~/ %sloy |= sod=slyd ^- slyt - |= {ref=* raw=*} + |= [ref=* raw=*] =+ pux=((soft path) raw) ?~ pux ~ - ?. ?=({@ @ @ @ *} u.pux) ~ + ?. ?=([@ @ @ @ *] u.pux) ~ =+ :* hyr=?~(i.u.pux (some %$) (slaw %tas i.u.pux)) fal=(slaw %p i.t.u.pux) dyc=?~(i.t.t.u.pux (some %$) (slaw %tas i.t.t.u.pux)) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 0b187e285d..152876e26a 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -234,22 +234,22 @@ :: :: :: ++ aftr |*(a=$-(* *) |*(b=$-(* *) (pair b a))) :: pair after -++ cork |*({a=$-(* *) b=$-(* *)} (corl b a)) :: compose forward +++ cork |*([a=$-(* *) b=$-(* *)] (corl b a)) :: compose forward ++ corl :: compose backwards - |* {a=$-(* *) b=$-(* *)} + |* [a=$-(* *) b=$-(* *)] =< +:|.((a (b))) :: type check =+ c=+<.b |@ ++ $ (a (b c)) -- :: ++ cury :: curry left - |* {a=$-(^ *) b=*} + |* [a=$-(^ *) b=*] =+ c=+<+.a |@ ++ $ (a b c) -- :: ++ curr :: curry right - |* {a=$-(^ *) c=*} + |* [a=$-(^ *) c=*] =+ b=+<+.a |@ ++ $ (a b c) -- @@ -269,7 +269,7 @@ :: :: the most basic of data types +| %containers -++ bloq ++$ bloq :: blocksize :: :: a blocksize is the power of 2 size of an atom. ie, 3 is a byte as 2^3 is @@ -287,7 +287,7 @@ [%& p=this] == :: -++ gate ++$ gate :: function :: :: a core with one arm, `$`--the empty name--which transforms a sample noun @@ -320,7 +320,7 @@ :: homogeneous type {a} with at least one element. [i=item t=(list item)] :: -++ mold ++$ mold :: normalizing gate :: :: a gate that accepts any noun, and validates its shape, producing the @@ -430,12 +430,12 @@ :: fall, flit, lift, mate, need, some :: :: ++ biff :: apply - |* {a=(unit) b=$-(* (unit))} + |* [a=(unit) b=$-(* (unit))] ?~ a ~ (b u.a) :: ++ bind :: argue - |* {a=(unit) b=gate} + |* [a=(unit) b=gate] ?~ a ~ [~ u=(b u.a)] :: @@ -446,19 +446,19 @@ u.b :: ++ both :: all the above - |* {a=(unit) b=(unit)} + |* [a=(unit) b=(unit)] ?~ a ~ ?~ b ~ [~ u=[u.a u.b]] :: ++ clap :: combine - |* {a=(unit) b=(unit) c=_=>(~ |=(^ +<-))} + |* [a=(unit) b=(unit) c=_=>(~ |=(^ +<-))] ?~ a b ?~ b a [~ u=(c u.a u.b)] :: ++ clef :: compose - |* {a=(unit) b=(unit) c=_=>(~ |=(^ `+<-))} + |* [a=(unit) b=(unit) c=_=>(~ |=(^ `+<-))] ?~ a ~ ?~ b ~ (c u.a u.b) @@ -469,7 +469,7 @@ [i=u.a t=~] :: ++ fall :: default - |* {a=(unit) b=*} + |* [a=(unit) b=*] ?~(a b u.a) :: ++ flit :: make filter @@ -493,7 +493,7 @@ (bind b a) :: bind :: ++ mate :: choose - |* {a=(unit) b=(unit)} + |* [a=(unit) b=(unit)] ?~ b a ?~ a b ?.(=(u.a u.b) ~>(%mean.'mate' !!) a) @@ -520,7 +520,7 @@ :: ++ fand :: all indices ~/ %fand - |= {nedl=(list) hstk=(list)} + |= [nedl=(list) hstk=(list)] =| i=@ud =| fnd=(list @ud) |- ^+ fnd @@ -536,7 +536,7 @@ :: ++ find :: first index ~/ %find - |= {nedl=(list) hstk=(list)} + |= [nedl=(list) hstk=(list)] =| i=@ud |- ^- (unit @ud) =+ [n=nedl h=hstk] @@ -560,7 +560,7 @@ $(a t.a, b [i.a b]) :: ++ gulf :: range inclusive - |= {a=@ b=@} + |= [a=@ b=@] ?> (lte a b) |- ^- (list @) ?:(=(a +(b)) ~ [a $(a +(a))]) @@ -601,7 +601,7 @@ :: ++ levy ~/ %levy :: all of - |* {a=(list) b=$-(* ?)} + |* [a=(list) b=$-(* ?)] |- ^- ? ?~ a & ?. (b i.a) | @@ -609,7 +609,7 @@ :: ++ lien :: some of ~/ %lien - |* {a=(list) b=$-(* ?)} + |* [a=(list) b=$-(* ?)] |- ^- ? ?~ a | ?: (b i.a) & @@ -624,7 +624,7 @@ :: ++ murn :: maybe transform ~/ %murn - |* {a=(list) b=$-(* (unit))} + |* [a=(list) b=$-(* (unit))] => .(a (homo a)) |- ^- (list _?>(?=(^ a) (need (b i.a)))) ?~ a ~ @@ -634,12 +634,12 @@ :: ++ oust :: remove ~/ %oust - |* {{a=@ b=@} c=(list)} + |* [[a=@ b=@] c=(list)] (weld (scag +<-< c) (slag (add +<-< +<->) c)) :: ++ reap :: replicate ~/ %reap - |* {a=@ b=*} + |* [a=@ b=*] |- ^- (list _b) ?~ a ~ [b $(a (dec a))] @@ -654,7 +654,7 @@ :: ++ reel :: right fold ~/ %reel - |* {a=(list) b=_=>(~ |=({* *} +<+))} + |* [a=(list) b=_=>(~ |=([* *] +<+))] |- ^+ ,.+<+.b ?~ a +<+.b @@ -662,7 +662,7 @@ :: ++ roll :: left fold ~/ %roll - |* {a=(list) b=_=>(~ |=({* *} +<+))} + |* [a=(list) b=_=>(~ |=([* *] +<+))] |- ^+ ,.+<+.b ?~ a +<+.b @@ -670,14 +670,14 @@ :: ++ scag :: prefix ~/ %scag - |* {a=@ b=(list)} + |* [a=@ b=(list)] |- ^+ b ?: |(?=(~ b) =(0 a)) ~ [i.b $(b t.b, a (dec a))] :: ++ skid :: separate ~/ %skid - |* {a=(list) b=$-(* ?)} + |* [a=(list) b=$-(* ?)] |- ^+ [p=a q=a] ?~ a [~ ~] =+ c=$(a t.a) @@ -685,7 +685,7 @@ :: ++ skim :: only ~/ %skim - |* {a=(list) b=$-(* ?)} + |* [a=(list) b=$-(* ?)] |- ^+ a ?~ a ~ @@ -693,7 +693,7 @@ :: ++ skip :: except ~/ %skip - |* {a=(list) b=$-(* ?)} + |* [a=(list) b=$-(* ?)] |- ^+ a ?~ a ~ @@ -701,7 +701,7 @@ :: ++ slag :: suffix ~/ %slag - |* {a=@ b=(list)} + |* [a=@ b=(list)] |- ^+ b ?: =(0 a) b ?~ b ~ @@ -709,7 +709,7 @@ :: ++ snag :: index ~/ %snag - |* {a=@ b=(list)} + |* [a=@ b=(list)] |- ^+ ?>(?=(^ b) i.b) ?~ b ~_ leaf+"snag-fail" @@ -727,7 +727,7 @@ :: ++ sort !. :: quicksort ~/ %sort - |* {a=(list) b=$-({* *} ?)} + |* [a=(list) b=$-([* *] ?)] => .(a ^.(homo a)) |- ^+ a ?~ a ~ @@ -763,7 +763,7 @@ p:(spin a +<+.b b) :: ++ swag :: slice - |* {{a=@ b=@} c=(list)} + |* [[a=@ b=@] c=(list)] (scag +<-> (slag +<-< c)) :: +turn: transform each value of list :a using the function :b :: @@ -778,7 +778,7 @@ :: ++ weld :: concatenate ~/ %weld - |* {a=(list) b=(list)} + |* [a=(list) b=(list)] => .(a ^.(homo a), b ^.(homo b)) |- ^+ b ?~ a b @@ -798,7 +798,7 @@ :: ++ welp :: faceless weld ~/ %welp - =| {* *} + =| [* *] |@ ++ $ ?~ +<- @@ -828,28 +828,28 @@ :: ++ can :: assemble ~/ %can - |= {a=bloq b=(list {p=@u q=@})} + |= [a=bloq b=(list [p=@u q=@])] ^- @ ?~ b 0 (add (end a p.i.b q.i.b) (lsh a p.i.b $(b t.b))) :: ++ cat :: concatenate ~/ %cat - |= {a=bloq b=@ c=@} + |= [a=bloq b=@ c=@] (add (lsh a (met a b) c) b) :: ++ cut :: slice ~/ %cut - |= {a=bloq {b=@u c=@u} d=@} + |= [a=bloq [b=@u c=@u] d=@] (end a c (rsh a b d)) :: ++ end :: tail ~/ %end - |= {a=bloq b=@u c=@} + |= [a=bloq b=@u c=@] (mod c (bex (mul (bex a) b))) :: ++ fil :: fill bloqstream - |= {a=bloq b=@u c=@} + |= [a=bloq b=@u c=@] =+ n=0 =+ d=c |- ^- @ @@ -859,12 +859,12 @@ :: ++ lsh :: left-shift ~/ %lsh - |= {a=bloq b=@u c=@} + |= [a=bloq b=@u c=@] (mul (bex (mul (bex a) b)) c) :: ++ met :: measure ~/ %met - |= {a=bloq b=@} + |= [a=bloq b=@] ^- @ =+ c=0 |- @@ -873,7 +873,7 @@ :: ++ rap :: assemble nonzero ~/ %rap - |= {a=bloq b=(list @)} + |= [a=bloq b=(list @)] ^- @ =+ ~ ::REMOVEME jet dashboard bump ?~ b 0 @@ -881,7 +881,7 @@ :: ++ rep :: assemble single ~/ %rep - |= {a=bloq b=(list @)} + |= [a=bloq b=(list @)] ^- @ =+ c=0 |- @@ -914,26 +914,26 @@ :: ++ ripn ~/ %ripn - |= {bits=@ud x=@} + |= [bits=@ud x=@] ^- (list @) ?: =(0 x) ~ [(end 0 bits x) $(x (rsh 0 bits x))] :: ++ rip :: disassemble ~/ %rip - |= {=bloq x=@} + |= [=bloq x=@] ^- (list @) ?: =(0 x) ~ [(end bloq 1 x) $(x (rsh bloq 1 x))] :: ++ rsh :: right-shift ~/ %rsh - |= {a=bloq b=@u c=@} + |= [a=bloq b=@u c=@] (div c (bex (mul (bex a) b))) :: ++ swp :: naive rev bloq order ~/ %swp - |= {a=bloq b=@} + |= [a=bloq b=@] (rep a (flop (rip a b))) :: ++ xeb :: binary logarithm @@ -945,7 +945,7 @@ ++ fe :: modulo bloq |_ a=bloq ++ dif :: difference - |=({b=@ c=@} (sit (sub (add out (sit b)) (sit c)))) + |=([b=@ c=@] (sit (sub (add out (sit b)) (sit c)))) ++ inv |=(b=@ (sub (dec out) (sit b))) :: inverse ++ net |= b=@ ^- @ :: flip byte endianness => .(b (sit b)) @@ -956,17 +956,17 @@ (lsh c 1 $(a c, b (cut c [0 1] b))) $(a c, b (cut c [1 1] b)) ++ out (bex (bex a)) :: mod value - ++ rol |= {b=bloq c=@ d=@} ^- @ :: roll left + ++ rol |= [b=bloq c=@ d=@] ^- @ :: roll left =+ e=(sit d) =+ f=(bex (sub a b)) =+ g=(mod c f) (sit (con (lsh b g e) (rsh b (sub f g) e))) - ++ ror |= {b=bloq c=@ d=@} ^- @ :: roll right + ++ ror |= [b=bloq c=@ d=@] ^- @ :: roll right =+ e=(sit d) =+ f=(bex (sub a b)) =+ g=(mod c f) (sit (con (rsh b g e) (lsh b (sub f g) e))) - ++ sum |=({b=@ c=@} (sit (add b c))) :: wrapping add + ++ sum |=([b=@ c=@] (sit (add b c))) :: wrapping add ++ sit |=(b=@ (end a 1 b)) :: enforce modulo -- :: :: @@ -975,7 +975,7 @@ :: ++ con :: binary or ~/ %con - |= {a=@ b=@} + |= [a=@ b=@] =+ [c=0 d=0] |- ^- @ ?: ?&(=(0 a) =(0 b)) d @@ -992,8 +992,8 @@ :: ++ dis :: binary and ~/ %dis - |= {a=@ b=@} - =| {c=@ d=@} + |= [a=@ b=@] + =| [c=@ d=@] |- ^- @ ?: ?|(=(0 a) =(0 b)) d %= $ @@ -1009,7 +1009,7 @@ :: ++ mix :: binary xor ~/ %mix - |= {a=@ b=@} + |= [a=@ b=@] ^- @ =+ [c=0 d=0] |- @@ -1021,7 +1021,7 @@ d (add d (lsh 0 c =((end 0 1 a) (end 0 1 b)))) == :: -++ not |= {a=bloq b=@ c=@} :: binary not (sized) +++ not |= [a=bloq b=@ c=@] :: binary not (sized) (mix c (dec (bex (mul b (bex a))))) :: :: :::: 2e: insecure hashing :: @@ -1113,7 +1113,7 @@ :: ++ aor ~/ %aor - |= {a=* b=*} + |= [a=* b=*] ^- ? ?: =(a b) & ?. ?=(@ a) @@ -1133,7 +1133,7 @@ :: ++ dor ~/ %dor - |= {a=* b=*} + |= [a=* b=*] ^- ? ?: =(a b) & ?. ?=(@ a) @@ -1149,7 +1149,7 @@ :: ++ gor ~/ %gor - |= {a=* b=*} + |= [a=* b=*] ^- ? =+ [c=(mug a) d=(mug b)] ?: =(c d) @@ -1161,7 +1161,7 @@ :: ++ mor ~/ %mor - |= {a=* b=*} + |= [a=* b=*] ^- ? =+ [c=(mug (mug a)) d=(mug (mug b))] ?: =(c d) @@ -1174,7 +1174,7 @@ :: ++ pow :: unsigned exponent ~/ %pow - |= {a=@ b=@} + |= [a=@ b=@] ?: =(b 0) 1 |- ?: =(b 1) a =+ c=$(b (div b 2)) @@ -1183,7 +1183,7 @@ :: ++ sqt :: unsigned sqrt/rem ~/ %sqt - |= a=@ ^- {p=@ q=@} + |= a=@ ^- [p=@ q=@] ?~ a [0 0] =+ [q=(div (dec (xeb a)) 2) r=0] =- [-.b (sub a +.b)] @@ -1224,7 +1224,7 @@ ++ apt :: check correctness =< $ ~/ %apt - =| {l=(unit) r=(unit)} + =| [l=(unit) r=(unit)] |. ^- ? ?~ a & ?& ?~(l & (gor n.a u.l)) @@ -1261,7 +1261,7 @@ ?: (gor b n.a) a(l $(a l.a)) a(r $(a r.a)) - |- ^- {$?(~ _a)} + |- ^- [$?(~ _a)] ?~ l.a r.a ?~ r.a l.a ?: (mor n.l.a n.r.a) @@ -1280,7 +1280,7 @@ ?> ?=(^ c) =+ d=$(a l.c, b l.b) =+ e=$(a r.c, b r.b) - |- ^- {$?(~ _a)} + |- ^- [$?(~ _a)] ?~ d e ?~ e d ?: (mor n.d n.e) @@ -1375,7 +1375,7 @@ :: ++ rep :: reduce to product ~/ %rep - |* b=_=>(~ |=({* *} +<+)) + |* b=_=>(~ |=([* *] +<+)) |- ?~ a +<+.b $(a r.a, +<+.b $(a l.a, +<+.b (b n.a +<+.b))) @@ -1453,7 +1453,7 @@ :: ++ bif :: splits a by b ~/ %bif - |* {b=* c=*} + |* [b=* c=*] ^+ [l=a r=a] =< + |- ^+ a @@ -1481,7 +1481,7 @@ ?: (gor b p.n.a) a(l $(a l.a)) a(r $(a r.a)) - |- ^- {$?(~ _a)} + |- ^- [$?(~ _a)] ?~ l.a r.a ?~ r.a l.a ?: (mor p.n.l.a p.n.r.a) @@ -1500,7 +1500,7 @@ ?> ?=(^ c) =+ d=$(a l.c, b l.b) =+ e=$(a r.c, b r.b) - |- ^- {$?(~ _a)} + |- ^- [$?(~ _a)] ?~ d e ?~ e d ?: (mor p.n.d p.n.e) @@ -1521,7 +1521,7 @@ ++ apt :: check correctness =< $ ~/ %apt - =| {l=(unit) r=(unit)} + =| [l=(unit) r=(unit)] |. ^- ? ?~ a & ?& ?~(l & &((gor p.n.a u.l) !=(p.n.a u.l))) @@ -1534,7 +1534,7 @@ :: ++ gas :: concatenate ~/ %gas - |* b=(list {p=* q=*}) + |* b=(list [p=* q=*]) => .(b `(list _?>(?=(^ a) n.a))`b) |- ^+ a ?~ b @@ -1606,14 +1606,14 @@ a(r $(a r.a)) :: ++ mar :: add with validation - |* {b=* c=(unit *)} + |* [b=* c=(unit *)] ?~ c (del b) (put b u.c) :: ++ put :: adds key-value pair ~/ %put - |* {b=* c=*} + |* [b=* c=*] |- ^+ a ?~ a [[b c] ~ ~] @@ -1635,13 +1635,13 @@ :: ++ rep :: reduce to product ~/ %rep - |* b=_=>(~ |=({* *} +<+)) + |* b=_=>(~ |=([* *] +<+)) |- ?~ a +<+.b $(a r.a, +<+.b $(a l.a, +<+.b (b n.a +<+.b))) :: ++ rib :: transform + product - |* {b=* c=gate} + |* [b=* c=gate] |- ^+ [b a] ?~ a [b ~] =+ d=(c n.a b) @@ -1697,7 +1697,7 @@ =+ b=a |@ ++ $ - |= meg=$-({_p:node _q:node _q:node} _q:node) + |= meg=$-([_p:node _q:node _q:node] _q:node) |- ^+ a ?~ b a @@ -1719,7 +1719,7 @@ :: ++ urn :: apply gate to nodes ~/ %urn - |* b=$-({* *} *) + |* b=$-([* *] *) |- ?~ a ~ a(n n.a(q (b p.n.a q.n.a)), l $(a l.a), r $(a r.a)) @@ -1757,7 +1757,7 @@ ?~(c ~ u.c) :: ++ add :: adds key-list pair - |* {b=* c=*} + |* [b=* c=*] =+ d=(get b) (~(put by a) b [c d]) -- @@ -1765,7 +1765,7 @@ =| a=(tree (pair * (tree))) :: (jug) |@ ++ del :: del key-set pair - |* {b=* c=*} + |* [b=* c=*] ^+ a =+ d=(get b) =+ e=(~(del in d) c) @@ -1774,8 +1774,8 @@ (~(put by a) b e) :: ++ gas :: concatenate - |* b=(list {p=* q=*}) - => .(b `(list _?>(?=({{* ^} ^} a) [p=p q=n.q]:n.a))`b) + |* b=(list [p=* q=*]) + => .(b `(list _?>(?=([[* ^] ^] a) [p=p q=n.q]:n.a))`b) |- ^+ a ?~ b a @@ -1787,12 +1787,12 @@ ?~(c ~ u.c) :: ++ has :: existence check - |* {b=* c=*} + |* [b=* c=*] ^- ? (~(has in (get b)) c) :: ++ put :: add key-set pair - |* {b=* c=*} + |* [b=* c=*] ^+ a =+ d=(get b) (~(put by a) b (~(put in d) c)) @@ -1904,11 +1904,11 @@ :: ++ malt :: map from list |* a=(list) - (molt `(list {p=_-<.a q=_->.a})`a) + (molt `(list [p=_-<.a q=_->.a])`a) :: ++ molt :: map from pair list |* a=(list (pair)) :: ^- =,(i.-.a (map _p _q)) - (~(gas by `(tree {p=_p.i.-.a q=_q.i.-.a})`~) a) + (~(gas by `(tree [p=_p.i.-.a q=_q.i.-.a])`~) a) :: ++ silt :: set from list |* a=(list) :: ^- (set _i.-.a) @@ -1948,7 +1948,7 @@ (~(gas in `(set _i.-.a)`~) a) :: :: ++ snag :: index - |* {a=@ b=(list)} + |* [a=@ b=(list)] ?~ b ~_ leaf+"snag-fail" !! @@ -1956,7 +1956,7 @@ $(b t.b, a (dec a)) :: :: ++ weld :: concatenate - |* {a=(list) b=(list)} + |* [a=(list) b=(list)] => .(a ^+((le a) a), b ^+((le b) b)) =+ 42 |- @@ -1973,7 +1973,7 @@ +$ char @t :: UTF8 byte +$ cord @t :: UTF8, LSB first +$ byts [wid=@ud dat=@] :: bytes, MSB first -+$ date {{a=? y=@ud} m=@ud t=tarp} :: parsed date ++$ date [[a=? y=@ud] m=@ud t=tarp] :: parsed date +$ knot @ta :: ASCII text +$ noun * :: any noun +$ path (list knot) :: like unix path @@ -2003,7 +2003,7 @@ :: +$ tape (list @tD) :: utf8 string as list +$ tour (list @c) :: utf32 clusters -+$ tarp {d=@ud h=@ud m=@ud s=@ud f=(list @ux)} :: parsed time ++$ tarp [d=@ud h=@ud m=@ud s=@ud f=(list @ux)] :: parsed time +$ term @tas :: ascii symbol +$ wain (list cord) :: text lines +$ wall (list tape) :: text lines @@ -2018,7 +2018,7 @@ =+ b=0 =+ m=`(map @ *)`~ =< q - |- ^- {p=@ q=* r=(map @ *)} + |- ^- [p=@ q=* r=(map @ *)] ?: =(0 (cut 0 [b 1] a)) =+ c=(rub +(b) a) [+(p.c) q.c (~(put by m) b q.c)] @@ -2038,7 +2038,7 @@ =+ b=0 =+ m=`(map * @)`~ =< q - |- ^- {p=@ q=@ r=(map * @)} + |- ^- [p=@ q=@ r=(map * @)] =+ c=(~(get by m) a) ?~ c => .(m (~(put by m) a b)) @@ -2058,7 +2058,7 @@ ++ mat :: length-encode ~/ %mat |= a=@ - ^- {p=@ q=@} + ^- [p=@ q=@] ?: =(0 a) [1 1] =+ b=(met 0 a) @@ -2068,8 +2068,8 @@ :: ++ rub :: length-decode ~/ %rub - |= {a=@ b=@} - ^- {p=@ q=@} + |= [a=@ b=@] + ^- [p=@ q=@] =+ ^= c =+ [c=0 m=(met 0 b)] |- ?< (gth c m) @@ -2085,23 +2085,23 @@ ++ fn :: float, infinity, or NaN :: s=sign, e=exponent, a=arithmetic form :: (-1)^s * a * 2^e - $% {%f s=? e=@s a=@u} - {%i s=?} - {%n ~} + $% [%f s=? e=@s a=@u] + [%i s=?] + [%n ~] == :: ++ dn :: decimal float, infinity, or NaN :: (-1)^s * a * 10^e - $% {%d s=? e=@s a=@u} - {%i s=?} - {%n ~} + $% [%d s=? e=@s a=@u] + [%i s=?] + [%n ~] == :: ++ rn :: parsed decimal float :: - $% {%d a=? b={c=@ {d=@ e=@} f=? i=@}} - {%i a=?} - {%n ~} + $% [%d a=? b=[c=@ [d=@ e=@] f=? i=@]] + [%i a=?] + [%n ~] == -- => :: :: @@ -2127,11 +2127,11 @@ :: :: :: ++ egcd :: schneier's egcd - |= {a=@ b=@} + |= [a=@ b=@] =+ si =+ [c=(sun a) d=(sun b)] =+ [u=[c=(sun 1) d=--0] v=[c=--0 d=(sun 1)]] - |- ^- {d=@ u=@s v=@s} + |- ^- [d=@ u=@s v=@s] ?: =(--0 c) [(abs d) d.u d.v] :: ?> ?& =(c (sum (pro (sun a) c.u) (pro (sun b) c.v))) @@ -2149,11 +2149,11 @@ ^| |_ a=@ ++ dif - |= {b=@ c=@} + |= [b=@ c=@] (sit (sub (add a b) (sit c))) :: ++ exp - |= {b=@ c=@} + |= [b=@ c=@] ?: =(0 b) 1 =+ d=$(b (rsh 0 1 b)) @@ -2161,7 +2161,7 @@ ?:(=(0 (end 0 1 b)) e (pro c e)) :: ++ fra - |= {b=@ c=@} + |= [b=@ c=@] (pro b (inv c)) :: ++ inv @@ -2170,7 +2170,7 @@ c :: ++ pro - |= {b=@ c=@} + |= [b=@ c=@] (sit (mul b c)) :: ++ sit @@ -2178,7 +2178,7 @@ (mod b a) :: ++ sum - |= {b=@ c=@} + |= [b=@ c=@] (sit (add b c)) -- :: @@ -2186,19 +2186,19 @@ ^? |% ++ abs |=(a=@s (add (end 0 1 a) (rsh 0 1 a))) :: absolute value - ++ dif |= {a=@s b=@s} :: subtraction + ++ dif |= [a=@s b=@s] :: subtraction (sum a (new !(syn b) (abs b))) - ++ dul |= {a=@s b=@} :: modulus + ++ dul |= [a=@s b=@] :: modulus =+(c=(old a) ?:(-.c (mod +.c b) (sub b +.c))) - ++ fra |= {a=@s b=@s} :: divide + ++ fra |= [a=@s b=@s] :: divide (new =(0 (mix (syn a) (syn b))) (div (abs a) (abs b))) - ++ new |= {a=? b=@} :: [sign value] to @s + ++ new |= [a=? b=@] :: [sign value] to @s `@s`?:(a (mul 2 b) ?:(=(0 b) 0 +((mul 2 (dec b))))) ++ old |=(a=@s [(syn a) (abs a)]) :: [sign value] - ++ pro |= {a=@s b=@s} :: multiplication + ++ pro |= [a=@s b=@s] :: multiplication (new =(0 (mix (syn a) (syn b))) (mul (abs a) (abs b))) - ++ rem |=({a=@s b=@s} (dif a (pro b (fra a b)))) :: remainder - ++ sum |= {a=@s b=@s} :: addition + ++ rem |=([a=@s b=@s] (dif a (pro b (fra a b)))) :: remainder + ++ sum |= [a=@s b=@s] :: addition =+ [c=(old a) d=(old b)] ?: -.c ?: -.d @@ -2213,7 +2213,7 @@ (new | (add +.c +.d)) ++ sun |=(a=@u (mul 2 a)) :: @u to @s ++ syn |=(a=@s =(0 (end 0 1 a))) :: sign test - ++ cmp |= {a=@s b=@s} :: compare + ++ cmp |= [a=@s b=@s] :: compare ^- @s ?: =(a b) --0 @@ -2235,7 +2235,7 @@ :: :: ++ fl :: arb. precision fp - =/ {{p=@u v=@s w=@u} r=$?(%n %u %d %z %a) d=$?(%d %f %i)} + =/ [[p=@u v=@s w=@u] r=$?(%n %u %d %z %a) d=$?(%d %f %i)] [[113 -16.494 32.765] %n %d] :: p=precision: number of bits in arithmetic form; must be at least 2 :: v=min exponent: minimum value of e @@ -2245,14 +2245,14 @@ :: infinite exponent range => ~% %cofl +> ~ - :: internal functions; mostly operating on {e=@s a=@u}, in other words + :: internal functions; mostly operating on [e=@s a=@u], in other words :: positive numbers. many of these error out if a=0. |% ++ rou - |= {a={e=@s a=@u}} ^- fn (rau a &) + |= [a=[e=@s a=@u]] ^- fn (rau a &) :: ++ rau - |= {a={e=@s a=@u} t=?} ^- fn + |= [a=[e=@s a=@u] t=?] ^- fn ?- r %z (lug %fl a t) %d (lug %fl a t) %a (lug %ce a t) %u (lug %ce a t) @@ -2260,7 +2260,7 @@ == :: ++ add :: add; exact if e - |= {a={e=@s a=@u} b={e=@s a=@u} e=?} ^- fn + |= [a=[e=@s a=@u] b=[e=@s a=@u] e=?] ^- fn =+ q=(dif:si e.a e.b) |- ?. (syn:si q) $(b a, a b, q +(q)) :: a has larger exp ?: e @@ -2278,7 +2278,7 @@ (rou [e.b (^add (lsh 0 (abs:si q) a.a) a.b)]) :: ++ sub :: subtract; exact if e - |= {a={e=@s a=@u} b={e=@s a=@u} e=?} ^- fn + |= [a=[e=@s a=@u] b=[e=@s a=@u] e=?] ^- fn =+ q=(dif:si e.a e.b) |- ?. (syn:si q) (fli $(b a, a b, q +(q), r swr)) @@ -2300,11 +2300,11 @@ ?: e [%f & e.b i] (rou [e.b i]) :: ++ mul :: multiply - |= {a={e=@s a=@u} b={e=@s a=@u}} ^- fn + |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- fn (rou (sum:si e.a e.b) (^mul a.a a.b)) :: ++ div :: divide - |= {a={e=@s a=@u} b={e=@s a=@u}} ^- fn + |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- fn =+ [ma=(met 0 a.a) mb=(met 0 a.b)] =+ v=(dif:si (sun:si ma) (sun:si +((^add mb prc)))) =. a ?: (syn:si v) a @@ -2313,7 +2313,7 @@ (rau [j p.q] =(q.q 0)) :: ++ sqt :: square root - |= {a={e=@s a=@u}} ^- fn + |= [a=[e=@s a=@u]] ^- fn =. a =+ [w=(met 0 a.a) x=(^mul +(prc) 2)] =+ ?:((^lth w x) (^sub x w) 0) @@ -2324,7 +2324,7 @@ (rau [z p.y] =(q.y 0)) :: ++ lth :: less-than - |= {a={e=@s a=@u} b={e=@s a=@u}} ^- ? + |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- ? ?: =(e.a e.b) (^lth a.a a.b) =+ c=(cmp:si (ibl a) (ibl b)) ?: =(c -1) & ?: =(c --1) | @@ -2333,7 +2333,7 @@ (^lth (lsh 0 (abs:si (dif:si e.a e.b)) a.a) a.b) :: ++ equ :: equals - |= {a={e=@s a=@u} b={e=@s a=@u}} ^- ? + |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- ? ?. =((ibl a) (ibl b)) | ?: =((cmp:si e.a e.b) -1) =((lsh 0 (abs:si (dif:si e.a e.b)) a.b) a.a) @@ -2341,19 +2341,19 @@ :: :: integer binary logarithm: 2^ibl(a) <= |a| < 2^(ibl(a)+1) ++ ibl - |= {a={e=@s a=@u}} ^- @s + |= [a=[e=@s a=@u]] ^- @s (sum:si (sun:si (dec (met 0 a.a))) e.a) :: :: change to a representation where a.a is odd :: every fn has a unique representation of this kind ++ uni - |= {a={e=@s a=@u}} + |= [a=[e=@s a=@u]] |- ?: =((end 0 1 a.a) 1) a $(a.a (rsh 0 1 a.a), e.a (sum:si e.a --1)) :: :: expands to either full precision or to denormalized ++ xpd - |= {a={e=@s a=@u}} + |= [a=[e=@s a=@u]] =+ ma=(met 0 a.a) ?: (gte ma prc) a =+ ?: =(den %i) (^sub prc ma) @@ -2370,11 +2370,11 @@ :: ++ lug ~/ %lug - |= {t=$?(%fl %ce %sm %lg %ne %na %nt) a={e=@s a=@u} s=?} ^- fn + |= [t=$?(%fl %ce %sm %lg %ne %na %nt) a=[e=@s a=@u] s=?] ^- fn ?< =(a.a 0) =- ?. =(den %f) - :: flush denormals - ?. ?=({%f *} -) - + ?. ?=([%f *] -) - ?: =((met 0 ->+>) prc) - [%f & zer] :: =+ m=(met 0 a.a) @@ -2435,7 +2435,7 @@ :: ++ drg :: dragon4; get ~/ %drg :: printable decimal; - |= {a={e=@s a=@u}} ^- {@s @u} :: guaranteed accurate + |= [a=[e=@s a=@u]] ^- [@s @u] :: guaranteed accurate ?< =(a.a 0) :: for rounded floats =. a (xpd a) =+ r=(lsh 0 ?:((syn:si e.a) (abs:si e.a) 0) a.a) @@ -2484,7 +2484,7 @@ [k o] :: ++ toj :: round to integer - |= {a={e=@s a=@u}} ^- fn + |= [a=[e=@s a=@u]] ^- fn ?. =((cmp:si e.a --0) -1) [%f & a] =+ x=(abs:si e.a) =+ y=(rsh 0 x a.a) @@ -2495,19 +2495,19 @@ ?: &(=(z i) =((dis y 1) 0)) [%f & --0 y] ?: (^lth z i) [%f & --0 y] [%f & --0 +(y)] :: - ++ ned :: require ?=({%f *} a) - |= {a=fn} ^- {%f s=? e=@s a=@u} - ?: ?=({%f *} a) a + ++ ned :: require ?=([%f *] a) + |= [a=fn] ^- [%f s=? e=@s a=@u] + ?: ?=([%f *] a) a ~_ leaf+"need-float" !! :: ++ shf :: a * 2^b; no rounding - |= {a=fn b=@s} - ?: |(?=({%n *} a) ?=({%i *} a)) a + |= [a=fn b=@s] + ?: |(?=([%n *] a) ?=([%i *] a)) a a(e (sum:si e.a b)) :: ++ fli :: flip sign - |= {a=fn} ^- fn + |= [a=fn] ^- fn ?-(-.a %f a(s !s.a), %i a(s !s.a), %n a) :: ++ swr ?+(r r %d %u, %u %d) :: flipped rounding @@ -2523,33 +2523,33 @@ -- |% ++ rou :: round - |= {a=fn} ^- fn - ?. ?=({%f *} a) a + |= [a=fn] ^- fn + ?. ?=([%f *] a) a ?~ a.a [%f s.a zer] ?: s.a (^rou +>.a) =.(r swr (fli (^rou +>.a))) :: ++ syn :: get sign - |= {a=fn} ^- ? + |= [a=fn] ^- ? ?-(-.a %f s.a, %i s.a, %n &) :: ++ abs :: absolute value - |= {a=fn} ^- fn - ?: ?=({%f *} a) [%f & e.a a.a] - ?: ?=({%i *} a) [%i &] [%n ~] + |= [a=fn] ^- fn + ?: ?=([%f *] a) [%f & e.a a.a] + ?: ?=([%i *] a) [%i &] [%n ~] :: ++ add :: add - |= {a=fn b=fn} ^- fn - ?: |(?=({%n *} a) ?=({%n *} b)) [%n ~] - ?: |(?=({%i *} a) ?=({%i *} b)) - ?: &(?=({%i *} a) ?=({%i *} b)) + |= [a=fn b=fn] ^- fn + ?: |(?=([%n *] a) ?=([%n *] b)) [%n ~] + ?: |(?=([%i *] a) ?=([%i *] b)) + ?: &(?=([%i *] a) ?=([%i *] b)) ?: =(a b) a [%n ~] - ?: ?=({%i *} a) a b + ?: ?=([%i *] a) a b ?: |(=(a.a 0) =(a.b 0)) ?. &(=(a.a 0) =(a.b 0)) %- rou ?~(a.a b a) [%f ?:(=(r %d) &(s.a s.b) |(s.a s.b)) zer] - %- |= {a=fn} - ?. ?=({%f *} a) a + %- |= [a=fn] + ?. ?=([%f *] a) a ?. =(a.a 0) a [%f !=(r %d) zer] ?: =(s.a s.b) @@ -2559,17 +2559,17 @@ (^sub +>.b +>.a |) :: ++ ead :: exact add - |= {a=fn b=fn} ^- fn - ?: |(?=({%n *} a) ?=({%n *} b)) [%n ~] - ?: |(?=({%i *} a) ?=({%i *} b)) - ?: &(?=({%i *} a) ?=({%i *} b)) + |= [a=fn b=fn] ^- fn + ?: |(?=([%n *] a) ?=([%n *] b)) [%n ~] + ?: |(?=([%i *] a) ?=([%i *] b)) + ?: &(?=([%i *] a) ?=([%i *] b)) ?: =(a b) a [%n ~] - ?: ?=({%i *} a) a b + ?: ?=([%i *] a) a b ?: |(=(a.a 0) =(a.b 0)) ?. &(=(a.a 0) =(a.b 0)) ?~(a.a b a) [%f ?:(=(r %d) &(s.a s.b) |(s.a s.b)) zer] - %- |= {a=fn} - ?. ?=({%f *} a) a + %- |= [a=fn] + ?. ?=([%f *] a) a ?. =(a.a 0) a [%f !=(r %d) zer] ?: =(s.a s.b) @@ -2579,74 +2579,74 @@ (^sub +>.b +>.a &) :: ++ sub :: subtract - |= {a=fn b=fn} ^- fn (add a (fli b)) + |= [a=fn b=fn] ^- fn (add a (fli b)) :: ++ mul :: multiply - |= {a=fn b=fn} ^- fn - ?: |(?=({%n *} a) ?=({%n *} b)) [%n ~] - ?: ?=({%i *} a) - ?: ?=({%i *} b) + |= [a=fn b=fn] ^- fn + ?: |(?=([%n *] a) ?=([%n *] b)) [%n ~] + ?: ?=([%i *] a) + ?: ?=([%i *] b) [%i =(s.a s.b)] ?: =(a.b 0) [%n ~] [%i =(s.a s.b)] - ?: ?=({%i *} b) + ?: ?=([%i *] b) ?: =(a.a 0) [%n ~] [%i =(s.a s.b)] ?: |(=(a.a 0) =(a.b 0)) [%f =(s.a s.b) zer] ?: =(s.a s.b) (^mul +>.a +>.b) =.(r swr (fli (^mul +>.a +>.b))) :: ++ emu :: exact multiply - |= {a=fn b=fn} ^- fn - ?: |(?=({%n *} a) ?=({%n *} b)) [%n ~] - ?: ?=({%i *} a) - ?: ?=({%i *} b) + |= [a=fn b=fn] ^- fn + ?: |(?=([%n *] a) ?=([%n *] b)) [%n ~] + ?: ?=([%i *] a) + ?: ?=([%i *] b) [%i =(s.a s.b)] ?: =(a.b 0) [%n ~] [%i =(s.a s.b)] - ?: ?=({%i *} b) + ?: ?=([%i *] b) ?: =(a.a 0) [%n ~] [%i =(s.a s.b)] ?: |(=(a.a 0) =(a.b 0)) [%f =(s.a s.b) zer] [%f =(s.a s.b) (sum:si e.a e.b) (^^mul a.a a.b)] :: ++ div :: divide - |= {a=fn b=fn} ^- fn - ?: |(?=({%n *} a) ?=({%n *} b)) [%n ~] - ?: ?=({%i *} a) - ?: ?=({%i *} b) [%n ~] [%i =(s.a s.b)] - ?: ?=({%i *} b) [%f =(s.a s.b) zer] + |= [a=fn b=fn] ^- fn + ?: |(?=([%n *] a) ?=([%n *] b)) [%n ~] + ?: ?=([%i *] a) + ?: ?=([%i *] b) [%n ~] [%i =(s.a s.b)] + ?: ?=([%i *] b) [%f =(s.a s.b) zer] ?: =(a.a 0) ?: =(a.b 0) [%n ~] [%f =(s.a s.b) zer] ?: =(a.b 0) [%i =(s.a s.b)] ?: =(s.a s.b) (^div +>.a +>.b) =.(r swr (fli (^div +>.a +>.b))) :: ++ fma :: fused multiply-add - |= {a=fn b=fn c=fn} ^- fn :: (a * b) + c + |= [a=fn b=fn c=fn] ^- fn :: (a * b) + c (add (emu a b) c) :: ++ sqt :: square root - |= {a=fn} ^- fn - ?: ?=({%n *} a) [%n ~] - ?: ?=({%i *} a) ?:(s.a a [%n ~]) + |= [a=fn] ^- fn + ?: ?=([%n *] a) [%n ~] + ?: ?=([%i *] a) ?:(s.a a [%n ~]) ?~ a.a [%f s.a zer] ?: s.a (^sqt +>.a) [%n ~] :: ++ inv :: inverse - |= {a=fn} ^- fn + |= [a=fn] ^- fn (div [%f & --0 1] a) :: ++ sun :: uns integer to float - |= {a=@u} ^- fn + |= [a=@u] ^- fn (rou [%f & --0 a]) :: ++ san :: sgn integer to float - |= {a=@s} ^- fn + |= [a=@s] ^- fn =+ b=(old:si a) (rou [%f -.b --0 +.b]) :: :: comparisons return ~ in the event of a NaN ++ lth :: less-than - |= {a=fn b=fn} ^- (unit ?) - ?: |(?=({%n *} a) ?=({%n *} b)) ~ :- ~ + |= [a=fn b=fn] ^- (unit ?) + ?: |(?=([%n *] a) ?=([%n *] b)) ~ :- ~ ?: =(a b) | - ?: ?=({%i *} a) !s.a ?: ?=({%i *} b) s.b + ?: ?=([%i *] a) !s.a ?: ?=([%i *] b) s.b ?: |(=(a.a 0) =(a.b 0)) ?: &(=(a.a 0) =(a.b 0)) | ?: =(a.a 0) s.b !s.a @@ -2654,36 +2654,36 @@ ?: s.a (^lth +>.a +>.b) (^lth +>.b +>.a) :: ++ lte :: less-equal - |= {a=fn b=fn} ^- (unit ?) + |= [a=fn b=fn] ^- (unit ?) %+ bind (lth b a) |= a=? !a :: ++ equ :: equal - |= {a=fn b=fn} ^- (unit ?) - ?: |(?=({%n *} a) ?=({%n *} b)) ~ :- ~ + |= [a=fn b=fn] ^- (unit ?) + ?: |(?=([%n *] a) ?=([%n *] b)) ~ :- ~ ?: =(a b) & - ?: |(?=({%i *} a) ?=({%i *} b)) | + ?: |(?=([%i *] a) ?=([%i *] b)) | ?: |(=(a.a 0) =(a.b 0)) ?: &(=(a.a 0) =(a.b 0)) & | ?: |(=(e.a e.b) !=(s.a s.b)) | (^equ +>.a +>.b) :: ++ gte :: greater-equal - |= {a=fn b=fn} ^- (unit ?) (lte b a) + |= [a=fn b=fn] ^- (unit ?) (lte b a) :: ++ gth :: greater-than - |= {a=fn b=fn} ^- (unit ?) (lth b a) + |= [a=fn b=fn] ^- (unit ?) (lth b a) :: ++ drg :: float to decimal - |= {a=fn} ^- dn - ?: ?=({%n *} a) [%n ~] - ?: ?=({%i *} a) [%i s.a] + |= [a=fn] ^- dn + ?: ?=([%n *] a) [%n ~] + ?: ?=([%i *] a) [%i s.a] ?~ a.a [%d s.a --0 0] [%d s.a (^drg +>.a)] :: ++ grd :: decimal to float - |= {a=dn} ^- fn - ?: ?=({%n *} a) [%n ~] - ?: ?=({%i *} a) [%i s.a] + |= [a=dn] ^- fn + ?: ?=([%n *] a) [%n ~] + ?: ?=([%i *] a) [%i s.a] => .(r %n) =+ q=(abs:si e.a) ?: (syn:si e.a) @@ -2691,22 +2691,22 @@ (div [%f s.a --0 a.a] [%f & (sun:si q) (pow 5 q)]) :: ++ toi :: round to integer @s - |= {a=fn} ^- (unit @s) + |= [a=fn] ^- (unit @s) =+ b=(toj a) - ?. ?=({%f *} b) ~ :- ~ + ?. ?=([%f *] b) ~ :- ~ =+ c=(^^mul (bex (abs:si e.b)) a.b) (new:si s.b c) :: ++ toj :: round to integer fn - |= {a=fn} ^- fn - ?. ?=({%f *} a) a + |= [a=fn] ^- fn + ?. ?=([%f *] a) a ?~ a.a [%f s.a zer] ?: s.a (^toj +>.a) =.(r swr (fli (^toj +>.a))) -- :: ++ ff :: ieee 754 format fp - |_ {{w=@u p=@u b=@s} r=$?(%n %u %d %z %a)} + |_ [[w=@u p=@u b=@s] r=$?(%n %u %d %z %a)] :: this core has no use outside of the functionality :: provided to ++rd, ++rs, ++rq, and ++rh :: @@ -2722,7 +2722,7 @@ %*(. fl p +(p), v me, w (^sub (bex w) 3), d %d, r r) :: ++ sea :: @r to fn - |= {a=@r} ^- fn + |= [a=@r] ^- fn =+ [f=(cut 0 [0 p] a) e=(cut 0 [p w] a)] =+ s=(sig a) ?: =(e 0) @@ -2733,14 +2733,14 @@ =+ r=(^add f (bex p)) [%f s q r] :: - ++ bit |= {a=fn} (bif (rou:pa a)) :: fn to @r w+ rounding + ++ bit |= [a=fn] (bif (rou:pa a)) :: fn to @r w+ rounding :: ++ bif :: fn to @r no rounding - |= {a=fn} ^- @r - ?: ?=({%i *} a) + |= [a=fn] ^- @r + ?: ?=([%i *] a) =+ q=(lsh 0 p (fil 0 w 1)) ?: s.a q (^add q sb) - ?: ?=({%n *} a) (lsh 0 (dec p) (fil 0 +(w) 1)) + ?: ?=([%n *] a) (lsh 0 (dec p) (fil 0 +(w) 1)) ?~ a.a ?: s.a `@r`0 sb =+ ma=(met 0 a.a) ?. =(ma +(p)) @@ -2752,57 +2752,57 @@ ?: s.a r (^add r sb) :: ++ sig :: get sign - |= {a=@r} ^- ? + |= [a=@r] ^- ? =(0 (cut 0 [(^add p w) 1] a)) :: ++ exp :: get exponent - |= {a=@r} ^- @s + |= [a=@r] ^- @s (dif:si (sun:si (cut 0 [p w] a)) b) :: ++ add :: add - |= {a=@r b=@r} + |= [a=@r b=@r] (bif (add:pa (sea a) (sea b))) :: ++ sub :: subtract - |= {a=@r b=@r} + |= [a=@r b=@r] (bif (sub:pa (sea a) (sea b))) :: ++ mul :: multiply - |= {a=@r b=@r} + |= [a=@r b=@r] (bif (mul:pa (sea a) (sea b))) :: ++ div :: divide - |= {a=@r b=@r} + |= [a=@r b=@r] (bif (div:pa (sea a) (sea b))) :: ++ fma :: fused multiply-add - |= {a=@r b=@r c=@r} + |= [a=@r b=@r c=@r] (bif (fma:pa (sea a) (sea b) (sea c))) :: ++ sqt :: square root - |= {a=@r} + |= [a=@r] (bif (sqt:pa (sea a))) :: ++ lth :: less-than - |= {a=@r b=@r} (fall (lth:pa (sea a) (sea b)) |) + |= [a=@r b=@r] (fall (lth:pa (sea a) (sea b)) |) ++ lte :: less-equals - |= {a=@r b=@r} (fall (lte:pa (sea a) (sea b)) |) + |= [a=@r b=@r] (fall (lte:pa (sea a) (sea b)) |) ++ equ :: equals - |= {a=@r b=@r} (fall (equ:pa (sea a) (sea b)) |) + |= [a=@r b=@r] (fall (equ:pa (sea a) (sea b)) |) ++ gte :: greater-equals - |= {a=@r b=@r} (fall (gte:pa (sea a) (sea b)) |) + |= [a=@r b=@r] (fall (gte:pa (sea a) (sea b)) |) ++ gth :: greater-than - |= {a=@r b=@r} (fall (gth:pa (sea a) (sea b)) |) + |= [a=@r b=@r] (fall (gth:pa (sea a) (sea b)) |) ++ sun :: uns integer to @r - |= {a=@u} (bit [%f & --0 a]) + |= [a=@u] (bit [%f & --0 a]) ++ san :: signed integer to @r - |= {a=@s} (bit [%f (syn:si a) --0 (abs:si a)]) + |= [a=@s] (bit [%f (syn:si a) --0 (abs:si a)]) ++ toi :: round to integer - |= {a=@r} (toi:pa (sea a)) + |= [a=@r] (toi:pa (sea a)) ++ drg :: @r to decimal float - |= {a=@r} (drg:pa (sea a)) + |= [a=@r] (drg:pa (sea a)) ++ grd :: decimal float to @r - |= {a=dn} (bif (grd:pa a)) + |= [a=dn] (bif (grd:pa a)) -- :: ++ rlyd |= a=@rd ^- dn (drg:rd a) :: prep @rd for print @@ -2824,72 +2824,72 @@ %*(. ff w 11, p 52, b --1.023, r r) :: ++ sea :: @rd to fn - |= {a=@rd} (sea:ma a) + |= [a=@rd] (sea:ma a) :: ++ bit :: fn to @rd - |= {a=fn} ^- @rd (bit:ma a) + |= [a=fn] ^- @rd (bit:ma a) :: ++ add ~/ %add :: add - |= {a=@rd b=@rd} ^- @rd + |= [a=@rd b=@rd] ^- @rd ~_ leaf+"rd-fail" (add:ma a b) :: ++ sub ~/ %sub :: subtract - |= {a=@rd b=@rd} ^- @rd + |= [a=@rd b=@rd] ^- @rd ~_ leaf+"rd-fail" (sub:ma a b) :: ++ mul ~/ %mul :: multiply - |= {a=@rd b=@rd} ^- @rd + |= [a=@rd b=@rd] ^- @rd ~_ leaf+"rd-fail" (mul:ma a b) :: ++ div ~/ %div :: divide - |= {a=@rd b=@rd} ^- @rd + |= [a=@rd b=@rd] ^- @rd ~_ leaf+"rd-fail" (div:ma a b) :: ++ fma ~/ %fma :: fused multiply-add - |= {a=@rd b=@rd c=@rd} ^- @rd + |= [a=@rd b=@rd c=@rd] ^- @rd ~_ leaf+"rd-fail" (fma:ma a b c) :: ++ sqt ~/ %sqt :: square root - |= {a=@rd} ^- @rd ~_ leaf+"rd-fail" + |= [a=@rd] ^- @rd ~_ leaf+"rd-fail" (sqt:ma a) :: ++ lth ~/ %lth :: less-than - |= {a=@rd b=@rd} + |= [a=@rd b=@rd] ~_ leaf+"rd-fail" (lth:ma a b) :: ++ lte ~/ %lte :: less-equals - |= {a=@rd b=@rd} + |= [a=@rd b=@rd] ~_ leaf+"rd-fail" (lte:ma a b) :: ++ equ ~/ %equ :: equals - |= {a=@rd b=@rd} + |= [a=@rd b=@rd] ~_ leaf+"rd-fail" (equ:ma a b) :: ++ gte ~/ %gte :: greater-equals - |= {a=@rd b=@rd} + |= [a=@rd b=@rd] ~_ leaf+"rd-fail" (gte:ma a b) :: ++ gth ~/ %gth :: greater-than - |= {a=@rd b=@rd} + |= [a=@rd b=@rd] ~_ leaf+"rd-fail" (gth:ma a b) :: - ++ sun |= {a=@u} ^- @rd (sun:ma a) :: uns integer to @rd - ++ san |= {a=@s} ^- @rd (san:ma a) :: sgn integer to @rd - ++ sig |= {a=@rd} ^- ? (sig:ma a) :: get sign - ++ exp |= {a=@rd} ^- @s (exp:ma a) :: get exponent - ++ toi |= {a=@rd} ^- (unit @s) (toi:ma a) :: round to integer - ++ drg |= {a=@rd} ^- dn (drg:ma a) :: @rd to decimal float - ++ grd |= {a=dn} ^- @rd (grd:ma a) :: decimal float to @rd + ++ sun |= [a=@u] ^- @rd (sun:ma a) :: uns integer to @rd + ++ san |= [a=@s] ^- @rd (san:ma a) :: sgn integer to @rd + ++ sig |= [a=@rd] ^- ? (sig:ma a) :: get sign + ++ exp |= [a=@rd] ^- @s (exp:ma a) :: get exponent + ++ toi |= [a=@rd] ^- (unit @s) (toi:ma a) :: round to integer + ++ drg |= [a=@rd] ^- dn (drg:ma a) :: @rd to decimal float + ++ grd |= [a=dn] ^- @rd (grd:ma a) :: decimal float to @rd -- :: ++ rs :: single precision fp @@ -2902,73 +2902,73 @@ %*(. ff w 8, p 23, b --127, r r) :: ++ sea :: @rs to fn - |= {a=@rs} (sea:ma a) + |= [a=@rs] (sea:ma a) :: ++ bit :: fn to @rs - |= {a=fn} ^- @rs (bit:ma a) + |= [a=fn] ^- @rs (bit:ma a) :: ++ add ~/ %add :: add - |= {a=@rs b=@rs} ^- @rs + |= [a=@rs b=@rs] ^- @rs ~_ leaf+"rs-fail" (add:ma a b) :: ++ sub ~/ %sub :: subtract - |= {a=@rs b=@rs} ^- @rs + |= [a=@rs b=@rs] ^- @rs ~_ leaf+"rs-fail" (sub:ma a b) :: ++ mul ~/ %mul :: multiply - |= {a=@rs b=@rs} ^- @rs + |= [a=@rs b=@rs] ^- @rs ~_ leaf+"rs-fail" (mul:ma a b) :: ++ div ~/ %div :: divide - |= {a=@rs b=@rs} ^- @rs + |= [a=@rs b=@rs] ^- @rs ~_ leaf+"rs-fail" (div:ma a b) :: ++ fma ~/ %fma :: fused multiply-add - |= {a=@rs b=@rs c=@rs} ^- @rs + |= [a=@rs b=@rs c=@rs] ^- @rs ~_ leaf+"rs-fail" (fma:ma a b c) :: ++ sqt ~/ %sqt :: square root - |= {a=@rs} ^- @rs + |= [a=@rs] ^- @rs ~_ leaf+"rs-fail" (sqt:ma a) :: ++ lth ~/ %lth :: less-than - |= {a=@rs b=@rs} + |= [a=@rs b=@rs] ~_ leaf+"rs-fail" (lth:ma a b) :: ++ lte ~/ %lte :: less-equals - |= {a=@rs b=@rs} + |= [a=@rs b=@rs] ~_ leaf+"rs-fail" (lte:ma a b) :: ++ equ ~/ %equ :: equals - |= {a=@rs b=@rs} + |= [a=@rs b=@rs] ~_ leaf+"rs-fail" (equ:ma a b) :: ++ gte ~/ %gte :: greater-equals - |= {a=@rs b=@rs} + |= [a=@rs b=@rs] ~_ leaf+"rs-fail" (gte:ma a b) :: ++ gth ~/ %gth :: greater-than - |= {a=@rs b=@rs} + |= [a=@rs b=@rs] ~_ leaf+"rs-fail" (gth:ma a b) :: - ++ sun |= {a=@u} ^- @rs (sun:ma a) :: uns integer to @rs - ++ san |= {a=@s} ^- @rs (san:ma a) :: sgn integer to @rs - ++ sig |= {a=@rs} ^- ? (sig:ma a) :: get sign - ++ exp |= {a=@rs} ^- @s (exp:ma a) :: get exponent - ++ toi |= {a=@rs} ^- (unit @s) (toi:ma a) :: round to integer - ++ drg |= {a=@rs} ^- dn (drg:ma a) :: @rs to decimal float - ++ grd |= {a=dn} ^- @rs (grd:ma a) :: decimal float to @rs + ++ sun |= [a=@u] ^- @rs (sun:ma a) :: uns integer to @rs + ++ san |= [a=@s] ^- @rs (san:ma a) :: sgn integer to @rs + ++ sig |= [a=@rs] ^- ? (sig:ma a) :: get sign + ++ exp |= [a=@rs] ^- @s (exp:ma a) :: get exponent + ++ toi |= [a=@rs] ^- (unit @s) (toi:ma a) :: round to integer + ++ drg |= [a=@rs] ^- dn (drg:ma a) :: @rs to decimal float + ++ grd |= [a=dn] ^- @rs (grd:ma a) :: decimal float to @rs -- :: ++ rq :: quad precision fp @@ -2981,73 +2981,73 @@ %*(. ff w 15, p 112, b --16.383, r r) :: ++ sea :: @rq to fn - |= {a=@rq} (sea:ma a) + |= [a=@rq] (sea:ma a) :: ++ bit :: fn to @rq - |= {a=fn} ^- @rq (bit:ma a) + |= [a=fn] ^- @rq (bit:ma a) :: ++ add ~/ %add :: add - |= {a=@rq b=@rq} ^- @rq + |= [a=@rq b=@rq] ^- @rq ~_ leaf+"rq-fail" (add:ma a b) :: ++ sub ~/ %sub :: subtract - |= {a=@rq b=@rq} ^- @rq + |= [a=@rq b=@rq] ^- @rq ~_ leaf+"rq-fail" (sub:ma a b) :: ++ mul ~/ %mul :: multiply - |= {a=@rq b=@rq} ^- @rq + |= [a=@rq b=@rq] ^- @rq ~_ leaf+"rq-fail" (mul:ma a b) :: ++ div ~/ %div :: divide - |= {a=@rq b=@rq} ^- @rq + |= [a=@rq b=@rq] ^- @rq ~_ leaf+"rq-fail" (div:ma a b) :: ++ fma ~/ %fma :: fused multiply-add - |= {a=@rq b=@rq c=@rq} ^- @rq + |= [a=@rq b=@rq c=@rq] ^- @rq ~_ leaf+"rq-fail" (fma:ma a b c) :: ++ sqt ~/ %sqt :: square root - |= {a=@rq} ^- @rq + |= [a=@rq] ^- @rq ~_ leaf+"rq-fail" (sqt:ma a) :: ++ lth ~/ %lth :: less-than - |= {a=@rq b=@rq} + |= [a=@rq b=@rq] ~_ leaf+"rq-fail" (lth:ma a b) :: ++ lte ~/ %lte :: less-equals - |= {a=@rq b=@rq} + |= [a=@rq b=@rq] ~_ leaf+"rq-fail" (lte:ma a b) :: ++ equ ~/ %equ :: equals - |= {a=@rq b=@rq} + |= [a=@rq b=@rq] ~_ leaf+"rq-fail" (equ:ma a b) :: ++ gte ~/ %gte :: greater-equals - |= {a=@rq b=@rq} + |= [a=@rq b=@rq] ~_ leaf+"rq-fail" (gte:ma a b) :: ++ gth ~/ %gth :: greater-than - |= {a=@rq b=@rq} + |= [a=@rq b=@rq] ~_ leaf+"rq-fail" (gth:ma a b) :: - ++ sun |= {a=@u} ^- @rq (sun:ma a) :: uns integer to @rq - ++ san |= {a=@s} ^- @rq (san:ma a) :: sgn integer to @rq - ++ sig |= {a=@rq} ^- ? (sig:ma a) :: get sign - ++ exp |= {a=@rq} ^- @s (exp:ma a) :: get exponent - ++ toi |= {a=@rq} ^- (unit @s) (toi:ma a) :: round to integer - ++ drg |= {a=@rq} ^- dn (drg:ma a) :: @rq to decimal float - ++ grd |= {a=dn} ^- @rq (grd:ma a) :: decimal float to @rq + ++ sun |= [a=@u] ^- @rq (sun:ma a) :: uns integer to @rq + ++ san |= [a=@s] ^- @rq (san:ma a) :: sgn integer to @rq + ++ sig |= [a=@rq] ^- ? (sig:ma a) :: get sign + ++ exp |= [a=@rq] ^- @s (exp:ma a) :: get exponent + ++ toi |= [a=@rq] ^- (unit @s) (toi:ma a) :: round to integer + ++ drg |= [a=@rq] ^- dn (drg:ma a) :: @rq to decimal float + ++ grd |= [a=dn] ^- @rq (grd:ma a) :: decimal float to @rq -- :: ++ rh :: half precision fp @@ -3060,79 +3060,79 @@ %*(. ff w 5, p 10, b --15, r r) :: ++ sea :: @rh to fn - |= {a=@rh} (sea:ma a) + |= [a=@rh] (sea:ma a) :: ++ bit :: fn to @rh - |= {a=fn} ^- @rh (bit:ma a) + |= [a=fn] ^- @rh (bit:ma a) :: ++ add ~/ %add :: add - |= {a=@rh b=@rh} ^- @rh + |= [a=@rh b=@rh] ^- @rh ~_ leaf+"rh-fail" (add:ma a b) :: ++ sub ~/ %sub :: subtract - |= {a=@rh b=@rh} ^- @rh + |= [a=@rh b=@rh] ^- @rh ~_ leaf+"rh-fail" (sub:ma a b) :: ++ mul ~/ %mul :: multiply - |= {a=@rh b=@rh} ^- @rh + |= [a=@rh b=@rh] ^- @rh ~_ leaf+"rh-fail" (mul:ma a b) :: ++ div ~/ %div :: divide - |= {a=@rh b=@rh} ^- @rh + |= [a=@rh b=@rh] ^- @rh ~_ leaf+"rh-fail" (div:ma a b) :: ++ fma ~/ %fma :: fused multiply-add - |= {a=@rh b=@rh c=@rh} ^- @rh + |= [a=@rh b=@rh c=@rh] ^- @rh ~_ leaf+"rh-fail" (fma:ma a b c) :: ++ sqt ~/ %sqt :: square root - |= {a=@rh} ^- @rh + |= [a=@rh] ^- @rh ~_ leaf+"rh-fail" (sqt:ma a) :: ++ lth ~/ %lth :: less-than - |= {a=@rh b=@rh} + |= [a=@rh b=@rh] ~_ leaf+"rh-fail" (lth:ma a b) :: ++ lte ~/ %lte :: less-equals - |= {a=@rh b=@rh} + |= [a=@rh b=@rh] ~_ leaf+"rh-fail" (lte:ma a b) :: ++ equ ~/ %equ :: equals - |= {a=@rh b=@rh} + |= [a=@rh b=@rh] ~_ leaf+"rh-fail" (equ:ma a b) :: ++ gte ~/ %gte :: greater-equals - |= {a=@rh b=@rh} + |= [a=@rh b=@rh] ~_ leaf+"rh-fail" (gte:ma a b) :: ++ gth ~/ %gth :: greater-than - |= {a=@rh b=@rh} + |= [a=@rh b=@rh] ~_ leaf+"rh-fail" (gth:ma a b) :: ++ tos :: @rh to @rs - |= {a=@rh} (bit:rs (sea a)) + |= [a=@rh] (bit:rs (sea a)) :: ++ fos :: @rs to @rh - |= {a=@rs} (bit (sea:rs a)) + |= [a=@rs] (bit (sea:rs a)) :: - ++ sun |= {a=@u} ^- @rh (sun:ma a) :: uns integer to @rh - ++ san |= {a=@s} ^- @rh (san:ma a) :: sgn integer to @rh - ++ sig |= {a=@rh} ^- ? (sig:ma a) :: get sign - ++ exp |= {a=@rh} ^- @s (exp:ma a) :: get exponent - ++ toi |= {a=@rh} ^- (unit @s) (toi:ma a) :: round to integer - ++ drg |= {a=@rh} ^- dn (drg:ma a) :: @rh to decimal float - ++ grd |= {a=dn} ^- @rh (grd:ma a) :: decimal float to @rh + ++ sun |= [a=@u] ^- @rh (sun:ma a) :: uns integer to @rh + ++ san |= [a=@s] ^- @rh (san:ma a) :: sgn integer to @rh + ++ sig |= [a=@rh] ^- ? (sig:ma a) :: get sign + ++ exp |= [a=@rh] ^- @s (exp:ma a) :: get exponent + ++ toi |= [a=@rh] ^- (unit @s) (toi:ma a) :: round to integer + ++ drg |= [a=@rh] ^- dn (drg:ma a) :: @rh to decimal float + ++ grd |= [a=dn] ^- @rh (grd:ma a) :: decimal float to @rh -- :: 3c: urbit time :: :::: :: @@ -3196,7 +3196,7 @@ :: ++ yall :: day / to day of year |= day=@ud - ^- {y=@ud m=@ud d=@ud} + ^- [y=@ud m=@ud d=@ud] =+ [era=0 cet=0 lep=*?] => .(era (div day era:yo), day (mod day era:yo)) => ^+ . @@ -3205,21 +3205,21 @@ => .(lep |, cet 1, day (sub day +(cet:yo))) .(cet (add cet (div day cet:yo)), day (mod day cet:yo)) =+ yer=(add (mul 400 era) (mul 100 cet)) - |- ^- {y=@ud m=@ud d=@ud} + |- ^- [y=@ud m=@ud d=@ud] =+ dis=?:(lep 366 365) ?. (lth day dis) =+ ner=+(yer) $(yer ner, day (sub day dis), lep =(0 (end 0 2 ner))) - |- ^- {y=@ud m=@ud d=@ud} + |- ^- [y=@ud m=@ud d=@ud] =+ [mot=0 cah=?:(lep moy:yo moh:yo)] - |- ^- {y=@ud m=@ud d=@ud} + |- ^- [y=@ud m=@ud d=@ud] =+ zis=(snag mot cah) ?: (lth day zis) [yer +(mot) +(day)] $(mot +(mot), day (sub day zis)) :: ++ yawn :: days since Jesus - |= {yer=@ud mot=@ud day=@ud} + |= [yer=@ud mot=@ud day=@ud] ^- @ud => .(mot (dec mot), day (dec day)) => ^+ . @@ -3265,7 +3265,7 @@ :: ++ shad |=(ruz=@ (shax (shax ruz))) :: double sha-256 ++ shaf :: half sha-256 - |= {sal=@ ruz=@} + |= [sal=@ ruz=@] =+ haz=(shas sal ruz) (mix (end 7 1 haz) (rsh 7 1 haz)) :: @@ -3277,7 +3277,7 @@ :: ++ shas :: salted hash ~/ %shas - |= {sal=@ ruz=@} + |= [sal=@ ruz=@] (shax (mix sal (shax ruz))) :: ++ shax :: sha-256 @@ -3287,9 +3287,9 @@ :: ++ shay :: sha-256 with length ~/ %shay - |= {len=@u ruz=@} ^- @ + |= [len=@u ruz=@] ^- @ => .(ruz (cut 3 [0 len] ruz)) - =+ [few==>(fe .(a 5)) wac=|=({a=@ b=@} (cut 5 [a 1] b))] + =+ [few==>(fe .(a 5)) wac=|=([a=@ b=@] (cut 5 [a 1] b))] =+ [sum=sum.few ror=ror.few net=net.few inv=inv.few] =+ ral=(lsh 0 3 len) =+ ^= ful @@ -3372,7 +3372,7 @@ $(j +(j), a (sum q n), b a, c b, d c, e (sum d q), f e, g f, h g) :: ++ shaw :: hash to nbits - |= {sal=@ len=@ ruz=@} + |= [sal=@ len=@ ruz=@] (~(raw og (shas sal (mix len ruz))) len) :: ++ shaz :: sha-512 @@ -3381,9 +3381,9 @@ :: ++ shal :: sha-512 with length ~/ %shal - |= {len=@ ruz=@} ^- @ + |= [len=@ ruz=@] ^- @ => .(ruz (cut 3 [0 len] ruz)) - =+ [few==>(fe .(a 6)) wac=|=({a=@ b=@} (cut 6 [a 1] b))] + =+ [few==>(fe .(a 6)) wac=|=([a=@ b=@] (cut 6 [a 1] b))] =+ [sum=sum.few ror=ror.few net=net.few inv=inv.few] =+ ral=(lsh 0 3 len) =+ ^= ful @@ -3493,7 +3493,7 @@ :: ++ shan :: sha-1 (deprecated) |= ruz=@ - =+ [few==>(fe .(a 5)) wac=|=({a=@ b=@} (cut 5 [a 1] b))] + =+ [few==>(fe .(a 5)) wac=|=([a=@ b=@] (cut 5 [a 1] b))] =+ [sum=sum.few ror=ror.few rol=rol.few net=net.few inv=inv.few] =+ ral=(lsh 0 3 (met 3 ruz)) =+ ^= ful @@ -3578,7 +3578,7 @@ %+ can 0 =+ c=(shas %og-a (mix b a)) - |- ^- (list {@ @}) + |- ^- (list [@ @]) ?: =(0 b) ~ =+ d=(shas %og-b (mix b (mix a c))) @@ -3617,7 +3617,7 @@ ~/ %sha1 |= byts ^- @ - =+ [few==>(fe .(a 5)) wac=|=({a=@ b=@} (cut 5 [a 1] b))] + =+ [few==>(fe .(a 5)) wac=|=([a=@ b=@] (cut 5 [a 1] b))] =+ [sum=sum.few ror=ror.few rol=rol.few net=net.few inv=inv.few] =+ ral=(lsh 0 3 wid) =+ ^= ful @@ -3700,9 +3700,9 @@ => .(len (dec len)) =+ mig=(zaft (xafo len (cut 3 [len 1] pyn))) %+ can 3 - %- flop ^- (list {@ @}) + %- flop ^- (list [@ @]) :- [1 mig] - |- ^- (list {@ @}) + |- ^- (list [@ @]) ?: =(0 len) ~ => .(len (dec len)) @@ -3717,17 +3717,17 @@ => .(len (dec len)) =+ mig=(cut 3 [len 1] cry) %+ can 3 - %- flop ^- (list {@ @}) + %- flop ^- (list [@ @]) :- [1 (xaro len (zart mig))] - |- ^- (list {@ @}) + |- ^- (list [@ @]) ?: =(0 len) ~ => .(len (dec len)) =+ mog=(cut 3 [len 1] cry) [[1 :(mix mig (end 3 1 len) (zyrt mog))] $(mig mog)] :: - ++ xafo |=({a=@ b=@} +((mod (add (dec b) a) 255))) - ++ xaro |=({a=@ b=@} +((mod (add (dec b) (sub 255 (mod a 255))) 255))) + ++ xafo |=([a=@ b=@] +((mod (add (dec b) a) 255))) + ++ xaro |=([a=@ b=@] +((mod (add (dec b) (sub 255 (mod a 255))) 255))) :: ++ zaft :: forward 255-sbox |= a=@D @@ -3997,14 +3997,14 @@ :: :::: 3g: molds and mold builders :: -++ coin $~ [%$ %ud 0] :: print format - $% {%$ p=dime} :: - {%blob p=*} :: - {%many p=(list coin)} :: ++$ coin $~ [%$ %ud 0] :: print format + $% [%$ p=dime] :: + [%blob p=*] :: + [%many p=(list coin)] :: == :: -++ dime {p=@ta q=@} :: -++ edge {p=hair q=(unit {p=* q=nail})} :: parsing output -++ hair {p=@ud q=@ud} :: parsing trace ++$ dime [p=@ta q=@] :: ++$ edge [p=hair q=(unit [p=* q=nail])] :: parsing output ++$ hair [p=@ud q=@ud] :: parsing trace ++ like |* a=$-(* *) :: generic edge |: b=`*`[(hair) ~] :: :- p=(hair -.b) :: @@ -4012,17 +4012,17 @@ ?@ +.b ~ :: :- ~ :: u=[p=(a +>-.b) q=[p=(hair -.b) q=(tape +.b)]] :: -++ nail {p=hair q=tape} :: parsing input -++ pint {p={p=@ q=@} q={p=@ q=@}} :: line+column range -++ rule _|:($:nail $:edge) :: parsing rule -++ spot {p=path q=pint} :: range in file -++ tone $% {%0 product=*} :: success - {%1 block=*} :: single block - {%2 trace=(list {@ta *})} :: error report ++$ nail [p=hair q=tape] :: parsing input ++$ pint [p=[p=@ q=@] q=[p=@ q=@]] :: line+column range ++$ rule _|:($:nail $:edge) :: parsing rule ++$ spot [p=path q=pint] :: range in file ++$ tone $% [%0 product=*] :: success + [%1 block=*] :: single block + [%2 trace=(list [@ta *])] :: error report == :: -++ toon $% {%0 p=*} :: success - {%1 p=*} :: block - {%2 p=(list tank)} :: stack trace ++$ toon $% [%0 p=*] :: success + [%1 p=*] :: block + [%2 p=(list tank)] :: stack trace == :: ++ wonk =+ veq=$:edge :: product from edge |@ ++ $ ?~(q.veq !! p.u.q.veq) :: @@ -4163,7 +4163,7 @@ ++ rub `tape`['0' 'b' (rum 2 ~ |=(b=@ (add '0' b)))] ++ rud (rum 10 ~ |=(b=@ (add '0' b))) ++ rum - |= {b=@ c=tape d=$-(@ @)} + |= [b=@ c=tape d=$-(@ @)] ^- tape ?: =(0 a) [(d 0) c] @@ -4240,7 +4240,7 @@ [i.vib $(vib t.vib)] :: ++ runt :: prepend repeatedly - |= {{a=@ b=@} c=tape} + |= [[a=@ b=@] c=tape] ^- tape ?: =(0 a) c @@ -4288,15 +4288,15 @@ == :: ++ ruth :: biblical sanity - |= {a=@ta b=*} + |= [a=@ta b=*] ^- @ ?^ b !! :: ?. ((sane a) b) !! b :: ++ trim :: tape split - |= {a=@ b=tape} - ^- {p=tape q=tape} + |= [a=@ b=tape] + ^- [p=tape q=tape] ?~ b [~ ~] ?: =(0 a) @@ -4329,14 +4329,14 @@ =+ ^= c %+ can 0 %+ turn - ^- (list {p=@ q=@}) + ^- (list [p=@ q=@]) ?+ b !! %1 [[0 7] ~] %2 [[8 6] [0 5] ~] %3 [[16 6] [8 6] [0 4] ~] %4 [[24 6] [16 6] [8 6] [0 3] ~] == - |=({p=@ q=@} [q (cut 0 [p q] a)]) + |=([p=@ q=@] [q (cut 0 [p q] a)]) ?> =((tuft c) (end 3 b a)) [c $(a (rsh 3 b a))] :: @@ -4398,7 +4398,7 @@ =+ b=(rip 3 a) =- ?^(b ~ (some (rap 3 (flop c)))) =| c=tape - |- ^- {b=tape c=tape} + |- ^- [b=tape c=tape] ?~ b [~ c] ?. =('~' i.b) $(b t.b, c [i.b c]) @@ -4426,7 +4426,7 @@ ?+ b =- (weld (rip 3 (tuft p.d)) $(a q.d)) ^= d =+ d=0 - |- ^- {p=@ q=@} + |- ^- [p=@ q=@] ?: =('.' b) [d c] ?< =(0 c) @@ -4475,7 +4475,7 @@ :::: 4c: tank printer :: ++ wash :: render tank at width - |= {{tab=@ edg=@} tac=tank} ^- wall + |= [[tab=@ edg=@] tac=tank] ^- wall (~(win re tac) tab edg) :: :: |re: tank renderer @@ -4613,43 +4613,43 @@ ?: ?=(@ vem) [%leaf (mesc (trip vem))] ?- vem - {s=~ c=*} + [s=~ c=*] [%leaf '\'' (weld (mesc (tape +.vem)) `tape`['\'' ~])] :: - {s=%a c=@} [%leaf (mesc (trip c.vem))] - {s=%b c=*} (shop c.vem |=(a=@ ~(rub at a))) - {s={%c p=@} c=*} + [s=%a c=@] [%leaf (mesc (trip c.vem))] + [s=%b c=*] (shop c.vem |=(a=@ ~(rub at a))) + [s=[%c p=@] c=*] :+ %palm [['.' ~] ['-' ~] ~ ~] [[%leaf (mesc (trip p.s.vem))] $(vem c.vem) ~] :: - {s=%d c=*} (shop c.vem |=(a=@ ~(rud at a))) - {s=%k c=*} (tank c.vem) - {s=%h c=*} + [s=%d c=*] (shop c.vem |=(a=@ ~(rud at a))) + [s=%k c=*] (tank c.vem) + [s=%h c=*] :+ %rose [['/' ~] ['/' ~] ~] =+ yol=((list @ta) c.vem) (turn yol |=(a=@ta [%leaf (trip a)])) :: - {s=%l c=*} (shol c.vem) - {s=%o c=*} + [s=%l c=*] (shol c.vem) + [s=%o c=*] %= $ vem :- [%m '%h::[%d %d].[%d %d]>'] [-.c.vem +<-.c.vem +<+.c.vem +>-.c.vem +>+.c.vem ~] == :: - {s=%p c=*} (shop c.vem |=(a=@ ~(rup at a))) - {s=%q c=*} (shop c.vem |=(a=@ ~(r at a))) - {s=%r c=*} $(vem [[%r ' ' '{' '}'] c.vem]) - {s=%t c=*} (shop c.vem |=(a=@ ~(rt at a))) - {s=%v c=*} (shop c.vem |=(a=@ ~(ruv at a))) - {s=%x c=*} (shop c.vem |=(a=@ ~(rux at a))) - {s={%m p=@} c=*} (shep p.s.vem c.vem) - {s={%r p=@} c=*} + [s=%p c=*] (shop c.vem |=(a=@ ~(rup at a))) + [s=%q c=*] (shop c.vem |=(a=@ ~(r at a))) + [s=%r c=*] $(vem [[%r ' ' '{' '}'] c.vem]) + [s=%t c=*] (shop c.vem |=(a=@ ~(rt at a))) + [s=%v c=*] (shop c.vem |=(a=@ ~(ruv at a))) + [s=%x c=*] (shop c.vem |=(a=@ ~(rux at a))) + [s=[%m p=@] c=*] (shep p.s.vem c.vem) + [s=[%r p=@] c=*] $(vem [[%r ' ' (cut 3 [0 1] p.s.vem) (cut 3 [1 1] p.s.vem)] c.vem]) :: - {s={%r p=@ q=@ r=@} c=*} + [s=[%r p=@ q=@ r=@] c=*] :+ %rose :* p=(mesc (trip p.s.vem)) q=(mesc (trip q.s.vem)) @@ -4660,11 +4660,11 @@ ~ [^$(vem -.c.vem) $(c.vem +.c.vem)] :: - {s=%z c=*} $(vem [[%r %$ %$ %$] c.vem]) + [s=%z c=*] $(vem [[%r %$ %$ %$] c.vem]) * !! == ++ shep - |= {fom=@ gar=*} + |= [fom=@ gar=*] ^- tank =+ l=(met 3 fom) =+ i=0 @@ -4681,7 +4681,7 @@ (weld ~(ram re (show d -.gar)) $(i (add 2 i), gar +.gar)) :: ++ shop - |= {aug=* vel=$-(a=@ tape)} + |= [aug=* vel=$-(a=@ tape)] ^- tank ?: ?=(@ aug) [%leaf (vel aug)] @@ -4703,25 +4703,25 @@ ?+ -.lim (show '#') ~ (show '$') c=@ (show c.lim) - {%& %1} (show '.') - {%& c=@} + [%& %1] (show '.') + [%& c=@] [%leaf '+' ~(rud at c.lim)] :: - {%| @ ~} (show ',') - {%| n=@ ~ c=@} + [%| @ ~] (show ',') + [%| n=@ ~ c=@] [%leaf (weld (reap n.lim '^') ?~(c.lim "$" (trip c.lim)))] == -- :: :::: 4d: parsing (tracing) :: -++ last |= {zyc=hair naz=hair} :: farther trace +++ last |= [zyc=hair naz=hair] :: farther trace ^- hair ?: =(p.zyc p.naz) ?:((gth q.zyc q.naz) zyc naz) ?:((gth p.zyc p.naz) zyc naz) :: -++ lust |= {weq=char naz=hair} :: detect newline +++ lust |= [weq=char naz=hair] :: detect newline ^- hair ?:(=(`@`10 weq) [+(p.naz) 1] [p.naz +(q.naz)]) :: @@ -4729,11 +4729,11 @@ :: ++ bend :: conditional comp ~/ %bend - =+ raq=|*({a=* b=*} [~ u=[a b]]) + =+ raq=|*([a=* b=*] [~ u=[a b]]) |@ ++ $ ~/ %fun - |* {vex=edge sab=rule} + |* [vex=edge sab=rule] ?~ q.vex vex =+ yit=(sab q.u.q.vex) @@ -4748,11 +4748,11 @@ :: ++ comp ~/ %comp - =+ raq=|*({a=* b=*} [a b]) :: arbitrary compose + =+ raq=|*([a=* b=*] [a b]) :: arbitrary compose |@ ++ $ ~/ %fun - |* {vex=edge sab=rule} + |* [vex=edge sab=rule] ~! +< ?~ q.vex vex @@ -4768,11 +4768,11 @@ ~/ %glue |* bus=rule ~/ %fun - |* {vex=edge sab=rule} + |* [vex=edge sab=rule] (plug vex ;~(pfix bus sab)) :: ++ less :: no first and second - |* {vex=edge sab=rule} + |* [vex=edge sab=rule] ?~ q.vex =+ roq=(sab) [p=(last p.vex p.roq) q=q.roq] @@ -4780,13 +4780,13 @@ :: ++ pfix :: discard first rule ~/ %pfix - |* sam={vex=edge sab=rule} + |* sam=[vex=edge sab=rule] %. sam - (comp |*({a=* b=*} b)) + (comp |*([a=* b=*] b)) :: ++ plug :: first then second ~/ %plug - |* {vex=edge sab=rule} + |* [vex=edge sab=rule] ?~ q.vex vex =+ yit=(sab q.u.q.vex) @@ -4797,14 +4797,14 @@ :: ++ pose :: first or second ~/ %pose - |* {vex=edge sab=rule} + |* [vex=edge sab=rule] ?~ q.vex =+ roq=(sab) [p=(last p.vex p.roq) q=q.roq] vex :: ++ simu :: first and second - |* {vex=edge sab=rule} + |* [vex=edge sab=rule] ?~ q.vex vex =+ roq=(sab) @@ -4812,33 +4812,33 @@ :: ++ sfix :: discard second rule ~/ %sfix - |* sam={vex=edge sab=rule} + |* sam=[vex=edge sab=rule] %. sam - (comp |*({a=* b=*} a)) + (comp |*([a=* b=*] a)) :: :::: 4f: parsing (rule builders) :: ++ bass :: leftmost base - |* {wuc=@ tyd=rule} + |* [wuc=@ tyd=rule] %+ cook |= waq=(list @) %+ roll waq - =|({p=@ q=@} |.((add p (mul wuc q)))) + =|([p=@ q=@] |.((add p (mul wuc q)))) tyd :: ++ boss :: rightmost base - |* {wuc=@ tyd=rule} + |* [wuc=@ tyd=rule] %+ cook |= waq=(list @) %+ reel waq - =|({p=@ q=@} |.((add p (mul wuc q)))) + =|([p=@ q=@] |.((add p (mul wuc q)))) tyd :: ++ cold :: replace w+ constant ~/ %cold - |* {cus=* sef=rule} + |* [cus=* sef=rule] ~/ %fun |= tub=nail =+ vex=(sef tub) @@ -4848,7 +4848,7 @@ :: ++ cook :: apply gate ~/ %cook - |* {poq=gate sef=rule} + |* [poq=gate sef=rule] ~/ %fun |= tub=nail =+ vex=(sef tub) @@ -4865,7 +4865,7 @@ [p=p.tub q=[~ u=[p=huf q=tub]]] :: ++ fuss - |= {sic=@t non=@t} + |= [sic=@t non=@t] ;~(pose (cold %& (jest sic)) (cold %| (jest non))) :: ++ full :: has to fully parse @@ -4875,13 +4875,13 @@ ?~(q.vex vex ?:(=(~ q.q.u.q.vex) vex [p=p.vex q=~])) :: ++ funk :: add to tape first - |* {pre=tape sef=rule} + |* [pre=tape sef=rule] |= tub=nail (sef p.tub (weld pre q.tub)) :: ++ here :: place-based apply ~/ %here - =+ [hez=|=({a=pint b=*} [a b]) sef=*rule] + =+ [hez=|=([a=pint b=*] [a b]) sef=*rule] |@ ++ $ ~/ %fun @@ -4912,7 +4912,7 @@ (welp [`@t`10 (trip lev)] $(res +.res)) :: ++ ifix - |* {fel={rule rule} hof=rule} + |* [fel=[rule rule] hof=rule] ~! +< ~! +<:-.fel ~! +<:+.fel @@ -4942,7 +4942,7 @@ (next tub) :: ++ knee :: callbacks - =| {gar=* sef=_|.(*rule)} + =| [gar=* sef=_|.(*rule)] |@ ++ $ |= tub=nail ^- (like _gar) @@ -4962,11 +4962,11 @@ (next tub) :: ++ more :: separated, * - |* {bus=rule fel=rule} + |* [bus=rule fel=rule] ;~(pose (most bus fel) (easy ~)) :: ++ most :: separated, + - |* {bus=rule fel=rule} + |* [bus=rule fel=rule] ;~(plug fel (star ;~(pfix bus fel))) :: ++ next :: consume a char @@ -4986,15 +4986,15 @@ == :: ++ pick :: rule for ++each - |* {a=rule b=rule} + |* [a=rule b=rule] ;~ pose (stag %& a) (stag %| b) == ++ plus |*(fel=rule ;~(plug fel (star fel))) :: -++ punt |*({a=rule} ;~(pose (stag ~ a) (easy ~))) :: +++ punt |*([a=rule] ;~(pose (stag ~ a) (easy ~))) :: ++ sear :: conditional cook - |* {pyq=$-(* (unit)) sef=rule} + |* [pyq=$-(* (unit)) sef=rule] |= tub=nail =+ vex=(sef tub) ?~ q.vex @@ -5006,7 +5006,7 @@ :: ++ shim :: match char in range ~/ %shim - |= {les=@ mos=@} + |= [les=@ mos=@] ~/ %fun |= tub=nail ^- (like char) @@ -5018,7 +5018,7 @@ :: ++ stag :: add a label ~/ %stag - |* {gob=* sef=rule} + |* [gob=* sef=rule] ~/ %fun |= tub=nail =+ vex=(sef tub) @@ -5027,7 +5027,7 @@ [p=p.vex q=[~ u=[p=[gob p.u.q.vex] q=q.u.q.vex]]] :: ++ stet :: - |* leh=(list {?(@ {@ @}) rule}) + |* leh=(list [?(@ [@ @]) rule]) |- ?~ leh ~ @@ -5035,9 +5035,9 @@ :: ++ stew :: switch by first char ~/ %stew - |* leh=(list {p=?(@ {@ @}) q=rule}) :: char+range keys + |* leh=(list [p=?(@ [@ @]) q=rule]) :: char+range keys =+ ^= wor :: range complete lth - |= {ort=?(@ {@ @}) wan=?(@ {@ @})} + |= [ort=?(@ [@ @]) wan=?(@ [@ @])] ?@ ort ?@(wan (lth ort wan) (lth ort -.wan)) ?@(wan (lth +.ort wan) (lth +.ort -.wan)) @@ -5078,13 +5078,13 @@ $(hel r.hel) :: ++ slug :: - |* raq=_=>(~ |*({a=* b=*} [a b])) - |* {bus=rule fel=rule} + |* raq=_=>(~ |*([a=* b=*] [a b])) + |* [bus=rule fel=rule] ;~((comp raq) fel (stir +<+.raq raq ;~(pfix bus fel))) :: ++ star :: 0 or more times |* fel=rule - (stir `(list _(wonk *fel))`~ |*({a=* b=*} [a b]) fel) + (stir `(list _(wonk *fel))`~ |*([a=* b=*] [a b]) fel) :: ++ stir ~/ %stir @@ -5115,7 +5115,7 @@ :: ++ stun :: parse several times ~/ %stun - |* {lig={@ @} fel=rule} + |* [lig=[@ @] fel=rule] |= tub=nail ^- (like (list _(wonk (fel)))) ?: =(0 +.lig) @@ -5136,19 +5136,19 @@ :: :::: 4g: parsing (outside caller) :: -++ rash |*({naf=@ sab=rule} (scan (trip naf) sab)) -++ rose |* {los=tape sab=rule} +++ rash |*([naf=@ sab=rule] (scan (trip naf) sab)) +++ rose |* [los=tape sab=rule] =+ vex=(sab [[1 1] los]) =+ len=(lent los) ?. =(+(len) q.p.vex) [%| p=(dec q.p.vex)] ?~ q.vex [%& p=~] [%& p=[~ u=p.u.q.vex]] -++ rush |*({naf=@ sab=rule} (rust (trip naf) sab)) -++ rust |* {los=tape sab=rule} +++ rush |*([naf=@ sab=rule] (rust (trip naf) sab)) +++ rust |* [los=tape sab=rule] =+ vex=((full sab) [[1 1] los]) ?~(q.vex ~ [~ u=p.u.q.vex]) -++ scan |* {los=tape sab=rule} +++ scan |* [los=tape sab=rule] =+ vex=((full sab) [[1 1] los]) ?~ q.vex ~_ (show [%m '{%d %d}'] p.p.vex q.p.vex ~) @@ -5267,7 +5267,7 @@ :: ++ low (shim 'a' 'z') :: lowercase ++ mes %+ cook :: hexbyte - |=({a=@ b=@} (add (mul 16 a) b)) + |=([a=@ b=@] (add (mul 16 a) b)) ;~(plug hit hit) ++ nix (boss 256 (star ;~(pose aln cab))) :: ++ nud (shim '0' '9') :: numeric @@ -5303,7 +5303,7 @@ |=(a=tape (rap 3 ^-((list @) a))) ;~(plug alf (star alp)) :: -++ ven ;~ (comp |=({a=@ b=@} (peg a b))) :: +>- axis syntax +++ ven ;~ (comp |=([a=@ b=@] (peg a b))) :: +>- axis syntax bet =+ hom=`?`| |= tub=nail @@ -5437,7 +5437,7 @@ ++ wiz (ape (bass 0x4000.0000 ;~(plug pew:ab (star ;~(pfix dog piw:ab))))) -- ++ mu - |_ {top=@ bot=@} + |_ [top=@ bot=@] ++ zag [p=(end 4 1 (add top bot)) q=bot] ++ zig [p=(end 4 1 (add top (sub 0x1.0000 bot))) q=bot] ++ zug (mix (lsh 4 1 top) bot) @@ -5746,7 +5746,7 @@ (cook |=(det=date `dime`[%da (year det)]) when) :: %+ cook - |= {a=(list {p=?(%d %h %m %s) q=@}) b=(list @)} + |= [a=(list [p=?(%d %h %m %s) q=@]) b=(list @)] =+ rop=`tarp`[0 0 0 0 b] |- ^- dime ?~ a @@ -5849,7 +5849,7 @@ ++ royl-cell |= rn ^- dn - ?. ?=({%d *} +<) +< + ?. ?=([%d *] +<) +< =+ ^= h (dif:si (new:si f.b i.b) (sun:si d.b)) [%d a h (add (mul c.b (pow 10 d.b)) e.b)] @@ -5857,7 +5857,7 @@ ++ tash ~+ =+ ^= neg - |= {syn=? mol=dime} ^- dime + |= [syn=? mol=dime] ^- dime ?> =('u' (end 3 1 p.mol)) [(cat 3 's' (rsh 3 1 p.mol)) (new:si syn q.mol)] ;~ pfix hep @@ -5884,7 +5884,7 @@ ~+ ;~ plug %+ cook - |=({a=@ b=?} [b a]) + |=([a=@ b=?] [b a]) ;~(plug dim:ag ;~(pose (cold | hep) (easy &))) ;~(pfix dot mot:ag) :: month ;~(pfix dot dip:ag) :: day @@ -5922,16 +5922,16 @@ ~/ %scow |=(mol=dime ~(rend co %$ mol)) ++ slat |=(mod=@tas |=(txt=@ta (slaw mod txt))) -++ slav |=({mod=@tas txt=@ta} (need (slaw mod txt))) +++ slav |=([mod=@tas txt=@ta] (need (slaw mod txt))) ++ slaw ~/ %slaw - |= {mod=@tas txt=@ta} + |= [mod=@tas txt=@ta] ^- (unit @) ?+ mod :: slow fallback case to the full slay :: =+ con=(slay txt) - ?.(&(?=({~ %$ @ @} con) =(p.p.u.con mod)) ~ [~ q.p.u.con]) + ?.(&(?=([~ %$ @ @] con) =(p.p.u.con mod)) ~ [~ q.p.u.con]) :: %da (rush txt ;~(pfix sig (cook year when:so))) @@ -6293,13 +6293,13 @@ %null :: ~ == 0 %void :: empty set == :: - {%atom p=aura} :: atom + [%atom p=aura] :: atom :: -+$ woof $@(@ {~ p=hoon}) :: simple embed ++$ woof $@(@ [~ p=hoon]) :: simple embed +$ chum $? lef=term :: jet name - {std=term kel=@} :: kelvin version - {ven=term pro=term kel=@} :: vendor and product - {ven=term pro=term ver=@ kel=@} :: all of the above + [std=term kel=@] :: kelvin version + [ven=term pro=term kel=@] :: vendor and product + [ven=term pro=term ver=@ kel=@] :: all of the above == :: +$ coil $: p=garb :: name, wet=dry, vary q=type :: context @@ -6307,8 +6307,8 @@ == :: +$ garb (trel (unit term) poly vair) :: core +$ poly ?(%wet %dry) :: polarity -+$ foot $% {%dry p=hoon} :: dry arm, geometric - {%wet p=hoon} :: wet arm, generic ++$ foot $% [%dry p=hoon] :: dry arm, geometric + [%wet p=hoon] :: wet arm, generic == :: +$ link :: lexical segment $% [%chat p=term] :: |chapter @@ -6319,16 +6319,16 @@ +$ crib [summary=cord details=(list sect)] :: +$ help [links=(list link) =crib] :: documentation +$ limb $@ term :: wing element - $% {%& p=axis} :: by geometry - {%| p=@ud q=(unit term)} :: by name + $% [%& p=axis] :: by geometry + [%| p=@ud q=(unit term)] :: by name == :: :: XX more and better sanity :: +$ null ~ :: null, nil, etc +$ onyx (list (pair type foot)) :: arm activation +$ opal :: limb match - $% {%& p=type} :: leg - {%| p=axis q=(set {p=type q=foot})} :: arm + $% [%& p=type] :: leg + [%| p=axis q=(set [p=type q=foot])] :: arm == :: +$ pica (pair ? cord) :: & prose, | code +$ palo (pair vein opal) :: wing trace, match @@ -6342,44 +6342,44 @@ +$ port (each palo (pair type nock)) :: successful match +$ spec :: structure definition $~ [%base %null] :: - $% {%base p=base} :: base type - {%dbug p=spot q=spec} :: set debug - {%leaf p=term q=@} :: constant atom - {%like p=wing q=(list wing)} :: reference - {%loop p=term} :: hygienic reference - {%made p=(pair term (list term)) q=spec} :: annotate synthetic - {%make p=hoon q=(list spec)} :: composed spec - {%name p=term q=spec} :: annotate simple - {%over p=wing q=spec} :: relative to subject + $% [%base p=base] :: base type + [%dbug p=spot q=spec] :: set debug + [%leaf p=term q=@] :: constant atom + [%like p=wing q=(list wing)] :: reference + [%loop p=term] :: hygienic reference + [%made p=(pair term (list term)) q=spec] :: annotate synthetic + [%make p=hoon q=(list spec)] :: composed spec + [%name p=term q=spec] :: annotate simple + [%over p=wing q=spec] :: relative to subject :: :: - {%bcgr p=spec q=spec} :: $>, filter: require - {%bcbc p=spec q=(map term spec)} :: $$, recursion - {%bcbr p=spec q=hoon} :: $|, verify - {%bccb p=hoon} :: $_, example - {%bccl p={i=spec t=(list spec)}} :: $:, tuple - {%bccn p={i=spec t=(list spec)}} :: $%, head pick - {%bcdt p=spec q=(map term spec)} :: $., read-write core - {%bcgl p=spec q=spec} :: $<, filter: exclude - {%bchp p=spec q=spec} :: $-, function core - {%bckt p=spec q=spec} :: $^, cons pick - {%bcls p=stud q=spec} :: $+, standard - {%bcfs p=spec q=(map term spec)} :: $/, write-only core - {%bcmc p=hoon} :: $;, manual - {%bcpm p=spec q=hoon} :: $&, repair - {%bcsg p=hoon q=spec} :: $~, default - {%bctc p=spec q=(map term spec)} :: $`, read-only core - {%bcts p=skin q=spec} :: $=, name - {%bcpt p=spec q=spec} :: $@, atom pick - {%bcwt p={i=spec t=(list spec)}} :: $?, full pick - {%bczp p=spec q=(map term spec)} :: $!, opaque core + [%bcgr p=spec q=spec] :: $>, filter: require + [%bcbc p=spec q=(map term spec)] :: $$, recursion + [%bcbr p=spec q=hoon] :: $|, verify + [%bccb p=hoon] :: $_, example + [%bccl p=[i=spec t=(list spec)]] :: $:, tuple + [%bccn p=[i=spec t=(list spec)]] :: $%, head pick + [%bcdt p=spec q=(map term spec)] :: $., read-write core + [%bcgl p=spec q=spec] :: $<, filter: exclude + [%bchp p=spec q=spec] :: $-, function core + [%bckt p=spec q=spec] :: $^, cons pick + [%bcls p=stud q=spec] :: $+, standard + [%bcfs p=spec q=(map term spec)] :: $/, write-only core + [%bcmc p=hoon] :: $;, manual + [%bcpm p=spec q=hoon] :: $&, repair + [%bcsg p=hoon q=spec] :: $~, default + [%bctc p=spec q=(map term spec)] :: $`, read-only core + [%bcts p=skin q=spec] :: $=, name + [%bcpt p=spec q=spec] :: $@, atom pick + [%bcwt p=[i=spec t=(list spec)]] :: $?, full pick + [%bczp p=spec q=(map term spec)] :: $!, opaque core == :: +$ tent :: model builder - $% {%| p=wing q=tent r=(list spec)} :: ~(p q r...) - {%& p=(list wing)} :: a.b:c.d + $% [%| p=wing q=tent r=(list spec)] :: ~(p q r...) + [%& p=(list wing)] :: a.b:c.d == :: +$ tiki :: test case - $% {%& p=(unit term) q=wing} :: simple wing - {%| p=(unit term) q=hoon} :: named wing + $% [%& p=(unit term) q=wing] :: simple wing + [%| p=(unit term) q=hoon] :: named wing == :: +$ skin :: texture $@ =term :: name/~[term %none] @@ -6401,12 +6401,12 @@ (pair tope tope) :: cell ++ hoot :: hoon tools |% - +$ beer $@(char {~ p=hoon}) :: simple embed - +$ mane $@(@tas {@tas @tas}) :: XML name+space - +$ manx $~([[%$ ~] ~] {g=marx c=marl}) :: dynamic XML node + +$ beer $@(char [~ p=hoon]) :: simple embed + +$ mane $@(@tas [@tas @tas]) :: XML name+space + +$ manx $~([[%$ ~] ~] [g=marx c=marl]) :: dynamic XML node +$ marl (list tuna) :: dynamic XML nodes - +$ mart (list {n=mane v=(list beer)}) :: dynamic XML attrs - +$ marx $~([%$ ~] {n=mane a=mart}) :: dynamic XML tag + +$ mart (list [n=mane v=(list beer)]) :: dynamic XML attrs + +$ marx $~([%$ ~] [n=mane a=mart]) :: dynamic XML tag +$ mare (each manx marl) :: node or nodes +$ maru (each tuna marl) :: interp or nodes +$ tuna :: maybe interpolation @@ -6418,180 +6418,180 @@ -- :: +$ hoon :: $~ [%zpzp ~] - $^ {p=hoon q=hoon} :: + $^ [p=hoon q=hoon] :: $% :: - {%$ p=axis} :: simple leg + [%$ p=axis] :: simple leg :: :: - {%base p=base} :: base spec - {%bust p=base} :: bunt base - {%dbug p=spot q=hoon} :: debug info in trace - {%eror p=tape} :: assembly error - {%hand p=type q=nock} :: premade result - {%note p=note q=hoon} :: annotate - {%fits p=hoon q=wing} :: underlying ?= - {%knit p=(list woof)} :: assemble string - {%leaf p=(pair term @)} :: symbol spec - {%limb p=term} :: take limb - {%lost p=hoon} :: not to be taken - {%rock p=term q=*} :: fixed constant - {%sand p=term q=*} :: unfixed constant - {%tell p=(list hoon)} :: render as tape - {%tune p=$@(term tune)} :: minimal face - {%wing p=wing} :: take wing - {%yell p=(list hoon)} :: render as tank - {%xray p=manx:hoot} :: ;foo; templating + [%base p=base] :: base spec + [%bust p=base] :: bunt base + [%dbug p=spot q=hoon] :: debug info in trace + [%eror p=tape] :: assembly error + [%hand p=type q=nock] :: premade result + [%note p=note q=hoon] :: annotate + [%fits p=hoon q=wing] :: underlying ?= + [%knit p=(list woof)] :: assemble string + [%leaf p=(pair term @)] :: symbol spec + [%limb p=term] :: take limb + [%lost p=hoon] :: not to be taken + [%rock p=term q=*] :: fixed constant + [%sand p=term q=*] :: unfixed constant + [%tell p=(list hoon)] :: render as tape + [%tune p=$@(term tune)] :: minimal face + [%wing p=wing] :: take wing + [%yell p=(list hoon)] :: render as tank + [%xray p=manx:hoot] :: ;foo; templating :: :::::: cores - {%brbc sample=(lest term) body=spec} :: |$ - {%brcb p=spec q=alas r=(map term tome)} :: |_ - {%brcl p=hoon q=hoon} :: |: - {%brcn p=(unit term) q=(map term tome)} :: |% - {%brdt p=hoon} :: |. - {%brkt p=hoon q=(map term tome)} :: |^ - {%brhp p=hoon} :: |- - {%brsg p=spec q=hoon} :: |~ - {%brtr p=spec q=hoon} :: |* - {%brts p=spec q=hoon} :: |= - {%brpt p=(unit term) q=(map term tome)} :: |@ - {%brwt p=hoon} :: |? + [%brbc sample=(lest term) body=spec] :: |$ + [%brcb p=spec q=alas r=(map term tome)] :: |_ + [%brcl p=hoon q=hoon] :: |: + [%brcn p=(unit term) q=(map term tome)] :: |% + [%brdt p=hoon] :: |. + [%brkt p=hoon q=(map term tome)] :: |^ + [%brhp p=hoon] :: |- + [%brsg p=spec q=hoon] :: |~ + [%brtr p=spec q=hoon] :: |* + [%brts p=spec q=hoon] :: |= + [%brpt p=(unit term) q=(map term tome)] :: |@ + [%brwt p=hoon] :: |? :: :::::: tuples - {%clcb p=hoon q=hoon} :: :_ [q p] - {%clkt p=hoon q=hoon r=hoon s=hoon} :: :^ [p q r s] - {%clhp p=hoon q=hoon} :: :- [p q] - {%clls p=hoon q=hoon r=hoon} :: :+ [p q r] - {%clsg p=(list hoon)} :: :~ [p ~] - {%cltr p=(list hoon)} :: :* p as a tuple + [%clcb p=hoon q=hoon] :: :_ [q p] + [%clkt p=hoon q=hoon r=hoon s=hoon] :: :^ [p q r s] + [%clhp p=hoon q=hoon] :: :- [p q] + [%clls p=hoon q=hoon r=hoon] :: :+ [p q r] + [%clsg p=(list hoon)] :: :~ [p ~] + [%cltr p=(list hoon)] :: :* p as a tuple :: :::::: invocations - {%cncb p=wing q=(list (pair wing hoon))} :: %_ - {%cndt p=hoon q=hoon} :: %. - {%cnhp p=hoon q=hoon} :: %- - {%cncl p=hoon q=(list hoon)} :: %: - {%cntr p=wing q=hoon r=(list (pair wing hoon))} :: %* - {%cnkt p=hoon q=hoon r=hoon s=hoon} :: %^ - {%cnls p=hoon q=hoon r=hoon} :: %+ - {%cnsg p=wing q=hoon r=(list hoon)} :: %~ - {%cnts p=wing q=(list (pair wing hoon))} :: %= + [%cncb p=wing q=(list (pair wing hoon))] :: %_ + [%cndt p=hoon q=hoon] :: %. + [%cnhp p=hoon q=hoon] :: %- + [%cncl p=hoon q=(list hoon)] :: %: + [%cntr p=wing q=hoon r=(list (pair wing hoon))] :: %* + [%cnkt p=hoon q=hoon r=hoon s=hoon] :: %^ + [%cnls p=hoon q=hoon r=hoon] :: %+ + [%cnsg p=wing q=hoon r=(list hoon)] :: %~ + [%cnts p=wing q=(list (pair wing hoon))] :: %= :: :::::: nock - {%dtkt p=spec q=hoon} :: .^ nock 11 - {%dtls p=hoon} :: .+ nock 4 - {%dttr p=hoon q=hoon} :: .* nock 2 - {%dtts p=hoon q=hoon} :: .= nock 5 - {%dtwt p=hoon} :: .? nock 3 + [%dtkt p=spec q=hoon] :: .^ nock 11 + [%dtls p=hoon] :: .+ nock 4 + [%dttr p=hoon q=hoon] :: .* nock 2 + [%dtts p=hoon q=hoon] :: .= nock 5 + [%dtwt p=hoon] :: .? nock 3 :: :::::: type conversion - {%ktbr p=hoon} :: ^| contravariant - {%ktcn p=hoon} :: ^% enter test mode - {%ktdt p=hoon q=hoon} :: ^. self-cast - {%ktls p=hoon q=hoon} :: ^+ expression cast - {%kthp p=spec q=hoon} :: ^- structure cast - {%ktpm p=hoon} :: ^& covariant - {%ktsg p=hoon} :: ^~ constant - {%ktts p=skin q=hoon} :: ^= label - {%ktwt p=hoon} :: ^? bivariant - {%kttr p=spec} :: ^* example - {%ktcl p=spec} :: ^: filter + [%ktbr p=hoon] :: ^| contravariant + [%ktcn p=hoon] :: ^% enter test mode + [%ktdt p=hoon q=hoon] :: ^. self-cast + [%ktls p=hoon q=hoon] :: ^+ expression cast + [%kthp p=spec q=hoon] :: ^- structure cast + [%ktpm p=hoon] :: ^& covariant + [%ktsg p=hoon] :: ^~ constant + [%ktts p=skin q=hoon] :: ^= label + [%ktwt p=hoon] :: ^? bivariant + [%kttr p=spec] :: ^* example + [%ktcl p=spec] :: ^: filter :: :::::: hints - {%sgbr p=hoon q=hoon} :: ~| sell on trace - {%sgcb p=hoon q=hoon} :: ~_ tank on trace - {%sgcn p=chum q=hoon r=tyre s=hoon} :: ~% general jet hint - {%sgfs p=chum q=hoon} :: ~/ function j-hint - {%sggl p=$@(term {p=term q=hoon}) q=hoon} :: ~< backward hint - {%sggr p=$@(term {p=term q=hoon}) q=hoon} :: ~> forward hint - {%sgbc p=term q=hoon} :: ~$ profiler hit - {%sgls p=@ q=hoon} :: ~+ cache=memoize - {%sgpm p=@ud q=hoon r=hoon} :: ~& printf=priority - {%sgts p=hoon q=hoon} :: ~= don't duplicate - {%sgwt p=@ud q=hoon r=hoon s=hoon} :: ~? tested printf - {%sgzp p=hoon q=hoon} :: ~! type on trace + [%sgbr p=hoon q=hoon] :: ~| sell on trace + [%sgcb p=hoon q=hoon] :: ~_ tank on trace + [%sgcn p=chum q=hoon r=tyre s=hoon] :: ~% general jet hint + [%sgfs p=chum q=hoon] :: ~/ function j-hint + [%sggl p=$@(term [p=term q=hoon]) q=hoon] :: ~< backward hint + [%sggr p=$@(term [p=term q=hoon]) q=hoon] :: ~> forward hint + [%sgbc p=term q=hoon] :: ~$ profiler hit + [%sgls p=@ q=hoon] :: ~+ cache=memoize + [%sgpm p=@ud q=hoon r=hoon] :: ~& printf=priority + [%sgts p=hoon q=hoon] :: ~= don't duplicate + [%sgwt p=@ud q=hoon r=hoon s=hoon] :: ~? tested printf + [%sgzp p=hoon q=hoon] :: ~! type on trace :: :::::: miscellaneous - {%mcts p=marl:hoot} :: ;= list templating - {%mccl p=hoon q=(list hoon)} :: ;: binary to nary - {%mcfs p=hoon} :: ;/ [%$ [%$ p ~] ~] - {%mcgl p=spec q=hoon r=hoon s=hoon} :: ;< bind - {%mcsg p=hoon q=(list hoon)} :: ;~ kleisli arrow - {%mcmc p=spec q=hoon} :: ;; normalize + [%mcts p=marl:hoot] :: ;= list templating + [%mccl p=hoon q=(list hoon)] :: ;: binary to nary + [%mcfs p=hoon] :: ;/ [%$ [%$ p ~] ~] + [%mcgl p=spec q=hoon r=hoon s=hoon] :: ;< bind + [%mcsg p=hoon q=(list hoon)] :: ;~ kleisli arrow + [%mcmc p=spec q=hoon] :: ;; normalize :: :::::: compositions - {%tsbr p=spec q=hoon} :: =| push bunt - {%tscl p=(list (pair wing hoon)) q=hoon} :: =: q w= p changes - {%tsfs p=skin q=hoon r=hoon} :: =/ typed variable - {%tsmc p=skin q=hoon r=hoon} :: =; =/(q p r) - {%tsdt p=wing q=hoon r=hoon} :: =. r with p as q - {%tswt p=wing q=hoon r=hoon s=hoon} :: =? conditional =. - {%tsgl p=hoon q=hoon} :: =< =>(q p) - {%tshp p=hoon q=hoon} :: =- =+(q p) - {%tsgr p=hoon q=hoon} :: => q w=subject p - {%tskt p=skin q=wing r=hoon s=hoon} :: =^ state machine - {%tsls p=hoon q=hoon} :: =+ q w=[p subject] - {%tssg p=(list hoon)} :: =~ hoon stack - {%tstr p=(pair term (unit spec)) q=hoon r=hoon} :: =* new style - {%tscm p=hoon q=hoon} :: =, overload p in q + [%tsbr p=spec q=hoon] :: =| push bunt + [%tscl p=(list (pair wing hoon)) q=hoon] :: =: q w= p changes + [%tsfs p=skin q=hoon r=hoon] :: =/ typed variable + [%tsmc p=skin q=hoon r=hoon] :: =; =/(q p r) + [%tsdt p=wing q=hoon r=hoon] :: =. r with p as q + [%tswt p=wing q=hoon r=hoon s=hoon] :: =? conditional =. + [%tsgl p=hoon q=hoon] :: =< =>(q p) + [%tshp p=hoon q=hoon] :: =- =+(q p) + [%tsgr p=hoon q=hoon] :: => q w=subject p + [%tskt p=skin q=wing r=hoon s=hoon] :: =^ state machine + [%tsls p=hoon q=hoon] :: =+ q w=[p subject] + [%tssg p=(list hoon)] :: =~ hoon stack + [%tstr p=(pair term (unit spec)) q=hoon r=hoon] :: =* new style + [%tscm p=hoon q=hoon] :: =, overload p in q :: :::::: conditionals - {%wtbr p=(list hoon)} :: ?| loobean or - {%wthp p=wing q=(list (pair spec hoon))} :: ?- pick case in q - {%wtcl p=hoon q=hoon r=hoon} :: ?: if=then=else - {%wtdt p=hoon q=hoon r=hoon} :: ?. ?:(p r q) - {%wtkt p=wing q=hoon r=hoon} :: ?^ if p is a cell - {%wtgl p=hoon q=hoon} :: ?< ?:(p !! q) - {%wtgr p=hoon q=hoon} :: ?> ?:(p q !!) - {%wtls p=wing q=hoon r=(list (pair spec hoon))} :: ?+ ?- w=default - {%wtpm p=(list hoon)} :: ?& loobean and - {%wtpt p=wing q=hoon r=hoon} :: ?@ if p is atom - {%wtsg p=wing q=hoon r=hoon} :: ?~ if p is null - {%wthx p=skin q=wing} :: ?# if q matches p - {%wtts p=spec q=wing} :: ?= if q matches p - {%wtzp p=hoon} :: ?! loobean not + [%wtbr p=(list hoon)] :: ?| loobean or + [%wthp p=wing q=(list (pair spec hoon))] :: ?- pick case in q + [%wtcl p=hoon q=hoon r=hoon] :: ?: if=then=else + [%wtdt p=hoon q=hoon r=hoon] :: ?. ?:(p r q) + [%wtkt p=wing q=hoon r=hoon] :: ?^ if p is a cell + [%wtgl p=hoon q=hoon] :: ?< ?:(p !! q) + [%wtgr p=hoon q=hoon] :: ?> ?:(p q !!) + [%wtls p=wing q=hoon r=(list (pair spec hoon))] :: ?+ ?- w=default + [%wtpm p=(list hoon)] :: ?& loobean and + [%wtpt p=wing q=hoon r=hoon] :: ?@ if p is atom + [%wtsg p=wing q=hoon r=hoon] :: ?~ if p is null + [%wthx p=skin q=wing] :: ?# if q matches p + [%wtts p=spec q=wing] :: ?= if q matches p + [%wtzp p=hoon] :: ?! loobean not :: :::::: special - {%zpcm p=hoon q=hoon} :: !, - {%zpgr p=hoon} :: !> - {%zpgl p=spec q=hoon} :: !< - {%zpmc p=hoon q=hoon} :: !; - {%zpts p=hoon} :: != - {%zppt p=(list wing) q=hoon r=hoon} :: !@ - {%zpwt p=$@(p=@ {p=@ q=@}) q=hoon} :: !? - {%zpzp ~} :: !! + [%zpcm p=hoon q=hoon] :: !, + [%zpgr p=hoon] :: !> + [%zpgl p=spec q=hoon] :: !< + [%zpmc p=hoon q=hoon] :: !; + [%zpts p=hoon] :: != + [%zppt p=(list wing) q=hoon r=hoon] :: !@ + [%zpwt p=$@(p=@ [p=@ q=@]) q=hoon] :: !? + [%zpzp ~] :: !! == :: -+$ tyre (list {p=term q=hoon}) :: ++$ tyre (list [p=term q=hoon]) :: +$ tyke (list (unit hoon)) :: :: :::::: virtual nock -+$ nock $^ {p=nock q=nock} :: autocons - $% {%1 p=*} :: constant - {%2 p=nock q=nock} :: compose - {%3 p=nock} :: cell test - {%4 p=nock} :: increment - {%5 p=nock q=nock} :: equality test - {%6 p=nock q=nock r=nock} :: if, then, else - {%7 p=nock q=nock} :: serial compose - {%8 p=nock q=nock} :: push onto subject - {%9 p=@ q=nock} :: select arm and fire - {%10 p={p=@ q=nock} q=nock} :: edit - {%11 p=$@(@ {p=@ q=nock}) q=nock} :: hint - {%12 p=nock q=nock} :: grab data from sky - {%0 p=@} :: axis select ++$ nock $^ [p=nock q=nock] :: autocons + $% [%1 p=*] :: constant + [%2 p=nock q=nock] :: compose + [%3 p=nock] :: cell test + [%4 p=nock] :: increment + [%5 p=nock q=nock] :: equality test + [%6 p=nock q=nock r=nock] :: if, then, else + [%7 p=nock q=nock] :: serial compose + [%8 p=nock q=nock] :: push onto subject + [%9 p=@ q=nock] :: select arm and fire + [%10 p=[p=@ q=nock] q=nock] :: edit + [%11 p=$@(@ [p=@ q=nock]) q=nock] :: hint + [%12 p=nock q=nock] :: grab data from sky + [%0 p=@] :: axis select == :: +$ note :: type annotation - $% {%help p=help} :: documentation - {%know p=stud} :: global standard - {%made p=term q=(unit (list wing))} :: structure + $% [%help p=help] :: documentation + [%know p=stud] :: global standard + [%made p=term q=(unit (list wing))] :: structure == :: +$ type $~ %noun :: $@ $? %noun :: any nouns %void :: no noun == :: - $% {%atom p=term q=(unit @)} :: atom / constant - {%cell p=type q=type} :: ordered pair - {%core p=type q=coil} :: object - {%face p=$@(term tune) q=type} :: namespace - {%fork p=(set type)} :: union - {%hint p=(pair type note) q=type} :: annotation - {%hold p=type q=hoon} :: lazy evaluation + $% [%atom p=term q=(unit @)] :: atom / constant + [%cell p=type q=type] :: ordered pair + [%core p=type q=coil] :: object + [%face p=$@(term tune) q=type] :: namespace + [%fork p=(set type)] :: union + [%hint p=(pair type note) q=type] :: annotation + [%hold p=type q=hoon] :: lazy evaluation == :: +$ tony :: ++tone done right - $% {%0 p=tine q=*} :: success - {%1 p=(set)} :: blocks - {%2 p=(list {@ta *})} :: error ~_s + $% [%0 p=tine q=*] :: success + [%1 p=(set)] :: blocks + [%2 p=(list [@ta *])] :: error ~_s == :: +$ tine :: partial noun $@ ~ :: open - $% {%& p=tine q=tine} :: half-blocked - {%| p=(set)} :: fully blocked + $% [%& p=tine q=tine] :: half-blocked + [%| p=(set)] :: fully blocked == :: +$ tool $@(term tune) :: type decoration +$ tune :: complex @@ -6600,8 +6600,8 @@ q=(list hoon) :: bridges == :: +$ typo type :: old type -+$ vase {p=type q=*} :: type-value pair -+$ vise {p=typo q=*} :: old vase ++$ vase [p=type q=*] :: type-value pair ++$ vise [p=typo q=*] :: old vase +$ vial ?(%read %rite %both %free) :: co/contra/in/bi +$ vair ?(%gold %iron %lead %zinc) :: in/contra/bi/co +$ vein (list (unit axis)) :: search trace @@ -6622,30 +6622,30 @@ :: :: +block: abstract identity of resource awaited :: -++ block ++$ block path :: :: +result: internal interpreter result :: -++ result ++$ result $@(~ seminoun) :: :: +thunk: fragment constructor :: -++ thunk ++$ thunk $-(@ud (unit noun)) :: :: +seminoun: :: -++ seminoun ++$ seminoun :: partial noun; blocked subtrees are ~ :: $~ [[%full ~] ~] - {mask=stencil data=noun} + [mask=stencil data=noun] :: :: +stencil: noun knowledge map :: -++ stencil ++$ stencil $% :: :: %half: noun has partial block substructure :: @@ -6660,7 +6660,7 @@ [%lazy fragment=axis resolve=thunk] == :: -++ output ++$ output :: ~: interpreter stopped :: %- unit @@ -6674,12 +6674,12 @@ [%wait p=(list block)] == :: profiling -++ doss ++$ doss $: mon=moan :: sample count hit=(map term @ud) :: hit points cut=(map path hump) :: cut points == -++ moan :: sample metric ++$ moan :: sample metric $: fun=@ud :: samples in C noc=@ud :: samples in nock glu=@ud :: samples in glue @@ -6689,7 +6689,7 @@ euq=@ud :: samples in equal == :: :: -++ hump ++$ hump $: mon=moan :: sample count out=(map path @ud) :: calls out of inn=(map path @ud) :: calls into @@ -6779,7 +6779,7 @@ ~ :: 0; fragment :: - {%0 b=@} + [%0 b=@] :: if bad axis, stop :: ?: =(0 b.fol) ~ @@ -6789,14 +6789,14 @@ :: :: 1; constant :: - {%1 b=*} + [%1 b=*] :: constant is complete :: [full/~ b.fol] :: :: 2; recursion :: - {%2 b=* c=*} + [%2 b=* c=*] :: require complete formula :: %+ require @@ -6818,7 +6818,7 @@ :: :: 3; probe :: - {%3 b=*} + [%3 b=*] %+ require $(fol b.fol) |= :: fig: probe input @@ -6830,7 +6830,7 @@ :: :: 4; increment :: - {%4 b=*} + [%4 b=*] %+ require $(fol b.fol) |= :: fig: increment input @@ -6842,7 +6842,7 @@ :: :: 5; compare :: - {%5 b=* c=*} + [%5 b=* c=*] %+ require $(fol b.fol) |= :: hed: left input @@ -6857,7 +6857,7 @@ :: :: 6; if-then-else :: - {%6 b=* c=* d=*} + [%6 b=* c=* d=*] :: semantic expansion :: %+ require @@ -6875,7 +6875,7 @@ :: :: 7; composition :: - {%7 b=* c=*} + [%7 b=* c=*] :: one: input :: =+ one=$(fol b.fol) @@ -6888,7 +6888,7 @@ :: :: 8; introduction :: - {%8 b=* c=*} + [%8 b=* c=*] :: one: input :: =+ one=$(fol b.fol) @@ -6901,7 +6901,7 @@ :: :: 9; invocation :: - {%9 b=* c=*} + [%9 b=* c=*] :: semantic expansion :: ?^ b.fol ~ @@ -6935,7 +6935,7 @@ :: :: 10; edit :: - {%10 {b=@ c=*} d=*} + [%10 [b=@ c=*] d=*] :: tar: target of edit :: =+ tar=$(fol d.fol) @@ -6952,14 +6952,14 @@ :: :: 11; static hint :: - {%11 @ c=*} + [%11 @ c=*] :: ignore hint :: $(fol c.fol) :: :: 11; dynamic hint :: - {%11 {b=* c=*} d=*} + [%11 [b=* c=*] d=*] :: noy: dynamic hint :: =+ noy=$(fol c.fol) @@ -7197,18 +7197,18 @@ ++ bool `type`(fork [%atom %f `0] [%atom %f `1] ~) :: make loobean ++ cell :: make %cell type ~/ %cell - |= {hed=type tal=type} + |= [hed=type tal=type] ^- type ?:(=(%void hed) %void ?:(=(%void tal) %void [%cell hed tal])) :: ++ core :: make %core type ~/ %core - |= {pac=type con=coil} + |= [pac=type con=coil] ^- type ?:(=(%void pac) %void [%core pac con]) :: ++ hint - |= {p=(pair type note) q=type} + |= [p=(pair type note) q=type] ^- type ?: =(%void q) %void ?: =(%noun q) %noun @@ -7216,7 +7216,7 @@ :: ++ face :: make %face type ~/ %face - |= {giz=$@(term tune) der=type} + |= [giz=$@(term tune) der=type] ^- type ?: =(%void der) %void @@ -7229,34 +7229,34 @@ |- ^- type ?~ yed ?~ lez %void - ?: ?=({* ~ ~} lez) n.lez + ?: ?=([* ~ ~] lez) n.lez [%fork lez] %= $ yed t.yed lez ?: =(%void i.yed) lez - ?: ?=({%fork *} i.yed) (~(uni in lez) p.i.yed) + ?: ?=([%fork *] i.yed) (~(uni in lez) p.i.yed) (~(put in lez) i.yed) == :: ++ cove :: extract [0 *] axis |= nug=nock ?- nug - {%0 *} p.nug - {%11 *} $(nug q.nug) + [%0 *] p.nug + [%11 *] $(nug q.nug) * ~_(leaf+"cove" !!) == ++ comb :: combine two formulas ~/ %comb - |= {mal=nock buz=nock} + |= [mal=nock buz=nock] ^- nock - ?: ?&(?=({%0 *} mal) !=(0 p.mal)) - ?: ?&(?=({%0 *} buz) !=(0 p.buz)) + ?: ?&(?=([%0 *] mal) !=(0 p.mal)) + ?: ?&(?=([%0 *] buz) !=(0 p.buz)) [%0 (peg p.mal p.buz)] - ?: ?=({%2 {%0 *} {%0 *}} buz) + ?: ?=([%2 [%0 *] [%0 *]] buz) [%2 [%0 (peg p.mal p.p.buz)] [%0 (peg p.mal p.q.buz)]] [%7 mal buz] - ?: ?=({^ {%0 %1}} mal) + ?: ?=([^ [%0 %1]] mal) [%8 p.mal buz] ?: =([%0 %1] buz) mal @@ -7264,17 +7264,17 @@ :: ++ cond :: ?: compile ~/ %cond - |= {pex=nock yom=nock woq=nock} + |= [pex=nock yom=nock woq=nock] ^- nock ?- pex - {%1 %0} yom - {%1 %1} woq + [%1 %0] yom + [%1 %1] woq * [%6 pex yom woq] == :: ++ cons :: make formula cell ~/ %cons - |= {vur=nock sed=nock} + |= [vur=nock sed=nock] ^- nock :: this optimization can remove crashes which are essential :: @@ -7282,15 +7282,15 @@ :: ?: ?&(=(+(p.vur) p.sed) =((div p.vur 2) (div p.sed 2))) :: [%0 (div p.vur 2)] :: [vur sed] - ?: ?=({{%1 *} {%1 *}} +<) + ?: ?=([[%1 *] [%1 *]] +<) [%1 p.vur p.sed] [vur sed] :: ++ fitz :: odor compatibility ~/ %fitz - |= {yaz=term wix=term} + |= [yaz=term wix=term] =+ ^= fiz - |= mot=@ta ^- {p=@ q=@ta} + |= mot=@ta ^- [p=@ q=@ta] =+ len=(met 3 mot) ?: =(0 len) [0 %$] @@ -7313,18 +7313,18 @@ :: ++ flan :: loobean & ~/ %flan - |= {bos=nock nif=nock} + |= [bos=nock nif=nock] ^- nock ?: =(bos nif) bos ?: =([%0 0] bos) nif ?: =([%0 0] nif) bos ?- bos - {%1 %1} bos - {%1 %0} nif + [%1 %1] bos + [%1 %0] nif * ?- nif - {%1 %1} nif - {%1 %0} bos + [%1 %1] nif + [%1 %0] bos * [%6 bos nif [%1 1]] == == @@ -7337,18 +7337,18 @@ :: ++ flor :: loobean | ~/ %flor - |= {bos=nock nif=nock} + |= [bos=nock nif=nock] ^- nock ?: =(bos nif) bos ?: =([%0 0] bos) nif ?: =([%0 0] nif) bos ?- bos - {%1 %1} nif - {%1 %0} bos + [%1 %1] nif + [%1 %0] bos * ?- nif - {%1 %1} bos - {%1 %0} nif + [%1 %1] bos + [%1 %0] nif * [%6 bos [%1 0] nif] == == @@ -7434,30 +7434,30 @@ :: ++ look ~/ %look - |= {cog=term dab=(map term hoon)} + |= [cog=term dab=(map term hoon)] =+ axe=1 - |- ^- (unit {p=axis q=hoon}) + |- ^- (unit [p=axis q=hoon]) ?- dab ~ ~ :: - {* ~ ~} + [* ~ ~] ?:(=(cog p.n.dab) [~ axe q.n.dab] ~) :: - {* ~ *} + [* ~ *] ?: =(cog p.n.dab) [~ (peg axe 2) q.n.dab] ?: (gor cog p.n.dab) ~ $(axe (peg axe 3), dab r.dab) :: - {* * ~} + [* * ~] ?: =(cog p.n.dab) [~ (peg axe 2) q.n.dab] ?: (gor cog p.n.dab) $(axe (peg axe 3), dab l.dab) ~ :: - {* * *} + [* * *] ?: =(cog p.n.dab) [~ (peg axe 2) q.n.dab] ?: (gor cog p.n.dab) @@ -7467,29 +7467,29 @@ :: ++ loot ~/ %loot - |= {cog=term dom=(map term tome)} + |= [cog=term dom=(map term tome)] =+ axe=1 - |- ^- (unit {p=axis q=hoon}) + |- ^- (unit [p=axis q=hoon]) ?- dom ~ ~ :: - {* ~ ~} + [* ~ ~] %+ bind (look cog q.q.n.dom) |=((pair axis hoon) [(peg axe p) q]) :: - {* ~ *} + [* ~ *] =+ yep=(look cog q.q.n.dom) ?^ yep [~ (peg (peg axe 2) p.u.yep) q.u.yep] $(axe (peg axe 3), dom r.dom) :: - {* * ~} + [* * ~] =+ yep=(look cog q.q.n.dom) ?^ yep [~ (peg (peg axe 2) p.u.yep) q.u.yep] $(axe (peg axe 3), dom l.dom) :: - {* * *} + [* * *] =+ yep=(look cog q.q.n.dom) ?^ yep [~ (peg (peg axe 2) p.u.yep) q.u.yep] @@ -7537,13 +7537,13 @@ :: ++ wthp |= opt=(list (pair spec hoon)) %+ gray %wthp - [puce (turn opt |=({a=spec b=hoon} [a (blue b)]))] - ++ wtkt |=({sic=hoon non=hoon} (gray [%wtkt puce (blue sic) (blue non)])) - ++ wtls |= {gen=hoon opt=(list (pair spec hoon))} + [puce (turn opt |=([a=spec b=hoon] [a (blue b)]))] + ++ wtkt |=([sic=hoon non=hoon] (gray [%wtkt puce (blue sic) (blue non)])) + ++ wtls |= [gen=hoon opt=(list (pair spec hoon))] %+ gray %wtls - [puce (blue gen) (turn opt |=({a=spec b=hoon} [a (blue b)]))] - ++ wtpt |=({sic=hoon non=hoon} (gray [%wtpt puce (blue sic) (blue non)])) - ++ wtsg |=({sic=hoon non=hoon} (gray [%wtsg puce (blue sic) (blue non)])) + [puce (blue gen) (turn opt |=([a=spec b=hoon] [a (blue b)]))] + ++ wtpt |=([sic=hoon non=hoon] (gray [%wtpt puce (blue sic) (blue non)])) + ++ wtsg |=([sic=hoon non=hoon] (gray [%wtsg puce (blue sic) (blue non)])) ++ wthx |=(syn=skin (gray [%wthx (tele syn) puce])) ++ wtts |=(mod=spec (gray [%wtts (teal mod) puce])) -- @@ -7562,7 +7562,7 @@ nut=*(unit note) def=*(unit hoon) == - |_ {fab=? mod=spec} + |_ [fab=? mod=spec] :: ++ autoname :: derive name from spec @@ -7608,7 +7608,7 @@ ++ function :: construct a function example :: - |= {fun=spec arg=spec} + |= [fun=spec arg=spec] ^- hoon :: minimal context as subject :: @@ -7628,7 +7628,7 @@ ++ interface :: construct a core example :: - |= {variance=vair payload=spec arms=(map term spec)} + |= [variance=vair payload=spec arms=(map term spec)] ^- hoon :: attach proper variance control :: @@ -7676,7 +7676,7 @@ |= bas=base ?- bas :: - {%atom *} + [%atom *] :: we may want sped :: [%sand p.bas ?:(=(%da p.bas) ~2000.1.1 0)] @@ -7758,8 +7758,8 @@ ~+ |- ^- hoon ?- mod - {%base *} ?:(=(%void p.mod) [%rock %n 0] (basal p.mod)) - {%bcbc *} :: track hygienic recursion points lexically + [%base *] ?:(=(%void p.mod) [%rock %n 0] (basal p.mod)) + [%bcbc *] :: track hygienic recursion points lexically :: %= $ mod p.mod @@ -7767,49 +7767,49 @@ :: (~(put by ^+(cox (~(uni by cox) q.mod))) %$ p.mod) == - {%dbug *} [%dbug p.mod $(mod q.mod)] - {%leaf *} [%rock p.mod q.mod] - {%loop *} ~|([%loop p.mod] $(mod (~(got by cox) p.mod))) - {%like *} $(mod bcmc/(unreel p.mod q.mod)) - {%made *} $(mod q.mod) - {%make *} $(mod bcmc/(unfold p.mod q.mod)) - {%name *} $(mod q.mod) - {%over *} $(hay p.mod, mod q.mod) + [%dbug *] [%dbug p.mod $(mod q.mod)] + [%leaf *] [%rock p.mod q.mod] + [%loop *] ~|([%loop p.mod] $(mod (~(got by cox) p.mod))) + [%like *] $(mod bcmc/(unreel p.mod q.mod)) + [%made *] $(mod q.mod) + [%make *] $(mod bcmc/(unfold p.mod q.mod)) + [%name *] $(mod q.mod) + [%over *] $(hay p.mod, mod q.mod) :: - {%bcbr *} $(mod p.mod) - {%bccb *} [%rock %n 0] - {%bccl *} |- ^- hoon + [%bcbr *] $(mod p.mod) + [%bccb *] [%rock %n 0] + [%bccl *] |- ^- hoon ?~ t.p.mod ^$(mod i.p.mod) :- ^$(mod i.p.mod) $(i.p.mod i.t.p.mod, t.p.mod t.t.p.mod) - {%bccn *} :: use last entry + [%bccn *] :: use last entry :: |- ^- hoon ?~ t.p.mod ^$(mod i.p.mod) $(i.p.mod i.t.p.mod, t.p.mod t.t.p.mod) - {%bchp *} :: see under %bccb + [%bchp *] :: see under %bccb :: [%rock %n 0] - {%bcgl *} $(mod q.mod) - {%bcgr *} $(mod q.mod) - {%bckt *} $(mod q.mod) - {%bcls *} $(mod q.mod) - {%bcmc *} :: borrow sample + [%bcgl *] $(mod q.mod) + [%bcgr *] $(mod q.mod) + [%bckt *] $(mod q.mod) + [%bcls *] $(mod q.mod) + [%bcmc *] :: borrow sample :: [%tsgl [%$ 6] p.mod] - {%bcpm *} $(mod p.mod) - {%bcsg *} [%kthp q.mod p.mod] - {%bcts *} [%ktts p.mod $(mod q.mod)] - {%bcpt *} $(mod p.mod) - {%bcwt *} :: use last entry + [%bcpm *] $(mod p.mod) + [%bcsg *] [%kthp q.mod p.mod] + [%bcts *] [%ktts p.mod $(mod q.mod)] + [%bcpt *] $(mod p.mod) + [%bcwt *] :: use last entry :: |- ^- hoon ?~ t.p.mod ^$(mod i.p.mod) $(i.p.mod i.t.p.mod, t.p.mod t.t.p.mod) - {%bcdt *} [%rock %n 0] - {%bcfs *} [%rock %n 0] - {%bctc *} [%rock %n 0] - {%bczp *} [%rock %n 0] + [%bcdt *] [%rock %n 0] + [%bcfs *] [%rock %n 0] + [%bctc *] [%rock %n 0] + [%bczp *] [%rock %n 0] == :: ++ example @@ -7824,32 +7824,32 @@ spore ~(relative analyze:(descend 3) 2) :: - {%base *} (decorate (basal p.mod)) - {%dbug *} example(mod q.mod, bug [p.mod bug]) - {%leaf *} (decorate [%rock p.mod q.mod]) - {%like *} example(mod bcmc/(unreel p.mod q.mod)) - {%loop *} [%limb p.mod] - {%made *} example(mod q.mod, nut `made/[p.p.mod `(pieces q.p.mod)]) - {%make *} example(mod bcmc/(unfold p.mod q.mod)) - {%name *} example(mod q.mod, nut `made/[p.mod ~]) - {%over *} example(hay p.mod, mod q.mod) + [%base *] (decorate (basal p.mod)) + [%dbug *] example(mod q.mod, bug [p.mod bug]) + [%leaf *] (decorate [%rock p.mod q.mod]) + [%like *] example(mod bcmc/(unreel p.mod q.mod)) + [%loop *] [%limb p.mod] + [%made *] example(mod q.mod, nut `made/[p.p.mod `(pieces q.p.mod)]) + [%make *] example(mod bcmc/(unfold p.mod q.mod)) + [%name *] example(mod q.mod, nut `made/[p.mod ~]) + [%over *] example(hay p.mod, mod q.mod) :: - {%bccb *} (decorate (home p.mod)) - {%bccl *} %- decorate + [%bccb *] (decorate (home p.mod)) + [%bccl *] %- decorate |- ^- hoon ?~ t.p.mod example:clear(mod i.p.mod) :- example:clear(mod i.p.mod) example:clear(i.p.mod i.t.p.mod, t.p.mod t.t.p.mod) - {%bchp *} (decorate (function:clear p.mod q.mod)) - {%bcmc *} (decorate (home [%tsgl [%limb %$] p.mod])) - {%bcsg *} [%ktls example(mod q.mod) (home p.mod)] - {%bcls *} (decorate example(mod q.mod)) - {%bcts *} (decorate [%ktts p.mod example:clear(mod q.mod)]) - {%bcdt *} (decorate (home (interface %gold p.mod q.mod))) - {%bcfs *} (decorate (home (interface %iron p.mod q.mod))) - {%bczp *} (decorate (home (interface %lead p.mod q.mod))) - {%bctc *} (decorate (home (interface %zinc p.mod q.mod))) + [%bchp *] (decorate (function:clear p.mod q.mod)) + [%bcmc *] (decorate (home [%tsgl [%limb %$] p.mod])) + [%bcsg *] [%ktls example(mod q.mod) (home p.mod)] + [%bcls *] (decorate example(mod q.mod)) + [%bcts *] (decorate [%ktts p.mod example:clear(mod q.mod)]) + [%bcdt *] (decorate (home (interface %gold p.mod q.mod))) + [%bcfs *] (decorate (home (interface %iron p.mod q.mod))) + [%bczp *] (decorate (home (interface %lead p.mod q.mod))) + [%bctc *] (decorate (home (interface %zinc p.mod q.mod))) == :: ++ factory @@ -7891,7 +7891,7 @@ |= bas=base ^- hoon ?- bas - {%atom *} + [%atom *] :+ %ktls example ^- hoon :^ %zppt @@ -8003,17 +8003,17 @@ :: :: base :: - {%base *} + [%base *] (decorate (basic:clear p.mod)) :: :: debug :: - {%dbug *} + [%dbug *] relative(mod q.mod, bug [p.mod bug]) :: :: constant :: - {%leaf *} + [%leaf *] %- decorate :+ %wtgr [%dtts fetch [%rock %$ q.mod]] @@ -8021,37 +8021,37 @@ :: :: composite :: - {%make *} + [%make *] relative(mod bcmc/(unfold p.mod q.mod)) :: :: indirect :: - {%like *} + [%like *] relative(mod bcmc/(unreel p.mod q.mod)) :: :: loop :: - {%loop *} + [%loop *] (decorate [%cnhp [%limb p.mod] fetch]) :: :: simple named structure :: - {%name *} + [%name *] relative(mod q.mod, nut `made/[p.mod ~]) :: :: synthetic named structure :: - {%made *} + [%made *] relative(mod q.mod, nut `made/[p.p.mod `(pieces q.p.mod)]) :: :: subjective :: - {%over *} + [%over *] relative(hay p.mod, mod q.mod) :: :: recursive, $$ :: - {%bcbc *} + [%bcbc *] :: :: apply semantically :: @@ -8067,7 +8067,7 @@ :: :: normalize, $& :: - {%bcpm *} + [%bcpm *] :: push the raw result :: :+ %tsls relative(mod p.mod) @@ -8096,7 +8096,7 @@ :: :: verify, $| :: - {%bcbr *} + [%bcbr *] ^- hoon :: push the raw product :: @@ -8114,17 +8114,17 @@ :: :: special, $_ :: - {%bccb *} + [%bccb *] (decorate (home p.mod)) :: :: switch, $% :: - {%bccn *} + [%bccn *] (decorate (switch i.p.mod t.p.mod)) :: :: tuple, $: :: - {%bccl *} + [%bccl *] %- decorate |- ^- hoon ?~ t.p.mod @@ -8138,7 +8138,7 @@ :: :: exclude, $< :: - {%bcgl *} + [%bcgl *] :+ %tsls relative:clear(mod q.mod) :+ %wtgl @@ -8147,7 +8147,7 @@ :: :: require, $> :: - {%bcgr *} + [%bcgr *] :+ %tsls relative:clear(mod q.mod) :+ %wtgr @@ -8156,7 +8156,7 @@ :: :: function :: - {%bchp *} + [%bchp *] %- decorate =/ fun (function:clear p.mod q.mod) ?^ def @@ -8165,7 +8165,7 @@ :: :: bridge, $^ :: - {%bckt *} + [%bckt *] %- decorate :^ %wtcl [%dtwt fetch(axe (peg axe 2))] @@ -8174,38 +8174,38 @@ :: :: synthesis, $; :: - {%bcmc *} + [%bcmc *] (decorate [%cncl (home p.mod) fetch ~]) :: :: default :: - {%bcsg *} + [%bcsg *] relative(mod q.mod, def `[%kthp q.mod p.mod]) :: :: choice, $? :: - {%bcwt *} + [%bcwt *] (decorate (choice i.p.mod t.p.mod)) :: :: name, $= :: - {%bcts *} + [%bcts *] [%ktts p.mod relative(mod q.mod)] :: :: branch, $@ :: - {%bcpt *} + [%bcpt *] %- decorate :^ %wtcl [%dtwt fetch] relative:clear(mod q.mod) relative:clear(mod p.mod) :: - {%bcls *} relative(mod q.mod) - {%bcdt *} (decorate (home (interface %gold p.mod q.mod))) - {%bcfs *} (decorate (home (interface %iron p.mod q.mod))) - {%bczp *} (decorate (home (interface %lead p.mod q.mod))) - {%bctc *} (decorate (home (interface %zinc p.mod q.mod))) + [%bcls *] relative(mod q.mod) + [%bcdt *] (decorate (home (interface %gold p.mod q.mod))) + [%bcfs *] (decorate (home (interface %iron p.mod q.mod))) + [%bczp *] (decorate (home (interface %lead p.mod q.mod))) + [%bctc *] (decorate (home (interface %zinc p.mod q.mod))) == -- -- @@ -8274,21 +8274,21 @@ ++ name |- ^- (unit term) ?+ gen ~ - {%wing *} ?~ p.gen ~ + [%wing *] ?~ p.gen ~ ?^ i.p.gen ?:(?=(%& -.i.p.gen) ~ q.i.p.gen) `i.p.gen - {%limb *} `p.gen - {%dbug *} $(gen ~(open ap gen)) - {%tsgl *} $(gen ~(open ap gen)) - {%tsgr *} $(gen q.gen) + [%limb *] `p.gen + [%dbug *] $(gen ~(open ap gen)) + [%tsgl *] $(gen ~(open ap gen)) + [%tsgr *] $(gen q.gen) == :: ++ feck |- ^- (unit term) ?- gen - {%sand %tas @} [~ q.gen] - {%dbug *} $(gen q.gen) + [%sand %tas @] [~ q.gen] + [%dbug *] $(gen q.gen) * ~ == :: @@ -8305,13 +8305,13 @@ ++ half |- ^- (unit (pair hoon hoon)) ?+ gen ~ - {^ *} `[p.gen q.gen] - {%dbug *} $(gen q.gen) - {%clcb *} `[q.gen p.gen] - {%clhp *} `[p.gen q.gen] - {%clkt *} `[p.gen %clls q.gen r.gen s.gen] - {%clsg *} ?~(p.gen ~ `[i.p.gen %clsg t.p.gen]) - {%cltr *} ?~ p.gen ~ + [^ *] `[p.gen q.gen] + [%dbug *] $(gen q.gen) + [%clcb *] `[q.gen p.gen] + [%clhp *] `[p.gen q.gen] + [%clkt *] `[p.gen %clls q.gen r.gen s.gen] + [%clsg *] ?~(p.gen ~ `[i.p.gen %clsg t.p.gen]) + [%cltr *] ?~ p.gen ~ ?~(t.p.gen $(gen i.p.gen) `[i.p.gen %cltr t.p.gen]) == :::: @@ -8372,15 +8372,15 @@ ++ open ^- hoon ?- gen - {~ *} [%cnts [[%& p.gen] ~] ~] + [~ *] [%cnts [[%& p.gen] ~] ~] :: - {%base *} ~(factory ax fab `spec`gen) - {%bust *} ~(example ax fab %base p.gen) - {%ktcl *} ~(factory ax fab p.gen) - {%dbug *} q.gen - {%eror *} ~>(%slog.[0 leaf=p.gen] !!) + [%base *] ~(factory ax fab `spec`gen) + [%bust *] ~(example ax fab %base p.gen) + [%ktcl *] ~(factory ax fab p.gen) + [%dbug *] q.gen + [%eror *] ~>(%slog.[0 leaf=p.gen] !!) :: - {%knit *} :: + [%knit *] :: :+ %tsgr [%ktts %v %$ 1] :: => v=. :- %brhp :: |- :+ %ktls :: ^+ @@ -8403,7 +8403,7 @@ :+ %ktls :: ^+ [%limb %$] :: $ [%tsgr [%limb %v] p.i.p.gen] :: =>(v {p.i.p.gen}) - [%ktts %b res] :: b={res} + [%ktts %b res] :: b=[res] ^- hoon :: :- %brhp :: |- :^ %wtpt :: ?@ @@ -8414,21 +8414,21 @@ [%$ ~] :: $ [[[%a ~] [%tsgl [%$ 3] [%limb %a]]] ~] :: a +.a :: - {%leaf *} ~(factory ax fab `spec`gen) - {%limb *} [%cnts [p.gen ~] ~] - {%tell *} [%cncl [%limb %noah] [%zpgr [%cltr p.gen]] ~] - {%wing *} [%cnts p.gen ~] - {%yell *} [%cncl [%limb %cain] [%zpgr [%cltr p.gen]] ~] - {%note *} q.gen + [%leaf *] ~(factory ax fab `spec`gen) + [%limb *] [%cnts [p.gen ~] ~] + [%tell *] [%cncl [%limb %noah] [%zpgr [%cltr p.gen]] ~] + [%wing *] [%cnts p.gen ~] + [%yell *] [%cncl [%limb %cain] [%zpgr [%cltr p.gen]] ~] + [%note *] q.gen :: - {%brbc *} =- ?~ - !! + [%brbc *] =- ?~ - !! [%brtr [%bccl -] [%ktcl body.gen]] %+ turn `(list term)`sample.gen |= =term ^- spec =/ tar [%base %noun] [%bcts term [%bcsg tar [%bchp tar tar]]] - {%brcb *} :+ %tsls [%kttr p.gen] + [%brcb *] :+ %tsls [%kttr p.gen] :+ %brcn ~ %- ~(run by r.gen) |= =tome @@ -8437,11 +8437,11 @@ |= =hoon ?~ q.gen hoon [%tstr [p.i.q.gen ~] q.i.q.gen $(q.gen t.q.gen)] - {%brcl *} [%tsls p.gen [%brdt q.gen]] - {%brdt *} :+ %brcn ~ + [%brcl *] [%tsls p.gen [%brdt q.gen]] + [%brdt *] :+ %brcn ~ =- [[%$ ~ -] ~ ~] (~(put by *(map term hoon)) %$ p.gen) - {%brkt *} :+ %tsgl [%limb %$] + [%brkt *] :+ %tsgl [%limb %$] :+ %brcn ~ =+ zil=(~(get by q.gen) %$) ?~ zil @@ -8449,28 +8449,28 @@ [*what [[%$ p.gen] ~ ~]] %+ ~(put by q.gen) %$ [p.u.zil (~(put by q.u.zil) %$ p.gen)] - {%brhp *} [%tsgl [%limb %$] [%brdt p.gen]] - {%brsg *} [%ktbr [%brts p.gen q.gen]] - {%brtr *} :+ %tsls [%kttr p.gen] + [%brhp *] [%tsgl [%limb %$] [%brdt p.gen]] + [%brsg *] [%ktbr [%brts p.gen q.gen]] + [%brtr *] :+ %tsls [%kttr p.gen] :+ %brpt ~ =- [[%$ ~ -] ~ ~] (~(put by *(map term hoon)) %$ q.gen) - {%brts *} :+ %brcb p.gen + [%brts *] :+ %brcb p.gen =- [~ [[%$ ~ -] ~ ~]] (~(put by *(map term hoon)) %$ q.gen) - {%brwt *} [%ktwt %brdt p.gen] + [%brwt *] [%ktwt %brdt p.gen] :: - {%clkt *} [p.gen q.gen r.gen s.gen] - {%clls *} [p.gen q.gen r.gen] - {%clcb *} [q.gen p.gen] - {%clhp *} [p.gen q.gen] - {%clsg *} + [%clkt *] [p.gen q.gen r.gen s.gen] + [%clls *] [p.gen q.gen r.gen] + [%clcb *] [q.gen p.gen] + [%clhp *] [p.gen q.gen] + [%clsg *] |- ^- hoon ?~ p.gen [%rock %n ~] [i.p.gen $(p.gen t.p.gen)] :: - {%cltr *} + [%cltr *] |- ^- hoon ?~ p.gen [%zpzp ~] @@ -8478,43 +8478,43 @@ i.p.gen [i.p.gen $(p.gen t.p.gen)] :: - {%kttr *} [%ktsg ~(example ax fab p.gen)] - {%cncb *} [%ktls [%wing p.gen] %cnts p.gen q.gen] - {%cndt *} [%cncl q.gen [p.gen ~]] - {%cnkt *} [%cncl p.gen q.gen r.gen s.gen ~] - {%cnls *} [%cncl p.gen q.gen r.gen ~] - {%cnhp *} [%cncl p.gen q.gen ~] + [%kttr *] [%ktsg ~(example ax fab p.gen)] + [%cncb *] [%ktls [%wing p.gen] %cnts p.gen q.gen] + [%cndt *] [%cncl q.gen [p.gen ~]] + [%cnkt *] [%cncl p.gen q.gen r.gen s.gen ~] + [%cnls *] [%cncl p.gen q.gen r.gen ~] + [%cnhp *] [%cncl p.gen q.gen ~] :: this probably should work, but doesn't :: - :: {%cncl *} [%cntr [%$ ~] p.gen [[[[%& 6] ~] [%cltr q.gen]] ~]] - {%cncl *} [%cnsg [%$ ~] p.gen q.gen] - {%cnsg *} + :: [%cncl *} [%cntr [%$ ~] p.gen [[[[%& 6] ~] [%cltr q.gen]] ~]] + [%cncl *] [%cnsg [%$ ~] p.gen q.gen] + [%cnsg *] :: this complex matching system is a leftover from the old :: "electroplating" era. %cnsg should be removed and replaced :: with the commented-out %cncl above. but something is broken. :: :^ %cntr p.gen q.gen =+ axe=6 - |- ^- (list {wing hoon}) + |- ^- (list [wing hoon]) ?~ r.gen ~ ?~ t.r.gen [[[[%| 0 ~] [%& axe] ~] i.r.gen] ~] :- [[[%| 0 ~] [%& (peg axe 2)] ~] i.r.gen] $(axe (peg axe 3), r.gen t.r.gen) :: - {%cntr *} + [%cntr *] ?: =(~ r.gen) [%tsgr q.gen [%wing p.gen]] :+ %tsls q.gen :+ %cnts (weld p.gen `wing`[[%& 2] ~]) - (turn r.gen |=({p=wing q=hoon} [p [%tsgr [%$ 3] q]])) + (turn r.gen |=([p=wing q=hoon] [p [%tsgr [%$ 3] q]])) :: - {%ktdt *} [%ktls [%cncl p.gen q.gen ~] q.gen] - {%kthp *} [%ktls ~(example ax fab p.gen) q.gen] - {%ktts *} (grip(gen q.gen) p.gen) + [%ktdt *] [%ktls [%cncl p.gen q.gen ~] q.gen] + [%kthp *] [%ktls ~(example ax fab p.gen) q.gen] + [%ktts *] (grip(gen q.gen) p.gen) :: - {%sgbr *} + [%sgbr *] :+ %sggr :- %mean =+ fek=~(feck ap p.gen) @@ -8522,8 +8522,8 @@ [%brdt [%cncl [%limb %cain] [%zpgr [%tsgr [%$ 3] p.gen]] ~]] q.gen :: - {%sgcb *} [%sggr [%mean [%brdt p.gen]] q.gen] - {%sgcn *} + [%sgcb *] [%sggr [%mean [%brdt p.gen]] q.gen] + [%sgcn *] :+ %sggl :- %fast :- %clls @@ -8537,23 +8537,23 @@ [[[%rock %$ p.i.r.gen] [%zpts q.i.r.gen]] $(r.gen t.r.gen)] s.gen :: - {%sgfs *} [%sgcn p.gen [%$ 7] ~ q.gen] - {%sggl *} [%tsgl [%sggr p.gen [%$ 1]] q.gen] - {%sgbc *} [%sggr [%live [%rock %$ p.gen]] q.gen] - {%sgls *} [%sggr [%memo %rock %$ p.gen] q.gen] - {%sgpm *} + [%sgfs *] [%sgcn p.gen [%$ 7] ~ q.gen] + [%sggl *] [%tsgl [%sggr p.gen [%$ 1]] q.gen] + [%sgbc *] [%sggr [%live [%rock %$ p.gen]] q.gen] + [%sgls *] [%sggr [%memo %rock %$ p.gen] q.gen] + [%sgpm *] :+ %sggr [%slog [%sand %$ p.gen] [%cncl [%limb %cain] [%zpgr q.gen] ~]] r.gen :: - {%sgts *} [%sggr [%germ p.gen] q.gen] - {%sgwt *} + [%sgts *] [%sggr [%germ p.gen] q.gen] + [%sgwt *] :+ %tsls [%wtdt q.gen [%bust %null] [[%bust %null] r.gen]] :^ %wtsg [%& 2]~ [%tsgr [%$ 3] s.gen] [%sgpm p.gen [%$ 5] [%tsgr [%$ 3] s.gen]] :: - {%mcts *} + [%mcts *] |- ?~ p.gen [%bust %null] ?- -.i.p.gen @@ -8576,24 +8576,24 @@ [%cnts sug [[[[%& 3] ~] [%cnts [%$ ~] [[sug [%$ 25]] ~]]] ~]] == :: - {%mccl *} + [%mccl *] ?- q.gen ~ [%zpzp ~] - {* ~} i.q.gen + [* ~] i.q.gen ^ :+ %tsls p.gen =+ yex=`(list hoon)`q.gen |- ^- hoon ?- yex - {* ~} [%tsgr [%$ 3] i.yex] - {* ^} [%cncl [%$ 2] [%tsgr [%$ 3] i.yex] $(yex t.yex) ~] + [* ~] [%tsgr [%$ 3] i.yex] + [* ^] [%cncl [%$ 2] [%tsgr [%$ 3] i.yex] $(yex t.yex) ~] ~ !! == == :: - {%mcfs *} =+(zoy=[%rock %ta %$] [%clsg [zoy [%clsg [zoy p.gen] ~]] ~]) - {%mcgl *} + [%mcfs *] =+(zoy=[%rock %ta %$] [%clsg [zoy [%clsg [zoy p.gen] ~]] ~]) + [%mcgl *] :^ %cnls :+ %cnhp q.gen @@ -8603,7 +8603,7 @@ p.gen s.gen :: - {%mcsg *} :: ;~ + [%mcsg *] :: ;~ |- ^- hoon ?- q.gen ~ ~_(leaf+"open-mcsg" !!) @@ -8628,30 +8628,30 @@ [[[[%| 0 ~] [%& 6] ~] [%limb %c]] ~] :: == :: :: - {%mcmc *} :: ;; + [%mcmc *] :: ;; [%cnhp ~(factory ax fab p.gen) q.gen] :: - {%tsbr *} + [%tsbr *] [%tsls ~(example ax fab p.gen) q.gen] :: - {%tstr *} + [%tstr *] :+ %tsgl r.gen [%tune [[p.p.gen ~ ?~(q.p.gen q.gen [%kthp u.q.p.gen q.gen])] ~ ~] ~] :: - {%tscl *} + [%tscl *] [%tsgr [%cncb [[%& 1] ~] p.gen] q.gen] :: - {%tsfs *} + [%tsfs *] [%tsls [%ktts p.gen q.gen] r.gen] :: - {%tsmc *} [%tsfs p.gen r.gen q.gen] - {%tsdt *} + [%tsmc *] [%tsfs p.gen r.gen q.gen] + [%tsdt *] [%tsgr [%cncb [[%& 1] ~] [[p.gen q.gen] ~]] r.gen] - {%tswt *} :: =? + [%tswt *] :: =? [%tsdt p.gen [%wtcl q.gen r.gen [%wing p.gen]] s.gen] :: - {%tskt *} :: =^ + [%tskt *] :: =^ =+ wuy=(weld q.gen `wing`[%v ~]) :: :+ %tsgr [%ktts %v %$ 1] :: => v=. :+ %tsls [%ktts %a %tsgr [%limb %v] r.gen] :: =+ a==>(v \r.gen) @@ -8661,25 +8661,25 @@ [%limb %v] s.gen :: - {%tsgl *} [%tsgr q.gen p.gen] - {%tsls *} [%tsgr [p.gen [%$ 1]] q.gen] - {%tshp *} [%tsls q.gen p.gen] - {%tssg *} + [%tsgl *] [%tsgr q.gen p.gen] + [%tsls *] [%tsgr [p.gen [%$ 1]] q.gen] + [%tshp *] [%tsls q.gen p.gen] + [%tssg *] |- ^- hoon ?~ p.gen [%$ 1] ?~ t.p.gen i.p.gen [%tsgr i.p.gen $(p.gen t.p.gen)] :: - {%wtbr *} + [%wtbr *] |- ?~(p.gen [%rock %f 1] [%wtcl i.p.gen [%rock %f 0] $(p.gen t.p.gen)]) :: - {%wtdt *} [%wtcl p.gen r.gen q.gen] - {%wtgl *} [%wtcl p.gen [%zpzp ~] q.gen] - {%wtgr *} [%wtcl p.gen q.gen [%zpzp ~]] - {%wtkt *} [%wtcl [%wtts [%base %atom %$] p.gen] r.gen q.gen] + [%wtdt *] [%wtcl p.gen r.gen q.gen] + [%wtgl *] [%wtcl p.gen [%zpzp ~] q.gen] + [%wtgr *] [%wtcl p.gen q.gen [%zpzp ~]] + [%wtkt *] [%wtcl [%wtts [%base %atom %$] p.gen] r.gen q.gen] :: - {%wthp *} + [%wthp *] |- ?~ q.gen [%lost [%wing p.gen]] @@ -8688,14 +8688,14 @@ q.i.q.gen $(q.gen t.q.gen) :: - {%wtls *} + [%wtls *] [%wthp p.gen (weld r.gen `_r.gen`[[[%base %noun] q.gen] ~])] :: - {%wtpm *} + [%wtpm *] |- ?~(p.gen [%rock %f 0] [%wtcl i.p.gen $(p.gen t.p.gen) [%rock %f 1]]) :: - {%xray *} + [%xray *] |^ :- [(open-mane n.g.p.gen) %clsg (turn a.g.p.gen open-mart)] [%mcts c.p.gen] :: @@ -8704,18 +8704,18 @@ ?@(a [%rock %tas a] [[%rock %tas -.a] [%rock %tas +.a]]) :: ++ open-mart - |= {n=mane:hoot v=(list beer:hoot)} + |= [n=mane:hoot v=(list beer:hoot)] [(open-mane n) %knit v] -- :: - {%wtpt *} [%wtcl [%wtts [%base %atom %$] p.gen] q.gen r.gen] - {%wtsg *} [%wtcl [%wtts [%base %null] p.gen] q.gen r.gen] - {%wtts *} [%fits ~(example ax fab p.gen) q.gen] - {%wtzp *} [%wtcl p.gen [%rock %f 1] [%rock %f 0]] - {%zpgr *} + [%wtpt *] [%wtcl [%wtts [%base %atom %$] p.gen] q.gen r.gen] + [%wtsg *] [%wtcl [%wtts [%base %null] p.gen] q.gen r.gen] + [%wtts *] [%fits ~(example ax fab p.gen) q.gen] + [%wtzp *] [%wtcl p.gen [%rock %f 1] [%rock %f 0]] + [%zpgr *] [%cncl [%limb %onan] [%zpmc [%kttr [%bcmc %limb %abel]] p.gen] ~] :: - {%zpwt *} + [%zpwt *] ?: ?: ?=(@ p.gen) (lte hoon-version p.gen) &((lte hoon-version p.p.gen) (gte hoon-version q.p.gen)) @@ -8729,16 +8729,16 @@ ++ reek ^- (unit wing) ?+ gen ~ - {~ *} `[[%& p.gen] ~] - {%limb *} `[p.gen ~] - {%wing *} `p.gen - {%cnts * ~} `p.gen - {%dbug *} reek(gen q.gen) + [~ *] `[[%& p.gen] ~] + [%limb *] `[p.gen ~] + [%wing *] `p.gen + [%cnts * ~] `p.gen + [%dbug *] reek(gen q.gen) == ++ rusk ^- term =+ wig=rake - ?. ?=({@ ~} wig) + ?. ?=([@ ~] wig) ~>(%mean.'rusk-hoon' !!) i.wig -- @@ -8791,8 +8791,8 @@ %toss toss %wrap wrap == - =+ :* fan=*(set {type hoon}) - rib=*(set {type type hoon}) + =+ :* fan=*(set [type hoon]) + rib=*(set [type type hoon]) vet=`?`& fab=`?`& == @@ -9041,8 +9041,8 @@ -- :: ++ bleu - |= {gol=type gen=hoon} - ^- {type nock} + |= [gol=type gen=hoon] + ^- [type nock] =+ pro=(mint gol gen) =+ jon=(apex:musk bran q.pro) ?: |(?=(~ jon) ?=(%wait -.u.jon)) @@ -9053,8 +9053,8 @@ [p.pro %1 p.u.jon] :: ++ blow - |= {gol=type gen=hoon} - ^- {type nock} + |= [gol=type gen=hoon] + ^- [type nock] =+ pro=(mint gol gen) =+ jon=(apex:musk bran q.pro) ?: |(?=(~ jon) ?=(%wait -.u.jon)) @@ -9068,15 +9068,15 @@ ?- sut %noun [full/[~ ~ ~] ~] %void [full/[~ ~ ~] ~] - {%atom *} ?~(q.sut [full/[~ ~ ~] ~] [full/~ u.q.sut]) - {%cell *} (combine:musk $(sut p.sut) $(sut q.sut)) - {%core *} %+ combine:musk + [%atom *] ?~(q.sut [full/[~ ~ ~] ~] [full/~ u.q.sut]) + [%cell *] (combine:musk $(sut p.sut) $(sut q.sut)) + [%core *] %+ combine:musk p.r.q.sut $(sut p.sut) - {%face *} $(sut repo) - {%fork *} [full/[~ ~ ~] ~] - {%hint *} $(sut repo) - {%hold *} ?: (~(has in gil) sut) + [%face *] $(sut repo) + [%fork *] [full/[~ ~ ~] ~] + [%hint *] $(sut repo) + [%hold *] ?: (~(has in gil) sut) [full/[~ ~ ~] ~] $(sut repo, gil (~(put in gil) sut)) == @@ -9112,14 +9112,14 @@ :: ++ buss ~/ %buss - |= {cog=term gen=hoon} + |= [cog=term gen=hoon] ^- type [%face [[[cog ~ gen] ~ ~] ~] sut] :: ++ crop ~/ %crop |= ref=type - =+ bix=*(set {type type}) + =+ bix=*(set [type type]) =< dext |% ++ dext @@ -9132,26 +9132,26 @@ ?: =(%void ref) sut ?- sut - {%atom *} + [%atom *] ?+ ref sint - {%atom *} ?^ q.sut + [%atom *] ?^ q.sut ?^(q.ref ?:(=(q.ref q.sut) %void sut) %void) ?^(q.ref sut %void) - {%cell *} sut + [%cell *] sut == :: - {%cell *} + [%cell *] ?+ ref sint - {%atom *} sut - {%cell *} ?. (nest(sut p.ref) | p.sut) sut + [%atom *] sut + [%cell *] ?. (nest(sut p.ref) | p.sut) sut (cell p.sut dext(sut q.sut, ref q.ref)) == :: - {%core *} ?:(?=(?({%atom *} {%cell *}) ref) sut sint) - {%face *} (face p.sut dext(sut q.sut)) - {%fork *} (fork (turn ~(tap in p.sut) |=(type dext(sut +<)))) - {%hint *} (hint p.sut dext(sut q.sut)) - {%hold *} ?< (~(has in bix) [sut ref]) + [%core *] ?:(?=(?([%atom *] [%cell *]) ref) sut sint) + [%face *] (face p.sut dext(sut q.sut)) + [%fork *] (fork (turn ~(tap in p.sut) |=(type dext(sut +<)))) + [%hint *] (hint p.sut dext(sut q.sut)) + [%hold *] ?< (~(has in bix) [sut ref]) dext(sut repo, bix (~(put in bix) [sut ref])) %noun dext(sut repo) %void %void @@ -9160,19 +9160,19 @@ ++ sint ^- type ?+ ref !! - {%core *} sut - {%face *} dext(ref repo(sut ref)) - {%fork *} =+ yed=~(tap in p.ref) + [%core *] sut + [%face *] dext(ref repo(sut ref)) + [%fork *] =+ yed=~(tap in p.ref) |- ^- type ?~ yed sut $(yed t.yed, sut dext(ref i.yed)) - {%hint *} dext(ref repo(sut ref)) - {%hold *} dext(ref repo(sut ref)) + [%hint *] dext(ref repo(sut ref)) + [%hold *] dext(ref repo(sut ref)) == -- :: ++ cool - |= {pol=? hyp=wing ref=type} + |= [pol=? hyp=wing ref=type] ^- type =+ fid=(find %both hyp) ?- -.fid @@ -9191,7 +9191,7 @@ [[%leaf (mesc (trip paz))] duck ~] :: ++ elbo - |= {lop=palo rig=(list (pair wing hoon))} + |= [lop=palo rig=(list (pair wing hoon))] ^- type ?: ?=(%& -.q.lop) |- ^- type @@ -9216,7 +9216,7 @@ == :: ++ ergo - |= {lop=palo rig=(list (pair wing hoon))} + |= [lop=palo rig=(list (pair wing hoon))] ^- (pair type nock) =+ axe=(tend p.lop) =| hej=(list (pair axis nock)) @@ -9246,7 +9246,7 @@ == :: ++ endo - |= {lop=(pair palo palo) dox=type rig=(list (pair wing hoon))} + |= [lop=(pair palo palo) dox=type rig=(list (pair wing hoon))] ^- (pair type type) ?: ?=(%& -.q.p.lop) ?> ?=(%& -.q.q.lop) @@ -9288,7 +9288,7 @@ |% ++ bath * :: leg match type ++ claw * :: arm match type - ++ form |*({* *} p=+<-) :: attach build state + ++ form |*([* *] p=+<-) :: attach build state ++ skin |*(p=* p) :: reveal build state ++ meat |*(p=* p) :: remove build state -- @@ -9296,9 +9296,9 @@ |% ++ bath type :: leg match type ++ claw onyx :: arm - ++ form |*({* *} [p=+<- q=+<+]) :: - ++ skin |*({p=* q=*} q) :: unwrap baggage - ++ meat |*({p=* q=*} p) :: unwrap filling + ++ form |*([* *] [p=+<- q=+<+]) :: + ++ skin |*([p=* q=*] q) :: unwrap baggage + ++ meat |*([p=* q=*] p) :: unwrap filling -- -- ++ def @@ -9321,13 +9321,13 @@ |% ++ halp ^|(|:($:hoon $:fleg)) ++ vant - |% ++ trep ^|(|:($:{bath wing bath} $:{axis bath})) - ++ tasp ^|(|:($:{{axis bath} fleg foat} $:foat)) + |% ++ trep ^|(|:($:,[bath wing bath] $:,[axis bath])) + ++ tasp ^|(|:($:,[[axis bath] fleg foat] $:foat)) ++ tyle ^|(|:($:foat $:foat)) -- ++ vunt - |% ++ trep ^|(|:($:{claw wing bath} $:{axis claw})) - ++ tasp ^|(|:($:{{axis claw} fleg fult} $:fult)) + |% ++ trep ^|(|:($:,[claw wing bath] $:,[axis claw])) + ++ tasp ^|(|:($:,[[axis claw] fleg fult] $:fult)) ++ tyle ^|(|:($:fult $:foat)) -- -- :: @@ -9338,19 +9338,19 @@ ^- fleg (mint %noun a) ++ vant - |% ++ trep |: $:{a=type b=wing c=type} - ^- {axis type} + |% ++ trep |: $:,[a=type b=wing c=type] + ^- [axis type] (tack(sut a) b c) - ++ tasp |: $:{a=(pair axis type) b=fleg c=foat} + ++ tasp |: $:,[a=(pair axis type) b=fleg c=foat] ^- foat [q.a [[p.a (skin b)] (skin c)]] ++ tyle |:($:foat +<) -- ++ vunt - |% ++ trep |: $:{a=claw b=wing c=bath} + |% ++ trep |: $:,[a=claw b=wing c=bath] ^- (pair axis claw) (toss b c a) - ++ tasp |: $:{a=(pair axis claw) b=fleg c=fult} + ++ tasp |: $:,[a=(pair axis claw) b=fleg c=fult] ^- fult [q.a [[p.a (skin b)] (skin c)]] ++ tyle |: $:fult @@ -9381,7 +9381,7 @@ =+ rame |@ ++ $ => +< - |: $:{rum=clom rig=(list (pair wing hoon))} + |: $:,[rum=clom rig=(list (pair wing hoon))] ^- foat %- tyle |- ^- ceut @@ -9398,16 +9398,16 @@ => inc |% ++ echo - |: $:{rum=bath rig=(list (pair wing hoon))} + |: $:,[rum=bath rig=(list (pair wing hoon))] (ecbo rum rig) :: ++ ecmo - |: $:{hag=claw rig=(list (pair wing hoon))} + |: $:,[hag=claw rig=(list (pair wing hoon))] (eclo hag rig) -- -- :: ++ etco - |= {lop=palo rig=(list (pair wing hoon))} + |= [lop=palo rig=(list (pair wing hoon))] ^- (pair type nock) =+ cin=(oc (bin:ad make:lib:ad)) =. rig (flop rig) :: XX this unbreaks, void order in devulc @@ -9419,7 +9419,7 @@ (ecmo:cin ~(tap in q.q.lop) rig) :: ++ et - |_ {hyp=wing rig=(list (pair wing hoon))} + |_ [hyp=wing rig=(list (pair wing hoon))] :: ++ play ^- type @@ -9436,8 +9436,8 @@ (etco p.lug rig) :: ++ mull - |= {gol=type dox=type} - ^- {type type} + |= [gol=type dox=type] + ^- [type type] =+ lug=[p=(find %read hyp) q=(find(sut dox) %read hyp)] ?: ?=(%| -.p.lug) ?> &(?=(%| -.q.lug) ?=(~ rig)) @@ -9449,19 +9449,19 @@ :: ++ epla ~/ %epla - |= {hyp=wing rig=(list (pair wing hoon))} + |= [hyp=wing rig=(list (pair wing hoon))] ^- type ~(play et hyp rig) :: ++ emin ~/ %emin - |= {gol=type hyp=wing rig=(list (pair wing hoon))} + |= [gol=type hyp=wing rig=(list (pair wing hoon))] ^- (pair type nock) (~(mint et hyp rig) gol) :: ++ emul ~/ %emul - |= {gol=type dox=type hyp=wing rig=(list (pair wing hoon))} + |= [gol=type dox=type hyp=wing rig=(list (pair wing hoon))] ^- (pair type type) (~(mull et hyp rig) gol dox) :: @@ -9490,7 +9490,7 @@ :: ++ fond ~/ %fond - |= {way=vial hyp=wing} + |= [way=vial hyp=wing] => |% ++ pony :: raw match $@ ~ :: void @@ -9534,7 +9534,7 @@ [%| %& (dec p.heg)] ++ lose [%| %& p.heg] ++ stop ?~(q.heg here lose) - ++ twin |= {hax=pony yor=pony} + ++ twin |= [hax=pony yor=pony] ^- pony ~_ leaf+"find-fork" ?: =(hax yor) hax @@ -9564,8 +9564,8 @@ ?- sut %void ~ %noun stop - {%atom *} stop - {%cell *} + [%atom *] stop + [%cell *] ?~ q.heg here =+ taf=$(axe (peg axe 2), sut p.sut) ?~ taf ~ @@ -9573,7 +9573,7 @@ taf $(axe (peg axe 3), p.heg p.p.taf, sut q.sut) :: - {%core *} + [%core *] ?~ q.heg here =^ zem p.heg =+ zem=(loot u.q.heg q.r.q.sut) @@ -9593,10 +9593,10 @@ ?: con.pec $(sut p.sut, axe (peg axe 3)) $(sut (peek(sut p.sut) way 2), axe (peg axe 6)) :: - {%hint *} + [%hint *] $(sut repo) :: - {%face *} + [%face *] ?: ?=(~ q.heg) here(sut q.sut) =* zot p.sut ?@ zot @@ -9624,7 +9624,7 @@ =+ tiv=(mint(sut q.sut) %noun i.q.zot) =+ fid=^$(sut p.tiv, lon ~, axe 1, gil ~) ?~ fid ~ - ?: ?=({%| %& *} fid) + ?: ?=([%| %& *] fid) $(q.zot t.q.zot, p.heg p.p.fid) =/ vat=(pair type nock) ?- -.fid @@ -9634,14 +9634,14 @@ [%| %| p.vat (comb (comb [%0 axe] q.tiv) q.vat)] -- :: - {%fork *} + [%fork *] =+ wiz=(turn ~(tap in p.sut) |=(a=type ^$(sut a))) ?~ wiz ~ |- ^- pony ?~ t.wiz i.wiz (twin i.wiz $(wiz t.wiz)) :: - {%hold *} + [%hold *] ?: (~(has in gil) sut) ~ $(gil (~(put in gil) sut), sut repo) @@ -9651,7 +9651,7 @@ :: ++ find ~/ %find - |= {way=vial hyp=wing} + |= [way=vial hyp=wing] ^- port ~_ (show [%c %find] %l hyp) =- ?@ - !! @@ -9665,7 +9665,7 @@ :: ++ fund ~/ %fund - |= {way=vial gen=hoon} + |= [way=vial gen=hoon] ^- port =+ hup=~(reek ap gen) ?~ hup @@ -9685,15 +9685,15 @@ == == :: ++ fire - |= hag=(list {p=type q=foot}) + |= hag=(list [p=type q=foot]) ^- type - ?: ?=({{* {%wet ~ %1}} ~} hag) + ?: ?=([[* [%wet ~ %1]] ~] hag) p.i.hag %- fork %+ turn hag.$ - |= {p=type q=foot} - ?. ?=({%core *} p) + |= [p=type q=foot] + ?. ?=([%core *] p) ~_ (dunk %fire-type) ~_ leaf+"expected-fork-to-be-core" ~_ (dunk(sut p) %fork-type) @@ -9722,21 +9722,21 @@ ?- sut %void [%1 1] %noun [%1 0] - {%atom *} ?~ q.sut + [%atom *] ?~ q.sut (flip [%3 %0 axe]) [%5 [%1 u.q.sut] [%0 axe]] - {%cell *} + [%cell *] %+ flan [%3 %0 axe] (flan $(sut p.sut, axe (peg axe 2)) $(sut q.sut, axe (peg axe 3))) :: - {%core *} ~>(%mean.'fish-core' !!) - {%face *} $(sut q.sut) - {%fork *} =+ yed=~(tap in p.sut) + [%core *] ~>(%mean.'fish-core' !!) + [%face *] $(sut q.sut) + [%fork *] =+ yed=~(tap in p.sut) |- ^- nock ?~(yed [%1 1] (flor ^$(sut i.yed) $(yed t.yed))) - {%hint *} $(sut q.sut) - {%hold *} + [%hint *] $(sut q.sut) + [%hold *] ?: (~(has in vot) sut) ~>(%mean.'fish-loop' !!) => %=(. vot (~(put in vot) sut)) @@ -9746,14 +9746,14 @@ ++ fuse ~/ %fuse |= ref=type - =+ bix=*(set {type type}) + =+ bix=*(set [type type]) |- ^- type ?: ?|(=(sut ref) =(%noun ref)) sut ?- sut - {%atom *} + [%atom *] ?- ref - {%atom *} =+ foc=?:((fitz p.ref p.sut) p.sut p.ref) + [%atom *] =+ foc=?:((fitz p.ref p.sut) p.sut p.ref) ?^ q.sut ?^ q.ref ?: =(q.sut q.ref) @@ -9761,20 +9761,20 @@ %void [%atom foc q.sut] [%atom foc q.ref] - {%cell *} %void + [%cell *] %void * $(sut ref, ref sut) == - {%cell *} + [%cell *] ?- ref - {%cell *} (cell $(sut p.sut, ref p.ref) $(sut q.sut, ref q.ref)) + [%cell *] (cell $(sut p.sut, ref p.ref) $(sut q.sut, ref q.ref)) * $(sut ref, ref sut) == :: - {%core *} $(sut repo) - {%face *} (face p.sut $(sut q.sut)) - {%fork *} (fork (turn ~(tap in p.sut) |=(type ^$(sut +<)))) - {%hint *} (hint p.sut $(sut q.sut)) - {%hold *} + [%core *] $(sut repo) + [%face *] (face p.sut $(sut q.sut)) + [%fork *] (fork (turn ~(tap in p.sut) |=(type ^$(sut +<)))) + [%hint *] (hint p.sut $(sut q.sut)) + [%hold *] ?: (~(has in bix) [sut ref]) ~>(%mean.'fuse-loop' !!) $(sut repo, bix (~(put in bix) [sut ref])) @@ -9881,10 +9881,10 @@ :: ++ chip ~/ %chip - |= {how=? gen=hoon} ^- type - ?: ?=({%wtts *} gen) + |= [how=? gen=hoon] ^- type + ?: ?=([%wtts *] gen) (cool how q.gen (play ~(example ax fab p.gen))) - ?: ?=({%wthx *} gen) + ?: ?=([%wthx *] gen) =+ (play %wing q.gen) ~> %slog.[0 [%leaf "chipping"]] ?: how @@ -9893,9 +9893,9 @@ - ~(gain ar - p.gen) ~(lose ar - p.gen) - ?: ?&(how ?=({%wtpm *} gen)) + ?: ?&(how ?=([%wtpm *] gen)) |-(?~(p.gen sut $(p.gen t.p.gen, sut ^$(gen i.p.gen)))) - ?: ?&(!how ?=({%wtbr *} gen)) + ?: ?&(!how ?=([%wtbr *] gen)) |-(?~(p.gen sut $(p.gen t.p.gen, sut ^$(gen i.p.gen)))) =+ neg=~(open ap gen) ?:(=(neg gen) sut $(gen neg)) @@ -9913,10 +9913,10 @@ %wet ~ == ?- dab - {* ~ ~} dov - {* ~ *} [dov $(dab r.dab)] - {* * ~} [dov $(dab l.dab)] - {* * *} [dov $(dab l.dab) $(dab r.dab)] + [* ~ ~] dov + [* ~ *] [dov $(dab r.dab)] + [* * ~] [dov $(dab l.dab)] + [* * *] [dov $(dab l.dab) $(dab r.dab)] == :: ++ balk @@ -9926,10 +9926,10 @@ ~ =+ dov=(bake dox hud q.q.n.dom) ?- dom - {* ~ ~} dov - {* ~ *} [dov $(dom r.dom)] - {* * ~} [dov $(dom l.dom)] - {* * *} [dov $(dom l.dom) $(dom r.dom)] + [* ~ ~] dov + [* ~ *] [dov $(dom r.dom)] + [* * ~] [dov $(dom l.dom)] + [* * *] [dov $(dom l.dom) $(dom r.dom)] == :: ++ mile @@ -9966,16 +9966,16 @@ =/ gog (get-arm-type log dag p.n.dab) =+ vad=(hemp hud gog q.n.dab) ?- dab - {* ~ ~} vad - {* ~ *} [vad $(dab r.dab)] - {* * ~} [vad $(dab l.dab)] - {* * *} [vad $(dab l.dab) $(dab r.dab)] + [* ~ ~] vad + [* ~ *] [vad $(dab r.dab)] + [* * ~] [vad $(dab l.dab)] + [* * *] [vad $(dab l.dab) $(dab r.dab)] == ?- dom - {* ~ ~} dov - {* ~ *} [dov $(dom r.dom)] - {* * ~} [dov $(dom l.dom)] - {* * *} [dov $(dom l.dom) $(dom r.dom)] + [* ~ ~] dov + [* ~ *] [dov $(dom r.dom)] + [* * ~] [dov $(dom l.dom)] + [* * *] [dov $(dom l.dom) $(dom r.dom)] == :: :: all the below arms are used for gol checking and should have no @@ -10093,60 +10093,60 @@ :: ++ mint ~/ %mint - |= {gol=type gen=hoon} - ^- {p=type q=nock} + |= [gol=type gen=hoon] + ^- [p=type q=nock] ::~& %pure-mint - |^ ^- {p=type q=nock} - ?: ?&(=(%void sut) !?=({%dbug *} gen)) - ?. |(!vet ?=({%lost *} gen) ?=({%zpzp *} gen)) + |^ ^- [p=type q=nock] + ?: ?&(=(%void sut) !?=([%dbug *] gen)) + ?. |(!vet ?=([%lost *] gen) ?=([%zpzp *] gen)) ~>(%mean.'mint-vain' !!) [%void %0 0] ?- gen :: - {^ *} + [^ *] =+ hed=$(gen p.gen, gol %noun) =+ tal=$(gen q.gen, gol %noun) [(nice (cell p.hed p.tal)) (cons q.hed q.tal)] :: - {%ktcn *} $(fab |, gen p.gen) - {%brcn *} (grow %gold p.gen %dry [%$ 1] q.gen) - {%brpt *} (grow %gold p.gen %wet [%$ 1] q.gen) + [%ktcn *] $(fab |, gen p.gen) + [%brcn *] (grow %gold p.gen %dry [%$ 1] q.gen) + [%brpt *] (grow %gold p.gen %wet [%$ 1] q.gen) :: - {%cnts *} (~(mint et p.gen q.gen) gol) + [%cnts *] (~(mint et p.gen q.gen) gol) :: - {%dtkt *} + [%dtkt *] =+ nef=$(gen [%kttr p.gen]) [p.nef [%12 [%1 %151 p.nef] q:$(gen q.gen, gol %noun)]] :: - {%dtls *} [(nice [%atom %$ ~]) [%4 q:$(gen p.gen, gol [%atom %$ ~])]] - {%sand *} [(nice (play gen)) [%1 q.gen]] - {%rock *} [(nice (play gen)) [%1 q.gen]] + [%dtls *] [(nice [%atom %$ ~]) [%4 q:$(gen p.gen, gol [%atom %$ ~])]] + [%sand *] [(nice (play gen)) [%1 q.gen]] + [%rock *] [(nice (play gen)) [%1 q.gen]] :: - {%dttr *} + [%dttr *] [(nice %noun) [%2 q:$(gen p.gen, gol %noun) q:$(gen q.gen, gol %noun)]] :: - {%dtts *} + [%dtts *] =+ [one two]=[$(gen p.gen, gol %noun) $(gen q.gen, gol %noun)] [(nice bool) [%5 q:$(gen p.gen, gol %noun) q:$(gen q.gen, gol %noun)]] :: - {%dtwt *} [(nice bool) [%3 q:$(gen p.gen, gol %noun)]] - {%hand *} [p.gen q.gen] - {%ktbr *} =+(vat=$(gen p.gen) [(nice (wrap(sut p.vat) %iron)) q.vat]) + [%dtwt *] [(nice bool) [%3 q:$(gen p.gen, gol %noun)]] + [%hand *] [p.gen q.gen] + [%ktbr *] =+(vat=$(gen p.gen) [(nice (wrap(sut p.vat) %iron)) q.vat]) :: - {%ktls *} + [%ktls *] =+(hif=(nice (play p.gen)) [hif q:$(gen q.gen, gol hif)]) :: - {%ktpm *} =+(vat=$(gen p.gen) [(nice (wrap(sut p.vat) %zinc)) q.vat]) - {%ktsg *} (blow gol p.gen) - {%tune *} [(face p.gen sut) [%0 %1]] - {%ktwt *} =+(vat=$(gen p.gen) [(nice (wrap(sut p.vat) %lead)) q.vat]) + [%ktpm *] =+(vat=$(gen p.gen) [(nice (wrap(sut p.vat) %zinc)) q.vat]) + [%ktsg *] (blow gol p.gen) + [%tune *] [(face p.gen sut) [%0 %1]] + [%ktwt *] =+(vat=$(gen p.gen) [(nice (wrap(sut p.vat) %lead)) q.vat]) :: - {%note *} + [%note *] =+ hum=$(gen q.gen) [(hint [sut p.gen] p.hum) q.hum] :: - {%sgzp *} ~_(duck(sut (play p.gen)) $(gen q.gen)) - {%sggr *} + [%sgzp *] ~_(duck(sut (play p.gen)) $(gen q.gen)) + [%sggr *] =+ hum=$(gen q.gen) :: ?: &(huz !?=(%|(@ [?(%sgcn %sgls) ^]) p.gen)) :: hum @@ -10158,15 +10158,15 @@ == q.hum :: - {%tsgr *} + [%tsgr *] =+ fid=$(gen p.gen, gol %noun) =+ dov=$(sut p.fid, gen q.gen) [p.dov (comb q.fid q.dov)] :: - {%tscm *} + [%tscm *] $(gen q.gen, sut (busk p.gen)) :: - {%wtcl *} + [%wtcl *] =+ nor=$(gen p.gen, gol bool) =+ fex=(gain p.gen) =+ wux=(lose p.gen) @@ -10178,14 +10178,14 @@ =+ ran=$(sut wux, gen r.gen) [(fork p.hiq p.ran ~) (cond duy q.hiq q.ran)] :: - {%wthx *} + [%wthx *] :- (nice bool) =+ fid=(find %read [[%& 1] q.gen]) ~> %mean.'mint-fragment' ?> &(?=(%& -.fid) ?=(%& -.q.p.fid)) (~(fish ar `type`p.q.p.fid `skin`p.gen) (tend p.p.fid)) :: - {%fits *} + [%fits *] :- (nice bool) =+ ref=(play p.gen) =+ fid=(find %read q.gen) @@ -10199,24 +10199,24 @@ %| [%7 q.p.fid (fish(sut ref) 1)] == :: - {%dbug *} + [%dbug *] ~_ (show %o p.gen) =+ hum=$(gen q.gen) [p.hum [%11 [%spot %1 p.gen] q.hum]] :: - {%zpcm *} [(nice (play p.gen)) [%1 q.gen]] :: XX validate! - {%lost *} + [%zpcm *] [(nice (play p.gen)) [%1 q.gen]] :: XX validate! + [%lost *] ?: vet ~_ (dunk(sut (play p.gen)) 'lost') ~>(%mean.'mint-lost' !!) [%void [%0 0]] :: - {%zpmc *} + [%zpmc *] =+ vos=$(gol %noun, gen q.gen) =+ ref=p:$(gol %noun, gen p.gen) [(nice (cell ref p.vos)) (cons [%1 burp(sut p.vos)] q.vos)] :: - {%zpgl *} + [%zpgl *] =/ typ (nice (play [%kttr p.gen])) =/ val =< q @@ -10233,10 +10233,10 @@ == [typ val] :: - {%zpts *} [(nice %noun) [%1 q:$(vet |, gen p.gen)]] - {%zppt *} ?:((feel p.gen) $(gen q.gen) $(gen r.gen)) + [%zpts *] [(nice %noun) [%1 q:$(vet |, gen p.gen)]] + [%zppt *] ?:((feel p.gen) $(gen q.gen) $(gen r.gen)) :: - {%zpzp ~} [%void [%0 0]] + [%zpzp ~] [%void [%0 0]] * =+ doz=~(open ap gen) ?: =(doz gen) @@ -10252,8 +10252,8 @@ typ :: ++ grow - |= {mel=vair nym=(unit term) hud=poly ruf=hoon dom=(map term tome)} - ^- {p=type q=nock} + |= [mel=vair nym=(unit term) hud=poly ruf=hoon dom=(map term tome)] + ^- [p=type q=nock] =+ dan=^$(gen ruf, gol %noun) =+ pul=(mine gol mel nym hud dom) [(nice p.pul) (cons q.pul q.dan)] @@ -10263,82 +10263,82 @@ =+ gil=*(set type) |- ^- ? ?- sut - {%atom *} | - {%cell *} |($(sut p.sut) $(sut q.sut)) - {%core *} $(sut p.sut) - {%face *} $(sut q.sut) - {%fork *} (levy ~(tap in p.sut) |=(type ^$(sut +<))) - {%hint *} $(sut q.sut) - {%hold *} |((~(has in gil) sut) $(gil (~(put in gil) sut), sut repo)) + [%atom *] | + [%cell *] |($(sut p.sut) $(sut q.sut)) + [%core *] $(sut p.sut) + [%face *] $(sut q.sut) + [%fork *] (levy ~(tap in p.sut) |=(type ^$(sut +<))) + [%hint *] $(sut q.sut) + [%hold *] |((~(has in gil) sut) $(gil (~(put in gil) sut), sut repo)) %noun | %void & == :: ++ mull ~/ %mull - |= {gol=type dox=type gen=hoon} - |^ ^- {p=type q=type} + |= [gol=type dox=type gen=hoon] + |^ ^- [p=type q=type] ?: =(%void sut) ~>(%mean.'mull-none' !!) ?- gen :: - {^ *} + [^ *] =+ hed=$(gen p.gen, gol %noun) =+ tal=$(gen q.gen, gol %noun) [(nice (cell p.hed p.tal)) (cell q.hed q.tal)] :: - {%ktcn *} $(fab |, gen p.gen) - {%brcn *} (grow %gold p.gen %dry [%$ 1] q.gen) - {%brpt *} (grow %gold p.gen %wet [%$ 1] q.gen) - {%cnts *} (~(mull et p.gen q.gen) gol dox) - {%dtkt *} =+($(gen q.gen, gol %noun) $(gen [%kttr p.gen])) - {%dtls *} =+($(gen p.gen, gol [%atom %$ ~]) (beth [%atom %$ ~])) - {%sand *} (beth (play gen)) - {%rock *} (beth (play gen)) + [%ktcn *] $(fab |, gen p.gen) + [%brcn *] (grow %gold p.gen %dry [%$ 1] q.gen) + [%brpt *] (grow %gold p.gen %wet [%$ 1] q.gen) + [%cnts *] (~(mull et p.gen q.gen) gol dox) + [%dtkt *] =+($(gen q.gen, gol %noun) $(gen [%kttr p.gen])) + [%dtls *] =+($(gen p.gen, gol [%atom %$ ~]) (beth [%atom %$ ~])) + [%sand *] (beth (play gen)) + [%rock *] (beth (play gen)) :: - {%dttr *} + [%dttr *] =+([$(gen p.gen, gol %noun) $(gen q.gen, gol %noun)] (beth %noun)) :: - {%dtts *} + [%dtts *] =+([$(gen p.gen, gol %noun) $(gen q.gen, gol %noun)] (beth bool)) :: - {%dtwt *} =+($(gen p.gen, gol %noun) (beth bool)) :: XX =| - {%hand *} [p.gen p.gen] - {%ktbr *} + [%dtwt *] =+($(gen p.gen, gol %noun) (beth bool)) :: XX =| + [%hand *] [p.gen p.gen] + [%ktbr *] =+(vat=$(gen p.gen) [(wrap(sut p.vat) %iron) (wrap(sut q.vat) %iron)]) :: - {%ktls *} + [%ktls *] =+ hif=[p=(nice (play p.gen)) q=(play(sut dox) p.gen)] =+($(gen q.gen, gol p.hif) hif) :: - {%ktpm *} + [%ktpm *] =+(vat=$(gen p.gen) [(wrap(sut p.vat) %zinc) (wrap(sut q.vat) %zinc)]) :: - {%tune *} + [%tune *] [(face p.gen sut) (face p.gen dox)] :: - {%ktwt *} + [%ktwt *] =+(vat=$(gen p.gen) [(wrap(sut p.vat) %lead) (wrap(sut q.vat) %lead)]) :: - {%note *} + [%note *] =+ vat=$(gen q.gen) [(hint [sut p.gen] p.vat) (hint [dox p.gen] q.vat)] :: - {%ktsg *} $(gen p.gen) - {%sgzp *} ~_(duck(sut (play p.gen)) $(gen q.gen)) - {%sggr *} $(gen q.gen) - {%tsgr *} + [%ktsg *] $(gen p.gen) + [%sgzp *] ~_(duck(sut (play p.gen)) $(gen q.gen)) + [%sggr *] $(gen q.gen) + [%tsgr *] =+ lem=$(gen p.gen, gol %noun) $(gen q.gen, sut p.lem, dox q.lem) :: - {%tscm *} + [%tscm *] =/ boc (busk p.gen) =/ nuf (busk(sut dox) p.gen) $(gen q.gen, sut boc, dox nuf) :: - {%wtcl *} + [%wtcl *] =+ nor=$(gen p.gen, gol bool) - =+ ^= hiq ^- {p=type q=type} + =+ ^= hiq ^- [p=type q=type] =+ fex=[p=(gain p.gen) q=(gain(sut dox) p.gen)] ?: =(%void p.fex) :- %void @@ -10348,7 +10348,7 @@ ?: =(%void q.fex) ~>(%mean.'mull-bonk-b' !!) $(sut p.fex, dox q.fex, gen q.gen) - =+ ^= ran ^- {p=type q=type} + =+ ^= ran ^- [p=type q=type] =+ wux=[p=(lose p.gen) q=(lose(sut dox) p.gen)] ?: =(%void p.wux) :- %void @@ -10360,7 +10360,7 @@ $(sut p.wux, dox q.wux, gen r.gen) [(nice (fork p.hiq p.ran ~)) (fork q.hiq q.ran ~)] :: - {%fits *} + [%fits *] =+ waz=[p=(play p.gen) q=(play(sut dox) p.gen)] =+ ^= syx :- p=(cove q:(mint %noun [%wing q.gen])) q=(cove q:(mint(sut dox) %noun [%wing q.gen])) @@ -10369,7 +10369,7 @@ ~>(%mean.'mull-bonk-a' !!) (beth bool) :: - {%wthx *} + [%wthx *] ~> %mean.'mull-bonk-x' =+ :- =+ (find %read [[%& 1] q.gen]) ?> &(?=(%& -.-) ?=(%& -.q.p.-)) @@ -10381,25 +10381,25 @@ ?> (nest(sut type.old) & type.new) (beth bool) :: - {%dbug *} ~_((show %o p.gen) $(gen q.gen)) - {%zpcm *} [(nice (play p.gen)) (play(sut dox) p.gen)] - {%lost *} + [%dbug *] ~_((show %o p.gen) $(gen q.gen)) + [%zpcm *] [(nice (play p.gen)) (play(sut dox) p.gen)] + [%lost *] ?: vet :: ~_ (dunk(sut (play p.gen)) 'also') ~>(%mean.'mull-skip' !!) (beth %void) :: - {%zpts *} (beth %noun) + [%zpts *] (beth %noun) :: - {%zpmc *} + [%zpmc *] =+ vos=$(gol %noun, gen q.gen) :: XX validate! [(nice (cell (play p.gen) p.vos)) (cell (play(sut dox) p.gen) q.vos)] :: - {%zpgl *} + [%zpgl *] :: XX is this right? (beth (play [%kttr p.gen])) :: - {%zppt *} + [%zppt *] =+ [(feel p.gen) (feel(sut dox) p.gen)] ?. =(-< ->) ~>(%mean.'mull-bonk-f' !!) @@ -10407,7 +10407,7 @@ $(gen q.gen) $(gen r.gen) :: - {%zpzp *} (beth %void) + [%zpzp *] (beth %void) * =+ doz=~(open ap gen) ?: =(doz gen) @@ -10429,10 +10429,10 @@ typ :: ++ grow - |= {mel=vair nym=(unit term) hud=poly ruf=hoon dom=(map term tome)} + |= [mel=vair nym=(unit term) hud=poly ruf=hoon dom=(map term tome)] :: make al ~_ leaf+"mull-grow" - ^- {p=type q=type} + ^- [p=type q=type] =+ dan=^$(gen ruf, gol %noun) =+ yaz=(mile(sut p.dan) q.dan mel nym hud dom) [(nice p.yaz) q.yaz] @@ -10458,14 +10458,14 @@ ?- sut %void & %noun (nest(sut %void) | ref) - {%atom *} sint - {%cell *} sint - {%core *} sint(sut [%cell %noun %noun]) - {%fork *} %+ levy ~(tap in p.sut) + [%atom *] sint + [%cell *] sint + [%core *] sint(sut [%cell %noun %noun]) + [%fork *] %+ levy ~(tap in p.sut) |=(type dext(sut +<)) - {%face *} dext(sut q.sut) - {%hint *} dext(sut q.sut) - {%hold *} =+ (~(gas in *(set type)) `(list type)`[sut ref ~]) + [%face *] dext(sut q.sut) + [%hint *] dext(sut q.sut) + [%hold *] =+ (~(gas in *(set type)) `(list type)`[sut ref ~]) ?: (~(has in gil) -) & %= dext @@ -10474,12 +10474,12 @@ == == ++ sint ?+ ref dext(sut ref, ref sut) - {%atom *} ?. ?=({%atom *} sut) & + [%atom *] ?. ?=([%atom *] sut) & ?& ?=(^ q.ref) ?=(^ q.sut) !=(q.ref q.sut) == - {%cell *} ?. ?=({%cell *} sut) & + [%cell *] ?. ?=([%cell *] sut) & ?| dext(sut p.sut, ref p.ref) dext(sut q.sut, ref q.ref) == == @@ -10487,16 +10487,16 @@ ++ mite |=(ref=type |((nest | ref) (nest(sut ref) & sut))) ++ nest ~/ %nest - |= {tel=? ref=type} + |= [tel=? ref=type] =| $: seg=(set type) :: degenerate sut reg=(set type) :: degenerate ref - gil=(set {p=type q=type}) :: assume nest + gil=(set [p=type q=type]) :: assume nest == =< dext ~% %nest-in ..$ ~ |% ++ deem - |= {mel=vair ram=vair} + |= [mel=vair ram=vair] ^- ? ?. |(=(mel ram) =(%lead mel) =(%gold ram)) | ?- mel @@ -10544,15 +10544,15 @@ ?- sut %void sint %noun & - {%atom *} ?. ?=({%atom *} ref) sint + [%atom *] ?. ?=([%atom *] ref) sint ?& (fitz p.sut p.ref) |(?=(~ q.sut) =(q.sut q.ref)) == - {%cell *} ?. ?=({%cell *} ref) sint + [%cell *] ?. ?=([%cell *] ref) sint ?& dext(sut p.sut, ref p.ref, seg ~, reg ~) dext(sut q.sut, ref q.ref, seg ~, reg ~) == - {%core *} ?. ?=({%core *} ref) sint + [%core *] ?. ?=([%core *] ref) sint ?: =(q.sut q.ref) dext(sut p.sut, ref p.ref) ?& =(q.p.q.sut q.p.q.ref) :: same wet/dry meet(sut q.q.sut, ref p.sut) @@ -10567,11 +10567,11 @@ ref ref(p q.q.ref, r.p.q %gold) == == == - {%face *} dext(sut q.sut) - {%fork *} ?. ?=(?({%atom *} %noun {%cell *} {%core *}) ref) sint + [%face *] dext(sut q.sut) + [%fork *] ?. ?=(?([%atom *] %noun [%cell *] [%core *]) ref) sint (lien ~(tap in p.sut) |=(type dext(tel |, sut +<))) - {%hint *} dext(sut q.sut) - {%hold *} ?: (~(has in seg) sut) | + [%hint *] dext(sut q.sut) + [%hold *] ?: (~(has in seg) sut) | ?: (~(has in gil) [sut ref]) & %= dext sut repo @@ -10585,13 +10585,13 @@ ?- ref %noun | %void & - {%atom *} | - {%cell *} | - {%core *} dext(ref repo(sut ref)) - {%face *} dext(ref q.ref) - {%fork *} (levy ~(tap in p.ref) |=(type dext(ref +<))) - {%hint *} dext(ref q.ref) - {%hold *} ?: (~(has in reg) ref) & + [%atom *] | + [%cell *] | + [%core *] dext(ref repo(sut ref)) + [%face *] dext(ref q.ref) + [%fork *] (levy ~(tap in p.ref) |=(type dext(ref +<))) + [%hint *] dext(ref q.ref) + [%hold *] ?: (~(has in reg) ref) & ?: (~(has in gil) [sut ref]) & %= dext ref repo(sut ref) @@ -10602,7 +10602,7 @@ :: ++ peek ~/ %peek - |= {way=?(%read %rite %both %free) axe=axis} + |= [way=?(%read %rite %both %free) axe=axis] ^- type ?: =(1 axe) sut @@ -10610,9 +10610,9 @@ =+ gil=*(set type) |- ^- type ?- sut - {%atom *} %void - {%cell *} ?:(=(2 now) ^$(sut p.sut, axe lat) ^$(sut q.sut, axe lat)) - {%core *} + [%atom *] %void + [%cell *] ?:(=(2 now) ^$(sut p.sut, axe lat) ^$(sut q.sut, axe lat)) + [%core *] ?. =(3 now) %noun =+ pec=(peel way r.p.q.sut) =/ tow @@ -10633,8 +10633,8 @@ ?.(con.pec %noun ^$(sut p.sut, axe 3)) == :: - {%fork *} (fork (turn ~(tap in p.sut) |=(type ^$(sut +<)))) - {%hold *} + [%fork *] (fork (turn ~(tap in p.sut) |=(type ^$(sut +<)))) + [%hold *] ?: (~(has in gil) sut) %void $(gil (~(put in gil) sut), sut repo) @@ -10645,8 +10645,8 @@ == :: ++ peel - |= {way=vial met=?(%gold %iron %lead %zinc)} - ^- {sam=? con=?} + |= [way=vial met=?(%gold %iron %lead %zinc)] + ^- [sam=? con=?] ?: ?=(%gold met) [& &] ?- way %both [| |] @@ -10661,51 +10661,51 @@ |= gen=hoon ^- type ?- gen - {^ *} (cell $(gen p.gen) $(gen q.gen)) - {%ktcn *} $(fab |, gen p.gen) - {%brcn *} (core sut [p.gen %dry %gold] sut *seminoun q.gen) - {%brpt *} (core sut [p.gen %wet %gold] sut *seminoun q.gen) - {%cnts *} ~(play et p.gen q.gen) - {%dtkt *} $(gen [%kttr p.gen]) - {%dtls *} [%atom %$ ~] - {%rock *} |- ^- type + [^ *] (cell $(gen p.gen) $(gen q.gen)) + [%ktcn *] $(fab |, gen p.gen) + [%brcn *] (core sut [p.gen %dry %gold] sut *seminoun q.gen) + [%brpt *] (core sut [p.gen %wet %gold] sut *seminoun q.gen) + [%cnts *] ~(play et p.gen q.gen) + [%dtkt *] $(gen [%kttr p.gen]) + [%dtls *] [%atom %$ ~] + [%rock *] |- ^- type ?@ q.gen [%atom p.gen `q.gen] [%cell $(q.gen -.q.gen) $(q.gen +.q.gen)] - {%sand *} ?@ q.gen + [%sand *] ?@ q.gen ?: =(%n p.gen) ?>(=(0 q.gen) [%atom p.gen `q.gen]) ?: =(%f p.gen) ?>((lte q.gen 1) bool) [%atom p.gen ~] $(-.gen %rock) - {%tune *} (face p.gen sut) - {%dttr *} %noun - {%dtts *} bool - {%dtwt *} bool - {%hand *} p.gen - {%ktbr *} (wrap(sut $(gen p.gen)) %iron) - {%ktls *} $(gen p.gen) - {%ktpm *} (wrap(sut $(gen p.gen)) %zinc) - {%ktsg *} $(gen p.gen) - {%ktwt *} (wrap(sut $(gen p.gen)) %lead) - {%note *} (hint [sut p.gen] $(gen q.gen)) - {%sgzp *} ~_(duck(sut ^$(gen p.gen)) $(gen q.gen)) - {%sggr *} $(gen q.gen) - {%tsgr *} $(gen q.gen, sut $(gen p.gen)) - {%tscm *} $(gen q.gen, sut (busk p.gen)) - {%wtcl *} =+ [fex=(gain p.gen) wux=(lose p.gen)] + [%tune *] (face p.gen sut) + [%dttr *] %noun + [%dtts *] bool + [%dtwt *] bool + [%hand *] p.gen + [%ktbr *] (wrap(sut $(gen p.gen)) %iron) + [%ktls *] $(gen p.gen) + [%ktpm *] (wrap(sut $(gen p.gen)) %zinc) + [%ktsg *] $(gen p.gen) + [%ktwt *] (wrap(sut $(gen p.gen)) %lead) + [%note *] (hint [sut p.gen] $(gen q.gen)) + [%sgzp *] ~_(duck(sut ^$(gen p.gen)) $(gen q.gen)) + [%sggr *] $(gen q.gen) + [%tsgr *] $(gen q.gen, sut $(gen p.gen)) + [%tscm *] $(gen q.gen, sut (busk p.gen)) + [%wtcl *] =+ [fex=(gain p.gen) wux=(lose p.gen)] %- fork :~ ?:(=(%void fex) %void $(sut fex, gen q.gen)) ?:(=(%void wux) %void $(sut wux, gen r.gen)) == - {%fits *} bool - {%wthx *} bool - {%dbug *} ~_((show %o p.gen) $(gen q.gen)) - {%zpcm *} $(gen p.gen) - {%lost *} %void - {%zpmc *} (cell $(gen p.gen) $(gen q.gen)) - {%zpgl *} (play [%kttr p.gen]) - {%zpts *} %noun - {%zppt *} ?:((feel p.gen) $(gen q.gen) $(gen r.gen)) - {%zpzp *} %void + [%fits *] bool + [%wthx *] bool + [%dbug *] ~_((show %o p.gen) $(gen q.gen)) + [%zpcm *] $(gen p.gen) + [%lost *] %void + [%zpmc *] (cell $(gen p.gen) $(gen q.gen)) + [%zpgl *] (play [%kttr p.gen]) + [%zpts *] %noun + [%zppt *] ?:((feel p.gen) $(gen q.gen) $(gen r.gen)) + [%zpzp *] %void * =+ doz=~(open ap gen) ?: =(doz gen) ~_ (show [%c 'hoon'] [%q gen]) @@ -10746,7 +10746,7 @@ ?~ wec `~ :: any reference faces must be clear :: - ?. ?=({* ~ ~} wec) + ?. ?=([* ~ ~] wec) ~& [%dear-many wec] ~ :- ~ @@ -10794,22 +10794,22 @@ :: check for trivial cases :: ?: ?| =(sut ref) - ?=(?(%noun %void {?(%atom %core) *}) ref) + ?=(?(%noun %void [?(%atom %core) *]) ref) == done :: ~_ (dunk 'redo: dext: sut') :: ~_ (dunk(sut ref) 'redo: dext: ref') ?- sut - ?(%noun %void {?(%atom %core) *}) + ?(%noun %void [?(%atom %core) *]) :: reduce reference and reassemble leaf :: done:(sint &) :: - {%cell *} + [%cell *] :: reduce reference to match subject :: => (sint &) - ?> ?=({%cell *} sut) + ?> ?=([%cell *] sut) :: leaf with possible recursive descent :: %= done @@ -10826,26 +10826,26 @@ dext(sut q.sut, ref (peek(sut ref) %free 3)) == :: - {%face *} + [%face *] :: push face on subject stack, and descend :: dext(hos [p.sut hos], sut q.sut) :: - {%hint *} + [%hint *] :: work through hint :: (hint p.sut dext(sut q.sut)) :: - {%fork *} + [%fork *] :: reconstruct each case in fork :: (fork (turn ~(tap in p.sut) |=(type dext(sut +<)))) :: - {%hold *} + [%hold *] :: reduce to hard :: => (sint |) - ?> ?=({%hold *} sut) + ?> ?=([%hold *] sut) ?: (~(has in fan) [p.sut q.sut]) :: repo loop; redo depends on its own product :: @@ -10894,8 +10894,8 @@ :: ~> %slog.[0 (dunk(sut =>(- ref)) 'sint: pro')] :: - ?+ ref . - {%hint *} $(ref q.ref) - {%face *} + [%hint *] $(ref q.ref) + [%face *] :: extend all stacks in set :: %= $ @@ -10903,7 +10903,7 @@ wec (~(run in wec) |=((list tool) [p.ref +<])) == :: - {%fork *} + [%fork *] :: reconstruct all relevant cases :: =- :: ~> %slog.[0 (dunk 'fork: sut')] @@ -10924,7 +10924,7 @@ =/ dis ^$(ref i.moy) [(~(uni in p.mor) wec.dis) [ref.dis q.mor]] :: - {%hold *} + [%hold *] ?. hod . $(ref repo(sut ref)) == @@ -10933,28 +10933,28 @@ ++ repo ^- type ?- sut - {%core *} [%cell %noun p.sut] - {%face *} q.sut - {%hint *} q.sut - {%hold *} (rest [[p.sut q.sut] ~]) + [%core *] [%cell %noun p.sut] + [%face *] q.sut + [%hint *] q.sut + [%hold *] (rest [[p.sut q.sut] ~]) %noun (fork [%atom %$ ~] [%cell %noun %noun] ~) * ~>(%mean.'repo-fltt' !!) == :: ++ rest ~/ %rest - |= leg=(list {p=type q=hoon}) + |= leg=(list [p=type q=hoon]) ^- type - ?: (lien leg |=({p=type q=hoon} (~(has in fan) [p q]))) + ?: (lien leg |=([p=type q=hoon] (~(has in fan) [p q]))) ~>(%mean.'rest-loop' !!) => .(fan (~(gas in fan) leg)) %- fork %~ tap in %- ~(gas in *(set type)) - (turn leg |=({p=type q=hoon} (play(sut p) q))) + (turn leg |=([p=type q=hoon] (play(sut p) q))) :: ++ take - |= {vit=vein duz=$-(type type)} + |= [vit=vein duz=$-(type type)] ^- (pair axis type) :- (tend vit) =. vit (flop vit) @@ -10963,10 +10963,10 @@ ?~ i.vit |- ^- type ?+ sut ^$(vit t.vit) - {%face *} (face p.sut ^$(vit t.vit, sut q.sut)) - {%hint *} (hint p.sut ^$(sut q.sut)) - {%fork *} (fork (turn ~(tap in p.sut) |=(type ^$(sut +<)))) - {%hold *} $(sut repo) + [%face *] (face p.sut ^$(vit t.vit, sut q.sut)) + [%hint *] (hint p.sut ^$(sut q.sut)) + [%fork *] (fork (turn ~(tap in p.sut) |=(type ^$(sut +<)))) + [%hold *] $(sut repo) == =+ vil=*(set type) |- ^- type @@ -10976,23 +10976,23 @@ ?- sut %noun $(sut [%cell %noun %noun]) %void %void - {%atom *} %void - {%cell *} ?: =(2 now) + [%atom *] %void + [%cell *] ?: =(2 now) (cell $(sut p.sut, u.i.vit lat) q.sut) (cell p.sut $(sut q.sut, u.i.vit lat)) - {%core *} ?: =(2 now) + [%core *] ?: =(2 now) $(sut repo) (core $(sut p.sut, u.i.vit lat) q.sut) - {%face *} (face p.sut $(sut q.sut)) - {%fork *} (fork (turn ~(tap in p.sut) |=(type ^$(sut +<)))) - {%hint *} (hint p.sut $(sut q.sut)) - {%hold *} ?: (~(has in vil) sut) + [%face *] (face p.sut $(sut q.sut)) + [%fork *] (fork (turn ~(tap in p.sut) |=(type ^$(sut +<)))) + [%hint *] (hint p.sut $(sut q.sut)) + [%hold *] ?: (~(has in vil) sut) %void $(sut repo, vil (~(put in vil) sut)) == :: ++ tack - |= {hyp=wing mur=type} + |= [hyp=wing mur=type] ~_ (show [%c %tack] %l hyp) =+ fid=(find %rite hyp) ?> ?=(%& -.fid) @@ -11005,11 +11005,11 @@ :: ++ toss ~/ %toss - |= {hyp=wing mur=type men=(list {p=type q=foot})} - ^- {p=axis q=(list {p=type q=foot})} + |= [hyp=wing mur=type men=(list [p=type q=foot])] + ^- [p=axis q=(list [p=type q=foot])] =- [(need p.wib) q.wib] ^= wib - |- ^- {p=(unit axis) q=(list {p=type q=foot})} + |- ^- [p=(unit axis) q=(list [p=type q=foot])] ?~ men [*(unit axis) ~] =+ geq=(tack(sut p.i.men) hyp mur) @@ -11022,18 +11022,18 @@ ~_ leaf+"wrap" ^- type ?+ sut sut - {%cell *} (cell $(sut p.sut) $(sut q.sut)) - {%core *} ?>(|(=(%gold r.p.q.sut) =(%lead yoz)) sut(r.p.q yoz)) - {%face *} (face p.sut $(sut q.sut)) - {%fork *} (fork (turn ~(tap in p.sut) |=(type ^$(sut +<)))) - {%hint *} (hint p.sut $(sut q.sut)) - {%hold *} $(sut repo) + [%cell *] (cell $(sut p.sut) $(sut q.sut)) + [%core *] ?>(|(=(%gold r.p.q.sut) =(%lead yoz)) sut(r.p.q yoz)) + [%face *] (face p.sut $(sut q.sut)) + [%fork *] (fork (turn ~(tap in p.sut) |=(type ^$(sut +<)))) + [%hint *] (hint p.sut $(sut q.sut)) + [%hold *] $(sut repo) == -- ++ us :: prettyprinter => |% - ++ cape {p=(map @ud wine) q=wine} :: - ++ wine :: + +$ cape [p=(map @ud wine) q=wine] :: + +$ wine :: $@ $? %noun :: %path :: %type :: @@ -11042,21 +11042,21 @@ %wool :: %yarn :: == :: - $% {%mato p=term} :: - {%core p=(list @ta) q=wine} :: - {%face p=term q=wine} :: - {%list p=term q=wine} :: - {%pear p=term q=@} :: - {%bcwt p=(list wine)} :: - {%plot p=(list wine)} :: - {%stop p=@ud} :: - {%tree p=term q=wine} :: - {%unit p=term q=wine} :: + $% [%mato p=term] :: + [%core p=(list @ta) q=wine] :: + [%face p=term q=wine] :: + [%list p=term q=wine] :: + [%pear p=term q=@] :: + [%bcwt p=(list wine)] :: + [%plot p=(list wine)] :: + [%stop p=@ud] :: + [%tree p=term q=wine] :: + [%unit p=term q=wine] :: == :: -- |_ sut=type ++ dash - |= {mil=tape lim=char lam=tape} + |= [mil=tape lim=char lam=tape] ^- tape =/ esc (~(gas in *(set @tD)) lam) :- lim @@ -11079,14 +11079,14 @@ |% ++ many |= haz=(list wine) - ^- {(list tank) (set @ud)} + ^- [(list tank) (set @ud)] ?~ haz [~ gid] =^ mor gid $(haz t.haz) =^ dis gid ^$(q.ham i.haz) [[dis mor] gid] :: ++ $ - ^- {tank (set @ud)} + ^- [tank (set @ud)] ?- q.ham %noun :_(gid [%leaf '*' ~]) %path :_(gid [%leaf '/' ~]) @@ -11095,8 +11095,8 @@ %wool :_(gid [%leaf '*' '"' '"' ~]) %wall :_(gid [%leaf '*' '\'' '\'' ~]) %yarn :_(gid [%leaf '"' '"' ~]) - {%mato *} :_(gid [%leaf '@' (trip p.q.ham)]) - {%core *} + [%mato *] :_(gid [%leaf '@' (trip p.q.ham)]) + [%core *] =^ cox gid $(q.ham q.q.ham) :_ gid :+ %rose @@ -11105,26 +11105,26 @@ ?~ p.q.ham [cox ~] [[%leaf (rip 3 i.p.q.ham)] $(p.q.ham t.p.q.ham)] :: - {%face *} + [%face *] =^ cox gid $(q.ham q.q.ham) :_(gid [%palm [['=' ~] ~ ~ ~] [%leaf (trip p.q.ham)] cox ~]) :: - {%list *} + [%list *] =^ cox gid $(q.ham q.q.ham) :_(gid [%rose [" " (weld (trip p.q.ham) "(") ")"] cox ~]) :: - {%bcwt *} + [%bcwt *] =^ coz gid (many p.q.ham) :_(gid [%rose [[' ' ~] ['?' '(' ~] [')' ~]] coz]) :: - {%plot *} + [%plot *] =^ coz gid (many p.q.ham) :_(gid [%rose [[' ' ~] ['[' ~] [']' ~]] coz]) :: - {%pear *} + [%pear *] :_(gid [%leaf '%' ~(rend co [%$ p.q.ham q.q.ham])]) :: - {%stop *} + [%stop *] =+ num=~(rend co [%$ %ud p.q.ham]) ?: (~(has in gid) p.q.ham) :_(gid [%leaf '#' num]) @@ -11135,23 +11135,23 @@ == :_(gid [%palm [['.' ~] ~ ~ ~] [%leaf ['^' '#' num]] cox ~]) :: - {%tree *} + [%tree *] =^ cox gid $(q.ham q.q.ham) :_(gid [%rose [" " (weld (trip p.q.ham) "(") ")"] cox ~]) :: - {%unit *} + [%unit *] =^ cox gid $(q.ham q.q.ham) :_(gid [%rose [" " (weld (trip p.q.ham) "(") ")"] cox ~]) == -- :: ++ dish !: - |= {ham=cape lum=*} ^- tank + |= [ham=cape lum=*] ^- tank ~| [%dish-h ?@(q.ham q.ham -.q.ham)] ~| [%lump lum] ~| [%ham ham] %- need - =| gil=(set {@ud *}) + =| gil=(set [@ud *]) |- ^- (unit tank) ?- q.ham %noun @@ -11206,7 +11206,7 @@ %void ~ :: - {%mato *} + [%mato *] ?. ?=(@ lum) ~ :+ ~ @@ -11218,7 +11218,7 @@ %tas ['%' ?.(=(0 lum) (rip 3 lum) ['$' ~])] == :: - {%core *} + [%core *] :: XX needs rethinking for core metal :: ?. ?=(^ lum) ~ :: => .(lum `*`lum) @@ -11232,13 +11232,13 @@ :: ?~(mur ~ [~ [[%leaf (rip 3 i.p.q.ham)] u.mur]]) [~ (dial ham)] :: - {%face *} + [%face *] =+ wal=$(q.ham q.q.ham) ?~ wal ~ [~ %palm [['=' ~] ~ ~ ~] [%leaf (trip p.q.ham)] u.wal ~] :: - {%list *} + [%list *] ?: =(~ lum) [~ %leaf '~' ~] =- ?~ tok @@ -11253,7 +11253,7 @@ ~ [~ u.for u.aft] :: - {%bcwt *} + [%bcwt *] |- ^- (unit tank) ?~ p.q.ham ~ @@ -11262,7 +11262,7 @@ $(p.q.ham t.p.q.ham) wal :: - {%plot *} + [%plot *] =- ?~ tok ~ [~ %rose [[' ' ~] ['[' ~] [']' ~]] u.tok] @@ -11270,7 +11270,7 @@ |- ^- (unit (list tank)) ?~ p.q.ham ~ - ?: ?=({* ~} p.q.ham) + ?: ?=([* ~] p.q.ham) =+ wal=^$(q.ham i.p.q.ham) ?~(wal ~ [~ [u.wal ~]]) ?@ lum @@ -11283,25 +11283,25 @@ ~ [~ u.gim u.myd] :: - {%pear *} + [%pear *] ?. =(lum q.q.ham) ~ =. p.q.ham (rash p.q.ham ;~(sfix (cook crip (star low)) (star hig))) =+ fox=$(q.ham [%mato p.q.ham]) - ?> ?=({~ %leaf ^} fox) + ?> ?=([~ %leaf ^] fox) ?: ?=(?(%n %tas) p.q.ham) fox [~ %leaf '%' p.u.fox] :: - {%stop *} + [%stop *] ?: (~(has in gil) [p.q.ham lum]) ~ =+ kep=(~(get by p.ham) p.q.ham) ?~ kep ~|([%stop-loss p.q.ham] !!) $(gil (~(put in gil) [p.q.ham lum]), q.ham u.kep) :: - {%tree *} + [%tree *] =- ?~ tok ~ [~ %rose [[' ' ~] ['{' ~] ['}' ~]] u.tok] @@ -11310,7 +11310,7 @@ |- ^- (unit (list tank)) ?: =(~ lum) [~ tuk] - ?. ?=({n=* l=* r=*} lum) + ?. ?=([n=* l=* r=*] lum) ~ =+ rol=$(lum r.lum) ?~ rol @@ -11320,7 +11320,7 @@ ~ $(lum l.lum, tuk [u.tim u.rol]) :: - {%unit *} + [%unit *] ?@ lum ?.(=(~ lum) ~ [~ %leaf '~' ~]) ?. =(~ -.lum) @@ -11334,15 +11334,15 @@ ++ doge |= ham=cape =- ?+ woz woz - {%list * {%mato %'ta'}} %path - {%list * {%mato %'t'}} %wall - {%list * {%mato %'tD'}} %yarn - {%list * %yarn} %wool + [%list * [%mato %'ta']] %path + [%list * [%mato %'t']] %wall + [%list * [%mato %'tD']] %yarn + [%list * %yarn] %wool == ^= woz ^- wine - ?. ?=({%stop *} q.ham) - ?: ?& ?= {%bcwt {%pear %n %0} {%plot {%pear %n %0} {%face *} ~} ~} + ?. ?=([%stop *] q.ham) + ?: ?& ?= [%bcwt [%pear %n %0] [%plot [%pear %n %0] [%face *] ~] ~] q.ham =(1 (met 3 p.i.t.p.i.t.p.q.ham)) == @@ -11352,13 +11352,13 @@ ?~ may q.ham =+ nul=[%pear %n 0] - ?. ?& ?=({%bcwt *} u.may) - ?=({* * ~} p.u.may) + ?. ?& ?=([%bcwt *] u.may) + ?=([* * ~] p.u.may) |(=(nul i.p.u.may) =(nul i.t.p.u.may)) == q.ham =+ din=?:(=(nul i.p.u.may) i.t.p.u.may i.p.u.may) - ?: ?& ?=({%plot {%face *} {%face * %stop *} ~} din) + ?: ?& ?=([%plot [%face *] [%face * %stop *] ~] din) =(p.q.ham p.q.i.t.p.din) =(1 (met 3 p.i.p.din)) =(1 (met 3 p.i.t.p.din)) @@ -11367,9 +11367,9 @@ (cat 3 p.i.p.din p.i.t.p.din) q.i.p.din ?: ?& ?= $: %plot - {%face *} - {%face * %stop *} - {{%face * %stop *} ~} + [%face *] + [%face * %stop *] + [[%face * %stop *] ~] == din =(p.q.ham p.q.i.t.p.din) @@ -11391,28 +11391,28 @@ =+ gil=*(set type) =+ dex=[p=*(map type @) q=*(map @ wine)] =< [q.p q] - |- ^- {p={p=(map type @) q=(map @ wine)} q=wine} + |- ^- [p=[p=(map type @) q=(map @ wine)] q=wine] =- [p.tez (doge q.p.tez q.tez)] ^= tez - ^- {p={p=(map type @) q=(map @ wine)} q=wine} + ^- [p=[p=(map type @) q=(map @ wine)] q=wine] ?: (~(meet ut sut) -:!>(*type)) [dex %type] ?- sut %noun [dex sut] %void [dex sut] - {%atom *} [dex ?~(q.sut [%mato p.sut] [%pear p.sut u.q.sut])] - {%cell *} + [%atom *] [dex ?~(q.sut [%mato p.sut] [%pear p.sut u.q.sut])] + [%cell *] =+ hin=$(sut p.sut) =+ yon=$(dex p.hin, sut q.sut) :- p.yon :- %plot - ?:(?=({%plot *} q.yon) [q.hin p.q.yon] [q.hin q.yon ~]) + ?:(?=([%plot *] q.yon) [q.hin p.q.yon] [q.hin q.yon ~]) :: - {%core *} + [%core *] =+ yad=$(sut p.sut) :- p.yad - =+ ^= doy ^- {p=(list @ta) q=wine} - ?: ?=({%core *} q.yad) + =+ ^= doy ^- [p=(list @ta) q=wine] + ?: ?=([%core *] q.yad) [p.q.yad q.q.yad] [~ q.yad] :- %core @@ -11432,24 +11432,24 @@ [1 (add 'a' (mod (div gum 676) 26))] == :: - {%hint *} + [%hint *] $(sut q.sut) :: - {%face *} + [%face *] =+ yad=$(sut q.sut) ?^(p.sut yad [p.yad [%face p.sut q.yad]]) :: - {%fork *} + [%fork *] =+ yed=(sort ~(tap in p.sut) aor) =- [p [%bcwt q]] - |- ^- {p={p=(map type @) q=(map @ wine)} q=(list wine)} + |- ^- [p=[p=(map type @) q=(map @ wine)] q=(list wine)] ?~ yed [dex ~] =+ mor=$(yed t.yed) =+ dis=^$(dex p.mor, sut i.yed) [p.dis q.dis q.mor] :: - {%hold *} + [%hold *] =+ hey=(~(get by p.dex) sut) ?^ hey [dex [%stop u.hey]] @@ -11496,7 +11496,7 @@ ~(duck ut typ) :: ++ slam :: slam a gate - |= {gat=vase sam=vase} ^- vase + |= [gat=vase sam=vase] ^- vase =+ :- ^= typ ^- type [%cell p.gat p.sam] ^= gen ^- hoon @@ -11517,7 +11517,7 @@ (~(fond ut typ) way ~[cog]) :: ++ slap - |= {vax=vase gen=hoon} ^- vase :: untyped vase .* + |= [vax=vase gen=hoon] ^- vase :: untyped vase .* =+ gun=(~(mint ut p.vax) %noun gen) [p.gun .*(q.vax q.gun)] :: @@ -11542,7 +11542,7 @@ == :: ++ slew :: get axis in vase - |= {axe=@ vax=vase} ^- (unit vase) + |= [axe=@ vax=vase] ^- (unit vase) ?. |- ^- ? ?: =(1 axe) & ?. ?=(^ q.vax) | @@ -11555,17 +11555,17 @@ old :: ++ slit :: type of slam - |= {gat=type sam=type} + |= [gat=type sam=type] ?> (~(nest ut (~(peek ut gat) %free 6)) & sam) (~(play ut [%cell gat sam]) [%cnsg [%$ ~] [%$ 2] [%$ 3] ~]) :: ++ slob :: superficial arm - |= {cog=@tas typ=type} + |= [cog=@tas typ=type] ^- ? ?+ typ | - {%hold *} $(typ ~(repo ut typ)) - {%hint *} $(typ ~(repo ut typ)) - {%core *} + [%hold *] $(typ ~(repo ut typ)) + [%hint *] $(typ ~(repo ut typ)) + [%core *] |- ^- ? ?~ q.r.q.typ | ?| (~(has by q.q.n.q.r.q.typ) cog) @@ -11578,28 +11578,28 @@ |= typ=type ^- (list term) ?+ typ ~ - {%hold *} $(typ ~(repo ut typ)) - {%hint *} $(typ ~(repo ut typ)) - {%core *} + [%hold *] $(typ ~(repo ut typ)) + [%hint *] $(typ ~(repo ut typ)) + [%core *] %- zing %+ turn ~(tap by q.r.q.typ) - |= {* b=tome} + |= [* b=tome] %+ turn ~(tap by q.b) - |= {a=term *} + |= [a=term *] a == :: ++ slop :: cons two vases - |= {hed=vase tal=vase} + |= [hed=vase tal=vase] ^- vase [[%cell p.hed p.tal] [q.hed q.tal]] :: ++ slot :: got axis in vase - |= {axe=@ vax=vase} ^- vase + |= [axe=@ vax=vase] ^- vase [(~(peek ut p.vax) %free axe) .*(q.vax [0 axe])] :: ++ slym :: slam w+o sample-type - |= {gat=vase sam=*} ^- vase + |= [gat=vase sam=*] ^- vase (slap gat(+<.q sam) [%limb %$]) :: ++ sped :: reconstruct type @@ -11616,7 +11616,7 @@ :::: 5d: parser :: ++ vang :: set ++vast params - |= {bug=? wer=path} :: bug: debug mode + |= [bug=? wer=path] :: bug: debug mode %*(. vast bug bug, wer wer) :: wer: where we are :: ++ vast :: main parsing core @@ -11628,7 +11628,7 @@ (more fas limp) ++ gasp ;~ pose :: parse =path= etc. %+ cook - |=({a=tyke b=tyke c=tyke} :(weld a b c)) + |=([a=tyke b=tyke c=tyke] :(weld a b c)) ;~ plug (cook |=(a=(list) (turn a |=(b=* ~))) (star tis)) (cook |=(a=hoon [[~ a] ~]) hasp) @@ -11643,19 +11643,19 @@ (stag %sand (stag %tas (cold %$ buc))) (stag %sand (stag %t qut)) %+ cook - |=(a=coin [%sand ?:(?=({~ %tas *} a) %tas %ta) ~(rent co a)]) + |=(a=coin [%sand ?:(?=([~ %tas *] a) %tas %ta) ~(rent co a)]) nuck:so == ++ limp %+ cook - |= {a=(list) b=tyke} + |= [a=(list) b=tyke] ?~ a b $(a t.a, b [`[%sand %tas %$] b]) ;~(plug (star fas) gasp) ++ mota %+ cook - |=({a=tape b=tape} (rap 3 (weld a b))) + |=([a=tape b=tape] (rap 3 (weld a b))) ;~(plug (star low) (star hig)) ++ glom - |= {wit=whit taw=whit} + |= [wit=whit taw=whit] ^- whit :* ?~(lab.wit lab.taw lab.wit) ?~(boy.wit boy.taw boy.wit) @@ -11683,7 +11683,7 @@ :: ++ apse ;~ pose - %+ cook |=({a=term b=cord} %*(. *whit def (my [a b ~] ~))) + %+ cook |=([a=term b=cord] %*(. *whit def (my [a b ~] ~))) (exit fine) :: %+ cook |=(a=cord %*(. *whit boy `[a ~])) @@ -11700,7 +11700,7 @@ == ^- whit =; def [lab boy (malt def) ~] - (turn def |=({{a=term b=cord} c=(list sect)} [a [b c]])) + (turn def |=([[a=term b=cord] c=(list sect)] [a [b c]])) :: :: ++ body @@ -11747,7 +11747,7 @@ :: fill: full definition :: ++ fill - %+ cook |=({{a=term b=cord} c=(list sect) (unit ~)} [a b c]) + %+ cook |=([[a=term b=cord] c=(list sect) (unit ~)] [a b c]) ;~ plug (into fine) (rant ;~(pfix step text)) @@ -11767,19 +11767,19 @@ :: ++ plex :: reparse static path |= gen=hoon ^- (unit path) - ?: ?=({%dbug *} gen) :: unwrap %dbug + ?: ?=([%dbug *] gen) :: unwrap %dbug $(gen q.gen) - ?. ?=({%clsg *} gen) ~ :: require :~ hoon + ?. ?=([%clsg *] gen) ~ :: require :~ hoon %+ reel p.gen :: build using elements - |= {a=hoon b=_`(unit path)`[~ u=/]} :: starting from just / + |= [a=hoon b=_`(unit path)`[~ u=/]] :: starting from just / ?~ b ~ - ?. ?=({%sand ?(%ta %tas) @} a) ~ :: /foo constants + ?. ?=([%sand ?(%ta %tas) @] a) ~ :: /foo constants `[q.a u.b] :: ++ phax |= ruw=(list (list woof)) =+ [yun=*(list hoon) cah=*(list @)] - =+ wod=|=({a=tape b=(list hoon)} ^+(b ?~(a b [[%mcfs %knit (flop a)] b]))) + =+ wod=|=([a=tape b=(list hoon)] ^+(b ?~(a b [[%mcfs %knit (flop a)] b]))) |- ^+ yun ?~ ruw (flop (wod cah yun)) @@ -11789,7 +11789,7 @@ $(i.ruw t.i.ruw, cah ~, yun [p.i.i.ruw (wod cah yun)]) :: ++ posh - |= {pre=(unit tyke) pof=(unit {p=@ud q=tyke})} + |= [pre=(unit tyke) pof=(unit [p=@ud q=tyke])] ^- (unit (list hoon)) =- ?^(- - ~&(%posh-fail -)) =+ wom=(poof wer) @@ -11811,7 +11811,7 @@ :: tyke is =foo== as ~[~ `foo ~ ~] :: interpolate '=' path components ++ poon :: try to replace '='s - |= {pag=(list hoon) goo=tyke} :: default to pag + |= [pag=(list hoon) goo=tyke] :: default to pag ^- (unit (list hoon)) :: for null goo's ?~ goo `~ :: keep empty goo %+ both :: otherwise head comes @@ -11833,8 +11833,8 @@ :: ++ rump %+ sear - |= {a=wing b=(unit hoon)} ^- (unit hoon) - ?~(b [~ %wing a] ?.(?=({@ ~} a) ~ [~ [%rock %tas i.a] u.b])) + |= [a=wing b=(unit hoon)] ^- (unit hoon) + ?~(b [~ %wing a] ?.(?=([@ ~] a) ~ [~ [%rock %tas i.a] u.b])) ;~(plug rope ;~(pose (stag ~ wede) (easy ~))) :: ++ rood @@ -11844,7 +11844,7 @@ :: ++ rupl %+ cook - |= {a=? b=(list hoon) c=?} + |= [a=? b=(list hoon) c=?] ?: a ?: c [%clsg [%clsg b] ~] @@ -11998,7 +11998,7 @@ :: ++ a-mane :: mane as hoon %+ cook - |= {a=@tas b=(unit @tas)} + |= [a=@tas b=(unit @tas)] ?~(b a [a u.b]) ;~ plug mixed-case-symbol @@ -12010,8 +12010,8 @@ == :: ++ en-class - |= a=(list {%class p=term}) - ^- (unit {%class tape}) + |= a=(list [%class p=term]) + ^- (unit [%class tape]) ?~ a ~ %- some :- %class @@ -12022,15 +12022,15 @@ :: ++ tag-head :: tag head %+ cook - |= {a=mane:hoot b=mart:hoot c=mart:hoot} + |= [a=mane:hoot b=mart:hoot c=mart:hoot] ^- marx:hoot [a (weld b c)] ;~ plug a-mane :: %+ cook - |= a=(list (unit {term (list beer:hoot)})) - ^- (list {term (list beer:hoot)}) + |= a=(list (unit [term (list beer:hoot)])) + ^- (list [term (list beer:hoot)]) :: discard nulls (murn a same) ;~ plug @@ -12066,7 +12066,7 @@ :: ++ tall-elem :: tall preface %+ cook - |= {a={p=mane:hoot q=mart:hoot} b=mart:hoot c=marl:hoot} + |= [a=[p=mane:hoot q=mart:hoot] b=mart:hoot c=marl:hoot] ^- manx:hoot [[p.a (weld q.a b)] c] ;~(plug tag-head tall-attrs tall-tail) @@ -12109,7 +12109,7 @@ ++ collapse-chars :: group consec chars |= reb=(list $@(@ tuna:hoot)) ^- marl:hoot - =| {sim=(list @) tuz=marl:hoot} + =| [sim=(list @) tuz=marl:hoot] |- ^- marl:hoot ?~ reb =. sim @@ -12150,8 +12150,8 @@ %fens :: ``` code fence %expr :: ;sail expression == == :: - {%new p=trig-new} :: open container - {%old %text} :: anything else + [%new p=trig-new] :: open container + [%old %text] :: anything else == :: ++ trig-new :: start a $? %lite :: + line item @@ -12161,14 +12161,14 @@ %poem :: [ ]{8} poem == :: ++ graf :: paragraph element - $% {%bold p=(list graf)} :: *bold* - {%talc p=(list graf)} :: _italics_ - {%quod p=(list graf)} :: "double quote" - {%code p=tape} :: code literal - {%text p=tape} :: text symbol - {%link p=(list graf) q=tape} :: URL - {%mage p=tape q=tape} :: image - {%expr p=tuna:hoot} :: interpolated hoon + $% [%bold p=(list graf)] :: *bold* + [%talc p=(list graf)] :: _italics_ + [%quod p=(list graf)] :: "double quote" + [%code p=tape] :: code literal + [%text p=tape] :: text symbol + [%link p=(list graf) q=tape] :: URL + [%mage p=tape q=tape] :: image + [%expr p=tuna:hoot] :: interpolated hoon == -- =< (non-empty:parse |=(nail `(like tarp)`~($ main +<))) @@ -12191,11 +12191,11 @@ :: =/ verbose & =| err=(unit hair) - =| ind={out=@ud inr=@ud} + =| ind=[out=@ud inr=@ud] =| hac=(list item) =/ cur=item [%down ~] =| par=(unit (pair hair wall)) - |_ {loc=hair txt=tape} + |_ [loc=hair txt=tape] :: ++ $ :: resolve ^- (like tarp) @@ -12285,14 +12285,14 @@ :: :: trim trailing spaces |- ^- tape - ?: ?=({%' ' *} lin) + ?: ?=([%' ' *] lin) $(lin t.lin) (flop lin) :: =/ eat-newline=nail [[+(p.loc) 1] t.txt] =/ saw look(+<.$ eat-newline) :: - ?: ?=({~ @ %end ?(%stet %dent)} saw) :: stop on == or dedent + ?: ?=([~ @ %end ?(%stet %dent)] saw) :: stop on == or dedent [[lin `~] +<.^$] [[lin ~] eat-newline] :: @@ -12368,7 +12368,7 @@ ?~ saw :: :: break section - =^ a={tape fin=(unit _err)} +<.$ read-line + =^ a=[tape fin=(unit _err)] +<.$ read-line ?^ fin.a ..$(err u.fin.a) =>(close-par line) @@ -12440,7 +12440,7 @@ ..$(err `[p.loc col.saw]) :: :: accept line and maybe continue - =^ a={lin=tape fin=(unit _err)} +<.$ read-line + =^ a=[lin=tape fin=(unit _err)] +<.$ read-line =. par par(q.u [lin.a q.u.par]) ?^ fin.a ..$(err u.fin.a) line @@ -12508,7 +12508,7 @@ %+ cook |=(a=(unit trig) a) ;~ pfix (star ace) %+ here :: report indent - |=({a=pint b=?(~ trig-style)} ?~(b ~ `[q.p.a b])) + |=([a=pint b=?(~ trig-style)] ?~(b ~ `[q.p.a b])) ;~ pose (cold ~ (just `@`10)) :: blank line :: @@ -12553,7 +12553,7 @@ fex=rule sab=rule == - |= {loc=hair txt=tape} + |= [loc=hair txt=tape] ^+ *sab :: :: vex: fenced span @@ -12579,7 +12579,7 @@ :: ++ echo :: hoon literal |* sab=rule - |= {loc=hair txt=tape} + |= [loc=hair txt=tape] ^- (like tape) :: :: vex: result of parsing wide hoon @@ -12774,7 +12774,7 @@ :: leading outdent is ok since container may :: have already been parsed and consumed %+ ifix [;~(plug (star ace) tics) ind-tics] - %^ stir "" |=({a=tape b=tape} "{a}\0a{b}") + %^ stir "" |=([a=tape b=tape] "{a}\0a{b}") ;~ pose %+ ifix [ind (just '\0a')] ;~(less tics (star prn)) @@ -12798,7 +12798,7 @@ :: ++ head :: parse heading %+ cook - |= {haxes=tape kids=tarp} ^- tarp + |= [haxes=tape kids=tarp] ^- tarp =/ tag (crip 'h' <(lent haxes)>) :: e.g. ### -> %h3 =/ id (contents-to-id kids) [[tag [%id id]~] kids]~ @@ -12825,10 +12825,10 @@ %+ weld ^- tape ?- i.a - {{%$ {%$ *} ~} ~} :: text node contents + [[%$ [%$ *] ~] ~] :: text node contents (murn v.i.a.g.i.a |=(a=beer:hoot ?^(a ~ (some a)))) - {^ *} $(a c.i.a) :: concatenate children - {@ *} ~ :: ignore interpolation + [^ *] $(a c.i.a) :: concatenate children + [@ *] ~ :: ignore interpolation == $(a t.a) -- @@ -12947,7 +12947,7 @@ :- '%' ;~ pfix cen ;~ pose - (stag %clsg (sear |~({a=@ud b=tyke} (posh ~ ~ a b)) porc)) + (stag %clsg (sear |~([a=@ud b=tyke] (posh ~ ~ a b)) porc)) (stag %rock (stag %tas (cold %$ buc))) (stag %rock (stag %f (cold & pam))) (stag %rock (stag %f (cold | bar))) @@ -13006,7 +13006,7 @@ == :- ['0' '9'] %+ cook - |= {a=dime b=(unit hoon)} + |= [a=dime b=(unit hoon)] ?~(b [%sand a] [[%rock a] u.b]) ;~(plug bisk:so (punt wede)) :- ':' @@ -13049,7 +13049,7 @@ ;~ pfix tic ;~ pose %+ cook - |=({a=@ta b=hoon} [%ktls [%sand a 0] [%ktls [%sand %$ 0] b]]) + |=([a=@ta b=hoon] [%ktls [%sand a 0] [%ktls [%sand %$ 0] b]]) ;~(pfix pat ;~(plug mota ;~(pfix tic wide))) ;~ pfix tar (stag %kthp (stag [%base %noun] ;~(pfix tic wide))) @@ -13372,7 +13372,7 @@ == :: %+ cook - |= {b=term d=spec} + |= [b=term d=spec] [b [%ktcl [%name b d]]] ;~ pfix (jest '+$') ;~ plug @@ -13524,7 +13524,7 @@ ++ muck ?:(tol gap ace) :: general separator ++ teak %+ knee *tiki |. ~+ :: wing or hoon =+ ^= gub - |= {a=term b=$%({%& p=wing} {%| p=hoon})} + |= [a=term b=$%([%& p=wing] [%| p=hoon])] ^- tiki ?-(-.b %& [%& [~ a] p.b], %| [%| [~ a] p.b]) =+ ^= wyp @@ -13607,25 +13607,25 @@ :: :: tiki expansion for %wt runes :: - ++ txhp |. %+ cook |= {a=tiki b=(list (pair spec hoon))} + ++ txhp |. %+ cook |= [a=tiki b=(list (pair spec hoon))] (~(wthp ah a) b) (butt ;~(gunk teak ruck)) - ++ tkkt |. %+ cook |= {a=tiki b=hoon c=hoon} + ++ tkkt |. %+ cook |= [a=tiki b=hoon c=hoon] (~(wtkt ah a) b c) ;~(gunk teak loaf loaf) - ++ txls |. %+ cook |= {a=tiki b=hoon c=(list (pair spec hoon))} + ++ txls |. %+ cook |= [a=tiki b=hoon c=(list (pair spec hoon))] (~(wtls ah a) b c) (butt ;~(gunk teak loaf ruck)) - ++ tkvt |. %+ cook |= {a=tiki b=hoon c=hoon} + ++ tkvt |. %+ cook |= [a=tiki b=hoon c=hoon] (~(wtpt ah a) b c) ;~(gunk teak loaf loaf) - ++ tksg |. %+ cook |= {a=tiki b=hoon c=hoon} + ++ tksg |. %+ cook |= [a=tiki b=hoon c=hoon] (~(wtsg ah a) b c) ;~(gunk teak loaf loaf) - ++ txts |. %+ cook |= {a=spec b=tiki} + ++ txts |. %+ cook |= [a=spec b=tiki] (~(wtts ah b) a) ;~(gunk loan teak) - ++ txhx |. %+ cook |= {a=skin b=tiki} + ++ txhx |. %+ cook |= [a=skin b=tiki] (~(wthx ah b) a) ;~(gunk lore teak) :: @@ -13680,10 +13680,10 @@ ++ lang :: lung sample $: ros=hoon $= vil - $% {%tis p=hoon} - {%col p=hoon} - {%ket p=hoon} - {%lit p=(list (pair wing hoon))} + $% [%tis p=hoon] + [%col p=hoon] + [%ket p=hoon] + [%lit p=(list (pair wing hoon))] == == :: @@ -13729,12 +13729,12 @@ ++ rope :: wing form %+ knee *wing |. ~+ - %+ (slug |=({a=limb b=wing} [a b])) + %+ (slug |=([a=limb b=wing] [a b])) dot ;~ pose (cold [%| 0 ~] com) %+ cook - |=({a=(list) b=term} ?~(a b [%| (lent a) `b])) + |=([a=(list) b=term] ?~(a b [%| (lent a) `b])) ;~(plug (star ket) ;~(pose sym (cold %$ buc))) :: %+ cook @@ -13795,13 +13795,13 @@ ++ wart |* zor=rule %+ here - |= {a=pint b=hoon} + |= [a=pint b=hoon] ?:(bug [%dbug [wer a] b] b) zor ++ wert |* zor=rule %+ here - |= {a=pint b=spec} + |= [a=pint b=spec] ?:(bug [%dbug [wer a] b] b) zor -- @@ -13824,7 +13824,7 @@ q:(~(mint ut %noun) %noun (ream txt)) :: ++ rain :: parse with % path - |= {bon=path txt=@} + |= [bon=path txt=@] ^- hoon =+ vaz=vast ~| bon @@ -13840,7 +13840,7 @@ (rain bon .^(@t %cx (weld bon `path`[%hoon ~]))) :: ++ ride :: end-to-end compiler - |= {typ=type txt=@} + |= [typ=type txt=@] ^- (pair type nock) ~> %slog.[0 leaf/"ride: parsing"] =/ gen (ream txt) @@ -13854,8 +13854,8 @@ |_ worm ++ nell |=(ref=type (nest [%cell %noun %noun] ref)) :: nest in cell ++ nest :: nest:ut, cached - |= {sut=type ref=type} - ^- {? worm} + |= [sut=type ref=type] + ^- [? worm] ?: (~(has in nes) [sut ref]) [& +>+<] ?. (~(nest ut sut) | ref) ~& %nest-failed @@ -13869,14 +13869,14 @@ [& +>+<(nes (~(put in nes) [sut ref]))] :: ++ call :: call gate - |= {vax=vase nam=term som=(each vase ^)} - ^- {vase worm} + |= [vax=vase nam=term som=(each vase ^)] + ^- [vase worm] =^ duf +>+<.$ (open vax nam som) (slap duf [%limb %$]) :: ++ open :: assemble door - |= {vax=vase nam=term som=(each vase ^)} - ^- {vase worm} + |= [vax=vase nam=term som=(each vase ^)] + ^- [vase worm] =* key [%cncb [[%& 2] ~] [[[%& 6] ~] [%$ 3]] ~] =^ dor +>+<.$ (slap vax [%limb nam]) =^ mes +>+<.$ (slot 6 dor) @@ -13889,7 +13889,7 @@ [[p.dor q.dor(+6 +7.som)] +>+<.$] :: ++ neat :: type compliance - |= {typ=type som=(each vase ^)} + |= [typ=type som=(each vase ^)] ^- worm =^ hip +>+<.$ ?- -.som @@ -13900,10 +13900,10 @@ +>+<.$ :: ++ nets :: typeless nest - |= {sut=* ref=*} - ^- {? worm} + |= [sut=* ref=*] + ^- [? worm] ?: (~(has in nes) [sut ref]) [& +>+<] - =+ gat=|=({a=type b=type} (~(nest ut a) | b)) + =+ gat=|=([a=type b=type] (~(nest ut a) | b)) ?. (? (slum gat [sut ref])) ~& %nets-failed =+ tag=`*`skol @@ -13918,8 +13918,8 @@ :: +play: +play:ut, cached :: ++ play - |= {sut=type gen=hoon} - ^- {type worm} + |= [sut=type gen=hoon] + ^- [type worm] =+ old=(~(get by pay) [sut gen]) ?^ old [u.old +>+<.$] =+ new=(~(play ut sut) gen) @@ -13927,8 +13927,8 @@ :: +mint: +mint:ut to noun, cached :: ++ mint - |= {sut=type gen=hoon} - ^- {(pair type nock) worm} + |= [sut=type gen=hoon] + ^- [(pair type nock) worm] =+ old=(~(get by mit) [sut gen]) ?^ old [u.old +>+<.$] =+ new=(~(mint ut sut) %noun gen) @@ -13944,27 +13944,27 @@ :: +slap: +slap:ut, cached :: ++ slap - |= {vax=vase gen=hoon} - ^- {vase worm} + |= [vax=vase gen=hoon] + ^- [vase worm] =^ gun +>+< (mint p.vax gen) [[p.gun .*(q.vax q.gun)] +>+<.$] :: +slot: +slot:ut, cached :: ++ slot - |= {axe=@ vax=vase} - ^- {vase worm} + |= [axe=@ vax=vase] + ^- [vase worm] =^ gun +>+< (mint p.vax [%$ axe]) [[p.gun .*(q.vax [0 axe])] +>+<.$] :: +slym: +slym:ut, cached :: ++ slym - |= {gat=vase sam=*} + |= [gat=vase sam=*] ^- [vase worm] (slap gat(+<.q sam) [%limb %$]) :: ++ sped :: specialize vase |= vax=vase - ^- {vase worm} + ^- [vase worm] =+ ^= gen ^- hoon ?@ q.vax [%wtts [%base [%atom %$]] [%& 1]~] ?@ -.q.vax [%wtts [%leaf %tas -.q.vax] [%& 2]~] @@ -13973,46 +13973,46 @@ [[typ q.vax] +>+<.$] :: ++ spot :: slot then sped - |= {axe=@ vax=vase} - ^- {vase worm} + |= [axe=@ vax=vase] + ^- [vase worm] =^ xav +>+< (slot axe vax) (sped xav) :: ++ stop :: sped then slot - |= {axe=@ vax=vase} - ^- {vase worm} + |= [axe=@ vax=vase] + ^- [vase worm] =^ xav +>+< (sped vax) (slot axe xav) -- :: :::: 5f: molds and mold builders :: -++ mane $@(@tas {@tas @tas}) :: XML name+space -++ manx $~([[%$ ~] ~] {g=marx c=marl}) :: dynamic XML node -++ marl (list manx) :: XML node list -++ mars {t={n=%$ a={i={n=%$ v=tape} t=~}} c=~} :: XML cdata -++ mart (list {n=mane v=tape}) :: XML attributes -++ marx $~([%$ ~] {n=mane a=mart}) :: dynamic XML tag -++ mite (list @ta) :: mime type -++ monk (each ship {p=@tas q=@ta}) :: general identity -++ pass @ :: public key -++ ring @ :: private key -++ ship @p :: network identity -++ shop (each ship (list @ta)) :: urbit/dns identity -++ spur path :: ship desk case spur -++ time @da :: galactic time ++$ mane $@(@tas [@tas @tas]) :: XML name+space ++$ manx $~([[%$ ~] ~] [g=marx c=marl]) :: dynamic XML node ++$ marl (list manx) :: XML node list ++$ mars [t=[n=%$ a=[i=[n=%$ v=tape] t=~]] c=~] :: XML cdata ++$ mart (list [n=mane v=tape]) :: XML attributes ++$ marx $~([%$ ~] [n=mane a=mart]) :: dynamic XML tag ++$ mite (list @ta) :: mime type ++$ monk (each ship [p=@tas q=@ta]) :: general identity ++$ pass @ :: public key ++$ ring @ :: private key ++$ ship @p :: network identity ++$ shop (each ship (list @ta)) :: urbit/dns identity ++$ spur path :: ship desk case spur ++$ time @da :: galactic time :: :::: 5g: profiling support (XX move) :: :: ++ pi-heck - |= {nam=@tas day=doss} + |= [nam=@tas day=doss] ^- doss =+ lam=(~(get by hit.day) nam) day(hit (~(put by hit.day) nam ?~(lam 1 +(u.lam)))) :: ++ pi-noon :: sample trace - |= {mot=term paz=(list path) day=doss} + |= [mot=term paz=(list path) day=doss] =| lax=(unit path) |- ^- doss ?~ paz day(mon (pi-mope mot mon.day)) @@ -14033,7 +14033,7 @@ (~(put by inn.hup) u.nax ?~(hag 1 +(u.hag))) == ++ pi-mope :: add sample - |= {mot=term mon=moan} + |= [mot=term mon=moan] ?+ mot mon %fun mon(fun +(fun.mon)) %noc mon(noc +(noc.mon)) @@ -14090,9 +14090,9 @@ :: %+ turn %+ sort ~(tap by hit.day) - |= {a={* @} b={* @}} + |= [a=[* @] b=[* @]] (lth +.a +.b) - |= {nam=term num=@ud} + |= [nam=term num=@ud] :(welp (trip nam) ": " (scow %ud num)) ["" ~] :: @@ -14100,9 +14100,9 @@ ^- (list (list tape)) %+ turn %+ sort ~(tap by cut.day) - |= {one=(pair path hump) two=(pair path hump)} + |= [one=(pair path hump) two=(pair path hump)] (gth (pi-moth mon.q.one) (pi-moth mon.q.two)) - |= {pax=path hup=hump} + |= [pax=path hup=hump] =+ ott=(pi-moth mon.hup) ;: welp [(welp "label: " (spud pax)) ~] @@ -14113,8 +14113,8 @@ :- "into:" %+ turn %+ sort ~(tap by out.hup) - |=({{* a=@ud} {* b=@ud}} (gth a b)) - |= {pax=path num=@ud} + |=([[* a=@ud] [* b=@ud]] (gth a b)) + |= [pax=path num=@ud] ^- tape :(welp " " (spud pax) ": " (scow %ud num)) :: @@ -14122,8 +14122,8 @@ :- "from:" %+ turn %+ sort ~(tap by inn.hup) - |=({{* a=@ud} {* b=@ud}} (gth a b)) - |= {pax=path num=@ud} + |=([[* a=@ud] [* b=@ud]] (gth a b)) + |= [pax=path num=@ud] ^- tape :(welp " " (spud pax) ": " (scow %ud num)) :: diff --git a/pkg/arvo/sys/vane/clay.hoon b/pkg/arvo/sys/vane/clay.hoon index b1e46c2e48..83fc16d5b1 100644 --- a/pkg/arvo/sys/vane/clay.hoon +++ b/pkg/arvo/sys/vane/clay.hoon @@ -21,7 +21,7 @@ :: +$ ankh :: expanded node $~ [~ ~] - $: fil=(unit {p=lobe q=cage}) :: file + $: fil=(unit [p=lobe q=cage]) :: file dir=(map @ta ankh) :: folders == :: :: @@ -64,7 +64,7 @@ :: Includes subscriber list, dome (desk content), possible commit state (for :: local changes), possible merge state (for incoming merges), and permissions. :: -++ dojo ++$ dojo $: qyx=cult :: subscribers dom=dome :: desk state per=regs :: read perms per path @@ -82,7 +82,7 @@ :: having changed; this lets us short-circuit that in some cases. :: Whenever you give an `%ergo`, you must update this. :: -++ dome ++$ dome $: ank=ankh :: state let=aeon :: top id hit=(map aeon tako) :: versions by id @@ -101,7 +101,7 @@ :: -- `dif` is the diffs in `dig` applied to their files. :: -- `mut` is the diffs between `muc` and the original files. :: -++ dork :: diff work ++$ dork :: diff work $: del=(list path) :: deletes ink=(list (pair path cage)) :: hoon inserts ins=(list (pair path cage)) :: inserts @@ -130,7 +130,7 @@ :: :: Hash of a blob, for lookup in the object store (lat.ran) :: -++ lobe @uvI :: blob ref ++$ lobe @uvI :: blob ref :: :: New desk data. :: @@ -138,7 +138,7 @@ :: of all new aeons to hashes of their commits, the most recent aeon, and sets :: of all new commits and data. :: -++ nako :: subscription state ++$ nako :: subscription state $: gar=(map aeon tako) :: new ids let=aeon :: next id lar=(set yaki) :: new commits @@ -157,7 +157,7 @@ :: -- `cez` is a collection of named permission groups. :: -- `pud` is an update that's waiting on a kernel upgrade :: -++ raft :: filesystem ++$ raft :: filesystem $: rom=room :: domestic hoy=(map ship rung) :: foreign ran=rang :: hashes @@ -172,17 +172,17 @@ :: :: Maps of commit hashes to commits and content hashes to content. :: -++ rang :: ++$ rang :: $: hut=(map tako yaki) :: lat=(map lobe blob) :: == :: :: :: Unvalidated response to a request. :: -:: Like a ++rant, but with a page of data rather than a cage of it. +:: Like a +$rant, but with a page of data rather than a cage of it. :: -++ rand :: unvalidated rant - $: p={p=care q=case r=@tas} :: clade release book ++$ rand :: unvalidated rant + $: p=[p=care q=case r=@tas] :: clade release book q=path :: spur r=page :: data == :: @@ -201,7 +201,7 @@ :: -- `dom` is the actual state of the filetree. Since this is used almost :: exclusively in `++ze`, we describe it there. :: -++ rede :: universal project ++$ rede :: universal project $: lim=@da :: complete to ref=(unit rind) :: outgoing requests qyx=cult :: subscribers @@ -238,7 +238,7 @@ :: :: Result of a subscription :: -++ sub-result ++$ sub-result $% [%blab =mood data=(each cage lobe)] [%bleb ver=@ud ins=@ud range=(unit (pair aeon aeon))] [%balk cage=(unit (each cage lobe)) =mood] @@ -250,19 +250,19 @@ :: :: `hun` is the duct to dill, and `dos` is a collection of our desks. :: -++ room :: fs per ship ++$ room :: fs per ship $: hun=duct :: terminal duct dos=(map desk dojo) :: native desk == :: :: :: Stored request. :: -:: Like a ++rave but with caches of current versions for %next and %many. +:: Like a +$rave but with caches of current versions for %next and %many. :: Generally used when we store a request in our state somewhere. :: -++ cach (unit (unit (each cage lobe))) :: cached result ++$ cach (unit (unit (each cage lobe))) :: cached result +$ wove [for=(unit [=ship ver=@ud]) =rove] :: stored source + req -++ rove :: stored request ++$ rove :: stored request $% [%sing =mood] :: single request [%next =mood aeon=(unit aeon) =cach] :: next version of one $: %mult :: next version of any @@ -276,12 +276,12 @@ :: :: Foreign desk data. :: -++ rung ++$ rung $: rus=(map desk rede) :: neighbor desks == :: -++ move {p=duct q=(wind note gift:able)} :: local move -++ note :: out request $-> ++$ move [p=duct q=(wind note gift:able)] :: local move ++$ note :: out request $-> $~ [%b %wait *@da] :: $% $: %a :: to %ames $>(%plea task:able:ames) :: @@ -311,8 +311,8 @@ $: %j :: by %jael $>(%public-keys task:able:jael) :: == == :: -++ riot (unit rant) :: response+complete -++ sign :: in result $<- ++$ riot (unit rant) :: response+complete ++$ sign :: in result $<- $~ [%b %wake ~] :: $% $: %a :: by %ames $> $? %boon :: response @@ -1023,7 +1023,7 @@ :: Handle `%sing` requests :: ++ aver - |= {for=(unit ship) mun=mood} + |= [for=(unit ship) mun=mood] ^- [(unit (unit (each cage lobe))) ford-cache] =+ ezy=?~(ref ~ (~(get by haw.u.ref) mun)) ?^ ezy @@ -1057,7 +1057,7 @@ :: Producing null means subscription has been completed or cancelled. :: ++ balk - |= {hen=duct cay=(unit (each cage lobe)) mun=mood} + |= [hen=duct cay=(unit (each cage lobe)) mun=mood] ^+ +> ?~ cay (blub hen) (blab hen mun u.cay) @@ -1065,13 +1065,13 @@ :: Set timer. :: ++ bait - |= {hen=duct tym=@da} + |= [hen=duct tym=@da] (emit hen %pass /tyme/(scot %p her)/[syd] %b %wait tym) :: :: Cancel timer. :: ++ best - |= {hen=duct tym=@da} + |= [hen=duct tym=@da] (emit hen %pass /tyme/(scot %p her)/[syd] %b %rest tym) :: :: Give subscription result. @@ -1141,7 +1141,7 @@ == :: ++ blas - |= {hen=duct das=(set mood)} + |= [hen=duct das=(set mood)] ^+ +> ?> ?=(^ das) :: translate the case to a date @@ -1180,8 +1180,8 @@ :: in `subs`. :: ++ duct-lift - |* send=_|=({duct *} ..duct-lift) - |= {a=(set duct) arg=_+<+.send} ^+ ..duct-lift + |* send=_|=([duct *] ..duct-lift) + |= [a=(set duct) arg=_+<+.send] ^+ ..duct-lift =+ all=~(tap by a) |- ^+ ..duct-lift ?~ all ..duct-lift @@ -1255,7 +1255,7 @@ =+ aey=(case-to-aeon case.mood.rov) ?~ aey ~ %- ~(rep in ~(key by qyx)) - |= {haw=wove res=(unit wove)} + |= [haw=wove res=(unit wove)] ?^ res res ?. =(for.wov for.haw) ~ =* hav rove.haw @@ -1273,7 +1273,7 @@ =+ aey=(case-to-aeon case.mool.rov) ?~ aey ~ %- ~(rep in ~(key by qyx)) - |= {haw=wove res=(unit wove)} + |= [haw=wove res=(unit wove)] ?^ res res ?. =(for.wov for.haw) ~ =* hav rove.haw @@ -1296,7 +1296,7 @@ =+ aey=(case-to-aeon from.moat.rov) ?~ aey ~ %- ~(rep in ~(key by qyx)) - |= {haw=wove res=(unit wove)} + |= [haw=wove res=(unit wove)] ?^ res res ?. =(for.wov for.haw) ~ =* hav rove.haw @@ -2576,7 +2576,7 @@ ^- (map term (pair @ud (set path))) %- malt ^- (list (trel term @ud (set path))) %+ murn ~(tap by mon) - |= {nam=term bem=beam} + |= [nam=term bem=beam] ^- (unit (trel term @ud (set path))) =- ?~(- ~ `[nam (lent s.bem) (silt `(list path)`-)]) %+ skim can @@ -2606,7 +2606,7 @@ :: Set permissions for a node. :: ++ perm - |= {pax=path rit=rite} + |= [pax=path rit=rite] ^+ +> =/ mis=(set @ta) %+ roll @@ -2616,7 +2616,7 @@ %w who:(fall wit.rit *rule) %rw (~(uni in who:(fall red.rit *rule)) who:(fall wit.rit *rule)) == - |= {w=whom s=(set @ta)} + |= [w=whom s=(set @ta)] ?: |(?=(%& -.w) (~(has by cez) p.w)) s (~(put in s) p.w) ?^ mis @@ -2626,7 +2626,7 @@ +>.$ =- (emit hen %give %done `[%perm-fail [%leaf "No such group(s): {-}"]~]) %+ roll ~(tap in `(set @ta)`mis) - |= {g=@ta t=tape} + |= [g=@ta t=tape] ?~ t (trip g) :(weld t ", " (trip g)) :: TODO remove this nasty hack @@ -2642,7 +2642,7 @@ == :: ++ put-perm - |= {pes=regs pax=path new=(unit rule)} + |= [pes=regs pax=path new=(unit rule)] ?~ new (~(del by pes) pax) (~(put by pes) pax u.new) :: @@ -2656,7 +2656,7 @@ == :: ++ forget-crew-in - |= {nom=@ta pes=regs} + |= [nom=@ta pes=regs] %- ~(run by pes) |= r=rule r(who (~(del in who.r) |+nom)) @@ -2671,7 +2671,7 @@ =^ wos=(list wove) qyx :_ (~(run by qyx) |=(a=(set duct) (~(del in a) hen))) %- ~(rep by qyx) - |= {{a=wove b=(set duct)} c=(list wove)} + |= [[a=wove b=(set duct)] c=(list wove)] ?.((~(has in b) hen) c [a c]) :: ?~ ref @@ -3259,7 +3259,7 @@ :: :: know about file in cach :: - ++ know |=({(pair care path) c=cach} ?=(^ c)) + ++ know |=([(pair care path) c=cach] ?=(^ c)) :: :: fill in the blanks :: @@ -3385,7 +3385,7 @@ :: Checks whether two pieces of data (either cages or lobes) are the same. :: ++ equivalent-data - |= {one=(each cage lobe) two=(each cage lobe)} + |= [one=(each cage lobe) two=(each cage lobe)] ^- ? ?: ?=(%& -.one) ?: ?=(%& -.two) @@ -3398,7 +3398,7 @@ :: Gets a map of the data at the given path and all children of it. :: ++ lobes-at-path - |= {for=(unit ship) yon=aeon pax=path} + |= [for=(unit ship) yon=aeon pax=path] ^- (map path lobe) ?: =(0 yon) ~ :: we use %z for the check because it looks at all child paths. @@ -3409,7 +3409,7 @@ =< q %- aeon-to-yaki yon - |= {p=path q=lobe} + |= [p=path q=lobe] ?| ?=(~ pax) ?& !?=(~ p) =(-.pax -.p) @@ -3477,15 +3477,15 @@ :: already in `b`. :: ++ new-lobes :: object hash set - |= {b=(set lobe) a=(set tako)} :: that aren't in b + |= [b=(set lobe) a=(set tako)] :: that aren't in b ^- (set lobe) %+ roll ~(tap in a) - |= {tak=tako bar=(set lobe)} + |= [tak=tako bar=(set lobe)] ^- (set lobe) =+ yak=(tako-to-yaki tak) %+ roll ~(tap by q.yak) =< .(far bar) - |= {{path lob=lobe} far=(set lobe)} + |= [[path lob=lobe] far=(set lobe)] ^- (set lobe) ?~ (~(has in b) lob) :: don't need far @@ -3566,14 +3566,14 @@ (read-p-in pax pew.red) :: ++ read-p-in - |= {pax=path pes=regs} + |= [pax=path pes=regs] ^- dict =/ rul=(unit rule) (~(get by pes) pax) ?^ rul :+ pax mod.u.rul %- ~(rep in who.u.rul) - |= {w=whom out=(pair (set ship) (map @ta crew))} - ?: ?=({%& @p} w) + |= [w=whom out=(pair (set ship) (map @ta crew))] + ?: ?=([%& @p] w) [(~(put in p.out) +.w) q.out] =/ cru=(unit crew) (~(get by cez.ruf) +.w) ?~ cru out @@ -3582,7 +3582,7 @@ $(pax (scag (dec (lent pax)) `path`pax)) :: ++ may-read - |= {who=ship car=care yon=aeon pax=path} + |= [who=ship car=care yon=aeon pax=path] ^- ? ?+ car (allowed-by who pax per.red) @@ -3597,7 +3597,7 @@ =+ len=(lent pax) =- (levy ~(tap in -) |=(p=path (allowed-by who p per.red))) %+ roll ~(tap in (~(del in ~(key by q.yak)) pax)) - |= {p=path s=(set path)} + |= [p=path s=(set path)] ?. =(pax (scag len p)) s %- ~(put in s) ?: ?=(%z car) p @@ -3605,18 +3605,18 @@ == :: ++ may-write - |= {w=ship p=path} + |= [w=ship p=path] (allowed-by w p pew.red) :: ++ allowed-by - |= {who=ship pax=path pes=regs} + |= [who=ship pax=path pes=regs] ^- ? =/ rul=real rul:(read-p-in pax pes) =/ in-list/? ?| (~(has in p.who.rul) who) :: %- ~(rep by q.who.rul) - |= {{@ta cru=crew} out=_|} + |= [[@ta cru=crew] out=_|] ?: out & (~(has in cru) who) == @@ -3632,9 +3632,9 @@ =/ descendants=(list (pair path lobe)) %+ turn %+ skim ~(tap by (~(del by q.yaki) pax)) - |= {paf=path lob=lobe} + |= [paf=path lob=lobe] =(pax (scag len paf)) - |= {paf=path lob=lobe} + |= [paf=path lob=lobe] [(slag len paf) lob] =+ us=(~(get by q.yaki) pax) ?: &(?=(~ descendants) ?=(~ us)) @@ -3642,7 +3642,7 @@ %+ roll ^- (list (pair path lobe)) [[~ ?~(us *lobe u.us)] descendants] - |=({{path lobe} @uvI} (shax (jam +<))) + |=([[path lobe] @uvI] (shax (jam +<))) :: +read-r: %x wrapped in a vase :: ++ read-r @@ -3765,15 +3765,15 @@ :: of the data is legit. We also never send the mime cache over the wire. :: ++ read-v - |= {yon=aeon pax=path} - ^- (unit (unit {%dome (hypo dome:clay)})) + |= [yon=aeon pax=path] + ^- (unit (unit [%dome (hypo dome:clay)])) ?: (lth yon let.dom) :* ~ ~ %dome -:!>(*dome:clay) ^- dome:clay :* ank=`[[%ank-in-old-v-not-implemented *ankh] ~ ~] let=yon - hit=(molt (skim ~(tap by hit.dom) |=({p=@ud *} (lte p yon)))) - lab=(molt (skim ~(tap by lab.dom) |=({* p=@ud} (lte p yon)))) + hit=(molt (skim ~(tap by hit.dom) |=([p=@ud *] (lte p yon)))) + lab=(molt (skim ~(tap by lab.dom) |=([* p=@ud] (lte p yon)))) == == ?: (gth yon let.dom) ~ @@ -3814,7 +3814,7 @@ :- ~ %+ bind fil.ank:(descend-path:(zu ank.dom) pax) - |=(a={p=lobe q=cage} [%& q.a]) + |=(a=[p=lobe q=cage] [%& q.a]) =+ yak=(tako-to-yaki u.tak) =+ lob=(~(get by q.yak) pax) ?~ lob @@ -3843,8 +3843,8 @@ :: Gets an arch (directory listing) at a node. :: ++ read-y - |= {yon=aeon pax=path} - ^- (unit (unit {%arch (hypo arch)})) + |= [yon=aeon pax=path] + ^- (unit (unit [%arch (hypo arch)])) ?: =(0 yon) ``[%arch -:!>(*arch) *arch] =+ tak=(~(get by hit.dom) yon) @@ -3862,17 +3862,17 @@ %+ turn ^- (list (pair path lobe)) %+ skim ~(tap by (~(del by q.yak) pax)) - |= {paf=path lob=lobe} + |= [paf=path lob=lobe] =(pax (scag len paf)) - |= {paf=path lob=lobe} + |= [paf=path lob=lobe] =+ pat=(slag len paf) [?>(?=(^ pat) i.pat) ~] :: :: Gets a recursive hash of a node and all its children. :: ++ read-z - |= {yon=aeon pax=path} - ^- (unit (unit {%uvi (hypo @uvI)})) + |= [yon=aeon pax=path] + ^- (unit (unit [%uvi (hypo @uvI)])) ?: =(0 yon) ``uvi+[-:!>(*@uvI) *@uvI] =+ tak=(~(get by hit.dom) yon) @@ -4006,7 +4006,7 @@ :: %crow =/ des ~(tap by dos.rom.ruf) - =| rus=(map desk {r=regs w=regs}) + =| rus=(map desk [r=regs w=regs]) |^ ?~ des [[hen %give %croz rus]~ ..^^$] =+ per=(filter-rules per.q.i.des) @@ -4020,7 +4020,7 @@ ^+ pes =- (~(gas in *regs) -) %+ skim ~(tap by pes) - |= {p=path r=rule} + |= [p=path r=rule] (~(has in who.r) |+nom.req) -- :: @@ -4116,7 +4116,7 @@ == %+ turn (skim ~(tap by mon.ruf) (corl (cury test pot) tail)) - |= {pon=term bem=beam} + |= [pon=term bem=beam] [u.hez.ruf %give %ogre pon] :: %park @@ -4468,7 +4468,7 @@ == +$ rind-3 $: nix=@ud - bom=(map @ud {p=duct q=rave}) + bom=(map @ud [p=duct q=rave]) fod=(map duct @ud) haw=(map mood (unit cage)) == @@ -4523,7 +4523,7 @@ == :: +$ rind-2 $: nix=@ud :: request index - bom=(map @ud {p=duct q=rave}) :: outstanding + bom=(map @ud [p=duct q=rave]) :: outstanding fod=(map duct @ud) :: current requests haw=(map mood (unit cage)) :: simple cache pud=update-qeu-2 :: active updates diff --git a/pkg/arvo/sys/vane/dill.hoon b/pkg/arvo/sys/vane/dill.hoon index b6d444f679..34bbe3d974 100644 --- a/pkg/arvo/sys/vane/dill.hoon +++ b/pkg/arvo/sys/vane/dill.hoon @@ -4,10 +4,10 @@ |= pit=vase =, dill => |% :: interface tiles -++ gill (pair ship term) :: general contact ++$ gill (pair ship term) :: general contact -- :: => |% :: console protocol -++ axle :: ++$ axle :: $: %4 ::TODO replace ducts with session ids :: hey=(unit duct) :: default duct dug=(map duct axon) :: conversations @@ -17,7 +17,7 @@ $~ (~(put by *(map @tas log-level)) %hole %soft) :: quiet packet crashes (map @tas log-level) :: == :: -++ axon :: dill per duct ++$ axon :: dill per duct $: ram=term :: console program tem=(unit (list dill-belt)) :: pending, reverse wid=_80 :: terminal width @@ -27,11 +27,11 @@ +$ log-level ?(%hush %soft %loud) :: none, line, full -- => :: |% :: protocol outward -++ mess :: - $% {%dill-belt p=(hypo dill-belt)} :: ++$ mess :: + $% [%dill-belt p=(hypo dill-belt)] :: == :: -++ move {p=duct q=(wind note gift:able)} :: local move -++ note :: out request $-> ++$ move [p=duct q=(wind note gift:able)] :: local move ++$ note :: out request $-> $~ [%d %verb ~] :: $% $: %c :: $> $? %merg :: merge desks @@ -64,7 +64,7 @@ == :: task:able:jael :: == == :: -++ sign :: in result $<- ++$ sign :: in result $<- $~ [%j %init *@p] :: $% $: %b :: $% $>(%writ gift:able:clay) :: XX %slip @@ -102,7 +102,7 @@ =| moz=(list move) |_ [hen=duct axon] ++ abet :: resolve - ^- {(list move) axle} + ^- [(list move) axle] [(flop moz) all(dug (~(put by dug.all) hen +<+))] :: ++ call :: receive input @@ -127,7 +127,7 @@ == :: ++ crud - |= {err=@tas tac=(list tank)} + |= [err=@tas tac=(list tank)] :: unknown errors default to %loud :: =/ lev=log-level (~(gut by veb.all) err %loud) @@ -261,7 +261,7 @@ (deal /sync %poke %kiln-ota !>(`syn)) :: ++ take :: receive - |= {tea=wire sih=sign} + |= [tea=wire sih=sign] ^+ +> ?- sih [%j %init *] @@ -269,14 +269,14 @@ :: +>(moz :_(moz [hen %give +.sih])) :: - {%g %onto *} + [%g %onto *] :: ~& [%take-gall-onto +>.sih] ?- -.+>.sih %| (crud %onto p.p.+>.sih) %& (done %blit [%lin (tuba "{}")]~) == :: - {%g %unto *} + [%g %unto *] :: ~& [%take-gall-unto +>.sih] ?- -.+>.sih %poke-ack ?~(p.p.+>.sih +>.$ (crud %coup u.p.p.+>.sih)) @@ -287,18 +287,18 @@ %fact (from ;;(dill-blit q:`vase`+>+>.sih)) == :: - {%c %note *} + [%c %note *] (from %out (tuba p.sih ' ' ~(ram re q.sih))) :: - {?(%b %c) %writ *} + [?(%b %c) %writ *] init :: - {?(%b %c) %mere *} + [?(%b %c) %mere *] ?: ?=(%& -.p.sih) mere (mean >%dill-mere-fail< >p.p.p.sih< q.p.p.sih) :: - {%d %blit *} + [%d %blit *] (done +.sih) == -- @@ -528,7 +528,7 @@ ++ stay all :: ++ take :: process move - |= {tea=wire hen=duct dud=(unit goof) hin=(hypo sign)} + |= [tea=wire hen=duct dud=(unit goof) hin=(hypo sign)] ^+ [*(list move) ..^$] ?^ dud ~|(%dill-take-dud (mean tang.u.dud)) diff --git a/pkg/arvo/sys/vane/eyre.hoon b/pkg/arvo/sys/vane/eyre.hoon index dd0262a473..d08ca75447 100644 --- a/pkg/arvo/sys/vane/eyre.hoon +++ b/pkg/arvo/sys/vane/eyre.hoon @@ -419,7 +419,7 @@ :: +render-tang-to-marl: renders a tang and adds
tags between each line :: ++ render-tang-to-marl - |= {wid=@u tan=tang} + |= [wid=@u tan=tang] ^- marl =/ raw=(list tape) (zing (turn tan |=(a=tank (wash 0^wid a)))) :: @@ -429,7 +429,7 @@ :: +render-tang-to-wall: renders tang as text lines :: ++ render-tang-to-wall - |= {wid=@u tan=tang} + |= [wid=@u tan=tang] ^- wall (zing (turn tan |=(a=tank (wash 0^wid a)))) :: +wall-to-octs: text to binary output diff --git a/pkg/arvo/sys/vane/jael.hoon b/pkg/arvo/sys/vane/jael.hoon index fbc189b225..5e526d63ee 100644 --- a/pkg/arvo/sys/vane/jael.hoon +++ b/pkg/arvo/sys/vane/jael.hoon @@ -272,7 +272,7 @@ :: =seed :: spon=ship :: czar=(map ship [=rift =life =pass]) - :: turf=(list turf)} + :: turf=(list turf) :: bloq=@ud :: node=purl :: == @@ -433,7 +433,7 @@ (sources:~(feel su hen our now pki etn) [whos source]:tac) :: :: cancel all trackers from duct - :: {%nuke whos=(set ship)} + :: [%nuke whos=(set ship)] :: %nuke =/ ships=(list ship) @@ -522,13 +522,13 @@ +>.$ :: :: watch private keys - :: {%private-keys ~} + :: [%private-keys ~] :: %private-keys (curd abet:~(private-keys ~(feed su hen our now pki etn) hen)) :: :: authenticated remote request - :: {%west p=ship q=path r=*} + :: [%west p=ship q=path r=*] :: %plea =* her ship.tac @@ -656,7 +656,7 @@ +>.$(moz [move moz]) :: ++ exec :: mass gift - |= {yen=(set duct) cad=card} + |= [yen=(set duct) cad=card] =/ noy ~(tap in yen) |- ^+ this-su ?~ noy this-su diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index 31b8c7d7d1..23390af674 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -471,14 +471,14 @@ ++ acru $_ ^? :: asym cryptosuite |% :: opaque object ++ as ^? :: asym ops - |% ++ seal |~({a=pass b=@} *@) :: encrypt to a + |% ++ seal |~([a=pass b=@] *@) :: encrypt to a ++ sign |~(a=@ *@) :: certify as us ++ sure |~(a=@ *(unit @)) :: authenticate from us - ++ tear |~({a=pass b=@} *(unit @)) :: accept from a + ++ tear |~([a=pass b=@] *(unit @)) :: accept from a -- ::as :: - ++ de |~({a=@ b=@} *(unit @)) :: symmetric de, soft - ++ dy |~({a=@ b=@} *@) :: symmetric de, hard - ++ en |~({a=@ b=@} *@) :: symmetric en + ++ de |~([a=@ b=@] *(unit @)) :: symmetric de, soft + ++ dy |~([a=@ b=@] *@) :: symmetric de, hard + ++ en |~([a=@ b=@] *@) :: symmetric en ++ ex ^? :: export |% ++ fig *@uvH :: fingerprint ++ pac *@uvG :: default passcode @@ -486,7 +486,7 @@ ++ sec *ring :: private key -- ::ex :: ++ nu ^? :: reconstructors - |% ++ pit |~({a=@ b=@} ^?(..nu)) :: from [width seed] + |% ++ pit |~([a=@ b=@] ^?(..nu)) :: from [width seed] ++ nol |~(a=ring ^?(..nu)) :: from ring ++ com |~(a=pass ^?(..nu)) :: from pass -- ::nu :: @@ -780,13 +780,13 @@ :: :::: ++ able ^? |% - ++ gift :: out result <-$ + +$ gift :: out result <-$ $% [%doze p=(unit @da)] :: next alarm [%wake error=(unit tang)] :: wakeup or failed [%meta p=vase] [%heck syn=sign-arvo] :: response to %huck == - ++ task :: in request ->$ + +$ task :: in request ->$ $~ [%vega ~] :: $% $>(%born vane-task) :: new unix process $>(%crud vane-task) :: error with trace @@ -810,64 +810,64 @@ :: :::: ++ able ^? |% - ++ gift :: out result <-$ + +$ gift :: out result <-$ $% [%boon payload=*] :: ames response - {%croz rus=(map desk {r=regs w=regs})} :: rules for group - {%cruz cez=(map @ta crew)} :: permission groups - {%dirk p=@tas} :: mark mount dirty - {%ergo p=@tas q=mode} :: version update - {%hill p=(list @tas)} :: mount points + [%croz rus=(map desk [r=regs w=regs])] :: rules for group + [%cruz cez=(map @ta crew)] :: permission groups + [%dirk p=@tas] :: mark mount dirty + [%ergo p=@tas q=mode] :: version update + [%hill p=(list @tas)] :: mount points [%done error=(unit error:ames)] :: ames message (n)ack - {%mere p=(each (set path) (pair term tang))} :: merge result - {%note p=@tD q=tank} :: debug message - {%ogre p=@tas} :: delete mount point - {%rule red=dict wit=dict} :: node r+w permissions - {%writ p=riot} :: response - {%wris p={%da p=@da} q=(set (pair care path))} :: many changes + [%mere p=(each (set path) (pair term tang))] :: merge result + [%note p=@tD q=tank] :: debug message + [%ogre p=@tas] :: delete mount point + [%rule red=dict wit=dict] :: node r+w permissions + [%writ p=riot] :: response + [%wris p=[%da p=@da] q=(set (pair care path))] :: many changes == :: - ++ task :: in request ->$ + +$ task :: in request ->$ $~ [%vega ~] :: - $% {%boat ~} :: pier rebooted - {%cred nom=@ta cew=crew} :: set permission group - {%crew ~} :: permission groups - {%crow nom=@ta} :: group usage + $% [%boat ~] :: pier rebooted + [%cred nom=@ta cew=crew] :: set permission group + [%crew ~] :: permission groups + [%crow nom=@ta] :: group usage $>(%crud vane-task) :: error with trace - {%drop des=desk} :: cancel pending merge - {%info des=desk dit=nori} :: internal edit + [%drop des=desk] :: cancel pending merge + [%info des=desk dit=nori] :: internal edit $>(%init vane-task) :: report install - {%into des=desk all=? fis=mode} :: external edit + [%into des=desk all=? fis=mode] :: external edit $: %merg :: merge desks des=desk :: target her=@p dem=desk cas=case :: source how=germ :: method == :: - {%mont pot=term bem=beam} :: mount to unix - {%dirk des=desk} :: mark mount dirty - {%ogre pot=$@(desk beam)} :: delete mount point - {%park des=desk yok=yoki ran=rang} :: synchronous commit - {%perm des=desk pax=path rit=rite} :: change permissions - {%pork ~} :: resume commit + [%mont pot=term bem=beam] :: mount to unix + [%dirk des=desk] :: mark mount dirty + [%ogre pot=$@(desk beam)] :: delete mount point + [%park des=desk yok=yoki ran=rang] :: synchronous commit + [%perm des=desk pax=path rit=rite] :: change permissions + [%pork ~] :: resume commit $>(%trim vane-task) :: trim state $>(%vega vane-task) :: report upgrade - {%warp wer=ship rif=riff} :: internal file req - {%werp who=ship wer=ship rif=riff-any} :: external file req + [%warp wer=ship rif=riff] :: internal file req + [%werp who=ship wer=ship rif=riff-any] :: external file req $>(%plea vane-task) :: ames request == :: -- ::able :: :::: :: (1c2) :: - ++ aeon @ud :: version number - ++ ankh :: fs node (new) + +$ aeon @ud :: version number + +$ ankh :: fs node (new) $~ [~ ~] - $: fil=(unit {p=lobe q=cage}) :: file + $: fil=(unit [p=lobe q=cage]) :: file dir=(map @ta ankh) :: folders == :: - ++ beam {{p=ship q=desk r=case} s=path} :: global name - ++ beak {p=ship q=desk r=case} :: path prefix - ++ blob :: fs blob - $% {%delta p=lobe q={p=mark q=lobe} r=page} :: delta on q - {%direct p=lobe q=page} :: immediate + +$ beam [[p=ship q=desk r=case] s=path] :: global name + +$ beak [p=ship q=desk r=case] :: path prefix + +$ blob :: fs blob + $% [%delta p=lobe q=[p=mark q=lobe] r=page] :: delta on q + [%direct p=lobe q=page] :: immediate == :: :: +cable: a reference to something on the filesystem :: face: the face to wrap around the imported file @@ -876,22 +876,22 @@ $: face=(unit term) file-path=term == - ++ care ?(%a %b %c %d %p %r %s %t %u %v %w %x %y %z) :: clay submode - ++ case :: ship desk case spur - $% {%da p=@da} :: date - {%tas p=@tas} :: label - {%ud p=@ud} :: number + +$ care ?(%a %b %c %d %p %r %s %t %u %v %w %x %y %z) :: clay submode + +$ case :: ship desk case spur + $% [%da p=@da] :: date + [%tas p=@tas] :: label + [%ud p=@ud] :: number == :: - ++ cass {ud=@ud da=@da} :: cases for revision - ++ crew (set ship) :: permissions group - ++ dict {src=path rul=real} :: effective permission - ++ dome :: project state + +$ cass [ud=@ud da=@da] :: cases for revision + +$ crew (set ship) :: permissions group + +$ dict [src=path rul=real] :: effective permission + +$ dome :: project state $: ank=ankh :: state let=@ud :: top id hit=(map @ud tako) :: changes by id lab=(map @tas @ud) :: labels == :: - ++ germ :: merge style + +$ germ :: merge style $? %init :: new desk %fine :: fast forward %meet :: orthogonal files @@ -904,86 +904,86 @@ %meet-this :: ours if conflict %meet-that :: hers if conflict == :: - ++ lobe @uvI :: blob ref - ++ maki {p=@ta q=@ta r=@ta s=path} :: - ++ miso :: ankh delta - $% {%del ~} :: delete - {%ins p=cage} :: insert - {%dif p=cage} :: mutate from diff - {%mut p=cage} :: mutate from raw + +$ lobe @uvI :: blob ref + +$ maki [p=@ta q=@ta r=@ta s=path] :: + +$ miso :: ankh delta + $% [%del ~] :: delete + [%ins p=cage] :: insert + [%dif p=cage] :: mutate from diff + [%mut p=cage] :: mutate from raw == :: - ++ misu :: computed delta - $% {%del ~} :: delete - {%ins p=cage} :: insert - {%dif p=lobe q=cage} :: mutate from diff + +$ misu :: computed delta + $% [%del ~] :: delete + [%ins p=cage] :: insert + [%dif p=lobe q=cage] :: mutate from diff == :: - ++ mizu {p=@u q=(map @ud tako) r=rang} :: new state - ++ moar {p=@ud q=@ud} :: normal change range + +$ mizu [p=@u q=(map @ud tako) r=rang] :: new state + +$ moar [p=@ud q=@ud] :: normal change range +$ moat [from=case to=case =path] :: change range - ++ mode (list {path (unit mime)}) :: external files + +$ mode (list [path (unit mime)]) :: external files +$ mood [=care =case =path] :: request in desk +$ mool [=case paths=(set (pair care path))] :: requests in desk - ++ nori :: repository action - $% {%& p=soba} :: delta - {%| p=@tas} :: label + +$ nori :: repository action + $% [%& p=soba] :: delta + [%| p=@tas] :: label == :: - ++ nuri :: repository action - $% {%& p=suba} :: delta - {%| p=@tas} :: label + +$ nuri :: repository action + $% [%& p=suba] :: delta + [%| p=@tas] :: label == :: - ++ open $-(path vase) :: get prelude - ++ page (cask *) :: untyped cage - ++ plop blob :: unvalidated blob - ++ rang :: repository + +$ open $-(path vase) :: get prelude + +$ page (cask *) :: untyped cage + +$ plop blob :: unvalidated blob + +$ rang :: repository $: hut=(map tako yaki) :: changes lat=(map lobe blob) :: data == :: - ++ rant :: response to request - $: p={p=care q=case r=desk} :: clade release book + +$ rant :: response to request + $: p=[p=care q=case r=desk] :: clade release book q=path :: spur r=cage :: data == :: - ++ rave :: general request + +$ rave :: general request $% [%sing =mood] :: single request [%next =mood] :: await next version [%mult =mool] :: next version of any [%many track=? =moat] :: track range == :: - ++ real :: resolved permissions + +$ real :: resolved permissions $: mod=?(%black %white) :: who=(pair (set ship) (map @ta crew)) :: == :: - ++ regs (map path rule) :: rules for paths + +$ regs (map path rule) :: rules for paths +$ riff [p=desk q=(unit rave)] :: request+desist +$ riff-any $^ [[%1 ~] riff] riff - ++ rite :: new permissions - $% {%r red=(unit rule)} :: for read - {%w wit=(unit rule)} :: for write - {%rw red=(unit rule) wit=(unit rule)} :: for read and write + +$ rite :: new permissions + $% [%r red=(unit rule)] :: for read + [%w wit=(unit rule)] :: for write + [%rw red=(unit rule) wit=(unit rule)] :: for read and write == :: - ++ riot (unit rant) :: response+complete - ++ rule {mod=?(%black %white) who=(set whom)} :: node permission - ++ rump {p=care q=case r=@tas s=path} :: relative path - ++ saba {p=ship q=@tas r=moar s=dome} :: patch+merge - ++ soba (list {p=path q=miso}) :: delta - ++ suba (list {p=path q=misu}) :: delta - ++ tako @ :: yaki ref - ++ toro {p=@ta q=nori} :: general change + +$ riot (unit rant) :: response+complete + +$ rule [mod=?(%black %white) who=(set whom)] :: node permission + +$ rump [p=care q=case r=@tas s=path] :: relative path + +$ saba [p=ship q=@tas r=moar s=dome] :: patch+merge + +$ soba (list [p=path q=miso]) :: delta + +$ suba (list [p=path q=misu]) :: delta + +$ tako @ :: yaki ref + +$ toro [p=@ta q=nori] :: general change ++ unce :: change part |* a=mold :: - $% {%& p=@ud} :: skip[copy] - {%| p=(list a) q=(list a)} :: p -> q[chunk] + $% [%& p=@ud] :: skip[copy] + [%| p=(list a) q=(list a)] :: p -> q[chunk] == :: ++ urge |*(a=mold (list (unce a))) :: list change - ++ whom (each ship @ta) :: ship or named crew - ++ yoki (each yuki yaki) :: commit - ++ yuki :: proto-commit + +$ whom (each ship @ta) :: ship or named crew + +$ yoki (each yuki yaki) :: commit + +$ yuki :: proto-commit $: p=(list tako) :: parents q=(map path (each page lobe)) :: namespace == :: - ++ yaki :: commit + +$ yaki :: commit $: p=(list tako) :: parents q=(map path lobe) :: namespace r=tako :: self-reference @@ -997,7 +997,7 @@ :: +make-yaki: make commit out of a list of parents, content, and date. :: ++ make-yaki - |= {p=(list tako) q=(map path lobe) t=@da} + |= [p=(list tako) q=(map path lobe) t=@da] ^- yaki =+ ^= has %^ cat 7 (sham [%yaki (roll p add) q t]) @@ -1091,110 +1091,110 @@ :: :::: ++ able ^? |% - ++ gift :: out result <-$ - $% {%bbye ~} :: reset prompt - {%blit p=(list blit)} :: terminal output - {%burl p=@t} :: activate url - {%init p=@p} :: set owner - {%logo ~} :: logout + +$ gift :: out result <-$ + $% [%bbye ~] :: reset prompt + [%blit p=(list blit)] :: terminal output + [%burl p=@t] :: activate url + [%init p=@p] :: set owner + [%logo ~] :: logout [%lyra hoon=(unit @t) arvo=@t] :: upgrade kernel - {%meld ~} :: unify memory - {%pack ~} :: compact memory - {%trim p=@ud} :: trim kernel state - {%veer p=@ta q=path r=@t} :: install vane - {%verb ~} :: verbose mode + [%meld ~] :: unify memory + [%pack ~] :: compact memory + [%trim p=@ud] :: trim kernel state + [%veer p=@ta q=path r=@t] :: install vane + [%verb ~] :: verbose mode [%whey ~] :: memory report == :: - ++ task :: in request ->$ + +$ task :: in request ->$ $~ [%vega ~] :: - $% {%belt p=belt} :: terminal input - {%blew p=blew} :: terminal config - {%boot lit=? p=*} :: weird %dill boot - {%crop p=@ud} :: trim kernel state + $% [%belt p=belt] :: terminal input + [%blew p=blew] :: terminal config + [%boot lit=? p=*] :: weird %dill boot + [%crop p=@ud] :: trim kernel state $>(%crud vane-task) :: error with trace [%flee session=~] :: unwatch session - {%flog p=flog} :: wrapped error - {%flow p=@tas q=(list gill:gall)} :: terminal config - {%hail ~} :: terminal refresh - {%heft ~} :: memory report - {%hook ~} :: this term hung up - {%harm ~} :: all terms hung up + [%flog p=flog] :: wrapped error + [%flow p=@tas q=(list gill:gall)] :: terminal config + [%hail ~] :: terminal refresh + [%heft ~] :: memory report + [%hook ~] :: this term hung up + [%harm ~] :: all terms hung up $>(%init vane-task) :: after gall ready [%lyra hoon=(unit @t) arvo=@t] :: upgrade kernel - {%meld ~} :: unify memory - {%noop ~} :: no operation - {%pack ~} :: compact memory - {%talk p=tank} :: - {%text p=tape} :: - {%veer p=@ta q=path r=@t} :: install vane + [%meld ~] :: unify memory + [%noop ~] :: no operation + [%pack ~] :: compact memory + [%talk p=tank] :: + [%text p=tape] :: + [%veer p=@ta q=path r=@t] :: install vane [%view session=~] :: watch session blits $>(%trim vane-task) :: trim state $>(%vega vane-task) :: report upgrade - {%verb ~} :: verbose mode + [%verb ~] :: verbose mode [%knob tag=term level=?(%hush %soft %loud)] :: error verbosity == :: -- ::able :: :::: :: (1d2) :: - ++ blew {p=@ud q=@ud} :: columns rows - ++ belt :: old belt - $% {%aro p=?(%d %l %r %u)} :: arrow key - {%bac ~} :: true backspace - {%ctl p=@c} :: control-key - {%del ~} :: true delete - {%met p=@c} :: meta-key - {%ret ~} :: return - {%txt p=(list @c)} :: utf32 text + +$ blew [p=@ud q=@ud] :: columns rows + +$ belt :: old belt + $% [%aro p=?(%d %l %r %u)] :: arrow key + [%bac ~] :: true backspace + [%ctl p=@c] :: control-key + [%del ~] :: true delete + [%met p=@c] :: meta-key + [%ret ~] :: return + [%txt p=(list @c)] :: utf32 text == :: - ++ blit :: old blit - $% {%bel ~} :: make a noise - {%clr ~} :: clear the screen - {%hop p=@ud} :: set cursor position + +$ blit :: old blit + $% [%bel ~] :: make a noise + [%clr ~] :: clear the screen + [%hop p=@ud] :: set cursor position [%klr p=stub] :: set styled line - {%lin p=(list @c)} :: set current line - {%mor ~} :: newline - {%sag p=path q=*} :: save to jamfile - {%sav p=path q=@} :: save to file - {%url p=@t} :: activate url + [%lin p=(list @c)] :: set current line + [%mor ~] :: newline + [%sag p=path q=*] :: save to jamfile + [%sav p=path q=@] :: save to file + [%url p=@t] :: activate url == :: - ++ dill-belt :: new belt - $% {%aro p=?(%d %l %r %u)} :: arrow key - {%bac ~} :: true backspace - {%cru p=@tas q=(list tank)} :: echo error - {%ctl p=@} :: control-key - {%del ~} :: true delete - {%hey ~} :: refresh - {%met p=@} :: meta-key - {%ret ~} :: return - {%rez p=@ud q=@ud} :: resize, cols, rows - {%txt p=(list @c)} :: utf32 text - {%yow p=gill:gall} :: connect to app + +$ dill-belt :: new belt + $% [%aro p=?(%d %l %r %u)] :: arrow key + [%bac ~] :: true backspace + [%cru p=@tas q=(list tank)] :: echo error + [%ctl p=@] :: control-key + [%del ~] :: true delete + [%hey ~] :: refresh + [%met p=@] :: meta-key + [%ret ~] :: return + [%rez p=@ud q=@ud] :: resize, cols, rows + [%txt p=(list @c)] :: utf32 text + [%yow p=gill:gall] :: connect to app == :: - ++ dill-blit :: new blit - $% {%bel ~} :: make a noise - {%clr ~} :: clear the screen - {%hop p=@ud} :: set cursor position - {%klr p=stub} :: styled text - {%mor p=(list dill-blit)} :: multiple blits - {%pom p=stub} :: styled prompt - {%pro p=(list @c)} :: show as cursor+line - {%qit ~} :: close console - {%out p=(list @c)} :: send output line - {%sag p=path q=*} :: save to jamfile - {%sav p=path q=@} :: save to file - {%url p=@t} :: activate url + +$ dill-blit :: new blit + $% [%bel ~] :: make a noise + [%clr ~] :: clear the screen + [%hop p=@ud] :: set cursor position + [%klr p=stub] :: styled text + [%mor p=(list dill-blit)] :: multiple blits + [%pom p=stub] :: styled prompt + [%pro p=(list @c)] :: show as cursor+line + [%qit ~] :: close console + [%out p=(list @c)] :: send output line + [%sag p=path q=*] :: save to jamfile + [%sav p=path q=@] :: save to file + [%url p=@t] :: activate url == :: - ++ flog :: sent to %dill - $% {%crop p=@ud} :: trim kernel state - {%crud p=@tas q=(list tank)} :: - {%heft ~} :: + +$ flog :: sent to %dill + $% [%crop p=@ud] :: trim kernel state + [%crud p=@tas q=(list tank)] :: + [%heft ~] :: [%lyra hoon=(unit @t) arvo=@t] :: upgrade kernel - {%meld ~} :: unify memory - {%pack ~} :: compact memory - {%text p=tape} :: - {%veer p=@ta q=path r=@t} :: install vane - {%verb ~} :: verbose mode + [%meld ~] :: unify memory + [%pack ~] :: compact memory + [%text p=tape] :: + [%veer p=@ta q=path r=@t] :: install vane + [%verb ~] :: verbose mode == :: -- ::dill :: :::: @@ -1204,7 +1204,7 @@ |% ++ able |% - ++ gift + +$ gift $% :: set-config: configures the external http server :: :: TODO: We need to actually return a (map (unit @t) http-config) @@ -1222,7 +1222,7 @@ [%bound accepted=? =binding] == :: - ++ task + +$ task $~ [%vega ~] $% :: event failure notification :: @@ -1528,7 +1528,7 @@ =request:http == :: - ++ cred :: credential + +$ cred :: credential $: hut=hart :: client host aut=(jug @tas @t) :: client identities orx=oryx :: CSRF secret @@ -1536,28 +1536,28 @@ cip=(each @if @is) :: client IP cum=(map @tas *) :: custom dirt == :: - ++ epic :: FCGI parameters + +$ epic :: FCGI parameters $: qix=(map @t @t) :: query ced=cred :: client credentials bem=beam :: original path == :: :: - ++ hart {p=? q=(unit @ud) r=host} :: http sec+port+host - ++ hate {p=purl q=@p r=moth} :: semi-cooked request - ++ hiss {p=purl q=moth} :: outbound request - ++ host (each turf @if) :: http host - ++ hoke %+ each {%localhost ~} :: local host + +$ hart [p=? q=(unit @ud) r=host] :: http sec+port+host + +$ hate [p=purl q=@p r=moth] :: semi-cooked request + +$ hiss [p=purl q=moth] :: outbound request + +$ host (each turf @if) :: http host + +$ hoke %+ each [%localhost ~] :: local host ?(%.0.0.0.0 %.127.0.0.1) :: - ++ httq :: raw http request + +$ httq :: raw http request $: p=meth :: method q=@t :: unparsed url - r=(list {p=@t q=@t}) :: headers + r=(list [p=@t q=@t]) :: headers s=(unit octs) :: body == :: - ++ httr {p=@ud q=mess r=(unit octs)} :: raw http response - ++ math (map @t (list @t)) :: semiparsed headers - ++ mess (list {p=@t q=@t}) :: raw http headers - ++ meth :: http methods + +$ httr [p=@ud q=mess r=(unit octs)] :: raw http response + +$ math (map @t (list @t)) :: semiparsed headers + +$ mess (list [p=@t q=@t]) :: raw http headers + +$ meth :: http methods $? %conn :: CONNECT %delt :: DELETE %get :: GET @@ -1567,9 +1567,9 @@ %put :: PUT %trac :: TRACE == :: - ++ moth {p=meth q=math r=(unit octs)} :: http operation - ++ oryx @t :: CSRF secret - ++ pork {p=(unit @ta) q=(list @t)} :: fully parsed url + +$ moth [p=meth q=math r=(unit octs)] :: http operation + +$ oryx @t :: CSRF secret + +$ pork [p=(unit @ta) q=(list @t)] :: fully parsed url :: +prox: proxy notification :: :: Used on both the proxy (ward) and upstream sides for @@ -1586,13 +1586,13 @@ :: non=@uvJ == - ++ purf (pair purl (unit @t)) :: url with fragment - ++ purl {p=hart q=pork r=quay} :: parsed url - ++ quay (list {p=@t q=@t}) :: parsed url query - ++ quer |-($@(~ {p=@t q=@t t=$})) :: query tree - ++ quri :: request-uri - $% {%& p=purl} :: absolute - {%| p=pork q=quay} :: relative + +$ purf (pair purl (unit @t)) :: url with fragment + +$ purl [p=hart q=pork r=quay] :: parsed url + +$ quay (list [p=@t q=@t]) :: parsed url query + ++ quer |-($@(~ [p=@t q=@t t=$])) :: query tree + +$ quri :: request-uri + $% [%& p=purl] :: absolute + [%| p=pork q=quay] :: relative == :: :: +reserved: check if an ipv4 address is in a reserved range :: @@ -1692,8 +1692,8 @@ ++ het (bass 16 (stun [1 4] six:ab)) -- :: - ++ rout {p=(list host) q=path r=oryx s=path} :: http route (new) - ++ user knot :: username + +$ rout [p=(list host) q=path r=oryx s=path] :: http route (new) + +$ user knot :: username -- ::eyre :: :::: :::: ++gall :: (1g) extensions @@ -1705,13 +1705,13 @@ :: :::: ++ able ^? |% - ++ gift :: outgoing result + +$ gift :: outgoing result $% [%boon payload=*] :: ames response [%done error=(unit error:ames)] :: ames message (n)ack [%onto p=(each suss tang)] :: about agent [%unto p=sign:agent] :: == :: - ++ task :: incoming request + +$ task :: incoming request $~ [%vega ~] :: $% [%conf dap=term] :: start agent [%deal p=sock q=term r=deal] :: full transmission @@ -1723,11 +1723,11 @@ $>(%plea vane-task) :: network request == :: -- ::able - ++ bitt (map duct (pair ship path)) :: incoming subs - ++ boat :: outgoing subs - %+ map ,[=wire =ship =term] :: - ,[acked=? =path] :: - ++ bowl :: standard app state + +$ bitt (map duct (pair ship path)) :: incoming subs + +$ boat :: outgoing subs + %+ map [=wire =ship =term] :: + [acked=? =path] :: + +$ bowl :: standard app state $: $: our=ship :: host src=ship :: guest dap=term :: agent @@ -1740,16 +1740,16 @@ now=@da :: current time byk=beak :: load source == == :: - ++ dude term :: server identity - ++ gill (pair ship term) :: general contact - ++ scar :: opaque duct + +$ dude term :: server identity + +$ gill (pair ship term) :: general contact + +$ scar :: opaque duct $: p=@ud :: bone sequence q=(map duct bone) :: by duct r=(map bone duct) :: by bone == :: - ++ suss (trel dude @tas @da) :: config report - ++ well (pair desk term) :: - ++ neat + +$ suss (trel dude @tas @da) :: config report + +$ well (pair desk term) :: + +$ neat $% [%arvo =note-arvo] [%agent [=ship name=term] =deal] == @@ -1839,7 +1839,7 @@ |% :: +gift: effects the client can emit :: - ++ gift + +$ gift $% :: %request: outbound http-request to earth :: :: TODO: id is sort of wrong for this interface; the duct should @@ -1854,7 +1854,7 @@ [%http-response =client-response] == :: - ++ task + +$ task $~ [%vega ~] $% :: event failure notification :: @@ -1958,7 +1958,7 @@ [%breach who=ship] == :: :: - ++ gift :: out result <-$ + +$ gift :: out result <-$ $% [%init p=ship] :: report install unix [%done error=(unit error:ames)] :: ames message (n)ack [%boon payload=*] :: ames response @@ -2161,14 +2161,14 @@ :: bit is set, the new life of this ship may have :: lost information that the old life had. :: - ++ hand @uvH :: 128-bit hash - ++ mind {who=ship lyf=life} :: key identifier - ++ name (pair @ta @t) :: ascii / unicode - ++ oath @ :: signature + +$ hand @uvH :: 128-bit hash + +$ mind [who=ship lyf=life] :: key identifier + +$ name (pair @ta @t) :: ascii / unicode + +$ oath @ :: signature -- :: pki -- :: jael :: -++ gift-arvo :: out result <-$ ++$ gift-arvo :: out result <-$ $~ [%init ~zod] $% gift:able:ames gift:able:behn @@ -2179,7 +2179,7 @@ gift:able:iris gift:able:jael == -++ task-arvo :: in request ->$ ++$ task-arvo :: in request ->$ $% task:able:ames task:able:clay task:able:behn @@ -2189,20 +2189,20 @@ task:able:iris task:able:jael == -++ note-arvo :: out request $-> ++$ note-arvo :: out request $-> $~ [%b %wake ~] - $% {%a task:able:ames} - {%b task:able:behn} - {%c task:able:clay} - {%d task:able:dill} + $% [%a task:able:ames] + [%b task:able:behn] + [%c task:able:clay] + [%d task:able:dill] [%e task:able:eyre] - {%g task:able:gall} + [%g task:able:gall] [%i task:able:iris] - {%j task:able:jael} - {@tas %meta vase} + [%j task:able:jael] + [@tas %meta vase] == -++ sign-arvo :: in result $<- - $% {%a gift:able:ames} ++$ sign-arvo :: in result $<- + $% [%a gift:able:ames] $: %b $% gift:able:behn $>(%wris gift:able:clay) @@ -2211,12 +2211,12 @@ $>(%unto gift:able:gall) == == - {%c gift:able:clay} - {%d gift:able:dill} + [%c gift:able:clay] + [%d gift:able:dill] [%e gift:able:eyre] - {%g gift:able:gall} + [%g gift:able:gall] [%i gift:able:iris] - {%j gift:able:jael} + [%j gift:able:jael] == :: $unix-task: input from unix :: @@ -2280,32 +2280,32 @@ |% :: :: ++fu:number ++ fu :: modulo (mul p q) - |= a={p=@ q=@} + |= a=[p=@ q=@] =+ b=?:(=([0 0] a) 0 (~(inv fo p.a) (~(sit fo p.a) q.a))) |% :: :: ++dif:fu:number ++ dif :: subtract - |= {c={@ @} d={@ @}} + |= [c=[@ @] d=[@ @]] [(~(dif fo p.a) -.c -.d) (~(dif fo q.a) +.c +.d)] :: :: ++exp:fu:number ++ exp :: exponent - |= {c=@ d={@ @}} + |= [c=@ d=[@ @]] :- (~(exp fo p.a) (mod c (dec p.a)) -.d) (~(exp fo q.a) (mod c (dec q.a)) +.d) :: :: ++out:fu:number ++ out :: garner's formula - |= c={@ @} + |= c=[@ @] %+ add +.c %+ mul q.a %+ ~(pro fo p.a) b (~(dif fo p.a) -.c (~(sit fo p.a) +.c)) :: :: ++pro:fu:number ++ pro :: multiply - |= {c={@ @} d={@ @}} + |= [c=[@ @] d=[@ @]] [(~(pro fo p.a) -.c -.d) (~(pro fo q.a) +.c +.d)] :: :: ++sum:fu:number ++ sum :: add - |= {c={@ @} d={@ @}} + |= [c=[@ @] d=[@ @]] [(~(sum fo p.a) -.c -.d) (~(sum fo q.a) +.c +.d)] :: :: ++sit:fu:number ++ sit :: represent @@ -2326,7 +2326,7 @@ | =+ ^= b =+ [s=(dec a) t=0] - |- ^- {s=@ t=@} + |- ^- [s=@ t=@] ?: =(0 (end 0 1 s)) $(s (rsh 0 1 s), t +(t)) [s t] @@ -2350,7 +2350,7 @@ == :: :: ++ramp:number ++ ramp :: make r-m prime - |= {a=@ b=(list @) c=@} ^- @ux :: {bits snags seed} + |= [a=@ b=(list @) c=@] ^- @ux :: [bits snags seed] => .(c (shas %ramp c)) =+ d=*@ |- @@ -2362,7 +2362,7 @@ $(c +(c), d (shax d)) :: :: ++curt:number ++ curt :: curve25519 - |= {a=@ b=@} + |= [a=@ b=@] => %= . + => + @@ -2385,7 +2385,7 @@ |=(a=@ (~(exp fo q) (sub q 2) a)) :: :: ++cad:curt:number ++ cad :: - |= {n={x=@ z=@} m={x=@ z=@} d={x=@ z=@}} + |= [n=[x=@ z=@] m=[x=@ z=@] d=[x=@ z=@]] =+ ^= xx ;: mul 4 z.d %- sqr %- abs:si @@ -2403,7 +2403,7 @@ [(sit.fq xx) (sit.fq zz)] :: :: ++cub:curt:number ++ cub :: - |= {x=@ z=@} + |= [x=@ z=@] =+ ^= xx %+ mul %- sqr %- abs:si @@ -2430,13 +2430,13 @@ $(i (dec i), r (cad r s one), s (cub s)) :: :: ++ga:number ++ ga :: GF (bex p.a) - |= a={p=@ q=@ r=@} :: dim poly gen + |= a=[p=@ q=@ r=@] :: dim poly gen =+ si=(bex p.a) =+ ma=(dec si) => |% :: :: ++dif:ga:number ++ dif :: add and sub - |= {b=@ c=@} + |= [b=@ c=@] ~| [%dif-ga a] ?> &((lth b si) (lth c si)) (mix b c) @@ -2450,7 +2450,7 @@ (lsh 0 1 b) :: :: ++pro:ga:number ++ pro :: slow multiply - |= {b=@ c=@} + |= [b=@ c=@] ?: =(0 b) 0 ?: =(1 (dis 1 b)) @@ -2459,7 +2459,7 @@ :: :: ++toe:ga:number ++ toe :: exp+log tables =+ ^= nu - |= {b=@ c=@} + |= [b=@ c=@] ^- (map @ @) =+ d=*(map @ @) |- @@ -2471,7 +2471,7 @@ == =+ [p=(nu 0 (bex p.a)) q=(nu ma ma)] =+ [b=1 c=0] - |- ^- {p=(map @ @) q=(map @ @)} + |- ^- [p=(map @ @) q=(map @ @)] ?: =(ma c) [(~(put by p) c b) q] %= $ @@ -2489,7 +2489,7 @@ |% :: :: ++fra:ga:number ++ fra :: divide - |= {b=@ c=@} + |= [b=@ c=@] (pro b (inv c)) :: :: ++inv:ga:number ++ inv :: invert @@ -2501,7 +2501,7 @@ (need d) :: :: ++pow:ga:number ++ pow :: exponent - |= {b=@ c=@} + |= [b=@ c=@] =+ [d=1 e=c f=0] |- ?: =(p.a f) @@ -2511,7 +2511,7 @@ $(e (pro e e), f +(f)) :: :: ++pro:ga:number ++ pro :: multiply - |= {b=@ c=@} + |= [b=@ c=@] ~| [%pro-ga a] =+ d=(~(get by q) b) ?~ d 0 @@ -2536,16 +2536,16 @@ |% :: :: ++ahem:aes:crypto ++ ahem :: kernel state - |= {nnk=@ nnb=@ nnr=@} + |= [nnk=@ nnb=@ nnr=@] => =+ => [gr=(ga 8 0x11b 3) few==>(fe .(a 5))] [pro=pro.gr dif=dif.gr pow=pow.gr ror=ror.few] => |% :: ++ cipa $_ ^? :: AES params |% - ++ co *{p=@ q=@ r=@ s=@} :: column coefficients + ++ co *[p=@ q=@ r=@ s=@] :: column coefficients ++ ix |~(a=@ *@) :: key index - ++ ro *{p=@ q=@ r=@ s=@} :: row shifts + ++ ro *[p=@ q=@ r=@ s=@] :: row shifts ++ su *@ :: s-box -- ::cipa -- :: @@ -2616,7 +2616,7 @@ -- :: :: ++mcol:ahem:aes: ++ mcol :: - |= {a=(list @) b={p=@ q=@ r=@ s=@}} + |= [a=(list @) b=[p=@ q=@ r=@ s=@]] ^- (list @) =+ c=[p=*@ q=*@ r=*@ s=*@] |- ^- (list @) @@ -2634,11 +2634,11 @@ [[p.c r.b] [q.c s.b] [r.c p.b] [s.c q.b]] [[p.c q.b] [q.c r.b] [r.c s.b] [s.c p.b]] == - |= {a={@ @} b={@ @} c={@ @} d={@ @}} + |= [a=[@ @] b=[@ @] c=[@ @] d=[@ @]] :(dif (pro a) (pro b) (pro c) (pro d)) :: :: ++pode:ahem:aes: ++ pode :: explode to block - |= {a=bloq b=@ c=@} ^- (list @) + |= [a=bloq b=@ c=@] ^- (list @) =+ d=(rip a c) =+ m=(met a c) |- @@ -2647,13 +2647,13 @@ $(m +(m), d (weld d (limo [0 ~]))) :: :: ++sube:ahem:aes: ++ sube :: s-box word - |= {a=@ b=@} ^- @ + |= [a=@ b=@] ^- @ (rep 3 (turn (pode 3 4 a) |=(c=@ (cut 3 [c 1] b)))) -- :: |% :: :: ++be:ahem:aes:crypto ++ be :: block cipher - |= {a=? b=@ c=@H} ^- @uxH + |= [a=? b=@ c=@H] ^- @uxH ~| %be-aesc => %= . + @@ -2661,18 +2661,18 @@ |% :: :: ++ankh:be:ahem:aes: ++ ankh :: - |= {a=cipa b=@ c=@} + |= [a=cipa b=@ c=@] (pode 5 nnb (cut 5 [(mul (ix.a b) nnb) nnb] c)) :: :: ++sark:be:ahem:aes: ++ sark :: - |= {c=(list @) d=(list @)} + |= [c=(list @) d=(list @)] ^- (list @) ?~ c ~ ?~ d !! [(mix i.c i.d) $(c t.c, d t.d)] :: :: ++srow:be:ahem:aes: ++ srow :: - |= {a=cipa b=(list @)} ^- (list @) + |= [a=cipa b=(list @)] ^- (list @) =+ [c=0 d=~ e=ro.a] |- ?: =(c nnb) @@ -2681,11 +2681,11 @@ %+ rep 3 %+ turn (limo [0 p.e] [1 q.e] [2 r.e] [3 s.e] ~) - |= {f=@ g=@} + |= [f=@ g=@] (cut 3 [f 1] (snag (mod (add g c) nnb) b)) :: :: ++subs:be:ahem:aes: ++ subs :: - |= {a=cipa b=(list @)} ^- (list @) + |= [a=cipa b=(list @)] ^- (list @) ?~ b ~ [(sube i.b su.a) $(b t.b)] -- @@ -2825,7 +2825,7 @@ :: :: ++cbca:aes:crypto ++ cbca :: AES-128 CBC ~% %cbca +> ~ - |_ {key=@H prv=@H} + |_ [key=@H prv=@H] :: :: ++en:cbca:aes:crypto ++ en :: encrypt ~/ %en @@ -2864,7 +2864,7 @@ :: :: ++cbcb:aes:crypto ++ cbcb :: AES-192 CBC ~% %cbcb +> ~ - |_ {key=@I prv=@H} + |_ [key=@I prv=@H] :: :: ++en:cbcb:aes:crypto ++ en :: encrypt ~/ %en @@ -2903,7 +2903,7 @@ :: :: ++cbcc:aes:crypto ++ cbcc :: AES-256 CBC ~% %cbcc +> ~ - |_ {key=@I prv=@H} + |_ [key=@I prv=@H] :: :: ++en:cbcc:aes:crypto ++ en :: encrypt ~/ %en @@ -2941,7 +2941,7 @@ -- ::cbcc :: :: ++inc:aes:crypto ++ inc :: inc. low bloq - |= {mod=bloq ctr=@H} + |= [mod=bloq ctr=@H] ^- @uxH =+ bqs=(rip mod ctr) ?~ bqs 0x1 @@ -2950,7 +2950,7 @@ :: :: ++ctra:aes:crypto ++ ctra :: AES-128 CTR ~% %ctra +> ~ - |_ {key=@H mod=bloq len=@ ctr=@H} + |_ [key=@H mod=bloq len=@ ctr=@H] :: :: ++en:ctra:aes:crypto ++ en :: encrypt ~/ %en @@ -2977,7 +2977,7 @@ :: :: ++ctrb:aes:crypto ++ ctrb :: AES-192 CTR ~% %ctrb +> ~ - |_ {key=@I mod=bloq len=@ ctr=@H} + |_ [key=@I mod=bloq len=@ ctr=@H] :: :: ++en:ctrb:aes:crypto ++ en ~/ %en @@ -3004,7 +3004,7 @@ :: :: ++ctrc:aes:crypto ++ ctrc :: AES-256 CTR ~% %ctrc +> ~ - |_ {key=@I mod=bloq len=@ ctr=@H} + |_ [key=@I mod=bloq len=@ ctr=@H] :: :: ++en:ctrc:aes:crypto ++ en :: encrypt ~/ %en @@ -3043,7 +3043,7 @@ (mix 0x87 (lsh 0 1 str)) :: :: ++mpad:aes:crypto ++ mpad :: - |= {oct=@ txt=@} + |= [oct=@ txt=@] :: :: pad message to multiple of 128 bits :: by appending 1, then 0s @@ -3060,7 +3060,7 @@ =+ l=(~(en ecba key) 0) =+ k1=(doub l) =+ k2=(doub k1) - ^- {@ux @ux} + ^- [@ux @ux] [k1 k2] :: :: ++subb:aes:crypto ++ subb :: AES-192 subkeys @@ -3068,7 +3068,7 @@ =+ l=(~(en ecbb key) 0) =+ k1=(doub l) =+ k2=(doub k1) - ^- {@ux @ux} + ^- [@ux @ux] [k1 k2] :: :: ++subc:aes:crypto ++ subc :: AES-256 subkeys @@ -3076,12 +3076,12 @@ =+ l=(~(en ecbc key) 0) =+ k1=(doub l) =+ k2=(doub k1) - ^- {@ux @ux} + ^- [@ux @ux] [k1 k2] :: :: ++maca:aes:crypto ++ maca :: AES-128 CMAC ~/ %maca - |= {key=@H oct=(unit @) txt=@} + |= [key=@H oct=(unit @) txt=@] ^- @ux =+ [sub=(suba key) len=?~(oct (met 3 txt) u.oct)] =+ ^= pdt @@ -3101,7 +3101,7 @@ :: :: ++macb:aes:crypto ++ macb :: AES-192 CMAC ~/ %macb - |= {key=@I oct=(unit @) txt=@} + |= [key=@I oct=(unit @) txt=@] ^- @ux =+ [sub=(subb key) len=?~(oct (met 3 txt) u.oct)] =+ ^= pdt @@ -3121,7 +3121,7 @@ :: :: ++macc:aes:crypto ++ macc :: AES-256 CMAC ~/ %macc - |= {key=@I oct=(unit @) txt=@} + |= [key=@I oct=(unit @) txt=@] ^- @ux =+ [sub=(subc key) len=?~(oct (met 3 txt) u.oct)] =+ ^= pdt @@ -3192,7 +3192,7 @@ :: :: ++siva:aes:crypto ++ siva :: AES-128 SIV ~% %siva +> ~ - |_ {key=@I vec=(list @)} + |_ [key=@I vec=(list @)] :: :: ++en:siva:aes:crypto ++ en :: encrypt ~/ %en @@ -3209,7 +3209,7 @@ :: :: ++de:siva:aes:crypto ++ de :: decrypt ~/ %de - |= {iv=@H len=@ txt=@} + |= [iv=@H len=@ txt=@] ^- (unit @ux) =+ [k1=(rsh 7 1 key) k2=(end 7 1 key)] =* hib (dis iv 0xffff.ffff.ffff.ffff.7fff.ffff.7fff.ffff) @@ -3222,7 +3222,7 @@ :: :: ++sivb:aes:crypto ++ sivb :: AES-192 SIV ~% %sivb +> ~ - |_ {key=@J vec=(list @)} + |_ [key=@J vec=(list @)] :: :: ++en:sivb:aes:crypto ++ en :: encrypt ~/ %en @@ -3238,7 +3238,7 @@ :: :: ++de:sivb:aes:crypto ++ de :: decrypt ~/ %de - |= {iv=@H len=@ txt=@} + |= [iv=@H len=@ txt=@] ^- (unit @ux) =+ [k1=(rsh 6 3 key) k2=(end 6 3 key)] =* hib (dis iv 0xffff.ffff.ffff.ffff.7fff.ffff.7fff.ffff) @@ -3251,7 +3251,7 @@ :: :: ++sivc:aes:crypto ++ sivc :: AES-256 SIV ~% %sivc +> ~ - |_ {key=@J vec=(list @)} + |_ [key=@J vec=(list @)] :: :: ++en:sivc:aes:crypto ++ en :: encrypt ~/ %en @@ -3268,7 +3268,7 @@ :: :: ++de:sivc:aes:crypto ++ de :: decrypt ~/ %de - |= {iv=@H len=@ txt=@} + |= [iv=@H len=@ txt=@] ^- (unit @ux) =+ [k1=(rsh 8 1 key) k2=(end 8 1 key)] =* hib (dis iv 0xffff.ffff.ffff.ffff.7fff.ffff.7fff.ffff) @@ -3310,7 +3310,7 @@ (norm x) :: :: ++ward:ed:crypto ++ ward :: edwards multiply - |= {pp={@ @} qq={@ @}} ^- {@ @} + |= [pp=[@ @] qq=[@ @]] ^- [@ @] =+ dp=:(pro.fq d -.pp -.qq +.pp +.qq) =+ ^= xt %+ pro.fq @@ -3327,7 +3327,7 @@ [xt yt] :: :: ++scam:ed:crypto ++ scam :: scalar multiply - |= {pp={@ @} e=@} ^- {@ @} + |= [pp=[@ @] e=@] ^- [@ @] ?: =(0 e) [0 1] =+ qq=$(e (div e 2)) @@ -3337,11 +3337,11 @@ qq :: :: ++etch:ed:crypto ++ etch :: encode point - |= pp={@ @} ^- @ + |= pp=[@ @] ^- @ (can 0 ~[[(sub b 1) +.pp] [1 (dis 1 -.pp)]]) :: :: ++curv:ed:crypto ++ curv :: point on curve? - |= {x=@ y=@} ^- ? + |= [x=@ y=@] ^- ? .= 0 %+ dif.fq %+ sum.fq @@ -3350,7 +3350,7 @@ (sum.fq 1 :(pro.fq d x x y y)) :: :: ++deco:ed:crypto ++ deco :: decode point - |= s=@ ^- (unit {@ @}) + |= s=@ ^- (unit [@ @]) =+ y=(cut 0 [0 (dec b)] s) =+ si=(cut 0 [(dec b) 1] s) =+ x=(xrec y) @@ -3439,7 +3439,7 @@ :: :: ++shar:ed:crypto ++ shar :: curve25519 secret ~/ %shar - |= {pub=@ sek=@} + |= [pub=@ sek=@] ^- @ux =+ exp=(shal (rsh 0 3 b) (suck sek)) =. exp (dis exp (can 0 ~[[3 0] [251 (fil 0 251 1)]])) @@ -3450,7 +3450,7 @@ :: :: ++sign:ed:crypto ++ sign :: certify ~/ %sign - |= {m=@ se=@} ^- @ + |= [m=@ se=@] ^- @ =+ sk=(suck se) =+ pk=(cut 0 [b b] sk) =+ h=(shal (rsh 0 3 b) sk) @@ -3480,7 +3480,7 @@ :: :: ++veri:ed:crypto ++ veri :: validate ~/ %veri - |= {s=@ m=@ pk=@} ^- ? + |= [s=@ m=@ pk=@] ^- ? ?: (gth (div b 4) (met 3 s)) | ?: (gth (div b 8) (met 3 pk)) | =+ cb=(rsh 0 3 b) @@ -3501,19 +3501,19 @@ |% :: :: ++sal:scr:crypto ++ sal :: salsa20 hash - |= {x=@ r=@} :: with r rounds + |= [x=@ r=@] :: with r rounds ?> =((mod r 2) 0) :: =+ few==>(fe .(a 5)) =+ ^= rot - |= {a=@ b=@} + |= [a=@ b=@] (mix (end 5 1 (lsh 0 a b)) (rsh 0 (sub 32 a) b)) =+ ^= lea - |= {a=@ b=@} + |= [a=@ b=@] (net:few (sum:few (net:few a) (net:few b))) => |% :: :: ++qr:sal:scr:crypto ++ qr :: quarterround - |= y={@ @ @ @ ~} + |= y=[@ @ @ @ ~] =+ zb=(mix &2.y (rot 7 (sum:few &1.y &4.y))) =+ zc=(mix &3.y (rot 9 (sum:few zb &1.y))) =+ zd=(mix &4.y (rot 13 (sum:few zc zb))) @@ -3521,7 +3521,7 @@ ~[za zb zc zd] :: :: ++rr:sal:scr:crypto ++ rr :: rowround - |= {y=(list @)} + |= [y=(list @)] =+ za=(qr ~[&1.y &2.y &3.y &4.y]) =+ zb=(qr ~[&6.y &7.y &8.y &5.y]) =+ zc=(qr ~[&11.y &12.y &9.y &10.y]) @@ -3533,7 +3533,7 @@ &2.zd &3.zd &4.zd &1.zd == :: :: ++cr:sal:scr:crypto ++ cr :: columnround - |= {x=(list @)} + |= [x=(list @)] =+ ya=(qr ~[&1.x &5.x &9.x &13.x]) =+ yb=(qr ~[&6.x &10.x &14.x &2.x]) =+ yc=(qr ~[&11.x &15.x &3.x &7.x]) @@ -3545,11 +3545,11 @@ &4.ya &3.yb &2.yc &1.yd == :: :: ++dr:sal:scr:crypto ++ dr :: doubleround - |= {x=(list @)} + |= [x=(list @)] (rr (cr x)) :: :: ++al:sal:scr:crypto ++ al :: add two lists - |= {a=(list @) b=(list @)} + |= [a=(list @) b=(list @)] |- ^- (list @) ?~ a ~ ?~ b ~ [i=(sum:few -.a -.b) t=$(a +.a, b +.b)] @@ -3561,7 +3561,7 @@ (rep 5 (al xw ow)) :: :: ++rpp:scr:crypto ++ rpp :: rip+filler blocks - |= {a=bloq b=@ c=@} + |= [a=bloq b=@ c=@] =+ q=(rip a c) =+ w=(lent q) ?. =(w b) @@ -3570,23 +3570,23 @@ q :: :: ++bls:scr:crypto ++ bls :: split to sublists - |= {a=@ b=(list @)} + |= [a=@ b=(list @)] ?> =((mod (lent b) a) 0) |- ^- (list (list @)) ?~ b ~ [i=(scag a `(list @)`b) t=$(b (slag a `(list @)`b))] :: :: ++slb:scr:crypto ++ slb :: - |= {a=(list (list @))} + |= [a=(list (list @))] |- ^- (list @) ?~ a ~ (weld `(list @)`-.a $(a +.a)) :: :: ++sbm:scr:crypto ++ sbm :: scryptBlockMix - |= {r=@ b=(list @)} + |= [r=@ b=(list @)] ?> =((lent b) (mul 2 r)) =+ [x=(snag (dec (mul 2 r)) b) c=0] - =| {ya=(list @) yb=(list @)} + =| [ya=(list @) yb=(list @)] |- ^- (list @) ?~ b (flop (weld yb ya)) =. x (sal (mix x -.b) 8) @@ -3595,7 +3595,7 @@ $(c +(c), b +.b, yb [i=x t=yb]) :: :: ++srm:scr:crypto ++ srm :: scryptROMix - |= {r=@ b=(list @) n=@} + |= [r=@ b=(list @) n=@] ?> ?& =((lent b) (mul 2 r)) =(n (bex (dec (xeb n)))) (lth n (bex (mul r 16))) @@ -3617,11 +3617,11 @@ $(x (sbm r w), c +(c)) :: :: ++hmc:scr:crypto ++ hmc :: HMAC-SHA-256 - |= {k=@ t=@} + |= [k=@ t=@] (hml k (met 3 k) t (met 3 t)) :: :: ++hml:scr:crypto ++ hml :: w+length - |= {k=@ kl=@ t=@ tl=@} + |= [k=@ kl=@ t=@ tl=@] => .(k (end 3 kl k), t (end 3 tl t)) =+ b=64 =? k (gth kl b) (shay kl k) @@ -3632,12 +3632,12 @@ :: :: ++pbk:scr:crypto ++ pbk :: PBKDF2-HMAC-SHA256 ~/ %pbk - |= {p=@ s=@ c=@ d=@} + |= [p=@ s=@ c=@ d=@] (pbl p (met 3 p) s (met 3 s) c d) :: :: ++pbl:scr:crypto ++ pbl :: w+length ~/ %pbl - |= {p=@ pl=@ s=@ sl=@ c=@ d=@} + |= [p=@ pl=@ s=@ sl=@ c=@ d=@] => .(p (end 3 pl p), s (end 3 sl s)) =+ h=32 :: @@ -3665,12 +3665,12 @@ :: :: ++hsh:scr:crypto ++ hsh :: scrypt ~/ %hsh - |= {p=@ s=@ n=@ r=@ z=@ d=@} + |= [p=@ s=@ n=@ r=@ z=@ d=@] (hsl p (met 3 p) s (met 3 s) n r z d) :: :: ++hsl:scr:crypto ++ hsl :: w+length ~/ %hsl - |= {p=@ pl=@ s=@ sl=@ n=@ r=@ z=@ d=@} + |= [p=@ pl=@ s=@ sl=@ n=@ r=@ z=@ d=@] =| v=(list (list @)) => .(p (end 3 pl p), s (end 3 sl s)) =+ u=(mul (mul 128 r) z) @@ -3697,7 +3697,7 @@ (pbl p pl (rep 3 (slb q)) u 1 d) :: :: ++ypt:scr:crypto ++ ypt :: 256bit {salt pass} - |= {s=@ p=@} + |= [s=@ p=@] ^- @ (hsh p s 16.384 8 1 256) -- ::scr @@ -3706,7 +3706,7 @@ :: :::: ++ crub !: ^- acru - =| {pub={cry=@ sgn=@} sek=(unit {cry=@ sgn=@})} + =| [pub=[cry=@ sgn=@] sek=(unit [cry=@ sgn=@])] |% :: :: ++as:crub:crypto ++ as :: @@ -3721,12 +3721,12 @@ ++ sure :: |= txt=@ ^- (unit @ux) - =+ ;;({sig=@ msg=@} (cue txt)) + =+ ;;([sig=@ msg=@] (cue txt)) ?. (veri:ed sig msg sgn.pub) ~ (some msg) :: :: ++seal:as:crub: ++ seal :: - |= {bpk=pass msg=@} + |= [bpk=pass msg=@] ^- @ux ?~ sek ~| %pubkey-only !! ?> =('b' (end 3 1 bpk)) @@ -3736,33 +3736,33 @@ (jam (~(en siva:aes shar ~) smsg)) :: :: ++tear:as:crub: ++ tear :: - |= {bpk=pass txt=@} + |= [bpk=pass txt=@] ^- (unit @ux) ?~ sek ~| %pubkey-only !! ?> =('b' (end 3 1 bpk)) =+ pk=(rsh 8 1 (rsh 3 1 bpk)) =+ shar=(shax (shar:ed pk cry.u.sek)) - =+ ;;({iv=@ len=@ cph=@} (cue txt)) + =+ ;;([iv=@ len=@ cph=@] (cue txt)) =+ try=(~(de siva:aes shar ~) iv len cph) ?~ try ~ (sure:as:(com:nu:crub bpk) u.try) -- ::as :: :: ++de:crub:crypto ++ de :: decrypt - |= {key=@J txt=@} + |= [key=@J txt=@] ^- (unit @ux) - =+ ;;({iv=@ len=@ cph=@} (cue txt)) + =+ ;;([iv=@ len=@ cph=@] (cue txt)) %^ ~(de sivc:aes (shaz key) ~) iv len cph :: :: ++dy:crub:crypto ++ dy :: need decrypt - |= {key=@J cph=@} + |= [key=@J cph=@] (need (de key cph)) :: :: ++en:crub:crypto ++ en :: encrypt - |= {key=@J msg=@} + |= [key=@J msg=@] ^- @ux (jam (~(en sivc:aes (shaz key) ~) msg)) :: :: ++ex:crub:crypto @@ -3792,7 +3792,7 @@ |% :: :: ++pit:nu:crub:crypto ++ pit :: create keypair - |= {w=@ seed=@} + |= [w=@ seed=@] =+ wid=(add (div w 8) ?:(=((mod w 8) 0) 0 1)) =+ bits=(shal wid seed) =+ [c=(rsh 8 1 bits) s=(end 8 1 bits)] @@ -5437,7 +5437,7 @@ :: :: ++drop-map:unity ++ drop-map :: collapse unit map |* lum=(map term (unit)) - ?: (~(rep by lum) |=({{@ a=(unit)} b=_|} |(b ?=(~ a)))) + ?: (~(rep by lum) |=([[@ a=(unit)] b=_|] |(b ?=(~ a)))) ~ (some (~(run by lum) need)) :: :: ++drop-pole:unity @@ -5505,14 +5505,14 @@ ++ de-beam :: parse path to beam |= pax=path ^- (unit beam) - ?. ?=({* * * *} pax) ~ + ?. ?=([* * * *] pax) ~ %+ biff (slaw %p i.pax) |= who=ship %+ biff (slaw %tas i.t.pax) |= dex=desk %+ biff (slay i.t.t.pax) |= cis=coin - ?. ?=({%$ case} cis) ~ + ?. ?=([%$ case] cis) ~ `(unit beam)`[~ [who dex `case`p.cis] t.t.t.pax] :: ++ json-rn :: json to rn parser @@ -5552,12 +5552,12 @@ |% :: :: ++frond:enjs:format ++ frond :: object from k-v pair - |= {p=@t q=json} + |= [p=@t q=json] ^- json [%o [[p q] ~ ~]] :: :: ++pairs:enjs:format ++ pairs :: object from k-v list - |= a=(list {p=@t q=json}) + |= a=(list [p=@t q=json]) ^- json [%o (~(gas by *(map @t json)) a)] :: :: ++tape:enjs:format @@ -5611,7 +5611,7 @@ ++ ar :: array as list |* wit=fist |= jon=json ^- (list _(wit *json)) - ?> ?=({%a *} jon) + ?> ?=([%a *] jon) (turn p.jon wit) :: :: ++as:dejs:format ++ as :: array as set @@ -5621,7 +5621,7 @@ ++ at :: array as tuple |* wil=(pole fist) |= jon=json - ?> ?=({%a *} jon) + ?> ?=([%a *] jon) ((at-raw wil) p.jon) :: :: ++at-raw:dejs:format ++ at-raw :: array as tuple @@ -5629,26 +5629,26 @@ |= jol=(list json) ?~ jol !! ?- wil :: mint-vain on empty - :: {wit=* t=*} - {* t=*} + :: {wit=* t=*] + [* t=*] => .(wil [wit *]=wil) ?~ t.wil ?^(t.jol !! (wit.wil i.jol)) [(wit.wil i.jol) ((at-raw t.wil) t.jol)] == :: :: ++bo:dejs:format ++ bo :: boolean - |=(jon=json ?>(?=({%b *} jon) p.jon)) + |=(jon=json ?>(?=([%b *] jon) p.jon)) :: :: ++bu:dejs:format ++ bu :: boolean not - |=(jon=json ?>(?=({%b *} jon) !p.jon)) + |=(jon=json ?>(?=([%b *] jon) !p.jon)) :: :: ++ci:dejs:format ++ ci :: maybe transform - |* {poq=gate wit=fist} + |* [poq=gate wit=fist] |= jon=json (need (poq (wit jon))) :: :: ++cu:dejs:format ++ cu :: transform - |* {poq=gate wit=fist} + |* [poq=gate wit=fist] |= jon=json (poq (wit jon)) :: :: ++di:dejs:format @@ -5671,20 +5671,20 @@ :: :: ++ni:dejs:format ++ ni :: number as integer |= jon=json - ?> ?=({%n *} jon) + ?> ?=([%n *] jon) (rash p.jon dem) :: :: ++no:dejs:format ++ no :: number as cord - |=(jon=json ?>(?=({%n *} jon) p.jon)) + |=(jon=json ?>(?=([%n *] jon) p.jon)) :: :: ++of:dejs:format ++ of :: object as frond - |* wer=(pole {cord fist}) + |* wer=(pole [cord fist]) |= jon=json - ?> ?=({%o {@ *} ~ ~} jon) + ?> ?=([%o [@ *] ~ ~] jon) |- ?- wer :: mint-vain on empty - :: {{key=@t wit=*} t=*} - {{key=@t *} t=*} + :: {{key=@t wit=*} t=*] + [[key=@t *] t=*] => .(wer [[* wit] *]=wer) ?: =(key.wer p.n.p.jon) [key.wer ~|(key+key.wer (wit.wer q.n.p.jon))] @@ -5693,34 +5693,34 @@ == :: :: ++ot:dejs:format ++ ot :: object as tuple - |* wer=(pole {cord fist}) + |* wer=(pole [cord fist]) |= jon=json - ?> ?=({%o *} jon) + ?> ?=([%o *] jon) ((ot-raw wer) p.jon) :: :: ++ot-raw:dejs:format ++ ot-raw :: object as tuple - |* wer=(pole {cord fist}) + |* wer=(pole [cord fist]) |= jom=(map @t json) ?- wer :: mint-vain on empty - :: {{key=@t wit=*} t=*} - {{key=@t *} t=*} + :: {{key=@t wit=*} t=*] + [[key=@t *] t=*] => .(wer [[* wit] *]=wer) =/ ten ~|(key+key.wer (wit.wer (~(got by jom) key.wer))) ?~(t.wer ten [ten ((ot-raw t.wer) jom)]) == :: ++ ou :: object of units - |* wer=(pole {cord fist}) + |* wer=(pole [cord fist]) |= jon=json - ?> ?=({%o *} jon) + ?> ?=([%o *] jon) ((ou-raw wer) p.jon) :: :: ++ou-raw:dejs:format ++ ou-raw :: object of units - |* wer=(pole {cord fist}) + |* wer=(pole [cord fist]) |= jom=(map @t json) ?- wer :: mint-vain on empty - :: {{key=@t wit=*} t=*} - {{key=@t *} t=*} + :: {{key=@t wit=*} t=*] + [[key=@t *] t=*] => .(wer [[* wit] *]=wer) =/ ten ~|(key+key.wer (wit.wer (~(get by jom) key.wer))) ?~(t.wer ten [ten ((ou-raw t.wer) jom)]) @@ -5729,16 +5729,16 @@ ++ om :: object as map |* wit=fist |= jon=json - ?> ?=({%o *} jon) + ?> ?=([%o *] jon) (~(run by p.jon) wit) :: :: ++op:dejs:format ++ op :: parse keys of map - |* {fel=rule wit=fist} + |* [fel=rule wit=fist] |= jon=json ^- (map _(wonk *fel) _*wit) =/ jom ((om wit) jon) %- malt %+ turn ~(tap by jom) - |* {a=cord b=*} + |* [a=cord b=*] => .(+< [a b]=+<) [(rash a fel) b] :: :: ++pa:dejs:format @@ -5746,11 +5746,11 @@ (su ;~(pfix fas (more fas urs:ab))) :: :: ++pe:dejs:format ++ pe :: prefix - |* {pre=* wit=fist} + |* [pre=* wit=fist] (cu |*(* [pre +<]) wit) :: :: ++sa:dejs:format ++ sa :: string as tape - |=(jon=json ?>(?=({%s *} jon) (trip p.jon))) + |=(jon=json ?>(?=([%s *] jon) (trip p.jon))) :: :: ++se:dejs:format ++ se :: string as aura |= aur=@tas @@ -5758,12 +5758,12 @@ ?>(?=([%s *] jon) (slav aur p.jon)) :: :: ++so:dejs:format ++ so :: string as cord - |=(jon=json ?>(?=({%s *} jon) p.jon)) + |=(jon=json ?>(?=([%s *] jon) p.jon)) :: :: ++su:dejs:format ++ su :: parse string |* sab=rule |= jon=json ^+ (wonk *sab) - ?> ?=({%s *} jon) + ?> ?=([%s *] jon) (rash p.jon sab) :: :: ++uf:dejs:format ++ uf :: unit fall @@ -5804,7 +5804,7 @@ :: ++ zm :: collapse unit map |* lum=(map term (unit)) - ?: (~(rep by lum) |=({{@ a=(unit)} b=_|} |(b ?=(~ a)))) + ?: (~(rep by lum) |=([[@ a=(unit)] b=_|] |(b ?=(~ a)))) ~ (some (~(run by lum) need)) -- ::dejs @@ -5823,7 +5823,7 @@ ++ ar :: array as list |* wit=fist |= jon=json - ?. ?=({%a *} jon) ~ + ?. ?=([%a *] jon) ~ %- zl |- ?~ p.jon ~ @@ -5832,7 +5832,7 @@ ++ at :: array as tuple |* wil=(pole fist) |= jon=json - ?. ?=({%a *} jon) ~ + ?. ?=([%a *] jon) ~ ?. =((lent wil) (lent p.jon)) ~ =+ raw=((at-raw wil) p.jon) ?.((za raw) ~ (some (zp raw))) @@ -5845,24 +5845,24 @@ ((at-raw +.wil) ?~(jol ~ t.jol)) :: ++ bo :: boolean - |=(jon=json ?.(?=({%b *} jon) ~ [~ u=p.jon])) + |=(jon=json ?.(?=([%b *] jon) ~ [~ u=p.jon])) :: ++ bu :: boolean not - |=(jon=json ?.(?=({%b *} jon) ~ [~ u=!p.jon])) + |=(jon=json ?.(?=([%b *] jon) ~ [~ u=!p.jon])) :: ++ ci :: maybe transform - |* {poq=gate wit=fist} + |* [poq=gate wit=fist] |= jon=json (biff (wit jon) poq) :: ++ cu :: transform - |* {poq=gate wit=fist} + |* [poq=gate wit=fist] |= jon=json (bind (wit jon) poq) :: ++ da :: UTC date |= jon=json - ?. ?=({%s *} jon) ~ + ?. ?=([%s *] jon) ~ (bind (stud:chrono:userlib p.jon) |=(a=date (year a))) :: ++ di :: millisecond date @@ -5884,18 +5884,18 @@ :: ++ ni :: number as integer |= jon=json - ?. ?=({%n *} jon) ~ + ?. ?=([%n *] jon) ~ (rush p.jon dem) :: ++ no :: number as cord |= jon=json - ?. ?=({%n *} jon) ~ + ?. ?=([%n *] jon) ~ (some p.jon) :: ++ of :: object as frond - |* wer=(pole {cord fist}) + |* wer=(pole [cord fist]) |= jon=json - ?. ?=({%o {@ *} ~ ~} jon) ~ + ?. ?=([%o [@ *] ~ ~] jon) ~ |- ?~ wer ~ ?: =(-.-.wer p.n.p.jon) @@ -5903,14 +5903,14 @@ ((of +.wer) jon) :: ++ ot :: object as tuple - |* wer=(pole {cord fist}) + |* wer=(pole [cord fist]) |= jon=json - ?. ?=({%o *} jon) ~ + ?. ?=([%o *] jon) ~ =+ raw=((ot-raw wer) p.jon) ?.((za raw) ~ (some (zp raw))) :: ++ ot-raw :: object as tuple - |* wer=(pole {cord fist}) + |* wer=(pole [cord fist]) |= jom=(map @t json) ?~ wer ~ =+ ten=(~(get by jom) -.-.wer) @@ -5919,11 +5919,11 @@ ++ om :: object as map |* wit=fist |= jon=json - ?. ?=({%o *} jon) ~ + ?. ?=([%o *] jon) ~ (zm (~(run by p.jon) wit)) :: ++ op :: parse keys of map - |* {fel=rule wit=fist} + |* [fel=rule wit=fist] %+ cu |= a=(list (pair _(wonk *fel) _(need *wit))) (my:nl a) @@ -5932,27 +5932,27 @@ ^- (unit (list _[(wonk *fel) (need *wit)])) %- zl %+ turn ~(tap by a) - |= {a=cord b=_(need *wit)} + |= [a=cord b=_(need *wit)] =+ nit=(rush a fel) ?~ nit ~ (some [u.nit b]) :: ++ pe :: prefix - |* {pre=* wit=fist} + |* [pre=* wit=fist] (cu |*(* [pre +<]) wit) :: ++ sa :: string as tape |= jon=json - ?.(?=({%s *} jon) ~ (some (trip p.jon))) + ?.(?=([%s *] jon) ~ (some (trip p.jon))) :: ++ so :: string as cord |= jon=json - ?.(?=({%s *} jon) ~ (some p.jon)) + ?.(?=([%s *] jon) ~ (some p.jon)) :: ++ su :: parse string |* sab=rule |= jon=json - ?. ?=({%s *} jon) ~ + ?. ?=([%s *] jon) ~ (rush p.jon sab) :: ++ ul |=(jon=json ?~(jon (some ~) ~)) :: null @@ -5981,7 +5981,7 @@ :: ++ zm :: collapse unit map |* lum=(map term (unit)) - ?: (~(rep by lum) |=({{@ a=(unit)} b=_|} |(b ?=(~ a)))) + ?: (~(rep by lum) |=([[@ a=(unit)] b=_|] |(b ?=(~ a)))) ~ (some (~(run by lum) need)) -- ::dejs-soft @@ -6006,7 +6006,7 @@ :: :: ++loss:differ ++ loss :: longest subsequence ~% %loss ..is ~ - |* {hel=(list) hev=(list)} + |* [hel=(list) hev=(list)] |- ^+ hev =+ ^= sev =+ [inx=0 sev=*(map _i.-.hev (list @ud))] @@ -6018,7 +6018,7 @@ inx +(inx) sev (~(put by sev) i.hev [inx ?~(guy ~ u.guy)]) == - =| gox={p=@ud q=(map @ud {p=@ud q=_hev})} + =| gox=[p=@ud q=(map @ud [p=@ud q=_hev])] =< abet =< main |% @@ -6029,19 +6029,19 @@ (flop q:(need (~(get by q.gox) (dec p.gox)))) :: :: ++hink:loss:differ ++ hink :: extend fits top - |= {inx=@ud goy=@ud} ^- ? + |= [inx=@ud goy=@ud] ^- ? ?| =(p.gox inx) (lth goy p:(need (~(get by q.gox) inx))) == :: :: ++lonk:loss:differ ++ lonk :: extend fits bottom - |= {inx=@ud goy=@ud} ^- ? + |= [inx=@ud goy=@ud] ^- ? ?| =(0 inx) (gth goy p:(need (~(get by q.gox) (dec inx)))) == :: :: ++luna:loss:differ ++ luna :: extend - |= {inx=@ud goy=@ud} + |= [inx=@ud goy=@ud] ^+ +> %_ +>.$ gox @@ -6056,7 +6056,7 @@ |= gay=(list @ud) ^+ +> =+ ^= zes - =+ [inx=0 zes=*(list {p=@ud q=@ud})] + =+ [inx=0 zes=*(list [p=@ud q=@ud])] |- ^+ zes ?: |(?=(~ gay) (gth inx p.gox)) zes ?. (lonk inx i.gay) $(gay t.gay) @@ -6074,7 +6074,7 @@ -- :: :: :: ++lurk:differ ++ lurk :: apply list patch - |* {hel=(list) rug=(urge)} + |* [hel=(list) rug=(urge)] ^+ hel =+ war=`_hel`~ |- ^+ hel @@ -6099,9 +6099,9 @@ == :: :: ++lusk:differ ++ lusk :: lcs to list patch - |* {hel=(list) hev=(list) lcs=(list)} + |* [hel=(list) hev=(list) lcs=(list)] =+ ^= rag - ^- {$%({%& p=@ud} {%| p=_lcs q=_lcs})} + ^- [$%([%& p=@ud] [%| p=_lcs q=_lcs])] [%& 0] => .(rag [p=rag q=*(list _rag)]) =< abet =< main @@ -6250,7 +6250,7 @@ |^ |=(val=json (apex val "")) :: :: ++apex:en-json:html ++ apex - |= {val=json rez=tape} + |= [val=json rez=tape] ^- tape ?~ val (weld "null" rez) ?- -.val @@ -6273,13 +6273,13 @@ |- ^- tape ?~ viz rez =+ hed=(jesc i.viz) - ?: ?=({@ ~} hed) + ?: ?=([@ ~] hed) [i.hed $(viz t.viz)] (weld hed $(viz t.viz)) :: %o :- '{' - =. rez ['}' rez] + =. rez [']' rez] =+ viz=~(tap by p.val) ?~ viz rez !. @@ -6391,7 +6391,7 @@ (star (mask [`@`9 `@`10 `@`13 ' ' ~])) :: :: ++twel:de-json:html ++ twel :: tape weld - |=({a=tape b=tape} (weld a b)) + |=([a=tape b=tape] (weld a b)) :: :: ++wish:de-json:html ++ wish :: with whitespace |*(sef=rule ;~(pfix spac sef)) @@ -6402,9 +6402,9 @@ |_ _[unq=`?`| cot=`?`|] :: :: ++apex:en-xml:html ++ apex :: top level - |= {mex=manx rez=tape} + |= [mex=manx rez=tape] ^- tape - ?: ?=({%$ {{%$ *} ~}} g.mex) + ?: ?=([%$ [[%$ *] ~]] g.mex) (escp v.i.a.g.mex rez) =+ man=`mane`n.g.mex =. unq |(unq =(%script man) =(%style man)) @@ -6420,7 +6420,7 @@ (many c.mex :(weld "" rez)) :: :: ++attr:en-xml:html ++ attr :: attributes to tape - |= {tat=mart rez=tape} + |= [tat=mart rez=tape] ^- tape ?~ tat rez =. rez $(tat t.tat) @@ -6431,7 +6431,7 @@ == :: :: ++escp:en-xml:html ++ escp :: escape for xml - |= {tex=tape rez=tape} + |= [tex=tape rez=tape] ?: unq (weld tex rez) =+ xet=`tape`(flop tex) @@ -6451,7 +6451,7 @@ == :: :: ++many:en-xml:html ++ many :: nodelist to tape - |= {lix=(list manx) rez=tape} + |= [lix=(list manx) rez=tape] |- ^- tape ?~ lix rez (apex i.lix $(lix t.lix)) @@ -6479,7 +6479,7 @@ %+ ifix [;~(plug (punt decl) (star spa)) (star spa)] ;~ pose - %+ sear |=({a=marx b=marl c=mane} ?.(=(c n.a) ~ (some [a b]))) + %+ sear |=([a=marx b=marl c=mane] ?.(=(c n.a) ~ (some [a b]))) ;~(plug head many tail) empt == @@ -6594,7 +6594,7 @@ ^- (unit tape) ?~ tep [~ ~] ?: =('%' i.tep) - ?. ?=({@ @ *} t.tep) ~ + ?. ?=([@ @ *] t.tep) ~ =+ nag=(mix i.t.tep (lsh 3 1 i.t.t.tep)) =+ val=(rush nag hex:ag) ?~ val ~ @@ -6679,7 +6679,7 @@ [1^1 (flop (trip i.rax))] ?~ q.raf [~ [i.rax ~]] - =+ `{ext=term {@ @} fyl=tape}`u.q.raf + =+ `[ext=term [@ @] fyl=tape]`u.q.raf :- `ext ?:(=(~ fyl) ~ [(crip (flop fyl)) ~]) :: :: ++apat:de-purl:html @@ -6699,8 +6699,8 @@ :: :: ++auru:de-purl:html ++ auru :: 2396 with maybe user %+ cook - |= $: a={p=? q=(unit user) r={(unit @ud) host}} - b={pork quay} + |= $: a=[p=? q=(unit user) r=[(unit @ud) host]] + b=[pork quay] == ^- (pair (unit user) purl) [q.a [[p.a r.a] b]] @@ -6781,7 +6781,7 @@ (cook crip (plus ptok)) :: :: ++thor:de-purl:html ++ thor :: 2396 host+port - %+ cook |*({* *} [+<+ +<-]) + %+ cook |*([* *] [+<+ +<-]) ;~ plug thos ;~((bend) (easy ~) ;~(pfix col dim:ag)) @@ -6853,7 +6853,7 @@ :: MOVEME :: :: ++fuel:html ++ fuel :: parse urbit fcgi - |= {bem=beam ced=noun:cred quy=quer} + |= [bem=beam ced=noun:cred quy=quer] ^- epic =+ qix=|-(`quay`?~(quy quy [[p q]:quy $(quy t.quy)])) [(malt qix) ;;(cred ced) bem] @@ -6897,22 +6897,22 @@ :: .= ~[p=~.ack q=~.~sarnel r=~..y] :: (dray ~[p=%tas q=%p r=%f] %ack ~sarnel &) :: - =- |* {a={@tas (pole @tas)} b=*} ^- (paf a) + =- |* [a=[@tas (pole @tas)] b=*] ^- (paf a) => .(b `,(tup -.a +.a)`b) ?~ +.a [(scot -.a b) ~] [(scot -.a -.b) `,(paf +.a)`(..$ +.a +.b)] - :- paf=|*(a=(pole) ?~(a ,~ {(odo:raid ,-.a(. %ta)) ,(..$ +.a)})) + :- paf=|*(a=(pole) ?~(a ,~ ,[(odo:raid ,-.a(. %ta)) ,(..$ +.a)])) ^= tup - |* {a=@tas b=(pole @tas)} + |* [a=@tas b=(pole @tas)] =+ c=(odo:raid a) - ?~(b c {c (..$ ,-.b ,+.b)}) + ?~(b c ,[c (..$ ,-.b ,+.b)]) :: :: ++raid:wired ++ raid :: demand path odors :: :: .= [p=%ack q=~sarnel r=&] :: (raid /ack/~sarnel+.y p=%tas q=%p r=%f ~) :: - =- |* {a=path b={@tas (pole @tas)}} + =- |* [a=path b=[@tas (pole @tas)]] =* fog (odo -.b) ?~ +.b `fog`(slav -.b -.a) [`fog`(slav -.b -.a) (..$ +.a +.b)] @@ -7639,7 +7639,7 @@ ^- tape =+ wey=(daws yed) =/ num (d-co:co 1) :: print as decimal without dots - =/ pik |=({n=@u t=wall} `tape`(scag 3 (snag n t))) + =/ pik |=([n=@u t=wall] `tape`(scag 3 (snag n t))) :: "{(pik wey wik:yu)}, ". "{(num d.t.yed)} {(pik (dec m.yed) mon:yu)} {(num y.yed)} ". @@ -7651,7 +7651,7 @@ |= b=(list _(wonk *elem)) ^- (unit date) =- ?.((za:dejs:format -) ~ (some (zp:dejs:format -))) ^+ =+ [*date u=unit] - *{(u _[a y]) (u _m) (u _d.t) (u _+.t) ~} + *[(u _[a y]) (u _m) (u _d.t) (u _+.t) ~] :~ |-(?~(b ~ ?.(?=(%y -.i.b) $(b t.b) `+.i.b))) |-(?~(b ~ ?.(?=(%m -.i.b) $(b t.b) `+.i.b))) @@ -7689,7 +7689,7 @@ (bass 10 (stun 1^2 dit)) :: :: ++t:stud:chrono: ++ t :: hours:minutes:secs - %+ cook |=({h=@u @ m=@u @ s=@u} ~[h m s]) + %+ cook |=([h=@u @ m=@u @ s=@u] ~[h m s]) ;~(plug d col d col d) :: :: XX day of week is currently unchecked, and @@ -7764,7 +7764,7 @@ |% :: :: ++feel:space:userlib ++ feel :: simple file write - |= {pax=path val=cage} + |= [pax=path val=cage] ^- miso =+ dir=.^(arch %cy pax) ?~ fil.dir [%ins val] @@ -7777,19 +7777,19 @@ ?~(fil.dir ~ [~ .^(* %cx pax)]) :: :: ++foal:space:userlib ++ foal :: high-level write - |= {pax=path val=cage} + |= [pax=path val=cage] ^- toro - ?> ?=({* * * *} pax) + ?> ?=([* * * *] pax) [i.t.pax [%& [[[t.t.t.pax (feel pax val)] ~]]]] :: :: ++fray:space:userlib ++ fray :: high-level delete |= pax=path ^- toro - ?> ?=({* * * *} pax) + ?> ?=([* * * *] pax) [i.t.pax [%& [[[t.t.t.pax [%del ~]] ~]]]] :: :: ++furl:space:userlib ++ furl :: unify changes - |= {one=toro two=toro} + |= [one=toro two=toro] ^- toro ~| %furl ?> ?& =(p.one p.two) :: same path @@ -7809,7 +7809,7 @@ ?~ txt ^- (list @t) ~ =+ [byt=(rip 3 txt) len=(met 3 txt)] - =| {lin=(list @t) off=@} + =| [lin=(list @t) off=@] ^- (list @t) %- flop |- ^+ lin @@ -7839,13 +7839,13 @@ :::: ++scanf:userlib :: (2uF) exterpolation :: :::: ++ scanf - =< |* {tape (pole _;/(*{$^(rule tape)}))} :: formatted scan + =< |* [tape (pole _;/(*[$^(rule tape)]))] :: formatted scan => .(+< [a b]=+<) (scan a (parsf b)) |% :: :: ++parsf:scanf: ++ parsf :: make parser from: - |* a=(pole _;/(*{$^(rule tape)})) :: ;"chars{rule}chars" + |* a=(pole _;/(*[$^(rule tape)])) :: ;"chars{rule}chars" =- (cook - (boil (norm a))) |* (list) ?~ +< ~ @@ -7860,14 +7860,14 @@ |* (list (each rule tape)) ?~ +< (easy ~) ?: ?=(%| -.i) ;~(pfix (jest (crip p.i)) $(+< t)) - %+ cook |*({* *} [i t]=+<) + %+ cook |*([* *] [i t]=+<) ;~(plug p.i $(+< t)) :: :: .= (norm [;"{n}, {n}"]:n=dim:ag) ~[[& dim] [| ", "] [& dim]]:ag :: :: :: ++norm:scanf:userlib ++ norm :: - |* (pole _;/(*{$^(rule tape)})) + |* (pole _;/(*[$^(rule tape)])) ?~ +< ~ => .(+< [i=+<- t=+<+]) :_ t=$(+< t) From 8e57961183f92b6b7c362ff747c728279c167678 Mon Sep 17 00:00:00 2001 From: fang Date: Thu, 26 Nov 2020 16:03:08 +0100 Subject: [PATCH 778/933] hoon: remove {type} syntax --- pkg/arvo/sys/hoon.hoon | 6 ------ pkg/arvo/sys/zuse.hoon | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 152876e26a..fadb25b538 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -12865,10 +12865,6 @@ wide ;~(pose ;~(pfix ace (most ace wyde)) (easy ~)) == - :- '{' - :: XX deprecated - :: - (stag %bccl (ifix [kel ker] (most ace wyde))) :- '[' (stag %bccl (ifix [sel ser] (most ace wyde))) :- '*' @@ -12967,8 +12963,6 @@ (stag %sand (stag %t qut)) :- '(' (stag %cncl (ifix [pal par] (most ace wide))) - :- '{' - (stag %ktcl (stag %bccl (ifix [kel ker] (most ace wyde)))) :- '*' ;~ pose (stag %kttr ;~(pfix tar wyde)) diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index 23390af674..ac9655ba9a 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -6279,7 +6279,7 @@ :: %o :- '{' - =. rez [']' rez] + =. rez ['}' rez] =+ viz=~(tap by p.val) ?~ viz rez !. From eef09dd63b0e00b1e8bd3be61e87c49b453f24bf Mon Sep 17 00:00:00 2001 From: fang Date: Thu, 26 Nov 2020 16:17:16 +0100 Subject: [PATCH 779/933] hoon: remove deprecated character parsers --- pkg/arvo/lib/hark/graph-hook.hoon | 2 +- pkg/arvo/sys/hoon.hoon | 20 -------------------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/pkg/arvo/lib/hark/graph-hook.hoon b/pkg/arvo/lib/hark/graph-hook.hoon index d379236ffe..31361a72ac 100644 --- a/pkg/arvo/lib/hark/graph-hook.hoon +++ b/pkg/arvo/lib/hark/graph-hook.hoon @@ -10,7 +10,7 @@ :: ++ index ^- $-(json index:graph-store) - (su ;~(pfix net (more net dem))) + (su ;~(pfix fas (more fas dem))) :: ++ graph-index %- ot diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index fadb25b538..2d49d69dfa 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -5191,26 +5191,6 @@ ++ wut (just '?') :: wut, what? ++ zap (just '!') :: zap! bang! crash!! :: -++ ban (just '>') :: XX deprecated, use gar -++ bat (just '\\') :: XX deprecated, use bas -++ bus (just '$') :: XX deprecated, use buc -++ lac (just '[') :: XX deprecated, use sel -++ leb (just '{') :: XX deprecated, use kel -++ led (just '<') :: XX deprecated, use gal -++ lit (just '(') :: XX deprecated, use pal -++ lob (just '{') :: XX deprecated, use kel -++ net (just '/') :: XX deprecated, use fas -++ pad (just '&') :: XX deprecated, use pam -++ rac (just ']') :: XX deprecated, use ser -++ reb (just '}') :: XX deprecated, use ker -++ rit (just ')') :: XX deprecated, use par -++ rob (just '}') :: XX deprecated, use ker -++ say (just '\'') :: XX deprecated, use soq -++ tec (just '`') :: XX deprecated, use tic -++ toc (just '"') :: XX deprecated, use doq -++ vat (just '@') :: XX deprecated, use pat -++ yel (just '"') :: XX deprecated, use doq -:: :::: 4i: parsing (useful idioms) :: ++ alf ;~(pose low hig) :: alphabetic From 88e3e5dabd0faf4852aae4ce1377b444722a2888 Mon Sep 17 00:00:00 2001 From: fang Date: Thu, 26 Nov 2020 16:17:56 +0100 Subject: [PATCH 780/933] group: remove unused library --- pkg/arvo/lib/group-json.hoon | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 pkg/arvo/lib/group-json.hoon diff --git a/pkg/arvo/lib/group-json.hoon b/pkg/arvo/lib/group-json.hoon deleted file mode 100644 index fe52ba0a08..0000000000 --- a/pkg/arvo/lib/group-json.hoon +++ /dev/null @@ -1,18 +0,0 @@ -/- *group-store -|% -++ groups-to-json - |= grp=groups - ^- json - =, enjs:format - %- pairs - %+ turn ~(tap by grp) - |= [pax=^path =group] - ^- [@t json] - :- (spat pax) - (set-to-array group ship:enjs:format) -:: -++ set-to-array - |* [a=(set) b=$-(* json)] - ^- json - [%a (turn ~(tap in a) b)] --- From d61e5afdc406e61f1b457663a0d2b39d24de49c0 Mon Sep 17 00:00:00 2001 From: fang Date: Thu, 26 Nov 2020 16:22:33 +0100 Subject: [PATCH 781/933] test: don't panic after building non-/tests files --- pkg/arvo/ted/test.hoon | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/arvo/ted/test.hoon b/pkg/arvo/ted/test.hoon index a8ec7cb2d3..10a2dc45cc 100644 --- a/pkg/arvo/ted/test.hoon +++ b/pkg/arvo/ted/test.hoon @@ -46,7 +46,8 @@ ^- (list test) :: strip off leading 'tests' from :path :: - =. path ?>(?=([%tests *] path) t.path) + ?. ?=([%tests *] path) ~ + =/ path t.path ::NOTE TMI :: for each test, add the test's name to :path :: %+ turn test-arms From d6a9c39f291d5887d16eb76286469df423a694bc Mon Sep 17 00:00:00 2001 From: fang Date: Thu, 26 Nov 2020 16:31:46 +0100 Subject: [PATCH 782/933] test: only build .hoon files Previously it would fail to build .txt files and such. Now it filters those out and doesn't try. --- pkg/arvo/ted/test.hoon | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/arvo/ted/test.hoon b/pkg/arvo/ted/test.hoon index 10a2dc45cc..f327adb926 100644 --- a/pkg/arvo/ted/test.hoon +++ b/pkg/arvo/ted/test.hoon @@ -86,7 +86,11 @@ loop(bez t.bez, fiz (~(put in fiz) [i.bez(s (snoc s.i.bez %hoon)) ~])) ;< fez=(list path) bind:m (list-tree:strandio i.bez) ?. =(~ fez) - =/ foz (turn fez |=(path [[-.i.bez +<] ~])) + =/ foz + %+ murn fez + |= p=path + ?. =(%hoon (rear p)) ~ + (some [[-.i.bez p] ~]) loop(bez t.bez, fiz (~(gas in fiz) foz)) ~| bad-test-beam+i.bez =/ tex=term =-(?>(((sane %tas) -) -) (rear s.i.bez)) From f71bcb9f114ca97bea10b7d2c41ac86a81539594 Mon Sep 17 00:00:00 2001 From: fang Date: Thu, 26 Nov 2020 16:44:54 +0100 Subject: [PATCH 783/933] ted: update threads that had fallen into disrepair --- pkg/arvo/ted/aqua/dill.hoon | 1 + pkg/arvo/ted/migrate-channels.hoon | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/ted/aqua/dill.hoon b/pkg/arvo/ted/aqua/dill.hoon index adc03dc41d..4d3b7b2e4e 100644 --- a/pkg/arvo/ted/aqua/dill.hoon +++ b/pkg/arvo/ted/aqua/dill.hoon @@ -18,6 +18,7 @@ |= [b=blit:dill line=tape] ?- -.b %lin (tape p.b) + %klr (tape (zing (turn p.b tail))) %mor ~& "{}: {line}" "" %hop line %bel line diff --git a/pkg/arvo/ted/migrate-channels.hoon b/pkg/arvo/ted/migrate-channels.hoon index d860c69de4..4abc4b3f44 100644 --- a/pkg/arvo/ted/migrate-channels.hoon +++ b/pkg/arvo/ted/migrate-channels.hoon @@ -17,7 +17,7 @@ (pure:m !>("no such group: {}")) :: =/ assoc=associations (scry-for associations %metadata-store [%group og-path]) -=/ assoc-list=(list [[group-path resource] metadata]) ~(tap by assoc) +=/ assoc-list=(list [[group-path md-resource] metadata]) ~(tap by assoc) :: |- =* loop $ @@ -25,7 +25,7 @@ ;< ~ bind:m (poke-our:strandio %group-store %group-action !>([%unbundle og-path])) (pure:m !>("done")) -=/ [[g-path=group-path res=resource] meta=metadata] i.assoc-list +=/ [[g-path=group-path res=md-resource] meta=metadata] i.assoc-list ?. =(our.bol creator.meta) loop(assoc-list t.assoc-list) ?> =(g-path og-path) From a3c36f2e76ee267daa212b49617a1ec96c3c2d07 Mon Sep 17 00:00:00 2001 From: fang Date: Thu, 26 Nov 2020 19:12:35 +0100 Subject: [PATCH 784/933] tests: update vane tests for new scry gate --- pkg/arvo/tests/sys/vane/ames.hoon | 16 ++++++------- pkg/arvo/tests/sys/vane/clay.hoon | 8 +++---- pkg/arvo/tests/sys/vane/eyre.hoon | 30 ++++++++++++------------ pkg/arvo/tests/sys/vane/gall.hoon | 6 ++--- pkg/arvo/tests/sys/vane/iris.hoon | 38 +++++++++++++++---------------- 5 files changed, 49 insertions(+), 49 deletions(-) diff --git a/pkg/arvo/tests/sys/vane/ames.hoon b/pkg/arvo/tests/sys/vane/ames.hoon index 83bc5a4b52..26e162d0a4 100644 --- a/pkg/arvo/tests/sys/vane/ames.hoon +++ b/pkg/arvo/tests/sys/vane/ames.hoon @@ -7,15 +7,15 @@ =/ nec vane =/ bud vane :: -=. our.nec ~nec -=. now.nec ~1111.1.1 -=. eny.nec 0xdead.beef -=. scry-gate.nec |=(* ``[%noun !>(*(list turf))]) +=. our.nec ~nec +=. now.nec ~1111.1.1 +=. eny.nec 0xdead.beef +=. rof.nec |=(* ``[%noun !>(*(list turf))]) :: -=. our.bud ~bud -=. now.bud ~1111.1.1 -=. eny.bud 0xbeef.dead -=. scry-gate.bud |=(* ``[%noun !>(*(list turf))]) +=. our.bud ~bud +=. now.bud ~1111.1.1 +=. eny.bud 0xbeef.dead +=. rof.bud |=(* ``[%noun !>(*(list turf))]) :: =. crypto-core.ames-state.nec (pit:nu:crub:crypto 512 (shaz 'nec')) =. crypto-core.ames-state.bud (pit:nu:crub:crypto 512 (shaz 'bud')) diff --git a/pkg/arvo/tests/sys/vane/clay.hoon b/pkg/arvo/tests/sys/vane/clay.hoon index 76b0f43dea..0487df3700 100644 --- a/pkg/arvo/tests/sys/vane/clay.hoon +++ b/pkg/arvo/tests/sys/vane/clay.hoon @@ -175,7 +175,7 @@ ++ clay-call |= $: clay-gate=_clay-gate now=@da - scry=sley + scry=roof call-args=[=duct =type wrapped-task=(hobo task:able:clay)] expected-moves=(list move:clay-gate) == @@ -196,7 +196,7 @@ ++ clay-call-with-comparator |= $: clay-gate=_clay-gate now=@da - scry=sley + scry=roof call-args=[=duct =type wrapped-task=(hobo task:able:clay)] move-comparator=$-((list move:clay-gate) tang) == @@ -214,7 +214,7 @@ ++ clay-take |= $: clay-gate=_clay-gate now=@da - scry=sley + scry=roof take-args=[=wire =duct wrapped-sign=(hypo sign:clay-gate)] expected-moves=(list move:clay-gate) == @@ -235,7 +235,7 @@ ++ clay-take-with-comparator |= $: clay-gate=_clay-gate now=@da - scry=sley + scry=roof take-args=[=wire =duct wrapped-sign=(hypo sign:clay-gate)] move-comparator=$-((list move:clay-gate) tang) == diff --git a/pkg/arvo/tests/sys/vane/eyre.hoon b/pkg/arvo/tests/sys/vane/eyre.hoon index e44f5297e0..61dc66b53d 100644 --- a/pkg/arvo/tests/sys/vane/eyre.hoon +++ b/pkg/arvo/tests/sys/vane/eyre.hoon @@ -882,7 +882,7 @@ == :: ++ test-channel-open-never-used-expire - =^ results1 eyre-gate (perform-init-start-channel eyre-gate *sley) + =^ results1 eyre-gate (perform-init-start-channel eyre-gate *roof) :: the behn timer wakes us up; we cancel our subscription :: =^ results2 eyre-gate @@ -918,7 +918,7 @@ ++ test-channel-results-before-open :: common initialization :: - =^ results1 eyre-gate (perform-init-start-channel eyre-gate *sley) + =^ results1 eyre-gate (perform-init-start-channel eyre-gate *roof) :: poke gets a success message :: =^ results2 eyre-gate @@ -1062,7 +1062,7 @@ ++ test-channel-second-get-updates-timer :: common initialization :: - =^ results1 eyre-gate (perform-init-start-channel eyre-gate *sley) + =^ results1 eyre-gate (perform-init-start-channel eyre-gate *roof) :: perform another poke to a different app :: :: Since we haven't connected with a GET, the old timer should be canceled @@ -1136,7 +1136,7 @@ ++ test-channel-unsubscribe-stops-events :: common initialization :: - =^ results1 eyre-gate (perform-init-start-channel eyre-gate *sley) + =^ results1 eyre-gate (perform-init-start-channel eyre-gate *roof) :: poke gets a success message :: =^ results2 eyre-gate @@ -1238,7 +1238,7 @@ ++ test-channel-double-subscription-works :: common initialization :: - =^ results1 eyre-gate (perform-init-start-channel eyre-gate *sley) + =^ results1 eyre-gate (perform-init-start-channel eyre-gate *roof) :: poke gets a success message :: =^ results2 eyre-gate @@ -1541,7 +1541,7 @@ ++ test-channel-sends-unacknowledged-events-on-reconnection :: common initialization :: - =^ results1 eyre-gate (perform-init-start-channel eyre-gate *sley) + =^ results1 eyre-gate (perform-init-start-channel eyre-gate *roof) :: poke gets a success message :: =^ results2 eyre-gate @@ -1811,7 +1811,7 @@ :: common initialization :: =^ tested-elsewhere eyre-gate - (perform-init-start-channel eyre-gate *sley) + (perform-init-start-channel eyre-gate *roof) :: =/ now=@da :(add ~1111.1.2 clog-timeout:eyre-gate ~s1) :: subscription gets a success message @@ -2051,7 +2051,7 @@ ++ eyre-call |= $: eyre-gate=_eyre-gate now=@da - scry=sley + scry=roof call-args=[=duct type=* wrapped-task=(hobo task:able:eyre-gate)] expected-moves=(list move:eyre-gate) == @@ -2073,7 +2073,7 @@ ++ eyre-call-with-comparator |= $: eyre-gate=_eyre-gate now=@da - scry=sley + scry=roof call-args=[=duct type=* wrapped-task=(hobo task:able:eyre-gate)] move-comparator=$-((list move:eyre-gate) tang) == @@ -2090,7 +2090,7 @@ ++ eyre-take |= $: eyre-gate=_eyre-gate now=@da - scry=sley + scry=roof take-args=[=wire =duct wrapped-sign=(hypo sign:eyre-gate)] expected-moves=(list move:eyre-gate) == @@ -2110,7 +2110,7 @@ ++ eyre-take-with-comparator |= $: eyre-gate=_eyre-gate now=@da - scry=sley + scry=roof take-args=[=wire =duct wrapped-sign=(hypo sign:eyre-gate)] move-comparator=$-((list move:eyre-gate) tang) == @@ -2202,7 +2202,7 @@ ++ perform-authentication |= $: eyre-gate=_eyre-gate start-now=@da - scry=sley + scry=roof == ^- [tang _eyre-gate] :: the browser then fetches the login page @@ -2276,7 +2276,7 @@ :: ++ perform-init-start-channel |= $: eyre-gate=_eyre-gate - scry=sley + scry=roof == ^- [tang _eyre-gate] :: @@ -2366,8 +2366,8 @@ :_ eyre-gate :(weld results1 results2 results3) :: -++ scry-provides-code ^- sley - |= [* (unit (set monk)) =term =beam] +++ scry-provides-code ^- roof + |= [gang =term =beam] ^- (unit (unit cage)) ?: &(=(%ca term) =(/gen/handler/hoon s.beam)) :+ ~ ~ diff --git a/pkg/arvo/tests/sys/vane/gall.hoon b/pkg/arvo/tests/sys/vane/gall.hoon index c4c71b6b5b..ac77088422 100644 --- a/pkg/arvo/tests/sys/vane/gall.hoon +++ b/pkg/arvo/tests/sys/vane/gall.hoon @@ -21,7 +21,7 @@ =/ expected-moves=(list move:gall-gate) ~ :: =/ res - (gall-call gall-gate time *sley call-args expected-moves) + (gall-call gall-gate time *roof call-args expected-moves) :: -.res :: +test-conf: test %conf; TODO: test clay response @@ -48,7 +48,7 @@ =/ expected-moves=(list move:gall-gate) ~[move] :: =/ res - (gall-call gall-gate time *sley call-args expected-moves) + (gall-call gall-gate time *roof call-args expected-moves) :: -.res :: +gall-call: have %gall run a +task and assert it produces expected-moves @@ -56,7 +56,7 @@ ++ gall-call |= $: gall-gate=_gall-gate now=@da - scry=sley + scry=roof call-args=[=duct =type wrapped-task=(hobo task:able:gall)] expected-moves=(list move:gall-gate) == diff --git a/pkg/arvo/tests/sys/vane/iris.hoon b/pkg/arvo/tests/sys/vane/iris.hoon index 6ea9913743..ccd4539a29 100644 --- a/pkg/arvo/tests/sys/vane/iris.hoon +++ b/pkg/arvo/tests/sys/vane/iris.hoon @@ -16,7 +16,7 @@ %- http-client-call :* http-client-gate now=~1111.1.1 - scry=*sley + scry=*roof call-args=[duct=~[/initial-born-duct] ~ [%born ~]] expected-moves=~ == @@ -33,7 +33,7 @@ %- http-client-call :* http-client-gate now=(add ~1111.1.1 ~s1) - scry=*sley + scry=*roof ^= call-args :* duct=~[/http-get-request] ~ %request @@ -57,7 +57,7 @@ %- http-client-call :* http-client-gate now=(add ~1111.1.1 ~s2) - scry=*sley + scry=*roof ^= call-args :+ duct=~[/initial-born-duct] ~ ^- task:able:iris @@ -112,7 +112,7 @@ %- http-client-call :* http-client-gate now=~1111.1.1 - scry=*sley + scry=*roof call-args=[duct=~[/initial-born-duct] ~ [%born ~]] expected-moves=~ == @@ -129,7 +129,7 @@ %- http-client-call :* http-client-gate now=(add ~1111.1.1 ~s1) - scry=*sley + scry=*roof ^= call-args :* duct=~[/http-get-request] ~ %request @@ -153,7 +153,7 @@ %- http-client-call :* http-client-gate now=(add ~1111.1.1 ~s2) - scry=*sley + scry=*roof ^= call-args :+ duct=~[/initial-born-duct] ~ ^- task:able:iris @@ -190,7 +190,7 @@ %- http-client-call :* http-client-gate now=(add ~1111.1.1 ~s3) - scry=*sley + scry=*roof ^= call-args :+ duct=~[/initial-born-duct] ~ ^- task:able:iris @@ -223,7 +223,7 @@ %- http-client-call :* http-client-gate now=(add ~1111.1.1 ~s4) - scry=*sley + scry=*roof ^= call-args :+ duct=~[/initial-born-duct] ~ ^- task:able:iris @@ -269,7 +269,7 @@ %- http-client-call :* http-client-gate now=~1111.1.1 - scry=*sley + scry=*roof call-args=[duct=~[/initial-born-duct] ~ [%born ~]] expected-moves=~ == @@ -286,7 +286,7 @@ %- http-client-call :* http-client-gate now=(add ~1111.1.1 ~s1) - scry=*sley + scry=*roof ^= call-args :* duct=~[/http-get-request] ~ %request @@ -310,7 +310,7 @@ %- http-client-call :* http-client-gate now=(add ~1111.1.1 ~s2) - scry=*sley + scry=*roof ^= call-args :+ duct=~[/initial-born-duct] ~ ^- task:able:iris @@ -347,7 +347,7 @@ %- http-client-call :* http-client-gate now=(add ~1111.1.1 ~s3) - scry=*sley + scry=*roof ^= call-args :* duct=~[/http-get-request] ~ %cancel-request @@ -375,7 +375,7 @@ %- http-client-call :* http-client-gate now=~1111.1.1 - scry=*sley + scry=*roof call-args=[duct=~[/initial-born-duct] ~ [%born ~]] expected-moves=~ == @@ -392,7 +392,7 @@ %- http-client-call :* http-client-gate now=(add ~1111.1.1 ~s1) - scry=*sley + scry=*roof ^= call-args :* duct=~[/http-get-request] ~ %request @@ -416,7 +416,7 @@ %- http-client-call :* http-client-gate now=(add ~1111.1.1 ~s2) - scry=*sley + scry=*roof ^= call-args :+ duct=~[/initial-born-duct] ~ ^- task:able:iris @@ -448,7 +448,7 @@ %- http-client-call :* http-client-gate now=~1111.1.1 - scry=*sley + scry=*roof call-args=[duct=~[/initial-born-duct] ~ [%born ~]] expected-moves=~ == @@ -465,7 +465,7 @@ %- http-client-call :* http-client-gate now=(add ~1111.1.1 ~s1) - scry=*sley + scry=*roof ^= call-args :* duct=~[/http-get-request] ~ %request @@ -488,7 +488,7 @@ %- http-client-call :* http-client-gate now=(add ~1111.1.1 ~s2) - scry=*sley + scry=*roof ^= call-args :+ duct=~[/secondary-born-duct] ~ ^- task:able:iris @@ -513,7 +513,7 @@ ++ http-client-call |= $: http-client-gate=_http-client-gate now=@da - scry=sley + scry=roof call-args=[=duct type=* wrapped-task=(hobo task:able:iris)] expected-moves=(list move:http-client-gate) == From c8ddfe435b6bdd1d48c8771f143e19f1af9ae073 Mon Sep 17 00:00:00 2001 From: fang Date: Thu, 26 Nov 2020 19:24:18 +0100 Subject: [PATCH 785/933] pill: all --- bin/brass.pill | 4 ++-- bin/ivory.pill | 4 ++-- bin/solid.pill | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/brass.pill b/bin/brass.pill index 13ad961271..448746b862 100644 --- a/bin/brass.pill +++ b/bin/brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d83b7a0878cdcba73a63769ad12896bf4f9d90ca662d79f19ae90e6be074d032 -size 4494462 +oid sha256:d764f3c853b127d84496efc5f04ee4fbd35b15c1e8a8c9823ba76633668f0a3b +size 4608972 diff --git a/bin/ivory.pill b/bin/ivory.pill index 0c5b8d3d3d..56cf8ea4dc 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d58f536429741585da358a8c2af8b2b631be1357887c9d4aae1d8a1cf31c3514 -size 1730073 +oid sha256:13cbef9277182a6d64dc9f8c8cfe157c6994f0663deb5664bea721c2c549fdb3 +size 1906511 diff --git a/bin/solid.pill b/bin/solid.pill index 7395f857d1..5fe479eb83 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0f6837ba8638026250669887992c1974aac62ef6365ede9920b03fac1ad39e59 -size 6303496 +oid sha256:257e1b21ba5fa9b58093394a5214ae58d8493f5424f718816b7b984eded2d735 +size 6476024 From 732addadd32ce491371bb980cd1bdcca7fb9d97b Mon Sep 17 00:00:00 2001 From: fang Date: Fri, 27 Nov 2020 13:25:40 +0100 Subject: [PATCH 786/933] various: touch up improperly rewritten comments Also patches /mar/snip to be more correct, but a &snip [~ ~] in dojo still does not work. --- pkg/arvo/app/dojo.hoon | 2 +- pkg/arvo/gen/deco.hoon | 4 ++-- pkg/arvo/lib/generators.hoon | 2 +- pkg/arvo/lib/group-store.hoon | 2 +- pkg/arvo/mar/dill/belt.hoon | 2 +- pkg/arvo/mar/snip.hoon | 2 +- pkg/arvo/sys/hoon.hoon | 4 ++-- pkg/arvo/sys/vane/clay.hoon | 2 +- pkg/arvo/sys/zuse.hoon | 18 +++++++++--------- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/pkg/arvo/app/dojo.hoon b/pkg/arvo/app/dojo.hoon index 49a1ff3248..c34dd8ea89 100644 --- a/pkg/arvo/app/dojo.hoon +++ b/pkg/arvo/app/dojo.hoon @@ -54,7 +54,7 @@ r=@t == [%poke p=goal] :: poke app - [%show p=?(%0 %1 %2 %3 %4 %5)] :: val=type=hoon=xray + [%show p=?(%0 %1 %2 %3 %4 %5)] :: val/type/hoon/xray [%verb p=term] :: store variable == :: +$ dojo-source :: construction node diff --git a/pkg/arvo/gen/deco.hoon b/pkg/arvo/gen/deco.hoon index 9af8d13e5a..02494f77ca 100644 --- a/pkg/arvo/gen/deco.hoon +++ b/pkg/arvo/gen/deco.hoon @@ -37,8 +37,8 @@ :: with {a}. use this convention only for one-liners, etc. :: :: the file below is a medium-sized generator, built around -:: a typical two-core structure. the cores are labeled [%arch} -:: (structures) and [%work} (productions). this is canonical. +:: a typical two-core structure. the cores are labeled {%arch} +:: (structures) and {%work} (productions). this is canonical. :: :: this code is written to display the variety of formatting :: options the parser allows. a specific convention should pick diff --git a/pkg/arvo/lib/generators.hoon b/pkg/arvo/lib/generators.hoon index 13585ab68e..e40714b7f9 100644 --- a/pkg/arvo/lib/generators.hoon +++ b/pkg/arvo/lib/generators.hoon @@ -27,7 +27,7 @@ |* [sef=rule fun=$-(* *)] :: |= txt=sole-input :: =+ vex=(sef [0 0] txt) :: - ?: |(!=((lent txt) q.p.vex) ?=(~ q.vex)) :: + ?: |(!=((lent txt) q.p.vex) ?=(~ q.vex)) :: q.p.vex :: (fun p.u.q.vex) :: -- diff --git a/pkg/arvo/lib/group-store.hoon b/pkg/arvo/lib/group-store.hoon index bf7be51619..07e28fdc02 100644 --- a/pkg/arvo/lib/group-store.hoon +++ b/pkg/arvo/lib/group-store.hoon @@ -309,7 +309,7 @@ ?> ?=([%o [@ *] ~ ~] jon) |- ?- wer - :: {{key=@t wit=*} t=*] + :: [[key=@t wit=*] t=*] [[key=@t *] t=*] => .(wer [[* wit] *]=wer) ?: =(key.wer (enkebab p.n.p.jon)) diff --git a/pkg/arvo/mar/dill/belt.hoon b/pkg/arvo/mar/dill/belt.hoon index 8ff233eb38..1677b6ef1e 100644 --- a/pkg/arvo/mar/dill/belt.hoon +++ b/pkg/arvo/mar/dill/belt.hoon @@ -24,7 +24,7 @@ :: %. jon => jo %- ot :: :~ mod+(cu silt (ar (su (perk ~[%ctrl %shift %alt %meta])))) :: :- %key -:: %+ cu |*(a=$%([%str @t} [%act @}) ?+(-.a a %str +.a)) +:: %+ cu |*(a=$%([%str @t] [%act @]) ?+(-.a a %str +.a)) :: =- (of [str+so act+(su (perk -)) ~]) :: :~ %ctrl %shift %alt %meta %entr %esc %caps %uncap :: %pgup %pgdn %home %end %baxp %del %ins diff --git a/pkg/arvo/mar/snip.hoon b/pkg/arvo/mar/snip.hoon index 86041dc16e..205348f495 100644 --- a/pkg/arvo/mar/snip.hoon +++ b/pkg/arvo/mar/snip.hoon @@ -57,6 +57,6 @@ -- -- ++ grab |% :: convert from - ++ noun [marl marl] :: clam from %noun + ++ noun ,[marl marl] :: clam from %noun ++ elem |=(a=manx (hedtal +.a)) -- -- diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 2d49d69dfa..4085fec59b 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -8466,7 +8466,7 @@ [%cnhp *] [%cncl p.gen q.gen ~] :: this probably should work, but doesn't :: - :: [%cncl *} [%cntr [%$ ~] p.gen [[[[%& 6] ~] [%cltr q.gen]] ~]] + :: [%cncl *] [%cntr [%$ ~] p.gen [[[[%& 6] ~] [%cltr q.gen]] ~]] [%cncl *] [%cnsg [%$ ~] p.gen q.gen] [%cnsg *] :: this complex matching system is a leftover from the old @@ -9474,7 +9474,7 @@ => |% ++ pony :: raw match $@ ~ :: void - %+ each :: natural=abnormal + %+ each :: natural/abnormal palo :: arm or leg %+ each :: abnormal @ud :: unmatched diff --git a/pkg/arvo/sys/vane/clay.hoon b/pkg/arvo/sys/vane/clay.hoon index 83fc16d5b1..7f01808a29 100644 --- a/pkg/arvo/sys/vane/clay.hoon +++ b/pkg/arvo/sys/vane/clay.hoon @@ -1722,7 +1722,7 @@ == == outer-loop(dels t.dels) - :: Add=change + :: Add/change :: =/ cans=(list [=path =lobe =cage]) ~(tap by changes) |- ^+ [ankh ford-cache.ford-args] diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index ac9655ba9a..b955e81c88 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -175,8 +175,8 @@ [%spawned who=@p] :: Spawned [%keys =life =pass] :: ChangedKeys [%continuity new=@ud] :: BrokeContinuity - [%sponsor new=[has=? who=@p]] :: EscapeAcc=LostSpons - [%escape new=(unit @p)] :: EscapeReq=Can + [%sponsor new=[has=? who=@p]] :: EscapeAcc/LostSpons + [%escape new=(unit @p)] :: EscapeReq/Can [%management-proxy new=address] :: ChangedManagementPro [%voting-proxy new=address] :: ChangedVotingProxy [%spawn-proxy new=address] :: ChangedSpawnProxy @@ -5629,7 +5629,7 @@ |= jol=(list json) ?~ jol !! ?- wil :: mint-vain on empty - :: {wit=* t=*] + :: [wit=* t=*] [* t=*] => .(wil [wit *]=wil) ?~ t.wil ?^(t.jol !! (wit.wil i.jol)) @@ -5683,7 +5683,7 @@ ?> ?=([%o [@ *] ~ ~] jon) |- ?- wer :: mint-vain on empty - :: {{key=@t wit=*} t=*] + :: [[key=@t wit=*] t=*] [[key=@t *] t=*] => .(wer [[* wit] *]=wer) ?: =(key.wer p.n.p.jon) @@ -5702,7 +5702,7 @@ |* wer=(pole [cord fist]) |= jom=(map @t json) ?- wer :: mint-vain on empty - :: {{key=@t wit=*} t=*] + :: [[key=@t wit=*] t=*] [[key=@t *] t=*] => .(wer [[* wit] *]=wer) =/ ten ~|(key+key.wer (wit.wer (~(got by jom) key.wer))) @@ -5719,7 +5719,7 @@ |* wer=(pole [cord fist]) |= jom=(map @t json) ?- wer :: mint-vain on empty - :: {{key=@t wit=*} t=*] + :: [[key=@t wit=*] t=*] [[key=@t *] t=*] => .(wer [[* wit] *]=wer) =/ ten ~|(key+key.wer (wit.wer (~(get by jom) key.wer))) @@ -6927,8 +6927,8 @@ == :: :: :: ++read:wired :: ++ read :: parse odored path -:: =< |*({a=path b={@tas (pole @tas)}} ((+> b) a)) -:: |* b={@tas (pole @tas)} +:: =< |*([a=path b=[@tas (pole @tas)]] ((+> b) a)) +:: |* b=[@tas (pole @tas)] :: |= a=path :: ?~ a ~ :: =+ hed=(slaw -.b i.a) @@ -6936,7 +6936,7 @@ :: ?~ +.b :: ^- (unit fog) :: ?^(+.a ~ hed) -:: ^- (unit {fog _(need *(..^$ +.b))}) +:: ^- (unit [fog _(need *(..^$ +.b))]) :: (both hed ((..^$ +.b) +.a)) -- ::wired :: :: From 122123c11a7700c7226988908858249cf371b6bd Mon Sep 17 00:00:00 2001 From: fang Date: Fri, 27 Nov 2020 13:55:21 +0100 Subject: [PATCH 787/933] ames: remove old state versions & conversions --- pkg/arvo/sys/vane/ames.hoon | 100 ++---------------------------------- 1 file changed, 3 insertions(+), 97 deletions(-) diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index d700531073..c76919ae77 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -364,58 +364,6 @@ $% [%memo =message-num message=*] [%send =message-num =ack-meat] == -:: previous state versions, for +stay/+load migrations -:: -+| %plasmonics -:: -+$ ames-state-2 - $: peers=(map ship ship-state) - =unix=duct - =life - crypto-core=acru:ames - veb=_veb-all-off - == -:: -+$ queued-event-1 - $% [%call =duct type=* wrapped-task=(hobo task-1)] - [%take =wire =duct type=* =sign] - == -:: -+$ task-1 - $% [%wegh ~] - task - == -:: -+$ ames-state-1 - $: peers=(map ship ship-state-1) - =unix=duct - =life - crypto-core=acru:ames - == -+$ ship-state-1 - $% [%alien alien-agenda] - [%known peer-state-1] - == -+$ peer-state-1 - $: $: =symmetric-key - =life - =public-key - sponsor=ship - == - route=(unit [direct=? =lane]) - qos=qos-1 - =ossuary - snd=(map bone message-pump-state) - rcv=(map bone message-sink-state) - nax=(set [=bone =message-num]) - heeds=(set duct) - == -+$ qos-1 - $~ [%unborn ~] - $% [%live last-contact=@da] - [%dead last-contact=@da] - [%unborn ~] - == -- :: external vane interface :: @@ -628,51 +576,9 @@ :: +load: load in old state after reload :: ++ load - |= $= old-state - $% [%4 ^ames-state] - == - |^ ^+ ames-gate - ?> ?=(%4 -.old-state) - ames-gate(ames-state +.old-state) - :: - ++ state-1-to-2 - |= =ames-state-1 - ^- ames-state-2 - :: - =| =ames-state-2 - =. +.ames-state-2 - :* unix-duct.ames-state-1 - life.ames-state-1 - crypto-core.ames-state-1 - veb=veb-all-off - == - =. peers.ames-state-2 - %- ~(gas by *(map ship ship-state)) - %+ turn ~(tap by peers.ames-state-1) - |= [peer=ship =ship-state-1] - ^- [ship ship-state] - ?: ?=(%alien -.ship-state-1) - [peer ship-state-1] - :+ peer %known - %= +.ship-state-1 - qos - ?+ -.qos.ship-state-1 qos.ship-state-1 - %unborn [%unborn now] - == - == - ames-state-2 - :: - ++ state-2-to-3 - |= =ames-state-2 - ^- ^ames-state - :: - :* peers.ames-state-2 - unix-duct.ames-state-2 - life.ames-state-2 - crypto-core.ames-state-2 - bug=[veb=veb.ames-state-2 ships=~] - == - -- + |= old-state=[%4 ^ames-state] + ^+ ames-gate + ames-gate(ames-state +.old-state) :: +scry: dereference namespace :: ++ scry From 908e2d32e6146078be43ca51c13a6eff52ab2678 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Mon, 30 Nov 2020 13:59:19 +1000 Subject: [PATCH 788/933] chat-fe: autodismiss mentions whilst in channel --- pkg/interface/src/views/apps/chat/components/ChatWindow.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/interface/src/views/apps/chat/components/ChatWindow.tsx b/pkg/interface/src/views/apps/chat/components/ChatWindow.tsx index ee56242f7b..12b285406c 100644 --- a/pkg/interface/src/views/apps/chat/components/ChatWindow.tsx +++ b/pkg/interface/src/views/apps/chat/components/ChatWindow.tsx @@ -182,6 +182,7 @@ export default class ChatWindow extends Component { From b4e66ec4edca42b0f48856e7d9f2cff88088b42d Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Mon, 30 Nov 2020 12:50:38 -0600 Subject: [PATCH 789/933] thread: %group-leave-graph now compiles --- pkg/arvo/ted/group/leave-graph.hoon | 31 +++++++++++++++++------------ 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/pkg/arvo/ted/group/leave-graph.hoon b/pkg/arvo/ted/group/leave-graph.hoon index 3ea41e1adc..da9b90c64b 100644 --- a/pkg/arvo/ted/group/leave-graph.hoon +++ b/pkg/arvo/ted/group/leave-graph.hoon @@ -14,22 +14,27 @@ (pure:m !>(~)) :: :: get graphs associated with group and archive them +;< =associations:met bind:m + %+ scry associations:met + ;: weld + /gx/metadata-store/resource/group + (en-path:res resource.update) + /noun + == =/ graphs=(list path) - %+ turn - %~ tap in - %~ key by - ^- associations:met - %+ scry - %noun - (weld /group (en-path:res resource.update)) + %+ turn ~(tap in ~(key by associations)) |= [g=group-path:met m=md-resource:met] ^- path app-path.m -|- -?~ groups +;< =bowl:spider bind:m get-bowl:strandio +|- ^- form:m +=* loop $ +?~ graphs (pure:m !>(~)) ;< ~ bind:m - %+ poke-our %graph-store - !> ^- update:graph-store - [%archive-graph (de-path:res i.groups)] -$(groups t.groups) + %^ poke-our + %graph-store + %graph-update + !> ^- update:gra + [%0 now.bowl [%archive-graph (de-path:res i.graphs)]] +loop(graphs t.graphs) From f2e20efcf01fbab20bf5bf775000fdf895f55fd4 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Mon, 30 Nov 2020 13:20:27 -0600 Subject: [PATCH 790/933] observe-hook: compiles --- pkg/arvo/app/observe-hook.hoon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/app/observe-hook.hoon b/pkg/arvo/app/observe-hook.hoon index e2ec831e9a..28d6291695 100644 --- a/pkg/arvo/app/observe-hook.hoon +++ b/pkg/arvo/app/observe-hook.hoon @@ -10,7 +10,7 @@ +$ card card:agent:gall +$ versioned-state $% state-0 - state-0 + state-1 == :: +$ serial @uv @@ -70,7 +70,7 @@ %1 `this(state old-state) :: %0 - =. this(state [%1 observers.old-state]) + =. state [%1 observers.old-state] %+ on-poke %observe-action !> ^- action:sur From 1aa933730170e2b44823215447cd54957f5531db Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Mon, 30 Nov 2020 14:33:22 -0600 Subject: [PATCH 791/933] leave-graph: emit %done upon failed poke-acks --- pkg/arvo/lib/strandio.hoon | 19 +++++++++++++++++++ pkg/arvo/ted/group/leave-graph.hoon | 10 +++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/pkg/arvo/lib/strandio.hoon b/pkg/arvo/lib/strandio.hoon index 80c4178a1e..f0e06f4b97 100644 --- a/pkg/arvo/lib/strandio.hoon +++ b/pkg/arvo/lib/strandio.hoon @@ -219,6 +219,25 @@ ;< ~ bind:m (send-raw-card card) (take-poke-ack /poke) :: +++ raw-poke + |= [=dock =cage] + =/ m (strand ,~) + ^- form:m + =/ =card:agent:gall [%pass /poke %agent dock %poke cage] + ;< ~ bind:m (send-raw-card card) + =/ m (strand ,~) + ^- form:m + |= tin=strand-input:strand + ?+ in.tin `[%skip ~] + ~ + `[%wait ~] + :: + [~ %agent * %poke-ack *] + ?. =(/poke wire.u.in.tin) + `[%skip ~] + `[%done ~] + == +:: ++ poke-our |= [=term =cage] =/ m (strand ,~) diff --git a/pkg/arvo/ted/group/leave-graph.hoon b/pkg/arvo/ted/group/leave-graph.hoon index da9b90c64b..ff0b8fb72c 100644 --- a/pkg/arvo/ted/group/leave-graph.hoon +++ b/pkg/arvo/ted/group/leave-graph.hoon @@ -2,7 +2,7 @@ /+ strandio, res=resource :: =* strand strand:spider -=* poke-our poke-our:strandio +=* raw-poke raw-poke:strandio =* scry scry:strandio :: ^- thread:spider @@ -17,7 +17,7 @@ ;< =associations:met bind:m %+ scry associations:met ;: weld - /gx/metadata-store/resource/group + /gx/metadata-store/group (en-path:res resource.update) /noun == @@ -32,9 +32,9 @@ ?~ graphs (pure:m !>(~)) ;< ~ bind:m - %^ poke-our - %graph-store - %graph-update + %+ raw-poke + [our.bowl %graph-store] + :- %graph-update !> ^- update:gra [%0 now.bowl [%archive-graph (de-path:res i.graphs)]] loop(graphs t.graphs) From 94bb140448111ae60c7e52f2d51731771b73e187 Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Sun, 29 Nov 2020 23:59:49 -0800 Subject: [PATCH 792/933] aqua: manage azimuth state within aqua itself rather than using a thread --- pkg/arvo/app/aqua.hoon | 304 +++++++++++++++++++++++++++++---- pkg/arvo/lib/aqua-azimuth.hoon | 241 ++++++++++++++++++++++++++ pkg/arvo/sur/aquarium.hoon | 13 ++ pkg/arvo/ted/aqua/behn.hoon | 3 +- pkg/arvo/ted/aqua/dill.hoon | 1 + pkg/arvo/ted/aqua/eyre.hoon | 3 +- 6 files changed, 529 insertions(+), 36 deletions(-) create mode 100644 pkg/arvo/lib/aqua-azimuth.hoon diff --git a/pkg/arvo/app/aqua.hoon b/pkg/arvo/app/aqua.hoon index 748a2ee2f5..3eec9a21df 100644 --- a/pkg/arvo/app/aqua.hoon +++ b/pkg/arvo/app/aqua.hoon @@ -21,11 +21,15 @@ :: We get ++unix-event and ++pill from /-aquarium :: /- aquarium -/+ pill, default-agent +/+ pill, default-agent, aqua-azimuth, dbug, verb =, pill-lib=pill =, aquarium => $~ |% - +$ state + +$ versioned-state + $% state-0 + state-1 + == + +$ state-0 $: %0 pil=pill assembled=* @@ -33,7 +37,16 @@ fleet-snaps=(map term (map ship pier)) piers=(map ship pier) == + +$ state-1 + $: %1 + pil=pill + assembled=* + tym=@da + fleet-snaps=(map term fleet) + piers=fleet + == :: + +$ fleet [ships=(map ship pier) azi=az-state] +$ pier $: snap=* event-log=(list unix-timed-event) @@ -42,9 +55,11 @@ == -- :: -=| state -=* all-state - +=| state-1 +=* state - =< + %- agent:dbug + %+ verb | ^- agent:gall |_ =bowl:gall +* this . @@ -52,24 +67,37 @@ ac ~(. aqua-core bowl) def ~(. (default-agent this %|) bowl) ++ on-init `this - ++ on-save !>(all-state) + ++ on-save !>(state) ++ on-load - |= old-state=vase + |= old-vase=vase ^- step:agent:gall ~& prep=%aqua - =+ new=((soft state) !<(* old-state)) - ?~ new - `this - `this(all-state u.new) + =+ !<(old=versioned-state old-vase) + =| cards=(list card:agent:gall) + |- + ?- -.old + :: wipe fleets and piers rather than give them falsely nulled azimuth state + :: + %0 + %_ $ + -.old %1 + fleet-snaps.old *(map term fleet) + piers.old *fleet + == + :: + %1 + [cards this(state old)] + == :: ++ on-poke |= [=mark =vase] ^- step:agent:gall - =^ cards all-state + =^ cards state ?+ mark ~|([%aqua-bad-mark mark] !!) - %aqua-events (poke-aqua-events:ac !<((list aqua-event) vase)) - %pill (poke-pill:ac !<(pill vase)) - %noun (poke-noun:ac !<(* vase)) + %aqua-events (poke-aqua-events:ac !<((list aqua-event) vase)) + %pill (poke-pill:ac !<(pill vase)) + %noun (poke-noun:ac !<(* vase)) + %azimuth-action (poke-azimuth-action:ac !<(azimuth-action vase)) == [cards this] :: @@ -92,7 +120,18 @@ ++ on-peek peek:ac :: ++ on-agent on-agent:def - ++ on-arvo on-arvo:def + :: + ++ on-arvo + |= [=wire sign=sign-arvo] + ^- step:agent:gall + ?+ wire (on-arvo:def wire sign) + [%wait @ ~] + ?> ?=(%wake +<.sign) + =/ wen=@da (slav %da i.t.wire) + =^ cards state + (handle-wake:ac wen) + [cards this] + == ++ on-fail on-fail:def -- :: @@ -110,7 +149,7 @@ :: ++ pe |= who=ship - =+ (~(gut by piers) who *pier) + =+ (~(gut by ships.piers) who *pier) =* pier-data - |% :: @@ -118,7 +157,7 @@ :: ++ abet-pe ^+ this - =. piers (~(put by piers) who pier-data) + =. ships.piers (~(put by ships.piers) who pier-data) this :: :: Initialize new ship @@ -248,7 +287,19 @@ this :: ++ abet-aqua - ^- (quip card:agent:gall state) + ^- (quip card:agent:gall _state) + :: + :: interecept %request effects to handle azimuth subscription + :: + =. this + %- emit-cards + %- zing + %+ turn ~(tap by unix-effects) + |= [=ship ufs=(list unix-effect)] + %+ murn ufs + |= uf=unix-effect + (router:aqua-azimuth our.hid ship uf azi.piers) + :: =. this =/ =path /effect %- emit-cards @@ -300,20 +351,19 @@ =/ =path /boths/(scot %p ship) [%give %fact ~[path] %aqua-boths !>(`aqua-boths`[ship (flop bo)])] :: - [(flop cards) all-state] + [(flop cards) state] :: ++ emit-cards |= ms=(list card:agent:gall) =. cards (weld ms cards) this :: -:: :: Run all events on all ships until all queues are empty :: ++ plow-all |- ^+ this =/ who - =/ pers ~(tap by piers) + =/ pers ~(tap by ships.piers) |- ^- (unit ship) ?~ pers ~ @@ -331,7 +381,7 @@ :: ++ poke-pill |= p=pill - ^- (quip card:agent:gall state) + ^- (quip card:agent:gall _state) =. this apex-aqua =< abet-aqua =. pil p ~& lent=(met 3 (jam boot-ova.pil)) @@ -362,7 +412,7 @@ :: ++ poke-noun |= val=* - ^- (quip card:agent:gall state) + ^- (quip card:agent:gall _state) =. this apex-aqua =< abet-aqua ^+ this :: Could potentially factor out the three lines of turn-ships @@ -391,7 +441,7 @@ =/ txt .^(@ %cx (weld pax /hoon)) [/vane/[vane] [%veer v pax txt]] => .(this ^+(this this)) - =^ ms all-state (poke-pill pil) + =^ ms state (poke-pill pil) (emit-cards ms) :: [%swap-files ~] @@ -402,7 +452,7 @@ %- unix-event %- %*(. file-ovum:pill-lib directories slim-dirs) /(scot %p our.hid)/work/(scot %da now.hid) - =^ ms all-state (poke-pill pil) + =^ ms state (poke-pill pil) (emit-cards ms) :: [%wish hers=* p=@t] @@ -412,12 +462,14 @@ (wish:(pe who) p.val) :: [%unpause-events hers=*] + =. this start-azimuth-timer %+ turn-ships ((list ship) hers.val) |= [who=ship thus=_this] =. this thus start-processing-events:(pe who) :: [%pause-events hers=*] + =. this stop-azimuth-timer %+ turn-ships ((list ship) hers.val) |= [who=ship thus=_this] =. this thus @@ -428,17 +480,47 @@ this == :: +:: Make changes to azimuth state for the current fleet +:: +++ poke-azimuth-action + |= act=azimuth-action + ^- (quip card:agent:gall _state) + =. this apex-aqua =< abet-aqua + ^+ this + ?- -.act + :: + %init-azimuth + =. azi.piers *az-state + start-azimuth-timer + :: + %spawn + =. state (spawn who.act) + this + :: + %breach + :: should we remove the pier from state here? + =. state (breach who.act) + this + :: + == +:: :: Apply a list of events tagged by ship :: ++ poke-aqua-events |= events=(list aqua-event) - ^- (quip card:agent:gall state) + ^- (quip card:agent:gall _state) =. this apex-aqua =< abet-aqua %+ turn-events events |= [ae=aqua-event thus=_this] =. this thus ?- -.ae + :: %init-ship + :: XX Note that the keys that get passed in are unused. The keys field + :: should be deleted now that aqua is capable of managing azimuth state + :: internally. Its been left this way for now until all the ph tests + :: can be rewritten + =/ keys=dawn-event:able:jael (dawn who.ae) =. this abet-pe:(publish-effect:(pe who.ae) [/ %sleep ~]) =/ initted =< plow @@ -451,7 +533,7 @@ :^ //term/1 %boot & ?~ keys.ae [%fake who.ae] - [%dawn u.keys.ae] + [%dawn keys] -.userspace-ova.pil [//http-client/0v1n.2m9vh %born ~] [//http-server/0v1n.2m9vh %born ~] @@ -464,27 +546,36 @@ stop-processing-events:(pe who.ae) :: %snap-ships + =. this + %+ turn-ships (turn ~(tap by ships.piers) head) + |= [who=ship thus=_this] + =. this thus + (publish-effect:(pe who) [/ %kill ~]) =. fleet-snaps %+ ~(put by fleet-snaps) lab.ae + :_ azi.piers %- malt %+ murn hers.ae |= her=ship ^- (unit (pair ship pier)) - =+ per=(~(get by piers) her) + =+ per=(~(get by ships.piers) her) ?~ per ~ `[her u.per] + =. this stop-azimuth-timer + =. piers *fleet (pe -.hers.ae) :: %restore-snap =. this - %+ turn-ships (turn ~(tap by piers) head) + %+ turn-ships (turn ~(tap by ships.piers) head) |= [who=ship thus=_this] =. this thus - (publish-effect:(pe who) [/ %sleep ~]) - =. piers (~(uni by piers) (~(got by fleet-snaps) lab.ae)) + (publish-effect:(pe who) [/ %kill ~]) + =. piers (~(got by fleet-snaps) lab.ae) + =. this start-azimuth-timer =. this - %+ turn-ships (turn ~(tap by piers) head) + %+ turn-ships (turn ~(tap by ships.piers) head) |= [who=ship thus=_this] =. this thus (publish-effect:(pe who) [/ %restore ~]) @@ -537,18 +628,163 @@ ^- (unit (unit cage)) ?+ path ~ [%x %fleet-snap @ ~] ``noun+!>((~(has by fleet-snaps) i.t.t.path)) - [%x %ships ~] ``noun+!>((turn ~(tap by piers) head)) + [%x %fleets ~] ``noun+!>((turn ~(tap by fleet-snaps) head)) + [%x %ships ~] ``noun+!>((turn ~(tap by ships.piers) head)) [%x %pill ~] ``pill+!>(pil) [%x %i @ @ @ @ @ *] =/ who (slav %p i.t.t.path) - =/ pier (~(get by piers) who) + =/ pier (~(get by ships.piers) who) ?~ pier ~ :^ ~ ~ %noun !> (peek:(pe who) t.t.t.path) + [%x %log-info ~] + ``noun+!>([lives.azi.piers (lent logs.azi.piers) tym.azi.piers]) == :: :: Trivial scry for mock :: ++ scry |=([* *] ~) +:: +++ handle-wake + |= wen=@da + ^- (quip card:agent:gall _state) + =. this apex-aqua =< abet-aqua + ?. =(wen tym.azi.piers) + this + =. state (spam-logs 10) + start-azimuth-timer +:: +++ start-azimuth-timer + ^+ this + =? this !=(tym.azi.piers *@da) + stop-azimuth-timer + =/ until=@da (add now.hid ~s40) + =. tym.azi.piers until + %- emit-cards + [%pass /wait/(scot %da until) %arvo %b %wait until]~ +:: +++ stop-azimuth-timer + ^+ this + =* tym tym.azi.piers + ?: =(tym *@da) + this + %- emit-cards + [%pass /wait/(scot %da tym) %arvo %b %rest tym]~ +:: +++ spam-logs + |= n=@ + ^- _state + =* loop $ + ?: =(n 0) + state + =/ new-state=_state + ?. (~(has by lives.azi.piers) ~fes) + (spawn ~fes) + (cycle-keys ~fes) + =. state new-state + loop(n (dec n)) +:: +++ spawn + |= who=@p + ^- _state + ?< (~(has by lives.azi.piers) who) + =. lives.azi.piers (~(put by lives.azi.piers) who [1 0]) + =. logs.azi.piers + %+ weld logs.azi.piers + :_ ~ + %- changed-keys:lo:aqua-azimuth + :* who + (get-public:aqua-azimuth who 1 %crypt) + (get-public:aqua-azimuth who 1 %auth) + 1 + 1 + == + (spam-logs 10) +:: +++ cycle-keys + |= who=@p + ^- _state + =/ prev + ~| no-such-ship+who + (~(got by lives.azi.piers) who) + =/ lyfe +(lyfe.prev) + =. lives.azi.piers (~(put by lives.azi.piers) who [lyfe rut.prev]) + =. logs.azi.piers + %+ weld logs.azi.piers + :_ ~ + %- changed-keys:lo:aqua-azimuth + :* who + (get-public:aqua-azimuth who lyfe %crypt) + (get-public:aqua-azimuth who lyfe %auth) + 1 + lyfe + == + state +:: +++ breach + |= who=@p + ^- _state + =. state (cycle-keys who) + =/ prev (~(got by lives.azi.piers) who) + =/ rut +(rut.prev) + =. lives.azi.piers (~(put by lives.azi.piers) who [lyfe.prev rut]) + =. logs.azi.piers + %+ weld logs.azi.piers + [(broke-continuity:lo:aqua-azimuth who rut) ~] + (spam-logs 10) +:: +++ dawn + |= who=ship + ^- dawn-event:able:jael + ?> ?=(?(%czar %king %duke) (clan:title who)) + =/ spon=(list [ship point:azimuth]) + %- flop + |- ^- (list [ship point:azimuth]) + =/ =ship (^sein:title who) + =/ a-point=[^ship point:azimuth] + =/ spon-spon [& (^sein:title ship)] + =/ life-rift ~|([ship lives.azi.piers] (~(got by lives.azi.piers) ship)) + =/ =life lyfe.life-rift + =/ =rift rut.life-rift + =/ =pass + %^ pass-from-eth:azimuth + (as-octs:mimes:html (get-public:aqua-azimuth ship life %crypt)) + (as-octs:mimes:html (get-public:aqua-azimuth ship life %auth)) + 1 + :^ ship + *[address address address address]:azimuth + `[life=life pass rift spon-spon ~] + ~ + ?: ?=(%czar (clan:title ship)) + [a-point]~ + [a-point $(who ship)] + =/ =seed:able:jael + =/ life-rift (~(got by lives.azi.piers) who) + =/ =life lyfe.life-rift + [who life sec:ex:(get-keys:aqua-azimuth who life) ~] + :* seed + spon + get-czars + ~[~['arvo' 'netw' 'ork']] + 0 + `(need (de-purl:html 'http://localhost:8545')) + == +:: +:: Should only do galaxies +:: +++ get-czars + ^- (map ship [rift life pass]) + %- malt + %+ murn + ~(tap by lives.azi.piers) + |= [who=ship lyfe=life rut=rift] + ?. =(%czar (clan:title who)) + ~ + %- some + :^ who rut lyfe + %^ pass-from-eth:azimuth + (as-octs:mimes:html (get-public:aqua-azimuth who lyfe %crypt)) + (as-octs:mimes:html (get-public:aqua-azimuth who lyfe %auth)) + 1 -- diff --git a/pkg/arvo/lib/aqua-azimuth.hoon b/pkg/arvo/lib/aqua-azimuth.hoon new file mode 100644 index 0000000000..7120757527 --- /dev/null +++ b/pkg/arvo/lib/aqua-azimuth.hoon @@ -0,0 +1,241 @@ +/- *aquarium +:: +|% +:: +++ extract-request + |= [uf=unix-effect dest=@t] + ^- (unit [num=@ud =request:http]) + ?. ?=(%request -.q.uf) ~ + ?. =(dest url.request.q.uf) ~ + `[id.q.uf request.q.uf] +:: +++ router + |= [our=ship her=ship uf=unix-effect azi=az-state] + ^- (unit card:agent:gall) + =, enjs:format + =/ ask (extract-request uf 'http://localhost:8545/') + ?~ ask + ~ + ?~ body.request.u.ask + ~ + =/ req q.u.body.request.u.ask + |^ ^- (unit card:agent:gall) + =/ method (get-method req) + ?: =(method 'eth_blockNumber') + :- ~ + %+ answer-request req + s+(crip (num-to-hex:ethereum latest-block)) + ?: =(method 'eth_getBlockByNumber') + :- ~ + %+ answer-request req + :- %o + =/ number (hex-to-num:ethereum (get-first-param req)) + =/ hash (number-to-hash number) + =/ parent-hash (number-to-hash ?~(number number (dec number))) + %- malt + ^- (list (pair term json)) + :~ hash+s+(crip (prefix-hex:ethereum (render-hex-bytes:ethereum 32 hash))) + number+s+(crip (num-to-hex:ethereum number)) + 'parentHash'^s+(crip (num-to-hex:ethereum parent-hash)) + == + ?: =(method 'eth_getLogs') + :- ~ + %+ answer-request req + ?^ (get-param-obj-maybe req 'blockHash') + %- logs-by-hash + (get-param-obj req 'blockHash') + %+ logs-by-range + (get-param-obj req 'fromBlock') + (get-param-obj req 'toBlock') + ~& [%ph-azimuth-miss req] + ~ + :: + ++ latest-block + (add launch:contracts:azimuth (dec (lent logs.azi))) + :: + ++ get-single-req + |= req=@t + =/ batch + ((ar:dejs:format same) (need (de-json:html req))) + ?> ?=([* ~] batch) + i.batch + :: + ++ get-id + |= req=@t + =, dejs:format + %. (get-single-req req) + (ot id+so ~) + :: + ++ get-method + |= req=@t + =, dejs:format + ~| req=req + %. (get-single-req req) + (ot method+so ~) + :: + ++ get-param-obj + |= [req=@t param=@t] + =, dejs:format + %- hex-to-num:ethereum + =/ array + %. (get-single-req req) + (ot params+(ar (ot param^so ~)) ~) + ?> ?=([* ~] array) + i.array + :: + ++ get-param-obj-maybe + |= [req=@t param=@t] + ^- (unit @ud) + =, dejs-soft:format + =/ array + %. (get-single-req req) + (ot params+(ar (ot param^so ~)) ~) + ?~ array + ~ + :- ~ + ?> ?=([* ~] u.array) + %- hex-to-num:ethereum + i.u.array + :: + ++ get-first-param + |= req=@t + =, dejs:format + =/ id + %. (get-single-req req) + (ot params+(at so bo ~) ~) + -.id + :: + ++ answer-request + |= [req=@t result=json] + ^- card:agent:gall + =/ resp + %- crip + %- en-json:html + :- %a :_ ~ + %- pairs + :~ id+s+(get-id req) + jsonrpc+s+'2.0' + result+result + == + =/ events=(list aqua-event) + :_ ~ + :* %event + her + //http-client/0v1n.2m9vh + %receive + num.u.ask + [%start [200 ~] `(as-octs:mimes:html resp) &] + == + :* %pass /aqua-events + %agent [our %aqua] + %poke %aqua-events + !>(events) + == + :: + ++ number-to-hash + |= =number:block:able:jael + ^- @ + ?: (lth number launch:contracts:azimuth) + (cat 3 0x5364 (sub launch:contracts:azimuth number)) + (cat 3 0x5363 (sub number launch:contracts:azimuth)) + :: + ++ hash-to-number + |= =hash:block:able:jael + (add launch:contracts:azimuth (div hash 0x1.0000)) + :: + ++ logs-by-range + |= [from-block=@ud to-block=@ud] + %+ logs-to-json (max launch:contracts:azimuth from-block) + ?: (lth to-block launch:contracts:azimuth) + ~ + %+ swag + ?: (lth from-block launch:contracts:azimuth) + [0 +((sub to-block launch:contracts:azimuth))] + :- (sub from-block launch:contracts:azimuth) + +((sub to-block from-block)) + logs.azi + :: + ++ logs-by-hash + |= =hash:block:able:jael + =/ =number:block:able:jael (hash-to-number hash) + (logs-by-range number number) + :: + ++ logs-to-json + |= [count=@ud selected-logs=(list az-log)] + ^- json + :- %a + |- ^- (list json) + ?~ selected-logs + ~ + :_ $(selected-logs t.selected-logs, count +(count)) + %- pairs + :~ 'logIndex'^s+'0x0' + 'transactionIndex'^s+'0x0' + :+ 'transactionHash' %s + (crip (prefix-hex:ethereum (render-hex-bytes:ethereum 32 `@`0x5362))) + :: + :+ 'blockHash' %s + =/ hash (number-to-hash count) + (crip (prefix-hex:ethereum (render-hex-bytes:ethereum 32 hash))) + :: + :+ 'blockNumber' %s + (crip (num-to-hex:ethereum count)) + :: + :+ 'address' %s + (crip (address-to-hex:ethereum azimuth:contracts:azimuth)) + :: + 'type'^s+'mined' + :: + 'data'^s+data.i.selected-logs + :+ 'topics' %a + %+ turn topics.i.selected-logs + |= topic=@ux + ^- json + :- %s + %- crip + %- prefix-hex:ethereum + (render-hex-bytes:ethereum 32 `@`topic) + == + -- +:: +++ get-keys + |= [who=@p lyfe=life] + ^- acru:ames + %+ pit:nu:crub:crypto 32 + (can 5 [1 (scot %p who)] [1 (scot %ud lyfe)] ~) +:: +++ get-public + |= [who=@p lyfe=life typ=?(%auth %crypt)] + =/ bod (rsh 3 1 pub:ex:(get-keys who lyfe)) + =+ [enc=(rsh 8 1 bod) aut=(end 8 1 bod)] + ?: =(%auth typ) + aut + enc +:: +:: Generate logs +:: +++ lo + =, azimuth-events:azimuth + |% + ++ broke-continuity + |= [who=ship rut=rift] + ^- az-log + :- ~[^broke-continuity who] + %- crip + %- prefix-hex:ethereum + (render-hex-bytes:ethereum 32 `@`rut) + :: + ++ changed-keys + |= [who=ship enc=@ux aut=@ux crypto=@ud lyfe=life] + ^- az-log + :- ~[^changed-keys who] + %- crip + %- prefix-hex:ethereum + ;: welp + (render-hex-bytes:ethereum 32 `@`enc) + (render-hex-bytes:ethereum 32 `@`aut) + (render-hex-bytes:ethereum 32 `@`crypto) + (render-hex-bytes:ethereum 32 `@`lyfe) + == + -- +-- diff --git a/pkg/arvo/sur/aquarium.hoon b/pkg/arvo/sur/aquarium.hoon index db760b355f..d9fa4703eb 100644 --- a/pkg/arvo/sur/aquarium.hoon +++ b/pkg/arvo/sur/aquarium.hoon @@ -13,6 +13,12 @@ /+ pill =, pill-lib=pill |% ++$ az-log [topics=(lest @) data=@t] ++$ az-state + $: logs=(list az-log) + lives=(map ship [lyfe=life rut=rift]) + tym=@da + == ++ ph-event $% [%test-done p=?] aqua-event @@ -29,6 +35,12 @@ [%event who=ship ue=unix-event] == :: ++$ azimuth-action + $% [%init-azimuth ~] + [%spawn who=ship] + [%breach who=ship] + == +:: +$ aqua-effects [who=ship ufs=(list unix-effect)] :: @@ -57,6 +69,7 @@ [%ergo p=@tas q=mode:clay] [%sleep ~] [%restore ~] + [%kill ~] [%init ~] [%request id=@ud request=request:http] == diff --git a/pkg/arvo/ted/aqua/behn.hoon b/pkg/arvo/ted/aqua/behn.hoon index 274c45d0e9..9b7e477384 100644 --- a/pkg/arvo/ted/aqua/behn.hoon +++ b/pkg/arvo/ted/aqua/behn.hoon @@ -85,7 +85,7 @@ -- -- :: -%+ aqua-vane-thread ~[%sleep %restore %doze] +%+ aqua-vane-thread ~[%sleep %restore %doze %kill] |_ =bowl:spider +* this . ++ handle-unix-effect @@ -96,6 +96,7 @@ %sleep abet-pe:handle-sleep:(pe bowl who) %restore abet-pe:handle-restore:(pe bowl who) %doze abet-pe:(handle-doze:(pe bowl who) ue) + %kill `(~(del by piers) who) == [cards this] :: diff --git a/pkg/arvo/ted/aqua/dill.hoon b/pkg/arvo/ted/aqua/dill.hoon index adc03dc41d..e56120a64d 100644 --- a/pkg/arvo/ted/aqua/dill.hoon +++ b/pkg/arvo/ted/aqua/dill.hoon @@ -25,6 +25,7 @@ %sag ~& [%save-jamfile-to p.b] line %sav ~& [%save-file-to p.b] line %url ~& [%activate-url p.b] line + %klr ~& %unhandled-case-klr "" == ~? !=(~ last-line) last-line ~ diff --git a/pkg/arvo/ted/aqua/eyre.hoon b/pkg/arvo/ted/aqua/eyre.hoon index 9cfa5c285b..baf512012e 100644 --- a/pkg/arvo/ted/aqua/eyre.hoon +++ b/pkg/arvo/ted/aqua/eyre.hoon @@ -100,7 +100,7 @@ -- -- :: -%+ aqua-vane-thread ~[%sleep %restore %thus] +%+ aqua-vane-thread ~[%sleep %restore %thus %kill] |_ =bowl:spider +* this . ++ handle-unix-effect @@ -111,6 +111,7 @@ %sleep abet-pe:handle-sleep:(pe bowl who) %restore abet-pe:handle-restore:(pe bowl who) %thus abet-pe:(handle-thus:(pe bowl who) ue) + %kill `(~(del by piers) who) == [cards this] :: From e03a18bad3e244cdec52c0fcd740e87a957fb9df Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Mon, 30 Nov 2020 00:00:58 -0800 Subject: [PATCH 793/933] aqua: update and add new generators --- pkg/arvo/gen/aqua/breach.hoon | 4 ++++ pkg/arvo/gen/aqua/init-azimuth.hoon | 4 ++++ pkg/arvo/gen/aqua/init.hoon | 2 +- pkg/arvo/gen/aqua/restore-fleet.hoon | 4 ++-- pkg/arvo/gen/aqua/snap-fleet.hoon | 2 +- pkg/arvo/gen/aqua/spawn.hoon | 4 ++++ 6 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 pkg/arvo/gen/aqua/breach.hoon create mode 100644 pkg/arvo/gen/aqua/init-azimuth.hoon create mode 100644 pkg/arvo/gen/aqua/spawn.hoon diff --git a/pkg/arvo/gen/aqua/breach.hoon b/pkg/arvo/gen/aqua/breach.hoon new file mode 100644 index 0000000000..78de7b8b8d --- /dev/null +++ b/pkg/arvo/gen/aqua/breach.hoon @@ -0,0 +1,4 @@ +:- %say +|= [* [her=ship ~] ~] +:- %azimuth-action +[%breach her] diff --git a/pkg/arvo/gen/aqua/init-azimuth.hoon b/pkg/arvo/gen/aqua/init-azimuth.hoon new file mode 100644 index 0000000000..9d29181e7b --- /dev/null +++ b/pkg/arvo/gen/aqua/init-azimuth.hoon @@ -0,0 +1,4 @@ +:- %say +|= [* ~ ~] +:- %azimuth-action +[%init-azimuth ~] diff --git a/pkg/arvo/gen/aqua/init.hoon b/pkg/arvo/gen/aqua/init.hoon index 3aced4c2a4..a9777c1923 100644 --- a/pkg/arvo/gen/aqua/init.hoon +++ b/pkg/arvo/gen/aqua/init.hoon @@ -3,4 +3,4 @@ :- %say |= [* [her=ship ~] ~] :- %aqua-events -[%init-ship her ~]~ +[%init-ship her `*dawn-event:able:jael]~ diff --git a/pkg/arvo/gen/aqua/restore-fleet.hoon b/pkg/arvo/gen/aqua/restore-fleet.hoon index 3a38cdaee1..3fde261aff 100644 --- a/pkg/arvo/gen/aqua/restore-fleet.hoon +++ b/pkg/arvo/gen/aqua/restore-fleet.hoon @@ -1,6 +1,6 @@ /- aquarium =, aquarium :- %say -|= [* [label=@ta] ~] +|= [* [label=@ta ~] ~] :- %aqua-events -[%snap-ships label]~ +[%restore-snap label]~ diff --git a/pkg/arvo/gen/aqua/snap-fleet.hoon b/pkg/arvo/gen/aqua/snap-fleet.hoon index 6fcdf0ab35..208fc0d01b 100644 --- a/pkg/arvo/gen/aqua/snap-fleet.hoon +++ b/pkg/arvo/gen/aqua/snap-fleet.hoon @@ -1,7 +1,7 @@ /- aquarium =, aquarium :- %say -|= [[now=@da eny=@uvJ bec=beak] [label=@ta] ships=(list ship)] +|= [[now=@da eny=@uvJ bec=beak] [label=@ta ships=(list ship)] ~] :- %aqua-events =? ships ?=(~ ships) .^((list ship) %gx /(scot %p p.bec)/aqua/(scot %da now)/ships/noun) diff --git a/pkg/arvo/gen/aqua/spawn.hoon b/pkg/arvo/gen/aqua/spawn.hoon new file mode 100644 index 0000000000..fc7a679992 --- /dev/null +++ b/pkg/arvo/gen/aqua/spawn.hoon @@ -0,0 +1,4 @@ +:- %say +|= [* [her=ship ~] ~] +:- %azimuth-action +[%spawn her] From 5217a5c00e9b9aa0785f11485b2a7d598fad9f8e Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Mon, 30 Nov 2020 00:02:51 -0800 Subject: [PATCH 794/933] ph: add and modify some ph helper functions; adds new thread for booting/breaching in the new paradigm, as well as a helper thread for just starting drivers in case you want to manipulate aqua manually --- pkg/arvo/lib/ph/io.hoon | 74 +++++++++++++++++++++++++++-- pkg/arvo/lib/strandio.hoon | 3 +- pkg/arvo/ted/ph/breach-hi-aqua.hoon | 19 ++++++++ pkg/arvo/ted/ph/start-drivers.hoon | 13 +++++ 4 files changed, 104 insertions(+), 5 deletions(-) create mode 100644 pkg/arvo/ted/ph/breach-hi-aqua.hoon create mode 100644 pkg/arvo/ted/ph/start-drivers.hoon diff --git a/pkg/arvo/lib/ph/io.hoon b/pkg/arvo/lib/ph/io.hoon index 58400579d8..4433670ca3 100644 --- a/pkg/arvo/lib/ph/io.hoon +++ b/pkg/arvo/lib/ph/io.hoon @@ -8,6 +8,12 @@ ^- form:m (poke-our %aqua %aqua-events !>(events)) :: +++ send-azimuth-action + |= =azimuth-action + =/ m (strand ,~) + ^- form:m + (poke-our %aqua %azimuth-action !>(azimuth-action)) +:: ++ take-unix-effect =/ m (strand ,[ship unix-effect]) ^- form:m @@ -34,7 +40,7 @@ =/ m (strand ,~) ^- form:m ~& > "starting" - ;< ~ bind:m (start-threads vane-threads) + ;< tids=(map term tid:spider) bind:m (start-threads vane-threads) ;< ~ bind:m (watch-our /effect %aqua /effect) :: Get our very own event with no mistakes in it... yet. :: @@ -64,16 +70,20 @@ :: ++ start-threads |= threads=(list term) - =/ m (strand ,~) + =/ m (strand ,(map term tid:spider)) ^- form:m ;< =bowl:spider bind:m get-bowl + =| tids=(map term tid:spider) |- ^- form:m =* loop $ ?~ threads - (pure:m ~) + (pure:m tids) + =/ tid + %+ scot %ta + (cat 3 (cat 3 'strand_' i.threads) (scot %uv (sham i.threads eny.bowl))) =/ poke-vase !>([`tid.bowl ~ i.threads *vase]) ;< ~ bind:m (poke-our %spider %spider-start poke-vase) - loop(threads t.threads) + loop(threads t.threads, tids (~(put by tids) i.threads tid)) :: ++ stop-threads |= threads=(list term) @@ -81,6 +91,29 @@ ^- form:m (pure:m ~) :: +:: XX +spawn-aqua and +breach-aqua mean do these actions using aqua's internal +:: azimuth management system, eventually these should just replace +spawn +:: +breach +:: +++ init-azimuth + =/ m (strand ,~) + ^- form:m + (send-azimuth-action %init-azimuth ~) +:: +++ spawn-aqua + |= =ship + ~& > "spawning {}" + =/ m (strand ,~) + ^- form:m + (send-azimuth-action %spawn ship) +:: +++ breach-aqua + |= =ship + ~& > "breaching {}" + =/ m (strand ,~) + ^- form:m + (send-azimuth-action %breach ship) +:: ++ spawn |= [=tid:spider =ship] ~& > "spawning {}" @@ -127,6 +160,39 @@ (pure:m ~) loop :: +++ breach-and-hear-aqua + |= [who=ship her=ship] + =/ m (strand ,~) + ;< =bowl:spider bind:m get-bowl + =/ aqua-pax + :- %i + /(scot %p her)/j/(scot %p her)/rift/(scot %da now.bowl)/(scot %p who)/noun + =/ old-rut ;;((unit @) (scry-aqua:util noun our.bowl now.bowl aqua-pax)) + =/ new-rut + ?~ old-rut + 1 + +(+.old-rut) + ;< ~ bind:m (send-azimuth-action %breach who) + |- ^- form:m + =* loop $ + ;< ~ bind:m (sleep ~s1) + ;< =bowl:spider bind:m get-bowl + =/ aqua-pax + :- %i + /(scot %p her)/j/(scot %p her)/rift/(scot %da now.bowl)/(scot %p who)/noun + =/ rut (scry-aqua:util noun our.bowl now.bowl aqua-pax) + ?: =([~ new-rut] rut) + (pure:m ~) + loop +:: +++ init-ship + |= =ship + =/ m (strand ,~) + ^- form:m + ~& > "starting {}" + ;< ~ bind:m (send-events (init:util ship `*dawn-event:able:jael)) + (check-ship-booted ship) +:: ++ real-ship |= [=tid:spider =ship] ~& > "booting real {}" diff --git a/pkg/arvo/lib/strandio.hoon b/pkg/arvo/lib/strandio.hoon index 80c4178a1e..050c92f40f 100644 --- a/pkg/arvo/lib/strandio.hoon +++ b/pkg/arvo/lib/strandio.hoon @@ -654,7 +654,8 @@ =/ m (strand ,tid:spider) ^- form:m ;< =bowl:spider bind:m get-bowl - =/ tid (scot %ta (cat 3 'strand_' (scot %uv (sham file eny.bowl)))) + =/ tid + (scot %ta (cat 3 (cat 3 'strand_' file) (scot %uv (sham file eny.bowl)))) =/ poke-vase !>([`tid.bowl `tid file *vase]) ;< ~ bind:m (poke-our %spider %spider-start poke-vase) ;< ~ bind:m (sleep ~s0) :: wait for thread to start diff --git a/pkg/arvo/ted/ph/breach-hi-aqua.hoon b/pkg/arvo/ted/ph/breach-hi-aqua.hoon new file mode 100644 index 0000000000..473ddb846b --- /dev/null +++ b/pkg/arvo/ted/ph/breach-hi-aqua.hoon @@ -0,0 +1,19 @@ +/- spider +/+ *ph-io, *ph-util +=, strand=strand:spider +^- thread:spider +|= vase +=/ m (strand ,vase) +;< =bowl:spider bind:m get-bowl +;< ~ bind:m start-simple +;< ~ bind:m init-azimuth +;< ~ bind:m (spawn-aqua ~bud) +;< ~ bind:m (spawn-aqua ~dev) +;< ~ bind:m (init-ship ~bud) +;< ~ bind:m (init-ship ~dev) +;< ~ bind:m (send-hi ~bud ~dev) +;< ~ bind:m (breach-and-hear-aqua ~dev ~bud) +;< ~ bind:m (send-hi-not-responding ~bud ~dev) +;< ~ bind:m (init-ship ~dev) +;< ~ bind:m (wait-for-output ~bud "hi ~dev successful") +(pure:m *vase) diff --git a/pkg/arvo/ted/ph/start-drivers.hoon b/pkg/arvo/ted/ph/start-drivers.hoon new file mode 100644 index 0000000000..825a2b814a --- /dev/null +++ b/pkg/arvo/ted/ph/start-drivers.hoon @@ -0,0 +1,13 @@ +/- spider +/+ *ph-io, *ph-util +=, strand=strand:spider +^- thread:spider +|= vase +=/ m (strand ,vase) +;< =bowl:spider bind:m get-bowl +;< ~ bind:m start-simple +|- +=* loop $ +~& >> %looping +;< ~ bind:m (sleep ~s5) +loop From d7c740b32aeefa2b865ad41a96812f5b073410a4 Mon Sep 17 00:00:00 2001 From: fang Date: Mon, 30 Nov 2020 22:35:22 +0100 Subject: [PATCH 795/933] jael: add %vile scry endpoint for current keyfile --- pkg/arvo/sys/vane/jael.hoon | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/arvo/sys/vane/jael.hoon b/pkg/arvo/sys/vane/jael.hoon index 401eb41abc..26ec3a2334 100644 --- a/pkg/arvo/sys/vane/jael.hoon +++ b/pkg/arvo/sys/vane/jael.hoon @@ -1156,6 +1156,11 @@ [~ ~] :: [~ ~ %noun !>(u.r)] + :: + %vile + =* life lyf.own.pki.lex + =/ =seed [our life (~(got by jaw.own.pki.lex) life) ~] + [~ ~ %atom !>((jam seed))] :: %deed ?. ?=([@ @ ~] tyl) [~ ~] From 8f22a9a501c7e30801f17e8b7953fac8b7cb28ea Mon Sep 17 00:00:00 2001 From: fang Date: Mon, 30 Nov 2020 22:50:12 +0100 Subject: [PATCH 796/933] vere: add -O for exporting keyfile For integration with other flagday-related logic. --- pkg/urbit/daemon/main.c | 4 +++- pkg/urbit/include/c/motes.h | 2 ++ pkg/urbit/include/vere/vere.h | 1 + pkg/urbit/vere/pier.c | 22 ++++++++++++++++++++-- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/pkg/urbit/daemon/main.c b/pkg/urbit/daemon/main.c index 4ef173240c..28d0eee426 100644 --- a/pkg/urbit/daemon/main.c +++ b/pkg/urbit/daemon/main.c @@ -75,6 +75,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.dem = c3n; u3_Host.ops_u.dry = c3n; u3_Host.ops_u.exp = c3n; + u3_Host.ops_u.kex = c3n; u3_Host.ops_u.gab = c3n; u3_Host.ops_u.git = c3n; @@ -97,7 +98,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.kno_w = DefaultKernel; while ( -1 != (ch_i=getopt(argc, argv, - "X:Y:G:J:B:K:A:H:I:C:w:u:e:F:k:n:p:r:i:LljacdgoqstvxPDRS")) ) + "X:Y:G:J:B:K:A:H:I:C:w:u:e:F:k:n:p:r:i:LljacdgoqstvxOPDRS")) ) { switch ( ch_i ) { case 'X': { @@ -200,6 +201,7 @@ _main_getopt(c3_i argc, c3_c** argv) case 'd': { u3_Host.ops_u.dem = c3y; break; } case 'g': { u3_Host.ops_u.gab = c3y; break; } case 'o': { u3_Host.ops_u.exp = c3y; break; } + case 'O': { u3_Host.ops_u.kex = c3y; break; } case 'P': { u3_Host.ops_u.pro = c3y; break; } case 'D': { u3_Host.ops_u.dry = c3y; break; } case 'q': { u3_Host.ops_u.qui = c3y; break; } diff --git a/pkg/urbit/include/c/motes.h b/pkg/urbit/include/c/motes.h index 6765024610..e535681f92 100644 --- a/pkg/urbit/include/c/motes.h +++ b/pkg/urbit/include/c/motes.h @@ -592,6 +592,7 @@ # define c3__is c3_s2('i','s') # define c3__item c3_s4('i','t','e','m') # define c3__ix c3_s2('i','x') +# define c3__j c3_s1('j') # define c3__jack c3_s4('j','a','c','k') # define c3__jamx c3_s4('j','a','m','x') # define c3__jamz c3_s4('j','a','m','z') @@ -1208,6 +1209,7 @@ # define c3__vern c3_s4('v','e','r','n') # define c3__very c3_s4('v','e','r','y') # define c3__view c3_s4('v','i','e','w') +# define c3__vile c3_s4('v','i','l','e') # define c3__vint c3_s4('v','i','n','t') # define c3__void c3_s4('v','o','i','d') # define c3__vorp c3_s4('v','o','r','p') diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index ba38d0c666..d484dfca02 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -267,6 +267,7 @@ c3_c* jin_c; // -I, inject raw event c3_c* imp_c; // -i, import pier state c3_o exp; // -o, export pier state + c3_o kex; // -O, export keyfile c3_w hap_w; // -C, cap memo cache c3_c* lit_c; // -J, ivory (fastboot) kernel c3_o tra; // -j, json trace diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index 289f1768a9..b57fcc1baf 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -510,9 +510,20 @@ _pier_on_scry_done(void* ptr_v, u3_noun nun) } c3_c fil_c[2048]; - snprintf(fil_c, 2048, "%s/.urb/put/%s.jam", pir_u->pax_c, pac_c+1); + snprintf(fil_c, 2048, "%s/.urb/put/%s.%s", pir_u->pax_c, pac_c+1, + (c3y == u3_Host.ops_u.kex) ? "key" : "jam"); - u3_walk_save(fil_c, 0, u3qe_jam(res), pir_u->pax_c, pad); + // if this was a keyfile scry, serialize it as @uw, + // otherwise, write it to a jamfile + // + //TODO support broader control over output format + // + if ( c3y == u3_Host.ops_u.kex ) { + u3_atom out = u3dc("scot", c3__uw, u3k(res)); + u3_walk_save(fil_c, 0, out, pir_u->pax_c, pad); + } else { + u3_walk_save(fil_c, 0, u3qe_jam(res), pir_u->pax_c, pad); + } u3l_log("pier: scry in %s\n", fil_c); } @@ -623,6 +634,13 @@ _pier_work_init(u3_pier* pir_u) u3z(pex); } + else if ( _(u3_Host.ops_u.kex) ) { + if (!u3_Host.ops_u.puk_c) { + u3_Host.ops_u.puk_c = strdup("/archive/keyfile"); + } + u3_pier_peek_last(pir_u, u3_nul, c3__j, c3__vile, u3_nul, + pir_u, _pier_on_scry_done); + } else { // initialize i/o drivers // From 99293c1e9094c23d679ac2f3b3d58902cf493f54 Mon Sep 17 00:00:00 2001 From: Tyler Brown Cifu Shuster Date: Sun, 22 Nov 2020 13:59:43 -0800 Subject: [PATCH 797/933] groups: better ship search validation Fixes #3824 --- .../src/views/components/DropdownSearch.tsx | 10 ++- .../src/views/components/ShipSearch.tsx | 73 ++++++++++++++++--- .../landscape/components/InvitePopover.tsx | 22 +++--- 3 files changed, 81 insertions(+), 24 deletions(-) diff --git a/pkg/interface/src/views/components/DropdownSearch.tsx b/pkg/interface/src/views/components/DropdownSearch.tsx index 9829058916..6a12e5acdd 100644 --- a/pkg/interface/src/views/components/DropdownSearch.tsx +++ b/pkg/interface/src/views/components/DropdownSearch.tsx @@ -35,6 +35,8 @@ interface DropdownSearchExtraProps { onSelect: (c: C) => void; disabled?: boolean; placeholder?: string; + onChange?: (e: ChangeEvent) => void; + onBlur?: (e: any) => void; } type DropdownSearchProps = PropFunc & @@ -51,6 +53,8 @@ export function DropdownSearch(props: DropdownSearchProps) { renderCandidate, disabled, placeholder, + onChange = () => {}, + onBlur = () => {}, ...rest } = props; @@ -101,8 +105,9 @@ export function DropdownSearch(props: DropdownSearchProps) { }; }, [textarea.current, next, back, onEnter]); - const onChange = useCallback( + const changeCallback = useCallback( (e: ChangeEvent) => { + onChange(e); search(e.target.value); setQuery(e.target.value); }, @@ -128,11 +133,12 @@ export function DropdownSearch(props: DropdownSearchProps) { {dropdown.length !== 0 && query.length !== 0 && ( ( export function ShipSearch(props: InviteSearchProps) { const { id, label, caption } = props; - const [{ value }, { error }, { setValue, setTouched }] = useField( - props.id + const [{}, meta, { setValue, setTouched, setError: _setError }] = useField({ + name: id, + multiple: true + }); + + const setError = _setError as unknown as (s: string | undefined) => void; + + const { error, touched } = meta; + + const [selected, setSelected] = useState([] as string[]); + const [inputShip, setInputShip] = useState(undefined as string | undefined); + const [inputTouched, setInputTouched] = useState(false); + + const checkInput = useCallback((valid: boolean, ship: string | undefined) => { + if(valid) { + setInputShip(ship); + setError(error === INVALID_SHIP_ERR ? undefined : error); + } else { + setError(INVALID_SHIP_ERR); + setInputTouched(false); + } + }, [setError, error, setInputTouched, setInputShip]); + + const onChange = useCallback( + (e: any) => { + let ship = `~${deSig(e.target.value) || ""}`; + if(ob.isValidPatp(ship)) { + checkInput(true, ship); + } else { + checkInput(ship.length !== 1, undefined) + } + }, + [checkInput] ); + const onBlur = useCallback(() => { + setInputTouched(true); + }, [setInputTouched]); + const onSelect = useCallback( (s: string) => { setTouched(true); - setValue([...value, s]); + checkInput(true, undefined); + s = `~${deSig(s)}`; + setSelected(v => _.uniq([...v, s])) }, - [setValue, value] + [setTouched, checkInput, setSelected] ); const onRemove = useCallback( (s: string) => { - setValue(value.filter((v) => v !== s)); + setSelected(ships => ships.filter(ship => ship !== s)) }, - [setValue, value] + [setSelected] ); + useEffect(() => { + const newValue = inputShip ? [...selected, inputShip] : selected; + setValue(newValue); + }, [inputShip, selected]) + const [peers, nicknames] = useMemo(() => { const peerSet = new Set(); const contacts = new Map(); @@ -125,20 +169,22 @@ export function ShipSearch(props: InviteSearchProps) { isExact={(s) => { const ship = `~${deSig(s)}`; const result = ob.isValidPatp(ship); - return result ? deSig(s) : undefined; + return result ? deSig(s) ?? undefined : undefined; }} placeholder="Search for ships" candidates={peers} renderCandidate={renderCandidate} - disabled={props.maxLength ? value.length >= props.maxLength : false} + disabled={props.maxLength ? selected.length >= props.maxLength : false} search={(s: string, t: string) => t.toLowerCase().startsWith(s.toLowerCase()) } getKey={(s: string) => s} onSelect={onSelect} + onChange={onChange} + onBlur={onBlur} /> - {value.map((s) => ( + {selected.map((s) => ( ))} + + {error} + ); } diff --git a/pkg/interface/src/views/landscape/components/InvitePopover.tsx b/pkg/interface/src/views/landscape/components/InvitePopover.tsx index 2aac6d151b..4c6a20acb5 100644 --- a/pkg/interface/src/views/landscape/components/InvitePopover.tsx +++ b/pkg/interface/src/views/landscape/components/InvitePopover.tsx @@ -1,18 +1,18 @@ import React, { useCallback, useRef, useMemo } from "react"; -import { Box, Text, Col, Button, Row } from "@tlon/indigo-react"; +import { Switch, Route, useHistory } from "react-router-dom"; +import { Formik, Form } from "formik"; import * as Yup from 'yup'; +import { Box, Text, Col, Button, Row } from "@tlon/indigo-react"; import { ShipSearch } from "~/views/components/ShipSearch"; import { Association } from "~/types/metadata-update"; -import { Switch, Route, useHistory } from "react-router-dom"; -import { Formik, Form } from "formik"; import { AsyncButton } from "~/views/components/AsyncButton"; import { useOutsideClick } from "~/logic/lib/useOutsideClick"; import { FormError } from "~/views/components/FormError"; import { resourceFromPath } from "~/logic/lib/group"; import GlobalApi from "~/logic/api/global"; import { Groups, Rolodex, Workspace } from "~/types"; -import { ChipInput } from "~/views/components/ChipInput"; +import { deSig } from "~/logic/lib/util"; interface InvitePopoverProps { baseUrl: string; @@ -30,7 +30,7 @@ interface FormSchema { const formSchema = Yup.object({ emails: Yup.array(Yup.string().email("Invalid email")), - ships: Yup.array(Yup.string()) + ships: Yup.array(Yup.string()).min(1, "Must invite at least one ship") }); export function InvitePopover(props: InvitePopoverProps) { @@ -48,14 +48,14 @@ export function InvitePopover(props: InvitePopoverProps) { const onSubmit = async ({ ships, emails }: { ships: string[] }, actions) => { if(props.workspace.type === 'home') { - history.push(`/~landscape/dm/${ships[0]}`); + history.push(`/~landscape/dm/${deSig(ships[0])}`); return; } // TODO: how to invite via email? try { const resource = resourceFromPath(association["group-path"]); await ships.reduce( - (acc, s) => acc.then(() => api.contacts.invite(resource, `~${s}`)), + (acc, s) => acc.then(() => api.contacts.invite(resource, `~${deSig(s)}`)), Promise.resolve() ); actions.setStatus({ success: null }); @@ -97,9 +97,10 @@ export function InvitePopover(props: InvitePopoverProps) { initialValues={initialValues} onSubmit={onSubmit} validationSchema={formSchema} + validateOnBlur >
- + Invite to {title || "DM"} @@ -122,13 +123,12 @@ export function InvitePopover(props: InvitePopoverProps) { /> */} Send From a6bf3ca92420d6fa791b24a2e3d1071f4f5509b7 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Mon, 30 Nov 2020 16:20:26 -0600 Subject: [PATCH 798/933] observe-hook + thread: remove metadata when leaving a group --- pkg/arvo/app/observe-hook.hoon | 13 ++++++-- pkg/arvo/ted/group/leave-metadata.hoon | 43 ++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 pkg/arvo/ted/group/leave-metadata.hoon diff --git a/pkg/arvo/app/observe-hook.hoon b/pkg/arvo/app/observe-hook.hoon index 28d6291695..720d81627c 100644 --- a/pkg/arvo/app/observe-hook.hoon +++ b/pkg/arvo/app/observe-hook.hoon @@ -11,11 +11,13 @@ +$ versioned-state $% state-0 state-1 + state-2 == :: +$ serial @uv +$ state-0 [%0 observers=(map serial observer:sur)] +$ state-1 [%1 observers=(map serial observer:sur)] ++$ state-1 [%2 observers=(map serial observer:sur)] :: ++ got-by-val |= [a=(map serial observer:sur) b=observer:sur] @@ -27,7 +29,7 @@ -- :: %- agent:dbug -=| state-1 +=| state-2 =* state - :: ^- agent:gall @@ -67,7 +69,14 @@ ^- (quip card _this) =/ old-state !<(versioned-state old-vase) ?- -.old-state - %1 `this(state old-state) + %2 `this(state old-state) + :: + %1 + =. state [%2 observers.old-state] + %+ on-poke + %observe-action + !> ^- action:sur + [%watch %group-store /groups %group-leave-metadata] :: %0 =. state [%1 observers.old-state] diff --git a/pkg/arvo/ted/group/leave-metadata.hoon b/pkg/arvo/ted/group/leave-metadata.hoon new file mode 100644 index 0000000000..5056f4389a --- /dev/null +++ b/pkg/arvo/ted/group/leave-metadata.hoon @@ -0,0 +1,43 @@ +/- spider, grp=group-store, met=metadata-store, hook=metadata-hook +/+ strandio, res=resource +:: +=* strand strand:spider +=* raw-poke raw-poke:strandio +=* scry scry:strandio +:: +^- thread:spider +|= arg=vase +=/ m (strand ,vase) +^- form:m +=+ !<([=update:grp ~] arg) +?. ?=(%remove-group -.update) + (pure:m !>(~)) +;< =bowl:spider bind:m get-bowl:strandio +;< ~ bind:m + %+ raw-poke + [our.bowl %metadata-hook] + :- %metadata-hook-action + !> ^- metadata-hook-action:hook + [%remove (en-path:res resource.update)] +:: +:: get metadata associated with group and remove it +;< =associations:met bind:m + %+ scry associations:met + ;: weld + /gx/metadata-store/group + (en-path:res resource.update) + /noun + == +=/ entries=(list [g=group-path:met m=md-resource:met]) + ~(tap in ~(key by associations)) +|- ^- form:m +=* loop $ +?~ entries + (pure:m !>(~)) +;< ~ bind:m + %+ raw-poke + [our.bowl %metadata-store] + :- %metadata-action + !> ^- metadata-action:met + [%remove g.i.entries m.i.entries] +loop(entries t.entries) From 6c26a01655cb3b8e57f5b8735c49843ffc44449e Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Mon, 30 Nov 2020 16:22:20 -0600 Subject: [PATCH 799/933] contact-view: remove (now) unnecessary metadata removal --- pkg/arvo/app/contact-view.hoon | 8 -------- 1 file changed, 8 deletions(-) diff --git a/pkg/arvo/app/contact-view.hoon b/pkg/arvo/app/contact-view.hoon index 2abbbb0f67..198d4362ce 100644 --- a/pkg/arvo/app/contact-view.hoon +++ b/pkg/arvo/app/contact-view.hoon @@ -195,7 +195,6 @@ (group-poke [%remove-group rid ~]) (contact-poke [%delete path.act]) == - (delete-metadata path.act) == :: %remove @@ -357,13 +356,6 @@ (metadata-hook-poke [%add-owned path]) == :: -++ delete-metadata - |= =path - ^- (list card) - :~ (metadata-poke [%remove path [%contacts path]]) - (metadata-hook-poke [%remove path]) - == -:: ++ all-scry ^- rolodex .^(rolodex %gx /(scot %p our.bol)/contact-store/(scot %da now.bol)/all/noun) From 41e3af25b34190a443ee3e5def76cdaf6f866ca8 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Mon, 30 Nov 2020 16:30:20 -0600 Subject: [PATCH 800/933] threads: collapse them into a single %group-on-leave thread --- pkg/arvo/app/observe-hook.hoon | 15 ++---- pkg/arvo/ted/group/leave-graph.hoon | 40 --------------- pkg/arvo/ted/group/leave-metadata.hoon | 50 ++++++++++++++----- pkg/arvo/ted/group/on-leave.hoon | 69 ++++++++++++++++++++++++++ 4 files changed, 110 insertions(+), 64 deletions(-) delete mode 100644 pkg/arvo/ted/group/leave-graph.hoon create mode 100644 pkg/arvo/ted/group/on-leave.hoon diff --git a/pkg/arvo/app/observe-hook.hoon b/pkg/arvo/app/observe-hook.hoon index 720d81627c..da2f3b8ba5 100644 --- a/pkg/arvo/app/observe-hook.hoon +++ b/pkg/arvo/app/observe-hook.hoon @@ -11,13 +11,11 @@ +$ versioned-state $% state-0 state-1 - state-2 == :: +$ serial @uv +$ state-0 [%0 observers=(map serial observer:sur)] +$ state-1 [%1 observers=(map serial observer:sur)] -+$ state-1 [%2 observers=(map serial observer:sur)] :: ++ got-by-val |= [a=(map serial observer:sur) b=observer:sur] @@ -46,7 +44,7 @@ :: %+ act /grp-gra - [%watch %group-store /groups %group-leave-graph] + [%watch %group-store /groups %group-on-leave] == :: ++ act @@ -69,21 +67,14 @@ ^- (quip card _this) =/ old-state !<(versioned-state old-vase) ?- -.old-state - %2 `this(state old-state) - :: - %1 - =. state [%2 observers.old-state] - %+ on-poke - %observe-action - !> ^- action:sur - [%watch %group-store /groups %group-leave-metadata] + %1 `this(state old-state) :: %0 =. state [%1 observers.old-state] %+ on-poke %observe-action !> ^- action:sur - [%watch %group-store /groups %group-leave-graph] + [%watch %group-store /groups %group-on-leave] == :: ++ on-poke diff --git a/pkg/arvo/ted/group/leave-graph.hoon b/pkg/arvo/ted/group/leave-graph.hoon deleted file mode 100644 index ff0b8fb72c..0000000000 --- a/pkg/arvo/ted/group/leave-graph.hoon +++ /dev/null @@ -1,40 +0,0 @@ -/- spider, grp=group-store, gra=graph-store, met=metadata-store -/+ strandio, res=resource -:: -=* strand strand:spider -=* raw-poke raw-poke:strandio -=* scry scry:strandio -:: -^- thread:spider -|= arg=vase -=/ m (strand ,vase) -^- form:m -=+ !<([=update:grp ~] arg) -?. ?=(%remove-group -.update) - (pure:m !>(~)) -:: -:: get graphs associated with group and archive them -;< =associations:met bind:m - %+ scry associations:met - ;: weld - /gx/metadata-store/group - (en-path:res resource.update) - /noun - == -=/ graphs=(list path) - %+ turn ~(tap in ~(key by associations)) - |= [g=group-path:met m=md-resource:met] - ^- path - app-path.m -;< =bowl:spider bind:m get-bowl:strandio -|- ^- form:m -=* loop $ -?~ graphs - (pure:m !>(~)) -;< ~ bind:m - %+ raw-poke - [our.bowl %graph-store] - :- %graph-update - !> ^- update:gra - [%0 now.bowl [%archive-graph (de-path:res i.graphs)]] -loop(graphs t.graphs) diff --git a/pkg/arvo/ted/group/leave-metadata.hoon b/pkg/arvo/ted/group/leave-metadata.hoon index 5056f4389a..bf235b0298 100644 --- a/pkg/arvo/ted/group/leave-metadata.hoon +++ b/pkg/arvo/ted/group/leave-metadata.hoon @@ -5,6 +5,37 @@ =* raw-poke raw-poke:strandio =* scry scry:strandio :: +=> +|% +++ remove-metadata + |= entries=(list [g=group-path:met m=md-resource:met]) + ^- form:m + |- ^- form:m + =* loop $ + ?~ entries + (pure:m !>(~)) + ;< ~ bind:m + %+ raw-poke + [our.bowl %metadata-store] + :- %metadata-action + !> ^- metadata-action:met + [%remove g.i.entries m.i.entries] + loop(entries t.entries) +:: +++ archive-graphs + |= graphs=(list path) + |- ^- form:m + =* loop $ + ?~ graphs + (pure:m !>(~)) + ;< ~ bind:m + %+ raw-poke + [our.bowl %graph-store] + :- %graph-update + !> ^- update:gra + [%0 now.bowl [%archive-graph (de-path:res i.graphs)]] + loop(graphs t.graphs) +-- ^- thread:spider |= arg=vase =/ m (strand ,vase) @@ -28,16 +59,11 @@ (en-path:res resource.update) /noun == -=/ entries=(list [g=group-path:met m=md-resource:met]) - ~(tap in ~(key by associations)) -|- ^- form:m -=* loop $ -?~ entries - (pure:m !>(~)) ;< ~ bind:m - %+ raw-poke - [our.bowl %metadata-store] - :- %metadata-action - !> ^- metadata-action:met - [%remove g.i.entries m.i.entries] -loop(entries t.entries) + (remove-metadata ~(tap in ~(key by associations))) +=/ graphs=(list path) + %+ turn ~(tap in ~(key by associations)) + |= [g=group-path:met m=md-resource:met] + ^- path + app-path.m +(archive-graphs graphs) diff --git a/pkg/arvo/ted/group/on-leave.hoon b/pkg/arvo/ted/group/on-leave.hoon new file mode 100644 index 0000000000..dfff1b179a --- /dev/null +++ b/pkg/arvo/ted/group/on-leave.hoon @@ -0,0 +1,69 @@ +/- spider, grp=group-store, gra=graph-store, met=metadata-store, hook=metadata-hook +/+ strandio, res=resource +:: +=* strand strand:spider +=* raw-poke raw-poke:strandio +=* scry scry:strandio +:: +=> +|% +++ remove-metadata + |= entries=(list [g=group-path:met m=md-resource:met]) + ^- form:m + |- ^- form:m + =* loop $ + ?~ entries + (pure:m !>(~)) + ;< ~ bind:m + %+ raw-poke + [our.bowl %metadata-store] + :- %metadata-action + !> ^- metadata-action:met + [%remove g.i.entries m.i.entries] + loop(entries t.entries) +:: +++ archive-graphs + |= graphs=(list path) + |- ^- form:m + =* loop $ + ?~ graphs + (pure:m !>(~)) + ;< ~ bind:m + %+ raw-poke + [our.bowl %graph-store] + :- %graph-update + !> ^- update:gra + [%0 now.bowl [%archive-graph (de-path:res i.graphs)]] + loop(graphs t.graphs) +-- +^- thread:spider +|= arg=vase +=/ m (strand ,vase) +^- form:m +=+ !<([=update:grp ~] arg) +?. ?=(%remove-group -.update) + (pure:m !>(~)) +;< =bowl:spider bind:m get-bowl:strandio +;< ~ bind:m + %+ raw-poke + [our.bowl %metadata-hook] + :- %metadata-hook-action + !> ^- metadata-hook-action:hook + [%remove (en-path:res resource.update)] +:: +:: get metadata associated with group and remove it +;< =associations:met bind:m + %+ scry associations:met + ;: weld + /gx/metadata-store/group + (en-path:res resource.update) + /noun + == +;< ~ bind:m + (remove-metadata ~(tap in ~(key by associations))) +=/ graphs=(list path) + %+ turn ~(tap in ~(key by associations)) + |= [g=group-path:met m=md-resource:met] + ^- path + app-path.m +(archive-graphs graphs) From 1b0e19eb515598dfd011060482494c5e45dfdb68 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Mon, 30 Nov 2020 16:32:53 -0600 Subject: [PATCH 801/933] observe-hook: state-2 typo --- pkg/arvo/app/observe-hook.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/arvo/app/observe-hook.hoon b/pkg/arvo/app/observe-hook.hoon index da2f3b8ba5..9f93de49a1 100644 --- a/pkg/arvo/app/observe-hook.hoon +++ b/pkg/arvo/app/observe-hook.hoon @@ -27,7 +27,7 @@ -- :: %- agent:dbug -=| state-2 +=| state-1 =* state - :: ^- agent:gall From 2a47b18be71a0adb8d3d59bc2da0118ed63e3916 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Mon, 30 Nov 2020 16:33:48 -0600 Subject: [PATCH 802/933] thread: remove group-leave-metadata --- pkg/arvo/ted/group/leave-metadata.hoon | 69 -------------------------- 1 file changed, 69 deletions(-) delete mode 100644 pkg/arvo/ted/group/leave-metadata.hoon diff --git a/pkg/arvo/ted/group/leave-metadata.hoon b/pkg/arvo/ted/group/leave-metadata.hoon deleted file mode 100644 index bf235b0298..0000000000 --- a/pkg/arvo/ted/group/leave-metadata.hoon +++ /dev/null @@ -1,69 +0,0 @@ -/- spider, grp=group-store, met=metadata-store, hook=metadata-hook -/+ strandio, res=resource -:: -=* strand strand:spider -=* raw-poke raw-poke:strandio -=* scry scry:strandio -:: -=> -|% -++ remove-metadata - |= entries=(list [g=group-path:met m=md-resource:met]) - ^- form:m - |- ^- form:m - =* loop $ - ?~ entries - (pure:m !>(~)) - ;< ~ bind:m - %+ raw-poke - [our.bowl %metadata-store] - :- %metadata-action - !> ^- metadata-action:met - [%remove g.i.entries m.i.entries] - loop(entries t.entries) -:: -++ archive-graphs - |= graphs=(list path) - |- ^- form:m - =* loop $ - ?~ graphs - (pure:m !>(~)) - ;< ~ bind:m - %+ raw-poke - [our.bowl %graph-store] - :- %graph-update - !> ^- update:gra - [%0 now.bowl [%archive-graph (de-path:res i.graphs)]] - loop(graphs t.graphs) --- -^- thread:spider -|= arg=vase -=/ m (strand ,vase) -^- form:m -=+ !<([=update:grp ~] arg) -?. ?=(%remove-group -.update) - (pure:m !>(~)) -;< =bowl:spider bind:m get-bowl:strandio -;< ~ bind:m - %+ raw-poke - [our.bowl %metadata-hook] - :- %metadata-hook-action - !> ^- metadata-hook-action:hook - [%remove (en-path:res resource.update)] -:: -:: get metadata associated with group and remove it -;< =associations:met bind:m - %+ scry associations:met - ;: weld - /gx/metadata-store/group - (en-path:res resource.update) - /noun - == -;< ~ bind:m - (remove-metadata ~(tap in ~(key by associations))) -=/ graphs=(list path) - %+ turn ~(tap in ~(key by associations)) - |= [g=group-path:met m=md-resource:met] - ^- path - app-path.m -(archive-graphs graphs) From 46fd3004bf74fead4d262a3f0b184487e37af793 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Mon, 30 Nov 2020 16:59:30 -0600 Subject: [PATCH 803/933] %group-on-leave thread: simplified and got it to compile --- pkg/arvo/ted/group/on-leave.hoon | 64 +++++++++++++------------------- 1 file changed, 25 insertions(+), 39 deletions(-) diff --git a/pkg/arvo/ted/group/on-leave.hoon b/pkg/arvo/ted/group/on-leave.hoon index dfff1b179a..33088c8c8c 100644 --- a/pkg/arvo/ted/group/on-leave.hoon +++ b/pkg/arvo/ted/group/on-leave.hoon @@ -5,37 +5,6 @@ =* raw-poke raw-poke:strandio =* scry scry:strandio :: -=> -|% -++ remove-metadata - |= entries=(list [g=group-path:met m=md-resource:met]) - ^- form:m - |- ^- form:m - =* loop $ - ?~ entries - (pure:m !>(~)) - ;< ~ bind:m - %+ raw-poke - [our.bowl %metadata-store] - :- %metadata-action - !> ^- metadata-action:met - [%remove g.i.entries m.i.entries] - loop(entries t.entries) -:: -++ archive-graphs - |= graphs=(list path) - |- ^- form:m - =* loop $ - ?~ graphs - (pure:m !>(~)) - ;< ~ bind:m - %+ raw-poke - [our.bowl %graph-store] - :- %graph-update - !> ^- update:gra - [%0 now.bowl [%archive-graph (de-path:res i.graphs)]] - loop(graphs t.graphs) --- ^- thread:spider |= arg=vase =/ m (strand ,vase) @@ -44,6 +13,8 @@ ?. ?=(%remove-group -.update) (pure:m !>(~)) ;< =bowl:spider bind:m get-bowl:strandio +:: stop serving or syncing metadata associated with group +:: ;< ~ bind:m %+ raw-poke [our.bowl %metadata-hook] @@ -51,7 +22,7 @@ !> ^- metadata-hook-action:hook [%remove (en-path:res resource.update)] :: -:: get metadata associated with group and remove it +:: get metadata associated with group ;< =associations:met bind:m %+ scry associations:met ;: weld @@ -59,11 +30,26 @@ (en-path:res resource.update) /noun == +=/ entries=(list [g=group-path:met m=md-resource:met]) + ~(tap in ~(key by associations)) +|- ^- form:m +=* loop $ +?~ entries + (pure:m !>(~)) +:: remove metadata associated with group +:: ;< ~ bind:m - (remove-metadata ~(tap in ~(key by associations))) -=/ graphs=(list path) - %+ turn ~(tap in ~(key by associations)) - |= [g=group-path:met m=md-resource:met] - ^- path - app-path.m -(archive-graphs graphs) + %+ raw-poke + [our.bowl %metadata-store] + :- %metadata-action + !> ^- metadata-action:met + [%remove g.i.entries m.i.entries] +:: archive graph associated with group +:: +;< ~ bind:m + %+ raw-poke + [our.bowl %graph-store] + :- %graph-update + !> ^- update:gra + [%0 now.bowl [%archive-graph (de-path:res app-path.m.i.entries)]] +loop(entries t.entries) From 918971d6886a7e45800cea0abf8da306a46c865c Mon Sep 17 00:00:00 2001 From: fang Date: Tue, 1 Dec 2020 00:33:08 +0100 Subject: [PATCH 804/933] vere: replace -O with more generic -Z Lets you specify the output format, either 'jam', or an aura that the scry result (assumed to be an atom in that case) gets rendered to, as a .txt file. --- pkg/urbit/daemon/main.c | 14 ++++++++----- pkg/urbit/include/c/motes.h | 2 +- pkg/urbit/include/vere/vere.h | 2 +- pkg/urbit/vere/pier.c | 39 +++++++++++++++++------------------ 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/pkg/urbit/daemon/main.c b/pkg/urbit/daemon/main.c index 28d0eee426..8186a8c476 100644 --- a/pkg/urbit/daemon/main.c +++ b/pkg/urbit/daemon/main.c @@ -75,7 +75,6 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.dem = c3n; u3_Host.ops_u.dry = c3n; u3_Host.ops_u.exp = c3n; - u3_Host.ops_u.kex = c3n; u3_Host.ops_u.gab = c3n; u3_Host.ops_u.git = c3n; @@ -94,11 +93,12 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.tex = c3n; u3_Host.ops_u.tra = c3n; u3_Host.ops_u.veb = c3n; + u3_Host.ops_u.puf_c = "jam"; u3_Host.ops_u.hap_w = 50000; u3_Host.ops_u.kno_w = DefaultKernel; while ( -1 != (ch_i=getopt(argc, argv, - "X:Y:G:J:B:K:A:H:I:C:w:u:e:F:k:n:p:r:i:LljacdgoqstvxOPDRS")) ) + "X:Y:G:J:B:K:A:H:I:C:w:u:e:F:k:n:p:r:i:Z:LljacdgoqstvxPDRS")) ) { switch ( ch_i ) { case 'X': { @@ -109,6 +109,10 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.puk_c = strdup(optarg); break; } + case 'Z': { + u3_Host.ops_u.puf_c = strdup(optarg); + break; + } case 'J': { u3_Host.ops_u.lit_c = strdup(optarg); break; @@ -201,7 +205,6 @@ _main_getopt(c3_i argc, c3_c** argv) case 'd': { u3_Host.ops_u.dem = c3y; break; } case 'g': { u3_Host.ops_u.gab = c3y; break; } case 'o': { u3_Host.ops_u.exp = c3y; break; } - case 'O': { u3_Host.ops_u.kex = c3y; break; } case 'P': { u3_Host.ops_u.pro = c3y; break; } case 'D': { u3_Host.ops_u.dry = c3y; break; } case 'q': { u3_Host.ops_u.qui = c3y; break; } @@ -423,9 +426,10 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-u url URL from which to download pill\n", "-v Verbose\n", "-w name Boot as ~name\n", - "-X path Scry, jam to file, then exit\n" + "-X path Scry, write to file, then exit\n" "-x Exit immediately\n", - "-Y file Optional name of jamfile (for -X and -o)\n" + "-Y file Optional name of file (for -X and -o)\n" + "-Z format Optional file format ('jam', or aura, for -X)\n" "\n", "Development Usage:\n", " To create a development ship, use a fakezod:\n", diff --git a/pkg/urbit/include/c/motes.h b/pkg/urbit/include/c/motes.h index e535681f92..da22a6b560 100644 --- a/pkg/urbit/include/c/motes.h +++ b/pkg/urbit/include/c/motes.h @@ -594,6 +594,7 @@ # define c3__ix c3_s2('i','x') # define c3__j c3_s1('j') # define c3__jack c3_s4('j','a','c','k') +# define c3__jam c3_s3('j','a','m') # define c3__jamx c3_s4('j','a','m','x') # define c3__jamz c3_s4('j','a','m','z') # define c3__jato c3_s4('j','a','t','o') @@ -1209,7 +1210,6 @@ # define c3__vern c3_s4('v','e','r','n') # define c3__very c3_s4('v','e','r','y') # define c3__view c3_s4('v','i','e','w') -# define c3__vile c3_s4('v','i','l','e') # define c3__vint c3_s4('v','i','n','t') # define c3__void c3_s4('v','o','i','d') # define c3__vorp c3_s4('v','o','r','p') diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index d484dfca02..89b303269b 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -267,7 +267,6 @@ c3_c* jin_c; // -I, inject raw event c3_c* imp_c; // -i, import pier state c3_o exp; // -o, export pier state - c3_o kex; // -O, export keyfile c3_w hap_w; // -C, cap memo cache c3_c* lit_c; // -J, ivory (fastboot) kernel c3_o tra; // -j, json trace @@ -290,6 +289,7 @@ c3_o tex; // -x, exit after loading c3_c* pek_c; // -X, scry path (/vc/desk/path) c3_c* puk_c; // -Y, scry result filename + c3_c* puf_c; // -Z, scry result format } u3_opts; /* u3_host: entire host. diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index b57fcc1baf..41b4aa4fbe 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -491,6 +491,23 @@ _pier_on_scry_done(void* ptr_v, u3_noun nun) else { u3l_log("pier: scry succeeded\n"); + // serialize as desired + // + u3_atom out; + c3_c* ext_c; + { + u3l_log("xxx\n"); + u3_atom puf = u3i_string(u3_Host.ops_u.puf_c); + if ( c3y == u3r_sing(c3__jam, puf) ) { + out = u3qe_jam(res); + ext_c = "jam"; + } + else { + out = u3dc("scot", puf, u3k(res)); + ext_c = "txt"; + } + } + c3_c* pac_c = u3_Host.ops_u.puk_c; if (!pac_c) { pac_c = u3_Host.ops_u.pek_c; @@ -510,20 +527,9 @@ _pier_on_scry_done(void* ptr_v, u3_noun nun) } c3_c fil_c[2048]; - snprintf(fil_c, 2048, "%s/.urb/put/%s.%s", pir_u->pax_c, pac_c+1, - (c3y == u3_Host.ops_u.kex) ? "key" : "jam"); + snprintf(fil_c, 2048, "%s/.urb/put/%s.%s", pir_u->pax_c, pac_c+1, ext_c); - // if this was a keyfile scry, serialize it as @uw, - // otherwise, write it to a jamfile - // - //TODO support broader control over output format - // - if ( c3y == u3_Host.ops_u.kex ) { - u3_atom out = u3dc("scot", c3__uw, u3k(res)); - u3_walk_save(fil_c, 0, out, pir_u->pax_c, pad); - } else { - u3_walk_save(fil_c, 0, u3qe_jam(res), pir_u->pax_c, pad); - } + u3_walk_save(fil_c, 0, out, pir_u->pax_c, pad); u3l_log("pier: scry in %s\n", fil_c); } @@ -634,13 +640,6 @@ _pier_work_init(u3_pier* pir_u) u3z(pex); } - else if ( _(u3_Host.ops_u.kex) ) { - if (!u3_Host.ops_u.puk_c) { - u3_Host.ops_u.puk_c = strdup("/archive/keyfile"); - } - u3_pier_peek_last(pir_u, u3_nul, c3__j, c3__vile, u3_nul, - pir_u, _pier_on_scry_done); - } else { // initialize i/o drivers // From 2c380e6cc6afd90bdd863982e1673fa6887c516d Mon Sep 17 00:00:00 2001 From: fang Date: Tue, 1 Dec 2020 01:11:25 +0100 Subject: [PATCH 805/933] vere: clean up refcounts, debug printf --- pkg/urbit/vere/pier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index 41b4aa4fbe..ac719f2765 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -496,7 +496,6 @@ _pier_on_scry_done(void* ptr_v, u3_noun nun) u3_atom out; c3_c* ext_c; { - u3l_log("xxx\n"); u3_atom puf = u3i_string(u3_Host.ops_u.puf_c); if ( c3y == u3r_sing(c3__jam, puf) ) { out = u3qe_jam(res); @@ -506,6 +505,7 @@ _pier_on_scry_done(void* ptr_v, u3_noun nun) out = u3dc("scot", puf, u3k(res)); ext_c = "txt"; } + u3z(puf); } c3_c* pac_c = u3_Host.ops_u.puk_c; From 350521853bf7ffdd4fb5c28dcf8c12c6cae80ef9 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Mon, 30 Nov 2020 19:05:05 -0800 Subject: [PATCH 806/933] clay: cleanup protocol versions +riff-any is all clay requests except "backfill" requests. Change to `$%` from `$^`, which was used to distinguish originally non-versioned requests. +fill is backfill requests and had no version number, so we add one. We do not have version numbers on responses since those are implied by the request. If someone requests at version `n` and you're at `n+1`, you must respond in the format of `n`. If someone requests at version `n+1` and you're at `n`, you crash; though possibly you should be able to respond with message "I only know up to `n`", in which case they may be able to re-request at `n`. In either case, the version of the response is dictated by the request. --- bin/solid.pill | 4 ++-- pkg/arvo/sys/vane/clay.hoon | 19 ++++++++----------- pkg/arvo/sys/zuse.hoon | 4 ++-- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index cbbd775bbb..706da716cc 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d89b2dd60b56680fb290f3782ab6137488a2df9e43db726199d9f8968db5831c -size 6314841 +oid sha256:90c1175611b87d9311ff495ed94cf391f2a60eb92c7ab6686cec2557b827382c +size 6325358 diff --git a/pkg/arvo/sys/vane/clay.hoon b/pkg/arvo/sys/vane/clay.hoon index 0b8a4c8370..7edc80ae83 100644 --- a/pkg/arvo/sys/vane/clay.hoon +++ b/pkg/arvo/sys/vane/clay.hoon @@ -111,7 +111,9 @@ :: :: Over-the-wire backfill request :: -+$ fill [=desk =lobe] ++$ fill + $% [%0 =desk =lobe] + == :: :: Ford cache :: @@ -1206,7 +1208,7 @@ =/ =desk p.riff =/ =wire /warp-index/(scot %p ship)/(scot %tas desk)/(scot %ud index) =/ =path [%question desk (scot %ud index) ~] - (emit duct %pass wire %a %plea ship %c path [[%1 ~] riff]) + (emit duct %pass wire %a %plea ship %c path `riff-any`[%1 riff]) :: :: Create a request that cannot be filled immediately. :: @@ -2924,7 +2926,7 @@ $(need.sat t.need.sat) :: Otherwise, fetch the next blob :: - =/ =fill [syd i.need.sat] + =/ =fill [%0 syd i.need.sat] =/ =wire /back-index/(scot %p her)/[syd]/(scot %ud inx) =/ =path [%backfill syd (scot %ud inx) ~] =. ..foreign-update @@ -4170,13 +4172,8 @@ [~ req] :: ?: =(our who.req) :: [~ [%warp wer.req rif.req]] - =^ ver rif.req - ?@ -.rif.req - [%0 rif.req] - [-<.rif.req +.rif.req] - ?> ?=(@ -.rif.req) - :- ?:(=(our who.req) ~ `[who.req ver]) - [%warp wer.req rif.req] + :- ?:(=(our who.req) ~ `[who.req -.rif.req]) + [%warp wer.req riff.rif.req] :: ?> ?=(%warp -.req) =* rif rif.req @@ -4197,7 +4194,7 @@ =+ ;;(=fill res) =^ mos ruf =/ den ((de our now ski hen ruf) our desk.fill) - abet:(give-backfill:den +.fill) + abet:(give-backfill:den lobe.fill) [[[hen %give %done ~] mos] ..^$] ?> ?=([%question *] pax) =+ ryf=;;(riff-any res) diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index 653db1a2f8..5cd0c759be 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -971,8 +971,8 @@ ++ regs (map path rule) :: rules for paths +$ riff [p=desk q=(unit rave)] :: request+desist +$ riff-any - $^ [[%1 ~] riff] - riff + $% [%1 =riff] + == ++ rite :: new permissions $% {$r red/(unit rule)} :: for read {$w wit/(unit rule)} :: for write From 3b4beded1dcd572957fcc6c8467c83650dac5080 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 30 Nov 2020 19:45:58 -0800 Subject: [PATCH 807/933] u3: removes .fab from |ut hooks --- pkg/urbit/jets/tree.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index b64be81e4d..057c4f7a19 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -548,8 +548,7 @@ static u3j_hood _141_pen__ut_ho[] = { { "ar", 12282 }, { "fan", 28, c3n }, { "rib", 58, c3n }, - { "vet", 118, c3n }, - { "fab", 119, c3n }, + { "vet", 59, c3n }, { "blow", 6015 }, { "burp", 342 }, From 55de9ab0a9caf7c0c76500fcc14d2d07c0ad83d8 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Mon, 30 Nov 2020 20:12:43 -0800 Subject: [PATCH 808/933] gall: add version to over-the-wire protocol All over-the-wire requests should have version numbers. This adds them to gall's +ames-request. --- bin/solid.pill | 4 ++-- pkg/arvo/sys/vane/gall.hoon | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index 706da716cc..e00329c3de 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:90c1175611b87d9311ff495ed94cf391f2a60eb92c7ab6686cec2557b827382c -size 6325358 +oid sha256:de1817f30b35176e866009031dad42bb3cdf3de7e059e2eaa9a401151d6436ed +size 6325695 diff --git a/pkg/arvo/sys/vane/gall.hoon b/pkg/arvo/sys/vane/gall.hoon index 8840909ba2..8fd28278e9 100644 --- a/pkg/arvo/sys/vane/gall.hoon +++ b/pkg/arvo/sys/vane/gall.hoon @@ -86,6 +86,9 @@ :: %s: watch :: %u: leave :: ++$ ames-request-all + $% [%0 ames-request] + == +$ ames-request $% [%m =mark noun=*] [%l =mark =path] @@ -492,7 +495,8 @@ :: =. mo-core (mo-track-ship ship) ?< ?=(?(%raw-poke %poke-as) -.deal) - =/ =ames-request + =/ =ames-request-all + :- %0 ?- -.deal %poke [%m p.cage.deal q.q.cage.deal] %leave [%u ~] @@ -505,7 +509,7 @@ :: =/ =note-arvo =/ =path /ge/[foreign-agent] - [%a %plea ship %g path ames-request] + [%a %plea ship %g path ames-request-all] :: =. outstanding.state =/ stand @@ -769,7 +773,9 @@ =/ sys-wire [%sys wire] :: TODO: %drip %kick so app crash can't kill the remote %pull :: - =. mo-core (mo-pass sys-wire %a %plea ship %g /ge/[foreign-agent] %u ~) + =/ =ames-request-all [%0 %u ~] + =. mo-core + (mo-pass sys-wire %a %plea ship %g /ge/[foreign-agent] ames-request-all) =. mo-core (mo-give %unto %kick ~) mo-core == @@ -1702,8 +1708,9 @@ ?> ?=([%ge @ ~] path) =/ agent-name i.t.path :: - =/ =ames-request ;;(ames-request noun) - => (mo-handle-ames-request:mo-core ship agent-name ames-request) + =+ ;;(=ames-request-all noun) + ?> ?=(%0 -.ames-request-all) + => (mo-handle-ames-request:mo-core ship agent-name +.ames-request-all) mo-abet :: %sear mo-abet:(mo-filter-queue:mo-core ship.task) From 444e331b6bffcbb9ebb3608a886682942a18fe09 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 30 Nov 2020 20:36:43 -0800 Subject: [PATCH 809/933] pill: all --- bin/brass.pill | 4 ++-- bin/ivory.pill | 4 ++-- bin/solid.pill | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/brass.pill b/bin/brass.pill index 448746b862..79fa7f1b8f 100644 --- a/bin/brass.pill +++ b/bin/brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d764f3c853b127d84496efc5f04ee4fbd35b15c1e8a8c9823ba76633668f0a3b -size 4608972 +oid sha256:b46dcd785a3a8852e4335caa397cb7119a5d24a8f8b289fae5552389665f6faa +size 4809733 diff --git a/bin/ivory.pill b/bin/ivory.pill index 56cf8ea4dc..0cd3d4fd97 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:13cbef9277182a6d64dc9f8c8cfe157c6994f0663deb5664bea721c2c549fdb3 -size 1906511 +oid sha256:841796bba5187166e9c3ce7c809d1f303abe11bb71f155ce3f07b2d6e3698bf1 +size 2118639 diff --git a/bin/solid.pill b/bin/solid.pill index 5fe479eb83..b650694aaf 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:257e1b21ba5fa9b58093394a5214ae58d8493f5424f718816b7b984eded2d735 -size 6476024 +oid sha256:bc5bff256055eae93ef1d8c39a16b7f319b71a34120ff038f2149b3fcdc1703d +size 6617429 From 7e4d1a0a8b06595463f5f5280641dc55053ff1b9 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Mon, 30 Nov 2020 20:33:42 -0800 Subject: [PATCH 810/933] jael: add version numbers All over-the-wire requests should have version numbers. This adds them to Jael's +message. --- bin/solid.pill | 4 ++-- pkg/arvo/sys/vane/jael.hoon | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index e00329c3de..27ab3209c0 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:de1817f30b35176e866009031dad42bb3cdf3de7e059e2eaa9a401151d6436ed -size 6325695 +oid sha256:59e597c43e90c8220dd5a9a747a405aa89ec06a541fdb6290b08536b53fdd336 +size 6326196 diff --git a/pkg/arvo/sys/vane/jael.hoon b/pkg/arvo/sys/vane/jael.hoon index 401eb41abc..3a978334c0 100644 --- a/pkg/arvo/sys/vane/jael.hoon +++ b/pkg/arvo/sys/vane/jael.hoon @@ -86,6 +86,9 @@ pos=(map ship point) :: on-chain ship state == :: == :: ++$ message-all + $% [%0 message] + == +$ message :: message to her jael $% [%nuke whos=(set ship)] :: cancel trackers [%public-keys whos=(set ship)] :: view ethereum events @@ -532,22 +535,24 @@ :: %plea =* her ship.tac - =/ mes ;;(message payload.plea.tac) - ?- -.mes + =+ ;;(=message-all payload.plea.tac) + ?> ?=(%0 -.message-all) + =/ =message +.message-all + ?- -.message :: :: cancel trackers :: [%nuke whos=(set ship)] :: %nuke =. moz [[hen %give %done ~] moz] - $(tac mes) + $(tac message) :: :: view ethereum events :: [%public-keys whos=(set ship)] :: %public-keys =. moz [[hen %give %done ~] moz] - $(tac mes) + $(tac message) == == :: @@ -972,10 +977,9 @@ ..feed :: ?: ?=(%& -.source) - =/ send-message - |= =message - [hen %pass /public-keys %a %plea p.source %j /public-keys message] - (emit (send-message %public-keys whos)) + %- emit + =/ =message-all [%0 %public-keys whos] + [hen %pass /public-keys %a %plea p.source %j /public-keys message-all] (peer p.source whos) -- :: From 096ef91f7a0ee093984fbcc958494959750cf043 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 30 Nov 2020 21:23:35 -0800 Subject: [PATCH 811/933] hood: fix obsolete syntax introduced in merge --- bin/brass.pill | 4 ++-- bin/ivory.pill | 4 ++-- bin/solid.pill | 4 ++-- pkg/arvo/lib/hood/drum.hoon | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bin/brass.pill b/bin/brass.pill index 79fa7f1b8f..448746b862 100644 --- a/bin/brass.pill +++ b/bin/brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b46dcd785a3a8852e4335caa397cb7119a5d24a8f8b289fae5552389665f6faa -size 4809733 +oid sha256:d764f3c853b127d84496efc5f04ee4fbd35b15c1e8a8c9823ba76633668f0a3b +size 4608972 diff --git a/bin/ivory.pill b/bin/ivory.pill index 0cd3d4fd97..56cf8ea4dc 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:841796bba5187166e9c3ce7c809d1f303abe11bb71f155ce3f07b2d6e3698bf1 -size 2118639 +oid sha256:13cbef9277182a6d64dc9f8c8cfe157c6994f0663deb5664bea721c2c549fdb3 +size 1906511 diff --git a/bin/solid.pill b/bin/solid.pill index b650694aaf..5fe479eb83 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bc5bff256055eae93ef1d8c39a16b7f319b71a34120ff038f2149b3fcdc1703d -size 6617429 +oid sha256:257e1b21ba5fa9b58093394a5214ae58d8493f5424f718816b7b984eded2d735 +size 6476024 diff --git a/pkg/arvo/lib/hood/drum.hoon b/pkg/arvo/lib/hood/drum.hoon index 2aa3ba07f5..16b78562d8 100644 --- a/pkg/arvo/lib/hood/drum.hoon +++ b/pkg/arvo/lib/hood/drum.hoon @@ -183,7 +183,7 @@ (se-born & wel) :: ++ poke-fade :: fade app - |= wel/well:gall + |= wel=well:gall =< se-abet =< se-view (se-fade wel) :: From a7f11df5067331299f8e9d7f9f8ed6f7dde36fb9 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 30 Nov 2020 21:24:01 -0800 Subject: [PATCH 812/933] pill: all --- bin/brass.pill | 4 ++-- bin/ivory.pill | 4 ++-- bin/solid.pill | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/brass.pill b/bin/brass.pill index 448746b862..b6799d99cb 100644 --- a/bin/brass.pill +++ b/bin/brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d764f3c853b127d84496efc5f04ee4fbd35b15c1e8a8c9823ba76633668f0a3b -size 4608972 +oid sha256:c55d8f37ad4014bf92f04d0a4a74235f5514de84dad4dca58c40ae2900d06be2 +size 4788607 diff --git a/bin/ivory.pill b/bin/ivory.pill index 56cf8ea4dc..5c7fabd885 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:13cbef9277182a6d64dc9f8c8cfe157c6994f0663deb5664bea721c2c549fdb3 -size 1906511 +oid sha256:85a4e1625d528b5fdc88faeff4fd288a23d6fbf1c11a846fc8f8d5b3cd38370f +size 2118873 diff --git a/bin/solid.pill b/bin/solid.pill index 5fe479eb83..bdbcb8fa4b 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:257e1b21ba5fa9b58093394a5214ae58d8493f5424f718816b7b984eded2d735 -size 6476024 +oid sha256:b3e9d1637efea5862a114ce320f6e14afeb1f9f418428e0490d9c079a9becc56 +size 6712875 From 7d1c58031ca15ddf4fb96d2f56cfd8aaebbe9e3a Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Mon, 30 Nov 2020 13:04:54 -0800 Subject: [PATCH 813/933] userspace: data migration testing utilities --- pkg/arvo/gen/aqua-export.hoon | 45 +++++++ pkg/arvo/lib/ph/io.hoon | 16 +++ pkg/arvo/lib/strandio.hoon | 6 +- pkg/arvo/mar/contact/view-action.hoon | 12 ++ pkg/arvo/mar/import.hoon | 15 +++ pkg/arvo/mar/metadata/hook-action.hoon | 12 ++ pkg/arvo/ted/ph/migrate/breach.hoon | 22 ++++ pkg/arvo/ted/ph/migrate/commit-home.hoon | 61 ++++++++++ pkg/arvo/ted/ph/migrate/import.hoon | 22 ++++ pkg/arvo/ted/ph/migrate/init.hoon | 24 ++++ pkg/arvo/ted/ph/migrate/make-chats.hoon | 96 +++++++++++++++ pkg/arvo/ted/ph/migrate/make-graphs.hoon | 112 ++++++++++++++++++ pkg/arvo/ted/ph/migrate/make-groups.hoon | 46 +++++++ pkg/arvo/ted/ph/migrate/post-import-chat.hoon | 36 ++++++ .../ted/ph/migrate/post-import-graphs.hoon | 56 +++++++++ .../ted/ph/migrate/post-import-groups.hoon | 24 ++++ .../post-import-metadata-contacts.hoon | 61 ++++++++++ pkg/arvo/ted/ph/migrate/send-his.hoon | 18 +++ pkg/arvo/ted/ph/migrate/start.hoon | 73 ++++++++++++ pkg/arvo/ted/ph/start-drivers.hoon | 2 +- 20 files changed, 757 insertions(+), 2 deletions(-) create mode 100644 pkg/arvo/gen/aqua-export.hoon create mode 100644 pkg/arvo/mar/contact/view-action.hoon create mode 100644 pkg/arvo/mar/import.hoon create mode 100644 pkg/arvo/mar/metadata/hook-action.hoon create mode 100644 pkg/arvo/ted/ph/migrate/breach.hoon create mode 100644 pkg/arvo/ted/ph/migrate/commit-home.hoon create mode 100644 pkg/arvo/ted/ph/migrate/import.hoon create mode 100644 pkg/arvo/ted/ph/migrate/init.hoon create mode 100644 pkg/arvo/ted/ph/migrate/make-chats.hoon create mode 100644 pkg/arvo/ted/ph/migrate/make-graphs.hoon create mode 100644 pkg/arvo/ted/ph/migrate/make-groups.hoon create mode 100644 pkg/arvo/ted/ph/migrate/post-import-chat.hoon create mode 100644 pkg/arvo/ted/ph/migrate/post-import-graphs.hoon create mode 100644 pkg/arvo/ted/ph/migrate/post-import-groups.hoon create mode 100644 pkg/arvo/ted/ph/migrate/post-import-metadata-contacts.hoon create mode 100644 pkg/arvo/ted/ph/migrate/send-his.hoon create mode 100644 pkg/arvo/ted/ph/migrate/start.hoon diff --git a/pkg/arvo/gen/aqua-export.hoon b/pkg/arvo/gen/aqua-export.hoon new file mode 100644 index 0000000000..046d85d24d --- /dev/null +++ b/pkg/arvo/gen/aqua-export.hoon @@ -0,0 +1,45 @@ +/+ *ph-util +:- %say +|= $: [now=@da eny=@uv bec=beak] + [who=@p ~] + ~ + == +|^ +:- %noun +(export-all who) +:: +++ export-app + |= [who=ship agent=term] + =/ aqua-pax=path + :~ %i + (scot %p who) + %gx + (scot %p who) + agent + (scot %da now) + %export + %noun + %noun + == + ~| agent + %- need + (scry-aqua (unit *) p.bec now aqua-pax) +:: +++ export-all + |= who=ship + %+ turn + ^- (list @tas) + :~ %group-store + %metadata-store + %metadata-hook + %contact-store + %contact-hook + %invite-store + %chat-store + %chat-hook + %graph-store + == + |= app=@tas + [app (export-app who app)] +:: +-- diff --git a/pkg/arvo/lib/ph/io.hoon b/pkg/arvo/lib/ph/io.hoon index 4433670ca3..d0327ab2e1 100644 --- a/pkg/arvo/lib/ph/io.hoon +++ b/pkg/arvo/lib/ph/io.hoon @@ -341,4 +341,20 @@ ?: =(warped (need (scry-aqua:util (unit @) our now aqua-pax))) (pure:m ~) loop +:: +:: Turns poke into a dojo command +:: +++ poke-app + |= [=ship app=term =mark data=*] + =/ m (strand ,~) + ^- form:m + =/ command=tape ":{(trip app)} &{(trip mark)} {}" + (send-events (dojo:util ship command)) +:: +++ dojo-thread + |= [=ship ted=term =mark data=*] + =/ m (strand ,~) + ^- form:m + =/ command=tape "-{(trip ted)} &{(trip mark)} {}" + (send-events (dojo:util ship command)) -- diff --git a/pkg/arvo/lib/strandio.hoon b/pkg/arvo/lib/strandio.hoon index 050c92f40f..bc17a28359 100644 --- a/pkg/arvo/lib/strandio.hoon +++ b/pkg/arvo/lib/strandio.hoon @@ -651,12 +651,16 @@ :: ++ start-thread |= file=term + (start-thread-with-args file *vase) +:: +++ start-thread-with-args + |= [file=term args=vase] =/ m (strand ,tid:spider) ^- form:m ;< =bowl:spider bind:m get-bowl =/ tid (scot %ta (cat 3 (cat 3 'strand_' file) (scot %uv (sham file eny.bowl)))) - =/ poke-vase !>([`tid.bowl `tid file *vase]) + =/ poke-vase !>([`tid.bowl `tid file args]) ;< ~ bind:m (poke-our %spider %spider-start poke-vase) ;< ~ bind:m (sleep ~s0) :: wait for thread to start (pure:m tid) diff --git a/pkg/arvo/mar/contact/view-action.hoon b/pkg/arvo/mar/contact/view-action.hoon new file mode 100644 index 0000000000..bd386555da --- /dev/null +++ b/pkg/arvo/mar/contact/view-action.hoon @@ -0,0 +1,12 @@ +/- *contact-view +|_ act=contact-view-action +++ grad %noun +++ grow + |% + ++ noun act + -- +++ grab + |% + ++ noun contact-view-action + -- +-- diff --git a/pkg/arvo/mar/import.hoon b/pkg/arvo/mar/import.hoon new file mode 100644 index 0000000000..53ee978c2c --- /dev/null +++ b/pkg/arvo/mar/import.hoon @@ -0,0 +1,15 @@ +=, mimes:html +|_ non=* +++ grab + |% + ++ noun * + ++ mime + |= [* p=octs] + (cue q.p) + -- +++ grow + |% + ++ mime [/application/x-urb-import (as-octs (jam non))] + -- +++ grad %mime +-- diff --git a/pkg/arvo/mar/metadata/hook-action.hoon b/pkg/arvo/mar/metadata/hook-action.hoon new file mode 100644 index 0000000000..6903555245 --- /dev/null +++ b/pkg/arvo/mar/metadata/hook-action.hoon @@ -0,0 +1,12 @@ +/- *metadata-hook +|_ act=metadata-hook-action +++ grad %noun +++ grow + |% + ++ noun act + -- +++ grab + |% + ++ noun metadata-hook-action + -- +-- diff --git a/pkg/arvo/ted/ph/migrate/breach.hoon b/pkg/arvo/ted/ph/migrate/breach.hoon new file mode 100644 index 0000000000..4678690cc2 --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/breach.hoon @@ -0,0 +1,22 @@ +/- spider +/+ *ph-io +=, strand=strand:spider +^- thread:spider +|= arg=vase +=+ !<(who=(list @p) arg) +=/ m (strand ,vase) +;< ~ bind:m start-simple +=? who ?=(~ who) ~[~zod ~bus ~web] +|- +=* loop $ +?~ who +:: ;< ~ bind:m (send-hi ~zod ~bus) +:: ;< ~ bind:m (send-hi ~zod ~web) +:: ;< ~ bind:m (send-hi ~bus ~zod) +:: ;< ~ bind:m (send-hi ~bus ~web) +:: ;< ~ bind:m (send-hi ~web ~zod) +:: ;< ~ bind:m (send-hi ~web ~bus) + (pure:m *vase) +;< ~ bind:m (breach-aqua i.who) +;< ~ bind:m (init-ship i.who) +loop(who t.who) diff --git a/pkg/arvo/ted/ph/migrate/commit-home.hoon b/pkg/arvo/ted/ph/migrate/commit-home.hoon new file mode 100644 index 0000000000..8f168f3ab8 --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/commit-home.hoon @@ -0,0 +1,61 @@ +:: +:: warning: using this thread will clobber aqua's currently active piers +:: +/- spider, *aquarium +/+ *ph-io +=, strand=strand:spider +=> +|% +++ commit + |= [our=@p now=@da ships=(list @p)] + ^- (list aqua-event) + %+ turn ships + |= her=@p + :+ %event her + =/ paths .^((list path) %ct /(scot %p our)/home/(scot %da now)) + =/ mod=mode:clay + %+ murn paths + |= pat=path + ^- (unit [path (unit mime)]) + ?. =((snag (dec (lent pat)) pat) %hoon) + ~ + =/ clay-pax=path (weld /(scot %p our)/home/(scot %da now) pat) + =/ file [/text/plain (as-octs:mimes:html .^(@ %cx clay-pax))] + `[pat `file] + :- //sync/0v1n.2m9vh + [%into %home | mod] +:: +++ restore-fleet + |= label=term + ^- (list aqua-event) + [%restore-snap label]~ +:: +++ snap-fleet + |= [label=term ships=(list @p)] + ^- (list aqua-event) + [%snap-ships label ships]~ +-- +^- thread:spider +|= arg=vase +=+ !<(fleets=(list term) arg) +=/ m (strand ,vase) +;< ~ bind:m start-simple +=/ ships=(list @p) ~[~zod ~bus ~web] +;< =bowl:spider bind:m get-bowl +=/ commit-events (commit our.bowl now.bowl ships) +|- +=* fleet-loop $ +?~ fleets + (pure:m *vase) +:: +;< ~ bind:m (send-events (restore-fleet i.fleets)) +;< ~ bind:m (sleep ~s0) +;< ~ bind:m (send-events commit-events) +;< ~ bind:m (sleep ~s0) +;< =bowl:spider bind:m get-bowl +=/ full-ships + .^((list @p) %gx /(scot %p our.bowl)/aqua/(scot %da now.bowl)/ships/noun) +;< ~ bind:m (send-events (snap-fleet i.fleets full-ships)) +;< ~ bind:m (sleep ~s0) +:: +fleet-loop(fleets t.fleets) diff --git a/pkg/arvo/ted/ph/migrate/import.hoon b/pkg/arvo/ted/ph/migrate/import.hoon new file mode 100644 index 0000000000..57d054c4cc --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/import.hoon @@ -0,0 +1,22 @@ +/- spider +/+ *ph-io +=, strand=strand:spider +=> +|% +++ import-all + |= [who=@p by-app=(list [@tas *])] + =/ m (strand:spider ,~) + ^- form:m + =* loop $ + ?~ by-app (pure:m ~) + =/ [app=@tas data=*] i.by-app + ;< ~ bind:m (poke-app who app %import data) + loop(by-app t.by-app) +-- +^- thread:spider +|= arg=vase +=+ !<([who=@p by-app=(list [@tas *]) ~] arg) +=/ m (strand ,vase) +;< ~ bind:m start-simple +;< ~ bind:m (import-all who by-app) +(pure:m *vase) diff --git a/pkg/arvo/ted/ph/migrate/init.hoon b/pkg/arvo/ted/ph/migrate/init.hoon new file mode 100644 index 0000000000..3433e80abb --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/init.hoon @@ -0,0 +1,24 @@ +/- spider +/+ *ph-io +=, strand=strand:spider +^- thread:spider +|= vase +=/ m (strand ,vase) +;< ~ bind:m start-simple +;< ~ bind:m init-azimuth +;< ~ bind:m (spawn-aqua ~zod) +;< ~ bind:m (spawn-aqua ~bus) +;< ~ bind:m (spawn-aqua ~web) +:: +;< ~ bind:m (init-ship ~zod) +;< ~ bind:m (init-ship ~bus) +;< ~ bind:m (init-ship ~web) +:: +;< ~ bind:m (send-hi ~zod ~web) +;< ~ bind:m (send-hi ~zod ~bus) +;< ~ bind:m (send-hi ~web ~zod) +;< ~ bind:m (send-hi ~bus ~zod) +;< ~ bind:m (send-hi ~bus ~web) +;< ~ bind:m (send-hi ~web ~bus) +:: +(pure:m *vase) diff --git a/pkg/arvo/ted/ph/migrate/make-chats.hoon b/pkg/arvo/ted/ph/migrate/make-chats.hoon new file mode 100644 index 0000000000..43b9b572e5 --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/make-chats.hoon @@ -0,0 +1,96 @@ +/- spider, + chat-view, + *resource, + chat-store +/+ *ph-io, strandio +=, strand=strand:spider +=> +|% +++ chat-message + |= [our=@p =path wen=@da mes=cord] + =/ act=action:chat-store + :* %message path `@uvH`(sham [our path mes]) + 0 our wen [%text mes] + == + (poke-app our %chat-hook %chat-action act) +-- +:: +^- thread:spider +|= vase +=/ m (strand ,vase) +;< ~ bind:m start-simple +;< bol=bowl:spider bind:m get-bowl:strandio +:: +:: chat setup +:: - ~zod creates a chat associated with group-1 +:: - ~bus creates a chat associated with group-1 +:: - ~web creates a dm with ~zod +:: +=/ chat-1=action:chat-view + :* %create + 'Chat 1' '' + /~zod/chat-1 + /ship/~zod/group-1 + [%invite ~] + ~ + %.y + %.n + == +=/ chat-2=action:chat-view + :* %create + 'Chat 2' '' + /~bus/chat-2 + /ship/~zod/group-1 + [%invite ~] + ~ + %.y + %.n + == +=/ web-zod-dm=action:chat-view + :* %create + '~web <-> ~zod' '' + /~web/dm--zod + /ship/~web/dm--zod + [%invite (sy ~zod ~)] + (sy ~zod ~) + %.y + %.n + == +=/ join-1 [%join ~zod /~zod/chat-1 %.y] +=/ join-2 [%join ~bus /~bus/chat-2 %.y] +=/ join-3 [%join ~web /~web/dm--zod %.y] +;< ~ bind:m (poke-app ~zod %chat-view %chat-view-action chat-1) +;< ~ bind:m (wait-for-output ~zod ">=") +;< ~ bind:m (poke-app ~bus %chat-view %chat-view-action chat-2) +;< ~ bind:m (wait-for-output ~bus ">=") +;< ~ bind:m (poke-app ~web %chat-view %chat-view-action web-zod-dm) +;< ~ bind:m (wait-for-output ~web ">=") +;< ~ bind:m (sleep ~s20) +:: +;< ~ bind:m (poke-app ~bus %chat-view %chat-view-action join-1) +;< ~ bind:m (wait-for-output ~bus ">=") +;< ~ bind:m (poke-app ~web %chat-view %chat-view-action join-1) +;< ~ bind:m (wait-for-output ~web ">=") +:: +;< ~ bind:m (poke-app ~zod %chat-view %chat-view-action join-2) +;< ~ bind:m (wait-for-output ~zod ">=") +;< ~ bind:m (poke-app ~web %chat-view %chat-view-action join-2) +;< ~ bind:m (wait-for-output ~web ">=") +:: +;< ~ bind:m (poke-app ~zod %chat-view %chat-view-action join-3) +;< ~ bind:m (wait-for-output ~zod ">=") +;< ~ bind:m (sleep ~s20) +:: +;< ~ bind:m (chat-message ~zod /~zod/chat-1 now.bol 'message 1') +;< ~ bind:m (chat-message ~bus /~zod/chat-1 now.bol 'message 2') +;< ~ bind:m (chat-message ~web /~bus/chat-2 now.bol 'message 3') +;< ~ bind:m (chat-message ~zod /~web/dm--zod now.bol 'message 4') +:: +;< ~ bind:m (send-hi ~zod ~bus) +;< ~ bind:m (send-hi ~zod ~web) +;< ~ bind:m (send-hi ~bus ~zod) +;< ~ bind:m (send-hi ~bus ~web) +;< ~ bind:m (send-hi ~web ~zod) +;< ~ bind:m (send-hi ~web ~bus) +:: +(pure:m *vase) diff --git a/pkg/arvo/ted/ph/migrate/make-graphs.hoon b/pkg/arvo/ted/ph/migrate/make-graphs.hoon new file mode 100644 index 0000000000..0bbfe6dbf2 --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/make-graphs.hoon @@ -0,0 +1,112 @@ +/- spider, + graph-store, + graph-view, + post, + *resource +/+ *ph-io, strandio +=, strand=strand:spider +=> +|% +:: +++ graph-post + |= [our=@p wen=@da rid=resource body=cord id=@] + =/ =index:post [id]~ + =/ =post:post [our index wen [%text body]~ ~ ~] + =/ =node:graph-store [post %empty ~] + =/ act=update:graph-store [%0 wen %add-nodes rid (my [index node] ~)] + (poke-app our %graph-push-hook %graph-update act) +-- +:: +^- thread:spider +|= vase +=/ m (strand ,vase) +;< ~ bind:m start-simple +;< bol=bowl:spider bind:m get-bowl:strandio +:: +:: create graphs +:: +=/ group-rid [~zod %group-1] +=/ group-path /ship/~zod/group-1 +=/ create-1=action:graph-view + :* %create + [~zod %graph-1] + 'graph 1' + 'desc 1' + ~ + [%group group-rid] + 'fake' + == +:: +=/ create-2=action:graph-view + :* %create + [~bus %graph-2] + 'graph 2' + 'desc 2' + ~ + [%group group-rid] + 'fake' + == +:: +=/ create-3=action:graph-view + :* %create + [~web %graph-3] + 'graph 3' + 'desc 3' + ~ + [%policy %invite (sy ~zod ~bus ~)] + 'fake' + == +:: +;< ~ bind:m (dojo-thread ~zod %graph-create %graph-view-action create-1) +;< ~ bind:m (dojo-thread ~bus %graph-create %graph-view-action create-2) +;< ~ bind:m (dojo-thread ~web %graph-create %graph-view-action create-3) +;< ~ bind:m (sleep ~s30) +:: +:: join graphs +:: +=/ join-1=action:graph-view + [%join [~zod %graph-1] ~zod] +=/ join-2=action:graph-view + [%join [~bus %graph-2] ~bus] +=/ join-3=action:graph-view + [%join [~web %graph-3] ~web] +:: +;< ~ bind:m (dojo-thread ~zod %graph-join %graph-view-action join-2) +;< ~ bind:m (dojo-thread ~zod %graph-join %graph-view-action join-3) +;< ~ bind:m (dojo-thread ~bus %graph-join %graph-view-action join-1) +;< ~ bind:m (dojo-thread ~bus %graph-join %graph-view-action join-3) +;< ~ bind:m (dojo-thread ~web %graph-join %graph-view-action join-1) +;< ~ bind:m (dojo-thread ~web %graph-join %graph-view-action join-2) +;< ~ bind:m (sleep ~s30) +:: +:: make posts +:: +;< ~ bind:m (graph-post ~zod now.bol [~zod %graph-1] 'post 1' 1) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (graph-post ~bus now.bol [~zod %graph-1] 'post 2' 2) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (graph-post ~web now.bol [~zod %graph-1] 'post 3' 3) +;< ~ bind:m (sleep ~s5) +:: +;< ~ bind:m (graph-post ~zod now.bol [~bus %graph-2] 'post 4' 4) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (graph-post ~bus now.bol [~bus %graph-2] 'post 5' 5) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (graph-post ~web now.bol [~bus %graph-2] 'post 6' 6) +;< ~ bind:m (sleep ~s5) +:: +;< ~ bind:m (graph-post ~zod now.bol [~web %graph-3] 'post 7' 7) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (graph-post ~bus now.bol [~web %graph-3] 'post 8' 8) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (graph-post ~web now.bol [~web %graph-3] 'post 9' 9) +;< ~ bind:m (sleep ~s5) +:: +;< ~ bind:m (send-hi ~zod ~bus) +;< ~ bind:m (send-hi ~zod ~web) +;< ~ bind:m (send-hi ~bus ~zod) +;< ~ bind:m (send-hi ~bus ~web) +;< ~ bind:m (send-hi ~web ~zod) +;< ~ bind:m (send-hi ~web ~bus) +:: +(pure:m *vase) diff --git a/pkg/arvo/ted/ph/migrate/make-groups.hoon b/pkg/arvo/ted/ph/migrate/make-groups.hoon new file mode 100644 index 0000000000..62a09dffa6 --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/make-groups.hoon @@ -0,0 +1,46 @@ +/- spider, + contact-view, + *resource +/+ *ph-io, strandio +=, strand=strand:spider +:: +^- thread:spider +|= vase +=/ m (strand ,vase) +;< ~ bind:m start-simple +;< bol=bowl:spider bind:m get-bowl:strandio +:: +:: group setup +:: - ~zod creates an open group +:: - ~zod creates and invite-only group, and invites ~bus and ~web +:: - ~bus and ~web join the first, but not the second group, to keep +:: invite-store populated +:: +=/ group-1=contact-view-action:contact-view + :* %create + %group-1 + [%open ~ ~] + 'Group 1' + 'this is group 1' + == +=/ group-2=contact-view-action:contact-view + :* %create + %group-2 + [%invite (sy ~bus ~web ~)] + 'Group 2' + 'this is group 2' + == +=/ join=contact-view-action:contact-view [%join ~zod %group-1] +;< ~ bind:m (poke-app ~zod %contact-view %contact-view-action group-1) +;< ~ bind:m (wait-for-output ~zod ">=") +;< ~ bind:m (poke-app ~zod %contact-view %contact-view-action group-2) +;< ~ bind:m (wait-for-output ~zod ">=") +;< ~ bind:m (sleep ~s10) +;< ~ bind:m (poke-app ~bus %contact-view %contact-view-action join) +;< ~ bind:m (wait-for-output ~bus ">=") +;< ~ bind:m (poke-app ~web %contact-view %contact-view-action join) +;< ~ bind:m (wait-for-output ~web ">=") +;< ~ bind:m (send-hi ~bus ~zod) +;< ~ bind:m (send-hi ~web ~zod) +;< ~ bind:m (sleep ~s2) +(pure:m *vase) diff --git a/pkg/arvo/ted/ph/migrate/post-import-chat.hoon b/pkg/arvo/ted/ph/migrate/post-import-chat.hoon new file mode 100644 index 0000000000..b25da4f7cf --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/post-import-chat.hoon @@ -0,0 +1,36 @@ +/- spider, + chat-view, + *resource, + chat-store +/+ *ph-io, strandio +=, strand=strand:spider +=> +|% +++ chat-message + |= [our=@p =path wen=@da mes=cord] + =/ act=action:chat-store + :* %message path `@uvH`(sham [our path mes]) + 0 our wen [%text mes] + == + (poke-app our %chat-hook %chat-action act) +-- +:: +^- thread:spider +|= vase +=/ m (strand ,vase) +;< ~ bind:m start-simple +;< bol=bowl:spider bind:m get-bowl:strandio +:: +;< ~ bind:m (chat-message ~zod /~zod/chat-1 now.bol 'message 5') +;< ~ bind:m (chat-message ~bus /~zod/chat-1 now.bol 'message 6') +;< ~ bind:m (chat-message ~web /~bus/chat-2 now.bol 'message 7') +;< ~ bind:m (chat-message ~zod /~web/dm--zod now.bol 'message 8') +:: +;< ~ bind:m (send-hi ~zod ~bus) +;< ~ bind:m (send-hi ~zod ~web) +;< ~ bind:m (send-hi ~bus ~zod) +;< ~ bind:m (send-hi ~bus ~web) +;< ~ bind:m (send-hi ~web ~zod) +;< ~ bind:m (send-hi ~web ~bus) +:: +(pure:m *vase) diff --git a/pkg/arvo/ted/ph/migrate/post-import-graphs.hoon b/pkg/arvo/ted/ph/migrate/post-import-graphs.hoon new file mode 100644 index 0000000000..eed757263b --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/post-import-graphs.hoon @@ -0,0 +1,56 @@ +/- spider, + graph-store, + graph-view, + post, + *resource +/+ *ph-io, strandio +=, strand=strand:spider +=> +|% +:: +++ graph-post + |= [our=@p wen=@da rid=resource body=cord id=@] + =/ =index:post [id]~ + =/ =post:post [our index wen [%text body]~ ~ ~] + =/ =node:graph-store [post %empty ~] + =/ act=update:graph-store [%0 wen %add-nodes rid (my [index node] ~)] + (poke-app our %graph-push-hook %graph-update act) +-- +:: +^- thread:spider +|= vase +=/ m (strand ,vase) +;< ~ bind:m start-simple +;< bol=bowl:spider bind:m get-bowl:strandio +:: +:: make posts +:: +;< ~ bind:m (graph-post ~zod now.bol [~zod %graph-1] 'post 10' 10) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (graph-post ~bus now.bol [~zod %graph-1] 'post 20' 20) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (graph-post ~web now.bol [~zod %graph-1] 'post 30' 30) +;< ~ bind:m (sleep ~s5) +:: +;< ~ bind:m (graph-post ~zod now.bol [~bus %graph-2] 'post 40' 40) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (graph-post ~bus now.bol [~bus %graph-2] 'post 50' 50) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (graph-post ~web now.bol [~bus %graph-2] 'post 60' 60) +;< ~ bind:m (sleep ~s5) +:: +;< ~ bind:m (graph-post ~zod now.bol [~web %graph-3] 'post 70' 70) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (graph-post ~bus now.bol [~web %graph-3] 'post 80' 80) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (graph-post ~web now.bol [~web %graph-3] 'post 90' 90) +;< ~ bind:m (sleep ~s5) +:: +;< ~ bind:m (send-hi ~zod ~bus) +;< ~ bind:m (send-hi ~zod ~web) +;< ~ bind:m (send-hi ~bus ~zod) +;< ~ bind:m (send-hi ~bus ~web) +;< ~ bind:m (send-hi ~web ~zod) +;< ~ bind:m (send-hi ~web ~bus) +:: +(pure:m *vase) diff --git a/pkg/arvo/ted/ph/migrate/post-import-groups.hoon b/pkg/arvo/ted/ph/migrate/post-import-groups.hoon new file mode 100644 index 0000000000..8681c14527 --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/post-import-groups.hoon @@ -0,0 +1,24 @@ +/- spider, + contact-view, + *resource, + group-store +/+ *ph-io, strandio +=, strand=strand:spider +:: +^- thread:spider +|= vase +=/ m (strand ,vase) +;< ~ bind:m start-simple +;< bol=bowl:spider bind:m get-bowl:strandio +:: +=/ join-2=contact-view-action:contact-view [%join ~zod %group-2] +=/ add-members-1=action:group-store + [%add-members [~zod %group-1] (sy ~def ~ten ~)] +=/ add-members-2=action:group-store + [%add-members [~zod %group-2] (sy ~def ~ten ~)] +;< ~ bind:m (poke-app ~bus %contact-view %contact-view-action join-2) +;< ~ bind:m (poke-app ~web %contact-view %contact-view-action join-2) +;< ~ bind:m (poke-app ~zod %group-store %group-action add-members-1) +;< ~ bind:m (poke-app ~zod %group-store %group-action add-members-2) +:: +(pure:m *vase) diff --git a/pkg/arvo/ted/ph/migrate/post-import-metadata-contacts.hoon b/pkg/arvo/ted/ph/migrate/post-import-metadata-contacts.hoon new file mode 100644 index 0000000000..81a9825937 --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/post-import-metadata-contacts.hoon @@ -0,0 +1,61 @@ +/- spider, + contact-view, + contact-store, + group-store, + metadata-store, + post, + graph-store, + *resource +/+ *ph-io, strandio +=, strand=strand:spider +:: +:: +^- thread:spider +|= vase +=/ m (strand ,vase) +;< ~ bind:m start-simple +;< bol=bowl:spider bind:m get-bowl:strandio +:: +:: test metadata import +:: +=/ change-group-1=metadata-action:metadata-store + :* %add + /ship/~zod/group-1 + [%contacts /ship/~zod/group-1] + 'New Group 1 Title' + 'new description' + 0x0 + now.bol + ~zod + 'fake' + == +=/ change-web-book=metadata-action:metadata-store + :* %add + /ship/~web/graph-3 + [%graph /ship/~web/graph-3] + 'New Graph 3 Title' + 'new description' + 0x0 + now.bol + ~web + 'fake' + == +;< ~ bind:m (poke-app ~zod %metadata-hook %metadata-action change-group-1) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (poke-app ~web %metadata-hook %metadata-action change-web-book) +;< ~ bind:m (sleep ~s5) +:: +:: test contacts import +:: +=/ add-zod=contact-action:contact-store + :* %add /ship/~zod/group-1 ~zod + 'ZOD' '' '' '' '' 0x0 ~ + == +=/ add-bus=contact-action:contact-store + :* %add /ship/~zod/group-2 ~bus + 'BUS' '' '' '' '' 0x0 ~ + == +;< ~ bind:m (poke-app ~zod %contact-hook %contact-action add-zod) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (poke-app ~bus %contact-hook %contact-action add-bus) +(pure:m *vase) diff --git a/pkg/arvo/ted/ph/migrate/send-his.hoon b/pkg/arvo/ted/ph/migrate/send-his.hoon new file mode 100644 index 0000000000..bb7a589097 --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/send-his.hoon @@ -0,0 +1,18 @@ +/- spider +/+ *ph-io, strandio +=, strand=strand:spider +:: +^- thread:spider +|= vase +=/ m (strand ,vase) +;< ~ bind:m start-simple +;< bol=bowl:spider bind:m get-bowl:strandio +:: +;< ~ bind:m (send-hi ~zod ~bus) +;< ~ bind:m (send-hi ~zod ~web) +;< ~ bind:m (send-hi ~bus ~zod) +;< ~ bind:m (send-hi ~bus ~web) +;< ~ bind:m (send-hi ~web ~zod) +;< ~ bind:m (send-hi ~web ~bus) +:: +(pure:m *vase) diff --git a/pkg/arvo/ted/ph/migrate/start.hoon b/pkg/arvo/ted/ph/migrate/start.hoon new file mode 100644 index 0000000000..6eede60422 --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/start.hoon @@ -0,0 +1,73 @@ +/- spider +/+ *ph-io +=, strand=strand:spider +=> +|% +++ start-agent + |= [=ship agent=term] + =/ m (strand:spider ,~) + ^- form:m + =* loop $ + ;< ~ bind:m (dojo ship "|start {}") + ;< ~ bind:m ::(wait-for-agent-start ship agent) + (wait-for-output ship "activated app home/{(trip agent)}") + (pure:m ~) +:: +++ wait-for-agent-start + |= [=ship agent=term] + =/ m (strand:spider ,~) + ^- form:m + =* loop $ + ;< [her=^ship =unix-effect] bind:m take-unix-effect + ?: (is-dojo-output:util ship her unix-effect "activated app home/{(trip agent)}") + (pure:m ~) + loop +:: +++ start-agents + |= =ship + =/ m (strand:spider ,~) + ~& %starting-agents + ^- form:m + ;< ~ bind:m (start-agent ship %group-store) + ;< ~ bind:m (start-agent ship %group-pull-hook) + ;< ~ bind:m (start-agent ship %group-push-hook) + :: + ;< ~ bind:m (start-agent ship %metadata-store) + ;< ~ bind:m (start-agent ship %metadata-hook) + :: + ;< ~ bind:m (start-agent ship %invite-store) + ;< ~ bind:m (start-agent ship %invite-hook) + :: + ;< ~ bind:m (start-agent ship %chat-store) + ;< ~ bind:m (start-agent ship %chat-hook) + ;< ~ bind:m (start-agent ship %chat-view) + :: + ;< ~ bind:m (start-agent ship %contact-store) + ;< ~ bind:m (start-agent ship %contact-hook) + ;< ~ bind:m (start-agent ship %contact-view) + :: + ;< ~ bind:m (start-agent ship %graph-store) + ;< ~ bind:m (start-agent ship %graph-push-hook) + ;< ~ bind:m (start-agent ship %graph-pull-hook) + :: + (pure:m ~) +:: +-- +^- thread:spider +|= arg=vase +=+ !<(who=?(~ [@p ~]) arg) +=/ m (strand ,vase) +;< ~ bind:m start-simple +:: +?~ who + ;< ~ bind:m (dojo ~zod "|mount %") + ;< ~ bind:m (dojo ~bus "|mount %") + ;< ~ bind:m (dojo ~web "|mount %") + ;< ~ bind:m (start-agents ~zod) + ;< ~ bind:m (start-agents ~bus) + ;< ~ bind:m (start-agents ~web) + (pure:m *vase) +:: +;< ~ bind:m (dojo -.who "|mount %") +;< ~ bind:m (start-agents -.who) +(pure:m *vase) diff --git a/pkg/arvo/ted/ph/start-drivers.hoon b/pkg/arvo/ted/ph/start-drivers.hoon index 825a2b814a..e4480b03fa 100644 --- a/pkg/arvo/ted/ph/start-drivers.hoon +++ b/pkg/arvo/ted/ph/start-drivers.hoon @@ -6,8 +6,8 @@ =/ m (strand ,vase) ;< =bowl:spider bind:m get-bowl ;< ~ bind:m start-simple +:: must be a better way to background threads |- =* loop $ -~& >> %looping ;< ~ bind:m (sleep ~s5) loop From 50ca536a2759769de02e33db96323d17f90e808e Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Mon, 30 Nov 2020 13:06:05 -0800 Subject: [PATCH 814/933] groups: import/export --- pkg/arvo/app/group-store.hoon | 89 +++++++++++++++++++++++++++++++---- pkg/arvo/lib/pull-hook.hoon | 1 + 2 files changed, 82 insertions(+), 8 deletions(-) diff --git a/pkg/arvo/app/group-store.hoon b/pkg/arvo/app/group-store.hoon index 57552866af..f61d145699 100644 --- a/pkg/arvo/app/group-store.hoon +++ b/pkg/arvo/app/group-store.hoon @@ -29,7 +29,7 @@ :: Modify the group. Further documented in /sur/group-store.hoon :: :: -/- *group, permission-store +/- *group, permission-store, *contact-view /+ store=group-store, default-agent, verb, dbug, resource |% +$ card card:agent:gall @@ -165,12 +165,15 @@ ^- (quip card _this) ?> (team:title our.bowl src.bowl) =^ cards state - ?+ mark (on-poke:def mark vase) - %noun (poke-noun:gc vase) - :: + ?+ mark (on-poke:def mark vase) + %noun + (poke-noun:gc vase) + :: ?(%group-update %group-action) (poke-group-update:gc !<(update:store vase)) - :: + :: + %import + (poke-import:gc q.vase) == [cards this] :: @@ -214,10 +217,42 @@ (slav %p i.t.t.t.t.t.t.path) ?~ rid ~ ``noun+!>((peek-group-join u.rid ship)) + :: + [%x %export ~] + ``noun+!>(state) == :: - ++ on-agent on-agent:def - ++ on-arvo on-arvo:def + ++ on-agent + |= [=wire =sign:agent:gall] + ^- (quip card _this) + ?. ?=([%try-rejoin @ *] wire) + (on-agent:def wire sign) + ?> ?=(%poke-ack -.sign) + =/ rid=resource (de-path:resource t.t.wire) + ?~ p.sign + =/ =cage + [%pull-hook-action !>([%add entity.rid rid])] + :_ this + [%pass / %agent [our.bowl %group-pull-hook] %poke cage]~ + =/ nack-count=@ud (slav %ud i.t.wire) + =/ wakeup=@da + (add now.bowl (mul ~s1 (bex (min 19 nack-count)))) + :_ this + [%pass wire %arvo %b %wait wakeup]~ + :: + ++ on-arvo + |= [=wire =sign-arvo] + ^- (quip card _this) + ?. ?=([%try-rejoin @ *] wire) + (on-arvo:def wire sign-arvo) + =/ =resource (de-path:resource t.t.wire) + =/ nack-count=@ud (slav %ud i.t.wire) + ?> ?=([%b %wake *] sign-arvo) + ~? ?=(^ error.sign-arvo) + "behn errored in backoff timers, continuing anyway" + :_ this + [(try-rejoin:gc resource +(nack-count))]~ + :: ++ on-fail on-fail:def -- :: @@ -226,7 +261,7 @@ |= rid=resource ^- (unit group) (~(get by groups) rid) - +:: ++ peek-group-join |= [rid=resource =ship] =/ ugroup @@ -246,6 +281,39 @@ (~(has in ban-ranks.policy) (clan:title ship)) == == +:: +++ poke-import + |= arc=* + ^- (quip card _state) + =/ sty=state-one ;;(state-one arc) + :_ sty + %+ roll ~(tap by groups.sty) + |= [[=resource =group] out=(list card)] + ?: =(entity.resource our.bol) + %+ weld out + %+ roll ~(tap in members.group) + |= [recipient=@p out=(list card)] + ?: =(recipient our.bol) + out + :_ out + %- poke-contact + :* %invite resource recipient + (crip "Rejoin disconnected group {}/{}") + == + :_ out + (try-rejoin resource 0) +:: +++ try-rejoin + |= [rid=resource nack-count=@ud] + ^- card + =/ =cage + :- %group-update + !> ^- update:store + [%add-members rid (sy our.bol ~)] + =/ =wire + [%try-rejoin (scot %ud nack-count) (en-path:resource rid)] + [%pass wire %agent [entity.rid %group-push-hook] %poke cage] +:: ++ poke-noun |= =vase ^- (quip card _state) @@ -604,6 +672,11 @@ |= =action:store ^- card [%pass / %agent [our.bol %group-store] %poke %group-action !>(action)] +:: +++ poke-contact + |= act=contact-view-action + ^- card + [%pass / %agent [our.bol %contact-view] %poke %contact-view-action !>(act)] :: +send-diff: update subscribers of new state :: :: We only allow subscriptions on /groups diff --git a/pkg/arvo/lib/pull-hook.hoon b/pkg/arvo/lib/pull-hook.hoon index cb3b5e6f73..eb91242e75 100644 --- a/pkg/arvo/lib/pull-hook.hoon +++ b/pkg/arvo/lib/pull-hook.hoon @@ -196,6 +196,7 @@ =. inner-state on-save:og !>(state) + :: ++ on-poke |= [=mark =vase] ^- [(list card:agent:gall) agent:gall] From c2d09c58e35f7d8b1290e9f5b0aed50c969e9dbc Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Mon, 30 Nov 2020 13:06:41 -0800 Subject: [PATCH 815/933] metadata: import/export --- pkg/arvo/app/metadata-hook.hoon | 62 ++++++++++++++++++++++++++++++-- pkg/arvo/app/metadata-store.hoon | 13 +++++++ 2 files changed, 73 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/app/metadata-hook.hoon b/pkg/arvo/app/metadata-hook.hoon index 5cad893191..1d3e6dbcef 100644 --- a/pkg/arvo/app/metadata-hook.hoon +++ b/pkg/arvo/app/metadata-hook.hoon @@ -51,9 +51,30 @@ `this :: ++ on-leave on-leave:def - ++ on-peek on-peek:def - ++ on-arvo on-arvo:def + ++ on-peek + |= =path + ^- (unit (unit cage)) + ?+ path (on-peek:def path) + [%x %export ~] + ``noun+!>(state) + == + :: + ++ on-arvo + |= [=wire =sign-arvo] + ^- (quip card _this) + ?. ?=([%try-rejoin @ @ *] wire) + (on-arvo:def wire sign-arvo) + =/ nack-count=@ud (slav %ud i.t.wire) + =/ who=@p (slav %p i.t.t.wire) + =/ pax t.t.t.wire + ?> ?=([%b %wake *] sign-arvo) + ~? ?=(^ error.sign-arvo) + "behn errored in backoff timers, continuing anyway" + :_ this + [(try-rejoin:hc who pax +(nack-count))]~ + :: ++ on-fail on-fail:def + :: ++ on-poke |= [=mark =vase] ^- (quip card _this) @@ -65,6 +86,12 @@ :: %metadata-action [(poke-action:hc !<(metadata-action vase)) this] + :: + %import + ?> (team:title our.bowl src.bowl) + =^ cards state + (poke-import:hc q.vase) + [cards this] == :: ++ on-watch @@ -166,6 +193,25 @@ !=(i.path '~') -- :: +++ poke-import + |= arc=* + ^- (quip card _state) + =/ sty=state-one ;;(state-one arc) + :_ sty + %+ murn ~(tap by synced.sty) + |= [=group-path =ship] + ?: =(ship our.bowl) + ~ + =/ =path [%group group-path] + `(try-rejoin ship path 0) +:: +++ try-rejoin + |= [who=@p pax=path nack-count=@ud] + ^- card + =/ =wire + [%try-rejoin (scot %ud nack-count) (scot %p who) pax] + [%pass wire %agent [who %metadata-hook] %watch pax] +:: ++ watch-group |= =path ^- (list card) @@ -240,7 +286,11 @@ |= wir=wire ^- (quip card _state) :_ state + |- ?+ wir !! + [%try-rejoin @ @ *] + $(wir t.t.t.wir) + :: [%updates ~] [%pass /updates %agent [our.bowl %metadata-store] %watch /updates]~ :: @@ -255,6 +305,14 @@ ++ watch-ack |= [wir=wire saw=(unit tang)] ^- (quip card _state) + ?: ?=([%try-rejoin @ *] wir) + ?~ saw + [~ state] + =/ nack-count=@ud (slav %ud i.t.wir) + =/ wakeup=@da + (add now.bowl (mul ~s1 (bex (min 19 nack-count)))) + :_ state + [%pass wir %arvo %b %wait wakeup]~ ?> ?=(^ wir) [~ ?~(saw state state(synced (~(del by synced) t.wir)))] :: diff --git a/pkg/arvo/app/metadata-store.hoon b/pkg/arvo/app/metadata-store.hoon index ec32cf8182..402e39501d 100644 --- a/pkg/arvo/app/metadata-store.hoon +++ b/pkg/arvo/app/metadata-store.hoon @@ -278,6 +278,7 @@ ?+ mark (on-poke:def mark vase) %metadata-action (poke-metadata-action:mc !<(metadata-action vase)) + :: %noun =/ val=(each [%cleanup path] tang) (mule |.(!<([%cleanup path] vase))) @@ -296,6 +297,9 @@ [app-name.r group app-path.r] == out + :: + %import + (poke-import:mc q.vase) == [cards this] :: @@ -350,6 +354,9 @@ =/ app=term i.t.t.path =/ app-path=^path t.t.t.path ``noun+!>((~(get by resource-indices) app app-path)) + :: + [%x %export ~] + ``noun+!>(state) == :: ++ on-leave on-leave:def @@ -368,6 +375,12 @@ %remove (handle-remove group-path.act resource.act) == :: +++ poke-import + |= arc=* + ^- (quip card _state) + =/ sty=state-6 ;;(state-6 arc) + [~ sty] +:: ++ handle-add |= [=group-path =md-resource =metadata] ^- (quip card _state) From 295340b422172661a44acc4d3b252df60c785cf5 Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Mon, 30 Nov 2020 13:07:04 -0800 Subject: [PATCH 816/933] contacts: import/export --- pkg/arvo/app/contact-hook.hoon | 57 +++++++++++++++++++++++++++++++-- pkg/arvo/app/contact-store.hoon | 17 ++++++++-- 2 files changed, 70 insertions(+), 4 deletions(-) diff --git a/pkg/arvo/app/contact-hook.hoon b/pkg/arvo/app/contact-hook.hoon index 0871201839..379b8fdc10 100644 --- a/pkg/arvo/app/contact-hook.hoon +++ b/pkg/arvo/app/contact-hook.hoon @@ -132,6 +132,10 @@ :: %contact-hook-action (poke-hook-action:cc !<(contact-hook-action vase)) + :: + %import + ?> (team:title our.bol src.bol) + (poke-import:cc q.vase) == [cards this] :: @@ -170,8 +174,27 @@ == :: ++ on-leave on-leave:def - ++ on-peek on-peek:def - ++ on-arvo on-arvo:def + ++ on-peek + |= =path + ^- (unit (unit cage)) + ?+ path (on-peek:def path) + [%x %export ~] + ``noun+!>(state) + == + ++ on-arvo + |= [=wire =sign-arvo] + ^- (quip card _this) + ?. ?=([%try-rejoin @ @ *] wire) + (on-arvo:def wire sign-arvo) + =/ nack-count=@ud (slav %ud i.t.wire) + =/ who=@p (slav %p i.t.t.wire) + =/ pax t.t.t.wire + ?> ?=([%b %wake *] sign-arvo) + ~? ?=(^ error.sign-arvo) + "behn errored in backoff timers, continuing anyway" + :_ this + [(try-rejoin:cc who pax +(nack-count))]~ + :: ++ on-fail on-fail:def -- :: @@ -260,6 +283,26 @@ == == :: +++ poke-import + |= arc=* + ^- (quip card _state) + =/ sty=state-three ;;(state-three arc) + :_ sty + %+ turn ~(tap by synced.sty) + |= [=path =ship] + ^- card + =/ contact-path [%contacts path] + ?: =(our.bol ship) + [%pass contact-path %agent [our.bol %contact-store] %watch contact-path] + (try-rejoin ship contact-path 0) +:: +++ try-rejoin + |= [who=@p pax=path nack-count=@ud] + ^- card + =/ =wire + [%try-rejoin (scot %ud nack-count) (scot %p who) pax] + [%pass wire %agent [who %contact-hook] %watch pax] +:: ++ watch-contacts |= pax=path ^- (list card) @@ -282,6 +325,13 @@ ^- (quip card _state) ?~ saw [~ state] + ?: ?=([%try-rejoin @ *] wir) + =/ nack-count=@ud (slav %ud i.t.wir) + =/ wakeup=@da + (add now.bol (mul ~s1 (bex (min 19 nack-count)))) + :_ state + [%pass wir %arvo %b %wait wakeup]~ + :: ?> ?=(^ wir) [~ state(synced (~(del by synced) t.wir))] :: @@ -295,6 +345,9 @@ |= wir=wire ^- (list card) ?+ wir !! + [%try-rejoin @ @ *] + $(wir t.t.t.wir) + :: [%inv ~] [%pass /inv %agent [our.bol %invite-store] %watch /invitatory/contacts]~ :: diff --git a/pkg/arvo/app/contact-store.hoon b/pkg/arvo/app/contact-store.hoon index 6089cae80c..8ed19228a0 100644 --- a/pkg/arvo/app/contact-store.hoon +++ b/pkg/arvo/app/contact-store.hoon @@ -121,8 +121,12 @@ ?> (team:title our.bowl src.bowl) =^ cards state ?+ mark (on-poke:def mark vase) - ::%json (poke-json:cc !<(json vase)) - %contact-action (poke-contact-action:cc !<(contact-action vase)) + ::%json (poke-json:cc !<(json vase)) + %contact-action + (poke-contact-action:cc !<(contact-action vase)) + :: + %import + (poke-import:cc q.vase) == [cards this] :: @@ -169,6 +173,9 @@ ?~ contacts ~ ``noun+!>((~(get by u.contacts) ship)) + :: + [%x %export ~] + ``noun+!>(state) == :: ++ on-agent on-agent:def @@ -197,6 +204,12 @@ %edit (handle-edit +.action) == :: +++ poke-import + |= arc=* + ^- (quip card _state) + =/ sty=state-three ;;(state-three arc) + [~ sty] +:: ++ handle-create |= =path ^- (quip card _state) From 0c0efae1e9557127bdd4328ec9150f24ac03ee28 Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Mon, 30 Nov 2020 13:07:26 -0800 Subject: [PATCH 817/933] invites: import/export --- pkg/arvo/app/invite-store.hoon | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/arvo/app/invite-store.hoon b/pkg/arvo/app/invite-store.hoon index 258f61a4c6..5e504be746 100644 --- a/pkg/arvo/app/invite-store.hoon +++ b/pkg/arvo/app/invite-store.hoon @@ -102,9 +102,16 @@ =^ cards state ?+ mark (on-poke:def mark vase) %invite-action (poke-invite-action !<(action:store vase)) + %import (poke-import q.vase) == [cards this] :: + ++ poke-import + |= arc=* + ^- (quip card _state) + =/ sty=state-1 ;;(state-1 arc) + [~ sty] + :: ++ poke-invite-action |= =action:store ^- (quip card _state) @@ -205,5 +212,7 @@ :^ ~ ~ %noun !> ^- (unit invite:store) (~(get by invitatory) serial) + :: + [%x %export ~] ``noun+!>(state) == -- From edcd29c4da862b13012168dbfdfecd9c519b0664 Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Mon, 30 Nov 2020 13:07:51 -0800 Subject: [PATCH 818/933] chat: import/export --- pkg/arvo/app/chat-hook.hoon | 59 ++++++++++++++++++++++++++++++++++-- pkg/arvo/app/chat-store.hoon | 16 ++++++++-- 2 files changed, 70 insertions(+), 5 deletions(-) diff --git a/pkg/arvo/app/chat-hook.hoon b/pkg/arvo/app/chat-hook.hoon index 340d1e6c14..a0f7a4ee99 100644 --- a/pkg/arvo/app/chat-hook.hoon +++ b/pkg/arvo/app/chat-hook.hoon @@ -369,6 +369,10 @@ :: %chat-hook-action (poke-chat-hook-action:cc !<(action:hook vase)) + :: + %import + ?> (team:title our.bol src.bol) + (poke-import:cc q.vase) == [cards this] :: @@ -417,8 +421,28 @@ == :: ++ on-leave on-leave:def - ++ on-peek on-peek:def - ++ on-arvo on-arvo:def + ++ on-peek + |= =path + ^- (unit (unit cage)) + ?+ path (on-peek:def path) + [%x %export ~] + ``noun+!>(state) + == + :: + ++ on-arvo + |= [=wire =sign-arvo] + ^- (quip card _this) + ?. ?=([%try-rejoin @ @ *] wire) + (on-arvo:def wire sign-arvo) + =/ nack-count=@ud (slav %ud i.t.wire) + =/ who=@p (slav %p i.t.t.wire) + =/ pax t.t.t.wire + ?> ?=([%b %wake *] sign-arvo) + ~? ?=(^ error.sign-arvo) + "behn errored in backoff timers, continuing anyway" + :_ this + [(try-rejoin:cc who pax +(nack-count))]~ + :: ++ on-fail on-fail:def -- :: @@ -677,6 +701,27 @@ == == :: +++ poke-import + |= arc=* + ^- (quip card _state) + =/ sty=state-10 ;;(state-10 arc) + :_ sty + %+ turn ~(tap by synced.sty) + |= [=path =ship] + ^- card + =/ watch-path=^path [%mailbox path] + ?: =(our.bol ship) + =/ store-wire=wire [%store path] + [%pass store-wire %agent [our.bol %chat-store] %watch watch-path] + (try-rejoin ship watch-path 0) +:: +++ try-rejoin + |= [who=@p pax=path nack-count=@ud] + ^- card + =/ =wire + [%try-rejoin (scot %ud nack-count) (scot %p who) pax] + [%pass wire %agent [who %chat-hook] %watch pax] +:: ++ watch-synced |= pax=path ^- (list card) @@ -835,6 +880,9 @@ [%pass /permissions %agent [our.bol %permission-store] %watch /updates]~ :: ?+ wir !! + [%try-rejoin @ @ *] + $(wir t.t.t.wir) + :: [%groups ~] [~[watch-groups] state] :: [%store @ *] @@ -909,6 +957,13 @@ ?> ?=(^ chat) (migrate-listen t.chat) [~ state] + :: + [%try-rejoin @ *] + =/ nack-count=@ud (slav %ud i.t.wir) + =/ wakeup=@da + (add now.bol (mul ~s1 (bex (min 19 nack-count)))) + :_ state + [%pass wir %arvo %b %wait wakeup]~ == :: ++ chat-poke diff --git a/pkg/arvo/app/chat-store.hoon b/pkg/arvo/app/chat-store.hoon index 5118babbcc..e1fab3631c 100644 --- a/pkg/arvo/app/chat-store.hoon +++ b/pkg/arvo/app/chat-store.hoon @@ -89,9 +89,10 @@ ?> (team:title our.bowl src.bowl) =^ cards state ?+ mark (on-poke:def mark vase) - %json (poke-json:cc !<(json vase)) - %chat-action (poke-chat-action:cc !<(action:store vase)) - %noun [~ (poke-noun:cc !<(admin-action vase))] + %json (poke-json:cc !<(json vase)) + %chat-action (poke-chat-action:cc !<(action:store vase)) + %noun [~ (poke-noun:cc !<(admin-action vase))] + %import (poke-import:cc q.vase) == [cards this] :: @@ -139,6 +140,9 @@ ?~ mailbox ~ ``noun+!>(config.u.mailbox) + :: + [%x %export ~] + ``noun+!>(state) == :: ++ on-agent on-agent:def @@ -235,6 +239,12 @@ [(weld message-moves read-moves) state] == :: +++ poke-import + |= arc=* + ^- (quip card _state) + =/ sty=state-3 ;;(state-3 arc) + [~ sty] +:: ++ handle-create |= =action:store ^- (quip card _state) From 94f7ca5b9de4b3888a5528700b3aa2166a3adfcc Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Mon, 30 Nov 2020 13:08:15 -0800 Subject: [PATCH 819/933] graphs: import-export --- pkg/arvo/app/graph-store.hoon | 54 ++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/pkg/arvo/app/graph-store.hoon b/pkg/arvo/app/graph-store.hoon index df39fb0ae5..1104fb4129 100644 --- a/pkg/arvo/app/graph-store.hoon +++ b/pkg/arvo/app/graph-store.hoon @@ -218,6 +218,7 @@ ?+ mark (on-poke:def mark vase) %graph-update (graph-update !<(update:store vase)) %noun (debug !<(debug-input vase)) + %import (poke-import q.vase) == [cards this] :: @@ -612,6 +613,26 @@ %graph ^$(graph p.children.node) == == + :: + ++ poke-import + |= arc=* + ^- (quip card _state) + =/ sty ;;(state-2 arc) + :_ sty + %+ turn ~(tap by graphs.sty) + |= [rid=resource:store =marked-graph:store] + ^- card + ?: =(our.bowl entity.rid) + =/ =cage [%push-hook-action !>([%add rid])] + [%pass / %agent [our.bowl %graph-push-hook] %poke cage] + (try-rejoin rid 0) + :: + ++ try-rejoin + |= [rid=resource:store nack-count=@] + ^- card + =/ res-path (en-path:res rid) + =/ wire [%try-rejoin (scot %ud nack-count) res-path] + [%pass wire %agent [entity.rid %graph-push-hook] %watch resource+res-path] -- :: ++ on-peek @@ -668,6 +689,9 @@ :+ %0 now.bowl [%add-graph [ship term] `graph:store`p.u.result q.u.result %.y] + :: + [%x %export ~] + ``noun+!>(state) :: [%x %graph-subset @ @ @ @ ~] =/ =ship (slav %p i.t.t.path) @@ -792,9 +816,37 @@ =* validator i.t.wire =/ =rave:clay [%next %b [%da now.bowl] /[validator]] [%pass wire %arvo %c %warp our.bowl [%home `rave]]~ + :: + [%try-rejoin @ *] + =/ rid=resource:store (de-path:res t.t.wire) + =/ nack-count (slav %ud i.t.wire) + ?> ?=([%b %wake *] sign-arvo) + ~? ?=(^ error.sign-arvo) + "behn errored in backoff timers, continuing anyway" + =/ new=^wire [%try-rejoin (scot %ud +(nack-count)) t.t.wire] + :_ this + [%pass new %agent [entity.rid %graph-push-hook] %watch resource+t.t.wire]~ == :: -++ on-agent on-agent:def +++ on-agent + |= [=wire =sign:agent:gall] + ^- (quip card _this) + ?. ?=([%try-rejoin @ *] wire) + (on-agent:def wire sign) + ?. ?=(%watch-ack -.sign) + [~ this] + =/ rid=resource:store (de-path:res t.t.wire) + ?~ p.sign + :: leave and poke our graph-pull-hook + =/ =cage [%pull-hook-action !>([%add entity.rid rid])] + :_ this + [%pass / %agent [our.bowl %graph-pull-hook] %poke cage]~ + =/ nack-count=@ud (slav %ud i.t.wire) + =/ wakeup=@da + (add now.bowl (mul ~s1 (bex (min 19 nack-count)))) + :_ this + [%pass wire %arvo %b %wait wakeup]~ +:: ++ on-leave on-leave:def ++ on-fail on-fail:def -- From 81cf81312849fa273269379eca77ddde3ae14265 Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Mon, 16 Nov 2020 15:57:35 -0800 Subject: [PATCH 820/933] herb/lens: add utilites for import/export --- pkg/arvo/app/dojo.hoon | 2 ++ pkg/arvo/app/lens.hoon | 63 ++++++++++++++++++++++++++++++---- pkg/arvo/mar/lens/command.hoon | 2 ++ pkg/arvo/sur/lens.hoon | 2 ++ pkg/herb/herb | 37 ++++++++++++++++++-- 5 files changed, 98 insertions(+), 8 deletions(-) diff --git a/pkg/arvo/app/dojo.hoon b/pkg/arvo/app/dojo.hoon index a15980b70d..5e54034a7b 100644 --- a/pkg/arvo/app/dojo.hoon +++ b/pkg/arvo/app/dojo.hoon @@ -1145,6 +1145,8 @@ $listen-api !! $export !! $import !! + $export-all !! + $import-all !! $as :* %as mar.source.com $(num +(num), source.com next.source.com) diff --git a/pkg/arvo/app/lens.hoon b/pkg/arvo/app/lens.hoon index 8c86f8f8d6..e08d3e395d 100644 --- a/pkg/arvo/app/lens.hoon +++ b/pkg/arvo/app/lens.hoon @@ -14,6 +14,28 @@ job=(unit [eyre-id=@ta com=command:lens]) == == +:: +++ export-app + |= [app=@tas our=@p now=@da] + .^(@ %gx /(scot %p our)/[app]/(scot %da now)/export/noun) +++ export-all + |= [our=@p now=@da] + ^- (list [@tas @]) + %+ turn + ^- (list @tas) + :~ %group-store + %metadata-store + %metadata-hook + %contact-store + %contact-hook + %invite-store + %chat-store + %chat-hook + %publish + %graph-store + == + |= app=@tas + [app (export-app app our now)] -- :: =| =state @@ -43,12 +65,15 @@ =/ com=command:lens (json:grab:lens-mark jon) :: - ?: ?=(%export -.source.com) - ~& [%export app.source.com] + ?+ -.source.com + :_ this(job.state (some [eyre-id com])) + [%pass /sole %agent [our.bowl %dojo] %watch /sole/[eyre-id]]~ + :: + %export :_ this(job.state (some [eyre-id com])) [%pass /export %agent [our.bowl app.source.com] %watch /export]~ :: - ?: ?=(%import -.source.com) + %import ?~ enc=(de:base64 base64-jam.source.com) !! :: @@ -57,8 +82,28 @@ :_ this(job.state (some [eyre-id com])) [%pass /import %agent [our.bowl app.source.com] %poke %import !>(c)]~ :: - :_ this(job.state (some [eyre-id com])) - [%pass /sole %agent [our.bowl %dojo] %watch /sole/[eyre-id]]~ + %export-all + =/ output (crip "{}-export/atom") + =/ jon + =/ =atom (jam (export-all our.bowl now.bowl)) + =/ =octs [(met 3 atom) atom] + =/ enc (en:base64 octs) + (pairs:enjs:format file+s+output data+s+enc ~) + :_ this + %+ give-simple-payload:app eyre-id + (json-response:gen jon) + :: + %import-all + =/ enc (de:base64 base64-jam.source.com) + ?~ enc !! + =/ by-app ;;((list [@tas @]) (cue q.u.enc)) + :_ this + %+ weld (give-simple-payload:app eyre-id not-found:gen) + %+ turn by-app + |= [app=@tas data=@] + ^- card:agent:gall + [%pass /import-all %agent [our.bowl app] %poke %import !>(data)] + == :: ++ on-watch |= =path @@ -68,7 +113,13 @@ (on-watch:def path) :: ++ on-leave on-leave:def -++ on-peek on-peek:def +++ on-peek + |= =path + ^- (unit (unit cage)) + ?+ path (on-peek:def path) + [%x %export-all ~] + ``noun+!>((jam (export-all our.bowl now.bowl))) + == ++ on-agent |= [=wire =sign:agent:gall] ^- (quip card:agent:gall _this) diff --git a/pkg/arvo/mar/lens/command.hoon b/pkg/arvo/mar/lens/command.hoon index 9a1defd3a9..3f29fc8336 100644 --- a/pkg/arvo/mar/lens/command.hoon +++ b/pkg/arvo/mar/lens/command.hoon @@ -42,6 +42,8 @@ listen-api+(su ;~(plug sym ;~(pfix col sym))) export+so import+(ot app+so base64-jam+so ~) + export-all+none + import-all+(ot base64-jam+so ~) as+(ot mark+(su sym) next+source ~) hoon+(ot code+so next+source ~) == diff --git a/pkg/arvo/sur/lens.hoon b/pkg/arvo/sur/lens.hoon index 5503aa7581..0c75afa8c7 100644 --- a/pkg/arvo/sur/lens.hoon +++ b/pkg/arvo/sur/lens.hoon @@ -17,6 +17,8 @@ {$listen-api api/term event/term} {$export app/@t} {$import app/@t base64-jam/@t} + {$export-all ~} + {$import-all base64-jam/@t} == ++ sink $% {$stdout ~} diff --git a/pkg/herb/herb b/pkg/herb/herb index 315992f01d..1ad9bfcd6d 100755 --- a/pkg/herb/herb +++ b/pkg/herb/herb @@ -145,6 +145,34 @@ class importFileAction(argparse.Action): res.source = {"import": {"app": new_value, "base64-jam": base_data}} +class importAllAction(argparse.Action): + """Handles the import-all statement. + + The --import-all statement reads in a jammed noun file from the path passed + in and stuffs it the base64 encoded version which gets passed into your + Urbit. + + """ + def __call__(self, parser, res, new_value, option_string): + logging.debug('%r %r' % (new_value, option_string)) + logging.debug('source %s' % res.source) + logging.debug('level %s' % res.level) + + # We check to see if there's a "{new_value}" file in the current + # working directory. If there isn't, we error + data = "" + filename = new_value + with open(filename, 'rb') as f: + data = f.read() + + if data == "": + raise ValueError('Failed to read jamfile') + + base_data = base64.b64encode(data) + + res.source = {"import-all": {"base64-jam": base_data}} + + class transformerAction(argparse.Action): """Handle transformer flag. @@ -350,6 +378,13 @@ parser.add_argument('-i', '--import', metavar='app-name', help='imports the application state', action=importFileAction) +parser.add_argument('-E', '--export-all', const={'export-all': None}, + help='exports data from all landscape apps', + action='store_const', dest='source') +parser.add_argument('-I', '--import-all', + metavar='jam-file', + help='imports data for all landscape apps', + action=importAllAction) parser.add_argument('-m', '--mark', which='as', metavar='mark', help='transform a source to another mark', @@ -398,10 +433,8 @@ sinks.add_argument('-p', '--app', which='app', metavar='app', action=sinkAction) - args = parser.parse_args(args) - if args.source is None: args.source = {"data": ''.join(sys.stdin)} From a779ca4d7e11344d39aaf76ca611657ca5bd08be Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Tue, 1 Dec 2020 00:15:05 -0800 Subject: [PATCH 821/933] herb: expect * rather than @ --- pkg/arvo/app/lens.hoon | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/arvo/app/lens.hoon b/pkg/arvo/app/lens.hoon index e08d3e395d..b1facd5645 100644 --- a/pkg/arvo/app/lens.hoon +++ b/pkg/arvo/app/lens.hoon @@ -17,10 +17,10 @@ :: ++ export-app |= [app=@tas our=@p now=@da] - .^(@ %gx /(scot %p our)/[app]/(scot %da now)/export/noun) + .^(* %gx /(scot %p our)/[app]/(scot %da now)/export/noun) ++ export-all |= [our=@p now=@da] - ^- (list [@tas @]) + ^- (list [@tas *]) %+ turn ^- (list @tas) :~ %group-store @@ -31,7 +31,6 @@ %invite-store %chat-store %chat-hook - %publish %graph-store == |= app=@tas @@ -94,13 +93,14 @@ (json-response:gen jon) :: %import-all + ~& %import-all =/ enc (de:base64 base64-jam.source.com) ?~ enc !! - =/ by-app ;;((list [@tas @]) (cue q.u.enc)) + =/ by-app ;;((list [@tas *]) (cue q.u.enc)) :_ this %+ weld (give-simple-payload:app eyre-id not-found:gen) %+ turn by-app - |= [app=@tas data=@] + |= [app=@tas data=*] ^- card:agent:gall [%pass /import-all %agent [our.bowl app] %poke %import !>(data)] == From 85c9647353b43b5c1924342a309c1b6144964ed9 Mon Sep 17 00:00:00 2001 From: fang Date: Tue, 1 Dec 2020 12:37:15 +0100 Subject: [PATCH 822/933] vere: remove -o in favor of manual -X --- pkg/urbit/daemon/main.c | 5 +---- pkg/urbit/include/vere/vere.h | 1 - pkg/urbit/vere/pier.c | 17 ----------------- 3 files changed, 1 insertion(+), 22 deletions(-) diff --git a/pkg/urbit/daemon/main.c b/pkg/urbit/daemon/main.c index 8186a8c476..9364dbc221 100644 --- a/pkg/urbit/daemon/main.c +++ b/pkg/urbit/daemon/main.c @@ -74,7 +74,6 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.abo = c3n; u3_Host.ops_u.dem = c3n; u3_Host.ops_u.dry = c3n; - u3_Host.ops_u.exp = c3n; u3_Host.ops_u.gab = c3n; u3_Host.ops_u.git = c3n; @@ -98,7 +97,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.kno_w = DefaultKernel; while ( -1 != (ch_i=getopt(argc, argv, - "X:Y:G:J:B:K:A:H:I:C:w:u:e:F:k:n:p:r:i:Z:LljacdgoqstvxPDRS")) ) + "X:Y:G:J:B:K:A:H:I:C:w:u:e:F:k:n:p:r:i:Z:LljacdgqstvxPDRS")) ) { switch ( ch_i ) { case 'X': { @@ -204,7 +203,6 @@ _main_getopt(c3_i argc, c3_c** argv) case 'c': { u3_Host.ops_u.nuu = c3y; break; } case 'd': { u3_Host.ops_u.dem = c3y; break; } case 'g': { u3_Host.ops_u.gab = c3y; break; } - case 'o': { u3_Host.ops_u.exp = c3y; break; } case 'P': { u3_Host.ops_u.pro = c3y; break; } case 'D': { u3_Host.ops_u.dry = c3y; break; } case 'q': { u3_Host.ops_u.qui = c3y; break; } @@ -414,7 +412,6 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-K stage Start at Hoon kernel version stage\n", "-k keys Private key file\n", "-L local networking only\n", - "-o export pier state\n", "-P Profiling\n", "-p ames_port Set the ames port to bind to\n", "-q Quiet\n", diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index 89b303269b..bc18f11f15 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -266,7 +266,6 @@ c3_c* dns_c; // -H, ames bootstrap domain c3_c* jin_c; // -I, inject raw event c3_c* imp_c; // -i, import pier state - c3_o exp; // -o, export pier state c3_w hap_w; // -C, cap memo cache c3_c* lit_c; // -J, ivory (fastboot) kernel c3_o tra; // -j, json trace diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index ac719f2765..3178c3b56e 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -623,23 +623,6 @@ _pier_work_init(u3_pier* pir_u) } u3z(pex); } - else if ( _(u3_Host.ops_u.exp) ) { - u3_noun pex = u3do("stab", u3i_string("/gx/lens/export-all/noun")); - u3_noun car; - u3_noun dek; - u3_noun pax; - u3r_trel(pex, &car, &dek, &pax); - if (!u3_Host.ops_u.puk_c) { - u3_Host.ops_u.puk_c = strdup("/archive"); - } - // run the requested scry, jam to disk, then exit - // - u3l_log("pier: scry\n"); - u3_pier_peek_last(pir_u, u3_nul, u3k(car), u3k(dek), u3k(pax), - pir_u, _pier_on_scry_done); - u3z(pex); - - } else { // initialize i/o drivers // From 005680a7b8244c66d1426b2a3310d47d133bc432 Mon Sep 17 00:00:00 2001 From: fang Date: Tue, 1 Dec 2020 12:40:13 +0100 Subject: [PATCH 823/933] vere: fix -Z refcounts --- pkg/urbit/vere/pier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index 3178c3b56e..f0bfc2a335 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -502,7 +502,7 @@ _pier_on_scry_done(void* ptr_v, u3_noun nun) ext_c = "jam"; } else { - out = u3dc("scot", puf, u3k(res)); + out = u3dc("scot", u3k(puf), u3k(res)); ext_c = "txt"; } u3z(puf); From c7b8ffbf4e39a58f2df999d2daf5f95284d69a56 Mon Sep 17 00:00:00 2001 From: Ted Blackman Date: Tue, 1 Dec 2020 09:51:14 -0500 Subject: [PATCH 824/933] ames: flat packet format --- pkg/arvo/sys/vane/ames.hoon | 785 ++++++++++++++++-------------- pkg/arvo/tests/sys/vane/ames.hoon | 155 +++++- pkg/urbit/vere/io/ames.c | 295 ++++++----- 3 files changed, 697 insertions(+), 538 deletions(-) diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index 790ed55e87..5ffedece11 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -105,7 +105,9 @@ rot=`?`%.n :: routing attempts == => +~% %ames ..is ~ |% ++| %helpers :: +trace: print if .verb is set and we're tracking .ship :: ++ trace @@ -117,22 +119,373 @@ ~+ |(=(~ ships) (~(has in ships) ship)) same (slog leaf/"ames: {(scow %p ship)}: {(print)}" ~) --- -=> -~% %ames-generics ..is ~ -|% +:: +qos-update-text: notice text for if connection state changes +:: +++ qos-update-text + |= [=ship old=qos new=qos] + ^- (unit tape) + :: + ?+ [-.old -.new] ~ + [%unborn %live] `"; {(scow %p ship)} is your neighbor" + [%dead %live] `"; {(scow %p ship)} is ok" + [%live %dead] `"; {(scow %p ship)} not responding still trying" + [%unborn %dead] `"; {(scow %p ship)} not responding still trying" + [%live %unborn] `"; {(scow %p ship)} has sunk" + [%dead %unborn] `"; {(scow %p ship)} has sunk" + == +:: +lte-packets: yes if a is before b +:: +++ lte-packets + |= [a=live-packet-key b=live-packet-key] + ^- ? + :: + ?: (lth message-num.a message-num.b) + %.y + ?: (gth message-num.a message-num.b) + %.n + (lte fragment-num.a fragment-num.b) +:: +split-message: split message into kilobyte-sized fragments +:: +:: We don't literally split it here since that would allocate many +:: large atoms with no structural sharing. Instead, each +:: static-fragment has the entire message and a counter. In +:: +encrypt, we interpret this to get the actual fragment. +:: +++ split-message + ~/ %split-message + |= [=message-num =message-blob] + ^- (list static-fragment) + :: + =/ num-fragments=fragment-num (met 13 message-blob) + =| counter=@ + :: + |- ^- (list static-fragment) + ?: (gte counter num-fragments) + ~ + :: + :- [message-num num-fragments counter `@`message-blob] + $(counter +(counter)) +:: +assemble-fragments: concatenate fragments into a $message +:: +++ assemble-fragments + ~/ %assemble-fragments + |= [num-fragments=fragment-num fragments=(map fragment-num fragment)] + ^- * + :: + =| sorted=(list fragment) + =. sorted + =/ index=fragment-num 0 + |- ^+ sorted + ?: =(index num-fragments) + sorted + $(index +(index), sorted [(~(got by fragments) index) sorted]) + :: + %- cue + %+ can 13 + %+ turn (flop sorted) + |=(a=@ [1 a]) +:: +bind-duct: find or make new $bone for .duct in .ossuary +:: +++ bind-duct + |= [=ossuary =duct] + ^+ [next-bone.ossuary ossuary] + :: + ?^ existing=(~(get by by-duct.ossuary) duct) + [u.existing ossuary] + :: + :- next-bone.ossuary + :+ (add 4 next-bone.ossuary) + (~(put by by-duct.ossuary) duct next-bone.ossuary) + (~(put by by-bone.ossuary) next-bone.ossuary duct) +:: +make-bone-wire: encode ship and bone in wire for sending to vane +:: +++ make-bone-wire + |= [her=ship =bone] + ^- wire + :: + /bone/(scot %p her)/(scot %ud bone) +:: +parse-bone-wire: decode ship and bone from wire from local vane +:: +++ parse-bone-wire + |= =wire + ^- [her=ship =bone] + :: + ~| %ames-wire-bone^wire + ?> ?=([%bone @ @ ~] wire) + [`@p`(slav %p i.t.wire) `@ud`(slav %ud i.t.t.wire)] +:: +make-pump-timer-wire: construct wire for |packet-pump timer +:: +++ make-pump-timer-wire + |= [her=ship =bone] + ^- wire + /pump/(scot %p her)/(scot %ud bone) +:: +parse-pump-timer-wire: parse .her and .bone from |packet-pump wire +:: +++ parse-pump-timer-wire + |= =wire + ^- (unit [her=ship =bone]) + :: + ~| %ames-wire-timer^wire + ?. ?=([%pump @ @ ~] wire) + ~ + ?~ ship=`(unit @p)`(slaw %p i.t.wire) + ~ + ?~ bone=`(unit @ud)`(slaw %ud i.t.t.wire) + ~ + `[u.ship u.bone] +:: +derive-symmetric-key: $symmetric-key from $private-key and $public-key +:: +:: Assumes keys have a tag on them like the result of the |ex:crub core. +:: +++ derive-symmetric-key + ~/ %derive-symmetric-key + |= [=public-key =private-key] + ^- symmetric-key + :: + ?> =('b' (end 3 1 public-key)) + =. public-key (rsh 8 1 (rsh 3 1 public-key)) + :: + ?> =('B' (end 3 1 private-key)) + =. private-key (rsh 8 1 (rsh 3 1 private-key)) + :: + `@`(shar:ed:crypto public-key private-key) +:: +encode-packet: serialize a packet into a bytestream +:: +++ encode-packet + ~/ %encode-packet + |= packet + ^- blob + :: + =/ sndr-meta (encode-ship-metadata sndr) + =/ rcvr-meta (encode-ship-metadata rcvr) + :: + =/ body=@ + ;: mix + sndr-tick + (lsh 2 1 rcvr-tick) + (lsh 3 1 sndr) + (lsh 3 +(size.sndr-meta) rcvr) + (lsh 3 +((add size.sndr-meta size.rcvr-meta)) content) + == + =/ checksum (end 0 20 (mug body)) + =? body ?=(^ origin) (mix u.origin (lsh 3 6 body)) + :: + =/ header=@ + %+ can 0 + :~ [3 reserved=0] + [1 is-ames=&] + [3 protocol-version] + [2 rank.sndr-meta] + [2 rank.rcvr-meta] + [20 checksum] + [1 relayed=.?(origin)] + == + (mix header (lsh 5 1 body)) +:: +decode-packet: deserialize packet from bytestream or crash +:: +++ decode-packet + ~/ %decode-packet + |= =blob + ^- packet + ~| %decode-packet-fail + :: first 32 (2^5) bits are header; the rest is body + :: + =/ header (end 5 1 blob) + =/ body (rsh 5 1 blob) + :: read header; first three bits are reserved + :: + =/ is-ames (cut 0 [3 1] header) + ?. =(& is-ames) + ~| %ames-not-ames !! + :: + =/ version (cut 0 [4 3] header) + ?. =(protocol-version version) + ~| ames-protocol-version+version !! + :: + =/ sndr-size (decode-ship-size (cut 0 [7 2] header)) + =/ rcvr-size (decode-ship-size (cut 0 [9 2] header)) + =/ checksum (cut 0 [11 20] header) + =/ relayed (cut 0 [31 1] header) + :: origin, if present, is 6 octets long, at the end of the body + :: + =^ origin=(unit @) body + ?: =(| relayed) + [~ body] + =/ len (sub (met 3 body) 6) + [`(end 3 6 body) (rsh 3 6 body)] + :: .checksum does not apply to the origin + :: + ?. =(checksum (end 0 20 (mug body))) + ~| %ames-checksum !! + :: read fixed-length sndr and rcvr life data from body + :: + :: These represent the last four bits of the sender and receiver + :: life fields, to be used for quick dropping of honest packets to + :: or from the wrong life. + :: + =/ sndr-tick (cut 0 [0 4] body) + =/ rcvr-tick (cut 0 [4 4] body) + :: read variable-length .sndr and .rcvr addresses + :: + =/ off 1 + =^ sndr off [(cut 3 [off sndr-size] body) (add off sndr-size)] + ?. (is-valid-rank sndr sndr-size) + ~| ames-sender-impostor+[sndr sndr-size] !! + :: + =^ rcvr off [(cut 3 [off rcvr-size] body) (add off rcvr-size)] + ?. (is-valid-rank rcvr rcvr-size) + ~| ames-receiver-impostor+[rcvr rcvr-size] !! + :: read variable-length .content from the rest of .body + :: + =/ content (cut 3 [off (sub (met 3 body) off)] body) + [[sndr rcvr] sndr-tick rcvr-tick origin content] +:: +is-valid-rank: does .ship match its stated .size? +:: +++ is-valid-rank + ~/ %is-valid-rank + |= [=ship size=@ubC] + ^- ? + .= size + ?- (clan:title ship) + %czar 2 + %king 2 + %duke 4 + %earl 8 + %pawn 16 + == +:: +encode-open-packet: convert $open-packet attestation to $packet +:: +++ encode-open-packet + ~/ %encode-open-packet + |= [pac=open-packet =acru:ames] + ^- packet + :* [sndr rcvr]:pac + (mod sndr-life.pac 16) + (mod rcvr-life.pac 16) + origin=~ + content=`@`(sign:as:acru (jam pac)) + == +:: +decode-open-packet: decode comet attestation into an $open-packet +:: +++ decode-open-packet + ~/ %decode-open-packet + |= [=packet our=ship our-life=@] + ^- open-packet + :: deserialize and type-check packet contents + :: + =+ ;; [signature=@ signed=@] (cue content.packet) + =+ ;; =open-packet (cue signed) + :: assert .our and .her and lives match + :: + ?> .= sndr.open-packet sndr.packet + ?> .= rcvr.open-packet our + ?> .= sndr-life.open-packet 1 + ?> .= rcvr-life.open-packet our-life + :: only a star can sponsor a comet + :: + ?> =(%king (clan:title (^sein:title sndr.packet))) + :: comet public-key must hash to its @p address + :: + ?> =(sndr.packet fig:ex:(com:nu:crub:crypto public-key.open-packet)) + :: verify signature + :: + :: Logic duplicates +com:nu:crub:crypto and +sure:as:crub:crypto. + :: + =/ key (end 8 1 (rsh 3 1 public-key.open-packet)) + ?> (veri:ed:crypto signature signed key) + open-packet +:: +encode-shut-packet: encrypt and packetize a $shut-packet +:: +++ encode-shut-packet + ~/ %encode-shut-packet + |= $: =shut-packet + =symmetric-key + sndr=ship + rcvr=ship + sndr-life=@ + rcvr-life=@ + == + ^- packet + :: + =? meat.shut-packet + ?& ?=(%& -.meat.shut-packet) + (gth (met 13 fragment.p.meat.shut-packet) 1) + == + %_ meat.shut-packet + fragment.p + (cut 13 [[fragment-num 1] fragment]:p.meat.shut-packet) + == + :: + =/ vec ~[sndr rcvr sndr-life rcvr-life] + =/ [siv=@uxH len=@ cyf=@ux] + (~(en sivc:aes:crypto (shaz symmetric-key) vec) (jam shut-packet)) + =/ content :(mix siv (lsh 7 1 len) (lsh 3 18 cyf)) + [[sndr rcvr] (mod sndr-life 16) (mod rcvr-life 16) origin=~ content] +:: +decode-shut-packet: decrypt a $shut-packet from a $packet +:: +++ decode-shut-packet + ~/ %decode-shut-packet + |= [=packet =symmetric-key sndr-life=@ rcvr-life=@] + ^- shut-packet + ?. =(sndr-tick.packet (mod sndr-life 16)) + ~| ames-sndr-tick+sndr-tick.packet !! + ?. =(rcvr-tick.packet (mod rcvr-life 16)) + ~| ames-rcvr-tick+rcvr-tick.packet !! + =/ siv (end 7 1 content.packet) + =/ len (end 4 1 (rsh 7 1 content.packet)) + =/ cyf (rsh 3 18 content.packet) + ~| ames-decrypt+[[sndr rcvr origin]:packet len siv] + =/ vec ~[sndr.packet rcvr.packet sndr-life rcvr-life] + ;; shut-packet %- cue %- need + (~(de sivc:aes:crypto (shaz symmetric-key) vec) siv len cyf) +:: +decode-ship-size: decode a 2-bit ship type specifier into a byte width +:: +:: Type 0: galaxy or star -- 2 bytes +:: Type 1: planet -- 4 bytes +:: Type 2: moon -- 8 bytes +:: Type 3: comet -- 16 bytes +:: +++ decode-ship-size + ~/ %decode-ship-size + |= rank=@ubC + ^- @ + :: + ?+ rank !! + %0b0 2 + %0b1 4 + %0b10 8 + %0b11 16 + == +:: +encode-ship-metadata: produce size (in bytes) and address rank for .ship +:: +:: 0: galaxy or star +:: 1: planet +:: 2: moon +:: 3: comet +:: +++ encode-ship-metadata + ~/ %encode-ship-metadata + |= =ship + ^- [size=@ =rank] + :: + =/ size=@ (met 3 ship) + :: + ?: (lte size 2) [2 %0b0] + ?: (lte size 4) [4 %0b1] + ?: (lte size 8) [8 %0b10] + [16 %0b11] +| %atomics :: +$ private-key @uwprivatekey +$ signature @uwsignature :: $rank: which kind of ship address, by length :: -:: 0: galaxy or star -- 2 bytes -:: 1: planet -- 4 bytes -:: 2: moon -- 8 bytes -:: 3: comet -- 16 bytes +:: 0b0: galaxy or star -- 2 bytes +:: 0b1: planet -- 4 bytes +:: 0b10: moon -- 8 bytes +:: 0b11: comet -- 16 bytes :: -+$ rank ?(%0 %1 %2 %3) ++$ rank ?(%0b0 %0b1 %0b10 %0b11) :: +| %kinetics :: $channel: combined sender and receiver identifying data @@ -165,7 +518,13 @@ :: address. Routes are opaque to Arvo and only have meaning in the :: interpreter. This enforces that Ames is transport-agnostic. :: -+$ packet [dyad encrypted=? origin=(unit lane) content=*] ++$ packet + $: dyad + sndr-tick=@ubC + rcvr-tick=@ubC + origin=(unit @uxaddress) + content=@uxcontent + == :: $open-packet: unencrypted packet payload, for comet self-attestation :: :: This data structure gets signed and jammed to form the .contents @@ -181,9 +540,7 @@ :: $shut-packet: encrypted packet payload :: +$ shut-packet - $: =sndr=life - =rcvr=life - =bone + $: =bone =message-num meat=(each fragment-meat ack-meat) == @@ -691,14 +1048,16 @@ ``noun+!>(!>(res)) == -- -:: helpers +:: |per-event: inner event-handling core :: -~% %ames-helpers +>+ ~ +~% %per-event ..decode-packet ~ |% ++ per-event =| moves=(list move) + ~% %event-gate ..per-event ~ |= [[our=ship now=@da eny=@ scry-gate=sley] =duct =ames-state] =* veb veb.bug.ames-state + ~% %event-core ..$ ~ |% ++ event-core . ++ abet [(flop moves) ames-state] @@ -848,20 +1207,14 @@ =/ =channel [[our ship] now channel-state -.peer-state] abet:on-jilt:(make-peer-core peer-state channel) :: +on-hear: handle raw packet receipt - :: - ++ on-hear - |= [=lane =blob] - ^+ event-core - (on-hear-packet lane (decode-packet blob) ok=%.y) :: +on-hole: handle packet crash notification :: - ++ on-hole - |= [=lane =blob] - ^+ event-core - (on-hear-packet lane (decode-packet blob) ok=%.n) + ++ on-hear |=([l=lane b=blob] (on-hear-packet l (decode-packet b) ok=&)) + ++ on-hole |=([l=lane b=blob] (on-hear-packet l (decode-packet b) ok=|)) :: +on-hear-packet: handle mildly processed packet receipt :: ++ on-hear-packet + ~/ %on-hear-packet |= [=lane =packet ok=?] ^+ event-core :: @@ -873,9 +1226,11 @@ ?. =(our rcvr.packet) on-hear-forward :: - ?: encrypted.packet - on-hear-shut - on-hear-open + ?: ?& ?=(%pawn (clan:title sndr.packet)) + !(~(has by peers.ames-state) sndr.packet) + == + on-hear-open + on-hear-shut :: +on-hear-forward: maybe forward a packet to someone else :: :: Note that this performs all forwarding requests without @@ -883,18 +1238,27 @@ :: provided by Vere. :: ++ on-hear-forward + ~/ %on-hear-forward |= [=lane =packet ok=?] ^+ event-core %- %^ trace for.veb sndr.packet |.("forward: {} -> {}") :: set .origin.packet if it doesn't already have one, re-encode, and send :: - =? origin.packet ?=(~ origin.packet) `lane + =? origin.packet + &(?=(~ origin.packet) !=(%czar (clan:title sndr.packet))) + ?: ?=(%& -.lane) + ~ + ?. (lte (met 3 p.lane) 6) + ~| ames-lane-size+p.lane !! + `p.lane + :: =/ =blob (encode-packet packet) (send-blob & rcvr.packet blob) :: +on-hear-open: handle receipt of plaintext comet self-attestation :: ++ on-hear-open + ~/ %on-hear-open |= [=lane =packet ok=?] ^+ event-core :: assert the comet can't pretend to be a moon or other address @@ -905,29 +1269,8 @@ =/ ship-state (~(get by peers.ames-state) sndr.packet) ?: ?=([~ %known *] ship-state) event-core - :: deserialize and type-check packet contents :: - ?> ?=(@ content.packet) - =+ ;; [signature=@ signed=@] (cue content.packet) - =+ ;; =open-packet (cue signed) - :: assert .our and .her and lives match - :: - ?> .= sndr.open-packet sndr.packet - ?> .= rcvr.open-packet our - ?> .= sndr-life.open-packet 1 - ?> .= rcvr-life.open-packet life.ames-state - :: only a star can sponsor a comet - :: - ?> =(%king (clan:title (^sein:title sndr.packet))) - :: comet public-key must hash to its @p address - :: - ?> =(sndr.packet fig:ex:(com:nu:crub:crypto public-key.open-packet)) - :: verify signature - :: - :: Logic duplicates +com:nu:crub:crypto and +sure:as:crub:crypto. - :: - =/ key (end 8 1 (rsh 3 1 public-key.open-packet)) - ?> (veri:ed:crypto signature signed key) + =/ =open-packet (decode-open-packet packet our life.ames-state) :: store comet as peer in our state :: =. peers.ames-state @@ -952,12 +1295,9 @@ :: +on-hear-shut: handle receipt of encrypted packet :: ++ on-hear-shut + ~/ %on-hear-shut |= [=lane =packet ok=?] ^+ event-core - :: encrypted packet content must be an encrypted atom - :: - ?> ?=(@ content.packet) - :: =/ sndr-state (~(get by peers.ames-state) sndr.packet) :: if we don't know them, maybe enqueue a jael %public-keys request :: @@ -977,19 +1317,11 @@ =/ =peer-state +.u.sndr-state =/ =channel [[our sndr.packet] now channel-state -.peer-state] ~| %ames-crash-on-packet-from^her.channel - =/ =shut-packet (decrypt symmetric-key.channel content.packet) - :: ward against replay attacks - :: - :: We only accept packets from a ship at their known life, and to - :: us at our current life. - :: - ~| our-life=[expected=our-life.channel got=rcvr-life.shut-packet] - ~| her-life=[expected=her-life.channel got=sndr-life.shut-packet] - ?> =(sndr-life.shut-packet her-life.channel) - ?> =(rcvr-life.shut-packet our-life.channel) + =/ =shut-packet + (decode-shut-packet packet [symmetric-key her-life our-life]:channel) :: non-galaxy: update route with heard lane or forwarded lane :: - =? route.peer-state !=(%czar (clan:title her.channel)) + =? route.peer-state !=(%czar (clan:title her.channel)) :: if new packet is direct, use that. otherwise, if the new new :: and old lanes are indirect, use the new one. if the new lane :: is indirect but the old lane is direct, then if the lanes are @@ -1012,10 +1344,10 @@ ?: ?=(~ origin.packet) `[direct=%.y lane] ?: ?=([~ %& *] route.peer-state) - ?: =(lane.u.route.peer-state u.origin.packet) + ?: =(lane.u.route.peer-state |+u.origin.packet) route.peer-state - `[direct=%.n u.origin.packet] - `[direct=%.n u.origin.packet] + `[direct=%.n |+u.origin.packet] + `[direct=%.n |+u.origin.packet] :: perform peer-specific handling of packet :: =/ peer-core (make-peer-core peer-state channel) @@ -1397,6 +1729,7 @@ :: request the information from Jael if we haven't already. :: ++ send-blob + ~/ %send-blob |= [for=? =ship =blob] :: =/ final-ship ship @@ -1461,19 +1794,15 @@ ++ attestation-packet |= [her=ship =her=life] ^- blob - :: - =/ =open-packet - :* ^= public-key pub:ex:crypto-core.ames-state - ^= sndr our - ^= sndr-life life.ames-state - ^= rcvr her - ^= rcvr-life her-life - == - :: - =/ signed=@ (sign:as:crypto-core.ames-state (jam open-packet)) - =/ =packet [[our her] encrypted=%.n origin=~ signed] - :: - (encode-packet packet) + %- encode-packet + %- encode-open-packet + :_ crypto-core.ames-state + :* ^= public-key pub:ex:crypto-core.ames-state + ^= sndr our + ^= sndr-life life.ames-state + ^= rcvr her + ^= rcvr-life her-life + == :: +get-peer-state: lookup .her state or ~ :: ++ get-peer-state @@ -1732,13 +2061,15 @@ :: kind of flow this is (forward/backward), so flip the bit :: here. :: - =. bone.shut-packet (mix 1 bone.shut-packet) - :: - =/ content (encrypt symmetric-key.channel shut-packet) - =/ =packet [[our her.channel] encrypted=%.y origin=~ content] - =/ =blob (encode-packet packet) - :: - =. event-core (send-blob | her.channel blob) + =. event-core + %^ send-blob | her.channel + %- encode-packet + %: encode-shut-packet + shut-packet(bone (mix 1 bone.shut-packet)) + symmetric-key.channel + our her.channel + our-life.channel her-life.channel + == peer-core :: +got-duct: look up $duct by .bone, asserting already bound :: @@ -1796,17 +2127,7 @@ :: +on-pump-send: emit message fragment requested by |message-pump :: ++ on-pump-send - |= =static-fragment - ^+ peer-core - :: encrypt and encode .static-fragment to .blob bitstream - :: - %- send-shut-packet :* - our-life.channel - her-life.channel - bone - message-num.static-fragment - %& +.static-fragment - == + |=(f=static-fragment (send-shut-packet bone [message-num %& +]:f)) :: +on-pump-wait: relay |message-pump's set-timer request :: ++ on-pump-wait @@ -1853,16 +2174,7 @@ :: +on-sink-send: emit ack packet as requested by |message-sink :: ++ on-sink-send - |= [=message-num =ack-meat] - ^+ peer-core - :: - %- send-shut-packet :* - our-life.channel - her-life.channel - bone - message-num - %| ack-meat - == + |=([num=message-num ack=ack-meat] (send-shut-packet bone num %| ack)) :: +on-sink-memo: dispatch message received by |message-sink :: :: odd bone: %plea request message @@ -2783,259 +3095,4 @@ :: message-sink -- -:: +qos-update-text: notice text for if connection state changes -:: -++ qos-update-text - |= [=ship old=qos new=qos] - ^- (unit tape) - :: - ?+ [-.old -.new] ~ - [%unborn %live] `"; {(scow %p ship)} is your neighbor" - [%dead %live] `"; {(scow %p ship)} is ok" - [%live %dead] `"; {(scow %p ship)} not responding still trying" - [%unborn %dead] `"; {(scow %p ship)} not responding still trying" - [%live %unborn] `"; {(scow %p ship)} has sunk" - [%dead %unborn] `"; {(scow %p ship)} has sunk" - == -:: +lte-packets: yes if a is before b -:: -++ lte-packets - |= [a=live-packet-key b=live-packet-key] - ^- ? - :: - ?: (lth message-num.a message-num.b) - %.y - ?: (gth message-num.a message-num.b) - %.n - (lte fragment-num.a fragment-num.b) -:: +split-message: split message into kilobyte-sized fragments -:: -:: We don't literally split it here since that would allocate many -:: large atoms with no structural sharing. Instead, each -:: static-fragment has the entire message and a counter. In -:: +encrypt, we interpret this to get the actual fragment. -:: -++ split-message - |= [=message-num =message-blob] - ^- (list static-fragment) - :: - =/ num-fragments=fragment-num (met 13 message-blob) - =| counter=@ - :: - |- ^- (list static-fragment) - ?: (gte counter num-fragments) - ~ - :: - :- [message-num num-fragments counter `@`message-blob] - $(counter +(counter)) -:: +assemble-fragments: concatenate fragments into a $message -:: -++ assemble-fragments - |= [num-fragments=fragment-num fragments=(map fragment-num fragment)] - ^- * - :: - =| sorted=(list fragment) - =. sorted - =/ index=fragment-num 0 - |- ^+ sorted - ?: =(index num-fragments) - sorted - $(index +(index), sorted [(~(got by fragments) index) sorted]) - :: - %- cue - %+ can 13 - %+ turn (flop sorted) - |=(a=@ [1 a]) -:: +bind-duct: find or make new $bone for .duct in .ossuary -:: -++ bind-duct - |= [=ossuary =duct] - ^+ [next-bone.ossuary ossuary] - :: - ?^ existing=(~(get by by-duct.ossuary) duct) - [u.existing ossuary] - :: - :- next-bone.ossuary - :+ (add 4 next-bone.ossuary) - (~(put by by-duct.ossuary) duct next-bone.ossuary) - (~(put by by-bone.ossuary) next-bone.ossuary duct) -:: +make-bone-wire: encode ship and bone in wire for sending to vane -:: -++ make-bone-wire - |= [her=ship =bone] - ^- wire - :: - /bone/(scot %p her)/(scot %ud bone) -:: +parse-bone-wire: decode ship and bone from wire from local vane -:: -++ parse-bone-wire - |= =wire - ^- [her=ship =bone] - :: - ~| %ames-wire-bone^wire - ?> ?=([%bone @ @ ~] wire) - [`@p`(slav %p i.t.wire) `@ud`(slav %ud i.t.t.wire)] -:: +make-pump-timer-wire: construct wire for |packet-pump timer -:: -++ make-pump-timer-wire - |= [her=ship =bone] - ^- wire - /pump/(scot %p her)/(scot %ud bone) -:: +parse-pump-timer-wire: parse .her and .bone from |packet-pump wire -:: -++ parse-pump-timer-wire - |= =wire - ^- (unit [her=ship =bone]) - :: - ~| %ames-wire-timer^wire - ?. ?=([%pump @ @ ~] wire) - ~ - ?~ ship=`(unit @p)`(slaw %p i.t.wire) - ~ - ?~ bone=`(unit @ud)`(slaw %ud i.t.t.wire) - ~ - `[u.ship u.bone] -:: +derive-symmetric-key: $symmetric-key from $private-key and $public-key -:: -:: Assumes keys have a tag on them like the result of the |ex:crub core. -:: -++ derive-symmetric-key - |= [=public-key =private-key] - ^- symmetric-key - :: - ?> =('b' (end 3 1 public-key)) - =. public-key (rsh 8 1 (rsh 3 1 public-key)) - :: - ?> =('B' (end 3 1 private-key)) - =. private-key (rsh 8 1 (rsh 3 1 private-key)) - :: - `@`(shar:ed:crypto public-key private-key) -:: +encrypt: encrypt $shut-packet into atomic packet content -:: -++ encrypt - |= [=symmetric-key plaintext=shut-packet] - ^- @ - :: - =? meat.plaintext - ?& ?=(%& -.meat.plaintext) - (gth (met 13 fragment.p.meat.plaintext) 1) - == - %_ meat.plaintext - fragment.p - (cut 13 [[fragment-num 1] fragment]:p.meat.plaintext) - == - (en:crub:crypto symmetric-key (jam plaintext)) -:: +decrypt: decrypt packet content to a $shut-packet or die -:: -++ decrypt - |= [=symmetric-key ciphertext=@] - ^- shut-packet - :: - ;; shut-packet - %- cue - %- need - (de:crub:crypto symmetric-key ciphertext) -:: +encode-packet: serialize a packet into a bytestream -:: -++ encode-packet - |= packet - ^- blob - :: - =/ sndr-meta (encode-ship-metadata sndr) - =/ rcvr-meta (encode-ship-metadata rcvr) - :: body: <> - :: - :: The .sndr and .rcvr ship addresses are encoded with fixed - :: lengths specified by the packet header. They live outside - :: the jammed-data section to simplify packet filtering in the - :: interpreter. - :: - =/ body=@ - ;: mix - sndr - (lsh 3 size.sndr-meta rcvr) - (lsh 3 (add size.sndr-meta size.rcvr-meta) (jam [origin content])) - == - :: header: 32-bit header assembled from bitstreams of fields - :: - :: <> - :: 4 bits at the end of the header are unused. - :: - =/ header=@ - %+ can 0 - :~ [3 protocol-version] - [20 (mug body)] - [2 rank.sndr-meta] - [2 rank.rcvr-meta] - [5 ?:(encrypted %0 %1)] - == - :: result is <
> - :: - (mix header (lsh 5 1 body)) -:: +decode-packet: deserialize packet from bytestream or crash -:: -++ decode-packet - |= =blob - ^- packet - :: first 32 (2^5) bits are header; the rest is body - :: - =/ header (end 5 1 blob) - =/ body (rsh 5 1 blob) - :: - =/ version (end 0 3 header) - =/ checksum (cut 0 [3 20] header) - =/ sndr-size (decode-ship-size (cut 0 [23 2] header)) - =/ rcvr-size (decode-ship-size (cut 0 [25 2] header)) - =/ encrypted ?+((cut 0 [27 5] header) !! %0 %.y, %1 %.n) - :: - =/ =dyad - :- sndr=(end 3 sndr-size body) - rcvr=(cut 3 [sndr-size rcvr-size] body) - :: - ?. =(protocol-version version) - ~| %ames-protocol^version^dyad !! - ?. =(checksum (end 0 20 (mug body))) - ~| %ames-checksum^dyad !! - :: - =+ ~| %ames-invalid-packet - ;; [origin=(unit lane) content=*] - ~| %ames-invalid-noun - %- cue - (rsh 3 (add rcvr-size sndr-size) body) - :: - [dyad encrypted origin content] -:: +decode-ship-size: decode a 2-bit ship type specifier into a byte width -:: -:: Type 0: galaxy or star -- 2 bytes -:: Type 1: planet -- 4 bytes -:: Type 2: moon -- 8 bytes -:: Type 3: comet -- 16 bytes -:: -++ decode-ship-size - |= rank=@ - ^- @ - :: - ?+ rank !! - %0 2 - %1 4 - %2 8 - %3 16 - == -:: +encode-ship-metadata: produce size (in bytes) and address rank for .ship -:: -:: 0: galaxy or star -:: 1: planet -:: 2: moon -:: 3: comet -:: -++ encode-ship-metadata - |= =ship - ^- [size=@ =rank] - :: - =/ size=@ (met 3 ship) - :: - ?: (lte size 2) [2 %0] - ?: (lte size 4) [4 %1] - ?: (lte size 8) [8 %2] - [16 %3] -- diff --git a/pkg/arvo/tests/sys/vane/ames.hoon b/pkg/arvo/tests/sys/vane/ames.hoon index 26e162d0a4..2e3ac4fa7d 100644 --- a/pkg/arvo/tests/sys/vane/ames.hoon +++ b/pkg/arvo/tests/sys/vane/ames.hoon @@ -6,31 +6,43 @@ :: =/ nec vane =/ bud vane +=/ comet vane :: -=. our.nec ~nec -=. now.nec ~1111.1.1 -=. eny.nec 0xdead.beef -=. rof.nec |=(* ``[%noun !>(*(list turf))]) -:: -=. our.bud ~bud -=. now.bud ~1111.1.1 -=. eny.bud 0xbeef.dead -=. rof.bud |=(* ``[%noun !>(*(list turf))]) -:: +=. our.nec ~nec +=. now.nec ~1111.1.1 +=. eny.nec 0xdead.beef +=. life.ames-state.nec 2 +=. scry-gate.nec |=(* ``[%noun !>(*(list turf))]) =. crypto-core.ames-state.nec (pit:nu:crub:crypto 512 (shaz 'nec')) -=. crypto-core.ames-state.bud (pit:nu:crub:crypto 512 (shaz 'bud')) -:: =/ nec-pub pub:ex:crypto-core.ames-state.nec =/ nec-sec sec:ex:crypto-core.ames-state.nec +:: +=. our.bud ~bud +=. now.bud ~1111.1.1 +=. eny.bud 0xbeef.dead +=. life.ames-state.bud 3 +=. scry-gate.bud |=(* ``[%noun !>(*(list turf))]) +=. crypto-core.ames-state.bud (pit:nu:crub:crypto 512 (shaz 'bud')) =/ bud-pub pub:ex:crypto-core.ames-state.bud =/ bud-sec sec:ex:crypto-core.ames-state.bud :: +=. our.comet ~bosrym-podwyl-magnes-dacrys--pander-hablep-masrym-marbud +=. now.comet ~1111.1.1 +=. eny.comet 0xbeef.cafe +=. scry-gate.comet |=(* ``[%noun !>(*(list turf))]) +=. crypto-core.ames-state.comet + %- nol:nu:crub:crypto + 0w9N.5uIvA.Jg0cx.NCD2R.o~MtZ.uEQOB.9uTbp.6LHvg.0yYTP. + 3q3td.T4UF0.d5sDL.JGpZq.S3A92.QUuWg.IHdw7.izyny.j9W92 +=/ comet-pub pub:ex:crypto-core.ames-state.comet +=/ comet-sec sec:ex:crypto-core.ames-state.comet +:: =/ nec-sym (derive-symmetric-key:vane bud-pub nec-sec) =/ bud-sym (derive-symmetric-key:vane nec-pub bud-sec) -:: ?> =(nec-sym bud-sym) :: -=. life.ames-state.nec 2 +=/ comet-sym (derive-symmetric-key:vane bud-pub comet-sec) +:: =. peers.ames-state.nec %+ ~(put by peers.ames-state.nec) ~bud =| =peer-state:ames @@ -43,7 +55,6 @@ =. route.peer-state `[direct=%.y `lane:ames`[%& ~nec]] [%known peer-state] :: -=. life.ames-state.bud 3 =. peers.ames-state.bud %+ ~(put by peers.ames-state.bud) ~nec =| =peer-state:ames @@ -106,9 +117,10 @@ :: =/ =packet:ames :* [sndr=~nec rcvr=~bud] - encrypted=%.n + sndr-tick=0b10 + rcvr-tick=0b11 origin=~ - content=[12 13] + content=0xdead.beef == :: =/ encoded (encode-packet:vane packet) @@ -118,6 +130,50 @@ !> packet !> decoded :: +++ test-origin-encoding ^- tang + :: + =/ =packet:ames + :* [sndr=~nec rcvr=~bud] + sndr-tick=0b10 + rcvr-tick=0b11 + origin=`0xbeef.cafe.beef + content=0xdead.beef + == + :: + =/ encoded (encode-packet:vane packet) + =/ decoded (decode-packet:vane encoded) + :: + %+ expect-eq + !> packet + !> decoded +:: +++ test-shut-packet-encoding ^- tang + :: + =/ =shut-packet:ames + :+ bone=17 message-num=18 + [%& num-fragments=1 fragment-num=1 fragment=`@`0xdead.beef] + :: + =/ =packet:ames + (encode-shut-packet:ames shut-packet nec-sym ~marnec ~marbud-marbud 3 17) + :: + =/ decoded (decode-shut-packet:ames packet nec-sym 3 17) + :: + %+ expect-eq + !> shut-packet + !> decoded +:: +++ test-shut-packet-associated-data ^- tang + :: + =/ =shut-packet:ames + :+ bone=17 message-num=18 + [%& num-fragments=1 fragment-num=1 fragment=`@`0xdead.beef] + :: + =/ =packet:ames + (encode-shut-packet:ames shut-packet nec-sym ~marnec ~marbud-marbud 3 1) + :: + %- expect-fail + |.((decode-shut-packet:ames packet nec-sym 3 17)) +:: ++ test-alien-encounter ^- tang :: =/ lane-foo=lane:ames [%| `@ux``@`%lane-foo] @@ -125,18 +181,19 @@ =/ =plea:ames [%g /talk [%first %post]] :: =/ =shut-packet:ames - :* sndr-life=4 - rcvr-life=3 - bone=1 + :* bone=1 message-num=1 [%& num-fragments=1 fragment-num=0 (jam plea)] == :: =/ =packet:ames - :* [sndr=~bus rcvr=~bud] - encrypted=%.y - origin=~ - content=(encrypt:vane nec-sym shut-packet) + %: encode-shut-packet:vane + shut-packet + nec-sym + ~bus + ~bud + sndr-life=4 + rcvr-life=3 == :: =/ =blob:ames (encode-packet:vane packet) @@ -170,6 +227,56 @@ !> (sy ,.moves3) == :: +++ test-comet-encounter ^- tang + :: + =/ lane-foo=lane:ames [%| `@ux``@`%lane-foo] + :: + =/ =open-packet:ames + :* public-key=`@`comet-pub + sndr=our.comet + sndr-life=1 + rcvr=~bud + rcvr-life=3 + == + =/ packet + (encode-open-packet:vane open-packet crypto-core.ames-state.comet) + =/ blob (encode-packet:vane packet) + :: + =^ moves0 bud (call bud ~[//unix] %hear lane-foo blob) + :: + =/ =plea:ames [%g /talk [%first %post]] + =/ =shut-packet:ames + :* bone=1 + message-num=1 + [%& num-fragments=1 fragment-num=0 (jam plea)] + == + =/ =packet:ames + %: encode-shut-packet:vane + shut-packet + comet-sym + our.comet + ~bud + sndr-life=1 + rcvr-life=3 + == + =/ blob (encode-packet:vane packet) + =^ moves1 bud (call bud ~[//unix] %hear lane-foo blob) + :: + ;: weld + %+ expect-eq + !> ~ + !> moves0 + :: + %+ expect-eq + !> :~ :* ~[//unix] %pass /qos %d %flog %text + "; {} is your neighbor" + == + :* ~[//unix] %pass /bone/(scot %p our.comet)/1 + %g %plea our.comet plea + == == + !> moves1 + == +:: ++ test-message-flow ^- tang :: ~nec -> %plea -> ~bud :: diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index ae0656c3f1..9a3ad2a731 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -66,11 +66,12 @@ /* u3_head: ames packet header */ typedef struct _u3_head { + c3_o sim_o; // is ames protocol? c3_y ver_y; // protocol version - c3_l mug_l; // truncated mug hash of u3_body c3_y sac_y; // sender class c3_y rac_y; // receiver class - c3_o enc_o; // encrypted? + c3_l mug_l; // truncated mug hash of u3_body + c3_o rel_o; // relayed? } u3_head; /* u3_body: ames packet body @@ -78,8 +79,12 @@ typedef struct _u3_body { c3_d sen_d[2]; // sender c3_d rec_d[2]; // receiver - c3_w con_w; // jam size - c3_y* con_y; // (jam [origin content]) + c3_y sic_y; // sender life tick + c3_y ric_y; // receiver life tick + c3_s con_s; // content size + c3_y* con_y; // content + c3_d rog_d; // origin lane (optional) + c3_l mug_l; // checksum } u3_body; /* u3_panc: deconstructed incoming packet @@ -140,14 +145,6 @@ _ames_panc_free(u3_panc* pac_u) c3_free(pac_u); } -/* _ames_mug_body(): truncated (20 least-significant bits) mug hash of bytes -*/ -static c3_l -_ames_mug_body(c3_w len_w, c3_y* byt_y) -{ - return u3r_mug_bytes(byt_y, len_w) & 0xfffff; -} - /* _ames_sift_head(): parse packet header. */ static c3_o @@ -158,36 +155,20 @@ _ames_sift_head(u3_head* hed_u, c3_y buf_y[4]) | (buf_y[2] << 16) | (buf_y[3] << 24); - // XX only version 0 currently recognized + // first three bits are reserved // - hed_u->ver_y = hed_w & 0x7; - hed_u->mug_l = (hed_w >> 3) & 0xfffff; // 20 bits - hed_u->sac_y = (hed_w >> 23) & 0x3; - hed_u->rac_y = (hed_w >> 25) & 0x3; - hed_u->enc_o = (hed_w >> 27) & 0x1; - return c3y; + hed_u->sim_o = (hed_w >> 3) & 0x1; + hed_u->ver_y = (hed_w >> 4) & 0x7; + hed_u->sac_y = (hed_w >> 7) & 0x3; + hed_u->rac_y = (hed_w >> 9) & 0x3; + hed_u->mug_l = (hed_w >> 11) & 0xfffff; // 20 bits + hed_u->rel_o = (hed_w >> 31) & 0x1; + + // reject packets that don't even claim to be ames packets + // + return hed_u->sim_o; } -/* _ames_etch_head(): serialize packet header. -*/ -static void -_ames_etch_head(u3_head* hed_u, c3_y buf_y[4]) -{ - c3_w hed_w = hed_u->ver_y - | (hed_u->mug_l << 3) - | (hed_u->sac_y << 23) - | (hed_u->rac_y << 25) - | (hed_u->enc_o << 27); - - // only version 0 currently recognized - // - c3_assert( 0 == hed_u->ver_y ); - - buf_y[0] = hed_w & 0xff; - buf_y[1] = (hed_w >> 8) & 0xff; - buf_y[2] = (hed_w >> 16) & 0xff; - buf_y[3] = (hed_w >> 24) & 0xff; -} /* _ames_chub_bytes(): c3_y[8] to c3_d ** XX factor out, deduplicate with other conversions @@ -254,57 +235,106 @@ _ames_sift_body(u3_head* hed_u, c3_w len_w, c3_y* bod_y) { - c3_y sen_y = 2 << hed_u->sac_y; - c3_y rec_y = 2 << hed_u->rac_y; + c3_y rog_y, sen_y, rec_y; - if ( (sen_y + rec_y) >= len_w ) { + rog_y = ( c3y == hed_u->rel_o )? 6 : 0; + + sen_y = 2 << hed_u->sac_y; + rec_y = 2 << hed_u->rac_y; + + if ( (1 + sen_y + rec_y + rog_y) >= len_w ) { return c3n; } else { - _ames_ship_to_chubs(bod_u->sen_d, sen_y, bod_y); - _ames_ship_to_chubs(bod_u->rec_d, rec_y, bod_y + sen_y); + c3_y* gob_y; + c3_s gob_s; + + if ( rog_y) { + c3_y rag_y[8] = {0}; + memcpy(rag_y, bod_y, rog_y); + bod_u->rog_d = _ames_chub_bytes(rag_y); + } + else { + bod_u->rog_d = 0; + } + + gob_y = bod_y + rog_y; + gob_s = len_w - rog_y; + + bod_u->mug_l = u3r_mug_bytes(gob_y, gob_s) & 0xfffff; + + bod_u->sic_y = gob_y[0] & 0xf; + bod_u->ric_y = (gob_y[0] >> 4) & 0xf; + + _ames_ship_to_chubs(bod_u->sen_d, sen_y, gob_y + 1); + _ames_ship_to_chubs(bod_u->rec_d, rec_y, gob_y + 1 + sen_y); + + bod_u->con_s = gob_s - 1 - sen_y - rec_y; + bod_u->con_y = gob_y + 1 + sen_y + rec_y; - bod_u->con_w = len_w - sen_y - rec_y; - bod_u->con_y = bod_y + sen_y + rec_y; return c3y; } } +/* _ames_etch_head(): serialize packet header. +*/ +static void +_ames_etch_head(u3_head* hed_u, c3_y buf_y[4]) +{ + c3_w hed_w = ((hed_u->sim_o & 0x1) << 3) + ^ ((hed_u->ver_y & 0x7) << 4) + ^ ((hed_u->sac_y & 0x3) << 7) + ^ ((hed_u->rac_y & 0x3) << 9) + ^ ((hed_u->mug_l & 0xfffff) << 11) + ^ ((hed_u->rel_o & 0x1) << 31); + + // only version 0 currently recognized + // + c3_assert( 0 == hed_u->ver_y ); // XX remove after testing + + buf_y[0] = hed_w & 0xff; + buf_y[1] = (hed_w >> 8) & 0xff; + buf_y[2] = (hed_w >> 16) & 0xff; + buf_y[3] = (hed_w >> 24) & 0xff; +} + /* _ames_etch_pack(): serialize packet header and body. */ static c3_w _ames_etch_pack(u3_head* hed_u, u3_body* bod_u, - c3_o mug_o, c3_y** out_y) { - // start with the body - // - c3_y sen_y = 2 << hed_u->sac_y; // sender len - c3_y rec_y = 2 << hed_u->rac_y; // receiver len - c3_w bod_w = sen_y + rec_y + bod_u->con_w; // body len - c3_w len_w = 4 + bod_w; // packet len - c3_y* pac_y = c3_malloc(len_w); - c3_y* bod_y = pac_y + 4; + c3_y sen_y = 2 << hed_u->sac_y; // sender len + c3_y rec_y = 2 << hed_u->rac_y; // receiver len + c3_y rog_y = ( c3y == hed_u->rel_o )? 6 : 0; // origin len + c3_w bod_w = rog_y + 1 + sen_y + rec_y + bod_u->con_s; // body len + c3_w len_w = 4 + bod_w; // packet len + c3_y* pac_y = c3_malloc(len_w); // output buf + c3_y* bod_y = pac_y + 4; // body cursor + c3_y* gob_y = bod_y + rog_y; // after origin - _ames_ship_of_chubs(bod_u->sen_d, sen_y, bod_y); - _ames_ship_of_chubs(bod_u->rec_d, rec_y, bod_y + sen_y); - - { - c3_y* con_y = bod_y + sen_y + rec_y; - memcpy(con_y, bod_u->con_y, bod_u->con_w); - } - - // if we updated the origin lane, we need to update the mug too - // - if ( c3y == mug_o ) { - hed_u->mug_l = _ames_mug_body(bod_w, bod_y); - } - - // now we can serialize the head + // serialize the head // _ames_etch_head(hed_u, pac_y); + // serialize the origin, if present + // + if ( rog_y ) { + c3_y rag_y[8] = {0}; + _ames_bytes_chub(rag_y, bod_u->rog_d); + memcpy(bod_y, rag_y, rog_y); + } + + // serialize the body + // + gob_y[0] = (bod_u->sic_y & 0xf) ^ ((bod_u->ric_y & 0xf) << 4); + + _ames_ship_of_chubs(bod_u->sen_d, sen_y, gob_y + 1); + _ames_ship_of_chubs(bod_u->rec_d, rec_y, gob_y + 1 + sen_y); + + memcpy(gob_y + 1 + sen_y + rec_y, bod_u->con_y, bod_u->con_s); + *out_y = pac_y; return len_w; } @@ -371,28 +401,29 @@ _ames_send(u3_pact* pac_u) */ u3_lane u3_ames_decode_lane(u3_atom lan) { - u3_noun cud, tag, pip, por; - - cud = u3ke_cue(lan); - u3x_trel(cud, &tag, &pip, &por); - c3_assert( c3__ipv4 == tag ); - u3_lane lan_u; - lan_u.pip_w = u3r_word(0, pip); + c3_d lan_d; - c3_assert( _(u3a_is_cat(por)) ); - c3_assert( por < 65536 ); - lan_u.por_s = por; + c3_assert( c3y == u3r_safe_chub(lan, &lan_d) ); + u3z(lan); - u3z(cud); + lan_u.pip_w = (c3_w)lan_d; + lan_u.por_s = (c3_s)(lan_d >> 32); return lan_u; } -/* u3_ames_encode_lane(): serialize lane to jammed noun +/* u3_ames_lane_to_chub(): serialize lane to double-word +*/ +c3_d +u3_ames_lane_to_chub(u3_lane lan) { + return ((c3_d)lan.por_s << 32) ^ (c3_d)lan.pip_w; +} + +/* u3_ames_encode_lane(): serialize lane to noun */ u3_atom u3_ames_encode_lane(u3_lane lan) { - return u3ke_jam(u3nt(c3__ipv4, u3i_words(1, &lan.pip_w), lan.por_s)); + return u3i_chub(u3_ames_lane_to_chub(lan)); } /* _ames_lane_into_cache(): put las for who into cache, including timestamp @@ -438,57 +469,18 @@ _ames_lane_from_cache(u3p(u3h_root) lax_p, u3_noun who) { static u3_noun _ames_serialize_packet(u3_panc* pac_u, c3_o dop_o) { - c3_o nal_o = c3n; - - // update the body's lane, if desired + // update the body's lane, if: + // - we're supposed to (dop_o) + // - it hasn't already been updated (rel_o) + // - sender is not a galaxy // - if ( c3y == dop_o ) { - // unpack (jam [(unit lane) body]) - // - u3_noun lon, bod; - { - //NOTE we checked for cue safety in _ames_recv_cb - // - u3_weak old = u3s_cue_xeno_with(pac_u->sam_u->sil_u, - pac_u->bod_u.con_w, - pac_u->bod_u.con_y); - u3x_cell(u3x_good(old), &lon, &bod); - u3k(lon); u3k(bod); - u3z(old); - } - - // only replace the lane if it was ~ - // - //NOTE this sets an opaque lane even in the "sender is galaxy" case, - // but that doesn't matter: ames.hoon ignores origin in that case, - // always using the appropriate galaxy lane instead. - // - if ( u3_nul == lon ) { - c3_w con_w; - c3_y* con_y; - - u3z(lon); - lon = u3nt(u3_nul, c3n, u3_ames_encode_lane(pac_u->ore_u)); - nal_o = c3y; - - // XX off-loom jam? - // - { - u3_noun jam = u3ke_jam(u3nc(lon, bod)); - con_w = u3r_met(3, jam); - con_y = c3_malloc(con_w); - u3r_bytes(0, con_w, con_y, jam); - u3z(jam); - } - - c3_free(pac_u->ptr_v); - pac_u->ptr_v = con_y; - pac_u->bod_u.con_y = con_y; - pac_u->bod_u.con_w = con_w; - } - else { - u3z(lon); u3z(bod); - } + if ( c3y == dop_o + && c3n == pac_u->hed_u.rel_o + && !( ( 256 > pac_u->bod_u.sen_d[0] ) + && ( 0 == pac_u->bod_u.sen_d[1] ) ) ) + { + pac_u->hed_u.rel_o = c3y; + pac_u->bod_u.rog_d = u3_ames_lane_to_chub(pac_u->ore_u); } // serialize the packet @@ -500,7 +492,7 @@ _ames_serialize_packet(u3_panc* pac_u, c3_o dop_o) c3_y* pac_y; c3_w len_w = _ames_etch_pack(&pac_u->hed_u, &pac_u->bod_u, - nal_o, &pac_y); + &pac_y); pac = u3i_bytes(len_w, pac_y); c3_free(pac_y); @@ -989,7 +981,8 @@ _ames_try_forward(u3_ames* sam_u, if ( (u3_none == lac) && (1000 < sam_u->sat_u.foq_d) ) { sam_u->sat_u.fod_d++; if ( 0 == (sam_u->sat_u.fod_d % 10000) ) { - u3l_log("ames: dropped %" PRIu64 " forwards total\n", sam_u->sat_u.fod_d); + u3l_log("ames: dropped %" PRIu64 " forwards total\n", + sam_u->sat_u.fod_d); } c3_free(hun_y); @@ -1042,7 +1035,7 @@ _ames_try_forward(u3_ames* sam_u, } } -/* _ames_hear(): parse a (potential packet), dispatch appropriately. +/* _ames_hear(): parse a (potential) packet, dispatch appropriately. */ static void _ames_hear(u3_ames* sam_u, @@ -1073,7 +1066,8 @@ _ames_hear(u3_ames* sam_u, { sam_u->sat_u.hed_d++; if ( 0 == (sam_u->sat_u.hed_d % 100) ) { - u3l_log("ames: %" PRIu64 " dropped, failed to read header\n", sam_u->sat_u.hed_d); + u3l_log("ames: %" PRIu64 " dropped, failed to read header\n", + sam_u->sat_u.hed_d); } c3_free(hun_y); @@ -1089,7 +1083,8 @@ _ames_hear(u3_ames* sam_u, { sam_u->sat_u.vet_d++; if ( 0 == (sam_u->sat_u.vet_d % 100) ) { - u3l_log("ames: %" PRIu64 " dropped for version mismatch\n", sam_u->sat_u.vet_d); + u3l_log("ames: %" PRIu64 " dropped for version mismatch\n", + sam_u->sat_u.vet_d); } c3_free(hun_y); @@ -1100,26 +1095,26 @@ _ames_hear(u3_ames* sam_u, c3_w bod_w = len_w - 4; c3_y* bod_y = hun_y + 4; - // ensure the mug is valid + // unpack and validate the body // - if ( _ames_mug_body(bod_w, bod_y) != hed_u.mug_l ) { - sam_u->sat_u.mut_d++; - if ( 0 == (sam_u->sat_u.mut_d % 100) ) { - u3l_log("ames: %" PRIu64 " dropped for invalid mug\n", sam_u->sat_u.mut_d); + if ( (c3n == _ames_sift_body(&hed_u, &bod_u, bod_w, bod_y)) ) { + sam_u->sat_u.bod_d++; + if ( 0 == (sam_u->sat_u.bod_d % 100) ) { + u3l_log("ames: %" PRIu64 " dropped, failed to read body\n", + sam_u->sat_u.bod_d); } c3_free(hun_y); return; } - // unpack and validate the body + // ensure the mug is valid // - if ( (c3n == _ames_sift_body(&hed_u, &bod_u, bod_w, bod_y)) - || !ur_cue_test_with(sam_u->tes_u, bod_u.con_w, bod_u.con_y) ) - { - sam_u->sat_u.bod_d++; - if ( 0 == (sam_u->sat_u.bod_d % 100) ) { - u3l_log("ames: %" PRIu64 " dropped, failed to read body\n", sam_u->sat_u.bod_d); + if ( bod_u.mug_l != hed_u.mug_l ) { + sam_u->sat_u.mut_d++; + if ( 0 == (sam_u->sat_u.mut_d % 100) ) { + u3l_log("ames: %" PRIu64 " dropped for invalid mug\n", + sam_u->sat_u.mut_d); } c3_free(hun_y); From 174f36f1a8fdd18e0769260acdb3b9750dcff817 Mon Sep 17 00:00:00 2001 From: Ted Blackman Date: Tue, 1 Dec 2020 09:59:07 -0500 Subject: [PATCH 825/933] aqua/ph: fix comet test --- pkg/arvo/ted/aqua/ames.hoon | 15 ++++++++++++--- pkg/arvo/ted/ph/hi-comet-az.hoon | 12 +++++++++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/pkg/arvo/ted/aqua/ames.hoon b/pkg/arvo/ted/aqua/ames.hoon index 76d02c4a31..e609353a43 100644 --- a/pkg/arvo/ted/aqua/ames.hoon +++ b/pkg/arvo/ted/aqua/ames.hoon @@ -29,23 +29,32 @@ [%event rcvr //newt/0v1n.2m9vh %hear hear-lane pac]~ :: +lane-to-ship: decode a ship from an aqua lane :: +:: Special-case one comet, since its address doesn't fit into a lane. +:: ++ lane-to-ship |= =lane:ames ^- ship :: ?- -.lane %& p.lane - %| `ship``@`p.lane + %| =/ s `ship``@`p.lane + ?. =(s 0xdead.beef.cafe) + s + ~bosrym-podwyl-magnes-dacrys--pander-hablep-masrym-marbud == :: +ship-to-lane: encode a lane to look like it came from .ship :: :: Never shows up as a galaxy, because Vere wouldn't know that either. +:: Special-case one comet, since its address doesn't fit into a lane. :: ++ ship-to-lane |= =ship ^- lane:ames - :: - [%| `address:ames``@`ship] + :- %| + ^- address:ames ^- @ + ?. =(ship ~bosrym-podwyl-magnes-dacrys--pander-hablep-masrym-marbud) + ship + 0xdead.beef.cafe -- :: %+ aqua-vane-thread ~[%restore %send] diff --git a/pkg/arvo/ted/ph/hi-comet-az.hoon b/pkg/arvo/ted/ph/hi-comet-az.hoon index 9fdc7aecf6..5b82b5e718 100644 --- a/pkg/arvo/ted/ph/hi-comet-az.hoon +++ b/pkg/arvo/ted/ph/hi-comet-az.hoon @@ -8,13 +8,19 @@ ;< az=tid:spider bind:m start-azimuth ;< ~ bind:m (spawn az ~bud) -;< ~ bind:m (spawn az ~marbud) -;< ~ bind:m (spawn az ~linnup-torsyx) ;< ~ bind:m (real-ship az ~bud) +:: +;< ~ bind:m (spawn az ~marbud) ;< ~ bind:m (real-ship az ~marbud) -;< ~ bind:m (real-ship az ~linnup-torsyx) +:: ;< ~ bind:m (real-ship az comet) +;< ~ bind:m (send-hi comet ~bud) +:: +;< ~ bind:m (spawn az ~linnup-torsyx) +;< ~ bind:m (real-ship az ~linnup-torsyx) +:: ;< ~ bind:m (send-hi comet ~linnup-torsyx) ;< ~ bind:m (send-hi ~linnup-torsyx comet) +:: ;< ~ bind:m end-azimuth (pure:m *vase) From 7cfde079436072c25bae8a82f10cb98a8586f8e6 Mon Sep 17 00:00:00 2001 From: Ted Blackman Date: Tue, 1 Dec 2020 10:37:30 -0500 Subject: [PATCH 826/933] pill: solid --- bin/solid.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index bdbcb8fa4b..6ade2b6140 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b3e9d1637efea5862a114ce320f6e14afeb1f9f418428e0490d9c079a9becc56 -size 6712875 +oid sha256:8e5d6fb3716e9e4dd3267a08aa70e8f782e722930eab3045a90c48b3e51a1668 +size 6853071 From 9545e8727efab6fd19b6db46390f29856980344b Mon Sep 17 00:00:00 2001 From: fang Date: Tue, 1 Dec 2020 16:55:19 +0100 Subject: [PATCH 827/933] dojo: correct mark conversion scry path Fixes an instance that hadn't accounted for #3994 yet. --- pkg/arvo/app/dojo.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/arvo/app/dojo.hoon b/pkg/arvo/app/dojo.hoon index c34dd8ea89..4949b00f83 100644 --- a/pkg/arvo/app/dojo.hoon +++ b/pkg/arvo/app/dojo.hoon @@ -869,7 +869,7 @@ :: %as =/ cag=cage (dy-cage p.q.bil) - =+ .^(=tube:clay cc+(en-beam:format he-beak /[p.bil]/[p.cag])) + =+ .^(=tube:clay cc+(en-beam:format he-beak /[p.cag]/[p.bil])) (dy-hand p.bil (tube q.cag)) :: %do From 9e69cba237445a76c20375e1c7846958540cc607 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Tue, 1 Dec 2020 12:51:26 -0600 Subject: [PATCH 828/933] group-on-leave: poke %graph-pull-hook to allow resubscription --- pkg/arvo/ted/group/on-leave.hoon | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/arvo/ted/group/on-leave.hoon b/pkg/arvo/ted/group/on-leave.hoon index 33088c8c8c..1fdc8ce0cb 100644 --- a/pkg/arvo/ted/group/on-leave.hoon +++ b/pkg/arvo/ted/group/on-leave.hoon @@ -52,4 +52,9 @@ :- %graph-update !> ^- update:gra [%0 now.bowl [%archive-graph (de-path:res app-path.m.i.entries)]] +;< ~ bind:m + %+ raw-poke + [our.bowl %graph-pull-hook] + :- %pull-hook-action + !>([%remove (de-path:res app-path.m.i.entries)]) loop(entries t.entries) From a0b733a2848a41566af5eb9a58ec65b4abd2ec7f Mon Sep 17 00:00:00 2001 From: Ted Blackman Date: Tue, 1 Dec 2020 14:07:20 -0500 Subject: [PATCH 829/933] pill: update ivory pill --- bin/ivory.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ivory.pill b/bin/ivory.pill index 5c7fabd885..feb24f9623 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:85a4e1625d528b5fdc88faeff4fd288a23d6fbf1c11a846fc8f8d5b3cd38370f -size 2118873 +oid sha256:5af78cbe22c8311af47b070be953ca0ec50f383bc20140f38e3364aa56a4e2a2 +size 2314689 From 635c09b6a73c77cc0247e1c3ae665b1805adabbe Mon Sep 17 00:00:00 2001 From: Ted Blackman Date: Tue, 1 Dec 2020 14:14:36 -0500 Subject: [PATCH 830/933] tests: fix ames tests --- pkg/arvo/tests/sys/vane/ames.hoon | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/arvo/tests/sys/vane/ames.hoon b/pkg/arvo/tests/sys/vane/ames.hoon index 2e3ac4fa7d..0400a627e0 100644 --- a/pkg/arvo/tests/sys/vane/ames.hoon +++ b/pkg/arvo/tests/sys/vane/ames.hoon @@ -12,7 +12,7 @@ =. now.nec ~1111.1.1 =. eny.nec 0xdead.beef =. life.ames-state.nec 2 -=. scry-gate.nec |=(* ``[%noun !>(*(list turf))]) +=. rof.nec |=(* ``[%noun !>(*(list turf))]) =. crypto-core.ames-state.nec (pit:nu:crub:crypto 512 (shaz 'nec')) =/ nec-pub pub:ex:crypto-core.ames-state.nec =/ nec-sec sec:ex:crypto-core.ames-state.nec @@ -21,7 +21,7 @@ =. now.bud ~1111.1.1 =. eny.bud 0xbeef.dead =. life.ames-state.bud 3 -=. scry-gate.bud |=(* ``[%noun !>(*(list turf))]) +=. rof.bud |=(* ``[%noun !>(*(list turf))]) =. crypto-core.ames-state.bud (pit:nu:crub:crypto 512 (shaz 'bud')) =/ bud-pub pub:ex:crypto-core.ames-state.bud =/ bud-sec sec:ex:crypto-core.ames-state.bud @@ -29,7 +29,7 @@ =. our.comet ~bosrym-podwyl-magnes-dacrys--pander-hablep-masrym-marbud =. now.comet ~1111.1.1 =. eny.comet 0xbeef.cafe -=. scry-gate.comet |=(* ``[%noun !>(*(list turf))]) +=. rof.comet |=(* ``[%noun !>(*(list turf))]) =. crypto-core.ames-state.comet %- nol:nu:crub:crypto 0w9N.5uIvA.Jg0cx.NCD2R.o~MtZ.uEQOB.9uTbp.6LHvg.0yYTP. From 2760f79f6604a92722a31a44a495f251eb54fe1c Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Tue, 1 Dec 2020 15:20:45 -0600 Subject: [PATCH 831/933] group-on-leave thread: clean up contacts as well as everything else --- pkg/arvo/app/contact-view.hoon | 16 +------ pkg/arvo/lib/group-store.hoon | 1 + pkg/arvo/ted/group/on-leave.hoon | 42 +++++++++++++++++-- pkg/interface/src/logic/api/contacts.ts | 4 -- pkg/interface/src/logic/api/groups.ts | 7 +++- .../components/GroupSettings/Personal.tsx | 3 +- 6 files changed, 48 insertions(+), 25 deletions(-) diff --git a/pkg/arvo/app/contact-view.hoon b/pkg/arvo/app/contact-view.hoon index 198d4362ce..4350e9d439 100644 --- a/pkg/arvo/app/contact-view.hoon +++ b/pkg/arvo/app/contact-view.hoon @@ -181,21 +181,7 @@ ~[(add-pending rid ship.act)] :: %delete - =/ rid=resource - (de-path:resource path.act) - =/ group-pokes=(list card) - ?: =(our.bol entity.rid) - ~[(group-push-poke %remove rid)] - :~ (group-proxy-poke %remove-members rid (sy our.bol ~)) - (group-pull-poke %remove rid) - == - ;: weld - group-pokes - :~ (contact-hook-poke [%remove path.act]) - (group-poke [%remove-group rid ~]) - (contact-poke [%delete path.act]) - == - == + ~ :: %remove =/ rid=resource diff --git a/pkg/arvo/lib/group-store.hoon b/pkg/arvo/lib/group-store.hoon index 56e663301f..e2a14576b7 100644 --- a/pkg/arvo/lib/group-store.hoon +++ b/pkg/arvo/lib/group-store.hoon @@ -417,6 +417,7 @@ :: ++ remove-group |= =json + ^- [resource ~] ?> ?=(%o -.json) =/ rid=resource (dejs:resource (~(got by p.json) 'resource')) diff --git a/pkg/arvo/ted/group/on-leave.hoon b/pkg/arvo/ted/group/on-leave.hoon index 1fdc8ce0cb..aa3fcad4e2 100644 --- a/pkg/arvo/ted/group/on-leave.hoon +++ b/pkg/arvo/ted/group/on-leave.hoon @@ -1,4 +1,4 @@ -/- spider, grp=group-store, gra=graph-store, met=metadata-store, hook=metadata-hook +/- spider, grp=group-store, gra=graph-store, met=metadata-store, con=contact-store /+ strandio, res=resource :: =* strand strand:spider @@ -13,16 +13,50 @@ ?. ?=(%remove-group -.update) (pure:m !>(~)) ;< =bowl:spider bind:m get-bowl:strandio +:: tell group host to remove us as member +:: +;< ~ bind:m + %+ raw-poke + [entity.resource.update %group-push-hook] + :- %group-update + !> ^- update:grp + [%remove-members resource.update (silt [our.bowl ~])] +:: stop serving or syncing group updates +:: +;< ~ bind:m + %+ raw-poke + [our.bowl %group-push-hook] + :- %push-hook-action + !>([%remove resource.update]) +;< ~ bind:m + %+ raw-poke + [our.bowl %group-pull-hook] + :- %pull-hook-action + !>([%remove resource.update]) +:: stop serving or syncing contacts associated with group +:: +;< ~ bind:m + %+ raw-poke + [our.bowl %contact-hook] + :- %contact-hook-action + !>([%remove (en-path:res resource.update)]) +:: remove contact data associated with group +:: +;< ~ bind:m + %+ raw-poke + [our.bowl %contact-store] + :- %contact-action + !> ^- contact-action:con + [%delete (en-path:res resource.update)] :: stop serving or syncing metadata associated with group :: ;< ~ bind:m %+ raw-poke [our.bowl %metadata-hook] :- %metadata-hook-action - !> ^- metadata-hook-action:hook - [%remove (en-path:res resource.update)] -:: + !>([%remove (en-path:res resource.update)]) :: get metadata associated with group +:: ;< =associations:met bind:m %+ scry associations:met ;: weld diff --git a/pkg/interface/src/logic/api/contacts.ts b/pkg/interface/src/logic/api/contacts.ts index 27f8faf25c..3049442f5a 100644 --- a/pkg/interface/src/logic/api/contacts.ts +++ b/pkg/interface/src/logic/api/contacts.ts @@ -32,10 +32,6 @@ export default class ContactsApi extends BaseApi { }); } - delete(path: Path) { - return this.viewAction({ delete: { path } }); - } - remove(path: Path, ship: Patp) { return this.viewAction({ remove: { path, ship } }); } diff --git a/pkg/interface/src/logic/api/groups.ts b/pkg/interface/src/logic/api/groups.ts index cdd1514ecc..3901149fd2 100644 --- a/pkg/interface/src/logic/api/groups.ts +++ b/pkg/interface/src/logic/api/groups.ts @@ -26,6 +26,10 @@ export default class GroupsApi extends BaseApi { return this.proxyAction({ addMembers: { resource, ships } }); } + removeGroup(resource: Resource) { + return this.storeAction({ removeGroup: { resource } }); + } + changePolicy(resource: Resource, diff: Enc) { return this.proxyAction({ changePolicy: { resource, diff } }); } @@ -35,6 +39,7 @@ export default class GroupsApi extends BaseApi { } private storeAction(action: GroupAction) { - return this.action('group-store', 'group-action', action); + console.log(action); + return this.action('group-store', 'group-update', action); } } diff --git a/pkg/interface/src/views/landscape/components/GroupSettings/Personal.tsx b/pkg/interface/src/views/landscape/components/GroupSettings/Personal.tsx index 9b036ec45a..c5abd75bdd 100644 --- a/pkg/interface/src/views/landscape/components/GroupSettings/Personal.tsx +++ b/pkg/interface/src/views/landscape/components/GroupSettings/Personal.tsx @@ -35,7 +35,8 @@ function DeleteGroup(props: { const onDelete = async () => { const name = props.association['group-path'].split('/').pop(); if (prompt(`To confirm deleting this group, type ${name}`) === name) { - await props.api.contacts.delete(props.association["group-path"]); + const resource = resourceFromPath(props.association["group-path"]) + await props.api.groups.removeGroup(resource); history.push("/"); } }; From 03fd56e8ccc5f9603397214343258cdcba9d2296 Mon Sep 17 00:00:00 2001 From: fang Date: Tue, 1 Dec 2020 23:38:02 +0100 Subject: [PATCH 832/933] various: start threads with unit of tuple args Instead of a list of arguments, with trailing ~. --- pkg/arvo/app/dojo.hoon | 12 +++++++++++- pkg/arvo/app/glob.hoon | 2 +- pkg/arvo/app/observe-hook.hoon | 2 +- pkg/arvo/app/spider.hoon | 2 +- pkg/arvo/ted/build-cast.hoon | 2 +- pkg/arvo/ted/build-file.hoon | 2 +- pkg/arvo/ted/build-mark.hoon | 2 +- pkg/arvo/ted/diff.hoon | 2 +- pkg/arvo/ted/dns/address.hoon | 2 +- pkg/arvo/ted/glob.hoon | 2 +- pkg/arvo/ted/graph/create.hoon | 2 +- pkg/arvo/ted/graph/delete.hoon | 2 +- pkg/arvo/ted/graph/groupify.hoon | 2 +- pkg/arvo/ted/graph/join.hoon | 2 +- pkg/arvo/ted/graph/leave.hoon | 2 +- pkg/arvo/ted/graph/restore.hoon | 2 +- pkg/arvo/ted/hi.hoon | 5 +++-- pkg/arvo/ted/invite/accepted-graph.hoon | 9 ++++----- pkg/arvo/ted/migrate-channels.hoon | 2 +- pkg/arvo/ted/read.hoon | 2 +- pkg/arvo/ted/test.hoon | 4 +++- pkg/arvo/ted/time.hoon | 2 +- pkg/arvo/ted/tree.hoon | 2 +- 23 files changed, 40 insertions(+), 28 deletions(-) diff --git a/pkg/arvo/app/dojo.hoon b/pkg/arvo/app/dojo.hoon index c34dd8ea89..c2bc08f3b3 100644 --- a/pkg/arvo/app/dojo.hoon +++ b/pkg/arvo/app/dojo.hoon @@ -728,6 +728,16 @@ :: ++ dy-cage |=(num=@ud (~(got by rez) num)) :: known cage ++ dy-vase |=(num=@ud q:(dy-cage num)) :: known vase + :: + ++ dy-some + |= src=(list dojo-source) + ^- vase + ?~ src !>(~) + %+ slop !>(~) + |- + ?~ t.src (dy-vase p.i.src) + (slop (dy-vase p.i.src) $(src t.src)) + :: ++ dy-sore |= src=(list dojo-source) ^- vase @@ -850,7 +860,7 @@ [%pass /wool %agent [our.hid %spider] %watch /thread-result/[tid]] %- he-card =/ =cage :: also sub - [%spider-start !>([~ `tid fil (dy-sore src)])] + [%spider-start !>([~ `tid fil (dy-some src)])] [%pass /wool %agent [our.hid %spider] %poke cage] :: ++ dy-make :: build step diff --git a/pkg/arvo/app/glob.hoon b/pkg/arvo/app/glob.hoon index 472f938331..23d18118ab 100644 --- a/pkg/arvo/app/glob.hoon +++ b/pkg/arvo/app/glob.hoon @@ -183,7 +183,7 @@ ^- (quip card _this) ?: ?=([%start ~] wire) =/ new-tid=@ta (cat 3 'glob--' (scot %uv eny.bowl)) - =/ args [~ `new-tid %glob !>([hash.state ~])] + =/ args [~ `new-tid %glob !>([~ hash.state])] =/ action !>([%unserve-dir serve-path]) :_ this(glob.state `[%| new-tid]) :~ (poke-file-server our.bowl %file-server-action action) diff --git a/pkg/arvo/app/observe-hook.hoon b/pkg/arvo/app/observe-hook.hoon index 174b90b13c..71b9e08f3f 100644 --- a/pkg/arvo/app/observe-hook.hoon +++ b/pkg/arvo/app/observe-hook.hoon @@ -148,7 +148,7 @@ [our.bowl %spider] %poke %spider-start - !>([~ `tid thread.observer (slop q.cage.sign !>(~))]) + !>([~ `tid thread.observer (slop !>(~) q.cage.sign)]) == == == :: diff --git a/pkg/arvo/app/spider.hoon b/pkg/arvo/app/spider.hoon index a328e0d476..bb3c360e66 100644 --- a/pkg/arvo/app/spider.hoon +++ b/pkg/arvo/app/spider.hoon @@ -290,7 +290,7 @@ =/ body=json (need (de-json:html q.u.body.request.inbound-request)) =/ input=vase - (slop (tube !>(body)) !>(~)) + (slop !>(~) (tube !>(body))) =/ =start-args [~ `tid thread input] =^ cards state diff --git a/pkg/arvo/ted/build-cast.hoon b/pkg/arvo/ted/build-cast.hoon index cf0a1c508d..fe85b0a180 100644 --- a/pkg/arvo/ted/build-cast.hoon +++ b/pkg/arvo/ted/build-cast.hoon @@ -5,7 +5,7 @@ |= arg=vase =/ m (strand ,vase) ^- form:m -=+ !<([pax=path ~] arg) +=+ !<([~ pax=path] arg) ?~ bem=(de-beam:format pax) (strand-fail:strand %path-not-beam >pax< ~) =/ =mars:clay [i i.t]:?>(?=([@ @ ~] s.u.bem) s.u.bem) diff --git a/pkg/arvo/ted/build-file.hoon b/pkg/arvo/ted/build-file.hoon index 8b3bda350a..55f231db76 100644 --- a/pkg/arvo/ted/build-file.hoon +++ b/pkg/arvo/ted/build-file.hoon @@ -5,7 +5,7 @@ |= arg=vase =/ m (strand ,vase) ^- form:m -=+ !<([pax=path ~] arg) +=+ !<([~ pax=path] arg) ?^ bem=(de-beam:format pax) (build-file:strandio u.bem) (strand-fail:strand %path-not-beam >pax< ~) diff --git a/pkg/arvo/ted/build-mark.hoon b/pkg/arvo/ted/build-mark.hoon index a134c896fe..72b4ffe9e3 100644 --- a/pkg/arvo/ted/build-mark.hoon +++ b/pkg/arvo/ted/build-mark.hoon @@ -5,7 +5,7 @@ |= arg=vase =/ m (strand ,vase) ^- form:m -=+ !<([pax=path ~] arg) +=+ !<([~ pax=path] arg) ?~ bem=(de-beam:format pax) (strand-fail:strand %path-not-beam >pax< ~) =/ =mark (rear s.u.bem) diff --git a/pkg/arvo/ted/diff.hoon b/pkg/arvo/ted/diff.hoon index 580416a4a7..6a4ff6cfd7 100644 --- a/pkg/arvo/ted/diff.hoon +++ b/pkg/arvo/ted/diff.hoon @@ -6,7 +6,7 @@ =/ m (strand ,vase) ^- form:m |^ -=+ !<([=a=path =b=path ~] arg) +=+ !<([~ =a=path =b=path] arg) =/ a-mark=mark -:(flop a-path) =/ b-mark=mark -:(flop b-path) ?. =(a-mark b-mark) diff --git a/pkg/arvo/ted/dns/address.hoon b/pkg/arvo/ted/dns/address.hoon index a5f5fb4b04..faf5b902c8 100644 --- a/pkg/arvo/ted/dns/address.hoon +++ b/pkg/arvo/ted/dns/address.hoon @@ -6,7 +6,7 @@ |^ =/ m (strand ,vase) ^- form:m -=+ !< [adr=address:dns ~] arg +=+ !< [~ adr=address:dns] arg :: ;< our=ship bind:m get-our:strandio =/ rac (clan:title our) diff --git a/pkg/arvo/ted/glob.hoon b/pkg/arvo/ted/glob.hoon index d50e7a114a..c207b7a1c8 100644 --- a/pkg/arvo/ted/glob.hoon +++ b/pkg/arvo/ted/glob.hoon @@ -5,7 +5,7 @@ |= arg=vase =/ m (strand ,vase) ^- form:m -=+ !<([hash=@uv ~] arg) +=+ !<([~ hash=@uv] arg) =/ url "https://bootstrap.urbit.org/glob-{(scow %uv hash)}.glob" ;< =cord bind:m (fetch-cord:strandio url) =+ ;;(=glob:glob (cue cord)) diff --git a/pkg/arvo/ted/graph/create.hoon b/pkg/arvo/ted/graph/create.hoon index e0c5448186..6e81e6636e 100644 --- a/pkg/arvo/ted/graph/create.hoon +++ b/pkg/arvo/ted/graph/create.hoon @@ -29,7 +29,7 @@ |= arg=vase =/ m (strand ,vase) ^- form:m -=+ !<([=action:graph-view ~] arg) +=+ !<([~ =action:graph-view] arg) ?> ?=(%create -.action) ;< =bowl:spider bind:m get-bowl:strandio :: diff --git a/pkg/arvo/ted/graph/delete.hoon b/pkg/arvo/ted/graph/delete.hoon index 1ffcdd97dc..8a3ea1b780 100644 --- a/pkg/arvo/ted/graph/delete.hoon +++ b/pkg/arvo/ted/graph/delete.hoon @@ -57,7 +57,7 @@ |= arg=vase =/ m (strand ,vase) ^- form:m -=+ !<([=action:graph-view ~] arg) +=+ !<([~ =action:graph-view] arg) ?> ?=(%delete -.action) ;< =bowl:spider bind:m get-bowl:strandio ?. =(our.bowl entity.rid.action) diff --git a/pkg/arvo/ted/graph/groupify.hoon b/pkg/arvo/ted/graph/groupify.hoon index 58a9ec4a90..7117f01e64 100644 --- a/pkg/arvo/ted/graph/groupify.hoon +++ b/pkg/arvo/ted/graph/groupify.hoon @@ -43,7 +43,7 @@ |= arg=vase =/ m (strand ,vase) ^- form:m -=+ !<([=action:graph-view ~] arg) +=+ !<([~ =action:graph-view] arg) ?> ?=(%groupify -.action) ;< =group bind:m (scry-group rid.action) ?. hidden.group diff --git a/pkg/arvo/ted/graph/join.hoon b/pkg/arvo/ted/graph/join.hoon index b4ebffff88..2e46fd9090 100644 --- a/pkg/arvo/ted/graph/join.hoon +++ b/pkg/arvo/ted/graph/join.hoon @@ -28,7 +28,7 @@ |= arg=vase =/ m (strand ,vase) ^- form:m -=+ !<([=action:graph-view ~] arg) +=+ !<([~ =action:graph-view] arg) ?> ?=(%join -.action) ;< =bowl:spider bind:m get-bowl:strandio ?: =(our.bowl entity.rid.action) diff --git a/pkg/arvo/ted/graph/leave.hoon b/pkg/arvo/ted/graph/leave.hoon index 9d0bc6797e..382841a7f7 100644 --- a/pkg/arvo/ted/graph/leave.hoon +++ b/pkg/arvo/ted/graph/leave.hoon @@ -49,7 +49,7 @@ |= arg=vase =/ m (strand ,vase) ^- form:m -=+ !<([=action:graph-view ~] arg) +=+ !<([~ =action:graph-view] arg) ?> ?=(%leave -.action) ;< =bowl:spider bind:m get-bowl:strandio ?: =(our.bowl entity.rid.action) diff --git a/pkg/arvo/ted/graph/restore.hoon b/pkg/arvo/ted/graph/restore.hoon index 5ed59534fd..ae03aa15e3 100644 --- a/pkg/arvo/ted/graph/restore.hoon +++ b/pkg/arvo/ted/graph/restore.hoon @@ -12,7 +12,7 @@ =/ m (strand ,vase) ^- form:m =+ !< - [[rid=resource title=@t description=@t group=resource module=@t ~] ~] + [~ rid=resource title=@t description=@t group=resource module=@t ~] arg ;< =bowl:spider bind:m get-bowl:strandio :: unarchive graph and share it diff --git a/pkg/arvo/ted/hi.hoon b/pkg/arvo/ted/hi.hoon index 2410c02110..5e02680a21 100644 --- a/pkg/arvo/ted/hi.hoon +++ b/pkg/arvo/ted/hi.hoon @@ -5,7 +5,8 @@ |= arg=vase =/ m (strand ,vase) ^- form:m -=+ !<([who=ship mez=$@(~ [=tape ~])] arg) -=/ message ?~(mez '' (crip tape.mez)) +=+ !<([~ arg=$@(who=ship [who=ship mez=tape])] arg) +=/ [who=ship message=@t] + ?@(arg [who.arg ''] [who.arg (crip mez.arg)]) ;< ~ bind:m (poke:strandio [who %hood] %helm-hi !>(message)) (pure:m !>("hi {} successful")) diff --git a/pkg/arvo/ted/invite/accepted-graph.hoon b/pkg/arvo/ted/invite/accepted-graph.hoon index bb1227082d..23aa836d27 100644 --- a/pkg/arvo/ted/invite/accepted-graph.hoon +++ b/pkg/arvo/ted/invite/accepted-graph.hoon @@ -10,7 +10,7 @@ |= arg=vase =/ m (strand ,vase) ^- form:m -=+ !<([=update:inv ~] arg) +=+ !<([~ =update:inv] arg) ?. ?=(%accepted -.update) (pure:m !>(~)) ;< =bowl:spider bind:m get-bowl:strandio @@ -21,8 +21,7 @@ ;< ~ bind:m %+ poke-our %spider =- spider-start+!>([`tid.bowl ~ %graph-join -]) - %+ slop - !> ^- action:graph-view - [%join resource.invite ship.invite] - !>(~) + %+ slop !>(~) + !> ^- action:graph-view + [%join resource.invite ship.invite] (pure:m !>(~)) diff --git a/pkg/arvo/ted/migrate-channels.hoon b/pkg/arvo/ted/migrate-channels.hoon index 4abc4b3f44..8334ccae47 100644 --- a/pkg/arvo/ted/migrate-channels.hoon +++ b/pkg/arvo/ted/migrate-channels.hoon @@ -5,7 +5,7 @@ |= arg=vase =/ m (strand ,vase) ^- form:m -=/ [og-path=path ng-path=path ~] !<([path path ~] arg) +=/ [~ og-path=path ng-path=path] !<([~ path path] arg) ;< bol=bowl:spider bind:m get-bowl:strandio |^ :: diff --git a/pkg/arvo/ted/read.hoon b/pkg/arvo/ted/read.hoon index 12816e9850..6d313c2ed4 100644 --- a/pkg/arvo/ted/read.hoon +++ b/pkg/arvo/ted/read.hoon @@ -7,7 +7,7 @@ ^- form:m :: Parse arguments as ship, desk, and path :: -=+ !<([=care:clay =ship =desk =case =target=path ~] arg) +=+ !<([~ =care:clay =ship =desk =case =target=path] arg) :: Read the file, possibly asyncrhonously :: ;< =bowl:spider bind:m get-bowl:strandio diff --git a/pkg/arvo/ted/test.hoon b/pkg/arvo/ted/test.hoon index f327adb926..755efd3529 100644 --- a/pkg/arvo/ted/test.hoon +++ b/pkg/arvo/ted/test.hoon @@ -104,8 +104,10 @@ |= arg=vase =/ m (strand ,vase) ^- form:m +=/ paz=(list path) + (tail !<([~ (list path)] arg)) =/ bez=(list beam) - (turn !<((list path) arg) |=(p=path (need (de-beam:format p)))) + (turn paz |=(p=path (need (de-beam:format p)))) ;< fiz=(set [=beam test=(unit term)]) bind:m (find-test-files bez) => .(fiz (sort ~(tap in fiz) aor)) =| test-arms=(map path (list test-arm)) diff --git a/pkg/arvo/ted/time.hoon b/pkg/arvo/ted/time.hoon index 02ba813c15..be3ff6dd0c 100644 --- a/pkg/arvo/ted/time.hoon +++ b/pkg/arvo/ted/time.hoon @@ -5,7 +5,7 @@ |= arg=vase =/ m (strand ,vase) ^- form:m -=+ !<([arg=@dr ~] arg) +=+ !<([~ arg=@dr] arg) ;< now-1=@da bind:m get-time:strandio ;< ~ bind:m (sleep:strandio arg) ;< now-2=@da bind:m get-time:strandio diff --git a/pkg/arvo/ted/tree.hoon b/pkg/arvo/ted/tree.hoon index 63dec6e08b..682cf8015c 100644 --- a/pkg/arvo/ted/tree.hoon +++ b/pkg/arvo/ted/tree.hoon @@ -5,7 +5,7 @@ |= arg=vase =/ m (strand ,vase) ^- form:m -=+ !<([pax=path ~] arg) +=+ !<([~ pax=path] arg) ;< bek=beak bind:m get-beak:strandio ;< paz=(list path) bind:m (list-tree:strandio bek (flop pax)) (pure:m !>(paz)) From dc6dddac4906a7a987ded046c5f30c61432a0125 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Tue, 1 Dec 2020 14:40:41 -0800 Subject: [PATCH 833/933] glob: update to 0v5.u5b0i.2ks0m.6ipcp.djea4.16n1h --- bin/solid.pill | 4 ++-- pkg/arvo/app/glob.hoon | 2 +- pkg/arvo/app/landscape/index.html | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index e198f12dcc..7f735c0e85 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d7225be3d29183c74892d556fde2e06a416584e386ece002e81386437ab65770 -size 6897081 +oid sha256:414730fedb33743a8e175344976784670be82ed9ba141f3ff4c23402377fe9a7 +size 6958477 diff --git a/pkg/arvo/app/glob.hoon b/pkg/arvo/app/glob.hoon index de1514d5a3..e6ce7bb7d5 100644 --- a/pkg/arvo/app/glob.hoon +++ b/pkg/arvo/app/glob.hoon @@ -5,7 +5,7 @@ /- glob /+ default-agent, verb, dbug |% -++ hash 0v5.0umdn.af5hq.bp84b.66eao.q0b98 +++ hash 0v5.u5b0i.2ks0m.6ipcp.djea4.16n1h +$ state-0 [%0 hash=@uv glob=(unit (each glob:glob tid=@ta))] +$ all-states $% state-0 diff --git a/pkg/arvo/app/landscape/index.html b/pkg/arvo/app/landscape/index.html index bd6b1828d2..8dee2f0537 100644 --- a/pkg/arvo/app/landscape/index.html +++ b/pkg/arvo/app/landscape/index.html @@ -24,6 +24,6 @@
- + From 85cd81be1c11582c409f6861f76c036a747d3939 Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Tue, 1 Dec 2020 18:18:32 -0500 Subject: [PATCH 834/933] publish: add 'cancel' button to edit form --- .../apps/publish/components/EditPost.tsx | 2 + .../apps/publish/components/NoteForm.tsx | 50 +++++++++++-------- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/pkg/interface/src/views/apps/publish/components/EditPost.tsx b/pkg/interface/src/views/apps/publish/components/EditPost.tsx index 1b5cae127c..8e96ec82b8 100644 --- a/pkg/interface/src/views/apps/publish/components/EditPost.tsx +++ b/pkg/interface/src/views/apps/publish/components/EditPost.tsx @@ -50,6 +50,8 @@ export function EditPost(props: EditPostProps & RouteComponentProps) { return ( @@ -21,8 +23,8 @@ interface PostFormProps { } const formSchema = Yup.object({ - title: Yup.string().required("Title cannot be blank"), - body: Yup.string().required("Post cannot be blank"), + title: Yup.string().required('Title cannot be blank'), + body: Yup.string().required('Post cannot be blank') }); export interface PostFormSchema { @@ -31,7 +33,7 @@ export interface PostFormSchema { } export function PostForm(props: PostFormProps) { - const { initial, onSubmit, submitLabel, loadingText } = props; + const { initial, onSubmit, cancel, submitLabel, loadingText, history } = props; return ( @@ -41,18 +43,26 @@ export function PostForm(props: PostFormProps) { onSubmit={onSubmit} validateOnBlur > - - + + - + + {submitLabel} + + {cancel && } + From d15d5ba1752e8d27b2da324a85216eeb6b065f2f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 23 Nov 2020 22:42:56 -0800 Subject: [PATCH 835/933] zuse: change to ropsten --- pkg/arvo/sys/zuse.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index 9662e1c93f..65aca5a0ed 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -7896,7 +7896,7 @@ :: # constants :: :: contract addresses - ++ contracts mainnet-contracts + ++ contracts ropsten-contracts ++ mainnet-contracts |% :: azimuth: data contract From 3473594b6445bdc491d2ad067ee4599fdfd9d824 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Tue, 1 Dec 2020 16:50:58 -0800 Subject: [PATCH 836/933] pill: ivory ropsten --- bin/ivory.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ivory.pill b/bin/ivory.pill index 29eeabbc5d..e8d37717d4 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e5c82dea80aa7c5593f43fa4294db7974211abceedd907663da73889857642e7 -size 1309381 +oid sha256:45d51478148fec9c32677a581c646a7ad0bbd29edcc46da15be4e1864dba59cd +size 1322242 From 7a08067cf1a1ac80fa2ba5d94e8978103bce70e4 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 1 Dec 2020 16:51:14 -0800 Subject: [PATCH 837/933] hoon: adds $step for bloq-sized atom offsets --- pkg/arvo/sys/hoon.hoon | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 6160485f89..7040946ca0 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -368,6 +368,11 @@ :: [(list item) state] :: +++ step + :: atom size or offset, in bloqs + :: + _`@u`1 +:: ++ trap |$ [product] :: a core with one arm `$` @@ -821,14 +826,14 @@ :: ++ bex :: binary exponent ~/ %bex - |= a=@ + |= a=bloq ^- @ ?: =(0 a) 1 (mul 2 $(a (dec a))) :: ++ can :: assemble ~/ %can - |= [a=bloq b=(list [p=@u q=@])] + |= [a=bloq b=(list [p=step q=@])] ^- @ ?~ b 0 (add (end a p.i.b q.i.b) (lsh a p.i.b $(b t.b))) @@ -840,16 +845,17 @@ :: ++ cut :: slice ~/ %cut - |= [a=bloq [b=@u c=@u] d=@] + |= [a=bloq [b=step c=step] d=@] (end a c (rsh a b d)) :: ++ end :: tail ~/ %end - |= [a=bloq b=@u c=@] + |= [a=bloq b=step c=@] (mod c (bex (mul (bex a) b))) :: ++ fil :: fill bloqstream - |= [a=bloq b=@u c=@] + ~/ %fil + |= [a=bloq b=step c=@] =+ n=0 =+ d=c |- ^- @ @@ -859,7 +865,7 @@ :: ++ lsh :: left-shift ~/ %lsh - |= [a=bloq b=@u c=@] + |= [a=bloq b=step c=@] (mul (bex (mul (bex a) b)) c) :: ++ met :: measure @@ -928,7 +934,7 @@ :: ++ rsh :: right-shift ~/ %rsh - |= [a=bloq b=@u c=@] + |= [a=bloq b=step c=@] (div c (bex (mul (bex a) b))) :: ++ swp :: naive rev bloq order From 9bfc0e6492d2a345a6d67615c46bfa3e9af6837c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 1 Dec 2020 16:52:10 -0800 Subject: [PATCH 838/933] hoon: adds $bite for atom slice specifiers --- pkg/arvo/sys/hoon.hoon | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 7040946ca0..cd9fc90afa 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -269,6 +269,12 @@ :: :: the most basic of data types +| %containers +:: ++$ bite + :: atom slice specifier + :: + $@(bloq [=bloq =step]) +:: +$ bloq :: blocksize :: From f5137a51142b9371c1090d9f1abfcd44bd529c62 Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Mon, 30 Nov 2020 13:04:54 -0800 Subject: [PATCH 839/933] userspace: data migration testing utilities --- pkg/arvo/gen/aqua-export.hoon | 45 +++++++ pkg/arvo/lib/ph/io.hoon | 16 +++ pkg/arvo/lib/strandio.hoon | 6 +- pkg/arvo/mar/contact/view-action.hoon | 12 ++ pkg/arvo/mar/import.hoon | 15 +++ pkg/arvo/mar/metadata/hook-action.hoon | 12 ++ pkg/arvo/ted/ph/migrate/breach.hoon | 22 ++++ pkg/arvo/ted/ph/migrate/commit-home.hoon | 61 ++++++++++ pkg/arvo/ted/ph/migrate/import.hoon | 22 ++++ pkg/arvo/ted/ph/migrate/init.hoon | 24 ++++ pkg/arvo/ted/ph/migrate/make-chats.hoon | 96 +++++++++++++++ pkg/arvo/ted/ph/migrate/make-graphs.hoon | 112 ++++++++++++++++++ pkg/arvo/ted/ph/migrate/make-groups.hoon | 46 +++++++ pkg/arvo/ted/ph/migrate/post-import-chat.hoon | 36 ++++++ .../ted/ph/migrate/post-import-graphs.hoon | 56 +++++++++ .../ted/ph/migrate/post-import-groups.hoon | 24 ++++ .../post-import-metadata-contacts.hoon | 61 ++++++++++ pkg/arvo/ted/ph/migrate/send-his.hoon | 18 +++ pkg/arvo/ted/ph/migrate/start.hoon | 73 ++++++++++++ pkg/arvo/ted/ph/start-drivers.hoon | 2 +- 20 files changed, 757 insertions(+), 2 deletions(-) create mode 100644 pkg/arvo/gen/aqua-export.hoon create mode 100644 pkg/arvo/mar/contact/view-action.hoon create mode 100644 pkg/arvo/mar/import.hoon create mode 100644 pkg/arvo/mar/metadata/hook-action.hoon create mode 100644 pkg/arvo/ted/ph/migrate/breach.hoon create mode 100644 pkg/arvo/ted/ph/migrate/commit-home.hoon create mode 100644 pkg/arvo/ted/ph/migrate/import.hoon create mode 100644 pkg/arvo/ted/ph/migrate/init.hoon create mode 100644 pkg/arvo/ted/ph/migrate/make-chats.hoon create mode 100644 pkg/arvo/ted/ph/migrate/make-graphs.hoon create mode 100644 pkg/arvo/ted/ph/migrate/make-groups.hoon create mode 100644 pkg/arvo/ted/ph/migrate/post-import-chat.hoon create mode 100644 pkg/arvo/ted/ph/migrate/post-import-graphs.hoon create mode 100644 pkg/arvo/ted/ph/migrate/post-import-groups.hoon create mode 100644 pkg/arvo/ted/ph/migrate/post-import-metadata-contacts.hoon create mode 100644 pkg/arvo/ted/ph/migrate/send-his.hoon create mode 100644 pkg/arvo/ted/ph/migrate/start.hoon diff --git a/pkg/arvo/gen/aqua-export.hoon b/pkg/arvo/gen/aqua-export.hoon new file mode 100644 index 0000000000..046d85d24d --- /dev/null +++ b/pkg/arvo/gen/aqua-export.hoon @@ -0,0 +1,45 @@ +/+ *ph-util +:- %say +|= $: [now=@da eny=@uv bec=beak] + [who=@p ~] + ~ + == +|^ +:- %noun +(export-all who) +:: +++ export-app + |= [who=ship agent=term] + =/ aqua-pax=path + :~ %i + (scot %p who) + %gx + (scot %p who) + agent + (scot %da now) + %export + %noun + %noun + == + ~| agent + %- need + (scry-aqua (unit *) p.bec now aqua-pax) +:: +++ export-all + |= who=ship + %+ turn + ^- (list @tas) + :~ %group-store + %metadata-store + %metadata-hook + %contact-store + %contact-hook + %invite-store + %chat-store + %chat-hook + %graph-store + == + |= app=@tas + [app (export-app who app)] +:: +-- diff --git a/pkg/arvo/lib/ph/io.hoon b/pkg/arvo/lib/ph/io.hoon index 4433670ca3..d0327ab2e1 100644 --- a/pkg/arvo/lib/ph/io.hoon +++ b/pkg/arvo/lib/ph/io.hoon @@ -341,4 +341,20 @@ ?: =(warped (need (scry-aqua:util (unit @) our now aqua-pax))) (pure:m ~) loop +:: +:: Turns poke into a dojo command +:: +++ poke-app + |= [=ship app=term =mark data=*] + =/ m (strand ,~) + ^- form:m + =/ command=tape ":{(trip app)} &{(trip mark)} {}" + (send-events (dojo:util ship command)) +:: +++ dojo-thread + |= [=ship ted=term =mark data=*] + =/ m (strand ,~) + ^- form:m + =/ command=tape "-{(trip ted)} &{(trip mark)} {}" + (send-events (dojo:util ship command)) -- diff --git a/pkg/arvo/lib/strandio.hoon b/pkg/arvo/lib/strandio.hoon index 58bc830b78..7fa9da0fa3 100644 --- a/pkg/arvo/lib/strandio.hoon +++ b/pkg/arvo/lib/strandio.hoon @@ -670,12 +670,16 @@ :: ++ start-thread |= file=term + (start-thread-with-args file *vase) +:: +++ start-thread-with-args + |= [file=term args=vase] =/ m (strand ,tid:spider) ^- form:m ;< =bowl:spider bind:m get-bowl =/ tid (scot %ta (cat 3 (cat 3 'strand_' file) (scot %uv (sham file eny.bowl)))) - =/ poke-vase !>([`tid.bowl `tid file *vase]) + =/ poke-vase !>([`tid.bowl `tid file args]) ;< ~ bind:m (poke-our %spider %spider-start poke-vase) ;< ~ bind:m (sleep ~s0) :: wait for thread to start (pure:m tid) diff --git a/pkg/arvo/mar/contact/view-action.hoon b/pkg/arvo/mar/contact/view-action.hoon new file mode 100644 index 0000000000..bd386555da --- /dev/null +++ b/pkg/arvo/mar/contact/view-action.hoon @@ -0,0 +1,12 @@ +/- *contact-view +|_ act=contact-view-action +++ grad %noun +++ grow + |% + ++ noun act + -- +++ grab + |% + ++ noun contact-view-action + -- +-- diff --git a/pkg/arvo/mar/import.hoon b/pkg/arvo/mar/import.hoon new file mode 100644 index 0000000000..53ee978c2c --- /dev/null +++ b/pkg/arvo/mar/import.hoon @@ -0,0 +1,15 @@ +=, mimes:html +|_ non=* +++ grab + |% + ++ noun * + ++ mime + |= [* p=octs] + (cue q.p) + -- +++ grow + |% + ++ mime [/application/x-urb-import (as-octs (jam non))] + -- +++ grad %mime +-- diff --git a/pkg/arvo/mar/metadata/hook-action.hoon b/pkg/arvo/mar/metadata/hook-action.hoon new file mode 100644 index 0000000000..6903555245 --- /dev/null +++ b/pkg/arvo/mar/metadata/hook-action.hoon @@ -0,0 +1,12 @@ +/- *metadata-hook +|_ act=metadata-hook-action +++ grad %noun +++ grow + |% + ++ noun act + -- +++ grab + |% + ++ noun metadata-hook-action + -- +-- diff --git a/pkg/arvo/ted/ph/migrate/breach.hoon b/pkg/arvo/ted/ph/migrate/breach.hoon new file mode 100644 index 0000000000..4678690cc2 --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/breach.hoon @@ -0,0 +1,22 @@ +/- spider +/+ *ph-io +=, strand=strand:spider +^- thread:spider +|= arg=vase +=+ !<(who=(list @p) arg) +=/ m (strand ,vase) +;< ~ bind:m start-simple +=? who ?=(~ who) ~[~zod ~bus ~web] +|- +=* loop $ +?~ who +:: ;< ~ bind:m (send-hi ~zod ~bus) +:: ;< ~ bind:m (send-hi ~zod ~web) +:: ;< ~ bind:m (send-hi ~bus ~zod) +:: ;< ~ bind:m (send-hi ~bus ~web) +:: ;< ~ bind:m (send-hi ~web ~zod) +:: ;< ~ bind:m (send-hi ~web ~bus) + (pure:m *vase) +;< ~ bind:m (breach-aqua i.who) +;< ~ bind:m (init-ship i.who) +loop(who t.who) diff --git a/pkg/arvo/ted/ph/migrate/commit-home.hoon b/pkg/arvo/ted/ph/migrate/commit-home.hoon new file mode 100644 index 0000000000..8f168f3ab8 --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/commit-home.hoon @@ -0,0 +1,61 @@ +:: +:: warning: using this thread will clobber aqua's currently active piers +:: +/- spider, *aquarium +/+ *ph-io +=, strand=strand:spider +=> +|% +++ commit + |= [our=@p now=@da ships=(list @p)] + ^- (list aqua-event) + %+ turn ships + |= her=@p + :+ %event her + =/ paths .^((list path) %ct /(scot %p our)/home/(scot %da now)) + =/ mod=mode:clay + %+ murn paths + |= pat=path + ^- (unit [path (unit mime)]) + ?. =((snag (dec (lent pat)) pat) %hoon) + ~ + =/ clay-pax=path (weld /(scot %p our)/home/(scot %da now) pat) + =/ file [/text/plain (as-octs:mimes:html .^(@ %cx clay-pax))] + `[pat `file] + :- //sync/0v1n.2m9vh + [%into %home | mod] +:: +++ restore-fleet + |= label=term + ^- (list aqua-event) + [%restore-snap label]~ +:: +++ snap-fleet + |= [label=term ships=(list @p)] + ^- (list aqua-event) + [%snap-ships label ships]~ +-- +^- thread:spider +|= arg=vase +=+ !<(fleets=(list term) arg) +=/ m (strand ,vase) +;< ~ bind:m start-simple +=/ ships=(list @p) ~[~zod ~bus ~web] +;< =bowl:spider bind:m get-bowl +=/ commit-events (commit our.bowl now.bowl ships) +|- +=* fleet-loop $ +?~ fleets + (pure:m *vase) +:: +;< ~ bind:m (send-events (restore-fleet i.fleets)) +;< ~ bind:m (sleep ~s0) +;< ~ bind:m (send-events commit-events) +;< ~ bind:m (sleep ~s0) +;< =bowl:spider bind:m get-bowl +=/ full-ships + .^((list @p) %gx /(scot %p our.bowl)/aqua/(scot %da now.bowl)/ships/noun) +;< ~ bind:m (send-events (snap-fleet i.fleets full-ships)) +;< ~ bind:m (sleep ~s0) +:: +fleet-loop(fleets t.fleets) diff --git a/pkg/arvo/ted/ph/migrate/import.hoon b/pkg/arvo/ted/ph/migrate/import.hoon new file mode 100644 index 0000000000..57d054c4cc --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/import.hoon @@ -0,0 +1,22 @@ +/- spider +/+ *ph-io +=, strand=strand:spider +=> +|% +++ import-all + |= [who=@p by-app=(list [@tas *])] + =/ m (strand:spider ,~) + ^- form:m + =* loop $ + ?~ by-app (pure:m ~) + =/ [app=@tas data=*] i.by-app + ;< ~ bind:m (poke-app who app %import data) + loop(by-app t.by-app) +-- +^- thread:spider +|= arg=vase +=+ !<([who=@p by-app=(list [@tas *]) ~] arg) +=/ m (strand ,vase) +;< ~ bind:m start-simple +;< ~ bind:m (import-all who by-app) +(pure:m *vase) diff --git a/pkg/arvo/ted/ph/migrate/init.hoon b/pkg/arvo/ted/ph/migrate/init.hoon new file mode 100644 index 0000000000..3433e80abb --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/init.hoon @@ -0,0 +1,24 @@ +/- spider +/+ *ph-io +=, strand=strand:spider +^- thread:spider +|= vase +=/ m (strand ,vase) +;< ~ bind:m start-simple +;< ~ bind:m init-azimuth +;< ~ bind:m (spawn-aqua ~zod) +;< ~ bind:m (spawn-aqua ~bus) +;< ~ bind:m (spawn-aqua ~web) +:: +;< ~ bind:m (init-ship ~zod) +;< ~ bind:m (init-ship ~bus) +;< ~ bind:m (init-ship ~web) +:: +;< ~ bind:m (send-hi ~zod ~web) +;< ~ bind:m (send-hi ~zod ~bus) +;< ~ bind:m (send-hi ~web ~zod) +;< ~ bind:m (send-hi ~bus ~zod) +;< ~ bind:m (send-hi ~bus ~web) +;< ~ bind:m (send-hi ~web ~bus) +:: +(pure:m *vase) diff --git a/pkg/arvo/ted/ph/migrate/make-chats.hoon b/pkg/arvo/ted/ph/migrate/make-chats.hoon new file mode 100644 index 0000000000..43b9b572e5 --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/make-chats.hoon @@ -0,0 +1,96 @@ +/- spider, + chat-view, + *resource, + chat-store +/+ *ph-io, strandio +=, strand=strand:spider +=> +|% +++ chat-message + |= [our=@p =path wen=@da mes=cord] + =/ act=action:chat-store + :* %message path `@uvH`(sham [our path mes]) + 0 our wen [%text mes] + == + (poke-app our %chat-hook %chat-action act) +-- +:: +^- thread:spider +|= vase +=/ m (strand ,vase) +;< ~ bind:m start-simple +;< bol=bowl:spider bind:m get-bowl:strandio +:: +:: chat setup +:: - ~zod creates a chat associated with group-1 +:: - ~bus creates a chat associated with group-1 +:: - ~web creates a dm with ~zod +:: +=/ chat-1=action:chat-view + :* %create + 'Chat 1' '' + /~zod/chat-1 + /ship/~zod/group-1 + [%invite ~] + ~ + %.y + %.n + == +=/ chat-2=action:chat-view + :* %create + 'Chat 2' '' + /~bus/chat-2 + /ship/~zod/group-1 + [%invite ~] + ~ + %.y + %.n + == +=/ web-zod-dm=action:chat-view + :* %create + '~web <-> ~zod' '' + /~web/dm--zod + /ship/~web/dm--zod + [%invite (sy ~zod ~)] + (sy ~zod ~) + %.y + %.n + == +=/ join-1 [%join ~zod /~zod/chat-1 %.y] +=/ join-2 [%join ~bus /~bus/chat-2 %.y] +=/ join-3 [%join ~web /~web/dm--zod %.y] +;< ~ bind:m (poke-app ~zod %chat-view %chat-view-action chat-1) +;< ~ bind:m (wait-for-output ~zod ">=") +;< ~ bind:m (poke-app ~bus %chat-view %chat-view-action chat-2) +;< ~ bind:m (wait-for-output ~bus ">=") +;< ~ bind:m (poke-app ~web %chat-view %chat-view-action web-zod-dm) +;< ~ bind:m (wait-for-output ~web ">=") +;< ~ bind:m (sleep ~s20) +:: +;< ~ bind:m (poke-app ~bus %chat-view %chat-view-action join-1) +;< ~ bind:m (wait-for-output ~bus ">=") +;< ~ bind:m (poke-app ~web %chat-view %chat-view-action join-1) +;< ~ bind:m (wait-for-output ~web ">=") +:: +;< ~ bind:m (poke-app ~zod %chat-view %chat-view-action join-2) +;< ~ bind:m (wait-for-output ~zod ">=") +;< ~ bind:m (poke-app ~web %chat-view %chat-view-action join-2) +;< ~ bind:m (wait-for-output ~web ">=") +:: +;< ~ bind:m (poke-app ~zod %chat-view %chat-view-action join-3) +;< ~ bind:m (wait-for-output ~zod ">=") +;< ~ bind:m (sleep ~s20) +:: +;< ~ bind:m (chat-message ~zod /~zod/chat-1 now.bol 'message 1') +;< ~ bind:m (chat-message ~bus /~zod/chat-1 now.bol 'message 2') +;< ~ bind:m (chat-message ~web /~bus/chat-2 now.bol 'message 3') +;< ~ bind:m (chat-message ~zod /~web/dm--zod now.bol 'message 4') +:: +;< ~ bind:m (send-hi ~zod ~bus) +;< ~ bind:m (send-hi ~zod ~web) +;< ~ bind:m (send-hi ~bus ~zod) +;< ~ bind:m (send-hi ~bus ~web) +;< ~ bind:m (send-hi ~web ~zod) +;< ~ bind:m (send-hi ~web ~bus) +:: +(pure:m *vase) diff --git a/pkg/arvo/ted/ph/migrate/make-graphs.hoon b/pkg/arvo/ted/ph/migrate/make-graphs.hoon new file mode 100644 index 0000000000..0bbfe6dbf2 --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/make-graphs.hoon @@ -0,0 +1,112 @@ +/- spider, + graph-store, + graph-view, + post, + *resource +/+ *ph-io, strandio +=, strand=strand:spider +=> +|% +:: +++ graph-post + |= [our=@p wen=@da rid=resource body=cord id=@] + =/ =index:post [id]~ + =/ =post:post [our index wen [%text body]~ ~ ~] + =/ =node:graph-store [post %empty ~] + =/ act=update:graph-store [%0 wen %add-nodes rid (my [index node] ~)] + (poke-app our %graph-push-hook %graph-update act) +-- +:: +^- thread:spider +|= vase +=/ m (strand ,vase) +;< ~ bind:m start-simple +;< bol=bowl:spider bind:m get-bowl:strandio +:: +:: create graphs +:: +=/ group-rid [~zod %group-1] +=/ group-path /ship/~zod/group-1 +=/ create-1=action:graph-view + :* %create + [~zod %graph-1] + 'graph 1' + 'desc 1' + ~ + [%group group-rid] + 'fake' + == +:: +=/ create-2=action:graph-view + :* %create + [~bus %graph-2] + 'graph 2' + 'desc 2' + ~ + [%group group-rid] + 'fake' + == +:: +=/ create-3=action:graph-view + :* %create + [~web %graph-3] + 'graph 3' + 'desc 3' + ~ + [%policy %invite (sy ~zod ~bus ~)] + 'fake' + == +:: +;< ~ bind:m (dojo-thread ~zod %graph-create %graph-view-action create-1) +;< ~ bind:m (dojo-thread ~bus %graph-create %graph-view-action create-2) +;< ~ bind:m (dojo-thread ~web %graph-create %graph-view-action create-3) +;< ~ bind:m (sleep ~s30) +:: +:: join graphs +:: +=/ join-1=action:graph-view + [%join [~zod %graph-1] ~zod] +=/ join-2=action:graph-view + [%join [~bus %graph-2] ~bus] +=/ join-3=action:graph-view + [%join [~web %graph-3] ~web] +:: +;< ~ bind:m (dojo-thread ~zod %graph-join %graph-view-action join-2) +;< ~ bind:m (dojo-thread ~zod %graph-join %graph-view-action join-3) +;< ~ bind:m (dojo-thread ~bus %graph-join %graph-view-action join-1) +;< ~ bind:m (dojo-thread ~bus %graph-join %graph-view-action join-3) +;< ~ bind:m (dojo-thread ~web %graph-join %graph-view-action join-1) +;< ~ bind:m (dojo-thread ~web %graph-join %graph-view-action join-2) +;< ~ bind:m (sleep ~s30) +:: +:: make posts +:: +;< ~ bind:m (graph-post ~zod now.bol [~zod %graph-1] 'post 1' 1) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (graph-post ~bus now.bol [~zod %graph-1] 'post 2' 2) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (graph-post ~web now.bol [~zod %graph-1] 'post 3' 3) +;< ~ bind:m (sleep ~s5) +:: +;< ~ bind:m (graph-post ~zod now.bol [~bus %graph-2] 'post 4' 4) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (graph-post ~bus now.bol [~bus %graph-2] 'post 5' 5) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (graph-post ~web now.bol [~bus %graph-2] 'post 6' 6) +;< ~ bind:m (sleep ~s5) +:: +;< ~ bind:m (graph-post ~zod now.bol [~web %graph-3] 'post 7' 7) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (graph-post ~bus now.bol [~web %graph-3] 'post 8' 8) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (graph-post ~web now.bol [~web %graph-3] 'post 9' 9) +;< ~ bind:m (sleep ~s5) +:: +;< ~ bind:m (send-hi ~zod ~bus) +;< ~ bind:m (send-hi ~zod ~web) +;< ~ bind:m (send-hi ~bus ~zod) +;< ~ bind:m (send-hi ~bus ~web) +;< ~ bind:m (send-hi ~web ~zod) +;< ~ bind:m (send-hi ~web ~bus) +:: +(pure:m *vase) diff --git a/pkg/arvo/ted/ph/migrate/make-groups.hoon b/pkg/arvo/ted/ph/migrate/make-groups.hoon new file mode 100644 index 0000000000..62a09dffa6 --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/make-groups.hoon @@ -0,0 +1,46 @@ +/- spider, + contact-view, + *resource +/+ *ph-io, strandio +=, strand=strand:spider +:: +^- thread:spider +|= vase +=/ m (strand ,vase) +;< ~ bind:m start-simple +;< bol=bowl:spider bind:m get-bowl:strandio +:: +:: group setup +:: - ~zod creates an open group +:: - ~zod creates and invite-only group, and invites ~bus and ~web +:: - ~bus and ~web join the first, but not the second group, to keep +:: invite-store populated +:: +=/ group-1=contact-view-action:contact-view + :* %create + %group-1 + [%open ~ ~] + 'Group 1' + 'this is group 1' + == +=/ group-2=contact-view-action:contact-view + :* %create + %group-2 + [%invite (sy ~bus ~web ~)] + 'Group 2' + 'this is group 2' + == +=/ join=contact-view-action:contact-view [%join ~zod %group-1] +;< ~ bind:m (poke-app ~zod %contact-view %contact-view-action group-1) +;< ~ bind:m (wait-for-output ~zod ">=") +;< ~ bind:m (poke-app ~zod %contact-view %contact-view-action group-2) +;< ~ bind:m (wait-for-output ~zod ">=") +;< ~ bind:m (sleep ~s10) +;< ~ bind:m (poke-app ~bus %contact-view %contact-view-action join) +;< ~ bind:m (wait-for-output ~bus ">=") +;< ~ bind:m (poke-app ~web %contact-view %contact-view-action join) +;< ~ bind:m (wait-for-output ~web ">=") +;< ~ bind:m (send-hi ~bus ~zod) +;< ~ bind:m (send-hi ~web ~zod) +;< ~ bind:m (sleep ~s2) +(pure:m *vase) diff --git a/pkg/arvo/ted/ph/migrate/post-import-chat.hoon b/pkg/arvo/ted/ph/migrate/post-import-chat.hoon new file mode 100644 index 0000000000..b25da4f7cf --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/post-import-chat.hoon @@ -0,0 +1,36 @@ +/- spider, + chat-view, + *resource, + chat-store +/+ *ph-io, strandio +=, strand=strand:spider +=> +|% +++ chat-message + |= [our=@p =path wen=@da mes=cord] + =/ act=action:chat-store + :* %message path `@uvH`(sham [our path mes]) + 0 our wen [%text mes] + == + (poke-app our %chat-hook %chat-action act) +-- +:: +^- thread:spider +|= vase +=/ m (strand ,vase) +;< ~ bind:m start-simple +;< bol=bowl:spider bind:m get-bowl:strandio +:: +;< ~ bind:m (chat-message ~zod /~zod/chat-1 now.bol 'message 5') +;< ~ bind:m (chat-message ~bus /~zod/chat-1 now.bol 'message 6') +;< ~ bind:m (chat-message ~web /~bus/chat-2 now.bol 'message 7') +;< ~ bind:m (chat-message ~zod /~web/dm--zod now.bol 'message 8') +:: +;< ~ bind:m (send-hi ~zod ~bus) +;< ~ bind:m (send-hi ~zod ~web) +;< ~ bind:m (send-hi ~bus ~zod) +;< ~ bind:m (send-hi ~bus ~web) +;< ~ bind:m (send-hi ~web ~zod) +;< ~ bind:m (send-hi ~web ~bus) +:: +(pure:m *vase) diff --git a/pkg/arvo/ted/ph/migrate/post-import-graphs.hoon b/pkg/arvo/ted/ph/migrate/post-import-graphs.hoon new file mode 100644 index 0000000000..eed757263b --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/post-import-graphs.hoon @@ -0,0 +1,56 @@ +/- spider, + graph-store, + graph-view, + post, + *resource +/+ *ph-io, strandio +=, strand=strand:spider +=> +|% +:: +++ graph-post + |= [our=@p wen=@da rid=resource body=cord id=@] + =/ =index:post [id]~ + =/ =post:post [our index wen [%text body]~ ~ ~] + =/ =node:graph-store [post %empty ~] + =/ act=update:graph-store [%0 wen %add-nodes rid (my [index node] ~)] + (poke-app our %graph-push-hook %graph-update act) +-- +:: +^- thread:spider +|= vase +=/ m (strand ,vase) +;< ~ bind:m start-simple +;< bol=bowl:spider bind:m get-bowl:strandio +:: +:: make posts +:: +;< ~ bind:m (graph-post ~zod now.bol [~zod %graph-1] 'post 10' 10) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (graph-post ~bus now.bol [~zod %graph-1] 'post 20' 20) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (graph-post ~web now.bol [~zod %graph-1] 'post 30' 30) +;< ~ bind:m (sleep ~s5) +:: +;< ~ bind:m (graph-post ~zod now.bol [~bus %graph-2] 'post 40' 40) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (graph-post ~bus now.bol [~bus %graph-2] 'post 50' 50) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (graph-post ~web now.bol [~bus %graph-2] 'post 60' 60) +;< ~ bind:m (sleep ~s5) +:: +;< ~ bind:m (graph-post ~zod now.bol [~web %graph-3] 'post 70' 70) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (graph-post ~bus now.bol [~web %graph-3] 'post 80' 80) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (graph-post ~web now.bol [~web %graph-3] 'post 90' 90) +;< ~ bind:m (sleep ~s5) +:: +;< ~ bind:m (send-hi ~zod ~bus) +;< ~ bind:m (send-hi ~zod ~web) +;< ~ bind:m (send-hi ~bus ~zod) +;< ~ bind:m (send-hi ~bus ~web) +;< ~ bind:m (send-hi ~web ~zod) +;< ~ bind:m (send-hi ~web ~bus) +:: +(pure:m *vase) diff --git a/pkg/arvo/ted/ph/migrate/post-import-groups.hoon b/pkg/arvo/ted/ph/migrate/post-import-groups.hoon new file mode 100644 index 0000000000..8681c14527 --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/post-import-groups.hoon @@ -0,0 +1,24 @@ +/- spider, + contact-view, + *resource, + group-store +/+ *ph-io, strandio +=, strand=strand:spider +:: +^- thread:spider +|= vase +=/ m (strand ,vase) +;< ~ bind:m start-simple +;< bol=bowl:spider bind:m get-bowl:strandio +:: +=/ join-2=contact-view-action:contact-view [%join ~zod %group-2] +=/ add-members-1=action:group-store + [%add-members [~zod %group-1] (sy ~def ~ten ~)] +=/ add-members-2=action:group-store + [%add-members [~zod %group-2] (sy ~def ~ten ~)] +;< ~ bind:m (poke-app ~bus %contact-view %contact-view-action join-2) +;< ~ bind:m (poke-app ~web %contact-view %contact-view-action join-2) +;< ~ bind:m (poke-app ~zod %group-store %group-action add-members-1) +;< ~ bind:m (poke-app ~zod %group-store %group-action add-members-2) +:: +(pure:m *vase) diff --git a/pkg/arvo/ted/ph/migrate/post-import-metadata-contacts.hoon b/pkg/arvo/ted/ph/migrate/post-import-metadata-contacts.hoon new file mode 100644 index 0000000000..81a9825937 --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/post-import-metadata-contacts.hoon @@ -0,0 +1,61 @@ +/- spider, + contact-view, + contact-store, + group-store, + metadata-store, + post, + graph-store, + *resource +/+ *ph-io, strandio +=, strand=strand:spider +:: +:: +^- thread:spider +|= vase +=/ m (strand ,vase) +;< ~ bind:m start-simple +;< bol=bowl:spider bind:m get-bowl:strandio +:: +:: test metadata import +:: +=/ change-group-1=metadata-action:metadata-store + :* %add + /ship/~zod/group-1 + [%contacts /ship/~zod/group-1] + 'New Group 1 Title' + 'new description' + 0x0 + now.bol + ~zod + 'fake' + == +=/ change-web-book=metadata-action:metadata-store + :* %add + /ship/~web/graph-3 + [%graph /ship/~web/graph-3] + 'New Graph 3 Title' + 'new description' + 0x0 + now.bol + ~web + 'fake' + == +;< ~ bind:m (poke-app ~zod %metadata-hook %metadata-action change-group-1) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (poke-app ~web %metadata-hook %metadata-action change-web-book) +;< ~ bind:m (sleep ~s5) +:: +:: test contacts import +:: +=/ add-zod=contact-action:contact-store + :* %add /ship/~zod/group-1 ~zod + 'ZOD' '' '' '' '' 0x0 ~ + == +=/ add-bus=contact-action:contact-store + :* %add /ship/~zod/group-2 ~bus + 'BUS' '' '' '' '' 0x0 ~ + == +;< ~ bind:m (poke-app ~zod %contact-hook %contact-action add-zod) +;< ~ bind:m (sleep ~s5) +;< ~ bind:m (poke-app ~bus %contact-hook %contact-action add-bus) +(pure:m *vase) diff --git a/pkg/arvo/ted/ph/migrate/send-his.hoon b/pkg/arvo/ted/ph/migrate/send-his.hoon new file mode 100644 index 0000000000..bb7a589097 --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/send-his.hoon @@ -0,0 +1,18 @@ +/- spider +/+ *ph-io, strandio +=, strand=strand:spider +:: +^- thread:spider +|= vase +=/ m (strand ,vase) +;< ~ bind:m start-simple +;< bol=bowl:spider bind:m get-bowl:strandio +:: +;< ~ bind:m (send-hi ~zod ~bus) +;< ~ bind:m (send-hi ~zod ~web) +;< ~ bind:m (send-hi ~bus ~zod) +;< ~ bind:m (send-hi ~bus ~web) +;< ~ bind:m (send-hi ~web ~zod) +;< ~ bind:m (send-hi ~web ~bus) +:: +(pure:m *vase) diff --git a/pkg/arvo/ted/ph/migrate/start.hoon b/pkg/arvo/ted/ph/migrate/start.hoon new file mode 100644 index 0000000000..6eede60422 --- /dev/null +++ b/pkg/arvo/ted/ph/migrate/start.hoon @@ -0,0 +1,73 @@ +/- spider +/+ *ph-io +=, strand=strand:spider +=> +|% +++ start-agent + |= [=ship agent=term] + =/ m (strand:spider ,~) + ^- form:m + =* loop $ + ;< ~ bind:m (dojo ship "|start {}") + ;< ~ bind:m ::(wait-for-agent-start ship agent) + (wait-for-output ship "activated app home/{(trip agent)}") + (pure:m ~) +:: +++ wait-for-agent-start + |= [=ship agent=term] + =/ m (strand:spider ,~) + ^- form:m + =* loop $ + ;< [her=^ship =unix-effect] bind:m take-unix-effect + ?: (is-dojo-output:util ship her unix-effect "activated app home/{(trip agent)}") + (pure:m ~) + loop +:: +++ start-agents + |= =ship + =/ m (strand:spider ,~) + ~& %starting-agents + ^- form:m + ;< ~ bind:m (start-agent ship %group-store) + ;< ~ bind:m (start-agent ship %group-pull-hook) + ;< ~ bind:m (start-agent ship %group-push-hook) + :: + ;< ~ bind:m (start-agent ship %metadata-store) + ;< ~ bind:m (start-agent ship %metadata-hook) + :: + ;< ~ bind:m (start-agent ship %invite-store) + ;< ~ bind:m (start-agent ship %invite-hook) + :: + ;< ~ bind:m (start-agent ship %chat-store) + ;< ~ bind:m (start-agent ship %chat-hook) + ;< ~ bind:m (start-agent ship %chat-view) + :: + ;< ~ bind:m (start-agent ship %contact-store) + ;< ~ bind:m (start-agent ship %contact-hook) + ;< ~ bind:m (start-agent ship %contact-view) + :: + ;< ~ bind:m (start-agent ship %graph-store) + ;< ~ bind:m (start-agent ship %graph-push-hook) + ;< ~ bind:m (start-agent ship %graph-pull-hook) + :: + (pure:m ~) +:: +-- +^- thread:spider +|= arg=vase +=+ !<(who=?(~ [@p ~]) arg) +=/ m (strand ,vase) +;< ~ bind:m start-simple +:: +?~ who + ;< ~ bind:m (dojo ~zod "|mount %") + ;< ~ bind:m (dojo ~bus "|mount %") + ;< ~ bind:m (dojo ~web "|mount %") + ;< ~ bind:m (start-agents ~zod) + ;< ~ bind:m (start-agents ~bus) + ;< ~ bind:m (start-agents ~web) + (pure:m *vase) +:: +;< ~ bind:m (dojo -.who "|mount %") +;< ~ bind:m (start-agents -.who) +(pure:m *vase) diff --git a/pkg/arvo/ted/ph/start-drivers.hoon b/pkg/arvo/ted/ph/start-drivers.hoon index 825a2b814a..e4480b03fa 100644 --- a/pkg/arvo/ted/ph/start-drivers.hoon +++ b/pkg/arvo/ted/ph/start-drivers.hoon @@ -6,8 +6,8 @@ =/ m (strand ,vase) ;< =bowl:spider bind:m get-bowl ;< ~ bind:m start-simple +:: must be a better way to background threads |- =* loop $ -~& >> %looping ;< ~ bind:m (sleep ~s5) loop From 4668ddf84dee452a7b4b4819a4f905c92bb51f75 Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Mon, 30 Nov 2020 13:06:05 -0800 Subject: [PATCH 840/933] groups: import/export --- pkg/arvo/app/group-store.hoon | 89 +++++++++++++++++++++++++++++++---- pkg/arvo/lib/pull-hook.hoon | 1 + 2 files changed, 82 insertions(+), 8 deletions(-) diff --git a/pkg/arvo/app/group-store.hoon b/pkg/arvo/app/group-store.hoon index 57552866af..f61d145699 100644 --- a/pkg/arvo/app/group-store.hoon +++ b/pkg/arvo/app/group-store.hoon @@ -29,7 +29,7 @@ :: Modify the group. Further documented in /sur/group-store.hoon :: :: -/- *group, permission-store +/- *group, permission-store, *contact-view /+ store=group-store, default-agent, verb, dbug, resource |% +$ card card:agent:gall @@ -165,12 +165,15 @@ ^- (quip card _this) ?> (team:title our.bowl src.bowl) =^ cards state - ?+ mark (on-poke:def mark vase) - %noun (poke-noun:gc vase) - :: + ?+ mark (on-poke:def mark vase) + %noun + (poke-noun:gc vase) + :: ?(%group-update %group-action) (poke-group-update:gc !<(update:store vase)) - :: + :: + %import + (poke-import:gc q.vase) == [cards this] :: @@ -214,10 +217,42 @@ (slav %p i.t.t.t.t.t.t.path) ?~ rid ~ ``noun+!>((peek-group-join u.rid ship)) + :: + [%x %export ~] + ``noun+!>(state) == :: - ++ on-agent on-agent:def - ++ on-arvo on-arvo:def + ++ on-agent + |= [=wire =sign:agent:gall] + ^- (quip card _this) + ?. ?=([%try-rejoin @ *] wire) + (on-agent:def wire sign) + ?> ?=(%poke-ack -.sign) + =/ rid=resource (de-path:resource t.t.wire) + ?~ p.sign + =/ =cage + [%pull-hook-action !>([%add entity.rid rid])] + :_ this + [%pass / %agent [our.bowl %group-pull-hook] %poke cage]~ + =/ nack-count=@ud (slav %ud i.t.wire) + =/ wakeup=@da + (add now.bowl (mul ~s1 (bex (min 19 nack-count)))) + :_ this + [%pass wire %arvo %b %wait wakeup]~ + :: + ++ on-arvo + |= [=wire =sign-arvo] + ^- (quip card _this) + ?. ?=([%try-rejoin @ *] wire) + (on-arvo:def wire sign-arvo) + =/ =resource (de-path:resource t.t.wire) + =/ nack-count=@ud (slav %ud i.t.wire) + ?> ?=([%b %wake *] sign-arvo) + ~? ?=(^ error.sign-arvo) + "behn errored in backoff timers, continuing anyway" + :_ this + [(try-rejoin:gc resource +(nack-count))]~ + :: ++ on-fail on-fail:def -- :: @@ -226,7 +261,7 @@ |= rid=resource ^- (unit group) (~(get by groups) rid) - +:: ++ peek-group-join |= [rid=resource =ship] =/ ugroup @@ -246,6 +281,39 @@ (~(has in ban-ranks.policy) (clan:title ship)) == == +:: +++ poke-import + |= arc=* + ^- (quip card _state) + =/ sty=state-one ;;(state-one arc) + :_ sty + %+ roll ~(tap by groups.sty) + |= [[=resource =group] out=(list card)] + ?: =(entity.resource our.bol) + %+ weld out + %+ roll ~(tap in members.group) + |= [recipient=@p out=(list card)] + ?: =(recipient our.bol) + out + :_ out + %- poke-contact + :* %invite resource recipient + (crip "Rejoin disconnected group {}/{}") + == + :_ out + (try-rejoin resource 0) +:: +++ try-rejoin + |= [rid=resource nack-count=@ud] + ^- card + =/ =cage + :- %group-update + !> ^- update:store + [%add-members rid (sy our.bol ~)] + =/ =wire + [%try-rejoin (scot %ud nack-count) (en-path:resource rid)] + [%pass wire %agent [entity.rid %group-push-hook] %poke cage] +:: ++ poke-noun |= =vase ^- (quip card _state) @@ -604,6 +672,11 @@ |= =action:store ^- card [%pass / %agent [our.bol %group-store] %poke %group-action !>(action)] +:: +++ poke-contact + |= act=contact-view-action + ^- card + [%pass / %agent [our.bol %contact-view] %poke %contact-view-action !>(act)] :: +send-diff: update subscribers of new state :: :: We only allow subscriptions on /groups diff --git a/pkg/arvo/lib/pull-hook.hoon b/pkg/arvo/lib/pull-hook.hoon index cb3b5e6f73..eb91242e75 100644 --- a/pkg/arvo/lib/pull-hook.hoon +++ b/pkg/arvo/lib/pull-hook.hoon @@ -196,6 +196,7 @@ =. inner-state on-save:og !>(state) + :: ++ on-poke |= [=mark =vase] ^- [(list card:agent:gall) agent:gall] From 9ea14aa5589865d47fa36c8e22d9e716733569d0 Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Mon, 30 Nov 2020 13:06:41 -0800 Subject: [PATCH 841/933] metadata: import/export --- pkg/arvo/app/metadata-hook.hoon | 62 ++++++++++++++++++++++++++++++-- pkg/arvo/app/metadata-store.hoon | 13 +++++++ 2 files changed, 73 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/app/metadata-hook.hoon b/pkg/arvo/app/metadata-hook.hoon index 5cad893191..1d3e6dbcef 100644 --- a/pkg/arvo/app/metadata-hook.hoon +++ b/pkg/arvo/app/metadata-hook.hoon @@ -51,9 +51,30 @@ `this :: ++ on-leave on-leave:def - ++ on-peek on-peek:def - ++ on-arvo on-arvo:def + ++ on-peek + |= =path + ^- (unit (unit cage)) + ?+ path (on-peek:def path) + [%x %export ~] + ``noun+!>(state) + == + :: + ++ on-arvo + |= [=wire =sign-arvo] + ^- (quip card _this) + ?. ?=([%try-rejoin @ @ *] wire) + (on-arvo:def wire sign-arvo) + =/ nack-count=@ud (slav %ud i.t.wire) + =/ who=@p (slav %p i.t.t.wire) + =/ pax t.t.t.wire + ?> ?=([%b %wake *] sign-arvo) + ~? ?=(^ error.sign-arvo) + "behn errored in backoff timers, continuing anyway" + :_ this + [(try-rejoin:hc who pax +(nack-count))]~ + :: ++ on-fail on-fail:def + :: ++ on-poke |= [=mark =vase] ^- (quip card _this) @@ -65,6 +86,12 @@ :: %metadata-action [(poke-action:hc !<(metadata-action vase)) this] + :: + %import + ?> (team:title our.bowl src.bowl) + =^ cards state + (poke-import:hc q.vase) + [cards this] == :: ++ on-watch @@ -166,6 +193,25 @@ !=(i.path '~') -- :: +++ poke-import + |= arc=* + ^- (quip card _state) + =/ sty=state-one ;;(state-one arc) + :_ sty + %+ murn ~(tap by synced.sty) + |= [=group-path =ship] + ?: =(ship our.bowl) + ~ + =/ =path [%group group-path] + `(try-rejoin ship path 0) +:: +++ try-rejoin + |= [who=@p pax=path nack-count=@ud] + ^- card + =/ =wire + [%try-rejoin (scot %ud nack-count) (scot %p who) pax] + [%pass wire %agent [who %metadata-hook] %watch pax] +:: ++ watch-group |= =path ^- (list card) @@ -240,7 +286,11 @@ |= wir=wire ^- (quip card _state) :_ state + |- ?+ wir !! + [%try-rejoin @ @ *] + $(wir t.t.t.wir) + :: [%updates ~] [%pass /updates %agent [our.bowl %metadata-store] %watch /updates]~ :: @@ -255,6 +305,14 @@ ++ watch-ack |= [wir=wire saw=(unit tang)] ^- (quip card _state) + ?: ?=([%try-rejoin @ *] wir) + ?~ saw + [~ state] + =/ nack-count=@ud (slav %ud i.t.wir) + =/ wakeup=@da + (add now.bowl (mul ~s1 (bex (min 19 nack-count)))) + :_ state + [%pass wir %arvo %b %wait wakeup]~ ?> ?=(^ wir) [~ ?~(saw state state(synced (~(del by synced) t.wir)))] :: diff --git a/pkg/arvo/app/metadata-store.hoon b/pkg/arvo/app/metadata-store.hoon index ec32cf8182..402e39501d 100644 --- a/pkg/arvo/app/metadata-store.hoon +++ b/pkg/arvo/app/metadata-store.hoon @@ -278,6 +278,7 @@ ?+ mark (on-poke:def mark vase) %metadata-action (poke-metadata-action:mc !<(metadata-action vase)) + :: %noun =/ val=(each [%cleanup path] tang) (mule |.(!<([%cleanup path] vase))) @@ -296,6 +297,9 @@ [app-name.r group app-path.r] == out + :: + %import + (poke-import:mc q.vase) == [cards this] :: @@ -350,6 +354,9 @@ =/ app=term i.t.t.path =/ app-path=^path t.t.t.path ``noun+!>((~(get by resource-indices) app app-path)) + :: + [%x %export ~] + ``noun+!>(state) == :: ++ on-leave on-leave:def @@ -368,6 +375,12 @@ %remove (handle-remove group-path.act resource.act) == :: +++ poke-import + |= arc=* + ^- (quip card _state) + =/ sty=state-6 ;;(state-6 arc) + [~ sty] +:: ++ handle-add |= [=group-path =md-resource =metadata] ^- (quip card _state) From 4f0e599cb10209016cf88fae90a456393c3e38c2 Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Mon, 30 Nov 2020 13:07:04 -0800 Subject: [PATCH 842/933] contacts: import/export --- pkg/arvo/app/contact-hook.hoon | 57 +++++++++++++++++++++++++++++++-- pkg/arvo/app/contact-store.hoon | 17 ++++++++-- 2 files changed, 70 insertions(+), 4 deletions(-) diff --git a/pkg/arvo/app/contact-hook.hoon b/pkg/arvo/app/contact-hook.hoon index 0871201839..379b8fdc10 100644 --- a/pkg/arvo/app/contact-hook.hoon +++ b/pkg/arvo/app/contact-hook.hoon @@ -132,6 +132,10 @@ :: %contact-hook-action (poke-hook-action:cc !<(contact-hook-action vase)) + :: + %import + ?> (team:title our.bol src.bol) + (poke-import:cc q.vase) == [cards this] :: @@ -170,8 +174,27 @@ == :: ++ on-leave on-leave:def - ++ on-peek on-peek:def - ++ on-arvo on-arvo:def + ++ on-peek + |= =path + ^- (unit (unit cage)) + ?+ path (on-peek:def path) + [%x %export ~] + ``noun+!>(state) + == + ++ on-arvo + |= [=wire =sign-arvo] + ^- (quip card _this) + ?. ?=([%try-rejoin @ @ *] wire) + (on-arvo:def wire sign-arvo) + =/ nack-count=@ud (slav %ud i.t.wire) + =/ who=@p (slav %p i.t.t.wire) + =/ pax t.t.t.wire + ?> ?=([%b %wake *] sign-arvo) + ~? ?=(^ error.sign-arvo) + "behn errored in backoff timers, continuing anyway" + :_ this + [(try-rejoin:cc who pax +(nack-count))]~ + :: ++ on-fail on-fail:def -- :: @@ -260,6 +283,26 @@ == == :: +++ poke-import + |= arc=* + ^- (quip card _state) + =/ sty=state-three ;;(state-three arc) + :_ sty + %+ turn ~(tap by synced.sty) + |= [=path =ship] + ^- card + =/ contact-path [%contacts path] + ?: =(our.bol ship) + [%pass contact-path %agent [our.bol %contact-store] %watch contact-path] + (try-rejoin ship contact-path 0) +:: +++ try-rejoin + |= [who=@p pax=path nack-count=@ud] + ^- card + =/ =wire + [%try-rejoin (scot %ud nack-count) (scot %p who) pax] + [%pass wire %agent [who %contact-hook] %watch pax] +:: ++ watch-contacts |= pax=path ^- (list card) @@ -282,6 +325,13 @@ ^- (quip card _state) ?~ saw [~ state] + ?: ?=([%try-rejoin @ *] wir) + =/ nack-count=@ud (slav %ud i.t.wir) + =/ wakeup=@da + (add now.bol (mul ~s1 (bex (min 19 nack-count)))) + :_ state + [%pass wir %arvo %b %wait wakeup]~ + :: ?> ?=(^ wir) [~ state(synced (~(del by synced) t.wir))] :: @@ -295,6 +345,9 @@ |= wir=wire ^- (list card) ?+ wir !! + [%try-rejoin @ @ *] + $(wir t.t.t.wir) + :: [%inv ~] [%pass /inv %agent [our.bol %invite-store] %watch /invitatory/contacts]~ :: diff --git a/pkg/arvo/app/contact-store.hoon b/pkg/arvo/app/contact-store.hoon index 6089cae80c..8ed19228a0 100644 --- a/pkg/arvo/app/contact-store.hoon +++ b/pkg/arvo/app/contact-store.hoon @@ -121,8 +121,12 @@ ?> (team:title our.bowl src.bowl) =^ cards state ?+ mark (on-poke:def mark vase) - ::%json (poke-json:cc !<(json vase)) - %contact-action (poke-contact-action:cc !<(contact-action vase)) + ::%json (poke-json:cc !<(json vase)) + %contact-action + (poke-contact-action:cc !<(contact-action vase)) + :: + %import + (poke-import:cc q.vase) == [cards this] :: @@ -169,6 +173,9 @@ ?~ contacts ~ ``noun+!>((~(get by u.contacts) ship)) + :: + [%x %export ~] + ``noun+!>(state) == :: ++ on-agent on-agent:def @@ -197,6 +204,12 @@ %edit (handle-edit +.action) == :: +++ poke-import + |= arc=* + ^- (quip card _state) + =/ sty=state-three ;;(state-three arc) + [~ sty] +:: ++ handle-create |= =path ^- (quip card _state) From 398fb5de5096dec41450f20f8bc39c2848b90f23 Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Mon, 30 Nov 2020 13:07:26 -0800 Subject: [PATCH 843/933] invites: import/export --- pkg/arvo/app/invite-store.hoon | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/arvo/app/invite-store.hoon b/pkg/arvo/app/invite-store.hoon index 258f61a4c6..5e504be746 100644 --- a/pkg/arvo/app/invite-store.hoon +++ b/pkg/arvo/app/invite-store.hoon @@ -102,9 +102,16 @@ =^ cards state ?+ mark (on-poke:def mark vase) %invite-action (poke-invite-action !<(action:store vase)) + %import (poke-import q.vase) == [cards this] :: + ++ poke-import + |= arc=* + ^- (quip card _state) + =/ sty=state-1 ;;(state-1 arc) + [~ sty] + :: ++ poke-invite-action |= =action:store ^- (quip card _state) @@ -205,5 +212,7 @@ :^ ~ ~ %noun !> ^- (unit invite:store) (~(get by invitatory) serial) + :: + [%x %export ~] ``noun+!>(state) == -- From feab60f8a91c70bf95a52e534cabdddecd3bceeb Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Mon, 30 Nov 2020 13:07:51 -0800 Subject: [PATCH 844/933] chat: import/export --- pkg/arvo/app/chat-hook.hoon | 59 ++++++++++++++++++++++++++++++++++-- pkg/arvo/app/chat-store.hoon | 16 ++++++++-- 2 files changed, 70 insertions(+), 5 deletions(-) diff --git a/pkg/arvo/app/chat-hook.hoon b/pkg/arvo/app/chat-hook.hoon index 340d1e6c14..a0f7a4ee99 100644 --- a/pkg/arvo/app/chat-hook.hoon +++ b/pkg/arvo/app/chat-hook.hoon @@ -369,6 +369,10 @@ :: %chat-hook-action (poke-chat-hook-action:cc !<(action:hook vase)) + :: + %import + ?> (team:title our.bol src.bol) + (poke-import:cc q.vase) == [cards this] :: @@ -417,8 +421,28 @@ == :: ++ on-leave on-leave:def - ++ on-peek on-peek:def - ++ on-arvo on-arvo:def + ++ on-peek + |= =path + ^- (unit (unit cage)) + ?+ path (on-peek:def path) + [%x %export ~] + ``noun+!>(state) + == + :: + ++ on-arvo + |= [=wire =sign-arvo] + ^- (quip card _this) + ?. ?=([%try-rejoin @ @ *] wire) + (on-arvo:def wire sign-arvo) + =/ nack-count=@ud (slav %ud i.t.wire) + =/ who=@p (slav %p i.t.t.wire) + =/ pax t.t.t.wire + ?> ?=([%b %wake *] sign-arvo) + ~? ?=(^ error.sign-arvo) + "behn errored in backoff timers, continuing anyway" + :_ this + [(try-rejoin:cc who pax +(nack-count))]~ + :: ++ on-fail on-fail:def -- :: @@ -677,6 +701,27 @@ == == :: +++ poke-import + |= arc=* + ^- (quip card _state) + =/ sty=state-10 ;;(state-10 arc) + :_ sty + %+ turn ~(tap by synced.sty) + |= [=path =ship] + ^- card + =/ watch-path=^path [%mailbox path] + ?: =(our.bol ship) + =/ store-wire=wire [%store path] + [%pass store-wire %agent [our.bol %chat-store] %watch watch-path] + (try-rejoin ship watch-path 0) +:: +++ try-rejoin + |= [who=@p pax=path nack-count=@ud] + ^- card + =/ =wire + [%try-rejoin (scot %ud nack-count) (scot %p who) pax] + [%pass wire %agent [who %chat-hook] %watch pax] +:: ++ watch-synced |= pax=path ^- (list card) @@ -835,6 +880,9 @@ [%pass /permissions %agent [our.bol %permission-store] %watch /updates]~ :: ?+ wir !! + [%try-rejoin @ @ *] + $(wir t.t.t.wir) + :: [%groups ~] [~[watch-groups] state] :: [%store @ *] @@ -909,6 +957,13 @@ ?> ?=(^ chat) (migrate-listen t.chat) [~ state] + :: + [%try-rejoin @ *] + =/ nack-count=@ud (slav %ud i.t.wir) + =/ wakeup=@da + (add now.bol (mul ~s1 (bex (min 19 nack-count)))) + :_ state + [%pass wir %arvo %b %wait wakeup]~ == :: ++ chat-poke diff --git a/pkg/arvo/app/chat-store.hoon b/pkg/arvo/app/chat-store.hoon index 5118babbcc..e1fab3631c 100644 --- a/pkg/arvo/app/chat-store.hoon +++ b/pkg/arvo/app/chat-store.hoon @@ -89,9 +89,10 @@ ?> (team:title our.bowl src.bowl) =^ cards state ?+ mark (on-poke:def mark vase) - %json (poke-json:cc !<(json vase)) - %chat-action (poke-chat-action:cc !<(action:store vase)) - %noun [~ (poke-noun:cc !<(admin-action vase))] + %json (poke-json:cc !<(json vase)) + %chat-action (poke-chat-action:cc !<(action:store vase)) + %noun [~ (poke-noun:cc !<(admin-action vase))] + %import (poke-import:cc q.vase) == [cards this] :: @@ -139,6 +140,9 @@ ?~ mailbox ~ ``noun+!>(config.u.mailbox) + :: + [%x %export ~] + ``noun+!>(state) == :: ++ on-agent on-agent:def @@ -235,6 +239,12 @@ [(weld message-moves read-moves) state] == :: +++ poke-import + |= arc=* + ^- (quip card _state) + =/ sty=state-3 ;;(state-3 arc) + [~ sty] +:: ++ handle-create |= =action:store ^- (quip card _state) From 2f53524e2ffcdb76f522191c60e1545ac5c3824e Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Mon, 30 Nov 2020 13:08:15 -0800 Subject: [PATCH 845/933] graphs: import-export --- pkg/arvo/app/graph-store.hoon | 54 ++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/pkg/arvo/app/graph-store.hoon b/pkg/arvo/app/graph-store.hoon index df39fb0ae5..1104fb4129 100644 --- a/pkg/arvo/app/graph-store.hoon +++ b/pkg/arvo/app/graph-store.hoon @@ -218,6 +218,7 @@ ?+ mark (on-poke:def mark vase) %graph-update (graph-update !<(update:store vase)) %noun (debug !<(debug-input vase)) + %import (poke-import q.vase) == [cards this] :: @@ -612,6 +613,26 @@ %graph ^$(graph p.children.node) == == + :: + ++ poke-import + |= arc=* + ^- (quip card _state) + =/ sty ;;(state-2 arc) + :_ sty + %+ turn ~(tap by graphs.sty) + |= [rid=resource:store =marked-graph:store] + ^- card + ?: =(our.bowl entity.rid) + =/ =cage [%push-hook-action !>([%add rid])] + [%pass / %agent [our.bowl %graph-push-hook] %poke cage] + (try-rejoin rid 0) + :: + ++ try-rejoin + |= [rid=resource:store nack-count=@] + ^- card + =/ res-path (en-path:res rid) + =/ wire [%try-rejoin (scot %ud nack-count) res-path] + [%pass wire %agent [entity.rid %graph-push-hook] %watch resource+res-path] -- :: ++ on-peek @@ -668,6 +689,9 @@ :+ %0 now.bowl [%add-graph [ship term] `graph:store`p.u.result q.u.result %.y] + :: + [%x %export ~] + ``noun+!>(state) :: [%x %graph-subset @ @ @ @ ~] =/ =ship (slav %p i.t.t.path) @@ -792,9 +816,37 @@ =* validator i.t.wire =/ =rave:clay [%next %b [%da now.bowl] /[validator]] [%pass wire %arvo %c %warp our.bowl [%home `rave]]~ + :: + [%try-rejoin @ *] + =/ rid=resource:store (de-path:res t.t.wire) + =/ nack-count (slav %ud i.t.wire) + ?> ?=([%b %wake *] sign-arvo) + ~? ?=(^ error.sign-arvo) + "behn errored in backoff timers, continuing anyway" + =/ new=^wire [%try-rejoin (scot %ud +(nack-count)) t.t.wire] + :_ this + [%pass new %agent [entity.rid %graph-push-hook] %watch resource+t.t.wire]~ == :: -++ on-agent on-agent:def +++ on-agent + |= [=wire =sign:agent:gall] + ^- (quip card _this) + ?. ?=([%try-rejoin @ *] wire) + (on-agent:def wire sign) + ?. ?=(%watch-ack -.sign) + [~ this] + =/ rid=resource:store (de-path:res t.t.wire) + ?~ p.sign + :: leave and poke our graph-pull-hook + =/ =cage [%pull-hook-action !>([%add entity.rid rid])] + :_ this + [%pass / %agent [our.bowl %graph-pull-hook] %poke cage]~ + =/ nack-count=@ud (slav %ud i.t.wire) + =/ wakeup=@da + (add now.bowl (mul ~s1 (bex (min 19 nack-count)))) + :_ this + [%pass wire %arvo %b %wait wakeup]~ +:: ++ on-leave on-leave:def ++ on-fail on-fail:def -- From 9ea43121a5ffc4a71ae486a24fc7914da7100115 Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Tue, 1 Dec 2020 17:52:24 -0800 Subject: [PATCH 846/933] graph-store: leave try-rejoin wire when subscription succeeds --- pkg/arvo/app/graph-store.hoon | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/app/graph-store.hoon b/pkg/arvo/app/graph-store.hoon index 1104fb4129..c863a1a0e6 100644 --- a/pkg/arvo/app/graph-store.hoon +++ b/pkg/arvo/app/graph-store.hoon @@ -837,10 +837,11 @@ [~ this] =/ rid=resource:store (de-path:res t.t.wire) ?~ p.sign - :: leave and poke our graph-pull-hook =/ =cage [%pull-hook-action !>([%add entity.rid rid])] :_ this - [%pass / %agent [our.bowl %graph-pull-hook] %poke cage]~ + :~ [%pass / %agent [our.bowl %graph-pull-hook] %poke cage] + [%pass wire %agent [entity.rid %graph-push-hook] %leave ~] + == =/ nack-count=@ud (slav %ud i.t.wire) =/ wakeup=@da (add now.bowl (mul ~s1 (bex (min 19 nack-count)))) From b27806769ec8c12ec3327faefbcb53800091ef6e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 1 Dec 2020 17:24:30 -0800 Subject: [PATCH 847/933] hoon: updates +rep and +rip to take a $bite --- pkg/arvo/sys/hoon.hoon | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index cd9fc90afa..ed49c71450 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -891,14 +891,15 @@ ?~ b 0 (cat a i.b $(b t.b)) :: -++ rep :: assemble single +++ rep :: assemble fixed ~/ %rep - |= [a=bloq b=(list @)] - ^- @ - =+ c=0 - |- - ?~ b 0 - (add (lsh a c (end a 1 i.b)) $(c +(c), b t.b)) + |= [a=bite b=(list @)] + =/ [=bloq =step] ?^(a a [a *step]) + =| i=@ud + |- ^- @ + ?~ b 0 + %+ add $(i +(i), b t.b) + (lsh bloq (mul step i) (end bloq step i.b)) :: ++ repn ~/ %repn @@ -933,10 +934,11 @@ :: ++ rip :: disassemble ~/ %rip - |= [=bloq x=@] + |= [a=bite b=@] + =/ [=bloq =step] ?^(a a [a *step]) ^- (list @) - ?: =(0 x) ~ - [(end bloq 1 x) $(x (rsh bloq 1 x))] + ?: =(0 b) ~ + [(end bloq step b) $(b (rsh bloq step b))] :: ++ rsh :: right-shift ~/ %rsh From e2fa71c5ca7bc139846767754631dd547843f670 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Tue, 1 Dec 2020 10:49:10 +1000 Subject: [PATCH 848/933] interface: bump indigo --- pkg/interface/package-lock.json | 6 +++--- pkg/interface/package.json | 2 +- .../src/views/apps/launch/components/tiles/tile.js | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/interface/package-lock.json b/pkg/interface/package-lock.json index 1adb54bcd5..09d985c69c 100644 --- a/pkg/interface/package-lock.json +++ b/pkg/interface/package-lock.json @@ -1693,9 +1693,9 @@ "integrity": "sha512-3OPSdf9cejP/TSzWXuBaYbzLtAfBzQnc75SlPLkoPfwpxnv1Bvy9hiWngLY0WnKRR6lMOldnkYQCCuNWeDibYQ==" }, "@tlon/indigo-react": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/@tlon/indigo-react/-/indigo-react-1.2.13.tgz", - "integrity": "sha512-6qYLjVcGZtDjI+BqS2PRrfAh9mUCDtYwDOHuYuPyV87mdVRAhduBlQ/3tDVlTNWICF9DeAhozeClxalACs5Ipw==", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/@tlon/indigo-react/-/indigo-react-1.2.5.tgz", + "integrity": "sha512-NOQTwH74l/XXMIfQ4ZzymvZuk1WK1nmO552TmXrQxBUSb7HmdlA8anG5oRrvnLJTkajLCY59McLkDca+lCcvwg==", "requires": { "@reach/menu-button": "^0.10.5", "react": "^16.13.1", diff --git a/pkg/interface/package.json b/pkg/interface/package.json index 5786f7494e..af7d355078 100644 --- a/pkg/interface/package.json +++ b/pkg/interface/package.json @@ -9,7 +9,7 @@ "@reach/menu-button": "^0.10.5", "@reach/tabs": "^0.10.5", "@tlon/indigo-light": "^1.0.3", - "@tlon/indigo-react": "1.2.13", + "@tlon/indigo-react": "1.2.5", "@tlon/sigil-js": "^1.4.2", "aws-sdk": "^2.726.0", "big-integer": "^1.6.48", diff --git a/pkg/interface/src/views/apps/launch/components/tiles/tile.js b/pkg/interface/src/views/apps/launch/components/tiles/tile.js index a83d46b4a5..d83862a358 100644 --- a/pkg/interface/src/views/apps/launch/components/tiles/tile.js +++ b/pkg/interface/src/views/apps/launch/components/tiles/tile.js @@ -18,6 +18,7 @@ const SquareBox = styled(Box)` position: absolute; top: 0; } + position: relative; `; const routeList = defaultApps.map(a => `/~${a}`); From 4e9c13834c3ac00f0aa55d9c03dd3764e7631fde Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Wed, 2 Dec 2020 12:09:26 +1000 Subject: [PATCH 849/933] channel.js: address L review --- pkg/arvo/app/landscape/js/channel.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pkg/arvo/app/landscape/js/channel.js b/pkg/arvo/app/landscape/js/channel.js index 1c089ff80c..2f10d6bc6c 100644 --- a/pkg/arvo/app/landscape/js/channel.js +++ b/pkg/arvo/app/landscape/js/channel.js @@ -63,8 +63,6 @@ class Channel { } resetDebounceTimer() { - console.log('cancelled, debouncing in 500'); - console.log(this.outstandingJSON); if(this.debounceTimer) { clearTimeout(this.debounceTimer); this.debounceTimer = null; @@ -259,9 +257,7 @@ class Channel { } else if (obj.response == "diff") { // ensure we ack before channel clogs if((this.lastEventId - this.lastAcknowledgedEventId) > 30) { - clearTimeout(this.debounceTimer); - this.debounceTimer = null; - this.sendJSONToChannel(); + this.clearQueue(); } let funcs = subFuncs; From e9937b306e1c3de67335e9ed4215c31b7f7233a7 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 1 Dec 2020 17:52:03 -0800 Subject: [PATCH 850/933] u3: updates +rep and +rip jets to take a $bite --- pkg/urbit/include/jets/k.h | 8 +- pkg/urbit/include/jets/q.h | 4 +- pkg/urbit/include/noun/retrieve.h | 5 + pkg/urbit/include/noun/xtract.h | 5 + pkg/urbit/jets/c/rep.c | 256 +++++++++++++++++++++--------- pkg/urbit/jets/c/rip.c | 132 +++++++++++++-- pkg/urbit/jets/c/swp.c | 56 ++++--- pkg/urbit/jets/e/trip.c | 47 +++--- pkg/urbit/noun/retrieve.c | 24 +++ pkg/urbit/noun/xtract.c | 10 ++ 10 files changed, 397 insertions(+), 150 deletions(-) diff --git a/pkg/urbit/include/jets/k.h b/pkg/urbit/include/jets/k.h index cbde1e3efb..0fb6d8d2b9 100644 --- a/pkg/urbit/include/jets/k.h +++ b/pkg/urbit/include/jets/k.h @@ -43,12 +43,16 @@ /* u3kc_rep(): assemble single. */ u3_noun - u3kc_rep(u3_atom a, u3_noun b); + u3kc_rep(u3_atom a, + u3_atom b, + u3_noun c); /* u3kc_rip(): disassemble. */ u3_noun - u3kc_rip(u3_atom a, u3_atom b); + u3kc_rip(u3_atom a, + u3_atom b, + u3_atom c); /* u3kc_rev(): reverse block order, accounting for leading zeroes. */ diff --git a/pkg/urbit/include/jets/q.h b/pkg/urbit/include/jets/q.h index 3f25452cae..b952ce7009 100644 --- a/pkg/urbit/include/jets/q.h +++ b/pkg/urbit/include/jets/q.h @@ -63,9 +63,9 @@ u3_noun u3qc_peg(u3_atom, u3_atom); u3_noun u3qc_pow(u3_atom, u3_atom); u3_noun u3qc_rap(u3_atom, u3_noun); - u3_noun u3qc_rep(u3_atom, u3_noun); + u3_noun u3qc_rep(u3_atom, u3_atom, u3_noun); u3_noun u3qc_rev(u3_atom, u3_atom, u3_atom); - u3_noun u3qc_rip(u3_atom, u3_atom); + u3_noun u3qc_rip(u3_atom, u3_atom, u3_atom); u3_noun u3qc_rsh(u3_atom, u3_atom, u3_atom); u3_noun u3qc_swp(u3_atom, u3_atom); u3_noun u3qc_sqt(u3_atom); diff --git a/pkg/urbit/include/noun/retrieve.h b/pkg/urbit/include/noun/retrieve.h index de4f645ec7..415323b2a0 100644 --- a/pkg/urbit/include/noun/retrieve.h +++ b/pkg/urbit/include/noun/retrieve.h @@ -188,6 +188,11 @@ u3_noun* b, u3_noun* c); + /* u3r_bite(): retrieve/default $bloq and $step from $bite. + */ + c3_o + u3r_bite(u3_noun bite, u3_atom* bloq, u3_atom *step); + /* u3r_cell(): ** ** Divide `a` as a cell `[b c]`. diff --git a/pkg/urbit/include/noun/xtract.h b/pkg/urbit/include/noun/xtract.h index 593ac7aa6f..5e22a90bb6 100644 --- a/pkg/urbit/include/noun/xtract.h +++ b/pkg/urbit/include/noun/xtract.h @@ -98,6 +98,11 @@ void u3x_mean(u3_noun a, ...); + /* u3x_bite(): xtract/default $bloq and $step from $bite. + */ + void + u3x_bite(u3_noun bite, u3_atom* bloq, u3_atom *step); + /* u3x_cell(): ** ** Divide `a` as a cell `[b c]`. diff --git a/pkg/urbit/jets/c/rep.c b/pkg/urbit/jets/c/rep.c index 7e34b8faa8..0ec4ded742 100644 --- a/pkg/urbit/jets/c/rep.c +++ b/pkg/urbit/jets/c/rep.c @@ -3,92 +3,194 @@ */ #include "all.h" - -/* functions +/* + Get the lowest `n` bits of a word `w` using a bitmask. */ - u3_noun - u3qc_rep(u3_atom a, - u3_noun b) +#define TAKEBITS(n,w) \ + ((n)==32) ? (w) : \ + ((n)==0) ? 0 : \ + ((w) & ((1 << (n)) - 1)) + +/* + Divide, rounding up. +*/ +#define DIVCEIL(x,y) \ + (x==0) ? 0 : \ + 1 + ((x - 1) / y); + +static u3_noun +_bit_rep(u3_atom bits, u3_noun blox) +{ + if ( (c3n == u3a_is_cat(bits) || bits==0 || bits>31) ) { + return u3m_bail(c3__fail); + } + + // + // Calculate input and output size. + // + c3_w num_blox_w = u3qb_lent(blox); + c3_w bit_widt_w = num_blox_w * bits; + c3_w wor_widt_w = DIVCEIL(bit_widt_w, 32); + u3i_slab sab_u; + u3i_slab_bare(&sab_u, 5, wor_widt_w); + + // + // Fill the atom buffer with bits from each block. + // + // Bits are pushed into the `acc_w` register and flushed to the buffer + // once full. + // + // acc_w register + // use_w number of register bits filled (used) + // cur_w next buffer word to flush into. + // { - if ( !_(u3a_is_cat(a)) || (a >= 32) ) { - return u3m_bail(c3__exit); + c3_w acc_w=0, use_w=0, *cur_w=sab_u.buf_w; + +# define FLUSH() *cur_w++=acc_w; acc_w=use_w=0 +# define SLICE(sz,off,val) TAKEBITS(sz, val) << off + + for (c3_w i=0; i> rem_in_acc_w; + FLUSH(); + } + } } - else { - c3_g a_g = a; - c3_w tot_w = 0; - u3i_slab sab_u; - /* Measure and validate the slab required. - */ - { - u3_noun cab = b; - - while ( 1 ) { - u3_noun h_cab; - c3_w len_w; - - if ( 0 == cab ) { - break; - } - else if ( c3n == u3du(cab) ) { - return u3m_bail(c3__exit); - } - else if ( c3n == u3ud(h_cab = u3h(cab)) ) { - return u3m_bail(c3__exit); - } - else if ( (tot_w + (len_w = u3r_met(a_g, h_cab))) < tot_w ) { - return u3m_bail(c3__fail); - } - tot_w++; - cab = u3t(cab); - } - - if ( 0 == tot_w ) { - return 0; - } - - u3i_slab_init(&sab_u, a_g, tot_w); - } - - /* Chop the list atoms in. - */ - { - u3_noun cab = b; - c3_w pos_w = 0; - - while ( 0 != cab ) { - u3_noun h_cab = u3h(cab); - - u3r_chop(a_g, 0, 1, pos_w, sab_u.buf_w, h_cab); - pos_w++; - cab = u3t(cab); - } - } - - return u3i_slab_mint(&sab_u); + // + // If the last word isn't fully used, it will still need to be + // flushed. + // + if (use_w) { + FLUSH(); } } - u3_noun - u3wc_rep(u3_noun cor) - { - u3_noun a, b; - if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0)) || - (c3n == u3ud(a)) ) + return u3i_slab_mint(&sab_u); +} + +static u3_noun +_block_rep(u3_atom a, + u3_noun b) +{ + if ( !_(u3a_is_cat(a)) || (a >= 32) ) { + return u3m_bail(c3__exit); + } + else { + c3_g a_g = a; + c3_w tot_w = 0; + u3i_slab sab_u; + + /* Measure and validate the slab required. + */ { - return u3m_bail(c3__exit); - } else { - u3_noun pro; + u3_noun cab = b; - pro = u3qc_rep(a, b); - return pro; + while ( 1 ) { + u3_noun h_cab; + c3_w len_w; + + if ( 0 == cab ) { + break; + } + else if ( c3n == u3du(cab) ) { + return u3m_bail(c3__exit); + } + else if ( c3n == u3ud(h_cab = u3h(cab)) ) { + return u3m_bail(c3__exit); + } + else if ( (tot_w + (len_w = u3r_met(a_g, h_cab))) < tot_w ) { + return u3m_bail(c3__fail); + } + tot_w++; + cab = u3t(cab); + } + + if ( 0 == tot_w ) { + return 0; + } + + u3i_slab_init(&sab_u, a_g, tot_w); } + + /* Chop the list atoms in. + */ + { + u3_noun cab = b; + c3_w pos_w = 0; + + while ( 0 != cab ) { + u3_noun h_cab = u3h(cab); + + u3r_chop(a_g, 0, 1, pos_w, sab_u.buf_w, h_cab); + pos_w++; + cab = u3t(cab); + } + } + + return u3i_slab_mint(&sab_u); } - u3_noun - u3kc_rep(u3_atom a, - u3_noun b) - { - u3_noun res = u3qc_rep(a, b); - u3z(a); u3z(b); - return res; +} + +u3_noun +u3qc_rep(u3_atom a, + u3_atom b, + u3_noun c) +{ + if ( 1 == b ) { + return _block_rep(a, c); } + + if ( 0 == a ) { + return _bit_rep(b, c); + } + + u3l_log("rep: stub\r\n"); + return u3m_bail(c3__fail); +} + +u3_noun +u3wc_rep(u3_noun cor) +{ + u3_atom bloq, step; + u3_noun a, b; + u3x_mean(cor, u3x_sam_2, &a, + u3x_sam_3, &b, 0); + u3x_bite(a, &bloq, &step); + + return u3qc_rep(bloq, step, b); +} + +u3_noun +u3kc_rep(u3_atom a, + u3_atom b, + u3_noun c) +{ + u3_noun res = u3qc_rep(a, b, c); + u3z(a); u3z(b); u3z(c); + return res; +} diff --git a/pkg/urbit/jets/c/rip.c b/pkg/urbit/jets/c/rip.c index b5e727b390..d8d4423d15 100644 --- a/pkg/urbit/jets/c/rip.c +++ b/pkg/urbit/jets/c/rip.c @@ -1,6 +1,90 @@ #include "all.h" -u3_noun u3qc_rip(u3_atom bloq, u3_atom b) { +/* + Get the lowest `n` bits of a word `w` using a bitmask. +*/ +#define TAKEBITS(n,w) \ + ((n)==32) ? (w) : \ + ((n)==0) ? 0 : \ + ((w) & ((1 << (n)) - 1)) + +/* + Divide, rounding up. +*/ +#define DIVCEIL(x,y) \ + (x==0) ? 0 : \ + 1 + ((x - 1) / y); + +/* + `ripn` breaks `atom` into a list of blocks, of bit-width `bits`. The + resulting list will be least-significant block first. + + XX TODO This only handles cases where the bit-width is <= 32. + + For each block we produce, we need to grab the relevant words inside + `atom`, so we first compute their indicies. + + `ins_idx` is the word-index of the least-significant word we + care about, and `sig_idx` is the word after that. + + Next we grab those words (`ins_word` and `sig_word`) from the atom + using `u3r_word`. Note that `sig_idx` might be out-of-bounds for the + underlying array of `atom`, but `u3r_word` returns 0 in that case, + which is exatly what we want. + + Now, we need to grab the relevant bits out of both words, and combine + them. `bits_rem_in_ins_word` is the number of remaining (insignificant) + bits in `ins_word`, `nbits_ins` is the number of bits we want from the + less-significant word, and `nbits_sig` from the more-significant one. + + Take the least significant `nbits_sig` bits from `sig_word`, and take + the slice we care about from `ins_word`. In order to take that slice, + we drop `bits_rem_in_ins_word` insignificant bits, and then take the + `nbits_sig` most-significant bits. + + Last, we slice out those bits from the two words, combine them into + one word, and cons them onto the front of the result. +*/ +static u3_noun +_bit_rip(u3_atom bits, u3_atom atom) +{ + if ( !_(u3a_is_cat(bits) || bits==0 || bits>31) ) { + return u3m_bail(c3__fail); + } + + c3_w bit_width = u3r_met(0, atom); + c3_w num_blocks = DIVCEIL(bit_width, bits); + + u3_noun res = u3_nul; + + for ( c3_w blk = 0; blk < num_blocks; blk++ ) { + c3_w next_blk = blk + 1; + c3_w blks_rem = num_blocks - next_blk; + c3_w bits_rem = blks_rem * bits; + c3_w ins_idx = bits_rem / 32; + c3_w sig_idx = ins_idx + 1; + + c3_w bits_rem_in_ins_word = bits_rem % 32; + + c3_w ins_word = u3r_word(ins_idx, atom); + c3_w sig_word = u3r_word(sig_idx, atom); + c3_w nbits_ins = c3_min(bits, 32 - bits_rem_in_ins_word); + c3_w nbits_sig = bits - nbits_ins; + + c3_w ins_word_bits = TAKEBITS(nbits_ins, ins_word >> bits_rem_in_ins_word); + c3_w sig_word_bits = TAKEBITS(nbits_sig, sig_word); + + c3_w item = ins_word_bits | (sig_word_bits << nbits_ins); + + res = u3nc(item, res); + } + + return res; +} + +static u3_noun +_block_rip(u3_atom bloq, u3_atom b) +{ if ( !_(u3a_is_cat(bloq)) || (bloq >= 32) ) { return u3m_bail(c3__fail); } @@ -62,21 +146,41 @@ u3_noun u3qc_rip(u3_atom bloq, u3_atom b) { return acc; } -u3_noun u3wc_rip(u3_noun cor) { - u3_noun a, b; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0)) || - (c3n == u3ud(a)) || - (c3n == u3ud(b)) - ) { - return u3m_bail(c3__exit); +u3_noun +u3qc_rip(u3_atom a, + u3_atom b, + u3_atom c) +{ + if ( 1 == b ) { + return _block_rip(a, c); } - return u3qc_rip(a, b); + if ( 0 == a ) { + return _bit_rip(b, c); + } + + u3l_log("rip: stub\r\n"); + return u3m_bail(c3__fail); } -u3_noun u3kc_rip(u3_atom a, u3_atom b) { - u3_noun res = u3qc_rip(a, b); - u3z(a); u3z(b); - return res; +u3_noun +u3wc_rip(u3_noun cor) +{ + u3_atom bloq, step; + u3_noun a, b; + u3x_mean(cor, u3x_sam_2, &a, + u3x_sam_3, &b, 0); + u3x_bite(a, &bloq, &step); + + return u3qc_rip(bloq, step, u3x_atom(b)); +} + +u3_noun +u3kc_rip(u3_atom a, + u3_atom b, + u3_atom c) +{ + u3_noun pro = u3qc_rip(a, b, c); + u3z(a); u3z(b); u3z(c); + return pro; } diff --git a/pkg/urbit/jets/c/swp.c b/pkg/urbit/jets/c/swp.c index 1b10dca2b5..9f7a68c9ae 100644 --- a/pkg/urbit/jets/c/swp.c +++ b/pkg/urbit/jets/c/swp.c @@ -3,37 +3,35 @@ */ #include "all.h" -/* functions -*/ +u3_noun +u3qc_swp(u3_atom a, + u3_atom b) +{ + //XX write a proper c-style swp, maybe + // + return u3kc_rep(u3k(a), 1, u3kb_flop(u3qc_rip(a, 1, b))); +} - u3_noun - u3qc_swp(u3_atom a, - u3_atom b) +u3_noun +u3wc_swp(u3_noun cor) +{ + u3_noun a, b; + u3x_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0); + + if ( (c3n == u3ud(a)) + || (c3n == u3ud(b)) ) { - //XX write a proper c-style swp, maybe - return u3kc_rep(u3k(a), u3kb_flop(u3qc_rip(a, b))); + return u3m_bail(c3__exit); } - u3_noun - u3wc_swp(u3_noun cor) - { - u3_noun a, b; + return u3qc_swp(a, b); + } - if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0)) || - (c3n == u3ud(a)) || - (c3n == u3ud(b)) ) - { - return u3m_bail(c3__exit); - } else { - return u3qc_swp(a, b); - } - } - - u3_noun - u3kc_swp(u3_atom a, - u3_atom b) - { - u3_noun res = u3qc_swp(a, b); - u3z(a); u3z(b); - return res; - } +u3_noun +u3kc_swp(u3_atom a, + u3_atom b) +{ + u3_noun pro = u3qc_swp(a, b); + u3z(a); u3z(b); + return pro; +} diff --git a/pkg/urbit/jets/e/trip.c b/pkg/urbit/jets/e/trip.c index 2c37aa2747..6f986cb7c9 100644 --- a/pkg/urbit/jets/e/trip.c +++ b/pkg/urbit/jets/e/trip.c @@ -3,33 +3,28 @@ */ #include "all.h" +u3_noun +u3qe_trip(u3_atom a) +{ + return u3qc_rip(3, 1, a); +} -/* functions -*/ - u3_noun - u3qe_trip(u3_atom a) - { - if ( c3n == u3ud(a) ) { - return u3m_bail(c3__exit); - } - return u3qc_rip(3, a); - } - u3_noun - u3we_trip(u3_noun cor) - { - u3_noun a; +u3_noun +u3we_trip(u3_noun cor) +{ + u3_noun a = u3x_at(u3x_sam, cor); - if ( (u3_none == (a = u3r_at(u3x_sam, cor))) ) { - return u3m_bail(c3__fail); - } else { - return u3qe_trip(a); - } + if ( c3n == u3ud(a) ) { + return u3m_bail(c3__exit); } - u3_atom - u3ke_trip(u3_noun a) - { - u3_atom b = u3qe_trip(a); - u3z(a); - return b; - } + return u3qe_trip(a); +} + +u3_atom +u3ke_trip(u3_noun a) +{ + u3_atom pro = u3qe_trip(a); + u3z(a); + return pro; +} diff --git a/pkg/urbit/noun/retrieve.c b/pkg/urbit/noun/retrieve.c index a279aa20e7..874b73d874 100644 --- a/pkg/urbit/noun/retrieve.c +++ b/pkg/urbit/noun/retrieve.c @@ -805,6 +805,30 @@ u3r_bush(u3_noun a, } } +/* u3r_bite(): retrieve/default $bloq and $step from $bite. +*/ +c3_o +u3r_bite(u3_noun bite, u3_atom* bloq, u3_atom *step) +{ + u3_noun hed, tal; + + if ( c3n == u3r_cell(bite, &hed, &tal) ) { + *bloq = bite; + *step = 1; + return c3y; + } + else if ( (c3n == u3a_is_atom(hed)) + || (c3n == u3a_is_atom(tal)) ) + { + return c3n; + } + else { + *bloq = hed; + *step = tal; + return c3y; + } +} + /* u3r_cell(): ** ** Factor (a) as a cell (b c). diff --git a/pkg/urbit/noun/xtract.c b/pkg/urbit/noun/xtract.c index 0d5deaf786..dd3fd0f9d4 100644 --- a/pkg/urbit/noun/xtract.c +++ b/pkg/urbit/noun/xtract.c @@ -39,6 +39,16 @@ u3x_mean(u3_noun som, ...) } } +/* u3x_bite(): xtract/default $bloq and $step from $bite. +*/ +void +u3x_bite(u3_noun bite, u3_atom* bloq, u3_atom *step) +{ + if ( c3n == u3r_bite(bite, bloq, step) ) { + u3m_bail(c3__exit); + } +} + /* u3x_cell(): ** ** Divide `a` as a cell `[b c]`. From 0420dad4432af52f56ee52818d223b77df09e10b Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 1 Dec 2020 17:56:45 -0800 Subject: [PATCH 851/933] hoon: removes +repn and +ripn --- pkg/arvo/lib/base64.hoon | 4 ++-- pkg/arvo/sys/hoon.hoon | 17 ----------------- pkg/arvo/sys/zuse.hoon | 2 +- pkg/arvo/tests/sys/hoon/bits.hoon | 24 ++++++++++++------------ 4 files changed, 15 insertions(+), 32 deletions(-) diff --git a/pkg/arvo/lib/base64.hoon b/pkg/arvo/lib/base64.hoon index aa58874195..c280c948ed 100644 --- a/pkg/arvo/lib/base64.hoon +++ b/pkg/arvo/lib/base64.hoon @@ -33,7 +33,7 @@ =/ atom-word-width (div-ceil atom-bit-width wid) =/ rslt-word-width (div-ceil octs-bit-width wid) =/ pad (sub rslt-word-width atom-word-width) - =/ x (ripn wid q.octs) + =/ x (rip [0 wid] q.octs) %+ weld x (reap pad 0) :: @@ -128,6 +128,6 @@ =/ len (sub (mul 3 (div (add lat dif) 4)) dif) :+ ~ len %+ swp 3 - (repn 6 (flop (weld dat (reap dif 0)))) + (rep [0 6] (flop (weld dat (reap dif 0)))) -- -- diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index ed49c71450..8e68085b6a 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -901,14 +901,6 @@ %+ add $(i +(i), b t.b) (lsh bloq (mul step i) (end bloq step i.b)) :: -++ repn - ~/ %repn - |= [bits=@ud x=(list @)] - =| c=@ud - |- ^- @ - ?~ x 0 - (add (lsh 0 (mul bits c) (end 0 bits i.x)) $(c +(c), x t.x)) -:: ++ rev :: reverses block order, accounting for leading zeroes :: @@ -923,15 +915,6 @@ (sub len (met boz dat)) (swp boz dat) :: -:: Like `rip` but produces n-bit blocks instead of 2^n bit blocks. -:: -++ ripn - ~/ %ripn - |= [bits=@ud x=@] - ^- (list @) - ?: =(0 x) ~ - [(end 0 bits x) $(x (rsh 0 bits x))] -:: ++ rip :: disassemble ~/ %rip |= [a=bite b=@] diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index 26f665dafa..4dc0b42289 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -6192,7 +6192,7 @@ ++ rule %+ cook |= a=(list @) ^- octs - [(add (dvr (lent a) 2)) (repn 4 (flop a))] + [(add (dvr (lent a) 2)) (rep [0 4] (flop a))] (star hit) -- :: :: ++en-base64:mimes: diff --git a/pkg/arvo/tests/sys/hoon/bits.hoon b/pkg/arvo/tests/sys/hoon/bits.hoon index 7f536ad8b2..474837b3ab 100644 --- a/pkg/arvo/tests/sys/hoon/bits.hoon +++ b/pkg/arvo/tests/sys/hoon/bits.hoon @@ -7,49 +7,49 @@ :: %+ expect-eq !> ~[0x3 0x7 0x7] - !> (flop (ripn 3 0xff)) + !> (flop (rip [0 3] 0xff)) %+ expect-eq !> ~[0x1 0xee 0xff] - !> (flop (ripn 8 0x1.eeff)) + !> (flop (rip [0 8] 0x1.eeff)) %+ expect-eq !> ~[0x1 0xe 0xe 0xf 0xf] - !> (flop (ripn 4 0x1.eeff)) + !> (flop (rip [0 4] 0x1.eeff)) :: :: Typical use-cases :: %+ expect-eq !> ~[0x1 0x23.4567 0x89.abcd] - !> (flop (ripn 24 0x1.2345.6789.abcd)) + !> (flop (rip [0 24] 0x1.2345.6789.abcd)) :: :: Edge cases :: %+ expect-eq !> ~ - !> (flop (ripn 31 0x0)) + !> (flop (rip [0 31] 0x0)) %+ expect-eq !> ~ - !> (flop (ripn 1 0x0)) + !> (flop (rip [0 1] 0x0)) :: :: Word boundaries :: %+ expect-eq !> ~[0x7fff.ffff] - !> (flop (ripn 31 0x7fff.ffff)) + !> (flop (rip [0 31] 0x7fff.ffff)) %+ expect-eq !> ~[0x1 0x7fff.ffff] - !> (flop (ripn 31 0xffff.ffff)) + !> (flop (rip [0 31] 0xffff.ffff)) %+ expect-eq !> ~[0x3 0x7fff.ffff] - !> (flop (ripn 31 0x1.ffff.ffff)) + !> (flop (rip [0 31] 0x1.ffff.ffff)) %+ expect-eq !> ~[0x3 0x7fff.ffff 0x7fff.ffff] - !> (flop (ripn 31 0xffff.ffff.ffff.ffff)) + !> (flop (rip [0 31] 0xffff.ffff.ffff.ffff)) %+ expect-eq !> ~[0x1 0x1.ffff 0x1.ffff] - !> (flop (ripn 17 0x7.ffff.ffff)) + !> (flop (rip [0 17] 0x7.ffff.ffff)) %+ expect-eq !> ~[0x123 0x456 0x789 0xabc 0xdef 0x12 0x345 0x678] - !> (flop (ripn 12 0x1234.5678.9abc.def0.1234.5678)) + !> (flop (rip [0 12] 0x1234.5678.9abc.def0.1234.5678)) == :: -- From 50f8650105e96514715f96b37660aa560ffbf286 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 1 Dec 2020 18:03:02 -0800 Subject: [PATCH 852/933] u3: removes +repn and +ripn --- pkg/urbit/include/jets/w.h | 2 - pkg/urbit/jets/c/repn.c | 113 ------------------------------------- pkg/urbit/jets/c/ripn.c | 100 -------------------------------- pkg/urbit/jets/tree.c | 13 +---- 4 files changed, 1 insertion(+), 227 deletions(-) delete mode 100644 pkg/urbit/jets/c/repn.c delete mode 100644 pkg/urbit/jets/c/ripn.c diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index ab953abb0f..8065457fd2 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -69,8 +69,6 @@ u3_noun u3wc_rep(u3_noun); u3_noun u3wc_rev(u3_noun); u3_noun u3wc_rip(u3_noun); - u3_noun u3wc_repn(u3_noun); - u3_noun u3wc_ripn(u3_noun); u3_noun u3wc_rsh(u3_noun); u3_noun u3wc_swp(u3_noun); u3_noun u3wc_sqt(u3_noun); diff --git a/pkg/urbit/jets/c/repn.c b/pkg/urbit/jets/c/repn.c deleted file mode 100644 index 4b9c694357..0000000000 --- a/pkg/urbit/jets/c/repn.c +++ /dev/null @@ -1,113 +0,0 @@ -#include "all.h" - -/* - Get the lowest `n` bits of a word `w` using a bitmask. -*/ -#define TAKEBITS(n,w) \ - ((n)==32) ? (w) : \ - ((n)==0) ? 0 : \ - ((w) & ((1 << (n)) - 1)) - -/* - Divide, rounding up. -*/ -#define DIVCEIL(x,y) \ - (x==0) ? 0 : \ - 1 + ((x - 1) / y); - -u3_noun -u3qc_repn(u3_atom bits, u3_noun blox) -{ - if ( (c3n == u3a_is_cat(bits) || bits==0 || bits>31) ) { - return u3m_bail(c3__fail); - } - - // - // Calculate input and output size. - // - c3_w num_blox_w = u3qb_lent(blox); - c3_w bit_widt_w = num_blox_w * bits; - c3_w wor_widt_w = DIVCEIL(bit_widt_w, 32); - u3i_slab sab_u; - u3i_slab_bare(&sab_u, 5, wor_widt_w); - - // - // Fill the atom buffer with bits from each block. - // - // Bits are pushed into the `acc_w` register and flushed to the buffer - // once full. - // - // acc_w register - // use_w number of register bits filled (used) - // cur_w next buffer word to flush into. - // - { - c3_w acc_w=0, use_w=0, *cur_w=sab_u.buf_w; - -# define FLUSH() *cur_w++=acc_w; acc_w=use_w=0 -# define SLICE(sz,off,val) TAKEBITS(sz, val) << off - - for (c3_w i=0; i> rem_in_acc_w; - FLUSH(); - } - } - } - - // - // If the last word isn't fully used, it will still need to be - // flushed. - // - if (use_w) { - FLUSH(); - } - } - - return u3i_slab_mint(&sab_u); -} - -u3_noun -u3wc_repn(u3_noun cor) -{ - u3_noun bits, blox; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &bits, u3x_sam_3, &blox, 0)) || - (c3n == u3ud(bits)) ) - { - return u3m_bail(c3__exit); - } - - return u3qc_repn(bits, blox); -} - -u3_noun -u3kc_repn(u3_atom bits, u3_atom blox) -{ - u3_noun res = u3qc_repn(bits, blox); - u3z(bits); u3z(blox); - return res; -} diff --git a/pkg/urbit/jets/c/ripn.c b/pkg/urbit/jets/c/ripn.c deleted file mode 100644 index e7a54a0f78..0000000000 --- a/pkg/urbit/jets/c/ripn.c +++ /dev/null @@ -1,100 +0,0 @@ -#include "all.h" - -/* - Get the lowest `n` bits of a word `w` using a bitmask. -*/ -#define TAKEBITS(n,w) \ - ((n)==32) ? (w) : \ - ((n)==0) ? 0 : \ - ((w) & ((1 << (n)) - 1)) - -/* - Divide, rounding up. -*/ -#define DIVCEIL(x,y) \ - (x==0) ? 0 : \ - 1 + ((x - 1) / y); - -/* - `ripn` breaks `atom` into a list of blocks, of bit-width `bits`. The - resulting list will be least-significant block first. - - XX TODO This only handles cases where the bit-width is <= 32. - - For each block we produce, we need to grab the relevant words inside - `atom`, so we first compute their indicies. - - `ins_idx` is the word-index of the least-significant word we - care about, and `sig_idx` is the word after that. - - Next we grab those words (`ins_word` and `sig_word`) from the atom - using `u3r_word`. Note that `sig_idx` might be out-of-bounds for the - underlying array of `atom`, but `u3r_word` returns 0 in that case, - which is exatly what we want. - - Now, we need to grab the relevant bits out of both words, and combine - them. `bits_rem_in_ins_word` is the number of remaining (insignificant) - bits in `ins_word`, `nbits_ins` is the number of bits we want from the - less-significant word, and `nbits_sig` from the more-significant one. - - Take the least significant `nbits_sig` bits from `sig_word`, and take - the slice we care about from `ins_word`. In order to take that slice, - we drop `bits_rem_in_ins_word` insignificant bits, and then take the - `nbits_sig` most-significant bits. - - Last, we slice out those bits from the two words, combine them into - one word, and cons them onto the front of the result. -*/ -u3_noun u3qc_ripn(u3_atom bits, u3_atom atom) { - if ( !_(u3a_is_cat(bits) || bits==0 || bits>31) ) { - return u3m_bail(c3__fail); - } - - c3_w bit_width = u3r_met(0, atom); - c3_w num_blocks = DIVCEIL(bit_width, bits); - - u3_noun res = u3_nul; - - for ( c3_w blk = 0; blk < num_blocks; blk++ ) { - c3_w next_blk = blk + 1; - c3_w blks_rem = num_blocks - next_blk; - c3_w bits_rem = blks_rem * bits; - c3_w ins_idx = bits_rem / 32; - c3_w sig_idx = ins_idx + 1; - - c3_w bits_rem_in_ins_word = bits_rem % 32; - - c3_w ins_word = u3r_word(ins_idx, atom); - c3_w sig_word = u3r_word(sig_idx, atom); - c3_w nbits_ins = c3_min(bits, 32 - bits_rem_in_ins_word); - c3_w nbits_sig = bits - nbits_ins; - - c3_w ins_word_bits = TAKEBITS(nbits_ins, ins_word >> bits_rem_in_ins_word); - c3_w sig_word_bits = TAKEBITS(nbits_sig, sig_word); - - c3_w item = ins_word_bits | (sig_word_bits << nbits_ins); - - res = u3nc(item, res); - } - - return res; -} - -u3_noun u3wc_ripn(u3_noun cor) { - u3_noun bits, atom; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &bits, u3x_sam_3, &atom, 0)) || - (c3n == u3ud(bits)) || - (c3n == u3ud(atom)) ) - { - return u3m_bail(c3__exit); - } - - return u3qc_ripn(bits, atom); -} - -u3_noun u3kc_ripn(u3_atom bits, u3_atom atom) { - u3_noun res = u3qc_ripn(bits, atom); - u3z(bits), u3z(atom); - return res; -} diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 057c4f7a19..c3d6d680a6 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -2,7 +2,7 @@ To generate the hashes, take the sha256 of the jammed battery. For example: ``` - > `@ux`(shax (jam -:ripn)) + > `@ux`(shax (jam -:rip)) 0x2759.a693.1e9e.f9a5.2c8e.ee43.1088.43d9.4d39.32a6.b04f.86cb.6ba1.5553.4329.3a28 ``` @@ -1572,15 +1572,6 @@ static c3_c* _141_two_rip_ha[] = { "e8e0b834aded0d2738bcf38a93bf373d412a51e0cee7f274277a6393e634a65e", 0 }; -static u3j_harm _141_two_repn_a[] = {{".2", u3wc_repn, c3y}, {}}; -static c3_c* _141_two_repn_ha[] = { - 0 -}; -static u3j_harm _141_two_ripn_a[] = {{".2", u3wc_ripn, c3y}, {}}; -static c3_c* _141_two_ripn_ha[] = { - "2759a6931e9ef9a52c8eee43108843d94d3932a6b04f86cb6ba1555343293a28", - 0 -}; static u3j_harm _141_two_rsh_a[] = {{".2", u3wc_rsh, c3y}, {}}; static c3_c* _141_two_rsh_ha[] = { "a401145b4c11ec8d17a729fe30f06c295865ffed1b970b0a788f0fec1ed0a703", @@ -1868,8 +1859,6 @@ static u3j_core _141_two_d[] = { "rep", 7, _141_two_rep_a, 0, _141_two_rep_ha }, { "rev", 7, _141_two_rev_a, 0, _141_two_rev_ha }, { "rip", 7, _141_two_rip_a, 0, _141_two_rip_ha }, - { "repn", 7, _141_two_repn_a, 0, _141_two_repn_ha }, - { "ripn", 7, _141_two_ripn_a, 0, _141_two_ripn_ha }, { "rsh", 7, _141_two_rsh_a, 0, _141_two_rsh_ha }, { "swp", 7, _141_two_swp_a, 0, _141_two_swp_ha }, { "rub", 7, _141_two_rub_a, 0, _141_two_rub_ha }, From 2cf1c656bf4df978cc3935b0b0de5fc702b95efe Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 1 Dec 2020 18:05:42 -0800 Subject: [PATCH 853/933] pill: solid/ivory --- bin/ivory.pill | 4 ++-- bin/solid.pill | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/ivory.pill b/bin/ivory.pill index 5c7fabd885..925ed6d0ae 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:85a4e1625d528b5fdc88faeff4fd288a23d6fbf1c11a846fc8f8d5b3cd38370f -size 2118873 +oid sha256:6d12c44e418116ade175b55f167b212fd6076efd548edcdfd066ad23317fa6cc +size 2217886 diff --git a/bin/solid.pill b/bin/solid.pill index bdbcb8fa4b..b9082fbeeb 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b3e9d1637efea5862a114ce320f6e14afeb1f9f418428e0490d9c079a9becc56 -size 6712875 +oid sha256:2c3801e81d414940be19e365b1694f8e4aa1760e413852cbc1964f5bdff863ff +size 6808573 From 12bf28e2c8578be2b837e1b4631390806567d7d9 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 30 Nov 2020 17:11:06 -0800 Subject: [PATCH 854/933] hoon: adds +sew, inverse of +cut --- pkg/arvo/sys/hoon.hoon | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 8e68085b6a..effda325f6 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -928,6 +928,15 @@ |= [a=bloq b=step c=@] (div c (bex (mul (bex a) b))) :: +++ sew :: stitch into + ~/ %sew + |= [a=bloq [b=step c=step d=@] e=@] + ^- @ + %+ add + (can a b^e c^d ~) + =/ f (add b c) + (lsh a f (rsh a f e)) +:: ++ swp :: naive rev bloq order ~/ %swp |= [a=bloq b=@] From 3f71826d6ba317f62098b63f19af05a156e9be6d Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 30 Nov 2020 14:32:40 -0800 Subject: [PATCH 855/933] hoon: adds atom map gates +run and +rut --- pkg/arvo/sys/hoon.hoon | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index effda325f6..621664fd6a 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -928,6 +928,16 @@ |= [a=bloq b=step c=@] (div c (bex (mul (bex a) b))) :: +++ run :: +turn into atom + ~/ %run + |= [a=bite b=@ c=$-(@ @)] + (rep a (turn (rip a b) c)) +:: +++ rut :: +turn into list + ~/ %rut + |* [a=bite b=@ c=$-(@ *)] + (turn (rip a b) c) +:: ++ sew :: stitch into ~/ %sew |= [a=bloq [b=step c=step d=@] e=@] From 390e0715485b32bc89c26e233c5b1de44e196c20 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Tue, 1 Dec 2020 18:22:03 -0800 Subject: [PATCH 856/933] lens: fix change lost in merge --- pkg/arvo/app/lens.hoon | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/app/lens.hoon b/pkg/arvo/app/lens.hoon index b550fea74c..b1facd5645 100644 --- a/pkg/arvo/app/lens.hoon +++ b/pkg/arvo/app/lens.hoon @@ -93,13 +93,14 @@ (json-response:gen jon) :: %import-all + ~& %import-all =/ enc (de:base64 base64-jam.source.com) ?~ enc !! - =/ by-app ;;((list [@tas @]) (cue q.u.enc)) + =/ by-app ;;((list [@tas *]) (cue q.u.enc)) :_ this %+ weld (give-simple-payload:app eyre-id not-found:gen) %+ turn by-app - |= [app=@tas data=@] + |= [app=@tas data=*] ^- card:agent:gall [%pass /import-all %agent [our.bowl app] %poke %import !>(data)] == From 181b1fbdb6087858d883ad0a798f67110f5a6533 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 1 Dec 2020 11:58:45 -0800 Subject: [PATCH 857/933] hoon: (and %zuse) use +run and +rut where appropriate --- pkg/arvo/sys/hoon.hoon | 8 ++++---- pkg/arvo/sys/zuse.hoon | 15 +++++---------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 621664fd6a..9180e7ddbe 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -3337,10 +3337,10 @@ =+ i=0 |- ^- @ ?: =(i lex) - (rep 5 (turn (rip 5 hax) net)) + (run 5 hax net) =+ ^= wox =+ dux=(cut 9 [i 1] ful) - =+ wox=(rep 5 (turn (rip 5 dux) net)) + =+ wox=(run 5 dux net) =+ j=16 |- ^- @ ?: =(64 j) @@ -3457,10 +3457,10 @@ =+ i=0 |- ^- @ ?: =(i lex) - (rep 6 (turn (rip 6 hax) net)) + (run 6 hax net) =+ ^= wox =+ dux=(cut 10 [i 1] ful) - =+ wox=(rep 6 (turn (rip 6 dux) net)) + =+ wox=(run 6 dux net) =+ j=16 |- ^- @ ?: =(80 j) diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index 4dc0b42289..e795b89591 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -3999,11 +3999,8 @@ ++ bytes-to-lanes :: flip byte order in blocks of 8 bytes. |= a=@ - %+ can 6 - %+ turn (rip 6 a) - |= b=@ - :- 1 - (lsh 3 (sub 8 (met 3 b)) (swp 3 b)) + %^ run 6 a + |=(b=@ (lsh 3 (sub 8 (met 3 b)) (swp 3 b))) :: ++ lanes-to-bytes :: unflip byte order in blocks of 8 bytes. @@ -5199,10 +5196,7 @@ :: add padding =+ (md5-pad wid dat) :: endianness - =. dat - %+ rep 5 - %+ turn (rip 5 dat) - |=(a=@ (rev 3 4 a)) + =. dat (run 5 dat |=(a=@ (rev 3 4 a))) =* x dat =+ blocks=(div wid 512) =+ fev=~(. fe 5) @@ -8668,7 +8662,8 @@ :: rex: string of hex bytes with leading 0x. |* [rex=@t tys=(list etyp)] =- (decode-arguments - tys) - %+ turn (rip 9 (rsh 3 2 rex)) + %^ rut 9 + (rsh 3 2 rex) (curr rash hex) :: ++ decode-arguments From a8df159496b4bd5e5c604ba3e1bd450e6c4f916c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 1 Dec 2020 18:41:57 -0800 Subject: [PATCH 858/933] pill: solid --- bin/solid.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index b9082fbeeb..b79b67cce1 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2c3801e81d414940be19e365b1694f8e4aa1760e413852cbc1964f5bdff863ff -size 6808573 +oid sha256:9fe3cbf26674fad093ef0d45c3532116c073b04d5cec5c7c06d565d6ab7b94ce +size 6892934 From 1394a9c45571bc67d80b453dcb4c2824d2d5d0f4 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Tue, 1 Dec 2020 22:27:52 -0800 Subject: [PATCH 859/933] kiln: add base-hash and our scries --- pkg/arvo/lib/hood/kiln.hoon | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/arvo/lib/hood/kiln.hoon b/pkg/arvo/lib/hood/kiln.hoon index be04366c7a..be5a2951b6 100644 --- a/pkg/arvo/lib/hood/kiln.hoon +++ b/pkg/arvo/lib/hood/kiln.hoon @@ -1,3 +1,4 @@ +/+ version =, clay =, space:userlib =, format @@ -108,9 +109,11 @@ ++ on-peek |= =path ^- (unit (unit cage)) - ?. ?=([%x %kiln %ota ~] path) - [~ ~] - ``noun+!>(ota) + ?+ path [~ ~] + [%x %kiln %ota ~] ``noun+!>(ota) + [%x %kiln %our ~] ``noun+!>(our) + [%x %kiln %base-hash ~] ``noun+!>((base-hash:version our now)) + == :: ++ poke-commit |= [mon/kiln-commit auto=?] From 0c3edb1ca9ded9e64b48cf48c2db15c56d9fa7f6 Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Tue, 1 Dec 2020 23:03:05 -0800 Subject: [PATCH 860/933] apps: reorder maps, sets, and jugs --- pkg/arvo/app/chat-hook.hoon | 9 ++- pkg/arvo/app/chat-store.hoon | 4 +- pkg/arvo/app/contact-hook.hoon | 12 ++- pkg/arvo/app/contact-store.hoon | 7 +- pkg/arvo/app/graph-store.hoon | 130 ++++++++++++++++++++++++++++++- pkg/arvo/app/group-store.hoon | 54 +++++++++++-- pkg/arvo/app/invite-store.hoon | 7 +- pkg/arvo/app/metadata-hook.hoon | 5 +- pkg/arvo/app/metadata-store.hoon | 23 +++++- pkg/arvo/lib/migrate.hoon | 19 +++++ 10 files changed, 246 insertions(+), 24 deletions(-) create mode 100644 pkg/arvo/lib/migrate.hoon diff --git a/pkg/arvo/app/chat-hook.hoon b/pkg/arvo/app/chat-hook.hoon index a0f7a4ee99..cfeb069ee0 100644 --- a/pkg/arvo/app/chat-hook.hoon +++ b/pkg/arvo/app/chat-hook.hoon @@ -8,7 +8,7 @@ view=chat-view, *group /+ default-agent, verb, dbug, store=chat-store, group-store, grpl=group, - resource + resource, *migrate ~% %chat-hook-top ..is ~ |% +$ card card:agent:gall @@ -704,7 +704,12 @@ ++ poke-import |= arc=* ^- (quip card _state) - =/ sty=state-10 ;;(state-10 arc) + =/ sty=state-10 + :* %10 + (remake-map ;;((tree [path ship]) -.arc)) + ;;(? +<.arc) + (remake-map ;;((tree [path ?]) +>.arc)) + == :_ sty %+ turn ~(tap by synced.sty) |= [=path =ship] diff --git a/pkg/arvo/app/chat-store.hoon b/pkg/arvo/app/chat-store.hoon index e1fab3631c..6726c12e00 100644 --- a/pkg/arvo/app/chat-store.hoon +++ b/pkg/arvo/app/chat-store.hoon @@ -2,7 +2,7 @@ :: :: data store that holds linear sequences of chat messages :: -/+ store=chat-store, default-agent, verb, dbug, group-store +/+ store=chat-store, default-agent, verb, dbug, group-store, *migrate ~% %chat-store-top ..is ~ |% +$ card card:agent:gall @@ -242,7 +242,7 @@ ++ poke-import |= arc=* ^- (quip card _state) - =/ sty=state-3 ;;(state-3 arc) + =/ sty=state-3 [%3 (remake-map ;;((tree [path mailbox:store]) +.arc))] [~ sty] :: ++ handle-create diff --git a/pkg/arvo/app/contact-hook.hoon b/pkg/arvo/app/contact-hook.hoon index 379b8fdc10..87767faac2 100644 --- a/pkg/arvo/app/contact-hook.hoon +++ b/pkg/arvo/app/contact-hook.hoon @@ -8,7 +8,14 @@ *metadata-hook, *metadata-store, *group -/+ *contact-json, default-agent, dbug, group-store, verb, resource, grpl=group +/+ *contact-json, + default-agent, + dbug, + group-store, + verb, + resource, + grpl=group, + *migrate ~% %contact-hook-top ..is ~ |% +$ card card:agent:gall @@ -286,7 +293,8 @@ ++ poke-import |= arc=* ^- (quip card _state) - =/ sty=state-three ;;(state-three arc) + =/ sty=state-three + [%3 (remake-map ;;((tree [path ship]) +<.arc)) ;;(? +>.arc)] :_ sty %+ turn ~(tap by synced.sty) |= [=path =ship] diff --git a/pkg/arvo/app/contact-store.hoon b/pkg/arvo/app/contact-store.hoon index 8ed19228a0..7f4323a640 100644 --- a/pkg/arvo/app/contact-store.hoon +++ b/pkg/arvo/app/contact-store.hoon @@ -2,7 +2,7 @@ :: :: data store that holds group-based contact data :: -/+ *contact-json, default-agent, dbug +/+ *contact-json, default-agent, dbug, *migrate |% +$ card card:agent:gall +$ versioned-state @@ -207,7 +207,10 @@ ++ poke-import |= arc=* ^- (quip card _state) - =/ sty=state-three ;;(state-three arc) + =/ sty=state-three + :- %3 + %- remake-map-of-map + ;;((tree [path (tree [ship contact])]) +.arc) [~ sty] :: ++ handle-create diff --git a/pkg/arvo/app/graph-store.hoon b/pkg/arvo/app/graph-store.hoon index c863a1a0e6..4af84305a0 100644 --- a/pkg/arvo/app/graph-store.hoon +++ b/pkg/arvo/app/graph-store.hoon @@ -1,7 +1,8 @@ :: graph-store [landscape] :: :: -/+ store=graph-store, sigs=signatures, res=resource, default-agent, dbug +/+ store=graph-store, sigs=signatures, res=resource, default-agent, dbug, + *migrate ~% %graph-store-top ..is ~ |% +$ card card:agent:gall @@ -617,7 +618,8 @@ ++ poke-import |= arc=* ^- (quip card _state) - =/ sty ;;(state-2 arc) + |^ + =/ sty=state-2 [%2 (remake-network ;;(tree-network +.arc))] :_ sty %+ turn ~(tap by graphs.sty) |= [rid=resource:store =marked-graph:store] @@ -626,6 +628,130 @@ =/ =cage [%push-hook-action !>([%add rid])] [%pass / %agent [our.bowl %graph-push-hook] %poke cage] (try-rejoin rid 0) + :: + +$ tree-network + $: graphs=tree-graphs + tag-queries=(tree [term (tree resource:store)]) + update-logs=tree-update-logs + archive=tree-graphs + validators=(tree ^mark) + == + +$ tree-graphs (tree [resource:store tree-marked-graph]) + +$ tree-marked-graph [p=tree-graph q=(unit ^mark)] + +$ tree-graph (tree [atom tree-node]) + +$ tree-node [post=tree-post children=tree-internal-graph] + +$ tree-internal-graph + $~ [%empty ~] + $% [%graph p=tree-graph] + [%empty ~] + == + +$ tree-update-logs (tree [resource:store tree-update-log]) + +$ tree-update-log (tree [time tree-logged-update]) + +$ tree-logged-update + $: %0 + p=time + $= q + $% [%add-nodes =resource:store nodes=(tree [index:store tree-node])] + [%remove-nodes =resource:store indices=(tree index:store)] + [%add-signatures =uid:store signatures=tree-signatures] + [%remove-signatures =uid:store signatures=tree-signatures] + == + == + +$ tree-signatures (tree signature:store) + +$ tree-post + $: author=ship + =index:store + time-sent=time + contents=(list content:store) + hash=(unit hash:store) + signatures=tree-signatures + == + :: + ++ remake-network + |= t=tree-network + ^- network:store + :* (remake-graphs graphs.t) + (remake-jug tag-queries.t) + (remake-update-logs update-logs.t) + (remake-graphs archive.t) + (remake-set validators.t) + == + :: + ++ remake-graphs + |= t=tree-graphs + ^- graphs:store + %- remake-map + (~(run by t) remake-marked-graph) + :: + ++ remake-marked-graph + |= t=tree-marked-graph + ^- marked-graph:store + [(remake-graph p.t) q.t] + :: + ++ remake-graph + |= t=tree-graph + ^- graph:store + %+ gas:orm *graph:store + %+ turn ~(tap by t) + |= [a=atom tn=tree-node] + ^- [atom node:store] + [a (remake-node tn)] + :: + ++ remake-internal-graph + |= t=tree-internal-graph + ^- internal-graph:store + ?: ?=(%empty -.t) + [%empty ~] + [%graph (remake-graph p.t)] + :: + ++ remake-node + |= t=tree-node + ^- node:store + :- (remake-post post.t) + (remake-internal-graph children.t) + :: + ++ remake-update-logs + |= t=tree-update-logs + ^- update-logs:store + %- remake-map + (~(run by t) remake-update-log) + :: + ++ remake-update-log + |= t=tree-update-log + ^- update-log:store + =/ ulm ((ordered-map time logged-update:store) gth) + %+ gas:ulm *update-log:store + %+ turn ~(tap by t) + |= [=time tlu=tree-logged-update] + ^- [^time logged-update:store] + [time (remake-logged-update tlu)] + :: + ++ remake-logged-update + |= t=tree-logged-update + ^- logged-update:store + :+ %0 p.t + ?- -.q.t + %add-nodes + :- %add-nodes + :- resource.q.t + %- remake-map + (~(run by nodes.q.t) remake-node) + :: + %remove-nodes + [%remove-nodes resource.q.t (remake-set indices.q.t)] + :: + %add-signatures + [%add-signatures uid.q.t (remake-set signatures.q.t)] + :: + %remove-signatures + [%remove-signatures uid.q.t (remake-set signatures.q.t)] + == + :: + ++ remake-post + |= t=tree-post + ^- post:store + t(signatures (remake-set signatures.t)) + -- :: ++ try-rejoin |= [rid=resource:store nack-count=@] diff --git a/pkg/arvo/app/group-store.hoon b/pkg/arvo/app/group-store.hoon index f61d145699..0a838195e1 100644 --- a/pkg/arvo/app/group-store.hoon +++ b/pkg/arvo/app/group-store.hoon @@ -30,7 +30,7 @@ :: :: /- *group, permission-store, *contact-view -/+ store=group-store, default-agent, verb, dbug, resource +/+ store=group-store, default-agent, verb, dbug, resource, *migrate |% +$ card card:agent:gall :: @@ -285,23 +285,61 @@ ++ poke-import |= arc=* ^- (quip card _state) - =/ sty=state-one ;;(state-one arc) + |^ + =/ sty=state-one + [%1 (remake-groups ;;((tree [resource tree-group]) +.arc))] :_ sty %+ roll ~(tap by groups.sty) - |= [[=resource =group] out=(list card)] - ?: =(entity.resource our.bol) + |= [[rid=resource grp=group] out=(list card)] + ?: =(entity.rid our.bol) %+ weld out - %+ roll ~(tap in members.group) + %+ roll ~(tap in members.grp) |= [recipient=@p out=(list card)] ?: =(recipient our.bol) out :_ out %- poke-contact - :* %invite resource recipient - (crip "Rejoin disconnected group {}/{}") + :* %invite rid recipient + (crip "Rejoin disconnected group {}/{}") == :_ out - (try-rejoin resource 0) + (try-rejoin rid 0) + :: + ++ remake-groups + |= grps=(tree [resource tree-group]) + ^- ^groups + %- remake-map + (~(run by grps) remake-group) + :: + ++ remake-group + |= grp=tree-group + ^- group + %= grp + members (remake-set members.grp) + tags (remake-jug tags.grp) + policy (remake-policy policy.grp) + == + :: + +$ tree-group + $: members=(tree ship) + tags=(tree [tag (tree ship)]) + policy=tree-policy + hidden=? + == + :: + +$ tree-policy + $% [%invite pending=(tree ship)] + [%open ban-ranks=(tree rank:title) banned=(tree ship)] + == + :: + ++ remake-policy + |= pl=tree-policy + ^- policy + ?- -.pl + %invite [%invite (remake-set pending.pl)] + %open [%open (remake-set ban-ranks.pl) (remake-set banned.pl)] + == + -- :: ++ try-rejoin |= [rid=resource nack-count=@ud] diff --git a/pkg/arvo/app/invite-store.hoon b/pkg/arvo/app/invite-store.hoon index 5e504be746..ae74a4e5f0 100644 --- a/pkg/arvo/app/invite-store.hoon +++ b/pkg/arvo/app/invite-store.hoon @@ -1,6 +1,6 @@ :: invite-store [landscape] /- store=invite-store -/+ res=resource, default-agent, dbug +/+ res=resource, default-agent, dbug, *migrate |% +$ card card:agent:gall +$ versioned-state @@ -109,7 +109,10 @@ ++ poke-import |= arc=* ^- (quip card _state) - =/ sty=state-1 ;;(state-1 arc) + =/ sty=state-1 + :- %1 + %- remake-map-of-map + ;;((tree [term (tree [serial:store invite:store])]) +.arc) [~ sty] :: ++ poke-invite-action diff --git a/pkg/arvo/app/metadata-hook.hoon b/pkg/arvo/app/metadata-hook.hoon index 1d3e6dbcef..2558a44816 100644 --- a/pkg/arvo/app/metadata-hook.hoon +++ b/pkg/arvo/app/metadata-hook.hoon @@ -6,7 +6,7 @@ :: /group/%group-path all updates related to this group :: /- *metadata-store, *metadata-hook -/+ default-agent, dbug, verb, grpl=group +/+ default-agent, dbug, verb, grpl=group, *migrate ~% %metadata-hook-top ..is ~ |% +$ card card:agent:gall @@ -196,7 +196,8 @@ ++ poke-import |= arc=* ^- (quip card _state) - =/ sty=state-one ;;(state-one arc) + =/ sty=state-one + [%1 (remake-map ;;((tree [group-path ship]) +.arc))] :_ sty %+ murn ~(tap by synced.sty) |= [=group-path =ship] diff --git a/pkg/arvo/app/metadata-store.hoon b/pkg/arvo/app/metadata-store.hoon index 402e39501d..10ca142d0d 100644 --- a/pkg/arvo/app/metadata-store.hoon +++ b/pkg/arvo/app/metadata-store.hoon @@ -24,7 +24,7 @@ :: /group/%group-path associations for group :: /- *metadata-store, *metadata-hook -/+ *metadata-json, default-agent, verb, dbug, resource +/+ *metadata-json, default-agent, verb, dbug, resource, *migrate |% +$ card card:agent:gall +$ base-state-0 @@ -378,8 +378,27 @@ ++ poke-import |= arc=* ^- (quip card _state) - =/ sty=state-6 ;;(state-6 arc) + |^ + =/ sty=state-6 + [%6 (remake-metadata ;;(tree-metadata +.arc))] [~ sty] + :: + +$ tree-metadata + $: associations=(tree [[group-path md-resource] metadata]) + group-indices=(tree [group-path (tree md-resource)]) + app-indices=(tree [app-name (tree [group-path app-path])]) + resource-indices=(tree [md-resource (tree group-path)]) + == + :: + ++ remake-metadata + |= tm=tree-metadata + ^- base-state-1 + :* (remake-map associations.tm) + (remake-jug group-indices.tm) + (remake-jug app-indices.tm) + (remake-jug resource-indices.tm) + == + -- :: ++ handle-add |= [=group-path =md-resource =metadata] diff --git a/pkg/arvo/lib/migrate.hoon b/pkg/arvo/lib/migrate.hoon new file mode 100644 index 0000000000..2f1d3b0152 --- /dev/null +++ b/pkg/arvo/lib/migrate.hoon @@ -0,0 +1,19 @@ +|% +++ remake-set + |* s=(tree) + (sy ~(tap in s)) +:: +++ remake-map + |* m=(tree) + (my ~(tap by m)) +:: +++ remake-jug + |* j=(tree [* (tree)]) + %- remake-map + (~(run by j) remake-set) +:: +++ remake-map-of-map + |* mm=(tree [* (tree)]) + %- remake-map + (~(run by mm) remake-map) +-- From 1d6a4603457edcd722ad72b9d29bd6ac3de6551b Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Tue, 1 Dec 2020 23:03:05 -0800 Subject: [PATCH 861/933] apps: reorder maps, sets, and jugs --- pkg/arvo/app/chat-hook.hoon | 9 ++- pkg/arvo/app/chat-store.hoon | 4 +- pkg/arvo/app/contact-hook.hoon | 12 ++- pkg/arvo/app/contact-store.hoon | 7 +- pkg/arvo/app/graph-store.hoon | 130 ++++++++++++++++++++++++++++++- pkg/arvo/app/group-store.hoon | 54 +++++++++++-- pkg/arvo/app/invite-store.hoon | 7 +- pkg/arvo/app/metadata-hook.hoon | 5 +- pkg/arvo/app/metadata-store.hoon | 23 +++++- pkg/arvo/lib/migrate.hoon | 19 +++++ 10 files changed, 246 insertions(+), 24 deletions(-) create mode 100644 pkg/arvo/lib/migrate.hoon diff --git a/pkg/arvo/app/chat-hook.hoon b/pkg/arvo/app/chat-hook.hoon index a0f7a4ee99..cfeb069ee0 100644 --- a/pkg/arvo/app/chat-hook.hoon +++ b/pkg/arvo/app/chat-hook.hoon @@ -8,7 +8,7 @@ view=chat-view, *group /+ default-agent, verb, dbug, store=chat-store, group-store, grpl=group, - resource + resource, *migrate ~% %chat-hook-top ..is ~ |% +$ card card:agent:gall @@ -704,7 +704,12 @@ ++ poke-import |= arc=* ^- (quip card _state) - =/ sty=state-10 ;;(state-10 arc) + =/ sty=state-10 + :* %10 + (remake-map ;;((tree [path ship]) -.arc)) + ;;(? +<.arc) + (remake-map ;;((tree [path ?]) +>.arc)) + == :_ sty %+ turn ~(tap by synced.sty) |= [=path =ship] diff --git a/pkg/arvo/app/chat-store.hoon b/pkg/arvo/app/chat-store.hoon index e1fab3631c..6726c12e00 100644 --- a/pkg/arvo/app/chat-store.hoon +++ b/pkg/arvo/app/chat-store.hoon @@ -2,7 +2,7 @@ :: :: data store that holds linear sequences of chat messages :: -/+ store=chat-store, default-agent, verb, dbug, group-store +/+ store=chat-store, default-agent, verb, dbug, group-store, *migrate ~% %chat-store-top ..is ~ |% +$ card card:agent:gall @@ -242,7 +242,7 @@ ++ poke-import |= arc=* ^- (quip card _state) - =/ sty=state-3 ;;(state-3 arc) + =/ sty=state-3 [%3 (remake-map ;;((tree [path mailbox:store]) +.arc))] [~ sty] :: ++ handle-create diff --git a/pkg/arvo/app/contact-hook.hoon b/pkg/arvo/app/contact-hook.hoon index 379b8fdc10..87767faac2 100644 --- a/pkg/arvo/app/contact-hook.hoon +++ b/pkg/arvo/app/contact-hook.hoon @@ -8,7 +8,14 @@ *metadata-hook, *metadata-store, *group -/+ *contact-json, default-agent, dbug, group-store, verb, resource, grpl=group +/+ *contact-json, + default-agent, + dbug, + group-store, + verb, + resource, + grpl=group, + *migrate ~% %contact-hook-top ..is ~ |% +$ card card:agent:gall @@ -286,7 +293,8 @@ ++ poke-import |= arc=* ^- (quip card _state) - =/ sty=state-three ;;(state-three arc) + =/ sty=state-three + [%3 (remake-map ;;((tree [path ship]) +<.arc)) ;;(? +>.arc)] :_ sty %+ turn ~(tap by synced.sty) |= [=path =ship] diff --git a/pkg/arvo/app/contact-store.hoon b/pkg/arvo/app/contact-store.hoon index 8ed19228a0..7f4323a640 100644 --- a/pkg/arvo/app/contact-store.hoon +++ b/pkg/arvo/app/contact-store.hoon @@ -2,7 +2,7 @@ :: :: data store that holds group-based contact data :: -/+ *contact-json, default-agent, dbug +/+ *contact-json, default-agent, dbug, *migrate |% +$ card card:agent:gall +$ versioned-state @@ -207,7 +207,10 @@ ++ poke-import |= arc=* ^- (quip card _state) - =/ sty=state-three ;;(state-three arc) + =/ sty=state-three + :- %3 + %- remake-map-of-map + ;;((tree [path (tree [ship contact])]) +.arc) [~ sty] :: ++ handle-create diff --git a/pkg/arvo/app/graph-store.hoon b/pkg/arvo/app/graph-store.hoon index 1104fb4129..688be9d9cb 100644 --- a/pkg/arvo/app/graph-store.hoon +++ b/pkg/arvo/app/graph-store.hoon @@ -1,7 +1,8 @@ :: graph-store [landscape] :: :: -/+ store=graph-store, sigs=signatures, res=resource, default-agent, dbug +/+ store=graph-store, sigs=signatures, res=resource, default-agent, dbug, + *migrate ~% %graph-store-top ..is ~ |% +$ card card:agent:gall @@ -617,7 +618,8 @@ ++ poke-import |= arc=* ^- (quip card _state) - =/ sty ;;(state-2 arc) + |^ + =/ sty=state-2 [%2 (remake-network ;;(tree-network +.arc))] :_ sty %+ turn ~(tap by graphs.sty) |= [rid=resource:store =marked-graph:store] @@ -626,6 +628,130 @@ =/ =cage [%push-hook-action !>([%add rid])] [%pass / %agent [our.bowl %graph-push-hook] %poke cage] (try-rejoin rid 0) + :: + +$ tree-network + $: graphs=tree-graphs + tag-queries=(tree [term (tree resource:store)]) + update-logs=tree-update-logs + archive=tree-graphs + validators=(tree ^mark) + == + +$ tree-graphs (tree [resource:store tree-marked-graph]) + +$ tree-marked-graph [p=tree-graph q=(unit ^mark)] + +$ tree-graph (tree [atom tree-node]) + +$ tree-node [post=tree-post children=tree-internal-graph] + +$ tree-internal-graph + $~ [%empty ~] + $% [%graph p=tree-graph] + [%empty ~] + == + +$ tree-update-logs (tree [resource:store tree-update-log]) + +$ tree-update-log (tree [time tree-logged-update]) + +$ tree-logged-update + $: %0 + p=time + $= q + $% [%add-nodes =resource:store nodes=(tree [index:store tree-node])] + [%remove-nodes =resource:store indices=(tree index:store)] + [%add-signatures =uid:store signatures=tree-signatures] + [%remove-signatures =uid:store signatures=tree-signatures] + == + == + +$ tree-signatures (tree signature:store) + +$ tree-post + $: author=ship + =index:store + time-sent=time + contents=(list content:store) + hash=(unit hash:store) + signatures=tree-signatures + == + :: + ++ remake-network + |= t=tree-network + ^- network:store + :* (remake-graphs graphs.t) + (remake-jug tag-queries.t) + (remake-update-logs update-logs.t) + (remake-graphs archive.t) + (remake-set validators.t) + == + :: + ++ remake-graphs + |= t=tree-graphs + ^- graphs:store + %- remake-map + (~(run by t) remake-marked-graph) + :: + ++ remake-marked-graph + |= t=tree-marked-graph + ^- marked-graph:store + [(remake-graph p.t) q.t] + :: + ++ remake-graph + |= t=tree-graph + ^- graph:store + %+ gas:orm *graph:store + %+ turn ~(tap by t) + |= [a=atom tn=tree-node] + ^- [atom node:store] + [a (remake-node tn)] + :: + ++ remake-internal-graph + |= t=tree-internal-graph + ^- internal-graph:store + ?: ?=(%empty -.t) + [%empty ~] + [%graph (remake-graph p.t)] + :: + ++ remake-node + |= t=tree-node + ^- node:store + :- (remake-post post.t) + (remake-internal-graph children.t) + :: + ++ remake-update-logs + |= t=tree-update-logs + ^- update-logs:store + %- remake-map + (~(run by t) remake-update-log) + :: + ++ remake-update-log + |= t=tree-update-log + ^- update-log:store + =/ ulm ((ordered-map time logged-update:store) gth) + %+ gas:ulm *update-log:store + %+ turn ~(tap by t) + |= [=time tlu=tree-logged-update] + ^- [^time logged-update:store] + [time (remake-logged-update tlu)] + :: + ++ remake-logged-update + |= t=tree-logged-update + ^- logged-update:store + :+ %0 p.t + ?- -.q.t + %add-nodes + :- %add-nodes + :- resource.q.t + %- remake-map + (~(run by nodes.q.t) remake-node) + :: + %remove-nodes + [%remove-nodes resource.q.t (remake-set indices.q.t)] + :: + %add-signatures + [%add-signatures uid.q.t (remake-set signatures.q.t)] + :: + %remove-signatures + [%remove-signatures uid.q.t (remake-set signatures.q.t)] + == + :: + ++ remake-post + |= t=tree-post + ^- post:store + t(signatures (remake-set signatures.t)) + -- :: ++ try-rejoin |= [rid=resource:store nack-count=@] diff --git a/pkg/arvo/app/group-store.hoon b/pkg/arvo/app/group-store.hoon index f61d145699..0a838195e1 100644 --- a/pkg/arvo/app/group-store.hoon +++ b/pkg/arvo/app/group-store.hoon @@ -30,7 +30,7 @@ :: :: /- *group, permission-store, *contact-view -/+ store=group-store, default-agent, verb, dbug, resource +/+ store=group-store, default-agent, verb, dbug, resource, *migrate |% +$ card card:agent:gall :: @@ -285,23 +285,61 @@ ++ poke-import |= arc=* ^- (quip card _state) - =/ sty=state-one ;;(state-one arc) + |^ + =/ sty=state-one + [%1 (remake-groups ;;((tree [resource tree-group]) +.arc))] :_ sty %+ roll ~(tap by groups.sty) - |= [[=resource =group] out=(list card)] - ?: =(entity.resource our.bol) + |= [[rid=resource grp=group] out=(list card)] + ?: =(entity.rid our.bol) %+ weld out - %+ roll ~(tap in members.group) + %+ roll ~(tap in members.grp) |= [recipient=@p out=(list card)] ?: =(recipient our.bol) out :_ out %- poke-contact - :* %invite resource recipient - (crip "Rejoin disconnected group {}/{}") + :* %invite rid recipient + (crip "Rejoin disconnected group {}/{}") == :_ out - (try-rejoin resource 0) + (try-rejoin rid 0) + :: + ++ remake-groups + |= grps=(tree [resource tree-group]) + ^- ^groups + %- remake-map + (~(run by grps) remake-group) + :: + ++ remake-group + |= grp=tree-group + ^- group + %= grp + members (remake-set members.grp) + tags (remake-jug tags.grp) + policy (remake-policy policy.grp) + == + :: + +$ tree-group + $: members=(tree ship) + tags=(tree [tag (tree ship)]) + policy=tree-policy + hidden=? + == + :: + +$ tree-policy + $% [%invite pending=(tree ship)] + [%open ban-ranks=(tree rank:title) banned=(tree ship)] + == + :: + ++ remake-policy + |= pl=tree-policy + ^- policy + ?- -.pl + %invite [%invite (remake-set pending.pl)] + %open [%open (remake-set ban-ranks.pl) (remake-set banned.pl)] + == + -- :: ++ try-rejoin |= [rid=resource nack-count=@ud] diff --git a/pkg/arvo/app/invite-store.hoon b/pkg/arvo/app/invite-store.hoon index 5e504be746..ae74a4e5f0 100644 --- a/pkg/arvo/app/invite-store.hoon +++ b/pkg/arvo/app/invite-store.hoon @@ -1,6 +1,6 @@ :: invite-store [landscape] /- store=invite-store -/+ res=resource, default-agent, dbug +/+ res=resource, default-agent, dbug, *migrate |% +$ card card:agent:gall +$ versioned-state @@ -109,7 +109,10 @@ ++ poke-import |= arc=* ^- (quip card _state) - =/ sty=state-1 ;;(state-1 arc) + =/ sty=state-1 + :- %1 + %- remake-map-of-map + ;;((tree [term (tree [serial:store invite:store])]) +.arc) [~ sty] :: ++ poke-invite-action diff --git a/pkg/arvo/app/metadata-hook.hoon b/pkg/arvo/app/metadata-hook.hoon index 1d3e6dbcef..2558a44816 100644 --- a/pkg/arvo/app/metadata-hook.hoon +++ b/pkg/arvo/app/metadata-hook.hoon @@ -6,7 +6,7 @@ :: /group/%group-path all updates related to this group :: /- *metadata-store, *metadata-hook -/+ default-agent, dbug, verb, grpl=group +/+ default-agent, dbug, verb, grpl=group, *migrate ~% %metadata-hook-top ..is ~ |% +$ card card:agent:gall @@ -196,7 +196,8 @@ ++ poke-import |= arc=* ^- (quip card _state) - =/ sty=state-one ;;(state-one arc) + =/ sty=state-one + [%1 (remake-map ;;((tree [group-path ship]) +.arc))] :_ sty %+ murn ~(tap by synced.sty) |= [=group-path =ship] diff --git a/pkg/arvo/app/metadata-store.hoon b/pkg/arvo/app/metadata-store.hoon index 402e39501d..10ca142d0d 100644 --- a/pkg/arvo/app/metadata-store.hoon +++ b/pkg/arvo/app/metadata-store.hoon @@ -24,7 +24,7 @@ :: /group/%group-path associations for group :: /- *metadata-store, *metadata-hook -/+ *metadata-json, default-agent, verb, dbug, resource +/+ *metadata-json, default-agent, verb, dbug, resource, *migrate |% +$ card card:agent:gall +$ base-state-0 @@ -378,8 +378,27 @@ ++ poke-import |= arc=* ^- (quip card _state) - =/ sty=state-6 ;;(state-6 arc) + |^ + =/ sty=state-6 + [%6 (remake-metadata ;;(tree-metadata +.arc))] [~ sty] + :: + +$ tree-metadata + $: associations=(tree [[group-path md-resource] metadata]) + group-indices=(tree [group-path (tree md-resource)]) + app-indices=(tree [app-name (tree [group-path app-path])]) + resource-indices=(tree [md-resource (tree group-path)]) + == + :: + ++ remake-metadata + |= tm=tree-metadata + ^- base-state-1 + :* (remake-map associations.tm) + (remake-jug group-indices.tm) + (remake-jug app-indices.tm) + (remake-jug resource-indices.tm) + == + -- :: ++ handle-add |= [=group-path =md-resource =metadata] diff --git a/pkg/arvo/lib/migrate.hoon b/pkg/arvo/lib/migrate.hoon new file mode 100644 index 0000000000..2f1d3b0152 --- /dev/null +++ b/pkg/arvo/lib/migrate.hoon @@ -0,0 +1,19 @@ +|% +++ remake-set + |* s=(tree) + (sy ~(tap in s)) +:: +++ remake-map + |* m=(tree) + (my ~(tap by m)) +:: +++ remake-jug + |* j=(tree [* (tree)]) + %- remake-map + (~(run by j) remake-set) +:: +++ remake-map-of-map + |* mm=(tree [* (tree)]) + %- remake-map + (~(run by mm) remake-map) +-- From 4f9cba2bafb748c3912e8dff5f0aa918627fd1e3 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 1 Dec 2020 20:42:38 -0800 Subject: [PATCH 862/933] hoon: adds +new-end, switches all +end call sites --- pkg/arvo/app/chat-hook.hoon | 2 +- pkg/arvo/app/dbug.hoon | 2 +- pkg/arvo/app/dojo.hoon | 8 +- pkg/arvo/app/file-server.hoon | 2 +- pkg/arvo/app/glob.hoon | 4 +- pkg/arvo/app/hood.hoon | 2 +- pkg/arvo/gen/help.hoon | 2 +- pkg/arvo/gen/hood/claz-invites.hoon | 2 +- pkg/arvo/gen/hood/moon.hoon | 2 +- pkg/arvo/gen/key.hoon | 4 +- pkg/arvo/gen/reload-event.hoon | 4 +- pkg/arvo/lib/bip32.hoon | 4 +- pkg/arvo/lib/bip39.hoon | 2 +- pkg/arvo/lib/der.hoon | 4 +- pkg/arvo/lib/hood/drum.hoon | 2 +- pkg/arvo/lib/hood/helm.hoon | 4 +- pkg/arvo/lib/keygen.hoon | 4 +- pkg/arvo/lib/language-server/complete.hoon | 10 +- pkg/arvo/lib/language-server/easy-print.hoon | 2 +- pkg/arvo/lib/old-phon.hoon | 8 +- pkg/arvo/lib/pkcs.hoon | 2 +- pkg/arvo/lib/ring.hoon | 8 +- pkg/arvo/lib/test/runner.hoon | 2 +- pkg/arvo/mar/eth/txs.hoon | 2 +- pkg/arvo/mar/udon.hoon | 2 +- pkg/arvo/mar/umd.hoon | 2 +- pkg/arvo/sys/arvo.hoon | 2 +- pkg/arvo/sys/hoon.hoon | 122 ++++++++++--------- pkg/arvo/sys/vane/ames.hoon | 24 ++-- pkg/arvo/sys/vane/clay.hoon | 4 +- pkg/arvo/sys/vane/gall.hoon | 2 +- pkg/arvo/sys/vane/jael.hoon | 2 +- pkg/arvo/sys/zuse.hoon | 88 ++++++------- pkg/arvo/ted/aqua/eyre-azimuth.hoon | 2 +- pkg/arvo/ted/eth/send-txs.hoon | 8 +- pkg/arvo/ted/test.hoon | 2 +- pkg/arvo/tests/sys/zuse/crypto/ripemd.hoon | 2 +- 37 files changed, 178 insertions(+), 172 deletions(-) diff --git a/pkg/arvo/app/chat-hook.hoon b/pkg/arvo/app/chat-hook.hoon index 340d1e6c14..e15e72b606 100644 --- a/pkg/arvo/app/chat-hook.hoon +++ b/pkg/arvo/app/chat-hook.hoon @@ -558,7 +558,7 @@ :: correctly initialized, no need to do cleanup :: ~ - ?. =((end 3 4 i.t.path) 'dm--') + ?. =((new-end [3 4] i.t.path) 'dm--') ~ :- =- [%pass /fixdm %agent [our.bol %chat-view] %poke %chat-view-action -] !> ^- action:view diff --git a/pkg/arvo/app/dbug.hoon b/pkg/arvo/app/dbug.hoon index dd4372c3f2..fb0c81a4d7 100644 --- a/pkg/arvo/app/dbug.hoon +++ b/pkg/arvo/app/dbug.hoon @@ -362,7 +362,7 @@ (gth expiry-time.a expiry-time.b) |= [cookie=@uv session:eyre] %- pairs - :~ 'cookie'^s+(end 3 4 (rsh 3 2 (scot %x (shax cookie)))) + :~ 'cookie'^s+(new-end [3 4] (rsh 3 2 (scot %x (shax cookie)))) 'expiry'^(time expiry-time) 'channels'^(numb ~(wyt in channels)) == diff --git a/pkg/arvo/app/dojo.hoon b/pkg/arvo/app/dojo.hoon index c34dd8ea89..04a3b7eb9f 100644 --- a/pkg/arvo/app/dojo.hoon +++ b/pkg/arvo/app/dojo.hoon @@ -1340,7 +1340,7 @@ %+ murn ~(tap by dir:.^(arch %cy pax)) |= [=term ~] ^- (unit [^term tank]) - ?. =(app (end 3 (met 3 app) term)) + ?. =(app (new-end [3 (met 3 app)] term)) ~ ?~ =<(fil .^(arch %cy (weld pax ~[term %hoon]))) ~ @@ -1352,7 +1352,7 @@ %+ murn ~(tap by var) |= [name=term =cage] ^- (unit [term tank]) - ?. =(variable (end 3 (met 3 variable) name)) + ?. =(variable (new-end [3 (met 3 variable)] name)) ~ `[name (sell q.cage)] :: @@ -1371,7 +1371,7 @@ %+ murn ~(tap by dir:.^(arch %cy pfix)) |= [=term ~] - ?. =(gen (end 3 (met 3 gen) term)) + ?. =(gen (new-end [3 (met 3 gen)] term)) ~ ?~ =<(fil .^(arch %cy (weld pfix ~[term %hoon]))) ~ @@ -1386,7 +1386,7 @@ %+ murn ~(tap by dir:.^(arch %cy pax)) |= [=term ~] - ?. =(gen (end 3 (met 3 gen) term)) + ?. =(gen (new-end [3 (met 3 gen)] term)) ~ ?~ =<(fil .^(arch %cy (weld pax ~[term %hoon]))) ~ diff --git a/pkg/arvo/app/file-server.hoon b/pkg/arvo/app/file-server.hoon index 9156cc7340..9c8d334ace 100644 --- a/pkg/arvo/app/file-server.hoon +++ b/pkg/arvo/app/file-server.hoon @@ -323,7 +323,7 @@ ?+ path (on-peek:def path) [%x %clay %base %hash ~] =/ versions (base-hash:version [our now]:bowl) - ``hash+!>(?~(versions 0v0 (end 0 25 i.versions))) + ``hash+!>(?~(versions 0v0 (new-end [0 25] i.versions))) == ++ on-agent on-agent:def ++ on-fail on-fail:def diff --git a/pkg/arvo/app/glob.hoon b/pkg/arvo/app/glob.hoon index 472f938331..94618d032e 100644 --- a/pkg/arvo/app/glob.hoon +++ b/pkg/arvo/app/glob.hoon @@ -94,8 +94,8 @@ %- ~(rep by dir) |= [[file=@t ~] out=(unit @t)] ?^ out out - ?. ?& =((end 3 6 file) 'index.') - !=('sj.' (end 3 3 (swp 3 file))) + ?. ?& =((new-end [3 6] file) 'index.') + !=('sj.' (new-end [3 3] (swp 3 file))) == out ``@t`(rsh 3 6 file) diff --git a/pkg/arvo/app/hood.hoon b/pkg/arvo/app/hood.hoon index 7ea33fe6b9..d62a98261a 100644 --- a/pkg/arvo/app/hood.hoon +++ b/pkg/arvo/app/hood.hoon @@ -72,7 +72,7 @@ |= [=mark =vase] ^- step:agent:gall |^ - =/ fin (end 3 4 mark) + =/ fin (new-end [3 4] mark) ?: =(%drum fin) poke-drum ?: =(%helm fin) poke-helm ?: =(%kiln fin) poke-kiln diff --git a/pkg/arvo/gen/help.hoon b/pkg/arvo/gen/help.hoon index 2116568b08..c73ce8dd55 100644 --- a/pkg/arvo/gen/help.hoon +++ b/pkg/arvo/gen/help.hoon @@ -27,7 +27,7 @@ == =/ c (to-wain:format a) ?~ c "~" - ?. =(':: ' (end 3 4 i.c)) + ?. =(':: ' (new-end [3 4] i.c)) "" (trip i.c) :: diff --git a/pkg/arvo/gen/hood/claz-invites.hoon b/pkg/arvo/gen/hood/claz-invites.hoon index b09393389f..9009c2a6dc 100644 --- a/pkg/arvo/gen/hood/claz-invites.hoon +++ b/pkg/arvo/gen/hood/claz-invites.hoon @@ -28,7 +28,7 @@ %+ turn (gulf min-child max-child) |= child=@ud =/ who=ship (cat 4 star child) -=/ ticket=@q (end 3 8 (shas who eny)) +=/ ticket=@q (new-end [3 8] (shas who eny)) =/ owner=address =< addr.keys ::NOTE ~zod because invite wallet convention diff --git a/pkg/arvo/gen/hood/moon.hoon b/pkg/arvo/gen/hood/moon.hoon index 9520b8b182..fb841b7836 100644 --- a/pkg/arvo/gen/hood/moon.hoon +++ b/pkg/arvo/gen/hood/moon.hoon @@ -23,7 +23,7 @@ =/ mon=ship ?^ arg mon.arg - (add our (lsh 5 1 (end 5 1 (shaz eny)))) + (add our (lsh 5 1 (new-end 5 (shaz eny)))) =/ seg=ship (sein:title our now mon) ?. =(our seg) %- %- slog :_ ~ diff --git a/pkg/arvo/gen/key.hoon b/pkg/arvo/gen/key.hoon index 6bdcb2f3a3..7fb8e7841b 100644 --- a/pkg/arvo/gen/key.hoon +++ b/pkg/arvo/gen/key.hoon @@ -17,11 +17,11 @@ =/ cub (pit:nu:crub:crypto 512 bur) :: =/ pub=pass pub:ex:cub -=/ mag=cord (end 3 1 pub) +=/ mag=cord (new-end 3 pub) ?> =('b' mag) =/ bod=@ (rsh 3 1 pub) =/ cry=@ (rsh 8 1 bod) -=/ sgn=@ (end 8 1 bod) +=/ sgn=@ (new-end 8 bod) %+ print leaf+" authentication: 0x{(render-hex-bytes:ethereum 32 sgn)}" %+ print leaf+" networking: 0x{(render-hex-bytes:ethereum 32 cry)}" %+ print leaf+"ethereum public keys:" diff --git a/pkg/arvo/gen/reload-event.hoon b/pkg/arvo/gen/reload-event.hoon index eebaf26459..745710adc4 100644 --- a/pkg/arvo/gen/reload-event.hoon +++ b/pkg/arvo/gen/reload-event.hoon @@ -16,10 +16,10 @@ ?. =(1 (met 3 tam)) tam =/ zaz=(list [p=knot ~]) - (skim van |=([a=term ~] =(tam (end 3 1 a)))) + (skim van |=([a=term ~] =(tam (new-end 3 a)))) ?> ?=([[@ ~] ~] zaz) `term`p.i.zaz -=/ tip (end 3 1 nam) +=/ tip (new-end 3 nam) =/ bip ?:(=('z' tip) %$ tip) =/ way ?:(=('z' tip) (welp top /sys/[nam]) (welp top /sys/vane/[nam])) =/ fil .^(@ %cx (welp way /hoon)) diff --git a/pkg/arvo/lib/bip32.hoon b/pkg/arvo/lib/bip32.hoon index 527cb1558d..a2f1cc32d1 100644 --- a/pkg/arvo/lib/bip32.hoon +++ b/pkg/arvo/lib/bip32.hoon @@ -56,7 +56,7 @@ ++ take |= b=@ud ^- [v=@ x=@] - :- (end 3 b x) + :- (new-end [3 b] x) (rsh 3 b x) -- =^ k x (take 33) @@ -219,7 +219,7 @@ |= [vw=@u t=tape] =+ x=(de-base58:mimes:html t) =+ hash=(sha-256l:sha 32 (sha-256:sha (rsh 3 4 x))) - ?> =((end 3 4 x) (rsh 3 28 hash)) + ?> =((new-end [3 4] x) (rsh 3 28 hash)) (cut 3 [vw (sub (met 3 x) (add 4 vw))] x) :: ++ hash160 diff --git a/pkg/arvo/lib/bip39.hoon b/pkg/arvo/lib/bip39.hoon index 9f7ec639fc..b0736f3aa5 100644 --- a/pkg/arvo/lib/bip39.hoon +++ b/pkg/arvo/lib/bip39.hoon @@ -23,7 +23,7 @@ :: =/ pieces |- ^- (list @) - :- (end 0 11 dat.bits) + :- (new-end [0 11] dat.bits) ?: (lte wid.bits 11) ~ $(bits [(sub wid.bits 11) (rsh 0 11 dat.bits)]) :: diff --git a/pkg/arvo/lib/der.hoon b/pkg/arvo/lib/der.hoon index 9b3876b403..f8f667b65c 100644 --- a/pkg/arvo/lib/der.hoon +++ b/pkg/arvo/lib/der.hoon @@ -142,7 +142,7 @@ ++ bit |= [len=@ud dat=@ux] ^- (unit [len=@ud dat=@ux]) - ?. =(0 (end 3 1 dat)) ~ + ?. =(0 (new-end 3 dat)) ~ :+ ~ (mul 8 (dec len)) (rsh 3 1 dat) @@ -188,7 +188,7 @@ =/ [nex=@ len=@] :: faz: meaningful bits in fuz :: - =/ faz (end 0 7 fuz) + =/ faz (new-end [0 7] fuz) ?: =(0 (cut 0 [7 1] fuz)) [0 faz] [faz (rep 3 (flop (scag faz t.q.tub)))] diff --git a/pkg/arvo/lib/hood/drum.hoon b/pkg/arvo/lib/hood/drum.hoon index 16b78562d8..f356e2ab01 100644 --- a/pkg/arvo/lib/hood/drum.hoon +++ b/pkg/arvo/lib/hood/drum.hoon @@ -1058,7 +1058,7 @@ %+ welp cad.pom ?~ buf.say.inp ~ - :(welp "<" (scow %p (end 4 1 (sham buf.say.inp))) "> ") + :(welp "<" (scow %p (new-end 4 (sham buf.say.inp))) "> ") :: ++ ta-yan :: yank (snag (sub num.kil pos.kil) old.kil) diff --git a/pkg/arvo/lib/hood/helm.hoon b/pkg/arvo/lib/hood/helm.hoon index 69627f714b..c4c13ccfeb 100644 --- a/pkg/arvo/lib/hood/helm.hoon +++ b/pkg/arvo/lib/hood/helm.hoon @@ -168,10 +168,10 @@ ?. =(1 (met 3 nam)) nam =/ zaz=(list [p=knot ~]) - (skim van |=([a=term ~] =(nam (end 3 1 a)))) + (skim van |=([a=term ~] =(nam (new-end 3 a)))) ?> ?=([[@ ~] ~] zaz) `term`p.i.zaz - =+ tip=(end 3 1 nam) + =+ tip=(new-end 3 nam) =+ zus==('z' tip) =+ way=?:(zus (welp top /sys/[nam]) (welp top /sys/vane/[nam])) =+ fil=.^(@ %cx (welp way /hoon)) diff --git a/pkg/arvo/lib/keygen.hoon b/pkg/arvo/lib/keygen.hoon index 624cd0e40e..e8c947ea3e 100644 --- a/pkg/arvo/lib/keygen.hoon +++ b/pkg/arvo/lib/keygen.hoon @@ -96,8 +96,8 @@ =+ =< [pub=pub:ex sec=sec:ex] (pit:nu:crub:crypto 256 seed) :- ^= auth - :- (rsh 3 1 (end 3 33 pub)) - (rsh 3 1 (end 3 33 sec)) + :- (rsh 3 1 (new-end [3 33] pub)) + (rsh 3 1 (new-end [3 33] sec)) ^= crypt :- (rsh 3 33 pub) (rsh 3 33 sec) diff --git a/pkg/arvo/lib/language-server/complete.hoon b/pkg/arvo/lib/language-server/complete.hoon index 5956dbadb0..0d4d109d99 100644 --- a/pkg/arvo/lib/language-server/complete.hoon +++ b/pkg/arvo/lib/language-server/complete.hoon @@ -87,7 +87,7 @@ %+ skim ids |= [id=cord *] ^- ?(%.y %.n) - =(sid (end 3 (met 3 sid) id)) + =(sid (new-end [3 (met 3 sid)] id)) :: :: Get the longest prefix of a list of identifiers. :: @@ -101,14 +101,14 @@ |- ^- term ?: (gth n last) term.i.matches - =/ prefix (end 3 n term.i.matches) + =/ prefix (new-end [3 n] term.i.matches) ?: |- ^- ? ?| ?=(~ t.matches) - ?& =(prefix (end 3 n term.i.t.matches)) + ?& =(prefix (new-end [3 n] term.i.t.matches)) $(t.matches t.t.matches) == == $(n +(n)) - (end 3 (dec n) term.i.matches) + (new-end [3 (dec n)] term.i.matches) :: :: Run +find-type safely, printing the first line of the stack trace on :: error. @@ -369,7 +369,7 @@ :- %leaf =/ c (to-wain:format a) ?~ c "~" - ?. =(':: ' (end 3 4 i.c)) + ?. =(':: ' (new-end [3 4] i.c)) "" (trip i.c) -- diff --git a/pkg/arvo/lib/language-server/easy-print.hoon b/pkg/arvo/lib/language-server/easy-print.hoon index cc4ecd1565..2113f9c142 100644 --- a/pkg/arvo/lib/language-server/easy-print.hoon +++ b/pkg/arvo/lib/language-server/easy-print.hoon @@ -39,7 +39,7 @@ ['\\' i.mil $(mil t.mil)] ?: (lte ' ' i.mil) [i.mil $(mil t.mil)] - ['\\' ~(x ne (rsh 2 1 i.mil)) ~(x ne (end 2 1 i.mil)) $(mil t.mil)] + ['\\' ~(x ne (rsh 2 1 i.mil)) ~(x ne (new-end 2 i.mil)) $(mil t.mil)] :: ++ deal |=(lum=* (dish dole lum)) ++ dial diff --git a/pkg/arvo/lib/old-phon.hoon b/pkg/arvo/lib/old-phon.hoon index 2db8670dc3..42433e896a 100644 --- a/pkg/arvo/lib/old-phon.hoon +++ b/pkg/arvo/lib/old-phon.hoon @@ -88,8 +88,8 @@ :: ++ mu |_ [top=@ bot=@] - ++ zag [p=(end 4 1 (add top bot)) q=bot] - ++ zig [p=(end 4 1 (add top (sub 0x1.0000 bot))) q=bot] + ++ zag [p=(new-end 4 (add top bot)) q=bot] + ++ zig [p=(new-end 4 (add top (sub 0x1.0000 bot))) q=bot] ++ zug (mix (lsh 4 1 top) bot) -- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @@ -111,7 +111,7 @@ ?: =(0 len) ~ => .(len (dec len)) - =+ mog=(zyft :(mix mig (end 3 1 len) (cut 3 [len 1] pyn))) + =+ mog=(zyft :(mix mig (new-end 3 len) (cut 3 [len 1] pyn))) [[1 mog] $(mig mog)] :: ++ wred :: restore structure @@ -129,7 +129,7 @@ ~ => .(len (dec len)) =+ mog=(cut 3 [len 1] cry) - [[1 :(mix mig (end 3 1 len) (zyrt mog))] $(mig mog)] + [[1 :(mix mig (new-end 3 len) (zyrt mog))] $(mig mog)] :: ++ xafo |=([a=@ b=@] +((mod (add (dec b) a) 255))) ++ xaro |=([a=@ b=@] +((mod (add (dec b) (sub 255 (mod a 255))) 255))) diff --git a/pkg/arvo/lib/pkcs.hoon b/pkg/arvo/lib/pkcs.hoon index 7b72452bc0..7d3f8cc178 100644 --- a/pkg/arvo/lib/pkcs.hoon +++ b/pkg/arvo/lib/pkcs.hoon @@ -62,7 +62,7 @@ |- ^- wain ?~ a [(rap 3 ['-----END ' lab '-----' ~]) ~] - [(end 3 64 a) $(a (rsh 3 64 a))] + [(new-end [3 64] a) $(a (rsh 3 64 a))] :: +de:pem: PEM decode :: ++ de diff --git a/pkg/arvo/lib/ring.hoon b/pkg/arvo/lib/ring.hoon index e1f5949414..29e27343f5 100644 --- a/pkg/arvo/lib/ring.hoon +++ b/pkg/arvo/lib/ring.hoon @@ -330,17 +330,17 @@ ++ get-public-key-from-pass |= a=pass ^- [@ @] - =+ [mag=(end 3 1 a) bod=(rsh 3 1 a)] + =+ [mag=(new-end 3 a) bod=(rsh 3 1 a)] ~| %not-crub-pubkey ?> =('b' mag) - [cry=(rsh 8 1 bod) sgn=(end 8 1 bod)] + [cry=(rsh 8 1 bod) sgn=(new-end 8 bod)] :: :: ++ get-private-key-from-ring |= a=ring ^- [@ @] - =+ [mag=(end 3 1 a) bod=(rsh 3 1 a)] + =+ [mag=(new-end 3 a) bod=(rsh 3 1 a)] ~| %not-crub-seckey ?> =('B' mag) - =+ [c=(rsh 8 1 bod) s=(end 8 1 bod)] + =+ [c=(rsh 8 1 bod) s=(new-end 8 bod)] :: todo: do we puck here? [c s] :: +ship-life-to-pubid: fetches public key information from jael diff --git a/pkg/arvo/lib/test/runner.hoon b/pkg/arvo/lib/test/runner.hoon index 2f1e708df7..aded2ffa5e 100644 --- a/pkg/arvo/lib/test/runner.hoon +++ b/pkg/arvo/lib/test/runner.hoon @@ -101,6 +101,6 @@ :: ++ has-test-prefix |= a=term ^- ? - =((end 3 5 a) 'test-') + =((new-end [3 5] a) 'test-') -- diff --git a/pkg/arvo/mar/eth/txs.hoon b/pkg/arvo/mar/eth/txs.hoon index f22c5dd09b..d5640c3ba8 100644 --- a/pkg/arvo/mar/eth/txs.hoon +++ b/pkg/arvo/mar/eth/txs.hoon @@ -10,7 +10,7 @@ %- cook :_ nuck:so |= =coin ?> ?=(%$ -.coin) - ?> ?=(%u (end 3 1 p.p.coin)) + ?> ?=(%u (new-end 3 p.p.coin)) `@`q.p.coin :: ++ grab diff --git a/pkg/arvo/mar/udon.hoon b/pkg/arvo/mar/udon.hoon index cfd6014ff9..3588acc97b 100644 --- a/pkg/arvo/mar/udon.hoon +++ b/pkg/arvo/mar/udon.hoon @@ -17,7 +17,7 @@ ^- (map term knot) %- ~(run by inf:(static:cram (ream mud))) |= a=dime ^- cord - ?+ (end 3 1 p.a) (scot a) + ?+ (new-end 3 p.a) (scot a) %t q.a == -- diff --git a/pkg/arvo/mar/umd.hoon b/pkg/arvo/mar/umd.hoon index 268622d411..227e3ac8fa 100644 --- a/pkg/arvo/mar/umd.hoon +++ b/pkg/arvo/mar/umd.hoon @@ -17,7 +17,7 @@ ^- (map term knot) %- ~(run by inf:(static:cram (ream mud))) |= a=dime ^- cord - ?+ (end 3 1 p.a) (scot a) + ?+ (new-end 3 p.a) (scot a) %t q.a == -- diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index 7296a354d7..df93fb81a2 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -1100,7 +1100,7 @@ :: :: XX vane and care are concatenated :: - =/ lal (end 3 1 cyr) + =/ lal (new-end 3 cyr) =/ ren ;;(@t (rsh 3 1 cyr)) ?. (~(has by van.mod) lal) ~ diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 9180e7ddbe..ba4777c77a 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -842,7 +842,7 @@ |= [a=bloq b=(list [p=step q=@])] ^- @ ?~ b 0 - (add (end a p.i.b q.i.b) (lsh a p.i.b $(b t.b))) + (add (new-end [a p.i.b] q.i.b) (lsh a p.i.b $(b t.b))) :: ++ cat :: concatenate ~/ %cat @@ -852,13 +852,19 @@ ++ cut :: slice ~/ %cut |= [a=bloq [b=step c=step] d=@] - (end a c (rsh a b d)) + (new-end [a c] (rsh a b d)) :: ++ end :: tail ~/ %end |= [a=bloq b=step c=@] (mod c (bex (mul (bex a) b))) :: +++ new-end :: tail + ~/ %new-end + |= [a=bite b=@] + =/ [=bloq =step] ?^(a a [a *step]) + (mod b (bex (mul (bex bloq) step))) +:: ++ fil :: fill bloqstream ~/ %fil |= [a=bloq b=step c=@] @@ -899,7 +905,7 @@ |- ^- @ ?~ b 0 %+ add $(i +(i), b t.b) - (lsh bloq (mul step i) (end bloq step i.b)) + (lsh bloq (mul step i) (new-end [bloq step] i.b)) :: ++ rev :: reverses block order, accounting for leading zeroes @@ -910,7 +916,7 @@ ~/ %rev |= [boz=bloq len=@ud dat=@] ^- @ - =. dat (end boz len dat) + =. dat (new-end [boz len] dat) %^ lsh boz (sub len (met boz dat)) (swp boz dat) @@ -921,7 +927,7 @@ =/ [=bloq =step] ?^(a a [a *step]) ^- (list @) ?: =(0 b) ~ - [(end bloq step b) $(b (rsh bloq step b))] + [(new-end [bloq step] b) $(b (rsh bloq step b))] :: ++ rsh :: right-shift ~/ %rsh @@ -983,7 +989,7 @@ =+ g=(mod c f) (sit (con (rsh b g e) (lsh b (sub f g) e))) ++ sum |=([b=@ c=@] (sit (add b c))) :: wrapping add - ++ sit |=(b=@ (end a 1 b)) :: enforce modulo + ++ sit |=(b=@ (new-end a b)) :: enforce modulo -- :: :: :::: 2d: bit logic :: @@ -1001,8 +1007,8 @@ c +(c) d %+ add d %^ lsh 0 c - ?& =(0 (end 0 1 a)) - =(0 (end 0 1 b)) + ?& =(0 (new-end 0 a)) + =(0 (new-end 0 b)) == == :: @@ -1018,8 +1024,8 @@ c +(c) d %+ add d %^ lsh 0 c - ?| =(0 (end 0 1 a)) - =(0 (end 0 1 b)) + ?| =(0 (new-end 0 a)) + =(0 (new-end 0 b)) == == :: @@ -1034,7 +1040,7 @@ a (rsh 0 1 a) b (rsh 0 1 b) c +(c) - d (add d (lsh 0 c =((end 0 1 a) (end 0 1 b)))) + d (add d (lsh 0 c =((new-end 0 a) (new-end 0 b)))) == :: ++ not |= [a=bloq b=@ c=@] :: binary not (sized) @@ -1047,7 +1053,7 @@ ~% %muk ..muk ~ =+ ~(. fe 5) |= [syd=@ len=@ key=@] - =. syd (end 5 1 syd) + =. syd (new-end 5 syd) =/ pad (sub len (met 3 key)) =/ data (weld (rip 3 key) (reap pad 0)) =/ nblocks (div len 4) :: intentionally off-by-one @@ -1115,7 +1121,7 @@ |- ^- @F ?: =(8 i) fal =/ haz=@F (muk syd wyd key) - =/ ham=@F (mix (rsh 0 31 haz) (end 0 31 haz)) + =/ ham=@F (mix (rsh 0 31 haz) (new-end [0 31] haz)) ?.(=(0 ham) ham $(i +(i), syd +(syd))) -- :: :: @@ -1139,7 +1145,7 @@ $(a -.a, b -.b) ?. ?=(@ b) & |- - =+ [c=(end 3 1 a) d=(end 3 1 b)] + =+ [c=(new-end 3 a) d=(new-end 3 b)] ?: =(c d) $(a (rsh 3 1 a), b (rsh 3 1 b)) (lth c d) @@ -2080,7 +2086,7 @@ =+ b=(met 0 a) =+ c=(met 0 b) :- (add (add c c) b) - (cat 0 (bex c) (mix (end 0 (dec c) b) (lsh 0 (dec c) a))) + (cat 0 (bex c) (mix (new-end [0 (dec c)] b) (lsh 0 (dec c) a))) :: ++ rub :: length-decode ~/ %rub @@ -2174,7 +2180,7 @@ 1 =+ d=$(b (rsh 0 1 b)) =+ e=(pro d d) - ?:(=(0 (end 0 1 b)) e (pro c e)) + ?:(=(0 (new-end 0 b)) e (pro c e)) :: ++ fra |= [b=@ c=@] @@ -2201,7 +2207,7 @@ ++ si :: signed integer ^? |% - ++ abs |=(a=@s (add (end 0 1 a) (rsh 0 1 a))) :: absolute value + ++ abs |=(a=@s (add (new-end 0 a) (rsh 0 1 a))) :: absolute value ++ dif |= [a=@s b=@s] :: subtraction (sum a (new !(syn b) (abs b))) ++ dul |= [a=@s b=@] :: modulus @@ -2228,7 +2234,7 @@ (new & (sub +.d +.c)) (new | (add +.c +.d)) ++ sun |=(a=@u (mul 2 a)) :: @u to @s - ++ syn |=(a=@s =(0 (end 0 1 a))) :: sign test + ++ syn |=(a=@s =(0 (new-end 0 a))) :: sign test ++ cmp |= [a=@s b=@s] :: compare ^- @s ?: =(a b) @@ -2364,7 +2370,7 @@ :: every fn has a unique representation of this kind ++ uni |= [a=[e=@s a=@u]] - |- ?: =((end 0 1 a.a) 1) a + |- ?: =((new-end 0 a.a) 1) a $(a.a (rsh 0 1 a.a), e.a (sum:si e.a --1)) :: :: expands to either full precision or to denormalized @@ -2399,7 +2405,7 @@ ?: (gth m prc) (^sub m prc) 0 :: reduce precision %- abs:si ?: =(den %i) --0 :: enforce min. exp ?: =((cmp:si e.a emn) -1) (dif:si emn e.a) --0 - =^ b a :- (end 0 q a.a) + =^ b a :- (new-end [0 q] a.a) a(e (sum:si e.a (sun:si q)), a (rsh 0 q a.a)) :: ?~ a.a @@ -2505,7 +2511,7 @@ =+ x=(abs:si e.a) =+ y=(rsh 0 x a.a) ?: |(=(r %d) =(r %z)) [%f & --0 y] - =+ z=(end 0 x a.a) + =+ z=(new-end [0 x] a.a) ?: |(=(r %u) =(r %a)) [%f & --0 ?~(z y +(y))] =+ i=(bex (dec x)) ?: &(=(z i) =((dis y 1) 0)) [%f & --0 y] @@ -2764,7 +2770,7 @@ ?> (^lth ma +(p)) ?: s.a `@r`a.a (^add a.a sb) =+ q=(sum:si (dif:si e.a me) --1) - =+ r=(^add (lsh 0 p (abs:si q)) (end 0 p a.a)) + =+ r=(^add (lsh 0 p (abs:si q)) (new-end [0 p] a.a)) ?: s.a r (^add r sb) :: ++ sig :: get sign @@ -3179,12 +3185,12 @@ ^- tarp =+ sec=(rsh 6 1 now) =+ ^= fan - =+ [muc=4 raw=(end 6 1 now)] + =+ [muc=4 raw=(new-end 6 now)] |- ^- (list @ux) ?: |(=(0 raw) =(0 muc)) ~ => .(muc (dec muc)) - [(cut 4 [muc 1] raw) $(raw (end 4 muc raw))] + [(cut 4 [muc 1] raw) $(raw (new-end [4 muc] raw))] =+ day=(div sec day:yo) => .(sec (mod sec day:yo)) =+ hor=(div sec hor:yo) @@ -3225,7 +3231,7 @@ =+ dis=?:(lep 366 365) ?. (lth day dis) =+ ner=+(yer) - $(yer ner, day (sub day dis), lep =(0 (end 0 2 ner))) + $(yer ner, day (sub day dis), lep =(0 (new-end [0 2] ner))) |- ^- [y=@ud m=@ud d=@ud] =+ [mot=0 cah=?:(lep moy:yo moh:yo)] |- ^- [y=@ud m=@ud d=@ud] @@ -3283,7 +3289,7 @@ ++ shaf :: half sha-256 |= [sal=@ ruz=@] =+ haz=(shas sal ruz) - (mix (end 7 1 haz) (rsh 7 1 haz)) + (mix (new-end 7 haz) (rsh 7 1 haz)) :: ++ sham :: 128bit noun hash |= yux=* ^- @uvH ^- @ @@ -3599,7 +3605,7 @@ ~ =+ d=(shas %og-b (mix b (mix a c))) ?: (lth b 256) - [[b (end 0 b d)] ~] + [[b (new-end [0 b] d)] ~] [[256 d] $(c d, b (sub b 256))] :: ++ raws :: random bits @@ -3722,7 +3728,7 @@ ?: =(0 len) ~ => .(len (dec len)) - =+ mog=(zyft :(mix mig (end 3 1 len) (cut 3 [len 1] pyn))) + =+ mog=(zyft :(mix mig (new-end 3 len) (cut 3 [len 1] pyn))) [[1 mog] $(mig mog)] :: ++ wred :: restore structure @@ -3740,7 +3746,7 @@ ~ => .(len (dec len)) =+ mog=(cut 3 [len 1] cry) - [[1 :(mix mig (end 3 1 len) (zyrt mog))] $(mig mog)] + [[1 :(mix mig (new-end 3 len) (zyrt mog))] $(mig mog)] :: ++ xafo |=([a=@ b=@] +((mod (add (dec b) a) 255))) ++ xaro |=([a=@ b=@] +((mod (add (dec b) (sub 255 (mod a 255))) 255))) @@ -4139,7 +4145,7 @@ ++ tok |= a=@ux ^- @ux =+ b=(pad a) - =- (~(net fe 5) (end 3 4 (shay 32 -))) + =- (~(net fe 5) (new-end [3 4] (shay 32 -))) (shay (add b (met 3 a)) (lsh 3 b (swp 3 a))) :: ++ pad |=(a=@ =+(b=(met 3 a) ?:((gte b 21) 0 (sub 21 b)))) @@ -4147,7 +4153,7 @@ ++ den |= a=@ux ^- (unit @ux) =+ b=(rsh 3 4 a) - ?. =((tok b) (end 3 4 a)) + ?. =((tok b) (new-end [3 4] a)) ~ `b -- @@ -4161,7 +4167,7 @@ |- ?: =(0 a) & - =+ vis=(end 3 1 a) + =+ vis=(new-end 3 a) ?& ?|(=('-' vis) ?&((gte vis 'a') (lte vis 'z'))) $(a (rsh 3 1 a)) == @@ -4202,7 +4208,7 @@ ?: (gth (met 5 a) 1) %+ weld $(a (rsh 5 1 a), b (sub b 4)) - `tape`['-' '-' $(a (end 5 1 a), b 4)] + `tape`['-' '-' $(a (new-end 5 a), b 4)] ?: =(0 b) ['~' ~] ?: (lte b 1) @@ -4210,10 +4216,10 @@ |- ^- tape ?: =(2 b) =+ c=(rsh 3 1 a) - =+ d=(end 3 1 a) + =+ d=(new-end 3 a) (weld (trip (tod:po c)) (trip (tos:po (mix c d)))) =+ c=(rsh 3 2 a) - =+ d=(end 3 2 a) + =+ d=(new-end [3 2] a) (weld ^$(a c, b (met 3 c)) `tape`['-' $(a (mix c d), b 2)]) :: ++ ruv @@ -4269,7 +4275,7 @@ ++ sane :: atom sanity |= a=@ta |= b=@ ^- ? - ?. =(%t (end 3 1 a)) + ?. =(%t (new-end 3 a)) :: XX more and better sanity :: & @@ -4296,7 +4302,7 @@ == |- ^- ? ?: =(0 b) & - =+ cur=(end 3 1 b) + =+ cur=(new-end 3 b) ?: &((lth cur 32) !=(10 cur)) | =+ len=(teff cur) ?& |(=(1 len) =+(i=1 |-(|(=(i len) &((gte (cut 3 [i 1] b) 128) $(i +(i))))))) @@ -4325,11 +4331,11 @@ |= a=@ ^- tape ?: =(0 (met 3 a)) ~ - [^-(@ta (end 3 1 a)) $(a (rsh 3 1 a))] + [^-(@ta (new-end 3 a)) $(a (rsh 3 1 a))] :: ++ teff :: length utf8 |= a=@t ^- @ - =+ b=(end 3 1 a) + =+ b=(new-end 3 a) ?: =(0 b) ?>(=(`@`0 a) 0) ?> |((gte b 32) =(10 b)) @@ -4353,7 +4359,7 @@ %4 [[24 6] [16 6] [8 6] [0 3] ~] == |=([p=@ q=@] [q (cut 0 [p q] a)]) - ?> =((tuft c) (end 3 b a)) + ?> =((tuft c) (new-end [3 b] a)) [c $(a (rsh 3 b a))] :: ++ tuba :: utf8 to utf32 tape @@ -4374,25 +4380,25 @@ |- ^- (list @) ?: =(`@`0 a) ~ - =+ b=(end 5 1 a) + =+ b=(new-end 5 a) =+ c=$(a (rsh 5 1 a)) ?: (lte b 0x7f) [b c] ?: (lte b 0x7ff) :* (mix 0b1100.0000 (cut 0 [6 5] b)) - (mix 0b1000.0000 (end 0 6 b)) + (mix 0b1000.0000 (new-end [0 6] b)) c == ?: (lte b 0xffff) :* (mix 0b1110.0000 (cut 0 [12 4] b)) (mix 0b1000.0000 (cut 0 [6 6] b)) - (mix 0b1000.0000 (end 0 6 b)) + (mix 0b1000.0000 (new-end [0 6] b)) c == :* (mix 0b1111.0000 (cut 0 [18 3] b)) (mix 0b1000.0000 (cut 0 [12 6] b)) (mix 0b1000.0000 (cut 0 [6 6] b)) - (mix 0b1000.0000 (end 0 6 b)) + (mix 0b1000.0000 (new-end [0 6] b)) c == :: @@ -4432,13 +4438,13 @@ |- ^- (list @) ?: =(`@`0 a) ~ - =+ b=(end 3 1 a) + =+ b=(new-end 3 a) =+ c=(rsh 3 1 a) ?: =('.' b) [' ' $(a c)] ?. =('~' b) [b $(a c)] - => .(b (end 3 1 c), c (rsh 3 1 c)) + => .(b (new-end 3 c), c (rsh 3 1 c)) ?+ b =- (weld (rip 3 (tuft p.d)) $(a q.d)) ^= d =+ d=0 @@ -4447,7 +4453,7 @@ [d c] ?< =(0 c) %= $ - b (end 3 1 c) + b (new-end 3 c) c (rsh 3 1 c) d %+ add (mul 16 d) %+ sub b @@ -4466,7 +4472,7 @@ ?: =(`@`0 a) ~ =+ b=(teff a) - =+ c=(taft (end 3 b a)) + =+ c=(taft (new-end [3 b] a)) =+ d=$(a (rsh 3 b a)) ?: ?| &((gte c 'a') (lte c 'z')) &((gte c '0') (lte c '9')) @@ -4481,7 +4487,7 @@ ['.' d] =. e (dec e) =+ f=(rsh 2 e c) - [(add ?:((lte f 9) 48 87) f) $(c (end 2 e c))] + [(add ?:((lte f 9) 48 87) f) $(c (new-end [2 e] c))] :: %' ' ['.' d] %'.' ['~' '.' d] @@ -4941,7 +4947,7 @@ |- ^- (like @t) ?: =(`@`0 daf) [p=p.tub q=[~ u=[p=fad q=tub]]] - ?: |(?=(~ q.tub) !=((end 3 1 daf) i.q.tub)) + ?: |(?=(~ q.tub) !=((new-end 3 daf) i.q.tub)) (fail tub) $(p.tub (lust i.q.tub p.tub), q.tub t.q.tub, daf (rsh 3 1 daf)) :: @@ -5434,8 +5440,8 @@ -- ++ mu |_ [top=@ bot=@] - ++ zag [p=(end 4 1 (add top bot)) q=bot] - ++ zig [p=(end 4 1 (add top (sub 0x1.0000 bot))) q=bot] + ++ zag [p=(new-end 4 (add top bot)) q=bot] + ++ zig [p=(new-end 4 (add top (sub 0x1.0000 bot))) q=bot] ++ zug (mix (lsh 4 1 top) bot) -- ++ ne @@ -5464,7 +5470,7 @@ ?~ p.lot ['_' '_' rep] ['_' (weld (trip (wack rent(lot i.p.lot))) $(p.lot t.p.lot))] - =+ [yed=(end 3 1 p.p.lot) hay=(cut 3 [1 1] p.p.lot)] + =+ [yed=(new-end 3 p.p.lot) hay=(cut 3 [1 1] p.p.lot)] |- ^- tape ?+ yed (z-co q.p.lot) %c ['~' '-' (weld (rip 3 (wood (tuft q.p.lot))) rep)] @@ -5525,7 +5531,7 @@ rep =/ log (cut 4 [imp 1] sxz) ;: weld (trip (tos:po (rsh 3 1 log))) - (trip (tod:po (end 3 1 log))) + (trip (tod:po (new-end 3 log))) ?:(=((mod imp 4) 0) ?:(=(imp 0) "" "--") "-") rep == == @@ -5854,7 +5860,7 @@ ~+ =+ ^= neg |= [syn=? mol=dime] ^- dime - ?> =('u' (end 3 1 p.mol)) + ?> =('u' (new-end 3 p.mol)) [(cat 3 's' (rsh 3 1 p.mol)) (new:si syn q.mol)] ;~ pfix hep ;~ pose @@ -7291,7 +7297,7 @@ [0 %$] =+ tyl=(rsh 3 (dec len) mot) ?: &((gte tyl 'A') (lte tyl 'Z')) - [(sub tyl 64) (end 3 (dec len) mot)] + [(sub tyl 64) (new-end [3 (dec len)] mot)] [0 mot] =+ [yoz=(fiz yaz) wux=(fiz wix)] ?& ?| =(0 p.yoz) @@ -7300,7 +7306,7 @@ == |- ?| =(%$ p.yoz) =(%$ p.wux) - ?& =((end 3 1 p.yoz) (end 3 1 p.wux)) + ?& =((new-end 3 p.yoz) (new-end 3 p.wux)) $(p.yoz (rsh 3 1 p.yoz), p.wux (rsh 3 1 p.wux)) == == @@ -11042,7 +11048,7 @@ ['\\' i.mil $(mil t.mil)] ?: (lte ' ' i.mil) [i.mil $(mil t.mil)] - ['\\' ~(x ne (rsh 2 1 i.mil)) ~(x ne (end 2 1 i.mil)) $(mil t.mil)] + ['\\' ~(x ne (rsh 2 1 i.mil)) ~(x ne (new-end 2 i.mil)) $(mil t.mil)] :: ++ deal |=(lum=* (dish dole lum)) ++ dial diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index 790ed55e87..b603b0f1ea 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -926,7 +926,7 @@ :: :: Logic duplicates +com:nu:crub:crypto and +sure:as:crub:crypto. :: - =/ key (end 8 1 (rsh 3 1 public-key.open-packet)) + =/ key (new-end 8 (rsh 3 1 public-key.open-packet)) ?> (veri:ed:crypto signature signed key) :: store comet as peer in our state :: @@ -1551,7 +1551,7 @@ =/ pumps=(list message-pump-state) %+ murn ~(tap by snd.peer-state) |= [=bone =message-pump-state] - ?: =(0 (end 0 1 bone)) + ?: =(0 (new-end 0 bone)) ~ `u=message-pump-state :: clogged: are five or more response messages unsent to this peer? @@ -1780,11 +1780,11 @@ ^+ peer-core :: if odd bone, ack is on "subscription update" message; no-op :: - ?: =(1 (end 0 1 bone)) + ?: =(1 (new-end 0 bone)) peer-core :: even bone; is this bone a nack-trace bone? :: - ?: =(1 (end 0 1 (rsh 0 1 bone))) + ?: =(1 (new-end 0 (rsh 0 1 bone))) :: nack-trace bone; assume .ok, clear nack from |message-sink :: =/ target-bone=^bone (mix 0b10 bone) @@ -1870,9 +1870,9 @@ :: even bone, 1 second bit: nack-trace %boon message :: ++ on-sink-memo - ?: =(1 (end 0 1 bone)) + ?: =(1 (new-end 0 bone)) on-sink-plea - ?: =(0 (end 0 1 (rsh 0 1 bone))) + ?: =(0 (new-end 0 (rsh 0 1 bone))) on-sink-boon on-sink-nack-trace :: +on-sink-boon: handle response message received by |message-sink @@ -2903,10 +2903,10 @@ |= [=public-key =private-key] ^- symmetric-key :: - ?> =('b' (end 3 1 public-key)) + ?> =('b' (new-end 3 public-key)) =. public-key (rsh 8 1 (rsh 3 1 public-key)) :: - ?> =('B' (end 3 1 private-key)) + ?> =('B' (new-end 3 private-key)) =. private-key (rsh 8 1 (rsh 3 1 private-key)) :: `@`(shar:ed:crypto public-key private-key) @@ -2979,22 +2979,22 @@ ^- packet :: first 32 (2^5) bits are header; the rest is body :: - =/ header (end 5 1 blob) + =/ header (new-end 5 blob) =/ body (rsh 5 1 blob) :: - =/ version (end 0 3 header) + =/ version (new-end [0 3] header) =/ checksum (cut 0 [3 20] header) =/ sndr-size (decode-ship-size (cut 0 [23 2] header)) =/ rcvr-size (decode-ship-size (cut 0 [25 2] header)) =/ encrypted ?+((cut 0 [27 5] header) !! %0 %.y, %1 %.n) :: =/ =dyad - :- sndr=(end 3 sndr-size body) + :- sndr=(new-end [3 sndr-size] body) rcvr=(cut 3 [sndr-size rcvr-size] body) :: ?. =(protocol-version version) ~| %ames-protocol^version^dyad !! - ?. =(checksum (end 0 20 (mug body))) + ?. =(checksum (new-end [0 20] (mug body))) ~| %ames-checksum^dyad !! :: =+ ~| %ames-invalid-packet diff --git a/pkg/arvo/sys/vane/clay.hoon b/pkg/arvo/sys/vane/clay.hoon index d22b055888..5118c3df80 100644 --- a/pkg/arvo/sys/vane/clay.hoon +++ b/pkg/arvo/sys/vane/clay.hoon @@ -1978,7 +1978,7 @@ |= =term =/ vane=@t (path-to-cord data /sys/vane/[term]/hoon) %- emit - =/ tip (end 3 1 term) + =/ tip (new-end 3 term) =/ =path /sys/vane/[term]/hoon [hen %pass /reload %d %flog %veer tip path vane] -- @@ -3839,7 +3839,7 @@ =+ pac=(of-wain (lurk:differ (to-wain (cat 3 txt '\0a')) dif)) ?~ pac '' - (end 3 (dec (met 3 pac)) pac) + (new-end [3 (dec (met 3 pac))] pac) :: :: Gets an arch (directory listing) at a node. :: diff --git a/pkg/arvo/sys/vane/gall.hoon b/pkg/arvo/sys/vane/gall.hoon index 3b2241951b..54ef6bf0b2 100644 --- a/pkg/arvo/sys/vane/gall.hoon +++ b/pkg/arvo/sys/vane/gall.hoon @@ -332,7 +332,7 @@ control-duct hen beak bek agent &+agent - nonce (scot %uw (end 5 1 (shas %yoke-nonce eny))) + nonce (scot %uw (new-end 5 (shas %yoke-nonce eny))) == :: =/ old mo-core diff --git a/pkg/arvo/sys/vane/jael.hoon b/pkg/arvo/sys/vane/jael.hoon index aea5275954..1f1e53eb17 100644 --- a/pkg/arvo/sys/vane/jael.hoon +++ b/pkg/arvo/sys/vane/jael.hoon @@ -1045,7 +1045,7 @@ =/ who (slaw %p i.tyl) ?~ who [~ ~] =/ sec (~(got by jaw.own.pki.lex) lyf.own.pki.lex) - ``[%noun !>((end 6 1 (shaf %pass (shax sec))))] + ``[%noun !>((new-end 6 (shaf %pass (shax sec))))] :: %life ?. ?=([@ ~] tyl) [~ ~] diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index e795b89591..dd512d410b 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -2316,7 +2316,7 @@ :: :: ++pram:number ++ pram :: rabin-miller |= a=@ ^- ? - ?: ?| =(0 (end 0 1 a)) + ?: ?| =(0 (new-end 0 a)) =(1 a) =+ b=1 |- ^- ? @@ -2328,7 +2328,7 @@ =+ ^= b =+ [s=(dec a) t=0] |- ^- [s=@ t=@] - ?: =(0 (end 0 1 s)) + ?: =(0 (new-end 0 s)) $(s (rsh 0 1 s), t +(t)) [s t] ?> =((mul s.b (bex t.b)) (dec a)) @@ -3199,7 +3199,7 @@ ~/ %en |= txt=@ ^- (trel @uxH @ud @ux) - =+ [k1=(rsh 7 1 key) k2=(end 7 1 key)] + =+ [k1=(rsh 7 1 key) k2=(new-end 7 key)] =+ iv=(s2va k1 (weld vec (limo ~[txt]))) =+ len=(met 3 txt) =* hib (dis iv 0xffff.ffff.ffff.ffff.7fff.ffff.7fff.ffff) @@ -3212,7 +3212,7 @@ ~/ %de |= [iv=@H len=@ txt=@] ^- (unit @ux) - =+ [k1=(rsh 7 1 key) k2=(end 7 1 key)] + =+ [k1=(rsh 7 1 key) k2=(new-end 7 key)] =* hib (dis iv 0xffff.ffff.ffff.ffff.7fff.ffff.7fff.ffff) =+ ^= pln (~(de ctra k2 7 len hib) txt) @@ -3229,7 +3229,7 @@ ~/ %en |= txt=@ ^- (trel @uxH @ud @ux) - =+ [k1=(rsh 6 3 key) k2=(end 6 3 key)] + =+ [k1=(rsh 6 3 key) k2=(new-end [6 3] key)] =+ iv=(s2vb k1 (weld vec (limo ~[txt]))) =* hib (dis iv 0xffff.ffff.ffff.ffff.7fff.ffff.7fff.ffff) =+ len=(met 3 txt) @@ -3241,7 +3241,7 @@ ~/ %de |= [iv=@H len=@ txt=@] ^- (unit @ux) - =+ [k1=(rsh 6 3 key) k2=(end 6 3 key)] + =+ [k1=(rsh 6 3 key) k2=(new-end [6 3] key)] =* hib (dis iv 0xffff.ffff.ffff.ffff.7fff.ffff.7fff.ffff) =+ ^= pln (~(de ctrb k2 7 len hib) txt) @@ -3258,7 +3258,7 @@ ~/ %en |= txt=@ ^- (trel @uxH @ud @ux) - =+ [k1=(rsh 8 1 key) k2=(end 8 1 key)] + =+ [k1=(rsh 8 1 key) k2=(new-end 8 key)] =+ iv=(s2vc k1 (weld vec (limo ~[txt]))) =* hib (dis iv 0xffff.ffff.ffff.ffff.7fff.ffff.7fff.ffff) =+ len=(met 3 txt) @@ -3271,7 +3271,7 @@ ~/ %de |= [iv=@H len=@ txt=@] ^- (unit @ux) - =+ [k1=(rsh 8 1 key) k2=(end 8 1 key)] + =+ [k1=(rsh 8 1 key) k2=(new-end 8 key)] =* hib (dis iv 0xffff.ffff.ffff.ffff.7fff.ffff.7fff.ffff) =+ ^= pln (~(de ctrc k2 7 len hib) txt) @@ -3445,7 +3445,7 @@ =+ exp=(shal (rsh 0 3 b) (suck sek)) =. exp (dis exp (can 0 ~[[3 0] [251 (fil 0 251 1)]])) =. exp (con exp (lsh 3 31 0b100.0000)) - =+ prv=(end 8 1 exp) + =+ prv=(new-end 8 exp) =+ crv=(fra.fq (sum.fq 1 pub) (dif.fq 1 pub)) (curt prv crv) :: :: ++sign:ed:crypto @@ -3507,7 +3507,7 @@ =+ few==>(fe .(a 5)) =+ ^= rot |= [a=@ b=@] - (mix (end 5 1 (lsh 0 a b)) (rsh 0 (sub 32 a) b)) + (mix (new-end 5 (lsh 0 a b)) (rsh 0 (sub 32 a) b)) =+ ^= lea |= [a=@ b=@] (net:few (sum:few (net:few a) (net:few b))) @@ -3623,7 +3623,7 @@ :: :: ++hml:scr:crypto ++ hml :: w+length |= [k=@ kl=@ t=@ tl=@] - => .(k (end 3 kl k), t (end 3 tl t)) + => .(k (new-end [3 kl] k), t (new-end [3 tl] t)) =+ b=64 =? k (gth kl b) (shay kl k) =+ ^= q %+ shay (add b tl) @@ -3639,7 +3639,7 @@ ++ pbl :: w+length ~/ %pbl |= [p=@ pl=@ s=@ sl=@ c=@ d=@] - => .(p (end 3 pl p), s (end 3 sl s)) + => .(p (new-end [3 pl] p), s (new-end [3 sl] s)) =+ h=32 :: :: max key length 1GB @@ -3662,7 +3662,7 @@ =+ q=(hml p pl u ?:(=(k 1) (add sl 4) h)) $(u q, f (mix f q), k +(k)) $(t (add t (lsh 3 (mul (dec j) h) f)), j +(j)) - (end 3 d t) + (new-end [3 d] t) :: :: ++hsh:scr:crypto ++ hsh :: scrypt ~/ %hsh @@ -3673,7 +3673,7 @@ ~/ %hsl |= [p=@ pl=@ s=@ sl=@ n=@ r=@ z=@ d=@] =| v=(list (list @)) - => .(p (end 3 pl p), s (end 3 sl s)) + => .(p (new-end [3 pl] p), s (new-end [3 sl] s)) =+ u=(mul (mul 128 r) z) :: :: n is power of 2; max 1GB memory @@ -3730,7 +3730,7 @@ |= [bpk=pass msg=@] ^- @ux ?~ sek ~| %pubkey-only !! - ?> =('b' (end 3 1 bpk)) + ?> =('b' (new-end 3 bpk)) =+ pk=(rsh 8 1 (rsh 3 1 bpk)) =+ shar=(shax (shar:ed pk cry.u.sek)) =+ smsg=(sign msg) @@ -3740,7 +3740,7 @@ |= [bpk=pass txt=@] ^- (unit @ux) ?~ sek ~| %pubkey-only !! - ?> =('b' (end 3 1 bpk)) + ?> =('b' (new-end 3 bpk)) =+ pk=(rsh 8 1 (rsh 3 1 bpk)) =+ shar=(shax (shar:ed pk cry.u.sek)) =+ ;;([iv=@ len=@ cph=@] (cue txt)) @@ -3777,7 +3777,7 @@ ++ pac :: private fingerprint ^- @uvG ?~ sek ~| %pubkey-only !! - (end 6 1 (shaf %bcod sec)) + (new-end 6 (shaf %bcod sec)) :: :: ++pub:ex:crub:crypto ++ pub :: public key ^- pass @@ -3796,21 +3796,21 @@ |= [w=@ seed=@] =+ wid=(add (div w 8) ?:(=((mod w 8) 0) 0 1)) =+ bits=(shal wid seed) - =+ [c=(rsh 8 1 bits) s=(end 8 1 bits)] + =+ [c=(rsh 8 1 bits) s=(new-end 8 bits)] ..nu(pub [cry=(puck:ed c) sgn=(puck:ed s)], sek `[cry=c sgn=s]) :: :: ++nol:nu:crub:crypto ++ nol :: activate secret |= a=ring - =+ [mag=(end 3 1 a) bod=(rsh 3 1 a)] + =+ [mag=(new-end 3 a) bod=(rsh 3 1 a)] ~| %not-crub-seckey ?> =('B' mag) - =+ [c=(rsh 8 1 bod) s=(end 8 1 bod)] + =+ [c=(rsh 8 1 bod) s=(new-end 8 bod)] ..nu(pub [cry=(puck:ed c) sgn=(puck:ed s)], sek `[cry=c sgn=s]) :: :: ++com:nu:crub:crypto ++ com :: activate public |= a=pass - =+ [mag=(end 3 1 a) bod=(rsh 3 1 a)] + =+ [mag=(new-end 3 a) bod=(rsh 3 1 a)] ~| %not-crub-pubkey ?> =('b' mag) - ..nu(pub [cry=(rsh 8 1 bod) sgn=(end 8 1 bod)], sek ~) + ..nu(pub [cry=(rsh 8 1 bod) sgn=(new-end 8 bod)], sek ~) -- ::nu -- ::crub :: :: @@ -4191,8 +4191,8 @@ :: out: bytes output by haj |* [[haj=$-([@u @] @) boq=@u out=@u] key=byts msg=byts] :: ensure key and message fit signaled lengths - =. dat.key (end 3 wid.key dat.key) - =. dat.msg (end 3 wid.msg dat.msg) + =. dat.key (new-end [3 wid.key] dat.key) + =. dat.msg (new-end [3 wid.msg] dat.msg) :: keys longer than block size are shortened by hashing =? dat.key (gth wid.key boq) (haj wid.key dat.key) =? wid.key (gth wid.key boq) out @@ -4249,7 +4249,7 @@ ++ decompress-point |= compressed=@ ^- point - =/ x=@ (end 3 bytes compressed) + =/ x=@ (new-end [3 bytes] compressed) ?> =(3 (mod p.domain 4)) =/ fop field-p =+ [fadd fmul fpow]=[sum.fop pro.fop exp.fop] @@ -4465,7 +4465,7 @@ (sub n.domain.c s) =? rp s-high [x.rp (sub p.domain.c y.rp)] - =/ v (end 0 1 y.rp) + =/ v (new-end 0 y.rp) =? v (gte x.rp n.domain.c) (add v 2) [v x.rp s] @@ -4486,7 +4486,7 @@ =+ [fadd fmul fpow]=[sum.fop pro.fop exp.fop] =/ ysq (fadd (fpow 3 x) b.domain.c) =/ beta (fpow (rsh 0 2 +(p.domain.c)) ysq) - =/ y ?: =((end 0 1 v.sig) (end 0 1 beta)) + =/ y ?: =((new-end 0 v.sig) (new-end 0 beta)) beta (sub p.domain.c beta) ?> =(0 (dif.fop ysq (fmul y y))) @@ -4577,7 +4577,7 @@ =. v %- mod-word :^ v 12 16 - (cury mix (end 0 64 t)) + (cury mix (new-end [0 64] t)) =. v %- mod-word :^ v 13 16 @@ -4594,7 +4594,7 @@ ?: =(i 12) :: xor upper and lower halves of v into state h =. h (mix h (rsh 6 8 v)) - (mix h (end 6 8 v)) + (mix h (new-end [6 8] v)) :: select message mixing schedule and mix v =. s (snag (mod i 10) sigma) =. v (do-mix 0 4 8 12 0 1) @@ -4644,8 +4644,8 @@ =. out (max 1 (min out 64)) =. wid.msg (min wid.msg (bex 128)) =. wid.key (min wid.key 64) - =. dat.msg (end 3 wid.msg dat.msg) - =. dat.key (end 3 wid.key dat.key) + =. dat.msg (new-end [3 wid.msg] dat.msg) + =. dat.key (new-end [3 wid.key] dat.key) :: initialize state vector =+ h=iv :: mix key length and output length into h0 @@ -4901,7 +4901,7 @@ |= a=@ ^- (pair @ @) :- (rev 3 4 (rsh 5 1 a)) - (rev 3 4 (end 5 1 a)) + (rev 3 4 (new-end 5 a)) :: :: iterate over the entire segment length :: @@ -5113,7 +5113,7 @@ =+ fed=~(. fe 6) =* sum sum:fed =* ror ror:fed - =+ end=(cury (cury end 5) 1) + =+ end=(cury new-end 5) =. a :(sum a b :(mul 2 (end a) (end b))) =. d (ror 0 32 (mix d a)) =. c :(sum c d :(mul 2 (end c) (end d))) @@ -5377,7 +5377,7 @@ ++ pbkdf ::TODO jet me! ++hmac:hmac is an example |* [[prf=$-([byts byts] @) out=@u] p=byts s=byts c=@ d=@] - => .(dat.p (end 3 p), dat.s (end 3 s)) + => .(dat.p (new-end [3 wid.p] dat.p), dat.s (new-end [3 wid.s] dat.s)) :: :: max key length 1GB :: max iterations 2^28 @@ -5411,7 +5411,7 @@ (prf [wid.p (rev 3 p)] [- (rev 3 - u)]) $(u q, f (mix f q), k +(k)) $(t (add t (lsh 3 (mul (dec j) out) f)), j +(j)) - (rev 3 d (end 3 d t)) + (rev 3 d (new-end [3 d] t)) -- -- ::crypto :: :::: @@ -6176,7 +6176,7 @@ ++ en ~/ %en |= a=octs ^- cord - (crip ((x-co:co (mul p.a 2)) (end 3 p.a q.a))) + (crip ((x-co:co (mul p.a 2)) (new-end [3 p.a] q.a))) :: ++ de ~/ %de @@ -6201,7 +6201,7 @@ |- ^- tape ?~ pad ~ - =+ d=(end 0 6 pad) + =+ d=(new-end [0 6] pad) [(cut 3 [d 1] cha) $(pad (rsh 0 6 pad))] (weld (flop (slag poc sif)) (reap poc '=')) :: :: ++de-base64:mimes: @@ -6582,7 +6582,7 @@ =('_' tap) == [tap ~] - ['%' (xen (rsh 0 4 tap)) (xen (end 0 4 tap)) ~] + ['%' (xen (rsh 0 4 tap)) (xen (new-end [0 4] tap)) ~] :: :: ++de-urlt:html ++ de-urlt :: url decode |= tep=tape @@ -6790,7 +6790,7 @@ |= a=(list @t) =+ b=(flop a) ?> ?=(^ b) - =+ c=(end 3 1 i.b) + =+ c=(new-end 3 i.b) ?.(&((gte c 'a') (lte c 'z')) ~ [~ u=b]) (most dot dlab) :: @@ -6970,10 +6970,10 @@ =/ mir (clan who) ?- mir %czar who - %king (end 3 1 who) - %duke (end 4 1 who) - %earl (end 5 1 who) - %pawn (end 4 1 who) + %king (new-end 3 who) + %duke (new-end 4 who) + %earl (new-end 5 who) + %pawn (new-end 4 who) == -- |% @@ -8336,7 +8336,7 @@ ++ address-from-pub =, keccak:crypto |= pub=@ - %^ end 3 20 + %+ new-end [3 20] %+ keccak-256 64 (rev 3 64 pub) :: diff --git a/pkg/arvo/ted/aqua/eyre-azimuth.hoon b/pkg/arvo/ted/aqua/eyre-azimuth.hoon index c8606c2461..1395312edb 100644 --- a/pkg/arvo/ted/aqua/eyre-azimuth.hoon +++ b/pkg/arvo/ted/aqua/eyre-azimuth.hoon @@ -427,7 +427,7 @@ ++ get-public |= [who=@p lyfe=life typ=?(%auth %crypt)] =/ bod (rsh 3 1 pub:ex:(get-keys who lyfe)) - =+ [enc=(rsh 8 1 bod) aut=(end 8 1 bod)] + =+ [enc=(rsh 8 1 bod) aut=(new-end 8 bod)] ?: =(%auth typ) aut enc diff --git a/pkg/arvo/ted/eth/send-txs.hoon b/pkg/arvo/ted/eth/send-txs.hoon index f59d95c48a..ef7e29f628 100644 --- a/pkg/arvo/ted/eth/send-txs.hoon +++ b/pkg/arvo/ted/eth/send-txs.hoon @@ -25,7 +25,7 @@ %+ request-batch-rpc-loose:ethio url %+ turn (scag step-size txs) |= tx=@ux - :- `(scot %ux (end 3 10 tx)) + :- `(scot %ux (new-end [3 10] tx)) [%eth-send-raw-transaction tx] :: parse tx hashes out of responses, bailing on submission failure :: @@ -42,9 +42,9 @@ == :: %error - ?: ?| =('known transaction' (end 3 17 message.res)) - =('Known transaction' (end 3 17 message.res)) - =('Transaction with the same ' (end 3 26 message.res)) + ?: ?| =('known transaction' (new-end [3 17] message.res)) + =('Known transaction' (new-end [3 17] message.res)) + =('Transaction with the same ' (new-end [3 26] message.res)) == ~& [%sent-a-known-transaction--skipping id.res] $(responses t.responses) diff --git a/pkg/arvo/ted/test.hoon b/pkg/arvo/ted/test.hoon index f327adb926..b4abd3af93 100644 --- a/pkg/arvo/ted/test.hoon +++ b/pkg/arvo/ted/test.hoon @@ -71,7 +71,7 @@ :: ++ has-test-prefix |= a=term ^- ? - =((end 3 5 a) 'test-') + =((new-end [3 5] a) 'test-') :: ++ find-test-files =| fiz=(set [=beam test=(unit term)]) diff --git a/pkg/arvo/tests/sys/zuse/crypto/ripemd.hoon b/pkg/arvo/tests/sys/zuse/crypto/ripemd.hoon index 44292ec4b7..5dc1f6e190 100644 --- a/pkg/arvo/tests/sys/zuse/crypto/ripemd.hoon +++ b/pkg/arvo/tests/sys/zuse/crypto/ripemd.hoon @@ -20,7 +20,7 @@ %+ category :: only first 100 chars, meme happens for super long values :: - (trip (end 3 100 msg)) + (trip (new-end [3 100] msg)) %+ expect-eq !> out.i.ves !> `@ux`(ripemd-160 wid (rev 3 wid msg)) From 089852e948e241812012255711eb6fb5290fb7a9 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 1 Dec 2020 20:58:00 -0800 Subject: [PATCH 863/933] hoon: adds +new-lsh, switches all +lsh call sites --- pkg/arvo/gen/hood/moon.hoon | 2 +- pkg/arvo/lib/base64.hoon | 2 +- pkg/arvo/lib/old-phon.hoon | 2 +- pkg/arvo/lib/primitive-rsa.hoon | 2 +- pkg/arvo/lib/ring.hoon | 2 +- pkg/arvo/sys/hoon.hoon | 112 +++++++++++++++++--------------- pkg/arvo/sys/vane/ames.hoon | 6 +- pkg/arvo/sys/zuse.hoon | 77 +++++++++++----------- 8 files changed, 106 insertions(+), 99 deletions(-) diff --git a/pkg/arvo/gen/hood/moon.hoon b/pkg/arvo/gen/hood/moon.hoon index fb841b7836..d941aa760e 100644 --- a/pkg/arvo/gen/hood/moon.hoon +++ b/pkg/arvo/gen/hood/moon.hoon @@ -23,7 +23,7 @@ =/ mon=ship ?^ arg mon.arg - (add our (lsh 5 1 (new-end 5 (shaz eny)))) + (add our (new-lsh 5 (new-end 5 (shaz eny)))) =/ seg=ship (sein:title our now mon) ?. =(our seg) %- %- slog :_ ~ diff --git a/pkg/arvo/lib/base64.hoon b/pkg/arvo/lib/base64.hoon index c280c948ed..287517437d 100644 --- a/pkg/arvo/lib/base64.hoon +++ b/pkg/arvo/lib/base64.hoon @@ -67,7 +67,7 @@ ++ octs-to-blocks |= bs=octs ^- [padding=@ud (list word24)] =/ padding=@ud (~(dif fo 3) 0 p.bs) - =/ padded=octs [(add padding p.bs) (lsh 3 padding (rev 3 bs))] + =/ padded=octs [(add padding p.bs) (new-lsh [3 padding] (rev 3 bs))] [padding (explode-words 24 padded)] :: ++ unpad diff --git a/pkg/arvo/lib/old-phon.hoon b/pkg/arvo/lib/old-phon.hoon index 42433e896a..559cfb7836 100644 --- a/pkg/arvo/lib/old-phon.hoon +++ b/pkg/arvo/lib/old-phon.hoon @@ -90,7 +90,7 @@ |_ [top=@ bot=@] ++ zag [p=(new-end 4 (add top bot)) q=bot] ++ zig [p=(new-end 4 (add top (sub 0x1.0000 bot))) q=bot] - ++ zug (mix (lsh 4 1 top) bot) + ++ zug (mix (new-lsh 4 top) bot) -- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: section 2eN, pseudo-cryptography :: diff --git a/pkg/arvo/lib/primitive-rsa.hoon b/pkg/arvo/lib/primitive-rsa.hoon index 45ae40ff64..4300e5b8ee 100644 --- a/pkg/arvo/lib/primitive-rsa.hoon +++ b/pkg/arvo/lib/primitive-rsa.hoon @@ -36,7 +36,7 @@ :: Sets low bit, as prime must be odd. :: Sets high bit, as +raw:og only gives up to :a bits. :: - =/ e :(con 1 (lsh 0 (dec a) 1) (~(raw og c) a)) + =/ e :(con 1 (new-lsh [0 (dec a)] 1) (~(raw og c) a)) :: XX what algorithm is this modular remainder check? :: ?: ?& (levy b |=(f=@ !=(1 (mod e f)))) diff --git a/pkg/arvo/lib/ring.hoon b/pkg/arvo/lib/ring.hoon index 29e27343f5..d4db64acb5 100644 --- a/pkg/arvo/lib/ring.hoon +++ b/pkg/arvo/lib/ring.hoon @@ -324,7 +324,7 @@ =+ h=(shal (rsh 0 3 b:ed:crypto) sk) %+ add (bex (sub b:ed:crypto 2)) - (lsh 0 3 (cut 0 [3 (sub b:ed:crypto 5)] h)) + (new-lsh [0 3] (cut 0 [3 (sub b:ed:crypto 5)] h)) :: +get-public-key-from-pass: decode the raw @ public key structure :: ++ get-public-key-from-pass diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index ba4777c77a..087a039d80 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -842,12 +842,12 @@ |= [a=bloq b=(list [p=step q=@])] ^- @ ?~ b 0 - (add (new-end [a p.i.b] q.i.b) (lsh a p.i.b $(b t.b))) + (add (new-end [a p.i.b] q.i.b) (new-lsh [a p.i.b] $(b t.b))) :: ++ cat :: concatenate ~/ %cat |= [a=bloq b=@ c=@] - (add (lsh a (met a b) c) b) + (add (new-lsh [a (met a b)] c) b) :: ++ cut :: slice ~/ %cut @@ -873,13 +873,19 @@ |- ^- @ ?: =(n b) (rsh a 1 d) - $(d (add c (lsh a 1 d)), n +(n)) + $(d (add c (new-lsh a d)), n +(n)) :: ++ lsh :: left-shift ~/ %lsh |= [a=bloq b=step c=@] (mul (bex (mul (bex a) b)) c) :: +++ new-lsh :: left-shift + ~/ %new-lsh + |= [a=bite b=@] + =/ [=bloq =step] ?^(a a [a *step]) + (mul b (bex (mul (bex bloq) step))) +:: ++ met :: measure ~/ %met |= [a=bloq b=@] @@ -905,7 +911,7 @@ |- ^- @ ?~ b 0 %+ add $(i +(i), b t.b) - (lsh bloq (mul step i) (new-end [bloq step] i.b)) + (new-lsh [bloq (mul step i)] (new-end [bloq step] i.b)) :: ++ rev :: reverses block order, accounting for leading zeroes @@ -917,8 +923,8 @@ |= [boz=bloq len=@ud dat=@] ^- @ =. dat (new-end [boz len] dat) - %^ lsh boz - (sub len (met boz dat)) + %+ new-lsh + [boz (sub len (met boz dat))] (swp boz dat) :: ++ rip :: disassemble @@ -951,7 +957,7 @@ %+ add (can a b^e c^d ~) =/ f (add b c) - (lsh a f (rsh a f e)) + (new-lsh [a f] (rsh a f e)) :: ++ swp :: naive rev bloq order ~/ %swp @@ -975,19 +981,19 @@ b =+ c=(dec a) %+ con - (lsh c 1 $(a c, b (cut c [0 1] b))) + (new-lsh c $(a c, b (cut c [0 1] b))) $(a c, b (cut c [1 1] b)) ++ out (bex (bex a)) :: mod value ++ rol |= [b=bloq c=@ d=@] ^- @ :: roll left =+ e=(sit d) =+ f=(bex (sub a b)) =+ g=(mod c f) - (sit (con (lsh b g e) (rsh b (sub f g) e))) + (sit (con (new-lsh [b g] e) (rsh b (sub f g) e))) ++ ror |= [b=bloq c=@ d=@] ^- @ :: roll right =+ e=(sit d) =+ f=(bex (sub a b)) =+ g=(mod c f) - (sit (con (rsh b g e) (lsh b (sub f g) e))) + (sit (con (rsh b g e) (new-lsh [b (sub f g)] e))) ++ sum |=([b=@ c=@] (sit (add b c))) :: wrapping add ++ sit |=(b=@ (new-end a b)) :: enforce modulo -- @@ -1006,7 +1012,7 @@ b (rsh 0 1 b) c +(c) d %+ add d - %^ lsh 0 c + %+ new-lsh [0 c] ?& =(0 (new-end 0 a)) =(0 (new-end 0 b)) == @@ -1023,7 +1029,7 @@ b (rsh 0 1 b) c +(c) d %+ add d - %^ lsh 0 c + %+ new-lsh [0 c] ?| =(0 (new-end 0 a)) =(0 (new-end 0 b)) == @@ -1040,7 +1046,7 @@ a (rsh 0 1 a) b (rsh 0 1 b) c +(c) - d (add d (lsh 0 c =((new-end 0 a) (new-end 0 b)))) + d (add d (new-lsh [0 c] =((new-end 0 a) (new-end 0 b)))) == :: ++ not |= [a=bloq b=@ c=@] :: binary not (sized) @@ -1076,14 +1082,14 @@ =/ tlen (dis len 3) =. h1 ?+ tlen h1 :: fallthrough switch - %3 =. k1 (mix k1 (lsh 0 16 (snag 2 tail))) - =. k1 (mix k1 (lsh 0 8 (snag 1 tail))) + %3 =. k1 (mix k1 (new-lsh [0 16] (snag 2 tail))) + =. k1 (mix k1 (new-lsh [0 8] (snag 1 tail))) =. k1 (mix k1 (snag 0 tail)) =. k1 (sit (mul k1 c1)) =. k1 (rol 0 15 k1) =. k1 (sit (mul k1 c2)) (mix h1 k1) - %2 =. k1 (mix k1 (lsh 0 8 (snag 1 tail))) + %2 =. k1 (mix k1 (new-lsh [0 8] (snag 1 tail))) =. k1 (mix k1 (snag 0 tail)) =. k1 (sit (mul k1 c1)) =. k1 (rol 0 15 k1) @@ -2066,16 +2072,16 @@ => .(m (~(put by m) a b)) ?: ?=(@ a) =+ d=(mat a) - [(add 1 p.d) (lsh 0 1 q.d) m] + [(add 1 p.d) (new-lsh 0 q.d) m] => .(b (add 2 b)) =+ d=$(a -.a) =+ e=$(a +.a, b (add b p.d), m r.d) - [(add 2 (add p.d p.e)) (mix 1 (lsh 0 2 (cat 0 q.d q.e))) r.e] + [(add 2 (add p.d p.e)) (mix 1 (new-lsh [0 2] (cat 0 q.d q.e))) r.e] ?: ?&(?=(@ a) (lte (met 0 a) (met 0 u.c))) =+ d=(mat a) - [(add 1 p.d) (lsh 0 1 q.d) m] + [(add 1 p.d) (new-lsh 0 q.d) m] =+ d=(mat u.c) - [(add 2 p.d) (mix 3 (lsh 0 2 q.d)) m] + [(add 2 p.d) (mix 3 (new-lsh [0 2] q.d)) m] :: ++ mat :: length-encode ~/ %mat @@ -2086,7 +2092,7 @@ =+ b=(met 0 a) =+ c=(met 0 b) :- (add (add c c) b) - (cat 0 (bex c) (mix (new-end [0 (dec c)] b) (lsh 0 (dec c) a))) + (cat 0 (bex c) (mix (new-end [0 (dec c)] b) (new-lsh [0 (dec c)] a))) :: ++ rub :: length-decode ~/ %rub @@ -2286,7 +2292,7 @@ =+ q=(dif:si e.a e.b) |- ?. (syn:si q) $(b a, a b, q +(q)) :: a has larger exp ?: e - [%f & e.b (^add (lsh 0 (abs:si q) a.a) a.b)] + [%f & e.b (^add (new-lsh [0 (abs:si q)] a.a) a.b)] =+ [ma=(met 0 a.a) mb=(met 0 a.b)] =+ ^= w %+ dif:si e.a %- sun:si :: expanded exp of a ?: (gth prc ma) (^sub prc ma) 0 @@ -2297,7 +2303,7 @@ %a (lug %lg a &) %u (lug %lg a &) %n (lug %na a &) == - (rou [e.b (^add (lsh 0 (abs:si q) a.a) a.b)]) + (rou [e.b (^add (new-lsh [0 (abs:si q)] a.a) a.b)]) :: ++ sub :: subtract; exact if e |= [a=[e=@s a=@u] b=[e=@s a=@u] e=?] ^- fn @@ -2314,7 +2320,7 @@ %a (lug %ce a &) %u (lug %ce a &) %n (lug %nt a &) == - =+ j=(lsh 0 (abs:si q) a.a) + =+ j=(new-lsh [0 (abs:si q)] a.a) |- ?. (gte j a.b) (fli $(a.b j, j a.b, r swr)) =+ i=(^sub j a.b) @@ -2330,7 +2336,7 @@ =+ [ma=(met 0 a.a) mb=(met 0 a.b)] =+ v=(dif:si (sun:si ma) (sun:si +((^add mb prc)))) =. a ?: (syn:si v) a - a(e (sum:si v e.a), a (lsh 0 (abs:si v) a.a)) + a(e (sum:si v e.a), a (new-lsh [0 (abs:si v)] a.a)) =+ [j=(dif:si e.a e.b) q=(dvr a.a a.b)] (rau [j p.q] =(q.q 0)) :: @@ -2341,7 +2347,7 @@ =+ ?:((^lth w x) (^sub x w) 0) =+ ?: =((dis - 1) (dis (abs:si e.a) 1)) - (^add - 1) - a(e (dif:si e.a (sun:si -)), a (lsh 0 - a.a)) + a(e (dif:si e.a (sun:si -)), a (new-lsh [0 -] a.a)) =+ [y=(^sqt a.a) z=(fra:si e.a --2)] (rau [z p.y] =(q.y 0)) :: @@ -2352,14 +2358,14 @@ ?: =(c -1) & ?: =(c --1) | ?: =((cmp:si e.a e.b) -1) (^lth (rsh 0 (abs:si (dif:si e.a e.b)) a.a) a.b) - (^lth (lsh 0 (abs:si (dif:si e.a e.b)) a.a) a.b) + (^lth (new-lsh [0 (abs:si (dif:si e.a e.b))] a.a) a.b) :: ++ equ :: equals |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- ? ?. =((ibl a) (ibl b)) | ?: =((cmp:si e.a e.b) -1) - =((lsh 0 (abs:si (dif:si e.a e.b)) a.b) a.a) - =((lsh 0 (abs:si (dif:si e.a e.b)) a.a) a.b) + =((new-lsh [0 (abs:si (dif:si e.a e.b))] a.b) a.a) + =((new-lsh [0 (abs:si (dif:si e.a e.b))] a.a) a.b) :: :: integer binary logarithm: 2^ibl(a) <= |a| < 2^(ibl(a)+1) ++ ibl @@ -2383,7 +2389,7 @@ =+ w=(dif:si e.a emn) ?: (syn:si w) (abs:si w) 0 (min q (^sub prc ma)) - a(e (dif:si e.a (sun:si -)), a (lsh 0 - a.a)) + a(e (dif:si e.a (sun:si -)), a (new-lsh [0 -] a.a)) :: :: central rounding mechanism :: can perform: floor, ceiling, smaller, larger, @@ -2460,9 +2466,9 @@ |= [a=[e=@s a=@u]] ^- [@s @u] :: guaranteed accurate ?< =(a.a 0) :: for rounded floats =. a (xpd a) - =+ r=(lsh 0 ?:((syn:si e.a) (abs:si e.a) 0) a.a) - =+ s=(lsh 0 ?.((syn:si e.a) (abs:si e.a) 0) 1) - =+ mn=(lsh 0 ?:((syn:si e.a) (abs:si e.a) 0) 1) + =+ r=(new-lsh [0 ?:((syn:si e.a) (abs:si e.a) 0)] a.a) + =+ s=(new-lsh [0 ?.((syn:si e.a) (abs:si e.a) 0)] 1) + =+ mn=(new-lsh [0 ?:((syn:si e.a) (abs:si e.a) 0)] 1) =+ mp=mn => ?. ?& =(a.a (bex (dec prc))) :: if next smallest @@ -2470,9 +2476,9 @@ == :: tighten lower bound . %= . - mp (lsh 0 1 mp) - r (lsh 0 1 r) - s (lsh 0 1 s) + mp (new-lsh 0 mp) + r (new-lsh 0 r) + s (new-lsh 0 s) == =+ [k=--0 q=(^div (^add s 9) 10)] |- ?: (^lth r q) @@ -2760,9 +2766,9 @@ ++ bif :: fn to @r no rounding |= [a=fn] ^- @r ?: ?=([%i *] a) - =+ q=(lsh 0 p (fil 0 w 1)) + =+ q=(new-lsh [0 p] (fil 0 w 1)) ?: s.a q (^add q sb) - ?: ?=([%n *] a) (lsh 0 (dec p) (fil 0 +(w) 1)) + ?: ?=([%n *] a) (new-lsh [0 (dec p)] (fil 0 +(w) 1)) ?~ a.a ?: s.a `@r`0 sb =+ ma=(met 0 a.a) ?. =(ma +(p)) @@ -2770,7 +2776,7 @@ ?> (^lth ma +(p)) ?: s.a `@r`a.a (^add a.a sb) =+ q=(sum:si (dif:si e.a me) --1) - =+ r=(^add (lsh 0 p (abs:si q)) (new-end [0 p] a.a)) + =+ r=(^add (new-lsh [0 p] (abs:si q)) (new-end [0 p] a.a)) ?: s.a r (^add r sb) :: ++ sig :: get sign @@ -3213,8 +3219,8 @@ ?~ f.rip 0 => .(muc (dec muc)) - (add (lsh 4 muc i.f.rip) $(f.rip t.f.rip)) - (con (lsh 6 1 sec) fac) + (add (new-lsh [4 muc] i.f.rip) $(f.rip t.f.rip)) + (con (new-lsh 6 sec) fac) :: ++ yall :: day / to day of year |= day=@ud @@ -3313,7 +3319,7 @@ => .(ruz (cut 3 [0 len] ruz)) =+ [few==>(fe .(a 5)) wac=|=([a=@ b=@] (cut 5 [a 1] b))] =+ [sum=sum.few ror=ror.few net=net.few inv=inv.few] - =+ ral=(lsh 0 3 len) + =+ ral=(new-lsh [0 3] len) =+ ^= ful %+ can 0 :~ [ral ruz] @@ -3359,7 +3365,7 @@ =+ x=:(mix (ror 0 7 l) (ror 0 18 l) (rsh 0 3 l)) =+ y=:(mix (ror 0 17 m) (ror 0 19 m) (rsh 0 10 m)) =+ z=:(sum n x o y) - $(wox (con (lsh 5 j z) wox), j +(j)) + $(wox (con (new-lsh [5 j] z) wox), j +(j)) =+ j=0 =+ :* a=(wac 0 hax) b=(wac 1 hax) @@ -3407,7 +3413,7 @@ => .(ruz (cut 3 [0 len] ruz)) =+ [few==>(fe .(a 6)) wac=|=([a=@ b=@] (cut 6 [a 1] b))] =+ [sum=sum.few ror=ror.few net=net.few inv=inv.few] - =+ ral=(lsh 0 3 len) + =+ ral=(new-lsh [0 3] len) =+ ^= ful %+ can 0 :~ [ral ruz] @@ -3479,7 +3485,7 @@ =+ x=:(mix (ror 0 1 l) (ror 0 8 l) (rsh 0 7 l)) =+ y=:(mix (ror 0 19 m) (ror 0 61 m) (rsh 0 6 m)) =+ z=:(sum n x o y) - $(wox (con (lsh 6 j z) wox), j +(j)) + $(wox (con (new-lsh [6 j] z) wox), j +(j)) =+ j=0 =+ :* a=(wac 0 hax) b=(wac 1 hax) @@ -3517,7 +3523,7 @@ |= ruz=@ =+ [few==>(fe .(a 5)) wac=|=([a=@ b=@] (cut 5 [a 1] b))] =+ [sum=sum.few ror=ror.few rol=rol.few net=net.few inv=inv.few] - =+ ral=(lsh 0 3 (met 3 ruz)) + =+ ral=(new-lsh [0 3] (met 3 ruz)) =+ ^= ful %+ can 0 :~ [ral ruz] @@ -3545,7 +3551,7 @@ o=(wac (sub j 16) wox) == =+ z=(rol 0 1 :(mix l m n o)) - $(wox (con (lsh 5 j z) wox), j +(j)) + $(wox (con (new-lsh [5 j] z) wox), j +(j)) =+ j=0 =+ :* a=(wac 0 hax) b=(wac 1 hax) @@ -3641,7 +3647,7 @@ ^- @ =+ [few==>(fe .(a 5)) wac=|=([a=@ b=@] (cut 5 [a 1] b))] =+ [sum=sum.few ror=ror.few rol=rol.few net=net.few inv=inv.few] - =+ ral=(lsh 0 3 wid) + =+ ral=(new-lsh [0 3] wid) =+ ^= ful %+ can 0 :~ [ral (rev 3 wid dat)] @@ -3669,7 +3675,7 @@ o=(wac (sub j 16) wox) == =+ z=(rol 0 1 :(mix l m n o)) - $(wox (con (lsh 5 j z) wox), j +(j)) + $(wox (con (new-lsh [5 j] z) wox), j +(j)) =+ j=0 =+ :* a=(wac 0 hax) b=(wac 1 hax) @@ -4139,17 +4145,17 @@ =- yek:(roll (rip 3 key) -) =+ [a=*char b=*@ yek=`@ux`(fil 3 256 0xff)] |. - [+(b) (mix yek (lsh 3 `@u`a (~(inv fe 3) b)))] + [+(b) (mix yek (new-lsh [3 `@u`a] (~(inv fe 3) b)))] |% ++ cha |=(a=char `(unit @uF)`=+(b=(cut 3 [`@`a 1] yek) ?:(=(b 0xff) ~ `b))) ++ tok |= a=@ux ^- @ux =+ b=(pad a) =- (~(net fe 5) (new-end [3 4] (shay 32 -))) - (shay (add b (met 3 a)) (lsh 3 b (swp 3 a))) + (shay (add b (met 3 a)) (new-lsh [3 b] (swp 3 a))) :: ++ pad |=(a=@ =+(b=(met 3 a) ?:((gte b 21) 0 (sub 21 b)))) - ++ enc |=(a=@ux `@ux`(mix (lsh 3 4 a) (tok a))) + ++ enc |=(a=@ux `@ux`(mix (new-lsh [3 4] a) (tok a))) ++ den |= a=@ux ^- (unit @ux) =+ b=(rsh 3 4 a) @@ -5442,7 +5448,7 @@ |_ [top=@ bot=@] ++ zag [p=(new-end 4 (add top bot)) q=bot] ++ zig [p=(new-end 4 (add top (sub 0x1.0000 bot))) q=bot] - ++ zug (mix (lsh 4 1 top) bot) + ++ zug (mix (new-lsh 4 top) bot) -- ++ ne |_ tig=@ diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index b603b0f1ea..1d5350e325 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -2953,8 +2953,8 @@ =/ body=@ ;: mix sndr - (lsh 3 size.sndr-meta rcvr) - (lsh 3 (add size.sndr-meta size.rcvr-meta) (jam [origin content])) + (new-lsh [3 size.sndr-meta] rcvr) + (new-lsh [3 (add size.sndr-meta size.rcvr-meta)] (jam [origin content])) == :: header: 32-bit header assembled from bitstreams of fields :: @@ -2971,7 +2971,7 @@ == :: result is <
> :: - (mix header (lsh 5 1 body)) + (mix header (new-lsh 5 body)) :: +decode-packet: deserialize packet from bytestream or crash :: ++ decode-packet diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index dd512d410b..ae431eeb9f 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -2447,8 +2447,8 @@ ~| [%dub-ga a] ?> (lth b si) ?: =(1 (cut 0 [(dec p.a) 1] b)) - (dif (sit q.a) (sit (lsh 0 1 b))) - (lsh 0 1 b) + (dif (sit q.a) (sit (new-lsh 0 b))) + (new-lsh 0 b) :: :: ++pro:ga:number ++ pro :: slow multiply |= [b=@ c=@] @@ -3040,8 +3040,8 @@ ^- @uxH %- ~(sit fe 7) ?. =((xeb str) 128) - (lsh 0 1 str) - (mix 0x87 (lsh 0 1 str)) + (new-lsh 0 str) + (mix 0x87 (new-lsh 0 str)) :: :: ++mpad:aes:crypto ++ mpad :: |= [oct=@ txt=@] @@ -3054,7 +3054,7 @@ ^- @ux =+ pad=(mod oct 16) ?: =(pad 0) 0x8000.0000.0000.0000.0000.0000.0000.0000 - (lsh 3 (sub 15 pad) (mix 0x80 (lsh 3 1 txt))) + (new-lsh [3 (sub 15 pad)] (mix 0x80 (new-lsh 3 txt))) :: :: ++suba:aes:crypto ++ suba :: AES-128 subkeys |= key=@H @@ -3429,7 +3429,7 @@ =+ ^= a %+ add (bex (sub b 2)) - (lsh 0 3 (cut 0 [3 (sub b 5)] h)) + (new-lsh [0 3] (cut 0 [3 (sub b 5)] h)) =+ aa=(scam bb a) (etch aa) :: :: ++suck:ed:crypto @@ -3444,7 +3444,7 @@ ^- @ux =+ exp=(shal (rsh 0 3 b) (suck sek)) =. exp (dis exp (can 0 ~[[3 0] [251 (fil 0 251 1)]])) - =. exp (con exp (lsh 3 31 0b100.0000)) + =. exp (con exp (new-lsh [3 31] 0b100.0000)) =+ prv=(new-end 8 exp) =+ crv=(fra.fq (sum.fq 1 pub) (dif.fq 1 pub)) (curt prv crv) @@ -3458,7 +3458,7 @@ =+ ^= a %+ add (bex (sub b 2)) - (lsh 0 3 (cut 0 [3 (sub b 5)] h)) + (new-lsh [0 3] (cut 0 [3 (sub b 5)] h)) =+ ^= r =+ hm=(cut 0 [b b] h) =+ ^= i @@ -3507,7 +3507,7 @@ =+ few==>(fe .(a 5)) =+ ^= rot |= [a=@ b=@] - (mix (new-end 5 (lsh 0 a b)) (rsh 0 (sub 32 a) b)) + (mix (new-end 5 (new-lsh [0 a] b)) (rsh 0 (sub 32 a) b)) =+ ^= lea |= [a=@ b=@] (net:few (sum:few (net:few a) (net:few b))) @@ -3627,9 +3627,9 @@ =+ b=64 =? k (gth kl b) (shay kl k) =+ ^= q %+ shay (add b tl) - (add (lsh 3 b t) (mix k (fil 3 b 0x36))) + (add (new-lsh [3 b] t) (mix k (fil 3 b 0x36))) %+ shay (add b 32) - (add (lsh 3 b q) (mix k (fil 3 b 0x5c))) + (add (new-lsh [3 b] q) (mix k (fil 3 b 0x5c))) :: :: ++pbk:scr:crypto ++ pbk :: PBKDF2-HMAC-SHA256 ~/ %pbk @@ -3656,12 +3656,12 @@ =+ [t=0 j=1 k=1] =. t |- ^- @ ?: (gth j l) t - =+ u=(add s (lsh 3 sl (rep 3 (flop (rpp 3 4 j))))) + =+ u=(add s (new-lsh [3 sl] (rep 3 (flop (rpp 3 4 j))))) =+ f=0 =. f |- ^- @ ?: (gth k c) f =+ q=(hml p pl u ?:(=(k 1) (add sl 4) h)) $(u q, f (mix f q), k +(k)) - $(t (add t (lsh 3 (mul (dec j) h) f)), j +(j)) + $(t (add t (new-lsh [3 (mul (dec j) h)] f)), j +(j)) (new-end [3 d] t) :: :: ++hsh:scr:crypto ++ hsh :: scrypt @@ -3934,7 +3934,7 @@ :- (add p.inp +(pal)) :: padding is provided in lane bit ordering, :: ie, LSB = left. - (cat 3 (con (lsh 3 pal dsb) 0x80) q.inp) + (cat 3 (con (new-lsh [3 pal] dsb) 0x80) q.inp) :: ++ sponge :: sponge construction @@ -3977,7 +3977,7 @@ %+ roll pieces |= [p=@ s=@] :: pad with capacity, - =. p (lsh 0 capacity p) + =. p (new-lsh [0 capacity] p) :: xor it into the state and permute it. (permute (mix s (bytes-to-lanes p))) :: @@ -3988,7 +3988,7 @@ :: append a bitrate-sized head of state to the :: result. =. res - %+ con (lsh 0 bitrate res) + %+ con (new-lsh [0 bitrate] res) (rsh 0 capacity (lanes-to-bytes state)) =. len (add len bitrate) ?: (gte len output) @@ -4000,7 +4000,7 @@ :: flip byte order in blocks of 8 bytes. |= a=@ %^ run 6 a - |=(b=@ (lsh 3 (sub 8 (met 3 b)) (swp 3 b))) + |=(b=@ (new-lsh [3 (sub 8 (met 3 b))] (swp 3 b))) :: ++ lanes-to-bytes :: unflip byte order in blocks of 8 bytes. @@ -4041,14 +4041,14 @@ =/ c=@ %+ roll (gulf 0 (dec size)) |= [x=@ud c=@] - %+ con (lsh lane-bloq 1 c) + %+ con (new-lsh [lane-bloq 1] c) %+ roll (gulf 0 (dec size)) |= [y=@ud c=@] (mix c (get-lane x y a)) =/ d=@ %+ roll (gulf 0 (dec size)) |= [x=@ud d=@] - %+ con (lsh lane-bloq 1 d) + %+ con (new-lsh [lane-bloq 1] d) %+ mix =- (get-word - size c) ?:(=(x 0) (dec size) (dec x)) @@ -4058,8 +4058,8 @@ %+ roll (gulf 0 (dec lanes)) |= [i=@ud a=_a] %+ mix a - %^ lsh lane-bloq - (sub lanes +(i)) + %+ new-lsh + [lane-bloq (sub lanes +(i))] (get-word i size d) :: :: rho and pi @@ -4069,7 +4069,8 @@ =+ x=(mod i 5) =+ y=(div i 5) %+ con b - %^ lsh lane-bloq + %+ new-lsh + :- lane-bloq %+ sub lanes %+ add +(y) %+ mul size @@ -4082,7 +4083,7 @@ =. a %+ roll (gulf 0 (dec lanes)) |= [i=@ud a=@] - %+ con (lsh lane-bloq 1 a) + %+ con (new-lsh lane-bloq a) =+ x=(mod i 5) =+ y=(div i 5) %+ mix (get-lane x y b) @@ -4095,7 +4096,7 @@ :: iota =. a =+ (round-constant round) - (mix a (lsh lane-bloq (dec lanes) -)) + (mix a (new-lsh [lane-bloq (dec lanes)] -)) :: :: next round $(round +(round)) @@ -4197,14 +4198,14 @@ =? dat.key (gth wid.key boq) (haj wid.key dat.key) =? wid.key (gth wid.key boq) out :: keys shorter than block size are right-padded - =? dat.key (lth wid.key boq) (lsh 3 (sub boq wid.key) dat.key) + =? dat.key (lth wid.key boq) (new-lsh [3 (sub boq wid.key)] dat.key) :: pad key, inner and outer =+ kip=(mix dat.key (fil 3 boq 0x36)) =+ kop=(mix dat.key (fil 3 boq 0x5c)) :: append inner padding to message, then hash - =+ (haj (add wid.msg boq) (add (lsh 3 wid.msg kip) dat.msg)) + =+ (haj (add wid.msg boq) (add (new-lsh [3 wid.msg] kip) dat.msg)) :: prepend outer padding to result, hash again - (haj (add out boq) (add (lsh 3 out kop) -)) + (haj (add out boq) (add (new-lsh [3 out] kop) -)) -- :: hmac :: :: :::: ++secp:crypto :: (2b9) secp family @@ -4566,13 +4567,13 @@ :: ++ pad |= [byts len=@ud] - (lsh 3 (sub len wid) dat) + (new-lsh [3 (sub len wid)] dat) :: ++ compress |= [h=@ c=@ t=@ud l=?] ^- @ :: set up local work vector - =+ v=(add (lsh 6 8 h) iv) + =+ v=(add (new-lsh [6 8] h) iv) :: xor the counter t into v =. v %- mod-word @@ -4654,7 +4655,7 @@ :^ h 0 8 %+ cury mix %+ add 0x101.0000 - (add (lsh 3 1 wid.key) out) + (add (new-lsh 3 wid.key) out) :: keep track of how much we've compressed =* mes dat.msg =+ com=0 @@ -4882,7 +4883,7 @@ =/ random-block=@ %+ compress 0 %+ compress 0 - %^ lsh 3 968 + %+ new-lsh [3 968] %+ rep 6 =+ (cury (cury rev 3) 8) :~ (- counter) @@ -5149,9 +5150,9 @@ |- ?: (gth out 64) =. tmp (blake2b 64^tmp 0^0 64) - =. res (add (lsh 3 32 res) (rsh 3 32 tmp)) + =. res (add (new-lsh [3 32] res) (rsh 3 32 tmp)) $(out (sub out 32)) - %+ add (lsh 3 out res) + %+ add (new-lsh [3 out] res) (blake2b 64^tmp 0^0 out) :: :: utilities @@ -5339,7 +5340,7 @@ =+ (sub 511 (mod (add wid 64) 512)) :- :(add 64 +(-) wid) %+ can 0 - ~[64^(rev 3 8 wid) +(-)^(lsh 0 - 1) wid^dat] + ~[64^(rev 3 8 wid) +(-)^(new-lsh [0 -] 1) wid^dat] -- :: ++ pbkdf @@ -5398,7 +5399,7 @@ ?: (gth j l) t =/ u %+ add dat.s - %^ lsh 3 wid.s + %+ new-lsh [3 wid.s] %+ rep 3 (flop (rpp:scr 3 4 j)) =+ f=0 @@ -5410,7 +5411,7 @@ =+ ?:(=(k 1) (add wid.s 4) out) (prf [wid.p (rev 3 p)] [- (rev 3 - u)]) $(u q, f (mix f q), k +(k)) - $(t (add t (lsh 3 (mul (dec j) out) f)), j +(j)) + $(t (add t (new-lsh [3 (mul (dec j) out)] f)), j +(j)) (rev 3 d (new-end [3 d] t)) -- -- ::crypto @@ -6194,7 +6195,7 @@ |= tig=@ ^- tape =+ poc=(~(dif fo 3) 0 (met 3 tig)) - =+ pad=(lsh 3 poc (swp 3 tig)) + =+ pad=(new-lsh [3 poc] (swp 3 tig)) =+ ^= cha 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' =+ ^= sif @@ -6590,7 +6591,7 @@ ?~ tep [~ ~] ?: =('%' i.tep) ?. ?=([@ @ *] t.tep) ~ - =+ nag=(mix i.t.tep (lsh 3 1 i.t.t.tep)) + =+ nag=(mix i.t.tep (new-lsh 3 i.t.t.tep)) =+ val=(rush nag hex:ag) ?~ val ~ =+ nex=$(tep t.t.t.tep) From bec63413b03c49f6d842ff3b805631abb247891a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 1 Dec 2020 22:30:36 -0800 Subject: [PATCH 864/933] hoon: adds +new-rsh, switches all +rsh call sites --- pkg/arvo/app/chat-cli.hoon | 2 +- pkg/arvo/app/dbug.hoon | 2 +- pkg/arvo/app/dojo.hoon | 4 +- pkg/arvo/app/file-server.hoon | 2 +- pkg/arvo/app/glob.hoon | 2 +- pkg/arvo/gen/key.hoon | 4 +- pkg/arvo/lib/bip32.hoon | 10 +- pkg/arvo/lib/bip39.hoon | 4 +- pkg/arvo/lib/der.hoon | 2 +- pkg/arvo/lib/keygen.hoon | 8 +- pkg/arvo/lib/language-server/easy-print.hoon | 2 +- pkg/arvo/lib/link-store.hoon | 2 +- pkg/arvo/lib/pkcs.hoon | 2 +- pkg/arvo/lib/primitive-rsa.hoon | 2 +- pkg/arvo/lib/ring.hoon | 10 +- pkg/arvo/lib/shoe.hoon | 2 +- pkg/arvo/mar/hash.hoon | 2 +- pkg/arvo/sys/arvo.hoon | 4 +- pkg/arvo/sys/hoon.hoon | 115 ++++++++++--------- pkg/arvo/sys/vane/ames.hoon | 14 +-- pkg/arvo/sys/vane/eyre.hoon | 4 +- pkg/arvo/sys/zuse.hoon | 103 +++++++++-------- pkg/arvo/ted/aqua/eyre-azimuth.hoon | 4 +- 23 files changed, 156 insertions(+), 150 deletions(-) diff --git a/pkg/arvo/app/chat-cli.hoon b/pkg/arvo/app/chat-cli.hoon index 830424815f..65c3b70cd9 100644 --- a/pkg/arvo/app/chat-cli.hoon +++ b/pkg/arvo/app/chat-cli.hoon @@ -767,7 +767,7 @@ :- %chat-view-action !> ^- action:view :* %create - (rsh 3 1 (spat path)) + (new-rsh 3 (spat path)) '' real-path :: chat group-path :: group diff --git a/pkg/arvo/app/dbug.hoon b/pkg/arvo/app/dbug.hoon index fb0c81a4d7..d1e542b7f4 100644 --- a/pkg/arvo/app/dbug.hoon +++ b/pkg/arvo/app/dbug.hoon @@ -362,7 +362,7 @@ (gth expiry-time.a expiry-time.b) |= [cookie=@uv session:eyre] %- pairs - :~ 'cookie'^s+(new-end [3 4] (rsh 3 2 (scot %x (shax cookie)))) + :~ 'cookie'^s+(new-end [3 4] (new-rsh [3 2] (scot %x (shax cookie)))) 'expiry'^(time expiry-time) 'channels'^(numb ~(wyt in channels)) == diff --git a/pkg/arvo/app/dojo.hoon b/pkg/arvo/app/dojo.hoon index 04a3b7eb9f..f55fe657cf 100644 --- a/pkg/arvo/app/dojo.hoon +++ b/pkg/arvo/app/dojo.hoon @@ -1249,7 +1249,7 @@ =/ advance (advance-hoon:auto typ p.q.q.p.u.q.vex) =? res ?=(^ advance) =/ to-send - (trip (rsh 3 (sub pos back-pos) u.advance)) + (trip (new-rsh [3 (sub pos back-pos)] u.advance)) =| fxs=(list sole-effect) =. . |- ^+ +.$ @@ -1403,7 +1403,7 @@ =/ back-pos (sub pos (met 3 completing)) =/ to-send - (trip (rsh 3 (sub pos back-pos) advance)) + (trip (new-rsh [3 (sub pos back-pos)] advance)) =| fxs=(list sole-effect) :: :: Cursor is guaranteed to be at end so we don't worry about the diff --git a/pkg/arvo/app/file-server.hoon b/pkg/arvo/app/file-server.hoon index 9c8d334ace..52f94ca363 100644 --- a/pkg/arvo/app/file-server.hoon +++ b/pkg/arvo/app/file-server.hoon @@ -234,7 +234,7 @@ ?~ data [not-found:gen %.n] :_ public.u.content - =/ mime-type=@t (rsh 3 1 (crip )) + =/ mime-type=@t (new-rsh 3 (crip )) :: Should maybe inspect to see how long cache should hold :: [[200 ['content-type' mime-type] max-1-da:gen ~] `q.u.data] diff --git a/pkg/arvo/app/glob.hoon b/pkg/arvo/app/glob.hoon index 94618d032e..eef64e1154 100644 --- a/pkg/arvo/app/glob.hoon +++ b/pkg/arvo/app/glob.hoon @@ -98,7 +98,7 @@ !=('sj.' (new-end [3 3] (swp 3 file))) == out - ``@t`(rsh 3 6 file) + ``@t`(new-rsh [3 6] file) =/ js-name (cat 3 'index.' bundle-hash) =/ map-name diff --git a/pkg/arvo/gen/key.hoon b/pkg/arvo/gen/key.hoon index 7fb8e7841b..4af7b21d9b 100644 --- a/pkg/arvo/gen/key.hoon +++ b/pkg/arvo/gen/key.hoon @@ -19,8 +19,8 @@ =/ pub=pass pub:ex:cub =/ mag=cord (new-end 3 pub) ?> =('b' mag) -=/ bod=@ (rsh 3 1 pub) -=/ cry=@ (rsh 8 1 bod) +=/ bod=@ (new-rsh 3 pub) +=/ cry=@ (new-rsh 8 bod) =/ sgn=@ (new-end 8 bod) %+ print leaf+" authentication: 0x{(render-hex-bytes:ethereum 32 sgn)}" %+ print leaf+" networking: 0x{(render-hex-bytes:ethereum 32 cry)}" diff --git a/pkg/arvo/lib/bip32.hoon b/pkg/arvo/lib/bip32.hoon index a2f1cc32d1..d92145f930 100644 --- a/pkg/arvo/lib/bip32.hoon +++ b/pkg/arvo/lib/bip32.hoon @@ -57,7 +57,7 @@ |= b=@ud ^- [v=@ x=@] :- (new-end [3 b] x) - (rsh 3 b x) + (new-rsh [3 b] x) -- =^ k x (take 33) =^ c x (take 32) @@ -173,7 +173,7 @@ ^- @uc :: removes checksum :: - %^ rsh 3 4 + %+ new-rsh [3 4] %+ en-base58check [4 (version-bytes network %pub %.n)] [20 identity] @@ -211,15 +211,15 @@ |= [v=byts d=byts] =+ p=[(add wid.v wid.d) (can 3 ~[d v])] =- (can 3 ~[4^- p]) - %^ rsh 3 28 + %+ new-rsh [3 28] (sha-256l:sha 32 (sha-256l:sha p)) :: ++ de-base58check :: vw: amount of version bytes |= [vw=@u t=tape] =+ x=(de-base58:mimes:html t) - =+ hash=(sha-256l:sha 32 (sha-256:sha (rsh 3 4 x))) - ?> =((new-end [3 4] x) (rsh 3 28 hash)) + =+ hash=(sha-256l:sha 32 (sha-256:sha (new-rsh [3 4] x))) + ?> =((new-end [3 4] x) (new-rsh [3 28] hash)) (cut 3 [vw (sub (met 3 x) (add 4 vw))] x) :: ++ hash160 diff --git a/pkg/arvo/lib/bip39.hoon b/pkg/arvo/lib/bip39.hoon index b0736f3aa5..01d97c01d5 100644 --- a/pkg/arvo/lib/bip39.hoon +++ b/pkg/arvo/lib/bip39.hoon @@ -12,7 +12,7 @@ :: =+ cs=(div wid 32) =/ check=@ - %^ rsh 0 (sub 256 cs) + %+ new-rsh [0 (sub 256 cs)] (sha-256l:sha (div wid 8) dat) =/ bits=byts :- (add wid cs) @@ -25,7 +25,7 @@ |- ^- (list @) :- (new-end [0 11] dat.bits) ?: (lte wid.bits 11) ~ - $(bits [(sub wid.bits 11) (rsh 0 11 dat.bits)]) + $(bits [(sub wid.bits 11) (new-rsh [0 11] dat.bits)]) :: =/ words=(list tape) %+ turn pieces diff --git a/pkg/arvo/lib/der.hoon b/pkg/arvo/lib/der.hoon index f8f667b65c..a7f48411d2 100644 --- a/pkg/arvo/lib/der.hoon +++ b/pkg/arvo/lib/der.hoon @@ -145,7 +145,7 @@ ?. =(0 (new-end 3 dat)) ~ :+ ~ (mul 8 (dec len)) - (rsh 3 1 dat) + (new-rsh 3 dat) :: +recur:parse:der: parse bytes for a list of +spec:asn1 :: ++ recur diff --git a/pkg/arvo/lib/keygen.hoon b/pkg/arvo/lib/keygen.hoon index e8c947ea3e..89cff138b0 100644 --- a/pkg/arvo/lib/keygen.hoon +++ b/pkg/arvo/lib/keygen.hoon @@ -96,11 +96,11 @@ =+ =< [pub=pub:ex sec=sec:ex] (pit:nu:crub:crypto 256 seed) :- ^= auth - :- (rsh 3 1 (new-end [3 33] pub)) - (rsh 3 1 (new-end [3 33] sec)) + :- (new-rsh 3 (new-end [3 33] pub)) + (new-rsh 3 (new-end [3 33] sec)) ^= crypt - :- (rsh 3 33 pub) - (rsh 3 33 sec) + :- (new-rsh [3 33] pub) + (new-rsh [3 33] sec) :: ++ seed |= [seed=byts salt=tape] diff --git a/pkg/arvo/lib/language-server/easy-print.hoon b/pkg/arvo/lib/language-server/easy-print.hoon index 2113f9c142..88a7699582 100644 --- a/pkg/arvo/lib/language-server/easy-print.hoon +++ b/pkg/arvo/lib/language-server/easy-print.hoon @@ -39,7 +39,7 @@ ['\\' i.mil $(mil t.mil)] ?: (lte ' ' i.mil) [i.mil $(mil t.mil)] - ['\\' ~(x ne (rsh 2 1 i.mil)) ~(x ne (new-end 2 i.mil)) $(mil t.mil)] + ['\\' ~(x ne (new-rsh 2 i.mil)) ~(x ne (new-end 2 i.mil)) $(mil t.mil)] :: ++ deal |=(lum=* (dish dole lum)) ++ dial diff --git a/pkg/arvo/lib/link-store.hoon b/pkg/arvo/lib/link-store.hoon index 494fa8c8f4..6da01c48f5 100644 --- a/pkg/arvo/lib/link-store.hoon +++ b/pkg/arvo/lib/link-store.hoon @@ -22,7 +22,7 @@ =* host r.p.u.murl ?- -.host %& (roll (join '.' p.host) (cury cat 3)) - %| (rsh 3 1 (scot %if p.host)) + %| (new-rsh 3 (scot %if p.host)) == :: ++ build-discussion-path diff --git a/pkg/arvo/lib/pkcs.hoon b/pkg/arvo/lib/pkcs.hoon index 7d3f8cc178..b1fce389f5 100644 --- a/pkg/arvo/lib/pkcs.hoon +++ b/pkg/arvo/lib/pkcs.hoon @@ -62,7 +62,7 @@ |- ^- wain ?~ a [(rap 3 ['-----END ' lab '-----' ~]) ~] - [(new-end [3 64] a) $(a (rsh 3 64 a))] + [(new-end [3 64] a) $(a (new-rsh [3 64] a))] :: +de:pem: PEM decode :: ++ de diff --git a/pkg/arvo/lib/primitive-rsa.hoon b/pkg/arvo/lib/primitive-rsa.hoon index 4300e5b8ee..aa6edd60cd 100644 --- a/pkg/arvo/lib/primitive-rsa.hoon +++ b/pkg/arvo/lib/primitive-rsa.hoon @@ -55,7 +55,7 @@ =/ e `@ux`65.537 |= [wid=@ eny=@] ^- key - =/ diw (rsh 0 1 wid) + =/ diw (new-rsh 0 wid) =/ p=@ux (ramp diw [3 5 ~] eny) =/ q=@ux (ramp diw [3 5 ~] +(eny)) =/ n=@ux (mul p q) diff --git a/pkg/arvo/lib/ring.hoon b/pkg/arvo/lib/ring.hoon index d4db64acb5..99f893223e 100644 --- a/pkg/arvo/lib/ring.hoon +++ b/pkg/arvo/lib/ring.hoon @@ -321,7 +321,7 @@ ++ seed-to-private-key-scalar |= sk=@I ^- @udscalar ?: (gth (met 3 sk) 32) !! - =+ h=(shal (rsh 0 3 b:ed:crypto) sk) + =+ h=(shal (new-rsh [0 3] b:ed:crypto) sk) %+ add (bex (sub b:ed:crypto 2)) (new-lsh [0 3] (cut 0 [3 (sub b:ed:crypto 5)] h)) @@ -330,17 +330,17 @@ ++ get-public-key-from-pass |= a=pass ^- [@ @] - =+ [mag=(new-end 3 a) bod=(rsh 3 1 a)] + =+ [mag=(new-end 3 a) bod=(new-rsh 3 a)] ~| %not-crub-pubkey ?> =('b' mag) - [cry=(rsh 8 1 bod) sgn=(new-end 8 bod)] + [cry=(new-rsh 8 bod) sgn=(new-end 8 bod)] :: :: ++ get-private-key-from-ring |= a=ring ^- [@ @] - =+ [mag=(new-end 3 a) bod=(rsh 3 1 a)] + =+ [mag=(new-end 3 a) bod=(new-rsh 3 a)] ~| %not-crub-seckey ?> =('B' mag) - =+ [c=(rsh 8 1 bod) s=(new-end 8 bod)] + =+ [c=(new-rsh 8 bod) s=(new-end 8 bod)] :: todo: do we puck here? [c s] :: +ship-life-to-pubid: fetches public key information from jael diff --git a/pkg/arvo/lib/shoe.hoon b/pkg/arvo/lib/shoe.hoon index d3ed0cc17c..66c0fbd365 100644 --- a/pkg/arvo/lib/shoe.hoon +++ b/pkg/arvo/lib/shoe.hoon @@ -302,7 +302,7 @@ (longest-match:auto options) =/ to-send=tape %- trip - (rsh 3 (met 3 needle) advance) + (new-rsh [3 (met 3 needle)] advance) =/ send-pos=@ud %+ add pos (met 3 (fall forward '')) diff --git a/pkg/arvo/mar/hash.hoon b/pkg/arvo/mar/hash.hoon index e57e151d61..1810bb12f7 100644 --- a/pkg/arvo/mar/hash.hoon +++ b/pkg/arvo/mar/hash.hoon @@ -5,7 +5,7 @@ |% ++ noun hash ++ json - s+(rsh 3 2 (scot %uv hash)) + s+(new-rsh [3 2] (scot %uv hash)) -- ++ grab |% diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index df93fb81a2..932c701b42 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -1076,7 +1076,7 @@ %+ turn von =/ bem=beam [[our %home da+now] /whey] |= [lal=@tas =vane] - =/ met (peek ~ (rsh 3 5 lal) bem) + =/ met (peek ~ (new-rsh [3 5] lal) bem) ?> &(?=(^ met) ?=(^ u.met)) :: XX make optional lal^|+;;((list mass) q.q.u.u.met) :: @@ -1101,7 +1101,7 @@ :: XX vane and care are concatenated :: =/ lal (new-end 3 cyr) - =/ ren ;;(@t (rsh 3 1 cyr)) + =/ ren ;;(@t (new-rsh 3 cyr)) ?. (~(has by van.mod) lal) ~ (peek:(plow lal) lyc ren bem) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 087a039d80..9cde2cfb1c 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -852,7 +852,7 @@ ++ cut :: slice ~/ %cut |= [a=bloq [b=step c=step] d=@] - (new-end [a c] (rsh a b d)) + (new-end [a c] (new-rsh [a b] d)) :: ++ end :: tail ~/ %end @@ -872,7 +872,7 @@ =+ d=c |- ^- @ ?: =(n b) - (rsh a 1 d) + (new-rsh a d) $(d (add c (new-lsh a d)), n +(n)) :: ++ lsh :: left-shift @@ -893,7 +893,7 @@ =+ c=0 |- ?: =(0 b) c - $(b (rsh a 1 b), c +(c)) + $(b (new-rsh a b), c +(c)) :: ++ rap :: assemble nonzero ~/ %rap @@ -930,16 +930,21 @@ ++ rip :: disassemble ~/ %rip |= [a=bite b=@] - =/ [=bloq =step] ?^(a a [a *step]) ^- (list @) ?: =(0 b) ~ - [(new-end [bloq step] b) $(b (rsh bloq step b))] + [(new-end a b) $(b (new-rsh a b))] :: ++ rsh :: right-shift ~/ %rsh |= [a=bloq b=step c=@] (div c (bex (mul (bex a) b))) :: +++ new-rsh :: right-shift + ~/ %new-rsh + |= [a=bite b=@] + =/ [=bloq =step] ?^(a a [a *step]) + (div b (bex (mul (bex bloq) step))) +:: ++ run :: +turn into atom ~/ %run |= [a=bite b=@ c=$-(@ @)] @@ -956,8 +961,8 @@ ^- @ %+ add (can a b^e c^d ~) - =/ f (add b c) - (new-lsh [a f] (rsh a f e)) + =/ f [a (add b c)] + (new-lsh f (new-rsh f e)) :: ++ swp :: naive rev bloq order ~/ %swp @@ -988,12 +993,12 @@ =+ e=(sit d) =+ f=(bex (sub a b)) =+ g=(mod c f) - (sit (con (new-lsh [b g] e) (rsh b (sub f g) e))) + (sit (con (new-lsh [b g] e) (new-rsh [b (sub f g)] e))) ++ ror |= [b=bloq c=@ d=@] ^- @ :: roll right =+ e=(sit d) =+ f=(bex (sub a b)) =+ g=(mod c f) - (sit (con (rsh b g e) (new-lsh [b (sub f g)] e))) + (sit (con (new-rsh [b g] e) (new-lsh [b (sub f g)] e))) ++ sum |=([b=@ c=@] (sit (add b c))) :: wrapping add ++ sit |=(b=@ (new-end a b)) :: enforce modulo -- @@ -1008,8 +1013,8 @@ |- ^- @ ?: ?&(=(0 a) =(0 b)) d %= $ - a (rsh 0 1 a) - b (rsh 0 1 b) + a (new-rsh 0 a) + b (new-rsh 0 b) c +(c) d %+ add d %+ new-lsh [0 c] @@ -1025,8 +1030,8 @@ |- ^- @ ?: ?|(=(0 a) =(0 b)) d %= $ - a (rsh 0 1 a) - b (rsh 0 1 b) + a (new-rsh 0 a) + b (new-rsh 0 b) c +(c) d %+ add d %+ new-lsh [0 c] @@ -1043,8 +1048,8 @@ |- ?: ?&(=(0 a) =(0 b)) d %= $ - a (rsh 0 1 a) - b (rsh 0 1 b) + a (new-rsh 0 a) + b (new-rsh 0 b) c +(c) d (add d (new-lsh [0 c] =((new-end 0 a) (new-end 0 b)))) == @@ -1105,11 +1110,11 @@ |^ (fmix32 h1) ++ fmix32 |= h=@ - =. h (mix h (rsh 0 16 h)) + =. h (mix h (new-rsh [0 16] h)) =. h (sit (mul h 0x85eb.ca6b)) - =. h (mix h (rsh 0 13 h)) + =. h (mix h (new-rsh [0 13] h)) =. h (sit (mul h 0xc2b2.ae35)) - =. h (mix h (rsh 0 16 h)) + =. h (mix h (new-rsh [0 16] h)) h -- :: @@ -1127,7 +1132,7 @@ |- ^- @F ?: =(8 i) fal =/ haz=@F (muk syd wyd key) - =/ ham=@F (mix (rsh 0 31 haz) (new-end [0 31] haz)) + =/ ham=@F (mix (new-rsh [0 31] haz) (new-end [0 31] haz)) ?.(=(0 ham) ham $(i +(i), syd +(syd))) -- :: :: @@ -1153,7 +1158,7 @@ |- =+ [c=(new-end 3 a) d=(new-end 3 b)] ?: =(c d) - $(a (rsh 3 1 a), b (rsh 3 1 b)) + $(a (new-rsh 3 a), b (new-rsh 3 b)) (lth c d) :: +dor: depth order :: @@ -2184,7 +2189,7 @@ |= [b=@ c=@] ?: =(0 b) 1 - =+ d=$(b (rsh 0 1 b)) + =+ d=$(b (new-rsh 0 b)) =+ e=(pro d d) ?:(=(0 (new-end 0 b)) e (pro c e)) :: @@ -2213,7 +2218,7 @@ ++ si :: signed integer ^? |% - ++ abs |=(a=@s (add (new-end 0 a) (rsh 0 1 a))) :: absolute value + ++ abs |=(a=@s (add (new-end 0 a) (new-rsh 0 a))) :: absolute value ++ dif |= [a=@s b=@s] :: subtraction (sum a (new !(syn b) (abs b))) ++ dul |= [a=@s b=@] :: modulus @@ -2357,7 +2362,7 @@ =+ c=(cmp:si (ibl a) (ibl b)) ?: =(c -1) & ?: =(c --1) | ?: =((cmp:si e.a e.b) -1) - (^lth (rsh 0 (abs:si (dif:si e.a e.b)) a.a) a.b) + (^lth (new-rsh [0 (abs:si (dif:si e.a e.b))] a.a) a.b) (^lth (new-lsh [0 (abs:si (dif:si e.a e.b))] a.a) a.b) :: ++ equ :: equals @@ -2377,7 +2382,7 @@ ++ uni |= [a=[e=@s a=@u]] |- ?: =((new-end 0 a.a) 1) a - $(a.a (rsh 0 1 a.a), e.a (sum:si e.a --1)) + $(a.a (new-rsh 0 a.a), e.a (sum:si e.a --1)) :: :: expands to either full precision or to denormalized ++ xpd @@ -2412,7 +2417,7 @@ %- abs:si ?: =(den %i) --0 :: enforce min. exp ?: =((cmp:si e.a emn) -1) (dif:si emn e.a) --0 =^ b a :- (new-end [0 q] a.a) - a(e (sum:si e.a (sun:si q)), a (rsh 0 q a.a)) + a(e (sum:si e.a (sun:si q)), a (new-rsh [0 q] a.a)) :: ?~ a.a ?< =(den %i) @@ -2455,7 +2460,7 @@ == :: =. a ?. =((met 0 a.a) +(prc)) a - a(a (rsh 0 1 a.a), e (sum:si e.a --1)) + a(a (new-rsh 0 a.a), e (sum:si e.a --1)) ?~ a.a [%f & zer] :: ?: =(den %i) [%f & a] @@ -2515,7 +2520,7 @@ |= [a=[e=@s a=@u]] ^- fn ?. =((cmp:si e.a --0) -1) [%f & a] =+ x=(abs:si e.a) - =+ y=(rsh 0 x a.a) + =+ y=(new-rsh [0 x] a.a) ?: |(=(r %d) =(r %z)) [%f & --0 y] =+ z=(new-end [0 x] a.a) ?: |(=(r %u) =(r %a)) [%f & --0 ?~(z y +(y))] @@ -3189,7 +3194,7 @@ ++ yell :: tarp from @d |= now=@d ^- tarp - =+ sec=(rsh 6 1 now) + =+ sec=(new-rsh 6 now) =+ ^= fan =+ [muc=4 raw=(new-end 6 now)] |- ^- (list @ux) @@ -3295,7 +3300,7 @@ ++ shaf :: half sha-256 |= [sal=@ ruz=@] =+ haz=(shas sal ruz) - (mix (new-end 7 haz) (rsh 7 1 haz)) + (mix (new-end 7 haz) (new-rsh 7 haz)) :: ++ sham :: 128bit noun hash |= yux=* ^- @uvH ^- @ @@ -3362,8 +3367,8 @@ n=(wac (sub j 16) wox) o=(wac (sub j 7) wox) == - =+ x=:(mix (ror 0 7 l) (ror 0 18 l) (rsh 0 3 l)) - =+ y=:(mix (ror 0 17 m) (ror 0 19 m) (rsh 0 10 m)) + =+ x=:(mix (ror 0 7 l) (ror 0 18 l) (new-rsh [0 3] l)) + =+ y=:(mix (ror 0 17 m) (ror 0 19 m) (new-rsh [0 10] m)) =+ z=:(sum n x o y) $(wox (con (new-lsh [5 j] z) wox), j +(j)) =+ j=0 @@ -3482,8 +3487,8 @@ n=(wac (sub j 16) wox) o=(wac (sub j 7) wox) == - =+ x=:(mix (ror 0 1 l) (ror 0 8 l) (rsh 0 7 l)) - =+ y=:(mix (ror 0 19 m) (ror 0 61 m) (rsh 0 6 m)) + =+ x=:(mix (ror 0 1 l) (ror 0 8 l) (new-rsh [0 7] l)) + =+ y=:(mix (ror 0 19 m) (ror 0 61 m) (new-rsh [0 6] m)) =+ z=:(sum n x o y) $(wox (con (new-lsh [6 j] z) wox), j +(j)) =+ j=0 @@ -4158,7 +4163,7 @@ ++ enc |=(a=@ux `@ux`(mix (new-lsh [3 4] a) (tok a))) ++ den |= a=@ux ^- (unit @ux) - =+ b=(rsh 3 4 a) + =+ b=(new-rsh [3 4] a) ?. =((tok b) (new-end [3 4] a)) ~ `b @@ -4175,7 +4180,7 @@ & =+ vis=(new-end 3 a) ?& ?|(=('-' vis) ?&((gte vis 'a') (lte vis 'z'))) - $(a (rsh 3 1 a)) + $(a (new-rsh 3 a)) == == rtam @@ -4213,7 +4218,7 @@ |- ^- tape ?: (gth (met 5 a) 1) %+ weld - $(a (rsh 5 1 a), b (sub b 4)) + $(a (new-rsh 5 a), b (sub b 4)) `tape`['-' '-' $(a (new-end 5 a), b 4)] ?: =(0 b) ['~' ~] @@ -4221,10 +4226,10 @@ (trip (tos:po a)) |- ^- tape ?: =(2 b) - =+ c=(rsh 3 1 a) + =+ c=(new-rsh 3 a) =+ d=(new-end 3 a) (weld (trip (tod:po c)) (trip (tos:po (mix c d)))) - =+ c=(rsh 3 2 a) + =+ c=(new-rsh [3 2] a) =+ d=(new-end [3 2] a) (weld ^$(a c, b (met 3 c)) `tape`['-' $(a (mix c d), b 2)]) :: @@ -4312,7 +4317,7 @@ ?: &((lth cur 32) !=(10 cur)) | =+ len=(teff cur) ?& |(=(1 len) =+(i=1 |-(|(=(i len) &((gte (cut 3 [i 1] b) 128) $(i +(i))))))) - $(b (rsh 3 len b)) + $(b (new-rsh [3 len] b)) == :: ++ ruth :: biblical sanity @@ -4337,7 +4342,7 @@ |= a=@ ^- tape ?: =(0 (met 3 a)) ~ - [^-(@ta (new-end 3 a)) $(a (rsh 3 1 a))] + [^-(@ta (new-end 3 a)) $(a (new-rsh 3 a))] :: ++ teff :: length utf8 |= a=@t ^- @ @@ -4366,7 +4371,7 @@ == |=([p=@ q=@] [q (cut 0 [p q] a)]) ?> =((tuft c) (new-end [3 b] a)) - [c $(a (rsh 3 b a))] + [c $(a (new-rsh [3 b] a))] :: ++ tuba :: utf8 to utf32 tape |= a=tape @@ -4387,7 +4392,7 @@ ?: =(`@`0 a) ~ =+ b=(new-end 5 a) - =+ c=$(a (rsh 5 1 a)) + =+ c=$(a (new-rsh 5 a)) ?: (lte b 0x7f) [b c] ?: (lte b 0x7ff) @@ -4445,12 +4450,12 @@ ?: =(`@`0 a) ~ =+ b=(new-end 3 a) - =+ c=(rsh 3 1 a) + =+ c=(new-rsh 3 a) ?: =('.' b) [' ' $(a c)] ?. =('~' b) [b $(a c)] - => .(b (new-end 3 c), c (rsh 3 1 c)) + => .(b (new-end 3 c), c (new-rsh 3 c)) ?+ b =- (weld (rip 3 (tuft p.d)) $(a q.d)) ^= d =+ d=0 @@ -4460,7 +4465,7 @@ ?< =(0 c) %= $ b (new-end 3 c) - c (rsh 3 1 c) + c (new-rsh 3 c) d %+ add (mul 16 d) %+ sub b ?: &((gte b '0') (lte b '9')) 48 @@ -4479,7 +4484,7 @@ ~ =+ b=(teff a) =+ c=(taft (new-end [3 b] a)) - =+ d=$(a (rsh 3 b a)) + =+ d=$(a (new-rsh [3 b] a)) ?: ?| &((gte c 'a') (lte c 'z')) &((gte c '0') (lte c '9')) =(`@`'-' c) @@ -4492,7 +4497,7 @@ ?: =(0 e) ['.' d] =. e (dec e) - =+ f=(rsh 2 e c) + =+ f=(new-rsh [2 e] c) [(add ?:((lte f 9) 48 87) f) $(c (new-end [2 e] c))] :: %' ' ['.' d] @@ -4955,7 +4960,7 @@ [p=p.tub q=[~ u=[p=fad q=tub]]] ?: |(?=(~ q.tub) !=((new-end 3 daf) i.q.tub)) (fail tub) - $(p.tub (lust i.q.tub p.tub), q.tub t.q.tub, daf (rsh 3 1 daf)) + $(p.tub (lust i.q.tub p.tub), q.tub t.q.tub, daf (new-rsh 3 daf)) :: ++ just :: XX redundant, jest ~/ %just :: match a char @@ -5536,7 +5541,7 @@ imp +(imp) rep =/ log (cut 4 [imp 1] sxz) ;: weld - (trip (tos:po (rsh 3 1 log))) + (trip (tos:po (new-rsh 3 log))) (trip (tod:po (new-end 3 log))) ?:(=((mod imp 4) 0) ?:(=(imp 0) "" "--") "-") rep @@ -5867,7 +5872,7 @@ =+ ^= neg |= [syn=? mol=dime] ^- dime ?> =('u' (new-end 3 p.mol)) - [(cat 3 's' (rsh 3 1 p.mol)) (new:si syn q.mol)] + [(cat 3 's' (new-rsh 3 p.mol)) (new:si syn q.mol)] ;~ pfix hep ;~ pose (cook |=(a=dime (neg | a)) bisk) @@ -7301,7 +7306,7 @@ =+ len=(met 3 mot) ?: =(0 len) [0 %$] - =+ tyl=(rsh 3 (dec len) mot) + =+ tyl=(new-rsh [3 (dec len)] mot) ?: &((gte tyl 'A') (lte tyl 'Z')) [(sub tyl 64) (new-end [3 (dec len)] mot)] [0 mot] @@ -7313,7 +7318,7 @@ |- ?| =(%$ p.yoz) =(%$ p.wux) ?& =((new-end 3 p.yoz) (new-end 3 p.wux)) - $(p.yoz (rsh 3 1 p.yoz), p.wux (rsh 3 1 p.wux)) + $(p.yoz (new-rsh 3 p.yoz), p.wux (new-rsh 3 p.wux)) == == == @@ -7380,11 +7385,11 @@ =/ small=@ (met 0 contained) ?: (lte small big) | =/ dif=@ (sub small big) - =(container (rsh 0 dif contained)) + =(container (new-rsh [0 dif] contained)) :: ++ parent |= a=axis - `axis`(rsh 0 1 a) + `axis`(new-rsh 0 a) :: ++ sibling |= a=axis @@ -11054,7 +11059,7 @@ ['\\' i.mil $(mil t.mil)] ?: (lte ' ' i.mil) [i.mil $(mil t.mil)] - ['\\' ~(x ne (rsh 2 1 i.mil)) ~(x ne (new-end 2 i.mil)) $(mil t.mil)] + ['\\' ~(x ne (new-rsh 2 i.mil)) ~(x ne (new-end 2 i.mil)) $(mil t.mil)] :: ++ deal |=(lum=* (dish dole lum)) ++ dial diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index 1d5350e325..9651bbb625 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -926,7 +926,7 @@ :: :: Logic duplicates +com:nu:crub:crypto and +sure:as:crub:crypto. :: - =/ key (new-end 8 (rsh 3 1 public-key.open-packet)) + =/ key (new-end 8 (new-rsh 3 public-key.open-packet)) ?> (veri:ed:crypto signature signed key) :: store comet as peer in our state :: @@ -1784,7 +1784,7 @@ peer-core :: even bone; is this bone a nack-trace bone? :: - ?: =(1 (new-end 0 (rsh 0 1 bone))) + ?: =(1 (new-end 0 (new-rsh 0 bone))) :: nack-trace bone; assume .ok, clear nack from |message-sink :: =/ target-bone=^bone (mix 0b10 bone) @@ -1872,7 +1872,7 @@ ++ on-sink-memo ?: =(1 (new-end 0 bone)) on-sink-plea - ?: =(0 (new-end 0 (rsh 0 1 bone))) + ?: =(0 (new-end 0 (new-rsh 0 bone))) on-sink-boon on-sink-nack-trace :: +on-sink-boon: handle response message received by |message-sink @@ -2904,10 +2904,10 @@ ^- symmetric-key :: ?> =('b' (new-end 3 public-key)) - =. public-key (rsh 8 1 (rsh 3 1 public-key)) + =. public-key (new-rsh 8 (new-rsh 3 public-key)) :: ?> =('B' (new-end 3 private-key)) - =. private-key (rsh 8 1 (rsh 3 1 private-key)) + =. private-key (new-rsh 8 (new-rsh 3 private-key)) :: `@`(shar:ed:crypto public-key private-key) :: +encrypt: encrypt $shut-packet into atomic packet content @@ -2980,7 +2980,7 @@ :: first 32 (2^5) bits are header; the rest is body :: =/ header (new-end 5 blob) - =/ body (rsh 5 1 blob) + =/ body (new-rsh 5 blob) :: =/ version (new-end [0 3] header) =/ checksum (cut 0 [3 20] header) @@ -3001,7 +3001,7 @@ ;; [origin=(unit lane) content=*] ~| %ames-invalid-noun %- cue - (rsh 3 (add rcvr-size sndr-size) body) + (new-rsh [3 (add rcvr-size sndr-size)] body) :: [dyad encrypted origin content] :: +decode-ship-size: decode a 2-bit ship type specifier into a byte width diff --git a/pkg/arvo/sys/vane/eyre.hoon b/pkg/arvo/sys/vane/eyre.hoon index 109397c006..b5d7cb760e 100644 --- a/pkg/arvo/sys/vane/eyre.hoon +++ b/pkg/arvo/sys/vane/eyre.hoon @@ -753,7 +753,7 @@ ?- -.mym %| (error-response 500 "failed tube from {(trip mark)} to mime") %& %+ return-static-data-on-duct 200 - [(rsh 3 1 (spat p.p.mym)) q.p.mym] + [(new-rsh 3 (spat p.p.mym)) q.p.mym] == :: ++ find-tube @@ -1031,7 +1031,7 @@ =+ pax=/(scot %p our)/code/(scot %da now)/(scot %p our) =+ res=((sloy scry) [151 %noun] %j pax) :: - (rsh 3 1 (scot %p (@ (need (need res))))) + (new-rsh 3 (scot %p (@ (need (need res))))) :: +session-cookie-string: compose session cookie :: ++ session-cookie-string diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index ae431eeb9f..a88c8709db 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -2329,7 +2329,7 @@ =+ [s=(dec a) t=0] |- ^- [s=@ t=@] ?: =(0 (new-end 0 s)) - $(s (rsh 0 1 s), t +(t)) + $(s (new-rsh 0 s), t +(t)) [s t] ?> =((mul s.b (bex t.b)) (dec a)) =+ c=0 @@ -2425,7 +2425,7 @@ ?: =(i 0) =+ x=(cub r) (sit.fq (mul -.x (inv +.x))) - =+ m=(rsh 0 i a) + =+ m=(new-rsh [0 i] a) ?: =(0 (mod m 2)) $(i (dec i), s (cad r s one), r (cub r)) $(i (dec i), r (cad r s one), s (cub s)) @@ -2455,8 +2455,8 @@ ?: =(0 b) 0 ?: =(1 (dis 1 b)) - (dif c $(b (rsh 0 1 b), c (dub c))) - $(b (rsh 0 1 b), c (dub c)) + (dif c $(b (new-rsh 0 b), c (dub c))) + $(b (new-rsh 0 b), c (dub c)) :: :: ++toe:ga:number ++ toe :: exp+log tables =+ ^= nu @@ -2779,7 +2779,7 @@ |= blk=@H ^- @uxH =+ (ahem 6 4 12) =: - key (rsh 6 1 (~(net fe 8) key)) + key (new-rsh 6 (~(net fe 8) key)) blk (~(net fe 7) blk) == %- ~(net fe 7) @@ -2790,7 +2790,7 @@ |= blk=@H ^- @uxH =+ (ahem 6 4 12) =: - key (rsh 6 1 (~(net fe 8) key)) + key (new-rsh 6 (~(net fe 8) key)) blk (~(net fe 7) blk) == %- ~(net fe 7) @@ -2961,7 +2961,7 @@ =/ blocks (add (div len 16) ?:(=((^mod len 16) 0) 0 1)) ?> (gte len (met 3 txt)) %+ mix txt - %^ rsh 3 (sub (mul 16 blocks) len) + %+ new-rsh [3 (sub (mul 16 blocks) len)] %+ rep 7 =| seed=(list @ux) |- ^+ seed @@ -2988,7 +2988,7 @@ =/ blocks (add (div len 16) ?:(=((^mod len 16) 0) 0 1)) ?> (gte len (met 3 txt)) %+ mix txt - %^ rsh 3 (sub (mul 16 blocks) len) + %+ new-rsh [3 (sub (mul 16 blocks) len)] %+ rep 7 =| seed=(list @ux) |- ^+ seed @@ -3015,7 +3015,7 @@ =/ blocks (add (div len 16) ?:(=((^mod len 16) 0) 0 1)) ?> (gte len (met 3 txt)) %+ mix txt - %^ rsh 3 (sub (mul 16 blocks) len) + %+ new-rsh [3 (sub (mul 16 blocks) len)] %+ rep 7 =| seed=(list @ux) |- ^+ seed @@ -3199,7 +3199,7 @@ ~/ %en |= txt=@ ^- (trel @uxH @ud @ux) - =+ [k1=(rsh 7 1 key) k2=(new-end 7 key)] + =+ [k1=(new-rsh 7 key) k2=(new-end 7 key)] =+ iv=(s2va k1 (weld vec (limo ~[txt]))) =+ len=(met 3 txt) =* hib (dis iv 0xffff.ffff.ffff.ffff.7fff.ffff.7fff.ffff) @@ -3212,7 +3212,7 @@ ~/ %de |= [iv=@H len=@ txt=@] ^- (unit @ux) - =+ [k1=(rsh 7 1 key) k2=(new-end 7 key)] + =+ [k1=(new-rsh 7 key) k2=(new-end 7 key)] =* hib (dis iv 0xffff.ffff.ffff.ffff.7fff.ffff.7fff.ffff) =+ ^= pln (~(de ctra k2 7 len hib) txt) @@ -3229,7 +3229,7 @@ ~/ %en |= txt=@ ^- (trel @uxH @ud @ux) - =+ [k1=(rsh 6 3 key) k2=(new-end [6 3] key)] + =+ [k1=(new-rsh [6 3] key) k2=(new-end [6 3] key)] =+ iv=(s2vb k1 (weld vec (limo ~[txt]))) =* hib (dis iv 0xffff.ffff.ffff.ffff.7fff.ffff.7fff.ffff) =+ len=(met 3 txt) @@ -3241,7 +3241,7 @@ ~/ %de |= [iv=@H len=@ txt=@] ^- (unit @ux) - =+ [k1=(rsh 6 3 key) k2=(new-end [6 3] key)] + =+ [k1=(new-rsh [6 3] key) k2=(new-end [6 3] key)] =* hib (dis iv 0xffff.ffff.ffff.ffff.7fff.ffff.7fff.ffff) =+ ^= pln (~(de ctrb k2 7 len hib) txt) @@ -3258,7 +3258,7 @@ ~/ %en |= txt=@ ^- (trel @uxH @ud @ux) - =+ [k1=(rsh 8 1 key) k2=(new-end 8 key)] + =+ [k1=(new-rsh 8 key) k2=(new-end 8 key)] =+ iv=(s2vc k1 (weld vec (limo ~[txt]))) =* hib (dis iv 0xffff.ffff.ffff.ffff.7fff.ffff.7fff.ffff) =+ len=(met 3 txt) @@ -3271,7 +3271,7 @@ ~/ %de |= [iv=@H len=@ txt=@] ^- (unit @ux) - =+ [k1=(rsh 8 1 key) k2=(new-end 8 key)] + =+ [k1=(new-rsh 8 key) k2=(new-end 8 key)] =* hib (dis iv 0xffff.ffff.ffff.ffff.7fff.ffff.7fff.ffff) =+ ^= pln (~(de ctrc k2 7 len hib) txt) @@ -3425,7 +3425,7 @@ ~/ %puck |= sk=@I ^- @ ?: (gth (met 3 sk) 32) !! - =+ h=(shal (rsh 0 3 b) sk) + =+ h=(shal (new-rsh [0 3] b) sk) =+ ^= a %+ add (bex (sub b 2)) @@ -3442,7 +3442,7 @@ ~/ %shar |= [pub=@ sek=@] ^- @ux - =+ exp=(shal (rsh 0 3 b) (suck sek)) + =+ exp=(shal (new-rsh [0 3] b) (suck sek)) =. exp (dis exp (can 0 ~[[3 0] [251 (fil 0 251 1)]])) =. exp (con exp (new-lsh [3 31] 0b100.0000)) =+ prv=(new-end 8 exp) @@ -3454,7 +3454,7 @@ |= [m=@ se=@] ^- @ =+ sk=(suck se) =+ pk=(cut 0 [b b] sk) - =+ h=(shal (rsh 0 3 b) sk) + =+ h=(shal (new-rsh [0 3] b) sk) =+ ^= a %+ add (bex (sub b 2)) @@ -3484,7 +3484,7 @@ |= [s=@ m=@ pk=@] ^- ? ?: (gth (div b 4) (met 3 s)) | ?: (gth (div b 8) (met 3 pk)) | - =+ cb=(rsh 0 3 b) + =+ cb=(new-rsh [0 3] b) =+ rr=(deco (cut 0 [0 b] s)) ?~ rr | =+ aa=(deco pk) @@ -3507,7 +3507,7 @@ =+ few==>(fe .(a 5)) =+ ^= rot |= [a=@ b=@] - (mix (new-end 5 (new-lsh [0 a] b)) (rsh 0 (sub 32 a) b)) + (mix (new-end 5 (new-lsh [0 a] b)) (new-rsh [0 (sub 32 a)] b)) =+ ^= lea |= [a=@ b=@] (net:few (sum:few (net:few a) (net:few b))) @@ -3731,7 +3731,7 @@ ^- @ux ?~ sek ~| %pubkey-only !! ?> =('b' (new-end 3 bpk)) - =+ pk=(rsh 8 1 (rsh 3 1 bpk)) + =+ pk=(new-rsh 8 (new-rsh 3 bpk)) =+ shar=(shax (shar:ed pk cry.u.sek)) =+ smsg=(sign msg) (jam (~(en siva:aes shar ~) smsg)) @@ -3741,7 +3741,7 @@ ^- (unit @ux) ?~ sek ~| %pubkey-only !! ?> =('b' (new-end 3 bpk)) - =+ pk=(rsh 8 1 (rsh 3 1 bpk)) + =+ pk=(new-rsh 8 (new-rsh 3 bpk)) =+ shar=(shax (shar:ed pk cry.u.sek)) =+ ;;([iv=@ len=@ cph=@] (cue txt)) =+ try=(~(de siva:aes shar ~) iv len cph) @@ -3796,21 +3796,21 @@ |= [w=@ seed=@] =+ wid=(add (div w 8) ?:(=((mod w 8) 0) 0 1)) =+ bits=(shal wid seed) - =+ [c=(rsh 8 1 bits) s=(new-end 8 bits)] + =+ [c=(new-rsh 8 bits) s=(new-end 8 bits)] ..nu(pub [cry=(puck:ed c) sgn=(puck:ed s)], sek `[cry=c sgn=s]) :: :: ++nol:nu:crub:crypto ++ nol :: activate secret |= a=ring - =+ [mag=(new-end 3 a) bod=(rsh 3 1 a)] + =+ [mag=(new-end 3 a) bod=(new-rsh 3 a)] ~| %not-crub-seckey ?> =('B' mag) - =+ [c=(rsh 8 1 bod) s=(new-end 8 bod)] + =+ [c=(new-rsh 8 bod) s=(new-end 8 bod)] ..nu(pub [cry=(puck:ed c) sgn=(puck:ed s)], sek `[cry=c sgn=s]) :: :: ++com:nu:crub:crypto ++ com :: activate public |= a=pass - =+ [mag=(new-end 3 a) bod=(rsh 3 1 a)] + =+ [mag=(new-end 3 a) bod=(new-rsh 3 a)] ~| %not-crub-pubkey ?> =('b' mag) - ..nu(pub [cry=(rsh 8 1 bod) sgn=(new-end 8 bod)], sek ~) + ..nu(pub [cry=(new-rsh 8 bod) sgn=(new-end 8 bod)], sek ~) -- ::nu -- ::crub :: :: @@ -3989,11 +3989,11 @@ :: result. =. res %+ con (new-lsh [0 bitrate] res) - (rsh 0 capacity (lanes-to-bytes state)) + (new-rsh [0 capacity] (lanes-to-bytes state)) =. len (add len bitrate) ?: (gte len output) :: produce the requested bits of output. - (rsh 0 (sub len output) res) + (new-rsh [0 (sub len output)] res) $(res res, state (permute state)) :: ++ bytes-to-lanes @@ -4254,11 +4254,11 @@ ?> =(3 (mod p.domain 4)) =/ fop field-p =+ [fadd fmul fpow]=[sum.fop pro.fop exp.fop] - =/ y=@ %+ fpow (rsh 0 2 +(p.domain)) + =/ y=@ %+ fpow (new-rsh [0 2] +(p.domain)) %+ fadd b.domain %+ fadd (fpow 3 x) (fmul a.domain x) - =/ s=@ (rsh 3 bytes compressed) + =/ s=@ (new-rsh [3 bytes] compressed) ~| [`@ux`s `@ux`compressed] ?> |(=(2 s) =(3 s)) :: check parity @@ -4343,8 +4343,8 @@ ?: (gte scalar n.domain) $(scalar (mod scalar n.domain)) ?: =(0 (mod scalar 2)) - (double $(scalar (rsh 0 1 scalar))) - (add a (double $(scalar (rsh 0 1 scalar)))) + (double $(scalar (new-rsh 0 scalar))) + (add a (double $(scalar (new-rsh 0 scalar)))) -- ++ add-points |= [a=point b=point] @@ -4486,7 +4486,7 @@ =/ fop field-p.c =+ [fadd fmul fpow]=[sum.fop pro.fop exp.fop] =/ ysq (fadd (fpow 3 x) b.domain.c) - =/ beta (fpow (rsh 0 2 +(p.domain.c)) ysq) + =/ beta (fpow (new-rsh [0 2] +(p.domain.c)) ysq) =/ y ?: =((new-end 0 v.sig) (new-end 0 beta)) beta (sub p.domain.c beta) @@ -4582,7 +4582,7 @@ =. v %- mod-word :^ v 13 16 - (cury mix (rsh 0 64 t)) + (cury mix (new-rsh [0 64] t)) :: for the last block, invert v14 =? v l %- mod-word @@ -4594,7 +4594,7 @@ |^ ?: =(i 12) :: xor upper and lower halves of v into state h - =. h (mix h (rsh 6 8 v)) + =. h (mix h (new-rsh [6 8] v)) (mix h (new-end [6 8] v)) :: select message mixing schedule and mix v =. s (snag (mod i 10) sigma) @@ -4680,7 +4680,7 @@ =. c (pad [rem c] 128) =. h (compress h c com &) :: produce output of desired length - %^ rsh 3 (sub 64 out) + %+ new-rsh [3 (sub 64 out)] :: do some word %+ rep 6 %+ turn (flop (gulf 0 7)) @@ -4901,7 +4901,7 @@ %+ turn (flop (rip 6 random-block)) |= a=@ ^- (pair @ @) - :- (rev 3 4 (rsh 5 1 a)) + :- (rev 3 4 (new-rsh 5 a)) (rev 3 4 (new-end 5 a)) :: :: iterate over the entire segment length @@ -4949,9 +4949,9 @@ (mul +(seg) seg-length) :: pseudorandom offset =- %+ sub (dec -) - %^ rsh 0 32 + %+ new-rsh [0 32] %+ mul - - (rsh 0 32 (mul c1 c1)) + (new-rsh [0 32] (mul c1 c1)) :: reference area size ?: =(0 itn) ?: |(=(0 seg) =(row ref-row)) (dec col) @@ -5145,12 +5145,12 @@ :: desired output size. :: =+ tmp=(blake2b msg 0^0 64) - =+ res=(rsh 3 32 tmp) + =+ res=(new-rsh [3 32] tmp) =. out (sub out 32) |- ?: (gth out 64) =. tmp (blake2b 64^tmp 0^0 64) - =. res (add (new-lsh [3 32] res) (rsh 3 32 tmp)) + =. res (add (new-lsh [3 32] res) (new-rsh [3 32] tmp)) $(out (sub out 32)) %+ add (new-lsh [3 out] res) (blake2b 64^tmp 0^0 out) @@ -6203,7 +6203,7 @@ ?~ pad ~ =+ d=(new-end [0 6] pad) - [(cut 3 [d 1] cha) $(pad (rsh 0 6 pad))] + [(cut 3 [d 1] cha) $(pad (new-rsh [0 6] pad))] (weld (flop (slag poc sif)) (reap poc '=')) :: :: ++de-base64:mimes: ++ de-base64 :: decode base64 @@ -6583,7 +6583,7 @@ =('_' tap) == [tap ~] - ['%' (xen (rsh 0 4 tap)) (xen (new-end [0 4] tap)) ~] + ['%' (xen (new-rsh [0 4] tap)) (xen (new-end [0 4] tap)) ~] :: :: ++de-urlt:html ++ de-urlt :: url decode |= tep=tape @@ -6630,7 +6630,7 @@ ?:(&(p.har !?=(hoke r.har)) "https://" "http://") :: ?- -.r.har - %| (trip (rsh 3 1 (scot %if p.r.har))) + %| (trip (new-rsh 3 (scot %if p.r.har))) %& =+ rit=(flop p.r.har) |- ^- tape ?~ rit ~ @@ -6717,7 +6717,7 @@ ++ dlab :: 2396 domainlabel %+ sear |= a=@ta - ?.(=('-' (rsh 3 (dec (met 3 a)) a)) [~ u=a] ~) + ?.(=('-' (new-rsh [3 (dec (met 3 a))] a)) [~ u=a] ~) %+ cook |=(a=tape (crip (cass a))) ;~(plug aln (star alp)) :: :: ++fque:de-purl:html @@ -8664,7 +8664,7 @@ |* [rex=@t tys=(list etyp)] =- (decode-arguments - tys) %^ rut 9 - (rsh 3 2 rex) + (new-rsh [3 2] rex) (curr rash hex) :: ++ decode-arguments @@ -8734,7 +8734,8 @@ ^- octs :: parse {bys} bytes from {fro}. :- bys - %^ rsh 3 + %+ new-rsh + :- 3 =+ (mod bys 32) ?:(=(0 -) - (sub 32 -)) %+ rep 8 @@ -9189,7 +9190,7 @@ :: ++ hex-to-num |= a=@t - (rash (rsh 3 2 a) hex) + (rash (new-rsh [3 2] a) hex) -- :: :: |jstd: json standard library @@ -9371,7 +9372,7 @@ %+ turn u.res |= [id=@t result=@t] ^- [who=ship point:azimuth-types] - =/ who `@p`(slav %ud (rsh 3 4 id)) + =/ who `@p`(slav %ud (new-rsh [3 4] id)) :- who %+ point-from-eth who @@ -9431,7 +9432,7 @@ %+ turn u.res |= [id=@t result=@t] ^- (pair @ud ^turf) - :- (slav %ud (rsh 3 5 id)) + :- (slav %ud (new-rsh [3 5] id)) =/ dom=tape (decode-results result [%string]~) =/ hot=host:eyre diff --git a/pkg/arvo/ted/aqua/eyre-azimuth.hoon b/pkg/arvo/ted/aqua/eyre-azimuth.hoon index 1395312edb..ba4fc65c1d 100644 --- a/pkg/arvo/ted/aqua/eyre-azimuth.hoon +++ b/pkg/arvo/ted/aqua/eyre-azimuth.hoon @@ -426,8 +426,8 @@ :: ++ get-public |= [who=@p lyfe=life typ=?(%auth %crypt)] - =/ bod (rsh 3 1 pub:ex:(get-keys who lyfe)) - =+ [enc=(rsh 8 1 bod) aut=(new-end 8 bod)] + =/ bod (new-rsh 3 pub:ex:(get-keys who lyfe)) + =+ [enc=(new-rsh 8 bod) aut=(new-end 8 bod)] ?: =(%auth typ) aut enc From f4442668c899c31b5a6749c76169c1022d181f24 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 1 Dec 2020 23:08:31 -0800 Subject: [PATCH 865/933] u3: adds +new-end, +new-lsh, and +new-rsh jet interfaces --- pkg/urbit/include/jets/w.h | 3 +++ pkg/urbit/jets/c/end.c | 11 +++++++++++ pkg/urbit/jets/c/lsh.c | 11 +++++++++++ pkg/urbit/jets/c/rsh.c | 11 +++++++++++ pkg/urbit/jets/tree.c | 15 +++++++++++++++ 5 files changed, 51 insertions(+) diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index 8065457fd2..e81acabb02 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -55,8 +55,10 @@ u3_noun u3wc_dor(u3_noun); u3_noun u3wc_dvr(u3_noun); u3_noun u3wc_end(u3_noun); + u3_noun u3wc_new_end(u3_noun); u3_noun u3wc_gor(u3_noun); u3_noun u3wc_lsh(u3_noun); + u3_noun u3wc_new_lsh(u3_noun); u3_noun u3wc_mas(u3_noun); u3_noun u3wc_met(u3_noun); u3_noun u3wc_mix(u3_noun); @@ -70,6 +72,7 @@ u3_noun u3wc_rev(u3_noun); u3_noun u3wc_rip(u3_noun); u3_noun u3wc_rsh(u3_noun); + u3_noun u3wc_new_rsh(u3_noun); u3_noun u3wc_swp(u3_noun); u3_noun u3wc_sqt(u3_noun); diff --git a/pkg/urbit/jets/c/end.c b/pkg/urbit/jets/c/end.c index dfa30fb214..3d23815507 100644 --- a/pkg/urbit/jets/c/end.c +++ b/pkg/urbit/jets/c/end.c @@ -56,3 +56,14 @@ } } +u3_noun +u3wc_new_end(u3_noun cor) +{ + u3_atom bloq, step; + u3_noun a, b; + u3x_mean(cor, u3x_sam_2, &a, + u3x_sam_3, &b, 0); + u3x_bite(a, &bloq, &step); + + return u3qc_end(bloq, step, u3x_atom(b)); +} diff --git a/pkg/urbit/jets/c/lsh.c b/pkg/urbit/jets/c/lsh.c index d6789144c3..a205d7249a 100644 --- a/pkg/urbit/jets/c/lsh.c +++ b/pkg/urbit/jets/c/lsh.c @@ -66,3 +66,14 @@ return d; } +u3_noun +u3wc_new_lsh(u3_noun cor) +{ + u3_atom bloq, step; + u3_noun a, b; + u3x_mean(cor, u3x_sam_2, &a, + u3x_sam_3, &b, 0); + u3x_bite(a, &bloq, &step); + + return u3qc_lsh(bloq, step, u3x_atom(b)); +} diff --git a/pkg/urbit/jets/c/rsh.c b/pkg/urbit/jets/c/rsh.c index 1919ce3eac..461109b16f 100644 --- a/pkg/urbit/jets/c/rsh.c +++ b/pkg/urbit/jets/c/rsh.c @@ -63,3 +63,14 @@ return d; } +u3_noun +u3wc_new_rsh(u3_noun cor) +{ + u3_atom bloq, step; + u3_noun a, b; + u3x_mean(cor, u3x_sam_2, &a, + u3x_sam_3, &b, 0); + u3x_bite(a, &bloq, &step); + + return u3qc_rsh(bloq, step, u3x_atom(b)); +} diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index c3d6d680a6..2c711f015a 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -1503,6 +1503,10 @@ static c3_c* _141_two_end_ha[] = { "45a0efc0c4ae4b93f554d480a9d2c52474d5ebd6b1b9b0ab888b9bee2117db55", 0 }; +static u3j_harm _141_two_new_end_a[] = {{".2", u3wc_new_end, c3y}, {}}; +static c3_c* _141_two_new_end_ha[] = { + 0 +}; static u3j_harm _141_two_gor_a[] = {{".2", u3wc_gor, c3y}, {}}; static c3_c* _141_two_gor_ha[] = { "3ab7d6a56b8b347bd677a77ec43cda984d1eb869bab5c9bc2185f5c4a366703a", @@ -1513,6 +1517,10 @@ static c3_c* _141_two_lsh_ha[] = { "a93f01f1db5bcaf1973d01234bbcec8f8adf9d6402a8d715a1b13b70a140a428", 0 }; +static u3j_harm _141_two_new_lsh_a[] = {{".2", u3wc_new_lsh, c3y}, {}}; +static c3_c* _141_two_new_lsh_ha[] = { + 0 +}; // XX appears to be a duplicate of _141_one_mas_a // static u3j_harm _141_two_mas_a[] = {{".2", u3wc_mas, c3y}, {}}; @@ -1577,6 +1585,10 @@ static c3_c* _141_two_rsh_ha[] = { "a401145b4c11ec8d17a729fe30f06c295865ffed1b970b0a788f0fec1ed0a703", 0 }; +static u3j_harm _141_two_new_rsh_a[] = {{".2", u3wc_new_rsh, c3y}, {}}; +static c3_c* _141_two_new_rsh_ha[] = { + 0 +}; static u3j_harm _141_two_swp_a[] = {{".2", u3wc_swp, c3y}, {}}; static c3_c* _141_two_swp_ha[] = { "f809ed11a87db6cef8944c7252d53cda1e030240ee52912c3843d56805ac17fa", @@ -1845,9 +1857,11 @@ static u3j_core _141_two_d[] = { "dor", 7, _141_two_dor_a, 0, _141_two_dor_ha }, { "dvr", 7, _141_two_dvr_a, 0, _141_two_dvr_ha }, { "end", 7, _141_two_end_a, 0, _141_two_end_ha }, + { "new-end", 7, _141_two_new_end_a, 0, _141_two_new_end_ha }, { "gor", 7, _141_two_gor_a, 0, _141_two_gor_ha }, { "jam", 7, _141_two_jam_a, 0, _141_two_jam_ha }, { "lsh", 7, _141_two_lsh_a, 0, _141_two_lsh_ha }, + { "new-lsh", 7, _141_two_new_lsh_a, 0, _141_two_new_lsh_ha }, { "mas", 7, _141_two_mas_a, 0, _141_two_mas_ha }, { "mat", 7, _141_two_mat_a, 0, _141_two_mat_ha }, { "met", 7, _141_two_met_a, 0, _141_two_met_ha }, @@ -1860,6 +1874,7 @@ static u3j_core _141_two_d[] = { "rev", 7, _141_two_rev_a, 0, _141_two_rev_ha }, { "rip", 7, _141_two_rip_a, 0, _141_two_rip_ha }, { "rsh", 7, _141_two_rsh_a, 0, _141_two_rsh_ha }, + { "new-rsh", 7, _141_two_new_rsh_a, 0, _141_two_new_rsh_ha }, { "swp", 7, _141_two_swp_a, 0, _141_two_swp_ha }, { "rub", 7, _141_two_rub_a, 0, _141_two_rub_ha }, { "peg", 7, _141_two_peg_a, 0, _141_two_peg_ha }, From ac4b2a46f2e3c93dbd5b783e7a3ba66117702515 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 2 Dec 2020 00:20:40 -0800 Subject: [PATCH 866/933] pill: solid/ivory --- bin/ivory.pill | 4 ++-- bin/solid.pill | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/ivory.pill b/bin/ivory.pill index 925ed6d0ae..a6240f8ece 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6d12c44e418116ade175b55f167b212fd6076efd548edcdfd066ad23317fa6cc -size 2217886 +oid sha256:b867fe922a2d08b7086aa4e4410f8226131799df100f95beb9ecd194732f2c7d +size 2414162 diff --git a/bin/solid.pill b/bin/solid.pill index b79b67cce1..ec320ab798 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9fe3cbf26674fad093ef0d45c3532116c073b04d5cec5c7c06d565d6ab7b94ce -size 6892934 +oid sha256:8a105bc02c193108fc51caade9de5fbf7b5c373419d9ded5e8e38d09c434503f +size 6997944 From 9e713a5e10263e8b35e8c4af3b2e85c860431919 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 2 Dec 2020 00:24:38 -0800 Subject: [PATCH 867/933] hoon: removes +end, +lsh, and +rsh --- pkg/arvo/sys/hoon.hoon | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 9cde2cfb1c..1ad480e2cb 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -854,11 +854,6 @@ |= [a=bloq [b=step c=step] d=@] (new-end [a c] (new-rsh [a b] d)) :: -++ end :: tail - ~/ %end - |= [a=bloq b=step c=@] - (mod c (bex (mul (bex a) b))) -:: ++ new-end :: tail ~/ %new-end |= [a=bite b=@] @@ -875,11 +870,6 @@ (new-rsh a d) $(d (add c (new-lsh a d)), n +(n)) :: -++ lsh :: left-shift - ~/ %lsh - |= [a=bloq b=step c=@] - (mul (bex (mul (bex a) b)) c) -:: ++ new-lsh :: left-shift ~/ %new-lsh |= [a=bite b=@] @@ -934,11 +924,6 @@ ?: =(0 b) ~ [(new-end a b) $(b (new-rsh a b))] :: -++ rsh :: right-shift - ~/ %rsh - |= [a=bloq b=step c=@] - (div c (bex (mul (bex a) b))) -:: ++ new-rsh :: right-shift ~/ %new-rsh |= [a=bite b=@] From c082c2677a63b82fc0bcc856d6866bc5e408181a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 2 Dec 2020 00:27:29 -0800 Subject: [PATCH 868/933] u3: updates +end, +lsh, and +rsh jet interfaces --- pkg/urbit/include/jets/w.h | 3 -- pkg/urbit/jets/c/end.c | 68 ++++++++++------------------ pkg/urbit/jets/c/lsh.c | 91 +++++++++++++++----------------------- pkg/urbit/jets/c/rsh.c | 85 ++++++++++++++--------------------- pkg/urbit/jets/tree.c | 18 ++------ 5 files changed, 96 insertions(+), 169 deletions(-) diff --git a/pkg/urbit/include/jets/w.h b/pkg/urbit/include/jets/w.h index e81acabb02..8065457fd2 100644 --- a/pkg/urbit/include/jets/w.h +++ b/pkg/urbit/include/jets/w.h @@ -55,10 +55,8 @@ u3_noun u3wc_dor(u3_noun); u3_noun u3wc_dvr(u3_noun); u3_noun u3wc_end(u3_noun); - u3_noun u3wc_new_end(u3_noun); u3_noun u3wc_gor(u3_noun); u3_noun u3wc_lsh(u3_noun); - u3_noun u3wc_new_lsh(u3_noun); u3_noun u3wc_mas(u3_noun); u3_noun u3wc_met(u3_noun); u3_noun u3wc_mix(u3_noun); @@ -72,7 +70,6 @@ u3_noun u3wc_rev(u3_noun); u3_noun u3wc_rip(u3_noun); u3_noun u3wc_rsh(u3_noun); - u3_noun u3wc_new_rsh(u3_noun); u3_noun u3wc_swp(u3_noun); u3_noun u3wc_sqt(u3_noun); diff --git a/pkg/urbit/jets/c/end.c b/pkg/urbit/jets/c/end.c index 3d23815507..c63451d8fe 100644 --- a/pkg/urbit/jets/c/end.c +++ b/pkg/urbit/jets/c/end.c @@ -3,61 +3,41 @@ */ #include "all.h" +u3_noun +u3qc_end(u3_atom a, + u3_atom b, + u3_atom c) +{ + if ( !_(u3a_is_cat(a)) || (a >= 32) ) { + return u3m_bail(c3__fail); + } + else if ( !_(u3a_is_cat(b)) ) { + return u3k(c); + } + else { + c3_g a_g = a; + c3_w b_w = b; + c3_w len_w = u3r_met(a_g, c); -/* functions -*/ - u3_noun - u3qc_end(u3_atom a, - u3_atom b, - u3_atom c) - { - if ( !_(u3a_is_cat(a)) || (a >= 32) ) { - return u3m_bail(c3__fail); + if ( 0 == b_w ) { + return 0; } - else if ( !_(u3a_is_cat(b)) ) { + else if ( b_w >= len_w ) { return u3k(c); } else { - c3_g a_g = a; - c3_w b_w = b; - c3_w len_w = u3r_met(a_g, c); + u3i_slab sab_u; + u3i_slab_init(&sab_u, a_g, b_w); - if ( 0 == b_w ) { - return 0; - } - else if ( b_w >= len_w ) { - return u3k(c); - } - else { - u3i_slab sab_u; - u3i_slab_init(&sab_u, a_g, b_w); + u3r_chop(a_g, 0, b_w, 0, sab_u.buf_w, c); - u3r_chop(a_g, 0, b_w, 0, sab_u.buf_w, c); - - return u3i_slab_mint(&sab_u); - } - } - } - u3_noun - u3wc_end(u3_noun cor) - { - u3_noun a, b, c; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, - u3x_sam_6, &b, - u3x_sam_7, &c, 0)) || - (c3n == u3ud(a)) || - (c3n == u3ud(b)) || - (c3n == u3ud(c)) ) - { - return u3m_bail(c3__exit); - } else { - return u3qc_end(a, b, c); + return u3i_slab_mint(&sab_u); } } +} u3_noun -u3wc_new_end(u3_noun cor) +u3wc_end(u3_noun cor) { u3_atom bloq, step; u3_noun a, b; diff --git a/pkg/urbit/jets/c/lsh.c b/pkg/urbit/jets/c/lsh.c index a205d7249a..7ef4f36357 100644 --- a/pkg/urbit/jets/c/lsh.c +++ b/pkg/urbit/jets/c/lsh.c @@ -3,71 +3,41 @@ */ #include "all.h" +u3_noun +u3qc_lsh(u3_atom a, + u3_atom b, + u3_atom c) +{ + if ( !_(u3a_is_cat(a)) || (a >= 32) ) { + return u3m_bail(c3__fail); + } + else if ( !_(u3a_is_cat(b)) ) { + return u3m_bail(c3__fail); + } + else { + c3_g a_g = a; + c3_w b_w = b; + c3_w len_w = u3r_met(a_g, c); -/* functions -*/ - u3_noun - u3qc_lsh(u3_atom a, - u3_atom b, - u3_atom c) - { - if ( !_(u3a_is_cat(a)) || (a >= 32) ) { - return u3m_bail(c3__fail); + if ( 0 == len_w ) { + return 0; } - else if ( !_(u3a_is_cat(b)) ) { - return u3m_bail(c3__fail); + else if ( (b_w + len_w) < len_w ) { + return u3m_bail(c3__exit); } else { - c3_g a_g = a; - c3_w b_w = b; - c3_w len_w = u3r_met(a_g, c); + u3i_slab sab_u; + u3i_slab_init(&sab_u, a_g, (b_w + len_w)); - if ( 0 == len_w ) { - return 0; - } - else if ( (b_w + len_w) < len_w ) { - return u3m_bail(c3__exit); - } - else { - u3i_slab sab_u; - u3i_slab_init(&sab_u, a_g, (b_w + len_w)); + u3r_chop(a_g, 0, len_w, b_w, sab_u.buf_w, c); - u3r_chop(a_g, 0, len_w, b_w, sab_u.buf_w, c); - - return u3i_slab_mint(&sab_u); - } + return u3i_slab_mint(&sab_u); } } - u3_noun - u3wc_lsh(u3_noun cor) - { - u3_noun a, b, c; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, - u3x_sam_6, &b, - u3x_sam_7, &c, 0)) || - (c3n == u3ud(a)) || - (c3n == u3ud(b)) || - (c3n == u3ud(c)) ) - { - return u3m_bail(c3__exit); - } else { - return u3qc_lsh(a, b, c); - } - } - u3_noun - u3kc_lsh(u3_noun a, - u3_noun b, - u3_noun c) - { - u3_noun d = u3qc_lsh(a, b, c); - - u3z(a); u3z(b); u3z(c); - return d; - } +} u3_noun -u3wc_new_lsh(u3_noun cor) +u3wc_lsh(u3_noun cor) { u3_atom bloq, step; u3_noun a, b; @@ -77,3 +47,14 @@ u3wc_new_lsh(u3_noun cor) return u3qc_lsh(bloq, step, u3x_atom(b)); } + +u3_noun +u3kc_lsh(u3_noun a, + u3_noun b, + u3_noun c) +{ + u3_noun d = u3qc_lsh(a, b, c); + + u3z(a); u3z(b); u3z(c); + return d; +} diff --git a/pkg/urbit/jets/c/rsh.c b/pkg/urbit/jets/c/rsh.c index 461109b16f..4922e0c587 100644 --- a/pkg/urbit/jets/c/rsh.c +++ b/pkg/urbit/jets/c/rsh.c @@ -3,68 +3,38 @@ */ #include "all.h" +u3_noun +u3qc_rsh(u3_atom a, + u3_atom b, + u3_atom c) +{ + if ( !_(u3a_is_cat(a)) || (a >= 32) ) { + return u3m_bail(c3__fail); + } + else if ( !_(u3a_is_cat(b)) ) { + return 0; + } + else { + c3_g a_g = a; + c3_w b_w = b; + c3_w len_w = u3r_met(a_g, c); -/* functions -*/ - u3_noun - u3qc_rsh(u3_atom a, - u3_atom b, - u3_atom c) - { - if ( !_(u3a_is_cat(a)) || (a >= 32) ) { - return u3m_bail(c3__fail); - } - else if ( !_(u3a_is_cat(b)) ) { + if ( b_w >= len_w ) { return 0; } else { - c3_g a_g = a; - c3_w b_w = b; - c3_w len_w = u3r_met(a_g, c); + u3i_slab sab_u; + u3i_slab_init(&sab_u, a_g, (len_w - b_w)); - if ( b_w >= len_w ) { - return 0; - } - else { - u3i_slab sab_u; - u3i_slab_init(&sab_u, a_g, (len_w - b_w)); + u3r_chop(a_g, b_w, (len_w - b_w), 0, sab_u.buf_w, c); - u3r_chop(a_g, b_w, (len_w - b_w), 0, sab_u.buf_w, c); - - return u3i_slab_mint(&sab_u); - } + return u3i_slab_mint(&sab_u); } } - u3_noun - u3wc_rsh(u3_noun cor) - { - u3_noun a, b, c; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, - u3x_sam_6, &b, - u3x_sam_7, &c, 0)) || - (c3n == u3ud(a)) || - (c3n == u3ud(b)) || - (c3n == u3ud(c)) ) - { - return u3m_bail(c3__exit); - } else { - return u3qc_rsh(a, b, c); - } - } - u3_noun - u3kc_rsh(u3_noun a, - u3_noun b, - u3_noun c) - { - u3_noun d = u3qc_rsh(a, b, c); - - u3z(a); u3z(b); u3z(c); - return d; - } +} u3_noun -u3wc_new_rsh(u3_noun cor) +u3wc_rsh(u3_noun cor) { u3_atom bloq, step; u3_noun a, b; @@ -74,3 +44,14 @@ u3wc_new_rsh(u3_noun cor) return u3qc_rsh(bloq, step, u3x_atom(b)); } + +u3_noun +u3kc_rsh(u3_noun a, + u3_noun b, + u3_noun c) +{ + u3_noun d = u3qc_rsh(a, b, c); + + u3z(a); u3z(b); u3z(c); + return d; +} diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 2c711f015a..62e0f48c72 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -1503,10 +1503,6 @@ static c3_c* _141_two_end_ha[] = { "45a0efc0c4ae4b93f554d480a9d2c52474d5ebd6b1b9b0ab888b9bee2117db55", 0 }; -static u3j_harm _141_two_new_end_a[] = {{".2", u3wc_new_end, c3y}, {}}; -static c3_c* _141_two_new_end_ha[] = { - 0 -}; static u3j_harm _141_two_gor_a[] = {{".2", u3wc_gor, c3y}, {}}; static c3_c* _141_two_gor_ha[] = { "3ab7d6a56b8b347bd677a77ec43cda984d1eb869bab5c9bc2185f5c4a366703a", @@ -1517,10 +1513,6 @@ static c3_c* _141_two_lsh_ha[] = { "a93f01f1db5bcaf1973d01234bbcec8f8adf9d6402a8d715a1b13b70a140a428", 0 }; -static u3j_harm _141_two_new_lsh_a[] = {{".2", u3wc_new_lsh, c3y}, {}}; -static c3_c* _141_two_new_lsh_ha[] = { - 0 -}; // XX appears to be a duplicate of _141_one_mas_a // static u3j_harm _141_two_mas_a[] = {{".2", u3wc_mas, c3y}, {}}; @@ -1585,10 +1577,6 @@ static c3_c* _141_two_rsh_ha[] = { "a401145b4c11ec8d17a729fe30f06c295865ffed1b970b0a788f0fec1ed0a703", 0 }; -static u3j_harm _141_two_new_rsh_a[] = {{".2", u3wc_new_rsh, c3y}, {}}; -static c3_c* _141_two_new_rsh_ha[] = { - 0 -}; static u3j_harm _141_two_swp_a[] = {{".2", u3wc_swp, c3y}, {}}; static c3_c* _141_two_swp_ha[] = { "f809ed11a87db6cef8944c7252d53cda1e030240ee52912c3843d56805ac17fa", @@ -1857,11 +1845,11 @@ static u3j_core _141_two_d[] = { "dor", 7, _141_two_dor_a, 0, _141_two_dor_ha }, { "dvr", 7, _141_two_dvr_a, 0, _141_two_dvr_ha }, { "end", 7, _141_two_end_a, 0, _141_two_end_ha }, - { "new-end", 7, _141_two_new_end_a, 0, _141_two_new_end_ha }, + { "new-end", 7, _141_two_end_a, 0, _141_two_end_ha }, { "gor", 7, _141_two_gor_a, 0, _141_two_gor_ha }, { "jam", 7, _141_two_jam_a, 0, _141_two_jam_ha }, { "lsh", 7, _141_two_lsh_a, 0, _141_two_lsh_ha }, - { "new-lsh", 7, _141_two_new_lsh_a, 0, _141_two_new_lsh_ha }, + { "new-lsh", 7, _141_two_lsh_a, 0, _141_two_lsh_ha }, { "mas", 7, _141_two_mas_a, 0, _141_two_mas_ha }, { "mat", 7, _141_two_mat_a, 0, _141_two_mat_ha }, { "met", 7, _141_two_met_a, 0, _141_two_met_ha }, @@ -1874,7 +1862,7 @@ static u3j_core _141_two_d[] = { "rev", 7, _141_two_rev_a, 0, _141_two_rev_ha }, { "rip", 7, _141_two_rip_a, 0, _141_two_rip_ha }, { "rsh", 7, _141_two_rsh_a, 0, _141_two_rsh_ha }, - { "new-rsh", 7, _141_two_new_rsh_a, 0, _141_two_new_rsh_ha }, + { "new-rsh", 7, _141_two_rsh_a, 0, _141_two_rsh_ha }, { "swp", 7, _141_two_swp_a, 0, _141_two_swp_ha }, { "rub", 7, _141_two_rub_a, 0, _141_two_rub_ha }, { "peg", 7, _141_two_peg_a, 0, _141_two_peg_ha }, From b5ec0c30f04f711a0c25f06b12c46af59d45bc29 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 2 Dec 2020 00:47:29 -0800 Subject: [PATCH 869/933] hoon: renames +new-end, +new-lsh, +new-rsh --- pkg/arvo/app/chat-cli.hoon | 2 +- pkg/arvo/app/chat-hook.hoon | 2 +- pkg/arvo/app/dbug.hoon | 2 +- pkg/arvo/app/dojo.hoon | 12 +- pkg/arvo/app/file-server.hoon | 4 +- pkg/arvo/app/glob.hoon | 6 +- pkg/arvo/app/hood.hoon | 2 +- pkg/arvo/gen/help.hoon | 2 +- pkg/arvo/gen/hood/claz-invites.hoon | 2 +- pkg/arvo/gen/hood/moon.hoon | 2 +- pkg/arvo/gen/key.hoon | 8 +- pkg/arvo/gen/reload-event.hoon | 4 +- pkg/arvo/lib/base64.hoon | 2 +- pkg/arvo/lib/bip32.hoon | 12 +- pkg/arvo/lib/bip39.hoon | 6 +- pkg/arvo/lib/der.hoon | 6 +- pkg/arvo/lib/hood/drum.hoon | 2 +- pkg/arvo/lib/hood/helm.hoon | 4 +- pkg/arvo/lib/keygen.hoon | 8 +- pkg/arvo/lib/language-server/complete.hoon | 10 +- pkg/arvo/lib/language-server/easy-print.hoon | 2 +- pkg/arvo/lib/link-store.hoon | 2 +- pkg/arvo/lib/old-phon.hoon | 10 +- pkg/arvo/lib/pkcs.hoon | 2 +- pkg/arvo/lib/primitive-rsa.hoon | 4 +- pkg/arvo/lib/ring.hoon | 12 +- pkg/arvo/lib/shoe.hoon | 2 +- pkg/arvo/lib/test/runner.hoon | 2 +- pkg/arvo/mar/eth/txs.hoon | 2 +- pkg/arvo/mar/hash.hoon | 2 +- pkg/arvo/mar/udon.hoon | 2 +- pkg/arvo/mar/umd.hoon | 2 +- pkg/arvo/sys/arvo.hoon | 6 +- pkg/arvo/sys/hoon.hoon | 306 +++++++++---------- pkg/arvo/sys/vane/ames.hoon | 38 +-- pkg/arvo/sys/vane/clay.hoon | 4 +- pkg/arvo/sys/vane/eyre.hoon | 4 +- pkg/arvo/sys/vane/gall.hoon | 2 +- pkg/arvo/sys/vane/jael.hoon | 2 +- pkg/arvo/sys/zuse.hoon | 234 +++++++------- pkg/arvo/ted/aqua/eyre-azimuth.hoon | 4 +- pkg/arvo/ted/eth/send-txs.hoon | 8 +- pkg/arvo/ted/test.hoon | 2 +- pkg/arvo/tests/sys/zuse/crypto/ripemd.hoon | 2 +- 44 files changed, 377 insertions(+), 377 deletions(-) diff --git a/pkg/arvo/app/chat-cli.hoon b/pkg/arvo/app/chat-cli.hoon index 65c3b70cd9..f23dbf684a 100644 --- a/pkg/arvo/app/chat-cli.hoon +++ b/pkg/arvo/app/chat-cli.hoon @@ -767,7 +767,7 @@ :- %chat-view-action !> ^- action:view :* %create - (new-rsh 3 (spat path)) + (rsh 3 (spat path)) '' real-path :: chat group-path :: group diff --git a/pkg/arvo/app/chat-hook.hoon b/pkg/arvo/app/chat-hook.hoon index e15e72b606..3f08ae8e16 100644 --- a/pkg/arvo/app/chat-hook.hoon +++ b/pkg/arvo/app/chat-hook.hoon @@ -558,7 +558,7 @@ :: correctly initialized, no need to do cleanup :: ~ - ?. =((new-end [3 4] i.t.path) 'dm--') + ?. =((end [3 4] i.t.path) 'dm--') ~ :- =- [%pass /fixdm %agent [our.bol %chat-view] %poke %chat-view-action -] !> ^- action:view diff --git a/pkg/arvo/app/dbug.hoon b/pkg/arvo/app/dbug.hoon index d1e542b7f4..59e3500792 100644 --- a/pkg/arvo/app/dbug.hoon +++ b/pkg/arvo/app/dbug.hoon @@ -362,7 +362,7 @@ (gth expiry-time.a expiry-time.b) |= [cookie=@uv session:eyre] %- pairs - :~ 'cookie'^s+(new-end [3 4] (new-rsh [3 2] (scot %x (shax cookie)))) + :~ 'cookie'^s+(end [3 4] (rsh [3 2] (scot %x (shax cookie)))) 'expiry'^(time expiry-time) 'channels'^(numb ~(wyt in channels)) == diff --git a/pkg/arvo/app/dojo.hoon b/pkg/arvo/app/dojo.hoon index f55fe657cf..43215f665c 100644 --- a/pkg/arvo/app/dojo.hoon +++ b/pkg/arvo/app/dojo.hoon @@ -1249,7 +1249,7 @@ =/ advance (advance-hoon:auto typ p.q.q.p.u.q.vex) =? res ?=(^ advance) =/ to-send - (trip (new-rsh [3 (sub pos back-pos)] u.advance)) + (trip (rsh [3 (sub pos back-pos)] u.advance)) =| fxs=(list sole-effect) =. . |- ^+ +.$ @@ -1340,7 +1340,7 @@ %+ murn ~(tap by dir:.^(arch %cy pax)) |= [=term ~] ^- (unit [^term tank]) - ?. =(app (new-end [3 (met 3 app)] term)) + ?. =(app (end [3 (met 3 app)] term)) ~ ?~ =<(fil .^(arch %cy (weld pax ~[term %hoon]))) ~ @@ -1352,7 +1352,7 @@ %+ murn ~(tap by var) |= [name=term =cage] ^- (unit [term tank]) - ?. =(variable (new-end [3 (met 3 variable)] name)) + ?. =(variable (end [3 (met 3 variable)] name)) ~ `[name (sell q.cage)] :: @@ -1371,7 +1371,7 @@ %+ murn ~(tap by dir:.^(arch %cy pfix)) |= [=term ~] - ?. =(gen (new-end [3 (met 3 gen)] term)) + ?. =(gen (end [3 (met 3 gen)] term)) ~ ?~ =<(fil .^(arch %cy (weld pfix ~[term %hoon]))) ~ @@ -1386,7 +1386,7 @@ %+ murn ~(tap by dir:.^(arch %cy pax)) |= [=term ~] - ?. =(gen (new-end [3 (met 3 gen)] term)) + ?. =(gen (end [3 (met 3 gen)] term)) ~ ?~ =<(fil .^(arch %cy (weld pax ~[term %hoon]))) ~ @@ -1403,7 +1403,7 @@ =/ back-pos (sub pos (met 3 completing)) =/ to-send - (trip (new-rsh [3 (sub pos back-pos)] advance)) + (trip (rsh [3 (sub pos back-pos)] advance)) =| fxs=(list sole-effect) :: :: Cursor is guaranteed to be at end so we don't worry about the diff --git a/pkg/arvo/app/file-server.hoon b/pkg/arvo/app/file-server.hoon index 52f94ca363..363545d673 100644 --- a/pkg/arvo/app/file-server.hoon +++ b/pkg/arvo/app/file-server.hoon @@ -234,7 +234,7 @@ ?~ data [not-found:gen %.n] :_ public.u.content - =/ mime-type=@t (new-rsh 3 (crip )) + =/ mime-type=@t (rsh 3 (crip )) :: Should maybe inspect to see how long cache should hold :: [[200 ['content-type' mime-type] max-1-da:gen ~] `q.u.data] @@ -323,7 +323,7 @@ ?+ path (on-peek:def path) [%x %clay %base %hash ~] =/ versions (base-hash:version [our now]:bowl) - ``hash+!>(?~(versions 0v0 (new-end [0 25] i.versions))) + ``hash+!>(?~(versions 0v0 (end [0 25] i.versions))) == ++ on-agent on-agent:def ++ on-fail on-fail:def diff --git a/pkg/arvo/app/glob.hoon b/pkg/arvo/app/glob.hoon index eef64e1154..1f8d84ce63 100644 --- a/pkg/arvo/app/glob.hoon +++ b/pkg/arvo/app/glob.hoon @@ -94,11 +94,11 @@ %- ~(rep by dir) |= [[file=@t ~] out=(unit @t)] ?^ out out - ?. ?& =((new-end [3 6] file) 'index.') - !=('sj.' (new-end [3 3] (swp 3 file))) + ?. ?& =((end [3 6] file) 'index.') + !=('sj.' (end [3 3] (swp 3 file))) == out - ``@t`(new-rsh [3 6] file) + ``@t`(rsh [3 6] file) =/ js-name (cat 3 'index.' bundle-hash) =/ map-name diff --git a/pkg/arvo/app/hood.hoon b/pkg/arvo/app/hood.hoon index d62a98261a..1b62fd165f 100644 --- a/pkg/arvo/app/hood.hoon +++ b/pkg/arvo/app/hood.hoon @@ -72,7 +72,7 @@ |= [=mark =vase] ^- step:agent:gall |^ - =/ fin (new-end [3 4] mark) + =/ fin (end [3 4] mark) ?: =(%drum fin) poke-drum ?: =(%helm fin) poke-helm ?: =(%kiln fin) poke-kiln diff --git a/pkg/arvo/gen/help.hoon b/pkg/arvo/gen/help.hoon index c73ce8dd55..7b893eb4eb 100644 --- a/pkg/arvo/gen/help.hoon +++ b/pkg/arvo/gen/help.hoon @@ -27,7 +27,7 @@ == =/ c (to-wain:format a) ?~ c "~" - ?. =(':: ' (new-end [3 4] i.c)) + ?. =(':: ' (end [3 4] i.c)) "" (trip i.c) :: diff --git a/pkg/arvo/gen/hood/claz-invites.hoon b/pkg/arvo/gen/hood/claz-invites.hoon index 9009c2a6dc..fcbe59ae76 100644 --- a/pkg/arvo/gen/hood/claz-invites.hoon +++ b/pkg/arvo/gen/hood/claz-invites.hoon @@ -28,7 +28,7 @@ %+ turn (gulf min-child max-child) |= child=@ud =/ who=ship (cat 4 star child) -=/ ticket=@q (new-end [3 8] (shas who eny)) +=/ ticket=@q (end [3 8] (shas who eny)) =/ owner=address =< addr.keys ::NOTE ~zod because invite wallet convention diff --git a/pkg/arvo/gen/hood/moon.hoon b/pkg/arvo/gen/hood/moon.hoon index d941aa760e..d684c75749 100644 --- a/pkg/arvo/gen/hood/moon.hoon +++ b/pkg/arvo/gen/hood/moon.hoon @@ -23,7 +23,7 @@ =/ mon=ship ?^ arg mon.arg - (add our (new-lsh 5 (new-end 5 (shaz eny)))) + (add our (lsh 5 (end 5 (shaz eny)))) =/ seg=ship (sein:title our now mon) ?. =(our seg) %- %- slog :_ ~ diff --git a/pkg/arvo/gen/key.hoon b/pkg/arvo/gen/key.hoon index 4af7b21d9b..de317c509a 100644 --- a/pkg/arvo/gen/key.hoon +++ b/pkg/arvo/gen/key.hoon @@ -17,11 +17,11 @@ =/ cub (pit:nu:crub:crypto 512 bur) :: =/ pub=pass pub:ex:cub -=/ mag=cord (new-end 3 pub) +=/ mag=cord (end 3 pub) ?> =('b' mag) -=/ bod=@ (new-rsh 3 pub) -=/ cry=@ (new-rsh 8 bod) -=/ sgn=@ (new-end 8 bod) +=/ bod=@ (rsh 3 pub) +=/ cry=@ (rsh 8 bod) +=/ sgn=@ (end 8 bod) %+ print leaf+" authentication: 0x{(render-hex-bytes:ethereum 32 sgn)}" %+ print leaf+" networking: 0x{(render-hex-bytes:ethereum 32 cry)}" %+ print leaf+"ethereum public keys:" diff --git a/pkg/arvo/gen/reload-event.hoon b/pkg/arvo/gen/reload-event.hoon index 745710adc4..5d87775f6b 100644 --- a/pkg/arvo/gen/reload-event.hoon +++ b/pkg/arvo/gen/reload-event.hoon @@ -16,10 +16,10 @@ ?. =(1 (met 3 tam)) tam =/ zaz=(list [p=knot ~]) - (skim van |=([a=term ~] =(tam (new-end 3 a)))) + (skim van |=([a=term ~] =(tam (end 3 a)))) ?> ?=([[@ ~] ~] zaz) `term`p.i.zaz -=/ tip (new-end 3 nam) +=/ tip (end 3 nam) =/ bip ?:(=('z' tip) %$ tip) =/ way ?:(=('z' tip) (welp top /sys/[nam]) (welp top /sys/vane/[nam])) =/ fil .^(@ %cx (welp way /hoon)) diff --git a/pkg/arvo/lib/base64.hoon b/pkg/arvo/lib/base64.hoon index 287517437d..6a73e3b2d9 100644 --- a/pkg/arvo/lib/base64.hoon +++ b/pkg/arvo/lib/base64.hoon @@ -67,7 +67,7 @@ ++ octs-to-blocks |= bs=octs ^- [padding=@ud (list word24)] =/ padding=@ud (~(dif fo 3) 0 p.bs) - =/ padded=octs [(add padding p.bs) (new-lsh [3 padding] (rev 3 bs))] + =/ padded=octs [(add padding p.bs) (lsh [3 padding] (rev 3 bs))] [padding (explode-words 24 padded)] :: ++ unpad diff --git a/pkg/arvo/lib/bip32.hoon b/pkg/arvo/lib/bip32.hoon index d92145f930..02187ad877 100644 --- a/pkg/arvo/lib/bip32.hoon +++ b/pkg/arvo/lib/bip32.hoon @@ -56,8 +56,8 @@ ++ take |= b=@ud ^- [v=@ x=@] - :- (new-end [3 b] x) - (new-rsh [3 b] x) + :- (end [3 b] x) + (rsh [3 b] x) -- =^ k x (take 33) =^ c x (take 32) @@ -173,7 +173,7 @@ ^- @uc :: removes checksum :: - %+ new-rsh [3 4] + %+ rsh [3 4] %+ en-base58check [4 (version-bytes network %pub %.n)] [20 identity] @@ -211,15 +211,15 @@ |= [v=byts d=byts] =+ p=[(add wid.v wid.d) (can 3 ~[d v])] =- (can 3 ~[4^- p]) - %+ new-rsh [3 28] + %+ rsh [3 28] (sha-256l:sha 32 (sha-256l:sha p)) :: ++ de-base58check :: vw: amount of version bytes |= [vw=@u t=tape] =+ x=(de-base58:mimes:html t) - =+ hash=(sha-256l:sha 32 (sha-256:sha (new-rsh [3 4] x))) - ?> =((new-end [3 4] x) (new-rsh [3 28] hash)) + =+ hash=(sha-256l:sha 32 (sha-256:sha (rsh [3 4] x))) + ?> =((end [3 4] x) (rsh [3 28] hash)) (cut 3 [vw (sub (met 3 x) (add 4 vw))] x) :: ++ hash160 diff --git a/pkg/arvo/lib/bip39.hoon b/pkg/arvo/lib/bip39.hoon index 01d97c01d5..cc33fe479f 100644 --- a/pkg/arvo/lib/bip39.hoon +++ b/pkg/arvo/lib/bip39.hoon @@ -12,7 +12,7 @@ :: =+ cs=(div wid 32) =/ check=@ - %+ new-rsh [0 (sub 256 cs)] + %+ rsh [0 (sub 256 cs)] (sha-256l:sha (div wid 8) dat) =/ bits=byts :- (add wid cs) @@ -23,9 +23,9 @@ :: =/ pieces |- ^- (list @) - :- (new-end [0 11] dat.bits) + :- (end [0 11] dat.bits) ?: (lte wid.bits 11) ~ - $(bits [(sub wid.bits 11) (new-rsh [0 11] dat.bits)]) + $(bits [(sub wid.bits 11) (rsh [0 11] dat.bits)]) :: =/ words=(list tape) %+ turn pieces diff --git a/pkg/arvo/lib/der.hoon b/pkg/arvo/lib/der.hoon index a7f48411d2..c46acc87f3 100644 --- a/pkg/arvo/lib/der.hoon +++ b/pkg/arvo/lib/der.hoon @@ -142,10 +142,10 @@ ++ bit |= [len=@ud dat=@ux] ^- (unit [len=@ud dat=@ux]) - ?. =(0 (new-end 3 dat)) ~ + ?. =(0 (end 3 dat)) ~ :+ ~ (mul 8 (dec len)) - (new-rsh 3 dat) + (rsh 3 dat) :: +recur:parse:der: parse bytes for a list of +spec:asn1 :: ++ recur @@ -188,7 +188,7 @@ =/ [nex=@ len=@] :: faz: meaningful bits in fuz :: - =/ faz (new-end [0 7] fuz) + =/ faz (end [0 7] fuz) ?: =(0 (cut 0 [7 1] fuz)) [0 faz] [faz (rep 3 (flop (scag faz t.q.tub)))] diff --git a/pkg/arvo/lib/hood/drum.hoon b/pkg/arvo/lib/hood/drum.hoon index f356e2ab01..df09a16ead 100644 --- a/pkg/arvo/lib/hood/drum.hoon +++ b/pkg/arvo/lib/hood/drum.hoon @@ -1058,7 +1058,7 @@ %+ welp cad.pom ?~ buf.say.inp ~ - :(welp "<" (scow %p (new-end 4 (sham buf.say.inp))) "> ") + :(welp "<" (scow %p (end 4 (sham buf.say.inp))) "> ") :: ++ ta-yan :: yank (snag (sub num.kil pos.kil) old.kil) diff --git a/pkg/arvo/lib/hood/helm.hoon b/pkg/arvo/lib/hood/helm.hoon index c4c13ccfeb..8dd29c03de 100644 --- a/pkg/arvo/lib/hood/helm.hoon +++ b/pkg/arvo/lib/hood/helm.hoon @@ -168,10 +168,10 @@ ?. =(1 (met 3 nam)) nam =/ zaz=(list [p=knot ~]) - (skim van |=([a=term ~] =(nam (new-end 3 a)))) + (skim van |=([a=term ~] =(nam (end 3 a)))) ?> ?=([[@ ~] ~] zaz) `term`p.i.zaz - =+ tip=(new-end 3 nam) + =+ tip=(end 3 nam) =+ zus==('z' tip) =+ way=?:(zus (welp top /sys/[nam]) (welp top /sys/vane/[nam])) =+ fil=.^(@ %cx (welp way /hoon)) diff --git a/pkg/arvo/lib/keygen.hoon b/pkg/arvo/lib/keygen.hoon index 89cff138b0..477ccfc006 100644 --- a/pkg/arvo/lib/keygen.hoon +++ b/pkg/arvo/lib/keygen.hoon @@ -96,11 +96,11 @@ =+ =< [pub=pub:ex sec=sec:ex] (pit:nu:crub:crypto 256 seed) :- ^= auth - :- (new-rsh 3 (new-end [3 33] pub)) - (new-rsh 3 (new-end [3 33] sec)) + :- (rsh 3 (end [3 33] pub)) + (rsh 3 (end [3 33] sec)) ^= crypt - :- (new-rsh [3 33] pub) - (new-rsh [3 33] sec) + :- (rsh [3 33] pub) + (rsh [3 33] sec) :: ++ seed |= [seed=byts salt=tape] diff --git a/pkg/arvo/lib/language-server/complete.hoon b/pkg/arvo/lib/language-server/complete.hoon index 0d4d109d99..6e352e8196 100644 --- a/pkg/arvo/lib/language-server/complete.hoon +++ b/pkg/arvo/lib/language-server/complete.hoon @@ -87,7 +87,7 @@ %+ skim ids |= [id=cord *] ^- ?(%.y %.n) - =(sid (new-end [3 (met 3 sid)] id)) + =(sid (end [3 (met 3 sid)] id)) :: :: Get the longest prefix of a list of identifiers. :: @@ -101,14 +101,14 @@ |- ^- term ?: (gth n last) term.i.matches - =/ prefix (new-end [3 n] term.i.matches) + =/ prefix (end [3 n] term.i.matches) ?: |- ^- ? ?| ?=(~ t.matches) - ?& =(prefix (new-end [3 n] term.i.t.matches)) + ?& =(prefix (end [3 n] term.i.t.matches)) $(t.matches t.t.matches) == == $(n +(n)) - (new-end [3 (dec n)] term.i.matches) + (end [3 (dec n)] term.i.matches) :: :: Run +find-type safely, printing the first line of the stack trace on :: error. @@ -369,7 +369,7 @@ :- %leaf =/ c (to-wain:format a) ?~ c "~" - ?. =(':: ' (new-end [3 4] i.c)) + ?. =(':: ' (end [3 4] i.c)) "" (trip i.c) -- diff --git a/pkg/arvo/lib/language-server/easy-print.hoon b/pkg/arvo/lib/language-server/easy-print.hoon index 88a7699582..12558c8a5f 100644 --- a/pkg/arvo/lib/language-server/easy-print.hoon +++ b/pkg/arvo/lib/language-server/easy-print.hoon @@ -39,7 +39,7 @@ ['\\' i.mil $(mil t.mil)] ?: (lte ' ' i.mil) [i.mil $(mil t.mil)] - ['\\' ~(x ne (new-rsh 2 i.mil)) ~(x ne (new-end 2 i.mil)) $(mil t.mil)] + ['\\' ~(x ne (rsh 2 i.mil)) ~(x ne (end 2 i.mil)) $(mil t.mil)] :: ++ deal |=(lum=* (dish dole lum)) ++ dial diff --git a/pkg/arvo/lib/link-store.hoon b/pkg/arvo/lib/link-store.hoon index 6da01c48f5..15ddfa91ac 100644 --- a/pkg/arvo/lib/link-store.hoon +++ b/pkg/arvo/lib/link-store.hoon @@ -22,7 +22,7 @@ =* host r.p.u.murl ?- -.host %& (roll (join '.' p.host) (cury cat 3)) - %| (new-rsh 3 (scot %if p.host)) + %| (rsh 3 (scot %if p.host)) == :: ++ build-discussion-path diff --git a/pkg/arvo/lib/old-phon.hoon b/pkg/arvo/lib/old-phon.hoon index 559cfb7836..69a08e525b 100644 --- a/pkg/arvo/lib/old-phon.hoon +++ b/pkg/arvo/lib/old-phon.hoon @@ -88,9 +88,9 @@ :: ++ mu |_ [top=@ bot=@] - ++ zag [p=(new-end 4 (add top bot)) q=bot] - ++ zig [p=(new-end 4 (add top (sub 0x1.0000 bot))) q=bot] - ++ zug (mix (new-lsh 4 top) bot) + ++ zag [p=(end 4 (add top bot)) q=bot] + ++ zig [p=(end 4 (add top (sub 0x1.0000 bot))) q=bot] + ++ zug (mix (lsh 4 top) bot) -- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: section 2eN, pseudo-cryptography :: @@ -111,7 +111,7 @@ ?: =(0 len) ~ => .(len (dec len)) - =+ mog=(zyft :(mix mig (new-end 3 len) (cut 3 [len 1] pyn))) + =+ mog=(zyft :(mix mig (end 3 len) (cut 3 [len 1] pyn))) [[1 mog] $(mig mog)] :: ++ wred :: restore structure @@ -129,7 +129,7 @@ ~ => .(len (dec len)) =+ mog=(cut 3 [len 1] cry) - [[1 :(mix mig (new-end 3 len) (zyrt mog))] $(mig mog)] + [[1 :(mix mig (end 3 len) (zyrt mog))] $(mig mog)] :: ++ xafo |=([a=@ b=@] +((mod (add (dec b) a) 255))) ++ xaro |=([a=@ b=@] +((mod (add (dec b) (sub 255 (mod a 255))) 255))) diff --git a/pkg/arvo/lib/pkcs.hoon b/pkg/arvo/lib/pkcs.hoon index b1fce389f5..d082666aef 100644 --- a/pkg/arvo/lib/pkcs.hoon +++ b/pkg/arvo/lib/pkcs.hoon @@ -62,7 +62,7 @@ |- ^- wain ?~ a [(rap 3 ['-----END ' lab '-----' ~]) ~] - [(new-end [3 64] a) $(a (new-rsh [3 64] a))] + [(end [3 64] a) $(a (rsh [3 64] a))] :: +de:pem: PEM decode :: ++ de diff --git a/pkg/arvo/lib/primitive-rsa.hoon b/pkg/arvo/lib/primitive-rsa.hoon index aa6edd60cd..b843e25459 100644 --- a/pkg/arvo/lib/primitive-rsa.hoon +++ b/pkg/arvo/lib/primitive-rsa.hoon @@ -36,7 +36,7 @@ :: Sets low bit, as prime must be odd. :: Sets high bit, as +raw:og only gives up to :a bits. :: - =/ e :(con 1 (new-lsh [0 (dec a)] 1) (~(raw og c) a)) + =/ e :(con 1 (lsh [0 (dec a)] 1) (~(raw og c) a)) :: XX what algorithm is this modular remainder check? :: ?: ?& (levy b |=(f=@ !=(1 (mod e f)))) @@ -55,7 +55,7 @@ =/ e `@ux`65.537 |= [wid=@ eny=@] ^- key - =/ diw (new-rsh 0 wid) + =/ diw (rsh 0 wid) =/ p=@ux (ramp diw [3 5 ~] eny) =/ q=@ux (ramp diw [3 5 ~] +(eny)) =/ n=@ux (mul p q) diff --git a/pkg/arvo/lib/ring.hoon b/pkg/arvo/lib/ring.hoon index 99f893223e..a7be742b7f 100644 --- a/pkg/arvo/lib/ring.hoon +++ b/pkg/arvo/lib/ring.hoon @@ -321,26 +321,26 @@ ++ seed-to-private-key-scalar |= sk=@I ^- @udscalar ?: (gth (met 3 sk) 32) !! - =+ h=(shal (new-rsh [0 3] b:ed:crypto) sk) + =+ h=(shal (rsh [0 3] b:ed:crypto) sk) %+ add (bex (sub b:ed:crypto 2)) - (new-lsh [0 3] (cut 0 [3 (sub b:ed:crypto 5)] h)) + (lsh [0 3] (cut 0 [3 (sub b:ed:crypto 5)] h)) :: +get-public-key-from-pass: decode the raw @ public key structure :: ++ get-public-key-from-pass |= a=pass ^- [@ @] - =+ [mag=(new-end 3 a) bod=(new-rsh 3 a)] + =+ [mag=(end 3 a) bod=(rsh 3 a)] ~| %not-crub-pubkey ?> =('b' mag) - [cry=(new-rsh 8 bod) sgn=(new-end 8 bod)] + [cry=(rsh 8 bod) sgn=(end 8 bod)] :: :: ++ get-private-key-from-ring |= a=ring ^- [@ @] - =+ [mag=(new-end 3 a) bod=(new-rsh 3 a)] + =+ [mag=(end 3 a) bod=(rsh 3 a)] ~| %not-crub-seckey ?> =('B' mag) - =+ [c=(new-rsh 8 bod) s=(new-end 8 bod)] + =+ [c=(rsh 8 bod) s=(end 8 bod)] :: todo: do we puck here? [c s] :: +ship-life-to-pubid: fetches public key information from jael diff --git a/pkg/arvo/lib/shoe.hoon b/pkg/arvo/lib/shoe.hoon index 66c0fbd365..d3769ad00f 100644 --- a/pkg/arvo/lib/shoe.hoon +++ b/pkg/arvo/lib/shoe.hoon @@ -302,7 +302,7 @@ (longest-match:auto options) =/ to-send=tape %- trip - (new-rsh [3 (met 3 needle)] advance) + (rsh [3 (met 3 needle)] advance) =/ send-pos=@ud %+ add pos (met 3 (fall forward '')) diff --git a/pkg/arvo/lib/test/runner.hoon b/pkg/arvo/lib/test/runner.hoon index aded2ffa5e..74a2f8e99c 100644 --- a/pkg/arvo/lib/test/runner.hoon +++ b/pkg/arvo/lib/test/runner.hoon @@ -101,6 +101,6 @@ :: ++ has-test-prefix |= a=term ^- ? - =((new-end [3 5] a) 'test-') + =((end [3 5] a) 'test-') -- diff --git a/pkg/arvo/mar/eth/txs.hoon b/pkg/arvo/mar/eth/txs.hoon index d5640c3ba8..e523a49bfe 100644 --- a/pkg/arvo/mar/eth/txs.hoon +++ b/pkg/arvo/mar/eth/txs.hoon @@ -10,7 +10,7 @@ %- cook :_ nuck:so |= =coin ?> ?=(%$ -.coin) - ?> ?=(%u (new-end 3 p.p.coin)) + ?> ?=(%u (end 3 p.p.coin)) `@`q.p.coin :: ++ grab diff --git a/pkg/arvo/mar/hash.hoon b/pkg/arvo/mar/hash.hoon index 1810bb12f7..a8b9445395 100644 --- a/pkg/arvo/mar/hash.hoon +++ b/pkg/arvo/mar/hash.hoon @@ -5,7 +5,7 @@ |% ++ noun hash ++ json - s+(new-rsh [3 2] (scot %uv hash)) + s+(rsh [3 2] (scot %uv hash)) -- ++ grab |% diff --git a/pkg/arvo/mar/udon.hoon b/pkg/arvo/mar/udon.hoon index 3588acc97b..72c9e6f5cf 100644 --- a/pkg/arvo/mar/udon.hoon +++ b/pkg/arvo/mar/udon.hoon @@ -17,7 +17,7 @@ ^- (map term knot) %- ~(run by inf:(static:cram (ream mud))) |= a=dime ^- cord - ?+ (new-end 3 p.a) (scot a) + ?+ (end 3 p.a) (scot a) %t q.a == -- diff --git a/pkg/arvo/mar/umd.hoon b/pkg/arvo/mar/umd.hoon index 227e3ac8fa..d249bcff85 100644 --- a/pkg/arvo/mar/umd.hoon +++ b/pkg/arvo/mar/umd.hoon @@ -17,7 +17,7 @@ ^- (map term knot) %- ~(run by inf:(static:cram (ream mud))) |= a=dime ^- cord - ?+ (new-end 3 p.a) (scot a) + ?+ (end 3 p.a) (scot a) %t q.a == -- diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index 932c701b42..e4583e64da 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -1076,7 +1076,7 @@ %+ turn von =/ bem=beam [[our %home da+now] /whey] |= [lal=@tas =vane] - =/ met (peek ~ (new-rsh [3 5] lal) bem) + =/ met (peek ~ (rsh [3 5] lal) bem) ?> &(?=(^ met) ?=(^ u.met)) :: XX make optional lal^|+;;((list mass) q.q.u.u.met) :: @@ -1100,8 +1100,8 @@ :: :: XX vane and care are concatenated :: - =/ lal (new-end 3 cyr) - =/ ren ;;(@t (new-rsh 3 cyr)) + =/ lal (end 3 cyr) + =/ ren ;;(@t (rsh 3 cyr)) ?. (~(has by van.mod) lal) ~ (peek:(plow lal) lyc ren bem) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 1ad480e2cb..70c4a4d961 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -842,20 +842,20 @@ |= [a=bloq b=(list [p=step q=@])] ^- @ ?~ b 0 - (add (new-end [a p.i.b] q.i.b) (new-lsh [a p.i.b] $(b t.b))) + (add (end [a p.i.b] q.i.b) (lsh [a p.i.b] $(b t.b))) :: ++ cat :: concatenate ~/ %cat |= [a=bloq b=@ c=@] - (add (new-lsh [a (met a b)] c) b) + (add (lsh [a (met a b)] c) b) :: ++ cut :: slice ~/ %cut |= [a=bloq [b=step c=step] d=@] - (new-end [a c] (new-rsh [a b] d)) + (end [a c] (rsh [a b] d)) :: -++ new-end :: tail - ~/ %new-end +++ end :: tail + ~/ %end |= [a=bite b=@] =/ [=bloq =step] ?^(a a [a *step]) (mod b (bex (mul (bex bloq) step))) @@ -867,11 +867,11 @@ =+ d=c |- ^- @ ?: =(n b) - (new-rsh a d) - $(d (add c (new-lsh a d)), n +(n)) + (rsh a d) + $(d (add c (lsh a d)), n +(n)) :: -++ new-lsh :: left-shift - ~/ %new-lsh +++ lsh :: left-shift + ~/ %lsh |= [a=bite b=@] =/ [=bloq =step] ?^(a a [a *step]) (mul b (bex (mul (bex bloq) step))) @@ -883,7 +883,7 @@ =+ c=0 |- ?: =(0 b) c - $(b (new-rsh a b), c +(c)) + $(b (rsh a b), c +(c)) :: ++ rap :: assemble nonzero ~/ %rap @@ -901,7 +901,7 @@ |- ^- @ ?~ b 0 %+ add $(i +(i), b t.b) - (new-lsh [bloq (mul step i)] (new-end [bloq step] i.b)) + (lsh [bloq (mul step i)] (end [bloq step] i.b)) :: ++ rev :: reverses block order, accounting for leading zeroes @@ -912,8 +912,8 @@ ~/ %rev |= [boz=bloq len=@ud dat=@] ^- @ - =. dat (new-end [boz len] dat) - %+ new-lsh + =. dat (end [boz len] dat) + %+ lsh [boz (sub len (met boz dat))] (swp boz dat) :: @@ -922,10 +922,10 @@ |= [a=bite b=@] ^- (list @) ?: =(0 b) ~ - [(new-end a b) $(b (new-rsh a b))] + [(end a b) $(b (rsh a b))] :: -++ new-rsh :: right-shift - ~/ %new-rsh +++ rsh :: right-shift + ~/ %rsh |= [a=bite b=@] =/ [=bloq =step] ?^(a a [a *step]) (div b (bex (mul (bex bloq) step))) @@ -947,7 +947,7 @@ %+ add (can a b^e c^d ~) =/ f [a (add b c)] - (new-lsh f (new-rsh f e)) + (lsh f (rsh f e)) :: ++ swp :: naive rev bloq order ~/ %swp @@ -971,21 +971,21 @@ b =+ c=(dec a) %+ con - (new-lsh c $(a c, b (cut c [0 1] b))) + (lsh c $(a c, b (cut c [0 1] b))) $(a c, b (cut c [1 1] b)) ++ out (bex (bex a)) :: mod value ++ rol |= [b=bloq c=@ d=@] ^- @ :: roll left =+ e=(sit d) =+ f=(bex (sub a b)) =+ g=(mod c f) - (sit (con (new-lsh [b g] e) (new-rsh [b (sub f g)] e))) + (sit (con (lsh [b g] e) (rsh [b (sub f g)] e))) ++ ror |= [b=bloq c=@ d=@] ^- @ :: roll right =+ e=(sit d) =+ f=(bex (sub a b)) =+ g=(mod c f) - (sit (con (new-rsh [b g] e) (new-lsh [b (sub f g)] e))) + (sit (con (rsh [b g] e) (lsh [b (sub f g)] e))) ++ sum |=([b=@ c=@] (sit (add b c))) :: wrapping add - ++ sit |=(b=@ (new-end a b)) :: enforce modulo + ++ sit |=(b=@ (end a b)) :: enforce modulo -- :: :: :::: 2d: bit logic :: @@ -998,13 +998,13 @@ |- ^- @ ?: ?&(=(0 a) =(0 b)) d %= $ - a (new-rsh 0 a) - b (new-rsh 0 b) + a (rsh 0 a) + b (rsh 0 b) c +(c) d %+ add d - %+ new-lsh [0 c] - ?& =(0 (new-end 0 a)) - =(0 (new-end 0 b)) + %+ lsh [0 c] + ?& =(0 (end 0 a)) + =(0 (end 0 b)) == == :: @@ -1015,13 +1015,13 @@ |- ^- @ ?: ?|(=(0 a) =(0 b)) d %= $ - a (new-rsh 0 a) - b (new-rsh 0 b) + a (rsh 0 a) + b (rsh 0 b) c +(c) d %+ add d - %+ new-lsh [0 c] - ?| =(0 (new-end 0 a)) - =(0 (new-end 0 b)) + %+ lsh [0 c] + ?| =(0 (end 0 a)) + =(0 (end 0 b)) == == :: @@ -1033,10 +1033,10 @@ |- ?: ?&(=(0 a) =(0 b)) d %= $ - a (new-rsh 0 a) - b (new-rsh 0 b) + a (rsh 0 a) + b (rsh 0 b) c +(c) - d (add d (new-lsh [0 c] =((new-end 0 a) (new-end 0 b)))) + d (add d (lsh [0 c] =((end 0 a) (end 0 b)))) == :: ++ not |= [a=bloq b=@ c=@] :: binary not (sized) @@ -1049,7 +1049,7 @@ ~% %muk ..muk ~ =+ ~(. fe 5) |= [syd=@ len=@ key=@] - =. syd (new-end 5 syd) + =. syd (end 5 syd) =/ pad (sub len (met 3 key)) =/ data (weld (rip 3 key) (reap pad 0)) =/ nblocks (div len 4) :: intentionally off-by-one @@ -1072,14 +1072,14 @@ =/ tlen (dis len 3) =. h1 ?+ tlen h1 :: fallthrough switch - %3 =. k1 (mix k1 (new-lsh [0 16] (snag 2 tail))) - =. k1 (mix k1 (new-lsh [0 8] (snag 1 tail))) + %3 =. k1 (mix k1 (lsh [0 16] (snag 2 tail))) + =. k1 (mix k1 (lsh [0 8] (snag 1 tail))) =. k1 (mix k1 (snag 0 tail)) =. k1 (sit (mul k1 c1)) =. k1 (rol 0 15 k1) =. k1 (sit (mul k1 c2)) (mix h1 k1) - %2 =. k1 (mix k1 (new-lsh [0 8] (snag 1 tail))) + %2 =. k1 (mix k1 (lsh [0 8] (snag 1 tail))) =. k1 (mix k1 (snag 0 tail)) =. k1 (sit (mul k1 c1)) =. k1 (rol 0 15 k1) @@ -1095,11 +1095,11 @@ |^ (fmix32 h1) ++ fmix32 |= h=@ - =. h (mix h (new-rsh [0 16] h)) + =. h (mix h (rsh [0 16] h)) =. h (sit (mul h 0x85eb.ca6b)) - =. h (mix h (new-rsh [0 13] h)) + =. h (mix h (rsh [0 13] h)) =. h (sit (mul h 0xc2b2.ae35)) - =. h (mix h (new-rsh [0 16] h)) + =. h (mix h (rsh [0 16] h)) h -- :: @@ -1117,7 +1117,7 @@ |- ^- @F ?: =(8 i) fal =/ haz=@F (muk syd wyd key) - =/ ham=@F (mix (new-rsh [0 31] haz) (new-end [0 31] haz)) + =/ ham=@F (mix (rsh [0 31] haz) (end [0 31] haz)) ?.(=(0 ham) ham $(i +(i), syd +(syd))) -- :: :: @@ -1141,9 +1141,9 @@ $(a -.a, b -.b) ?. ?=(@ b) & |- - =+ [c=(new-end 3 a) d=(new-end 3 b)] + =+ [c=(end 3 a) d=(end 3 b)] ?: =(c d) - $(a (new-rsh 3 a), b (new-rsh 3 b)) + $(a (rsh 3 a), b (rsh 3 b)) (lth c d) :: +dor: depth order :: @@ -2062,16 +2062,16 @@ => .(m (~(put by m) a b)) ?: ?=(@ a) =+ d=(mat a) - [(add 1 p.d) (new-lsh 0 q.d) m] + [(add 1 p.d) (lsh 0 q.d) m] => .(b (add 2 b)) =+ d=$(a -.a) =+ e=$(a +.a, b (add b p.d), m r.d) - [(add 2 (add p.d p.e)) (mix 1 (new-lsh [0 2] (cat 0 q.d q.e))) r.e] + [(add 2 (add p.d p.e)) (mix 1 (lsh [0 2] (cat 0 q.d q.e))) r.e] ?: ?&(?=(@ a) (lte (met 0 a) (met 0 u.c))) =+ d=(mat a) - [(add 1 p.d) (new-lsh 0 q.d) m] + [(add 1 p.d) (lsh 0 q.d) m] =+ d=(mat u.c) - [(add 2 p.d) (mix 3 (new-lsh [0 2] q.d)) m] + [(add 2 p.d) (mix 3 (lsh [0 2] q.d)) m] :: ++ mat :: length-encode ~/ %mat @@ -2082,7 +2082,7 @@ =+ b=(met 0 a) =+ c=(met 0 b) :- (add (add c c) b) - (cat 0 (bex c) (mix (new-end [0 (dec c)] b) (new-lsh [0 (dec c)] a))) + (cat 0 (bex c) (mix (end [0 (dec c)] b) (lsh [0 (dec c)] a))) :: ++ rub :: length-decode ~/ %rub @@ -2174,9 +2174,9 @@ |= [b=@ c=@] ?: =(0 b) 1 - =+ d=$(b (new-rsh 0 b)) + =+ d=$(b (rsh 0 b)) =+ e=(pro d d) - ?:(=(0 (new-end 0 b)) e (pro c e)) + ?:(=(0 (end 0 b)) e (pro c e)) :: ++ fra |= [b=@ c=@] @@ -2203,7 +2203,7 @@ ++ si :: signed integer ^? |% - ++ abs |=(a=@s (add (new-end 0 a) (new-rsh 0 a))) :: absolute value + ++ abs |=(a=@s (add (end 0 a) (rsh 0 a))) :: absolute value ++ dif |= [a=@s b=@s] :: subtraction (sum a (new !(syn b) (abs b))) ++ dul |= [a=@s b=@] :: modulus @@ -2230,7 +2230,7 @@ (new & (sub +.d +.c)) (new | (add +.c +.d)) ++ sun |=(a=@u (mul 2 a)) :: @u to @s - ++ syn |=(a=@s =(0 (new-end 0 a))) :: sign test + ++ syn |=(a=@s =(0 (end 0 a))) :: sign test ++ cmp |= [a=@s b=@s] :: compare ^- @s ?: =(a b) @@ -2282,7 +2282,7 @@ =+ q=(dif:si e.a e.b) |- ?. (syn:si q) $(b a, a b, q +(q)) :: a has larger exp ?: e - [%f & e.b (^add (new-lsh [0 (abs:si q)] a.a) a.b)] + [%f & e.b (^add (lsh [0 (abs:si q)] a.a) a.b)] =+ [ma=(met 0 a.a) mb=(met 0 a.b)] =+ ^= w %+ dif:si e.a %- sun:si :: expanded exp of a ?: (gth prc ma) (^sub prc ma) 0 @@ -2293,7 +2293,7 @@ %a (lug %lg a &) %u (lug %lg a &) %n (lug %na a &) == - (rou [e.b (^add (new-lsh [0 (abs:si q)] a.a) a.b)]) + (rou [e.b (^add (lsh [0 (abs:si q)] a.a) a.b)]) :: ++ sub :: subtract; exact if e |= [a=[e=@s a=@u] b=[e=@s a=@u] e=?] ^- fn @@ -2310,7 +2310,7 @@ %a (lug %ce a &) %u (lug %ce a &) %n (lug %nt a &) == - =+ j=(new-lsh [0 (abs:si q)] a.a) + =+ j=(lsh [0 (abs:si q)] a.a) |- ?. (gte j a.b) (fli $(a.b j, j a.b, r swr)) =+ i=(^sub j a.b) @@ -2326,7 +2326,7 @@ =+ [ma=(met 0 a.a) mb=(met 0 a.b)] =+ v=(dif:si (sun:si ma) (sun:si +((^add mb prc)))) =. a ?: (syn:si v) a - a(e (sum:si v e.a), a (new-lsh [0 (abs:si v)] a.a)) + a(e (sum:si v e.a), a (lsh [0 (abs:si v)] a.a)) =+ [j=(dif:si e.a e.b) q=(dvr a.a a.b)] (rau [j p.q] =(q.q 0)) :: @@ -2337,7 +2337,7 @@ =+ ?:((^lth w x) (^sub x w) 0) =+ ?: =((dis - 1) (dis (abs:si e.a) 1)) - (^add - 1) - a(e (dif:si e.a (sun:si -)), a (new-lsh [0 -] a.a)) + a(e (dif:si e.a (sun:si -)), a (lsh [0 -] a.a)) =+ [y=(^sqt a.a) z=(fra:si e.a --2)] (rau [z p.y] =(q.y 0)) :: @@ -2347,15 +2347,15 @@ =+ c=(cmp:si (ibl a) (ibl b)) ?: =(c -1) & ?: =(c --1) | ?: =((cmp:si e.a e.b) -1) - (^lth (new-rsh [0 (abs:si (dif:si e.a e.b))] a.a) a.b) - (^lth (new-lsh [0 (abs:si (dif:si e.a e.b))] a.a) a.b) + (^lth (rsh [0 (abs:si (dif:si e.a e.b))] a.a) a.b) + (^lth (lsh [0 (abs:si (dif:si e.a e.b))] a.a) a.b) :: ++ equ :: equals |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- ? ?. =((ibl a) (ibl b)) | ?: =((cmp:si e.a e.b) -1) - =((new-lsh [0 (abs:si (dif:si e.a e.b))] a.b) a.a) - =((new-lsh [0 (abs:si (dif:si e.a e.b))] a.a) a.b) + =((lsh [0 (abs:si (dif:si e.a e.b))] a.b) a.a) + =((lsh [0 (abs:si (dif:si e.a e.b))] a.a) a.b) :: :: integer binary logarithm: 2^ibl(a) <= |a| < 2^(ibl(a)+1) ++ ibl @@ -2366,8 +2366,8 @@ :: every fn has a unique representation of this kind ++ uni |= [a=[e=@s a=@u]] - |- ?: =((new-end 0 a.a) 1) a - $(a.a (new-rsh 0 a.a), e.a (sum:si e.a --1)) + |- ?: =((end 0 a.a) 1) a + $(a.a (rsh 0 a.a), e.a (sum:si e.a --1)) :: :: expands to either full precision or to denormalized ++ xpd @@ -2379,7 +2379,7 @@ =+ w=(dif:si e.a emn) ?: (syn:si w) (abs:si w) 0 (min q (^sub prc ma)) - a(e (dif:si e.a (sun:si -)), a (new-lsh [0 -] a.a)) + a(e (dif:si e.a (sun:si -)), a (lsh [0 -] a.a)) :: :: central rounding mechanism :: can perform: floor, ceiling, smaller, larger, @@ -2401,8 +2401,8 @@ ?: (gth m prc) (^sub m prc) 0 :: reduce precision %- abs:si ?: =(den %i) --0 :: enforce min. exp ?: =((cmp:si e.a emn) -1) (dif:si emn e.a) --0 - =^ b a :- (new-end [0 q] a.a) - a(e (sum:si e.a (sun:si q)), a (new-rsh [0 q] a.a)) + =^ b a :- (end [0 q] a.a) + a(e (sum:si e.a (sun:si q)), a (rsh [0 q] a.a)) :: ?~ a.a ?< =(den %i) @@ -2445,7 +2445,7 @@ == :: =. a ?. =((met 0 a.a) +(prc)) a - a(a (new-rsh 0 a.a), e (sum:si e.a --1)) + a(a (rsh 0 a.a), e (sum:si e.a --1)) ?~ a.a [%f & zer] :: ?: =(den %i) [%f & a] @@ -2456,9 +2456,9 @@ |= [a=[e=@s a=@u]] ^- [@s @u] :: guaranteed accurate ?< =(a.a 0) :: for rounded floats =. a (xpd a) - =+ r=(new-lsh [0 ?:((syn:si e.a) (abs:si e.a) 0)] a.a) - =+ s=(new-lsh [0 ?.((syn:si e.a) (abs:si e.a) 0)] 1) - =+ mn=(new-lsh [0 ?:((syn:si e.a) (abs:si e.a) 0)] 1) + =+ r=(lsh [0 ?:((syn:si e.a) (abs:si e.a) 0)] a.a) + =+ s=(lsh [0 ?.((syn:si e.a) (abs:si e.a) 0)] 1) + =+ mn=(lsh [0 ?:((syn:si e.a) (abs:si e.a) 0)] 1) =+ mp=mn => ?. ?& =(a.a (bex (dec prc))) :: if next smallest @@ -2466,9 +2466,9 @@ == :: tighten lower bound . %= . - mp (new-lsh 0 mp) - r (new-lsh 0 r) - s (new-lsh 0 s) + mp (lsh 0 mp) + r (lsh 0 r) + s (lsh 0 s) == =+ [k=--0 q=(^div (^add s 9) 10)] |- ?: (^lth r q) @@ -2505,9 +2505,9 @@ |= [a=[e=@s a=@u]] ^- fn ?. =((cmp:si e.a --0) -1) [%f & a] =+ x=(abs:si e.a) - =+ y=(new-rsh [0 x] a.a) + =+ y=(rsh [0 x] a.a) ?: |(=(r %d) =(r %z)) [%f & --0 y] - =+ z=(new-end [0 x] a.a) + =+ z=(end [0 x] a.a) ?: |(=(r %u) =(r %a)) [%f & --0 ?~(z y +(y))] =+ i=(bex (dec x)) ?: &(=(z i) =((dis y 1) 0)) [%f & --0 y] @@ -2756,9 +2756,9 @@ ++ bif :: fn to @r no rounding |= [a=fn] ^- @r ?: ?=([%i *] a) - =+ q=(new-lsh [0 p] (fil 0 w 1)) + =+ q=(lsh [0 p] (fil 0 w 1)) ?: s.a q (^add q sb) - ?: ?=([%n *] a) (new-lsh [0 (dec p)] (fil 0 +(w) 1)) + ?: ?=([%n *] a) (lsh [0 (dec p)] (fil 0 +(w) 1)) ?~ a.a ?: s.a `@r`0 sb =+ ma=(met 0 a.a) ?. =(ma +(p)) @@ -2766,7 +2766,7 @@ ?> (^lth ma +(p)) ?: s.a `@r`a.a (^add a.a sb) =+ q=(sum:si (dif:si e.a me) --1) - =+ r=(^add (new-lsh [0 p] (abs:si q)) (new-end [0 p] a.a)) + =+ r=(^add (lsh [0 p] (abs:si q)) (end [0 p] a.a)) ?: s.a r (^add r sb) :: ++ sig :: get sign @@ -3179,14 +3179,14 @@ ++ yell :: tarp from @d |= now=@d ^- tarp - =+ sec=(new-rsh 6 now) + =+ sec=(rsh 6 now) =+ ^= fan - =+ [muc=4 raw=(new-end 6 now)] + =+ [muc=4 raw=(end 6 now)] |- ^- (list @ux) ?: |(=(0 raw) =(0 muc)) ~ => .(muc (dec muc)) - [(cut 4 [muc 1] raw) $(raw (new-end [4 muc] raw))] + [(cut 4 [muc 1] raw) $(raw (end [4 muc] raw))] =+ day=(div sec day:yo) => .(sec (mod sec day:yo)) =+ hor=(div sec hor:yo) @@ -3209,8 +3209,8 @@ ?~ f.rip 0 => .(muc (dec muc)) - (add (new-lsh [4 muc] i.f.rip) $(f.rip t.f.rip)) - (con (new-lsh 6 sec) fac) + (add (lsh [4 muc] i.f.rip) $(f.rip t.f.rip)) + (con (lsh 6 sec) fac) :: ++ yall :: day / to day of year |= day=@ud @@ -3227,7 +3227,7 @@ =+ dis=?:(lep 366 365) ?. (lth day dis) =+ ner=+(yer) - $(yer ner, day (sub day dis), lep =(0 (new-end [0 2] ner))) + $(yer ner, day (sub day dis), lep =(0 (end [0 2] ner))) |- ^- [y=@ud m=@ud d=@ud] =+ [mot=0 cah=?:(lep moy:yo moh:yo)] |- ^- [y=@ud m=@ud d=@ud] @@ -3285,7 +3285,7 @@ ++ shaf :: half sha-256 |= [sal=@ ruz=@] =+ haz=(shas sal ruz) - (mix (new-end 7 haz) (new-rsh 7 haz)) + (mix (end 7 haz) (rsh 7 haz)) :: ++ sham :: 128bit noun hash |= yux=* ^- @uvH ^- @ @@ -3309,7 +3309,7 @@ => .(ruz (cut 3 [0 len] ruz)) =+ [few==>(fe .(a 5)) wac=|=([a=@ b=@] (cut 5 [a 1] b))] =+ [sum=sum.few ror=ror.few net=net.few inv=inv.few] - =+ ral=(new-lsh [0 3] len) + =+ ral=(lsh [0 3] len) =+ ^= ful %+ can 0 :~ [ral ruz] @@ -3352,10 +3352,10 @@ n=(wac (sub j 16) wox) o=(wac (sub j 7) wox) == - =+ x=:(mix (ror 0 7 l) (ror 0 18 l) (new-rsh [0 3] l)) - =+ y=:(mix (ror 0 17 m) (ror 0 19 m) (new-rsh [0 10] m)) + =+ x=:(mix (ror 0 7 l) (ror 0 18 l) (rsh [0 3] l)) + =+ y=:(mix (ror 0 17 m) (ror 0 19 m) (rsh [0 10] m)) =+ z=:(sum n x o y) - $(wox (con (new-lsh [5 j] z) wox), j +(j)) + $(wox (con (lsh [5 j] z) wox), j +(j)) =+ j=0 =+ :* a=(wac 0 hax) b=(wac 1 hax) @@ -3403,7 +3403,7 @@ => .(ruz (cut 3 [0 len] ruz)) =+ [few==>(fe .(a 6)) wac=|=([a=@ b=@] (cut 6 [a 1] b))] =+ [sum=sum.few ror=ror.few net=net.few inv=inv.few] - =+ ral=(new-lsh [0 3] len) + =+ ral=(lsh [0 3] len) =+ ^= ful %+ can 0 :~ [ral ruz] @@ -3472,10 +3472,10 @@ n=(wac (sub j 16) wox) o=(wac (sub j 7) wox) == - =+ x=:(mix (ror 0 1 l) (ror 0 8 l) (new-rsh [0 7] l)) - =+ y=:(mix (ror 0 19 m) (ror 0 61 m) (new-rsh [0 6] m)) + =+ x=:(mix (ror 0 1 l) (ror 0 8 l) (rsh [0 7] l)) + =+ y=:(mix (ror 0 19 m) (ror 0 61 m) (rsh [0 6] m)) =+ z=:(sum n x o y) - $(wox (con (new-lsh [6 j] z) wox), j +(j)) + $(wox (con (lsh [6 j] z) wox), j +(j)) =+ j=0 =+ :* a=(wac 0 hax) b=(wac 1 hax) @@ -3513,7 +3513,7 @@ |= ruz=@ =+ [few==>(fe .(a 5)) wac=|=([a=@ b=@] (cut 5 [a 1] b))] =+ [sum=sum.few ror=ror.few rol=rol.few net=net.few inv=inv.few] - =+ ral=(new-lsh [0 3] (met 3 ruz)) + =+ ral=(lsh [0 3] (met 3 ruz)) =+ ^= ful %+ can 0 :~ [ral ruz] @@ -3541,7 +3541,7 @@ o=(wac (sub j 16) wox) == =+ z=(rol 0 1 :(mix l m n o)) - $(wox (con (new-lsh [5 j] z) wox), j +(j)) + $(wox (con (lsh [5 j] z) wox), j +(j)) =+ j=0 =+ :* a=(wac 0 hax) b=(wac 1 hax) @@ -3601,7 +3601,7 @@ ~ =+ d=(shas %og-b (mix b (mix a c))) ?: (lth b 256) - [[b (new-end [0 b] d)] ~] + [[b (end [0 b] d)] ~] [[256 d] $(c d, b (sub b 256))] :: ++ raws :: random bits @@ -3637,7 +3637,7 @@ ^- @ =+ [few==>(fe .(a 5)) wac=|=([a=@ b=@] (cut 5 [a 1] b))] =+ [sum=sum.few ror=ror.few rol=rol.few net=net.few inv=inv.few] - =+ ral=(new-lsh [0 3] wid) + =+ ral=(lsh [0 3] wid) =+ ^= ful %+ can 0 :~ [ral (rev 3 wid dat)] @@ -3665,7 +3665,7 @@ o=(wac (sub j 16) wox) == =+ z=(rol 0 1 :(mix l m n o)) - $(wox (con (new-lsh [5 j] z) wox), j +(j)) + $(wox (con (lsh [5 j] z) wox), j +(j)) =+ j=0 =+ :* a=(wac 0 hax) b=(wac 1 hax) @@ -3724,7 +3724,7 @@ ?: =(0 len) ~ => .(len (dec len)) - =+ mog=(zyft :(mix mig (new-end 3 len) (cut 3 [len 1] pyn))) + =+ mog=(zyft :(mix mig (end 3 len) (cut 3 [len 1] pyn))) [[1 mog] $(mig mog)] :: ++ wred :: restore structure @@ -3742,7 +3742,7 @@ ~ => .(len (dec len)) =+ mog=(cut 3 [len 1] cry) - [[1 :(mix mig (new-end 3 len) (zyrt mog))] $(mig mog)] + [[1 :(mix mig (end 3 len) (zyrt mog))] $(mig mog)] :: ++ xafo |=([a=@ b=@] +((mod (add (dec b) a) 255))) ++ xaro |=([a=@ b=@] +((mod (add (dec b) (sub 255 (mod a 255))) 255))) @@ -4135,21 +4135,21 @@ =- yek:(roll (rip 3 key) -) =+ [a=*char b=*@ yek=`@ux`(fil 3 256 0xff)] |. - [+(b) (mix yek (new-lsh [3 `@u`a] (~(inv fe 3) b)))] + [+(b) (mix yek (lsh [3 `@u`a] (~(inv fe 3) b)))] |% ++ cha |=(a=char `(unit @uF)`=+(b=(cut 3 [`@`a 1] yek) ?:(=(b 0xff) ~ `b))) ++ tok |= a=@ux ^- @ux =+ b=(pad a) - =- (~(net fe 5) (new-end [3 4] (shay 32 -))) - (shay (add b (met 3 a)) (new-lsh [3 b] (swp 3 a))) + =- (~(net fe 5) (end [3 4] (shay 32 -))) + (shay (add b (met 3 a)) (lsh [3 b] (swp 3 a))) :: ++ pad |=(a=@ =+(b=(met 3 a) ?:((gte b 21) 0 (sub 21 b)))) - ++ enc |=(a=@ux `@ux`(mix (new-lsh [3 4] a) (tok a))) + ++ enc |=(a=@ux `@ux`(mix (lsh [3 4] a) (tok a))) ++ den |= a=@ux ^- (unit @ux) - =+ b=(new-rsh [3 4] a) - ?. =((tok b) (new-end [3 4] a)) + =+ b=(rsh [3 4] a) + ?. =((tok b) (end [3 4] a)) ~ `b -- @@ -4163,9 +4163,9 @@ |- ?: =(0 a) & - =+ vis=(new-end 3 a) + =+ vis=(end 3 a) ?& ?|(=('-' vis) ?&((gte vis 'a') (lte vis 'z'))) - $(a (new-rsh 3 a)) + $(a (rsh 3 a)) == == rtam @@ -4203,19 +4203,19 @@ |- ^- tape ?: (gth (met 5 a) 1) %+ weld - $(a (new-rsh 5 a), b (sub b 4)) - `tape`['-' '-' $(a (new-end 5 a), b 4)] + $(a (rsh 5 a), b (sub b 4)) + `tape`['-' '-' $(a (end 5 a), b 4)] ?: =(0 b) ['~' ~] ?: (lte b 1) (trip (tos:po a)) |- ^- tape ?: =(2 b) - =+ c=(new-rsh 3 a) - =+ d=(new-end 3 a) + =+ c=(rsh 3 a) + =+ d=(end 3 a) (weld (trip (tod:po c)) (trip (tos:po (mix c d)))) - =+ c=(new-rsh [3 2] a) - =+ d=(new-end [3 2] a) + =+ c=(rsh [3 2] a) + =+ d=(end [3 2] a) (weld ^$(a c, b (met 3 c)) `tape`['-' $(a (mix c d), b 2)]) :: ++ ruv @@ -4271,7 +4271,7 @@ ++ sane :: atom sanity |= a=@ta |= b=@ ^- ? - ?. =(%t (new-end 3 a)) + ?. =(%t (end 3 a)) :: XX more and better sanity :: & @@ -4298,11 +4298,11 @@ == |- ^- ? ?: =(0 b) & - =+ cur=(new-end 3 b) + =+ cur=(end 3 b) ?: &((lth cur 32) !=(10 cur)) | =+ len=(teff cur) ?& |(=(1 len) =+(i=1 |-(|(=(i len) &((gte (cut 3 [i 1] b) 128) $(i +(i))))))) - $(b (new-rsh [3 len] b)) + $(b (rsh [3 len] b)) == :: ++ ruth :: biblical sanity @@ -4327,11 +4327,11 @@ |= a=@ ^- tape ?: =(0 (met 3 a)) ~ - [^-(@ta (new-end 3 a)) $(a (new-rsh 3 a))] + [^-(@ta (end 3 a)) $(a (rsh 3 a))] :: ++ teff :: length utf8 |= a=@t ^- @ - =+ b=(new-end 3 a) + =+ b=(end 3 a) ?: =(0 b) ?>(=(`@`0 a) 0) ?> |((gte b 32) =(10 b)) @@ -4355,8 +4355,8 @@ %4 [[24 6] [16 6] [8 6] [0 3] ~] == |=([p=@ q=@] [q (cut 0 [p q] a)]) - ?> =((tuft c) (new-end [3 b] a)) - [c $(a (new-rsh [3 b] a))] + ?> =((tuft c) (end [3 b] a)) + [c $(a (rsh [3 b] a))] :: ++ tuba :: utf8 to utf32 tape |= a=tape @@ -4376,25 +4376,25 @@ |- ^- (list @) ?: =(`@`0 a) ~ - =+ b=(new-end 5 a) - =+ c=$(a (new-rsh 5 a)) + =+ b=(end 5 a) + =+ c=$(a (rsh 5 a)) ?: (lte b 0x7f) [b c] ?: (lte b 0x7ff) :* (mix 0b1100.0000 (cut 0 [6 5] b)) - (mix 0b1000.0000 (new-end [0 6] b)) + (mix 0b1000.0000 (end [0 6] b)) c == ?: (lte b 0xffff) :* (mix 0b1110.0000 (cut 0 [12 4] b)) (mix 0b1000.0000 (cut 0 [6 6] b)) - (mix 0b1000.0000 (new-end [0 6] b)) + (mix 0b1000.0000 (end [0 6] b)) c == :* (mix 0b1111.0000 (cut 0 [18 3] b)) (mix 0b1000.0000 (cut 0 [12 6] b)) (mix 0b1000.0000 (cut 0 [6 6] b)) - (mix 0b1000.0000 (new-end [0 6] b)) + (mix 0b1000.0000 (end [0 6] b)) c == :: @@ -4434,13 +4434,13 @@ |- ^- (list @) ?: =(`@`0 a) ~ - =+ b=(new-end 3 a) - =+ c=(new-rsh 3 a) + =+ b=(end 3 a) + =+ c=(rsh 3 a) ?: =('.' b) [' ' $(a c)] ?. =('~' b) [b $(a c)] - => .(b (new-end 3 c), c (new-rsh 3 c)) + => .(b (end 3 c), c (rsh 3 c)) ?+ b =- (weld (rip 3 (tuft p.d)) $(a q.d)) ^= d =+ d=0 @@ -4449,8 +4449,8 @@ [d c] ?< =(0 c) %= $ - b (new-end 3 c) - c (new-rsh 3 c) + b (end 3 c) + c (rsh 3 c) d %+ add (mul 16 d) %+ sub b ?: &((gte b '0') (lte b '9')) 48 @@ -4468,8 +4468,8 @@ ?: =(`@`0 a) ~ =+ b=(teff a) - =+ c=(taft (new-end [3 b] a)) - =+ d=$(a (new-rsh [3 b] a)) + =+ c=(taft (end [3 b] a)) + =+ d=$(a (rsh [3 b] a)) ?: ?| &((gte c 'a') (lte c 'z')) &((gte c '0') (lte c '9')) =(`@`'-' c) @@ -4482,8 +4482,8 @@ ?: =(0 e) ['.' d] =. e (dec e) - =+ f=(new-rsh [2 e] c) - [(add ?:((lte f 9) 48 87) f) $(c (new-end [2 e] c))] + =+ f=(rsh [2 e] c) + [(add ?:((lte f 9) 48 87) f) $(c (end [2 e] c))] :: %' ' ['.' d] %'.' ['~' '.' d] @@ -4943,9 +4943,9 @@ |- ^- (like @t) ?: =(`@`0 daf) [p=p.tub q=[~ u=[p=fad q=tub]]] - ?: |(?=(~ q.tub) !=((new-end 3 daf) i.q.tub)) + ?: |(?=(~ q.tub) !=((end 3 daf) i.q.tub)) (fail tub) - $(p.tub (lust i.q.tub p.tub), q.tub t.q.tub, daf (new-rsh 3 daf)) + $(p.tub (lust i.q.tub p.tub), q.tub t.q.tub, daf (rsh 3 daf)) :: ++ just :: XX redundant, jest ~/ %just :: match a char @@ -5436,9 +5436,9 @@ -- ++ mu |_ [top=@ bot=@] - ++ zag [p=(new-end 4 (add top bot)) q=bot] - ++ zig [p=(new-end 4 (add top (sub 0x1.0000 bot))) q=bot] - ++ zug (mix (new-lsh 4 top) bot) + ++ zag [p=(end 4 (add top bot)) q=bot] + ++ zig [p=(end 4 (add top (sub 0x1.0000 bot))) q=bot] + ++ zug (mix (lsh 4 top) bot) -- ++ ne |_ tig=@ @@ -5466,7 +5466,7 @@ ?~ p.lot ['_' '_' rep] ['_' (weld (trip (wack rent(lot i.p.lot))) $(p.lot t.p.lot))] - =+ [yed=(new-end 3 p.p.lot) hay=(cut 3 [1 1] p.p.lot)] + =+ [yed=(end 3 p.p.lot) hay=(cut 3 [1 1] p.p.lot)] |- ^- tape ?+ yed (z-co q.p.lot) %c ['~' '-' (weld (rip 3 (wood (tuft q.p.lot))) rep)] @@ -5526,8 +5526,8 @@ imp +(imp) rep =/ log (cut 4 [imp 1] sxz) ;: weld - (trip (tos:po (new-rsh 3 log))) - (trip (tod:po (new-end 3 log))) + (trip (tos:po (rsh 3 log))) + (trip (tod:po (end 3 log))) ?:(=((mod imp 4) 0) ?:(=(imp 0) "" "--") "-") rep == == @@ -5856,8 +5856,8 @@ ~+ =+ ^= neg |= [syn=? mol=dime] ^- dime - ?> =('u' (new-end 3 p.mol)) - [(cat 3 's' (new-rsh 3 p.mol)) (new:si syn q.mol)] + ?> =('u' (end 3 p.mol)) + [(cat 3 's' (rsh 3 p.mol)) (new:si syn q.mol)] ;~ pfix hep ;~ pose (cook |=(a=dime (neg | a)) bisk) @@ -7291,9 +7291,9 @@ =+ len=(met 3 mot) ?: =(0 len) [0 %$] - =+ tyl=(new-rsh [3 (dec len)] mot) + =+ tyl=(rsh [3 (dec len)] mot) ?: &((gte tyl 'A') (lte tyl 'Z')) - [(sub tyl 64) (new-end [3 (dec len)] mot)] + [(sub tyl 64) (end [3 (dec len)] mot)] [0 mot] =+ [yoz=(fiz yaz) wux=(fiz wix)] ?& ?| =(0 p.yoz) @@ -7302,8 +7302,8 @@ == |- ?| =(%$ p.yoz) =(%$ p.wux) - ?& =((new-end 3 p.yoz) (new-end 3 p.wux)) - $(p.yoz (new-rsh 3 p.yoz), p.wux (new-rsh 3 p.wux)) + ?& =((end 3 p.yoz) (end 3 p.wux)) + $(p.yoz (rsh 3 p.yoz), p.wux (rsh 3 p.wux)) == == == @@ -7370,11 +7370,11 @@ =/ small=@ (met 0 contained) ?: (lte small big) | =/ dif=@ (sub small big) - =(container (new-rsh [0 dif] contained)) + =(container (rsh [0 dif] contained)) :: ++ parent |= a=axis - `axis`(new-rsh 0 a) + `axis`(rsh 0 a) :: ++ sibling |= a=axis @@ -11044,7 +11044,7 @@ ['\\' i.mil $(mil t.mil)] ?: (lte ' ' i.mil) [i.mil $(mil t.mil)] - ['\\' ~(x ne (new-rsh 2 i.mil)) ~(x ne (new-end 2 i.mil)) $(mil t.mil)] + ['\\' ~(x ne (rsh 2 i.mil)) ~(x ne (end 2 i.mil)) $(mil t.mil)] :: ++ deal |=(lum=* (dish dole lum)) ++ dial diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index 9651bbb625..be58fc0e80 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -926,7 +926,7 @@ :: :: Logic duplicates +com:nu:crub:crypto and +sure:as:crub:crypto. :: - =/ key (new-end 8 (new-rsh 3 public-key.open-packet)) + =/ key (end 8 (rsh 3 public-key.open-packet)) ?> (veri:ed:crypto signature signed key) :: store comet as peer in our state :: @@ -1551,7 +1551,7 @@ =/ pumps=(list message-pump-state) %+ murn ~(tap by snd.peer-state) |= [=bone =message-pump-state] - ?: =(0 (new-end 0 bone)) + ?: =(0 (end 0 bone)) ~ `u=message-pump-state :: clogged: are five or more response messages unsent to this peer? @@ -1780,11 +1780,11 @@ ^+ peer-core :: if odd bone, ack is on "subscription update" message; no-op :: - ?: =(1 (new-end 0 bone)) + ?: =(1 (end 0 bone)) peer-core :: even bone; is this bone a nack-trace bone? :: - ?: =(1 (new-end 0 (new-rsh 0 bone))) + ?: =(1 (end 0 (rsh 0 bone))) :: nack-trace bone; assume .ok, clear nack from |message-sink :: =/ target-bone=^bone (mix 0b10 bone) @@ -1870,9 +1870,9 @@ :: even bone, 1 second bit: nack-trace %boon message :: ++ on-sink-memo - ?: =(1 (new-end 0 bone)) + ?: =(1 (end 0 bone)) on-sink-plea - ?: =(0 (new-end 0 (new-rsh 0 bone))) + ?: =(0 (end 0 (rsh 0 bone))) on-sink-boon on-sink-nack-trace :: +on-sink-boon: handle response message received by |message-sink @@ -2903,11 +2903,11 @@ |= [=public-key =private-key] ^- symmetric-key :: - ?> =('b' (new-end 3 public-key)) - =. public-key (new-rsh 8 (new-rsh 3 public-key)) + ?> =('b' (end 3 public-key)) + =. public-key (rsh 8 (rsh 3 public-key)) :: - ?> =('B' (new-end 3 private-key)) - =. private-key (new-rsh 8 (new-rsh 3 private-key)) + ?> =('B' (end 3 private-key)) + =. private-key (rsh 8 (rsh 3 private-key)) :: `@`(shar:ed:crypto public-key private-key) :: +encrypt: encrypt $shut-packet into atomic packet content @@ -2953,8 +2953,8 @@ =/ body=@ ;: mix sndr - (new-lsh [3 size.sndr-meta] rcvr) - (new-lsh [3 (add size.sndr-meta size.rcvr-meta)] (jam [origin content])) + (lsh [3 size.sndr-meta] rcvr) + (lsh [3 (add size.sndr-meta size.rcvr-meta)] (jam [origin content])) == :: header: 32-bit header assembled from bitstreams of fields :: @@ -2971,7 +2971,7 @@ == :: result is <
> :: - (mix header (new-lsh 5 body)) + (mix header (lsh 5 body)) :: +decode-packet: deserialize packet from bytestream or crash :: ++ decode-packet @@ -2979,29 +2979,29 @@ ^- packet :: first 32 (2^5) bits are header; the rest is body :: - =/ header (new-end 5 blob) - =/ body (new-rsh 5 blob) + =/ header (end 5 blob) + =/ body (rsh 5 blob) :: - =/ version (new-end [0 3] header) + =/ version (end [0 3] header) =/ checksum (cut 0 [3 20] header) =/ sndr-size (decode-ship-size (cut 0 [23 2] header)) =/ rcvr-size (decode-ship-size (cut 0 [25 2] header)) =/ encrypted ?+((cut 0 [27 5] header) !! %0 %.y, %1 %.n) :: =/ =dyad - :- sndr=(new-end [3 sndr-size] body) + :- sndr=(end [3 sndr-size] body) rcvr=(cut 3 [sndr-size rcvr-size] body) :: ?. =(protocol-version version) ~| %ames-protocol^version^dyad !! - ?. =(checksum (new-end [0 20] (mug body))) + ?. =(checksum (end [0 20] (mug body))) ~| %ames-checksum^dyad !! :: =+ ~| %ames-invalid-packet ;; [origin=(unit lane) content=*] ~| %ames-invalid-noun %- cue - (new-rsh [3 (add rcvr-size sndr-size)] body) + (rsh [3 (add rcvr-size sndr-size)] body) :: [dyad encrypted origin content] :: +decode-ship-size: decode a 2-bit ship type specifier into a byte width diff --git a/pkg/arvo/sys/vane/clay.hoon b/pkg/arvo/sys/vane/clay.hoon index 5118c3df80..08cd76dc67 100644 --- a/pkg/arvo/sys/vane/clay.hoon +++ b/pkg/arvo/sys/vane/clay.hoon @@ -1978,7 +1978,7 @@ |= =term =/ vane=@t (path-to-cord data /sys/vane/[term]/hoon) %- emit - =/ tip (new-end 3 term) + =/ tip (end 3 term) =/ =path /sys/vane/[term]/hoon [hen %pass /reload %d %flog %veer tip path vane] -- @@ -3839,7 +3839,7 @@ =+ pac=(of-wain (lurk:differ (to-wain (cat 3 txt '\0a')) dif)) ?~ pac '' - (new-end [3 (dec (met 3 pac))] pac) + (end [3 (dec (met 3 pac))] pac) :: :: Gets an arch (directory listing) at a node. :: diff --git a/pkg/arvo/sys/vane/eyre.hoon b/pkg/arvo/sys/vane/eyre.hoon index b5d7cb760e..597c60a06f 100644 --- a/pkg/arvo/sys/vane/eyre.hoon +++ b/pkg/arvo/sys/vane/eyre.hoon @@ -753,7 +753,7 @@ ?- -.mym %| (error-response 500 "failed tube from {(trip mark)} to mime") %& %+ return-static-data-on-duct 200 - [(new-rsh 3 (spat p.p.mym)) q.p.mym] + [(rsh 3 (spat p.p.mym)) q.p.mym] == :: ++ find-tube @@ -1031,7 +1031,7 @@ =+ pax=/(scot %p our)/code/(scot %da now)/(scot %p our) =+ res=((sloy scry) [151 %noun] %j pax) :: - (new-rsh 3 (scot %p (@ (need (need res))))) + (rsh 3 (scot %p (@ (need (need res))))) :: +session-cookie-string: compose session cookie :: ++ session-cookie-string diff --git a/pkg/arvo/sys/vane/gall.hoon b/pkg/arvo/sys/vane/gall.hoon index 54ef6bf0b2..63900b3d7c 100644 --- a/pkg/arvo/sys/vane/gall.hoon +++ b/pkg/arvo/sys/vane/gall.hoon @@ -332,7 +332,7 @@ control-duct hen beak bek agent &+agent - nonce (scot %uw (new-end 5 (shas %yoke-nonce eny))) + nonce (scot %uw (end 5 (shas %yoke-nonce eny))) == :: =/ old mo-core diff --git a/pkg/arvo/sys/vane/jael.hoon b/pkg/arvo/sys/vane/jael.hoon index 1f1e53eb17..c3a107a874 100644 --- a/pkg/arvo/sys/vane/jael.hoon +++ b/pkg/arvo/sys/vane/jael.hoon @@ -1045,7 +1045,7 @@ =/ who (slaw %p i.tyl) ?~ who [~ ~] =/ sec (~(got by jaw.own.pki.lex) lyf.own.pki.lex) - ``[%noun !>((new-end 6 (shaf %pass (shax sec))))] + ``[%noun !>((end 6 (shaf %pass (shax sec))))] :: %life ?. ?=([@ ~] tyl) [~ ~] diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index a88c8709db..392bfac4d0 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -2316,7 +2316,7 @@ :: :: ++pram:number ++ pram :: rabin-miller |= a=@ ^- ? - ?: ?| =(0 (new-end 0 a)) + ?: ?| =(0 (end 0 a)) =(1 a) =+ b=1 |- ^- ? @@ -2328,8 +2328,8 @@ =+ ^= b =+ [s=(dec a) t=0] |- ^- [s=@ t=@] - ?: =(0 (new-end 0 s)) - $(s (new-rsh 0 s), t +(t)) + ?: =(0 (end 0 s)) + $(s (rsh 0 s), t +(t)) [s t] ?> =((mul s.b (bex t.b)) (dec a)) =+ c=0 @@ -2425,7 +2425,7 @@ ?: =(i 0) =+ x=(cub r) (sit.fq (mul -.x (inv +.x))) - =+ m=(new-rsh [0 i] a) + =+ m=(rsh [0 i] a) ?: =(0 (mod m 2)) $(i (dec i), s (cad r s one), r (cub r)) $(i (dec i), r (cad r s one), s (cub s)) @@ -2447,16 +2447,16 @@ ~| [%dub-ga a] ?> (lth b si) ?: =(1 (cut 0 [(dec p.a) 1] b)) - (dif (sit q.a) (sit (new-lsh 0 b))) - (new-lsh 0 b) + (dif (sit q.a) (sit (lsh 0 b))) + (lsh 0 b) :: :: ++pro:ga:number ++ pro :: slow multiply |= [b=@ c=@] ?: =(0 b) 0 ?: =(1 (dis 1 b)) - (dif c $(b (new-rsh 0 b), c (dub c))) - $(b (new-rsh 0 b), c (dub c)) + (dif c $(b (rsh 0 b), c (dub c))) + $(b (rsh 0 b), c (dub c)) :: :: ++toe:ga:number ++ toe :: exp+log tables =+ ^= nu @@ -2779,7 +2779,7 @@ |= blk=@H ^- @uxH =+ (ahem 6 4 12) =: - key (new-rsh 6 (~(net fe 8) key)) + key (rsh 6 (~(net fe 8) key)) blk (~(net fe 7) blk) == %- ~(net fe 7) @@ -2790,7 +2790,7 @@ |= blk=@H ^- @uxH =+ (ahem 6 4 12) =: - key (new-rsh 6 (~(net fe 8) key)) + key (rsh 6 (~(net fe 8) key)) blk (~(net fe 7) blk) == %- ~(net fe 7) @@ -2961,7 +2961,7 @@ =/ blocks (add (div len 16) ?:(=((^mod len 16) 0) 0 1)) ?> (gte len (met 3 txt)) %+ mix txt - %+ new-rsh [3 (sub (mul 16 blocks) len)] + %+ rsh [3 (sub (mul 16 blocks) len)] %+ rep 7 =| seed=(list @ux) |- ^+ seed @@ -2988,7 +2988,7 @@ =/ blocks (add (div len 16) ?:(=((^mod len 16) 0) 0 1)) ?> (gte len (met 3 txt)) %+ mix txt - %+ new-rsh [3 (sub (mul 16 blocks) len)] + %+ rsh [3 (sub (mul 16 blocks) len)] %+ rep 7 =| seed=(list @ux) |- ^+ seed @@ -3015,7 +3015,7 @@ =/ blocks (add (div len 16) ?:(=((^mod len 16) 0) 0 1)) ?> (gte len (met 3 txt)) %+ mix txt - %+ new-rsh [3 (sub (mul 16 blocks) len)] + %+ rsh [3 (sub (mul 16 blocks) len)] %+ rep 7 =| seed=(list @ux) |- ^+ seed @@ -3040,8 +3040,8 @@ ^- @uxH %- ~(sit fe 7) ?. =((xeb str) 128) - (new-lsh 0 str) - (mix 0x87 (new-lsh 0 str)) + (lsh 0 str) + (mix 0x87 (lsh 0 str)) :: :: ++mpad:aes:crypto ++ mpad :: |= [oct=@ txt=@] @@ -3054,7 +3054,7 @@ ^- @ux =+ pad=(mod oct 16) ?: =(pad 0) 0x8000.0000.0000.0000.0000.0000.0000.0000 - (new-lsh [3 (sub 15 pad)] (mix 0x80 (new-lsh 3 txt))) + (lsh [3 (sub 15 pad)] (mix 0x80 (lsh 3 txt))) :: :: ++suba:aes:crypto ++ suba :: AES-128 subkeys |= key=@H @@ -3199,7 +3199,7 @@ ~/ %en |= txt=@ ^- (trel @uxH @ud @ux) - =+ [k1=(new-rsh 7 key) k2=(new-end 7 key)] + =+ [k1=(rsh 7 key) k2=(end 7 key)] =+ iv=(s2va k1 (weld vec (limo ~[txt]))) =+ len=(met 3 txt) =* hib (dis iv 0xffff.ffff.ffff.ffff.7fff.ffff.7fff.ffff) @@ -3212,7 +3212,7 @@ ~/ %de |= [iv=@H len=@ txt=@] ^- (unit @ux) - =+ [k1=(new-rsh 7 key) k2=(new-end 7 key)] + =+ [k1=(rsh 7 key) k2=(end 7 key)] =* hib (dis iv 0xffff.ffff.ffff.ffff.7fff.ffff.7fff.ffff) =+ ^= pln (~(de ctra k2 7 len hib) txt) @@ -3229,7 +3229,7 @@ ~/ %en |= txt=@ ^- (trel @uxH @ud @ux) - =+ [k1=(new-rsh [6 3] key) k2=(new-end [6 3] key)] + =+ [k1=(rsh [6 3] key) k2=(end [6 3] key)] =+ iv=(s2vb k1 (weld vec (limo ~[txt]))) =* hib (dis iv 0xffff.ffff.ffff.ffff.7fff.ffff.7fff.ffff) =+ len=(met 3 txt) @@ -3241,7 +3241,7 @@ ~/ %de |= [iv=@H len=@ txt=@] ^- (unit @ux) - =+ [k1=(new-rsh [6 3] key) k2=(new-end [6 3] key)] + =+ [k1=(rsh [6 3] key) k2=(end [6 3] key)] =* hib (dis iv 0xffff.ffff.ffff.ffff.7fff.ffff.7fff.ffff) =+ ^= pln (~(de ctrb k2 7 len hib) txt) @@ -3258,7 +3258,7 @@ ~/ %en |= txt=@ ^- (trel @uxH @ud @ux) - =+ [k1=(new-rsh 8 key) k2=(new-end 8 key)] + =+ [k1=(rsh 8 key) k2=(end 8 key)] =+ iv=(s2vc k1 (weld vec (limo ~[txt]))) =* hib (dis iv 0xffff.ffff.ffff.ffff.7fff.ffff.7fff.ffff) =+ len=(met 3 txt) @@ -3271,7 +3271,7 @@ ~/ %de |= [iv=@H len=@ txt=@] ^- (unit @ux) - =+ [k1=(new-rsh 8 key) k2=(new-end 8 key)] + =+ [k1=(rsh 8 key) k2=(end 8 key)] =* hib (dis iv 0xffff.ffff.ffff.ffff.7fff.ffff.7fff.ffff) =+ ^= pln (~(de ctrc k2 7 len hib) txt) @@ -3425,11 +3425,11 @@ ~/ %puck |= sk=@I ^- @ ?: (gth (met 3 sk) 32) !! - =+ h=(shal (new-rsh [0 3] b) sk) + =+ h=(shal (rsh [0 3] b) sk) =+ ^= a %+ add (bex (sub b 2)) - (new-lsh [0 3] (cut 0 [3 (sub b 5)] h)) + (lsh [0 3] (cut 0 [3 (sub b 5)] h)) =+ aa=(scam bb a) (etch aa) :: :: ++suck:ed:crypto @@ -3442,10 +3442,10 @@ ~/ %shar |= [pub=@ sek=@] ^- @ux - =+ exp=(shal (new-rsh [0 3] b) (suck sek)) + =+ exp=(shal (rsh [0 3] b) (suck sek)) =. exp (dis exp (can 0 ~[[3 0] [251 (fil 0 251 1)]])) - =. exp (con exp (new-lsh [3 31] 0b100.0000)) - =+ prv=(new-end 8 exp) + =. exp (con exp (lsh [3 31] 0b100.0000)) + =+ prv=(end 8 exp) =+ crv=(fra.fq (sum.fq 1 pub) (dif.fq 1 pub)) (curt prv crv) :: :: ++sign:ed:crypto @@ -3454,11 +3454,11 @@ |= [m=@ se=@] ^- @ =+ sk=(suck se) =+ pk=(cut 0 [b b] sk) - =+ h=(shal (new-rsh [0 3] b) sk) + =+ h=(shal (rsh [0 3] b) sk) =+ ^= a %+ add (bex (sub b 2)) - (new-lsh [0 3] (cut 0 [3 (sub b 5)] h)) + (lsh [0 3] (cut 0 [3 (sub b 5)] h)) =+ ^= r =+ hm=(cut 0 [b b] h) =+ ^= i @@ -3484,7 +3484,7 @@ |= [s=@ m=@ pk=@] ^- ? ?: (gth (div b 4) (met 3 s)) | ?: (gth (div b 8) (met 3 pk)) | - =+ cb=(new-rsh [0 3] b) + =+ cb=(rsh [0 3] b) =+ rr=(deco (cut 0 [0 b] s)) ?~ rr | =+ aa=(deco pk) @@ -3507,7 +3507,7 @@ =+ few==>(fe .(a 5)) =+ ^= rot |= [a=@ b=@] - (mix (new-end 5 (new-lsh [0 a] b)) (new-rsh [0 (sub 32 a)] b)) + (mix (end 5 (lsh [0 a] b)) (rsh [0 (sub 32 a)] b)) =+ ^= lea |= [a=@ b=@] (net:few (sum:few (net:few a) (net:few b))) @@ -3623,13 +3623,13 @@ :: :: ++hml:scr:crypto ++ hml :: w+length |= [k=@ kl=@ t=@ tl=@] - => .(k (new-end [3 kl] k), t (new-end [3 tl] t)) + => .(k (end [3 kl] k), t (end [3 tl] t)) =+ b=64 =? k (gth kl b) (shay kl k) =+ ^= q %+ shay (add b tl) - (add (new-lsh [3 b] t) (mix k (fil 3 b 0x36))) + (add (lsh [3 b] t) (mix k (fil 3 b 0x36))) %+ shay (add b 32) - (add (new-lsh [3 b] q) (mix k (fil 3 b 0x5c))) + (add (lsh [3 b] q) (mix k (fil 3 b 0x5c))) :: :: ++pbk:scr:crypto ++ pbk :: PBKDF2-HMAC-SHA256 ~/ %pbk @@ -3639,7 +3639,7 @@ ++ pbl :: w+length ~/ %pbl |= [p=@ pl=@ s=@ sl=@ c=@ d=@] - => .(p (new-end [3 pl] p), s (new-end [3 sl] s)) + => .(p (end [3 pl] p), s (end [3 sl] s)) =+ h=32 :: :: max key length 1GB @@ -3656,13 +3656,13 @@ =+ [t=0 j=1 k=1] =. t |- ^- @ ?: (gth j l) t - =+ u=(add s (new-lsh [3 sl] (rep 3 (flop (rpp 3 4 j))))) + =+ u=(add s (lsh [3 sl] (rep 3 (flop (rpp 3 4 j))))) =+ f=0 =. f |- ^- @ ?: (gth k c) f =+ q=(hml p pl u ?:(=(k 1) (add sl 4) h)) $(u q, f (mix f q), k +(k)) - $(t (add t (new-lsh [3 (mul (dec j) h)] f)), j +(j)) - (new-end [3 d] t) + $(t (add t (lsh [3 (mul (dec j) h)] f)), j +(j)) + (end [3 d] t) :: :: ++hsh:scr:crypto ++ hsh :: scrypt ~/ %hsh @@ -3673,7 +3673,7 @@ ~/ %hsl |= [p=@ pl=@ s=@ sl=@ n=@ r=@ z=@ d=@] =| v=(list (list @)) - => .(p (new-end [3 pl] p), s (new-end [3 sl] s)) + => .(p (end [3 pl] p), s (end [3 sl] s)) =+ u=(mul (mul 128 r) z) :: :: n is power of 2; max 1GB memory @@ -3730,8 +3730,8 @@ |= [bpk=pass msg=@] ^- @ux ?~ sek ~| %pubkey-only !! - ?> =('b' (new-end 3 bpk)) - =+ pk=(new-rsh 8 (new-rsh 3 bpk)) + ?> =('b' (end 3 bpk)) + =+ pk=(rsh 8 (rsh 3 bpk)) =+ shar=(shax (shar:ed pk cry.u.sek)) =+ smsg=(sign msg) (jam (~(en siva:aes shar ~) smsg)) @@ -3740,8 +3740,8 @@ |= [bpk=pass txt=@] ^- (unit @ux) ?~ sek ~| %pubkey-only !! - ?> =('b' (new-end 3 bpk)) - =+ pk=(new-rsh 8 (new-rsh 3 bpk)) + ?> =('b' (end 3 bpk)) + =+ pk=(rsh 8 (rsh 3 bpk)) =+ shar=(shax (shar:ed pk cry.u.sek)) =+ ;;([iv=@ len=@ cph=@] (cue txt)) =+ try=(~(de siva:aes shar ~) iv len cph) @@ -3777,7 +3777,7 @@ ++ pac :: private fingerprint ^- @uvG ?~ sek ~| %pubkey-only !! - (new-end 6 (shaf %bcod sec)) + (end 6 (shaf %bcod sec)) :: :: ++pub:ex:crub:crypto ++ pub :: public key ^- pass @@ -3796,21 +3796,21 @@ |= [w=@ seed=@] =+ wid=(add (div w 8) ?:(=((mod w 8) 0) 0 1)) =+ bits=(shal wid seed) - =+ [c=(new-rsh 8 bits) s=(new-end 8 bits)] + =+ [c=(rsh 8 bits) s=(end 8 bits)] ..nu(pub [cry=(puck:ed c) sgn=(puck:ed s)], sek `[cry=c sgn=s]) :: :: ++nol:nu:crub:crypto ++ nol :: activate secret |= a=ring - =+ [mag=(new-end 3 a) bod=(new-rsh 3 a)] + =+ [mag=(end 3 a) bod=(rsh 3 a)] ~| %not-crub-seckey ?> =('B' mag) - =+ [c=(new-rsh 8 bod) s=(new-end 8 bod)] + =+ [c=(rsh 8 bod) s=(end 8 bod)] ..nu(pub [cry=(puck:ed c) sgn=(puck:ed s)], sek `[cry=c sgn=s]) :: :: ++com:nu:crub:crypto ++ com :: activate public |= a=pass - =+ [mag=(new-end 3 a) bod=(new-rsh 3 a)] + =+ [mag=(end 3 a) bod=(rsh 3 a)] ~| %not-crub-pubkey ?> =('b' mag) - ..nu(pub [cry=(new-rsh 8 bod) sgn=(new-end 8 bod)], sek ~) + ..nu(pub [cry=(rsh 8 bod) sgn=(end 8 bod)], sek ~) -- ::nu -- ::crub :: :: @@ -3934,7 +3934,7 @@ :- (add p.inp +(pal)) :: padding is provided in lane bit ordering, :: ie, LSB = left. - (cat 3 (con (new-lsh [3 pal] dsb) 0x80) q.inp) + (cat 3 (con (lsh [3 pal] dsb) 0x80) q.inp) :: ++ sponge :: sponge construction @@ -3977,7 +3977,7 @@ %+ roll pieces |= [p=@ s=@] :: pad with capacity, - =. p (new-lsh [0 capacity] p) + =. p (lsh [0 capacity] p) :: xor it into the state and permute it. (permute (mix s (bytes-to-lanes p))) :: @@ -3988,19 +3988,19 @@ :: append a bitrate-sized head of state to the :: result. =. res - %+ con (new-lsh [0 bitrate] res) - (new-rsh [0 capacity] (lanes-to-bytes state)) + %+ con (lsh [0 bitrate] res) + (rsh [0 capacity] (lanes-to-bytes state)) =. len (add len bitrate) ?: (gte len output) :: produce the requested bits of output. - (new-rsh [0 (sub len output)] res) + (rsh [0 (sub len output)] res) $(res res, state (permute state)) :: ++ bytes-to-lanes :: flip byte order in blocks of 8 bytes. |= a=@ %^ run 6 a - |=(b=@ (new-lsh [3 (sub 8 (met 3 b))] (swp 3 b))) + |=(b=@ (lsh [3 (sub 8 (met 3 b))] (swp 3 b))) :: ++ lanes-to-bytes :: unflip byte order in blocks of 8 bytes. @@ -4041,14 +4041,14 @@ =/ c=@ %+ roll (gulf 0 (dec size)) |= [x=@ud c=@] - %+ con (new-lsh [lane-bloq 1] c) + %+ con (lsh [lane-bloq 1] c) %+ roll (gulf 0 (dec size)) |= [y=@ud c=@] (mix c (get-lane x y a)) =/ d=@ %+ roll (gulf 0 (dec size)) |= [x=@ud d=@] - %+ con (new-lsh [lane-bloq 1] d) + %+ con (lsh [lane-bloq 1] d) %+ mix =- (get-word - size c) ?:(=(x 0) (dec size) (dec x)) @@ -4058,7 +4058,7 @@ %+ roll (gulf 0 (dec lanes)) |= [i=@ud a=_a] %+ mix a - %+ new-lsh + %+ lsh [lane-bloq (sub lanes +(i))] (get-word i size d) :: @@ -4069,7 +4069,7 @@ =+ x=(mod i 5) =+ y=(div i 5) %+ con b - %+ new-lsh + %+ lsh :- lane-bloq %+ sub lanes %+ add +(y) @@ -4083,7 +4083,7 @@ =. a %+ roll (gulf 0 (dec lanes)) |= [i=@ud a=@] - %+ con (new-lsh lane-bloq a) + %+ con (lsh lane-bloq a) =+ x=(mod i 5) =+ y=(div i 5) %+ mix (get-lane x y b) @@ -4096,7 +4096,7 @@ :: iota =. a =+ (round-constant round) - (mix a (new-lsh [lane-bloq (dec lanes)] -)) + (mix a (lsh [lane-bloq (dec lanes)] -)) :: :: next round $(round +(round)) @@ -4192,20 +4192,20 @@ :: out: bytes output by haj |* [[haj=$-([@u @] @) boq=@u out=@u] key=byts msg=byts] :: ensure key and message fit signaled lengths - =. dat.key (new-end [3 wid.key] dat.key) - =. dat.msg (new-end [3 wid.msg] dat.msg) + =. dat.key (end [3 wid.key] dat.key) + =. dat.msg (end [3 wid.msg] dat.msg) :: keys longer than block size are shortened by hashing =? dat.key (gth wid.key boq) (haj wid.key dat.key) =? wid.key (gth wid.key boq) out :: keys shorter than block size are right-padded - =? dat.key (lth wid.key boq) (new-lsh [3 (sub boq wid.key)] dat.key) + =? dat.key (lth wid.key boq) (lsh [3 (sub boq wid.key)] dat.key) :: pad key, inner and outer =+ kip=(mix dat.key (fil 3 boq 0x36)) =+ kop=(mix dat.key (fil 3 boq 0x5c)) :: append inner padding to message, then hash - =+ (haj (add wid.msg boq) (add (new-lsh [3 wid.msg] kip) dat.msg)) + =+ (haj (add wid.msg boq) (add (lsh [3 wid.msg] kip) dat.msg)) :: prepend outer padding to result, hash again - (haj (add out boq) (add (new-lsh [3 out] kop) -)) + (haj (add out boq) (add (lsh [3 out] kop) -)) -- :: hmac :: :: :::: ++secp:crypto :: (2b9) secp family @@ -4250,15 +4250,15 @@ ++ decompress-point |= compressed=@ ^- point - =/ x=@ (new-end [3 bytes] compressed) + =/ x=@ (end [3 bytes] compressed) ?> =(3 (mod p.domain 4)) =/ fop field-p =+ [fadd fmul fpow]=[sum.fop pro.fop exp.fop] - =/ y=@ %+ fpow (new-rsh [0 2] +(p.domain)) + =/ y=@ %+ fpow (rsh [0 2] +(p.domain)) %+ fadd b.domain %+ fadd (fpow 3 x) (fmul a.domain x) - =/ s=@ (new-rsh [3 bytes] compressed) + =/ s=@ (rsh [3 bytes] compressed) ~| [`@ux`s `@ux`compressed] ?> |(=(2 s) =(3 s)) :: check parity @@ -4343,8 +4343,8 @@ ?: (gte scalar n.domain) $(scalar (mod scalar n.domain)) ?: =(0 (mod scalar 2)) - (double $(scalar (new-rsh 0 scalar))) - (add a (double $(scalar (new-rsh 0 scalar)))) + (double $(scalar (rsh 0 scalar))) + (add a (double $(scalar (rsh 0 scalar)))) -- ++ add-points |= [a=point b=point] @@ -4466,7 +4466,7 @@ (sub n.domain.c s) =? rp s-high [x.rp (sub p.domain.c y.rp)] - =/ v (new-end 0 y.rp) + =/ v (end 0 y.rp) =? v (gte x.rp n.domain.c) (add v 2) [v x.rp s] @@ -4486,8 +4486,8 @@ =/ fop field-p.c =+ [fadd fmul fpow]=[sum.fop pro.fop exp.fop] =/ ysq (fadd (fpow 3 x) b.domain.c) - =/ beta (fpow (new-rsh [0 2] +(p.domain.c)) ysq) - =/ y ?: =((new-end 0 v.sig) (new-end 0 beta)) + =/ beta (fpow (rsh [0 2] +(p.domain.c)) ysq) + =/ y ?: =((end 0 v.sig) (end 0 beta)) beta (sub p.domain.c beta) ?> =(0 (dif.fop ysq (fmul y y))) @@ -4567,22 +4567,22 @@ :: ++ pad |= [byts len=@ud] - (new-lsh [3 (sub len wid)] dat) + (lsh [3 (sub len wid)] dat) :: ++ compress |= [h=@ c=@ t=@ud l=?] ^- @ :: set up local work vector - =+ v=(add (new-lsh [6 8] h) iv) + =+ v=(add (lsh [6 8] h) iv) :: xor the counter t into v =. v %- mod-word :^ v 12 16 - (cury mix (new-end [0 64] t)) + (cury mix (end [0 64] t)) =. v %- mod-word :^ v 13 16 - (cury mix (new-rsh [0 64] t)) + (cury mix (rsh [0 64] t)) :: for the last block, invert v14 =? v l %- mod-word @@ -4594,8 +4594,8 @@ |^ ?: =(i 12) :: xor upper and lower halves of v into state h - =. h (mix h (new-rsh [6 8] v)) - (mix h (new-end [6 8] v)) + =. h (mix h (rsh [6 8] v)) + (mix h (end [6 8] v)) :: select message mixing schedule and mix v =. s (snag (mod i 10) sigma) =. v (do-mix 0 4 8 12 0 1) @@ -4645,8 +4645,8 @@ =. out (max 1 (min out 64)) =. wid.msg (min wid.msg (bex 128)) =. wid.key (min wid.key 64) - =. dat.msg (new-end [3 wid.msg] dat.msg) - =. dat.key (new-end [3 wid.key] dat.key) + =. dat.msg (end [3 wid.msg] dat.msg) + =. dat.key (end [3 wid.key] dat.key) :: initialize state vector =+ h=iv :: mix key length and output length into h0 @@ -4655,7 +4655,7 @@ :^ h 0 8 %+ cury mix %+ add 0x101.0000 - (add (new-lsh 3 wid.key) out) + (add (lsh 3 wid.key) out) :: keep track of how much we've compressed =* mes dat.msg =+ com=0 @@ -4680,7 +4680,7 @@ =. c (pad [rem c] 128) =. h (compress h c com &) :: produce output of desired length - %+ new-rsh [3 (sub 64 out)] + %+ rsh [3 (sub 64 out)] :: do some word %+ rep 6 %+ turn (flop (gulf 0 7)) @@ -4883,7 +4883,7 @@ =/ random-block=@ %+ compress 0 %+ compress 0 - %+ new-lsh [3 968] + %+ lsh [3 968] %+ rep 6 =+ (cury (cury rev 3) 8) :~ (- counter) @@ -4901,8 +4901,8 @@ %+ turn (flop (rip 6 random-block)) |= a=@ ^- (pair @ @) - :- (rev 3 4 (new-rsh 5 a)) - (rev 3 4 (new-end 5 a)) + :- (rev 3 4 (rsh 5 a)) + (rev 3 4 (end 5 a)) :: :: iterate over the entire segment length :: @@ -4949,9 +4949,9 @@ (mul +(seg) seg-length) :: pseudorandom offset =- %+ sub (dec -) - %+ new-rsh [0 32] + %+ rsh [0 32] %+ mul - - (new-rsh [0 32] (mul c1 c1)) + (rsh [0 32] (mul c1 c1)) :: reference area size ?: =(0 itn) ?: |(=(0 seg) =(row ref-row)) (dec col) @@ -5114,7 +5114,7 @@ =+ fed=~(. fe 6) =* sum sum:fed =* ror ror:fed - =+ end=(cury new-end 5) + =+ end=(cury end 5) =. a :(sum a b :(mul 2 (end a) (end b))) =. d (ror 0 32 (mix d a)) =. c :(sum c d :(mul 2 (end c) (end d))) @@ -5145,14 +5145,14 @@ :: desired output size. :: =+ tmp=(blake2b msg 0^0 64) - =+ res=(new-rsh [3 32] tmp) + =+ res=(rsh [3 32] tmp) =. out (sub out 32) |- ?: (gth out 64) =. tmp (blake2b 64^tmp 0^0 64) - =. res (add (new-lsh [3 32] res) (new-rsh [3 32] tmp)) + =. res (add (lsh [3 32] res) (rsh [3 32] tmp)) $(out (sub out 32)) - %+ add (new-lsh [3 out] res) + %+ add (lsh [3 out] res) (blake2b 64^tmp 0^0 out) :: :: utilities @@ -5340,7 +5340,7 @@ =+ (sub 511 (mod (add wid 64) 512)) :- :(add 64 +(-) wid) %+ can 0 - ~[64^(rev 3 8 wid) +(-)^(new-lsh [0 -] 1) wid^dat] + ~[64^(rev 3 8 wid) +(-)^(lsh [0 -] 1) wid^dat] -- :: ++ pbkdf @@ -5378,7 +5378,7 @@ ++ pbkdf ::TODO jet me! ++hmac:hmac is an example |* [[prf=$-([byts byts] @) out=@u] p=byts s=byts c=@ d=@] - => .(dat.p (new-end [3 wid.p] dat.p), dat.s (new-end [3 wid.s] dat.s)) + => .(dat.p (end [3 wid.p] dat.p), dat.s (end [3 wid.s] dat.s)) :: :: max key length 1GB :: max iterations 2^28 @@ -5399,7 +5399,7 @@ ?: (gth j l) t =/ u %+ add dat.s - %+ new-lsh [3 wid.s] + %+ lsh [3 wid.s] %+ rep 3 (flop (rpp:scr 3 4 j)) =+ f=0 @@ -5411,8 +5411,8 @@ =+ ?:(=(k 1) (add wid.s 4) out) (prf [wid.p (rev 3 p)] [- (rev 3 - u)]) $(u q, f (mix f q), k +(k)) - $(t (add t (new-lsh [3 (mul (dec j) out)] f)), j +(j)) - (rev 3 d (new-end [3 d] t)) + $(t (add t (lsh [3 (mul (dec j) out)] f)), j +(j)) + (rev 3 d (end [3 d] t)) -- -- ::crypto :: :::: @@ -6177,7 +6177,7 @@ ++ en ~/ %en |= a=octs ^- cord - (crip ((x-co:co (mul p.a 2)) (new-end [3 p.a] q.a))) + (crip ((x-co:co (mul p.a 2)) (end [3 p.a] q.a))) :: ++ de ~/ %de @@ -6195,15 +6195,15 @@ |= tig=@ ^- tape =+ poc=(~(dif fo 3) 0 (met 3 tig)) - =+ pad=(new-lsh [3 poc] (swp 3 tig)) + =+ pad=(lsh [3 poc] (swp 3 tig)) =+ ^= cha 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' =+ ^= sif |- ^- tape ?~ pad ~ - =+ d=(new-end [0 6] pad) - [(cut 3 [d 1] cha) $(pad (new-rsh [0 6] pad))] + =+ d=(end [0 6] pad) + [(cut 3 [d 1] cha) $(pad (rsh [0 6] pad))] (weld (flop (slag poc sif)) (reap poc '=')) :: :: ++de-base64:mimes: ++ de-base64 :: decode base64 @@ -6583,7 +6583,7 @@ =('_' tap) == [tap ~] - ['%' (xen (new-rsh [0 4] tap)) (xen (new-end [0 4] tap)) ~] + ['%' (xen (rsh [0 4] tap)) (xen (end [0 4] tap)) ~] :: :: ++de-urlt:html ++ de-urlt :: url decode |= tep=tape @@ -6591,7 +6591,7 @@ ?~ tep [~ ~] ?: =('%' i.tep) ?. ?=([@ @ *] t.tep) ~ - =+ nag=(mix i.t.tep (new-lsh 3 i.t.t.tep)) + =+ nag=(mix i.t.tep (lsh 3 i.t.t.tep)) =+ val=(rush nag hex:ag) ?~ val ~ =+ nex=$(tep t.t.t.tep) @@ -6630,7 +6630,7 @@ ?:(&(p.har !?=(hoke r.har)) "https://" "http://") :: ?- -.r.har - %| (trip (new-rsh 3 (scot %if p.r.har))) + %| (trip (rsh 3 (scot %if p.r.har))) %& =+ rit=(flop p.r.har) |- ^- tape ?~ rit ~ @@ -6717,7 +6717,7 @@ ++ dlab :: 2396 domainlabel %+ sear |= a=@ta - ?.(=('-' (new-rsh [3 (dec (met 3 a))] a)) [~ u=a] ~) + ?.(=('-' (rsh [3 (dec (met 3 a))] a)) [~ u=a] ~) %+ cook |=(a=tape (crip (cass a))) ;~(plug aln (star alp)) :: :: ++fque:de-purl:html @@ -6791,7 +6791,7 @@ |= a=(list @t) =+ b=(flop a) ?> ?=(^ b) - =+ c=(new-end 3 i.b) + =+ c=(end 3 i.b) ?.(&((gte c 'a') (lte c 'z')) ~ [~ u=b]) (most dot dlab) :: @@ -6971,10 +6971,10 @@ =/ mir (clan who) ?- mir %czar who - %king (new-end 3 who) - %duke (new-end 4 who) - %earl (new-end 5 who) - %pawn (new-end 4 who) + %king (end 3 who) + %duke (end 4 who) + %earl (end 5 who) + %pawn (end 4 who) == -- |% @@ -8337,7 +8337,7 @@ ++ address-from-pub =, keccak:crypto |= pub=@ - %+ new-end [3 20] + %+ end [3 20] %+ keccak-256 64 (rev 3 64 pub) :: @@ -8664,7 +8664,7 @@ |* [rex=@t tys=(list etyp)] =- (decode-arguments - tys) %^ rut 9 - (new-rsh [3 2] rex) + (rsh [3 2] rex) (curr rash hex) :: ++ decode-arguments @@ -8734,7 +8734,7 @@ ^- octs :: parse {bys} bytes from {fro}. :- bys - %+ new-rsh + %+ rsh :- 3 =+ (mod bys 32) ?:(=(0 -) - (sub 32 -)) @@ -9190,7 +9190,7 @@ :: ++ hex-to-num |= a=@t - (rash (new-rsh [3 2] a) hex) + (rash (rsh [3 2] a) hex) -- :: :: |jstd: json standard library @@ -9372,7 +9372,7 @@ %+ turn u.res |= [id=@t result=@t] ^- [who=ship point:azimuth-types] - =/ who `@p`(slav %ud (new-rsh [3 4] id)) + =/ who `@p`(slav %ud (rsh [3 4] id)) :- who %+ point-from-eth who @@ -9432,7 +9432,7 @@ %+ turn u.res |= [id=@t result=@t] ^- (pair @ud ^turf) - :- (slav %ud (new-rsh [3 5] id)) + :- (slav %ud (rsh [3 5] id)) =/ dom=tape (decode-results result [%string]~) =/ hot=host:eyre diff --git a/pkg/arvo/ted/aqua/eyre-azimuth.hoon b/pkg/arvo/ted/aqua/eyre-azimuth.hoon index ba4fc65c1d..1c9768df15 100644 --- a/pkg/arvo/ted/aqua/eyre-azimuth.hoon +++ b/pkg/arvo/ted/aqua/eyre-azimuth.hoon @@ -426,8 +426,8 @@ :: ++ get-public |= [who=@p lyfe=life typ=?(%auth %crypt)] - =/ bod (new-rsh 3 pub:ex:(get-keys who lyfe)) - =+ [enc=(new-rsh 8 bod) aut=(new-end 8 bod)] + =/ bod (rsh 3 pub:ex:(get-keys who lyfe)) + =+ [enc=(rsh 8 bod) aut=(end 8 bod)] ?: =(%auth typ) aut enc diff --git a/pkg/arvo/ted/eth/send-txs.hoon b/pkg/arvo/ted/eth/send-txs.hoon index ef7e29f628..8dd3530f1d 100644 --- a/pkg/arvo/ted/eth/send-txs.hoon +++ b/pkg/arvo/ted/eth/send-txs.hoon @@ -25,7 +25,7 @@ %+ request-batch-rpc-loose:ethio url %+ turn (scag step-size txs) |= tx=@ux - :- `(scot %ux (new-end [3 10] tx)) + :- `(scot %ux (end [3 10] tx)) [%eth-send-raw-transaction tx] :: parse tx hashes out of responses, bailing on submission failure :: @@ -42,9 +42,9 @@ == :: %error - ?: ?| =('known transaction' (new-end [3 17] message.res)) - =('Known transaction' (new-end [3 17] message.res)) - =('Transaction with the same ' (new-end [3 26] message.res)) + ?: ?| =('known transaction' (end [3 17] message.res)) + =('Known transaction' (end [3 17] message.res)) + =('Transaction with the same ' (end [3 26] message.res)) == ~& [%sent-a-known-transaction--skipping id.res] $(responses t.responses) diff --git a/pkg/arvo/ted/test.hoon b/pkg/arvo/ted/test.hoon index b4abd3af93..cd59ef968f 100644 --- a/pkg/arvo/ted/test.hoon +++ b/pkg/arvo/ted/test.hoon @@ -71,7 +71,7 @@ :: ++ has-test-prefix |= a=term ^- ? - =((new-end [3 5] a) 'test-') + =((end [3 5] a) 'test-') :: ++ find-test-files =| fiz=(set [=beam test=(unit term)]) diff --git a/pkg/arvo/tests/sys/zuse/crypto/ripemd.hoon b/pkg/arvo/tests/sys/zuse/crypto/ripemd.hoon index 5dc1f6e190..6ff8b854e8 100644 --- a/pkg/arvo/tests/sys/zuse/crypto/ripemd.hoon +++ b/pkg/arvo/tests/sys/zuse/crypto/ripemd.hoon @@ -20,7 +20,7 @@ %+ category :: only first 100 chars, meme happens for super long values :: - (trip (new-end [3 100] msg)) + (trip (end [3 100] msg)) %+ expect-eq !> out.i.ves !> `@ux`(ripemd-160 wid (rev 3 wid msg)) From 3248e8eeb1bd6b51374383acf03a8ed4172b01a4 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 2 Dec 2020 00:59:29 -0800 Subject: [PATCH 870/933] pill: solid/ivory --- bin/ivory.pill | 4 ++-- bin/solid.pill | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/ivory.pill b/bin/ivory.pill index a6240f8ece..0d68c9204c 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b867fe922a2d08b7086aa4e4410f8226131799df100f95beb9ecd194732f2c7d -size 2414162 +oid sha256:3eaf1adbd6908b9d0cd653f62baf329bad4b738794bca20c74e8be33c3b8382c +size 2514048 diff --git a/bin/solid.pill b/bin/solid.pill index ec320ab798..467669b89f 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8a105bc02c193108fc51caade9de5fbf7b5c373419d9ded5e8e38d09c434503f -size 6997944 +oid sha256:437d6a5556f0149b3f1f8dea670cf3c6b51bfb7b1cb166c02cff9bd8e67512d0 +size 7094031 From 28d4cd3e549faa799075ad43005d0e69a9e8a39e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 2 Dec 2020 00:56:06 -0800 Subject: [PATCH 871/933] u3: removes +new-end, +new-lsh, and +new-rsh jet declarations --- pkg/urbit/jets/tree.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index 62e0f48c72..c3d6d680a6 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -1845,11 +1845,9 @@ static u3j_core _141_two_d[] = { "dor", 7, _141_two_dor_a, 0, _141_two_dor_ha }, { "dvr", 7, _141_two_dvr_a, 0, _141_two_dvr_ha }, { "end", 7, _141_two_end_a, 0, _141_two_end_ha }, - { "new-end", 7, _141_two_end_a, 0, _141_two_end_ha }, { "gor", 7, _141_two_gor_a, 0, _141_two_gor_ha }, { "jam", 7, _141_two_jam_a, 0, _141_two_jam_ha }, { "lsh", 7, _141_two_lsh_a, 0, _141_two_lsh_ha }, - { "new-lsh", 7, _141_two_lsh_a, 0, _141_two_lsh_ha }, { "mas", 7, _141_two_mas_a, 0, _141_two_mas_ha }, { "mat", 7, _141_two_mat_a, 0, _141_two_mat_ha }, { "met", 7, _141_two_met_a, 0, _141_two_met_ha }, @@ -1862,7 +1860,6 @@ static u3j_core _141_two_d[] = { "rev", 7, _141_two_rev_a, 0, _141_two_rev_ha }, { "rip", 7, _141_two_rip_a, 0, _141_two_rip_ha }, { "rsh", 7, _141_two_rsh_a, 0, _141_two_rsh_ha }, - { "new-rsh", 7, _141_two_rsh_a, 0, _141_two_rsh_ha }, { "swp", 7, _141_two_swp_a, 0, _141_two_swp_ha }, { "rub", 7, _141_two_rub_a, 0, _141_two_rub_ha }, { "peg", 7, _141_two_peg_a, 0, _141_two_peg_ha }, From 0e3941f146b9e285b92a404047e5ec5800dc3aa7 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 2 Dec 2020 01:20:49 -0800 Subject: [PATCH 872/933] hoon: updates +fil to bloq-truncate the repeated atom --- pkg/arvo/sys/hoon.hoon | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 70c4a4d961..86de2f0824 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -863,8 +863,9 @@ ++ fil :: fill bloqstream ~/ %fil |= [a=bloq b=step c=@] - =+ n=0 - =+ d=c + =| n=@ud + =. c (end a c) + =/ d c |- ^- @ ?: =(n b) (rsh a d) From fa0680d2012a337e618970129433ae84b9355112 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 30 Nov 2020 14:29:18 -0800 Subject: [PATCH 873/933] hoon: updates +rap comment, removes jet-match hack --- pkg/arvo/sys/hoon.hoon | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 86de2f0824..9be10a6dc1 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -886,11 +886,10 @@ ?: =(0 b) c $(b (rsh a b), c +(c)) :: -++ rap :: assemble nonzero +++ rap :: assemble variable ~/ %rap |= [a=bloq b=(list @)] ^- @ - =+ ~ ::REMOVEME jet dashboard bump ?~ b 0 (cat a i.b $(b t.b)) :: From 13f49d42e17d8b877e29fa27b0d833ca5aad8c5a Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Wed, 2 Dec 2020 01:32:25 -0800 Subject: [PATCH 874/933] chat-hook: fix poke-import issue --- pkg/arvo/app/chat-hook.hoon | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/arvo/app/chat-hook.hoon b/pkg/arvo/app/chat-hook.hoon index cfeb069ee0..cbc70f991d 100644 --- a/pkg/arvo/app/chat-hook.hoon +++ b/pkg/arvo/app/chat-hook.hoon @@ -706,9 +706,9 @@ ^- (quip card _state) =/ sty=state-10 :* %10 - (remake-map ;;((tree [path ship]) -.arc)) - ;;(? +<.arc) - (remake-map ;;((tree [path ?]) +>.arc)) + (remake-map ;;((tree [path ship]) +<.arc)) + ;;(? +<-.arc) + (remake-map ;;((tree [path ?]) +>+.arc)) == :_ sty %+ turn ~(tap by synced.sty) From 1ea59bbad33a27f61fcd380ee534e5cfc532a24b Mon Sep 17 00:00:00 2001 From: fang Date: Tue, 1 Dec 2020 19:32:29 +0100 Subject: [PATCH 875/933] webterm: update mar and js to support 24-bit color --- pkg/arvo/mar/blit.hoon | 13 +++++++++---- .../src/views/apps/term/components/line.js | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pkg/arvo/mar/blit.hoon b/pkg/arvo/mar/blit.hoon index 242678ea31..f8f1e5bf5a 100644 --- a/pkg/arvo/mar/blit.hoon +++ b/pkg/arvo/mar/blit.hoon @@ -48,10 +48,15 @@ :: :- 'stye' %- pairs - :~ 'back'^[?~(. ~ s+.)]:p.q.stye - 'fore'^[?~(. ~ s+.)]:q.q.stye - 'deco'^a+(turn ~(tap in p.stye) |=(d=deco ?~(d ~ s+d))) - == + |^ :~ 'back'^(color p.q.stye) + 'fore'^(color q.q.stye) + 'deco'^a+(turn ~(tap in p.stye) |=(d=deco ?~(d ~ s+d))) + == + ++ color + |= =tint + ?@ tint ?~(tint ~ s+tint) + s+(crip ((x-co:co 6) (rep 3 ~[b g r]:tint))) + -- == == -- diff --git a/pkg/interface/src/views/apps/term/components/line.js b/pkg/interface/src/views/apps/term/components/line.js index deff862a12..151b96639b 100644 --- a/pkg/interface/src/views/apps/term/components/line.js +++ b/pkg/interface/src/views/apps/term/components/line.js @@ -31,7 +31,7 @@ export default React.memo(({line}) => { case 'y': prop.color = 'yellow'; break; case 'k': prop.color = 'black'; break; case 'w': prop.color = 'white'; break; - default: console.log('weird fore', part.stye.fore); + default: prop.color = '#' + part.stye.fore; } switch (part.stye.back) { case null: break; @@ -43,7 +43,7 @@ export default React.memo(({line}) => { case 'y': prop.backgroundColor = 'yellow'; break; case 'k': prop.backgroundColor = 'black'; break; case 'w': prop.backgroundColor = 'white'; break; - default: console.log('weird back', part.stye.back); + default: prop.backgroundColor = '#' + part.stye.back; } if (Object.keys(prop).length === 0) { From 270a2ab52869ce2079dc3e79b67d04c55e06ea46 Mon Sep 17 00:00:00 2001 From: fang Date: Tue, 1 Dec 2020 19:33:12 +0100 Subject: [PATCH 876/933] vere: support 24-bit %klr colors --- pkg/urbit/vere/io/term.c | 91 +++++++++++++++++++++++++++++++--------- 1 file changed, 71 insertions(+), 20 deletions(-) diff --git a/pkg/urbit/vere/io/term.c b/pkg/urbit/vere/io/term.c index 937ccf156c..7780494e7f 100644 --- a/pkg/urbit/vere/io/term.c +++ b/pkg/urbit/vere/io/term.c @@ -1128,23 +1128,72 @@ u3_term_ef_ctlc(void) _term_it_refresh_line(uty_u); } +/* _term_it_put_value(): put numeric color value on lin_w. +*/ +static c3_w +_term_it_put_value(c3_w* lin_w, + u3_atom val) +{ + u3_atom ren = u3dc("scot", c3__ud, (val % 256)); + c3_w len = u3r_met(3, ren); + for ( c3_w i_w = 0; i_w < len; i_w++ ) { + lin_w[i_w] = u3r_byte(i_w, ren); + } + u3z(val); + return len; +} + /* _term_it_put_tint(): put ansi color id on lin_w. RETAINS col. */ -static void -_term_it_put_tint(c3_w* lin_w, +static c3_w +_term_it_put_tint(c3_w* lin_w, u3_noun col) { - switch ( col ) { - default: - case u3_nul: *lin_w = '9'; break; - case 'k': *lin_w = '0'; break; - case 'r': *lin_w = '1'; break; - case 'g': *lin_w = '2'; break; - case 'y': *lin_w = '3'; break; - case 'b': *lin_w = '4'; break; - case 'm': *lin_w = '5'; break; - case 'c': *lin_w = '6'; break; - case 'w': *lin_w = '7'; break; + u3_noun red, gre, blu; + c3_o tru = u3r_trel(col, &red, &gre, &blu); + + // 24-bit color + // + if ( c3y == tru ) { + c3_w n = 0; + + *lin_w++ = '8'; + *lin_w++ = ';'; + *lin_w++ = '2'; + *lin_w++ = ';'; + + c3_w m = _term_it_put_value(lin_w, red); + n += m; + lin_w += m; + + *lin_w++ = ';'; + + m = _term_it_put_value(lin_w, gre); + n += m; + lin_w += m; + + *lin_w++ = ';'; + + n += _term_it_put_value(lin_w, blu); + + return n + 6; + } + // standard color + // + else { + switch ( col ) { + default: + case u3_nul: *lin_w = '9'; break; + case 'k': *lin_w = '0'; break; + case 'r': *lin_w = '1'; break; + case 'g': *lin_w = '2'; break; + case 'y': *lin_w = '3'; break; + case 'b': *lin_w = '4'; break; + case 'm': *lin_w = '5'; break; + case 'c': *lin_w = '6'; break; + case 'w': *lin_w = '7'; break; + } + return 1; } } @@ -1185,11 +1234,11 @@ _term_it_show_stub(u3_utty* uty_u, // allocate enough memory for every display character, plus styles // - //NOTE we use max 20 characters per styl for escape codes: - // 3 for opening, 4 for decorations, 4 for colors, 4 for closing, + //NOTE we use max 31 characters per styl for escape codes: + // 3 for opening, 4 for decorations, 15 for colors, 4 for closing, // and 5 as separators between decorations and colors. // - c3_w* lin_w = c3_malloc( sizeof(c3_w) * (lec_w + (20 * tuc_w)) ); + c3_w* lin_w = c3_malloc( sizeof(c3_w) * (lec_w + (31 * tuc_w)) ); // write the contents to the buffer, // tracking total and escape characters written @@ -1243,8 +1292,9 @@ _term_it_show_stub(u3_utty* uty_u, sap_w++; } lin_w[i_w++] = '4'; - _term_it_put_tint(&lin_w[i_w++], bag); - sap_w += 2; + c3_w put_w = _term_it_put_tint(&lin_w[i_w], bag); + i_w += put_w; + sap_w += ++put_w; mor_o = c3y; } @@ -1256,8 +1306,9 @@ _term_it_show_stub(u3_utty* uty_u, sap_w++; } lin_w[i_w++] = '3'; - _term_it_put_tint(&lin_w[i_w++], fog); - sap_w += 2; + c3_w put_w = _term_it_put_tint(&lin_w[i_w], fog); + i_w += put_w; + sap_w += ++put_w; mor_o = c3y; } From 7fa7716ab076f41aba9daa96f527a5f29144139b Mon Sep 17 00:00:00 2001 From: fang Date: Tue, 1 Dec 2020 20:53:57 +0100 Subject: [PATCH 877/933] kh: support 24-bit %klr colors --- pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs | 22 ++++++++++-------- pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs | 27 ++++++++++++---------- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs b/pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs index b6a2bd1747..f9d8510095 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs @@ -144,6 +144,7 @@ data Tint | TintK | TintW | TintNull + | TintTrue Atom Atom Atom deriving (Eq, Ord, Show) data Stye = Stye @@ -174,19 +175,22 @@ instance FromNoun Deco where instance ToNoun Tint where toNoun = \case - TintR -> toNoun $ Cord "r" - TintG -> toNoun $ Cord "g" - TintB -> toNoun $ Cord "b" - TintC -> toNoun $ Cord "c" - TintM -> toNoun $ Cord "m" - TintY -> toNoun $ Cord "y" - TintK -> toNoun $ Cord "k" - TintW -> toNoun $ Cord "w" - TintNull -> Atom 0 + TintR -> toNoun $ Cord "r" + TintG -> toNoun $ Cord "g" + TintB -> toNoun $ Cord "b" + TintC -> toNoun $ Cord "c" + TintM -> toNoun $ Cord "m" + TintY -> toNoun $ Cord "y" + TintK -> toNoun $ Cord "k" + TintW -> toNoun $ Cord "w" + TintNull -> Atom 0 + TintTrue r g b -> Cell (Atom r) $ Cell (Atom g) (Atom b) instance FromNoun Tint where parseNoun = named "Tint" . \case Atom 0 -> pure TintNull + Cell (Atom r) (Cell (Atom g) (Atom b)) + -> pure (TintTrue r g b) n -> parseNoun @Cord n <&> unCord >>= \case "r" -> pure TintR "g" -> pure TintG diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs index a5ab80b92e..da43f289cb 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs @@ -391,17 +391,20 @@ localClient doneSignal = fst <$> mkRAcquire start stop DecoBl -> '5' DecoNull -> '0' - termRenderTint :: Tint -> Char + termRenderTint :: Tint -> [Char] termRenderTint = \case - TintK -> '0' - TintR -> '1' - TintG -> '2' - TintY -> '3' - TintB -> '4' - TintM -> '5' - TintC -> '6' - TintW -> '7' - TintNull -> '9' + TintK -> ['0'] + TintR -> ['1'] + TintG -> ['2'] + TintY -> ['3'] + TintB -> ['4'] + TintM -> ['5'] + TintC -> ['6'] + TintW -> ['7'] + TintNull -> ['9'] + TintTrue r g b -> + mconcat ["8;2;", bite r, ";", bite g, ";", bite b] + where bite = show . flip mod 256 -- Wraps the appropriate escape sequence around a piece of styled text termRenderStubSegment :: Stye -> [Char] -> [Char] @@ -417,10 +420,10 @@ localClient doneSignal = fst <$> mkRAcquire start stop [ intersperse ';' $ fmap termRenderDeco $ toList decoset , case back of TintNull -> [] - tint -> ['4', termRenderTint tint] + tint -> cons '4' $ termRenderTint tint , case fore of TintNull -> [] - tint -> ['3', termRenderTint tint] + tint -> cons '3' $ termRenderTint tint ] styled = mconcat [escape, styles, "m", tape, escape, "0m"] From 07285a9147908ceab005b6c3c61175e60c5c9b21 Mon Sep 17 00:00:00 2001 From: fang Date: Tue, 1 Dec 2020 21:39:47 +0100 Subject: [PATCH 878/933] vere: avoid +scot call for color value rendering --- pkg/urbit/vere/io/term.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/urbit/vere/io/term.c b/pkg/urbit/vere/io/term.c index 7780494e7f..00968357d1 100644 --- a/pkg/urbit/vere/io/term.c +++ b/pkg/urbit/vere/io/term.c @@ -1134,10 +1134,10 @@ static c3_w _term_it_put_value(c3_w* lin_w, u3_atom val) { - u3_atom ren = u3dc("scot", c3__ud, (val % 256)); - c3_w len = u3r_met(3, ren); + c3_c str_c[4]; + c3_w len = snprintf(str_c, 4, "%d", val % 256); for ( c3_w i_w = 0; i_w < len; i_w++ ) { - lin_w[i_w] = u3r_byte(i_w, ren); + lin_w[i_w] = str_c[i_w]; } u3z(val); return len; From 8758ae9f7a694bf1f6cdc8f88ce6a94cca4ed41f Mon Sep 17 00:00:00 2001 From: fang Date: Wed, 2 Dec 2020 17:43:22 +0100 Subject: [PATCH 879/933] webterm: improve line-spacing in certain browsers Lines had a sub-pixel gap between them in Firefox browsers. Using display='flex' resolves that, somehow. --- pkg/interface/src/views/apps/term/components/line.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/interface/src/views/apps/term/components/line.js b/pkg/interface/src/views/apps/term/components/line.js index 151b96639b..cbf817f282 100644 --- a/pkg/interface/src/views/apps/term/components/line.js +++ b/pkg/interface/src/views/apps/term/components/line.js @@ -59,7 +59,7 @@ export default React.memo(({line}) => { // render line // return ( - {text} From ed016c97aad74475d785b5cc7332d7432aea8437 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 2 Dec 2020 10:13:59 -0800 Subject: [PATCH 880/933] pill: solid --- bin/solid.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index 467669b89f..c82cd9b4f6 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:437d6a5556f0149b3f1f8dea670cf3c6b51bfb7b1cb166c02cff9bd8e67512d0 -size 7094031 +oid sha256:ec3b1bb741e14fabacf567c3ffaf3e3a0c473cba91f46e40b04613d588988cf3 +size 7217780 From 1913cdf4f1ce0a615e0faf4c20f5a565a37caae7 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Wed, 2 Dec 2020 13:31:11 -0600 Subject: [PATCH 881/933] arvo: remove unused app files, libraries, and imports --- pkg/arvo/app/chat-cli.hoon | 2 +- pkg/arvo/app/chat-hook.hoon | 88 +-- pkg/arvo/app/chat-view.hoon | 27 +- pkg/arvo/app/contact-hook.hoon | 3 +- pkg/arvo/app/contact-view.hoon | 17 - pkg/arvo/app/group-hook.hoon | 114 --- pkg/arvo/app/group-pull-hook.hoon | 2 +- pkg/arvo/app/group-push-hook.hoon | 2 +- pkg/arvo/app/group-store.hoon | 92 +-- pkg/arvo/app/link-listen-hook.hoon | 52 -- pkg/arvo/app/link-proxy-hook.hoon | 46 -- pkg/arvo/app/link-store.hoon | 148 ---- pkg/arvo/app/link-view.hoon | 39 - pkg/arvo/app/permission-group-hook.hoon | 26 - pkg/arvo/app/permission-hook.hoon | 26 - pkg/arvo/app/permission-store.hoon | 36 - pkg/arvo/app/publish.hoon | 691 ------------------ pkg/arvo/app/soto.hoon | 4 - pkg/arvo/gen/group-hook/add.hoon | 10 - pkg/arvo/gen/group-hook/remove.hoon | 10 - pkg/arvo/gen/link-store/note.hoon | 10 - pkg/arvo/gen/link-store/save.hoon | 10 - pkg/arvo/lib/group.hoon | 2 +- pkg/arvo/lib/hood/drum.hoon | 15 +- pkg/arvo/lib/link-store.hoon | 204 ------ pkg/arvo/lib/metadata.hoon | 15 - pkg/arvo/lib/permission-json.hoon | 103 --- pkg/arvo/lib/soto.hoon | 99 --- pkg/arvo/mar/group/hook-action.hoon | 30 - pkg/arvo/mar/link/action.hoon | 17 - pkg/arvo/mar/link/initial.hoon | 15 - pkg/arvo/mar/link/listen-action.hoon | 22 - pkg/arvo/mar/link/listen-poke.hoon | 13 - pkg/arvo/mar/link/listen-update.hoon | 24 - pkg/arvo/mar/link/update.hoon | 15 - pkg/arvo/mar/link/view-action.hoon | 42 -- pkg/arvo/mar/permission/action.hoon | 62 -- .../mar/permission/group-hook-action.hoon | 16 - pkg/arvo/mar/permission/hook-action.hoon | 12 - pkg/arvo/mar/permission/update.hoon | 15 - pkg/arvo/mar/publish/action.hoon | 20 - pkg/arvo/mar/publish/comment.hoon | 65 -- pkg/arvo/mar/publish/info.hoon | 58 -- pkg/arvo/mar/publish/notebook-delta.hoon | 18 - pkg/arvo/mar/publish/primary-delta.hoon | 17 - pkg/arvo/sur/group-hook.hoon | 16 - pkg/arvo/sur/link-listen-hook.hoon | 17 - pkg/arvo/sur/link-store.hoon | 50 -- pkg/arvo/sur/link-view.hoon | 34 - pkg/arvo/sur/link.hoon | 49 -- pkg/arvo/sur/permission-group-hook.hoon | 17 - pkg/arvo/sur/permission-hook.hoon | 15 - pkg/arvo/sur/permission-store.hoon | 28 - pkg/arvo/sur/publish.hoon | 146 ---- pkg/arvo/ted/ph/group-rejoin.hoon | 4 - 55 files changed, 15 insertions(+), 2715 deletions(-) delete mode 100644 pkg/arvo/app/group-hook.hoon delete mode 100644 pkg/arvo/app/link-listen-hook.hoon delete mode 100644 pkg/arvo/app/link-proxy-hook.hoon delete mode 100644 pkg/arvo/app/link-store.hoon delete mode 100644 pkg/arvo/app/link-view.hoon delete mode 100644 pkg/arvo/app/permission-group-hook.hoon delete mode 100644 pkg/arvo/app/permission-hook.hoon delete mode 100644 pkg/arvo/app/permission-store.hoon delete mode 100644 pkg/arvo/app/publish.hoon delete mode 100644 pkg/arvo/app/soto.hoon delete mode 100644 pkg/arvo/gen/group-hook/add.hoon delete mode 100644 pkg/arvo/gen/group-hook/remove.hoon delete mode 100644 pkg/arvo/gen/link-store/note.hoon delete mode 100644 pkg/arvo/gen/link-store/save.hoon delete mode 100644 pkg/arvo/lib/link-store.hoon delete mode 100644 pkg/arvo/lib/permission-json.hoon delete mode 100644 pkg/arvo/lib/soto.hoon delete mode 100644 pkg/arvo/mar/group/hook-action.hoon delete mode 100644 pkg/arvo/mar/link/action.hoon delete mode 100644 pkg/arvo/mar/link/initial.hoon delete mode 100644 pkg/arvo/mar/link/listen-action.hoon delete mode 100644 pkg/arvo/mar/link/listen-poke.hoon delete mode 100644 pkg/arvo/mar/link/listen-update.hoon delete mode 100644 pkg/arvo/mar/link/update.hoon delete mode 100644 pkg/arvo/mar/link/view-action.hoon delete mode 100644 pkg/arvo/mar/permission/action.hoon delete mode 100644 pkg/arvo/mar/permission/group-hook-action.hoon delete mode 100644 pkg/arvo/mar/permission/hook-action.hoon delete mode 100644 pkg/arvo/mar/permission/update.hoon delete mode 100644 pkg/arvo/mar/publish/action.hoon delete mode 100644 pkg/arvo/mar/publish/comment.hoon delete mode 100644 pkg/arvo/mar/publish/info.hoon delete mode 100644 pkg/arvo/mar/publish/notebook-delta.hoon delete mode 100644 pkg/arvo/mar/publish/primary-delta.hoon delete mode 100644 pkg/arvo/sur/group-hook.hoon delete mode 100644 pkg/arvo/sur/link-listen-hook.hoon delete mode 100644 pkg/arvo/sur/link-store.hoon delete mode 100644 pkg/arvo/sur/link-view.hoon delete mode 100644 pkg/arvo/sur/link.hoon delete mode 100644 pkg/arvo/sur/permission-group-hook.hoon delete mode 100644 pkg/arvo/sur/permission-hook.hoon delete mode 100644 pkg/arvo/sur/permission-store.hoon delete mode 100644 pkg/arvo/sur/publish.hoon diff --git a/pkg/arvo/app/chat-cli.hoon b/pkg/arvo/app/chat-cli.hoon index 830424815f..eb0a6e7edd 100644 --- a/pkg/arvo/app/chat-cli.hoon +++ b/pkg/arvo/app/chat-cli.hoon @@ -10,7 +10,7 @@ :: and trust it to take care of the rest. :: /- view=chat-view, hook=chat-hook, *group, - *permission-store, *group-store, inv=invite-store, + *group-store, inv=invite-store, sole /+ shoe, default-agent, verb, dbug, store=chat-store, group-store, grpl=group, resource diff --git a/pkg/arvo/app/chat-hook.hoon b/pkg/arvo/app/chat-hook.hoon index 340d1e6c14..66024b7e41 100644 --- a/pkg/arvo/app/chat-hook.hoon +++ b/pkg/arvo/app/chat-hook.hoon @@ -1,12 +1,8 @@ :: chat-hook [landscape]: -:: mirror chat data from foreign to local based on read permissions +:: mirror chat data from foreign to local based on read :: allow sending chat messages to foreign paths based on write perms :: -/- *permission-store, inv=invite-store, *metadata-store, - *permission-hook, *group-store, *permission-group-hook, ::TMP for upgrade - hook=chat-hook, - view=chat-view, - *group +/- inv=invite-store, *metadata-store, *group-store, hook=chat-hook, view=chat-view, *group /+ default-agent, verb, dbug, store=chat-store, group-store, grpl=group, resource ~% %chat-hook-top ..is ~ @@ -51,7 +47,6 @@ :: +$ poke $% [%chat-action action:store] - [%permission-action permission-action] [%invite-action action:inv] [%chat-view-action action:view] == @@ -119,7 +114,6 @@ =. cards %+ weld cards :~ watch-groups:cc - [%pass /permissions %agent [our.bol %permission-store] %leave ~] == =^ new-cards=(list card) old =| crds=(list card) @@ -223,15 +217,12 @@ ^- (list card) =/ host=ship (slav %p (snag 0 old-chat)) =/ new-chat [%'~' old-chat] - =/ newp=permission (unify-permissions old-chat) =/ old-group=path [%chat old-chat] %- zing :~ :~ (delete-group host (snoc old-group %read)) (delete-group host (snoc old-group %write)) == :: - (create-group new-chat who.newp) - (hookup-group new-chat kind.newp) [(record-group new-chat new-chat)]~ (recreate-chat host old-chat new-chat) == @@ -253,38 +244,6 @@ [%add-synced host new-chat %.y] == :: - ++ unify-permissions - |= chat=path - ^- permission - =/ read=(unit permission) (get-permission chat %read) - =/ write=(unit permission) (get-permission chat %write) - ?. &(?=(^ read) ?=(^ write)) - ~& [%missing-permission chat read=?=(~ read) write=?=(~ write)] - [%white [(slav %p (snag 0 chat)) ~ ~]] - ?+ [kind.u.read kind.u.write] !! - :: village: exclusive to writers - :: - [%white %white] [%white who.u.write] - :: - :: channel: merge blacklists - :: - [%black %black] [%black (~(uni in who.u.read) who.u.write)] - :: - :: journal: exclusive to writers - :: - [%black %white] [%white who.u.write] - :: - :: mailbox: exclusive to readers - :: - [%white %black] [%white who.u.read] - == - :: - ++ get-permission - |= [chat=path what=?(%read %write)] - %^ scry:cc (unit permission) - %permission-store - [%permission %chat (snoc chat what)] - :: ++ make-poke |= [app=term =mark =vase] ^- card @@ -293,19 +252,10 @@ ++ delete-group |= [host=ship group=path] ^- card - :: if we host the group, delete it directly - :: - ?: =(our.bol host) - %^ make-poke %group-store - %group-action - !> ^- action:group-store - [%remove-group (de-path:resource group) ~] - :: else, just delete the sync in the hook - :: - %^ make-poke %permission-hook - %permission-hook-action - !> ^- permission-hook-action - [%remove group] + %^ make-poke %group-store + %group-action + !> ^- action:group-store + [%remove-group (de-path:resource group) ~] :: ++ create-group |= [group=path who=(set ship)] @@ -323,23 +273,6 @@ [%add-members rid who] == :: - ++ hookup-group - |= [group=path =kind] - ^- (list card) - :* %^ make-poke %permission-group-hook - %permission-group-hook-action - !> ^- permission-group-hook-action - [%associate group [group^kind ~ ~]] - :: - =/ =ship (slav %p (snag 1 group)) - ?. =(our.bol ship) ~ - :_ ~ - %^ make-poke %permission-hook - %permission-hook-action - !> ^- permission-hook-action - [%add-owned group group] - == - :: ++ record-group |= [group=path chat=path] ^- card @@ -830,10 +763,6 @@ ++ kick |= wir=wire ^- (quip card _state) - ?: =(wir /permissions) - :_ state - [%pass /permissions %agent [our.bol %permission-store] %watch /updates]~ - :: ?+ wir !! [%groups ~] [~[watch-groups] state] :: @@ -926,11 +855,6 @@ ^- card [%pass / %agent [our.bol %invite-store] %poke %invite-action !>(action)] :: -++ sec-to-perm - |= [pax=path =kind] - ^- permission-action - [%create pax kind *(set ship)] -:: ++ chat-scry |= pax=path ^- (unit mailbox:store) diff --git a/pkg/arvo/app/chat-view.hoon b/pkg/arvo/app/chat-view.hoon index 648f42082b..5f94fecf10 100644 --- a/pkg/arvo/app/chat-view.hoon +++ b/pkg/arvo/app/chat-view.hoon @@ -3,13 +3,9 @@ :: sets up chat JS client, paginates data, and combines commands :: into semantic actions for the UI :: -/- *permission-store, - *permission-hook, - *group, +/- *group, inv=invite-store, *metadata-store, - group-hook, - *permission-group-hook, *chat-hook, *metadata-hook, hook=chat-hook, @@ -37,8 +33,6 @@ $% [%chat-action action:store] [%group-action action:group-store] [%chat-hook-action action:hook] - [%permission-hook-action permission-hook-action] - [%permission-group-hook-action permission-group-hook-action] == :: +$ card card:agent:gall @@ -518,30 +512,11 @@ ^- card [%pass / %agent [entity.resource.act %group-push-hook] %poke %group-update !>(act)] :: -++ permission-poke - |= act=permission-action - ^- card - [%pass / %agent [our.bol %permission-store] %poke %permission-action !>(act)] -:: ++ chat-hook-poke |= act=action:hook ^- card [%pass / %agent [our.bol %chat-hook] %poke %chat-hook-action !>(act)] :: -++ permission-hook-poke - |= act=permission-hook-action - ^- card - :* %pass / %agent [our.bol %permission-hook] - %poke %permission-hook-action !>(act) - == -:: -++ perm-group-hook-poke - |= act=permission-group-hook-action - ^- card - :* %pass / %agent [our.bol %permission-group-hook] - %poke %permission-group-hook-action !>(act) - == -:: ++ metadata-hook-poke |= act=metadata-hook-action ^- card diff --git a/pkg/arvo/app/contact-hook.hoon b/pkg/arvo/app/contact-hook.hoon index 0871201839..5368c162c1 100644 --- a/pkg/arvo/app/contact-hook.hoon +++ b/pkg/arvo/app/contact-hook.hoon @@ -1,8 +1,7 @@ :: contact-hook [landscape] :: :: -/- group-hook, - *contact-hook, +/- *contact-hook, *contact-view, inv=invite-store, *metadata-hook, diff --git a/pkg/arvo/app/contact-view.hoon b/pkg/arvo/app/contact-view.hoon index 2abbbb0f67..dd186cab26 100644 --- a/pkg/arvo/app/contact-view.hoon +++ b/pkg/arvo/app/contact-view.hoon @@ -4,13 +4,10 @@ :: into semantic actions for the UI :: /- - group-hook, inv=invite-store, *contact-hook, *metadata-store, *metadata-hook, - *permission-group-hook, - *permission-hook, pull-hook, push-hook /+ *server, *contact-json, default-agent, dbug, verb, @@ -324,20 +321,6 @@ ^- card [%pass / %agent [our.bol %metadata-hook] %poke %metadata-hook-action !>(act)] :: -++ perm-group-hook-poke - |= act=permission-group-hook-action - ^- card - :* %pass / %agent [our.bol %permission-group-hook] - %poke %permission-group-hook-action !>(act) - == -:: -++ permission-hook-poke - |= act=permission-hook-action - ^- card - :* %pass / %agent [our.bol %permission-hook] - %poke %permission-hook-action !>(act) - == -:: ++ sync-metadata |= [=ship =path] ^- card diff --git a/pkg/arvo/app/group-hook.hoon b/pkg/arvo/app/group-hook.hoon deleted file mode 100644 index 5a29752e35..0000000000 --- a/pkg/arvo/app/group-hook.hoon +++ /dev/null @@ -1,114 +0,0 @@ -:: group-hook [landscape]: -:: -:: allow syncing group data from foreign paths to local paths -:: -/- *group, hook=group-hook, *invite-store -/+ default-agent, verb, dbug, store=group-store, grpl=group, pull-hook, push-hook, resource -~% %group-hook-top ..is ~ -|% -+$ card card:agent:gall -:: -++ versioned-state - $% state-zero - state-one - == -:: -:: -+$ state-zero - $: %0 - synced=(map path ship) - == -:: -+$ state-one - $: %1 - ~ - == -:: --- -:: -=| state-one -=* state - -:: -%- agent:dbug -%+ verb | -^- agent:gall -|_ =bowl:gall -+* this . - group-core +> - gc ~(. group-core bowl) - def ~(. (default-agent this %|) bowl) -:: -++ on-init on-init:def - :: ^- (quip card _this) - :: :_ this - :: ~[watch-store:gc] -++ on-save !>(state) -++ on-load - |= =vase - ^- (quip card _this) - =/ old !<(versioned-state vase) - ?- -.old - %1 [~ this(state old)] - %0 - :_ this(state *state-one) - |^ - %+ murn - ~(tap by synced.old) - |= [=path host=ship] - ^- (unit card) - ?> ?=([@ @ *] path) - :: ignore duplicate publish groups - ?: =(4 (lent path)) - ~& "ignoring: {}" - ~ - =/ pax=^path - ?: =('~' i.path) - t.path - path - =/ rid=resource - ?> ?=([@ @ *] pax) - =/ ship - (slav %p i.pax) - [ship i.t.pax] - ?: =(our.bowl host) - `(add-push rid) - `(add-pull rid host) - :: - ++ poke-our - |= [app=term =cage] - ^- card - [%pass / %agent [our.bowl app] %poke cage] - ++ add-pull - |= [rid=resource host=ship] - ^- card - %+ poke-our - %group-pull-hook - :- %pull-hook-action - !> ^- action:pull-hook - [%add host rid] - :: - ++ add-push - |= rid=resource - ^- card - %+ poke-our - %group-push-hook - :- %push-hook-action - !> ^- action:push-hook - [%add rid] - -- - - == - -:: -++ on-poke on-poke:def -:: -++ on-agent on-agent:def -:: -++ on-watch on-watch:def -:: -++ on-leave on-leave:def - -++ on-peek on-peek:def -++ on-arvo on-arvo:def -++ on-fail on-fail:def --- diff --git a/pkg/arvo/app/group-pull-hook.hoon b/pkg/arvo/app/group-pull-hook.hoon index 4d6da63891..d8d8d961ce 100644 --- a/pkg/arvo/app/group-pull-hook.hoon +++ b/pkg/arvo/app/group-pull-hook.hoon @@ -2,7 +2,7 @@ :: :: allow syncing group data from foreign paths to local paths :: -/- *group, hook=group-hook, *invite-store, *resource +/- *group, *invite-store, *resource /+ default-agent, verb, dbug, store=group-store, grpl=group, pull-hook ~% %group-hook-top ..is ~ |% diff --git a/pkg/arvo/app/group-push-hook.hoon b/pkg/arvo/app/group-push-hook.hoon index 7e5215fa02..f96f4c6101 100644 --- a/pkg/arvo/app/group-push-hook.hoon +++ b/pkg/arvo/app/group-push-hook.hoon @@ -2,7 +2,7 @@ :: :: allow syncing group data from foreign paths to local paths :: -/- *group, hook=group-hook, *invite-store +/- *group, *invite-store /+ default-agent, verb, dbug, store=group-store, grpl=group, push-hook, resource ~% %group-hook-top ..is ~ diff --git a/pkg/arvo/app/group-store.hoon b/pkg/arvo/app/group-store.hoon index 57552866af..e72768e9b3 100644 --- a/pkg/arvo/app/group-store.hoon +++ b/pkg/arvo/app/group-store.hoon @@ -4,7 +4,7 @@ :: :: group-store stores groups of ships, so that resources in other apps can be :: associated with a group. The current model of group-store rolls -:: permissions and invites inside this store for simplicity reasons, although +:: and invites inside this store for simplicity reasons, although :: these should be prised apart in a future revision of group store. :: :: @@ -29,7 +29,7 @@ :: Modify the group. Further documented in /sur/group-store.hoon :: :: -/- *group, permission-store +/- *group /+ store=group-store, default-agent, verb, dbug, resource |% +$ card card:agent:gall @@ -166,8 +166,6 @@ ?> (team:title our.bowl src.bowl) =^ cards state ?+ mark (on-poke:def mark vase) - %noun (poke-noun:gc vase) - :: ?(%group-update %group-action) (poke-group-update:gc !<(update:store vase)) :: @@ -246,92 +244,6 @@ (~(has in ban-ranks.policy) (clan:title ship)) == == -++ poke-noun - |= =vase - ^- (quip card _state) - =/ noun - !<(%perm-upgrade vase) - |^ - =/ perms=(list path) - ~(tap in scry-permissions) - |- - ?~ perms - `state - =* pax i.perms - ?> ?=(^ pax) - ?: |(!=('~' i.pax) =(4 (lent pax))) - $(perms t.perms) - =/ rid=resource - (make-rid t.pax) - =/ perm - (scry-group-permissions pax) - ?~ perm - $(perms t.perms) - ?: (~(has by groups) rid) - %_ $ - perms t.perms - :: - groups - %+ ~(jab by groups) rid - (update-existing u.perm) - == - %_ $ - perms t.perms - :: - groups - %+ ~(put by groups) rid - (add-new u.perm) - == - ++ make-rid - |= =path - ^- resource - ?> ?=([@ @ *] path) - :- (slav %p i.path) - i.t.path - :: - ++ add-new - |= =permission:permission-store - ^- group - ?: ?=(%black kind.permission) - [~ ~ [%open ~ who.permission] %.y] - [who.permission ~ [%invite ~] %.y] - :: - ++ update-existing - |= =permission:permission-store - |= =group - ^+ group - ?: ?=(%black kind.permission) - group - ?> ?=(%invite -.policy.group) - %_ group - members (~(uni in members.group) who.permission) - == - :: - ++ scry-permissions - ^- (set path) - .^ (set path) - %gx - (scot %p our.bol) - %permission-store - (scot %da now.bol) - /keys/noun - == - :: - ++ scry-group-permissions - |= pax=path - ^- (unit permission:permission-store) - .^ (unit permission:permission-store) - %gx - (scot %p our.bol) - %permission-store - (scot %da now.bol) - ;: weld - /permission - pax - /noun - == - == - -- :: ++ poke-group-update |= =update:store diff --git a/pkg/arvo/app/link-listen-hook.hoon b/pkg/arvo/app/link-listen-hook.hoon deleted file mode 100644 index 0d8dc59b44..0000000000 --- a/pkg/arvo/app/link-listen-hook.hoon +++ /dev/null @@ -1,52 +0,0 @@ -:: link-listen-hook: no longer in use -:: -/+ default-agent, verb, dbug -:: -~% %link-listen-hook-top ..is ~ -|% -+$ versioned-state - $% [%0 *] - [%1 *] - [%2 *] - [%3 *] - [%4 ~] - == -+$ card card:agent:gall --- -:: -=| [%4 ~] -=* state - -:: -%- agent:dbug -%+ verb | -^- agent:gall -|_ =bowl:gall -+* this . - def ~(. (default-agent this %|) bowl) -:: -++ on-init [~ this] -++ on-save !>(state) -++ on-load - |= =vase - ^- (quip card _this) - :_ this - :- [%pass /groups %agent [our.bowl %group-store] %leave ~] - %+ turn ~(tap in ~(key by wex.bowl)) - |= [=wire =ship =term] - ^- card - [%pass wire %agent [ship term] %leave ~] -:: -++ on-arvo - |= [=wire =sign-arvo] - ^- (quip card _this) - ?+ sign-arvo (on-arvo:def wire sign-arvo) - [%b *] [~ this] - == -:: -++ on-agent on-agent:def -++ on-poke on-poke:def -++ on-peek on-peek:def -++ on-watch on-watch:def -++ on-leave on-leave:def -++ on-fail on-fail:def --- diff --git a/pkg/arvo/app/link-proxy-hook.hoon b/pkg/arvo/app/link-proxy-hook.hoon deleted file mode 100644 index 9557d0f185..0000000000 --- a/pkg/arvo/app/link-proxy-hook.hoon +++ /dev/null @@ -1,46 +0,0 @@ -:: link-proxy-hook: no longer in use -:: -/+ default-agent, verb, dbug -~% %link-proxy-hook-top ..is ~ -|% -+$ versioned-state - $% [%0 *] - [%1 *] - [%2 ~] - == -:: -+$ card card:agent:gall --- -:: -=| [%2 ~] -=* state - -:: -%- agent:dbug -%+ verb | -^- agent:gall -|_ =bowl:gall -+* this . - def ~(. (default-agent this %&) bowl) -:: -++ on-init on-init:def -++ on-save !>(state) -++ on-load - |= old-vase=vase - ^- (quip card _this) - =/ paths - %+ turn ~(val by sup.bowl) - |=([=ship =path] path) - :_ this - :- [%pass /groups %agent [our.bowl %group-store] %leave ~] - ?~ paths ~ - [%give %kick paths ~]~ -:: -++ on-watch on-watch:def -++ on-leave on-leave:def -++ on-agent on-agent:def -++ on-poke on-poke:def -++ on-peek on-peek:def -++ on-arvo on-arvo:def -++ on-fail on-fail:def --- - diff --git a/pkg/arvo/app/link-store.hoon b/pkg/arvo/app/link-store.hoon deleted file mode 100644 index d653e7748c..0000000000 --- a/pkg/arvo/app/link-store.hoon +++ /dev/null @@ -1,148 +0,0 @@ -:: link [landscape]: -:: -/- *link, gra=graph-store, *resource -/+ store=link-store, graph-store, default-agent, verb, dbug -:: -|% -+$ spore-any $%(spore-1 state-0) -+$ state-any $%(state-1 state-0) -+$ spore-1 [%1 cards=*] -+$ state-1 [%1 cards=(list card)] -+$ state-0 - $: %0 - by-group=(map path links) - by-site=(map site (list [path submission])) - discussions=(per-path-url discussion) - == -:: -+$ links - $: ::NOTE all lists by recency - =submissions - ours=pages - seen=(set url) - == -:: -+$ discussion - $: =comments - ours=notes - == -:: -+$ card card:agent:gall --- -:: -=| state-1 -=* state - -:: -%- agent:dbug -%+ verb | -^- agent:gall -|_ =bowl:gall -+* this . - do ~(. +> bowl) - def ~(. (default-agent this %|) bowl) -:: -++ on-init on-init:def -++ on-save !>(state) -++ on-load - |= old=vase - ^- (quip card _this) - :: - =/ s !<(spore-any old) - ?: ?=(%1 -.s) - [~ this(state s(cards ~))] - :: defer card emission to later event - :: - =; [cards=(list card) that=_this] - :_ that(state [%1 cards]) - [%pass /load %arvo %b %wait now.bowl]~ - :: - :_ this(state *state-1) - =/ orm orm:graph-store - |^ ^- (list card) - %- zing - %+ turn ~(tap by by-group.s) - |= [=path =links] - ^- (list card) - ?. ?=([@ ~] path) - (on-bad-path path links) - =/ =resource [our.bowl i.path] - :_ [(archive-graph resource)]~ - %+ add-graph resource - ^- graph:gra - %+ gas:orm ~ - =/ comments (~(gut by discussions.s) path *(map url discussion)) - %+ turn submissions.links - |= sub=submission - ^- [atom node:gra] - :- time.sub - =/ contents ~[text+title.sub url+url.sub] - =/ parent-hash `@ux`(sham ~ ship.sub time.sub contents) - :- ^- post:gra - :* author=ship.sub - index=~[time.sub] - time-sent=time.sub - contents - hash=`parent-hash - signatures=~ - == - ^- internal-graph:gra - =/ dis (~(get by comments) url.sub) - ?~ dis - [%empty ~] - :- %graph - ^- graph:gra - %+ gas:orm ~ - %+ turn comments.u.dis - |= [=ship =time udon=@t] - ^- [atom node:gra] - :- time - :_ `internal-graph:gra`[%empty ~] - =/ contents ~[text+udon] - :* author=ship - index=~[time.sub time] - time-sent=time - contents - hash=``@ux`(sham `parent-hash ship time contents) - signatures=~ - == - :: - ++ on-bad-path - |= [=path =links] - ^- (list card) - ~& discarding-malformed-links+[path links] - ~ - :: - ++ add-graph - |= [=resource =graph:gra] - ^- card - %- poke-graph-store - [%0 now.bowl %add-graph resource graph `%graph-validator-link %.y] - :: - ++ archive-graph - |= =resource - ^- card - %- poke-graph-store - [%0 now.bowl %archive-graph resource] - :: - ++ poke-graph-store - |= =update:gra - ^- card - :* %pass /migrate-link %agent [our.bowl %graph-store] - %poke %graph-update !>(update) - == - -- -:: -++ on-poke on-poke:def -++ on-peek on-peek:def -++ on-watch on-watch:def -++ on-leave on-leave:def -++ on-agent on-agent:def -++ on-arvo - |= [=wire =sign-arvo] - ^- (quip card _this) - ?+ sign-arvo (on-arvo:def wire sign-arvo) - [%b %wake *] - [cards.state this] - == -++ on-fail on-fail:def --- diff --git a/pkg/arvo/app/link-view.hoon b/pkg/arvo/app/link-view.hoon deleted file mode 100644 index 0850862124..0000000000 --- a/pkg/arvo/app/link-view.hoon +++ /dev/null @@ -1,39 +0,0 @@ -:: link-view: no longer in use -/+ default-agent, verb, dbug -~% %link-view-top ..is ~ -|% -+$ versioned-state - $% [%0 ~] - [%1 ~] - [%2 ~] - == -:: -+$ card card:agent:gall --- -:: -=| [%2 ~] -=* state - -:: -%+ verb | -%- agent:dbug -^- agent:gall -|_ =bowl:gall -+* this . - def ~(. (default-agent this %|) bowl) -:: -++ on-init [~ this] -++ on-save !>(state) -++ on-load - |= old-vase=vase - ^- (quip card _this) - :_ this(state [%2 ~]) - [%pass /connect %arvo %e %disconnect [~ /'~link']]~ -:: -++ on-poke on-poke:def -++ on-watch on-watch:def -++ on-agent on-agent:def -++ on-arvo on-arvo:def -++ on-peek on-peek:def -++ on-leave on-leave:def -++ on-fail on-fail:def --- diff --git a/pkg/arvo/app/permission-group-hook.hoon b/pkg/arvo/app/permission-group-hook.hoon deleted file mode 100644 index 01cddc18d4..0000000000 --- a/pkg/arvo/app/permission-group-hook.hoon +++ /dev/null @@ -1,26 +0,0 @@ -:: permission-group-hook [landscape]: deprecated -:: -/+ default-agent -:: -=| [%1 ~] -=* state - -:: -^- agent:gall -|_ =bowl:gall -+* this . - def ~(. (default-agent this %|) bowl) -:: -++ on-init on-init:def -++ on-save !>(state) -++ on-load - |= old=vase - [~ this] -:: -++ on-poke on-poke:def -++ on-agent on-agent:def -++ on-peek on-peek:def -++ on-watch on-watch:def -++ on-leave on-leave:def -++ on-arvo on-arvo:def -++ on-fail on-fail:def --- diff --git a/pkg/arvo/app/permission-hook.hoon b/pkg/arvo/app/permission-hook.hoon deleted file mode 100644 index ba2dd8d428..0000000000 --- a/pkg/arvo/app/permission-hook.hoon +++ /dev/null @@ -1,26 +0,0 @@ -:: permission-hook [landscape]: deprecated -:: -/+ default-agent -:: -=| [%1 ~] -=* state - -:: -^- agent:gall -|_ =bowl:gall -+* this . - def ~(. (default-agent this %|) bowl) -:: -++ on-init on-init:def -++ on-save !>(state) -++ on-load - |= old=vase - [~ this] -++ on-poke on-poke:def -++ on-watch on-watch:def -++ on-agent on-agent:def -++ on-leave on-leave:def -++ on-peek on-peek:def -++ on-arvo on-arvo:def -++ on-fail on-fail:def --- - diff --git a/pkg/arvo/app/permission-store.hoon b/pkg/arvo/app/permission-store.hoon deleted file mode 100644 index ac8c6d389d..0000000000 --- a/pkg/arvo/app/permission-store.hoon +++ /dev/null @@ -1,36 +0,0 @@ -:: permission-store [landscape]: deprecated -:: -/+ default-agent -|% -+$ card card:agent:gall -+$ versioned-state - $% state-0 - state-1 - == -:: -+$ state-0 [%0 *] -+$ state-1 [%1 ~] --- -:: -=| state-1 -=* state - -:: -^- agent:gall -|_ =bowl:gall -+* this . - def ~(. (default-agent this %|) bowl) -:: -++ on-init on-init:def -++ on-save !>(state) -++ on-load - |= old=vase - [~ this] -:: -++ on-poke on-poke:def -++ on-peek on-peek:def -++ on-watch on-watch:def -++ on-leave on-leave:def -++ on-agent on-agent:def -++ on-arvo on-arvo:def -++ on-fail on-fail:def --- diff --git a/pkg/arvo/app/publish.hoon b/pkg/arvo/app/publish.hoon deleted file mode 100644 index 2588be4338..0000000000 --- a/pkg/arvo/app/publish.hoon +++ /dev/null @@ -1,691 +0,0 @@ -:: publish [landscape] -:: -:: stores notebooks in clay, subscribes and allow subscriptions to notebooks -:: -/- *publish -/- *group -/- group-hook -/- *permission-hook -/- *permission-group-hook -/- *permission-store -/- inv=invite-store -/- *metadata-store -/- *metadata-hook -/- contact-view -/- pull-hook -/- push-hook -/+ *server -/+ *publish -/+ cram -/+ default-agent -/+ dbug -/+ verb -/+ grpl=group -/+ group-store -/+ graph-store -/+ resource -:: -~% %publish ..is ~ -|% -+$ card card:agent:gall -:: -+$ collection-zero [* pos=(map @tas *) *] -:: -+$ state-zero - $: pubs=(map @tas collection-zero) - * - == -:: -+$ state-two - $: our-paths=(list path) - books=(map @tas notebook-2) - subs=(map [@p @tas] notebook-2) - tile-num=@ud - == -:: -+$ state-three - $: our-paths=(list path) - books=(map [@p @tas] notebook) - tile-num=@ud - $= limbo - $: notes=(map [@p @tas @tas] note) - comments=(map [@p @tas @tas @da] comment) - == - == -:: -+$ state-four - [state-three migrate=migration-state] -:: -:: $migration-state: resources that are unavailable because their host -:: has not processed the ota, and number of times we've tried to reach -:: the host -+$ migration-state - (map resource @ud) -:: -+$ versioned-state - $% [%1 state-two] - [%2 state-two] - [%3 state-three] - [%4 state-three] - [%5 state-three] - [%6 state-three] - [%7 state-four] - == -:: -+$ metadata-delta - $% $: %add - group-path=path - app-path=path - title=@t - desc=@t - author=@p - created=@da - == - [%remove author=@p book=@tas] - == --- -:: -=| [%7 state-four] -=* state - -%- agent:dbug -%+ verb | -^- agent:gall -=< - |_ bol=bowl:gall - +* this . - def ~(. (default-agent this %|) bol) - main ~(. +> bol) - :: - ++ on-init - ^- (quip card _this) - `this - :: - ++ on-save !>(state) - :: - ++ on-load - |= old=vase - ^- (quip card _this) - =/ old-state=(each versioned-state tang) - (mule |.(!<(versioned-state old))) - =| cards=(list card) - |^ - ?: ?=(%| -.old-state) - =/ zero !<(state-zero old) - =/ rav [%next %t [%da now.bol] /app/publish/notebooks] - =/ init-cards=(list card) - :~ [%pass /read/paths %arvo %c %warp our.bol q.byk.bol `rav] - :* %pass /permissions %agent [our.bol %permission-store] %watch - /updates - == - (invite-poke:main [%create %publish]) - :* %pass /invites %agent [our.bol %invite-store] %watch - /invitatory/publish - == - [%pass /bind %arvo %e %disconnect [~ /'~publish']] - [%pass /view-bind %arvo %e %connect [~ /'publish-view'] %publish] - :* %pass /srv %agent [our.bol %file-server] - %poke %file-server-action - !>([%serve-dir /'~publish' /app/landscape %.n %.y]) - == - == - =+ ^- [kick-cards=(list card) old-subs=(jug @tas @p)] kick-subs - =/ inv-scry-pax - /(scot %p our.bol)/invite-store/(scot %da now.bol)/invitatory/publish/noun - =/ invi=(unit invitatory:inv) .^((unit invitatory:inv) %gx inv-scry-pax) - =| new-state=state-two - =? tile-num.new-state ?=(^ invi) - ~(wyt by u.invi) - %= $ - old-state [%& %2 new-state] - :: - cards - ;: weld - kick-cards - init-cards - (move-files old-subs) - == - == - ?- -.p.old-state - %1 - %= $ - -.p.old-state %2 - :: - cards - %- zing - %+ turn ~(tap by books.p.old-state) - |= [name=@tas book=notebook-2] - ^- (list card) - =/ group-host=(unit @p) - ?> ?=(^ writers.book) - (slaw %p i.writers.book) - ?~ group-host ~ - ?: =(u.group-host our.bol) ~ - :~ %- perm-group-hook-poke:main - [%associate writers.book [[writers.book %white] ~ ~]] - :: - (perm-hook-poke:main [%add-owned writers.book writers.book]) - == - == - :: - %2 - %= $ - p.old-state - =/ new-books=(map [@p @tas] notebook) - %- %~ uni by - %- ~(run by subs.p.old-state) - |= old-notebook=notebook-2 - ^- notebook-3 - (convert-notebook-2-3 old-notebook) - ^- (map [@p @tas] notebook) - %- ~(rep by books.p.old-state) - |= [[key=@tas val=notebook-2] out=(map [@p @tas] notebook)] - ^- (map [@p @tas] notebook) - %+ ~(put by out) - [our.bol key] - (convert-notebook-2-3 val) - [%3 our-paths.p.old-state new-books tile-num.p.old-state [~ ~]] - == - :: - %3 - %= $ - -.p.old-state %4 - :: - cards - %+ welp cards - :~ [%pass /bind %arvo %e %disconnect [~ /'~publish']] - [%pass /view-bind %arvo %e %connect [~ /'publish-view'] %publish] - :* %pass /srving %agent [our.bol %file-server] - %poke %file-server-action - !>([%serve-dir /'~publish' /app/landscape %.n %.y]) - == == - == - :: - %4 - %= $ - p.old-state - =/ new-books=(map [@p @tas] notebook) - %- ~(run by books.p.old-state) - |= old-notebook=notebook-3 - ^- notebook-3 - (convert-notebook-3-4 old-notebook) - [%5 our-paths.p.old-state new-books tile-num.p.old-state [~ ~]] - :: - cards - %+ welp cards - :~ [%pass /groups %agent [our.bol %group-store] %watch /groups] - == - == - :: - %5 - %= $ - -.p.old-state %6 - cards - %+ weld cards - %+ roll ~(tap by books.p.old-state) - |= [[[who=@p book=@tas] nb=notebook] out=(list card)] - ^- (list card) - ?. =(who our.bol) - out - =/ rid (de-path:resource writers.nb) - =/ grp=(unit group) (scry-group:grup:main rid) - ?~ grp out - ?: hidden.u.grp - out - =/ =tag [%publish (cat 3 'writers-' book)] - :_ out - (group-proxy-poke entity.rid %add-tag rid tag members.u.grp) - == - :: - %6 - =/ [ours=(set [rid=resource nb=notebook]) theirs=(set resource)] - %+ roll ~(tap by books.p.old-state) - |= [[[who=@p book=@tas] nb=notebook] [ours=(set [resource notebook]) theirs=(set resource)]] - ^- [(set [resource notebook]) (set resource)] - =/ =resource - [who book] - ?. =(who our.bol) - ours^(~(put in theirs) resource) - :_ theirs - (~(put in ours) [resource nb]) - :: - %_ $ - p.old-state - :+ %7 +.p.old-state - %- ~(gas by *(map resource @ud)) - (turn ~(tap in theirs) (late 0)) - :: - cards - ;: weld - cards - :: move our books to graph-store - ^- (list card) - %- zing - %+ turn ~(tap in ours) - |= [rid=resource nb=notebook] - ^- (list card) - =/ =graph:graph-store - (notebook-to-graph nb) - :~ - %- poke-graph-store - :* %0 date-created.nb %add-graph - rid - graph - `%graph-validator-publish - %.y - == - (poke-graph-push %add rid) - == - :: for their books, subscribe to graph-pull-hook, to see if host has migrated - ^- (list card) - (turn ~(tap in theirs) check-host-migrate:main) - :: leave all subscriptions - ^- (list card) - %+ turn ~(tap in ~(key by wex.bol)) - |= [=wire =ship app=term] - ^- card - [%pass wire %agent [ship app] %leave ~] - == - == - :: - %7 - [cards this(state p.old-state)] - == - ++ blank-note-node - |= =note - %* . *node:graph-store - author.post author.note - time-sent.post date-created.note - == - :: - ++ notebook-to-graph - |= =notebook - ^- graph:graph-store - %+ gas:orm:graph-store *graph:graph-store - %+ turn ~(tap by notes.notebook) - |= [@ta =note] - ^- [atom node:graph-store] - :- date-created.note - %* . (blank-note-node note) - index.post ~[date-created.note] - :: - children - :- %graph - (note-to-revision-container notebook note) - == - :: - ++ note-to-revision-container - |= [=notebook =note] - ^- graph:graph-store - %+ gas:orm:graph-store *graph:graph-store - :~ - :- %1 - %* . (blank-note-node note) - index.post ~[date-created.note %1] - children graph+(note-to-revisions note) - == - :: - :- %2 - %* . (blank-note-node note) - index.post ~[date-created.note %2] - children (comments-to-internal-graph note) - == - == - :: - ++ note-to-revisions - |= =note - ^- graph:graph-store - %^ put:orm:graph-store - *graph:graph-store %1 - =/ body=@t - =/ file - (trip file.note) - =/ idx - (find ";>" file) - ?~ idx - file.note - %- crip - (slag (add 2 u.idx) (trip file.note)) - %* . (blank-note-node note) - index.post ~[date-created.note %1 %1] - contents.post ~[text+title.note text+body] - == - :: - ++ comments-to-internal-graph - |= =note - ^- internal-graph:graph-store - ?: =(~ comments.note) - [%empty ~] - :- %graph - %+ gas:orm:graph-store *graph:graph-store - %+ turn ~(tap by comments.note) - |= [when=@da =comment] - ^- [atom node:graph-store] - :- when - %* . *node:graph-store - author.post author.comment - index.post ~[date-created.note %2 when] - time-sent.post when - contents.post [%text content.comment]~ - == - :: - ++ poke-our - |= [app=term =cage] - [%pass / %agent [our.bol app] %poke cage] - :: - ++ poke-graph-pull - |= =action:pull-hook - (poke-our %graph-pull-hook pull-hook-action+!>(action)) - :: - ++ poke-graph-store - |= =update:graph-store - (poke-our %graph-store graph-update+!>(update)) - :: - ++ poke-graph-push - |= =action:push-hook - (poke-our %graph-push-hook push-hook-action+!>(action)) - ++ convert-notebook-3-4 - |= prev=notebook-3 - ^- notebook-3 - %= prev - writers - ?> ?=(^ writers.prev) - :- %ship - ?: =('~' i.writers.prev) - t.writers.prev - writers.prev - :: - subscribers - ?> ?=(^ subscribers.prev) - :- %ship - %+ scag 2 - ?: =('~' i.subscribers.prev) - t.subscribers.prev - subscribers.prev - - == - :: - ++ convert-comment-2-3 - |= prev=comment-2 - ^- comment-3 - %= prev - content [content.prev %.n] - == - :: - ++ convert-note-2-3 - |= prev=note-2 - ^- note-3 - %= prev - comments - [(~(run by comments.prev) convert-comment-2-3) %.n] - == - :: - ++ convert-notebook-2-3 - |= prev=notebook-2 - ^- notebook-3 - %= prev - notes - %- ~(run by notes.prev) - |= =note-2 - (convert-note-2-3 note-2) - == - :: - ++ kick-subs - ^- [(list card) (jug @tas @p)] - =+ ^- [paths=(list path) subs=(jug @tas @p)] - %+ roll ~(tap by sup.bol) - |= [[duct [who=@p pax=path]] paths=(list path) subs=(jug @tas @p)] - ^- [(list path) (jug @tas @p)] - ?. ?=([%collection @ ~] pax) - [paths subs] - =/ book-name i.t.pax - :- [pax paths] - (~(put ju subs) book-name who) - ?~ paths - [~ subs] - [[%give %kick paths ~]~ subs] - :: - ++ send-invites - |= [book=@tas subscribers=(set @p)] - ^- (list card) - %+ turn ~(tap in subscribers) - |= who=@p - ^- card - =/ uid (sham %publish who book eny.bol) - =/ =invite:inv - :* our.bol %publish [our.bol book] who - (crip "invite for notebook {}/{(trip book)}") - == - =/ =action:inv [%invite %publish uid invite] - [%pass /invite %agent [who %invite-hook] %poke %invite-action !>(action)] - :: - ++ move-files - |= old-subs=(jug @tas @p) - ^- (list card) - =+ ^- [cards=(list card) sob=soba:clay] - %+ roll .^((list path) %ct (weld our-beak:main /web/publish)) - |= [pax=path car=(list card) sob=soba:clay] - ^- [(list card) soba:clay] - ?+ pax - [car sob] - :: - [%web %publish @ %publish-info ~] - =/ book-name i.t.t.pax - =/ old=old-info .^(old-info %cx (welp our-beak:main pax)) - =/ group-pax /~/(scot %p our.bol)/[book-name] - =/ book=notebook-info - [title.old '' =(%open comments.old) / /] - =+ ^- [grp-car=(list card) write-pax=path read-pax=path] - (make-groups:main book-name [group-pax ~ %.n %.n] title.old '') - =. writers.book write-pax - =. subscribers.book read-pax - =/ inv-car (send-invites book-name (~(get ju old-subs) book-name)) - :- :(weld car grp-car inv-car) - ^- soba:clay - :+ [pax %del ~] - :- /app/publish/notebooks/[book-name]/publish-info - [%ins %publish-info !>(book)] - sob - :: - [%web %publish @ @ %udon ~] - =/ book i.t.t.pax - =/ note i.t.t.t.pax - :- car - :+ [pax %del ~] - :- /app/publish/notebooks/[book]/[note]/udon - [%ins %udon !>(.^(@t %cx (welp our-beak:main pax)))] - sob - :: - [%web %publish @ @ @ %publish-comment ~] - =/ book i.t.t.pax - =/ note i.t.t.t.pax - =/ comm i.t.t.t.t.pax - =/ old-com .^(old-comment %cx (welp our-beak:main pax)) - =/ new=comment-2 - [creator.old-com date-created.old-com content.old-com] - :- car - - :+ [pax %del ~] - :- /app/publish/notebooks/[book]/[note]/[comm]/publish-comment - [%ins %publish-comment !>(new)] - sob - == - [[%pass /move-files %arvo %c %info q.byk.bol %& sob] cards] - -- - :: - ++ on-poke on-poke:def - ++ on-watch on-watch:def - ++ on-leave on-leave:def - ++ on-peek on-peek:def - ++ on-agent - |= [=wire =sign:agent:gall] - ^- (quip card _this) - ?. ?=([%graph-migrate *] wire) - (on-agent:def wire sign) - =/ rid=resource - (de-path:resource t.wire) - ?. ?=(%watch-ack -.sign) - ~| "Expected error, please ignore" - (on-agent:def wire sign) - ?~ p.sign - :: if watch acked successfully, then host has completed OTA, and - :: we are safe to add it to the pull-hook - :_ this(migrate (~(del by migrate) rid)) - ~[(poke-graph-pull:main %add entity.rid rid)] - :: if nacked, then set a exponential backoff and retry - =/ nack-count=@ud - +((~(gut by migrate) rid 0)) - ?: (gte nack-count 24) - ~& >>> "failed to migrate notebook {} to graph-store" - [~ this] - :_ this(migrate (~(put by migrate) rid nack-count)) - :: (bex 19) is roughly 6 days - =/ wakeup=@da - (add now.bol (mul ~s1 (bex (min 19 nack-count)))) - [%pass wire %arvo %b %wait wakeup]~ - :: - ++ on-arvo - |= [=wire =sign-arvo] - ^- (quip card _this) - ?. ?=([%graph-migrate *] wire) - (on-arvo:def wire sign-arvo) - =/ rid=resource - (de-path:resource t.wire) - ?> ?=([%b %wake *] sign-arvo) - ~? ?=(^ error.sign-arvo) - "behn errored in backoff timers, continuing anyway" - :_ this - ~[(check-host-migrate:main rid)] - :: - ++ on-fail on-fail:def - -- -:: -|_ bol=bowl:gall -++ grup ~(. grpl bol) -:: -++ our-beak /(scot %p our.bol)/[q.byk.bol]/(scot %da now.bol) -:: -++ perm-hook-poke - |= act=permission-hook-action - ^- card - :* %pass - / - %agent - [our.bol %permission-hook] - %poke - %permission-hook-action - !>(act) - == -:: -++ invite-poke - |= act=action:inv - ^- card - [%pass / %agent [our.bol %invite-store] %poke %invite-action !>(act)] -:: -++ perm-group-hook-poke - |= act=permission-group-hook-action - ^- card - :* %pass - / - %agent - [our.bol %permission-group-hook] - %poke - %permission-group-hook-action - !>(act) - == -:: -++ generate-invites - |= [book=@tas invitees=(set ship)] - ^- (list card) - %+ turn ~(tap in invitees) - |= who=ship - =/ uid (sham %publish who book eny.bol) - =/ =invite:inv - :* our.bol %publish [our.bol book] who - (crip "invite for notebook {}/{(trip book)}") - == - =/ act=action:inv [%invite %publish uid invite] - [%pass / %agent [our.bol %invite-hook] %poke %invite-action !>(act)] -:: -++ make-groups - |= [book=@tas group=group-info title=@t about=@t] - ^- [(list card) write=path read=path] - ?> ?=(^ group-path.group) - =/ scry-path - ;: welp - /(scot %p our.bol)/group-store/(scot %da now.bol) - [%groups group-path.group] - /noun - == - =/ rid=resource (de-path:resource group-path.group) - =/ grp=(unit ^group) (scry-group:grup rid) - ?: use-preexisting.group - ?~ grp !! - ?. (is-managed group-path.group) !! - =/ =tag [%publish (cat 3 'writers-' book)] - :_ [group-path.group group-path.group] - [(group-proxy-poke entity.rid %add-tag rid tag members.u.grp)]~ - :: - =/ =policy - *open:policy - ?: make-managed.group - ?^ grp [~ group-path.group group-path.group] - ?. (is-managed group-path.group) !! - =/ whole-grp (~(put in invitees.group) our.bol) - :_ [group-path.group group-path.group] - [(contact-view-create [group-path.group whole-grp policy title about])]~ - :: make unmanaged group - =* group-path group-path.group - :_ [group-path group-path] - ?^ grp ~ - =/ rid=resource - (de-path:resource group-path) - :- (group-poke %add-group rid policy %.y) - (generate-invites book (~(del in invitees.group) our.bol)) -:: -++ is-managed - |= =path - ^- ? - ?> ?=(^ path) - !=(i.path '~') -:: -++ group-poke - |= =update:group-store - ^- card - [%pass / %agent [our.bol %group-store] %poke %group-update !>(update)] -:: -++ group-proxy-poke - |= [=ship =update:group-store] - ^- card - [%pass / %agent [ship %group-push-hook] %poke %group-update !>(update)] -++ contact-view-poke - |= act=contact-view-action:contact-view - ^- card - [%pass / %agent [our.bol %contact-view] %poke %contact-view-action !>(act)] -:: -++ contact-view-create - |= [=path ships=(set ship) =policy title=@t description=@t] - =/ rid=resource - (de-path:resource path) - =/ act=contact-view-action:contact-view - [%create name.rid policy title description] - (contact-view-poke act) -:: -++ check-host-migrate - |= rid=resource - ^- card - =/ res-path - (en-path:resource rid) - =- [%pass graph-migrate+res-path %agent -] - [[entity.rid %graph-push-hook] %watch resource+res-path] -:: - -:: -++ poke-our - |= [app=term =cage] - [%pass / %agent [our.bol app] %poke cage] -:: -++ poke-graph-pull - |= =action:pull-hook - (poke-our %graph-pull-hook pull-hook-action+!>(action)) -:: --- diff --git a/pkg/arvo/app/soto.hoon b/pkg/arvo/app/soto.hoon deleted file mode 100644 index 29d9a7a940..0000000000 --- a/pkg/arvo/app/soto.hoon +++ /dev/null @@ -1,4 +0,0 @@ -:: soto [tombstone]: former dojo relay for urbit's landscape interface -:: -/+ default-agent -(default-agent *agent:gall %|) diff --git a/pkg/arvo/gen/group-hook/add.hoon b/pkg/arvo/gen/group-hook/add.hoon deleted file mode 100644 index b8e46c2ce1..0000000000 --- a/pkg/arvo/gen/group-hook/add.hoon +++ /dev/null @@ -1,10 +0,0 @@ -:: group-listen-hook|add: add a group -:: -/- *group, *group-hook -:- %say -|= $: [now=@da eny=@uvJ =beak] - [[=ship =term ~] ~] - == -:- %group-hook-action -^- action -[%add ship term] diff --git a/pkg/arvo/gen/group-hook/remove.hoon b/pkg/arvo/gen/group-hook/remove.hoon deleted file mode 100644 index 1dffdf04cb..0000000000 --- a/pkg/arvo/gen/group-hook/remove.hoon +++ /dev/null @@ -1,10 +0,0 @@ -:: group-listen-hook|remove: add a group -:: -/- *group, *group-hook -:- %say -|= $: [now=@da eny=@uvJ =beak] - [[=ship =term ~] ~] - == -:- %group-hook-action -^- action -[%remove ship term] diff --git a/pkg/arvo/gen/link-store/note.hoon b/pkg/arvo/gen/link-store/note.hoon deleted file mode 100644 index 6b3651ad69..0000000000 --- a/pkg/arvo/gen/link-store/note.hoon +++ /dev/null @@ -1,10 +0,0 @@ -:: link-store|note: write a note on a link in a path -:: -/- *link-store, *link -:- %say -|= $: [now=@da eny=@uvJ =beak] - [[=path =url note=@t ~] ~] - == -:- %link-action -^- action -[%note path url note] diff --git a/pkg/arvo/gen/link-store/save.hoon b/pkg/arvo/gen/link-store/save.hoon deleted file mode 100644 index 59a5c6012e..0000000000 --- a/pkg/arvo/gen/link-store/save.hoon +++ /dev/null @@ -1,10 +0,0 @@ -:: link-store|save: save a link to a path -:: -/- *link-store, *link -:- %say -|= $: [now=@da eny=@uvJ =beak] - [[=path title=@t =url ~] ~] - == -:- %link-action -^- action -[%save path title url] diff --git a/pkg/arvo/lib/group.hoon b/pkg/arvo/lib/group.hoon index 9644fcc58c..cd9134c7a4 100644 --- a/pkg/arvo/lib/group.hoon +++ b/pkg/arvo/lib/group.hoon @@ -1,4 +1,4 @@ -/- *group, *metadata-store, hook=group-hook +/- *group, *metadata-store /+ store=group-store, resource :: |_ =bowl:gall diff --git a/pkg/arvo/lib/hood/drum.hoon b/pkg/arvo/lib/hood/drum.hoon index 16b78562d8..9a4affea36 100644 --- a/pkg/arvo/lib/hood/drum.hoon +++ b/pkg/arvo/lib/hood/drum.hoon @@ -82,9 +82,6 @@ %group-store %group-pull-hook %group-push-hook - %permission-store - %permission-hook - %permission-group-hook %invite-store %invite-hook %chat-store @@ -95,10 +92,6 @@ %contact-store %contact-hook %contact-view - %link-store - %link-proxy-hook - %link-listen-hook - %link-view %metadata-store %metadata-hook %s3-store @@ -227,10 +220,6 @@ =? ..on-load (lte hood-version %4) ~> %slog.0^leaf+"drum: starting os1 agents" => (se-born | %home %s3-store) - => (se-born | %home %link-view) - => (se-born | %home %link-listen-hook) - => (se-born | %home %link-store) - => (se-born | %home %link-proxy-hook) => (se-born | %home %contact-view) => (se-born | %home %contact-hook) => (se-born | %home %contact-store) @@ -364,11 +353,9 @@ :~ :: set up stores with priority: depended on, but never depending %- sy - :~ %permission-store - %chat-store + :~ %chat-store %contact-store %group-store - %link-store %invite-store %metadata-store == diff --git a/pkg/arvo/lib/link-store.hoon b/pkg/arvo/lib/link-store.hoon deleted file mode 100644 index 494fa8c8f4..0000000000 --- a/pkg/arvo/lib/link-store.hoon +++ /dev/null @@ -1,204 +0,0 @@ -:: link: social bookmarking -:: -/- sur=link-store, *link -:: -^? -=< [. sur] -=, sur -|% -++ site-from-url - |= =url - ^- site - =/ murl=(unit purl:eyre) - (de-purl:html url) - ?~ murl 'http://example.com' - %^ cat 3 - :: render protocol - :: - =* sec p.p.u.murl - ?:(sec 'https://' 'http://') - :: render host - :: - =* host r.p.u.murl - ?- -.host - %& (roll (join '.' p.host) (cury cat 3)) - %| (rsh 3 1 (scot %if p.host)) - == -:: -++ build-discussion-path - |= args=$@(url [=path =url]) - |^ ^- path - ?@ args ~[(encode-url-for-path args)] - :_ path.args - (encode-url-for-path url.args) - :: - ++ encode-url-for-path - |= =url - (scot %ta (wood url)) - -- -:: -++ break-discussion-path - |= =path - ^- [=^path =url] - ?~ path [/ ''] - :- t.path - ?: =(~ i.path) '' - ~| path - (woad (slav %ta i.path)) -:: -:: zip sorted a into sorted b, maintaining sort order, avoiding duplicates -:: -++ merge-sorted-unique - |* [sort=$-([* *] ?) a=(list) b=(list)] - |- ^- ?(_a _b) - ?~ a b - ?~ b a - ?: =(i.a i.b) - [i.a $(a t.a, b t.b)] - ?: (sort i.a i.b) - [i.a $(a t.a)] - [i.b $(b t.b)] -:: -++ merge - |% - ++ pages - ::TODO we would just use +cury here but it don't work - |= [a=^pages b=^pages] - ^+ a - %+ merge-sorted-unique - |= [a=page b=page] - (gth time.a time.b) - [a b] - :: - ++ submissions - |= [a=^submissions b=^submissions] - ^+ a - %+ merge-sorted-unique - |= [a=submission b=submission] - (gth time.a time.b) - [a b] - :: - ++ notes - |= [a=^notes b=^notes] - ^+ a - %+ merge-sorted-unique - |= [a=note b=note] - (gth time.a time.b) - [a b] - :: - ++ comments - |= [a=^comments b=^comments] - ^+ a - %+ merge-sorted-unique - |= [a=comment b=comment] - (gth time.a time.b) - [a b] - -- -:: -++ enjs - =, enjs:format - ^? - |% - ++ update - |= upd=^update - ^- json - %- frond - :- -.upd - ?- -.upd - %local-pages - %- pairs - :~ 'path'^(path path.upd) - 'pages'^a+(turn pages.upd page) - == - :: - %submissions - %- pairs - :~ 'path'^(path path.upd) - 'pages'^a+(turn submissions.upd submission) - == - :: - %annotations - %- pairs - :~ 'path'^(path path.upd) - 'url'^s+url.upd - 'notes'^a+(turn notes.upd note) - == - :: - %discussions - %- pairs - :~ 'path'^(path path.upd) - 'url'^s+url.upd - 'comments'^a+(turn comments.upd comment) - == - :: - %observation - %- pairs - :~ 'path'^(path path.upd) - 'urls'^a+(turn ~(tap in urls.upd) |=(=url s+url)) - == - == - :: - ++ submission - |= sub=^submission - ^- json - =+ p=(page +.sub) - ?> ?=([%o *] p) - o+(~(put by p.p) 'ship' (ship ship.sub)) - :: - ++ page - |= =^page - ^- json - %- pairs - :~ 'title'^s+title.page - 'url'^s+url.page - 'time'^(time time.page) - == - :: - ++ comment - |= =^comment - ^- json - =+ n=(note +.comment) - ?> ?=([%o *] n) - o+(~(put by p.n) 'ship' (ship ship.comment)) - :: - ++ note - |= =^note - ^- json - %- pairs - :~ 'time'^(time time.note) - 'udon'^s+udon.note ::TODO convert? - == - -- -:: -++ dejs - =, dejs:format - ^? - |% - :: +action: json into action - :: - :: formats: - :: {save: {path: '/path', title: 'title', url: 'url'}} - :: {note: {path: '/path', url: 'url', udon: 'text, maybe udon'}} - :: - ++ action - |= =json - ^- ^action - ::TODO the type system doesn't like +of here? - ?+ json ~|(json !!) - [%o [%save *] ~ ~] - :- %save - %. q.n.p.json - (ot 'path'^pa 'title'^so 'url'^so ~) - :: - [%o [%note *] ~ ~] - :- %note - %. q.n.p.json - (ot 'path'^pa 'url'^so 'udon'^so ~) - :: - [%o [%seen *] ~ ~] - :- %seen - %. q.n.p.json - (ot 'path'^pa 'url'^(mu so) ~) - == - -- --- diff --git a/pkg/arvo/lib/metadata.hoon b/pkg/arvo/lib/metadata.hoon index 71c894b20f..13ac9ac1e0 100644 --- a/pkg/arvo/lib/metadata.hoon +++ b/pkg/arvo/lib/metadata.hoon @@ -58,19 +58,4 @@ (scot %da now.bowl) /resource-indices == -:: -++ check-resource-permissions - |= [=ship =md-resource] - ^- ? - %+ lien (groups-from-resource md-resource) - |= =group-path - .^ ? - %gx - (scot %p our.bowl) - %permission-store - (scot %da now.bowl) - %permitted - (scot %p ship) - (snoc group-path %noun) - == -- diff --git a/pkg/arvo/lib/permission-json.hoon b/pkg/arvo/lib/permission-json.hoon deleted file mode 100644 index 36f1af1f77..0000000000 --- a/pkg/arvo/lib/permission-json.hoon +++ /dev/null @@ -1,103 +0,0 @@ -/- *permission-store -|% -++ update-to-json - |= upd=permission-update - ^- json - =, enjs:format - %+ frond %permission-update - %- pairs - :~ - ?: =(%initial -.upd) - ?> ?=(%initial -.upd) - [%initial (permission-to-json permissions.upd)] - :: - :: %create - ?: =(%create -.upd) - ?> ?=(%create -.upd) - :- %create - %- pairs - :~ [%path (path path.upd)] - [%kind s+kind.permission.upd] - [%who [%a (turn ~(tap in who.permission.upd) ship)]] - == - :: - :: %delete - ?: =(%delete -.upd) - ?> ?=(%delete -.upd) - [%delete (path path.upd)] - :: - :: %add - ?: =(%add -.upd) - ?> ?=(%add -.upd) - :- %add - %- pairs - :~ [%path (path path.upd)] - [%who [%a (turn ~(tap in who.upd) ship)]] - == - :: - :: %remove - ?: =(%remove -.upd) - ?> ?=(%remove -.upd) - :- %remove - %- pairs - :~ [%path (path path.upd)] - [%who [%a (turn ~(tap in who.upd) ship)]] - == - :: - :: %noop - [*@t *^json] - == -:: -++ permission-to-json - |= pem=permission-map - =, enjs:format - ^- json - %- pairs - %+ turn ~(tap by pem) - |= [pax=^path =permission] - ^- [cord json] - :- (spat pax) - %- pairs - :~ [%kind s+kind.permission] - [%who [%a (turn ~(tap in who.permission) ship)]] - == -:: -++ ki - =, dejs:format - ^- $-(json kind) - (su (perk %black %white ~)) -:: -++ json-to-set-path-kind - =, dejs:format - %- as - %- ot - :~ [%path pa] - [%kind ki] - == -:: -++ json-to-perm-group-hook-action - |= jon=json - =, dejs:format - =< (parse-action jon) - |% - ++ parse-action - %- of - :~ [%associate associate] - [%dissociate dissociate] - == - :: - ++ associate - %- ot - :~ [%group pa] - [%permissions json-to-set-path-kind] - == - :: - ++ dissociate - %- ot - :~ [%group pa] - [%permissions (as pa)] - == - :: - -- --- - diff --git a/pkg/arvo/lib/soto.hoon b/pkg/arvo/lib/soto.hoon deleted file mode 100644 index 6077c6c4f1..0000000000 --- a/pkg/arvo/lib/soto.hoon +++ /dev/null @@ -1,99 +0,0 @@ -/+ *sole -:: -::TODO revert after #1946 -:: -|% -:: -++ json-to-action - |= jon=json ^- sole-action - %- need %. jon - => [dejs-soft:format ..sole-action] - |^ (ot id+so dat+(fo %ret (of det+change tab+ni ~)) ~) - ++ fo - |* [a=term b=fist] - |=(c=json ?.(=([%s a] c) (b c) (some [a ~]))) - :: - ++ ra - |* [a=[term fist] b=fist] - |= c=json %. c - ?.(=(%a -.c) b (pe -.a (ar +.a))) - :: - ++ ke :: callbacks - |* [gar=* sef=(trap fist)] - |= jon=json ^- (unit _gar) - =- ~! gar ~! (need -) - - ((sef) jon) - :: - ++ change (ot ler+(at ni ni ~) ted+(pe 0v0 edit) ~) - ++ char (cu taft so) - ++ edit - %+ ke *sole-edit |. ~+ - %+ fo %nop - %+ ra mor+edit - (of del+ni set+(cu tuba sa) ins+(ot at+ni cha+char ~) ~) - -- -:: -++ effect-to-json - |= sef=sole-effect - |^ ^- json - =, enjs:format - ?+ -.sef - ~|(unsupported-effect+-.sef !!) - %mor [%a (turn p.sef |=(a=sole-effect ^$(sef a)))] - %err (frond %hop (numb p.sef)) - %txt (frond %txt (tape p.sef)) - %tan (frond %tan (tape (wush 160 p.sef))) - %det (frond %det json:~(grow mar-sole-change +.sef)) - :: - %pro - %+ frond %pro - (pairs vis+b+vis.sef tag+s+tag.sef cad+(tape (purge cad.sef)) ~) - :: - %tab - :- %a - %+ turn p.sef - |= [=cord =^tank] - %+ frond %tab - %- pairs - :~ match+s+cord - info+(tape ~(ram re tank)) - == - :: - ?(%bel %clr %nex) - (frond %act %s -.sef) - == - ++ mar-sole-change - |_ cha=sole-change - ++ grow - |% ++ json - ^- ^json - =, enjs:format - =; edi - =,(cha (pairs ted+(edi ted) ler+a+~[(numb own.ler) (numb his.ler)] ~)) - |= det=sole-edit - ?- -.det - %nop [%s 'nop'] - %mor [%a (turn p.det ..$)] - %del (frond %del (numb p.det)) - %set (frond %set (tape (tufa p.det))) - %ins (frond %ins (pairs at+(numb p.det) cha+s+(tuft q.det) ~)) - == - -- - -- - ++ wush - |= [wid=@u tan=tang] - ^- tape - %- of-wall:format - %+ turn (flop tan) - |= =tank - ~! wid - ~! tank - (of-wall:format (wash 0^wid tank)) - :: - ++ purge - |= a=styx ^- tape - %- zing %+ turn a - |= a=_?>(?=(^ a) i.a) - ?@(a (trip a) ^$(a q.a)) - -- --- diff --git a/pkg/arvo/mar/group/hook-action.hoon b/pkg/arvo/mar/group/hook-action.hoon deleted file mode 100644 index 477fbf5c26..0000000000 --- a/pkg/arvo/mar/group/hook-action.hoon +++ /dev/null @@ -1,30 +0,0 @@ -/- *group-hook -=, dejs:format -|_ act=action -++ grad %noun -++ grow - |% - ++ noun act - -- -++ grab - |% - ++ noun action - ++ json - |= jon=^json - =< (parse-action jon) - |% - ++ parse-action - %- of - :~ - [%add add-action] - [%remove pa] - == - :: - ++ add-action - %- ot - :~ [%ship (su ;~(pfix sig fed:ag))] - [%path pa] - == - -- - -- --- diff --git a/pkg/arvo/mar/link/action.hoon b/pkg/arvo/mar/link/action.hoon deleted file mode 100644 index f02dfdd357..0000000000 --- a/pkg/arvo/mar/link/action.hoon +++ /dev/null @@ -1,17 +0,0 @@ -:: link: subscription updates -:: -::TODO this should include json conversion once mark performance improves -/+ *link-store -|_ =action -++ grad %noun -++ grow - |% - ++ noun action - -- -:: -++ grab - |% - ++ noun ^action - ++ json action:dejs - -- --- diff --git a/pkg/arvo/mar/link/initial.hoon b/pkg/arvo/mar/link/initial.hoon deleted file mode 100644 index 488dc1869a..0000000000 --- a/pkg/arvo/mar/link/initial.hoon +++ /dev/null @@ -1,15 +0,0 @@ -:: link: initial subscription result -:: -/- *link-store -|_ =initial -++ grad %noun -++ grow - |% - ++ noun initial - -- -:: -++ grab - |% - ++ noun ^initial - -- --- diff --git a/pkg/arvo/mar/link/listen-action.hoon b/pkg/arvo/mar/link/listen-action.hoon deleted file mode 100644 index 49910ccd6d..0000000000 --- a/pkg/arvo/mar/link/listen-action.hoon +++ /dev/null @@ -1,22 +0,0 @@ -:: link-listen-action -:: -/- *link-listen-hook -=, dejs:format -|_ act=action -++ grad %noun -++ grab - |% - ++ noun action - ++ json - =, dejs:format - %- of - :~ %watch^pa - %leave^pa - == - -- -:: -++ grow - |% - ++ noun act - -- --- diff --git a/pkg/arvo/mar/link/listen-poke.hoon b/pkg/arvo/mar/link/listen-poke.hoon deleted file mode 100644 index 14e44e8c17..0000000000 --- a/pkg/arvo/mar/link/listen-poke.hoon +++ /dev/null @@ -1,13 +0,0 @@ -:: link-listen-poke: prod another listener into paying attention -:: -|_ =path -++ grad %noun -++ grow - |% - ++ noun path - -- -++ grab - |% - ++ noun ^path - -- --- diff --git a/pkg/arvo/mar/link/listen-update.hoon b/pkg/arvo/mar/link/listen-update.hoon deleted file mode 100644 index ecffba9e5b..0000000000 --- a/pkg/arvo/mar/link/listen-update.hoon +++ /dev/null @@ -1,24 +0,0 @@ -:: link-listen-update -:: -/- *link-listen-hook -=, dejs:format -|_ upd=update -++ grad %noun -++ grab - |% - ++ noun update - -- -:: -++ grow - |% - ++ noun upd - ++ json - =, enjs:format - %+ frond 'link-listen-update' - %+ frond -.upd - ?- -.upd - %listening a+(turn ~(tap in paths.upd) path) - ?(%watch %leave) (path path.upd) - == - -- --- diff --git a/pkg/arvo/mar/link/update.hoon b/pkg/arvo/mar/link/update.hoon deleted file mode 100644 index a71624a710..0000000000 --- a/pkg/arvo/mar/link/update.hoon +++ /dev/null @@ -1,15 +0,0 @@ -:: link: subscription updates -:: -/- *link-store -|_ =update -++ grad %noun -++ grow - |% - ++ noun update - -- -:: -++ grab - |% - ++ noun ^update - -- --- diff --git a/pkg/arvo/mar/link/view-action.hoon b/pkg/arvo/mar/link/view-action.hoon deleted file mode 100644 index cb261d32e0..0000000000 --- a/pkg/arvo/mar/link/view-action.hoon +++ /dev/null @@ -1,42 +0,0 @@ -/- *link-view -=, dejs:format -|_ act=action -++ grad %noun -++ grow - |% - ++ noun act - -- -++ grab - |% - ++ noun action - ++ json - |^ %- of - :~ %create^create - %delete^delete - %invite^invite - == - :: - ++ create - %- ot - :~ 'path'^pa - 'title'^so - 'description'^so - 'members'^mems - 'realGroup'^bo - == - :: - ++ mems - (of %group^pa %ships^ships ~) - :: - ++ delete - (ot 'path'^pa ~) - :: - ++ invite - (ot 'path'^pa 'ships'^ships ~) - :: - ::TODO stdlib - ++ ships - (cu sy (ar (su ;~(pfix sig fed:ag)))) - -- - -- --- diff --git a/pkg/arvo/mar/permission/action.hoon b/pkg/arvo/mar/permission/action.hoon deleted file mode 100644 index a5670a5514..0000000000 --- a/pkg/arvo/mar/permission/action.hoon +++ /dev/null @@ -1,62 +0,0 @@ -/+ *permission-json -=, dejs:format -|_ act=permission-action -++ grad %noun -++ grow - |% - ++ noun act - -- -++ grab - |% - ++ noun permission-action - ++ json - |= jon=^json - =< (parse-permission-action jon) - |% - ++ parse-permission-action - %- of - :~ [%create create] - [%delete delete] - [%add add] - [%remove remove] - [%allow allow] - [%deny deny] - == - :: - ++ create - %- ot - :~ [%path pa] - [%kind ki] - [%who (as pa)] - == - :: - ++ delete - (ot [%path pa]~) - :: - ++ add - %- ot - :~ [%path pa] - [%who (as (su ;~(pfix sig fed:ag)))] - == - :: - ++ remove - %- ot - :~ [%path pa] - [%who (as (su ;~(pfix sig fed:ag)))] - == - :: - ++ allow - %- ot - :~ [%path pa] - [%who (as (su ;~(pfix sig fed:ag)))] - == - :: - ++ deny - %- ot - :~ [%path pa] - [%who (as (su ;~(pfix sig fed:ag)))] - == - :: - -- - -- --- diff --git a/pkg/arvo/mar/permission/group-hook-action.hoon b/pkg/arvo/mar/permission/group-hook-action.hoon deleted file mode 100644 index f68dc793ec..0000000000 --- a/pkg/arvo/mar/permission/group-hook-action.hoon +++ /dev/null @@ -1,16 +0,0 @@ -/- *permission-group-hook -/+ *permission-json -|_ act=permission-group-hook-action -++ grad %noun -++ grow - |% - ++ noun act - -- -++ grab - |% - ++ noun permission-group-hook-action - ++ json - |= jon=^json - (json-to-perm-group-hook-action jon) - -- --- diff --git a/pkg/arvo/mar/permission/hook-action.hoon b/pkg/arvo/mar/permission/hook-action.hoon deleted file mode 100644 index 3706fee33d..0000000000 --- a/pkg/arvo/mar/permission/hook-action.hoon +++ /dev/null @@ -1,12 +0,0 @@ -/- *permission-hook -|_ act=permission-hook-action -++ grad %noun -++ grow - |% - ++ noun act - -- -++ grab - |% - ++ noun permission-hook-action - -- --- diff --git a/pkg/arvo/mar/permission/update.hoon b/pkg/arvo/mar/permission/update.hoon deleted file mode 100644 index fed5550392..0000000000 --- a/pkg/arvo/mar/permission/update.hoon +++ /dev/null @@ -1,15 +0,0 @@ -/+ *permission-json -|_ upd=permission-update -:: -++ grad %noun -++ grow - |% - ++ noun upd - ++ json (update-to-json upd) - -- -:: -++ grab - |% - ++ noun permission-update - -- --- diff --git a/pkg/arvo/mar/publish/action.hoon b/pkg/arvo/mar/publish/action.hoon deleted file mode 100644 index f346ed8161..0000000000 --- a/pkg/arvo/mar/publish/action.hoon +++ /dev/null @@ -1,20 +0,0 @@ -:: -:::: /hoon/action/publish/mar - :: tombstoned, now unused -/- *publish -=, format -:: -|_ act=action -:: -++ grad %noun -++ grow - |% - ++ noun act - ++ tank >act< - -- -:: -++ grab - |% - ++ noun action - -- --- diff --git a/pkg/arvo/mar/publish/comment.hoon b/pkg/arvo/mar/publish/comment.hoon deleted file mode 100644 index 052ebbd0e7..0000000000 --- a/pkg/arvo/mar/publish/comment.hoon +++ /dev/null @@ -1,65 +0,0 @@ -/- *publish -|_ com=?(comment-2 comment-3) -:: -:: -++ grow - |% - ++ mime - :- /text/x-publish-comments - (as-octs:mimes:html (of-wain:format txt)) - ++ txt - ^- wain - ?: ?=(comment-2 com) - :* (cat 3 'author: ' (scot %p author.com)) - (cat 3 'date-created: ' (scot %da date-created.com)) - '-----' - (to-wain:format content.com) - == - ?> ?=(comment-3 com) - :* (cat 3 'author: ' (scot %p author.com)) - (cat 3 'date-created: ' (scot %da date-created.com)) - '-----' - (to-wain:format content.com) - == - -- -++ grab - |% - ++ mime - |= [mite p=octs] - |^ (rash q.p both-parser) - ++ key-val - |* [key=rule val=rule] - ;~(sfix ;~(pfix key val) gaq) - ++ old-parser - ;~ plug - (key-val (jest 'creator: ~') fed:ag) - (key-val (jest 'collection: ') sym) - (key-val (jest 'post: ') sym) - (key-val (jest 'date-created: ~') (cook year when:so)) - (key-val (jest 'last-modified: ~') (cook year when:so)) - ;~(pfix (jest (cat 3 '-----' 10)) (cook crip (star next))) - == - ++ new-parser - ;~ plug - (key-val (jest 'author: ~') fed:ag) - (key-val (jest 'date-created: ~') (cook year when:so)) - ;~(pfix (jest (cat 3 '-----' 10)) (cook crip (star next))) - == - ++ both-parser - ;~ pose - %+ cook - |= [author=@ date-created=@da content=@t] - ^- comment - [author date-created content %.n] - new-parser - %+ cook - |= [author=@ @ @ date-created=@da @ content=@t] - ^- comment - [author date-created content %.n] - old-parser - == - -- - ++ noun ?(comment-2 comment-3) - -- -++ grad %mime --- diff --git a/pkg/arvo/mar/publish/info.hoon b/pkg/arvo/mar/publish/info.hoon deleted file mode 100644 index 288c3609dd..0000000000 --- a/pkg/arvo/mar/publish/info.hoon +++ /dev/null @@ -1,58 +0,0 @@ -:: -:::: /hoon/info/publish/mar - :: tombstoned, now unused - :: -/- *publish -!: -|_ info=notebook-info -:: -:: -++ grab - |% - ++ mime - |= [mite p=octs] - |^ (rash q.p both-parser) - ++ key-val - |* [key=rule val=rule] - ;~(sfix ;~(pfix key val) gaq) - ++ old-parser - ;~ plug - (key-val (jest 'owner: ~') fed:ag) - (key-val (jest 'title: ') (cook crip (star prn))) - (key-val (jest 'filename: ') sym) - %+ key-val (jest 'comments: ') - ;~(pose (jest %open) (jest %closed) (jest %none)) - %+ key-val (jest 'allow-edit: ') - ;~(pose (jest %post) (jest %comment) (jest %all) (jest %none)) - (key-val (jest 'date-created: ~') (cook year when:so)) - ;~ pose - (key-val (jest 'last-modified: ~') (cook year when:so)) - ;~(pfix (jest 'last-modified: ~') (cook year when:so)) - == - == - ++ new-parser - ;~ plug - (key-val (jest 'title: ') (cook crip (star prn))) - (key-val (jest 'description: ') (cook crip (star prn))) - %+ key-val (jest 'comments: ') - (cook |=(a=@ =(%on a)) ;~(pose (jest %on) (jest %off))) - (key-val (jest 'writers: ') ;~(pfix fas (more fas urs:ab))) - ;~ pose - (key-val (jest 'subscribers: ') ;~(pfix fas (more fas urs:ab))) - ;~(pfix (jest 'subscribers: ') ;~(pfix fas (more fas urs:ab))) - == - == - ++ both-parser - ;~ pose - new-parser - %+ cook - |= [@ title=@t @ comments=@ *] - ^- notebook-info - [title '' =('open' comments) / /] - old-parser - == - -- - ++ noun notebook-info - -- -++ grad %mime --- diff --git a/pkg/arvo/mar/publish/notebook-delta.hoon b/pkg/arvo/mar/publish/notebook-delta.hoon deleted file mode 100644 index 59c73a0030..0000000000 --- a/pkg/arvo/mar/publish/notebook-delta.hoon +++ /dev/null @@ -1,18 +0,0 @@ -:: -:::: /hoon/action/publish/mar - :: -/- *publish -=, format -:: -|_ del=notebook-delta -:: -++ grad %noun -++ grow - |% - ++ noun del - -- -++ grab - |% - ++ noun notebook-delta - -- --- diff --git a/pkg/arvo/mar/publish/primary-delta.hoon b/pkg/arvo/mar/publish/primary-delta.hoon deleted file mode 100644 index 41b331c080..0000000000 --- a/pkg/arvo/mar/publish/primary-delta.hoon +++ /dev/null @@ -1,17 +0,0 @@ -:: -:::: /hoon/action/publish/mar - :: -/+ *publish -:: -|_ del=primary-delta -:: -++ grad %noun -++ grab - |% - ++ noun primary-delta - -- -++ grow - |% - ++ noun del - -- --- diff --git a/pkg/arvo/sur/group-hook.hoon b/pkg/arvo/sur/group-hook.hoon deleted file mode 100644 index b5c0c9f4c2..0000000000 --- a/pkg/arvo/sur/group-hook.hoon +++ /dev/null @@ -1,16 +0,0 @@ -/- *group, store=group-store, *resource -|% -:: $action: request to change group-hook state -:: -:: %add: -:: if ship is ours make group available to sync, else sync foreign group -:: to group-store. -:: %remove: -:: if ship is ours make unavailable to sync, else stop syncing foreign -:: group. -:: -+$ action - $% [%add rid=resource] - [%remove rid=resource] - == --- diff --git a/pkg/arvo/sur/link-listen-hook.hoon b/pkg/arvo/sur/link-listen-hook.hoon deleted file mode 100644 index 83dba4505e..0000000000 --- a/pkg/arvo/sur/link-listen-hook.hoon +++ /dev/null @@ -1,17 +0,0 @@ -:: link-listen-hook: actions for getting your friends' bookmarks -:: -:: Note that /app/link-listen-hook auto-joins any new collections in groups -:: you're a part of. You only need the watch action here for leaving and -:: re-joining. -:: -|% -+$ action - $% [%watch =path] - [%leave =path] - == -:: -+$ update - $% [%listening paths=(set path)] - action - == --- diff --git a/pkg/arvo/sur/link-store.hoon b/pkg/arvo/sur/link-store.hoon deleted file mode 100644 index 2646190394..0000000000 --- a/pkg/arvo/sur/link-store.hoon +++ /dev/null @@ -1,50 +0,0 @@ -:: link-store: store specific types -:: -/- *link -^? -|% -:: -:: +action: local actions -:: -+$ action - $% :: user actions - :: - :: %save: save page to path on our ship - :: - [%save =path title=@t =url] - :: %note: save a note for a url - :: - [%note =path =url udon=@t] - :: %seen: mark item as read (~ for all in path) - :: - [%seen =path url=(unit url)] - :: hook actions - :: - :: %hear: hear about page at path on other ship - :: - [%hear =path submission] - :: %read: hear about note on url from ship - :: - [%read =path =url comment] - == -:: -:: +initial: local result -:: -+$ initial - $% [%local-pages pages=(map path pages)] - [%submissions submissions=(map path submissions)] - [%annotations notes=(per-path-url notes)] - [%discussions comments=(per-path-url comments)] - == -:: +update: local updates -:: -::NOTE we include paths/urls to support the "subscribed to all" case -:: -+$ update - $% [%local-pages =path =pages] - [%submissions =path =submissions] - [%annotations =path =url =notes] - [%discussions =path =url =comments] - [%observation =path urls=(set url)] - == --- diff --git a/pkg/arvo/sur/link-view.hoon b/pkg/arvo/sur/link-view.hoon deleted file mode 100644 index db3e2f4a97..0000000000 --- a/pkg/arvo/sur/link-view.hoon +++ /dev/null @@ -1,34 +0,0 @@ -:: link-view: encapsulating link management -:: -|% -++ action - $% :: %create: create a new link collection - :: - :: with specified metadata and group. %ships creates a new group, - :: :real-group indicates whether it's global (&) or local (|). - :: - $: %create - =path - title=@t - description=@t - members=create-members - real-group=? - == - :: - :: %delete: remove collection from local metadata & stop syncing - :: - :: if the resource is associated with a real group, and we're the owner, - :: this deletes it for everyone - :: - [%delete =path] - :: - :: %invite: add to resource's group and send invite - :: - [%invite =path ships=(set ship)] - == -:: -++ create-members - $% [%group =path] - [%ships ships=(set ship)] - == --- diff --git a/pkg/arvo/sur/link.hoon b/pkg/arvo/sur/link.hoon deleted file mode 100644 index 20b30a98cc..0000000000 --- a/pkg/arvo/sur/link.hoon +++ /dev/null @@ -1,49 +0,0 @@ -:: link: social bookmarking -:: -:: link operates on the core structure of "pages", which are URLs saved at a -:: specific time with a specific title. -:: submissions, then, are pages received from a specific ship. -:: -|% -:: primitives -:: -+$ url @t -+$ site @t :: domain, host, etc. -:: +page: a saved URL with timestamp and custom title -:: -+$ page - $: title=@t - =url - =time - == -:: +submission: a page saved by a ship -:: -+$ submission - $: =ship - page - == -:: +note: a comment on some url -:: -+$ note - $: =time - udon=@t - == -:: +comment: a comment by a ship on some url -:: -+$ comment - $: =ship - note - == -:: lists, reverse chronological / newest first -:: -+$ pages (list page) -+$ submissions (list submission) -+$ notes (list note) -+$ comments (list comment) -:: -:: state builder -:: -++ per-path-url - |$ [value] - (map path (map url value)) --- diff --git a/pkg/arvo/sur/permission-group-hook.hoon b/pkg/arvo/sur/permission-group-hook.hoon deleted file mode 100644 index a414d48a21..0000000000 --- a/pkg/arvo/sur/permission-group-hook.hoon +++ /dev/null @@ -1,17 +0,0 @@ -|% -+$ kind ?(%black %white) -:: -+$ permission-group-hook-action - $% :: %associate: cause a group of ships to be mirrored onto some - :: set of permission paths. - :: note: this deletes any existing data at those permission paths first. - :: - [%associate group=path permissions=(set [path kind])] - :: - :: %dissociate: stop mirroring between a group and a set - :: of permission paths. - :: - [%dissociate group=path permissions=(set path)] - == --- - diff --git a/pkg/arvo/sur/permission-hook.hoon b/pkg/arvo/sur/permission-hook.hoon deleted file mode 100644 index ea49ffbcdb..0000000000 --- a/pkg/arvo/sur/permission-hook.hoon +++ /dev/null @@ -1,15 +0,0 @@ -|% -+$ permission-hook-action - $% :: %add-owned: make a permission set accessible to foreign ships - :: who are allowed by the permission set at the access path. - :: - [%add-owned owned=path access=path] - :: %add-synced: mirror a foreign permission set to our permission-store - :: - [%add-synced =ship =path] - :: %remove: stop mirroring a foreign permission set or allowing a local - :: permission set to be mirrored - :: - [%remove =path] - == --- diff --git a/pkg/arvo/sur/permission-store.hoon b/pkg/arvo/sur/permission-store.hoon deleted file mode 100644 index 6c13b59ed4..0000000000 --- a/pkg/arvo/sur/permission-store.hoon +++ /dev/null @@ -1,28 +0,0 @@ -|% -+$ kind ?(%black %white) -:: -+$ permission - $: =kind - who=(set ship) - == -:: -+$ permission-map (map path permission) -:: -+$ permission-update - $% [%create =path =permission] :: create perm at path - [%delete =path] :: delete perm at path - [%add =path who=(set ship)] :: add ships to perm path - [%remove =path who=(set ship)] :: remove ships from perm path - [%initial permissions=permission-map] - == -:: -+$ permission-action - $% permission-update - [%allow =path who=(set ship)] :: if %black, remove - :: if %white, add - [%deny =path who=(set ship)] :: if %black, add - :: if %white, remove - == -:: --- - diff --git a/pkg/arvo/sur/publish.hoon b/pkg/arvo/sur/publish.hoon deleted file mode 100644 index a2be5c0562..0000000000 --- a/pkg/arvo/sur/publish.hoon +++ /dev/null @@ -1,146 +0,0 @@ -/- *rw-security -^? -|% -:: -+$ group-info - $: group-path=path - invitees=(set ship) - use-preexisting=? - make-managed=? - == -:: -+$ action - $% [%new-book book=@tas title=@t about=@t coms=? group=group-info] - [%new-note who=@p book=@tas note=@tas title=@t body=@t] - [%new-comment who=@p book=@tas note=@tas body=@t] - :: - [%edit-book book=@tas title=@t about=@t coms=? group=(unit group-info)] - [%edit-note who=@p book=@tas note=@tas title=@t body=@t] - [%edit-comment who=@p book=@tas note=@tas comment=@tas body=@t] - :: - [%del-book book=@tas] - [%del-note who=@p book=@tas note=@tas] - [%del-comment who=@p book=@tas note=@tas comment=@tas] - :: - [%subscribe who=@p book=@tas] - [%unsubscribe who=@p book=@tas] - :: - [%read who=@p book=@tas note=@tas] - :: - [%groupify book=@tas target=(unit path) inclusive=?] - == -:: -+$ comment comment-3 -:: -+$ comment-2 - $: author=@p - date-created=@da - content=@t - == -:: -+$ comment-3 - $: author=@p - date-created=@da - content=@t - pending=? - == -:: -+$ note note-3 -:: -+$ note-2 - $: author=@p - title=@t - filename=@tas - date-created=@da - last-edit=@da - read=? - file=@t - snippet=@t - comments=(map @da comment-2) - == -:: -+$ note-3 - $: author=@p - title=@t - filename=@tas - date-created=@da - last-edit=@da - read=? - file=@t - snippet=@t - comments=(map @da comment) - pending=? - == -:: -+$ notebook notebook-3 -:: -+$ notebook-2 - $: title=@t - description=@t - comments=? - writers=path - subscribers=path - date-created=@da - notes=(map @tas note-2) - order=(list @tas) - unread=(set @tas) - == -:: -+$ notebook-3 - $: title=@t - description=@t - comments=? - writers=path - subscribers=path - date-created=@da - notes=(map @tas note) - order=(list @tas) - unread=(set @tas) - == -:: -+$ notebook-info - $: title=@t - description=@t - comments=? - writers=path - subscribers=path - == -:: -+$ old-info - $: owner=@p - title=@t - filename=@tas - comments=?(%open %closed %none) - allow-edit=?(%post %comment %all %none) - date-created=@da - last-modified=@da - == -+$ old-comment - $: $: creator=@p - collection=@tas - post=@tas - date-created=@da - last-modified=@da - == - content=@t - == -:: -+$ notebook-delta - $% [%add-book host=@p book=@tas data=notebook] - [%add-note host=@p book=@tas note=@tas data=note] - [%add-comment host=@p book=@tas note=@tas comment-date=@da data=comment] - :: - [%edit-book host=@p book=@tas data=notebook] - [%edit-note host=@p book=@tas note=@tas data=note] - [%edit-comment host=@p book=@tas note=@tas comment-date=@da data=comment] - :: - [%del-book host=@p book=@tas] - [%del-note host=@p book=@tas note=@tas] - [%del-comment host=@p book=@tas note=@tas comment=@da] - == -:: -+$ primary-delta - $% notebook-delta - [%read who=@p book=@tas note=@tas] - == --- diff --git a/pkg/arvo/ted/ph/group-rejoin.hoon b/pkg/arvo/ted/ph/group-rejoin.hoon index df453268aa..9fcf2e8ac1 100644 --- a/pkg/arvo/ted/ph/group-rejoin.hoon +++ b/pkg/arvo/ted/ph/group-rejoin.hoon @@ -36,7 +36,6 @@ =/ m (strand:spider ,~) ^- form:m ;< ~ bind:m (start-agent ship %group-store) - ;< ~ bind:m (start-agent ship %group-hook) (pure:m ~) -- =, strand=strand:spider @@ -59,14 +58,11 @@ ;< ~ bind:m (start-group-agents ~marzod) ;< ~ bind:m (dojo ~marbud ":group-store|create 'test-group'") ;< ~ bind:m (wait-for-output ~marbud ">=") -;< ~ bind:m (dojo ~marzod ":group-hook|add ~marbud 'test-group'") -;< ~ bind:m (wait-for-output ~marzod ">=") ;< ~ bind:m (sleep ~s1) ;< ~ bind:m (breach-and-hear az ~marzod ~marbud) ;< ~ bind:m (real-ship az ~marzod) ;< ~ bind:m (wait-for-goad ~marzod) ;< ~ bind:m (start-group-agents ~marzod) -;< ~ bind:m (dojo ~marzod ":group-hook|add ~marbud 'test-group'") ;< ~ bind:m (sleep ~s3) ;< ~ bind:m end-azimuth (pure:m *vase) From 613281e5870f1699c0feda9c391dd57b88d364d6 Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Wed, 2 Dec 2020 15:48:12 -0500 Subject: [PATCH 882/933] chat: add leading sig when copying patp Fixes #4059. --- pkg/interface/src/views/apps/chat/components/ChatMessage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx b/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx index 7c3ec900bb..4fe7e6700c 100644 --- a/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx +++ b/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx @@ -240,7 +240,7 @@ export class MessageWithSigil extends PureComponent { className={`mw5 db truncate pointer`} ref={e => nameSpan = e} onClick={() => { - writeText(msg.author); + writeText(`~${msg.author}`); copyNotice(name); }} title={`~${msg.author}`} From 0711c15be9e2fe87da886a5933b3ea01f96c86d9 Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Wed, 2 Dec 2020 16:01:00 -0500 Subject: [PATCH 883/933] chat: mobile input uses textarea --- pkg/interface/src/views/apps/chat/components/chat-editor.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/interface/src/views/apps/chat/components/chat-editor.js b/pkg/interface/src/views/apps/chat/components/chat-editor.js index 2bf49bf7e4..93cdea4f47 100644 --- a/pkg/interface/src/views/apps/chat/components/chat-editor.js +++ b/pkg/interface/src/views/apps/chat/components/chat-editor.js @@ -3,7 +3,7 @@ import { UnControlled as CodeEditor } from 'react-codemirror2'; import { MOBILE_BROWSER_REGEX } from "~/logic/lib/util"; import CodeMirror from 'codemirror'; -import { Row, BaseInput } from '@tlon/indigo-react'; +import { Row, BaseTextArea } from '@tlon/indigo-react'; import 'codemirror/mode/markdown/markdown'; import 'codemirror/addon/display/placeholder'; @@ -167,9 +167,10 @@ export default class ChatEditor extends Component { color="black" > {MOBILE_BROWSER_REGEX.test(navigator.userAgent) - ? { From b95e8a46d7f70f9ab7fed45263b279562067f906 Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Wed, 2 Dec 2020 16:07:58 -0500 Subject: [PATCH 884/933] chat: even padding on daybreak --- .../src/views/apps/chat/components/ChatMessage.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx b/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx index 4fe7e6700c..3fdcabdf29 100644 --- a/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx +++ b/pkg/interface/src/views/apps/chat/components/ChatMessage.tsx @@ -23,9 +23,9 @@ export const UnreadMarker = React.forwardRef(({ dayBreak, when }, ref) => ( )); export const DayBreak = ({ when }) => ( -
-

{moment(when).calendar(null, { sameElse: DATESTAMP_FORMAT })}

-
+ + {moment(when).calendar(null, { sameElse: DATESTAMP_FORMAT })} + ); interface ChatMessageProps { From ae3b40271df37bde2362b853d42051030cf8bfc5 Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Wed, 2 Dec 2020 16:12:37 -0500 Subject: [PATCH 885/933] groups: prevent admins from banning themselves --- .../src/views/landscape/components/Participants.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/interface/src/views/landscape/components/Participants.tsx b/pkg/interface/src/views/landscape/components/Participants.tsx index 7f383d342b..a706c428fe 100644 --- a/pkg/interface/src/views/landscape/components/Participants.tsx +++ b/pkg/interface/src/views/landscape/components/Participants.tsx @@ -347,7 +347,7 @@ function Participant(props: { {props.role === 'admin' && ( <> - {!isInvite && ( + {(!isInvite && contact.patp !== window.ship) && ( Ban from {title} @@ -358,9 +358,9 @@ function Participant(props: { ) : ( <> - + {(contact.patp !== window.ship) && ( Kick from {title} - + )} Promote to Admin From 44a17db1fb50efd910fa4a35bfb7aa94b203d7e3 Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Wed, 2 Dec 2020 16:16:02 -0500 Subject: [PATCH 886/933] groups: prevent demoting yourself if only admin --- pkg/interface/src/views/landscape/components/Participants.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/interface/src/views/landscape/components/Participants.tsx b/pkg/interface/src/views/landscape/components/Participants.tsx index a706c428fe..46836fc0e4 100644 --- a/pkg/interface/src/views/landscape/components/Participants.tsx +++ b/pkg/interface/src/views/landscape/components/Participants.tsx @@ -353,9 +353,9 @@ function Participant(props: { )} {role === 'admin' ? ( - + group?.tags?.role?.admin?.size > 1 && ( Demote from Admin - + ) ) : ( <> {(contact.patp !== window.ship) && ( From 3283bd7134f4b917e99869db65c1345790558a72 Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Wed, 2 Dec 2020 16:21:04 -0500 Subject: [PATCH 887/933] groups: add margin to mobile invite popover --- .../src/views/landscape/components/InvitePopover.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/interface/src/views/landscape/components/InvitePopover.tsx b/pkg/interface/src/views/landscape/components/InvitePopover.tsx index 4c6a20acb5..d66044f351 100644 --- a/pkg/interface/src/views/landscape/components/InvitePopover.tsx +++ b/pkg/interface/src/views/landscape/components/InvitePopover.tsx @@ -90,7 +90,9 @@ export function InvitePopover(props: InvitePopoverProps) { borderColor="washedGray" borderRadius={1} maxHeight="472px" - width="380px" + width="100%" + maxWidth="380px" + mx={[4,0]} bg="white" > Date: Wed, 2 Dec 2020 16:23:30 -0500 Subject: [PATCH 888/933] profile: amend mobile 'back' link size --- pkg/interface/src/views/apps/profile/profile.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/interface/src/views/apps/profile/profile.tsx b/pkg/interface/src/views/apps/profile/profile.tsx index 7bcae36c72..72b716a113 100644 --- a/pkg/interface/src/views/apps/profile/profile.tsx +++ b/pkg/interface/src/views/apps/profile/profile.tsx @@ -104,6 +104,7 @@ export default function ProfileScreen(props: any) { alignItems="center" px={3} borderBottom={1} + fontSize='0' borderBottomColor="washedGray" > {"<- Back"} From 000e8c69648e7a3538eaf84d3351c03dc1cf531f Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Wed, 2 Dec 2020 16:35:39 -0500 Subject: [PATCH 889/933] profile: add icons, sidebar bg matches others --- .../src/views/apps/profile/profile.tsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/pkg/interface/src/views/apps/profile/profile.tsx b/pkg/interface/src/views/apps/profile/profile.tsx index 72b716a113..672aa74f15 100644 --- a/pkg/interface/src/views/apps/profile/profile.tsx +++ b/pkg/interface/src/views/apps/profile/profile.tsx @@ -12,7 +12,16 @@ import { ContactCard } from "~/views/landscape/components/ContactCard"; const SidebarItem = ({ children, view, current }) => { const selected = current === view; - const color = selected ? "blue" : "black"; + const icon = (view) => { + switch(view) { + case 'identity': + return 'Smiley'; + case 'settings': + return 'Adjust'; + default: + return 'Circle' + } + } return ( { verticalAlign="middle" py={1} px={3} - backgroundColor={selected ? "washedBlue" : "white"} + backgroundColor={selected ? "washedGray" : "white"} > - - + + {children} From 49d66989fd5a04913d7b7fd387a27ba9be8d1f06 Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Wed, 2 Dec 2020 17:09:22 -0500 Subject: [PATCH 890/933] groups: fix sharing contacts with avatars Fixes #4064. --- .../src/views/landscape/components/ContactCard.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/interface/src/views/landscape/components/ContactCard.tsx b/pkg/interface/src/views/landscape/components/ContactCard.tsx index e167ea8a3a..eee9e57a22 100644 --- a/pkg/interface/src/views/landscape/components/ContactCard.tsx +++ b/pkg/interface/src/views/landscape/components/ContactCard.tsx @@ -71,12 +71,15 @@ const emptyContact = { export function ContactCard(props: ContactCardProps) { const us = `~${window.ship}`; const { contact, rootIdentity } = props; - const onSubmit = async (values: Contact, actions: FormikHelpers) => { + const onSubmit = async (values: any, actions: FormikHelpers) => { try { if(!contact) { const [,,ship] = props.path.split('/'); values.color = uxToHex(values.color); - await props.api.contacts.share(ship, props.path, us, values) + const sharedValues = Object.assign({}, values); + sharedValues.avatar = (values.avatar === "") ? null : { url: values.avatar }; + console.log(values); + await props.api.contacts.share(ship, props.path, us, sharedValues); actions.setStatus({ success: null }); return; } From bf31deb69821cb4ee2ae12697b08ddf3e041d71e Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Wed, 2 Dec 2020 17:20:01 -0500 Subject: [PATCH 891/933] profile: nickname and avatar surfaced --- pkg/interface/src/views/apps/profile/profile.tsx | 9 +++++++-- .../src/views/landscape/components/ContactCard.tsx | 14 ++++++++++++-- .../views/landscape/components/PopoverRoutes.tsx | 2 ++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/pkg/interface/src/views/apps/profile/profile.tsx b/pkg/interface/src/views/apps/profile/profile.tsx index 672aa74f15..01c14587fc 100644 --- a/pkg/interface/src/views/apps/profile/profile.tsx +++ b/pkg/interface/src/views/apps/profile/profile.tsx @@ -2,7 +2,7 @@ import React from "react"; import { Route, Link, Switch } from "react-router-dom"; import Helmet from 'react-helmet'; -import { Box, Text, Row, Col, Icon } from "@tlon/indigo-react"; +import { Box, Text, Row, Col, Icon, BaseImage } from "@tlon/indigo-react"; import { Sigil } from "~/logic/lib/sigil"; import { uxToHex, MOBILE_BROWSER_REGEX } from "~/logic/lib/util"; @@ -65,6 +65,9 @@ export default function ProfileScreen(props: any) { history.replace("/~profile/identity"); } + const image = (!props?.hideAvatars && contact?.avatar) + ? + : ; return ( - + {image} @@ -129,6 +132,8 @@ export default function ProfileScreen(props: any) { path="/~/default" api={props.api} s3={props.s3} + hideAvatars={props.hideAvatars} + hideNicknames={props.hideNicknames} /> )} diff --git a/pkg/interface/src/views/landscape/components/ContactCard.tsx b/pkg/interface/src/views/landscape/components/ContactCard.tsx index eee9e57a22..5f8bb920c0 100644 --- a/pkg/interface/src/views/landscape/components/ContactCard.tsx +++ b/pkg/interface/src/views/landscape/components/ContactCard.tsx @@ -10,6 +10,7 @@ import { Box, Text, Row, + BaseImage } from "@tlon/indigo-react"; import { Formik, FormikHelpers } from "formik"; import { Contact } from "~/types/contact-update"; @@ -25,6 +26,8 @@ interface ContactCardProps { api: GlobalApi; s3: S3State; rootIdentity: Contact; + hideAvatars: boolean; + hideNicknames: boolean; } const formSchema = Yup.object({ @@ -111,6 +114,11 @@ export function ContactCard(props: ContactCardProps) { }; const hexColor = contact?.color ? `#${uxToHex(contact.color)}` : "#000000"; + const image = (!props?.hideAvatars && contact?.avatar) + ? + : ; + + const nickname = (!props.hideNicknames && contact?.nickname) ? contact.nickname : ""; return ( @@ -132,9 +140,11 @@ export function ContactCard(props: ContactCardProps) { pb={3} alignItems="center" > - + + {image} + - {us} + {nickname} diff --git a/pkg/interface/src/views/landscape/components/PopoverRoutes.tsx b/pkg/interface/src/views/landscape/components/PopoverRoutes.tsx index 9c50487302..1ed935445b 100644 --- a/pkg/interface/src/views/landscape/components/PopoverRoutes.tsx +++ b/pkg/interface/src/views/landscape/components/PopoverRoutes.tsx @@ -144,6 +144,8 @@ export function PopoverRoutes( contact={props.contacts[window.ship]} rootIdentity={props.rootIdentity} api={props.api} + hideAvatars={props.hideAvatars} + hideNicknames={props.hideNicknames} path={props.association["group-path"]} s3={props.s3} /> From f099ec9505c4c820b1d534e9ff6623bc2217d51a Mon Sep 17 00:00:00 2001 From: fang Date: Thu, 3 Dec 2020 01:45:46 +0100 Subject: [PATCH 892/933] kh: use Word8 for Tint true color values Also does some minor style cleanup. --- pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs | 9 ++++++--- pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs | 7 +++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs b/pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs index f9d8510095..29d7187afd 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Arvo/Effect.hs @@ -13,6 +13,7 @@ import Urbit.Noun.Time import Urbit.Prelude import Control.Monad.Fail (fail) +import Numeric.Natural (Natural) import Urbit.Arvo.Common (KingId(..), ServId(..)) import Urbit.Arvo.Common (Header, HttpEvent, HttpServerConf, Method, Mime) import Urbit.Arvo.Common (AmesDest, Turf) @@ -144,7 +145,7 @@ data Tint | TintK | TintW | TintNull - | TintTrue Atom Atom Atom + | TintTrue Word8 Word8 Word8 deriving (Eq, Ord, Show) data Stye = Stye @@ -184,13 +185,15 @@ instance ToNoun Tint where TintK -> toNoun $ Cord "k" TintW -> toNoun $ Cord "w" TintNull -> Atom 0 - TintTrue r g b -> Cell (Atom r) $ Cell (Atom g) (Atom b) + TintTrue r g b -> Cell (atom r) $ Cell (atom g) (atom b) + where atom a = Atom (fromIntegral a :: Natural) instance FromNoun Tint where parseNoun = named "Tint" . \case Atom 0 -> pure TintNull Cell (Atom r) (Cell (Atom g) (Atom b)) - -> pure (TintTrue r g b) + -> pure (TintTrue (word r) (word g) (word b)) + where word w = fromIntegral w :: Word8 n -> parseNoun @Cord n <&> unCord >>= \case "r" -> pure TintR "g" -> pure TintG diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs index da43f289cb..0cfd065f78 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Term.hs @@ -403,8 +403,7 @@ localClient doneSignal = fst <$> mkRAcquire start stop TintW -> ['7'] TintNull -> ['9'] TintTrue r g b -> - mconcat ["8;2;", bite r, ";", bite g, ";", bite b] - where bite = show . flip mod 256 + mconcat ["8;2;", show r, ";", show g, ";", show b] -- Wraps the appropriate escape sequence around a piece of styled text termRenderStubSegment :: Stye -> [Char] -> [Char] @@ -420,10 +419,10 @@ localClient doneSignal = fst <$> mkRAcquire start stop [ intersperse ';' $ fmap termRenderDeco $ toList decoset , case back of TintNull -> [] - tint -> cons '4' $ termRenderTint tint + tint -> '4' : termRenderTint tint , case fore of TintNull -> [] - tint -> cons '3' $ termRenderTint tint + tint -> '3' : termRenderTint tint ] styled = mconcat [escape, styles, "m", tape, escape, "0m"] From 79308eb4edfadd94af76a20fb9b4c9417e0e275f Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Wed, 2 Dec 2020 22:48:33 -0800 Subject: [PATCH 893/933] chat-hook: fix another poke-import issue --- pkg/arvo/app/chat-hook.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/arvo/app/chat-hook.hoon b/pkg/arvo/app/chat-hook.hoon index cbc70f991d..15e374624c 100644 --- a/pkg/arvo/app/chat-hook.hoon +++ b/pkg/arvo/app/chat-hook.hoon @@ -707,7 +707,7 @@ =/ sty=state-10 :* %10 (remake-map ;;((tree [path ship]) +<.arc)) - ;;(? +<-.arc) + ;;(? +>-.arc) (remake-map ;;((tree [path ?]) +>+.arc)) == :_ sty From fb6488bc682173f7e33277bd11a686cb3250c2f1 Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Thu, 3 Dec 2020 13:16:27 -0500 Subject: [PATCH 894/933] interface: bump indigo-react 1.2.5 -> 1.2.15 --- pkg/interface/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/interface/package.json b/pkg/interface/package.json index af7d355078..04b1ba4fb4 100644 --- a/pkg/interface/package.json +++ b/pkg/interface/package.json @@ -9,7 +9,7 @@ "@reach/menu-button": "^0.10.5", "@reach/tabs": "^0.10.5", "@tlon/indigo-light": "^1.0.3", - "@tlon/indigo-react": "1.2.5", + "@tlon/indigo-react": "1.2.15", "@tlon/sigil-js": "^1.4.2", "aws-sdk": "^2.726.0", "big-integer": "^1.6.48", From 275144c72a9c0f5b5a82370a922528bdffe54739 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Thu, 3 Dec 2020 12:59:21 -0600 Subject: [PATCH 895/933] observe-hook: add %group-on-remove-member thread --- pkg/arvo/app/observe-hook.hoon | 60 ++++++++++++++---------- pkg/arvo/ted/group/on-remove-member.hoon | 23 +++++++++ 2 files changed, 59 insertions(+), 24 deletions(-) create mode 100644 pkg/arvo/ted/group/on-remove-member.hoon diff --git a/pkg/arvo/app/observe-hook.hoon b/pkg/arvo/app/observe-hook.hoon index 9f93de49a1..b298e87a2f 100644 --- a/pkg/arvo/app/observe-hook.hoon +++ b/pkg/arvo/app/observe-hook.hoon @@ -9,14 +9,12 @@ |% +$ card card:agent:gall +$ versioned-state - $% state-0 - state-1 + $% [%0 observers=(map serial observer:sur)] + [%1 observers=(map serial observer:sur)] + [%2 observers=(map serial observer:sur)] == :: +$ serial @uv -+$ state-0 [%0 observers=(map serial observer:sur)] -+$ state-1 [%1 observers=(map serial observer:sur)] -:: ++ got-by-val |= [a=(map serial observer:sur) b=observer:sur] ^- serial @@ -27,7 +25,7 @@ -- :: %- agent:dbug -=| state-1 +=| [%2 observers=(map serial observer:sur)] =* state - :: ^- agent:gall @@ -38,20 +36,16 @@ ++ on-init |^ ^- (quip card _this) :_ this - :~ %+ act - /inv-gra - [%watch %invite-store /invitatory/graph %invite-accepted-graph] - :: - %+ act - /grp-gra - [%watch %group-store /groups %group-on-leave] + :~ (act [%watch %invite-store /invitatory/graph %invite-accepted-graph]) + (act [%watch %group-store /groups %group-on-leave]) + (act [%watch %group-store /groups %group-on-remove-member]) == :: ++ act - |= [=wire =action:sur] + |= =action:sur ^- card :* %pass - wire + /poke %agent [our.bowl %observe-hook] %poke @@ -65,17 +59,35 @@ ++ on-load |= old-vase=vase ^- (quip card _this) + |^ =/ old-state !<(versioned-state old-vase) - ?- -.old-state - %1 `this(state old-state) + =| cards=(list card) + |- + ?: ?=(%2 -.old-state) + [cards this(state old-state)] + ?: ?=(%1 -.old-state) + =. cards + :_ cards + (act [%watch %group-store /groups %group-on-leave]) + $(-.old-state %2) + =. cards + :_ cards + (act [%watch %group-store /groups %group-on-remove-member]) + $(-.old-state %1) :: - %0 - =. state [%1 observers.old-state] - %+ on-poke - %observe-action - !> ^- action:sur - [%watch %group-store /groups %group-on-leave] - == + ++ act + |= =action:sur + ^- card + :* %pass + /poke + %agent + [our.bowl %observe-hook] + %poke + %observe-action + !> ^- action:sur + action + == + -- :: ++ on-poke |= [=mark =vase] diff --git a/pkg/arvo/ted/group/on-remove-member.hoon b/pkg/arvo/ted/group/on-remove-member.hoon new file mode 100644 index 0000000000..3c295353ab --- /dev/null +++ b/pkg/arvo/ted/group/on-remove-member.hoon @@ -0,0 +1,23 @@ +/- spider, grp=group-store +/+ strandio, res=resource +:: +=* strand strand:spider +=* raw-poke raw-poke:strandio +:: +^- thread:spider +|= arg=vase +=/ m (strand ,vase) +^- form:m +=+ !<([=update:grp ~] arg) +?. ?=(%remove-members -.update) + (pure:m !>(~)) +;< =bowl:spider bind:m get-bowl:strandio +?. (~(has in ships.update) our.bowl) + (pure:m !>(~)) +;< ~ bind:m + %+ raw-poke + [our.bowl %group-store] + :- %group-action + !> ^- action:grp + [%remove-group resource.update ~] +(pure:m !>(~)) From 9bb790e3e9822b2cccae912233f2382d492d8bc8 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 3 Dec 2020 14:25:31 -0800 Subject: [PATCH 896/933] ames: updates +end, +lsh, and +rsh call sites --- pkg/arvo/sys/vane/ames.hoon | 50 ++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index 5ffedece11..e41b70dfa1 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -242,11 +242,11 @@ |= [=public-key =private-key] ^- symmetric-key :: - ?> =('b' (end 3 1 public-key)) - =. public-key (rsh 8 1 (rsh 3 1 public-key)) + ?> =('b' (end 3 public-key)) + =. public-key (rsh 8 (rsh 3 public-key)) :: - ?> =('B' (end 3 1 private-key)) - =. private-key (rsh 8 1 (rsh 3 1 private-key)) + ?> =('B' (end 3 private-key)) + =. private-key (rsh 8 (rsh 3 private-key)) :: `@`(shar:ed:crypto public-key private-key) :: +encode-packet: serialize a packet into a bytestream @@ -262,13 +262,13 @@ =/ body=@ ;: mix sndr-tick - (lsh 2 1 rcvr-tick) - (lsh 3 1 sndr) - (lsh 3 +(size.sndr-meta) rcvr) - (lsh 3 +((add size.sndr-meta size.rcvr-meta)) content) + (lsh 2 rcvr-tick) + (lsh 3 sndr) + (lsh [3 +(size.sndr-meta)] rcvr) + (lsh [3 +((add size.sndr-meta size.rcvr-meta))] content) == - =/ checksum (end 0 20 (mug body)) - =? body ?=(^ origin) (mix u.origin (lsh 3 6 body)) + =/ checksum (end [0 20] (mug body)) + =? body ?=(^ origin) (mix u.origin (lsh [3 6] body)) :: =/ header=@ %+ can 0 @@ -280,7 +280,7 @@ [20 checksum] [1 relayed=.?(origin)] == - (mix header (lsh 5 1 body)) + (mix header (lsh 5 body)) :: +decode-packet: deserialize packet from bytestream or crash :: ++ decode-packet @@ -290,8 +290,8 @@ ~| %decode-packet-fail :: first 32 (2^5) bits are header; the rest is body :: - =/ header (end 5 1 blob) - =/ body (rsh 5 1 blob) + =/ header (end 5 blob) + =/ body (rsh 5 blob) :: read header; first three bits are reserved :: =/ is-ames (cut 0 [3 1] header) @@ -312,10 +312,10 @@ ?: =(| relayed) [~ body] =/ len (sub (met 3 body) 6) - [`(end 3 6 body) (rsh 3 6 body)] + [`(end [3 6] body) (rsh [3 6] body)] :: .checksum does not apply to the origin :: - ?. =(checksum (end 0 20 (mug body))) + ?. =(checksum (end [0 20] (mug body))) ~| %ames-checksum !! :: read fixed-length sndr and rcvr life data from body :: @@ -391,7 +391,7 @@ :: :: Logic duplicates +com:nu:crub:crypto and +sure:as:crub:crypto. :: - =/ key (end 8 1 (rsh 3 1 public-key.open-packet)) + =/ key (end 8 (rsh 3 public-key.open-packet)) ?> (veri:ed:crypto signature signed key) open-packet :: +encode-shut-packet: encrypt and packetize a $shut-packet @@ -419,7 +419,7 @@ =/ vec ~[sndr rcvr sndr-life rcvr-life] =/ [siv=@uxH len=@ cyf=@ux] (~(en sivc:aes:crypto (shaz symmetric-key) vec) (jam shut-packet)) - =/ content :(mix siv (lsh 7 1 len) (lsh 3 18 cyf)) + =/ content :(mix siv (lsh 7 len) (lsh [3 18] cyf)) [[sndr rcvr] (mod sndr-life 16) (mod rcvr-life 16) origin=~ content] :: +decode-shut-packet: decrypt a $shut-packet from a $packet :: @@ -431,9 +431,9 @@ ~| ames-sndr-tick+sndr-tick.packet !! ?. =(rcvr-tick.packet (mod rcvr-life 16)) ~| ames-rcvr-tick+rcvr-tick.packet !! - =/ siv (end 7 1 content.packet) - =/ len (end 4 1 (rsh 7 1 content.packet)) - =/ cyf (rsh 3 18 content.packet) + =/ siv (end 7 content.packet) + =/ len (end 4 (rsh 7 content.packet)) + =/ cyf (rsh [3 18] content.packet) ~| ames-decrypt+[[sndr rcvr origin]:packet len siv] =/ vec ~[sndr.packet rcvr.packet sndr-life rcvr-life] ;; shut-packet %- cue %- need @@ -1880,7 +1880,7 @@ =/ pumps=(list message-pump-state) %+ murn ~(tap by snd.peer-state) |= [=bone =message-pump-state] - ?: =(0 (end 0 1 bone)) + ?: =(0 (end 0 bone)) ~ `u=message-pump-state :: clogged: are five or more response messages unsent to this peer? @@ -2111,11 +2111,11 @@ ^+ peer-core :: if odd bone, ack is on "subscription update" message; no-op :: - ?: =(1 (end 0 1 bone)) + ?: =(1 (end 0 bone)) peer-core :: even bone; is this bone a nack-trace bone? :: - ?: =(1 (end 0 1 (rsh 0 1 bone))) + ?: =(1 (end 0 (rsh 0 bone))) :: nack-trace bone; assume .ok, clear nack from |message-sink :: =/ target-bone=^bone (mix 0b10 bone) @@ -2182,9 +2182,9 @@ :: even bone, 1 second bit: nack-trace %boon message :: ++ on-sink-memo - ?: =(1 (end 0 1 bone)) + ?: =(1 (end 0 bone)) on-sink-plea - ?: =(0 (end 0 1 (rsh 0 1 bone))) + ?: =(0 (end 0 (rsh 0 bone))) on-sink-boon on-sink-nack-trace :: +on-sink-boon: handle response message received by |message-sink From 5111831a036eadff8b8ec48a578ecf1075bb0239 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 3 Dec 2020 14:26:55 -0800 Subject: [PATCH 897/933] ames: use +rep to assemble message fragments --- pkg/arvo/sys/vane/ames.hoon | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index e41b70dfa1..b2e63e8e2c 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -180,10 +180,7 @@ sorted $(index +(index), sorted [(~(got by fragments) index) sorted]) :: - %- cue - %+ can 13 - %+ turn (flop sorted) - |=(a=@ [1 a]) + (cue (rep 13 (flop sorted))) :: +bind-duct: find or make new $bone for .duct in .ossuary :: ++ bind-duct From abb1e8f71739eeafe2c6e39f4faa85aa728d2865 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 3 Dec 2020 14:40:18 -0800 Subject: [PATCH 898/933] pill: all --- bin/brass.pill | 4 ++-- bin/ivory.pill | 4 ++-- bin/solid.pill | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/brass.pill b/bin/brass.pill index b6799d99cb..7b7fad8500 100644 --- a/bin/brass.pill +++ b/bin/brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c55d8f37ad4014bf92f04d0a4a74235f5514de84dad4dca58c40ae2900d06be2 -size 4788607 +oid sha256:1e3ad5f88585ef7938cc2c6b5e37a05e04b7a4e5a9d66f1e9e4c20bfa2d303e8 +size 5356007 diff --git a/bin/ivory.pill b/bin/ivory.pill index 0d68c9204c..3c2c7dfa0e 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3eaf1adbd6908b9d0cd653f62baf329bad4b738794bca20c74e8be33c3b8382c -size 2514048 +oid sha256:a2626da031efd3b1b7e743b86d62f959ea54274bf779d9dfb6fcd44dfc118092 +size 2711173 diff --git a/bin/solid.pill b/bin/solid.pill index c82cd9b4f6..638b96b3cd 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ec3b1bb741e14fabacf567c3ffaf3e3a0c473cba91f46e40b04613d588988cf3 -size 7217780 +oid sha256:5402f3b52a34bda8a7189be0644bb6e31c738f358edc272ed4e542f597ed1c07 +size 7294878 From 914c6ce570a694241dd0403fad0e3c00d5a2a063 Mon Sep 17 00:00:00 2001 From: Ted Blackman Date: Thu, 3 Dec 2020 17:43:02 -0500 Subject: [PATCH 899/933] vere/aes_siv: check claimed length for all key sizes --- pkg/urbit/jets/e/aes_siv.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/urbit/jets/e/aes_siv.c b/pkg/urbit/jets/e/aes_siv.c index 6fc2cf5bd2..707bcffa5d 100644 --- a/pkg/urbit/jets/e/aes_siv.c +++ b/pkg/urbit/jets/e/aes_siv.c @@ -104,6 +104,10 @@ static u3_noun _siv_de(c3_y* key_y, return u3_none; } + if ( c3y == u3qa_gth(u3r_met(3, txt), len) ) { + return u3_none; + } + while (u3_nul != ads) { c3_w ad_w = u3r_met(3, u3h(ads)); c3_y* ad_y = u3a_malloc(ad_w); @@ -330,9 +334,6 @@ u3qea_sivc_de(u3_atom key, if ( u3r_met(3, key) > 64 ) { return u3_none; } - if ( c3y == u3qa_gth(u3r_met(3, txt), len) ) { - return u3_none; - } u3r_bytes_reverse(0, 64, key_y, key); return _siv_de(key_y, 64, ads, iv, len, txt); From 84bec6f7c1dec4da3c5a6fe53937ac3d47b419a1 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 2 Dec 2020 11:15:21 -0800 Subject: [PATCH 900/933] clay: %pass's %home commits to arvo as %what, unconditionally --- pkg/arvo/sys/vane/clay.hoon | 118 +++++++++--------------------------- 1 file changed, 29 insertions(+), 89 deletions(-) diff --git a/pkg/arvo/sys/vane/clay.hoon b/pkg/arvo/sys/vane/clay.hoon index 08cd76dc67..ed6bf4204f 100644 --- a/pkg/arvo/sys/vane/clay.hoon +++ b/pkg/arvo/sys/vane/clay.hoon @@ -284,7 +284,10 @@ +$ move [p=duct q=(wind note gift:able)] :: local move +$ note :: out request $-> $~ [%b %wait *@da] :: - $% $: %a :: to %ames + $% $: %$ :: to arvo + $>(%what waif) :: + == :: + $: %a :: to %ames $>(%plea task:able:ames) :: == :: $: %b :: to %behn @@ -1394,15 +1397,11 @@ :: promote and fill in ankh :: promote and fill in mime cache :: - =/ sys-changes (need-sys-update changes) - ?: ?& =(%home syd) - !updated - |(!=(~ sys-changes) !=(~ (need-vane-update changes))) - == - (sys-update yoki new-data changes) + ?: &(=(%home syd) !updated) + (sys-update yoki new-data) :: clear caches if zuse reloaded :: - =/ is-zuse-new=? !=(~ sys-changes) + =/ is-zuse-new=? (need-sys-update changes) =. fod.dom ?: is-zuse-new *ford-cache @@ -1642,11 +1641,7 @@ :: ++ path-to-hoon |= [data=(map path (each page lobe)) =path] - (rain path (path-to-cord data path)) - :: - ++ path-to-cord - |= [data=(map path (each page lobe)) =path] - ^- @t + %+ rain path =/ datum (~(got by data) path) ?- -.datum %& (page-to-cord p.datum) @@ -1887,100 +1882,45 @@ :: ++ need-sys-update |= changes=(map path (each page lobe)) - ^- (map path (each page lobe)) - ~+ - ?: =(0 let.dom) - ~ - %- malt - %+ skim ~(tap by changes) + ^- ? + %+ lien ~(tap by changes) |= [=path *] ?| =(/sys/hoon/hoon path) =(/sys/arvo/hoon path) =(/sys/zuse/hoon path) == :: - ++ need-vane-update - |= changes=(map path (each page lobe)) - ^- (map path (each page lobe)) - ~+ - ?: =(0 let.dom) - ~ - %- malt - %+ skim ~(tap by changes) - |= [=path *] - =(/sys/vane (scag 2 path)) - :: :: Delay current update until sys update is complete :: ++ sys-update |= $: =yoki data=(map path (each page lobe)) - changes=(map path (each page lobe)) == ^+ ..park - =/ updates - %- ~(uni by (need-sys-update changes)) - (need-vane-update changes) ?> =(~ pud) =. pud `[syd yoki] |^ %. [hen %slip %c %pork ~] - =< emit - ?: (~(has by updates) /sys/hoon/hoon) - (reset &) - ?: (~(has by updates) /sys/arvo/hoon) - (reset |) - ?: (~(has by updates) /sys/zuse/hoon) - reboot - =/ vanes=(list [=path *]) ~(tap by updates) - |- ^+ ..park - ?~ vanes - ..park - ?. ?=([%sys %vane * %hoon ~] path.i.vanes) - ~& [%strange-sys-update path.i.vanes] - $(vanes t.vanes) - =. ..park (reload i.t.t.path.i.vanes) - $(vanes t.vanes) + emit:(pass-what files) :: - ++ reset - |= new-hoon=? + ++ files + ^- (list (pair path (cask))) + %+ murn + ~(tap by data) + |= [pax=path dat=(each page lobe)] + ^- (unit (pair path (cask))) + =/ xap (flop pax) + ?> ?=(^ xap) + ?. ?=(%hoon i.xap) ~ + :^ ~ (flop t.xap) %hoon + ?- -.dat + %& (page-to-cord p.dat) + %| (lobe-to-cord p.dat) + == + :: + ++ pass-what + |= fil=(list (pair path (cask))) ^+ ..park - ?. new-hoon - =/ arvo=@t (path-to-cord data /sys/arvo/hoon) - =. ..park (pass-lyra hoon=~ arvo) - reboot - =/ hoon=@t (path-to-cord data /sys/hoon/hoon) - =/ arvo=@t (path-to-cord data /sys/arvo/hoon) - =. ..park (pass-lyra `hoon arvo) - reboot - :: - ++ pass-lyra - |= [hoon=(unit @t) arvo=@t] - ^+ ..park - (emit hen %pass /reset %d %flog %lyra hoon arvo) - :: - ++ reboot - =/ zuse=@t (path-to-cord data /sys/zuse/hoon) - =. ..park - %- emit - [hen %pass /reboot %d %flog %veer %$ /sys/zuse/hoon zuse] - reload-all - :: - ++ reload-all - =/ vanes=(list term) - ~[%ames %behn %clay %dill %eyre %gall %iris %jael] - |- ^+ ..park - ?~ vanes - ..park - =. ..park (reload i.vanes) - $(vanes t.vanes) - :: - ++ reload - |= =term - =/ vane=@t (path-to-cord data /sys/vane/[term]/hoon) - %- emit - =/ tip (end 3 term) - =/ =path /sys/vane/[term]/hoon - [hen %pass /reload %d %flog %veer tip path vane] + (emit hen %pass /what %$ what/fil) -- -- :: From 0cc8c450a8bfef49b85b5d9b4d66b97e544c0320 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 2 Dec 2020 11:35:29 -0800 Subject: [PATCH 901/933] arvo: removes %lyra and %veer --- pkg/arvo/gen/hood/reboot.hoon | 13 --------- pkg/arvo/gen/hood/reload-desk.hoon | 14 ---------- pkg/arvo/gen/hood/reload.hoon | 14 ---------- pkg/arvo/gen/hood/reset.hoon | 13 --------- pkg/arvo/gen/reload-event.hoon | 26 ------------------ pkg/arvo/lib/hood/helm.hoon | 44 ------------------------------ pkg/arvo/lib/pill.hoon | 23 ---------------- pkg/arvo/sys/arvo.hoon | 22 ++------------- pkg/arvo/sys/vane/dill.hoon | 4 --- pkg/arvo/sys/zuse.hoon | 6 ---- 10 files changed, 3 insertions(+), 176 deletions(-) delete mode 100644 pkg/arvo/gen/hood/reboot.hoon delete mode 100644 pkg/arvo/gen/hood/reload-desk.hoon delete mode 100644 pkg/arvo/gen/hood/reload.hoon delete mode 100644 pkg/arvo/gen/hood/reset.hoon delete mode 100644 pkg/arvo/gen/reload-event.hoon diff --git a/pkg/arvo/gen/hood/reboot.hoon b/pkg/arvo/gen/hood/reboot.hoon deleted file mode 100644 index aa48d85cb3..0000000000 --- a/pkg/arvo/gen/hood/reboot.hoon +++ /dev/null @@ -1,13 +0,0 @@ -:: Helm: Reload %zuse and all vanes -:: -:::: /hoon/reboot/hood/gen - :: -/? 310 -:: -:::: - :: -:- %say -|= $: [now=@da eny=@uvJ bec=beak] - [arg=~ ~] - == -[%helm-reload ~[%z %a %b %c %d %e %g %i %j]] diff --git a/pkg/arvo/gen/hood/reload-desk.hoon b/pkg/arvo/gen/hood/reload-desk.hoon deleted file mode 100644 index c242a2da17..0000000000 --- a/pkg/arvo/gen/hood/reload-desk.hoon +++ /dev/null @@ -1,14 +0,0 @@ -:: Helm: Reload vane/s from desk -:: -:::: /hoon/reload-desk/hood/gen - :: -/? 310 -:: -:::: - :: -:- %say -|= $: [now=@da eny=@uvJ bec=beak] - [arg=[desk (list term)] ~] - == -:- %helm-reload-desk -arg diff --git a/pkg/arvo/gen/hood/reload.hoon b/pkg/arvo/gen/hood/reload.hoon deleted file mode 100644 index d22ea1b523..0000000000 --- a/pkg/arvo/gen/hood/reload.hoon +++ /dev/null @@ -1,14 +0,0 @@ -:: Helm: Reload vane/s -:: -:::: /hoon/reload/hood/gen - :: -/? 310 -:: -:::: - :: -:- %say -|= $: [now=@da eny=@uvJ bec=beak] - [arg=(list term) ~] - == -:- %helm-reload -arg diff --git a/pkg/arvo/gen/hood/reset.hoon b/pkg/arvo/gen/hood/reset.hoon deleted file mode 100644 index 0e15ce59fa..0000000000 --- a/pkg/arvo/gen/hood/reset.hoon +++ /dev/null @@ -1,13 +0,0 @@ -:: Helm: Reload hoon/hoon and all vanes -:: -:::: /hoon/reset/hood/gen - :: -/? 310 -:: -:::: - :: -:- %say -|= $: [now=@da eny=@uvJ bec=beak] - [arg=~ ~] - == -[%helm-reset ~] diff --git a/pkg/arvo/gen/reload-event.hoon b/pkg/arvo/gen/reload-event.hoon deleted file mode 100644 index 5d87775f6b..0000000000 --- a/pkg/arvo/gen/reload-event.hoon +++ /dev/null @@ -1,26 +0,0 @@ -:: Produce a raw event to reload a vane -:: -:: Try: .event/ovo +reload-event %c, then restart urbit with -:: -I pier/.urb/put/event.ovo -:: -:- %say -|= $: [now=@da eny=@uvJ bek=beak] - [[tam=term ~] ~] - == -:- %ovo -=/ top `path`/(scot %p p.bek)/[q.bek]/(scot r.bek) -=/ nam - =/ van=(list [term ~]) - :- zus=[%zuse ~] - ~(tap by dir:.^(arch %cy (welp top /sys/vane))) - ?. =(1 (met 3 tam)) - tam - =/ zaz=(list [p=knot ~]) - (skim van |=([a=term ~] =(tam (end 3 a)))) - ?> ?=([[@ ~] ~] zaz) - `term`p.i.zaz -=/ tip (end 3 nam) -=/ bip ?:(=('z' tip) %$ tip) -=/ way ?:(=('z' tip) (welp top /sys/[nam]) (welp top /sys/vane/[nam])) -=/ fil .^(@ %cx (welp way /hoon)) -[//arvo %veer bip way fil] diff --git a/pkg/arvo/lib/hood/helm.hoon b/pkg/arvo/lib/hood/helm.hoon index 8dd29c03de..336b066f08 100644 --- a/pkg/arvo/lib/hood/helm.hoon +++ b/pkg/arvo/lib/hood/helm.hoon @@ -154,47 +154,6 @@ ?> ?=([@t ~] pax) (flog %text "hi {(trip i.pax)} {?~(cop "" "un")}successful") :: -++ poke-reload |=(all=(list term) (poke-reload-desk %home all)) -++ poke-reload-desk :: reload vanes - |: $:,[syd=desk all=(list term)] =< abet - %- emil - %+ turn all - =+ top=`path`/(scot %p our.bowl)/[syd]/(scot %da now.bowl) - =/ van=(list [term ~]) - :- zus=[%zuse ~] - ~(tap by dir:.^(arch %cy (welp top /sys/vane))) - |= nam=@tas - =. nam - ?. =(1 (met 3 nam)) - nam - =/ zaz=(list [p=knot ~]) - (skim van |=([a=term ~] =(nam (end 3 a)))) - ?> ?=([[@ ~] ~] zaz) - `term`p.i.zaz - =+ tip=(end 3 nam) - =+ zus==('z' tip) - =+ way=?:(zus (welp top /sys/[nam]) (welp top /sys/vane/[nam])) - =+ fil=.^(@ %cx (welp way /hoon)) - [%pass /reload %arvo %d %flog %veer ?:(=('z' tip) %$ tip) way fil] -:: +poke-reset: send %lyra to initiate kernel upgrade -:: -:: And reinstall %zuse and the vanes with %veer. -:: Trigger with |reset. -:: -++ poke-reset - |= hood-reset=~ - =< abet - %- emil - ^- (list card:agent:gall) - =/ top=path /(scot %p our.bowl)/home/(scot %da now.bowl)/sys - =/ hun .^(@t %cx (welp top /hoon/hoon)) - =/ arv .^(@t %cx (welp top /arvo/hoon)) - ~! *task:able:dill - :- [%pass /reset %arvo %d %flog %lyra `hun arv] - %+ turn - (module-ova:pill top) - |=([=wire =flog:dill] [%pass wire %arvo %d %flog flog]) -:: ++ poke-trim |= pri=@ud =< abet (emit %pass /pack %arvo %d %flog %crop pri) @@ -253,9 +212,6 @@ %helm-pack =;(f (f !<(_+<.f vase)) poke-pack) %helm-pass =;(f (f !<(_+<.f vase)) poke-pass) %helm-rekey =;(f (f !<(_+<.f vase)) poke-rekey) - %helm-reload =;(f (f !<(_+<.f vase)) poke-reload) - %helm-reload-desk =;(f (f !<(_+<.f vase)) poke-reload-desk) - %helm-reset =;(f (f !<(_+<.f vase)) poke-reset) %helm-send-hi =;(f (f !<(_+<.f vase)) poke-send-hi) %helm-serve =;(f (f !<(_+<.f vase)) poke-serve) %helm-trim =;(f (f !<(_+<.f vase)) poke-trim) diff --git a/pkg/arvo/lib/pill.hoon b/pkg/arvo/lib/pill.hoon index 634310db70..9b683af396 100644 --- a/pkg/arvo/lib/pill.hoon +++ b/pkg/arvo/lib/pill.hoon @@ -17,29 +17,6 @@ [%boot ? $%($>(%fake task:able:jael) $>(%dawn task:able:jael))] unix-task == -:: +module-ova: vane load operations -:: -:: sys: full path to /sys directory -:: -++ module-ova - |= sys=path - ^- (list [wire [%veer term path cord]]) - %+ turn - ^- (list (pair term path)) - :~ [%$ /zuse] :: standard library - [%a /vane/ames] :: network - [%b /vane/behn] :: timer - [%c /vane/clay] :: revision control - [%d /vane/dill] :: console - [%e /vane/eyre] :: http server - [%g /vane/gall] :: applications - [%i /vane/iris] :: http client - [%j /vane/jael] :: identity and security - == - |= [=term =path] - =/ pax (weld sys path) - =/ txt .^(@ %cx (weld pax /hoon)) - [[%vane path] [%veer term pax txt]] :: +file-ovum: userspace filesystem load :: :: bas: full path to / directory diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index e4583e64da..d72ae5a335 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -271,21 +271,17 @@ == :: +$ waif - :: %lyra: upgrade kernel :: %trim: trim state, spam to all :: %vega: notify vanes post upgrade :: %what: update from files :: %whey: produce $mass :: XX remove, scry :: %verb: toggle laconicity - :: %veer: upgrade module :: - $% [%lyra hun=(unit @t) van=@t] - [%trim p=@ud] + $% [%trim p=@ud] [%vega ~] [%what p=(list (pair path (cask)))] [%whey ~] [%verb p=(unit ?)] - [%veer lal=@tas pax=path txt=@t] == +$ wasp :: %crud: reroute $ovum with $goof @@ -297,7 +293,7 @@ [%wyrd p=vere] == +$ wisp - $% $>(?(%verb %veer %what) waif) + $% $>(?(%verb %what) waif) $>(?(%wack %wyrd) wasp) [%whom p=ship] == @@ -1239,10 +1235,6 @@ ^+ ..pith ?^ dud ~>(%mean.'pith: goof' !!) ?- -.waif - %lyra =; wat $(waif wat) - :+ %what [/sys/arvo hoon/van.waif] - ?~ hun.waif ~ - [[/sys/hoon hoon/u.hun.waif] ~] :: :: %trim: clear state :: @@ -1255,10 +1247,6 @@ :: %vega (emit $/~ (spam /arvo !>(waif))) :: XX also out %verb ..pith(lac.fad ?~(p.waif !lac.fad u.p.waif)) - :: - %veer =/ pax - sys/?:(?=(%$ lal.waif) /zuse /vane/[(grow lal.waif)]) - $(waif what/[[pax hoon/txt.waif] ~]) :: %what ~(kel what p.waif) %whey ..pith(out [[//arvo mass/whey] out]) @@ -1331,7 +1319,7 @@ ^+ this :: XX update clients to %pass to arvo, remove :: - ?: ?=(?(%lyra %veer %verb %whey) -.card.ovum) + ?: ?=(?(%verb %whey) -.card.ovum) %- call ~> %mean.'xeno: bad waif' ;;(waif:pith card.ovum) @@ -1639,10 +1627,6 @@ |- ^+ ..poke ?- -.wip %verb ..poke(lac ?~(p.wip !lac u.p.wip)) - :: - %veer =/ pax - sys/?:(?=(%$ lal.wip) /zuse /vane/[(grow lal.wip)]) - $(q.ovo what/[[pax hoon/txt.wip] ~]) :: %wack ..poke(eny `p.wip) :: diff --git a/pkg/arvo/sys/vane/dill.hoon b/pkg/arvo/sys/vane/dill.hoon index 00feb64f6c..63351f0dac 100644 --- a/pkg/arvo/sys/vane/dill.hoon +++ b/pkg/arvo/sys/vane/dill.hoon @@ -44,9 +44,7 @@ $> $? %crud :: %heft :: %init :: XX obsolete? - %lyra :: %text :: - %veer :: %verb :: == :: task:able:dill :: @@ -118,11 +116,9 @@ (crud p.kyz q.kyz) %blew (send %rez p.p.kyz q.p.kyz) %heft (dump %whey ~) - %lyra (dump kyz) %meld (dump kyz) %pack (dump kyz) %crop (dump trim+p.kyz) - %veer (dump kyz) %verb (dump kyz) == :: diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index 1e1f30d8de..64225ba6d9 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -1098,11 +1098,9 @@ [%burl p=@t] :: activate url [%init p=@p] :: set owner [%logo ~] :: logout - [%lyra hoon=(unit @t) arvo=@t] :: upgrade kernel [%meld ~] :: unify memory [%pack ~] :: compact memory [%trim p=@ud] :: trim kernel state - [%veer p=@ta q=path r=@t] :: install vane [%verb ~] :: verbose mode [%whey ~] :: memory report == :: @@ -1121,13 +1119,11 @@ [%hook ~] :: this term hung up [%harm ~] :: all terms hung up $>(%init vane-task) :: after gall ready - [%lyra hoon=(unit @t) arvo=@t] :: upgrade kernel [%meld ~] :: unify memory [%noop ~] :: no operation [%pack ~] :: compact memory [%talk p=tank] :: [%text p=tape] :: - [%veer p=@ta q=path r=@t] :: install vane [%view session=~] :: watch session blits $>(%trim vane-task) :: trim state $>(%vega vane-task) :: report upgrade @@ -1190,11 +1186,9 @@ $% [%crop p=@ud] :: trim kernel state [%crud p=@tas q=(list tank)] :: [%heft ~] :: - [%lyra hoon=(unit @t) arvo=@t] :: upgrade kernel [%meld ~] :: unify memory [%pack ~] :: compact memory [%text p=tape] :: - [%veer p=@ta q=path r=@t] :: install vane [%verb ~] :: verbose mode == :: -- ::dill From a773ff408dfed28611e6e7ca1047f95865956261 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 2 Dec 2020 12:01:55 -0800 Subject: [PATCH 902/933] arvo: updates %dill to %pass %verb/%whey, removes %give to arvo --- pkg/arvo/sys/arvo.hoon | 10 ---------- pkg/arvo/sys/vane/dill.hoon | 9 ++++++--- pkg/arvo/sys/zuse.hoon | 2 -- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index d72ae5a335..23b90c2139 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -1317,16 +1317,6 @@ ++ xeno |= =ovum ^+ this - :: XX update clients to %pass to arvo, remove - :: - ?: ?=(?(%verb %whey) -.card.ovum) - %- call - ~> %mean.'xeno: bad waif' - ;;(waif:pith card.ovum) - :: - :: XX uncomment to restore previous routing - :: - :: =. wire.ovum $/wire.ovum this(out [ovum out]) -- -- diff --git a/pkg/arvo/sys/vane/dill.hoon b/pkg/arvo/sys/vane/dill.hoon index 63351f0dac..45756adf6f 100644 --- a/pkg/arvo/sys/vane/dill.hoon +++ b/pkg/arvo/sys/vane/dill.hoon @@ -33,7 +33,10 @@ +$ move [p=duct q=(wind note gift:able)] :: local move +$ note :: out request $-> $~ [%d %verb ~] :: - $% $: %c :: + $% $: %$ :: + $>(?(%verb %whey) waif) :: + == :: + $: %c :: $> $? %merg :: merge desks %perm :: change permissions %warp :: wait for clay hack @@ -115,11 +118,11 @@ %crud :: (send `dill-belt`[%cru p.kyz q.kyz]) (crud p.kyz q.kyz) %blew (send %rez p.p.kyz q.p.kyz) - %heft (dump %whey ~) + %heft (pass /whey %$ whey/~) %meld (dump kyz) %pack (dump kyz) %crop (dump trim+p.kyz) - %verb (dump kyz) + %verb (pass /verb %$ kyz) == :: ++ crud diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index 64225ba6d9..8abf6004d3 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -1101,8 +1101,6 @@ [%meld ~] :: unify memory [%pack ~] :: compact memory [%trim p=@ud] :: trim kernel state - [%verb ~] :: verbose mode - [%whey ~] :: memory report == :: +$ task :: in request ->$ $~ [%vega ~] :: From 862fa14823bd3397c566f0981cc218e501f39b2a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 2 Dec 2020 13:52:49 -0800 Subject: [PATCH 903/933] arvo: removes $curd, moves $card and $ovum to top level --- pkg/arvo/sys/arvo.hoon | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index 23b90c2139..0cb7784206 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -88,7 +88,7 @@ +| %interface :: :: $ball: dynamic kernel action -:: $curd: tagged, untyped event +:: $card: tagged, untyped event :: $duct: causal history :: +hobo: %soft task builder :: $goof: crash label and trace XX fail/ruin/crud/flaw/lack/miss @@ -108,7 +108,7 @@ :: +wite: kernel action/error builder :: +$ ball (wite [vane=term task=maze] maze) -+$ curd (cask) ++$ card (cask) +$ duct (list wire) ++ hobo |$ [a] @@ -121,7 +121,7 @@ (pair cord (each * (list mass))) +$ monk (each ship (pair @tas @ta)) +$ move [=duct =ball] -+$ ovum (pair wire curd) ++$ ovum [=wire =card] :: +$ roof (room vase) :: namespace +$ rook (room meta) :: meta-namespace @@ -490,11 +490,8 @@ :: $hoof: hoon source :: $news: collated updates :: $oped: module updates + :: $seed: next kernel source :: - :: XX replace top-level structures - :: - +$ card (cask) - +$ ovum [=wire =card] +$ hoof @t +$ news $: :: sys: installs + replacements @@ -1273,7 +1270,7 @@ ?~ wire.ovum ~>(%mean.'pith: bad wire' !!) :: - ?. ?=(?(%crud %wack %wyrd) -.card.ovum) + ?. ?=(?(%crud %wack %wyrd) p.card.ovum) (emit $/~ [*duct (gest ovum)] ~) :: =/ buz ~> %mean.'pith: bad wasp' @@ -1537,7 +1534,7 @@ now.sol now == :: - ~| poke+-.q.ovo + ~| poke/p.card.ovo =/ zef=(each (pair (list ovum) soul) (trap ^)) loop:(~(poke le:part [pit vil] sol) ovo) ?- -.zef @@ -1609,9 +1606,9 @@ |= [now=@da ovo=ovum] ^- ^ =/ wip - ~| [p.ovo p.q.ovo] + ~| poke/p.card.ovo ~> %mean.'arvo: bad wisp' - ;;(wisp q.ovo) + ;;(wisp card.ovo) :: =. ..poke |- ^+ ..poke From 83bd3943a8e61069bd95b6f2587a8bb2ace1212e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 2 Dec 2020 16:16:59 -0800 Subject: [PATCH 904/933] arvo: adds %lull, vane structures --- pkg/arvo/gen/ivory.hoon | 1 + pkg/arvo/sys/arvo.hoon | 143 ++++++++++++++++++++++-------------- pkg/arvo/sys/lull.hoon | 4 + pkg/arvo/sys/vane/clay.hoon | 137 +++++++++++++++------------------- pkg/arvo/sys/zuse.hoon | 2 +- pkg/urbit/include/c/motes.h | 1 + pkg/urbit/vere/pier.c | 2 +- 7 files changed, 157 insertions(+), 133 deletions(-) create mode 100644 pkg/arvo/sys/lull.hoon diff --git a/pkg/arvo/gen/ivory.hoon b/pkg/arvo/gen/ivory.hoon index c85587d3fc..858a6d975b 100644 --- a/pkg/arvo/gen/ivory.hoon +++ b/pkg/arvo/gen/ivory.hoon @@ -56,6 +56,7 @@ %what [/sys/hoon hoon/compiler-source] [/sys/arvo hoon/arvo-source] + [/sys/lull hoon/.^(@ %cx (weld sys /lull/hoon))] [/sys/zuse hoon/.^(@ %cx (weld sys /zuse/hoon))] == :: installed: Arvo gate (formal instance) with %zuse installed diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index 0cb7784206..52e02239df 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -18,6 +18,7 @@ :::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::: :::::: volume 3, Arvo models and skeleton :::::: :::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::: +=> ..ride => |% +| %global @@ -212,14 +213,20 @@ +$ grub $: :: who: identity once we know it :: eny: entropy once we learn it - :: bod: %zuse once we receive it + :: lac: laconicity as we want it + :: ver: the Outside as we see it + :: fat: source when we attain it + :: lul: %lull when we acquire it + :: zus: %zuse once we receive it + :: van: vanes while we desire it :: who=(unit ship) eny=(unit @) lac=? ver=(unit vere) fat=(unit (axal (cask))) - bod=(unit (trap vase)) + lul=(unit (trap vase)) + zus=(unit (trap vase)) van=(map term (trap vase)) == +$ heir @@ -248,10 +255,12 @@ == $= mod $: :: fat: filesystem + :: lul: %lull :: zus: %zuse :: van: vanes :: fat=(axal (cask)) + lul=vase zus=vase van=(map term vane) == @@ -501,7 +510,8 @@ use=(map path (cask)) == +$ oped - $: zus=(unit hoof) + $: lul=(unit hoof) + zus=(unit hoof) van=(list (cask hoof)) == +$ seed [hun=(unit hoof) arv=hoof] @@ -588,8 +598,20 @@ ++ adorn |= [del=news all=?] ^- (pair oped _fat) + :: lull: shared structures + :: + =^ lul fat + ?^ hav=(~(get by sys.del) /sys/lull) + :- `(sole u.hav) + (~(put de fat) /sys/lull u.hav) + :_ fat + ~| %adorn-no-lull + ?.(all ~ `(sole (need fil:(~(get de fat) /sys/lull)))) :: zuse: shared library :: + :: %lull is the subject of %zuse; force all if we have a new %lull + :: + =. all |(all ?=(^ lul)) =^ zus fat ?^ hav=(~(get by sys.del) /sys/zuse) :- `(sole u.hav) @@ -601,8 +623,9 @@ :: :: %zuse is the subject of the vanes; force all if we have a new %zuse :: + =. all |(all ?=(^ zus)) =| nav=(map term hoof) - =? nav |(all ?=(^ zus)) + =? nav all %- ~(gas by nav) %+ turn ~(tap by dir:(~(get de fat) /sys/vane)) @@ -621,7 +644,7 @@ [[`@tas`nam (sole q)] (~(put de taf) p q)] :: =; van - [[zus van] fat] + [[lul zus van] fat] %+ sort ~(tap by (~(gas by nav) new)) |=([[a=@tas *] [b=@tas *]] (aor a b)) -- :: adapt @@ -1211,9 +1234,14 @@ |= [del=news all=?] ^+ ..pith =^ job=oped fat.mod.sol (~(adorn adapt fat.mod.sol) del all) + =? lul.mod.sol ?=(^ lul.job) + $:(smit:va "lull" pit /sys/lull/hoon u.lul.job) =? zus.mod.sol ?=(^ zus.job) - $:(smit:va "zuse" pit /sys/zuse/hoon u.zus.job) - %- (wyrd kel.ver.zen [zuse/;;(@ud q:(slap zus.mod.sol limb/%zuse)) ~]) + $:(smit:va "zuse" lul.mod.sol /sys/zuse/hoon u.zus.job) + %- %+ wyrd kel.ver.zen + :~ lull/;;(@ud q:(slap lul.mod.sol limb/%lull)) + zuse/;;(@ud q:(slap zus.mod.sol limb/%zuse)) + == %= ..pith van.mod %+ roll van.job @@ -1297,7 +1325,8 @@ ^- (list (pair term @)) :~ hoon/hoon-version arvo/arvo - zuse/;;(@ q:(slap zus.mod limb/%zuse)) + lull/;;(@ud q:(slap lul.mod limb/%lull)) + zuse/;;(@ud q:(slap zus.mod limb/%zuse)) == =? lag.zen !=(rev.ver.zen rev.p.buz) ~&(%unlagging |) ..pith(ver.zen p.buz) @@ -1485,7 +1514,8 @@ ^- (list (pair term @)) :~ hoon/hoon-version arvo/arvo - zuse/;;(@ q:(slap zus.mod limb/%zuse)) + lull/;;(@ud q:(slap lul.mod limb/%lull)) + zuse/;;(@ud q:(slap zus.mod limb/%zuse)) == :: restore working state and resume :: @@ -1562,28 +1592,59 @@ :: with +wish and vane installation with the %veer event. :: => |% - ++ mint - |= [vax=vase lal=term pax=path txt=@t] - ^- (trap vase) - =/ cap ?:(?=(%$ lal) "zuse" "vane {}") - (smit:va:part cap vax pax txt) - :: ++ molt |= [now=@da grub] ^- (unit heir) - ?. &(?=(^ who) ?=(^ eny) ?=(^ ver) ?=(^ fat) ?=(^ bod)) + ?. &(?=(^ who) ?=(^ eny) ?=(^ ver) ?=(^ fat) ?=(^ lul) ?=(^ zus)) ~ - =/ zus $:u.bod + =/ lul $:u.lul + =/ zus $:u.zus %- %+ wyrd kel.u.ver ^- (list (pair term @)) :~ hoon/hoon-version arvo/arvo + lull/;;(@ud q:(slap lul limb/%lull)) zuse/;;(@ud q:(slap zus limb/%zuse)) == =/ nav %- ~(run by van) |=(a=(trap vase) (settle:va:part (slym $:a zus))) :^ ~ arvo *debt - [[u.who now u.eny] [lac] [u.ver |] u.fat zus nav] + [[u.who now u.eny] [lac] [u.ver |] u.fat lul zus nav] + :: + ++ what + |= [grub fil=(list (pair path (cask)))] + ^- grub + =* gub +<- + =/ taf (fall fat *(axal (cask))) + =/ del (~(group adapt:part taf) fil) + =/ tub (~(usurp adapt:part taf) del) + ?: &(?=(^ dir.taf) ?=(^ tub)) + ~>(%mean.'arvo: larval reboot' !!) :: XX support + :: + :: require, and unconditionally adopt, initial kernel source + :: + =? taf =(~ dir.taf) :: XX TMI + ~| %larval-need-kernel + ?> &(?=(^ tub) ?=(^ hun.p.u.tub)) + (~(gas de taf) q.u.tub) + :: + =^ job=oped:part taf (~(adorn adapt:part taf) del |) + =? lul ?=(^ lul.job) + `(smit:va:part "lull" pit /sys/lull/hoon u.lul.job) + =? zus ?=(^ zus.job) + ?. ?=(^ lul) + ~|(%larval-need-lull !!) + `(smit:va:part "zuse" $:u.lul /sys/zuse/hoon u.zus.job) + =? van !=(~ van.job) :: XX TMI + ?. ?=(^ zus) + ~|(%larval-need-zuse !!) + %+ roll van.job + |= [[(cask hoof:part)] =_van] + ^+ van + =/ way (wilt p) + %+ ~(put by van) way + (smit:va:part "vane {}" $:u.zus /sys/vane/[p]/hoon q) + gub(fat `taf) -- :: :: larval state, as a discriminable sample @@ -1605,66 +1666,38 @@ ++ poke :: +47 |= [now=@da ovo=ovum] ^- ^ + ~| poke/p.card.ovo =/ wip - ~| poke/p.card.ovo ~> %mean.'arvo: bad wisp' ;;(wisp card.ovo) :: =. ..poke - |- ^+ ..poke ?- -.wip %verb ..poke(lac ?~(p.wip !lac u.p.wip)) - :: %wack ..poke(eny `p.wip) - :: - %what =/ taf (fall fat *(axal (cask))) - =/ del (~(group adapt:part taf) p.wip) - =/ tub (~(usurp adapt:part taf) del) - ?: &(?=(^ dir.taf) ?=(^ tub)) - ~>(%mean.'arvo: larval reboot' !!) :: XX support - :: - :: require, and unconditionally adopt, initial kernel source - :: - =? taf =(~ dir.taf) :: XX TMI - ~| %larval-need-kernel - ?> &(?=(^ tub) ?=(^ hun.p.u.tub)) - (~(gas de taf) q.u.tub) - :: - =^ job taf [p q]:(~(adorn adapt:part taf) del |) - =? bod ?=(^ zus.job) - `(mint pit %$ /sys/zuse/hoon u.zus.job) - %= ..poke - fat `taf - van - %+ roll van.job - |= [[(cask hoof:part)] =_van] - ^+ van - ?> ?=(^ bod) - =/ way (wilt p) - (~(put by van) way (mint $:u.bod way /sys/vane/[p]/hoon q)) - == - :: + %what ..poke(gub (what gub p.wip)) %whom ..poke(who ~|(%whom-once ?>(?=(~ who) `p.wip))) :: %wyrd %- %+ wyrd kel.p.wip ^- (list (pair term @)) :* hoon/hoon-version arvo/arvo - ?~ bod ~ - [zuse/;;(@ud q:(slap $:u.bod limb/%zuse)) ~] + ?~ lul ~ + :- lull/;;(@ud q:(slap $:u.lul limb/%lull)) + ?~ zus ~ + [zuse/;;(@ud q:(slap $:u.zus limb/%zuse)) ~] == ..poke(ver `p.wip) == :: - ?~ hir=(molt now gub) - [~ ..poke] - :: :: upgrade once we've accumulated necessary state :: + ?~ hir=(molt now gub) + [~ ..poke] ~> %slog.[0 leaf+"arvo: metamorphosis"] (load u.hir) :: ++ wish :: +22 |= txt=* - q:(slap ?~(bod pit $:u.bod) (ream ;;(@t txt))) + q:(slap ?~(zus pit $:u.zus) (ream ;;(@t txt))) -- diff --git a/pkg/arvo/sys/lull.hoon b/pkg/arvo/sys/lull.hoon new file mode 100644 index 0000000000..ea8effd8c5 --- /dev/null +++ b/pkg/arvo/sys/lull.hoon @@ -0,0 +1,4 @@ +=> ..is +|% +++ lull %lull-kelvin +-- diff --git a/pkg/arvo/sys/vane/clay.hoon b/pkg/arvo/sys/vane/clay.hoon index ed6bf4204f..148fdfd6f3 100644 --- a/pkg/arvo/sys/vane/clay.hoon +++ b/pkg/arvo/sys/vane/clay.hoon @@ -127,6 +127,7 @@ +$ reef-cache $: hoon=vase arvo=vase + lull=vase zuse=vase == :: @@ -1401,7 +1402,7 @@ (sys-update yoki new-data) :: clear caches if zuse reloaded :: - =/ is-zuse-new=? (need-sys-update changes) + =/ is-zuse-new=? (need-reef-update changes) =. fod.dom ?: is-zuse-new *ford-cache @@ -1546,89 +1547,68 @@ (~(put by $(builds t.builds)) i.builds) :: ++ build-reef + => |% + +$ reef-step + :: vary: source or dependencies changed + :: deep: source and dependencies match kernel + :: + [vary=? deep=?] + -- + :: |= $: fer=(unit reef-cache) invalid=(set path) data=(map path (each page lobe)) == - ^- reef-cache - ?: =(%home syd) - [!>(..ride) !>(..is) !>(..zuse)] - |^ - ?: |(?=(~ fer) (~(has in invalid) /sys/hoon/hoon)) - =/ [home=? hoon=vase] - ?: (same-as-home /sys/hoon/hoon) - &+!>(..ride) - |+build-hoon - :- hoon - =/ [home=? arvo=vase] - ?: &(home (same-as-home /sys/arvo/hoon)) - &+!>(..is) - |+(build-arvo hoon) - :- arvo - ?: &(home (same-as-home /sys/zuse/hoon)) - !>(..zuse) - (build-zuse arvo) - :- hoon.u.fer - ?: (~(has in invalid) /sys/arvo/hoon) - =/ [home=? arvo=vase] - ?: &((same-as-home /sys/hoon/hoon) (same-as-home /sys/arvo/hoon)) - &+!>(..is) - |+(build-arvo hoon.u.fer) - :- arvo - ?: &(home (same-as-home /sys/zuse/hoon)) - !>(..zuse) - (build-zuse arvo) - :- arvo.u.fer - ?: (~(has in invalid) /sys/zuse/hoon) - ?: ?& (same-as-home /sys/hoon/hoon) - (same-as-home /sys/arvo/hoon) - (same-as-home /sys/zuse/hoon) + |^ ^- reef-cache + =/ [tep=reef-step ref=reef-cache] + ?^ fer + [[vary=| deep=&] u.fer] + [[vary=& deep=&] *reef-cache] + :: + =^ hon tep (build tep /sys/hoon hoon.ref !>(**) !,(*hoon ..ride)) + =^ rav tep (build tep /sys/arvo arvo.ref hon !,(*hoon ..part)) + =^ lul tep (build tep /sys/lull lull.ref rav !,(*hoon .)) + =^ zus tep (build tep /sys/zuse zuse.ref rav !,(*hoon .)) + [hon rav lul zus] + :: + ++ build + |= [tep=reef-step pax=path pre=vase sub=vase pro=hoon] + ^- (pair vase reef-step) + =/ ful (weld pax /hoon) + ?. ?| vary.tep + (~(has in invalid) ful) == - !>(..zuse) - (build-zuse arvo.u.fer) - zuse.u.fer - :: - ++ build-hoon - %- road |. - ~> %slog.0^leaf+"clay: building hoon on {}" + [pre tep] + =. vary.tep & + =/ src (path-to-cord data ful) + :: + ?: &(deep.tep (deep pax src)) + [(slap !>(..zuse) pro) tep] + :: + =/ nam=term ?.(?=([@ta @ta *] pax) %$ i.t.pax) + ~> %slog.0^leaf+"clay: building %{(trip nam)} on %{(trip syd)}" =/ gen - ~> %mean.%hoon-parse-fail - (path-to-hoon data /sys/hoon/hoon) - ~> %mean.%hoon-compile-fail - (slot 7 (slap !>(0) gen)) + ~_ leaf+"%{(trip nam)}-parse-fail" + (rain ful src) + ~_ leaf+"%{(trip nam)}-compile-fail" + [(slap (slap sub gen) pro) tep(deep |)] :: - ++ build-arvo - |= hoon=vase - %- road |. - ~> %slog.0^leaf+"clay: building arvo on {}" - =/ gen - ~> %mean.%arvo-parse-fail - (path-to-hoon data /sys/arvo/hoon) - ~> %mean.%arvo-compile-fail - (slap (slap hoon gen) !,(*^hoon ..is)) - :: - ++ build-zuse - |= arvo=vase - %- road |. - ~> %slog.0^leaf+"clay: building zuse on {}" - =/ gen - ~> %mean.%zuse-parse-fail - (path-to-hoon data /sys/zuse/hoon) - ~> %mean.%zuse-compile-fail - (slap arvo gen) - :: - ++ same-as-home - |= =path + ++ deep + |= [pax=path src=cord] ^- ? + :: XX scry into arvo + :: + :: //=//=/mod/fat + :: =+ (~(get ^de fat) pax) + :: &(?=(^ fil) ?=(%hoon p.fil) =(src q.fil)) + :: =/ our-lobe=lobe - =/ datum (~(got by data) path) - ?- -.datum - %& (page-to-lobe %hoon (page-to-cord p.datum)) - %| p.datum - == + (page-to-lobe hoon/src) =/ =dome dom:(~(got by dos.rom) %home) =/ =yaki (~(got by hut.ran) (~(got by hit.dome) let.dome)) - =(`our-lobe (~(get by q.yaki) path)) + =/ lobe=(unit lobe) + (~(get by q.yaki) (weld pax /hoon)) + &(?=(^ lobe) =(our-lobe u.lobe)) -- :: ++ page-to-cord @@ -1641,7 +1621,11 @@ :: ++ path-to-hoon |= [data=(map path (each page lobe)) =path] - %+ rain path + (rain path (path-to-cord data path)) + :: + ++ path-to-cord + |= [data=(map path (each page lobe)) =path] + ^- @t =/ datum (~(got by data) path) ?- -.datum %& (page-to-cord p.datum) @@ -1878,15 +1862,16 @@ test-ankh (~(got by dir.test-ankh) ta) == :: - :: Find /sys changes; does not reload on first commit + :: Find reef dependency changes :: - ++ need-sys-update + ++ need-reef-update |= changes=(map path (each page lobe)) ^- ? %+ lien ~(tap by changes) |= [=path *] ?| =(/sys/hoon/hoon path) =(/sys/arvo/hoon path) + =(/sys/lull/hoon path) =(/sys/zuse/hoon path) == :: diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index 8abf6004d3..dbe5265730 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -29,7 +29,7 @@ :: it's important to keep %zuse minimal. models and :: engines not used outside a vane should stay inside :: that vane. -~% %zuse +> ~ +~% %zuse ..is ~ => :: :: :: :::: :: :: (1) models diff --git a/pkg/urbit/include/c/motes.h b/pkg/urbit/include/c/motes.h index 10f00710ef..206f69dcc7 100644 --- a/pkg/urbit/include/c/motes.h +++ b/pkg/urbit/include/c/motes.h @@ -696,6 +696,7 @@ # define c3__low c3_s3('l','o','w') # define c3__lsh c3_s3('l','s','h') # define c3__lt c3_s2('l','t') +# define c3__lull c3_s4('l','u','l','l') # define c3__lunt c3_s4('l','u','n','t') # define c3__mack c3_s4('m','a','c','k') # define c3__mach c3_s4('m','a','c','h') diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index 31a5dad76b..02d15f2834 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -793,7 +793,7 @@ _pier_wyrd_card(u3_pier* pir_u) // u3_noun ver = u3nq(u3i_string(VERE_NAME), VERE_MAJOR, VERE_MINOR, VERE_PATCH); u3_noun kel = u3nl(u3nc(c3__zuse, VERE_ZUSE), // XX god_u->zus_w - // u3nc(c3__lull, PIER_LULL), // XX define + u3nc(c3__lull, u3i_string("lull-kelvin")), // XX define u3nc(c3__arvo, u3i_string("arvo-kelvin")), // XX from both king and serf? u3nc(c3__hoon, 141), // god_u->hon_y u3nc(c3__nock, 4), // god_u->noc_y From cea0db4670f4648552ec7c150541a2ae88036dea Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 3 Dec 2020 13:56:25 -0800 Subject: [PATCH 905/933] arvo: fills out scry interface --- pkg/arvo/sys/arvo.hoon | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index 52e02239df..77dd78e026 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -1287,9 +1287,11 @@ == ~ ?+ s.bem ~ - [%whey ~] ``mass/!>(whey) - [%zen %lag ~] ``noun/!>(lag.zen) - [%zen %vere ~] ``noun/!>(ver.zen) + [%whey ~] ``mass/!>(whey) + [%fad %lac ~] ``noun/!>(lac.fad) + [%zen %lag ~] ``noun/!>(lag.zen) + [%zen %ver ~] ``noun/!>(ver.zen) + [%mod %fat *] ``noun/!>((~(get de fat.mod) t.t.s.bem)) == :: ++ poke From 81b868a3644f3fc73d38df714e6e0fc30495e012 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 3 Dec 2020 13:57:00 -0800 Subject: [PATCH 906/933] clay: scry kernel source out of arvo for reef short-circuit --- pkg/arvo/sys/vane/clay.hoon | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/pkg/arvo/sys/vane/clay.hoon b/pkg/arvo/sys/vane/clay.hoon index 148fdfd6f3..95f18a1248 100644 --- a/pkg/arvo/sys/vane/clay.hoon +++ b/pkg/arvo/sys/vane/clay.hoon @@ -1596,19 +1596,18 @@ ++ deep |= [pax=path src=cord] ^- ? - :: XX scry into arvo + :: XX use roof :: - :: //=//=/mod/fat - :: =+ (~(get ^de fat) pax) - :: &(?=(^ fil) ?=(%hoon p.fil) =(src q.fil)) + :: =/ dat (rof `[our ~ ~] $/[[our $/da/now] mod/fat/pax]) + :: ?: |(?=(~ dat) ?=(~ u.dat)) | + :: =/ nod !<((axal (cask)) q.u.u.dat) :: - =/ our-lobe=lobe - (page-to-lobe hoon/src) - =/ =dome dom:(~(got by dos.rom) %home) - =/ =yaki (~(got by hut.ran) (~(got by hit.dome) let.dome)) - =/ lobe=(unit lobe) - (~(get by q.yaki) (weld pax /hoon)) - &(?=(^ lobe) =(our-lobe u.lobe)) + =/ dat + ;; (unit (unit (axal (cask)))) + ((sloy-light ski) [hoon-version %noun] %$ our %$ da/now mod/fat/pax) + ?: |(?=(~ dat) ?=(~ u.dat)) | + =* nod u.u.dat + &(?=(^ fil.nod) ?=(%hoon p.u.fil.nod) =(src q.u.fil.nod)) -- :: ++ page-to-cord From 6fc40bcea4114f10b9ca30b04211a9c106db8c0a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 3 Dec 2020 15:53:18 -0800 Subject: [PATCH 907/933] pill: solid --- bin/solid.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index 638b96b3cd..5876fd3b34 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5402f3b52a34bda8a7189be0644bb6e31c738f358edc272ed4e542f597ed1c07 -size 7294878 +oid sha256:80f25c7953348649f4151c43b03a8025abf458054c66c110839c4c4388c53d06 +size 7345051 From 7584b4d33c8778ddba099d87148d4b9e356c1d1a Mon Sep 17 00:00:00 2001 From: Tyler Brown Cifu Shuster Date: Wed, 2 Dec 2020 19:36:39 -0800 Subject: [PATCH 908/933] eyre: translate login to indigo fixes https://github.com/urbit/landscape/issues/154 --- pkg/arvo/sys/vane/eyre.hoon | 273 ++++++++++++++---------------- pkg/arvo/tests/sys/vane/eyre.hoon | 2 +- 2 files changed, 132 insertions(+), 143 deletions(-) diff --git a/pkg/arvo/sys/vane/eyre.hoon b/pkg/arvo/sys/vane/eyre.hoon index 109397c006..67f28effbc 100644 --- a/pkg/arvo/sys/vane/eyre.hoon +++ b/pkg/arvo/sys/vane/eyre.hoon @@ -236,16 +236,20 @@ :: +login-page: internal page to login to an Urbit :: ++ login-page - |= [redirect-url=(unit @t) our=@p] + |= [redirect-url=(unit @t) our=@p failed=?] ^- octs =+ redirect-str=?~(redirect-url "" (trip u.redirect-url)) %- as-octs:mimes:html %- crip %- en-xml:html + =/ favicon %+ + weld "" + "" ;html ;head ;meta(charset "utf-8"); ;meta(name "viewport", content "width=device-width, initial-scale=1, shrink-to-fit=no"); + ;link(rel "icon", type "image/svg+xml", href (weld "data:image/svg+xml;utf8," favicon)); ;title:"OS1" ;style:''' @import url("https://rsms.me/inter/inter.css"); @@ -254,167 +258,152 @@ src: url("https://storage.googleapis.com/media.urbit.org/fonts/scp-regular.woff"); font-weight: 400; } - html, body { + :root { + --red05: rgba(255,65,54,0.05); + --red100: rgba(255,65,54,1); + --blue05: rgba(33,157,255,0.05); + --blue30: rgba(33,157,255,0.3); + --blue100: rgba(33,157,255,1); + --black05: rgba(0,0,0,0.05); + --black20: rgba(0,0,0,0.2); + --black60: rgba(0,0,0,0.6); + --white: rgba(255,255,255,1); + } + html { font-family: Inter, sans-serif; height: 100%; - margin: 0 !important; + margin: 0; width: 100%; - background: #fff; - color: #000; + background: var(--white); + color: var(--black100); -webkit-font-smoothing: antialiased; line-height: 1.5; - font-size: 12pt; + font-size: 12px; + display: flex; + flex-flow: row nowrap; + justify-content: center; } - a, a:visited { - color: #000; - text-decoration: none; - font-size: 0.875rem; + body { + display: flex; + flex-flow: column nowrap; + justify-content: center; + max-width: 300px; + padding: 1rem; + width: 100%; } - p { - margin-block-start: 0; - margin-block-end: 0; - font-size: 0.875rem; + body > *, + form > input { + width: 100%; + } + form { + display: flex; + flex-flow: column; + align-items: flex-start; } input { - width: 100%; - padding: 0.75rem; - border: 1px solid #e6e6e6; - margin-top: 0.25rem; - margin-bottom: 1rem; - font-size: 0.875rem; + background: transparent; + border: 1px solid var(--black20); + padding: 8px; + border-radius: 4px; + font-size: inherit; + color: var(--black); + box-shadow: none; + } + input:disabled { + background: var(--black05); + color: var(--black60); } input:focus { - outline: 0; - border: 1px solid #000; + outline: none; + border-color: var(--blue30); } - button { - -webkit-appearance: none; - padding: 0.75rem; - background-color: #eee; - border: 1px solid #d1d2d3; - color: #666; - font-size: 0.875rem; - border-radius: 0; + input:invalid:not(:focus) { + background: var(--red05); + border-color: var(--red100); + outline: none; + color: var(--red100); } - footer { - position: absolute; - bottom: 0; + button[type=submit] { + margin-top: 16px; + padding: 8px 16px; + border-radius: 4px; + background: var(--blue100); + color: var(--white); + border: 1px solid var(--blue100); + } + input:invalid ~ button[type=submit] { + border-color: currentColor; + background: var(--blue05); + color: var(--blue30); + pointer-events: none; + } + span.failed { + display: flex; + flex-flow: row nowrap; + height: 16px; + align-items: center; + margin-top: 6px; + color: var(--red100); + } + span.failed svg { + height: 12px; + margin-right: 6px; + } + span.failed circle, + span.failed line { + fill: transparent; + stroke: currentColor } .mono { - font-family: "Source Code Pro", monospace; - } - .gray2 { - color: #7f7f7f; - } - .f9 { - font-size: 0.75rem; - } - .relative { - position: relative; - } - .absolute { - position: absolute; - } - .w-100 { - width: 100%; - } - .tr { - text-align: right; - } - .pb2 { - padding-bottom: 0.5rem; - } - .pr1 { - padding-right: 0.25rem; - } - .pr2 { - padding-right: .5rem; - } - .dn { - display: none; - } - #main { - width: 100%; - height: 100%; - } - #inner { - position: fixed; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); + font-family: 'Source Code Pro', monospace; } @media all and (prefers-color-scheme: dark) { - html, body { - background-color: #333; - color: #fff; - } - a, a:visited { - color: #fff; - } - input { - background: #333; - color: #fff; - border: 1px solid #7f7f7f; - } - input:focus { - border: 1px solid #fff; - } - } - @media all and (min-width: 34.375rem) { - .tc-ns { - text-align: center; - } - .pr0-ns { - padding-right: 0; - } - .dib-ns { - display: inline-block; + :root { + --white: rgb(51, 51, 51); + --black100: rgba(255,255,255,1); + --black05: rgba(255,255,255,0.05); + --black20: rgba(255,255,255,0.2); } } ''' == ;body - ;div#main - ;div#inner - ;p:"Urbit ID" - ;input(value "{(scow %p our)}", disabled "true", class "mono"); - ;p:"Access Key" - ;p.f9.gray2 - ; Get key from Bridge, or - ;span.mono.pr1:"+code" - ; in dojo - == - ;form(action "/~/login", method "post", enctype "application/x-www-form-urlencoded") - ;input - =type "password" - =name "password" - =placeholder "sampel-ticlyt-migfun-falmel" - =class "mono" - =autofocus "true"; - ;input(type "hidden", name "redirect", value redirect-str); - ;button(type "submit"):"Continue" - == - == - ;footer.absolute.w-100 - ;div.relative.w-100.tr.tc-ns - ;p.pr2.pr0-ns.pb2 - ;a(href "https://bridge.urbit.org", target "_blank") - ;span.dn.dib-ns.pr1:"Open" - ; Bridge ↗ - == - ;a - =href "https://urbit.org/using/install/#id" - =style "margin-left: 8px; color: #2aa779;" - =target "_blank" - ; Purchase - ;span.dn.dib-ns.pr1:"an Urbit ID" - ; ↗ - == + ;p:"Urbit ID" + ;input(value "{(scow %p our)}", disabled "true", class "mono"); + ;p:"Access Key" + ;form(action "/~/login", method "post", enctype "application/x-www-form-urlencoded") + ;input + =type "password" + =name "password" + =placeholder "sampel-ticlyt-migfun-falmel" + =class "mono" + =required "true" + =minlength "27" + =maxlength "27" + =pattern "((?:[a-z]\{6}-)\{3}(?:[a-z]\{6}))" + =autofocus "true"; + ;input(type "hidden", name "redirect", value redirect-str); + ;+ ?. failed ;span; + ;span.failed + ;svg(xmlns "http://www.w3.org/2000/svg", viewBox "0 0 12 12") + ;circle(cx "6", cy "6", r "5.5"); + ;line(x1 "3.27", y1 "3.27", x2 "8.73", y2 "8.73"); + ;line(x1 "8.73", y1 "3.27", x2 "3.27", y2 "8.73"); == + Key is incorrect == - == + ;button(type "submit"):"Continue" == == + ;script:''' + var failSpan = document.querySelector('.failed'); + if (failSpan) { + document.querySelector("input[type=password]") + .addEventListener('keyup', function (event) { + failSpan.style.display = 'none'; + }); + } + ''' == :: +render-tang-to-marl: renders a tang and adds
tags between each line :: @@ -862,28 +851,28 @@ :: =+ request-line=(parse-request-line url.request) %^ return-static-data-on-duct 200 'text/html' - (login-page (get-header:http 'redirect' args.request-line) our) + (login-page (get-header:http 'redirect' args.request-line) our %.n) :: if we are not a post, return an error :: ?. =('POST' method.request) - (return-static-data-on-duct 400 'text/html' (login-page ~ our)) + (return-static-data-on-duct 400 'text/html' (login-page ~ our %.n)) :: we are a post, and must process the body type as form data :: ?~ body.request - (return-static-data-on-duct 400 'text/html' (login-page ~ our)) + (return-static-data-on-duct 400 'text/html' (login-page ~ our %.n)) :: =/ parsed=(unit (list [key=@t value=@t])) (rush q.u.body.request yquy:de-purl:html) ?~ parsed - (return-static-data-on-duct 400 'text/html' (login-page ~ our)) + (return-static-data-on-duct 400 'text/html' (login-page ~ our %.n)) :: =/ redirect=(unit @t) (get-header:http 'redirect' u.parsed) ?~ password=(get-header:http 'password' u.parsed) - (return-static-data-on-duct 400 'text/html' (login-page redirect our)) + (return-static-data-on-duct 400 'text/html' (login-page redirect our %.n)) :: check that the password is correct :: ?. =(u.password code) - (return-static-data-on-duct 400 'text/html' (login-page redirect our)) + (return-static-data-on-duct 400 'text/html' (login-page redirect our %.y)) :: mint a unique session cookie :: =/ session=@uv diff --git a/pkg/arvo/tests/sys/vane/eyre.hoon b/pkg/arvo/tests/sys/vane/eyre.hoon index 61dc66b53d..a05bcf5917 100644 --- a/pkg/arvo/tests/sys/vane/eyre.hoon +++ b/pkg/arvo/tests/sys/vane/eyre.hoon @@ -2229,7 +2229,7 @@ %+ complete-http-start-event :- 200 ['content-type' 'text/html']~ - [~ (login-page:eyre-gate `'/~landscape/inner-path' ~nul)] + [~ (login-page:eyre-gate `'/~landscape/inner-path' ~nul %.n)] == == == :: a response post redirects back to the application, setting cookie From ed6c20a7a6362df90c0011509f6762bbb0061785 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Thu, 3 Dec 2020 17:37:18 -0800 Subject: [PATCH 909/933] Revert "zuse: change to ropsten" This reverts commit d15d5ba1752e8d27b2da324a85216eeb6b065f2f. --- pkg/arvo/sys/zuse.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index 1e1f30d8de..a6ade2bec1 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -7971,7 +7971,7 @@ :: # constants :: :: contract addresses - ++ contracts ropsten-contracts + ++ contracts mainnet-contracts ++ mainnet-contracts |% :: azimuth: data contract From e8ba12c7e342cc8be9ecb2d779ebb1cae53bd403 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Fri, 4 Dec 2020 11:49:10 +1000 Subject: [PATCH 910/933] pull-hook: L review --- pkg/arvo/lib/pull-hook.hoon | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/arvo/lib/pull-hook.hoon b/pkg/arvo/lib/pull-hook.hoon index 78566ad3c2..606c057ae0 100644 --- a/pkg/arvo/lib/pull-hook.hoon +++ b/pkg/arvo/lib/pull-hook.hoon @@ -158,6 +158,7 @@ og ~(. pull-hook bowl) hc ~(. +> bowl) def ~(. (default-agent this %|) bowl) + :: ++ on-init ^- [(list card:agent:gall) agent:gall] =^ cards pull-hook @@ -311,6 +312,7 @@ -- |_ =bowl:gall +* og ~(. pull-hook bowl) + :: ++ mule-scry |= [ref=* raw=*] =/ pax=(unit path) From 90b27bd171cec430bf0d8e939dbf17a2cfaf175d Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Thu, 3 Dec 2020 18:01:17 -0800 Subject: [PATCH 911/933] pill: mainnet --- bin/ivory.pill | 4 ++-- bin/solid.pill | 4 ++-- pkg/urbit/version | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/ivory.pill b/bin/ivory.pill index 3c2c7dfa0e..cbf84b0fd1 100644 --- a/bin/ivory.pill +++ b/bin/ivory.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a2626da031efd3b1b7e743b86d62f959ea54274bf779d9dfb6fcd44dfc118092 -size 2711173 +oid sha256:1ddcdd98af2befa672da7bbf74ba5170cd5b079f2fb75deb24685608da6a29c8 +size 2841752 diff --git a/bin/solid.pill b/bin/solid.pill index 638b96b3cd..517533e844 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5402f3b52a34bda8a7189be0644bb6e31c738f358edc272ed4e542f597ed1c07 -size 7294878 +oid sha256:a4d5ce04d9578576ff4d2eb5fcfbafd3d830e80ad66fcce896080aeccdd97ad6 +size 9548407 diff --git a/pkg/urbit/version b/pkg/urbit/version index 706e712b06..0701ea274d 100644 --- a/pkg/urbit/version +++ b/pkg/urbit/version @@ -1 +1 @@ -0.10.9-rc1 \ No newline at end of file +0.10.9-main-post From d22f3f04c218aef2d84e67b78810426cf26d889e Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Thu, 3 Dec 2020 19:34:56 -0800 Subject: [PATCH 912/933] version: strip trailing newline --- pkg/urbit/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/urbit/version b/pkg/urbit/version index 0701ea274d..a820902461 100644 --- a/pkg/urbit/version +++ b/pkg/urbit/version @@ -1 +1 @@ -0.10.9-main-post +0.10.9-main-post \ No newline at end of file From cd0a5a67a06f661e3b693a122563081b15b468db Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Thu, 3 Dec 2020 22:50:37 -0800 Subject: [PATCH 913/933] vere: make import flow not use base64 encoding --- pkg/urbit/vere/io/fore.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/pkg/urbit/vere/io/fore.c b/pkg/urbit/vere/io/fore.c index 1da96bcc6d..600e791d2f 100644 --- a/pkg/urbit/vere/io/fore.c +++ b/pkg/urbit/vere/io/fore.c @@ -85,18 +85,11 @@ _fore_inject(u3_auto* car_u, c3_c* pax_c) static void _fore_import(u3_auto* car_u, c3_c* pax_c) { - // With apologies - u3_noun arc = u3ke_cue(u3m_file(pax_c)); - u3_noun b64 = u3do("crip", u3do("en-base64:mimes:html", arc)); - c3_c * b64_c = u3r_string(b64); + u3_noun arc = u3ke_cue(u3m_file(pax_c)); + u3_noun imp = u3do("cat", u3nt(u3i_word(3), u3i_string("#import_"), arc); + u3_noun siz = u3r_met(3, imp)); + u3_noun dat = u3nt(u3_nul, siz, imp); - c3_w siz_w = strlen(b64_c) + 120; - c3_c * bod_c = (c3_c *) c3_malloc(siz_w); - snprintf(bod_c, siz_w, - "{\"source\": {\"import-all\": {\"base64-jam\": \"%s\"}}, \ - \"sink\": {\"stdout\": null}}", b64_c); - - u3_noun dat = u3nt(u3_nul, u3i_word(strlen(bod_c)), u3i_string(bod_c)); u3_noun req = u3nt(c3n, u3nc(u3i_string("ipv4"), u3i_word(0x7f000001)), u3nq(u3i_string("POST"), u3i_string("/"), u3_nul, dat)); From 8329b90efa3b0a069cbbd0b4f94aa0a43240544d Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Thu, 3 Dec 2020 22:50:45 -0800 Subject: [PATCH 914/933] lens: don't de-base64 --- pkg/arvo/app/lens.hoon | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/arvo/app/lens.hoon b/pkg/arvo/app/lens.hoon index b1facd5645..e6297970a8 100644 --- a/pkg/arvo/app/lens.hoon +++ b/pkg/arvo/app/lens.hoon @@ -59,8 +59,18 @@ =/ request-line (parse-request-line url.request.inbound-request) =/ site (flop site.request-line) :: + =/ body=@t q:(need body.request.inbound-request) + ?: =('#import_' (end [3 8] body)) + ~& %import-all + =/ by-app ;;((list [@tas *]) (cue (rsh [3 8] body))) + :_ this + %+ weld (give-simple-payload:app eyre-id not-found:gen) + %+ turn by-app + |= [app=@tas data=*] + ^- card:agent:gall + [%pass /import-all %agent [our.bowl app] %poke %import !>(data)] =/ jon=json - (need (de-json:html q:(need body.request.inbound-request))) + (need (de-json:html body)) =/ com=command:lens (json:grab:lens-mark jon) :: From 96e4e5c022a3d55014e03009d1666317ebd8363e Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Thu, 3 Dec 2020 22:56:35 -0800 Subject: [PATCH 915/933] vere: compile --- pkg/urbit/vere/io/fore.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pkg/urbit/vere/io/fore.c b/pkg/urbit/vere/io/fore.c index 600e791d2f..cb46fd187d 100644 --- a/pkg/urbit/vere/io/fore.c +++ b/pkg/urbit/vere/io/fore.c @@ -85,9 +85,9 @@ _fore_inject(u3_auto* car_u, c3_c* pax_c) static void _fore_import(u3_auto* car_u, c3_c* pax_c) { - u3_noun arc = u3ke_cue(u3m_file(pax_c)); - u3_noun imp = u3do("cat", u3nt(u3i_word(3), u3i_string("#import_"), arc); - u3_noun siz = u3r_met(3, imp)); + u3_noun arc = u3ke_cue(u3m_file(pax_c)); + u3_noun imp = u3dt("cat", 3, u3i_string("#import_"), arc); + u3_noun siz = u3r_met(3, imp); u3_noun dat = u3nt(u3_nul, siz, imp); u3_noun req = u3nt(c3n, @@ -98,10 +98,6 @@ _fore_import(u3_auto* car_u, c3_c* pax_c) u3_auto_peer( u3_auto_plan(car_u, u3_ovum_init(0, c3__e, wir, cad)), 0, 0, _fore_import_bail); - - u3z(b64); - c3_free(b64_c); - c3_free(bod_c); } /* _fore_io_talk(): From 8082d9f1ae8a88e4b4c7100a35271093b3eea3d1 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Thu, 3 Dec 2020 23:44:05 -0800 Subject: [PATCH 916/933] pill: update --- bin/solid.pill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index 517533e844..229e194d7f 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a4d5ce04d9578576ff4d2eb5fcfbafd3d830e80ad66fcce896080aeccdd97ad6 -size 9548407 +oid sha256:4ef4474711c8d3ee3707032c2e857323e5abf3dd8e1659ef0263755809fa0f0c +size 9548777 From 08332993b33a77e65cd3ce0d42e318b5fdbf19cc Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Fri, 4 Dec 2020 08:59:49 +0100 Subject: [PATCH 917/933] build: ensuring correct workflow naming and static binary upload --- .github/workflows/build.yml | 4 ++-- .github/workflows/release.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ca821bc083..e3faf128d3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,7 +30,7 @@ # # https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions -name: Build and test urbit binaries +name: build on: [push, pull_request] @@ -55,7 +55,7 @@ jobs: - run: nix-build -A urbit --arg enableStatic true - - if: ${{ matrix.os == 'ubuntu-latest' && github.event_name == 'pull_request' }} + - if: ${{ matrix.os == 'ubuntu-latest' }} run: nix-build -A urbit-tests haskell: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 97a3cf4520..1cce58ad73 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Upload urbit release tarball +name: release on: [release] @@ -27,7 +27,7 @@ jobs: project_id: ${{ secrets.GCS_PROJECT }} export_default_credentials: true - - run: nix-build -A tarball + - run: nix-build -A tarball --arg enableStatic true - name: Run upload to bootstrap.urbit.org run: | From 7542ff141355975cf934c219fefd45e6be850c4f Mon Sep 17 00:00:00 2001 From: Brendan Hay Date: Fri, 4 Dec 2020 09:20:48 +0100 Subject: [PATCH 918/933] build: upload static tarballs when a new tag is pushed --- .github/workflows/release.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1cce58ad73..8295ee5a3d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,9 @@ name: release -on: [release] +on: + release: null + push: + tags: ['*'] jobs: upload: From 92d58338259fcd91c0ae1d0c4d337546bbd9e9cf Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 4 Dec 2020 00:41:27 -0800 Subject: [PATCH 919/933] u3: disable +scot and +scow jets --- pkg/urbit/jets/tree.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index c3d6d680a6..761774bf95 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -944,8 +944,11 @@ static u3j_core _141_qua_d[] = { "mole", 7, _141_qua_mole_a, 0, _141_qua_mole_ha }, { "mule", 7, _141_qua_mule_a, 0, _141_qua_mule_ha }, - { "scot", 7, _141_qua_scot_a, 0, _141_qua_scot_ha }, - { "scow", 7, _141_qua_scow_a, 0, _141_qua_scow_ha }, + // XX disabled, implicated in memory corruption + // write tests and re-enable + // + // { "scot", 7, _141_qua_scot_a, 0, _141_qua_scot_ha }, + // { "scow", 7, _141_qua_scow_a, 0, _141_qua_scow_ha }, { "slaw", 7, _141_qua_slaw_a, 0, _141_qua_slaw_ha }, {} }; From 3be0ab503009eaf14413f85f5e268fd52006b25b Mon Sep 17 00:00:00 2001 From: fang Date: Fri, 4 Dec 2020 13:45:35 +0100 Subject: [PATCH 920/933] ted: update straggler threads for vase unit change Also cleans up a duplicate case in a ?-. --- pkg/arvo/ted/aqua/dill.hoon | 1 - pkg/arvo/ted/group/on-leave.hoon | 2 +- pkg/arvo/ted/group/on-remove-member.hoon | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/arvo/ted/aqua/dill.hoon b/pkg/arvo/ted/aqua/dill.hoon index 7fc87cb3d4..4d3b7b2e4e 100644 --- a/pkg/arvo/ted/aqua/dill.hoon +++ b/pkg/arvo/ted/aqua/dill.hoon @@ -26,7 +26,6 @@ %sag ~& [%save-jamfile-to p.b] line %sav ~& [%save-file-to p.b] line %url ~& [%activate-url p.b] line - %klr ~& %unhandled-case-klr "" == ~? !=(~ last-line) last-line ~ diff --git a/pkg/arvo/ted/group/on-leave.hoon b/pkg/arvo/ted/group/on-leave.hoon index aa3fcad4e2..6bd00c4c64 100644 --- a/pkg/arvo/ted/group/on-leave.hoon +++ b/pkg/arvo/ted/group/on-leave.hoon @@ -9,7 +9,7 @@ |= arg=vase =/ m (strand ,vase) ^- form:m -=+ !<([=update:grp ~] arg) +=+ !<([~ =update:grp] arg) ?. ?=(%remove-group -.update) (pure:m !>(~)) ;< =bowl:spider bind:m get-bowl:strandio diff --git a/pkg/arvo/ted/group/on-remove-member.hoon b/pkg/arvo/ted/group/on-remove-member.hoon index 3c295353ab..d7989e3d52 100644 --- a/pkg/arvo/ted/group/on-remove-member.hoon +++ b/pkg/arvo/ted/group/on-remove-member.hoon @@ -8,7 +8,7 @@ |= arg=vase =/ m (strand ,vase) ^- form:m -=+ !<([=update:grp ~] arg) +=+ !<([~ =update:grp] arg) ?. ?=(%remove-members -.update) (pure:m !>(~)) ;< =bowl:spider bind:m get-bowl:strandio From 18de133167d0ec3f132fcf3bd8f5e406c8c43cd6 Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Fri, 4 Dec 2020 14:43:24 -0500 Subject: [PATCH 921/933] landscape: remove ~2020.12 breach banner --- pkg/interface/src/views/App.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/pkg/interface/src/views/App.js b/pkg/interface/src/views/App.js index c44ed52914..3e533d6aef 100644 --- a/pkg/interface/src/views/App.js +++ b/pkg/interface/src/views/App.js @@ -142,21 +142,6 @@ class App extends React.Component { : null} - banner = e} - display={showBanner} - justifyContent="space-between" - width='100%' - p='2' - backgroundColor='yellow'> - - A network-wide breach is scheduled for early December 2020. Please visit urbit.org/breach for more information. - - { - banner.style.display = "none"; - localStorage.setItem("2020BreachBanner", "none"); - }}>Dismiss - Date: Fri, 4 Dec 2020 13:24:42 -0600 Subject: [PATCH 922/933] pull-hook: fix handle-kick printouts --- pkg/arvo/lib/pull-hook.hoon | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/lib/pull-hook.hoon b/pkg/arvo/lib/pull-hook.hoon index 606c057ae0..595aee882e 100644 --- a/pkg/arvo/lib/pull-hook.hoon +++ b/pkg/arvo/lib/pull-hook.hoon @@ -339,6 +339,7 @@ == ~ ``.^(* u.pax) + :: ++ handle-kick |= [rid=resource =ship] ^- (quip card _state) @@ -349,13 +350,16 @@ :- -:!>(*(unit path)) ?:(?=(%0 -.res) p.res ~) =? failed-kicks !?=(%0 -.res) - =/ tang + =/ =tang :+ leaf+"failed kick handler, please report" leaf+"{} in {(trip dap.bowl)}" ?: ?=(%2 -.res) p.res ?> ?=(%1 -.res) - (turn `(list *)`p.res (cork path smyt)) + =/ paths=(unit (list path)) ((soft (list path)) p.res) + ?~ paths ~ + %+ turn u.paths + (cork path smyt) %- (slog tang) (~(put by failed-kicks) rid ship) ?^ pax From 09a5d7c71d7af8be66fdc811d5664d9dc96fee49 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Fri, 4 Dec 2020 14:31:05 -0600 Subject: [PATCH 923/933] pull-hook: fix +end --- pkg/arvo/lib/pull-hook.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/arvo/lib/pull-hook.hoon b/pkg/arvo/lib/pull-hook.hoon index 595aee882e..7c0e0decf9 100644 --- a/pkg/arvo/lib/pull-hook.hoon +++ b/pkg/arvo/lib/pull-hook.hoon @@ -332,7 +332,7 @@ p.u.cas now.bowl :: catch bad gall scries early - ?: ?& =((end 3 1 i.u.pax) %g) + ?: ?& =((end 3 i.u.pax) %g) ?| !=(`our.bowl ship) !=(dat now.bowl) == From 29d118af7294ebe9d9272d5f33e4b429b331893d Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Fri, 4 Dec 2020 15:11:22 -0600 Subject: [PATCH 924/933] pull-hook: convert list of paths to single path --- pkg/arvo/lib/pull-hook.hoon | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/arvo/lib/pull-hook.hoon b/pkg/arvo/lib/pull-hook.hoon index 7c0e0decf9..2357487396 100644 --- a/pkg/arvo/lib/pull-hook.hoon +++ b/pkg/arvo/lib/pull-hook.hoon @@ -356,10 +356,9 @@ ?: ?=(%2 -.res) p.res ?> ?=(%1 -.res) - =/ paths=(unit (list path)) ((soft (list path)) p.res) - ?~ paths ~ - %+ turn u.paths - (cork path smyt) + =/ maybe-path=(unit path) ((soft path) p.res) + ?~ maybe-path ~ + [(smyt u.maybe-path) ~] %- (slog tang) (~(put by failed-kicks) rid ship) ?^ pax From 7588203f457605d13f9c28ed5ee28e0013367df3 Mon Sep 17 00:00:00 2001 From: Tyler Brown Cifu Shuster Date: Fri, 4 Dec 2020 13:27:41 -0800 Subject: [PATCH 925/933] clock: use new weather data Fixes #4073 --- pkg/interface/src/views/apps/launch/components/tiles.js | 3 ++- .../src/views/apps/launch/components/tiles/clock.js | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/interface/src/views/apps/launch/components/tiles.js b/pkg/interface/src/views/apps/launch/components/tiles.js index c5701302c3..d1bb7fc9db 100644 --- a/pkg/interface/src/views/apps/launch/components/tiles.js +++ b/pkg/interface/src/views/apps/launch/components/tiles.js @@ -36,8 +36,9 @@ export default class Tiles extends React.PureComponent { /> ); } else if (key === 'clock') { + const location = 'nearest-area' in props.weather ? props.weather['nearest-area'][0] : ''; return ( - + ); } } else { diff --git a/pkg/interface/src/views/apps/launch/components/tiles/clock.js b/pkg/interface/src/views/apps/launch/components/tiles/clock.js index 0aa636c944..df0df8f599 100644 --- a/pkg/interface/src/views/apps/launch/components/tiles/clock.js +++ b/pkg/interface/src/views/apps/launch/components/tiles/clock.js @@ -202,10 +202,9 @@ class Clock extends React.PureComponent { } initGeolocation() { - if (typeof this.props.data === 'string') { - const latlon = this.props.data.split(','); - const lat = latlon[0]; - const lon = latlon[1]; + if (typeof this.props.data === 'object') { + + const { latitude: lat, longitude: lon } = this.props.data; const suncalc = SunCalc.getTimes(new Date(), lat, lon); From 72ef78ad6e353519c7b3339ce2c9a36db27241f4 Mon Sep 17 00:00:00 2001 From: matildepark Date: Fri, 4 Dec 2020 16:41:27 -0500 Subject: [PATCH 926/933] leap: position notification dot relatively After indigo-react 1.2.15, Box no longer has `position:relative` by default. While we caught this elsewhere, we dropped this in Leap results, aligning the notification dot to the top left of the browser window instead. --- pkg/interface/src/views/components/leap/OmniboxResult.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/interface/src/views/components/leap/OmniboxResult.js b/pkg/interface/src/views/components/leap/OmniboxResult.js index 1d61c1a8a9..504fbafac7 100644 --- a/pkg/interface/src/views/components/leap/OmniboxResult.js +++ b/pkg/interface/src/views/components/leap/OmniboxResult.js @@ -41,7 +41,7 @@ export class OmniboxResult extends Component { (icon === 'Terminal') ? 'Dojo' : icon; graphic = ; } else if (icon === 'inbox') { - graphic = + graphic = {(notifications > 0 || inviteCount.length > 0) && ( From 1e3378a7f5dc8df4c1adcfc8ba23d6ea1792bfc1 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 4 Dec 2020 21:36:05 -0800 Subject: [PATCH 927/933] hoon: fixes logic bug in date printer (truncation) --- pkg/arvo/sys/hoon.hoon | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 9be10a6dc1..1addd5b374 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -5475,9 +5475,7 @@ %a =+ yod=(yore q.p.lot) =? rep ?=(^ f.t.yod) ['.' (s-co f.t.yod)] - =? rep ?& ?=(^ f.t.yod) - !|(=(0 h.t.yod) =(0 m.t.yod) =(0 s.t.yod)) - == + =? rep !&(?=(~ f) =(0 h) =(0 m) =(0 s)):t.yod =. rep ['.' (y-co s.t.yod)] =. rep ['.' (y-co m.t.yod)] ['.' '.' (y-co h.t.yod)] From c45e10fa5c8713e1306d65fdfeb52512a627ebb1 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 4 Dec 2020 21:36:57 -0800 Subject: [PATCH 928/933] aqua: fixes obsolete atom api calls missed in merge --- pkg/arvo/lib/aqua-azimuth.hoon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/lib/aqua-azimuth.hoon b/pkg/arvo/lib/aqua-azimuth.hoon index 7120757527..8dbc8b6f0c 100644 --- a/pkg/arvo/lib/aqua-azimuth.hoon +++ b/pkg/arvo/lib/aqua-azimuth.hoon @@ -206,8 +206,8 @@ :: ++ get-public |= [who=@p lyfe=life typ=?(%auth %crypt)] - =/ bod (rsh 3 1 pub:ex:(get-keys who lyfe)) - =+ [enc=(rsh 8 1 bod) aut=(end 8 1 bod)] + =/ bod (rsh 3 pub:ex:(get-keys who lyfe)) + =+ [enc=(rsh 8 bod) aut=(end 8 bod)] ?: =(%auth typ) aut enc From 5980fbedd0051d055bdf218d475fb79bcd1d2788 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 4 Dec 2020 21:46:05 -0800 Subject: [PATCH 929/933] ci: updates herb call to -test, matching new invocation --- nix/lib/test-fake-ship.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/lib/test-fake-ship.nix b/nix/lib/test-fake-ship.nix index 133c041b8d..b5b567e3c5 100644 --- a/nix/lib/test-fake-ship.nix +++ b/nix/lib/test-fake-ship.nix @@ -48,7 +48,7 @@ stdenvNoCC.mkDerivation { # run the unit tests # herb ./pier -d '~& ~ ~& %test-unit-start ~' - herb ./pier -d '####-test %/tests' + herb ./pier -d '####-test %/tests ~' herb ./pier -d '~& ~ ~& %test-unit-end ~' # use the :test app to build all agents, generators, and marks From b9fe6af97672a07c337471f21bb962ce429d0c6d Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Fri, 4 Dec 2020 23:08:47 -0800 Subject: [PATCH 930/933] jael: don't signal breach if first hearing of ship When you first boot, if you try talk to someone before your azimuth is up-to-date (for example by import), then if they've ever breached (twice) then you'll get breach notification, cancelling your message. This changes is it so that if we haven't heard anything about this ship, we don't signal a breach. The implementation complexity is primarily because we need eth-watcher/azimuth-tracker to produce an update of a list instead of a list of updates. This way, Jael can keep a "state as of the beginning of this move" variable to check when deciding whether to signal a breach. --- pkg/arvo/app/azimuth-tracker.hoon | 12 ++++++---- pkg/arvo/app/eth-watcher.hoon | 38 ++++++++++++++++--------------- pkg/arvo/sur/eth-watcher.hoon | 2 +- pkg/arvo/sys/hoon.hoon | 2 +- pkg/arvo/sys/vane/gall.hoon | 2 +- pkg/arvo/sys/vane/jael.hoon | 32 ++++++++++++++++---------- pkg/arvo/ted/eth-watcher.hoon | 2 +- 7 files changed, 51 insertions(+), 39 deletions(-) diff --git a/pkg/arvo/app/azimuth-tracker.hoon b/pkg/arvo/app/azimuth-tracker.hoon index f5a49cbcb7..89eccc9c92 100644 --- a/pkg/arvo/app/azimuth-tracker.hoon +++ b/pkg/arvo/app/azimuth-tracker.hoon @@ -75,13 +75,15 @@ ++ jael-update |= =udiffs:point ^- (list card:agent:gall) + :- [%give %fact ~[/] %azimuth-udiffs !>(udiffs)] + |- ^- (list card:agent:gall) ?~ udiffs ~ =/ =path /(scot %p ship.i.udiffs) - :* [%give %fact ~[/] %azimuth-udiff !>(i.udiffs)] - [%give %fact ~[path] %azimuth-udiff !>(i.udiffs)] - $(udiffs t.udiffs) - == + :: Should really give all diffs involving each ship at the same time + :: + :- [%give %fact ~[path] %azimuth-udiffs !>(~[i.udiffs])] + $(udiffs t.udiffs) :: ++ start |= [state=app-state our=ship dap=term] @@ -158,7 +160,7 @@ %- jael-update ?- -.diff %history (event-logs-to-udiffs loglist.diff) - %log (event-logs-to-udiffs event-log.diff ~) + %logs (event-logs-to-udiffs loglist.diff) %disavow [*ship id.diff %disavow ~]~ == :: diff --git a/pkg/arvo/app/eth-watcher.hoon b/pkg/arvo/app/eth-watcher.hoon index 0a4355a470..5c13740582 100644 --- a/pkg/arvo/app/eth-watcher.hoon +++ b/pkg/arvo/app/eth-watcher.hoon @@ -394,24 +394,26 @@ =/ rel-number (sub number.dog 30) =/ numbers=(list number:block) ~(tap in ~(key by pending-logs.dog)) =. numbers (sort numbers lth) - |- ^- (quip card watchdog) - ?~ numbers - `dog - ?: (gth i.numbers rel-number) - $(numbers t.numbers) - =^ cards-1 dog - =/ =loglist (~(get ja pending-logs.dog) i.numbers) - =. pending-logs.dog (~(del by pending-logs.dog) i.numbers) - ?~ loglist + =^ logs=(list event-log:rpc:ethereum) dog + |- ^- (quip event-log:rpc:ethereum watchdog) + ?~ numbers `dog - =. history.dog [loglist history.dog] - :_ dog - %+ turn loglist - |= =event-log:rpc:ethereum - ^- card - [%give %fact [%logs path]~ %eth-watcher-diff !>([%log event-log])] - =^ cards-2 dog $(numbers t.numbers) - [(weld cards-1 cards-2) dog] + ?: (gth i.numbers rel-number) + $(numbers t.numbers) + =^ rel-logs-1 dog + =/ =loglist (~(get ja pending-logs.dog) i.numbers) + =. pending-logs.dog (~(del by pending-logs.dog) i.numbers) + ?~ loglist + `dog + =. history.dog [loglist history.dog] + [loglist dog] + =^ rel-logs-2 dog $(numbers t.numbers) + [(weld rel-logs-1 rel-logs-2) dog] + :_ dog + ?~ logs + ~ + ^- (list card:agent:gall) + [%give %fact [%logs path]~ %eth-watcher-diff !>([%logs logs])]~ -- :: ++ on-arvo @@ -461,7 +463,7 @@ :_ dog(running `[now.bowl new-tid]) =/ args :^ ~ `new-tid %eth-watcher - !>(`watchpup`[- number pending-logs blocks]:dog) + !>([~ `watchpup`[- number pending-logs blocks]:dog]) :~ (watch-spider path our.bowl /thread-result/[new-tid]) (poke-spider path our.bowl %spider-start !>(args)) == diff --git a/pkg/arvo/sur/eth-watcher.hoon b/pkg/arvo/sur/eth-watcher.hoon index d21747a047..a268c7be2f 100644 --- a/pkg/arvo/sur/eth-watcher.hoon +++ b/pkg/arvo/sur/eth-watcher.hoon @@ -48,7 +48,7 @@ [%history =loglist] :: %log: newly added log :: - [%log =event-log:rpc:ethereum] + [%logs =loglist] :: %disavow: forget logs :: :: this is sent when a reorg happens that invalidates diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 9be10a6dc1..0546ad0e59 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -5476,7 +5476,7 @@ =+ yod=(yore q.p.lot) =? rep ?=(^ f.t.yod) ['.' (s-co f.t.yod)] =? rep ?& ?=(^ f.t.yod) - !|(=(0 h.t.yod) =(0 m.t.yod) =(0 s.t.yod)) + !&(=(0 h.t.yod) =(0 m.t.yod) =(0 s.t.yod)) == =. rep ['.' (y-co s.t.yod)] =. rep ['.' (y-co m.t.yod)] diff --git a/pkg/arvo/sys/vane/gall.hoon b/pkg/arvo/sys/vane/gall.hoon index 63900b3d7c..902c249f3d 100644 --- a/pkg/arvo/sys/vane/gall.hoon +++ b/pkg/arvo/sys/vane/gall.hoon @@ -1,4 +1,4 @@ -!: :: %gall, agent execution +:: :: %gall, agent execution !? 163 :: :::: diff --git a/pkg/arvo/sys/vane/jael.hoon b/pkg/arvo/sys/vane/jael.hoon index c7759d70d2..233e00e199 100644 --- a/pkg/arvo/sys/vane/jael.hoon +++ b/pkg/arvo/sys/vane/jael.hoon @@ -97,7 +97,7 @@ $% $>(%init vane-task) :: report install == == == :: :: :: -+$ peer-sign [=ship =udiff:point] :: ++$ peer-sign (list [=ship =udiff:point]) :: :: :: +$ sign :: in result $<- $~ [%a %done ~] :: @@ -313,7 +313,7 @@ (~(gas by points) spon-points) =. +>.$ %- curd =< abet - (public-keys:~(feel su hen our now pki etn) %full points) + (public-keys:~(feel su hen our now pki etn) pos.zim.pki %full points) :: :: start subscriptions :: @@ -451,7 +451,7 @@ ~& [%not-our-moon ship.tac] +>.$ %- curd =< abet - (~(new-event su hen our now pki etn) [ship udiff]:tac) + (~(new-event su hen our now pki etn) [ship udiff]~:tac) :: :: rotate web login code :: @@ -544,7 +544,7 @@ [%a %boon *] =+ ;; [%public-keys-result =public-keys-result] payload.hin %- curd =< abet - (public-keys:~(feel su hen our now pki etn) public-keys-result) + (public-keys:~(feel su hen our now pki etn) pos.zim.pki public-keys-result) :: [%a %lost *] :: TODO: better error handling @@ -716,13 +716,19 @@ == :: ++ new-event - |= [=a=ship =a=udiff:point] + |= =udiffs:point ^+ this-su - =/ a-point=point (~(gut by pos.zim.pki) a-ship *point) - =/ a-diff=(unit diff:point) (udiff-to-diff:point a-udiff a-point) - ?~ a-diff + =/ original-pos pos.zim.pki + |- ^+ this-su + ?~ udiffs this-su - (public-keys:feel %diff a-ship u.a-diff) + =/ a-point=point (~(gut by pos.zim.pki) ship.i.udiffs *point) + =/ a-diff=(unit diff:point) (udiff-to-diff:point udiff.i.udiffs a-point) + =. this-su + ?~ a-diff + this-su + (public-keys:feel original-pos %diff ship.i.udiffs u.a-diff) + $(udiffs t.udiffs) :: ++ subscribers-on-ship |= =ship @@ -837,7 +843,7 @@ :: Update public-keys :: ++ public-keys - |= =public-keys-result + |= [original=(map ship point) =public-keys-result] ^+ ..feel ?: ?=(%full -.public-keys-result) =/ pointl=(list [who=ship =point]) @@ -850,7 +856,8 @@ =? ..feel =/ point (~(get by pos.zim) who.i.pointl) - ?& ?=(^ point) + ?& (~(has by original) who.i.pointl) + ?=(^ point) (gth rift.point.i.pointl rift.u.point) == =. ..feel @@ -882,7 +889,8 @@ :: if changing rift upward, then signal a breach :: =? ..feel - ?& ?=(^ maybe-point) + ?& (~(has by original) who) + ?=(^ maybe-point) ?=(%rift -.a-diff) (gth to.a-diff rift.point) == diff --git a/pkg/arvo/ted/eth-watcher.hoon b/pkg/arvo/ted/eth-watcher.hoon index 01ddb58391..367a7662e9 100644 --- a/pkg/arvo/ted/eth-watcher.hoon +++ b/pkg/arvo/ted/eth-watcher.hoon @@ -9,7 +9,7 @@ :: |= args=vase |^ -=+ !<(pup=watchpup args) +=+ !<([~ pup=watchpup] args) =/ m (strand:strandio ,vase) ^- form:m ;< =latest=block bind:m (get-latest-block:ethio url.pup) From 8103a6423cf875edee1d77e311fa5fa713371abc Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Sat, 5 Dec 2020 15:17:37 -0800 Subject: [PATCH 931/933] jael: cleanup per review --- pkg/arvo/sur/eth-watcher.hoon | 2 +- pkg/arvo/sys/vane/jael.hoon | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/pkg/arvo/sur/eth-watcher.hoon b/pkg/arvo/sur/eth-watcher.hoon index a268c7be2f..5ef0f6fdb3 100644 --- a/pkg/arvo/sur/eth-watcher.hoon +++ b/pkg/arvo/sur/eth-watcher.hoon @@ -46,7 +46,7 @@ $% :: %history: full event log history, oldest first :: [%history =loglist] - :: %log: newly added log + :: %logs: newly added logs :: [%logs =loglist] :: %disavow: forget logs diff --git a/pkg/arvo/sys/vane/jael.hoon b/pkg/arvo/sys/vane/jael.hoon index 233e00e199..89b3353ead 100644 --- a/pkg/arvo/sys/vane/jael.hoon +++ b/pkg/arvo/sys/vane/jael.hoon @@ -97,8 +97,6 @@ $% $>(%init vane-task) :: report install == == == :: :: :: -+$ peer-sign (list [=ship =udiff:point]) :: -:: :: +$ sign :: in result $<- $~ [%a %done ~] :: $% $: %a :: @@ -587,9 +585,9 @@ %fact ?> ?=([@ *] tea) =* app i.tea - =/ =peer-sign ;;(peer-sign q.q.cage.p.+>.hin) + =+ ;;(=udiffs:point q.q.cage.p.+>.hin) %- curd =< abet - (~(new-event su hen our now pki etn) peer-sign) + (~(new-event su hen our now pki etn) udiffs) == == :: :: ++curd:of @@ -724,9 +722,7 @@ this-su =/ a-point=point (~(gut by pos.zim.pki) ship.i.udiffs *point) =/ a-diff=(unit diff:point) (udiff-to-diff:point udiff.i.udiffs a-point) - =. this-su - ?~ a-diff - this-su + =? this-su ?=(^ a-diff) (public-keys:feel original-pos %diff ship.i.udiffs u.a-diff) $(udiffs t.udiffs) :: @@ -851,7 +847,8 @@ |- ^+ ..feel ?~ pointl ..feel(pos.zim (~(uni by pos.zim) points.public-keys-result)) - :: if changing rift upward, then signal a breach + :: if changing rift upward and we already had keys for them, + :: then signal a breach :: =? ..feel =/ point @@ -886,7 +883,8 @@ =/ a-diff=diff:point diff.public-keys-result =/ maybe-point (~(get by pos.zim) who) =/ =point (fall maybe-point *point) - :: if changing rift upward, then signal a breach + :: if changing rift upward and we already had keys for them, then + :: signal a breach :: =? ..feel ?& (~(has by original) who) From 4b8be294b2227bd1c57ea4be1887d019513dec27 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Sat, 5 Dec 2020 20:02:31 -0800 Subject: [PATCH 932/933] ames: don't crash on forward-lane scry --- pkg/arvo/sys/vane/ames.hoon | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index b2e63e8e2c..2a2baf854c 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -984,10 +984,12 @@ [%peers @ *] =/ who (slaw %p i.t.tyl) ?~ who [~ ~] - ?~ peer=(~(get by peers.ames-state) u.who) - [~ ~] - ?+ t.t.tyl [~ ~] - ~ ``noun+!>(u.peer) + =/ peer (~(get by peers.ames-state) u.who) + ?+ t.t.tyl [~ ~] + ~ + ?~ peer + [~ ~] + ``noun+!>(u.peer) :: [%forward-lane ~] :: From 358a6e73fdd2895fa6cf04e837c254895db96c32 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Mon, 7 Dec 2020 14:16:55 -0600 Subject: [PATCH 933/933] pull-hook: make wires more stable identifiers based on resource --- pkg/arvo/lib/pull-hook.hoon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/lib/pull-hook.hoon b/pkg/arvo/lib/pull-hook.hoon index 05ffbee1a0..f3ef4b5c35 100644 --- a/pkg/arvo/lib/pull-hook.hoon +++ b/pkg/arvo/lib/pull-hook.hoon @@ -404,7 +404,7 @@ =/ =wire (make-wire pull+resource+(en-path:resource rid)) [%pass wire %agent [u.ship push-hook-name.config] %leave ~]~ - + :: ++ watch-resource |= [rid=resource pax=path] ^- (list card) @@ -414,7 +414,7 @@ =/ =path (welp resource+(en-path:resource rid) pax) =/ =wire - (make-wire pull+path) + (make-wire pull+resource+(en-path:resource rid)) [%pass wire %agent [u.ship push-hook-name.config] %watch path]~ :: ++ make-wire