From fe8150f39537e6c96439075aa7bfe3ec6f38778d Mon Sep 17 00:00:00 2001 From: drbeefsupreme Date: Wed, 28 Apr 2021 15:13:31 -0400 Subject: [PATCH 01/39] naive: key change test --- pkg/arvo/tests/lib/naive.hoon | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/pkg/arvo/tests/lib/naive.hoon b/pkg/arvo/tests/lib/naive.hoon index 8b65d6efa..b6dd1ad23 100644 --- a/pkg/arvo/tests/lib/naive.hoon +++ b/pkg/arvo/tests/lib/naive.hoon @@ -218,7 +218,6 @@ ++ set-management-proxy |= [nonce=@ud =ship pk=@ proxy=@tas =address] ^- octs %^ sign-tx pk nonce - ^- octs (take-ship-address:bits %set-management-proxy ship proxy ship address) :: ++ set-spawn-proxy @@ -426,10 +425,38 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(set-spawn-proxy:l2 0 ~marbud %marbud-key-0 %own (addr %marbud-spawn-0))) - =^ f state (n state %bat q:(spawn:l2 0 ~marbud %marbud-spawn-0 %spawn ~linnup-torsyx (addr %ll-key-0))) + =^ f state (n state %bat q:(set-spawn-proxy:l2 0 ~marbud %marbud-key-0 %own (addr %marbud-spn))) + =^ f state (n state %bat q:(spawn:l2 0 ~marbud %marbud-spn %spawn ~linnup-torsyx (addr %ll-key-0))) transfer-proxy.own:(~(got by points.state) ~linnup-torsyx) :: +++ test-marbud-l2-change-keys + =/ encrypt (shax 'You will forget that you ever read this sentence.') + =/ auth (shax 'You cant know that this sentence is true.') + =/ new-keys-own [0 ~marbud %marbud-key-0 %own 0 encrypt auth 1] + =/ new-keys-mgt [0 ~marbud %marbud-mgt %manage 0 encrypt auth 1] + =/ mgt-proxy [0 ~marbud %marbud-key-0 %own (addr %marbud-mgt)] + ;: weld + %+ expect-eq + !> (pass-from-eth:naive 32^encrypt 32^auth 1) + :: + !> + =| =^state:naive + =^ f state (init-marbud state) + =^ f state (n state %bat q:(configure-keys:l2 new-keys-own)) + pass.net:(~(got by points.state) ~marbud) + :: + %+ expect-eq + !> (pass-from-eth:naive 32^encrypt 32^auth 1) + :: + !> + =| =^state:naive + =^ f state (init-marbud state) + =^ f state (n state %bat q:(set-management-proxy:l2 mgt-proxy)) + =^ f state (n state %bat q:(configure-keys:l2 new-keys-mgt)) + pass.net:(~(got by points.state) ~marbud) + :: + == +:: ++ test-dopbud-l2-spawn ^- tang %+ expect-eq !> [`@ux`(addr %pp-key-0) 0] From 7f1e21d3d5750969478cb52c24fe0dc727d790b7 Mon Sep 17 00:00:00 2001 From: drbeefsupreme Date: Wed, 28 Apr 2021 15:29:20 -0400 Subject: [PATCH 02/39] naive: l1 key change test --- pkg/arvo/tests/lib/naive.hoon | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/arvo/tests/lib/naive.hoon b/pkg/arvo/tests/lib/naive.hoon index b6dd1ad23..79ac70605 100644 --- a/pkg/arvo/tests/lib/naive.hoon +++ b/pkg/arvo/tests/lib/naive.hoon @@ -369,6 +369,19 @@ =^ f state (n state (changed-voting-proxy:l1 ~bud 0x123)) voting-proxy.own:(~(got by points.state) ~bud) :: +++ test-l1-changed-keys ^- tang + =/ encrypt (shax 'Your eyes dont see, you do.') + =/ auth (shax 'We think much less than we think we think.') + =/ new-keys [~bud encrypt auth 1 1] + %+ expect-eq + !> (pass-from-eth:naive 32^encrypt 32^auth 1) + :: + !> + =| =^state:naive + =^ f state (init-bud state) + =^ f state (n state (changed-keys:l1 new-keys)) + pass.net:(~(got by points.state) ~bud) +:: ++ test-l2-set-spawn-proxy ^- tang %+ expect-eq !> [0x123 0] @@ -455,6 +468,7 @@ =^ f state (n state %bat q:(configure-keys:l2 new-keys-mgt)) pass.net:(~(got by points.state) ~marbud) :: + :: TODO: make sure nobody else can change these keys == :: ++ test-dopbud-l2-spawn ^- tang From 84a8a5c86095e307390f5d56733b15741f45dd08 Mon Sep 17 00:00:00 2001 From: drbeefsupreme Date: Thu, 29 Apr 2021 16:31:45 -0400 Subject: [PATCH 03/39] naive: fix key format for tests --- pkg/arvo/tests/lib/naive.hoon | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/pkg/arvo/tests/lib/naive.hoon b/pkg/arvo/tests/lib/naive.hoon index 604400fe1..2970f077f 100644 --- a/pkg/arvo/tests/lib/naive.hoon +++ b/pkg/arvo/tests/lib/naive.hoon @@ -1,4 +1,4 @@ -/+ *test, naive, ethereum +/+ *test, naive, ethereum, azimuth |% ++ address @ux ++ n |=([=^state:naive =^input:naive] (%*(. naive lac |) verifier 1.337 +<)) @@ -383,15 +383,17 @@ ++ test-l1-changed-keys ^- tang =/ encrypt (shax 'Your eyes dont see, you do.') =/ auth (shax 'We think much less than we think we think.') - =/ new-keys [~bud encrypt auth 1 1] + =/ suite 1 + =/ life 1 + =/ new-keys [~bud encrypt auth suite life] %+ expect-eq - !> (pass-from-eth:naive 32^encrypt 32^auth 1) + !> [suite auth encrypt] :: !> =| =^state:naive =^ f state (init-bud state) =^ f state (n state (changed-keys:l1 new-keys)) - pass.net:(~(got by points.state) ~bud) + |1:keys.net:(~(got by points.state) ~bud) :: ++ test-l2-set-spawn-proxy ^- tang %+ expect-eq @@ -456,28 +458,29 @@ ++ test-marbud-l2-change-keys =/ encrypt (shax 'You will forget that you ever read this sentence.') =/ auth (shax 'You cant know that this sentence is true.') - =/ new-keys-own [0 ~marbud %marbud-key-0 %own 0 encrypt auth 1] - =/ new-keys-mgt [0 ~marbud %marbud-mgt %manage 0 encrypt auth 1] + =/ suite 1 + =/ new-keys-own [0 ~marbud %marbud-key-0 %own 0 encrypt auth suite] + =/ new-keys-mgt [0 ~marbud %marbud-mgt %manage 0 encrypt auth suite] =/ mgt-proxy [0 ~marbud %marbud-key-0 %own (addr %marbud-mgt)] ;: weld %+ expect-eq - !> (pass-from-eth:naive 32^encrypt 32^auth 1) + !> [suite auth encrypt] :: !> =| =^state:naive =^ f state (init-marbud state) =^ f state (n state %bat q:(configure-keys:l2 new-keys-own)) - pass.net:(~(got by points.state) ~marbud) + |1:keys.net:(~(got by points.state) ~marbud) :: %+ expect-eq - !> (pass-from-eth:naive 32^encrypt 32^auth 1) + !> [suite auth encrypt] :: !> =| =^state:naive =^ f state (init-marbud state) =^ f state (n state %bat q:(set-management-proxy:l2 mgt-proxy)) =^ f state (n state %bat q:(configure-keys:l2 new-keys-mgt)) - pass.net:(~(got by points.state) ~marbud) + |1:keys.net:(~(got by points.state) ~marbud) :: :: TODO: make sure nobody else can change these keys == From 7f32d9125861b74c65c34949548de98c7454e13c Mon Sep 17 00:00:00 2001 From: drbeefsupreme Date: Fri, 30 Apr 2021 14:00:03 -0400 Subject: [PATCH 04/39] naive: breach is flag not atom --- pkg/arvo/tests/lib/naive.hoon | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/arvo/tests/lib/naive.hoon b/pkg/arvo/tests/lib/naive.hoon index 2970f077f..b504bc30c 100644 --- a/pkg/arvo/tests/lib/naive.hoon +++ b/pkg/arvo/tests/lib/naive.hoon @@ -191,7 +191,7 @@ :: ++ configure-keys |= $: nonce=@ud =ship pk=@ proxy=@tas - breach=@ encrypt=@ auth=@ crypto-suite=@ + breach=? encrypt=@ auth=@ crypto-suite=@ == ^- octs %^ sign-tx pk nonce @@ -459,8 +459,8 @@ =/ encrypt (shax 'You will forget that you ever read this sentence.') =/ auth (shax 'You cant know that this sentence is true.') =/ suite 1 - =/ new-keys-own [0 ~marbud %marbud-key-0 %own 0 encrypt auth suite] - =/ new-keys-mgt [0 ~marbud %marbud-mgt %manage 0 encrypt auth suite] + =/ new-keys-own [0 ~marbud %marbud-key-0 %own | encrypt auth suite] + =/ new-keys-mgt [0 ~marbud %marbud-mgt %manage | encrypt auth suite] =/ mgt-proxy [0 ~marbud %marbud-key-0 %own (addr %marbud-mgt)] ;: weld %+ expect-eq From e87b1e262109fa4e878d4feac8f6a66d9b53a9aa Mon Sep 17 00:00:00 2001 From: drbeefsupreme Date: Fri, 30 Apr 2021 16:39:13 -0400 Subject: [PATCH 05/39] naive: test breach proxies+keys for l2 transfers --- pkg/arvo/tests/lib/naive.hoon | 78 +++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/pkg/arvo/tests/lib/naive.hoon b/pkg/arvo/tests/lib/naive.hoon index b504bc30c..4028136a5 100644 --- a/pkg/arvo/tests/lib/naive.hoon +++ b/pkg/arvo/tests/lib/naive.hoon @@ -485,6 +485,84 @@ :: TODO: make sure nobody else can change these keys == :: +++ test-marbud-l2-transfer-breach ^- tang + =/ encrypt (shax 'You will forget that you ever read this sentence.') + =/ auth (shax 'You cant know that this sentence is true.') + =/ suite 1 + =/ new-keys [0 ~marbud %marbud-key-0 %own | encrypt auth suite] + ;: weld + %+ expect-eq + :: Tests that proxies are reset on transfer breach + !> + :* [(addr %marbud-key-1) 3] :: ownership + [0 0] :: spawn-proxy + [0 0] :: management-proxy + [0 0] :: voting-proxy + [0 1] :: transfer-proxy + == + :: + !> + =| =^state:naive + =^ f state (init-marbud state) + =^ f state (n state %bat q:(set-spawn-proxy:l2 0 ~marbud %marbud-key-0 %own 0x123)) + =^ f state (n state %bat q:(set-management-proxy:l2 1 ~marbud %marbud-key-0 %own 0x234)) + =^ f state (n state %bat q:(set-transfer-proxy:l2 2 ~marbud %marbud-key-0 %own (addr %marbud-key-1))) + =^ f state (n state %bat q:(transfer-point:l2 0 ~marbud %marbud-key-1 (addr %marbud-key-1) %transfer &)) + ^- [[@ @] [@ @] [@ @] [@ @] [@ @]] + own:(~(got by points.state) ~marbud) + :: + %+ expect-eq + :: Tests that networking keys are reset on transfer breach + !> + [0 0 0] + :: + !> + =| =^state:naive + =^ f state (init-marbud state) + =^ f state (n state %bat q:(configure-keys:l2 new-keys)) + =^ f state (n state %bat q:(transfer-point:l2 1 ~marbud %marbud-key-0 (addr %marbud-key-0) %own &)) + |1:keys.net:(~(got by points.state) ~marbud) + == +:: +++ test-marbud-l2-transfer-no-breach ^- tang + =/ encrypt (shax 'You will forget that you ever read this sentence.') + =/ auth (shax 'You cant know that this sentence is true.') + =/ suite 1 + =/ new-keys [0 ~marbud %marbud-key-0 %own | encrypt auth suite] + ;: weld + %+ expect-eq + :: Tests that proxies are not reset when transfering with no breach + !> + :* [(addr %marbud-key-1) 3] :: ownership + [`@`0x123 0] :: spawn-proxy + [`@`0x234 0] :: management-proxy + [0 0] :: voting-proxy + [0 1] :: transfer-proxy + == + :: + !> + =| =^state:naive + =^ f state (init-marbud state) + =^ f state (n state %bat q:(set-spawn-proxy:l2 0 ~marbud %marbud-key-0 %own 0x123)) + =^ f state (n state %bat q:(set-management-proxy:l2 1 ~marbud %marbud-key-0 %own 0x234)) + =^ f state (n state %bat q:(set-transfer-proxy:l2 2 ~marbud %marbud-key-0 %own (addr %marbud-key-1))) + =^ f state (n state %bat q:(transfer-point:l2 0 ~marbud %marbud-key-1 (addr %marbud-key-1) %transfer |)) + ^- [[@ @] [@ @] [@ @] [@ @] [@ @]] + own:(~(got by points.state) ~marbud) + :: + %+ expect-eq + :: Tests that networking keys are not reset when transfering with no breach + !> + [suite auth encrypt] + :: + !> + =| =^state:naive + =^ f state (init-marbud state) + =^ f state (n state %bat q:(configure-keys:l2 new-keys)) + =^ f state (n state %bat q:(transfer-point:l2 1 ~marbud %marbud-key-0 (addr %marbud-key-0) %own |)) + |1:keys.net:(~(got by points.state) ~marbud) + == +:: ++ test-dopbud-l2-spawn ^- tang %+ expect-eq !> [`@ux`(addr %pp-key-0) 0] From d7909375c8d2b150cd7181e2ee1544a1a30a46ad Mon Sep 17 00:00:00 2001 From: drbeefsupreme Date: Fri, 30 Apr 2021 17:16:53 -0400 Subject: [PATCH 06/39] naive: life and rift tests --- pkg/arvo/tests/lib/naive.hoon | 52 +++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/pkg/arvo/tests/lib/naive.hoon b/pkg/arvo/tests/lib/naive.hoon index 4028136a5..581099b51 100644 --- a/pkg/arvo/tests/lib/naive.hoon +++ b/pkg/arvo/tests/lib/naive.hoon @@ -306,6 +306,9 @@ -- :: |% +:: +:: TODO: Factor out commonly used things like keys and addresses +:: ++ test-log ^- tang %+ expect-eq !> @@ -563,6 +566,55 @@ |1:keys.net:(~(got by points.state) ~marbud) == :: +++ test-marbud-keys-life-rift ^- tang + =/ encrypt (shax 'You will forget that you ever read this sentence.') + =/ auth (shax 'You cant know that this sentence is true.') + =/ suite 1 + =/ no-breach [0 ~marbud %marbud-key-0 %own | encrypt auth suite] + =/ yes-breach [0 ~marbud %marbud-key-0 %own & encrypt auth suite] + ;: weld + %+ expect-eq + !> [0 1] :: [rift life] + :: + !> + =| =^state:naive + =^ f state (init-marbud state) + =^ f state (n state %bat q:(configure-keys:l2 no-breach)) + [rift.net life.keys.net]:(~(got by points.state) ~marbud) + :: + %+ expect-eq + !> [1 1] + :: + !> + =| =^state:naive + =^ f state (init-marbud state) + =^ f state (n state %bat q:(configure-keys:l2 yes-breach)) + [rift.net life.keys.net]:(~(got by points.state) ~marbud) + == +:: +++ test-marbud-transfer-life-rift ^- tang + ;: weld + %+ expect-eq + !> [1 0] :: [rift life] + :: + !> + =| =^state:naive + =^ f state (init-marbud state) + =^ f state (n state %bat q:(set-transfer-proxy:l2 0 ~marbud %marbud-key-0 %own (addr %marbud-key-1))) + =^ f state (n state %bat q:(transfer-point:l2 0 ~marbud %marbud-key-1 (addr %marbud-key-1) %transfer |)) + [rift.net life.keys.net]:(~(got by points.state) ~marbud) + :: + %+ expect-eq + !> [1 1] + :: + !> + =| =^state:naive + =^ f state (init-marbud state) + =^ f state (n state %bat q:(set-transfer-proxy:l2 0 ~marbud %marbud-key-0 %own (addr %marbud-key-1))) + =^ f state (n state %bat q:(transfer-point:l2 0 ~marbud %marbud-key-1 (addr %marbud-key-1) %transfer &)) + [rift.net life.keys.net]:(~(got by points.state) ~marbud) + == +:: ++ test-dopbud-l2-spawn ^- tang %+ expect-eq !> [`@ux`(addr %pp-key-0) 0] From 90d91472b4eca94a1d9b77b790ec75b59c598e9e Mon Sep 17 00:00:00 2001 From: drbeefsupreme Date: Fri, 30 Apr 2021 17:42:30 -0400 Subject: [PATCH 07/39] naive: test l2 escape request --- pkg/arvo/tests/lib/naive.hoon | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pkg/arvo/tests/lib/naive.hoon b/pkg/arvo/tests/lib/naive.hoon index 581099b51..870aaae9e 100644 --- a/pkg/arvo/tests/lib/naive.hoon +++ b/pkg/arvo/tests/lib/naive.hoon @@ -574,6 +574,7 @@ =/ yes-breach [0 ~marbud %marbud-key-0 %own & encrypt auth suite] ;: weld %+ expect-eq + :: breach=%.n !> [0 1] :: [rift life] :: !> @@ -583,6 +584,7 @@ [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: %+ expect-eq + :: breach=%.y !> [1 1] :: !> @@ -595,6 +597,7 @@ ++ test-marbud-transfer-life-rift ^- tang ;: weld %+ expect-eq + :: reset=%.n !> [1 0] :: [rift life] :: !> @@ -605,6 +608,7 @@ [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: %+ expect-eq + :: reset=%.y !> [1 1] :: !> @@ -689,6 +693,19 @@ =^ f state (n state %bat q:(transfer-point:l2 0 ~palsep-picdun %pp-key-0 (addr %pp-key-0) %transfer &)) owner.own:(~(got by points.state) ~palsep-picdun) :: +++ test-linnup-torsyx-l2-escape-request ^- tang + :: TODO: Are you supposed to be able to request escape to a non-existent star? + %+ expect-eq + !> [~ ~sambud] + :: + !> + =| =^state:naive + =^ f state (init-marbud state) + =^ f state (n state %bat q:(spawn:l2 0 ~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0))) + =^ f state (n state %bat q:(transfer-point:l2 0 ~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &)) + =^ f state (n state %bat q:(escape:l2 0 ~linnup-torsyx %lt-key-0 %own ~sambud)) + escape.net:(~(got by points.state) ~linnup-torsyx) +:: :: TODO: signature format changed; regenerate :: :: ++ test-metamask-signature ^- tang From 7b89b552b61ce31d4abf293a1444b60ef653352e Mon Sep 17 00:00:00 2001 From: drbeefsupreme Date: Fri, 30 Apr 2021 17:45:24 -0400 Subject: [PATCH 08/39] naive: fix transfer life+rift test --- pkg/arvo/tests/lib/naive.hoon | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/tests/lib/naive.hoon b/pkg/arvo/tests/lib/naive.hoon index 870aaae9e..12d3773fd 100644 --- a/pkg/arvo/tests/lib/naive.hoon +++ b/pkg/arvo/tests/lib/naive.hoon @@ -598,7 +598,7 @@ ;: weld %+ expect-eq :: reset=%.n - !> [1 0] :: [rift life] + !> [0 0] :: [rift life] :: !> =| =^state:naive @@ -609,7 +609,8 @@ :: %+ expect-eq :: reset=%.y - !> [1 1] + :: TODO: This test currently fails - rift is not increments on transfer w/ breach + !> [1 0] :: !> =| =^state:naive From b2a1da4faa67df0f696c6745cf2f8f7f58633cbf Mon Sep 17 00:00:00 2001 From: drbeefsupreme Date: Tue, 4 May 2021 13:27:43 -0400 Subject: [PATCH 09/39] naive: l2 life+rift tests --- pkg/arvo/tests/lib/naive.hoon | 124 ++++++++++++++++++++++------------ 1 file changed, 81 insertions(+), 43 deletions(-) diff --git a/pkg/arvo/tests/lib/naive.hoon b/pkg/arvo/tests/lib/naive.hoon index 12d3773fd..0475a7221 100644 --- a/pkg/arvo/tests/lib/naive.hoon +++ b/pkg/arvo/tests/lib/naive.hoon @@ -305,6 +305,18 @@ :: -- :: +:: Keys +:: +|% +:: +++ encr (shax 'You will forget that you ever read this sentence.') +++ auth (shax 'You cant know that this sentence is true.') +++ suit 1 +:: +-- +:: +:: Tests +:: |% :: :: TODO: Factor out commonly used things like keys and addresses @@ -384,13 +396,10 @@ voting-proxy.own:(~(got by points.state) ~bud) :: ++ test-l1-changed-keys ^- tang - =/ encrypt (shax 'Your eyes dont see, you do.') - =/ auth (shax 'We think much less than we think we think.') - =/ suite 1 =/ life 1 - =/ new-keys [~bud encrypt auth suite life] + =/ new-keys [~bud encr auth suit life] %+ expect-eq - !> [suite auth encrypt] + !> [suit auth encr] :: !> =| =^state:naive @@ -459,40 +468,35 @@ transfer-proxy.own:(~(got by points.state) ~linnup-torsyx) :: ++ test-marbud-l2-change-keys - =/ encrypt (shax 'You will forget that you ever read this sentence.') - =/ auth (shax 'You cant know that this sentence is true.') - =/ suite 1 - =/ new-keys-own [0 ~marbud %marbud-key-0 %own | encrypt auth suite] - =/ new-keys-mgt [0 ~marbud %marbud-mgt %manage | encrypt auth suite] - =/ mgt-proxy [0 ~marbud %marbud-key-0 %own (addr %marbud-mgt)] + =/ new-keys-own [~marbud %marbud-key-0 %own | encr auth suit] + =/ new-keys-mgt [~marbud %marbud-mgt %manage | encr auth suit] + =/ mgt-proxy [~marbud %marbud-key-0 %own (addr %marbud-mgt)] ;: weld %+ expect-eq - !> [suite auth encrypt] + !> [suit auth encr] :: !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(configure-keys:l2 new-keys-own)) + =^ f state (n state %bat q:(configure-keys:l2 0 new-keys-own)) |1:keys.net:(~(got by points.state) ~marbud) :: %+ expect-eq - !> [suite auth encrypt] + !> [suit auth encr] :: !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(set-management-proxy:l2 mgt-proxy)) - =^ f state (n state %bat q:(configure-keys:l2 new-keys-mgt)) + =^ f state (n state %bat q:(set-management-proxy:l2 0 mgt-proxy)) + =^ f state (n state %bat q:(configure-keys:l2 0 new-keys-mgt)) |1:keys.net:(~(got by points.state) ~marbud) :: :: TODO: make sure nobody else can change these keys == :: +:: TODO: transfer breach via transfer proxy ++ test-marbud-l2-transfer-breach ^- tang - =/ encrypt (shax 'You will forget that you ever read this sentence.') - =/ auth (shax 'You cant know that this sentence is true.') - =/ suite 1 - =/ new-keys [0 ~marbud %marbud-key-0 %own | encrypt auth suite] + =/ new-keys [~marbud %marbud-key-0 %own | encr auth suit] ;: weld %+ expect-eq :: Tests that proxies are reset on transfer breach @@ -522,16 +526,13 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(configure-keys:l2 new-keys)) + =^ f state (n state %bat q:(configure-keys:l2 0 new-keys)) =^ f state (n state %bat q:(transfer-point:l2 1 ~marbud %marbud-key-0 (addr %marbud-key-0) %own &)) |1:keys.net:(~(got by points.state) ~marbud) == :: ++ test-marbud-l2-transfer-no-breach ^- tang - =/ encrypt (shax 'You will forget that you ever read this sentence.') - =/ auth (shax 'You cant know that this sentence is true.') - =/ suite 1 - =/ new-keys [0 ~marbud %marbud-key-0 %own | encrypt auth suite] + =/ new-keys [~marbud %marbud-key-0 %own | encr auth suit] ;: weld %+ expect-eq :: Tests that proxies are not reset when transfering with no breach @@ -556,22 +557,24 @@ %+ expect-eq :: Tests that networking keys are not reset when transfering with no breach !> - [suite auth encrypt] + [suit auth encr] :: !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(configure-keys:l2 new-keys)) + =^ f state (n state %bat q:(configure-keys:l2 0 new-keys)) =^ f state (n state %bat q:(transfer-point:l2 1 ~marbud %marbud-key-0 (addr %marbud-key-0) %own |)) |1:keys.net:(~(got by points.state) ~marbud) == :: +:: TODO: life+rift changes via transfer proxy +:: ++ test-marbud-keys-life-rift ^- tang - =/ encrypt (shax 'You will forget that you ever read this sentence.') - =/ auth (shax 'You cant know that this sentence is true.') - =/ suite 1 - =/ no-breach [0 ~marbud %marbud-key-0 %own | encrypt auth suite] - =/ yes-breach [0 ~marbud %marbud-key-0 %own & encrypt auth suite] + =/ new-keys-no-reset [~marbud %marbud-key-0 %own | encr auth suit] + =/ new-keys-yes-reset [~marbud %marbud-key-0 %own & encr auth suit] + =/ zero-keys-no-reset [~marbud %marbud-key-0 %own | 0 0 0] + =/ zero-keys-yes-reset [~marbud %marbud-key-0 %own & 0 0 0] + ;: weld %+ expect-eq :: breach=%.n @@ -580,7 +583,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(configure-keys:l2 no-breach)) + =^ f state (n state %bat q:(configure-keys:l2 0 new-keys-no-reset)) [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: %+ expect-eq @@ -590,35 +593,70 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(configure-keys:l2 yes-breach)) + =^ f state (n state %bat q:(configure-keys:l2 0 new-keys-yes-reset)) [rift.net life.keys.net]:(~(got by points.state) ~marbud) + :: + %+ expect-eq + :: networking keys set incremenets life, reset=%.y + :: then zero keys and transfer, should increment rift but not life + :: + !> [2 2] + :: + !> + =| =^state:naive + =^ f state (init-marbud state) + =^ f state (n state %bat q:(configure-keys:l2 0 new-keys-yes-reset)) :: inc life and rift + =^ f state (n state %bat q:(configure-keys:l2 1 zero-keys-no-reset)) :: inc life + =^ f state (n state %bat q:(configure-keys:l2 2 zero-keys-yes-reset)) :: inc rift + [rift.net life.keys.net]:(~(got by points.state) ~marbud) + :: == :: ++ test-marbud-transfer-life-rift ^- tang + =/ new-keys-no-reset [~marbud %marbud-key-0 %own | encr auth suit] + =/ new-keys-yes-reset [~marbud %marbud-key-0 %own & encr auth suit] + =/ zero-keys-no-reset [~marbud %marbud-key-0 %own | 0 0 0] + =/ zero-keys-yes-reset [~marbud %marbud-key-0 %own & 0 0 0] ;: weld %+ expect-eq - :: reset=%.n + :: networking keys not set, reset=%.n + :: !> [0 0] :: [rift life] :: !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(set-transfer-proxy:l2 0 ~marbud %marbud-key-0 %own (addr %marbud-key-1))) - =^ f state (n state %bat q:(transfer-point:l2 0 ~marbud %marbud-key-1 (addr %marbud-key-1) %transfer |)) + =^ f state (n state %bat q:(transfer-point:l2 0 ~marbud %marbud-key-0 (addr %marbud-key-1) %own |)) [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: %+ expect-eq - :: reset=%.y - :: TODO: This test currently fails - rift is not increments on transfer w/ breach - !> [1 0] + :: networking keys not set, reset=%.y + :: + !> [0 0] :: !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(set-transfer-proxy:l2 0 ~marbud %marbud-key-0 %own (addr %marbud-key-1))) - =^ f state (n state %bat q:(transfer-point:l2 0 ~marbud %marbud-key-1 (addr %marbud-key-1) %transfer &)) + =^ f state (n state %bat q:(transfer-point:l2 0 ~marbud %marbud-key-0 (addr %marbud-key-1) %own &)) [rift.net life.keys.net]:(~(got by points.state) ~marbud) - == + :: + %+ expect-eq + :: networking keys set incremenets life, reset=%.y + :: then zero keys and transfer, should increment rift but not life + :: TODO: transferring and reset with already zeroed keys ought to incr rift but not life, right? + :: but currently the transfer w/ reset increments both life and rift, despite keys already being 0 + :: + !> [2 2] + :: + !> + =| =^state:naive + =^ f state (init-marbud state) + =^ f state (n state %bat q:(configure-keys:l2 0 new-keys-yes-reset)) :: inc life and rift + =^ f state (n state %bat q:(configure-keys:l2 1 zero-keys-no-reset)) :: inc life + =^ f state (n state %bat q:(transfer-point:l2 2 ~marbud %marbud-key-0 (addr %marbud-key-1) %own &)) :: inc rift + [rift.net life.keys.net]:(~(got by points.state) ~marbud) + :: + == :: ++ test-dopbud-l2-spawn ^- tang %+ expect-eq From 839a660b69e45f682dadf368747d2690edcf8ef1 Mon Sep 17 00:00:00 2001 From: drbeefsupreme Date: Tue, 4 May 2021 14:10:25 -0400 Subject: [PATCH 10/39] naive: sponsorship tests --- pkg/arvo/tests/lib/naive.hoon | 80 ++++++++++++++++++++++++++++++++--- 1 file changed, 75 insertions(+), 5 deletions(-) diff --git a/pkg/arvo/tests/lib/naive.hoon b/pkg/arvo/tests/lib/naive.hoon index 0475a7221..75248543c 100644 --- a/pkg/arvo/tests/lib/naive.hoon +++ b/pkg/arvo/tests/lib/naive.hoon @@ -54,6 +54,17 @@ =^ f3 state (n state (owner-changed:l1 ~marbud deposit-address:naive)) [:(welp f1 f2 f3) state] :: +:: ~litbud is for testing L2 sponsorship +:: +++ init-litbud + |= =^state:naive + ^- [effects:naive ^state:naive] + :: ~bud should already be spawned, though trying to init ~bud again shouldn't matter i think? + :: =^ f1 state (init-bud state) + =^ f2 state (n state (owner-changed:l1 ~litbud (addr %litbud-key-0))) + =^ f3 state (n state (owner-changed:l1 ~litbud deposit-address:naive)) + [:(welp f2 f3) state] +:: :: ~sambud is for testing L1 stars attempting L2 actions :: ++ init-sambud @@ -216,17 +227,17 @@ (take-escape:bits %cancel-escape child proxy parent) :: ++ adopt - |= [nonce=@ud child=ship pk=@ proxy=@tas parent=ship] ^- octs + |= [nonce=@ud parent=ship pk=@ proxy=@tas child=ship] ^- octs %^ sign-tx pk nonce (take-escape:bits %adopt parent proxy child) :: ++ reject - |= [nonce=@ud child=ship pk=@ proxy=@tas parent=ship] ^- octs + |= [nonce=@ud parent=ship pk=@ proxy=@tas child=ship] ^- octs %^ sign-tx pk nonce (take-escape:bits %reject parent proxy child) :: ++ detach - |= [nonce=@ud child=ship pk=@ proxy=@tas parent=ship] ^- octs + |= [nonce=@ud parent=ship pk=@ proxy=@tas child=ship] ^- octs %^ sign-tx pk nonce (take-escape:bits %detach parent proxy child) :: @@ -735,16 +746,75 @@ ++ test-linnup-torsyx-l2-escape-request ^- tang :: TODO: Are you supposed to be able to request escape to a non-existent star? %+ expect-eq - !> [~ ~sambud] + !> [~ ~litbud] :: !> =| =^state:naive =^ f state (init-marbud state) + =^ f state (init-litbud state) =^ f state (n state %bat q:(spawn:l2 0 ~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0))) =^ f state (n state %bat q:(transfer-point:l2 0 ~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &)) - =^ f state (n state %bat q:(escape:l2 0 ~linnup-torsyx %lt-key-0 %own ~sambud)) + :: why is the nonce for the escape still 0? + =^ f state (n state %bat q:(escape:l2 0 ~linnup-torsyx %lt-key-0 %own ~litbud)) escape.net:(~(got by points.state) ~linnup-torsyx) :: +++ test-linnup-torsyx-l2-cancel-escape-request ^- tang + %+ expect-eq + !> ~ + :: + !> + =| =^state:naive + =^ f state (init-marbud state) + =^ f state (init-litbud state) + =^ f state (n state %bat q:(spawn:l2 0 ~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0))) + =^ f state (n state %bat q:(transfer-point:l2 0 ~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &)) + =^ f state (n state %bat q:(escape:l2 0 ~linnup-torsyx %lt-key-0 %own ~litbud)) + =^ f state (n state %bat q:(cancel-escape:l2 1 ~linnup-torsyx %lt-key-0 %own ~litbud)) + escape.net:(~(got by points.state) ~linnup-torsyx) +:: +++ test-linnup-torsyx-l2-adopt-accept + %+ expect-eq + !> [~ %.y ~litbud] + :: + !> + =| =^state:naive + =^ f state (init-marbud state) + =^ f state (init-litbud state) + =^ f state (n state %bat q:(spawn:l2 0 ~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0))) + =^ f state (n state %bat q:(transfer-point:l2 0 ~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &)) + =^ f state (n state %bat q:(escape:l2 0 ~linnup-torsyx %lt-key-0 %own ~litbud)) + =^ f state (n state %bat q:(adopt:l2 0 ~litbud %litbud-key-0 %own ~linnup-torsyx)) + [escape.net sponsor.net]:(~(got by points.state) ~linnup-torsyx) +:: +++ test-linnup-torsyx-l2-adopt-reject + :: TODO: at the moment the default sponsor is always ~zod, but it should probably + :: be ~marbud here + %+ expect-eq + !> ~ + :: + !> + =| =^state:naive + =^ f state (init-marbud state) + =^ f state (init-litbud state) + =^ f state (n state %bat q:(spawn:l2 0 ~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0))) + =^ f state (n state %bat q:(transfer-point:l2 0 ~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &)) + =^ f state (n state %bat q:(escape:l2 0 ~linnup-torsyx %lt-key-0 %own ~litbud)) + =^ f state (n state %bat q:(reject:l2 0 ~litbud %litbud-key-0 %own ~linnup-torsyx)) + escape.net:(~(got by points.state) ~linnup-torsyx) +:: +++ test-linnup-torsyx-l2-detach + %+ expect-eq + !> [~ %.n ~marbud] + :: + !> + =| =^state:naive + =^ f state (init-marbud state) + =^ f state (init-litbud state) + =^ f state (n state %bat q:(spawn:l2 0 ~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0))) + =^ f state (n state %bat q:(transfer-point:l2 0 ~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &)) + =^ f state (n state %bat q:(detach:l2 1 ~marbud %marbud-key-0 %own ~linnup-torsyx)) + [escape.net sponsor.net]:(~(got by points.state) ~linnup-torsyx) +:: :: TODO: signature format changed; regenerate :: :: ++ test-metamask-signature ^- tang From f395a7668ddeb89109ff16fb54b7bf425af57340 Mon Sep 17 00:00:00 2001 From: drbeefsupreme Date: Tue, 4 May 2021 14:11:19 -0400 Subject: [PATCH 11/39] naive: missing tangs --- pkg/arvo/tests/lib/naive.hoon | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/arvo/tests/lib/naive.hoon b/pkg/arvo/tests/lib/naive.hoon index 75248543c..1c271c24b 100644 --- a/pkg/arvo/tests/lib/naive.hoon +++ b/pkg/arvo/tests/lib/naive.hoon @@ -772,7 +772,7 @@ =^ f state (n state %bat q:(cancel-escape:l2 1 ~linnup-torsyx %lt-key-0 %own ~litbud)) escape.net:(~(got by points.state) ~linnup-torsyx) :: -++ test-linnup-torsyx-l2-adopt-accept +++ test-linnup-torsyx-l2-adopt-accept ^- tang %+ expect-eq !> [~ %.y ~litbud] :: @@ -786,7 +786,7 @@ =^ f state (n state %bat q:(adopt:l2 0 ~litbud %litbud-key-0 %own ~linnup-torsyx)) [escape.net sponsor.net]:(~(got by points.state) ~linnup-torsyx) :: -++ test-linnup-torsyx-l2-adopt-reject +++ test-linnup-torsyx-l2-adopt-reject ^- tang :: TODO: at the moment the default sponsor is always ~zod, but it should probably :: be ~marbud here %+ expect-eq @@ -802,7 +802,7 @@ =^ f state (n state %bat q:(reject:l2 0 ~litbud %litbud-key-0 %own ~linnup-torsyx)) escape.net:(~(got by points.state) ~linnup-torsyx) :: -++ test-linnup-torsyx-l2-detach +++ test-linnup-torsyx-l2-detach ^- tang %+ expect-eq !> [~ %.n ~marbud] :: From 2189a54ae9e30e882482f11a9d488be7970b5c26 Mon Sep 17 00:00:00 2001 From: drbeefsupreme Date: Wed, 5 May 2021 22:55:15 -0400 Subject: [PATCH 12/39] naive: dumb way to make tests more readable --- pkg/arvo/tests/lib/naive.hoon | 132 ++++++++++++++++++++++------------ 1 file changed, 88 insertions(+), 44 deletions(-) diff --git a/pkg/arvo/tests/lib/naive.hoon b/pkg/arvo/tests/lib/naive.hoon index 1c271c24b..5c31266fc 100644 --- a/pkg/arvo/tests/lib/naive.hoon +++ b/pkg/arvo/tests/lib/naive.hoon @@ -419,33 +419,36 @@ |1:keys.net:(~(got by points.state) ~bud) :: ++ test-l2-set-spawn-proxy ^- tang + =/ marbud-sproxy [~marbud %marbud-key-0 %own (addr %marbud-skey)] %+ expect-eq - !> [0x123 0] + !> [(addr %marbud-skey) 0] :: !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(set-spawn-proxy:l2 0 ~marbud %marbud-key-0 %own 0x123)) + =^ f state (n state %bat q:(set-spawn-proxy:l2 0 marbud-sproxy)) spawn-proxy.own:(~(got by points.state) ~marbud) :: ++ test-l2-set-transfer-proxy ^- tang + =/ marbud-tproxy [~marbud %marbud-key-0 %own (addr %marbud-tkey)] %+ expect-eq - !> [0x123 0] + !> [(addr %marbud-tkey) 0] :: !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(set-transfer-proxy:l2 0 ~marbud %marbud-key-0 %own 0x123)) + =^ f state (n state %bat q:(set-transfer-proxy:l2 0 marbud-tproxy)) transfer-proxy.own:(~(got by points.state) ~marbud) :: ++ test-l2-set-management-proxy ^- tang + =/ marbud-mproxy [~marbud %marbud-key-0 %own (addr %marbud-mkey)] %+ expect-eq - !> [0x123 0] + !> [(addr %marbud-mkey) 0] :: !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(set-management-proxy:l2 0 ~marbud %marbud-key-0 %own 0x123)) + =^ f state (n state %bat q:(set-management-proxy:l2 0 marbud-mproxy)) management-proxy.own:(~(got by points.state) ~marbud) :: ++ test-l2-spawn-proxy-deposit ^- tang @@ -458,30 +461,47 @@ dominion:(~(got by points.state) ~dopbud) :: ++ test-marbud-l2-spawn ^- tang + =/ lt-ospawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %ll-key-0)] %+ expect-eq !> [`@ux`(addr %ll-key-0) 0] :: !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(spawn:l2 0 ~marbud %marbud-key-0 %own ~linnup-torsyx (addr %ll-key-0))) + =^ f state (n state %bat q:(spawn:l2 0 lt-ospawn)) transfer-proxy.own:(~(got by points.state) ~linnup-torsyx) :: ++ test-marbud-l2-spawn-w-proxy ^- tang + =/ marbud-sproxy [~marbud %marbud-key-0 %own (addr %marbud-skey)] + =/ lt-ospawn [~marbud %marbud-skey %spawn ~linnup-torsyx (addr %lt-key-0)] %+ expect-eq - !> [`@ux`(addr %ll-key-0) 0] + !> [`@ux`(addr %lt-key-0) 0] :: !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(set-spawn-proxy:l2 0 ~marbud %marbud-key-0 %own (addr %marbud-spn))) - =^ f state (n state %bat q:(spawn:l2 0 ~marbud %marbud-spn %spawn ~linnup-torsyx (addr %ll-key-0))) + =^ f state (n state %bat q:(set-spawn-proxy:l2 0 marbud-sproxy)) + =^ f state (n state %bat q:(spawn:l2 0 lt-ospawn)) transfer-proxy.own:(~(got by points.state) ~linnup-torsyx) :: +++ test-marbud-l2-double-spawn ^- tang + :: Attempts to spawn the same planet twice, once with ownership and once with spawn proxy + =/ marbud-sproxy [~marbud %marbud-key-0 %own (addr %marbud-skey)] + =/ lt-ospawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] + =/ lt-sspawn [~marbud %marbud-skey %spawn ~linnup-torsyx (addr %lt-key-1)] + %- expect-fail + |. + =| =^state:naive + =^ f state (init-marbud state) + =^ f state (n state %bat q:(set-spawn-proxy:l2 0 marbud-sproxy)) + =^ f state (n state %bat q:(spawn:l2 1 lt-ospawn)) + =^ f state (n state %bat q:(spawn:l2 0 lt-sspawn)) + state +:: ++ test-marbud-l2-change-keys - =/ new-keys-own [~marbud %marbud-key-0 %own | encr auth suit] - =/ new-keys-mgt [~marbud %marbud-mgt %manage | encr auth suit] - =/ mgt-proxy [~marbud %marbud-key-0 %own (addr %marbud-mgt)] + =/ new-keys-own [~marbud %marbud-key-0 %own | encr auth suit] + =/ new-keys-mgt [~marbud %marbud-mkey %manage | encr auth suit] + =/ marbud-mproxy [~marbud %marbud-key-0 %own (addr %marbud-mkey)] ;: weld %+ expect-eq !> [suit auth encr] @@ -498,7 +518,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(set-management-proxy:l2 0 mgt-proxy)) + =^ f state (n state %bat q:(set-management-proxy:l2 0 marbud-mproxy)) =^ f state (n state %bat q:(configure-keys:l2 0 new-keys-mgt)) |1:keys.net:(~(got by points.state) ~marbud) :: @@ -507,10 +527,15 @@ :: :: TODO: transfer breach via transfer proxy ++ test-marbud-l2-transfer-breach ^- tang - =/ new-keys [~marbud %marbud-key-0 %own | encr auth suit] + =/ new-keys [~marbud %marbud-key-0 %own | encr auth suit] + =/ marbud-sproxy [~marbud %marbud-key-0 %own (addr %marbud-skey)] + =/ marbud-mproxy [~marbud %marbud-key-0 %own (addr %marbud-mkey)] + =/ marbud-tproxy [~marbud %marbud-key-0 %own (addr %marbud-key-1)] + =/ marbud-transfer-breach [~marbud %marbud-key-1 (addr %marbud-key-1) %transfer &] ;: weld %+ expect-eq :: Tests that proxies are reset on transfer breach + :: !> :* [(addr %marbud-key-1) 3] :: ownership [0 0] :: spawn-proxy @@ -522,10 +547,10 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(set-spawn-proxy:l2 0 ~marbud %marbud-key-0 %own 0x123)) - =^ f state (n state %bat q:(set-management-proxy:l2 1 ~marbud %marbud-key-0 %own 0x234)) - =^ f state (n state %bat q:(set-transfer-proxy:l2 2 ~marbud %marbud-key-0 %own (addr %marbud-key-1))) - =^ f state (n state %bat q:(transfer-point:l2 0 ~marbud %marbud-key-1 (addr %marbud-key-1) %transfer &)) + =^ f state (n state %bat q:(set-spawn-proxy:l2 0 marbud-sproxy)) + =^ f state (n state %bat q:(set-management-proxy:l2 1 marbud-mproxy)) + =^ f state (n state %bat q:(set-transfer-proxy:l2 2 marbud-tproxy)) + =^ f state (n state %bat q:(transfer-point:l2 0 marbud-transfer-breach)) ^- [[@ @] [@ @] [@ @] [@ @] [@ @]] own:(~(got by points.state) ~marbud) :: @@ -624,10 +649,13 @@ == :: ++ test-marbud-transfer-life-rift ^- tang - =/ new-keys-no-reset [~marbud %marbud-key-0 %own | encr auth suit] - =/ new-keys-yes-reset [~marbud %marbud-key-0 %own & encr auth suit] - =/ zero-keys-no-reset [~marbud %marbud-key-0 %own | 0 0 0] - =/ zero-keys-yes-reset [~marbud %marbud-key-0 %own & 0 0 0] + =/ new-keys-no-reset [~marbud %marbud-key-0 %own | encr auth suit] + =/ new-keys-yes-reset [~marbud %marbud-key-0 %own & encr auth suit] + =/ zero-keys-no-reset [~marbud %marbud-key-0 %own | 0 0 0] + =/ zero-keys-yes-reset [~marbud %marbud-key-0 %own & 0 0 0] + =/ marbud-transfer-no-breach [~marbud %marbud-key-0 (addr %marbud-key-1) %own |] + =/ marbud-transfer-yes-breach [~marbud %marbud-key-0 (addr %marbud-key-1) %own &] + :: ;: weld %+ expect-eq :: networking keys not set, reset=%.n @@ -637,7 +665,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(transfer-point:l2 0 ~marbud %marbud-key-0 (addr %marbud-key-1) %own |)) + =^ f state (n state %bat q:(transfer-point:l2 0 marbud-transfer-no-breach)) [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: %+ expect-eq @@ -648,7 +676,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(transfer-point:l2 0 ~marbud %marbud-key-0 (addr %marbud-key-1) %own &)) + =^ f state (n state %bat q:(transfer-point:l2 0 marbud-transfer-no-breach)) [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: %+ expect-eq @@ -664,31 +692,34 @@ =^ f state (init-marbud state) =^ f state (n state %bat q:(configure-keys:l2 0 new-keys-yes-reset)) :: inc life and rift =^ f state (n state %bat q:(configure-keys:l2 1 zero-keys-no-reset)) :: inc life - =^ f state (n state %bat q:(transfer-point:l2 2 ~marbud %marbud-key-0 (addr %marbud-key-1) %own &)) :: inc rift + =^ f state (n state %bat q:(transfer-point:l2 2 marbud-transfer-yes-breach)) :: inc rift [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: == :: ++ test-dopbud-l2-spawn ^- tang + =/ pp-spawn [~dopbud %dopbud-key-0 %own ~palsep-picdun (addr %pp-key-0)] %+ expect-eq !> [`@ux`(addr %pp-key-0) 0] :: !> =| =^state:naive =^ f state (init-dopbud state) - =^ f state (n state %bat q:(spawn:l2 0 ~dopbud %dopbud-key-0 %own ~palsep-picdun (addr %pp-key-0))) + =^ f state (n state %bat q:(spawn:l2 0 pp-spawn)) transfer-proxy.own:(~(got by points.state) ~palsep-picdun) :: ++ test-dopbud-l2-spawn-after-transfer ^- tang + =/ pp-spawn [~dopbud %dopbud-key-0 %own ~palsep-picdun (addr %pp-key-0)] + =/ lr-spawn [~dopbud %dopbud-key-1 %own ~laclur-rachul (addr %lr-key-0)] %+ expect-eq !> [`@ux`(addr %lr-key-0) 0] :: !> =| =^state:naive =^ f state (init-dopbud state) - =^ f state (n state %bat q:(spawn:l2 0 ~dopbud %dopbud-key-0 %own ~palsep-picdun (addr %pp-key-0))) + =^ f state (n state %bat q:(spawn:l2 0 pp-spawn)) =^ f state (n state (owner-changed:l1 ~dopbud (addr %dopbud-key-1))) - =^ f state (n state %bat q:(spawn:l2 1 ~dopbud %dopbud-key-1 %own ~laclur-rachul (addr %lr-key-0))) + =^ f state (n state %bat q:(spawn:l2 1 lr-spawn)) transfer-proxy.own:(~(got by points.state) ~laclur-rachul) :: :: ++ test-sambud-double-spawn ^- tang @@ -722,29 +753,35 @@ :: state :: ++ test-linnup-torsyx-l2-transfer-ownership ^- tang + =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] + =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &] %+ expect-eq !> [`@ux`(addr %lt-key-0) 0] :: !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(spawn:l2 0 ~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0))) - =^ f state (n state %bat q:(transfer-point:l2 0 ~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &)) + =^ f state (n state %bat q:(spawn:l2 0 lt-spawn)) + =^ f state (n state %bat q:(transfer-point:l2 0 lt-transfer-yes-breach)) owner.own:(~(got by points.state) ~linnup-torsyx) :: ++ test-palsep-picdun-l2-transfer-ownership ^- tang + =/ pp-spawn [~dopbud %dopbud-key-0 %own ~palsep-picdun (addr %pp-key-0)] + =/ pp-transfer-yes-breach [~palsep-picdun %pp-key-0 (addr %pp-key-0) %transfer &] %+ expect-eq !> [`@ux`(addr %pp-key-0) 0] :: !> =| =^state:naive =^ f state (init-dopbud state) - =^ f state (n state %bat q:(spawn:l2 0 ~dopbud %dopbud-key-0 %own ~palsep-picdun (addr %pp-key-0))) - =^ f state (n state %bat q:(transfer-point:l2 0 ~palsep-picdun %pp-key-0 (addr %pp-key-0) %transfer &)) + =^ f state (n state %bat q:(spawn:l2 0 pp-spawn)) + =^ f state (n state %bat q:(transfer-point:l2 0 pp-transfer-yes-breach)) owner.own:(~(got by points.state) ~palsep-picdun) :: ++ test-linnup-torsyx-l2-escape-request ^- tang :: TODO: Are you supposed to be able to request escape to a non-existent star? + =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] + =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &] %+ expect-eq !> [~ ~litbud] :: @@ -752,13 +789,14 @@ =| =^state:naive =^ f state (init-marbud state) =^ f state (init-litbud state) - =^ f state (n state %bat q:(spawn:l2 0 ~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0))) - =^ f state (n state %bat q:(transfer-point:l2 0 ~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &)) - :: why is the nonce for the escape still 0? + =^ f state (n state %bat q:(spawn:l2 0 lt-spawn)) + =^ f state (n state %bat q:(transfer-point:l2 0 lt-transfer-yes-breach)) =^ f state (n state %bat q:(escape:l2 0 ~linnup-torsyx %lt-key-0 %own ~litbud)) escape.net:(~(got by points.state) ~linnup-torsyx) :: ++ test-linnup-torsyx-l2-cancel-escape-request ^- tang + =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] + =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &] %+ expect-eq !> ~ :: @@ -766,13 +804,15 @@ =| =^state:naive =^ f state (init-marbud state) =^ f state (init-litbud state) - =^ f state (n state %bat q:(spawn:l2 0 ~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0))) - =^ f state (n state %bat q:(transfer-point:l2 0 ~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &)) + =^ f state (n state %bat q:(spawn:l2 0 lt-spawn)) + =^ f state (n state %bat q:(transfer-point:l2 0 lt-transfer-yes-breach)) =^ f state (n state %bat q:(escape:l2 0 ~linnup-torsyx %lt-key-0 %own ~litbud)) =^ f state (n state %bat q:(cancel-escape:l2 1 ~linnup-torsyx %lt-key-0 %own ~litbud)) escape.net:(~(got by points.state) ~linnup-torsyx) :: ++ test-linnup-torsyx-l2-adopt-accept ^- tang + =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] + =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &] %+ expect-eq !> [~ %.y ~litbud] :: @@ -780,8 +820,8 @@ =| =^state:naive =^ f state (init-marbud state) =^ f state (init-litbud state) - =^ f state (n state %bat q:(spawn:l2 0 ~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0))) - =^ f state (n state %bat q:(transfer-point:l2 0 ~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &)) + =^ f state (n state %bat q:(spawn:l2 0 lt-spawn)) + =^ f state (n state %bat q:(transfer-point:l2 0 lt-transfer-yes-breach)) =^ f state (n state %bat q:(escape:l2 0 ~linnup-torsyx %lt-key-0 %own ~litbud)) =^ f state (n state %bat q:(adopt:l2 0 ~litbud %litbud-key-0 %own ~linnup-torsyx)) [escape.net sponsor.net]:(~(got by points.state) ~linnup-torsyx) @@ -789,6 +829,8 @@ ++ test-linnup-torsyx-l2-adopt-reject ^- tang :: TODO: at the moment the default sponsor is always ~zod, but it should probably :: be ~marbud here + =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] + =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &] %+ expect-eq !> ~ :: @@ -796,13 +838,15 @@ =| =^state:naive =^ f state (init-marbud state) =^ f state (init-litbud state) - =^ f state (n state %bat q:(spawn:l2 0 ~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0))) - =^ f state (n state %bat q:(transfer-point:l2 0 ~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &)) + =^ f state (n state %bat q:(spawn:l2 0 lt-spawn)) + =^ f state (n state %bat q:(transfer-point:l2 0 lt-transfer-yes-breach)) =^ f state (n state %bat q:(escape:l2 0 ~linnup-torsyx %lt-key-0 %own ~litbud)) =^ f state (n state %bat q:(reject:l2 0 ~litbud %litbud-key-0 %own ~linnup-torsyx)) escape.net:(~(got by points.state) ~linnup-torsyx) :: ++ test-linnup-torsyx-l2-detach ^- tang + =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] + =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &] %+ expect-eq !> [~ %.n ~marbud] :: @@ -810,8 +854,8 @@ =| =^state:naive =^ f state (init-marbud state) =^ f state (init-litbud state) - =^ f state (n state %bat q:(spawn:l2 0 ~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0))) - =^ f state (n state %bat q:(transfer-point:l2 0 ~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &)) + =^ f state (n state %bat q:(spawn:l2 0 lt-spawn)) + =^ f state (n state %bat q:(transfer-point:l2 0 lt-transfer-yes-breach)) =^ f state (n state %bat q:(detach:l2 1 ~marbud %marbud-key-0 %own ~linnup-torsyx)) [escape.net sponsor.net]:(~(got by points.state) ~linnup-torsyx) :: From 8c3ee149cb413eb0baec65d25d21e277785898ba Mon Sep 17 00:00:00 2001 From: drbeefsupreme Date: Wed, 5 May 2021 23:25:34 -0400 Subject: [PATCH 13/39] naive: l1 sponsorship tests --- pkg/arvo/tests/lib/naive.hoon | 150 +++++++++++++++++++++++++++++++--- 1 file changed, 137 insertions(+), 13 deletions(-) diff --git a/pkg/arvo/tests/lib/naive.hoon b/pkg/arvo/tests/lib/naive.hoon index 5c31266fc..d36433c75 100644 --- a/pkg/arvo/tests/lib/naive.hoon +++ b/pkg/arvo/tests/lib/naive.hoon @@ -32,7 +32,14 @@ ++ init-bud |= =^state:naive ^- [effects:naive ^state:naive] - (n state (owner-changed:l1 ~bud (addr ~bud))) + (n state (owner-changed:l1 ~bud (addr %bud-key-0))) +:: +:: ~wes is for testing sponsors of stars +:: +++ init-wes + |= =^state:naive + ^- [effects:naive ^state:naive] + (n state (owner-changed:l1 ~wes (addr %wes-key-0))) :: :: ~dopbud is for testing L1 ownership with L2 spawn proxy :: @@ -65,7 +72,7 @@ =^ f3 state (n state (owner-changed:l1 ~litbud deposit-address:naive)) [:(welp f2 f3) state] :: -:: ~sambud is for testing L1 stars attempting L2 actions +:: ~sambud is for testing L1 stars :: ++ init-sambud |= =^state:naive @@ -356,54 +363,56 @@ dominion:(~(got by points.state) ~marbud) :: ++ test-batch ^- tang + =/ marbud-transfer-no-breach [~marbud %marbud-key-0 (addr %marbud-key-0) %own |] + =/ marbud-transfer-no-breach-2 [~marbud %marbud-key-0 (addr %marbud-key-1) %own |] %+ expect-eq - !> [0x234 2] + !> [(addr %marbud-key-1) 2] :: !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(transfer-point:l2 0 ~marbud %marbud-key-0 (addr %marbud-key-0) %own |)) - =^ f state (n state %bat q:(transfer-point:l2 1 ~marbud %marbud-key-0 0x234 %own |)) + =^ f state (n state %bat q:(transfer-point:l2 0 marbud-transfer-no-breach)) + =^ f state (n state %bat q:(transfer-point:l2 1 marbud-transfer-no-breach-2)) owner.own:(~(got by points.state) ~marbud) :: ++ test-l1-changed-spawn-proxy ^- tang %+ expect-eq - !> [0x123 0] + !> [(addr %bud-skey) 0] :: !> =| =^state:naive =^ f state (init-bud state) - =^ f state (n state (changed-spawn-proxy:l1 ~bud 0x123)) + =^ f state (n state (changed-spawn-proxy:l1 ~bud (addr %bud-skey))) spawn-proxy.own:(~(got by points.state) ~bud) :: ++ test-l1-changed-transfer-proxy ^- tang %+ expect-eq - !> [0x123 0] + !> [(addr %bud-tkey) 0] :: !> =| =^state:naive =^ f state (init-bud state) - =^ f state (n state (changed-transfer-proxy:l1 ~bud 0x123)) + =^ f state (n state (changed-transfer-proxy:l1 ~bud (addr %bud-tkey))) transfer-proxy.own:(~(got by points.state) ~bud) :: ++ test-l1-changed-management-proxy ^- tang %+ expect-eq - !> [0x123 0] + !> [(addr %bud-mkey) 0] :: !> =| =^state:naive =^ f state (init-bud state) - =^ f state (n state (changed-management-proxy:l1 ~bud 0x123)) + =^ f state (n state (changed-management-proxy:l1 ~bud (addr %bud-mkey))) management-proxy.own:(~(got by points.state) ~bud) :: ++ test-l1-changed-voting-proxy ^- tang %+ expect-eq - !> [0x123 0] + !> [(addr %bud-vkey) 0] :: !> =| =^state:naive =^ f state (init-bud state) - =^ f state (n state (changed-voting-proxy:l1 ~bud 0x123)) + =^ f state (n state (changed-voting-proxy:l1 ~bud (addr %bud-vkey))) voting-proxy.own:(~(got by points.state) ~bud) :: ++ test-l1-changed-keys ^- tang @@ -418,6 +427,121 @@ =^ f state (n state (changed-keys:l1 new-keys)) |1:keys.net:(~(got by points.state) ~bud) :: +++ test-l1-star-escape-requested + %+ expect-eq + !> [~ ~wes] + :: + !> + =| =^state:naive + =^ f state (init-wes state) + =^ f state (init-sambud state) + =^ f state (n state (escape-requested:l1 ~sambud ~wes)) + escape.net:(~(got by points.state) ~sambud) +:: +++ test-l1-star-escape-canceled + %+ expect-eq + !> ~ + :: + !> + =| =^state:naive + =^ f state (init-wes state) + =^ f state (init-sambud state) + =^ f state (n state (escape-requested:l1 ~sambud ~wes)) + =^ f state (n state (escape-canceled:l1 ~sambud ~wes)) + escape.net:(~(got by points.state) ~sambud) +:: +++ test-l1-star-adopt-accept + %+ expect-eq + !> [~ %.y ~wes] + :: + !> + =| =^state:naive + =^ f state (init-wes state) + =^ f state (init-sambud state) + =^ f state (n state (escape-requested:l1 ~sambud ~wes)) + =^ f state (n state (escape-accepted:l1 ~sambud ~wes)) + [escape.net sponsor.net]:(~(got by points.state) ~sambud) +:: +++ test-l1-star-lost-sponsor + %+ expect-eq + !> [~ %.n ~bud] + :: + !> + =| =^state:naive + =^ f state (init-sambud state) + =^ f state (n state (lost-sponsor:l1 ~sambud ~bud)) + [escape.net sponsor.net]:(~(got by points.state) ~sambud) +:: +:: +:: +:: ++ test-linnup-torsyx-l2-adopt-accept ^- tang +:: =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] +:: =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &] +:: %+ expect-eq +:: !> [~ %.y ~litbud] +:: :: +:: !> +:: =| =^state:naive +:: =^ f state (init-marbud state) +:: =^ f state (init-litbud state) +:: =^ f state (n state %bat q:(spawn:l2 0 lt-spawn)) +:: =^ f state (n state %bat q:(transfer-point:l2 0 lt-transfer-yes-breach)) +:: =^ f state (n state %bat q:(escape:l2 0 ~linnup-torsyx %lt-key-0 %own ~litbud)) +:: =^ f state (n state %bat q:(adopt:l2 0 ~litbud %litbud-key-0 %own ~linnup-torsyx)) +:: [escape.net sponsor.net]:(~(got by points.state) ~linnup-torsyx) +:: :: +:: ++ test-linnup-torsyx-l2-adopt-reject ^- tang +:: :: TODO: at the moment the default sponsor is always ~zod, but it should probably +:: :: be ~marbud here +:: =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] +:: =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &] +:: %+ expect-eq +:: !> ~ +:: :: +:: !> +:: =| =^state:naive +:: =^ f state (init-marbud state) +:: =^ f state (init-litbud state) +:: =^ f state (n state %bat q:(spawn:l2 0 lt-spawn)) +:: =^ f state (n state %bat q:(transfer-point:l2 0 lt-transfer-yes-breach)) +:: =^ f state (n state %bat q:(escape:l2 0 ~linnup-torsyx %lt-key-0 %own ~litbud)) +:: =^ f state (n state %bat q:(reject:l2 0 ~litbud %litbud-key-0 %own ~linnup-torsyx)) +:: escape.net:(~(got by points.state) ~linnup-torsyx) +:: :: +:: ++ test-linnup-torsyx-l2-detach ^- tang +:: =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] +:: =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &] +:: %+ expect-eq +:: !> [~ %.n ~marbud] +:: :: +:: !> +:: =| =^state:naive +:: =^ f state (init-marbud state) +:: =^ f state (init-litbud state) +:: =^ f state (n state %bat q:(spawn:l2 0 lt-spawn)) +:: =^ f state (n state %bat q:(transfer-point:l2 0 lt-transfer-yes-breach)) +:: =^ f state (n state %bat q:(detach:l2 1 ~marbud %marbud-key-0 %own ~linnup-torsyx)) +:: [escape.net sponsor.net]:(~(got by points.state) ~linnup-torsyx) +:: :: +:: : +:: +:: :: ++ escape-requested +:: |= [escapee=ship parent=ship] +:: (log escape-requested:log-names:naive *@ux escapee parent ~) +:: :: +:: ++ escape-canceled +:: :: The parent is pinned but not used in lib/naive.hoon for some reason +:: |= [escapee=ship parent=ship] +:: (log escape-canceled:log-names:naive *@ux escapee parent ~) +:: :: +:: ++ escape-accepted +:: |= [escapee=ship parent=ship] +:: (log escape-accepted:log-names:naive *@ux escapee parent ~) +:: :: +:: ++ lost-sponsor +:: |= [lost=ship parent=ship] +:: (log lost-sponsor:log-names:naive *@ux lost parent ~) +:: ++ test-l2-set-spawn-proxy ^- tang =/ marbud-sproxy [~marbud %marbud-key-0 %own (addr %marbud-skey)] %+ expect-eq From 2c445fe49548820bbcfbbff6bd41c90333b04f7a Mon Sep 17 00:00:00 2001 From: drbeefsupreme Date: Thu, 6 May 2021 00:54:13 -0400 Subject: [PATCH 14/39] naive: more test standardization --- pkg/arvo/tests/lib/naive.hoon | 158 ++++++++++++---------------------- 1 file changed, 56 insertions(+), 102 deletions(-) diff --git a/pkg/arvo/tests/lib/naive.hoon b/pkg/arvo/tests/lib/naive.hoon index d36433c75..17f8f67be 100644 --- a/pkg/arvo/tests/lib/naive.hoon +++ b/pkg/arvo/tests/lib/naive.hoon @@ -209,7 +209,7 @@ :: ++ configure-keys |= $: nonce=@ud =ship pk=@ proxy=@tas - breach=? encrypt=@ auth=@ crypto-suite=@ + encrypt=@ auth=@ crypto-suite=@ breach=? == ^- octs %^ sign-tx pk nonce @@ -342,15 +342,15 @@ ++ test-log ^- tang %+ expect-eq !> - :- [%point ~bud %owner 0x123]~ + :- [%point ~bud %owner (addr %bud-key-0)]~ :_ [~ ~] :_ [~ ~] :- ~bud - %*(. *point:naive dominion %l1, owner.own 0x123^0, who.sponsor.net ~bud) + %*(. *point:naive dominion %l1, owner.own (addr %bud-key-0)^0, who.sponsor.net ~bud) :: !> %^ naive verifier 1.337 :- *^state:naive :* %log *@ux *@ux - owner-changed:log-names:naive (@ux ~bud) 0x123 ~ + owner-changed:log-names:naive (@ux ~bud) (addr %bud-key-0) ~ == :: ++ test-deposit ^- tang @@ -363,16 +363,17 @@ dominion:(~(got by points.state) ~marbud) :: ++ test-batch ^- tang - =/ marbud-transfer-no-breach [~marbud %marbud-key-0 (addr %marbud-key-0) %own |] - =/ marbud-transfer-no-breach-2 [~marbud %marbud-key-0 (addr %marbud-key-1) %own |] + =/ marbud-transfer [~marbud %marbud-key-0 (addr %marbud-key-0) %own |] + =/ marbud-transfer-2 [~marbud %marbud-key-0 (addr %marbud-key-1) %own |] + :: %+ expect-eq !> [(addr %marbud-key-1) 2] :: !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(transfer-point:l2 0 marbud-transfer-no-breach)) - =^ f state (n state %bat q:(transfer-point:l2 1 marbud-transfer-no-breach-2)) + =^ f state (n state %bat q:(transfer-point:l2 0 marbud-transfer)) + =^ f state (n state %bat q:(transfer-point:l2 1 marbud-transfer-2)) owner.own:(~(got by points.state) ~marbud) :: ++ test-l1-changed-spawn-proxy ^- tang @@ -387,12 +388,12 @@ :: ++ test-l1-changed-transfer-proxy ^- tang %+ expect-eq - !> [(addr %bud-tkey) 0] + !> [(addr %bud-key-1) 0] :: !> =| =^state:naive =^ f state (init-bud state) - =^ f state (n state (changed-transfer-proxy:l1 ~bud (addr %bud-tkey))) + =^ f state (n state (changed-transfer-proxy:l1 ~bud (addr %bud-key-1))) transfer-proxy.own:(~(got by points.state) ~bud) :: ++ test-l1-changed-management-proxy ^- tang @@ -418,6 +419,7 @@ ++ test-l1-changed-keys ^- tang =/ life 1 =/ new-keys [~bud encr auth suit life] + :: %+ expect-eq !> [suit auth encr] :: @@ -427,7 +429,7 @@ =^ f state (n state (changed-keys:l1 new-keys)) |1:keys.net:(~(got by points.state) ~bud) :: -++ test-l1-star-escape-requested +++ test-l1-star-escape-requested ^- tang %+ expect-eq !> [~ ~wes] :: @@ -438,7 +440,7 @@ =^ f state (n state (escape-requested:l1 ~sambud ~wes)) escape.net:(~(got by points.state) ~sambud) :: -++ test-l1-star-escape-canceled +++ test-l1-star-escape-canceled ^- tang %+ expect-eq !> ~ :: @@ -450,7 +452,7 @@ =^ f state (n state (escape-canceled:l1 ~sambud ~wes)) escape.net:(~(got by points.state) ~sambud) :: -++ test-l1-star-adopt-accept +++ test-l1-star-adopt-accept ^- tang %+ expect-eq !> [~ %.y ~wes] :: @@ -462,7 +464,7 @@ =^ f state (n state (escape-accepted:l1 ~sambud ~wes)) [escape.net sponsor.net]:(~(got by points.state) ~sambud) :: -++ test-l1-star-lost-sponsor +++ test-l1-star-lost-sponsor ^- tang %+ expect-eq !> [~ %.n ~bud] :: @@ -472,78 +474,11 @@ =^ f state (n state (lost-sponsor:l1 ~sambud ~bud)) [escape.net sponsor.net]:(~(got by points.state) ~sambud) :: -:: -:: -:: ++ test-linnup-torsyx-l2-adopt-accept ^- tang -:: =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] -:: =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &] -:: %+ expect-eq -:: !> [~ %.y ~litbud] -:: :: -:: !> -:: =| =^state:naive -:: =^ f state (init-marbud state) -:: =^ f state (init-litbud state) -:: =^ f state (n state %bat q:(spawn:l2 0 lt-spawn)) -:: =^ f state (n state %bat q:(transfer-point:l2 0 lt-transfer-yes-breach)) -:: =^ f state (n state %bat q:(escape:l2 0 ~linnup-torsyx %lt-key-0 %own ~litbud)) -:: =^ f state (n state %bat q:(adopt:l2 0 ~litbud %litbud-key-0 %own ~linnup-torsyx)) -:: [escape.net sponsor.net]:(~(got by points.state) ~linnup-torsyx) -:: :: -:: ++ test-linnup-torsyx-l2-adopt-reject ^- tang -:: :: TODO: at the moment the default sponsor is always ~zod, but it should probably -:: :: be ~marbud here -:: =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] -:: =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &] -:: %+ expect-eq -:: !> ~ -:: :: -:: !> -:: =| =^state:naive -:: =^ f state (init-marbud state) -:: =^ f state (init-litbud state) -:: =^ f state (n state %bat q:(spawn:l2 0 lt-spawn)) -:: =^ f state (n state %bat q:(transfer-point:l2 0 lt-transfer-yes-breach)) -:: =^ f state (n state %bat q:(escape:l2 0 ~linnup-torsyx %lt-key-0 %own ~litbud)) -:: =^ f state (n state %bat q:(reject:l2 0 ~litbud %litbud-key-0 %own ~linnup-torsyx)) -:: escape.net:(~(got by points.state) ~linnup-torsyx) -:: :: -:: ++ test-linnup-torsyx-l2-detach ^- tang -:: =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] -:: =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &] -:: %+ expect-eq -:: !> [~ %.n ~marbud] -:: :: -:: !> -:: =| =^state:naive -:: =^ f state (init-marbud state) -:: =^ f state (init-litbud state) -:: =^ f state (n state %bat q:(spawn:l2 0 lt-spawn)) -:: =^ f state (n state %bat q:(transfer-point:l2 0 lt-transfer-yes-breach)) -:: =^ f state (n state %bat q:(detach:l2 1 ~marbud %marbud-key-0 %own ~linnup-torsyx)) -:: [escape.net sponsor.net]:(~(got by points.state) ~linnup-torsyx) -:: :: -:: : -:: -:: :: ++ escape-requested -:: |= [escapee=ship parent=ship] -:: (log escape-requested:log-names:naive *@ux escapee parent ~) -:: :: -:: ++ escape-canceled -:: :: The parent is pinned but not used in lib/naive.hoon for some reason -:: |= [escapee=ship parent=ship] -:: (log escape-canceled:log-names:naive *@ux escapee parent ~) -:: :: -:: ++ escape-accepted -:: |= [escapee=ship parent=ship] -:: (log escape-accepted:log-names:naive *@ux escapee parent ~) -:: :: -:: ++ lost-sponsor -:: |= [lost=ship parent=ship] -:: (log lost-sponsor:log-names:naive *@ux lost parent ~) +:: TODO: sponsorship tests for l1 planets, and L1/L2 sponsorship tests :: ++ test-l2-set-spawn-proxy ^- tang =/ marbud-sproxy [~marbud %marbud-key-0 %own (addr %marbud-skey)] + :: %+ expect-eq !> [(addr %marbud-skey) 0] :: @@ -555,6 +490,7 @@ :: ++ test-l2-set-transfer-proxy ^- tang =/ marbud-tproxy [~marbud %marbud-key-0 %own (addr %marbud-tkey)] + :: %+ expect-eq !> [(addr %marbud-tkey) 0] :: @@ -566,6 +502,7 @@ :: ++ test-l2-set-management-proxy ^- tang =/ marbud-mproxy [~marbud %marbud-key-0 %own (addr %marbud-mkey)] + :: %+ expect-eq !> [(addr %marbud-mkey) 0] :: @@ -586,6 +523,7 @@ :: ++ test-marbud-l2-spawn ^- tang =/ lt-ospawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %ll-key-0)] + :: %+ expect-eq !> [`@ux`(addr %ll-key-0) 0] :: @@ -598,6 +536,7 @@ ++ test-marbud-l2-spawn-w-proxy ^- tang =/ marbud-sproxy [~marbud %marbud-key-0 %own (addr %marbud-skey)] =/ lt-ospawn [~marbud %marbud-skey %spawn ~linnup-torsyx (addr %lt-key-0)] + :: %+ expect-eq !> [`@ux`(addr %lt-key-0) 0] :: @@ -613,6 +552,7 @@ =/ marbud-sproxy [~marbud %marbud-key-0 %own (addr %marbud-skey)] =/ lt-ospawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] =/ lt-sspawn [~marbud %marbud-skey %spawn ~linnup-torsyx (addr %lt-key-1)] + :: %- expect-fail |. =| =^state:naive @@ -622,10 +562,11 @@ =^ f state (n state %bat q:(spawn:l2 0 lt-sspawn)) state :: -++ test-marbud-l2-change-keys - =/ new-keys-own [~marbud %marbud-key-0 %own | encr auth suit] - =/ new-keys-mgt [~marbud %marbud-mkey %manage | encr auth suit] +++ test-marbud-l2-change-keys ^- tang + =/ new-keys-own [~marbud %marbud-key-0 %own encr auth suit |] + =/ new-keys-mgt [~marbud %marbud-mkey %manage encr auth suit |] =/ marbud-mproxy [~marbud %marbud-key-0 %own (addr %marbud-mkey)] + :: ;: weld %+ expect-eq !> [suit auth encr] @@ -651,11 +592,12 @@ :: :: TODO: transfer breach via transfer proxy ++ test-marbud-l2-transfer-breach ^- tang - =/ new-keys [~marbud %marbud-key-0 %own | encr auth suit] + =/ new-keys [~marbud %marbud-key-0 %own encr auth suit |] =/ marbud-sproxy [~marbud %marbud-key-0 %own (addr %marbud-skey)] =/ marbud-mproxy [~marbud %marbud-key-0 %own (addr %marbud-mkey)] =/ marbud-tproxy [~marbud %marbud-key-0 %own (addr %marbud-key-1)] =/ marbud-transfer-breach [~marbud %marbud-key-1 (addr %marbud-key-1) %transfer &] + :: ;: weld %+ expect-eq :: Tests that proxies are reset on transfer breach @@ -692,14 +634,18 @@ == :: ++ test-marbud-l2-transfer-no-breach ^- tang - =/ new-keys [~marbud %marbud-key-0 %own | encr auth suit] + =/ new-keys [~marbud %marbud-key-0 %own encr auth suit |] + =/ marbud-sproxy [~marbud %marbud-key-0 %own (addr %marbud-skey)] + =/ marbud-mproxy [~marbud %marbud-key-0 %own (addr %marbud-mkey)] + =/ marbud-tproxy [~marbud %marbud-key-0 %own (addr %marbud-key-1)] + :: ;: weld %+ expect-eq :: Tests that proxies are not reset when transfering with no breach !> :* [(addr %marbud-key-1) 3] :: ownership - [`@`0x123 0] :: spawn-proxy - [`@`0x234 0] :: management-proxy + [`@`(addr %marbud-skey) 0] :: spawn-proxy + [`@`(addr %marbud-mkey) 0] :: management-proxy [0 0] :: voting-proxy [0 1] :: transfer-proxy == @@ -707,9 +653,9 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(set-spawn-proxy:l2 0 ~marbud %marbud-key-0 %own 0x123)) - =^ f state (n state %bat q:(set-management-proxy:l2 1 ~marbud %marbud-key-0 %own 0x234)) - =^ f state (n state %bat q:(set-transfer-proxy:l2 2 ~marbud %marbud-key-0 %own (addr %marbud-key-1))) + =^ f state (n state %bat q:(set-spawn-proxy:l2 0 marbud-sproxy)) + =^ f state (n state %bat q:(set-management-proxy:l2 1 marbud-mproxy)) + =^ f state (n state %bat q:(set-transfer-proxy:l2 2 marbud-tproxy)) =^ f state (n state %bat q:(transfer-point:l2 0 ~marbud %marbud-key-1 (addr %marbud-key-1) %transfer |)) ^- [[@ @] [@ @] [@ @] [@ @] [@ @]] own:(~(got by points.state) ~marbud) @@ -730,11 +676,11 @@ :: TODO: life+rift changes via transfer proxy :: ++ test-marbud-keys-life-rift ^- tang - =/ new-keys-no-reset [~marbud %marbud-key-0 %own | encr auth suit] - =/ new-keys-yes-reset [~marbud %marbud-key-0 %own & encr auth suit] - =/ zero-keys-no-reset [~marbud %marbud-key-0 %own | 0 0 0] - =/ zero-keys-yes-reset [~marbud %marbud-key-0 %own & 0 0 0] - + =/ new-keys-no-reset [~marbud %marbud-key-0 %own encr auth suit |] + =/ new-keys-yes-reset [~marbud %marbud-key-0 %own encr auth suit &] + =/ zero-keys-no-reset [~marbud %marbud-key-0 %own 0 0 0 |] + =/ zero-keys-yes-reset [~marbud %marbud-key-0 %own 0 0 0 &] + :: ;: weld %+ expect-eq :: breach=%.n @@ -773,10 +719,10 @@ == :: ++ test-marbud-transfer-life-rift ^- tang - =/ new-keys-no-reset [~marbud %marbud-key-0 %own | encr auth suit] - =/ new-keys-yes-reset [~marbud %marbud-key-0 %own & encr auth suit] - =/ zero-keys-no-reset [~marbud %marbud-key-0 %own | 0 0 0] - =/ zero-keys-yes-reset [~marbud %marbud-key-0 %own & 0 0 0] + =/ new-keys-no-reset [~marbud %marbud-key-0 %own encr auth suit |] + =/ new-keys-yes-reset [~marbud %marbud-key-0 %own encr auth suit &] + =/ zero-keys-no-reset [~marbud %marbud-key-0 %own 0 0 0 |] + =/ zero-keys-yes-reset [~marbud %marbud-key-0 %own 0 0 0 &] =/ marbud-transfer-no-breach [~marbud %marbud-key-0 (addr %marbud-key-1) %own |] =/ marbud-transfer-yes-breach [~marbud %marbud-key-0 (addr %marbud-key-1) %own &] :: @@ -823,6 +769,7 @@ :: ++ test-dopbud-l2-spawn ^- tang =/ pp-spawn [~dopbud %dopbud-key-0 %own ~palsep-picdun (addr %pp-key-0)] + :: %+ expect-eq !> [`@ux`(addr %pp-key-0) 0] :: @@ -835,6 +782,7 @@ ++ test-dopbud-l2-spawn-after-transfer ^- tang =/ pp-spawn [~dopbud %dopbud-key-0 %own ~palsep-picdun (addr %pp-key-0)] =/ lr-spawn [~dopbud %dopbud-key-1 %own ~laclur-rachul (addr %lr-key-0)] + :: %+ expect-eq !> [`@ux`(addr %lr-key-0) 0] :: @@ -879,6 +827,7 @@ ++ test-linnup-torsyx-l2-transfer-ownership ^- tang =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &] + :: %+ expect-eq !> [`@ux`(addr %lt-key-0) 0] :: @@ -906,6 +855,7 @@ :: TODO: Are you supposed to be able to request escape to a non-existent star? =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &] + :: %+ expect-eq !> [~ ~litbud] :: @@ -921,6 +871,7 @@ ++ test-linnup-torsyx-l2-cancel-escape-request ^- tang =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &] + :: %+ expect-eq !> ~ :: @@ -937,6 +888,7 @@ ++ test-linnup-torsyx-l2-adopt-accept ^- tang =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &] + :: %+ expect-eq !> [~ %.y ~litbud] :: @@ -955,6 +907,7 @@ :: be ~marbud here =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &] + :: %+ expect-eq !> ~ :: @@ -971,6 +924,7 @@ ++ test-linnup-torsyx-l2-detach ^- tang =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &] + :: %+ expect-eq !> [~ %.n ~marbud] :: From e7c268f53a65ba8cf70bfc4300a100c0f5e9eab1 Mon Sep 17 00:00:00 2001 From: drbeefsupreme Date: Thu, 6 May 2021 11:22:03 -0400 Subject: [PATCH 15/39] naive: change +transfer-point sample --- pkg/arvo/tests/lib/naive.hoon | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/pkg/arvo/tests/lib/naive.hoon b/pkg/arvo/tests/lib/naive.hoon index 17f8f67be..c654aa6a0 100644 --- a/pkg/arvo/tests/lib/naive.hoon +++ b/pkg/arvo/tests/lib/naive.hoon @@ -197,7 +197,7 @@ == :: ++ transfer-point - |= [nonce=@ud =ship pk=@ =address proxy=@tas reset=?] ^- octs + |= [nonce=@ud =ship pk=@ proxy=@tas =address reset=?] ^- octs %^ sign-tx pk nonce %: cad:naive 3 (from-proxy:bits proxy) @@ -363,8 +363,8 @@ dominion:(~(got by points.state) ~marbud) :: ++ test-batch ^- tang - =/ marbud-transfer [~marbud %marbud-key-0 (addr %marbud-key-0) %own |] - =/ marbud-transfer-2 [~marbud %marbud-key-0 (addr %marbud-key-1) %own |] + =/ marbud-transfer [~marbud %marbud-key-0 %own (addr %marbud-key-0) |] + =/ marbud-transfer-2 [~marbud %marbud-key-0 %own (addr %marbud-key-1) |] :: %+ expect-eq !> [(addr %marbud-key-1) 2] @@ -596,7 +596,7 @@ =/ marbud-sproxy [~marbud %marbud-key-0 %own (addr %marbud-skey)] =/ marbud-mproxy [~marbud %marbud-key-0 %own (addr %marbud-mkey)] =/ marbud-tproxy [~marbud %marbud-key-0 %own (addr %marbud-key-1)] - =/ marbud-transfer-breach [~marbud %marbud-key-1 (addr %marbud-key-1) %transfer &] + =/ marbud-transfer-breach [~marbud %marbud-key-1 %transfer (addr %marbud-key-1) &] :: ;: weld %+ expect-eq @@ -629,7 +629,7 @@ =| =^state:naive =^ f state (init-marbud state) =^ f state (n state %bat q:(configure-keys:l2 0 new-keys)) - =^ f state (n state %bat q:(transfer-point:l2 1 ~marbud %marbud-key-0 (addr %marbud-key-0) %own &)) + =^ f state (n state %bat q:(transfer-point:l2 1 ~marbud %marbud-key-0 %own (addr %marbud-key-0) &)) |1:keys.net:(~(got by points.state) ~marbud) == :: @@ -656,7 +656,7 @@ =^ f state (n state %bat q:(set-spawn-proxy:l2 0 marbud-sproxy)) =^ f state (n state %bat q:(set-management-proxy:l2 1 marbud-mproxy)) =^ f state (n state %bat q:(set-transfer-proxy:l2 2 marbud-tproxy)) - =^ f state (n state %bat q:(transfer-point:l2 0 ~marbud %marbud-key-1 (addr %marbud-key-1) %transfer |)) + =^ f state (n state %bat q:(transfer-point:l2 0 ~marbud %marbud-key-1 %transfer (addr %marbud-key-1) |)) ^- [[@ @] [@ @] [@ @] [@ @] [@ @]] own:(~(got by points.state) ~marbud) :: @@ -669,7 +669,7 @@ =| =^state:naive =^ f state (init-marbud state) =^ f state (n state %bat q:(configure-keys:l2 0 new-keys)) - =^ f state (n state %bat q:(transfer-point:l2 1 ~marbud %marbud-key-0 (addr %marbud-key-0) %own |)) + =^ f state (n state %bat q:(transfer-point:l2 1 ~marbud %marbud-key-0 %own (addr %marbud-key-0) |)) |1:keys.net:(~(got by points.state) ~marbud) == :: @@ -723,8 +723,8 @@ =/ new-keys-yes-reset [~marbud %marbud-key-0 %own encr auth suit &] =/ zero-keys-no-reset [~marbud %marbud-key-0 %own 0 0 0 |] =/ zero-keys-yes-reset [~marbud %marbud-key-0 %own 0 0 0 &] - =/ marbud-transfer-no-breach [~marbud %marbud-key-0 (addr %marbud-key-1) %own |] - =/ marbud-transfer-yes-breach [~marbud %marbud-key-0 (addr %marbud-key-1) %own &] + =/ marbud-transfer-no-breach [~marbud %marbud-key-0 %own (addr %marbud-key-1) |] + =/ marbud-transfer-yes-breach [~marbud %marbud-key-0 %own (addr %marbud-key-1) &] :: ;: weld %+ expect-eq @@ -826,7 +826,7 @@ :: ++ test-linnup-torsyx-l2-transfer-ownership ^- tang =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] - =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &] + =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 %transfer (addr %lt-key-0) &] :: %+ expect-eq !> [`@ux`(addr %lt-key-0) 0] @@ -840,7 +840,7 @@ :: ++ test-palsep-picdun-l2-transfer-ownership ^- tang =/ pp-spawn [~dopbud %dopbud-key-0 %own ~palsep-picdun (addr %pp-key-0)] - =/ pp-transfer-yes-breach [~palsep-picdun %pp-key-0 (addr %pp-key-0) %transfer &] + =/ pp-transfer-yes-breach [~palsep-picdun %pp-key-0 %transfer (addr %pp-key-0) &] %+ expect-eq !> [`@ux`(addr %pp-key-0) 0] :: @@ -854,7 +854,7 @@ ++ test-linnup-torsyx-l2-escape-request ^- tang :: TODO: Are you supposed to be able to request escape to a non-existent star? =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] - =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &] + =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 %transfer (addr %lt-key-0) &] :: %+ expect-eq !> [~ ~litbud] @@ -870,7 +870,7 @@ :: ++ test-linnup-torsyx-l2-cancel-escape-request ^- tang =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] - =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &] + =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 %transfer (addr %lt-key-0) &] :: %+ expect-eq !> ~ @@ -887,7 +887,7 @@ :: ++ test-linnup-torsyx-l2-adopt-accept ^- tang =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] - =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &] + =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 %transfer (addr %lt-key-0) &] :: %+ expect-eq !> [~ %.y ~litbud] @@ -906,7 +906,7 @@ :: TODO: at the moment the default sponsor is always ~zod, but it should probably :: be ~marbud here =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] - =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &] + =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 %transfer (addr %lt-key-0) &] :: %+ expect-eq !> ~ @@ -923,7 +923,7 @@ :: ++ test-linnup-torsyx-l2-detach ^- tang =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] - =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 (addr %lt-key-0) %transfer &] + =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 %transfer (addr %lt-key-0) &] :: %+ expect-eq !> [~ %.n ~marbud] From f39ca44a9d194d4d5ca8a41ec685ea72b301bd6e Mon Sep 17 00:00:00 2001 From: drbeefsupreme Date: Thu, 6 May 2021 11:29:17 -0400 Subject: [PATCH 16/39] naive: combine transfer proxy tests --- pkg/arvo/tests/lib/naive.hoon | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/pkg/arvo/tests/lib/naive.hoon b/pkg/arvo/tests/lib/naive.hoon index c654aa6a0..4b7025085 100644 --- a/pkg/arvo/tests/lib/naive.hoon +++ b/pkg/arvo/tests/lib/naive.hoon @@ -591,7 +591,7 @@ == :: :: TODO: transfer breach via transfer proxy -++ test-marbud-l2-transfer-breach ^- tang +++ test-marbud-l2-proxies-transfer ^- tang =/ new-keys [~marbud %marbud-key-0 %own encr auth suit |] =/ marbud-sproxy [~marbud %marbud-key-0 %own (addr %marbud-skey)] =/ marbud-mproxy [~marbud %marbud-key-0 %own (addr %marbud-mkey)] @@ -600,7 +600,7 @@ :: ;: weld %+ expect-eq - :: Tests that proxies are reset on transfer breach + :: Tests that proxies are reset on transfer with breach :: !> :* [(addr %marbud-key-1) 3] :: ownership @@ -621,7 +621,7 @@ own:(~(got by points.state) ~marbud) :: %+ expect-eq - :: Tests that networking keys are reset on transfer breach + :: Tests that networking keys are reset on transfer with breach !> [0 0 0] :: @@ -631,21 +631,13 @@ =^ f state (n state %bat q:(configure-keys:l2 0 new-keys)) =^ f state (n state %bat q:(transfer-point:l2 1 ~marbud %marbud-key-0 %own (addr %marbud-key-0) &)) |1:keys.net:(~(got by points.state) ~marbud) - == -:: -++ test-marbud-l2-transfer-no-breach ^- tang - =/ new-keys [~marbud %marbud-key-0 %own encr auth suit |] - =/ marbud-sproxy [~marbud %marbud-key-0 %own (addr %marbud-skey)] - =/ marbud-mproxy [~marbud %marbud-key-0 %own (addr %marbud-mkey)] - =/ marbud-tproxy [~marbud %marbud-key-0 %own (addr %marbud-key-1)] - :: - ;: weld + :: %+ expect-eq - :: Tests that proxies are not reset when transfering with no breach + :: Tests that proxies are not reset when transfering without breach !> :* [(addr %marbud-key-1) 3] :: ownership - [`@`(addr %marbud-skey) 0] :: spawn-proxy - [`@`(addr %marbud-mkey) 0] :: management-proxy + [(addr %marbud-skey) 0] :: spawn-proxy + [(addr %marbud-mkey) 0] :: management-proxy [0 0] :: voting-proxy [0 1] :: transfer-proxy == @@ -661,7 +653,7 @@ own:(~(got by points.state) ~marbud) :: %+ expect-eq - :: Tests that networking keys are not reset when transfering with no breach + :: Tests that networking keys are not reset when transfering without breach !> [suit auth encr] :: From 0266805b12b97a885b1e87b0b726fb704dfef93b Mon Sep 17 00:00:00 2001 From: drbeefsupreme Date: Thu, 6 May 2021 11:37:02 -0400 Subject: [PATCH 17/39] naive: combine l2 spawn tests --- pkg/arvo/tests/lib/naive.hoon | 46 ++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/pkg/arvo/tests/lib/naive.hoon b/pkg/arvo/tests/lib/naive.hoon index 4b7025085..30ee45934 100644 --- a/pkg/arvo/tests/lib/naive.hoon +++ b/pkg/arvo/tests/lib/naive.hoon @@ -522,30 +522,32 @@ dominion:(~(got by points.state) ~dopbud) :: ++ test-marbud-l2-spawn ^- tang - =/ lt-ospawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %ll-key-0)] - :: - %+ expect-eq - !> [`@ux`(addr %ll-key-0) 0] - :: - !> - =| =^state:naive - =^ f state (init-marbud state) - =^ f state (n state %bat q:(spawn:l2 0 lt-ospawn)) - transfer-proxy.own:(~(got by points.state) ~linnup-torsyx) -:: -++ test-marbud-l2-spawn-w-proxy ^- tang =/ marbud-sproxy [~marbud %marbud-key-0 %own (addr %marbud-skey)] - =/ lt-ospawn [~marbud %marbud-skey %spawn ~linnup-torsyx (addr %lt-key-0)] + =/ lt-ospawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] + =/ lt-sspawn [~marbud %marbud-skey %spawn ~linnup-torsyx (addr %lt-key-0)] :: - %+ expect-eq - !> [`@ux`(addr %lt-key-0) 0] - :: - !> - =| =^state:naive - =^ f state (init-marbud state) - =^ f state (n state %bat q:(set-spawn-proxy:l2 0 marbud-sproxy)) - =^ f state (n state %bat q:(spawn:l2 0 lt-ospawn)) - transfer-proxy.own:(~(got by points.state) ~linnup-torsyx) + ;: weld + %+ expect-eq + :: Tests l2 spawning with ownership + !> [`@ux`(addr %lt-key-0) 0] + :: + !> + =| =^state:naive + =^ f state (init-marbud state) + =^ f state (n state %bat q:(spawn:l2 0 lt-ospawn)) + transfer-proxy.own:(~(got by points.state) ~linnup-torsyx) + :: + %+ expect-eq + :: Tests l2 spawning with spawn proxy + !> [`@ux`(addr %lt-key-0) 0] + :: + !> + =| =^state:naive + =^ f state (init-marbud state) + =^ f state (n state %bat q:(set-spawn-proxy:l2 0 marbud-sproxy)) + =^ f state (n state %bat q:(spawn:l2 0 lt-sspawn)) + transfer-proxy.own:(~(got by points.state) ~linnup-torsyx) + == :: ++ test-marbud-l2-double-spawn ^- tang :: Attempts to spawn the same planet twice, once with ownership and once with spawn proxy From baadf059d4562221ad50540aec65d31696b1638c Mon Sep 17 00:00:00 2001 From: drbeefsupreme Date: Tue, 11 May 2021 14:28:43 -0400 Subject: [PATCH 18/39] naive: add basic types --- pkg/arvo/tests/lib/naive.hoon | 211 ++++++++++++++++++---------------- 1 file changed, 115 insertions(+), 96 deletions(-) diff --git a/pkg/arvo/tests/lib/naive.hoon b/pkg/arvo/tests/lib/naive.hoon index 30ee45934..ec6f1ee11 100644 --- a/pkg/arvo/tests/lib/naive.hoon +++ b/pkg/arvo/tests/lib/naive.hoon @@ -1,6 +1,13 @@ /+ *test, naive, ethereum, azimuth +:: +:: Types +|% ++$ address @ux ++$ nonce @ud ++$ skp [=ship pk=@ proxy=@tas] +-- +:: |% -++ address @ux ++ n |=([=^state:naive =^input:naive] (%*(. naive lac |) verifier 1.337 +<)) :: TODO: does this uniquely produce the pubkey? :: @@ -82,7 +89,7 @@ [:(welp f1 f2) state] :: ++ sign-tx - |= [pk=@ nonce=@ud tx=octs] ^- octs + |= [pk=@ =nonce tx=octs] ^- octs =/ prepared-data (prepare-for-sig 1.337 nonce tx) =/ sign-data =/ len (rsh [3 2] (scot %ui p.prepared-data)) @@ -97,7 +104,7 @@ (cad:naive 3 1^v 32^s 32^r tx ~) :: ++ prepare-for-sig - |= [chain-id=@ud nonce=@ud tx=octs] + |= [chain-id=@ud =nonce tx=octs] ^- octs =/ chain-t (rsh [3 2] (scot %ui chain-id)) %: cad:naive 3 @@ -185,11 +192,12 @@ |% :: ++ spawn - |= [nonce=@ud parent=ship pk=@ proxy=@tas child=ship =address] ^- octs - %^ sign-tx pk nonce +:: |= [=nonce parent=ship pk=@ proxy=@tas child=ship =address] ^- octs + |= [=nonce =skp child=ship =address] ^- octs + %^ sign-tx pk.skp nonce %: cad:naive 3 - (from-proxy:bits proxy) - 4^parent + (from-proxy:bits proxy.skp) + 4^ship.skp 1^%1 :: %spawn 4^child 20^address @@ -197,25 +205,25 @@ == :: ++ transfer-point - |= [nonce=@ud =ship pk=@ proxy=@tas =address reset=?] ^- octs - %^ sign-tx pk nonce + |= [=nonce =skp =address reset=?] ^- octs + %^ sign-tx pk.skp nonce %: cad:naive 3 - (from-proxy:bits proxy) - 4^ship + (from-proxy:bits proxy.skp) + 4^ship.skp 1^(can 0 7^%0 1^reset ~) :: %transfer-point 20^address ~ == :: ++ configure-keys - |= $: nonce=@ud =ship pk=@ proxy=@tas + |= $: =nonce =skp encrypt=@ auth=@ crypto-suite=@ breach=? == ^- octs - %^ sign-tx pk nonce + %^ sign-tx pk.skp nonce %: cad:naive 3 - (from-proxy:bits proxy) - 4^ship + (from-proxy:bits proxy.skp) + 4^ship.skp 1^(can 0 7^%2 1^breach ~) :: %configure-keys 32^encrypt 32^auth @@ -224,45 +232,45 @@ == :: ++ escape - |= [nonce=@ud child=ship pk=@ proxy=@tas parent=ship] ^- octs - %^ sign-tx pk nonce - (take-escape:bits %escape child proxy parent) + |= [=nonce =skp parent=ship] ^- octs + %^ sign-tx pk.skp nonce + (take-escape:bits %escape ship.skp proxy.skp parent) :: ++ cancel-escape - |= [nonce=@ud child=ship pk=@ proxy=@tas parent=ship] ^- octs - %^ sign-tx pk nonce - (take-escape:bits %cancel-escape child proxy parent) + |= [=nonce =skp parent=ship] ^- octs + %^ sign-tx pk.skp nonce + (take-escape:bits %cancel-escape ship.skp proxy.skp parent) :: ++ adopt - |= [nonce=@ud parent=ship pk=@ proxy=@tas child=ship] ^- octs - %^ sign-tx pk nonce - (take-escape:bits %adopt parent proxy child) + |= [=nonce =skp child=ship] ^- octs + %^ sign-tx pk.skp nonce + (take-escape:bits %adopt ship.skp proxy.skp child) :: ++ reject - |= [nonce=@ud parent=ship pk=@ proxy=@tas child=ship] ^- octs - %^ sign-tx pk nonce - (take-escape:bits %reject parent proxy child) + |= [=nonce =skp child=ship] ^- octs + %^ sign-tx pk.skp nonce + (take-escape:bits %reject ship.skp proxy.skp child) :: ++ detach - |= [nonce=@ud parent=ship pk=@ proxy=@tas child=ship] ^- octs - %^ sign-tx pk nonce - (take-escape:bits %detach parent proxy child) + |= [=nonce =skp child=ship] ^- octs + %^ sign-tx pk.skp nonce + (take-escape:bits %detach ship.skp proxy.skp child) :: ++ set-management-proxy - |= [nonce=@ud =ship pk=@ proxy=@tas =address] ^- octs - %^ sign-tx pk nonce + |= [=nonce =skp =address] ^- octs + %^ sign-tx pk.skp nonce ^- octs - (take-ship-address:bits %set-management-proxy ship proxy address) + (take-ship-address:bits %set-management-proxy ship.skp proxy.skp address) :: ++ set-spawn-proxy - |= [nonce=@ud =ship pk=@ proxy=@tas =address] ^- octs - %^ sign-tx pk nonce - (take-ship-address:bits %set-spawn-proxy ship proxy address) + |= [=nonce =skp =address] ^- octs + %^ sign-tx pk.skp nonce + (take-ship-address:bits %set-spawn-proxy ship.skp proxy.skp address) :: ++ set-transfer-proxy - |= [nonce=@ud =ship pk=@ proxy=@tas =address] ^- octs - %^ sign-tx pk nonce - (take-ship-address:bits %set-transfer-proxy ship proxy address) + |= [=nonce =skp =address] ^- octs + %^ sign-tx pk.skp nonce + (take-ship-address:bits %set-transfer-proxy ship.skp proxy.skp address) :: ++ bits :: @@ -331,6 +339,16 @@ ++ auth (shax 'You cant know that this sentence is true.') ++ suit 1 :: +++ marbud-own [~marbud %marbud-key-0 %own] +++ marbud-spn [~marbud %marbud-skey %spawn] +++ marbud-mgt [~marbud %marbud-mkey %manage] +:: +++ dopbud-own [~dopbud %dopbud-key-0 %own] +:: +++ litbud-own [~litbud %litbud-key-0 %own] +:: +++ lt-own [~linnup-torsyx %lt-key-0 %own] +++ lt-xfr [~linnup-torsyx %lt-key-0 %transfer] -- :: :: Tests @@ -363,8 +381,8 @@ dominion:(~(got by points.state) ~marbud) :: ++ test-batch ^- tang - =/ marbud-transfer [~marbud %marbud-key-0 %own (addr %marbud-key-0) |] - =/ marbud-transfer-2 [~marbud %marbud-key-0 %own (addr %marbud-key-1) |] + =/ marbud-transfer [marbud-own (addr %marbud-key-0) |] + =/ marbud-transfer-2 [marbud-own (addr %marbud-key-1) |] :: %+ expect-eq !> [(addr %marbud-key-1) 2] @@ -477,7 +495,7 @@ :: TODO: sponsorship tests for l1 planets, and L1/L2 sponsorship tests :: ++ test-l2-set-spawn-proxy ^- tang - =/ marbud-sproxy [~marbud %marbud-key-0 %own (addr %marbud-skey)] + =/ marbud-sproxy [marbud-own (addr %marbud-skey)] :: %+ expect-eq !> [(addr %marbud-skey) 0] @@ -489,7 +507,7 @@ spawn-proxy.own:(~(got by points.state) ~marbud) :: ++ test-l2-set-transfer-proxy ^- tang - =/ marbud-tproxy [~marbud %marbud-key-0 %own (addr %marbud-tkey)] + =/ marbud-tproxy [marbud-own (addr %marbud-tkey)] :: %+ expect-eq !> [(addr %marbud-tkey) 0] @@ -501,7 +519,7 @@ transfer-proxy.own:(~(got by points.state) ~marbud) :: ++ test-l2-set-management-proxy ^- tang - =/ marbud-mproxy [~marbud %marbud-key-0 %own (addr %marbud-mkey)] + =/ marbud-mproxy [marbud-own (addr %marbud-mkey)] :: %+ expect-eq !> [(addr %marbud-mkey) 0] @@ -522,9 +540,9 @@ dominion:(~(got by points.state) ~dopbud) :: ++ test-marbud-l2-spawn ^- tang - =/ marbud-sproxy [~marbud %marbud-key-0 %own (addr %marbud-skey)] - =/ lt-ospawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] - =/ lt-sspawn [~marbud %marbud-skey %spawn ~linnup-torsyx (addr %lt-key-0)] + =/ marbud-sproxy [marbud-own (addr %marbud-skey)] + =/ lt-ospawn [marbud-own ~linnup-torsyx (addr %lt-key-0)] + =/ lt-sspawn [marbud-spn ~linnup-torsyx (addr %lt-key-0)] :: ;: weld %+ expect-eq @@ -551,9 +569,9 @@ :: ++ test-marbud-l2-double-spawn ^- tang :: Attempts to spawn the same planet twice, once with ownership and once with spawn proxy - =/ marbud-sproxy [~marbud %marbud-key-0 %own (addr %marbud-skey)] - =/ lt-ospawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] - =/ lt-sspawn [~marbud %marbud-skey %spawn ~linnup-torsyx (addr %lt-key-1)] + =/ marbud-sproxy [marbud-own (addr %marbud-skey)] + =/ lt-ospawn [marbud-own ~linnup-torsyx (addr %lt-key-0)] + =/ lt-sspawn [marbud-spn ~linnup-torsyx (addr %lt-key-1)] :: %- expect-fail |. @@ -565,9 +583,9 @@ state :: ++ test-marbud-l2-change-keys ^- tang - =/ new-keys-own [~marbud %marbud-key-0 %own encr auth suit |] - =/ new-keys-mgt [~marbud %marbud-mkey %manage encr auth suit |] - =/ marbud-mproxy [~marbud %marbud-key-0 %own (addr %marbud-mkey)] + =/ new-keys-own [marbud-own encr auth suit |] + =/ new-keys-mgt [marbud-mgt encr auth suit |] + =/ marbud-mproxy [marbud-own (addr %marbud-mkey)] :: ;: weld %+ expect-eq @@ -594,11 +612,12 @@ :: :: TODO: transfer breach via transfer proxy ++ test-marbud-l2-proxies-transfer ^- tang - =/ new-keys [~marbud %marbud-key-0 %own encr auth suit |] - =/ marbud-sproxy [~marbud %marbud-key-0 %own (addr %marbud-skey)] - =/ marbud-mproxy [~marbud %marbud-key-0 %own (addr %marbud-mkey)] - =/ marbud-tproxy [~marbud %marbud-key-0 %own (addr %marbud-key-1)] - =/ marbud-transfer-breach [~marbud %marbud-key-1 %transfer (addr %marbud-key-1) &] + =/ new-keys [marbud-own encr auth suit |] + =/ marbud-sproxy [marbud-own (addr %marbud-skey)] + =/ marbud-mproxy [marbud-own (addr %marbud-mkey)] + =/ marbud-tproxy [marbud-own (addr %marbud-key-1)] + =/ marbud-transfer-breach [[~marbud %marbud-key-1 %transfer] (addr %marbud-key-1) &] + =/ marbud-transfer-no-breach [[~marbud %marbud-key-1 %transfer] (addr %marbud-key-1) |] :: ;: weld %+ expect-eq @@ -631,7 +650,7 @@ =| =^state:naive =^ f state (init-marbud state) =^ f state (n state %bat q:(configure-keys:l2 0 new-keys)) - =^ f state (n state %bat q:(transfer-point:l2 1 ~marbud %marbud-key-0 %own (addr %marbud-key-0) &)) + =^ f state (n state %bat q:(transfer-point:l2 1 marbud-own (addr %marbud-key-0) &)) |1:keys.net:(~(got by points.state) ~marbud) :: %+ expect-eq @@ -650,7 +669,7 @@ =^ f state (n state %bat q:(set-spawn-proxy:l2 0 marbud-sproxy)) =^ f state (n state %bat q:(set-management-proxy:l2 1 marbud-mproxy)) =^ f state (n state %bat q:(set-transfer-proxy:l2 2 marbud-tproxy)) - =^ f state (n state %bat q:(transfer-point:l2 0 ~marbud %marbud-key-1 %transfer (addr %marbud-key-1) |)) + =^ f state (n state %bat q:(transfer-point:l2 0 marbud-transfer-no-breach)) ^- [[@ @] [@ @] [@ @] [@ @] [@ @]] own:(~(got by points.state) ~marbud) :: @@ -663,17 +682,17 @@ =| =^state:naive =^ f state (init-marbud state) =^ f state (n state %bat q:(configure-keys:l2 0 new-keys)) - =^ f state (n state %bat q:(transfer-point:l2 1 ~marbud %marbud-key-0 %own (addr %marbud-key-0) |)) + =^ f state (n state %bat q:(transfer-point:l2 1 marbud-own (addr %marbud-key-0) |)) |1:keys.net:(~(got by points.state) ~marbud) == :: :: TODO: life+rift changes via transfer proxy :: ++ test-marbud-keys-life-rift ^- tang - =/ new-keys-no-reset [~marbud %marbud-key-0 %own encr auth suit |] - =/ new-keys-yes-reset [~marbud %marbud-key-0 %own encr auth suit &] - =/ zero-keys-no-reset [~marbud %marbud-key-0 %own 0 0 0 |] - =/ zero-keys-yes-reset [~marbud %marbud-key-0 %own 0 0 0 &] + =/ new-keys-no-reset [marbud-own encr auth suit |] + =/ new-keys-yes-reset [marbud-own encr auth suit &] + =/ zero-keys-no-reset [marbud-own 0 0 0 |] + =/ zero-keys-yes-reset [marbud-own 0 0 0 &] :: ;: weld %+ expect-eq @@ -713,12 +732,12 @@ == :: ++ test-marbud-transfer-life-rift ^- tang - =/ new-keys-no-reset [~marbud %marbud-key-0 %own encr auth suit |] - =/ new-keys-yes-reset [~marbud %marbud-key-0 %own encr auth suit &] - =/ zero-keys-no-reset [~marbud %marbud-key-0 %own 0 0 0 |] - =/ zero-keys-yes-reset [~marbud %marbud-key-0 %own 0 0 0 &] - =/ marbud-transfer-no-breach [~marbud %marbud-key-0 %own (addr %marbud-key-1) |] - =/ marbud-transfer-yes-breach [~marbud %marbud-key-0 %own (addr %marbud-key-1) &] + =/ new-keys-no-reset [marbud-own encr auth suit |] + =/ new-keys-yes-reset [marbud-own encr auth suit &] + =/ zero-keys-no-reset [marbud-own 0 0 0 |] + =/ zero-keys-yes-reset [marbud-own 0 0 0 &] + =/ marbud-transfer-no-breach [marbud-own (addr %marbud-key-1) |] + =/ marbud-transfer-yes-breach [marbud-own (addr %marbud-key-1) &] :: ;: weld %+ expect-eq @@ -762,7 +781,7 @@ == :: ++ test-dopbud-l2-spawn ^- tang - =/ pp-spawn [~dopbud %dopbud-key-0 %own ~palsep-picdun (addr %pp-key-0)] + =/ pp-spawn [dopbud-own ~palsep-picdun (addr %pp-key-0)] :: %+ expect-eq !> [`@ux`(addr %pp-key-0) 0] @@ -774,8 +793,8 @@ transfer-proxy.own:(~(got by points.state) ~palsep-picdun) :: ++ test-dopbud-l2-spawn-after-transfer ^- tang - =/ pp-spawn [~dopbud %dopbud-key-0 %own ~palsep-picdun (addr %pp-key-0)] - =/ lr-spawn [~dopbud %dopbud-key-1 %own ~laclur-rachul (addr %lr-key-0)] + =/ pp-spawn [dopbud-own ~palsep-picdun (addr %pp-key-0)] + =/ lr-spawn [[~dopbud %dopbud-key-1 %own] ~laclur-rachul (addr %lr-key-0)] :: %+ expect-eq !> [`@ux`(addr %lr-key-0) 0] @@ -819,8 +838,8 @@ :: state :: ++ test-linnup-torsyx-l2-transfer-ownership ^- tang - =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] - =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 %transfer (addr %lt-key-0) &] + =/ lt-spawn [marbud-own ~linnup-torsyx (addr %lt-key-0)] + =/ lt-transfer-yes-breach [lt-xfr (addr %lt-key-0) &] :: %+ expect-eq !> [`@ux`(addr %lt-key-0) 0] @@ -833,8 +852,8 @@ owner.own:(~(got by points.state) ~linnup-torsyx) :: ++ test-palsep-picdun-l2-transfer-ownership ^- tang - =/ pp-spawn [~dopbud %dopbud-key-0 %own ~palsep-picdun (addr %pp-key-0)] - =/ pp-transfer-yes-breach [~palsep-picdun %pp-key-0 %transfer (addr %pp-key-0) &] + =/ pp-spawn [dopbud-own ~palsep-picdun (addr %pp-key-0)] + =/ pp-transfer-yes-breach [[~palsep-picdun %pp-key-0 %transfer] (addr %pp-key-0) &] %+ expect-eq !> [`@ux`(addr %pp-key-0) 0] :: @@ -847,8 +866,8 @@ :: ++ test-linnup-torsyx-l2-escape-request ^- tang :: TODO: Are you supposed to be able to request escape to a non-existent star? - =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] - =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 %transfer (addr %lt-key-0) &] + =/ lt-spawn [marbud-own ~linnup-torsyx (addr %lt-key-0)] + =/ lt-transfer-yes-breach [lt-xfr (addr %lt-key-0) &] :: %+ expect-eq !> [~ ~litbud] @@ -859,12 +878,12 @@ =^ f state (init-litbud state) =^ f state (n state %bat q:(spawn:l2 0 lt-spawn)) =^ f state (n state %bat q:(transfer-point:l2 0 lt-transfer-yes-breach)) - =^ f state (n state %bat q:(escape:l2 0 ~linnup-torsyx %lt-key-0 %own ~litbud)) + =^ f state (n state %bat q:(escape:l2 0 [lt-own] ~litbud)) escape.net:(~(got by points.state) ~linnup-torsyx) :: ++ test-linnup-torsyx-l2-cancel-escape-request ^- tang - =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] - =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 %transfer (addr %lt-key-0) &] + =/ lt-spawn [marbud-own ~linnup-torsyx (addr %lt-key-0)] + =/ lt-transfer-yes-breach [lt-xfr (addr %lt-key-0) &] :: %+ expect-eq !> ~ @@ -875,13 +894,13 @@ =^ f state (init-litbud state) =^ f state (n state %bat q:(spawn:l2 0 lt-spawn)) =^ f state (n state %bat q:(transfer-point:l2 0 lt-transfer-yes-breach)) - =^ f state (n state %bat q:(escape:l2 0 ~linnup-torsyx %lt-key-0 %own ~litbud)) - =^ f state (n state %bat q:(cancel-escape:l2 1 ~linnup-torsyx %lt-key-0 %own ~litbud)) + =^ f state (n state %bat q:(escape:l2 0 lt-own ~litbud)) + =^ f state (n state %bat q:(cancel-escape:l2 1 lt-own ~litbud)) escape.net:(~(got by points.state) ~linnup-torsyx) :: ++ test-linnup-torsyx-l2-adopt-accept ^- tang - =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] - =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 %transfer (addr %lt-key-0) &] + =/ lt-spawn [marbud-own ~linnup-torsyx (addr %lt-key-0)] + =/ lt-transfer-yes-breach [lt-xfr (addr %lt-key-0) &] :: %+ expect-eq !> [~ %.y ~litbud] @@ -892,15 +911,15 @@ =^ f state (init-litbud state) =^ f state (n state %bat q:(spawn:l2 0 lt-spawn)) =^ f state (n state %bat q:(transfer-point:l2 0 lt-transfer-yes-breach)) - =^ f state (n state %bat q:(escape:l2 0 ~linnup-torsyx %lt-key-0 %own ~litbud)) - =^ f state (n state %bat q:(adopt:l2 0 ~litbud %litbud-key-0 %own ~linnup-torsyx)) + =^ f state (n state %bat q:(escape:l2 0 lt-own ~litbud)) + =^ f state (n state %bat q:(adopt:l2 0 litbud-own ~linnup-torsyx)) [escape.net sponsor.net]:(~(got by points.state) ~linnup-torsyx) :: ++ test-linnup-torsyx-l2-adopt-reject ^- tang :: TODO: at the moment the default sponsor is always ~zod, but it should probably :: be ~marbud here - =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] - =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 %transfer (addr %lt-key-0) &] + =/ lt-spawn [marbud-own ~linnup-torsyx (addr %lt-key-0)] + =/ lt-transfer-yes-breach [lt-xfr (addr %lt-key-0) &] :: %+ expect-eq !> ~ @@ -911,13 +930,13 @@ =^ f state (init-litbud state) =^ f state (n state %bat q:(spawn:l2 0 lt-spawn)) =^ f state (n state %bat q:(transfer-point:l2 0 lt-transfer-yes-breach)) - =^ f state (n state %bat q:(escape:l2 0 ~linnup-torsyx %lt-key-0 %own ~litbud)) - =^ f state (n state %bat q:(reject:l2 0 ~litbud %litbud-key-0 %own ~linnup-torsyx)) + =^ f state (n state %bat q:(escape:l2 0 lt-own ~litbud)) + =^ f state (n state %bat q:(reject:l2 0 litbud-own ~linnup-torsyx)) escape.net:(~(got by points.state) ~linnup-torsyx) :: ++ test-linnup-torsyx-l2-detach ^- tang - =/ lt-spawn [~marbud %marbud-key-0 %own ~linnup-torsyx (addr %lt-key-0)] - =/ lt-transfer-yes-breach [~linnup-torsyx %lt-key-0 %transfer (addr %lt-key-0) &] + =/ lt-spawn [marbud-own ~linnup-torsyx (addr %lt-key-0)] + =/ lt-transfer-yes-breach [lt-xfr (addr %lt-key-0) &] :: %+ expect-eq !> [~ %.n ~marbud] @@ -928,7 +947,7 @@ =^ f state (init-litbud state) =^ f state (n state %bat q:(spawn:l2 0 lt-spawn)) =^ f state (n state %bat q:(transfer-point:l2 0 lt-transfer-yes-breach)) - =^ f state (n state %bat q:(detach:l2 1 ~marbud %marbud-key-0 %own ~linnup-torsyx)) + =^ f state (n state %bat q:(detach:l2 1 marbud-own ~linnup-torsyx)) [escape.net sponsor.net]:(~(got by points.state) ~linnup-torsyx) :: :: TODO: signature format changed; regenerate From 7470b148b8dac06852a49d6d1aa9002c60fceadf Mon Sep 17 00:00:00 2001 From: drbeefsupreme Date: Tue, 11 May 2021 16:32:33 -0400 Subject: [PATCH 19/39] naive: unified l2 transaction firing arm --- pkg/arvo/tests/lib/naive.hoon | 370 ++++++++++++++++------------------ 1 file changed, 178 insertions(+), 192 deletions(-) diff --git a/pkg/arvo/tests/lib/naive.hoon b/pkg/arvo/tests/lib/naive.hoon index ec6f1ee11..370bb2d62 100644 --- a/pkg/arvo/tests/lib/naive.hoon +++ b/pkg/arvo/tests/lib/naive.hoon @@ -4,7 +4,22 @@ |% +$ address @ux +$ nonce @ud -+$ skp [=ship pk=@ proxy=@tas] ++$ proxy ?(%own %spawn %manage %vote %transfer) ++$ skp [=ship pk=@ =proxy] +:: ++$ l2-tx + $% [%spawn child=ship =address] + [%transfer-point =address reset=?] + [%configure-keys encrypt=@ auth=@ crypto-suite=@ breach=?] + [%escape parent=ship] + [%cancel-escape parent=ship] + [%adopt child=ship] + [%reject child=ship] + [%detach child=ship] + [%set-management-proxy =address] + [%set-spawn-proxy =address] + [%set-transfer-proxy =address] + == -- :: |% @@ -191,86 +206,23 @@ :: |% :: - ++ spawn -:: |= [=nonce parent=ship pk=@ proxy=@tas child=ship =address] ^- octs - |= [=nonce =skp child=ship =address] ^- octs - %^ sign-tx pk.skp nonce - %: cad:naive 3 - (from-proxy:bits proxy.skp) - 4^ship.skp - 1^%1 :: %spawn - 4^child - 20^address - ~ - == - :: - ++ transfer-point - |= [=nonce =skp =address reset=?] ^- octs - %^ sign-tx pk.skp nonce - %: cad:naive 3 - (from-proxy:bits proxy.skp) - 4^ship.skp - 1^(can 0 7^%0 1^reset ~) :: %transfer-point - 20^address - ~ - == - :: - ++ configure-keys - |= $: =nonce =skp - encrypt=@ auth=@ crypto-suite=@ breach=? - == - ^- octs - %^ sign-tx pk.skp nonce - %: cad:naive 3 - (from-proxy:bits proxy.skp) - 4^ship.skp - 1^(can 0 7^%2 1^breach ~) :: %configure-keys - 32^encrypt - 32^auth - 4^crypto-suite - ~ - == - :: - ++ escape - |= [=nonce =skp parent=ship] ^- octs - %^ sign-tx pk.skp nonce - (take-escape:bits %escape ship.skp proxy.skp parent) - :: - ++ cancel-escape - |= [=nonce =skp parent=ship] ^- octs - %^ sign-tx pk.skp nonce - (take-escape:bits %cancel-escape ship.skp proxy.skp parent) - :: - ++ adopt - |= [=nonce =skp child=ship] ^- octs - %^ sign-tx pk.skp nonce - (take-escape:bits %adopt ship.skp proxy.skp child) - :: - ++ reject - |= [=nonce =skp child=ship] ^- octs - %^ sign-tx pk.skp nonce - (take-escape:bits %reject ship.skp proxy.skp child) - :: - ++ detach - |= [=nonce =skp child=ship] ^- octs - %^ sign-tx pk.skp nonce - (take-escape:bits %detach ship.skp proxy.skp child) - :: - ++ set-management-proxy - |= [=nonce =skp =address] ^- octs - %^ sign-tx pk.skp nonce - ^- octs - (take-ship-address:bits %set-management-proxy ship.skp proxy.skp address) - :: - ++ set-spawn-proxy - |= [=nonce =skp =address] ^- octs - %^ sign-tx pk.skp nonce - (take-ship-address:bits %set-spawn-proxy ship.skp proxy.skp address) - :: - ++ set-transfer-proxy - |= [=nonce =skp =address] ^- octs - %^ sign-tx pk.skp nonce - (take-ship-address:bits %set-transfer-proxy ship.skp proxy.skp address) + ++ gen-tx + |= [=nonce =skp tx=l2-tx] ^- octs + =/ raw=octs + ?- -.tx + %spawn (get-spawn:bits ship.skp proxy.skp +.tx) + %transfer-point (get-transfer:bits ship.skp proxy.skp +.tx) + %configure-keys (get-keys:bits ship.skp proxy.skp +.tx) + %escape (get-escape:bits %escape ship.skp proxy.skp +.tx) + %cancel-escape (get-escape:bits %cancel-escape ship.skp proxy.skp +.tx) + %adopt (get-escape:bits %adopt ship.skp proxy.skp +.tx) + %reject (get-escape:bits %reject ship.skp proxy.skp +.tx) + %detach (get-escape:bits %detach ship.skp proxy.skp +.tx) + %set-management-proxy (get-ship-address:bits %set-management-proxy ship.skp proxy.skp +.tx) + %set-spawn-proxy (get-ship-address:bits %set-spawn-proxy ship.skp proxy.skp +.tx) + %set-transfer-proxy (get-ship-address:bits %set-transfer-proxy ship.skp proxy.skp +.tx) + == + %^ sign-tx pk.skp nonce raw :: ++ bits :: @@ -278,7 +230,40 @@ :: :: TODO: Shouldn't need to pass all these arguments along - they should already be in the subject somewhere :: - ++ take-escape + ++ get-spawn + |= [=ship =proxy child=ship =address] ^- octs + %: cad:naive 3 + (from-proxy:bits proxy) + 4^ship + 1^%1 :: %spawn + 4^child + 20^address + ~ + == + :: + ++ get-transfer + |= [=ship =proxy =address reset=?] ^- octs + %: cad:naive 3 + (from-proxy:bits proxy) + 4^ship + 1^(can 0 7^%0 1^reset ~) :: %transfer-point + 20^address + ~ + == + :: + ++ get-keys + |= [=ship =proxy encrypt=@ auth=@ crypto-suite=@ breach=?] ^- octs + %: cad:naive 3 + (from-proxy:bits proxy) + 4^ship + 1^(can 0 7^%2 1^breach ~) :: %configure-keys + 32^encrypt + 32^auth + 4^crypto-suite + ~ + == + :: + ++ get-escape |= [action=@tas from=ship proxy=@tas other=ship] ^- octs =/ op ?+ action !! @@ -296,7 +281,7 @@ ~ == :: - ++ take-ship-address + ++ get-ship-address |= [action=@tas from=ship proxy=@tas =address] ^- octs =/ op ?+ action !! @@ -331,7 +316,7 @@ :: -- :: -:: Keys +:: Common values used for tests :: |% :: @@ -381,8 +366,8 @@ dominion:(~(got by points.state) ~marbud) :: ++ test-batch ^- tang - =/ marbud-transfer [marbud-own (addr %marbud-key-0) |] - =/ marbud-transfer-2 [marbud-own (addr %marbud-key-1) |] + =/ marbud-transfer [%transfer-point (addr %marbud-key-0) |] + =/ marbud-transfer-2 [%transfer-point (addr %marbud-key-1) |] :: %+ expect-eq !> [(addr %marbud-key-1) 2] @@ -390,8 +375,8 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(transfer-point:l2 0 marbud-transfer)) - =^ f state (n state %bat q:(transfer-point:l2 1 marbud-transfer-2)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own marbud-transfer)) + =^ f state (n state %bat q:(gen-tx:l2 1 marbud-own marbud-transfer-2)) owner.own:(~(got by points.state) ~marbud) :: ++ test-l1-changed-spawn-proxy ^- tang @@ -495,7 +480,7 @@ :: TODO: sponsorship tests for l1 planets, and L1/L2 sponsorship tests :: ++ test-l2-set-spawn-proxy ^- tang - =/ marbud-sproxy [marbud-own (addr %marbud-skey)] + =/ marbud-sproxy [%set-spawn-proxy (addr %marbud-skey)] :: %+ expect-eq !> [(addr %marbud-skey) 0] @@ -503,11 +488,11 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(set-spawn-proxy:l2 0 marbud-sproxy)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own marbud-sproxy)) spawn-proxy.own:(~(got by points.state) ~marbud) :: ++ test-l2-set-transfer-proxy ^- tang - =/ marbud-tproxy [marbud-own (addr %marbud-tkey)] + =/ marbud-tproxy [%set-transfer-proxy (addr %marbud-tkey)] :: %+ expect-eq !> [(addr %marbud-tkey) 0] @@ -515,11 +500,11 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(set-transfer-proxy:l2 0 marbud-tproxy)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own marbud-tproxy)) transfer-proxy.own:(~(got by points.state) ~marbud) :: ++ test-l2-set-management-proxy ^- tang - =/ marbud-mproxy [marbud-own (addr %marbud-mkey)] + =/ marbud-mproxy [%set-management-proxy (addr %marbud-mkey)] :: %+ expect-eq !> [(addr %marbud-mkey) 0] @@ -527,7 +512,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(set-management-proxy:l2 0 marbud-mproxy)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own marbud-mproxy)) management-proxy.own:(~(got by points.state) ~marbud) :: ++ test-l2-spawn-proxy-deposit ^- tang @@ -540,9 +525,8 @@ dominion:(~(got by points.state) ~dopbud) :: ++ test-marbud-l2-spawn ^- tang - =/ marbud-sproxy [marbud-own (addr %marbud-skey)] - =/ lt-ospawn [marbud-own ~linnup-torsyx (addr %lt-key-0)] - =/ lt-sspawn [marbud-spn ~linnup-torsyx (addr %lt-key-0)] + =/ marbud-sproxy [%set-spawn-proxy (addr %marbud-skey)] + =/ lt-spawn [%spawn ~linnup-torsyx (addr %lt-key-0)] :: ;: weld %+ expect-eq @@ -552,7 +536,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(spawn:l2 0 lt-ospawn)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own lt-spawn)) transfer-proxy.own:(~(got by points.state) ~linnup-torsyx) :: %+ expect-eq @@ -562,30 +546,29 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(set-spawn-proxy:l2 0 marbud-sproxy)) - =^ f state (n state %bat q:(spawn:l2 0 lt-sspawn)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own marbud-sproxy)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-spn lt-spawn)) transfer-proxy.own:(~(got by points.state) ~linnup-torsyx) == :: ++ test-marbud-l2-double-spawn ^- tang :: Attempts to spawn the same planet twice, once with ownership and once with spawn proxy - =/ marbud-sproxy [marbud-own (addr %marbud-skey)] - =/ lt-ospawn [marbud-own ~linnup-torsyx (addr %lt-key-0)] - =/ lt-sspawn [marbud-spn ~linnup-torsyx (addr %lt-key-1)] + =/ marbud-sproxy [%set-spawn-proxy (addr %marbud-skey)] + =/ lt-spawn-0 [%spawn ~linnup-torsyx (addr %lt-key-0)] + =/ lt-spawn-1 [%spawn ~linnup-torsyx (addr %lt-key-1)] :: %- expect-fail |. =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(set-spawn-proxy:l2 0 marbud-sproxy)) - =^ f state (n state %bat q:(spawn:l2 1 lt-ospawn)) - =^ f state (n state %bat q:(spawn:l2 0 lt-sspawn)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own marbud-sproxy)) + =^ f state (n state %bat q:(gen-tx:l2 1 marbud-own lt-spawn-0)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-spn lt-spawn-1)) state :: ++ test-marbud-l2-change-keys ^- tang - =/ new-keys-own [marbud-own encr auth suit |] - =/ new-keys-mgt [marbud-mgt encr auth suit |] - =/ marbud-mproxy [marbud-own (addr %marbud-mkey)] + =/ new-keys [%configure-keys encr auth suit |] + =/ marbud-mproxy [%set-management-proxy (addr %marbud-mkey)] :: ;: weld %+ expect-eq @@ -594,7 +577,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(configure-keys:l2 0 new-keys-own)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own new-keys)) |1:keys.net:(~(got by points.state) ~marbud) :: %+ expect-eq @@ -603,8 +586,8 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(set-management-proxy:l2 0 marbud-mproxy)) - =^ f state (n state %bat q:(configure-keys:l2 0 new-keys-mgt)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own marbud-mproxy)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-mgt new-keys)) |1:keys.net:(~(got by points.state) ~marbud) :: :: TODO: make sure nobody else can change these keys @@ -612,12 +595,13 @@ :: :: TODO: transfer breach via transfer proxy ++ test-marbud-l2-proxies-transfer ^- tang - =/ new-keys [marbud-own encr auth suit |] - =/ marbud-sproxy [marbud-own (addr %marbud-skey)] - =/ marbud-mproxy [marbud-own (addr %marbud-mkey)] - =/ marbud-tproxy [marbud-own (addr %marbud-key-1)] - =/ marbud-transfer-breach [[~marbud %marbud-key-1 %transfer] (addr %marbud-key-1) &] - =/ marbud-transfer-no-breach [[~marbud %marbud-key-1 %transfer] (addr %marbud-key-1) |] + =/ marbud-t1 [~marbud %marbud-key-1 %transfer] + =/ new-keys [%configure-keys encr auth suit |] + =/ marbud-sproxy [%set-spawn-proxy (addr %marbud-skey)] + =/ marbud-mproxy [%set-management-proxy (addr %marbud-mkey)] + =/ marbud-tproxy [%set-transfer-proxy (addr %marbud-key-1)] + =/ marbud-transfer-breach [%transfer-point (addr %marbud-key-1) &] + =/ marbud-transfer-no-breach [%transfer-point (addr %marbud-key-1) |] :: ;: weld %+ expect-eq @@ -634,10 +618,10 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(set-spawn-proxy:l2 0 marbud-sproxy)) - =^ f state (n state %bat q:(set-management-proxy:l2 1 marbud-mproxy)) - =^ f state (n state %bat q:(set-transfer-proxy:l2 2 marbud-tproxy)) - =^ f state (n state %bat q:(transfer-point:l2 0 marbud-transfer-breach)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own marbud-sproxy)) + =^ f state (n state %bat q:(gen-tx:l2 1 marbud-own marbud-mproxy)) + =^ f state (n state %bat q:(gen-tx:l2 2 marbud-own marbud-tproxy)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-t1 marbud-transfer-breach)) ^- [[@ @] [@ @] [@ @] [@ @] [@ @]] own:(~(got by points.state) ~marbud) :: @@ -649,8 +633,8 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(configure-keys:l2 0 new-keys)) - =^ f state (n state %bat q:(transfer-point:l2 1 marbud-own (addr %marbud-key-0) &)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own new-keys)) + =^ f state (n state %bat q:(gen-tx:l2 1 marbud-own [%transfer-point (addr %marbud-key-0) &])) |1:keys.net:(~(got by points.state) ~marbud) :: %+ expect-eq @@ -666,10 +650,10 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(set-spawn-proxy:l2 0 marbud-sproxy)) - =^ f state (n state %bat q:(set-management-proxy:l2 1 marbud-mproxy)) - =^ f state (n state %bat q:(set-transfer-proxy:l2 2 marbud-tproxy)) - =^ f state (n state %bat q:(transfer-point:l2 0 marbud-transfer-no-breach)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own marbud-sproxy)) + =^ f state (n state %bat q:(gen-tx:l2 1 marbud-own marbud-mproxy)) + =^ f state (n state %bat q:(gen-tx:l2 2 marbud-own marbud-tproxy)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-t1 marbud-transfer-no-breach)) ^- [[@ @] [@ @] [@ @] [@ @] [@ @]] own:(~(got by points.state) ~marbud) :: @@ -681,18 +665,18 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(configure-keys:l2 0 new-keys)) - =^ f state (n state %bat q:(transfer-point:l2 1 marbud-own (addr %marbud-key-0) |)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own new-keys)) + =^ f state (n state %bat q:(gen-tx:l2 1 marbud-own [%transfer-point (addr %marbud-key-0) |])) |1:keys.net:(~(got by points.state) ~marbud) == :: :: TODO: life+rift changes via transfer proxy :: ++ test-marbud-keys-life-rift ^- tang - =/ new-keys-no-reset [marbud-own encr auth suit |] - =/ new-keys-yes-reset [marbud-own encr auth suit &] - =/ zero-keys-no-reset [marbud-own 0 0 0 |] - =/ zero-keys-yes-reset [marbud-own 0 0 0 &] + =/ new-keys-no-reset [%configure-keys encr auth suit |] + =/ new-keys-yes-reset [%configure-keys encr auth suit &] + =/ zero-keys-no-reset [%configure-keys 0 0 0 |] + =/ zero-keys-yes-reset [%configure-keys 0 0 0 &] :: ;: weld %+ expect-eq @@ -702,7 +686,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(configure-keys:l2 0 new-keys-no-reset)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own new-keys-no-reset)) [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: %+ expect-eq @@ -712,7 +696,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(configure-keys:l2 0 new-keys-yes-reset)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own new-keys-yes-reset)) [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: %+ expect-eq @@ -724,20 +708,20 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(configure-keys:l2 0 new-keys-yes-reset)) :: inc life and rift - =^ f state (n state %bat q:(configure-keys:l2 1 zero-keys-no-reset)) :: inc life - =^ f state (n state %bat q:(configure-keys:l2 2 zero-keys-yes-reset)) :: inc rift + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own new-keys-yes-reset)) :: inc life and rift + =^ f state (n state %bat q:(gen-tx:l2 1 marbud-own zero-keys-no-reset)) :: inc life + =^ f state (n state %bat q:(gen-tx:l2 2 marbud-own zero-keys-yes-reset)) :: inc rift [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: == :: ++ test-marbud-transfer-life-rift ^- tang - =/ new-keys-no-reset [marbud-own encr auth suit |] - =/ new-keys-yes-reset [marbud-own encr auth suit &] - =/ zero-keys-no-reset [marbud-own 0 0 0 |] - =/ zero-keys-yes-reset [marbud-own 0 0 0 &] - =/ marbud-transfer-no-breach [marbud-own (addr %marbud-key-1) |] - =/ marbud-transfer-yes-breach [marbud-own (addr %marbud-key-1) &] + =/ new-keys-no-reset [%configure-keys encr auth suit |] + =/ new-keys-yes-reset [%configure-keys encr auth suit &] + =/ zero-keys-no-reset [%configure-keys 0 0 0 |] + =/ zero-keys-yes-reset [%configure-keys 0 0 0 &] + =/ marbud-transfer-no-breach [%transfer-point (addr %marbud-key-1) |] + =/ marbud-transfer-yes-breach [%transfer-point (addr %marbud-key-1) &] :: ;: weld %+ expect-eq @@ -748,7 +732,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(transfer-point:l2 0 marbud-transfer-no-breach)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own marbud-transfer-no-breach)) [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: %+ expect-eq @@ -759,7 +743,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(transfer-point:l2 0 marbud-transfer-no-breach)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own marbud-transfer-no-breach)) [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: %+ expect-eq @@ -773,15 +757,15 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(configure-keys:l2 0 new-keys-yes-reset)) :: inc life and rift - =^ f state (n state %bat q:(configure-keys:l2 1 zero-keys-no-reset)) :: inc life - =^ f state (n state %bat q:(transfer-point:l2 2 marbud-transfer-yes-breach)) :: inc rift + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own new-keys-yes-reset)) :: inc life and rift + =^ f state (n state %bat q:(gen-tx:l2 1 marbud-own zero-keys-no-reset)) :: inc life + =^ f state (n state %bat q:(gen-tx:l2 2 marbud-own marbud-transfer-yes-breach)) :: inc rift [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: == :: ++ test-dopbud-l2-spawn ^- tang - =/ pp-spawn [dopbud-own ~palsep-picdun (addr %pp-key-0)] + =/ pp-spawn [%spawn ~palsep-picdun (addr %pp-key-0)] :: %+ expect-eq !> [`@ux`(addr %pp-key-0) 0] @@ -789,12 +773,13 @@ !> =| =^state:naive =^ f state (init-dopbud state) - =^ f state (n state %bat q:(spawn:l2 0 pp-spawn)) + =^ f state (n state %bat q:(gen-tx:l2 0 dopbud-own pp-spawn)) transfer-proxy.own:(~(got by points.state) ~palsep-picdun) :: ++ test-dopbud-l2-spawn-after-transfer ^- tang - =/ pp-spawn [dopbud-own ~palsep-picdun (addr %pp-key-0)] - =/ lr-spawn [[~dopbud %dopbud-key-1 %own] ~laclur-rachul (addr %lr-key-0)] + =/ pp-spawn [%spawn ~palsep-picdun (addr %pp-key-0)] + =/ lr-spawn [%spawn ~laclur-rachul (addr %lr-key-0)] + =/ dopbud-own-1 [~dopbud %dopbud-key-1 %own] :: %+ expect-eq !> [`@ux`(addr %lr-key-0) 0] @@ -802,9 +787,9 @@ !> =| =^state:naive =^ f state (init-dopbud state) - =^ f state (n state %bat q:(spawn:l2 0 pp-spawn)) + =^ f state (n state %bat q:(gen-tx:l2 0 dopbud-own pp-spawn)) =^ f state (n state (owner-changed:l1 ~dopbud (addr %dopbud-key-1))) - =^ f state (n state %bat q:(spawn:l2 1 lr-spawn)) + =^ f state (n state %bat q:(gen-tx:l2 1 dopbud-own-1 lr-spawn)) transfer-proxy.own:(~(got by points.state) ~laclur-rachul) :: :: ++ test-sambud-double-spawn ^- tang @@ -838,8 +823,8 @@ :: state :: ++ test-linnup-torsyx-l2-transfer-ownership ^- tang - =/ lt-spawn [marbud-own ~linnup-torsyx (addr %lt-key-0)] - =/ lt-transfer-yes-breach [lt-xfr (addr %lt-key-0) &] + =/ lt-spawn [%spawn ~linnup-torsyx (addr %lt-key-0)] + =/ lt-transfer-yes-breach [%transfer-point (addr %lt-key-0) &] :: %+ expect-eq !> [`@ux`(addr %lt-key-0) 0] @@ -847,27 +832,28 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(spawn:l2 0 lt-spawn)) - =^ f state (n state %bat q:(transfer-point:l2 0 lt-transfer-yes-breach)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own lt-spawn)) + =^ f state (n state %bat q:(gen-tx:l2 0 lt-xfr lt-transfer-yes-breach)) owner.own:(~(got by points.state) ~linnup-torsyx) :: ++ test-palsep-picdun-l2-transfer-ownership ^- tang - =/ pp-spawn [dopbud-own ~palsep-picdun (addr %pp-key-0)] - =/ pp-transfer-yes-breach [[~palsep-picdun %pp-key-0 %transfer] (addr %pp-key-0) &] + =/ pp-xfr [~palsep-picdun %pp-key-0 %transfer] + =/ pp-spawn [%spawn ~palsep-picdun (addr %pp-key-0)] + =/ pp-transfer-yes-breach [%transfer-point (addr %pp-key-0) &] %+ expect-eq !> [`@ux`(addr %pp-key-0) 0] :: !> =| =^state:naive =^ f state (init-dopbud state) - =^ f state (n state %bat q:(spawn:l2 0 pp-spawn)) - =^ f state (n state %bat q:(transfer-point:l2 0 pp-transfer-yes-breach)) + =^ f state (n state %bat q:(gen-tx:l2 0 dopbud-own pp-spawn)) + =^ f state (n state %bat q:(gen-tx:l2 0 pp-xfr pp-transfer-yes-breach)) owner.own:(~(got by points.state) ~palsep-picdun) :: ++ test-linnup-torsyx-l2-escape-request ^- tang :: TODO: Are you supposed to be able to request escape to a non-existent star? - =/ lt-spawn [marbud-own ~linnup-torsyx (addr %lt-key-0)] - =/ lt-transfer-yes-breach [lt-xfr (addr %lt-key-0) &] + =/ lt-spawn [%spawn ~linnup-torsyx (addr %lt-key-0)] + =/ lt-transfer-yes-breach [%transfer-point (addr %lt-key-0) &] :: %+ expect-eq !> [~ ~litbud] @@ -876,14 +862,14 @@ =| =^state:naive =^ f state (init-marbud state) =^ f state (init-litbud state) - =^ f state (n state %bat q:(spawn:l2 0 lt-spawn)) - =^ f state (n state %bat q:(transfer-point:l2 0 lt-transfer-yes-breach)) - =^ f state (n state %bat q:(escape:l2 0 [lt-own] ~litbud)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own lt-spawn)) + =^ f state (n state %bat q:(gen-tx:l2 0 lt-xfr lt-transfer-yes-breach)) + =^ f state (n state %bat q:(gen-tx:l2 0 lt-own [%escape ~litbud])) escape.net:(~(got by points.state) ~linnup-torsyx) :: ++ test-linnup-torsyx-l2-cancel-escape-request ^- tang - =/ lt-spawn [marbud-own ~linnup-torsyx (addr %lt-key-0)] - =/ lt-transfer-yes-breach [lt-xfr (addr %lt-key-0) &] + =/ lt-spawn [%spawn ~linnup-torsyx (addr %lt-key-0)] + =/ lt-transfer-yes-breach [%transfer-point (addr %lt-key-0) &] :: %+ expect-eq !> ~ @@ -892,15 +878,15 @@ =| =^state:naive =^ f state (init-marbud state) =^ f state (init-litbud state) - =^ f state (n state %bat q:(spawn:l2 0 lt-spawn)) - =^ f state (n state %bat q:(transfer-point:l2 0 lt-transfer-yes-breach)) - =^ f state (n state %bat q:(escape:l2 0 lt-own ~litbud)) - =^ f state (n state %bat q:(cancel-escape:l2 1 lt-own ~litbud)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own lt-spawn)) + =^ f state (n state %bat q:(gen-tx:l2 0 lt-xfr lt-transfer-yes-breach)) + =^ f state (n state %bat q:(gen-tx:l2 0 lt-own [%escape ~litbud])) + =^ f state (n state %bat q:(gen-tx:l2 1 lt-own [%cancel-escape ~litbud])) escape.net:(~(got by points.state) ~linnup-torsyx) :: ++ test-linnup-torsyx-l2-adopt-accept ^- tang - =/ lt-spawn [marbud-own ~linnup-torsyx (addr %lt-key-0)] - =/ lt-transfer-yes-breach [lt-xfr (addr %lt-key-0) &] + =/ lt-spawn [%spawn ~linnup-torsyx (addr %lt-key-0)] + =/ lt-transfer-yes-breach [%transfer-point (addr %lt-key-0) &] :: %+ expect-eq !> [~ %.y ~litbud] @@ -909,17 +895,17 @@ =| =^state:naive =^ f state (init-marbud state) =^ f state (init-litbud state) - =^ f state (n state %bat q:(spawn:l2 0 lt-spawn)) - =^ f state (n state %bat q:(transfer-point:l2 0 lt-transfer-yes-breach)) - =^ f state (n state %bat q:(escape:l2 0 lt-own ~litbud)) - =^ f state (n state %bat q:(adopt:l2 0 litbud-own ~linnup-torsyx)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own lt-spawn)) + =^ f state (n state %bat q:(gen-tx:l2 0 lt-xfr lt-transfer-yes-breach)) + =^ f state (n state %bat q:(gen-tx:l2 0 lt-own [%escape ~litbud])) + =^ f state (n state %bat q:(gen-tx:l2 0 litbud-own [%adopt ~linnup-torsyx])) [escape.net sponsor.net]:(~(got by points.state) ~linnup-torsyx) :: ++ test-linnup-torsyx-l2-adopt-reject ^- tang :: TODO: at the moment the default sponsor is always ~zod, but it should probably :: be ~marbud here - =/ lt-spawn [marbud-own ~linnup-torsyx (addr %lt-key-0)] - =/ lt-transfer-yes-breach [lt-xfr (addr %lt-key-0) &] + =/ lt-spawn [%spawn ~linnup-torsyx (addr %lt-key-0)] + =/ lt-transfer-yes-breach [%transfer-point (addr %lt-key-0) &] :: %+ expect-eq !> ~ @@ -928,15 +914,15 @@ =| =^state:naive =^ f state (init-marbud state) =^ f state (init-litbud state) - =^ f state (n state %bat q:(spawn:l2 0 lt-spawn)) - =^ f state (n state %bat q:(transfer-point:l2 0 lt-transfer-yes-breach)) - =^ f state (n state %bat q:(escape:l2 0 lt-own ~litbud)) - =^ f state (n state %bat q:(reject:l2 0 litbud-own ~linnup-torsyx)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own lt-spawn)) + =^ f state (n state %bat q:(gen-tx:l2 0 lt-xfr lt-transfer-yes-breach)) + =^ f state (n state %bat q:(gen-tx:l2 0 lt-own [%escape ~litbud])) + =^ f state (n state %bat q:(gen-tx:l2 0 litbud-own [%reject ~linnup-torsyx])) escape.net:(~(got by points.state) ~linnup-torsyx) :: ++ test-linnup-torsyx-l2-detach ^- tang - =/ lt-spawn [marbud-own ~linnup-torsyx (addr %lt-key-0)] - =/ lt-transfer-yes-breach [lt-xfr (addr %lt-key-0) &] + =/ lt-spawn [%spawn ~linnup-torsyx (addr %lt-key-0)] + =/ lt-transfer-yes-breach [%transfer-point (addr %lt-key-0) &] :: %+ expect-eq !> [~ %.n ~marbud] @@ -945,9 +931,9 @@ =| =^state:naive =^ f state (init-marbud state) =^ f state (init-litbud state) - =^ f state (n state %bat q:(spawn:l2 0 lt-spawn)) - =^ f state (n state %bat q:(transfer-point:l2 0 lt-transfer-yes-breach)) - =^ f state (n state %bat q:(detach:l2 1 marbud-own ~linnup-torsyx)) + =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own lt-spawn)) + =^ f state (n state %bat q:(gen-tx:l2 0 lt-xfr lt-transfer-yes-breach)) + =^ f state (n state %bat q:(gen-tx:l2 1 marbud-own [%detach ~linnup-torsyx])) [escape.net sponsor.net]:(~(got by points.state) ~linnup-torsyx) :: :: TODO: signature format changed; regenerate From de5a907300062a0a18ff8ca532074276ad334db1 Mon Sep 17 00:00:00 2001 From: drbeefsupreme Date: Tue, 11 May 2021 16:47:33 -0400 Subject: [PATCH 20/39] naive: factor out l2 transaction firing into lib Moved everything related to generating layer 2 transactions, including verification, into their own library. This ought to be shared between the aggregator and tests --- pkg/arvo/lib/naive-transactions.hoon | 177 ++++++++++++++++ pkg/arvo/tests/lib/naive.hoon | 305 ++++++--------------------- 2 files changed, 239 insertions(+), 243 deletions(-) create mode 100644 pkg/arvo/lib/naive-transactions.hoon diff --git a/pkg/arvo/lib/naive-transactions.hoon b/pkg/arvo/lib/naive-transactions.hoon new file mode 100644 index 000000000..20dbe8b84 --- /dev/null +++ b/pkg/arvo/lib/naive-transactions.hoon @@ -0,0 +1,177 @@ +/+ naive, ethereum +:: Types +|% ++$ address @ux ++$ nonce @ud ++$ proxy ?(%own %spawn %manage %vote %transfer) ++$ skp [=ship pk=@ =proxy] +:: ++$ l2-tx + $% [%spawn child=ship =address] + [%transfer-point =address reset=?] + [%configure-keys suite=@ud encrypt=@ auth=@ breach=?] + [%escape parent=ship] + [%cancel-escape parent=ship] + [%adopt child=ship] + [%reject child=ship] + [%detach child=ship] + [%set-management-proxy =address] + [%set-spawn-proxy =address] + [%set-transfer-proxy =address] + == +-- +:: +|% +:: +++ gen-tx + |= [=nonce =skp tx=l2-tx] ^- octs + =/ raw=octs + ?- -.tx + %spawn (get-spawn:bits ship.skp proxy.skp +.tx) + %transfer-point (get-transfer:bits ship.skp proxy.skp +.tx) + %configure-keys (get-keys:bits ship.skp proxy.skp +.tx) + %escape (get-escape:bits %escape ship.skp proxy.skp +.tx) + %cancel-escape (get-escape:bits %cancel-escape ship.skp proxy.skp +.tx) + %adopt (get-escape:bits %adopt ship.skp proxy.skp +.tx) + %reject (get-escape:bits %reject ship.skp proxy.skp +.tx) + %detach (get-escape:bits %detach ship.skp proxy.skp +.tx) + %set-management-proxy (get-ship-address:bits %set-management-proxy ship.skp proxy.skp +.tx) + %set-spawn-proxy (get-ship-address:bits %set-spawn-proxy ship.skp proxy.skp +.tx) + %set-transfer-proxy (get-ship-address:bits %set-transfer-proxy ship.skp proxy.skp +.tx) + == + %^ sign-tx pk.skp nonce raw +:: +:: TODO: does this uniquely produce the pubkey? +++ verifier + ^- ^verifier:naive + |= [dat=octs v=@ r=@ s=@] + ?: (gth v 3) ~ :: TODO: move to jet + =/ result + %- mule + |. + =, secp256k1:secp:crypto + %- address-from-pub:key:ethereum + %- serialize-point + (ecdsa-raw-recover (keccak-256:keccak:crypto dat) v r s) + ?- -.result + %| ~ + %& `p.result + == +:: +++ sign-tx + |= [pk=@ =nonce tx=octs] ^- octs + =/ prepared-data (prepare-for-sig 1.337 nonce tx) + =/ sign-data + =/ len (rsh [3 2] (scot %ui p.prepared-data)) + %- keccak-256:keccak:crypto + %: cad:naive 3 + 26^'\19Ethereum Signed Message:\0a' + (met 3 len)^len + prepared-data + ~ + == + =+ (ecdsa-raw-sign:secp256k1:secp:crypto sign-data pk) + (cad:naive 3 1^v 32^s 32^r tx ~) +:: +++ prepare-for-sig + |= [chain-id=@ud =nonce tx=octs] + ^- octs + =/ chain-t (rsh [3 2] (scot %ui chain-id)) + %: cad:naive 3 + 14^'UrbitIDV1Chain' + (met 3 chain-t)^chain-t + 1^':' + 4^nonce + tx + ~ + == +:: +++ bits + :: + |% + :: + :: TODO: Shouldn't need to pass all these arguments along - they should already be in the subject somewhere + :: + ++ get-spawn + |= [=ship =proxy child=ship =address] ^- octs + %: cad:naive 3 + (from-proxy:bits proxy) + 4^ship + 1^%1 :: %spawn + 4^child + 20^address + ~ + == + :: + ++ get-transfer + |= [=ship =proxy =address reset=?] ^- octs + %: cad:naive 3 + (from-proxy:bits proxy) + 4^ship + 1^(can 0 7^%0 1^reset ~) :: %transfer-point + 20^address + ~ + == + :: + ++ get-keys + |= [=ship =proxy suite=@ud encrypt=@ auth=@ breach=?] ^- octs + %: cad:naive 3 + (from-proxy:bits proxy) + 4^ship + 1^(can 0 7^%2 1^breach ~) :: %configure-keys + 32^encrypt + 32^auth + 4^suite + ~ + == + :: + ++ get-escape + |= [action=@tas from=ship proxy=@tas other=ship] ^- octs + =/ op + ?+ action !! + %escape %3 + %cancel-escape %4 + %adopt %5 + %reject %6 + %detach %7 + == + %: cad:naive 3 + (from-proxy proxy) + 4^from + 1^(can 0 7^op 1^0 ~) + 4^other + ~ + == + :: + ++ get-ship-address + |= [action=@tas from=ship proxy=@tas =address] ^- octs + =/ op + ?+ action !! + %set-management-proxy %8 + %set-spawn-proxy %9 + %set-transfer-proxy %10 + == + %: cad:naive 3 + (from-proxy proxy) + 4^from + 1^(can 0 7^op 1^0 ~) + 20^address + ~ + == + :: + ++ from-proxy + |= prx=@tas + ^- [@ @] + =/ proxy + ?+ prx !! + %own %0 + %spawn %1 + %manage %2 + %vote %3 + %transfer %4 + == + 1^(can 0 3^proxy 5^0 ~) + :: + -- +:: +-- diff --git a/pkg/arvo/tests/lib/naive.hoon b/pkg/arvo/tests/lib/naive.hoon index 370bb2d62..e26473254 100644 --- a/pkg/arvo/tests/lib/naive.hoon +++ b/pkg/arvo/tests/lib/naive.hoon @@ -1,46 +1,7 @@ -/+ *test, naive, ethereum, azimuth -:: -:: Types -|% -+$ address @ux -+$ nonce @ud -+$ proxy ?(%own %spawn %manage %vote %transfer) -+$ skp [=ship pk=@ =proxy] -:: -+$ l2-tx - $% [%spawn child=ship =address] - [%transfer-point =address reset=?] - [%configure-keys encrypt=@ auth=@ crypto-suite=@ breach=?] - [%escape parent=ship] - [%cancel-escape parent=ship] - [%adopt child=ship] - [%reject child=ship] - [%detach child=ship] - [%set-management-proxy =address] - [%set-spawn-proxy =address] - [%set-transfer-proxy =address] - == --- +/+ *test, naive, ethereum, azimuth, *naive-transactions :: |% ++ n |=([=^state:naive =^input:naive] (%*(. naive lac |) verifier 1.337 +<)) -:: TODO: does this uniquely produce the pubkey? -:: -++ verifier - ^- ^verifier:naive - |= [dat=octs v=@ r=@ s=@] - ?: (gth v 3) ~ :: TODO: move to jet - =/ result - %- mule - |. - =, secp256k1:secp:crypto - %- address-from-pub:key:ethereum - %- serialize-point - (ecdsa-raw-recover (keccak-256:keccak:crypto dat) v r s) - ?- -.result - %| ~ - %& `p.result - == :: ++ addr address-from-prv:key:ethereum :: @@ -103,34 +64,6 @@ =^ f2 state (n state (owner-changed:l1 ~sambud (addr %sambud-key-0))) [:(welp f1 f2) state] :: -++ sign-tx - |= [pk=@ =nonce tx=octs] ^- octs - =/ prepared-data (prepare-for-sig 1.337 nonce tx) - =/ sign-data - =/ len (rsh [3 2] (scot %ui p.prepared-data)) - %- keccak-256:keccak:crypto - %: cad:naive 3 - 26^'\19Ethereum Signed Message:\0a' - (met 3 len)^len - prepared-data - ~ - == - =+ (ecdsa-raw-sign:secp256k1:secp:crypto sign-data pk) - (cad:naive 3 1^v 32^s 32^r tx ~) -:: -++ prepare-for-sig - |= [chain-id=@ud =nonce tx=octs] - ^- octs - =/ chain-t (rsh [3 2] (scot %ui chain-id)) - %: cad:naive 3 - 14^'UrbitIDV1Chain' - (met 3 chain-t)^chain-t - 1^':' - 4^nonce - tx - ~ - == -:: ++ l1 |% :: @@ -202,118 +135,6 @@ :: -- :: -++ l2 - :: - |% - :: - ++ gen-tx - |= [=nonce =skp tx=l2-tx] ^- octs - =/ raw=octs - ?- -.tx - %spawn (get-spawn:bits ship.skp proxy.skp +.tx) - %transfer-point (get-transfer:bits ship.skp proxy.skp +.tx) - %configure-keys (get-keys:bits ship.skp proxy.skp +.tx) - %escape (get-escape:bits %escape ship.skp proxy.skp +.tx) - %cancel-escape (get-escape:bits %cancel-escape ship.skp proxy.skp +.tx) - %adopt (get-escape:bits %adopt ship.skp proxy.skp +.tx) - %reject (get-escape:bits %reject ship.skp proxy.skp +.tx) - %detach (get-escape:bits %detach ship.skp proxy.skp +.tx) - %set-management-proxy (get-ship-address:bits %set-management-proxy ship.skp proxy.skp +.tx) - %set-spawn-proxy (get-ship-address:bits %set-spawn-proxy ship.skp proxy.skp +.tx) - %set-transfer-proxy (get-ship-address:bits %set-transfer-proxy ship.skp proxy.skp +.tx) - == - %^ sign-tx pk.skp nonce raw - :: - ++ bits - :: - |% - :: - :: TODO: Shouldn't need to pass all these arguments along - they should already be in the subject somewhere - :: - ++ get-spawn - |= [=ship =proxy child=ship =address] ^- octs - %: cad:naive 3 - (from-proxy:bits proxy) - 4^ship - 1^%1 :: %spawn - 4^child - 20^address - ~ - == - :: - ++ get-transfer - |= [=ship =proxy =address reset=?] ^- octs - %: cad:naive 3 - (from-proxy:bits proxy) - 4^ship - 1^(can 0 7^%0 1^reset ~) :: %transfer-point - 20^address - ~ - == - :: - ++ get-keys - |= [=ship =proxy encrypt=@ auth=@ crypto-suite=@ breach=?] ^- octs - %: cad:naive 3 - (from-proxy:bits proxy) - 4^ship - 1^(can 0 7^%2 1^breach ~) :: %configure-keys - 32^encrypt - 32^auth - 4^crypto-suite - ~ - == - :: - ++ get-escape - |= [action=@tas from=ship proxy=@tas other=ship] ^- octs - =/ op - ?+ action !! - %escape %3 - %cancel-escape %4 - %adopt %5 - %reject %6 - %detach %7 - == - %: cad:naive 3 - (from-proxy proxy) - 4^from - 1^(can 0 7^op 1^0 ~) - 4^other - ~ - == - :: - ++ get-ship-address - |= [action=@tas from=ship proxy=@tas =address] ^- octs - =/ op - ?+ action !! - %set-management-proxy %8 - %set-spawn-proxy %9 - %set-transfer-proxy %10 - == - %: cad:naive 3 - (from-proxy proxy) - 4^from - 1^(can 0 7^op 1^0 ~) - 20^address - ~ - == - :: - ++ from-proxy - |= prx=@tas - ^- [@ @] - =/ proxy - ?+ prx !! - %own %0 - %spawn %1 - %manage %2 - %vote %3 - %transfer %4 - == - 1^(can 0 3^proxy 5^0 ~) - :: - -- - :: - -- -:: -- :: :: Common values used for tests @@ -340,8 +161,6 @@ :: |% :: -:: TODO: Factor out commonly used things like keys and addresses -:: ++ test-log ^- tang %+ expect-eq !> @@ -375,8 +194,8 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own marbud-transfer)) - =^ f state (n state %bat q:(gen-tx:l2 1 marbud-own marbud-transfer-2)) + =^ f state (n state %bat q:(gen-tx 0 marbud-own marbud-transfer)) + =^ f state (n state %bat q:(gen-tx 1 marbud-own marbud-transfer-2)) owner.own:(~(got by points.state) ~marbud) :: ++ test-l1-changed-spawn-proxy ^- tang @@ -488,7 +307,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own marbud-sproxy)) + =^ f state (n state %bat q:(gen-tx 0 marbud-own marbud-sproxy)) spawn-proxy.own:(~(got by points.state) ~marbud) :: ++ test-l2-set-transfer-proxy ^- tang @@ -500,7 +319,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own marbud-tproxy)) + =^ f state (n state %bat q:(gen-tx 0 marbud-own marbud-tproxy)) transfer-proxy.own:(~(got by points.state) ~marbud) :: ++ test-l2-set-management-proxy ^- tang @@ -512,7 +331,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own marbud-mproxy)) + =^ f state (n state %bat q:(gen-tx 0 marbud-own marbud-mproxy)) management-proxy.own:(~(got by points.state) ~marbud) :: ++ test-l2-spawn-proxy-deposit ^- tang @@ -536,7 +355,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own lt-spawn)) + =^ f state (n state %bat q:(gen-tx 0 marbud-own lt-spawn)) transfer-proxy.own:(~(got by points.state) ~linnup-torsyx) :: %+ expect-eq @@ -546,8 +365,8 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own marbud-sproxy)) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-spn lt-spawn)) + =^ f state (n state %bat q:(gen-tx 0 marbud-own marbud-sproxy)) + =^ f state (n state %bat q:(gen-tx 0 marbud-spn lt-spawn)) transfer-proxy.own:(~(got by points.state) ~linnup-torsyx) == :: @@ -561,9 +380,9 @@ |. =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own marbud-sproxy)) - =^ f state (n state %bat q:(gen-tx:l2 1 marbud-own lt-spawn-0)) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-spn lt-spawn-1)) + =^ f state (n state %bat q:(gen-tx 0 marbud-own marbud-sproxy)) + =^ f state (n state %bat q:(gen-tx 1 marbud-own lt-spawn-0)) + =^ f state (n state %bat q:(gen-tx 0 marbud-spn lt-spawn-1)) state :: ++ test-marbud-l2-change-keys ^- tang @@ -577,7 +396,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own new-keys)) + =^ f state (n state %bat q:(gen-tx 0 marbud-own new-keys)) |1:keys.net:(~(got by points.state) ~marbud) :: %+ expect-eq @@ -586,8 +405,8 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own marbud-mproxy)) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-mgt new-keys)) + =^ f state (n state %bat q:(gen-tx 0 marbud-own marbud-mproxy)) + =^ f state (n state %bat q:(gen-tx 0 marbud-mgt new-keys)) |1:keys.net:(~(got by points.state) ~marbud) :: :: TODO: make sure nobody else can change these keys @@ -618,10 +437,10 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own marbud-sproxy)) - =^ f state (n state %bat q:(gen-tx:l2 1 marbud-own marbud-mproxy)) - =^ f state (n state %bat q:(gen-tx:l2 2 marbud-own marbud-tproxy)) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-t1 marbud-transfer-breach)) + =^ f state (n state %bat q:(gen-tx 0 marbud-own marbud-sproxy)) + =^ f state (n state %bat q:(gen-tx 1 marbud-own marbud-mproxy)) + =^ f state (n state %bat q:(gen-tx 2 marbud-own marbud-tproxy)) + =^ f state (n state %bat q:(gen-tx 0 marbud-t1 marbud-transfer-breach)) ^- [[@ @] [@ @] [@ @] [@ @] [@ @]] own:(~(got by points.state) ~marbud) :: @@ -633,8 +452,8 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own new-keys)) - =^ f state (n state %bat q:(gen-tx:l2 1 marbud-own [%transfer-point (addr %marbud-key-0) &])) + =^ f state (n state %bat q:(gen-tx 0 marbud-own new-keys)) + =^ f state (n state %bat q:(gen-tx 1 marbud-own [%transfer-point (addr %marbud-key-0) &])) |1:keys.net:(~(got by points.state) ~marbud) :: %+ expect-eq @@ -650,10 +469,10 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own marbud-sproxy)) - =^ f state (n state %bat q:(gen-tx:l2 1 marbud-own marbud-mproxy)) - =^ f state (n state %bat q:(gen-tx:l2 2 marbud-own marbud-tproxy)) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-t1 marbud-transfer-no-breach)) + =^ f state (n state %bat q:(gen-tx 0 marbud-own marbud-sproxy)) + =^ f state (n state %bat q:(gen-tx 1 marbud-own marbud-mproxy)) + =^ f state (n state %bat q:(gen-tx 2 marbud-own marbud-tproxy)) + =^ f state (n state %bat q:(gen-tx 0 marbud-t1 marbud-transfer-no-breach)) ^- [[@ @] [@ @] [@ @] [@ @] [@ @]] own:(~(got by points.state) ~marbud) :: @@ -665,8 +484,8 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own new-keys)) - =^ f state (n state %bat q:(gen-tx:l2 1 marbud-own [%transfer-point (addr %marbud-key-0) |])) + =^ f state (n state %bat q:(gen-tx 0 marbud-own new-keys)) + =^ f state (n state %bat q:(gen-tx 1 marbud-own [%transfer-point (addr %marbud-key-0) |])) |1:keys.net:(~(got by points.state) ~marbud) == :: @@ -686,7 +505,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own new-keys-no-reset)) + =^ f state (n state %bat q:(gen-tx 0 marbud-own new-keys-no-reset)) [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: %+ expect-eq @@ -696,7 +515,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own new-keys-yes-reset)) + =^ f state (n state %bat q:(gen-tx 0 marbud-own new-keys-yes-reset)) [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: %+ expect-eq @@ -708,9 +527,9 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own new-keys-yes-reset)) :: inc life and rift - =^ f state (n state %bat q:(gen-tx:l2 1 marbud-own zero-keys-no-reset)) :: inc life - =^ f state (n state %bat q:(gen-tx:l2 2 marbud-own zero-keys-yes-reset)) :: inc rift + =^ f state (n state %bat q:(gen-tx 0 marbud-own new-keys-yes-reset)) :: inc life and rift + =^ f state (n state %bat q:(gen-tx 1 marbud-own zero-keys-no-reset)) :: inc life + =^ f state (n state %bat q:(gen-tx 2 marbud-own zero-keys-yes-reset)) :: inc rift [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: == @@ -732,7 +551,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own marbud-transfer-no-breach)) + =^ f state (n state %bat q:(gen-tx 0 marbud-own marbud-transfer-no-breach)) [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: %+ expect-eq @@ -743,7 +562,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own marbud-transfer-no-breach)) + =^ f state (n state %bat q:(gen-tx 0 marbud-own marbud-transfer-no-breach)) [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: %+ expect-eq @@ -757,9 +576,9 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own new-keys-yes-reset)) :: inc life and rift - =^ f state (n state %bat q:(gen-tx:l2 1 marbud-own zero-keys-no-reset)) :: inc life - =^ f state (n state %bat q:(gen-tx:l2 2 marbud-own marbud-transfer-yes-breach)) :: inc rift + =^ f state (n state %bat q:(gen-tx 0 marbud-own new-keys-yes-reset)) :: inc life and rift + =^ f state (n state %bat q:(gen-tx 1 marbud-own zero-keys-no-reset)) :: inc life + =^ f state (n state %bat q:(gen-tx 2 marbud-own marbud-transfer-yes-breach)) :: inc rift [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: == @@ -773,7 +592,7 @@ !> =| =^state:naive =^ f state (init-dopbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 dopbud-own pp-spawn)) + =^ f state (n state %bat q:(gen-tx 0 dopbud-own pp-spawn)) transfer-proxy.own:(~(got by points.state) ~palsep-picdun) :: ++ test-dopbud-l2-spawn-after-transfer ^- tang @@ -787,9 +606,9 @@ !> =| =^state:naive =^ f state (init-dopbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 dopbud-own pp-spawn)) + =^ f state (n state %bat q:(gen-tx 0 dopbud-own pp-spawn)) =^ f state (n state (owner-changed:l1 ~dopbud (addr %dopbud-key-1))) - =^ f state (n state %bat q:(gen-tx:l2 1 dopbud-own-1 lr-spawn)) + =^ f state (n state %bat q:(gen-tx 1 dopbud-own-1 lr-spawn)) transfer-proxy.own:(~(got by points.state) ~laclur-rachul) :: :: ++ test-sambud-double-spawn ^- tang @@ -832,8 +651,8 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own lt-spawn)) - =^ f state (n state %bat q:(gen-tx:l2 0 lt-xfr lt-transfer-yes-breach)) + =^ f state (n state %bat q:(gen-tx 0 marbud-own lt-spawn)) + =^ f state (n state %bat q:(gen-tx 0 lt-xfr lt-transfer-yes-breach)) owner.own:(~(got by points.state) ~linnup-torsyx) :: ++ test-palsep-picdun-l2-transfer-ownership ^- tang @@ -846,8 +665,8 @@ !> =| =^state:naive =^ f state (init-dopbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 dopbud-own pp-spawn)) - =^ f state (n state %bat q:(gen-tx:l2 0 pp-xfr pp-transfer-yes-breach)) + =^ f state (n state %bat q:(gen-tx 0 dopbud-own pp-spawn)) + =^ f state (n state %bat q:(gen-tx 0 pp-xfr pp-transfer-yes-breach)) owner.own:(~(got by points.state) ~palsep-picdun) :: ++ test-linnup-torsyx-l2-escape-request ^- tang @@ -862,9 +681,9 @@ =| =^state:naive =^ f state (init-marbud state) =^ f state (init-litbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own lt-spawn)) - =^ f state (n state %bat q:(gen-tx:l2 0 lt-xfr lt-transfer-yes-breach)) - =^ f state (n state %bat q:(gen-tx:l2 0 lt-own [%escape ~litbud])) + =^ f state (n state %bat q:(gen-tx 0 marbud-own lt-spawn)) + =^ f state (n state %bat q:(gen-tx 0 lt-xfr lt-transfer-yes-breach)) + =^ f state (n state %bat q:(gen-tx 0 lt-own [%escape ~litbud])) escape.net:(~(got by points.state) ~linnup-torsyx) :: ++ test-linnup-torsyx-l2-cancel-escape-request ^- tang @@ -878,10 +697,10 @@ =| =^state:naive =^ f state (init-marbud state) =^ f state (init-litbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own lt-spawn)) - =^ f state (n state %bat q:(gen-tx:l2 0 lt-xfr lt-transfer-yes-breach)) - =^ f state (n state %bat q:(gen-tx:l2 0 lt-own [%escape ~litbud])) - =^ f state (n state %bat q:(gen-tx:l2 1 lt-own [%cancel-escape ~litbud])) + =^ f state (n state %bat q:(gen-tx 0 marbud-own lt-spawn)) + =^ f state (n state %bat q:(gen-tx 0 lt-xfr lt-transfer-yes-breach)) + =^ f state (n state %bat q:(gen-tx 0 lt-own [%escape ~litbud])) + =^ f state (n state %bat q:(gen-tx 1 lt-own [%cancel-escape ~litbud])) escape.net:(~(got by points.state) ~linnup-torsyx) :: ++ test-linnup-torsyx-l2-adopt-accept ^- tang @@ -895,10 +714,10 @@ =| =^state:naive =^ f state (init-marbud state) =^ f state (init-litbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own lt-spawn)) - =^ f state (n state %bat q:(gen-tx:l2 0 lt-xfr lt-transfer-yes-breach)) - =^ f state (n state %bat q:(gen-tx:l2 0 lt-own [%escape ~litbud])) - =^ f state (n state %bat q:(gen-tx:l2 0 litbud-own [%adopt ~linnup-torsyx])) + =^ f state (n state %bat q:(gen-tx 0 marbud-own lt-spawn)) + =^ f state (n state %bat q:(gen-tx 0 lt-xfr lt-transfer-yes-breach)) + =^ f state (n state %bat q:(gen-tx 0 lt-own [%escape ~litbud])) + =^ f state (n state %bat q:(gen-tx 0 litbud-own [%adopt ~linnup-torsyx])) [escape.net sponsor.net]:(~(got by points.state) ~linnup-torsyx) :: ++ test-linnup-torsyx-l2-adopt-reject ^- tang @@ -914,10 +733,10 @@ =| =^state:naive =^ f state (init-marbud state) =^ f state (init-litbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own lt-spawn)) - =^ f state (n state %bat q:(gen-tx:l2 0 lt-xfr lt-transfer-yes-breach)) - =^ f state (n state %bat q:(gen-tx:l2 0 lt-own [%escape ~litbud])) - =^ f state (n state %bat q:(gen-tx:l2 0 litbud-own [%reject ~linnup-torsyx])) + =^ f state (n state %bat q:(gen-tx 0 marbud-own lt-spawn)) + =^ f state (n state %bat q:(gen-tx 0 lt-xfr lt-transfer-yes-breach)) + =^ f state (n state %bat q:(gen-tx 0 lt-own [%escape ~litbud])) + =^ f state (n state %bat q:(gen-tx 0 litbud-own [%reject ~linnup-torsyx])) escape.net:(~(got by points.state) ~linnup-torsyx) :: ++ test-linnup-torsyx-l2-detach ^- tang @@ -931,9 +750,9 @@ =| =^state:naive =^ f state (init-marbud state) =^ f state (init-litbud state) - =^ f state (n state %bat q:(gen-tx:l2 0 marbud-own lt-spawn)) - =^ f state (n state %bat q:(gen-tx:l2 0 lt-xfr lt-transfer-yes-breach)) - =^ f state (n state %bat q:(gen-tx:l2 1 marbud-own [%detach ~linnup-torsyx])) + =^ f state (n state %bat q:(gen-tx 0 marbud-own lt-spawn)) + =^ f state (n state %bat q:(gen-tx 0 lt-xfr lt-transfer-yes-breach)) + =^ f state (n state %bat q:(gen-tx 1 marbud-own [%detach ~linnup-torsyx])) [escape.net sponsor.net]:(~(got by points.state) ~linnup-torsyx) :: :: TODO: signature format changed; regenerate From 49fdf0a49675e7da8dcbad9c5032c05d743c1b30 Mon Sep 17 00:00:00 2001 From: drbeefsupreme Date: Tue, 11 May 2021 17:33:57 -0400 Subject: [PATCH 21/39] naive: fix key changing tests --- pkg/arvo/lib/naive-transactions.hoon | 2 +- pkg/arvo/tests/lib/naive.hoon | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/arvo/lib/naive-transactions.hoon b/pkg/arvo/lib/naive-transactions.hoon index 20dbe8b84..82d4cc9dc 100644 --- a/pkg/arvo/lib/naive-transactions.hoon +++ b/pkg/arvo/lib/naive-transactions.hoon @@ -1,7 +1,7 @@ /+ naive, ethereum :: Types |% -+$ address @ux ++$ address address:ethereum +$ nonce @ud +$ proxy ?(%own %spawn %manage %vote %transfer) +$ skp [=ship pk=@ =proxy] diff --git a/pkg/arvo/tests/lib/naive.hoon b/pkg/arvo/tests/lib/naive.hoon index e26473254..da5de9b71 100644 --- a/pkg/arvo/tests/lib/naive.hoon +++ b/pkg/arvo/tests/lib/naive.hoon @@ -94,7 +94,7 @@ (log lost-sponsor:log-names:naive *@ux lost parent ~) :: ++ changed-keys - |= [=ship encr=@ auth=@ suite=@ life=@] + |= [=ship suite=@ encr=@ auth=@ life=@] =/ keys=@ux %: can 8 1^life @@ -240,7 +240,7 @@ :: ++ test-l1-changed-keys ^- tang =/ life 1 - =/ new-keys [~bud encr auth suit life] + =/ new-keys [~bud suit encr auth life] :: %+ expect-eq !> [suit auth encr] @@ -386,7 +386,7 @@ state :: ++ test-marbud-l2-change-keys ^- tang - =/ new-keys [%configure-keys encr auth suit |] + =/ new-keys [%configure-keys suit encr auth |] =/ marbud-mproxy [%set-management-proxy (addr %marbud-mkey)] :: ;: weld @@ -415,7 +415,7 @@ :: TODO: transfer breach via transfer proxy ++ test-marbud-l2-proxies-transfer ^- tang =/ marbud-t1 [~marbud %marbud-key-1 %transfer] - =/ new-keys [%configure-keys encr auth suit |] + =/ new-keys [%configure-keys suit encr auth |] =/ marbud-sproxy [%set-spawn-proxy (addr %marbud-skey)] =/ marbud-mproxy [%set-management-proxy (addr %marbud-mkey)] =/ marbud-tproxy [%set-transfer-proxy (addr %marbud-key-1)] @@ -492,8 +492,8 @@ :: TODO: life+rift changes via transfer proxy :: ++ test-marbud-keys-life-rift ^- tang - =/ new-keys-no-reset [%configure-keys encr auth suit |] - =/ new-keys-yes-reset [%configure-keys encr auth suit &] + =/ new-keys-no-reset [%configure-keys suit encr auth |] + =/ new-keys-yes-reset [%configure-keys suit encr auth &] =/ zero-keys-no-reset [%configure-keys 0 0 0 |] =/ zero-keys-yes-reset [%configure-keys 0 0 0 &] :: @@ -535,8 +535,8 @@ == :: ++ test-marbud-transfer-life-rift ^- tang - =/ new-keys-no-reset [%configure-keys encr auth suit |] - =/ new-keys-yes-reset [%configure-keys encr auth suit &] + =/ new-keys-no-reset [%configure-keys suit encr auth |] + =/ new-keys-yes-reset [%configure-keys suit encr auth &] =/ zero-keys-no-reset [%configure-keys 0 0 0 |] =/ zero-keys-yes-reset [%configure-keys 0 0 0 &] =/ marbud-transfer-no-breach [%transfer-point (addr %marbud-key-1) |] From 31cc219997d9092cbae8218e983014b534ef71e5 Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Sun, 25 Apr 2021 15:37:01 +0200 Subject: [PATCH 22/39] naive: support "get point" scry --- pkg/arvo/app/azimuth.hoon | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pkg/arvo/app/azimuth.hoon b/pkg/arvo/app/azimuth.hoon index 70fdd8bcd..45e165469 100644 --- a/pkg/arvo/app/azimuth.hoon +++ b/pkg/arvo/app/azimuth.hoon @@ -256,11 +256,19 @@ ++ on-leave on-leave:def ++ on-peek |= =path - ?: =(/x/nas path) - ``nas+!>(nas.state) - ?: =(/x/logs path) + ^- (unit (unit cage)) + ?+ path (on-peek:def path) + [%x %logs ~] ``logs+!>(logs.state) - ~ + :: + [%x %nas ~] + ``nas+!>(nas.state) + :: + [%x %nas @t ~] + ?~ ship=(rush i.t.t.path ;~(pfix sig fed:ag)) + ``noun+!>(*(unit point:naive)) + ``noun+!>((~(get by points.nas.state) u.ship)) + == :: ++ on-agent |= [=wire =sign:agent:gall] From de3007dc06842406475724799c27cb9f74bd54e6 Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Sun, 25 Apr 2021 15:37:16 +0200 Subject: [PATCH 23/39] json-rpc: add jsonrpc key to request --- pkg/arvo/sur/json/rpc.hoon | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/arvo/sur/json/rpc.hoon b/pkg/arvo/sur/json/rpc.hoon index 350f2cae1..809c1935a 100644 --- a/pkg/arvo/sur/json/rpc.hoon +++ b/pkg/arvo/sur/json/rpc.hoon @@ -3,6 +3,7 @@ |% +$ request $: id=@t + jsonrpc=@t method=@t params=request-params == From afd3c9b85e172f22cd465590c332fdc380420bef Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Sun, 25 Apr 2021 15:37:40 +0200 Subject: [PATCH 24/39] naive: add azimuth rpc api Currently supports one endpoint 'get-point' that returns Azimuth Point data (see +point in %/lib/naive.hoon), for a given ship. To run it: curl -X POST --data '{ "jsonrpc": "2.0", "method": "get-point", "params": {"ship": "~sampel-palnet"}, "id": 1234 }' http://localhost:8080/v1/azimuth --- pkg/arvo/app/azimuth-rpc.hoon | 243 +++++++++++++++++++++++ pkg/arvo/gen/azimuth-rpc/disconnect.hoon | 4 + 2 files changed, 247 insertions(+) create mode 100644 pkg/arvo/app/azimuth-rpc.hoon create mode 100644 pkg/arvo/gen/azimuth-rpc/disconnect.hoon diff --git a/pkg/arvo/app/azimuth-rpc.hoon b/pkg/arvo/app/azimuth-rpc.hoon new file mode 100644 index 000000000..4911ae362 --- /dev/null +++ b/pkg/arvo/app/azimuth-rpc.hoon @@ -0,0 +1,243 @@ +:: Azimuth RPC API +:: +/- rpc=json-rpc +/+ naive, *server, default-agent, verb, dbug, version +|% ++$ card card:agent:gall +:: ++$ state-0 [%0 ~] +-- +:: +%+ verb | +%- agent:dbug +:: +=| state-0 +=* state - +:: +^- agent:gall +=< + |_ =bowl:gall + +* this . + do ~(. +> bowl) + def ~(. (default-agent this %|) bowl) + :: + ++ on-init + ^- (quip card _this) + ~& > 'init' + :_ this + [%pass /bind %arvo %e %connect [~ [%v1 %azimuth ~]] dap.bowl]~ + :: + ++ on-save !>(state) + ++ on-load + |= old=vase + ^- (quip card _this) + [~ this(state !<(state-0 old))] + :: + ++ on-poke + |= [=mark =vase] + ^- (quip card _this) + |^ + ?> (team:title our.bowl src.bowl) + ?+ mark (on-poke:def mark vase) + %handle-http-request + =+ !<([id=@ta req=inbound-request:eyre] vase) + :_ this + %+ give-simple-payload:app id + (handle-http-request req) + :: + %azimuth-action + =+ !<([%disconnect bind=binding:eyre] vase) + ~& >>> "disconnecting at {}" + :_ this + [[%pass /bind %arvo %e %disconnect bind]]~ + == + :: + ++ handle-http-request + |= =inbound-request:eyre + ^- simple-payload:http + |^ + =* req request.inbound-request + =* headers header-list.req + =/ req-line (parse-request-line url.req) + ?. =(method.req %'POST') + :: TODO: method not supported + :: + not-found:gen + ?~ json-rpc=(validate-json-rpc body.req) + :: TODO: malformed request + :: + not-found:gen + (process-rpc-request:do u.json-rpc) + :: TODO: validate that format is e.g. 'get-point' + :: TODO: maybe replace with getPoint and translate to %term + :: + ++ parse-method |=(t=@t t) + :: TODO: move to library + :: + ++ validate-json-rpc + |= body=(unit octs) + ^- (unit request:rpc) + ?~ body ~ + ?~ jon=(de-json:html q.u.body) ~ + :: ignores non-object responses + :: + :: ?. ?=([%o *] json) ~|([%format-not-valid json] !!) + ?. ?=([%o *] u.jon) ~ + %- some + %. u.jon + =, dejs:format + %- ot + :~ ['id' no] + ['jsonrpc' so] + ['method' (cu parse-method so)] + :: + :- 'params' + |= =json + ^- request-params:rpc + ?: =(%a -.json) + [%list ((ar same) json)] + ?. =(%o -.json) + !! + [%object ~(tap by ((om same) json))] + == + -- + -- + :: + ++ on-watch + |= =path + ^- (quip card _this) + ?> (team:title our.bowl src.bowl) + ?+ path (on-watch:def path) + [%http-response *] [~ this] + == + :: + ++ on-arvo + |= [=wire =sign-arvo] + ^- (quip card _this) + ?+ sign-arvo (on-arvo:def wire sign-arvo) + [%eyre %bound *] + ~? !accepted.sign-arvo + [dap.bowl 'bind rejected!' binding.sign-arvo] + [~ this] + == + :: + ++ on-leave on-leave:def + ++ on-peek on-peek:def + ++ on-agent on-agent:def + ++ on-fail on-fail:def + -- +:: +|_ =bowl:gall +++ process-rpc-request + |= req=request:rpc + ^- simple-payload:http + |^ + ?+ method.req ~|([%unsupported-azimuth-request method.req] !!) + %get-point (get-point id.req params.req) + == + :: TODO: move this to a library + :: TODO: handle rpc error responses properly + :: + ++ get-point + |= [id=@t params=request-params:rpc] + %- json-response:gen + %- rpc-response-to-json + ?. ?=([%object *] params) + [%error id 'X' 'RPC params must be an object'] + ?> ?=(^ +.params) + ?. =('ship' p.i.+.params) + [%error id 'X' 'A "ship" key must exist'] + =/ ship=(unit ship) + (rush (so:dejs:format q.i.+.params) ;~(pfix sig fed:ag)) + ?~ ship + [%error id 'X' 'Ship @p invalid'] + ?~ point=(scry-point u.ship) + [%error id 'X' 'Ship @p not found'] + [%result id (point-to-json u.point)] + :: + ++ point-to-json + |= =point:naive + ^- json + |^ + :: :+ %result id + :- %o + %- molt + ^- (list [@t json]) + :~ ['dominion' s+dominion.point] + :: + :- 'ownership' + :- %o + %- molt + =* own own.point + ^- (list [@t json]) + :~ ['owner' (own-to-json owner.own)] + ['spawnProxy' (own-to-json spawn-proxy.own)] + ['managementProxy' (own-to-json spawn-proxy.own)] + ['votingProxy' (own-to-json management-proxy.own)] + ['transferProxy' (own-to-json transfer-proxy.own)] + == + :: + :- 'network' + :- %o + =, enjs:format + %- molt + =* net net.point + ^- (list [@t json]) + :* ['life' (numb life.net)] + ['pass' s+(crip ((x-co:co 20) pass.net))] + ['rift' (numb rift.net)] + :- 'sponsor' + :- %o + %- molt ^- (list [@t json]) + ~[['has' b+has.sponsor.net] ['who' (ship who.sponsor.net)]] + :: + ?~ escape.net ~ + ['escape' (ship u.escape.net)]~ + == == + :: + ++ own-to-json + |= [=address:naive =nonce:naive] + ^- json + :- %o + %- molt ^- (list [@t json]) + :~ ['address' s+(crip "0x{((x-co:co 20) address)}")] + ['nonce' (numb:enjs:format nonce)] + == + -- + :: TODO: move to rpc library + :: + ++ rpc-response-to-json + |= =response:rpc + ^- json + :: TODO: consider all cases + :: + ?+ -.response ~|([%unsupported-rpc-response response] !!) + %result + :- %o + %- molt + ^- (list [@t json]) + ~[['id' s+id.response] ['res' res.response]] + :: + %error + :- %o + %- molt + ^- (list [@t json]) + :~ ['id' s+id.response] + ['code' s+code.response] + ['message' s+message.response] + == + == + -- +:: +++ scry-point + |= =ship + .^ (unit point:naive) + %gx + (scot %p our.bowl) + %naive + (scot %da now.bowl) + %nas + (scot %p ship) + /noun + == +-- diff --git a/pkg/arvo/gen/azimuth-rpc/disconnect.hoon b/pkg/arvo/gen/azimuth-rpc/disconnect.hoon new file mode 100644 index 000000000..7b3214713 --- /dev/null +++ b/pkg/arvo/gen/azimuth-rpc/disconnect.hoon @@ -0,0 +1,4 @@ +:: +:- %say +|= [* [=binding:eyre ~] ~] +[%azimuth-action %disconnect binding] From 0c704bb145a9a35a808e2b737149ba41d93b9b8f Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Thu, 29 Apr 2021 10:56:29 +0200 Subject: [PATCH 25/39] json-rpc: add response-to-json --- pkg/arvo/app/azimuth-rpc.hoon | 27 ++------------------------- pkg/arvo/lib/json/rpc.hoon | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/pkg/arvo/app/azimuth-rpc.hoon b/pkg/arvo/app/azimuth-rpc.hoon index 4911ae362..5c26790f2 100644 --- a/pkg/arvo/app/azimuth-rpc.hoon +++ b/pkg/arvo/app/azimuth-rpc.hoon @@ -1,7 +1,7 @@ :: Azimuth RPC API :: /- rpc=json-rpc -/+ naive, *server, default-agent, verb, dbug, version +/+ naive, json-rpc, *server, default-agent, verb, dbug, version |% +$ card card:agent:gall :: @@ -141,7 +141,7 @@ ++ get-point |= [id=@t params=request-params:rpc] %- json-response:gen - %- rpc-response-to-json + %- response-to-json:json-rpc ?. ?=([%object *] params) [%error id 'X' 'RPC params must be an object'] ?> ?=(^ +.params) @@ -204,29 +204,6 @@ ['nonce' (numb:enjs:format nonce)] == -- - :: TODO: move to rpc library - :: - ++ rpc-response-to-json - |= =response:rpc - ^- json - :: TODO: consider all cases - :: - ?+ -.response ~|([%unsupported-rpc-response response] !!) - %result - :- %o - %- molt - ^- (list [@t json]) - ~[['id' s+id.response] ['res' res.response]] - :: - %error - :- %o - %- molt - ^- (list [@t json]) - :~ ['id' s+id.response] - ['code' s+code.response] - ['message' s+message.response] - == - == -- :: ++ scry-point diff --git a/pkg/arvo/lib/json/rpc.hoon b/pkg/arvo/lib/json/rpc.hoon index e44ad1d68..c5ead16c7 100644 --- a/pkg/arvo/lib/json/rpc.hoon +++ b/pkg/arvo/lib/json/rpc.hoon @@ -28,4 +28,26 @@ %object [%o (~(gas by *(map @t json)) +.params)] == == +:: +++ response-to-json + |= =response + ^- json + :: TODO: consider all cases + :: + ?+ -.response ~|([%unsupported-rpc-response response] !!) + %result + :- %o + %- molt + ^- (list [@t json]) + ~[['id' s+id.response] ['res' res.response]] + :: + %error + :- %o + %- molt + ^- (list [@t json]) + :~ ['id' s+id.response] + ['code' s+code.response] + ['message' s+message.response] + == + == -- From d8a24d7d6b660cb5c28d90c9b314d45e23f2cbbe Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Thu, 29 Apr 2021 11:14:32 +0200 Subject: [PATCH 26/39] naive: add json library for rpc responses --- pkg/arvo/app/azimuth-rpc.hoon | 62 +++++------------------------------ pkg/arvo/lib/azimuth-rpc.hoon | 53 ++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 53 deletions(-) create mode 100644 pkg/arvo/lib/azimuth-rpc.hoon diff --git a/pkg/arvo/app/azimuth-rpc.hoon b/pkg/arvo/app/azimuth-rpc.hoon index 5c26790f2..ed1d0dedf 100644 --- a/pkg/arvo/app/azimuth-rpc.hoon +++ b/pkg/arvo/app/azimuth-rpc.hoon @@ -1,7 +1,14 @@ :: Azimuth RPC API :: /- rpc=json-rpc -/+ naive, json-rpc, *server, default-agent, verb, dbug, version +/+ naive, + azimuth-rpc, + json-rpc, + *server, + default-agent, + verb, + dbug, + version |% +$ card card:agent:gall :: @@ -135,7 +142,6 @@ ?+ method.req ~|([%unsupported-azimuth-request method.req] !!) %get-point (get-point id.req params.req) == - :: TODO: move this to a library :: TODO: handle rpc error responses properly :: ++ get-point @@ -153,57 +159,7 @@ [%error id 'X' 'Ship @p invalid'] ?~ point=(scry-point u.ship) [%error id 'X' 'Ship @p not found'] - [%result id (point-to-json u.point)] - :: - ++ point-to-json - |= =point:naive - ^- json - |^ - :: :+ %result id - :- %o - %- molt - ^- (list [@t json]) - :~ ['dominion' s+dominion.point] - :: - :- 'ownership' - :- %o - %- molt - =* own own.point - ^- (list [@t json]) - :~ ['owner' (own-to-json owner.own)] - ['spawnProxy' (own-to-json spawn-proxy.own)] - ['managementProxy' (own-to-json spawn-proxy.own)] - ['votingProxy' (own-to-json management-proxy.own)] - ['transferProxy' (own-to-json transfer-proxy.own)] - == - :: - :- 'network' - :- %o - =, enjs:format - %- molt - =* net net.point - ^- (list [@t json]) - :* ['life' (numb life.net)] - ['pass' s+(crip ((x-co:co 20) pass.net))] - ['rift' (numb rift.net)] - :- 'sponsor' - :- %o - %- molt ^- (list [@t json]) - ~[['has' b+has.sponsor.net] ['who' (ship who.sponsor.net)]] - :: - ?~ escape.net ~ - ['escape' (ship u.escape.net)]~ - == == - :: - ++ own-to-json - |= [=address:naive =nonce:naive] - ^- json - :- %o - %- molt ^- (list [@t json]) - :~ ['address' s+(crip "0x{((x-co:co 20) address)}")] - ['nonce' (numb:enjs:format nonce)] - == - -- + [%result id (point-to-json:azimuth-rpc u.point)] -- :: ++ scry-point diff --git a/pkg/arvo/lib/azimuth-rpc.hoon b/pkg/arvo/lib/azimuth-rpc.hoon new file mode 100644 index 000000000..284134987 --- /dev/null +++ b/pkg/arvo/lib/azimuth-rpc.hoon @@ -0,0 +1,53 @@ +/- rpc=json-rpc +/+ naive +:: +|% +++ point-to-json + |= =point:naive + ^- json + |^ + :- %o + %- molt + ^- (list [@t json]) + :~ ['dominion' s+dominion.point] + :: + :- 'ownership' + :- %o + %- molt + =* own own.point + ^- (list [@t json]) + :~ ['owner' (own-to-json owner.own)] + ['spawnProxy' (own-to-json spawn-proxy.own)] + ['managementProxy' (own-to-json management-proxy.own)] + ['votingProxy' (own-to-json voting-proxy.own)] + ['transferProxy' (own-to-json transfer-proxy.own)] + == + :: + :- 'network' + :- %o + =, enjs:format + %- molt + =* net net.point + ^- (list [@t json]) + :* ['life' (numb life.net)] + ['pass' s+(crip ((x-co:co 20) pass.net))] + ['rift' (numb rift.net)] + :- 'sponsor' + :- %o + %- molt ^- (list [@t json]) + ~[['has' b+has.sponsor.net] ['who' (ship who.sponsor.net)]] + :: + ?~ escape.net ~ + ['escape' (ship u.escape.net)]~ + == == + :: + ++ own-to-json + |= [=address:naive =nonce:naive] + ^- json + :- %o + %- molt ^- (list [@t json]) + :~ ['address' s+(crip "0x{((x-co:co 20) address)}")] + ['nonce' (numb:enjs:format nonce)] + == + -- +-- \ No newline at end of file From 843fe4ce386a732d86dbab476f1245fdd961cfdb Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Thu, 29 Apr 2021 11:23:50 +0200 Subject: [PATCH 27/39] json-rpc: add validation for json-rpc request --- pkg/arvo/app/azimuth-rpc.hoon | 36 ++++------------------------------- pkg/arvo/lib/json/rpc.hoon | 27 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 32 deletions(-) diff --git a/pkg/arvo/app/azimuth-rpc.hoon b/pkg/arvo/app/azimuth-rpc.hoon index ed1d0dedf..35b9a4ad0 100644 --- a/pkg/arvo/app/azimuth-rpc.hoon +++ b/pkg/arvo/app/azimuth-rpc.hoon @@ -70,43 +70,15 @@ :: TODO: method not supported :: not-found:gen - ?~ json-rpc=(validate-json-rpc body.req) + ?~ rpc-request=(validate-request:json-rpc body.req parse-method) :: TODO: malformed request :: not-found:gen - (process-rpc-request:do u.json-rpc) - :: TODO: validate that format is e.g. 'get-point' - :: TODO: maybe replace with getPoint and translate to %term + (process-rpc-request:do u.rpc-request) + :: TODO: validate that format is e.g. 'getPoint' + :: TODO: maybe use getPoint and translate to %get-point :: ++ parse-method |=(t=@t t) - :: TODO: move to library - :: - ++ validate-json-rpc - |= body=(unit octs) - ^- (unit request:rpc) - ?~ body ~ - ?~ jon=(de-json:html q.u.body) ~ - :: ignores non-object responses - :: - :: ?. ?=([%o *] json) ~|([%format-not-valid json] !!) - ?. ?=([%o *] u.jon) ~ - %- some - %. u.jon - =, dejs:format - %- ot - :~ ['id' no] - ['jsonrpc' so] - ['method' (cu parse-method so)] - :: - :- 'params' - |= =json - ^- request-params:rpc - ?: =(%a -.json) - [%list ((ar same) json)] - ?. =(%o -.json) - !! - [%object ~(tap by ((om same) json))] - == -- -- :: diff --git a/pkg/arvo/lib/json/rpc.hoon b/pkg/arvo/lib/json/rpc.hoon index c5ead16c7..89f100b81 100644 --- a/pkg/arvo/lib/json/rpc.hoon +++ b/pkg/arvo/lib/json/rpc.hoon @@ -50,4 +50,31 @@ ['message' s+message.response] == == +:: +++ validate-request + |= [body=(unit octs) parse-method=$-(@t term)] + ^- (unit request) + ?~ body ~ + ?~ jon=(de-json:html q.u.body) ~ + :: ignores non-object responses + :: + :: ?. ?=([%o *] json) ~|([%format-not-valid json] !!) + ?. ?=([%o *] u.jon) ~ + %- some + %. u.jon + =, dejs:format + %- ot + :~ ['id' no] + ['jsonrpc' so] + ['method' (cu parse-method so)] + :: + :- 'params' + |= =json + ^- request-params + ?: =(%a -.json) + [%list ((ar same) json)] + ?. =(%o -.json) + !! + [%object ~(tap by ((om same) json))] + == -- From fe8c36dd3f82845ef8d655a43f61e1c3aded5a1f Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Thu, 29 Apr 2021 12:10:58 +0200 Subject: [PATCH 28/39] naive: use agentio for scry point --- pkg/arvo/app/azimuth-rpc.hoon | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pkg/arvo/app/azimuth-rpc.hoon b/pkg/arvo/app/azimuth-rpc.hoon index 35b9a4ad0..857a58ec5 100644 --- a/pkg/arvo/app/azimuth-rpc.hoon +++ b/pkg/arvo/app/azimuth-rpc.hoon @@ -8,7 +8,8 @@ default-agent, verb, dbug, - version + version, + agentio |% +$ card card:agent:gall :: @@ -136,13 +137,8 @@ :: ++ scry-point |= =ship - .^ (unit point:naive) - %gx - (scot %p our.bowl) - %naive - (scot %da now.bowl) - %nas - (scot %p ship) - /noun + .^ (unit point:naive) + %gx + (~(scry agentio bowl) %naive /nas/[(scot %p ship)]/noun) == -- From fe6f189e33372b9f18ee703cd07d9aaed7bc59b8 Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Mon, 3 May 2021 13:21:16 +0200 Subject: [PATCH 29/39] json-rpc: add support for params as map object --- pkg/arvo/lib/json/rpc.hoon | 30 +++++++++++++++++------------- pkg/arvo/sur/json/rpc.hoon | 1 + 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/pkg/arvo/lib/json/rpc.hoon b/pkg/arvo/lib/json/rpc.hoon index 89f100b81..22d4d9536 100644 --- a/pkg/arvo/lib/json/rpc.hoon +++ b/pkg/arvo/lib/json/rpc.hoon @@ -24,10 +24,10 @@ :- %params ^- json ?- -.params - %list [%a +.params] - %object [%o (~(gas by *(map @t json)) +.params)] - == - == + %list [%a +.params] + %map [%o +.params] + %object [%o (~(gas by *(map @t json)) +.params)] + == == :: ++ response-to-json |= =response @@ -45,7 +45,9 @@ :- %o %- molt ^- (list [@t json]) - :~ ['id' s+id.response] + :~ :: FIXME: return 'id' as string, number or NULL + :: + ['id' s+id.response] ['code' s+code.response] ['message' s+message.response] == @@ -63,18 +65,20 @@ %- some %. u.jon =, dejs:format + :: TODO: If parsing fails, return a proper error (not 500) + :: %- ot - :~ ['id' no] - ['jsonrpc' so] + :~ :: FIXME: parse 'id' as string, number or NULL + :: + ['id' so] + ['jsonrpc' (su (jest '2.0'))] ['method' (cu parse-method so)] :: :- 'params' |= =json ^- request-params - ?: =(%a -.json) - [%list ((ar same) json)] - ?. =(%o -.json) - !! - [%object ~(tap by ((om same) json))] - == + ?+ -.json !! + %a [%list ((ar same) json)] + %o [%map ((om same) json)] + == == -- diff --git a/pkg/arvo/sur/json/rpc.hoon b/pkg/arvo/sur/json/rpc.hoon index 809c1935a..63f5a06f1 100644 --- a/pkg/arvo/sur/json/rpc.hoon +++ b/pkg/arvo/sur/json/rpc.hoon @@ -10,6 +10,7 @@ :: +$ request-params $% [%list (list json)] + [%map (map @t json)] [%object (list (pair @t json))] == +$ response From 36cdb9493d8870a8eb80ef52bbf58acca324324b Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Mon, 3 May 2021 13:35:21 +0200 Subject: [PATCH 30/39] naive: add jsonrpc parsing for naive txs --- pkg/arvo/app/azimuth-rpc.hoon | 70 ++++----- pkg/arvo/lib/azimuth-rpc.hoon | 258 ++++++++++++++++++++++++++++------ 2 files changed, 251 insertions(+), 77 deletions(-) diff --git a/pkg/arvo/app/azimuth-rpc.hoon b/pkg/arvo/app/azimuth-rpc.hoon index 857a58ec5..911d3abf6 100644 --- a/pkg/arvo/app/azimuth-rpc.hoon +++ b/pkg/arvo/app/azimuth-rpc.hoon @@ -50,8 +50,7 @@ %handle-http-request =+ !<([id=@ta req=inbound-request:eyre] vase) :_ this - %+ give-simple-payload:app id - (handle-http-request req) + (handle-http-request id req) :: %azimuth-action =+ !<([%disconnect bind=binding:eyre] vase) @@ -61,8 +60,8 @@ == :: ++ handle-http-request - |= =inbound-request:eyre - ^- simple-payload:http + |= [id=@ta =inbound-request:eyre] + ^- (list card) |^ =* req request.inbound-request =* headers header-list.req @@ -70,16 +69,23 @@ ?. =(method.req %'POST') :: TODO: method not supported :: - not-found:gen + (give-simple-payload:app id not-found:gen) ?~ rpc-request=(validate-request:json-rpc body.req parse-method) :: TODO: malformed request :: - not-found:gen - (process-rpc-request:do u.rpc-request) + (give-simple-payload:app id not-found:gen) + =/ [data=(unit cage) response=simple-payload:http] + (process-rpc-request:do u.rpc-request) + %+ weld + (give-simple-payload:app id response) + ?~ data ~ + :_ ~ + ^- card + [%pass / %agent [our.bowl %dice] %poke u.data] :: TODO: validate that format is e.g. 'getPoint' :: TODO: maybe use getPoint and translate to %get-point :: - ++ parse-method |=(t=@t t) + ++ parse-method |=(t=@t `term`t) -- -- :: @@ -109,36 +115,34 @@ :: |_ =bowl:gall ++ process-rpc-request - |= req=request:rpc - ^- simple-payload:http - |^ - ?+ method.req ~|([%unsupported-azimuth-request method.req] !!) - %get-point (get-point id.req params.req) - == - :: TODO: handle rpc error responses properly - :: - ++ get-point - |= [id=@t params=request-params:rpc] + |= request:rpc + ^- [(unit cage) simple-payload:http] + =; [data=(unit cage) =response:rpc] + :- data %- json-response:gen - %- response-to-json:json-rpc - ?. ?=([%object *] params) - [%error id 'X' 'RPC params must be an object'] - ?> ?=(^ +.params) - ?. =('ship' p.i.+.params) - [%error id 'X' 'A "ship" key must exist'] - =/ ship=(unit ship) - (rush (so:dejs:format q.i.+.params) ;~(pfix sig fed:ag)) - ?~ ship - [%error id 'X' 'Ship @p invalid'] - ?~ point=(scry-point u.ship) - [%error id 'X' 'Ship @p not found'] - [%result id (point-to-json:azimuth-rpc u.point)] - -- + (response-to-json:json-rpc response) + ?. ?=([%map *] params) + [~ [%error id 'X' 'RPC params must be an object']] + =, azimuth-rpc + ?+ method [~ [%error id 'X' 'Unsupported Azimuth RPC']] + %get-point [~ (get-point id +.params scry-point)] + %transfer-point (transfer-point id +.params) + %configure-keys (configure-keys id +.params) + %spawn (spawn id +.params) + %escape (escape id +.params) + %cancel-escape (cancel-escape id +.params) + %adopt (adopt id +.params) + %detach (detach id +.params) + %reject (reject id +.params) + %set-management-proxy (management-proxy id +.params) + %set-spawn-proxy (spawn-proxy id +.params) + %set-transfer-proxy (transfer-proxy id +.params) + == :: ++ scry-point |= =ship .^ (unit point:naive) %gx - (~(scry agentio bowl) %naive /nas/[(scot %p ship)]/noun) + (~(scry agentio bowl) %azimuth /nas/[(scot %p ship)]/noun) == -- diff --git a/pkg/arvo/lib/azimuth-rpc.hoon b/pkg/arvo/lib/azimuth-rpc.hoon index 284134987..e9a58fc56 100644 --- a/pkg/arvo/lib/azimuth-rpc.hoon +++ b/pkg/arvo/lib/azimuth-rpc.hoon @@ -1,53 +1,223 @@ +:: azimuth-rpc: command parsing and utilities +:: /- rpc=json-rpc /+ naive :: -|% -++ point-to-json - |= =point:naive - ^- json - |^ - :- %o - %- molt - ^- (list [@t json]) - :~ ['dominion' s+dominion.point] - :: - :- 'ownership' - :- %o - %- molt - =* own own.point - ^- (list [@t json]) - :~ ['owner' (own-to-json owner.own)] - ['spawnProxy' (own-to-json spawn-proxy.own)] - ['managementProxy' (own-to-json management-proxy.own)] - ['votingProxy' (own-to-json voting-proxy.own)] - ['transferProxy' (own-to-json transfer-proxy.own)] +=> :: Utilities + :: + |% + ++ extract + |% + ++ keys + |= params=(map @t json) + ^- (unit [encrypt=@ auth=@ crypto-suite=@ breach=?]) + ?~ data=(~(get by params) 'data') ~ + =, dejs:format + %- some + %. u.data + %- ot + :~ ['encrypt' so] + ['auth' so] + ['crypto-suite' so] + ['breach' bo] == :: - :- 'network' - :- %o - =, enjs:format - %- molt - =* net net.point - ^- (list [@t json]) - :* ['life' (numb life.net)] - ['pass' s+(crip ((x-co:co 20) pass.net))] - ['rift' (numb rift.net)] - :- 'sponsor' - :- %o - %- molt ^- (list [@t json]) - ~[['has' b+has.sponsor.net] ['who' (ship who.sponsor.net)]] - :: - ?~ escape.net ~ - ['escape' (ship u.escape.net)]~ - == == + ++ address-ship + |= params=(map @t json) + ^- (unit [@ux ship]) + ?~ data=(~(get by params) 'data') ~ + =, dejs:format + =; [add=(unit @ux) =ship] + ?~ add ~ + (some [u.add ship]) + %. u.data + %- ot + :~ ['address' (cu to-hex so)] + ['ship' (su ;~(pfix sig fed:ag))] + == + :: + ++ address + |= params=(map @t json) + ^- (unit @ux) + ?~ data=(~(get by params) 'data') ~ + =, dejs:format + %. u.data + (ot ['address' (cu to-hex so)]~) + :: + ++ sig + |= params=(map @t json) + ^- (unit @) + ?~ sig=(~(get by params) 'sig') ~ + (some (so:dejs:format u.sig)) + :: + ++ from + |= params=(map @t json) + ^- (unit [ship @t]) + ?~ from=(~(get by params) 'from') ~ + %- some + =, dejs:format + %. u.from + %- ot + :~ ['ship' (su ;~(pfix sig fed:ag))] + ['proxy' so] + == + -- :: - ++ own-to-json - |= [=address:naive =nonce:naive] + ++ point-to-json + |= =point:naive ^- json + |^ :- %o - %- molt ^- (list [@t json]) - :~ ['address' s+(crip "0x{((x-co:co 20) address)}")] - ['nonce' (numb:enjs:format nonce)] - == + %- molt + ^- (list [@t json]) + :~ ['dominion' s+dominion.point] + :: + :- 'ownership' + :- %o + %- molt + =* own own.point + ^- (list [@t json]) + :~ ['owner' (own-to-json owner.own)] + ['spawnProxy' (own-to-json spawn-proxy.own)] + ['managementProxy' (own-to-json management-proxy.own)] + ['votingProxy' (own-to-json voting-proxy.own)] + ['transferProxy' (own-to-json transfer-proxy.own)] + == + :: + :- 'network' + :- %o + =, enjs:format + %- molt ^- (list [@t json]) + =* net net.point + :* ['rift' (numb rift.net)] + :: + :- 'keys' + :- %o + %- molt ^- (list [@t json]) + :~ ['life' (numb life.keys.net)] + ['suite' (numb suite.keys.net)] + ['auth' (numb auth.keys.net)] + ['crypt' (numb crypt.keys.net)] + == + :: + ['rift' (numb rift.net)] + :- 'sponsor' + :- %o + %- molt ^- (list [@t json]) + ~[['has' b+has.sponsor.net] ['who' (ship who.sponsor.net)]] + :: + ?~ escape.net ~ + ['escape' (ship u.escape.net)]~ + == == + :: + ++ own-to-json + |= [=address:naive =nonce:naive] + ^- json + :- %o + %- molt ^- (list [@t json]) + :~ ['address' s+(crip "0x{((x-co:co 20) address)}")] + ['nonce' (numb:enjs:format nonce)] + == + -- + :: + ++ to-hex + |= =cord + ^- (unit @ux) + =/ parsed=(unit (pair @ud @ux)) (de:base16:mimes:html cord) + ?~ parsed + ::~|(%non-hex-cord !!) + ~ + (some q.u.parsed) + :: + ++ sponsor-call + |= [id=@t params=(map @t json)] + ?. =((lent ~(tap by params)) 3) + [~ [%error id 'X' 'Params missing']] + ?> =((lent ~(tap by params)) 3) + =/ sig=(unit @) (sig:extract params) + =/ from=(unit [ship @t]) (from:extract params) + =/ data=(unit [@ux ship]) (address-ship:extract params) + ?. &(?=(^ sig) ?=(^ from) ?=(^ data)) + + [~ [%error id 'X' 'Failed to parsed']] + :_ [%result id s+'ok'] + %- some + noun+!>([u.sig u.from u.data]) + :: + ++ proxy-call + |= [id=@t params=(map @t json)] + ^- [(unit cage) response:rpc] + ?. =((lent ~(tap by params)) 3) + [~ [%error id 'X' 'Params missing']] + =/ sig=(unit @) (sig:extract params) + =/ from=(unit [ship @t]) (from:extract params) + =/ data=(unit @ux) (address:extract params) + ?. &(?=(^ sig) ?=(^ from) ?=(^ data)) + [~ [%error id 'X' 'Failed to parsed']] + :_ [%result id s+'ok'] + %- some + noun+!>([u.sig u.from u.data]) -- --- \ No newline at end of file +|% +:: TODO: move error handling to separate core +:: +++ get-point + |= [id=@t params=(map @t json) scry=$-(ship (unit point:naive))] + ^- response:rpc + ?. =((lent ~(tap by params)) 1) + [%error id 'X' 'Params missing'] + ?~ ship=(~(get by params) 'ship') + [%error id 'X' 'A "ship" key must exist'] + ?~ ship=(rush (so:dejs:format u.ship) ;~(pfix sig fed:ag)) + [%error id 'X' 'Ship @p invalid'] + ?~ point=(scry u.ship) + [%error id 'X' 'Ship @p not found'] + [%result id (point-to-json u.point)] +:: +++ transfer-point + |= [id=@t params=(map @t json)] + ^- [(unit cage) response:rpc] + ?. =((lent ~(tap by params)) 3) + [~ [%error id 'X' 'Params missing']] + =/ sig=(unit @) (sig:extract params) + =/ from=(unit [ship @t]) (from:extract params) + =/ data=(unit [@ux ?]) + ?~ data=(~(get by params) 'data') ~ + =, dejs:format + =; [add=(unit @ux) r=?] + ?~ add ~ + (some [u.add r]) + %. u.data + %- ot + ~[['address' (cu to-hex so)] ['reset' bo]] + ?. &(?=(^ sig) ?=(^ from) ?=(^ data)) + [~ [%error id 'X' 'Failed to parsed']] + :_ [%result id s+'ok'] + %- some + noun+!>([u.sig u.from u.data]) +:: +++ configure-keys + |= [id=@t params=(map @t json)] + ^- [(unit cage) response:rpc] + ?. =((lent ~(tap by params)) 3) + [~ [%error id 'X' 'Params missing']] + =/ sig=(unit @) (sig:extract params) + =/ from=(unit [ship @t]) (from:extract params) + =/ data=(unit [encrypt=@ auth=@ crypto-suite=@ breach=?]) + (keys:extract params) + ?. &(?=(^ sig) ?=(^ from) ?=(^ data)) + [~ [%error id 'X' 'Failed to parsed']] + :_ [%result id s+'ok'] + %- some + noun+!>([u.sig u.from u.data]) +:: +++ spawn sponsor-call +++ escape sponsor-call +++ cancel-escape sponsor-call +++ adopt sponsor-call +++ detach sponsor-call +++ reject sponsor-call +++ management-proxy proxy-call +++ spawn-proxy proxy-call +++ transfer-proxy proxy-call +-- From 0380d1873558bc85755509f52c0c85c8e7fe0a67 Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Tue, 4 May 2021 10:08:44 +0200 Subject: [PATCH 31/39] naive: add rpc response error codes --- pkg/arvo/app/azimuth-rpc.hoon | 8 +-- pkg/arvo/lib/azimuth-rpc.hoon | 94 ++++++++++++++++++++--------------- pkg/arvo/lib/json/rpc.hoon | 14 ++++-- 3 files changed, 66 insertions(+), 50 deletions(-) diff --git a/pkg/arvo/app/azimuth-rpc.hoon b/pkg/arvo/app/azimuth-rpc.hoon index 911d3abf6..135827dbc 100644 --- a/pkg/arvo/app/azimuth-rpc.hoon +++ b/pkg/arvo/app/azimuth-rpc.hoon @@ -121,10 +121,10 @@ :- data %- json-response:gen (response-to-json:json-rpc response) - ?. ?=([%map *] params) - [~ [%error id 'X' 'RPC params must be an object']] =, azimuth-rpc - ?+ method [~ [%error id 'X' 'Unsupported Azimuth RPC']] + ?. ?=([%map *] params) + [~ ~(parse error id)] + ?+ method [~ ~(method error id)] %get-point [~ (get-point id +.params scry-point)] %transfer-point (transfer-point id +.params) %configure-keys (configure-keys id +.params) @@ -136,7 +136,7 @@ %reject (reject id +.params) %set-management-proxy (management-proxy id +.params) %set-spawn-proxy (spawn-proxy id +.params) - %set-transfer-proxy (transfer-proxy id +.params) + %set-transfer-proxy (transfer-proxy id +.params) == :: ++ scry-point diff --git a/pkg/arvo/lib/azimuth-rpc.hoon b/pkg/arvo/lib/azimuth-rpc.hoon index e9a58fc56..3045658ed 100644 --- a/pkg/arvo/lib/azimuth-rpc.hoon +++ b/pkg/arvo/lib/azimuth-rpc.hoon @@ -12,9 +12,8 @@ |= params=(map @t json) ^- (unit [encrypt=@ auth=@ crypto-suite=@ breach=?]) ?~ data=(~(get by params) 'data') ~ - =, dejs:format - %- some %. u.data + =, dejs-soft:format %- ot :~ ['encrypt' so] ['auth' so] @@ -26,11 +25,12 @@ |= params=(map @t json) ^- (unit [@ux ship]) ?~ data=(~(get by params) 'data') ~ - =, dejs:format - =; [add=(unit @ux) =ship] - ?~ add ~ - (some [u.add ship]) + =; ans=(unit [add=(unit @ux) =ship]) + ?~ ans ~ + ?~ add.u.ans ~ + (some [u.add.u.ans ship.u.ans]) %. u.data + =, dejs-soft:format %- ot :~ ['address' (cu to-hex so)] ['ship' (su ;~(pfix sig fed:ag))] @@ -40,22 +40,26 @@ |= params=(map @t json) ^- (unit @ux) ?~ data=(~(get by params) 'data') ~ - =, dejs:format + =; ans=(unit (unit @ux)) + ?~ ans ~ + ?~ u.ans ~ + (some u.u.ans) + =, dejs-soft:format %. u.data (ot ['address' (cu to-hex so)]~) - :: + :: ++ sig |= params=(map @t json) ^- (unit @) + =, dejs-soft:format ?~ sig=(~(get by params) 'sig') ~ - (some (so:dejs:format u.sig)) + (so:dejs-soft:format u.sig) :: ++ from |= params=(map @t json) ^- (unit [ship @t]) ?~ from=(~(get by params) 'from') ~ - %- some - =, dejs:format + =, dejs-soft:format %. u.from %- ot :~ ['ship' (su ;~(pfix sig fed:ag))] @@ -131,15 +135,14 @@ :: ++ sponsor-call |= [id=@t params=(map @t json)] - ?. =((lent ~(tap by params)) 3) - [~ [%error id 'X' 'Params missing']] - ?> =((lent ~(tap by params)) 3) + ^- [(unit cage) response:rpc] + ?. =((lent ~(tap by params)) 3) + [~ ~(params error id)] =/ sig=(unit @) (sig:extract params) =/ from=(unit [ship @t]) (from:extract params) =/ data=(unit [@ux ship]) (address-ship:extract params) - ?. &(?=(^ sig) ?=(^ from) ?=(^ data)) - - [~ [%error id 'X' 'Failed to parsed']] + ?. &(?=(^ sig) ?=(^ from) ?=(^ data)) + [~ ~(parse error id)] :_ [%result id s+'ok'] %- some noun+!>([u.sig u.from u.data]) @@ -147,51 +150,60 @@ ++ proxy-call |= [id=@t params=(map @t json)] ^- [(unit cage) response:rpc] - ?. =((lent ~(tap by params)) 3) - [~ [%error id 'X' 'Params missing']] + ?. =((lent ~(tap by params)) 3) + [~ ~(params error id)] =/ sig=(unit @) (sig:extract params) =/ from=(unit [ship @t]) (from:extract params) =/ data=(unit @ux) (address:extract params) - ?. &(?=(^ sig) ?=(^ from) ?=(^ data)) - [~ [%error id 'X' 'Failed to parsed']] + ?. &(?=(^ sig) ?=(^ from) ?=(^ data)) + [~ ~(parse error id)] :_ [%result id s+'ok'] %- some noun+!>([u.sig u.from u.data]) + :: + ++ error + |_ id=@t + :: https://www.jsonrpc.org/specification#error_object + :: + ++ parse [%error id '-32700' 'Failed to parsed'] + ++ request [%error id '-32600' 'Invalid Request'] + ++ method [%error id '-32601' 'Method not found'] + ++ params [%error id '-32602' 'Invalid params'] + ++ internal [%error id '-32603' 'Internal error'] + -- -- |% -:: TODO: move error handling to separate core -:: ++ get-point |= [id=@t params=(map @t json) scry=$-(ship (unit point:naive))] ^- response:rpc - ?. =((lent ~(tap by params)) 1) - [%error id 'X' 'Params missing'] - ?~ ship=(~(get by params) 'ship') - [%error id 'X' 'A "ship" key must exist'] + ?. =((lent ~(tap by params)) 1) + ~(params error id) + ?~ ship=(~(get by params) 'ship') + ~(params error id) ?~ ship=(rush (so:dejs:format u.ship) ;~(pfix sig fed:ag)) - [%error id 'X' 'Ship @p invalid'] - ?~ point=(scry u.ship) - [%error id 'X' 'Ship @p not found'] + ~(params error id) + ?~ point=(scry u.ship) + ~(params error id) [%result id (point-to-json u.point)] :: ++ transfer-point |= [id=@t params=(map @t json)] ^- [(unit cage) response:rpc] - ?. =((lent ~(tap by params)) 3) - [~ [%error id 'X' 'Params missing']] - =/ sig=(unit @) (sig:extract params) - =/ from=(unit [ship @t]) (from:extract params) + ?. =((lent ~(tap by params)) 3) + [~ ~(params error id)] + =/ sig=(unit @) (sig:extract params) + =/ from=(unit [ship @t]) (from:extract params) =/ data=(unit [@ux ?]) ?~ data=(~(get by params) 'data') ~ - =, dejs:format =; [add=(unit @ux) r=?] ?~ add ~ (some [u.add r]) %. u.data + =, dejs:format %- ot ~[['address' (cu to-hex so)] ['reset' bo]] - ?. &(?=(^ sig) ?=(^ from) ?=(^ data)) - [~ [%error id 'X' 'Failed to parsed']] + ?: |(?=(~ sig) ?=(~ from) ?=(~ data)) + [~ ~(parse error id)] :_ [%result id s+'ok'] %- some noun+!>([u.sig u.from u.data]) @@ -199,14 +211,14 @@ ++ configure-keys |= [id=@t params=(map @t json)] ^- [(unit cage) response:rpc] - ?. =((lent ~(tap by params)) 3) - [~ [%error id 'X' 'Params missing']] + ?. =((lent ~(tap by params)) 3) + [~ ~(params error id)] =/ sig=(unit @) (sig:extract params) =/ from=(unit [ship @t]) (from:extract params) =/ data=(unit [encrypt=@ auth=@ crypto-suite=@ breach=?]) (keys:extract params) - ?. &(?=(^ sig) ?=(^ from) ?=(^ data)) - [~ [%error id 'X' 'Failed to parsed']] + ?. &(?=(^ sig) ?=(^ from) ?=(^ data)) + [~ ~(parse error id)] :_ [%result id s+'ok'] %- some noun+!>([u.sig u.from u.data]) diff --git a/pkg/arvo/lib/json/rpc.hoon b/pkg/arvo/lib/json/rpc.hoon index 22d4d9536..97543c704 100644 --- a/pkg/arvo/lib/json/rpc.hoon +++ b/pkg/arvo/lib/json/rpc.hoon @@ -39,16 +39,20 @@ :- %o %- molt ^- (list [@t json]) - ~[['id' s+id.response] ['res' res.response]] + :: FIXME: return 'id' as string, number or NULL + :: + :~ ['jsonrpc' s+'2.0'] + ['id' s+id.response] + ['res' res.response] + == :: %error :- %o %- molt ^- (list [@t json]) - :~ :: FIXME: return 'id' as string, number or NULL - :: - ['id' s+id.response] - ['code' s+code.response] + :~ ['jsonrpc' s+'2.0'] + ['id' ?~(id.response ~ s+id.response)] + ['code' n+code.response] ['message' s+message.response] == == From 00334d582eeaa604e2fa2a5921708c9eb89a8b91 Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Tue, 4 May 2021 10:36:50 +0200 Subject: [PATCH 32/39] naive: use +pairs:enjs for point-to-json reponse --- pkg/arvo/lib/azimuth-rpc.hoon | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/pkg/arvo/lib/azimuth-rpc.hoon b/pkg/arvo/lib/azimuth-rpc.hoon index 3045658ed..7ad8763df 100644 --- a/pkg/arvo/lib/azimuth-rpc.hoon +++ b/pkg/arvo/lib/azimuth-rpc.hoon @@ -70,15 +70,13 @@ ++ point-to-json |= =point:naive ^- json + =, enjs:format |^ - :- %o - %- molt - ^- (list [@t json]) + %- pairs :~ ['dominion' s+dominion.point] :: :- 'ownership' - :- %o - %- molt + %- pairs =* own own.point ^- (list [@t json]) :~ ['owner' (own-to-json owner.own)] @@ -89,15 +87,12 @@ == :: :- 'network' - :- %o - =, enjs:format - %- molt ^- (list [@t json]) + %- pairs =* net net.point :* ['rift' (numb rift.net)] :: :- 'keys' - :- %o - %- molt ^- (list [@t json]) + %- pairs :~ ['life' (numb life.keys.net)] ['suite' (numb suite.keys.net)] ['auth' (numb auth.keys.net)] @@ -106,8 +101,7 @@ :: ['rift' (numb rift.net)] :- 'sponsor' - :- %o - %- molt ^- (list [@t json]) + %- pairs ~[['has' b+has.sponsor.net] ['who' (ship who.sponsor.net)]] :: ?~ escape.net ~ @@ -117,8 +111,7 @@ ++ own-to-json |= [=address:naive =nonce:naive] ^- json - :- %o - %- molt ^- (list [@t json]) + %- pairs :~ ['address' s+(crip "0x{((x-co:co 20) address)}")] ['nonce' (numb:enjs:format nonce)] == From c150da0372d7bb21c2ccc7182ecbb1b5fffa715e Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Thu, 6 May 2021 08:14:04 +0200 Subject: [PATCH 33/39] naive: validate proxy in from is one of proxy:naive --- pkg/arvo/lib/azimuth-rpc.hoon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/lib/azimuth-rpc.hoon b/pkg/arvo/lib/azimuth-rpc.hoon index 7ad8763df..5c62f61c1 100644 --- a/pkg/arvo/lib/azimuth-rpc.hoon +++ b/pkg/arvo/lib/azimuth-rpc.hoon @@ -57,13 +57,13 @@ :: ++ from |= params=(map @t json) - ^- (unit [ship @t]) + ^- (unit [ship proxy:naive]) ?~ from=(~(get by params) 'from') ~ =, dejs-soft:format %. u.from %- ot :~ ['ship' (su ;~(pfix sig fed:ag))] - ['proxy' so] + ['proxy' (cu proxy:naive so)] == -- :: From 66d0c7d47b52d3607731763f84a066cbfce3be33 Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Thu, 6 May 2021 08:22:08 +0200 Subject: [PATCH 34/39] naive: handle malformed data in transfer-point --- pkg/arvo/lib/azimuth-rpc.hoon | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/pkg/arvo/lib/azimuth-rpc.hoon b/pkg/arvo/lib/azimuth-rpc.hoon index 5c62f61c1..960aaac05 100644 --- a/pkg/arvo/lib/azimuth-rpc.hoon +++ b/pkg/arvo/lib/azimuth-rpc.hoon @@ -21,6 +21,19 @@ ['breach' bo] == :: + ++ address-transfer + |= params=(map @t json) + ^- (unit [@ux ?]) + ?~ data=(~(get by params) 'data') ~ + =; ans=(unit [add=(unit @ux) r=?]) + ?~ ans ~ + ?~ add.u.ans ~ + (some [u.add.u.ans r.u.ans]) + %. u.data + =, dejs-soft:format + %- ot + ~[['address' (cu to-hex so)] ['reset' bo]] + :: ++ address-ship |= params=(map @t json) ^- (unit [@ux ship]) @@ -186,15 +199,7 @@ [~ ~(params error id)] =/ sig=(unit @) (sig:extract params) =/ from=(unit [ship @t]) (from:extract params) - =/ data=(unit [@ux ?]) - ?~ data=(~(get by params) 'data') ~ - =; [add=(unit @ux) r=?] - ?~ add ~ - (some [u.add r]) - %. u.data - =, dejs:format - %- ot - ~[['address' (cu to-hex so)] ['reset' bo]] + =/ data=(unit [@ux ?]) (address-transfer:extract params) ?: |(?=(~ sig) ?=(~ from) ?=(~ data)) [~ ~(parse error id)] :_ [%result id s+'ok'] From ae8d98c467e08c8cf4059f3c29f1e14ce882ec13 Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Thu, 6 May 2021 13:20:13 +0200 Subject: [PATCH 35/39] naive: add jsonrpc parsing for sending pending rolls --- pkg/arvo/app/azimuth-rpc.hoon | 27 ++++++- pkg/arvo/lib/azimuth-rpc.hoon | 136 ++++++++++++++++++++++++++++++---- 2 files changed, 147 insertions(+), 16 deletions(-) diff --git a/pkg/arvo/app/azimuth-rpc.hoon b/pkg/arvo/app/azimuth-rpc.hoon index 135827dbc..7eb82ccca 100644 --- a/pkg/arvo/app/azimuth-rpc.hoon +++ b/pkg/arvo/app/azimuth-rpc.hoon @@ -136,7 +136,10 @@ %reject (reject id +.params) %set-management-proxy (management-proxy id +.params) %set-spawn-proxy (spawn-proxy id +.params) - %set-transfer-proxy (transfer-proxy id +.params) + %set-transfer-proxy (transfer-proxy id +.params) + %pending (pending id +.params all:pending-rolls) + %pending-by-ship (pending-ship id +.params ship:pending-rolls) + %pending-by-address (pending-address id +.params addr:pending-rolls) == :: ++ scry-point @@ -145,4 +148,26 @@ %gx (~(scry agentio bowl) %azimuth /nas/[(scot %p ship)]/noun) == +:: +++ pending-rolls + |% + ++ all + .^ (list tx:naive) + %gx + (~(scry agentio bowl) %dice /pending/all/noun) + == + ++ ship + |= =^ship + .^ (list tx:naive) + %gx + (~(scry agentio bowl) %dice /pending/ship/[(scot %p ship)]/noun) + == + ++ addr + |= =address:naive + .^ (list tx:naive) + %gx + %+ ~(scry agentio bowl) %dice + /pending/address/[(scot %ux address)]/noun + == + -- -- diff --git a/pkg/arvo/lib/azimuth-rpc.hoon b/pkg/arvo/lib/azimuth-rpc.hoon index 960aaac05..a9af00cb2 100644 --- a/pkg/arvo/lib/azimuth-rpc.hoon +++ b/pkg/arvo/lib/azimuth-rpc.hoon @@ -36,9 +36,9 @@ :: ++ address-ship |= params=(map @t json) - ^- (unit [@ux ship]) + ^- (unit [@ux @p]) ?~ data=(~(get by params) 'data') ~ - =; ans=(unit [add=(unit @ux) =ship]) + =; ans=(unit [add=(unit @ux) ship=@p]) ?~ ans ~ ?~ add.u.ans ~ (some [u.add.u.ans ship.u.ans]) @@ -60,7 +60,15 @@ =, dejs-soft:format %. u.data (ot ['address' (cu to-hex so)]~) - :: + :: + ++ ship + |= params=(map @t json) + ^- (unit @p) + ?~ data=(~(get by params) 'data') ~ + =, dejs-soft:format + %. u.data + (ot ['ship' (su ;~(pfix sig fed:ag))]~) + :: ++ sig |= params=(map @t json) ^- (unit @) @@ -70,7 +78,7 @@ :: ++ from |= params=(map @t json) - ^- (unit [ship proxy:naive]) + ^- (unit [@p proxy:naive]) ?~ from=(~(get by params) 'from') ~ =, dejs-soft:format %. u.from @@ -80,6 +88,60 @@ == -- :: + ++ pending-to-json + |= pending=(list tx:naive) + ^- json + =, enjs:format + :- %a + %+ turn pending + |= =tx:naive + ^- json + |^ + =, enjs:format + %- pairs + :~ ['tx' (parse-tx +.tx)] + :: + :- 'from' + %- pairs + ~[['ship' (ship ship.from.tx)] ['proxy' s+proxy.from.tx]] + == + :: + ++ parse-tx + |= tx=skim-tx:naive + ^- json + %- pairs + :~ ['type' s+-.tx] + :: + :- 'data' + %- pairs + ?- -.tx + %transfer-point (en-transfer +.tx) + %spawn (en-spawn +.tx) + %configure-keys (en-keys +.tx) + %escape ~[(en-ship parent.tx)] + %cancel-escape ~[(en-ship parent.tx)] + %adopt ~[(en-ship ship.tx)] + %reject ~[(en-ship ship.tx)] + %detach ~[(en-ship ship.tx)] + %set-management-proxy ~[(en-address address.tx)] + %set-spawn-proxy ~[(en-address address.tx)] + %set-transfer-proxy ~[(en-address address.tx)] + == == + :: + ++ en-ship |=(s=@p ship+(ship s)) + ++ en-address |=(a=@ux address+s+(crip "0x{((x-co:co 20) a)}")) + ++ en-spawn |=([s=@p a=@ux] ~[(en-ship s) (en-address a)]) + ++ en-transfer |=([a=@ux r=?] ~[(en-address a) reset+b+r]) + ++ en-keys + |= [encrypt=@ auth=@ crypto-suite=@ breach=?] + ^- (list [@t json]) + :~ ['encrypt' (numb encrypt)] + ['auth' (numb auth)] + ['crypto-suite' (numb crypto-suite)] + ['breach' b+breach] + == + -- + :: ++ point-to-json |= =point:naive ^- json @@ -144,9 +206,9 @@ ^- [(unit cage) response:rpc] ?. =((lent ~(tap by params)) 3) [~ ~(params error id)] - =/ sig=(unit @) (sig:extract params) - =/ from=(unit [ship @t]) (from:extract params) - =/ data=(unit [@ux ship]) (address-ship:extract params) + =/ sig=(unit @) (sig:extract params) + =/ from=(unit [@p proxy:naive]) (from:extract params) + =/ data=(unit [@ux @p]) (address-ship:extract params) ?. &(?=(^ sig) ?=(^ from) ?=(^ data)) [~ ~(parse error id)] :_ [%result id s+'ok'] @@ -158,9 +220,9 @@ ^- [(unit cage) response:rpc] ?. =((lent ~(tap by params)) 3) [~ ~(params error id)] - =/ sig=(unit @) (sig:extract params) - =/ from=(unit [ship @t]) (from:extract params) - =/ data=(unit @ux) (address:extract params) + =/ sig=(unit @) (sig:extract params) + =/ from=(unit [@p proxy:naive]) (from:extract params) + =/ data=(unit @ux) (address:extract params) ?. &(?=(^ sig) ?=(^ from) ?=(^ data)) [~ ~(parse error id)] :_ [%result id s+'ok'] @@ -171,11 +233,12 @@ |_ id=@t :: https://www.jsonrpc.org/specification#error_object :: - ++ parse [%error id '-32700' 'Failed to parsed'] - ++ request [%error id '-32600' 'Invalid Request'] - ++ method [%error id '-32601' 'Method not found'] - ++ params [%error id '-32602' 'Invalid params'] - ++ internal [%error id '-32603' 'Internal error'] + ++ parse [%error id '-32700' 'Failed to parsed'] + ++ request [%error id '-32600' 'Invalid Request'] + ++ method [%error id '-32601' 'Method not found'] + ++ params [%error id '-32602' 'Invalid params'] + ++ internal [%error id '-32603' 'Internal error'] + ++ not-found [%error id '-32000' 'Resource not found'] -- -- |% @@ -230,4 +293,47 @@ ++ management-proxy proxy-call ++ spawn-proxy proxy-call ++ transfer-proxy proxy-call +:: - readNonce(from=[ship proxy]) -> @ :: automatically increment for pending wraps +:: +++ read-nonce + |= [id=@t params=(map @t json) scry=$-([ship proxy:naive] (unit @))] + ^- response:rpc + ?. =((lent ~(tap by params)) 3) + ~(params error id) + ?~ from=(from:extract params) + ~(parse error id) + ?~ nonce=(scry u.from) + ~(params error id) + [%result id (numb:enjs:format u.nonce)] +:: +:: - readPendingRoll() -> (list tx) +:: +++ pending + |= [id=@t params=(map @t json) pending=(list tx:naive)] + ^- response:rpc + ?. =((lent ~(tap by params)) 0) + ~(params error id) + [%result id (pending-to-json pending)] +:: +:: - readPendingByShip(ship) -> (list tx) +:: +++ pending-by-ship + |= [id=@t params=(map @t json) scry=$-(ship (list tx:naive))] + ^- response:rpc + ?. =((lent ~(tap by params)) 1) + ~(params error id) + ?~ ship=(ship:extract params) + ~(parse error id) + [%result id (pending-to-json (scry u.ship))] +:: +:: - readPendingByAddress(address) -> (list tx) +:: +++ pending-by-address + |= [id=@t params=(map @t json) scry=$-(@ux (list tx:naive))] + ^- response:rpc + ?. =((lent ~(tap by params)) 1) + ~(params error id) + ?~ address=(address:extract params) + ~(parse error id) + [%result id (pending-to-json (scry u.address))] -- From 7ede24c3ccbf429d1db06f1ee5b5a206c6725e95 Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Thu, 6 May 2021 16:47:38 +0200 Subject: [PATCH 36/39] naive: first pass at tx history RPC --- pkg/arvo/app/azimuth-rpc.hoon | 19 +++++++-- pkg/arvo/lib/azimuth-rpc.hoon | 74 +++++++++++++++++++++++------------ 2 files changed, 65 insertions(+), 28 deletions(-) diff --git a/pkg/arvo/app/azimuth-rpc.hoon b/pkg/arvo/app/azimuth-rpc.hoon index 7eb82ccca..80a8ceb5a 100644 --- a/pkg/arvo/app/azimuth-rpc.hoon +++ b/pkg/arvo/app/azimuth-rpc.hoon @@ -137,9 +137,10 @@ %set-management-proxy (management-proxy id +.params) %set-spawn-proxy (spawn-proxy id +.params) %set-transfer-proxy (transfer-proxy id +.params) - %pending (pending id +.params all:pending-rolls) - %pending-by-ship (pending-ship id +.params ship:pending-rolls) - %pending-by-address (pending-address id +.params addr:pending-rolls) + %pending [~ (all:pending id +.params all:pending-rolls)] + %pending-by-ship [~ (ship:pending id +.params ship:pending-rolls)] + %pending-by-address [~ (addr:pending id +.params addr:pending-rolls)] + %history [~ (history id +.params scry-history)] == :: ++ scry-point @@ -149,7 +150,7 @@ (~(scry agentio bowl) %azimuth /nas/[(scot %p ship)]/noun) == :: -++ pending-rolls +++ pending-rolls |% ++ all .^ (list tx:naive) @@ -170,4 +171,14 @@ /pending/address/[(scot %ux address)]/noun == -- +:: +++ scry-history + |= [=ship =proxy:naive] + :: FIXME: use proper type from aggregator/index + :: + .^ (list [tx:naive ?]) + %gx + %+ ~(scry agentio bowl) %dice + /history/[(scot %p ship)]/proxy/noun + == -- diff --git a/pkg/arvo/lib/azimuth-rpc.hoon b/pkg/arvo/lib/azimuth-rpc.hoon index a9af00cb2..dbb30511b 100644 --- a/pkg/arvo/lib/azimuth-rpc.hoon +++ b/pkg/arvo/lib/azimuth-rpc.hoon @@ -192,6 +192,13 @@ == -- :: + ++ txs-to-json + :: TODO: implement me! + :: + |= txs=(list [tx:naive success=?]) + ^- json + ~ + :: ++ to-hex |= =cord ^- (unit @ux) @@ -306,34 +313,53 @@ ~(params error id) [%result id (numb:enjs:format u.nonce)] :: -:: - readPendingRoll() -> (list tx) -:: ++ pending - |= [id=@t params=(map @t json) pending=(list tx:naive)] - ^- response:rpc - ?. =((lent ~(tap by params)) 0) - ~(params error id) - [%result id (pending-to-json pending)] + :: FIXME: send raw-tx (i.e. tx with signature) instead? + :: + |% + :: - readPendingRoll() -> (list tx) + :: + ++ all + |= [id=@t params=(map @t json) pending=(list tx:naive)] + ^- response:rpc + ?. =((lent ~(tap by params)) 0) + ~(params error id) + [%result id (pending-to-json pending)] + :: + :: - readPendingByShip(ship) -> (list tx) + :: + ++ ship + |= [id=@t params=(map @t json) scry=$-(@p (list tx:naive))] + ^- response:rpc + ?. =((lent ~(tap by params)) 1) + ~(params error id) + ?~ ship=(ship:extract params) + ~(parse error id) + [%result id (pending-to-json (scry u.ship))] + :: + :: - readPendingByAddress(address) -> (list tx) + :: + ++ addr + |= [id=@t params=(map @t json) scry=$-(@ux (list tx:naive))] + ^- response:rpc + ?. =((lent ~(tap by params)) 1) + ~(params error id) + ?~ address=(address:extract params) + ~(parse error id) + [%result id (pending-to-json (scry u.address))] + -- :: -:: - readPendingByShip(ship) -> (list tx) -:: -++ pending-by-ship - |= [id=@t params=(map @t json) scry=$-(ship (list tx:naive))] +++ history + |= $: id=@t + params=(map @t json) + :: FIXME: use proper type from aggregator/index + :: + scry=$-([@p proxy:naive] (list [tx:naive success=?])) + == ^- response:rpc ?. =((lent ~(tap by params)) 1) ~(params error id) - ?~ ship=(ship:extract params) + ?~ from=(from:extract params) ~(parse error id) - [%result id (pending-to-json (scry u.ship))] -:: -:: - readPendingByAddress(address) -> (list tx) -:: -++ pending-by-address - |= [id=@t params=(map @t json) scry=$-(@ux (list tx:naive))] - ^- response:rpc - ?. =((lent ~(tap by params)) 1) - ~(params error id) - ?~ address=(address:extract params) - ~(parse error id) - [%result id (pending-to-json (scry u.address))] + [%result id (txs-to-json (scry u.from))] -- From 8ebb5e2d6ce6a25345f5c795b27b44664b8b3e25 Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Tue, 11 May 2021 13:28:26 +0200 Subject: [PATCH 37/39] naive: add pending and tx status RPCs --- pkg/arvo/app/azimuth-rpc.hoon | 127 ++++++++---- pkg/arvo/lib/azimuth-rpc.hoon | 379 +++++++++++++++++++--------------- 2 files changed, 304 insertions(+), 202 deletions(-) diff --git a/pkg/arvo/app/azimuth-rpc.hoon b/pkg/arvo/app/azimuth-rpc.hoon index 80a8ceb5a..88a2e3fd1 100644 --- a/pkg/arvo/app/azimuth-rpc.hoon +++ b/pkg/arvo/app/azimuth-rpc.hoon @@ -1,4 +1,4 @@ -:: Azimuth RPC API +:: Azimuth JSON-RPC API :: /- rpc=json-rpc /+ naive, @@ -11,6 +11,15 @@ version, agentio |% +:: FIXME: import tx-status, pend-tx from aggregator +:: ++$ tx-status + $: status=?(%unknown %pending %sent %confirmed %failed) + tx=(unit @ux) + == +:: ++$ pend-tx [force=? =raw-tx:naive] +:: +$ card card:agent:gall :: +$ state-0 [%0 ~] @@ -125,7 +134,7 @@ ?. ?=([%map *] params) [~ ~(parse error id)] ?+ method [~ ~(method error id)] - %get-point [~ (get-point id +.params scry-point)] + %get-point [~ (get-point id +.params point:scry)] %transfer-point (transfer-point id +.params) %configure-keys (configure-keys id +.params) %spawn (spawn id +.params) @@ -137,48 +146,90 @@ %set-management-proxy (management-proxy id +.params) %set-spawn-proxy (spawn-proxy id +.params) %set-transfer-proxy (transfer-proxy id +.params) - %pending [~ (all:pending id +.params all:pending-rolls)] - %pending-by-ship [~ (ship:pending id +.params ship:pending-rolls)] - %pending-by-address [~ (addr:pending id +.params addr:pending-rolls)] - %history [~ (history id +.params scry-history)] + %pending [~ (all:pending id +.params all:pending:scry)] + %pending-by-ship [~ (ship:pending id +.params ship:pending:scry)] + %pending-by-address [~ (addr:pending id +.params addr:pending:scry)] + %status [~ (status id +.params tx-status:scry)] + :: %history [~ (history id +.params all:history:scry)] == :: -++ scry-point - |= =ship - .^ (unit point:naive) - %gx - (~(scry agentio bowl) %azimuth /nas/[(scot %p ship)]/noun) - == -:: -++ pending-rolls +++ scry |% - ++ all - .^ (list tx:naive) - %gx - (~(scry agentio bowl) %dice /pending/all/noun) - == - ++ ship - |= =^ship - .^ (list tx:naive) + ++ point + |= =ship + .^ (unit point:naive) %gx - (~(scry agentio bowl) %dice /pending/ship/[(scot %p ship)]/noun) + (~(scry agentio bowl) %azimuth /nas/[(scot %p ship)]/noun) == - ++ addr - |= =address:naive - .^ (list tx:naive) + :: + ++ pending + |% + ++ all + .^ (list pend-tx) + %gx + (~(scry agentio bowl) %dice /pending/noun) + == + :: + ++ ship + |= =^ship + .^ (list pend-tx) + %gx + (~(scry agentio bowl) %dice /pending/[(scot %p ship)]/noun) + == + :: + ++ addr + |= =address:naive + .^ (list pend-tx) + %gx + %+ ~(scry agentio bowl) %dice + /pending/[(scot %ux address)]/noun + == + -- + :: + ++ history + |% + ++ all + :: FIXME: use proper type from aggregator/index + :: + .^ (list tx:naive) + %gx + (~(scry agentio bowl) %dice /history/noun) + == + :: + ++ ship + |= =^ship + :: FIXME: use proper type from aggregator/index + :: + .^ (list tx:naive) + %gx + (~(scry agentio bowl) %dice /history/[(scot %p ship)]/noun) + == + :: + ++ addr + |= =address:naive + :: FIXME: use proper type from aggregator/index + :: + .^ (list tx:naive) + %gx + (~(scry agentio bowl) %dice /history/[(scot %ux address)]/noun) + == + -- + :: + ++ tx-status + |= keccak=@ux + .^ ^tx-status %gx - %+ ~(scry agentio bowl) %dice - /pending/address/[(scot %ux address)]/noun + (~(scry agentio bowl) %dice /tx/[(scot %ux keccak)]/status/noun) + == + :: + ++ nonce + |= [=ship =address:naive] + :: FIXME: use proper type from aggregator/index + .^ @ + %gx + %+ ~(scry agentio bowl) + %dice + /nonce/[(scot %p ship)]/[(scot %ux address)]/atom == -- -:: -++ scry-history - |= [=ship =proxy:naive] - :: FIXME: use proper type from aggregator/index - :: - .^ (list [tx:naive ?]) - %gx - %+ ~(scry agentio bowl) %dice - /history/[(scot %p ship)]/proxy/noun - == -- diff --git a/pkg/arvo/lib/azimuth-rpc.hoon b/pkg/arvo/lib/azimuth-rpc.hoon index dbb30511b..9c20de491 100644 --- a/pkg/arvo/lib/azimuth-rpc.hoon +++ b/pkg/arvo/lib/azimuth-rpc.hoon @@ -6,7 +6,16 @@ => :: Utilities :: |% - ++ extract + :: FIXME: import tx-status, pend-tx from aggregator + :: + +$ tx-status + $: status=?(%unknown %pending %sent %confirmed %failed) + tx=(unit @ux) + == + :: + +$ pend-tx [force=? =raw-tx:naive] + :: + ++ from-json |% ++ keys |= params=(map @t json) @@ -54,9 +63,7 @@ ^- (unit @ux) ?~ data=(~(get by params) 'data') ~ =; ans=(unit (unit @ux)) - ?~ ans ~ - ?~ u.ans ~ - (some u.u.ans) + ?~(ans ~ u.ans) =, dejs-soft:format %. u.data (ot ['address' (cu to-hex so)]~) @@ -72,7 +79,6 @@ ++ sig |= params=(map @t json) ^- (unit @) - =, dejs-soft:format ?~ sig=(~(get by params) 'sig') ~ (so:dejs-soft:format u.sig) :: @@ -86,119 +92,153 @@ :~ ['ship' (su ;~(pfix sig fed:ag))] ['proxy' (cu proxy:naive so)] == + :: + ++ keccak + |= params=(map @t json) + ^- (unit @ux) + ?~ keccak=(~(get by params) 'keccak') ~ + =; ans=(unit (unit @ux)) + ?~(ans ~ u.ans) + =, dejs-soft:format + ((cu to-hex so) u.keccak) -- :: - ++ pending-to-json - |= pending=(list tx:naive) - ^- json - =, enjs:format - :- %a - %+ turn pending - |= =tx:naive - ^- json - |^ - =, enjs:format - %- pairs - :~ ['tx' (parse-tx +.tx)] - :: - :- 'from' - %- pairs - ~[['ship' (ship ship.from.tx)] ['proxy' s+proxy.from.tx]] - == - :: - ++ parse-tx - |= tx=skim-tx:naive + ++ to-json + |% + ++ pending + |= pending=(list pend-tx) ^- json + =, enjs:format + :- %a + %+ turn pending + |= pend-tx + ^- json + =, enjs:format %- pairs - :~ ['type' s+-.tx] + :~ ['force' b+force] :: - :- 'data' + :- 'raw-tx' %- pairs - ?- -.tx - %transfer-point (en-transfer +.tx) - %spawn (en-spawn +.tx) - %configure-keys (en-keys +.tx) - %escape ~[(en-ship parent.tx)] - %cancel-escape ~[(en-ship parent.tx)] - %adopt ~[(en-ship ship.tx)] - %reject ~[(en-ship ship.tx)] - %detach ~[(en-ship ship.tx)] - %set-management-proxy ~[(en-address address.tx)] - %set-spawn-proxy ~[(en-address address.tx)] - %set-transfer-proxy ~[(en-address address.tx)] + :~ ['sig' (numb sig.raw-tx)] + ['tx' (tx:to-json tx.raw-tx)] == == :: - ++ en-ship |=(s=@p ship+(ship s)) - ++ en-address |=(a=@ux address+s+(crip "0x{((x-co:co 20) a)}")) - ++ en-spawn |=([s=@p a=@ux] ~[(en-ship s) (en-address a)]) - ++ en-transfer |=([a=@ux r=?] ~[(en-address a) reset+b+r]) - ++ en-keys - |= [encrypt=@ auth=@ crypto-suite=@ breach=?] - ^- (list [@t json]) - :~ ['encrypt' (numb encrypt)] - ['auth' (numb auth)] - ['crypto-suite' (numb crypto-suite)] - ['breach' b+breach] + ++ tx + |= =tx:naive + ^- json + =, enjs:format + |^ + %- pairs + :~ ['tx' (parse-tx +.tx)] + :: + :- 'from' + %- pairs + ~[['ship' (ship ship.from.tx)] ['proxy' s+proxy.from.tx]] == - -- - :: - ++ point-to-json - |= =point:naive - ^- json - =, enjs:format - |^ - %- pairs - :~ ['dominion' s+dominion.point] :: - :- 'ownership' + ++ parse-tx + |= tx=skim-tx:naive + ^- json %- pairs - =* own own.point + :~ ['type' s+-.tx] + :: + :- 'data' + %- pairs + ?- -.tx + %transfer-point (en-transfer +.tx) + %spawn (en-spawn +.tx) + %configure-keys (en-keys +.tx) + %escape ~[(en-ship parent.tx)] + %cancel-escape ~[(en-ship parent.tx)] + %adopt ~[(en-ship ship.tx)] + %reject ~[(en-ship ship.tx)] + %detach ~[(en-ship ship.tx)] + %set-management-proxy ~[(en-address address.tx)] + %set-spawn-proxy ~[(en-address address.tx)] + %set-transfer-proxy ~[(en-address address.tx)] + == == + :: + ++ en-ship |=(s=@p ship+(ship s)) + ++ en-address |=(a=@ux address+s+(crip "0x{((x-co:co 20) a)}")) + ++ en-spawn |=([s=@p a=@ux] ~[(en-ship s) (en-address a)]) + ++ en-transfer |=([a=@ux r=?] ~[(en-address a) reset+b+r]) + ++ en-keys + |= [encrypt=@ auth=@ crypto-suite=@ breach=?] ^- (list [@t json]) - :~ ['owner' (own-to-json owner.own)] - ['spawnProxy' (own-to-json spawn-proxy.own)] - ['managementProxy' (own-to-json management-proxy.own)] - ['votingProxy' (own-to-json voting-proxy.own)] - ['transferProxy' (own-to-json transfer-proxy.own)] + :~ ['encrypt' (numb encrypt)] + ['auth' (numb auth)] + ['crypto-suite' (numb crypto-suite)] + ['breach' b+breach] == - :: - :- 'network' - %- pairs - =* net net.point - :* ['rift' (numb rift.net)] - :: - :- 'keys' - %- pairs - :~ ['life' (numb life.keys.net)] - ['suite' (numb suite.keys.net)] - ['auth' (numb auth.keys.net)] - ['crypt' (numb crypt.keys.net)] - == - :: - ['rift' (numb rift.net)] - :- 'sponsor' - %- pairs - ~[['has' b+has.sponsor.net] ['who' (ship who.sponsor.net)]] - :: - ?~ escape.net ~ - ['escape' (ship u.escape.net)]~ - == == + -- + :: + ++ txs + |= txs=(list tx:naive) + ^- json + a+(turn txs |=(=tx:naive (tx:to-json tx))) + :: + ++ point + |= =point:naive + ^- json + =, enjs:format + %- pairs + :~ ['dominion' s+dominion.point] + :: + :- 'ownership' + %- pairs + =* own own.point + ^- (list [@t json]) + :~ ['owner' (ownership owner.own)] + ['spawnProxy' (ownership spawn-proxy.own)] + ['managementProxy' (ownership management-proxy.own)] + ['votingProxy' (ownership voting-proxy.own)] + ['transferProxy' (ownership transfer-proxy.own)] + == + :: + :- 'network' + %- pairs + =* net net.point + :* ['rift' (numb rift.net)] + :: + :- 'keys' + %- pairs + :~ ['life' (numb life.keys.net)] + ['suite' (numb suite.keys.net)] + ['auth' (numb auth.keys.net)] + ['crypt' (numb crypt.keys.net)] + == + :: + ['rift' (numb rift.net)] + :- 'sponsor' + %- pairs + ~[['has' b+has.sponsor.net] ['who' (ship who.sponsor.net)]] + :: + ?~ escape.net ~ + ['escape' (ship u.escape.net)]~ + == == :: - ++ own-to-json + ++ ownership |= [=address:naive =nonce:naive] ^- json + =, enjs:format %- pairs :~ ['address' s+(crip "0x{((x-co:co 20) address)}")] - ['nonce' (numb:enjs:format nonce)] + ['nonce' (numb nonce)] + == + :: + ++ tx-status + |= =^tx-status + ^- json + =, enjs:format + %- pairs + :~ ['status' s+status.tx-status] + :: + :- 'tx' + ?~ tx.tx-status ~ + s+(crip "0x{((x-co:co 20) u.tx.tx-status)}") == -- :: - ++ txs-to-json - :: TODO: implement me! - :: - |= txs=(list [tx:naive success=?]) - ^- json - ~ - :: ++ to-hex |= =cord ^- (unit @ux) @@ -208,33 +248,37 @@ ~ (some q.u.parsed) :: - ++ sponsor-call - |= [id=@t params=(map @t json)] - ^- [(unit cage) response:rpc] - ?. =((lent ~(tap by params)) 3) - [~ ~(params error id)] - =/ sig=(unit @) (sig:extract params) - =/ from=(unit [@p proxy:naive]) (from:extract params) - =/ data=(unit [@ux @p]) (address-ship:extract params) - ?. &(?=(^ sig) ?=(^ from) ?=(^ data)) - [~ ~(parse error id)] - :_ [%result id s+'ok'] - %- some - noun+!>([u.sig u.from u.data]) - :: - ++ proxy-call - |= [id=@t params=(map @t json)] - ^- [(unit cage) response:rpc] - ?. =((lent ~(tap by params)) 3) - [~ ~(params error id)] - =/ sig=(unit @) (sig:extract params) - =/ from=(unit [@p proxy:naive]) (from:extract params) - =/ data=(unit @ux) (address:extract params) - ?. &(?=(^ sig) ?=(^ from) ?=(^ data)) - [~ ~(parse error id)] - :_ [%result id s+'ok'] - %- some - noun+!>([u.sig u.from u.data]) + ++ rpc-res + |% + ++ sponsor + |= [id=@t params=(map @t json)] + ^- [(unit cage) response:rpc] + ?. =((lent ~(tap by params)) 3) + [~ ~(params error id)] + =/ sig=(unit @) (sig:from-json params) + =/ from=(unit [@p proxy:naive]) (from:from-json params) + =/ data=(unit [@ux @p]) (address-ship:from-json params) + ?. &(?=(^ sig) ?=(^ from) ?=(^ data)) + [~ ~(parse error id)] + :_ [%result id s+'ok'] + %- some + noun+!>([u.sig u.from u.data]) + :: + ++ proxy + |= [id=@t params=(map @t json)] + ^- [(unit cage) response:rpc] + ?. =((lent ~(tap by params)) 3) + [~ ~(params error id)] + =/ sig=(unit @) (sig:from-json params) + =/ from=(unit [@p proxy:naive]) (from:from-json params) + =/ data=(unit @ux) (address:from-json params) + ?. &(?=(^ sig) ?=(^ from) ?=(^ data)) + [~ ~(parse error id)] + :_ [%result id s+'ok'] + %- some + noun+!>([u.sig u.from u.data]) + :: + -- :: ++ error |_ id=@t @@ -260,16 +304,16 @@ ~(params error id) ?~ point=(scry u.ship) ~(params error id) - [%result id (point-to-json u.point)] + [%result id (point:to-json u.point)] :: ++ transfer-point |= [id=@t params=(map @t json)] ^- [(unit cage) response:rpc] ?. =((lent ~(tap by params)) 3) [~ ~(params error id)] - =/ sig=(unit @) (sig:extract params) - =/ from=(unit [ship @t]) (from:extract params) - =/ data=(unit [@ux ?]) (address-transfer:extract params) + =/ sig=(unit @) (sig:from-json params) + =/ from=(unit [ship @t]) (from:from-json params) + =/ data=(unit [@ux ?]) (address-transfer:from-json params) ?: |(?=(~ sig) ?=(~ from) ?=(~ data)) [~ ~(parse error id)] :_ [%result id s+'ok'] @@ -281,25 +325,25 @@ ^- [(unit cage) response:rpc] ?. =((lent ~(tap by params)) 3) [~ ~(params error id)] - =/ sig=(unit @) (sig:extract params) - =/ from=(unit [ship @t]) (from:extract params) + =/ sig=(unit @) (sig:from-json params) + =/ from=(unit [ship @t]) (from:from-json params) =/ data=(unit [encrypt=@ auth=@ crypto-suite=@ breach=?]) - (keys:extract params) + (keys:from-json params) ?. &(?=(^ sig) ?=(^ from) ?=(^ data)) [~ ~(parse error id)] :_ [%result id s+'ok'] %- some noun+!>([u.sig u.from u.data]) :: -++ spawn sponsor-call -++ escape sponsor-call -++ cancel-escape sponsor-call -++ adopt sponsor-call -++ detach sponsor-call -++ reject sponsor-call -++ management-proxy proxy-call -++ spawn-proxy proxy-call -++ transfer-proxy proxy-call +++ spawn sponsor:rpc-res +++ escape sponsor:rpc-res +++ cancel-escape sponsor:rpc-res +++ adopt sponsor:rpc-res +++ detach sponsor:rpc-res +++ reject sponsor:rpc-res +++ management-proxy proxy:rpc-res +++ spawn-proxy proxy:rpc-res +++ transfer-proxy proxy:rpc-res :: - readNonce(from=[ship proxy]) -> @ :: automatically increment for pending wraps :: ++ read-nonce @@ -307,7 +351,7 @@ ^- response:rpc ?. =((lent ~(tap by params)) 3) ~(params error id) - ?~ from=(from:extract params) + ?~ from=(from:from-json params) ~(parse error id) ?~ nonce=(scry u.from) ~(params error id) @@ -317,49 +361,56 @@ :: FIXME: send raw-tx (i.e. tx with signature) instead? :: |% - :: - readPendingRoll() -> (list tx) + :: - readPendingRoll() -> (list pend-tx) :: - ++ all - |= [id=@t params=(map @t json) pending=(list tx:naive)] + ++ all + |= [id=@t params=(map @t json) pending=(list pend-tx)] ^- response:rpc ?. =((lent ~(tap by params)) 0) ~(params error id) - [%result id (pending-to-json pending)] - :: - :: - readPendingByShip(ship) -> (list tx) + [%result id (pending:to-json pending)] + :: - readPendingByShip(ship) -> (list pend-tx) :: ++ ship - |= [id=@t params=(map @t json) scry=$-(@p (list tx:naive))] + |= [id=@t params=(map @t json) scry=$-(@p (list pend-tx))] ^- response:rpc ?. =((lent ~(tap by params)) 1) ~(params error id) - ?~ ship=(ship:extract params) + ?~ ship=(ship:from-json params) ~(parse error id) - [%result id (pending-to-json (scry u.ship))] - :: - :: - readPendingByAddress(address) -> (list tx) + [%result id (pending:to-json (scry u.ship))] + :: - readPendingByAddress(address) -> (list pend-tx) :: ++ addr - |= [id=@t params=(map @t json) scry=$-(@ux (list tx:naive))] + |= [id=@t params=(map @t json) scry=$-(@ux (list pend-tx))] ^- response:rpc ?. =((lent ~(tap by params)) 1) ~(params error id) - ?~ address=(address:extract params) + ?~ address=(address:from-json params) ~(parse error id) - [%result id (pending-to-json (scry u.address))] + [%result id (pending:to-json (scry u.address))] -- :: -++ history - |= $: id=@t - params=(map @t json) - :: FIXME: use proper type from aggregator/index - :: - scry=$-([@p proxy:naive] (list [tx:naive success=?])) - == +++ status + |= [id=@t params=(map @t json) scry=$-(@ tx-status)] ^- response:rpc ?. =((lent ~(tap by params)) 1) ~(params error id) - ?~ from=(from:extract params) + ?~ keccak=(keccak:from-json params) ~(parse error id) - [%result id (txs-to-json (scry u.from))] + [%result id (tx-status:to-json (scry u.keccak))] +:: +:: ++ history +:: |= $: id=@t +:: params=(map @t json) +:: :: FIXME: use proper type from aggregator/index +:: :: +:: scry=$-([@p proxy:naive] (list tx:naive)) +:: == +:: ^- response:rpc +:: ?. =((lent ~(tap by params)) 1) +:: ~(params error id) +:: ?~ from=(from:from-json params) +:: ~(parse error id) +:: [%result id (txs:to-json (scry u.from))] -- From c5d61b7076950835ebef772a60266b3465ac1300 Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Tue, 11 May 2021 13:28:55 +0200 Subject: [PATCH 38/39] json-rpc: fix result key in rpc response --- pkg/arvo/lib/json/rpc.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/arvo/lib/json/rpc.hoon b/pkg/arvo/lib/json/rpc.hoon index 97543c704..2cc0c7ff0 100644 --- a/pkg/arvo/lib/json/rpc.hoon +++ b/pkg/arvo/lib/json/rpc.hoon @@ -43,7 +43,7 @@ :: :~ ['jsonrpc' s+'2.0'] ['id' s+id.response] - ['res' res.response] + ['result' res.response] == :: %error From 152cf894ff0dee035b229d739a5c88ad6283848c Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Mon, 17 May 2021 17:49:41 +0200 Subject: [PATCH 39/39] naive: hook rpc-api with aggregator --- pkg/arvo/app/azimuth-rpc.hoon | 34 +++--- pkg/arvo/lib/azimuth-rpc.hoon | 207 ++++++++++++++++++++++++---------- 2 files changed, 164 insertions(+), 77 deletions(-) diff --git a/pkg/arvo/app/azimuth-rpc.hoon b/pkg/arvo/app/azimuth-rpc.hoon index 88a2e3fd1..7320530f9 100644 --- a/pkg/arvo/app/azimuth-rpc.hoon +++ b/pkg/arvo/app/azimuth-rpc.hoon @@ -90,7 +90,7 @@ ?~ data ~ :_ ~ ^- card - [%pass / %agent [our.bowl %dice] %poke u.data] + [%pass / %agent [our.bowl %aggregator] %poke u.data] :: TODO: validate that format is e.g. 'getPoint' :: TODO: maybe use getPoint and translate to %get-point :: @@ -138,14 +138,14 @@ %transfer-point (transfer-point id +.params) %configure-keys (configure-keys id +.params) %spawn (spawn id +.params) - %escape (escape id +.params) - %cancel-escape (cancel-escape id +.params) - %adopt (adopt id +.params) - %detach (detach id +.params) - %reject (reject id +.params) - %set-management-proxy (management-proxy id +.params) - %set-spawn-proxy (spawn-proxy id +.params) - %set-transfer-proxy (transfer-proxy id +.params) + %escape (escape id +.params method) + %cancel-escape (cancel-escape id +.params method) + %adopt (adopt id +.params method) + %detach (detach id +.params method) + %reject (reject id +.params method) + %set-management-proxy (management-proxy id +.params method) + %set-spawn-proxy (spawn-proxy id +.params method) + %set-transfer-proxy (transfer-proxy id +.params method) %pending [~ (all:pending id +.params all:pending:scry)] %pending-by-ship [~ (ship:pending id +.params ship:pending:scry)] %pending-by-address [~ (addr:pending id +.params addr:pending:scry)] @@ -167,21 +167,21 @@ ++ all .^ (list pend-tx) %gx - (~(scry agentio bowl) %dice /pending/noun) + (~(scry agentio bowl) %aggregator /pending/noun) == :: ++ ship |= =^ship .^ (list pend-tx) %gx - (~(scry agentio bowl) %dice /pending/[(scot %p ship)]/noun) + (~(scry agentio bowl) %aggregator /pending/[(scot %p ship)]/noun) == :: ++ addr |= =address:naive .^ (list pend-tx) %gx - %+ ~(scry agentio bowl) %dice + %+ ~(scry agentio bowl) %aggregator /pending/[(scot %ux address)]/noun == -- @@ -193,7 +193,7 @@ :: .^ (list tx:naive) %gx - (~(scry agentio bowl) %dice /history/noun) + (~(scry agentio bowl) %aggregator /history/noun) == :: ++ ship @@ -202,7 +202,7 @@ :: .^ (list tx:naive) %gx - (~(scry agentio bowl) %dice /history/[(scot %p ship)]/noun) + (~(scry agentio bowl) %aggregator /history/[(scot %p ship)]/noun) == :: ++ addr @@ -211,7 +211,7 @@ :: .^ (list tx:naive) %gx - (~(scry agentio bowl) %dice /history/[(scot %ux address)]/noun) + (~(scry agentio bowl) %aggregator /history/[(scot %ux address)]/noun) == -- :: @@ -219,7 +219,7 @@ |= keccak=@ux .^ ^tx-status %gx - (~(scry agentio bowl) %dice /tx/[(scot %ux keccak)]/status/noun) + (~(scry agentio bowl) %aggregator /tx/[(scot %ux keccak)]/status/noun) == :: ++ nonce @@ -228,7 +228,7 @@ .^ @ %gx %+ ~(scry agentio bowl) - %dice + %aggregator /nonce/[(scot %p ship)]/[(scot %ux address)]/atom == -- diff --git a/pkg/arvo/lib/azimuth-rpc.hoon b/pkg/arvo/lib/azimuth-rpc.hoon index 9c20de491..78167fa37 100644 --- a/pkg/arvo/lib/azimuth-rpc.hoon +++ b/pkg/arvo/lib/azimuth-rpc.hoon @@ -6,6 +6,19 @@ => :: Utilities :: |% + +$ spawn-action + $? %escape + %cancel-escape + %adopt + %reject + %detach + == + :: + +$ proxy-action + $? %set-management-proxy + %set-spawn-proxy + %set-transfer-proxy + == :: FIXME: import tx-status, pend-tx from aggregator :: +$ tx-status @@ -30,52 +43,72 @@ ['breach' bo] == :: - ++ address-transfer - |= params=(map @t json) - ^- (unit [@ux ?]) - ?~ data=(~(get by params) 'data') ~ - =; ans=(unit [add=(unit @ux) r=?]) - ?~ ans ~ - ?~ add.u.ans ~ - (some [u.add.u.ans r.u.ans]) - %. u.data - =, dejs-soft:format - %- ot - ~[['address' (cu to-hex so)] ['reset' bo]] - :: - ++ address-ship - |= params=(map @t json) - ^- (unit [@ux @p]) - ?~ data=(~(get by params) 'data') ~ - =; ans=(unit [add=(unit @ux) ship=@p]) - ?~ ans ~ - ?~ add.u.ans ~ - (some [u.add.u.ans ship.u.ans]) - %. u.data - =, dejs-soft:format - %- ot - :~ ['address' (cu to-hex so)] - ['ship' (su ;~(pfix sig fed:ag))] - == - :: - ++ address - |= params=(map @t json) - ^- (unit @ux) - ?~ data=(~(get by params) 'data') ~ - =; ans=(unit (unit @ux)) - ?~(ans ~ u.ans) - =, dejs-soft:format - %. u.data - (ot ['address' (cu to-hex so)]~) - :: + ++ data + |% + ++ address-transfer + |= params=(map @t json) + ^- (unit [@ux ?]) + ?~ data=(~(get by params) 'data') ~ + =; ans=(unit [add=(unit @ux) r=?]) + ?~ ans ~ + ?~ add.u.ans ~ + (some [u.add.u.ans r.u.ans]) + %. u.data + =, dejs-soft:format + %- ot + ~[['address' (cu to-hex so)] ['reset' bo]] + :: + ++ address-ship + |= params=(map @t json) + ^- (unit [@p @ux]) + ?~ data=(~(get by params) 'data') ~ + =; ans=(unit [ship=@p add=(unit @ux)]) + ?~ ans ~ + ?~ add.u.ans ~ + (some [ship.u.ans u.add.u.ans]) + %. u.data + =, dejs-soft:format + %- ot + :~ ['ship' (su ;~(pfix sig fed:ag))] + ['address' (cu to-hex so)] + == + :: + ++ address + |= params=(map @t json) + ^- (unit @ux) + ?~ data=(~(get by params) 'data') ~ + =; ans=(unit (unit @ux)) + ?~(ans ~ u.ans) + =, dejs-soft:format + %. u.data + (ot ['address' (cu to-hex so)]~) + :: + ++ ship + |= params=(map @t json) + ^- (unit @p) + ?~ data=(~(get by params) 'data') ~ + =, dejs-soft:format + %. u.data + (ot ['ship' (su ;~(pfix sig fed:ag))]~) + -- + :: ++ ship |= params=(map @t json) ^- (unit @p) - ?~ data=(~(get by params) 'data') ~ + ?~ data=(~(get by params) 'ship') ~ =, dejs-soft:format %. u.data - (ot ['ship' (su ;~(pfix sig fed:ag))]~) - :: + (su ;~(pfix sig fed:ag)) + :: + ++ address + |= params=(map @t json) + ^- (unit @ux) + ?~ data=(~(get by params) 'address') ~ + =; ans=(unit (unit @ux)) + ?~(ans ~ u.ans) + =, dejs-soft:format + ((cu to-hex so) u.data) + :: ++ sig |= params=(map @t json) ^- (unit @) @@ -101,6 +134,17 @@ ?~(ans ~ u.ans) =, dejs-soft:format ((cu to-hex so) u.keccak) + :: + ++ raw + |= params=(map @t json) + ^- (unit octs) + ?~ raw=(~(get by params) 'raw') ~ + =; ans=(unit (unit @ux)) + ?~ ans ~ + ?~ u.ans ~ + (some (as-octs:mimes:html u.u.ans)) + =, dejs-soft:format + ((cu to-hex so) u.raw) -- :: ++ to-json @@ -251,33 +295,52 @@ ++ rpc-res |% ++ sponsor - |= [id=@t params=(map @t json)] + |= [id=@t params=(map @t json) action=spawn-action] ^- [(unit cage) response:rpc] - ?. =((lent ~(tap by params)) 3) + ?. (params:validate params) [~ ~(params error id)] =/ sig=(unit @) (sig:from-json params) =/ from=(unit [@p proxy:naive]) (from:from-json params) - =/ data=(unit [@ux @p]) (address-ship:from-json params) - ?. &(?=(^ sig) ?=(^ from) ?=(^ data)) + =/ raw=(unit octs) (raw:from-json params) + =/ data=(unit @p) (ship:data:from-json params) + ?. &(?=(^ sig) ?=(^ from) ?=(^ raw) ?=(^ data)) [~ ~(parse error id)] - :_ [%result id s+'ok'] + :_ [%result id s+'ok'] %- some - noun+!>([u.sig u.from u.data]) + :- %aggregator-action + !> + =; =skim-tx:naive + [%submit | u.sig %ful u.raw u.from skim-tx] + ?- action + %escape [%escape u.data] + %cancel-escape [%cancel-escape u.data] + %adopt [%adopt u.data] + %reject [%reject u.data] + %detach [%detach u.data] + == :: ++ proxy - |= [id=@t params=(map @t json)] + |= [id=@t params=(map @t json) action=proxy-action] ^- [(unit cage) response:rpc] - ?. =((lent ~(tap by params)) 3) + ?. (params:validate params) [~ ~(params error id)] =/ sig=(unit @) (sig:from-json params) =/ from=(unit [@p proxy:naive]) (from:from-json params) - =/ data=(unit @ux) (address:from-json params) - ?. &(?=(^ sig) ?=(^ from) ?=(^ data)) + =/ raw=(unit octs) (raw:from-json params) + =/ data=(unit @ux) (address:data:from-json params) + ?. &(?=(^ sig) ?=(^ from) ?=(^ raw) ?=(^ data)) [~ ~(parse error id)] :_ [%result id s+'ok'] %- some - noun+!>([u.sig u.from u.data]) - :: + :- %aggregator-action + !> + =; =skim-tx:naive + [%submit | u.sig %ful u.raw u.from skim-tx] + ?- action + %set-management-proxy [%set-management-proxy u.data] + %set-spawn-proxy [%set-spawn-proxy u.data] + %set-transfer-proxy [%set-transfer-proxy u.data] + == -- :: ++ error @@ -291,6 +354,14 @@ ++ internal [%error id '-32603' 'Internal error'] ++ not-found [%error id '-32000' 'Resource not found'] -- + :: + ++ validate + |% + ++ params + |= params=(map @t json) + ^- ? + =((lent ~(tap by params)) 4) + -- -- |% ++ get-point @@ -309,12 +380,13 @@ ++ transfer-point |= [id=@t params=(map @t json)] ^- [(unit cage) response:rpc] - ?. =((lent ~(tap by params)) 3) + ?. (params:validate params) [~ ~(params error id)] =/ sig=(unit @) (sig:from-json params) =/ from=(unit [ship @t]) (from:from-json params) - =/ data=(unit [@ux ?]) (address-transfer:from-json params) - ?: |(?=(~ sig) ?=(~ from) ?=(~ data)) + =/ raw=(unit octs) (raw:from-json params) + =/ data=(unit [@ux ?]) (address-transfer:data:from-json params) + ?: |(?=(~ sig) ?=(~ from) ?=(~ raw) ?=(~ data)) [~ ~(parse error id)] :_ [%result id s+'ok'] %- some @@ -323,19 +395,34 @@ ++ configure-keys |= [id=@t params=(map @t json)] ^- [(unit cage) response:rpc] - ?. =((lent ~(tap by params)) 3) + ?. (params:validate params) [~ ~(params error id)] =/ sig=(unit @) (sig:from-json params) =/ from=(unit [ship @t]) (from:from-json params) + =/ raw=(unit octs) (raw:from-json params) =/ data=(unit [encrypt=@ auth=@ crypto-suite=@ breach=?]) - (keys:from-json params) - ?. &(?=(^ sig) ?=(^ from) ?=(^ data)) + (keys:data:from-json params) + ?. &(?=(^ sig) ?=(^ from) ?=(^ raw) ?=(^ data)) [~ ~(parse error id)] :_ [%result id s+'ok'] %- some noun+!>([u.sig u.from u.data]) :: -++ spawn sponsor:rpc-res +++ spawn + |= [id=@t params=(map @t json)] + ^- [(unit cage) response:rpc] + ?. (params:validate params) + [~ ~(params error id)] + =/ sig=(unit @) (sig:from-json params) + =/ from=(unit [@p proxy:naive]) (from:from-json params) + =/ raw=(unit octs) (raw:from-json params) + =/ data=(unit [@p @ux]) (address-ship:data:from-json params) + ?. &(?=(^ sig) ?=(^ from) ?=(^ raw) ?=(^ data)) + [~ ~(parse error id)] + :_ [%result id s+'ok'] + %- some + aggregator-action+!>([%submit | u.sig %ful u.raw u.from %spawn u.data]) +:: ++ escape sponsor:rpc-res ++ cancel-escape sponsor:rpc-res ++ adopt sponsor:rpc-res