From 1c641629e216fabb765ff6d1d0a61dbd6efeadcf Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Thu, 4 Nov 2021 09:54:25 +0100 Subject: [PATCH] roller: add azimuth refresh-rate to getConfig RPC --- pkg/arvo/app/azimuth-rpc.hoon | 7 +++++++ pkg/arvo/app/azimuth.hoon | 15 ++++++++++++-- pkg/arvo/app/roller-rpc.hoon | 8 ++++++++ pkg/arvo/app/roller.hoon | 6 ++++-- pkg/arvo/lib/azimuth-roll-rpc.hoon | 33 ++++++++++++++++++++++-------- pkg/arvo/sur/dice.hoon | 7 ++++++- 6 files changed, 62 insertions(+), 14 deletions(-) diff --git a/pkg/arvo/app/azimuth-rpc.hoon b/pkg/arvo/app/azimuth-rpc.hoon index a9ce4340a..832971233 100644 --- a/pkg/arvo/app/azimuth-rpc.hoon +++ b/pkg/arvo/app/azimuth-rpc.hoon @@ -148,6 +148,7 @@ %get-point `(get-point id +.params point:scry) %get-dns `(get-dns id +.params dns:scry) %get-naive-state `(get-naive id +.params naive-state:scry) + %get-refresh `(get-refresh id +.params refresh:scry) == -- :: @@ -171,5 +172,11 @@ %gx (~(scry agentio bowl) %azimuth /nas/noun) == + :: + ++ refresh + .^ @dr + %gx + (~(scry agentio bowl) %azimuth /refresh/noun) + == -- -- diff --git a/pkg/arvo/app/azimuth.hoon b/pkg/arvo/app/azimuth.hoon index bca549e52..4e47d5ed9 100644 --- a/pkg/arvo/app/azimuth.hoon +++ b/pkg/arvo/app/azimuth.hoon @@ -43,6 +43,9 @@ +$ tagged-diff [=id:block diff:naive] +$ network ?(%mainnet %ropsten %local) +$ card card:agent:gall +:: TODO: add to state? +:: +++ refresh ~m5 -- :: =| state=app-state @@ -59,7 +62,14 @@ ^- (quip card _this) =. net.state %local :_ this - [%pass /eth-watcher %agent [our.bowl %eth-watcher] %watch /logs/[dap.bowl]]~ + :_ ~ + :* %pass + /eth-watcher + %agent + [our.bowl %eth-watcher] + %watch + /logs/[dap.bowl] + == :: ++ on-save !>(state) ++ on-load @@ -140,6 +150,7 @@ [%x %nas ~] ``noun+!>(nas.state) [%x %dns ~] ``noun+!>(dns.nas.state) [%x %own ~] ``noun+!>(own.state) + [%x %refresh ~] ``atom+!>(refresh) [%x %point @ ~] ``noun+(point i.t.t.path) == :: @@ -319,7 +330,7 @@ =/ args=vase !> :+ %watch /[dap.bowl] ^- config:eth-watcher - :* url.state =(%czar (clan:title our.bowl)) ~m5 ~h30 + :* url.state =(%czar (clan:title our.bowl)) refresh ~h30 (max launch.net last-snap) ~[azimuth.net] ~[naive.net] diff --git a/pkg/arvo/app/roller-rpc.hoon b/pkg/arvo/app/roller-rpc.hoon index 43c564352..96e45d9ba 100644 --- a/pkg/arvo/app/roller-rpc.hoon +++ b/pkg/arvo/app/roller-rpc.hoon @@ -301,6 +301,8 @@ == :: ++ config + ^- [azimuth-config roller-config] + :- refresh .^ roller-config %gx %+ ~(scry agentio bowl) @@ -321,5 +323,11 @@ %gx (~(scry agentio bowl) %roller /predicted/noun) == + :: + ++ refresh + .^ @dr + %gx + (~(scry agentio bowl) %azimuth /refresh/noun) + == -- -- diff --git a/pkg/arvo/app/roller.hoon b/pkg/arvo/app/roller.hoon index 3466331be..3d5ba85dd 100644 --- a/pkg/arvo/app/roller.hoon +++ b/pkg/arvo/app/roller.hoon @@ -101,6 +101,7 @@ :: TODO: add to config :: ++ resend-time ~m5 +++ update-rate ~m1 :: ++ lverb & -- @@ -334,6 +335,7 @@ :* next-batch frequency resend-time + update-rate contract chain-id == @@ -874,7 +876,7 @@ ?. derive ~ :: derive predicted state in 1m. :: - [(wait:b:sys /predict (add ~m1 now.bowl))]~ + [(wait:b:sys /predict (add update-rate now.bowl))]~ :: +set-timer: %wait until next whole :frequency :: ++ set-timer @@ -1110,7 +1112,7 @@ ?. derive ~ :: derive predicted/ownership state in 1m. :: - [(wait:b:sys /predict (add ~m1 now.bowl))]~ + [(wait:b:sys /predict (add update-rate now.bowl))]~ :: ?: ?=(%point -.diff) [~ state] ?> ?=(%tx -.diff) diff --git a/pkg/arvo/lib/azimuth-roll-rpc.hoon b/pkg/arvo/lib/azimuth-roll-rpc.hoon index 88caa803e..fefbf7314 100644 --- a/pkg/arvo/lib/azimuth-roll-rpc.hoon +++ b/pkg/arvo/lib/azimuth-roll-rpc.hoon @@ -345,17 +345,25 @@ :: ++ tx-status |=(=^tx-status ^-(json s+status.tx-status)) :: - ++ config - |= roller-config + ++ roller-config + |= [az=^azimuth-config ro=^roller-config] ^- json %- pairs - :~ ['nextBatch' (time next-batch)] - ['frequency' (numb (div frequency ~s1))] - ['refreshTime' (numb (div refresh-time ~s1))] - ['contract' (hex 20 contract)] - ['chainId' (numb chain-id)] + :~ ['azimuthRefreshRate' (numb (div refresh-rate.az ~s1))] + ['nextBatch' (time next-batch.ro)] + ['frequency' (numb (div frequency.ro ~s1))] + ['rollerResendTime' (numb (div resend-time.ro ~s1))] + ['rollerUpdateRate' (numb (div update-rate.ro ~s1))] + ['contract' (hex 20 contract.ro)] + ['chainId' (numb chain-id.ro)] == :: + ++ azimuth-config + |= config=^azimuth-config + ^- json + %- pairs + ['refreshRate' (numb (div refresh-rate.config ~s1))]~ + :: ++ hex |= [p=@ q=@] ^- json @@ -578,11 +586,11 @@ [%result id (hist-txs:to-json (scry u.address))] :: ++ get-config - |= [id=@t params=(map @t json) =roller-config] + |= [id=@t params=(map @t json) config=[azimuth-config roller-config]] ^- response:rpc ?. =((lent ~(tap by params)) 0) ~(params error:json-rpc id) - [%result id (config:to-json roller-config)] + [%result id (roller-config:to-json config)] :: ++ hash-transaction |= [id=@t params=(map @t json) chain-id=@] @@ -609,4 +617,11 @@ ?. =((lent ~(tap by params)) 0) ~(params error:json-rpc id) [%result id (naive-state:to-json state)] +:: +++ get-refresh + |= [id=@t params=(map @t json) =azimuth-config] + ^- response:rpc + ?. =((lent ~(tap by params)) 0) + ~(params error:json-rpc id) + [%result id (azimuth-config:to-json azimuth-config)] -- diff --git a/pkg/arvo/sur/dice.hoon b/pkg/arvo/sur/dice.hoon index 3baccc4e4..21637bc1f 100644 --- a/pkg/arvo/sur/dice.hoon +++ b/pkg/arvo/sur/dice.hoon @@ -6,10 +6,15 @@ +$ owner [=proxy:naive =address:naive] +$ owners (jug owner ship) :: ++$ azimuth-config + $: refresh-rate=@dr + == +:: +$ roller-config $: next-batch=time frequency=@dr - refresh-time=@dr + resend-time=@dr + update-rate=@dr contract=@ux chain-id=@ ==