From 7610c65bc4cf647ada78b91ffe96d556a37061b2 Mon Sep 17 00:00:00 2001 From: Fang Date: Sat, 13 Jul 2019 17:43:21 +0200 Subject: [PATCH 001/124] Allow glyph binding during ;join and ;create --- pkg/arvo/app/talk.hoon | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pkg/arvo/app/talk.hoon b/pkg/arvo/app/talk.hoon index df3a331624..0bd50acb5f 100644 --- a/pkg/arvo/app/talk.hoon +++ b/pkg/arvo/app/talk.hoon @@ -66,9 +66,9 @@ == :: ++ work :: interface action $% :: circle management :: - {$join (map circle range)} :: subscribe to + {$join (map circle range) (unit char)} :: subscribe to {$leave audience} :: unsubscribe from - {$create security name cord} :: create circle + {$create security name cord (unit char)} :: create circle {$delete name (unit cord)} :: delete circle {$depict name cord} :: change description {$filter name ? ?} :: change message rules @@ -838,7 +838,7 @@ :: ;~((glue ace) (perk %read ~) cire dem:ag) :: - ;~((glue ace) (perk %join ~) sorz) + ;~((glue ace) (perk %join ~) sorz (punt glyph)) :: ;~((glue ace) (perk %leave ~) cirs) :: @@ -846,6 +846,7 @@ pore cire qut + (punt glyph) == :: ;~ plug (perk %delete ~) @@ -1186,8 +1187,10 @@ :: change local mailbox config to include :: subscriptions to {pas}. :: - |= pos/(map circle range) + |= {pos/(map circle range) gyf/(unit char)} ^+ ..sh-work + =? ..sh-work ?=(^ gyf) + (bind u.gyf `~(key by pos)) =+ pas=~(key by pos) =. ..sh-work sh-prod(active.she pas) @@ -1226,11 +1229,11 @@ :: :: creates circle {nom} with specified config. :: - |= {sec/security nom/name txt/cord} + |= {sec/security nom/name txt/cord gyf/(unit char)} ^+ ..sh-work =. ..sh-work (sh-act %create nom txt sec) - (join [[[self nom] ~] ~ ~]) + (join [[[self nom] ~] ~ ~] gyf) :: ++ delete :: %delete From 5082ce6b98615e8c3ce7b50897ef644091f9d090 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 15 Jul 2019 15:18:28 -0700 Subject: [PATCH 002/124] Part 1: Add the export action and get that into herb. --- pkg/arvo/app/dojo.hoon | 1 + pkg/arvo/app/lens.hoon | 6 ++++++ pkg/arvo/mar/lens/command.hoon | 1 + pkg/arvo/sur/lens.hoon | 1 + pkg/herb/herb | 4 ++++ 5 files changed, 13 insertions(+) diff --git a/pkg/arvo/app/dojo.hoon b/pkg/arvo/app/dojo.hoon index 0a6b07941f..1d2bc1711b 100644 --- a/pkg/arvo/app/dojo.hoon +++ b/pkg/arvo/app/dojo.hoon @@ -1019,6 +1019,7 @@ == :: $listen-api !! + $export !! $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 ef3347683e..41181ce0d0 100644 --- a/pkg/arvo/app/lens.hoon +++ b/pkg/arvo/app/lens.hoon @@ -61,6 +61,12 @@ =/ com=command:lens (json:grab:lens-mark jon) :_ this(job.state (some [ost.bow com])) + :: + ?: ?=(%export -.source.com) + :: todo: send export commands + ~& [%export app.source.com] + ~ +:: [ost.bow %peer /sole [our.bow app.source.com] /export]~ [ost.bow %peel /sole [our.bow %dojo] %lens-json /sole]~ :: ++ diff-lens-json diff --git a/pkg/arvo/mar/lens/command.hoon b/pkg/arvo/mar/lens/command.hoon index 699f9b968b..9583a1d689 100644 --- a/pkg/arvo/mar/lens/command.hoon +++ b/pkg/arvo/mar/lens/command.hoon @@ -35,6 +35,7 @@ ;~(pfix col (more net (cook crip (star ;~(less net prn))))) == listen-api+(su ;~(plug sym ;~(pfix col sym))) + export+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 7961822113..71a4d621e9 100644 --- a/pkg/arvo/sur/lens.hoon +++ b/pkg/arvo/sur/lens.hoon @@ -15,6 +15,7 @@ {$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} == ++ sink $% {$stdout ~} diff --git a/pkg/herb/herb b/pkg/herb/herb index 675a3e25ec..08fac45c70 100755 --- a/pkg/herb/herb +++ b/pkg/herb/herb @@ -310,6 +310,10 @@ parser.add_argument('-l', '--listen-api', which='listen-api', metavar='api:event', help='listen to event from api', action=sourceAction) +parser.add_argument('-e', '--export', which='export', + metavar='app-name', + help='exports the application state', + action=sourceAction) parser.add_argument('-m', '--mark', which='as', metavar='mark', help='transform a source to another mark', From fa1f68e45f30f045f403fe5abb42dfa744aeb2ee Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 15 Jul 2019 16:43:38 -0700 Subject: [PATCH 003/124] Writes an app's data to a static file location. Next steps: - Specifying filenames - Importing - Handle bad messages sent to %dojo on +reap. --- pkg/arvo/app/hall.hoon | 8 ++++++++ pkg/arvo/app/lens.hoon | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/pkg/arvo/app/hall.hoon b/pkg/arvo/app/hall.hoon index 3973ce38fe..8234bd9fb7 100644 --- a/pkg/arvo/app/hall.hoon +++ b/pkg/arvo/app/hall.hoon @@ -92,6 +92,7 @@ ++ lime :: diff fruit $% {$hall-prize prize} :: {$hall-rumor rumor} :: + {$export (list telegram)} == :: ++ pear :: poke fruit $% {$hall-command command} :: @@ -2789,6 +2790,8 @@ ^- (list move) =+ mur=(~(get by res) p) ?^ mur u.mur + ?: =([%export ~] p) + ~ =- =. res (~(put by res) p -) - =+ qer=(path-to-query p) @@ -3017,6 +3020,11 @@ |= pax/path ^- (quip move _+>) ?: ?=([%sole *] pax) ~&(%hall-no-sole !!) + ?: ?=([%export *] pax) + ~& %hall-peer-export + :_ +>.$ + [ost.bol %diff %export grams:(~(got by stories) ~.inbox)]~ + :: =+ qer=(path-to-query pax) ?. (leak src.bol qer) ~&(%peer-invisible !!) =^ mos +>.$ diff --git a/pkg/arvo/app/lens.hoon b/pkg/arvo/app/lens.hoon index 41181ce0d0..cbc7432458 100644 --- a/pkg/arvo/app/lens.hoon +++ b/pkg/arvo/app/lens.hoon @@ -1,5 +1,5 @@ /- lens -/+ *server +/+ *server, base64 /= lens-mark /: /===/mar/lens/command /!noun/ =, format @@ -12,6 +12,7 @@ +$ card $% [%connect wire binding:eyre term] [%http-response =http-event:http] + [%peer wire dock path] [%peel wire dock mark path] [%poke wire dock poke] [%pull wire dock ~] @@ -49,6 +50,7 @@ %- (require-authorization:app ost.bow move this) |= =inbound-request:eyre ^- (quip move _this) + ~& %poke-handle-http-request-lens ?^ job.state :_ this [ost.bow %http-response %start [%500 ~] ~ %.y]~ @@ -65,8 +67,7 @@ ?: ?=(%export -.source.com) :: todo: send export commands ~& [%export app.source.com] - ~ -:: [ost.bow %peer /sole [our.bow app.source.com] /export]~ + [ost.bow %peer /sole [our.bow app.source.com] /export]~ [ost.bow %peel /sole [our.bow %dojo] %lens-json /sole]~ :: ++ diff-lens-json @@ -74,10 +75,40 @@ ^- (quip move _this) ?~ jon [~ this] + ~& [%json jon] ?> ?=(^ job.state) :_ this(job.state ~) [bone.u.job.state %http-response (json-response:app (json-to-octs jon))]~ :: +++ diff-export + |= [=wire data=*] + ^- (quip move _this) + :: + ?> ?=(^ job.state) + :: TOOD: the following isn't really good enough. + :: + :: To have herb write a file to the cwd, you need to have an --output-pill + :: blah.txt which gets turned into '/blah/txt' here. So we need to have + :: + :: Thankfully, --output-pill is already so fragile it barely works on any + :: paths that aren't referencing a file in the CWD. + :: + ?> ?=(%output-pill -.sink.com.u.job.state) + =/ output=@t '/myfile/txt' :: pax.sink.com.u.job.state + ::(need (de-beam:format pax.sink.com.u.job.state)) + :: + =/ jon=json + =/ =atom (jam data) + =/ =octs [(met 3 atom) atom] + =/ enc (en:base64 octs) + (pairs:enjs:format file+s+output data+s+enc ~) + :: + ~& [%jon jon] + :: + :_ this(job.state ~) + [bone.u.job.state %http-response (json-response:app (json-to-octs jon))]~ + +:: ++ quit |= =wire ^- (quip move _this) From 3f71ddc9253ac12405fa844a31279551a8b2281f Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 16 Jul 2019 10:40:11 -0700 Subject: [PATCH 004/124] Filename cleanups and don't talk to dojo --- pkg/arvo/app/lens.hoon | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/pkg/arvo/app/lens.hoon b/pkg/arvo/app/lens.hoon index cbc7432458..e95dc5c55f 100644 --- a/pkg/arvo/app/lens.hoon +++ b/pkg/arvo/app/lens.hoon @@ -67,7 +67,7 @@ ?: ?=(%export -.source.com) :: todo: send export commands ~& [%export app.source.com] - [ost.bow %peer /sole [our.bow app.source.com] /export]~ + [ost.bow %peer /export [our.bow app.source.com] /export]~ [ost.bow %peel /sole [our.bow %dojo] %lens-json /sole]~ :: ++ diff-lens-json @@ -87,15 +87,12 @@ ?> ?=(^ job.state) :: TOOD: the following isn't really good enough. :: - :: To have herb write a file to the cwd, you need to have an --output-pill - :: blah.txt which gets turned into '/blah/txt' here. So we need to have + :: herb will do whatever we tell it to, so by convention have it write to + :: an app name based on the file name. :: - :: Thankfully, --output-pill is already so fragile it barely works on any - :: paths that aren't referencing a file in the CWD. - :: - ?> ?=(%output-pill -.sink.com.u.job.state) - =/ output=@t '/myfile/txt' :: pax.sink.com.u.job.state - ::(need (de-beam:format pax.sink.com.u.job.state)) + ?> ?=(%export -.source.com.u.job.state) + =/ app-name=tape (trip app.source.com.u.job.state) + =/ output=@t (crip "/{app-name}/jam") :: =/ jon=json =/ =atom (jam data) @@ -103,11 +100,8 @@ =/ enc (en:base64 octs) (pairs:enjs:format file+s+output data+s+enc ~) :: - ~& [%jon jon] - :: :_ this(job.state ~) [bone.u.job.state %http-response (json-response:app (json-to-octs jon))]~ - :: ++ quit |= =wire @@ -119,6 +113,9 @@ |= [=wire saw=(unit tang)] ^- (quip move _this) ~& [%reap wire] + ?: =([%export ~] wire) + [~ this] + :: ?^ saw [((slog u.saw) ~) this] ?> ?=(^ job.state) From a8c2c06db9c68a14064fff73adaf139a0128ecec Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 16 Jul 2019 13:52:42 -0700 Subject: [PATCH 005/124] Now with a working --import. --- pkg/arvo/app/dojo.hoon | 1 + pkg/arvo/app/hall.hoon | 13 ++++++++++++- pkg/arvo/app/lens.hoon | 29 +++++++++++++++++++++++++++-- pkg/arvo/mar/lens/command.hoon | 1 + pkg/arvo/sur/lens.hoon | 1 + pkg/herb/herb | 31 +++++++++++++++++++++++++++++++ 6 files changed, 73 insertions(+), 3 deletions(-) diff --git a/pkg/arvo/app/dojo.hoon b/pkg/arvo/app/dojo.hoon index 1d2bc1711b..b67fb1a929 100644 --- a/pkg/arvo/app/dojo.hoon +++ b/pkg/arvo/app/dojo.hoon @@ -1020,6 +1020,7 @@ :: $listen-api !! $export !! + $import !! $as :* %as mar.source.com $(num +(num), source.com next.source.com) diff --git a/pkg/arvo/app/hall.hoon b/pkg/arvo/app/hall.hoon index 8234bd9fb7..ed29af5846 100644 --- a/pkg/arvo/app/hall.hoon +++ b/pkg/arvo/app/hall.hoon @@ -3021,7 +3021,6 @@ ^- (quip move _+>) ?: ?=([%sole *] pax) ~&(%hall-no-sole !!) ?: ?=([%export *] pax) - ~& %hall-peer-export :_ +>.$ [ost.bol %diff %export grams:(~(got by stories) ~.inbox)]~ :: @@ -3204,6 +3203,18 @@ :- ~ +>.$(log (~(del by log) nom)) :: +++ poke-import + |= i=* + ^- (quip move _+>) + =/ grams=(list telegram) ;;((list telegram) i) + :: + ~& [%importing-telegrams count=(lent grams)] + :: + %- pre-bake + %+ turn grams + |= t/telegram + [%story ~.inbox %gram [our.bol ~.inbox] t] +:: ++ log-all-to-file :: update stories logs :: diff --git a/pkg/arvo/app/lens.hoon b/pkg/arvo/app/lens.hoon index e95dc5c55f..719ea63f4e 100644 --- a/pkg/arvo/app/lens.hoon +++ b/pkg/arvo/app/lens.hoon @@ -20,6 +20,7 @@ :: +$ poke $% [%lens-command command:lens] + [%import *] == :: +$ state @@ -62,12 +63,23 @@ (need (de-json:html q:(need body.request.inbound-request))) =/ com=command:lens (json:grab:lens-mark jon) - :_ this(job.state (some [ost.bow com])) :: ?: ?=(%export -.source.com) - :: todo: send export commands ~& [%export app.source.com] + :_ this(job.state (some [ost.bow com])) [ost.bow %peer /export [our.bow app.source.com] /export]~ + :: + ?: ?=(%import -.source.com) + ?~ enc=(de:base64 base64-jam.source.com) + :_ this + [ost.bow %http-response %start [%500 ~] ~ %.y]~ + :: + =/ c=* (cue q.u.enc) + :: + :_ this(job.state (some [ost.bow com])) + [ost.bow %poke /import [our.bow app.source.com] %import c]~ + :: + :_ this(job.state (some [ost.bow com])) [ost.bow %peel /sole [our.bow %dojo] %lens-json /sole]~ :: ++ diff-lens-json @@ -128,6 +140,19 @@ |= [=wire saw=(unit tang)] ^- (quip move _this) ~& [%coup wire] + :: + ?: =([%import ~] wire) + ?> ?=(^ job.state) + :_ this(job.state ~) + :_ ~ + :* bone.u.job.state + %http-response + %start + [%200 ~] + [~ (as-octt:mimes:html "\"Imported data\"")] + %.y + == + :: ?^ saw [((slog u.saw) ~) this] [~ this] diff --git a/pkg/arvo/mar/lens/command.hoon b/pkg/arvo/mar/lens/command.hoon index 9583a1d689..9080780270 100644 --- a/pkg/arvo/mar/lens/command.hoon +++ b/pkg/arvo/mar/lens/command.hoon @@ -36,6 +36,7 @@ == listen-api+(su ;~(plug sym ;~(pfix col sym))) export+so + import+(ot app+so 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 71a4d621e9..5503aa7581 100644 --- a/pkg/arvo/sur/lens.hoon +++ b/pkg/arvo/sur/lens.hoon @@ -16,6 +16,7 @@ {$tuple next/(list source)} :: don't bunt well {$listen-api api/term event/term} {$export app/@t} + {$import app/@t base64-jam/@t} == ++ sink $% {$stdout ~} diff --git a/pkg/herb/herb b/pkg/herb/herb index 08fac45c70..abd8303e34 100755 --- a/pkg/herb/herb +++ b/pkg/herb/herb @@ -113,6 +113,33 @@ class sourceAction(argparse.Action): else: return {self.which: new_value} +class importFileAction(argparse.Action): + """Handles the import statement. + + The --import statement reads in a jammed noun file from the current working + directory 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}.jam" file in the current + # working directory. If there isn't, we error + data = "" + filename = new_value + ".jam" + 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": {"app": new_value, "base64-jam": base_data}} + class transformerAction(argparse.Action): """Handle transformer flag. @@ -314,6 +341,10 @@ parser.add_argument('-e', '--export', which='export', metavar='app-name', help='exports the application state', action=sourceAction) +parser.add_argument('-i', '--import', + metavar='appname', + help='imports the application state', + action=importFileAction) parser.add_argument('-m', '--mark', which='as', metavar='mark', help='transform a source to another mark', From c98105277e2ab40b3ffecccd738f71d50e6c9884 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 17 Jul 2019 01:12:49 +0200 Subject: [PATCH 006/124] Less repetitive style --- pkg/arvo/app/talk.hoon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/app/talk.hoon b/pkg/arvo/app/talk.hoon index 0bd50acb5f..e4071a2d62 100644 --- a/pkg/arvo/app/talk.hoon +++ b/pkg/arvo/app/talk.hoon @@ -1189,9 +1189,9 @@ :: |= {pos/(map circle range) gyf/(unit char)} ^+ ..sh-work - =? ..sh-work ?=(^ gyf) - (bind u.gyf `~(key by pos)) =+ pas=~(key by pos) + =? ..sh-work ?=(^ gyf) + (bind u.gyf `pas) =. ..sh-work sh-prod(active.she pas) :: default to a day of backlog From f3d3981db89b3dad790d473b79d79cc36d16fb52 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 17 Jul 2019 01:19:40 +0200 Subject: [PATCH 007/124] Don't require trailing ace when not binding --- pkg/arvo/app/talk.hoon | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/arvo/app/talk.hoon b/pkg/arvo/app/talk.hoon index e4071a2d62..9e0bba9ae0 100644 --- a/pkg/arvo/app/talk.hoon +++ b/pkg/arvo/app/talk.hoon @@ -838,15 +838,14 @@ :: ;~((glue ace) (perk %read ~) cire dem:ag) :: - ;~((glue ace) (perk %join ~) sorz (punt glyph)) + ;~((glue ace) (perk %join ~) ;~(plug sorz (punt ;~(pfix ace glyph)))) :: ;~((glue ace) (perk %leave ~) cirs) :: ;~ (glue ace) (perk %create ~) pore cire - qut - (punt glyph) + ;~(plug qut (punt ;~(pfix ace glyph))) == :: ;~ plug (perk %delete ~) From c9770317f9d8be9ad613a84863b7a7af60d57699 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 19 Jul 2019 10:27:11 -0700 Subject: [PATCH 008/124] Version tag hall messages and general cleanup. --- pkg/arvo/app/hall.hoon | 8 +++++--- pkg/arvo/app/lens.hoon | 9 +++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/pkg/arvo/app/hall.hoon b/pkg/arvo/app/hall.hoon index ed29af5846..cd4042c077 100644 --- a/pkg/arvo/app/hall.hoon +++ b/pkg/arvo/app/hall.hoon @@ -92,7 +92,7 @@ ++ lime :: diff fruit $% {$hall-prize prize} :: {$hall-rumor rumor} :: - {$export (list telegram)} + {$export [%hall-v0 (list telegram)]} :: sent to lens == :: ++ pear :: poke fruit $% {$hall-command command} :: @@ -3022,7 +3022,7 @@ ?: ?=([%sole *] pax) ~&(%hall-no-sole !!) ?: ?=([%export *] pax) :_ +>.$ - [ost.bol %diff %export grams:(~(got by stories) ~.inbox)]~ + [ost.bol %diff %export [%hall-v0 grams:(~(got by stories) ~.inbox)]]~ :: =+ qer=(path-to-query pax) ?. (leak src.bol qer) ~&(%peer-invisible !!) @@ -3206,7 +3206,9 @@ ++ poke-import |= i=* ^- (quip move _+>) - =/ grams=(list telegram) ;;((list telegram) i) + :: + ?> ?=([%hall-v0 *] i) + =/ grams=(list telegram) ;;((list telegram) +.i) :: ~& [%importing-telegrams count=(lent grams)] :: diff --git a/pkg/arvo/app/lens.hoon b/pkg/arvo/app/lens.hoon index 719ea63f4e..9fc695d837 100644 --- a/pkg/arvo/app/lens.hoon +++ b/pkg/arvo/app/lens.hoon @@ -51,7 +51,7 @@ %- (require-authorization:app ost.bow move this) |= =inbound-request:eyre ^- (quip move _this) - ~& %poke-handle-http-request-lens + :: ?^ job.state :_ this [ost.bow %http-response %start [%500 ~] ~ %.y]~ @@ -87,7 +87,6 @@ ^- (quip move _this) ?~ jon [~ this] - ~& [%json jon] ?> ?=(^ job.state) :_ this(job.state ~) [bone.u.job.state %http-response (json-response:app (json-to-octs jon))]~ @@ -97,10 +96,8 @@ ^- (quip move _this) :: ?> ?=(^ job.state) - :: TOOD: the following isn't really good enough. - :: - :: herb will do whatever we tell it to, so by convention have it write to - :: an app name based on the file name. + :: herb will do whatever we tell it to, so by convention have it write to an + :: app name based on the file name. :: ?> ?=(%export -.source.com.u.job.state) =/ app-name=tape (trip app.source.com.u.job.state) From 80dfced914cd43c70ce2cfbafc79b78a3d59d5d7 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 19 Jul 2019 16:42:00 -0700 Subject: [PATCH 009/124] updates lib/pill to support all relevant userspace marks --- pkg/arvo/lib/pill.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/arvo/lib/pill.hoon b/pkg/arvo/lib/pill.hoon index f7018bd663..6bb7c058b9 100644 --- a/pkg/arvo/lib/pill.hoon +++ b/pkg/arvo/lib/pill.hoon @@ -97,7 +97,7 @@ =? hav ?=(^ fil.lon) :: XX this whitelist needs to be reviewed :: - ?. ?= ?($css $hoon $json $md $txt $udon $umd) + ?. ?= ?($css $hoon $html $js $json $md $png $txt $udon $umd) -.tyl :: :: install only files with whitelisted marks From 8debf3fa60595ba9f1d91cd6b5a2a550de666a70 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 22 Jul 2019 10:48:45 -0700 Subject: [PATCH 010/124] Further cleanup. --- pkg/arvo/app/lens.hoon | 4 +++- pkg/herb/herb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/app/lens.hoon b/pkg/arvo/app/lens.hoon index 9fc695d837..f69959464a 100644 --- a/pkg/arvo/app/lens.hoon +++ b/pkg/arvo/app/lens.hoon @@ -110,7 +110,9 @@ (pairs:enjs:format file+s+output data+s+enc ~) :: :_ this(job.state ~) - [bone.u.job.state %http-response (json-response:app (json-to-octs jon))]~ + :~ [bone.u.job.state %http-response (json-response:app (json-to-octs jon))] + [ost.bow %pull /export [our.bow app.source.com.u.job.state] ~] + == :: ++ quit |= =wire diff --git a/pkg/herb/herb b/pkg/herb/herb index abd8303e34..70dde1275c 100755 --- a/pkg/herb/herb +++ b/pkg/herb/herb @@ -342,7 +342,7 @@ parser.add_argument('-e', '--export', which='export', help='exports the application state', action=sourceAction) parser.add_argument('-i', '--import', - metavar='appname', + metavar='app-name', help='imports the application state', action=importFileAction) parser.add_argument('-m', '--mark', which='as', From c4a0823eb72464d485790cd782f4609a5340acfd Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 23 Jul 2019 13:46:44 -0700 Subject: [PATCH 011/124] Fix merge which reintroduced ~&s --- pkg/arvo/app/lens.hoon | 3 --- 1 file changed, 3 deletions(-) diff --git a/pkg/arvo/app/lens.hoon b/pkg/arvo/app/lens.hoon index 0d1ef0a0d4..0b84a8aa28 100644 --- a/pkg/arvo/app/lens.hoon +++ b/pkg/arvo/app/lens.hoon @@ -124,7 +124,6 @@ |= [=wire saw=(unit tang)] ^- (quip move _this) :: - ~& [%reap wire] ?: =([%export ~] wire) [~ this] :: @@ -140,8 +139,6 @@ |= [=wire saw=(unit tang)] ^- (quip move _this) :: - ~& [%coup wire] - :: ?: =([%import ~] wire) ?> ?=(^ job.state) :_ this(job.state ~) From 80e40582c1c202da4221b0b1e4ab7062f464812f Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 25 Jul 2019 21:44:09 +0200 Subject: [PATCH 012/124] Don't sh-note updates to a circle's read counter Fixes #1381. --- pkg/arvo/app/talk.hoon | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/arvo/app/talk.hoon b/pkg/arvo/app/talk.hoon index cff250abb7..c99a00acc1 100644 --- a/pkg/arvo/app/talk.hoon +++ b/pkg/arvo/app/talk.hoon @@ -1922,7 +1922,7 @@ $(dif [%filter fit.cof.dif]) ?: ?=($remove -.dif) (sh-note (weld "rip " (~(cr-show cr cir) ~))) - ?: ?=($usage -.dif) +> + ?: ?=(?($usage $read) -.dif) +> %- sh-note %+ weld (weld ~(cr-phat cr cir) ": ") @@ -1933,9 +1933,6 @@ :: $caption "cap: {(trip cap.dif)}" - :: - $read - "" :: $filter ;: weld From 36b8902fadcb9d058d2ad15a2665621463af66e0 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 25 Jul 2019 14:12:44 -0700 Subject: [PATCH 013/124] Fix ~zod crash by fixing how %eyre handles app cancels. When we ask an app to run a %handle-http-cancel event, we don't actually care about the return value or even if it errors. The cancel event is purely informative. Likewise, because we cause cancels on restart of urbit, they cannot expose crashes to the system. Otherwise, an app with an open connection but a broken or non-existent cancel handler can prevent your ship from coming back up. --- pkg/arvo/sys/vane/eyre.hoon | 32 +++++++++++++++-------- pkg/arvo/tests/sys/vane/eyre.hoon | 43 ++++++++++++++++++++++--------- 2 files changed, 52 insertions(+), 23 deletions(-) diff --git a/pkg/arvo/sys/vane/eyre.hoon b/pkg/arvo/sys/vane/eyre.hoon index 83efcf5b73..8fa83a5ab7 100644 --- a/pkg/arvo/sys/vane/eyre.hoon +++ b/pkg/arvo/sys/vane/eyre.hoon @@ -802,7 +802,7 @@ :: :_ state :_ ~ - :^ duct %pass /run-app/[app.act] + :^ duct %pass /run-app-request/[app.act] ^- note :^ %g %deal [our our] :: @@ -847,7 +847,7 @@ %app :_ state :_ ~ - :^ duct %pass /run-app/[app.action] + :^ duct %pass /run-app-request/[app.action] ^- note :^ %g %deal [our our] :: todo: i don't entirely understand gall; there's a way to make a gall @@ -892,12 +892,9 @@ %app :_ state :_ ~ - :^ duct %pass /run-app/[app.action.u.connection] + :^ duct %pass /run-app-cancel/[app.action.u.connection] ^- note :^ %g %deal [our our] - :: todo: i don't entirely understand gall; there's a way to make a gall - :: use a %handle arm instead of a sub-%poke with the - :: %handle-http-request type. :: ^- cush:gall :* app.action.u.connection @@ -2029,13 +2026,14 @@ ?+ i.wire ~|([%bad-take-wire wire] !!) :: - %run-app run-app - %run-build run-build - %channel channel - %acme acme-ack + %run-app-request run-app-request + %run-app-cancel run-app-cancel + %run-build run-build + %channel channel + %acme acme-ack == :: - ++ run-app + ++ run-app-request :: ?> ?=([%g %unto *] sign) :: @@ -2060,6 +2058,18 @@ =^ moves server-state.ax (handle-response http-event.p.sign) [moves http-server-gate] :: + ++ run-app-cancel + :: + ?> ?=([%g %unto *] sign) + :: + :: we explicitly don't care about the return value of a + :: %handle-http-cancel. It is purely a notification and we don't care if + :: it succeeds or not. The user might not have implemented + :: +poke-handle-http-cancel or it might have crashed, but since it's a + :: notification, we don't don't care about its return value. + :: + [~ http-server-gate] + :: ++ run-build :: ?> ?=([%f %made *] sign) diff --git a/pkg/arvo/tests/sys/vane/eyre.hoon b/pkg/arvo/tests/sys/vane/eyre.hoon index 390250b144..7eb63f96c9 100644 --- a/pkg/arvo/tests/sys/vane/eyre.hoon +++ b/pkg/arvo/tests/sys/vane/eyre.hoon @@ -272,7 +272,7 @@ (expect-eq !>(~[/http-blah]) !>(duct)) :: %+ expect-gall-deal - :+ /run-app/app1 [~nul ~nul] + :+ /run-app-request/app1 [~nul ~nul] ^- cush:gall :* %app1 %poke %handle-http-request !>([%.n %.n [%ipv4 .192.168.1.1] [%'GET' '/' ~ ~]]) @@ -287,7 +287,7 @@ now=~1111.1.4 scry=scry-provides-code ^= take-args - :* wire=/run-app/app1 duct=~[/http-blah] + :* wire=/run-app-request/app1 duct=~[/http-blah] ^- (hypo sign:http-server-gate) :- *type :* %g %unto %http-response @@ -359,7 +359,7 @@ (expect-eq !>(~[/http-blah]) !>(duct)) :: %+ expect-gall-deal - :+ /run-app/app1 [~nul ~nul] + :+ /run-app-request/app1 [~nul ~nul] ^- cush:gall :* %app1 %poke %handle-http-request !>([%.n %.n [%ipv4 .192.168.1.1] [%'GET' '/' ~ ~]]) @@ -374,7 +374,7 @@ now=~1111.1.4 scry=scry-provides-code ^= take-args - :* wire=/run-app/app1 duct=~[/http-blah] + :* wire=/run-app-request/app1 duct=~[/http-blah] ^- (hypo sign:http-server-gate) :- *type :* %g %unto %coup ~ @@ -449,7 +449,7 @@ (expect-eq !>(~[/http-blah]) !>(duct)) :: %+ expect-gall-deal - :+ /run-app/app1 [~nul ~nul] + :+ /run-app-request/app1 [~nul ~nul] ^- cush:gall :* %app1 %poke %handle-http-request !>([%.n %.n [%ipv4 .192.168.1.1] [%'GET' '/' ~ ~]]) @@ -464,7 +464,7 @@ now=~1111.1.4 scry=scry-provides-code ^= take-args - :* wire=/run-app/app1 duct=~[/http-blah] + :* wire=/run-app-request/app1 duct=~[/http-blah] ^- (hypo sign:http-server-gate) :- *type :* %g %unto %http-response %start @@ -485,7 +485,7 @@ now=~1111.1.4 scry=scry-provides-code ^= take-args - :* wire=/run-app/app1 duct=~[/http-blah] + :* wire=/run-app-request/app1 duct=~[/http-blah] ^- (hypo sign:http-server-gate) :- *type :* %g %unto %http-response [%continue [~ (as-octs:mimes:html 'ya!')] %.y] @@ -556,7 +556,7 @@ (expect-eq !>(~[/http-blah]) !>(duct)) :: %+ expect-gall-deal - :+ /run-app/app1 [~nul ~nul] + :+ /run-app-request/app1 [~nul ~nul] ^- cush:gall :* %app1 %poke %handle-http-request !>([%.n %.n [%ipv4 .192.168.1.1] [%'GET' '/~landscape/inner-path' ~ ~]]) @@ -571,7 +571,7 @@ now=~1111.1.4 scry=scry-provides-code ^= take-args - :* wire=/run-app/app1 duct=~[/http-blah] + :* wire=/run-app-request/app1 duct=~[/http-blah] ^- (hypo sign:http-server-gate) :- *type :* %g %unto %http-response [%start [307 ['location' '/~/login?redirect=/~landscape/inner-path']~] ~ %.y] @@ -624,7 +624,7 @@ :: expect authenticated=%.y in the handle below :: %+ expect-gall-deal - :+ /run-app/app1 [~nul ~nul] + :+ /run-app-request/app1 [~nul ~nul] ^- cush:gall :* %app1 %poke %handle-http-request !> :* @@ -1814,7 +1814,7 @@ (expect-eq !>(~[/http-blah]) !>(duct)) :: %+ expect-gall-deal - :+ /run-app/app1 [~nul ~nul] + :+ /run-app-request/app1 [~nul ~nul] ^- cush:gall :* %app1 %poke %handle-http-request !>([%.n %.n [%ipv4 .192.168.1.1] [%'GET' '/' ~ ~]]) @@ -1848,19 +1848,38 @@ (expect-eq !>(~[/http-blah]) !>(duct)) :: %+ expect-gall-deal - :+ /run-app/app1 [~nul ~nul] + :+ /run-app-cancel/app1 [~nul ~nul] ^- cush:gall :* %app1 %poke %handle-http-cancel !>([%.n %.n [%ipv4 .192.168.1.1] [%'GET' '/' ~ ~]]) == card == + :: app1 doesn't have a %handle-http-cancel arm, but that's fine and doesn't + :: crash eyre when it sends its error coup back because we take no action on + :: the response to handle-http-cancel. + :: + =^ results5 http-server-gate + %- http-server-take :* + http-server-gate + now=~1111.1.4 + scry=scry-provides-code + ^= take-args + :* wire=/run-app-cancel/app1 duct=~[/http-blah] + ^- (hypo sign:http-server-gate) :- *type + :* %g %unto %coup + `[[%leaf "error! error! error!"] ~] + == + == + expected-move=~ + == :: ;: weld results1 results2 results3 results4 + results5 == :: ++ http-server-call From ef9b71a93184579b8c7849f3117308ab82bc1b7e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 25 Jul 2019 19:56:00 -0700 Subject: [PATCH 014/124] updates ames i/o driver to drop outbound packets if not live --- pkg/urbit/vere/ames.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/urbit/vere/ames.c b/pkg/urbit/vere/ames.c index b79902250f..d2b8df3a72 100644 --- a/pkg/urbit/vere/ames.c +++ b/pkg/urbit/vere/ames.c @@ -309,6 +309,12 @@ u3_ames_ef_send(u3_pier* pir_u, u3_noun lan, u3_noun pac) return; } + if ( c3n == sam_u->liv ) { + u3l_log("ames: not yet live, dropping outbound\r\n"); + u3z(lan); u3z(pac); + return; + } + u3_pact* pac_u = c3_calloc(sizeof(*pac_u)); if ( c3y == _ames_lane_ip(lan, &pac_u->por_s, &pac_u->pip_w) ) { From f31e60b38513558ab29c191bd722b866fb3d421e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 25 Jul 2019 19:56:34 -0700 Subject: [PATCH 015/124] updates ames i/o driver to track galaxy state transitions and print less --- pkg/urbit/include/vere/vere.h | 1 + pkg/urbit/vere/ames.c | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index f906cf5b8f..c59c61db7b 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -337,6 +337,7 @@ c3_c* dns_c; // domain XX multiple/fallback c3_w imp_w[256]; // imperial IPs time_t imp_t[256]; // imperial IP timestamps + c3_o imp_o[256]; // imperial print status } u3_ames; /* u3_save: checkpoint control. diff --git a/pkg/urbit/vere/ames.c b/pkg/urbit/vere/ames.c index d2b8df3a72..719c840f1c 100644 --- a/pkg/urbit/vere/ames.c +++ b/pkg/urbit/vere/ames.c @@ -122,11 +122,19 @@ _ames_czar_gone(u3_pact* pac_u, time_t now) u3_pier* pir_u = u3_pier_stub(); u3_ames* sam_u = pir_u->sam_u; - u3l_log("ames: czar at %s: not found (b)\n", pac_u->dns_c); + 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]) ) { + (0xffffffff == sam_u->imp_w[pac_u->imp_y]) ) + { sam_u->imp_w[pac_u->imp_y] = 0xffffffff; - } /* else keep existing ip for 5 more minutes */ + } + + // keep existing ip for 5 more minutes + // sam_u->imp_t[pac_u->imp_y] = now; _ames_pact_free(pac_u); @@ -136,8 +144,8 @@ _ames_czar_gone(u3_pact* pac_u, time_t now) */ static void _ames_czar_cb(uv_getaddrinfo_t* adr_u, - c3_i sas_i, - struct addrinfo* aif_u) + c3_i sas_i, + struct addrinfo* aif_u) { // XX revisit u3_pier* pir_u = u3_pier_stub(); @@ -160,6 +168,7 @@ _ames_czar_cb(uv_getaddrinfo_t* adr_u, 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 From b19c91dcf016a96b011276ca42245f6cc2634e4f Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Mon, 22 Jul 2019 14:11:54 -0700 Subject: [PATCH 016/124] specialize azimuth-tracker to sets of ships --- pkg/arvo/app/azimuth-tracker.hoon | 58 ++++++++++++++---------- pkg/arvo/gen/azimuth-tracker/listen.hoon | 2 +- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/pkg/arvo/app/azimuth-tracker.hoon b/pkg/arvo/app/azimuth-tracker.hoon index 30a5c92eb4..ff47da7f13 100644 --- a/pkg/arvo/app/azimuth-tracker.hoon +++ b/pkg/arvo/app/azimuth-tracker.hoon @@ -7,16 +7,18 @@ from-number=number:block == +$ app-state - $: url=@ta + $: %1 + url=@ta =number:block =pending-udiffs blocks=(list block) + whos=(set ship) == +$ peek-data ~ +$ in-poke-data $: %azimuth-tracker-poke $% [%init ~] - [%listen whos=(set ship) =source:kale] + [%listen whos=(list ship) =source:kale] [%watch =config] == == @@ -40,13 +42,16 @@ :: => |% ++ topics - => azimuth-events:azimuth - :_ ~ - :~ broke-continuity - changed-keys - lost-sponsor - escape-accepted - == + |= ships=(set ship) + :- => azimuth-events:azimuth + :~ broke-continuity + changed-keys + lost-sponsor + escape-accepted + == + ?: =(~ ships) + ~ + [(turn ~(tap in ships) ,@) ~] :: ++ request-rpc |= [url=@ta id=(unit @t) req=request:rpc:ethereum] @@ -177,7 +182,7 @@ -- :: ++ get-logs-by-hash - |= [url=@ta =hash:block] + |= [url=@ta whos=(set ship) =hash:block] =/ m (async:stdio udiffs:point) ^- form:m ;< =json bind:m @@ -186,7 +191,7 @@ %eth-get-logs-by-hash hash ~[azimuth:contracts:azimuth] - topics + (topics whos) == =/ event-logs=(list event-log:rpc:ethereum) (parse-event-logs:rpc:ethereum json) @@ -194,7 +199,7 @@ (pure:m udiffs) :: ++ get-logs-by-range - |= [url=@ta =from=number:block =to=number:block] + |= [url=@ta whos=(set ship) =from=number:block =to=number:block] =/ m (async:stdio udiffs:point) ^- form:m ;< =json bind:m @@ -204,7 +209,7 @@ `number+from-number `number+to-number ~[azimuth:contracts:azimuth] - topics + (topics whos) == =/ event-logs=(list event-log:rpc:ethereum) (parse-event-logs:rpc:ethereum json) @@ -274,10 +279,10 @@ :: Send %listen to kale :: ++ listen - |= [state=app-state whos=(set ship) =source:kale] + |= [state=app-state whos=(list ship) =source:kale] =/ m (async:stdio ,app-state) ^- form:m - ;< ~ bind:m (send-effect:stdio %listen /lo whos source) + ;< ~ bind:m (send-effect:stdio %listen /lo (silt whos) source) (pure:m state) :: :: Take %source from kale @@ -290,6 +295,7 @@ (pure:m state) =/ a-purl=purl:eyre node.p.source =. url.state (crip (en-purl:html a-purl)) + =. whos.state whos (watch state url.state launch:contracts:azimuth) :: :: Start watching a node @@ -324,7 +330,8 @@ (pure:m state) ;< =block bind:m (get-block-by-number url.state number.state) ;< [=new=pending-udiffs new-blocks=(lest ^block)] bind:m - (take-block url.state pending-udiffs.state block blocks.state) + %- take-block + [url.state whos.state pending-udiffs.state block blocks.state] =: pending-udiffs.state new-pending-udiffs blocks.state new-blocks number.state +(number.id.i.new-blocks) @@ -334,7 +341,7 @@ :: Process a block, detecting and handling reorgs :: ++ take-block - |= [url=@ta =a=pending-udiffs =block blocks=(list block)] + |= [url=@ta whos=(set ship) =a=pending-udiffs =block blocks=(list block)] =/ m (async:stdio ,[pending-udiffs (lest ^block)]) ^- form:m ~& [%taking id.block] @@ -343,7 +350,7 @@ (rewind url a-pending-udiffs block blocks) ;< =b=pending-udiffs bind:m (release-old-events a-pending-udiffs number.id.block) - ;< =new=udiffs:point bind:m (get-logs-by-hash url hash.id.block) + ;< =new=udiffs:point bind:m (get-logs-by-hash url whos hash.id.block) ~? !=(~ new-udiffs) [%adding-diffs new-udiffs] =. b-pending-udiffs (~(put by b-pending-udiffs) number.id.block new-udiffs) (pure:m b-pending-udiffs block blocks) @@ -396,11 +403,12 @@ |= [state=app-state =latest=number:block] =/ m (async:stdio ,number:block) ^- form:m - ?: (lth latest-number (add number.state 500)) - (pure:m latest-number) - =/ to-number=number:block (sub latest-number 500) + =/ zoom-margin=number:block 30 + ?: (lth latest-number (add number.state zoom-margin)) + (pure:m number.state) + =/ to-number=number:block (sub latest-number zoom-margin) ;< =udiffs:point bind:m - (get-logs-by-range url.state number.state to-number) + (get-logs-by-range url.state whos.state number.state to-number) ;< ~ bind:m (jael-update udiffs) (pure:m to-number) -- @@ -415,9 +423,9 @@ =/ m tapp-async ^- form:m ?- +<.in-poke-data - %init (init state) - %listen (listen state +>.in-poke-data) - %watch (watch state +>.in-poke-data) + %init (init state) + %listen (listen state +>.in-poke-data) + %watch (watch state +>.in-poke-data) == :: ++ handle-take diff --git a/pkg/arvo/gen/azimuth-tracker/listen.hoon b/pkg/arvo/gen/azimuth-tracker/listen.hoon index 228d0958ad..e672c583a9 100644 --- a/pkg/arvo/gen/azimuth-tracker/listen.hoon +++ b/pkg/arvo/gen/azimuth-tracker/listen.hoon @@ -5,7 +5,7 @@ == -- :- %say -|= [* [whos=(set ship) =src] ~] +|= [* [whos=(list ship) =src] ~] =/ =source:kale ?- -.src %ship [%& ship.src] From e2ff00bf9d97124db9d674e870bcf680d1e730b9 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Mon, 22 Jul 2019 15:02:51 -0700 Subject: [PATCH 017/124] listen to eth node for sponsor --- pkg/arvo/sys/vane/kale.hoon | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/sys/vane/kale.hoon b/pkg/arvo/sys/vane/kale.hoon index 5204b592a6..00cedabb29 100644 --- a/pkg/arvo/sys/vane/kale.hoon +++ b/pkg/arvo/sys/vane/kale.hoon @@ -47,7 +47,7 @@ sig=(unit oath) :: for a moon tuf=(list turf) :: domains boq=@ud :: boot block - nod=(unit purl:eyre) :: eth gateway + nod=purl:eyre :: eth gateway fak=_| :: fake keys lyf=life :: version jaw=(map life ring) :: private keys @@ -219,7 +219,9 @@ =. boq.own.pki bloq.tac :: save our ethereum gateway (required for galaxies) :: - =. nod.own.pki node.tac + =. nod.own.pki + %+ fall node.tac + (need (de-purl:html 'http://eth-mainnet.urbit.org:8545')) :: save our parent signature (only for moons) :: =. sig.own.pki sig.seed.tac @@ -262,6 +264,15 @@ [%diff ship diff]:i.diffs $(diffs t.diffs) :: + :: + =. +>.$ + %- curd =< abet + %+ sources:~(feel su hen our pki etn sap) + ?: =(%czar (clan:title our)) + ~ + (silt spon.tac ~) + [%| nod.own.pki *@ud *@da] + :: =. moz %+ weld moz :: order is crucial! From 577eed93b8173c6feae58f227b169449b9128cd0 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Tue, 23 Jul 2019 11:39:29 -0700 Subject: [PATCH 018/124] migrate ames to kale --- pkg/arvo/app/aqua.hoon | 5 ++- pkg/arvo/app/azimuth-tracker.hoon | 2 +- pkg/arvo/app/ph.hoon | 13 ++++++ pkg/arvo/lib/hood/drum.hoon | 3 +- pkg/arvo/lib/ph/azimuth.hoon | 75 ++++++++++++++++++++++++++----- pkg/arvo/lib/pill.hoon | 1 + pkg/arvo/sys/vane/ames.hoon | 69 +++++++++++++++------------- pkg/arvo/sys/vane/dill.hoon | 38 ++++++++++------ pkg/arvo/sys/vane/kale.hoon | 12 +++-- 9 files changed, 158 insertions(+), 60 deletions(-) diff --git a/pkg/arvo/app/aqua.hoon b/pkg/arvo/app/aqua.hoon index 865525ef60..20f7d74df7 100644 --- a/pkg/arvo/app/aqua.hoon +++ b/pkg/arvo/app/aqua.hoon @@ -435,8 +435,9 @@ [%fake who.ae] [%dawn u.keys.ae] -.userspace-ova.pil - [//http/0v1n.2m9vh %born ~] - [//http/0v1n.2m9vh %live 8.080 `8.445] + [//http-client/0v1n.2m9vh %born ~] + [//http-server/0v1n.2m9vh %born ~] + [//http-server/0v1n.2m9vh %live 8.080 `8.445] == =. this abet-pe:initted (pe who.ae) diff --git a/pkg/arvo/app/azimuth-tracker.hoon b/pkg/arvo/app/azimuth-tracker.hoon index ff47da7f13..0afba5268e 100644 --- a/pkg/arvo/app/azimuth-tracker.hoon +++ b/pkg/arvo/app/azimuth-tracker.hoon @@ -7,7 +7,7 @@ from-number=number:block == +$ app-state - $: %1 + $: %2 url=@ta =number:block =pending-udiffs diff --git a/pkg/arvo/app/ph.hoon b/pkg/arvo/app/ph.hoon index 3fd92ef386..b820f2a25e 100644 --- a/pkg/arvo/app/ph.hoon +++ b/pkg/arvo/app/ph.hoon @@ -112,6 +112,19 @@ router:eth-node (raw-ship ~bud `(dawn:eth-node ~bud)) (pure:m ~) + :: + :+ %hi-az + ~[~bud ~dev] + =. eth-node (spawn:eth-node ~dev) + ;< [eth-node=_eth-node ~] bind:m + %+ (wrap-philter ,_eth-node ,~) + router:eth-node + ;< ~ bind:m (raw-ship ~dev `(dawn:eth-node ~dev)) + ~& > %dev-done + ;< ~ bind:m (raw-ship ~bud `(dawn:eth-node ~bud)) + ~& > %bud-done + (send-hi ~bud ~dev) + (pure:m ~) :: :+ %breach-hi ~[~bud ~dev] diff --git a/pkg/arvo/lib/hood/drum.hoon b/pkg/arvo/lib/hood/drum.hoon index 773c2a9fff..ed61c9e990 100644 --- a/pkg/arvo/lib/hood/drum.hoon +++ b/pkg/arvo/lib/hood/drum.hoon @@ -97,6 +97,7 @@ [%home %publish] [%home %clock] [%home %weather] + [%home %azimuth-tracker] == :: ++ deft-fish :: default connects @@ -105,7 +106,7 @@ ^- (list gill:gall) [[our %talk] [our %dojo] ~] :: -++ make :: initial part +++ make :: initial part |= our/ship ^- part :* %drum diff --git a/pkg/arvo/lib/ph/azimuth.hoon b/pkg/arvo/lib/ph/azimuth.hoon index c634cfca87..3476466241 100644 --- a/pkg/arvo/lib/ph/azimuth.hoon +++ b/pkg/arvo/lib/ph/azimuth.hoon @@ -42,10 +42,26 @@ :- | :_ [%wait ~] %+ answer-request req s+(crip (num-to-hex:ethereum latest-block)) + ?: =(method 'eth_getBlockByNumber') + :- | :_ [%wait ~] + %+ answer-request req + :- %o + =/ hash (get-block-hash req) + =/ number (hash-to-number (hex-to-num:ethereum hash)) + =/ parent-hash (number-to-hash ?~(number number (dec number))) + %- malt + ^- (list (pair term json)) + :~ hash+s+hash + number+s+(crip (num-to-hex:ethereum number)) + 'parentHash'^s+(crip (num-to-hex:ethereum parent-hash)) + == ?: =(method 'eth_getLogs') :- | :_ [%wait ~] %+ answer-request req - %+ logs-to-json + ?~ (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') ?: =(method 'eth_newFilter') @@ -67,7 +83,7 @@ :+ | %+ answer-request req ~| [eth-filters latest-block] - (logs-to-json from-block.u.fil latest-block) + (logs-by-range from-block.u.fil latest-block) =. last-block.u.fil latest-block [%cont ..stay] ?: =(method 'eth_getFilterChanges') @@ -77,7 +93,7 @@ ~|(%no-filter-not-implemented !!) :+ | %+ answer-request req - (logs-to-json last-block.u.fil latest-block) + (logs-by-range last-block.u.fil latest-block) =. all.eth-filters %+ ~(put by all.eth-filters) fil-id @@ -110,6 +126,20 @@ ?> ?=([* ~] array) i.array :: + ++ get-param-obj-maybe + |= [req=@t param=@t] + ^- (unit @ud) + =, dejs-soft:format + =/ array + %. (need (de-json:html req)) + (ot params+(ar (ot param^so ~)) ~) + ?~ array + ~ + :- ~ + ?> ?=([* ~] u.array) + %- hex-to-num:ethereum + i.u.array + :: ++ get-filter-id |= req=@t =, dejs:format @@ -120,6 +150,15 @@ ?> ?=([* ~] id) i.id :: + ++ get-block-hash + |= req=@t + =, dejs:format + =/ id + %. (need (de-json:html req)) + (ot params+(ar so) ~) + ?> ?=([* * ~] id) + i.id + :: ++ answer-request |= [req=@t result=json] ^- (list ph-event) @@ -140,15 +179,30 @@ [%start [200 ~] `(as-octs:mimes:html resp) &] == :: - ++ logs-to-json + ++ number-to-hash + |= =number:block:able:kale + `@`(cat 3 0x5363 number) + :: + ++ hash-to-number + |= =hash:block:able:kale + (div hash 0x1.0000) + :: + ++ logs-by-range |= [from-block=@ud to-block=@ud] + %+ logs-to-json from-block + %+ swag + [(sub from-block launch:contracts:azimuth) (sub to-block from-block)] + logs + :: + ++ logs-by-hash + |= =hash:block:able:kale + =/ =number:block:able:kale (hash-to-number hash) + (logs-by-range number +(number)) + :: + ++ logs-to-json + |= [count=@ud selected-logs=(list az-log)] ^- json :- %a - =/ selected-logs - %+ swag - [(sub from-block launch:contracts:azimuth) (sub to-block from-block)] - logs - =/ count from-block |- ^- (list json) ?~ selected-logs ~ @@ -160,7 +214,8 @@ (crip (prefix-hex:ethereum (render-hex-bytes:ethereum 32 `@`0x5362))) :: :+ 'blockHash' %s - (crip (prefix-hex:ethereum (render-hex-bytes:ethereum 32 `@`0x5363))) + =/ hash (number-to-hash count) + (crip (prefix-hex:ethereum (render-hex-bytes:ethereum 32 hash))) :: :+ 'blockNumber' %s (crip (num-to-hex:ethereum count)) diff --git a/pkg/arvo/lib/pill.hoon b/pkg/arvo/lib/pill.hoon index f7018bd663..b3289cda36 100644 --- a/pkg/arvo/lib/pill.hoon +++ b/pkg/arvo/lib/pill.hoon @@ -41,6 +41,7 @@ :: sys/vane/jael: security :: [%j /vane/jael] + [%k /vane/kale] == |= [=term =path] =/ pax (weld sys path) diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index 67cfa59b65..3ee8fc811f 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -20,13 +20,13 @@ $: %d :: to %dill $>(%flog task:able:dill) :: log output == :: - $: %j :: to %jael + $: %k :: to %jael $> $? %meet :: neighbor - %pubs :: view public keys + %public-keys :: view public keys %turf :: view domains - %vein :: view private keys + %private-keys :: view private keys == :: - task:able:jael :: + task:able:kale :: == :: $: @tas :: to any $>(%west task:able) :: deliver message @@ -36,12 +36,12 @@ $% $: %b :: from %behn $>(%wake gift:able:behn) :: timer activate == :: - $: %j :: from %jael - $> $? %pubs :: public keys + $: %k :: from %jael + $> $? %public-keys :: public keys %turf :: bind to domains - %vein :: private keys + %private-keys :: private keys == :: - gift:able:jael :: + gift:able:kale :: == :: $: %g :: from %gall $% [%mean p=ares] :: XX obsolete @@ -573,7 +573,7 @@ %- (sloy-light ski) =/ pur=spur /(scot %ud lyf)/(scot %p who) - [[151 %noun] %j our %deed da+now pur] + [[151 %noun] %k our %deed da+now pur] :: +life-scry: for a +life :: ++ life-scry @@ -586,7 +586,7 @@ %- (sloy-light ski) =/ pur=spur /(scot %p who) - [[151 %noun] %j our %life da+now pur] + [[151 %noun] %k our %life da+now pur] :: +sein-scry: for sponsor :: ++ sein-scry @@ -595,7 +595,7 @@ ;; ship %- need %- need %- (sloy-light ski) - [[151 %noun] %j our %sein da+now /(scot %p who)] + [[151 %noun] %k our %sein da+now /(scot %p who)] :: +saxo-scry: for sponsorship chain :: ++ saxo-scry @@ -604,7 +604,7 @@ ;; (list ship) %- need %- need %- (sloy-light ski) - [[151 %noun] %j our %saxo da+now /(scot %p who)] + [[151 %noun] %k our %saxo da+now /(scot %p who)] :: +turf-scry: for network domains :: ++ turf-scry @@ -613,7 +613,7 @@ |. ;; (list turf) %- need %- need %- (sloy-light ski) - [[151 %noun] %j our %turf da+now ~] + [[151 %noun] %k our %turf da+now ~] :: ++ vein :: vein:am ~/ %vein @@ -1358,7 +1358,7 @@ ?- -.bon %beer =/ =wire /pubs/(scot %p p.bon) - :_ fox [hen [%pass wire %j %pubs p.bon]]~ + :_ fox [hen [%pass wire %k %public-keys (silt p.bon ~)]]~ :: %bock :: ignore %turf if we haven't yet learned a unix duct @@ -1371,7 +1371,7 @@ [gad.fox %give %turf tuf.fox]~ :: %brew - :_ fox [hen [%pass / %j %turf ~]]~ + :_ fox [hen [%pass / %k %turf ~]]~ :: %cake :: ~? ?=(^ r.bon) [%cake-woot-bad hen r.bon] @@ -1386,7 +1386,7 @@ %milk :: ~& [%milk p.bon q.bon] ?> ?=([@ @ *] q.q.bon) - ?> ?=(?(%a %c %e %g %j) i.q.q.bon) + ?> ?=(?(%a %c %e %g %j %k) i.q.q.bon) =/ =wire [(scot %p our) (scot %p p.bon) q.q.bon] :_ fox [hen %pass wire i.q.q.bon %west p.bon t.q.q.bon r.bon]~ :: @@ -1417,11 +1417,11 @@ :: %raki :_ fox - [hen [%pass / %j %meet who=p.bon life=q.bon pass=r.bon]]~ + [hen [%pass / %k %meet who=p.bon life=q.bon pass=r.bon]]~ :: %sake =/ =wire /our/(scot %p our) - :_ fox [hen [%pass wire %j %vein ~]]~ + :_ fox [hen [%pass wire %k %private-keys ~]]~ :: %wine :_ fox @@ -1453,30 +1453,39 @@ %mack ?~ +>.sih $(sih [%g %nice ~]) :: XX using old code $(sih [%g %mean `[%mack +>+.sih]]) :: - %pubs + %public-keys ?. ?=([%pubs @ ~] tea) ~& [%strange-pubs tea] - [~ +>] + [~ +>.$] + ?: ?& ?=(%diff -.public-keys-result.sih) + !?=(%keys -.diff.public-keys-result.sih) + == + [~ +>.$] =/ her=ship (slav %p i.t.tea) =/ gus (~(us go ton.fox) our) =/ diz (myx:gus her) - ?: =(0 life.sih) - :: this should clear lew.wod.dur.diz because it means - :: we no longer trust that their public key came to - :: us honestly (becuse of a %jael snapshot restore). - :: in practice, that crashes in ++cluy:las:as:go, so - :: we ignore for now. - ~& [%ames-hear-empty-pub her] - [~ +>.$] =/ ded=deed - [life.sih (~(got by pubs.sih) life.sih) oath=~] + ?: ?=(%full -.public-keys-result.sih) + ~| [her=her public-keys-result=public-keys-result.sih] + =/ a-point=(unit point:able:kale) + (~(get by points.public-keys-result.sih) her) + ?~ a-point + ~& [%no-keys her] + [*life *pass ~] + =/ a-pass=pass pass:(~(got by keys.u.a-point) life.u.a-point) + [life.u.a-point a-pass oath=~] + ?> ?=(%keys -.diff.public-keys-result.sih) + ?> =(her who.public-keys-result.sih) + =/ a-key-update=key-update:point:able:kale + to.diff.public-keys-result.sih + [life.a-key-update pass.a-key-update oath=~] =. lew.wod.dur.diz `ded =. ton.fox (~(su go ton.fox) (nux:gus diz)) [~ +>.$] :: %unto [~ +>] :: - %vein + %private-keys ?. ?=([%our @ ~] tea) ~& [%strange-vein tea] [~ +>] diff --git a/pkg/arvo/sys/vane/dill.hoon b/pkg/arvo/sys/vane/dill.hoon index 80472e7cd3..ca15846f18 100644 --- a/pkg/arvo/sys/vane/dill.hoon +++ b/pkg/arvo/sys/vane/dill.hoon @@ -79,15 +79,15 @@ $: %i :: $>(%wegh task:able:iris) :: == :: - $: %j :: + $: %k :: $> $? %dawn :: %fake :: %wegh :: == :: - task:able:jael :: + task:able:kale :: == == :: ++ sign :: in result $<- - $~ [%j %init *@p] :: + $~ [%k %init *@p] :: $% $: %a :: $% [%nice ~] :: XX obsolete $> $? %mass :: @@ -127,11 +127,11 @@ $: %i :: $>(%mass gift:able:iris) :: == :: - $: %j :: + $: %k :: $> $? %init :: %mass :: == :: - gift:able:jael :: + gift:able:kale :: == == :: :::::::: :: dill tiles -- @@ -283,7 +283,7 @@ [hen %pass /heft/ford %f %wegh ~] [hen %pass /heft/gall %g %wegh ~] [hen %pass /heft/iris %i %wegh ~] - [hen %pass /heft/jael %j %wegh ~] + [hen %pass /heft/jael %k %wegh ~] moz == == @@ -294,7 +294,7 @@ ;; ship %- need %- need %- (sloy-light ski) - [[151 %noun] %j our %sein da+now /(scot %p who)] + [[151 %noun] %k our %sein da+now /(scot %p who)] :: ++ init :: initialize ~& [%dill-init our ram] @@ -302,6 +302,18 @@ =. moz :_ moz [hen %pass /merg/home %c %merg %home our %base da+now %init] + =. moz + :_ moz + :* hen + %pass + ~ + %g + %deal + [our our] + %azimuth-tracker + %poke + [%azimuth-tracker-poke -:!>([%init ~]) [%init ~]] + == . :: ++ mere :: continue init @@ -385,14 +397,14 @@ |= sih/sign ^+ +> ?- sih - {?($a $b $c $e $f $g $i $j) $mass *} + {?($a $b $c $e $f $g $i $j %k) $mass *} (wegh -.sih p.sih) :: {$a $nice *} :: ~& [%take-nice-ames sih] +> :: - [%j %init *] + [%k %init *] :: pass thru to unix :: +>(moz :_(moz [hen %give +.sih])) @@ -440,7 +452,7 @@ :: +wegh: receive a memory report from a vane and maybe emit full report :: ++ wegh - |= [lal=?(%a %b %c %e %f %g %i %j) mas=mass] + |= [lal=?(%a %b %c %e %f %g %i %k) mas=mass] ^+ +> :: update our listing of vane responses with this new one :: @@ -453,7 +465,7 @@ %f ~?(?=(^ f.hef.all) %double-mass-f hef.all(f `mas)) %g ~?(?=(^ g.hef.all) %double-mass-g hef.all(g `mas)) %i ~?(?=(^ i.hef.all) %double-mass-i hef.all(i `mas)) - %j ~?(?=(^ j.hef.all) %double-mass-j hef.all(j `mas)) + %k ~?(?=(^ j.hef.all) %double-mass-j hef.all(j `mas)) == :: if not all vanes have responded yet, no-op :: @@ -512,10 +524,10 @@ ?> =(~ hey.all) =. hey.all `hen =/ boot - ((soft $>($?(%dawn %fake) task:able:jael)) p.task) + ((soft $>($?(%dawn %fake) task:able:kale)) p.task) ?~ boot ~| invalid-boot-event+hen !! - :_(..^$ [hen %pass / %j u.boot]~) + :_(..^$ [hen %pass / %k u.boot]~) :: we are subsequently initialized. single-home :: ?: ?=(%init -.task) diff --git a/pkg/arvo/sys/vane/kale.hoon b/pkg/arvo/sys/vane/kale.hoon index 00cedabb29..684c650559 100644 --- a/pkg/arvo/sys/vane/kale.hoon +++ b/pkg/arvo/sys/vane/kale.hoon @@ -580,7 +580,7 @@ ?~ yez this-su =* d i.yez =. this-su - ?. ?=([[%a @ @ *] *] d) + ?. &(?=([[%a @ @ *] *] d) !=(%pubs i.t.i.d)) %- emit [d %give %public-keys public-keys-result] =/ our (slav %p i.t.i.d) @@ -635,6 +635,7 @@ :: ++ public-keys |= whos=(set ship) + ~& [%public-keys-fake fak.own.pki whos] ?: fak.own.pki (public-keys:fake whos) =. ney.zim @@ -686,6 +687,7 @@ |% ++ public-keys |= whos=(set ship) + ~& [%fake-1 whos] =/ whol=(list ship) ~(tap in whos) =/ passes |- ^- (list [who=ship =pass]) @@ -694,12 +696,15 @@ =/ cub (pit:nu:crub:crypto 512 i.whol) :- [i.whol pub:ex:cub] $(whol t.whol) + ~& [%fake-2 passes] =/ points=(list (pair ship point)) %+ turn passes |= [who=ship =pass] ^- [who=ship =point] [who [rift=1 life=1 (my [1 1 pass] ~) `(^sein:title who)]] + ~& [%fake-3 points] =. moz [[hen %give %public-keys %full (my points)] moz] + ~& [%fake-4 moz] ..feel -- -- @@ -788,7 +793,8 @@ |= [who=ship =life =pass] :: XX rethink meet ^+ +> - !! + ~& [%kale-meet-should-do-something-about-moons who life pass] + +>.$ -- -- :: :::: @@ -835,7 +841,7 @@ :: old/state == ^+ ..^$ - ..^$ + ..^$(fak.own.pki.lex &) :: ..^$(lex old) :: :: ++scry ++ scry :: inspect From a47ef9ac7758c3a6fe89546ce48b737cc1b42357 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Wed, 24 Jul 2019 15:54:45 -0700 Subject: [PATCH 019/124] wip --- pkg/arvo/app/aqua.hoon | 5 ++-- pkg/arvo/app/azimuth-tracker.hoon | 9 ++++--- pkg/arvo/app/ph.hoon | 7 ++++++ pkg/arvo/lib/hood/drum.hoon | 22 ++++++++--------- pkg/arvo/lib/ph/azimuth.hoon | 41 ++++++++++++++++++++----------- pkg/arvo/lib/ph/util.hoon | 11 ++++----- pkg/arvo/lib/tapp.hoon | 8 +++--- pkg/arvo/sur/aquarium.hoon | 3 +-- pkg/arvo/sys/vane/clay.hoon | 3 +-- pkg/arvo/sys/vane/kale.hoon | 12 ++++++--- 10 files changed, 72 insertions(+), 49 deletions(-) diff --git a/pkg/arvo/app/aqua.hoon b/pkg/arvo/app/aqua.hoon index 20f7d74df7..38686c89fa 100644 --- a/pkg/arvo/app/aqua.hoon +++ b/pkg/arvo/app/aqua.hoon @@ -169,7 +169,7 @@ =. ..abet-pe =/ sof ((soft unix-effect) i.effects) ?~ sof - ~? aqua-debug=| [who=who %unknown-effect i.effects] + ~? aqua-debug=& [who=who %unknown-effect i.effects] ..abet-pe (publish-effect u.sof) $(effects t.effects) @@ -366,7 +366,8 @@ %e %eyre %f %ford %g %gall - %j %ford + %j %jael + %k %kale == =/ pax /(scot %p our.hid)/home/(scot %da now.hid)/sys/vane/[vane] diff --git a/pkg/arvo/app/azimuth-tracker.hoon b/pkg/arvo/app/azimuth-tracker.hoon index 0afba5268e..37aea63ebc 100644 --- a/pkg/arvo/app/azimuth-tracker.hoon +++ b/pkg/arvo/app/azimuth-tracker.hoon @@ -152,6 +152,7 @@ =/ m (async:stdio ,block) ^- form:m ;< =json bind:m (request-rpc url `'block number' %eth-block-number ~) + ~& [%block-number json (parse-eth-block-number:rpc:ethereum json)] (get-block-by-number url (parse-eth-block-number:rpc:ethereum json)) :: ++ get-block-by-number @@ -296,7 +297,7 @@ =/ a-purl=purl:eyre node.p.source =. url.state (crip (en-purl:html a-purl)) =. whos.state whos - (watch state url.state launch:contracts:azimuth) + (watch state url.state 0) :: launch:contracts:azimuth) :: :: Start watching a node :: @@ -317,9 +318,11 @@ |= state=app-state =/ m (async:stdio ,app-state) ^- form:m - ~& [%get-updates number.state] + ~& [%get-updatessss number.state] ;< =latest=block bind:m (get-latest-block url.state) + ~& [%latest-block number.state] ;< =new=number:block bind:m (zoom state number.id.latest-block) + ~& [%zoomed-to number.state] =. number.state new-number |- ^- form:m =* walk-loop $ @@ -403,7 +406,7 @@ |= [state=app-state =latest=number:block] =/ m (async:stdio ,number:block) ^- form:m - =/ zoom-margin=number:block 30 + =/ zoom-margin=number:block 3 ?: (lth latest-number (add number.state zoom-margin)) (pure:m number.state) =/ to-number=number:block (sub latest-number zoom-margin) diff --git a/pkg/arvo/app/ph.hoon b/pkg/arvo/app/ph.hoon index b820f2a25e..8c286f21a4 100644 --- a/pkg/arvo/app/ph.hoon +++ b/pkg/arvo/app/ph.hoon @@ -133,16 +133,23 @@ %+ (wrap-philter ,_eth-node ,~) router:eth-node ;< ~ bind:m (raw-ship ~bud `(dawn:eth-node ~bud)) + ~& > 'BUD DONE' ;< ~ bind:m (raw-ship ~dev `(dawn:eth-node ~dev)) + ~& > 'DEV DONE' (send-hi ~bud ~dev) + ~& > 'HI DONE' ;< eth-node=_eth-node bind:m (breach-and-hear:eth-node our.hid ~dev ~bud) + ~& > 'BREACH DONE' ;< [eth-node=_eth-node ~] bind:m %+ (wrap-philter ,_eth-node ,~) router:eth-node ;< ~ bind:m (send-hi-not-responding ~bud ~dev) + ~& > 'HI NOT RESPONDING DONE' ;< ~ bind:m (raw-ship ~dev `(dawn:eth-node ~dev)) + ~& > 'REBOOT DEV DONE' (wait-for-dojo ~bud "hi ~dev successful") + ~& > 'DONE' (pure:m ~) :: :+ %breach-hi-cousin diff --git a/pkg/arvo/lib/hood/drum.hoon b/pkg/arvo/lib/hood/drum.hoon index ed61c9e990..9b987da687 100644 --- a/pkg/arvo/lib/hood/drum.hoon +++ b/pkg/arvo/lib/hood/drum.hoon @@ -85,18 +85,18 @@ [%base %dojo] [%base %modulo] == - :~ [%home %lens] - [%home %acme] - [%home %dns] + :~ :: [%home %lens] + :: [%home %acme] + :: [%home %dns] [%home %dojo] - [%home %hall] - [%home %talk] - [%home %modulo] - [%home %launch] - [%home %chat] - [%home %publish] - [%home %clock] - [%home %weather] + :: [%home %hall] + :: [%home %talk] + :: [%home %modulo] + :: [%home %launch] + :: [%home %chat] + :: [%home %publish] + :: [%home %clock] + :: [%home %weather] [%home %azimuth-tracker] == :: diff --git a/pkg/arvo/lib/ph/azimuth.hoon b/pkg/arvo/lib/ph/azimuth.hoon index 3476466241..14b5b1aa31 100644 --- a/pkg/arvo/lib/ph/azimuth.hoon +++ b/pkg/arvo/lib/ph/azimuth.hoon @@ -30,14 +30,15 @@ |= pin=ph-input ^- output:n =, enjs:format - =/ thus (extract-thus-to uf.pin 'http://localhost:8545') - ?~ thus + =/ ask (extract-request uf.pin 'http://localhost:8545/') + ?~ ask [& ~ %wait ~] - ?~ r.mot.u.thus + ?~ body.request.u.ask [& ~ %wait ~] - =/ req q.u.r.mot.u.thus + =/ req q.u.body.request.u.ask |^ ^- output:n =/ method (get-method req) + :: =; a ~& [%give-azimuth-response a] - ?: =(method 'eth_blockNumber') :- | :_ [%wait ~] %+ answer-request req @@ -46,19 +47,22 @@ :- | :_ [%wait ~] %+ answer-request req :- %o - =/ hash (get-block-hash req) - =/ number (hash-to-number (hex-to-num:ethereum hash)) + =/ number (hex-to-num:ethereum (get-block-hash req)) + ~& number=number + =/ hash (number-to-hash number) + ~& hash=hash =/ parent-hash (number-to-hash ?~(number number (dec number))) + ~& parent-hash=parent-hash %- malt ^- (list (pair term json)) - :~ hash+s+hash + :~ 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') :- | :_ [%wait ~] %+ answer-request req - ?~ (get-param-obj-maybe req 'blockHash') + ?^ (get-param-obj-maybe req 'blockHash') %- logs-by-hash (get-param-obj req 'blockHash') %+ logs-by-range @@ -155,9 +159,8 @@ =, dejs:format =/ id %. (need (de-json:html req)) - (ot params+(ar so) ~) - ?> ?=([* * ~] id) - i.id + (ot params+(at so bo ~) ~) + -.id :: ++ answer-request |= [req=@t result=json] @@ -175,23 +178,31 @@ who.pin //http-client/0v1n.2m9vh %receive - num.u.thus + num.u.ask [%start [200 ~] `(as-octs:mimes:html resp) &] == :: ++ number-to-hash |= =number:block:able:kale - `@`(cat 3 0x5363 number) + ^- @ + ?: (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:kale - (div hash 0x1.0000) + (add launch:contracts:azimuth (div hash 0x1.0000)) :: ++ logs-by-range |= [from-block=@ud to-block=@ud] %+ logs-to-json from-block + ?: (lth to-block launch:contracts:azimuth) + ~ %+ swag - [(sub from-block launch:contracts:azimuth) (sub to-block from-block)] + ?: (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 :: ++ logs-by-hash diff --git a/pkg/arvo/lib/ph/util.hoon b/pkg/arvo/lib/ph/util.hoon index 995f9db0bf..4d370b0524 100644 --- a/pkg/arvo/lib/ph/util.hoon +++ b/pkg/arvo/lib/ph/util.hoon @@ -80,13 +80,12 @@ :: :: Check if given effect is an http request; extract :: -++ extract-thus-to +++ extract-request |= [uf=unix-effect dest=@t] - ^- (unit [num=@ud mot=moth:eyre]) - ?. ?=(%thus -.q.uf) ~ - ?~ q.q.uf ~ - ?. =(p.u.q.q.uf (rash dest auri:de-purl:html)) ~ - `[p.q.uf q.u.q.q.uf] + ^- (unit [num=@ud =request:http]) + ?. ?=(%request -.q.uf) ~ + ?. =(dest url.request.q.uf) ~ + `[id.q.uf request.q.uf] :: :: Scry into a running aqua ship :: diff --git a/pkg/arvo/lib/tapp.hoon b/pkg/arvo/lib/tapp.hoon index c5071b7d21..3d8dfc479e 100644 --- a/pkg/arvo/lib/tapp.hoon +++ b/pkg/arvo/lib/tapp.hoon @@ -254,10 +254,10 @@ :: XX use only for development may break contracts! :: XX if active clam contracts only to abort transaction? :: - :: ~& [%tapp-reset dap.bowl] - :: `this-tapp - ~| [%tapp-load-incompatible dap.bowl] - !! + ~& [%tapp-reset dap.bowl] + `this-tapp + :: ~| [%tapp-load-incompatible dap.bowl] + :: !! :: :: because the clam replaces the active continuation with :: the bunt of its mold, we must fail the transaction diff --git a/pkg/arvo/sur/aquarium.hoon b/pkg/arvo/sur/aquarium.hoon index dd1c89d444..59d56f781e 100644 --- a/pkg/arvo/sur/aquarium.hoon +++ b/pkg/arvo/sur/aquarium.hoon @@ -44,8 +44,6 @@ %+ pair wire $% [%wack p=@] [%whom p=ship] - [%live p=@ud q=(unit @ud)] - [%barn ~] [%boot $%([%fake p=ship] [%dawn p=dawn-event])] unix-task == @@ -60,6 +58,7 @@ [%sleep ~] [%restore ~] [%init ~] + [%request id=@ud request=request:http] == +$ pill [boot-ova=* kernel-ova=(list unix-event) userspace-ova=(list unix-event)] diff --git a/pkg/arvo/sys/vane/clay.hoon b/pkg/arvo/sys/vane/clay.hoon index 166616b828..8b95318e37 100644 --- a/pkg/arvo/sys/vane/clay.hoon +++ b/pkg/arvo/sys/vane/clay.hoon @@ -2402,7 +2402,6 @@ :: Must uni the old-lat into the new-lat so that if we recreate :: the same blob hash, we use the old blob not the new one. Else :: you get mutually recurring %delta blobs. - :: ++ add-blobs |= [new-blobs=(map path blob) old-lat=(map lobe blob)] ^- (map lobe blob) @@ -4107,7 +4106,7 @@ %boat :_ ..^$ [hen %give %hill (turn ~(tap by mon.ruf) head)]~ - ::. + :: %cred =. cez.ruf ?~ cew.req (~(del by cez.ruf) nom.req) diff --git a/pkg/arvo/sys/vane/kale.hoon b/pkg/arvo/sys/vane/kale.hoon index 684c650559..2a98be6018 100644 --- a/pkg/arvo/sys/vane/kale.hoon +++ b/pkg/arvo/sys/vane/kale.hoon @@ -83,7 +83,7 @@ $>(%want task:able:ames) :: send message == :: $: %k :: to self - $>(%listen task) :: set ethereum source + $>(%listen task) :: set ethereum source == :: $: @tas :: $% $>(%init vane-task) :: report install @@ -411,6 +411,7 @@ :: ships with real keys must have domains, :: those with fake keys must not :: + ~| [fak.own.pki tuf.own.pki] ?< =(fak.own.pki ?=(^ tuf.own.pki)) +>.$(moz [[hen %give %turf tuf.own.pki] moz]) :: @@ -676,7 +677,10 @@ yen.etn (~(put in yen.etn) hen) moz %- welp :_ moz + ~& [%kale-sources-feed etn=etn] %+ turn + ^- (list (pair source-id (set ship))) + :- [default-source.etn ~] ~(tap by ship-sources-reverse.etn) |= [=source-id whos=(set ship)] [hen %give %source whos (~(got by sources.etn) source-id)] @@ -782,8 +786,8 @@ ?~ whol ship-sources.etn (~(put by $(whol t.whol)) i.whol source-id) - =. ship-sources-reverse - %- ~(gas ju ship-sources-reverse) + =. ship-sources-reverse.etn + %- ~(gas ju ship-sources-reverse.etn) (turn whol |=(=ship [source-id ship])) ..feed (exec yen.etn [%give %source whos source]) @@ -841,7 +845,7 @@ :: old/state == ^+ ..^$ - ..^$(fak.own.pki.lex &) + ..^$ :: ..^$(lex old) :: :: ++scry ++ scry :: inspect From dd76358f6a97782c832674acf9240e21eb8a4094 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Fri, 26 Jul 2019 20:43:07 -0700 Subject: [PATCH 020/124] %breach-hi works with kale --- pkg/arvo/lib/ph/azimuth.hoon | 4 +- pkg/arvo/sys/arvo.hoon | 2 +- pkg/arvo/sys/vane/ames.hoon | 59 +++++++++--------- pkg/arvo/sys/vane/clay.hoon | 116 +++++++++++++++++++---------------- pkg/arvo/sys/vane/dill.hoon | 6 -- pkg/arvo/sys/vane/ford.hoon | 6 -- pkg/arvo/sys/vane/gall.hoon | 2 - pkg/arvo/sys/vane/jael.hoon | 14 ++--- pkg/arvo/sys/zuse.hoon | 10 --- 9 files changed, 104 insertions(+), 115 deletions(-) diff --git a/pkg/arvo/lib/ph/azimuth.hoon b/pkg/arvo/lib/ph/azimuth.hoon index 14b5b1aa31..c3ad8e1f40 100644 --- a/pkg/arvo/lib/ph/azimuth.hoon +++ b/pkg/arvo/lib/ph/azimuth.hoon @@ -103,6 +103,7 @@ fil-id u.fil(last-block latest-block) [%cont ..stay] + ~& [%ph-azimuth-miss req] [& ~ %wait ~] :: ++ latest-block @@ -346,6 +347,7 @@ ++ breach-and-hear |= [our=@p who=@p her=@p] =. this-az (breach who) + =. this-az (spawn ~fes) =/ new-rut rut:(~(got by lives) who) =/ m (ph ,_this-az) ;< [this-az=_this-az ~] bind:m @@ -356,7 +358,7 @@ :+ & ~ =/ aqua-pax :- %i - /(scot %p her)/j/(scot %p her)/rift/(scot %da now.pin)/(scot %p who)/noun + /(scot %p her)/k/(scot %p her)/rift/(scot %da now.pin)/(scot %p who)/noun =/ rut (scry-aqua noun our now.pin aqua-pax) ?: =([~ new-rut] rut) [%done ~] diff --git a/pkg/arvo/sys/arvo.hoon b/pkg/arvo/sys/arvo.hoon index 49321eb07b..6e74ffabe4 100644 --- a/pkg/arvo/sys/arvo.hoon +++ b/pkg/arvo/sys/arvo.hoon @@ -459,7 +459,7 @@ :: ++ dint :: input routing |= hap/path ^- @tas - ?+ hap !! + ?+ hap ~|([%bad-dint hap] !!) {@ $ames *} %a {@ $boat *} %c {@ $newt *} %a diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index 3ee8fc811f..e7beff2bcd 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -1424,17 +1424,20 @@ :_ fox [hen [%pass wire %k %private-keys ~]]~ :: %wine - :_ fox - =+ fom=~(rend co %$ %p p.bon) - :~ :- hen - :+ %slip %d - :+ %flog %text - ;: weld - "; " - fom - q.bon - == - == + [[(print hen p.bon q.bon) ~] fox] + == + :: + ++ print + |= [hen=duct who=ship =tape] + ^- move + =+ fom=~(rend co %$ %p who) + :- hen + :+ %slip %d + :+ %flog %text + ;: weld + "; " + fom + tape == :: ++ knap @@ -1457,6 +1460,10 @@ ?. ?=([%pubs @ ~] tea) ~& [%strange-pubs tea] [~ +>.$] + ?: ?& ?=(%diff -.public-keys-result.sih) + ?=(%rift -.diff.public-keys-result.sih) + == + (sink hen [who [from to]:diff]:public-keys-result.sih) ?: ?& ?=(%diff -.public-keys-result.sih) !?=(%keys -.diff.public-keys-result.sih) == @@ -1530,6 +1537,17 @@ $(p.fuy t.p.fuy, out (weld (flop toe) out)) == :: + ++ sink + |= [hen=duct who=ship from=rift to=rift] + ^- [(list move) _+>] + ?: =(our who) + [[(print hen who ", you have sunk") ~] +>.$] + :: + =: hoc.ton.fox (~(del by hoc.ton.fox) who) + wab.zac.fox (~(del by wab.zac.fox) who) + == + [[(print hen who " has sunk") ~] +>.$] + :: ++ knob ~/ %knob |= [hen=duct kyz=task:able] @@ -1594,25 +1612,6 @@ fox(bad (~(del in bad.fox) p.kyz)) ~& [%block p.kyz] fox(bad (~(put in bad.fox) p.kyz)) - :: - %sunk - =* who p.kyz - =* lyf q.kyz - ?: =(our who) - ?: (lth lyf p:(head val.ton.fox)) - :: replaying our old sinkage, ignore - :: XX review - :: - [~ fox] - :: XX include some helpful instructions here - :: - :_ fox - [%wine who ", you have sunk"]~ - :: - =: hoc.ton.fox (~(del by hoc.ton.fox) who) - wab.zac.fox (~(del by wab.zac.fox) who) - == - [[%wine who " has sunk"]~ fox] :: %vega :: re-initialize our cryptosuite B cores diff --git a/pkg/arvo/sys/vane/clay.hoon b/pkg/arvo/sys/vane/clay.hoon index 8b95318e37..006df86e04 100644 --- a/pkg/arvo/sys/vane/clay.hoon +++ b/pkg/arvo/sys/vane/clay.hoon @@ -524,6 +524,9 @@ $: %f :: by %ford $>(%made gift:able:ford) :: == :: + $: %k :: by %kale + $>(%public-keys gift:able:kale) :: + == :: $: @tas :: by any $>(%crud vane-task) :: XX strange == == :: @@ -4303,49 +4306,6 @@ =/ den ((de our now ski hen ruf) our des.req) abet:(perm:den pax.req rit.req) [mos ..^$] - :: - %sunk - ~& rift=[p.req q.req] - ~& desks=(turn ~(tap by dos.rom.ruf) head) - ~& hoy=(turn ~(tap by hoy.ruf) head) - :: - ?: =(our p.req) - [~ ..^$] - :: Cancel subscriptions - :: - =/ foreign-desk=(unit rung) - (~(get by hoy.ruf) p.req) - ?~ foreign-desk - ~& [%never-heard-of-her p.req q.req] - [~ ..^$] - ~& old-rift=rit.u.foreign-desk - ?: (gte rit.u.foreign-desk q.req) - ~& 'replaying sunk, so not clearing state' - [~ ..^$] - =/ cancel-ducts=(list duct) - %- zing ^- (list (list duct)) - %+ turn ~(tap by rus.u.foreign-desk) - |= [=desk =rede] - ^- (list duct) %- zing ^- (list (list duct)) - %+ turn ~(tap by qyx.rede) - |= [=wove ducts=(set duct)] - :: ~& [%sunk-wove desk (print-wove wove) ducts] - ~(tap in ducts) - =/ cancel-moves=(list move) - %+ turn cancel-ducts - |= =duct - [duct %slip %b %drip !>([%writ ~])] - :: Clear ford cache - :: - =/ clear-ford-cache-moves=(list move) - :~ [hen %pass /clear/keep %f %keep 0 1] - [hen %pass /clear/wipe %f %wipe 100] - [hen %pass /clear/kep %f %keep 2.048 64] - == - :: delete local state of foreign desk - :: - =. hoy.ruf (~(del by hoy.ruf) p.req) - [(weld clear-ford-cache-moves cancel-moves) ..^$] :: %vega [~ ..^$] :: @@ -4445,30 +4405,30 @@ :: ++ stay [%1 ruf] ++ take :: accept response - |= {tea/wire hen/duct hin/(hypo sign)} + |= [tea=wire hen=duct hin=(hypo sign)] ^+ [*(list move) ..^$] - ?: ?=({$commit @ *} tea) + ?: ?=([%commit @ *] tea) =* syd i.t.tea =^ mos ruf =/ den ((de our now ski hen ruf) our syd) abet:(take-commit:den q.hin) [mos ..^$] :: - ?: ?=({$merge @ *} tea) + ?: ?=([%merge @ *] tea) =* syd i.t.tea =^ mos ruf =/ den ((de our now ski hen ruf) our syd) abet:(take-merge:den q.hin) [mos ..^$] :: - ?: ?=({$mount @ *} tea) + ?: ?=([%mount @ *] tea) =* syd i.t.tea =^ mos ruf =/ den ((de our now ski hen ruf) our syd) abet:(take-mount:den q.hin) [mos ..^$] :: - ?: ?=({%foreign-request @ @ @ *} tea) + ?: ?=([%foreign-request @ @ @ *] tea) =/ her (slav %p i.t.tea) =/ syd (slav %tas i.t.t.tea) =/ inx (slav %ud i.t.t.t.tea) @@ -4477,7 +4437,7 @@ abet:(take-foreign-request:den inx q.hin) [mos ..^$] :: - ?: ?=({%foreign-update @ @ *} tea) + ?: ?=([%foreign-update @ @ *] tea) =/ her (slav %p i.t.tea) =/ syd (slav %tas i.t.t.tea) =^ mos ruf @@ -4485,8 +4445,8 @@ abet:(take-foreign-update:den q.hin) [mos ..^$] :: - ?: ?=({$blab care @ @ *} tea) - ?> ?=($made +<.q.hin) + ?: ?=([%blab care @ @ *] tea) + ?> ?=(%made +<.q.hin) ?. ?=([%complete %success *] result.q.hin) ~| %blab-fail ~> %mean.|.((made-result-as-error:ford result.q.hin)) @@ -4494,14 +4454,66 @@ :_ ..^$ :_ ~ :* hen %slip %b %drip !> :* %writ ~ - ^- {care case @tas} + ^- [care case @tas] [i.t.tea ;;(case +>:(slay i.t.t.tea)) i.t.t.t.tea] :: `path`t.t.t.t.tea `cage`(result-to-cage:ford build-result.result.q.hin) == == :: + ?: ?=([%sinks ~] tea) + ?> ?=(%public-keys +<.q.hin) + ~& 'XXX' + ?: ?=(%full -.public-keys-result.q.hin) + !! + ?. ?=(%rift -.diff.public-keys-result.q.hin) + [~ ..^$] + ~& rift=public-keys-result.q.hin + =/ who who.public-keys-result.q.hin + =/ to-rift to.diff.public-keys-result.q.hin + ~& desks=(turn ~(tap by dos.rom.ruf) head) + ~& hoy=(turn ~(tap by hoy.ruf) head) + :: + ?: =(our who) + [~ ..^$] + :: Cancel subscriptions + :: + =/ foreign-desk=(unit rung) + (~(get by hoy.ruf) who) + ?~ foreign-desk + ~& [%never-heard-of-her who] + [~ ..^$] + ~& old-rift=rit.u.foreign-desk + ?: (gte rit.u.foreign-desk to-rift) + ~& 'replaying sunk, so not clearing state' + [~ ..^$] + =/ cancel-ducts=(list duct) + %- zing ^- (list (list duct)) + %+ turn ~(tap by rus.u.foreign-desk) + |= [=desk =rede] + ^- (list duct) %- zing ^- (list (list duct)) + %+ turn ~(tap by qyx.rede) + |= [=wove ducts=(set duct)] + :: ~& [%sunk-wove desk (print-wove wove) ducts] + ~(tap in ducts) + =/ cancel-moves=(list move) + %+ turn cancel-ducts + |= =duct + [duct %slip %b %drip !>([%writ ~])] + :: Clear ford cache + :: + =/ clear-ford-cache-moves=(list move) + :~ [hen %pass /clear/keep %f %keep 0 1] + [hen %pass /clear/wipe %f %wipe 100] + [hen %pass /clear/kep %f %keep 2.048 64] + == + :: delete local state of foreign desk + :: + =. hoy.ruf (~(del by hoy.ruf) who) + [(weld clear-ford-cache-moves cancel-moves) ..^$] + :: ?- -.+.q.hin + %public-keys ~|([%public-keys-raw tea] !!) %init-clad ~|(%clad-not-real !!) :: diff --git a/pkg/arvo/sys/vane/dill.hoon b/pkg/arvo/sys/vane/dill.hoon index ca15846f18..26a23708fa 100644 --- a/pkg/arvo/sys/vane/dill.hoon +++ b/pkg/arvo/sys/vane/dill.hoon @@ -297,7 +297,6 @@ [[151 %noun] %k our %sein da+now /(scot %p who)] :: ++ init :: initialize - ~& [%dill-init our ram] ^+ . =. moz :_ moz @@ -317,7 +316,6 @@ . :: ++ mere :: continue init - ~& [%dill-mere our ram] ^+ . =/ myt (flop (fall tem ~)) =/ can (clan:title our) @@ -551,10 +549,6 @@ =? p.task ?=([%crud %hax-heft ~] p.task) [%heft ~] :: $(hen u.hey.all, wrapped-task p.task) - :: a %sunk notification from %jail comes in on an unfamiliar duct - :: - ?: ?=(%sunk -.task) - [~ ..^$] :: a %vega notification on kernel upgrade comes in on an unfamiliar duct :: ?: ?=(%vega -.task) diff --git a/pkg/arvo/sys/vane/ford.hoon b/pkg/arvo/sys/vane/ford.hoon index da93d11db0..23b81fa159 100644 --- a/pkg/arvo/sys/vane/ford.hoon +++ b/pkg/arvo/sys/vane/ford.hoon @@ -6168,12 +6168,6 @@ =^ moves state.ax cancel:this-event :: [moves ford-gate] - :: - :: %sunk: foreign ship has lost continutity - :: - %sunk - :: - [~ ford-gate] :: :: %vega: learn of kernel upgrade :: diff --git a/pkg/arvo/sys/vane/gall.hoon b/pkg/arvo/sys/vane/gall.hoon index 034a221891..f23088c292 100644 --- a/pkg/arvo/sys/vane/gall.hoon +++ b/pkg/arvo/sys/vane/gall.hoon @@ -1381,8 +1381,6 @@ :: $init [~ ..^$(sys.mast.all hen)] - :: - $sunk [~ ..^$] :: $vega [~ ..^$] :: diff --git a/pkg/arvo/sys/vane/jael.hoon b/pkg/arvo/sys/vane/jael.hoon index 749e18c573..dcd33e0042 100644 --- a/pkg/arvo/sys/vane/jael.hoon +++ b/pkg/arvo/sys/vane/jael.hoon @@ -118,7 +118,6 @@ == :: $: @tas :: $% $>(%init vane-task) :: report install - $>(%sunk vane-task) :: report death == == == :: :: :: +$ sign :: in result $<- @@ -1484,12 +1483,13 @@ %+ weld :: %- flop ^- (list move) - :~ [hen %slip %a %sunk who rit] - [hen %slip %c %sunk who rit] - [hen %slip %d %sunk who rit] - [hen %slip %f %sunk who rit] - [hen %slip %g %sunk who rit] - == + ~ + :: :~ [hen %slip %a %sunk who rit] + :: [hen %slip %c %sunk who rit] + :: [hen %slip %d %sunk who rit] + :: [hen %slip %f %sunk who rit] + :: [hen %slip %g %sunk who rit] + :: == moz == :: pon: updated point diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index 9d3b8ea020..bf2ae38d79 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -203,9 +203,6 @@ :: boot completed (XX legacy) :: [%init p=ship] - :: peer discontinuity - :: - [%sunk p=ship q=rift] :: kernel upgraded :: [%vega ~] @@ -393,7 +390,6 @@ $>(%init vane-task) :: report install {$kick p/@da} :: wake up {$nuke p/@p} :: toggle auto-block - $>(%sunk vane-task) :: report death $>(%vega vane-task) :: report upgrade {$wake ~} :: timer activate $>(%wegh vane-task) :: report memory @@ -628,7 +624,6 @@ {$dirk des/desk} :: mark mount dirty {$ogre pot/$@(desk beam)} :: delete mount point {$perm des/desk pax/path rit/rite} :: change permissions - $>(%sunk vane-task) :: report death $>(%vega vane-task) :: report upgrade {$warp wer/ship rif/riff} :: internal file req {$werp who/ship wer/ship rif/riff} :: external file req @@ -795,7 +790,6 @@ $>(%init vane-task) :: after gall ready {$lyra p/@t q/@t} :: upgrade kernel {$noop ~} :: no operation - $>(%sunk vane-task) :: report death {$talk p/tank} :: {$text p/tape} :: {$veer p/@ta q/path r/@t} :: install vane @@ -1182,9 +1176,6 @@ :: %kill: stop a build; send on same duct as original %build request :: [%kill ~] - :: %sunk: receive a report that a foreign ship has lost continuity - :: - $>(%sunk vane-task) :: %vega: report kernel upgrade :: $>(%vega vane-task) @@ -1879,7 +1870,6 @@ $% {$conf p/dock q/culm} :: configure app $>(%init vane-task) :: set owner {$deal p/sock q/cush} :: full transmission - $>(%sunk vane-task) :: report death $>(%vega vane-task) :: report upgrade $>(%west vane-task) :: network request $>(%wegh vane-task) :: report memory From 0286d03edbd5cf855a31c78cf9fd20b4e5e7f401 Mon Sep 17 00:00:00 2001 From: Fang Date: Sat, 27 Jul 2019 15:00:28 +0200 Subject: [PATCH 021/124] Refactor code duplication in Chat root --- pkg/interface/chat/src/js/components/root.js | 94 +++++--------------- 1 file changed, 23 insertions(+), 71 deletions(-) diff --git a/pkg/interface/chat/src/js/components/root.js b/pkg/interface/chat/src/js/components/root.js index 739909db10..360357345c 100644 --- a/pkg/interface/chat/src/js/components/root.js +++ b/pkg/interface/chat/src/js/components/root.js @@ -61,7 +61,7 @@ export class Root extends Component { let internalStation = host + '/hall-internal-' + circle; if (internalStation in state.configs) { - unreads[cir] = + unreads[cir] = state.configs[internalStation].red <= messages[cir][messages[cir].length - 1].num; } else { @@ -87,6 +87,18 @@ export class Root extends Component { inviteConfig = configs[`~${window.ship}/i`]; } + const renderChannelsSidebar = (props) => ( + + ); + return (
@@ -94,17 +106,7 @@ export class Root extends Component { render={ (props) => { return ( - }> + sidebar={renderChannelsSidebar(props)}>
@@ -119,18 +121,8 @@ export class Root extends Component { return ( - }> - + { return ( - }> + sidebar={renderDefaultSidebar(props)}> { - let station = + let station = props.match.params.ship + "/" + props.match.params.station; let messages = state.messages[station] || []; return ( - }> + sidebar={renderChannelsSidebar(props) }> { return ( - }> + sidebar={renderChannelsSidebar(props) }> @@ -221,18 +183,8 @@ export class Root extends Component { return ( - }> - + Date: Sat, 27 Jul 2019 16:11:15 +0200 Subject: [PATCH 022/124] Refactor message.js to fully support %lin and %url Renders messages based on their speech type, as opposed to interpreting %lin speeches and ignoring all others. Italicizes %lin "@" messages. Makes images clickable to open in new window. --- pkg/interface/chat/src/css/custom.css | 4 + .../chat/src/js/components/lib/message.js | 97 ++++++++++++------- 2 files changed, 67 insertions(+), 34 deletions(-) diff --git a/pkg/interface/chat/src/css/custom.css b/pkg/interface/chat/src/css/custom.css index 46ec6d39f6..074215e2e3 100644 --- a/pkg/interface/chat/src/css/custom.css +++ b/pkg/interface/chat/src/css/custom.css @@ -87,6 +87,10 @@ h2 { font-weight: bold; } +.fs-italic { + font-style: italic; +} + .bg-v-light-gray { background-color: #f9f9f9; } diff --git a/pkg/interface/chat/src/js/components/lib/message.js b/pkg/interface/chat/src/js/components/lib/message.js index 50d34c189c..49212c465c 100644 --- a/pkg/interface/chat/src/js/components/lib/message.js +++ b/pkg/interface/chat/src/js/components/lib/message.js @@ -5,56 +5,85 @@ import moment from 'moment'; import _ from 'lodash'; export class Message extends Component { - - renderMessage(content) { + + renderSpeech(speech) { + if (_.has(speech, 'lin')) { + return this.renderLin(speech.lin.msg, speech.lin.pat); + } else if (_.has(speech, 'url')) { + return this.renderUrl(speech.url); + } else { + return this.renderUnknown(); + } + } + + renderUnknown() { + return this.renderLin('') + } + + renderLin(content, action = false) { return ( -

+

{content}

); } - renderContent() { - const { props } = this; - - let content = _.get( - props.msg, - 'sep.lin.msg', - '' - ); - + renderUrl(url) { try { - let url = new URL(content); - let imgMatch = + let urlObject = new URL(url); + let imgMatch = /(jpg|img|png|gif|tiff|jpeg|JPG|IMG|PNG|TIFF|GIF|webp|WEBP|webm|WEBM)$/ .exec( - url.pathname + urlObject.pathname ); if (imgMatch) { - return ( - - ) + return this.renderImageUrl(url); } else { - let url = this.urlTransmogrifier(content); - - return ( - {url} - ) + let localUrl = this.localizeUrl(url); + return this.renderAnchor(localUrl, url); } } catch(e) { - return this.renderMessage(content); + console.error('url render error', e); + return this.renderAnchor(url); } } - urlTransmogrifier(url) { + renderImageUrl(url) { + return this.renderAnchor(url, ( + + )); + } + + renderAnchor(href, content) { + content = content || href; + return ( + {content} + ); + } + + renderContent() { + const { props } = this; + + try { + if (!_.has(props.msg, 'sep')) { + return this.renderUnknown(); + } + return this.renderSpeech(props.msg.sep); + } catch (e) { + console.error('speech rendering error', e); + return this.renderUnknown(); + } + } + + localizeUrl(url) { if (typeof url !== 'string') { throw 'Only transmogrify strings!'; } const ship = window.ship; if (url.indexOf('arvo://') === 0) { @@ -68,7 +97,7 @@ export class Message extends Component { let pending = !!props.msg.pending ? ' o-80' : ''; let timestamp = moment.unix(props.msg.wen / 1000).format('hh:mm'); let datestamp = moment.unix(props.msg.wen / 1000).format('LL'); - + return (
Date: Sat, 27 Jul 2019 18:28:04 +0200 Subject: [PATCH 023/124] Refactor chat-input to fully support %lin and %url Supports sending both regular and action %lin messages, using the optional @ prefix. Now transforms on-urbit URLs into arvo:// URLs prior to sending, as opposed to on-render. Unfortunately, the type hall uses for URLs doesn't support non-HTTP protocols yet, so we send arvo:// URLs as %lin messages for now. Input field gets styled based on detected message type. Italics for action lins, underline for URLs. --- pkg/interface/chat/src/css/custom.css | 4 + .../chat/src/js/components/lib/chat-input.js | 105 ++++++++++++++++-- .../chat/src/js/components/lib/message.js | 21 +++- 3 files changed, 115 insertions(+), 15 deletions(-) diff --git a/pkg/interface/chat/src/css/custom.css b/pkg/interface/chat/src/css/custom.css index 074215e2e3..5b949ec8f0 100644 --- a/pkg/interface/chat/src/css/custom.css +++ b/pkg/interface/chat/src/css/custom.css @@ -91,6 +91,10 @@ h2 { font-style: italic; } +.td-underline { + text-decoration: underline; +} + .bg-v-light-gray { background-color: #f9f9f9; } diff --git a/pkg/interface/chat/src/js/components/lib/chat-input.js b/pkg/interface/chat/src/js/components/lib/chat-input.js index 3632905982..1416562b96 100644 --- a/pkg/interface/chat/src/js/components/lib/chat-input.js +++ b/pkg/interface/chat/src/js/components/lib/chat-input.js @@ -54,7 +54,8 @@ export class ChatInput extends Component { setTimeout(closure, 2000);*/ this.state = { - message: "" + message: '', + messageType: 'lin' }; this.textareaRef = React.createRef(); @@ -100,22 +101,105 @@ export class ChatInput extends Component { } messageChange(event) { - this.setState({message: event.target.value}); + this.setState({ + message: event.target.value, + messageType: this.getSpeechType(event.target.value) + }); + } + + getSpeechType(input) { + if (input[0] === '@') { + return 'lin@' + } else if (this.isUrl(input)) { + return 'url'; + } else { + return 'lin'; + } + } + + getSpeechStyle(type) { + switch (type) { + case 'lin@': + return 'fs-italic'; + case 'url': + return 'td-underline'; + default: + return ''; + } + } + + isUrl(string) { + try { + const urlObject = new URL(string); + //NOTE we check for a host to ensure a url is actually being posted + // to combat false positives for things like "marzod: ur cool". + // this does mean you can't send "mailto:e@ma.il" as %url message, + // but the desirability of that seems questionable anyway. + return (urlObject.host !== ''); + } catch (e) { + return false; + } + } + + // turns select urls into arvo:// urls + // + // we detect app names from the url. if the app is known to handle requests + // for remote data (instead of serving only from the host) we transfor the + // url into a generic arvo:// one. + // the app name format is pretty distinct and rare to find in the non-urbit + // wild, but this could still result in false positives for older-school + // websites serving pages under /~user paths. + // we could match only on ship.arvo.network, but that would exclude those + // running on localhost or under a custom domain. + // + // + globalizeUrl(url) { + const urlObject = new URL(url); + const app = urlObject.pathname.split('/')[1]; + if (app === '~chat' || + app === '~publish') { + //TODO send proper url speeches once hall starts using a url type that + // supports non-http protocols. + return { lin: { + msg: 'arvo://' + url.slice(urlObject.origin.length+1), + pat: false + } }; + } else { + return {url}; + } + } + + speechFromInput(content, type = 'lin') { + switch (type) { + case 'lin': + return { lin: { + msg: content, + pat: false + } }; + // + case 'lin@': + return { lin: { + msg: content.slice(1), + pat: true + } }; + // + case 'url': + return this.globalizeUrl(content); + // + default: + throw new Error('Unimplemented speech type', type); + } } messageSubmit() { const { props, state } = this; + let message = { uid: uuid(), aut: window.ship, wen: Date.now(), aud: [props.station], - sep: { - lin: { - msg: state.message, - pat: false - } - } + sep: this.speechFromInput(state.message, state.messageType) }; props.api.hall( @@ -125,7 +209,8 @@ export class ChatInput extends Component { ); this.setState({ - message: "" + message: '', + messageType: 'lin' }); } @@ -160,7 +245,7 @@ export class ChatInput extends Component {
- {content} @@ -83,13 +87,20 @@ export class Message extends Component { } } + //NOTE see also lib/chat-input's globalizeUrl localizeUrl(url) { - if (typeof url !== 'string') { throw 'Only transmogrify strings!'; } - const ship = window.ship; - if (url.indexOf('arvo://') === 0) { - return `http://${ship}.arvo.network` + url.split('arvo://')[1]; + if (typeof url !== 'string') { throw 'Only localize strings!'; } + const arvo = 'arvo://'; + if (url.indexOf(arvo) === 0) { + // this application is being served by an urbit also, so /path will + // point to the arvo url as hosted by this same urbit. + let path = url.slice(arvo.length); + // ensure single leading / + if (path[0] !== '/') path = '/' + path; + return path; + } else { + return url; } - return url; } render() { From f78d755a0d82afcc1d2858dab2f76c0fdb7abd1c Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Fri, 26 Jul 2019 23:36:59 -0700 Subject: [PATCH 024/124] %breach-sync works with kale --- bin/solid.pill | 4 ++-- pkg/arvo/app/azimuth-tracker.hoon | 17 ++++++++--------- pkg/arvo/app/ph.hoon | 14 ++++++++++++-- pkg/arvo/lib/ph/azimuth.hoon | 12 +++++++----- pkg/arvo/lib/pill.hoon | 1 - pkg/arvo/sys/vane/ames.hoon | 13 ++++++++----- pkg/arvo/sys/vane/clay.hoon | 20 ++++++++++++++------ pkg/arvo/sys/vane/kale.hoon | 1 + 8 files changed, 52 insertions(+), 30 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index 1a0fc416d7..5a14bcb600 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a4a8e1daf0bfe86d5fc4ef7060b0c6a6c2678a344787926f14bb4b8cfabe8752 -size 9549390 +oid sha256:276e7ae464a476ade3f1c99bbfd6fa24cb104d361d447d2dbc6d7e42a9792fc2 +size 9474521 diff --git a/pkg/arvo/app/azimuth-tracker.hoon b/pkg/arvo/app/azimuth-tracker.hoon index 37aea63ebc..4689957f74 100644 --- a/pkg/arvo/app/azimuth-tracker.hoon +++ b/pkg/arvo/app/azimuth-tracker.hoon @@ -318,12 +318,8 @@ |= state=app-state =/ m (async:stdio ,app-state) ^- form:m - ~& [%get-updatessss number.state] - ;< =latest=block bind:m (get-latest-block url.state) - ~& [%latest-block number.state] - ;< =new=number:block bind:m (zoom state number.id.latest-block) - ~& [%zoomed-to number.state] - =. number.state new-number + ;< =latest=block bind:m (get-latest-block url.state) + ;< state=app-state bind:m (zoom state number.id.latest-block) |- ^- form:m =* walk-loop $ ~& [%walk-loop number.state] @@ -404,16 +400,18 @@ :: ++ zoom |= [state=app-state =latest=number:block] - =/ m (async:stdio ,number:block) + =/ m (async:stdio ,app-state) ^- form:m =/ zoom-margin=number:block 3 ?: (lth latest-number (add number.state zoom-margin)) - (pure:m number.state) + (pure:m state) =/ to-number=number:block (sub latest-number zoom-margin) ;< =udiffs:point bind:m (get-logs-by-range url.state whos.state number.state to-number) ;< ~ bind:m (jael-update udiffs) - (pure:m to-number) + =. number.state +(to-number) + =. blocks.state ~ + (pure:m state) -- :: :: Main @@ -425,6 +423,7 @@ |= =in-poke-data =/ m tapp-async ^- form:m + ~& [%azimuth-tracker our.bowl number.state in-poke-data] ?- +<.in-poke-data %init (init state) %listen (listen state +>.in-poke-data) diff --git a/pkg/arvo/app/ph.hoon b/pkg/arvo/app/ph.hoon index 8c286f21a4..79d1bac354 100644 --- a/pkg/arvo/app/ph.hoon +++ b/pkg/arvo/app/ph.hoon @@ -178,30 +178,40 @@ :+ %breach-sync ~[~bud ~marbud] =. eth-node (spawn:eth-node ~marbud) + =. eth-node (spawn:eth-node ~fipfes) ;< [eth-node=_eth-node ~] bind:m %+ (wrap-philter ,_eth-node ,~) router:eth-node ;< ~ bind:m (raw-ship ~bud `(dawn:eth-node ~bud)) + ~& > 'BUD DONE' ;< ~ bind:m (raw-ship ~marbud `(dawn:eth-node ~marbud)) + ~& > 'MARBUD DONE' ;< file=@t bind:m (touch-file ~bud %base) - ~& %checking-file-touched + ~& > 'TOUCH FILE DONE' (check-file-touched ~marbud %home file) - ~& %checked-file-touched + ~& > 'TOUCH FILE CHECK DONE' ;< eth-node=_eth-node bind:m (breach-and-hear:eth-node our.hid ~bud ~marbud) + ~& > 'BREACH DONE' ;< [eth-node=_eth-node ~] bind:m %+ (wrap-philter ,_eth-node ,~) router:eth-node ;< ~ bind:m (raw-ship ~bud `(dawn:eth-node ~bud)) + ~& > 'BUD RE DONE' ;< ~ bind:m (just-events (dojo ~bud "|merge %base ~marbud %kids, =gem %this")) + ~& > 'THIS MERGE STARTED DONE' ;< file=@t bind:m (touch-file ~bud %base) + ~& > 'TOUCH-1 DONE' ;< file=@t bind:m (touch-file ~bud %base) + ~& > 'TOUCH-2 DONE' (check-file-touched ~marbud %home file) + ~& > 'DONE DONE' (pure:m ~) :: :+ %breach-multiple ~[~bud ~marbud] =. eth-node (spawn:eth-node ~marbud) + =. eth-node (spawn:eth-node ~fipfes) ;< [eth-node=_eth-node ~] bind:m %+ (wrap-philter ,_eth-node ,~) router:eth-node diff --git a/pkg/arvo/lib/ph/azimuth.hoon b/pkg/arvo/lib/ph/azimuth.hoon index c3ad8e1f40..0b5f410d0e 100644 --- a/pkg/arvo/lib/ph/azimuth.hoon +++ b/pkg/arvo/lib/ph/azimuth.hoon @@ -48,6 +48,7 @@ %+ answer-request req :- %o =/ number (hex-to-num:ethereum (get-block-hash req)) + ~& who=who.pin ~& number=number =/ hash (number-to-hash number) ~& hash=hash @@ -107,7 +108,7 @@ [& ~ %wait ~] :: ++ latest-block - (add launch:contracts:azimuth (lent logs)) + (add launch:contracts:azimuth (dec (lent logs))) :: ++ get-id |= req=@t @@ -200,10 +201,11 @@ ?: (lth to-block launch:contracts:azimuth) ~ %+ swag + ~& [%logs-by-range from-block to-block launch:contracts:azimuth] ?: (lth from-block launch:contracts:azimuth) - [0 (sub to-block launch:contracts:azimuth)] + [0 +((sub to-block launch:contracts:azimuth))] :- (sub from-block launch:contracts:azimuth) - (sub to-block from-block) + +((sub to-block from-block)) logs :: ++ logs-by-hash @@ -230,7 +232,7 @@ (crip (prefix-hex:ethereum (render-hex-bytes:ethereum 32 hash))) :: :+ 'blockNumber' %s - (crip (num-to-hex:ethereum count)) + (crip (num-to-hex:ethereum (add launch:contracts:azimuth count))) :: :+ 'address' %s (crip (address-to-hex:ethereum azimuth:contracts:azimuth)) @@ -347,7 +349,7 @@ ++ breach-and-hear |= [our=@p who=@p her=@p] =. this-az (breach who) - =. this-az (spawn ~fes) + =. this-az ?:((~(has by lives) ~fes) (cycle-keys ~fes) (spawn ~fes)) =/ new-rut rut:(~(got by lives) who) =/ m (ph ,_this-az) ;< [this-az=_this-az ~] bind:m diff --git a/pkg/arvo/lib/pill.hoon b/pkg/arvo/lib/pill.hoon index b3289cda36..362d96906b 100644 --- a/pkg/arvo/lib/pill.hoon +++ b/pkg/arvo/lib/pill.hoon @@ -40,7 +40,6 @@ [%i /vane/iris] :: sys/vane/jael: security :: - [%j /vane/jael] [%k /vane/kale] == |= [=term =path] diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index e7beff2bcd..17931bbcec 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -1471,22 +1471,25 @@ =/ her=ship (slav %p i.t.tea) =/ gus (~(us go ton.fox) our) =/ diz (myx:gus her) - =/ ded=deed + =/ ded=(unit deed) ?: ?=(%full -.public-keys-result.sih) ~| [her=her public-keys-result=public-keys-result.sih] =/ a-point=(unit point:able:kale) (~(get by points.public-keys-result.sih) her) ?~ a-point ~& [%no-keys her] - [*life *pass ~] + ~ =/ a-pass=pass pass:(~(got by keys.u.a-point) life.u.a-point) - [life.u.a-point a-pass oath=~] + `[life.u.a-point a-pass oath=~] ?> ?=(%keys -.diff.public-keys-result.sih) ?> =(her who.public-keys-result.sih) =/ a-key-update=key-update:point:able:kale to.diff.public-keys-result.sih - [life.a-key-update pass.a-key-update oath=~] - =. lew.wod.dur.diz `ded + `[life.a-key-update pass.a-key-update oath=~] + ?~ ded + [~ +>.$] + ~& [%installing-deed her u.ded] + =. lew.wod.dur.diz `u.ded =. ton.fox (~(su go ton.fox) (nux:gus diz)) [~ +>.$] :: diff --git a/pkg/arvo/sys/vane/clay.hoon b/pkg/arvo/sys/vane/clay.hoon index 006df86e04..f932cbf693 100644 --- a/pkg/arvo/sys/vane/clay.hoon +++ b/pkg/arvo/sys/vane/clay.hoon @@ -497,6 +497,9 @@ %wipe :: == :: task:able:ford :: + == :: + $: %k :: by %kale + $>(%public-keys task:able:kale) :: == == :: ++ riot (unit rant) :: response+complete ++ sign :: in result $<- @@ -2634,22 +2637,25 @@ :: =* ruf |4.+6.^$ :: - =+ ^- [hun=(unit duct) rede] + =+ ^- [mow=(list move) hun=(unit duct) rede] ?. =(our her) :: no duct, foreign +rede or default :: - :- ~ + + :+ ?: (~(has by hoy.ruf) her) + ~ + [hun.rom.ruf %pass /sinks %k %public-keys (silt her ~)]~ + ~ =/ rus rus:(~(gut by hoy.ruf) her *rung) %+ ~(gut by rus) syd [lim=~2000.1.1 ref=`*rind qyx=~ dom=*dome per=~ pew=~] :: administrative duct, domestic +rede :: - :- `hun.rom.ruf + :+ ~ `hun.rom.ruf =/ jod (~(gut by dos.rom.ruf) syd *dojo) [lim=now ref=~ [qyx dom per pew]:jod] :: - =* red=rede -> - =| mow/(list move) + =* red=rede ->+ |% ++ abet :: resolve ^- [(list move) raft] @@ -4464,8 +4470,10 @@ ?: ?=([%sinks ~] tea) ?> ?=(%public-keys +<.q.hin) ~& 'XXX' + ~& our=our ?: ?=(%full -.public-keys-result.q.hin) - !! + ~& %clay-sinks-full + [~ ..^$] ?. ?=(%rift -.diff.public-keys-result.q.hin) [~ ..^$] ~& rift=public-keys-result.q.hin diff --git a/pkg/arvo/sys/vane/kale.hoon b/pkg/arvo/sys/vane/kale.hoon index 2a98be6018..e5d72c2ab5 100644 --- a/pkg/arvo/sys/vane/kale.hoon +++ b/pkg/arvo/sys/vane/kale.hoon @@ -478,6 +478,7 @@ %public-keys-result =. moz [[hen %give %mack ~] moz] %- curd =< abet + ~& [%kale-new-from-kale public-keys-result.mes] (public-keys:~(feel su hen our pki etn sap) public-keys-result.mes) == :: From efd37a1e3c8b28846fddba9c6f4d2dd68b3f2b54 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Sat, 27 Jul 2019 21:01:55 -0700 Subject: [PATCH 025/124] simplify kale/azimuth-tracker subscription semantics --- pkg/arvo/app/azimuth-tracker.hoon | 60 +++++------- pkg/arvo/sys/vane/dill.hoon | 12 --- pkg/arvo/sys/vane/gall.hoon | 2 - pkg/arvo/sys/vane/kale.hoon | 146 +++++++++++++++++++++--------- pkg/arvo/sys/zuse.hoon | 100 +++++++++----------- 5 files changed, 168 insertions(+), 152 deletions(-) diff --git a/pkg/arvo/app/azimuth-tracker.hoon b/pkg/arvo/app/azimuth-tracker.hoon index 4689957f74..abb05dbc2b 100644 --- a/pkg/arvo/app/azimuth-tracker.hoon +++ b/pkg/arvo/app/azimuth-tracker.hoon @@ -2,10 +2,6 @@ =, able:kale => |% +$ pending-udiffs (map number:block udiffs:point) - +$ config - $: url=@ta - from-number=number:block - == +$ app-state $: %2 url=@ta @@ -17,14 +13,14 @@ +$ peek-data ~ +$ in-poke-data $: %azimuth-tracker-poke - $% [%init ~] - [%listen whos=(list ship) =source:kale] - [%watch =config] + $% [%listen whos=(list ship) =source:kale] + [%watch url=@ta] == == +$ out-poke-data ~ +$ in-peer-data ~ - +$ out-peer-data ~ + +$ out-peer-data + [%azimuth-udiff =ship =udiff:point] ++ tapp %: ^tapp app-state @@ -260,7 +256,9 @@ ?~ udiffs (pure:m ~) ~& [%sending-event i.udiffs] - ;< ~ bind:m (send-effect:stdio %new-event /ne i.udiffs) + =/ =path /(scot %p ship.i.udiffs) + ;< ~ bind:m (give-result:stdio / %azimuth-udiff i.udiffs) + ;< ~ bind:m (give-result:stdio path %azimuth-udiff i.udiffs) loop(udiffs t.udiffs) -- :: @@ -268,15 +266,6 @@ :: => |% :: - :: Subscribe to %sources from kale - :: - ++ init - |= state=app-state - =/ m (async:stdio ,app-state) - ^- form:m - ;< ~ bind:m (send-effect:stdio %sources /se ~) - (pure:m state) - :: :: Send %listen to kale :: ++ listen @@ -286,27 +275,13 @@ ;< ~ bind:m (send-effect:stdio %listen /lo (silt whos) source) (pure:m state) :: - :: Take %source from kale - :: - ++ take-source - |= [state=app-state whos=(set ship) =source:kale] - =/ m (async:stdio ,app-state) - ^- form:m - ?: ?=(%& -.source) - (pure:m state) - =/ a-purl=purl:eyre node.p.source - =. url.state (crip (en-purl:html a-purl)) - =. whos.state whos - (watch state url.state 0) :: launch:contracts:azimuth) - :: :: Start watching a node :: - ++ watch - |= [state=app-state =config] + ++ start + |= state=app-state =/ m (async:stdio ,app-state) ^- form:m - =: url.state url.config - number.state from-number.config + =: number.state 0 pending-udiffs.state *pending-udiffs blocks.state *(list block) == @@ -425,9 +400,8 @@ ^- form:m ~& [%azimuth-tracker our.bowl number.state in-poke-data] ?- +<.in-poke-data - %init (init state) %listen (listen state +>.in-poke-data) - %watch (watch state +>.in-poke-data) + %watch (pure:m state(url url.in-poke-data)) == :: ++ handle-take @@ -435,9 +409,17 @@ =/ m tapp-async ^- form:m ?+ -.sign ~|([%strange-sign -.sign] !!) - %source (take-source state +.sign) %wake (get-updates state) == :: -++ handle-peer ~(handle-peer default-tapp bowl state) +++ handle-peer + |= =path + =/ m tapp-async + ^- form:m + =/ who=(unit ship) ?~(path ~ `(slav %p i.path)) + =. whos.state + ?~ who + ~ + (~(put in whos.state) u.who) + (start state) -- diff --git a/pkg/arvo/sys/vane/dill.hoon b/pkg/arvo/sys/vane/dill.hoon index 26a23708fa..009f535a02 100644 --- a/pkg/arvo/sys/vane/dill.hoon +++ b/pkg/arvo/sys/vane/dill.hoon @@ -301,18 +301,6 @@ =. moz :_ moz [hen %pass /merg/home %c %merg %home our %base da+now %init] - =. moz - :_ moz - :* hen - %pass - ~ - %g - %deal - [our our] - %azimuth-tracker - %poke - [%azimuth-tracker-poke -:!>([%init ~]) [%init ~]] - == . :: ++ mere :: continue init diff --git a/pkg/arvo/sys/vane/gall.hoon b/pkg/arvo/sys/vane/gall.hoon index f23088c292..eb8744051f 100644 --- a/pkg/arvo/sys/vane/gall.hoon +++ b/pkg/arvo/sys/vane/gall.hoon @@ -1338,13 +1338,11 @@ %merg `%c %mint `%j %mont `%c - %new-event `%k %nuke `%a %ogre `%c %perm `%c %rest `%b %snap `%j - %sources `%k %wait `%b %want `%a %warp `%c diff --git a/pkg/arvo/sys/vane/kale.hoon b/pkg/arvo/sys/vane/kale.hoon index e5d72c2ab5..489d5b0fed 100644 --- a/pkg/arvo/sys/vane/kale.hoon +++ b/pkg/arvo/sys/vane/kale.hoon @@ -37,7 +37,7 @@ => |% +$ state :: all vane state $: ver=$0 :: vane version - pki=state-pki :: + pki=state-pki :: etn=state-eth-node :: eth connection state sap=state-snapshots :: state snapshots == :: @@ -82,6 +82,9 @@ $% $: %a :: to %ames $>(%want task:able:ames) :: send message == :: + $: %g :: to self + $>(%deal task:able:gall) :: set ethereum source + == :: $: %k :: to self $>(%listen task) :: set ethereum source == :: @@ -89,9 +92,17 @@ $% $>(%init vane-task) :: report install == == == :: :: :: ++$ peer-sign [=ship =udiff:point] :: +:: :: +$ sign :: in result $<- $~ [%a %woot *ship ~] :: $% [%a $>(%woot gift:able:ames)] :: message result + $: %g :: + $> $? %onto :: + %unto :: + == :: + gift:able:gall :: + == == :: -- :: :: :::: @@ -172,6 +183,25 @@ ++ abet :: resolve [(flop moz) lex] :: :: ++sein:of + ++ emit + |= =move + +>.$(moz [move moz]) + :: + ++ poke-watch + |= [hen=duct app=term =purl:eyre] + %- emit + :* hen + %pass + /[app]/poke + %g + %deal + [our our] + app + %poke + %azimuth-tracker-poke + !>([%watch (crip (en-purl:html purl))]) + == + :: ++ sein :: sponsor |= who=ship ^- ship @@ -219,7 +249,7 @@ =. boq.own.pki bloq.tac :: save our ethereum gateway (required for galaxies) :: - =. nod.own.pki + =. nod.own.pki %+ fall node.tac (need (de-purl:html 'http://eth-mainnet.urbit.org:8545')) :: save our parent signature (only for moons) @@ -264,14 +294,22 @@ [%diff ship diff]:i.diffs $(diffs t.diffs) :: + :: start subscriptions :: + =. +>.$ (poke-watch hen %azimuth-tracker nod.own.pki) =. +>.$ %- curd =< abet %+ sources:~(feel su hen our pki etn sap) ?: =(%czar (clan:title our)) ~ (silt spon.tac ~) - [%| nod.own.pki *@ud *@da] + [%| %azimuth-tracker] + :: + =? +>.$ !=(%czar (clan:title our)) + %- curd =< abet + %+ sources:~(feel su hen our pki etn sap) + ~ + [%& spon.tac] :: =. moz %+ weld moz @@ -372,7 +410,6 @@ +>.$ %_ +>.$ yen.own.pki (~(del in yen.own.pki) hen) - yen.etn (~(del in yen.etn) hen) == :: :: watch public keys @@ -395,13 +432,6 @@ %snap (restore-snap hen snap.tac kick.tac) :: - :: sources subscription - :: [%sources ~] - :: - %sources - ~& [%kale-sources] - (curd abet:~(sources ~(feed su hen our pki etn sap) hen)) - :: :: XX should be a subscription :: XX reconcile with .dns.eth :: request domains @@ -415,14 +445,6 @@ ?< =(fak.own.pki ?=(^ tuf.own.pki)) +>.$(moz [[hen %give %turf tuf.own.pki] moz]) :: - :: Update from app - :: [%new-event =ship =udiff:point] - :: - %new-event - ~& [%kale-new-event ship udiff]:tac - %- curd =< abet - (~(new-event su hen our pki etn sap) ship.tac udiff.tac) - :: :: learn of kernel upgrade :: [%vega ~] :: @@ -492,8 +514,6 @@ ++ take |= [tea=wire hen=duct hin=sign] ^+ +> - ?> ?=([@ *] tea) - =* wir t.tea ?- hin [%a %woot *] ?~ q.hin +>.$ @@ -502,6 +522,36 @@ ~_ q.u.u.q.hin ::TODO fail:et +>.$ + :: + [%g %onto *] + ~& [%kale-onto tea hin] + +>.$ + :: + [%g %unto *] + ?- +>-.hin + $quit ~|([%kale-unexpected-quit tea hin] !!) + $http-response ~|([%kale-unexpected-http-response tea hin] !!) + $coup + ?~ p.p.+>.hin + +>.$ + %- (slog leaf+"kale-bad-coup" u.p.p.+>.hin) + +>.$ + :: + $reap + ?~ p.p.+>.hin + +>.$ + %- (slog u.p.p.+>.hin) + ~|([%kale-unexpected-reap tea hin] +>.$) + :: + $diff + ?> ?=([@ *] tea) + =* app i.tea + =/ =peer-sign ;;(peer-sign q.q.p.p.+>.hin) + %. [hen tea app] + =< pump + %- curd =< abet + (~(new-event su hen our pki etn sap) peer-sign) + == == :: :: ++curd:of ++ curd :: relative moves @@ -512,6 +562,10 @@ == +>(pki pki, etn etn, sap sap, moz (weld (flop moz) ^moz)) :: :: ++wind:of + ++ pump + |= [hen=duct =wire app=term] + (emit [hen %pass wire %g %deal [our our] app %pump ~]) + :: ++ wind :: rewind to snap |= [hen=duct block=@ud] ^+ +> @@ -575,6 +629,30 @@ ?~ noy this-su $(noy t.noy, moz [[i.noy cad] moz]) :: + ++ emit-peer + |= [app=term =path] + %- emit + :* hen + %pass + [app path] + %g + %deal + [our our] + app + %peer + path + == + :: + ++ peer + |= [app=term whos=(set ship)] + ?: =(~ whos) + (emit-peer app /) + =/ whol=(list ship) ~(tap in whos) + |- ^+ this-su + ?~ whol this-su + =. this-su (emit-peer app /(scot %p i.whol)) + $(whol t.whol) + :: ++ public-keys-give |= [yen=(set duct) =public-keys-result] =+ yez=~(tap in yen) @@ -673,20 +751,6 @@ yen.own (~(put in yen.own) hen) == :: - ++ sources - %_ ..feed - yen.etn (~(put in yen.etn) hen) - moz - %- welp :_ moz - ~& [%kale-sources-feed etn=etn] - %+ turn - ^- (list (pair source-id (set ship))) - :- [default-source.etn ~] - ~(tap by ship-sources-reverse.etn) - |= [=source-id whos=(set ship)] - [hen %give %source whos (~(got by sources.etn) source-id)] - == - :: :: ++fake:feed:su ++ fake :: fake subs and state ?> fak.own.pki |% @@ -736,12 +800,8 @@ =/ =point (fall maybe-point *point) =. point ?- -.a-diff - %spon - point(sponsor to.a-diff) - :: - %rift - point(rift to.a-diff) - :: + %spon point(sponsor to.a-diff) + %rift point(rift to.a-diff) %keys %_ point life life.to.a-diff @@ -774,8 +834,6 @@ =/ send-message |= =message [hen %pass /public-keys %a %want p.source /k/public-keys message] - =. ..feel - (emit (send-message %nuke whos)) (emit (send-message %public-keys whos)) =^ =source-id this-su (get-source-id source) =. ..feed @@ -791,7 +849,7 @@ %- ~(gas ju ship-sources-reverse.etn) (turn whol |=(=ship [source-id ship])) ..feed - (exec yen.etn [%give %source whos source]) + (peer p.source whos) -- :: :: ++meet:su ++ meet :: seen after breach diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index bf2ae38d79..285d78ff8d 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -2285,7 +2285,50 @@ ++ able ^? =, pki |% + +$ public-keys-result + $% [%full points=(map ship point)] + [%diff who=ship =diff:point] + == + :: :: + ++ gift :: out result <-$ + $% [%init p=ship] :: report install unix + [%mass p=mass] :: memory usage report + [%mack p=(unit tang)] :: message n/ack + [%turf turf=(list turf)] :: domains + [%private-keys =life vein=(map life ring)] :: private keys + [%public-keys =public-keys-result] :: ethereum changes + == :: + :: +seed: private boot parameters + :: + +$ seed [who=ship lyf=life key=ring sig=(unit oath:pki)] + :: + += task :: in request ->$ + $~ [%vega ~] :: + $% $: %dawn :: boot from keys + =seed:able:kale :: identity params + spon=ship :: sponsor + czar=(map ship [=life =pass]) :: galaxy table + turf=(list turf) :: domains + bloq=@ud :: block number + node=(unit purl:eyre) :: gateway url + snap=(unit snapshot) :: head start + == :: + [%fake =ship] :: fake boot + [%listen whos=(set ship) =source] :: set ethereum source + ::TODO %next for generating/putting new private key + [%nuke whos=(set ship)] :: cancel tracker from + [%private-keys ~] :: sub to privates + [%public-keys ships=(set ship)] :: sub to publics + [%meet =ship =life =pass] :: met after breach + [%snap snap=snapshot kick=?] :: load snapshot + [%turf ~] :: view domains + $>(%vega vane-task) :: report upgrade + $>(%wegh vane-task) :: memory usage request + $>(%west vane-task) :: remote request + [%wind p=@ud] :: rewind before block + == :: :: %kale has two general kinds of task: changes + :: :: and change subscriptions. :: :: change tasks are designed to match high-level @@ -2421,71 +2464,18 @@ a-point(sponsor to.diff) == -- - :: - +$ public-keys-result - $% [%full points=(map ship point)] - [%diff who=ship =diff:point] - == - :: :: - ++ gift :: out result <-$ - $% [%init p=ship] :: report install unix - [%mass p=mass] :: memory usage report - [%mack p=(unit tang)] :: message n/ack - [%source whos=(set ship) src=source] :: - [%turf turf=(list turf)] :: domains - [%private-keys =life vein=(map life ring)] :: private keys - [%public-keys =public-keys-result] :: ethereum changes - == :: - :: +seed: private boot parameters - :: - +$ seed [who=ship lyf=life key=ring sig=(unit oath:pki)] - :: - += task :: in request ->$ - $~ [%vega ~] :: - $% $: %dawn :: boot from keys - =seed:able:kale :: identity params - spon=ship :: sponsor - czar=(map ship [=life =pass]) :: galaxy table - turf=(list turf) :: domains - bloq=@ud :: block number - node=(unit purl:eyre) :: gateway url - snap=(unit snapshot) :: head start - == :: - [%fake =ship] :: fake boot - [%listen whos=(set ship) =source] :: set ethereum source - ::TODO %next for generating/putting new private key - [%nuke whos=(set ship)] :: cancel tracker from - [%private-keys ~] :: sub to privates - [%public-keys ships=(set ship)] :: sub to publics - [%sources ~] - [%meet =ship =life =pass] :: met after breach - [%snap snap=snapshot kick=?] :: load snapshot - [%turf ~] :: view domains - [%new-event =ship =udiff:point] :: update from app - $>(%vega vane-task) :: report upgrade - $>(%wegh vane-task) :: memory usage request - $>(%west vane-task) :: remote request - [%wind p=@ud] :: rewind before block - == :: -- :: :: :: :::: :: :: :: - +$ node-src :: ethereum node comms - $: node=purl:eyre :: node url - filter-id=@ud :: current filter - poll-timer=@da :: next filter poll - == :: - :: - +$ source (each ship node-src) + +$ source (each ship term) +$ source-id @udsourceid +$ snapshot ~ :: :: +state-eth-node: state of a connection to an ethereum node :: +$ state-eth-node :: node config + meta - $: yen=(set duct) - top-source-id=source-id + $: top-source-id=source-id sources=(map source-id source) sources-reverse=(map source source-id) default-source=source-id From c91ad893c05daa634d4a5123b8f21ac1cbff650d Mon Sep 17 00:00:00 2001 From: Fang Date: Sun, 28 Jul 2019 13:06:08 +0200 Subject: [PATCH 026/124] Support rendering %app --- .../chat/src/js/components/lib/message.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkg/interface/chat/src/js/components/lib/message.js b/pkg/interface/chat/src/js/components/lib/message.js index 1aa982e842..b4ba115aa4 100644 --- a/pkg/interface/chat/src/js/components/lib/message.js +++ b/pkg/interface/chat/src/js/components/lib/message.js @@ -11,6 +11,8 @@ export class Message extends Component { return this.renderLin(speech.lin.msg, speech.lin.pat); } else if (_.has(speech, 'url')) { return this.renderUrl(speech.url); + } else if (_.has(speech, 'app')) { + return this.renderSpeech(speech.app.sep); } else { return this.renderUnknown(); } @@ -87,6 +89,16 @@ export class Message extends Component { } } + renderAuthor() { + const msg = this.props.msg; + const ship = '~' + msg.aut; + if (_.has(msg, 'sep.app.app')) { + return `:${msg.sep.app.app} (${ship})`; + } else { + return ship; + } + } + //NOTE see also lib/chat-input's globalizeUrl localizeUrl(url) { if (typeof url !== 'string') { throw 'Only localize strings!'; } @@ -120,7 +132,7 @@ export class Message extends Component {

- ~{props.msg.aut} + {this.renderAuthor()}

{timestamp}

From 1974c8b4e4d9eb4b820acb8c326ccebdcdb6745a Mon Sep 17 00:00:00 2001 From: Fang Date: Sun, 28 Jul 2019 13:09:55 +0200 Subject: [PATCH 027/124] Support rendering %ire --- pkg/interface/chat/src/js/components/lib/message.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/interface/chat/src/js/components/lib/message.js b/pkg/interface/chat/src/js/components/lib/message.js index b4ba115aa4..41d9f5b5dd 100644 --- a/pkg/interface/chat/src/js/components/lib/message.js +++ b/pkg/interface/chat/src/js/components/lib/message.js @@ -11,6 +11,8 @@ export class Message extends Component { return this.renderLin(speech.lin.msg, speech.lin.pat); } else if (_.has(speech, 'url')) { return this.renderUrl(speech.url); + } else if (_.has(speech, 'ire')) { + return this.renderSpeech(speech.ire.sep); } else if (_.has(speech, 'app')) { return this.renderSpeech(speech.app.sep); } else { From ea3f46183a6c0f36c54a62955edd5adfc644e9c5 Mon Sep 17 00:00:00 2001 From: Fang Date: Sun, 28 Jul 2019 13:21:54 +0200 Subject: [PATCH 028/124] Support rendering %exp --- pkg/interface/chat/src/js/components/lib/message.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/interface/chat/src/js/components/lib/message.js b/pkg/interface/chat/src/js/components/lib/message.js index 41d9f5b5dd..6441c6feb4 100644 --- a/pkg/interface/chat/src/js/components/lib/message.js +++ b/pkg/interface/chat/src/js/components/lib/message.js @@ -11,6 +11,8 @@ export class Message extends Component { return this.renderLin(speech.lin.msg, speech.lin.pat); } else if (_.has(speech, 'url')) { return this.renderUrl(speech.url); + } else if (_.has(speech, 'exp')) { + return this.renderExp(speech.exp.exp, speech.exp.res); } else if (_.has(speech, 'ire')) { return this.renderSpeech(speech.ire.sep); } else if (_.has(speech, 'app')) { @@ -77,6 +79,13 @@ export class Message extends Component { ); } + renderExp(expression, result) { + return (<> +

# {expression}

+

{result[0]}

+ ); + } + renderContent() { const { props } = this; From c4ad4aa2473d2730dc2c37fde045868d930cb2a9 Mon Sep 17 00:00:00 2001 From: Fang Date: Sun, 28 Jul 2019 22:33:54 +0200 Subject: [PATCH 029/124] Support rendering %fat --- pkg/interface/chat/src/css/custom.css | 5 ++++ .../chat/src/js/components/lib/message.js | 25 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/pkg/interface/chat/src/css/custom.css b/pkg/interface/chat/src/css/custom.css index 5b949ec8f0..293bcf79b2 100644 --- a/pkg/interface/chat/src/css/custom.css +++ b/pkg/interface/chat/src/css/custom.css @@ -123,6 +123,11 @@ h2 { -webkit-box-orient: vertical; } +.clamp-attachment { + overflow: scroll; + max-height: 10em; +} + .lh-16 { line-height: 16px; } diff --git a/pkg/interface/chat/src/js/components/lib/message.js b/pkg/interface/chat/src/js/components/lib/message.js index 6441c6feb4..b4c011e77c 100644 --- a/pkg/interface/chat/src/js/components/lib/message.js +++ b/pkg/interface/chat/src/js/components/lib/message.js @@ -17,6 +17,8 @@ export class Message extends Component { return this.renderSpeech(speech.ire.sep); } else if (_.has(speech, 'app')) { return this.renderSpeech(speech.app.sep); + } else if (_.has(speech, 'fat')) { + return this.renderFat(speech.fat.sep, speech.fat.tac); } else { return this.renderUnknown(); } @@ -86,6 +88,29 @@ export class Message extends Component { ); } + renderFat(speech, attachment) { + return (<> + {this.renderSpeech(speech)} + {this.renderAttachment(attachment)} + ); + } + + renderAttachment(content, title = '') { + if (_.has(content, 'name')) { + return this.renderAttachment(content.name.tac, content.name.nom); + } + + return (
+ {'Attached: ' + title} + { _.has(content, 'text') + ?
{content.text}
+ : _.has(content, 'tank') + ? content.tank.map(l =>

{l}

) + : null + } + ); + } + renderContent() { const { props } = this; From 716af367bf00910225209c2698316814443cba56 Mon Sep 17 00:00:00 2001 From: Fang Date: Sun, 28 Jul 2019 23:21:03 +0200 Subject: [PATCH 030/124] Forbid sending empty messages And don't render any elements for them. --- pkg/interface/chat/src/js/components/lib/chat-input.js | 4 ++++ pkg/interface/chat/src/js/components/lib/message.js | 3 +++ 2 files changed, 7 insertions(+) diff --git a/pkg/interface/chat/src/js/components/lib/chat-input.js b/pkg/interface/chat/src/js/components/lib/chat-input.js index 1416562b96..777f9ae9b9 100644 --- a/pkg/interface/chat/src/js/components/lib/chat-input.js +++ b/pkg/interface/chat/src/js/components/lib/chat-input.js @@ -194,6 +194,10 @@ export class ChatInput extends Component { messageSubmit() { const { props, state } = this; + if (state.message === '') { + return; + } + let message = { uid: uuid(), aut: window.ship, diff --git a/pkg/interface/chat/src/js/components/lib/message.js b/pkg/interface/chat/src/js/components/lib/message.js index b4c011e77c..4910ac0a12 100644 --- a/pkg/interface/chat/src/js/components/lib/message.js +++ b/pkg/interface/chat/src/js/components/lib/message.js @@ -29,6 +29,9 @@ export class Message extends Component { } renderLin(content, action = false) { + if (content === '') { + return null; + } //TODO remove once arvo:// urls are supported in url speeches if (content.indexOf('arvo://') === 0) { return this.renderUrl(content); From c880736eea1fb7447ac87430625da813d6ba6ee1 Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 29 Jul 2019 01:58:08 +0200 Subject: [PATCH 031/124] Remove noisy printf --- pkg/interface/chat/src/js/components/lib/icons/sigil.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/interface/chat/src/js/components/lib/icons/sigil.js b/pkg/interface/chat/src/js/components/lib/icons/sigil.js index 2f3227ed0d..b639de0870 100644 --- a/pkg/interface/chat/src/js/components/lib/icons/sigil.js +++ b/pkg/interface/chat/src/js/components/lib/icons/sigil.js @@ -6,8 +6,6 @@ export class Sigil extends Component { render() { const { props } = this; - console.log("sigil ship", props.ship); - if (props.ship.length > 14) { return (
From c04ee7a0dee5eb279df869f6341badad729b6ce6 Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 29 Jul 2019 02:01:16 +0200 Subject: [PATCH 032/124] Ensure (%fat) messages get rendered within screen bounds --- pkg/interface/chat/src/css/custom.css | 5 +++++ pkg/interface/chat/src/js/components/lib/message.js | 12 +++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pkg/interface/chat/src/css/custom.css b/pkg/interface/chat/src/css/custom.css index 293bcf79b2..2f29bd5628 100644 --- a/pkg/interface/chat/src/css/custom.css +++ b/pkg/interface/chat/src/css/custom.css @@ -123,9 +123,14 @@ h2 { -webkit-box-orient: vertical; } +.clamp-message { + max-width: calc(100% - 32px - .5em); +} + .clamp-attachment { overflow: scroll; max-height: 10em; + max-width: 100%; } .lh-16 { diff --git a/pkg/interface/chat/src/js/components/lib/message.js b/pkg/interface/chat/src/js/components/lib/message.js index 4910ac0a12..6e23f5a3e7 100644 --- a/pkg/interface/chat/src/js/components/lib/message.js +++ b/pkg/interface/chat/src/js/components/lib/message.js @@ -103,12 +103,14 @@ export class Message extends Component { return this.renderAttachment(content.name.tac, content.name.nom); } - return (
- {'Attached: ' + title} + return (
+ {'Attached: ' + title} { _.has(content, 'text') - ?
{content.text}
+ ?
{content.text}
: _.has(content, 'tank') - ? content.tank.map(l =>

{l}

) + ?
+ {content.tank.map(l =>

{l}

)} +
: null } ); @@ -168,7 +170,7 @@ export class Message extends Component {
-
+

{this.renderAuthor()} From 37d061cbfed7c668b407524f373cafeda04d0cab Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 29 Jul 2019 02:08:19 +0200 Subject: [PATCH 033/124] Support sending %fat messages for clipboard pastes and long-form content. If a multi-line string is pasted into an empty input field, treat is as a "clipboard" message if it's sent directly afterwards. (A text %fat.) If a multi-line message is composed in any other way, treat it as a long-form message, moving all but the first line into the attachment. (A more display-friendly tank %fat.) --- .../chat/src/js/components/lib/chat-input.js | 66 +++++++++++++++---- 1 file changed, 55 insertions(+), 11 deletions(-) diff --git a/pkg/interface/chat/src/js/components/lib/chat-input.js b/pkg/interface/chat/src/js/components/lib/chat-input.js index 777f9ae9b9..2fc68e7905 100644 --- a/pkg/interface/chat/src/js/components/lib/chat-input.js +++ b/pkg/interface/chat/src/js/components/lib/chat-input.js @@ -55,7 +55,8 @@ export class ChatInput extends Component { this.state = { message: '', - messageType: 'lin' + messageType: 'lin', + clipboard: null }; this.textareaRef = React.createRef(); @@ -101,15 +102,24 @@ export class ChatInput extends Component { } messageChange(event) { - this.setState({ - message: event.target.value, - messageType: this.getSpeechType(event.target.value) - }); + const input = event.target.value; + const previous = this.state.message; + //NOTE dumb hack to work around paste event flow oddities + const pasted = (previous.length === 0 && input.length > 1); + if (input !== this.state.clipboard) { + this.setState({ + message: input, + messageType: this.getSpeechType(input), + clipboard: (pasted ? input : null) + }); + } } getSpeechType(input) { - if (input[0] === '@') { - return 'lin@' + if (input.indexOf('\n') >= 0) { + return 'fat'; + } else if (input[0] === '@') { + return 'lin@'; } else if (this.isUrl(input)) { return 'url'; } else { @@ -117,12 +127,14 @@ export class ChatInput extends Component { } } - getSpeechStyle(type) { + getSpeechStyle(type, clipboard) { switch (type) { case 'lin@': return 'fs-italic'; case 'url': return 'td-underline'; + case 'fat': + if (clipboard) return 'code'; default: return ''; } @@ -169,7 +181,7 @@ export class ChatInput extends Component { } } - speechFromInput(content, type = 'lin') { + speechFromInput(content, type, clipboard) { switch (type) { case 'lin': return { lin: { @@ -186,6 +198,31 @@ export class ChatInput extends Component { case 'url': return this.globalizeUrl(content); // + case 'fat': + // clipboard contents + if (clipboard !== null) { + return { fat: { + sep: { lin: { msg: '', pat: false } }, + tac: { name: { + nom: 'clipboard', + tac: { text: content } + } } + } }; + // long-form message + } else { + const lines = content.split('\n'); + return { fat: { + sep: { lin: { + msg: lines[0], + pat: false + } }, + tac: { name: { + nom: 'long-form', + tac: { tank: lines.slice(1).map(l => { return {leaf: l }; }) } + } }, + } }; + } + // default: throw new Error('Unimplemented speech type', type); } @@ -203,7 +240,11 @@ export class ChatInput extends Component { aut: window.ship, wen: Date.now(), aud: [props.station], - sep: this.speechFromInput(state.message, state.messageType) + sep: this.speechFromInput( + state.message, + state.messageType, + state.clipboard + ) }; props.api.hall( @@ -249,7 +290,10 @@ export class ChatInput extends Component {

- Date: Mon, 29 Jul 2019 02:16:11 +0200 Subject: [PATCH 034/124] Make input area resizable and touch up its styling issues. --- pkg/interface/chat/src/js/components/chat.js | 4 ++-- pkg/interface/chat/src/js/components/lib/chat-input.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/interface/chat/src/js/components/chat.js b/pkg/interface/chat/src/js/components/chat.js index 4fb15236e5..3a7445566a 100644 --- a/pkg/interface/chat/src/js/components/chat.js +++ b/pkg/interface/chat/src/js/components/chat.js @@ -210,8 +210,8 @@ export class ChatScreen extends Component { numPeers={peers.length} />
{ this.scrollElement = el; }}>
{chatMessages} diff --git a/pkg/interface/chat/src/js/components/lib/chat-input.js b/pkg/interface/chat/src/js/components/lib/chat-input.js index 2fc68e7905..159374f1d5 100644 --- a/pkg/interface/chat/src/js/components/lib/chat-input.js +++ b/pkg/interface/chat/src/js/components/lib/chat-input.js @@ -281,7 +281,7 @@ export class ChatInput extends Component { } return ( -
+
-
+