From c8da5efe2bdea0f0b6a0d224339a00692a3f59b5 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Sun, 10 Jun 2018 10:39:36 -0700 Subject: [PATCH 01/64] first pass at nock 12 impl --- noun/nock.c | 183 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) diff --git a/noun/nock.c b/noun/nock.c index 89ebaa4e5..10124cd43 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -526,6 +526,23 @@ _n_nock_on(u3_noun bus, u3_noun fol) #define SLIB 70 #define SLIS 71 #define SAVE 72 +// nock 12 +#define MUTH 73 +#define KUTH 74 +#define MUTT 75 +#define KUTT 76 +#define MUSM 77 +#define KUSM 78 +#define MUCS 79 +#define KUCS 80 +#define MUTB 81 +#define MUTS 82 +#define MITB 83 +#define MITS 84 +#define KUTB 85 +#define KUTS 86 +#define KITB 87 +#define KITS 88 /* _n_arg(): return the size (in bytes) of an opcode's argument */ @@ -538,6 +555,7 @@ _n_arg(c3_y cod_y) case SAMB: case SANB: case SBIP: case SBIN: case SLIB: case SKIB: case KICB: case TICB: case BUSH: case BAST: case BALT: + case KITB: case MITB: return sizeof(c3_y); case FASK: case FASL: case FISL: case FISK: @@ -545,6 +563,7 @@ _n_arg(c3_y cod_y) case SAMS: case SANS: case SIPS: case SINS: case SLIS: case SKIS: case KICS: case TICS: case SUSH: case SAST: case SALT: + case KITS: case MITS: return sizeof(c3_s); case SWIP: case SWIN: @@ -657,6 +676,7 @@ _n_melt(u3_noun ops, c3_w* byc_w, c3_w* cal_w, case BUSH: case FIBK: case FIBL: case SANB: case LIBL: case LIBK: + case KITB: case MITB: a_w = (*lit_w)++; if ( a_w <= 0xFF ) { siz_y[i_w] = 2; @@ -885,6 +905,7 @@ _n_prog_asm(u3_noun ops, u3n_prog* pog_u, u3_noun sip) case FIBK: case FIBL: case LIBK: case LIBL: case BUSH: case SANB: + case KITB: case MITB: _n_prog_asm_inx(buf_y, &i_w, lit_s, cod); pog_u->lit_u.non[lit_s++] = u3k(u3t(op)); break; @@ -992,6 +1013,10 @@ static char* opcode_names[] = { "balt", "salt", "skib", "skis", "slib", "slis", "save", + "muth", "kuth", "mutt", "kutt", + "musm", "kusm", "mucs", "kucs", + "mutb", "muts", "mitb", "mits", + "kutb", "kuts", "kitb", "kits", }; #endif @@ -1289,6 +1314,42 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) ++tot_w; _n_emit(ops, (c3y == los_o) ? WILS : WISH); break; + case 12: { + u3_noun axe, nef; + u3x_cell(arg, &hed, &tel); + u3x_cell(hed, &axe, &nef); + tot_w += _n_comp(ops, tel, c3n, c3n); + ++tot_w; _n_emit(ops, SWAP); + tot_w += _n_comp(ops, nef, c3n, c3n); + + ++tot_w; + switch ( axe ) { + case 2: + _n_emit(ops, (c3y == los_o) ? MUTH : KUTH); + break; + + case 3: + _n_emit(ops, (c3y == los_o) ? MUTT : KUTT); + break; + + case u3x_sam: + _n_emit(ops, (c3y == los_o) ? MUSM : KUSM); + break; + + case u3x_con_sam: + _n_emit(ops, (c3y == los_o) ? MUCS : KUCS); + break; + + default: + op_y = (c3y == los_o) + ? (axe <= 0xFF) ? MUTB : (axe <= 0xFFFF) ? MUTS : MITB // overflows to MITL + : (axe <= 0xFF) ? KUTB : (axe <= 0xFFFF) ? KUTS : KITB; // overflows to KITS + _n_emit(ops, u3nc(op_y, axe)); + break; + } + break; + } + default: u3m_bail(c3__exit); return 0; @@ -1533,6 +1594,26 @@ _n_kale(u3_noun a) return a; } + +/* _n_edit(): PRODUCE a modified big with its axe axis + * changed to som. axe is RETAINED. + */ +static u3_noun +_n_edit(u3_noun big, u3_noun axe, u3_noun som) +{ + if ( c3y == u3a_is_cat(axe) ) { + return u3i_molt(big, axe, som, 0); + } + else { + u3_noun mor = u3qc_mas(axe); + u3_noun pro = ( 2 == u3qc_cap(axe) ) + ? u3nc(_n_edit(u3k(u3h(big)), mor, som), u3k(u3t(big))) + : u3nc(u3k(u3h(big)), _n_edit(u3k(u3t(big)), mor, som)); + u3z(mor); + return pro; + } +} + typedef struct { u3n_prog* pog_u; c3_w ip_w; @@ -1573,6 +1654,10 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) &&do_balt, &&do_salt, &&do_skib, &&do_skis, &&do_slib, &&do_slis, &&do_save, + &&do_muth, &&do_kuth, &&do_mutt, &&do_kutt, + &&do_musm, &&do_kusm, &&do_mucs, &&do_kucs, + &&do_mutb, &&do_muts, &&do_mitb, &&do_mits, + &&do_kutb, &&do_kuts, &&do_kitb, &&do_kits, }; u3j_site* sit_u; @@ -2158,6 +2243,104 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) *top = x; u3z(o); BURN(); + + do_kuth: + x = _n_pep(mov, off); + top = _n_swap(mov, off); + goto muth_in; + do_muth: + x = _n_pep(mov, off); + _n_toss(mov, off); + top = _n_peek(off); + muth_in: + o = *top; + *top = u3nc(x, u3k(u3t(o))); + u3z(o); + BURN(); + + do_kutt: + x = _n_pep(mov, off); + top = _n_swap(mov, off); + goto mutt_in; + do_mutt: + x = _n_pep(mov, off); + _n_toss(mov, off); + top = _n_peek(off); + mutt_in: + o = *top; + *top = u3nc(u3k(u3h(o)), x); + u3z(o); + BURN(); + + do_kusm: + x = _n_pep(mov, off); + top = _n_swap(mov, off); + goto musm_in; + do_musm: + x = _n_pep(mov, off); + _n_toss(mov, off); + top = _n_peek(off); + musm_in: + o = *top; + *top = u3nt(u3k(u3h(o)), x, u3k(u3t(u3t(o)))); + u3z(o); + BURN(); + + do_kucs: + x = _n_pep(mov, off); + top = _n_swap(mov, off); + goto mucs_in; + do_mucs: + x = _n_pep(mov, off); + _n_toss(mov, off); + top = _n_peek(off); + mucs_in: + o = *top; + *top = u3nc(u3k(u3h(o)), + u3nt(u3k(u3h(u3t(o))), x, u3k(u3t(u3t(u3t(o)))))); + u3z(o); + BURN(); + + do_kitb: + x = pog_u->lit_u.non[pog[ip_w++]]; + goto kut_in; + + do_kits: + x = pog_u->lit_u.non[_n_resh(pog, &ip_w)]; + goto kut_in; + + do_kuts: + x = _n_resh(pog, &ip_w); + goto kut_in; + + do_kutb: + x = pog[ip_w++]; + kut_in: + o = _n_pep(mov, off); + top = _n_swap(mov, off); + goto edit_in; + + do_mitb: + x = pog_u->lit_u.non[pog[ip_w++]]; + goto mut_in; + + do_mits: + x = pog_u->lit_u.non[_n_resh(pog, &ip_w)]; + goto mut_in; + + do_muts: + x = _n_resh(pog, &ip_w); + goto mut_in; + + do_mutb: + x = pog[ip_w++]; + mut_in: + o = _n_pep(mov, off); + _n_toss(mov, off); + top = _n_peek(off); + edit_in: + *top = _n_edit(*top, x, o); + BURN(); } } From 0c64dabc972a26e82276198b9e8866424874a1f8 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Sun, 10 Jun 2018 14:02:07 -0700 Subject: [PATCH 02/64] bugfixes --- noun/jets.c | 16 ++++++++++++---- noun/nock.c | 13 ++++++++----- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index 00fe06f24..e186b4a1b 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -1399,15 +1399,23 @@ u3j_site_ream(u3j_site* sit_u) static void _cj_site_lock(u3_noun loc, u3_noun cor, u3j_site* sit_u) { + u3_weak fol; if ( (u3_none != sit_u->bat) && (c3y == u3r_sing(sit_u->bat, u3h(cor))) ) { return; } - sit_u->pog_p = _cj_prog(loc, u3r_at(sit_u->axe, cor)); - if ( u3_none != sit_u->bat ) { - u3z(sit_u->bat); + + fol = u3r_at(sit_u->axe, cor); + if ( u3_none == fol ) { + u3m_bail(c3__exit); + } + else { + sit_u->pog_p = _cj_prog(loc, fol); + if ( u3_none != sit_u->bat ) { + u3z(sit_u->bat); + } + sit_u->bat = u3k(u3h(cor)); } - sit_u->bat = u3k(u3h(cor)); } /* _cj_burn(): stop tracing glu and call a nock program diff --git a/noun/nock.c b/noun/nock.c index 10124cd43..c63a466c3 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -543,6 +543,7 @@ _n_nock_on(u3_noun bus, u3_noun fol) #define KUTS 86 #define KITB 87 #define KITS 88 +#define LAST 89 /* _n_arg(): return the size (in bytes) of an opcode's argument */ @@ -555,7 +556,7 @@ _n_arg(c3_y cod_y) case SAMB: case SANB: case SBIP: case SBIN: case SLIB: case SKIB: case KICB: case TICB: case BUSH: case BAST: case BALT: - case KITB: case MITB: + case MUTB: case KUTB: case MITB: case KITB: return sizeof(c3_y); case FASK: case FASL: case FISL: case FISK: @@ -563,14 +564,14 @@ _n_arg(c3_y cod_y) case SAMS: case SANS: case SIPS: case SINS: case SLIS: case SKIS: case KICS: case TICS: case SUSH: case SAST: case SALT: - case KITS: case MITS: + case MUTS: case KUTS: case MITS: case KITS: return sizeof(c3_s); case SWIP: case SWIN: return sizeof(c3_l); default: - c3_assert( cod_y <= SAVE ); + c3_assert( cod_y < LAST ); return 0; } } @@ -874,6 +875,7 @@ _n_prog_asm(u3_noun ops, u3n_prog* pog_u, u3_noun sip) /* 8-bit direct args */ case FABK: case FABL: case LITB: case LILB: + case MUTB: case KUTB: case SAMB: buf_y[i_w--] = (c3_y) u3t(op); buf_y[i_w] = (c3_y) cod; @@ -882,6 +884,7 @@ _n_prog_asm(u3_noun ops, u3n_prog* pog_u, u3_noun sip) /* 16-bit direct args */ case FASK: case FASL: case LILS: case LITS: + case MUTS: case KUTS: case SAMS: case SIPS: case SINS: { c3_s off_s = u3t(op); buf_y[i_w--] = (c3_y) (off_s >> 8); @@ -1342,9 +1345,9 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) default: op_y = (c3y == los_o) - ? (axe <= 0xFF) ? MUTB : (axe <= 0xFFFF) ? MUTS : MITB // overflows to MITL + ? (axe <= 0xFF) ? MUTB : (axe <= 0xFFFF) ? MUTS : MITB // overflows to MITS : (axe <= 0xFF) ? KUTB : (axe <= 0xFFFF) ? KUTS : KITB; // overflows to KITS - _n_emit(ops, u3nc(op_y, axe)); + _n_emit(ops, u3nc(op_y, u3k(axe))); break; } break; From 61f9a39f3551cc1266f383119c028043cb0f183b Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 11 Jun 2018 15:04:49 -0700 Subject: [PATCH 03/64] disable hike jet, kill errant and unneccessary mutate-context-sample opcodes --- jets/f/hike.c | 1 + jets/tree.c | 4 +++- noun/nock.c | 43 +++++++++++-------------------------------- 3 files changed, 15 insertions(+), 33 deletions(-) diff --git a/jets/f/hike.c b/jets/f/hike.c index 567b1ca0d..6b1bb5b36 100644 --- a/jets/f/hike.c +++ b/jets/f/hike.c @@ -89,6 +89,7 @@ u3qf_hike(u3_noun axe, u3_noun pac) { + c3_assert(0); if ( (u3_nul == pac) ) { return u3nc(0, u3k(axe)); } diff --git a/jets/tree.c b/jets/tree.c index 6ca70d218..cf490820f 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -285,11 +285,13 @@ static u3j_core _143_hex_d[] = 0, }; +/* hike disabled while implementing edit static u3j_harm _143_pen_hike_a[] = {{".2", u3wf_hike}, {}}; static c3_c* _143_pen_hike_ha[] = { "7503dc65fe3164b3e95f81b51afd64ab615e26516b60df95241244e2b793d024", 0, }; +*/ static u3j_harm _143_pen_look_a[] = {{".2", u3wf_look}, {}}; static c3_c* _143_pen_look_ha[] = { "04349d58bcb1317eba57eed8011c27a3ef7c3332c6595e45307a2d06bfc0e8d0", @@ -473,7 +475,7 @@ static u3j_core _143_pen_d[] = { "flor", 7, _143_pen_flor_a, 0, _143_pen_flor_ha }, { "fork", 7, _143_pen_fork_a, 0, _143_pen_fork_ha }, { "help", 7, _143_pen_help_a, 0, _143_pen_help_ha }, - { "hike", 7, _143_pen_hike_a, 0, _143_pen_hike_ha }, +// { "hike", 7, _143_pen_hike_a, 0, _143_pen_hike_ha }, { "look", 7, _143_pen_look_a, 0, _143_pen_look_ha }, { "loot", 7, _143_pen_loot_a, 0, _143_pen_loot_ha }, diff --git a/noun/nock.c b/noun/nock.c index c63a466c3..ca9506920 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -533,17 +533,15 @@ _n_nock_on(u3_noun bus, u3_noun fol) #define KUTT 76 #define MUSM 77 #define KUSM 78 -#define MUCS 79 -#define KUCS 80 -#define MUTB 81 -#define MUTS 82 -#define MITB 83 -#define MITS 84 -#define KUTB 85 -#define KUTS 86 -#define KITB 87 -#define KITS 88 -#define LAST 89 +#define MUTB 79 +#define MUTS 80 +#define MITB 81 +#define MITS 82 +#define KUTB 83 +#define KUTS 84 +#define KITB 85 +#define KITS 86 +#define LAST 87 /* _n_arg(): return the size (in bytes) of an opcode's argument */ @@ -1017,7 +1015,7 @@ static char* opcode_names[] = { "skib", "skis", "slib", "slis", "save", "muth", "kuth", "mutt", "kutt", - "musm", "kusm", "mucs", "kucs", + "musm", "kusm", "mutb", "muts", "mitb", "mits", "kutb", "kuts", "kitb", "kits", }; @@ -1339,10 +1337,6 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) _n_emit(ops, (c3y == los_o) ? MUSM : KUSM); break; - case u3x_con_sam: - _n_emit(ops, (c3y == los_o) ? MUCS : KUCS); - break; - default: op_y = (c3y == los_o) ? (axe <= 0xFF) ? MUTB : (axe <= 0xFFFF) ? MUTS : MITB // overflows to MITS @@ -1658,7 +1652,7 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) &&do_skib, &&do_skis, &&do_slib, &&do_slis, &&do_save, &&do_muth, &&do_kuth, &&do_mutt, &&do_kutt, - &&do_musm, &&do_kusm, &&do_mucs, &&do_kucs, + &&do_musm, &&do_kusm, &&do_mutb, &&do_muts, &&do_mitb, &&do_mits, &&do_kutb, &&do_kuts, &&do_kitb, &&do_kits, }; @@ -2289,21 +2283,6 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) u3z(o); BURN(); - do_kucs: - x = _n_pep(mov, off); - top = _n_swap(mov, off); - goto mucs_in; - do_mucs: - x = _n_pep(mov, off); - _n_toss(mov, off); - top = _n_peek(off); - mucs_in: - o = *top; - *top = u3nc(u3k(u3h(o)), - u3nt(u3k(u3h(u3t(o))), x, u3k(u3t(u3t(u3t(o)))))); - u3z(o); - BURN(); - do_kitb: x = pog_u->lit_u.non[pog[ip_w++]]; goto kut_in; From 0fe4157b8252d9965356a1e9134b94d62ae6aeba Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 12 Jun 2018 10:23:47 -0700 Subject: [PATCH 04/64] small memory leak for large edits --- noun/nock.c | 1 + 1 file changed, 1 insertion(+) diff --git a/noun/nock.c b/noun/nock.c index ca9506920..a2e3a9194 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1607,6 +1607,7 @@ _n_edit(u3_noun big, u3_noun axe, u3_noun som) ? u3nc(_n_edit(u3k(u3h(big)), mor, som), u3k(u3t(big))) : u3nc(u3k(u3h(big)), _n_edit(u3k(u3t(big)), mor, som)); u3z(mor); + u3z(big); return pro; } } From a3f27a6a39c55d5430689bfd1a18a31673da078e Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 12 Jun 2018 10:24:36 -0700 Subject: [PATCH 05/64] bypass mat and chop directly in jam --- jets/e/jam.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/jets/e/jam.c b/jets/e/jam.c index 908556736..209b9e0f1 100644 --- a/jets/e/jam.c +++ b/jets/e/jam.c @@ -57,9 +57,17 @@ _jam_buf_chop(_jam_buf* buf_u, c3_w met_w, u3_noun a) static void _jam_buf_atom(_jam_buf* buf_u, u3_noun a) { - u3_noun mat = u3qe_mat(a); - _jam_buf_chop(buf_u, u3h(mat), u3t(mat)); - u3z(mat); + if ( 0 == a ) { + _jam_buf_chop(buf_u, 1, 1); + } + else { + c3_w b_w = u3r_met(0, a), + c_w = u3r_met(0, b_w); + c3_assert(c_w <= 32); + _jam_buf_chop(buf_u, c_w+1, 1 << c_w); + _jam_buf_chop(buf_u, c_w-1, b_w & ((1 << (c_w-1)) - 1)); + _jam_buf_chop(buf_u, b_w, a); + } } static u3_noun From e629272ac6aa8931a7e2994aaecaccfc71a00c3c Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 14 Jun 2018 11:36:56 -0700 Subject: [PATCH 06/64] avoid allocating an atom for _cj_bash --- jets/e/jam.c | 144 +++++++++++++++++++++++++++------------------------ noun/jets.c | 39 ++++++++++++-- 2 files changed, 112 insertions(+), 71 deletions(-) diff --git a/jets/e/jam.c b/jets/e/jam.c index 209b9e0f1..5869d657b 100644 --- a/jets/e/jam.c +++ b/jets/e/jam.c @@ -40,7 +40,7 @@ _jam_buf_grow(_jam_buf* buf_u, c3_w mor_w) ++new_w; } - buf_u->wor_w = u3a_realloc(buf_u->wor_w, new_w * sizeof(c3_w)); + buf_u->wor_w = u3a_wealloc(buf_u->wor_w, new_w); memset(buf_u->wor_w + old_w, 0, (new_w - old_w) * sizeof(c3_w)); } } @@ -70,91 +70,99 @@ _jam_buf_atom(_jam_buf* buf_u, u3_noun a) } } -static u3_noun -_jam_buf_top(u3_noun a) -{ - u3p(u3h_root) har_p = u3h_new(); - c3_o nor_o = u3a_is_north(u3R); - c3_y wis_y = c3_wiseof(u3_noun); - c3_ys mov = ( c3y == nor_o ? -wis_y : wis_y ); - c3_ys off = ( c3y == nor_o ? 0 : -wis_y ); - u3_noun* top, *don = u3to(u3_noun, u3R->cap_p + off); - _jam_buf buf_u; - u3_weak c; - c3_o cel_o; - c3_w* sal_w, len_w; +/* functions +*/ + /* u3qe_jam_buf(): jam without atom allocation. returns + * atom-suitable words, and *bit_w will + * have the length (in bits). return should + * be freed with u3a_wfree(). + */ + c3_w* + u3qe_jam_buf(u3_noun a, c3_w* bit_w) + { + u3p(u3h_root) har_p = u3h_new(); + c3_o nor_o = u3a_is_north(u3R); + c3_y wis_y = c3_wiseof(u3_noun); + c3_ys mov = ( c3y == nor_o ? -wis_y : wis_y ); + c3_ys off = ( c3y == nor_o ? 0 : -wis_y ); + u3_noun* top, *don = u3to(u3_noun, u3R->cap_p + off); + u3_weak c; + c3_o cel_o; + c3_w len_w; + _jam_buf buf_u; - buf_u.a_w = 144; // fib(12) is small enough to be reasonably fast to allocate. - buf_u.b_w = 89; // fib(11) is needed to get fib(13). - len_w = buf_u.a_w >> 5; - if ( (len_w << 5) != buf_u.a_w ) { - ++len_w; - } - buf_u.wor_w = u3a_calloc(len_w, sizeof(c3_w)); - buf_u.bit_w = 0; + buf_u.a_w = 144; // fib(12) is small enough to be reasonably fast to allocate. + buf_u.b_w = 89; // fib(11) is needed to get fib(13). + len_w = buf_u.a_w >> 5; + if ( (len_w << 5) != buf_u.a_w ) { + ++len_w; + } + buf_u.wor_w = u3a_walloc(len_w); + buf_u.bit_w = 0; + memset(buf_u.wor_w, 0, len_w * sizeof(c3_w)); - u3R->cap_p += mov; - top = u3to(u3_noun, u3R->cap_p + off); - *top = a; + u3R->cap_p += mov; + top = u3to(u3_noun, u3R->cap_p + off); + *top = a; - while ( top != don ) { - a = *top; - cel_o = u3du(a); - c = u3h_git(har_p, a); - if ( u3_none != c ) { - if ( c3y == cel_o ) { - _jam_buf_chop(&buf_u, 2, 3); - _jam_buf_atom(&buf_u, c); - } - else { - if ( u3r_met(0, a) <= u3r_met(0, c) ) { - _jam_buf_chop(&buf_u, 1, 0); - _jam_buf_atom(&buf_u, a); + while ( top != don ) { + a = *top; + cel_o = u3du(a); + c = u3h_git(har_p, a); + if ( u3_none != c ) { + if ( c3y == cel_o ) { + _jam_buf_chop(&buf_u, 2, 3); + _jam_buf_atom(&buf_u, c); } else { - _jam_buf_chop(&buf_u, 2, 3); - _jam_buf_atom(&buf_u, c); + if ( u3r_met(0, a) <= u3r_met(0, c) ) { + _jam_buf_chop(&buf_u, 1, 0); + _jam_buf_atom(&buf_u, a); + } + else { + _jam_buf_chop(&buf_u, 2, 3); + _jam_buf_atom(&buf_u, c); + } } - } - u3R->cap_p -= mov; - top = u3to(u3_noun, u3R->cap_p + off); - } - else { - u3h_put(har_p, a, buf_u.bit_w); - if ( c3n == cel_o ) { - _jam_buf_chop(&buf_u, 1, 0); - _jam_buf_atom(&buf_u, a); u3R->cap_p -= mov; top = u3to(u3_noun, u3R->cap_p + off); } else { - _jam_buf_chop(&buf_u, 2, 1); - *top = u3t(a); + u3h_put(har_p, a, buf_u.bit_w); + if ( c3n == cel_o ) { + _jam_buf_chop(&buf_u, 1, 0); + _jam_buf_atom(&buf_u, a); + u3R->cap_p -= mov; + top = u3to(u3_noun, u3R->cap_p + off); + } + else { + _jam_buf_chop(&buf_u, 2, 1); + *top = u3t(a); - u3R->cap_p += mov; - top = u3to(u3_noun, u3R->cap_p + off); - *top = u3h(a); + u3R->cap_p += mov; + top = u3to(u3_noun, u3R->cap_p + off); + *top = u3h(a); + } } } - } - len_w = buf_u.bit_w >> 5; - if ( (len_w << 5) != buf_u.bit_w ) { - ++len_w; + *bit_w = buf_u.bit_w; + u3h_free(har_p); + return buf_u.wor_w; } - sal_w = u3a_slab(len_w); - memcpy(sal_w, buf_u.wor_w, len_w*sizeof(c3_w)); - u3a_free(buf_u.wor_w); - u3h_free(har_p); - return u3a_moot(sal_w); -} - -/* functions -*/ u3_noun u3qe_jam(u3_atom a) { - return _jam_buf_top(a); + c3_w bit_w, *sal_w; + c3_w* wor_w = u3qe_jam_buf(a, &bit_w); + c3_w len_w = bit_w >> 5; + if ( (len_w << 5) != bit_w ) { + ++len_w; + } + sal_w = u3a_slab(len_w); + memcpy(sal_w, wor_w, len_w*sizeof(c3_w)); + u3a_wfree(wor_w); + return u3a_moot(sal_w); } u3_noun u3we_jam(u3_noun cor) diff --git a/noun/jets.c b/noun/jets.c index e186b4a1b..5da4c3b56 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -3,6 +3,12 @@ */ #include "all.h" +#if defined(U3_OS_osx) +#include +#else +#include +#endif + /** Data structures. **/ @@ -90,6 +96,9 @@ _cj_hash(c3_c* has_c) return pro; } +// in the jam jet file +c3_w* u3qe_jam_buf(u3_noun, c3_w* bit_w); + /* _cj_bash(): battery hash. RETAIN. */ static u3_noun @@ -108,10 +117,34 @@ _cj_bash(u3_noun bat) rod_u = u3to(u3_road, rod_u->par_p); } else { - u3_noun jan = u3qe_jam(bat); - pro = u3qe_shax(jan); + c3_w bit_w, met_w; + c3_w* wor_w; + c3_y* fat_y; + c3_y dig_y[32]; + + wor_w = u3qe_jam_buf(bat, &bit_w); + met_w = bit_w >> 3; + if ( bit_w != met_w << 3 ) { + ++met_w; + } + // assume little-endian + fat_y = (c3_y*) wor_w; +#if defined(U3_OS_osx) + CC_SHA256_CTX ctx_h; + + CC_SHA256_Init(&ctx_h); + CC_SHA256_Update(&ctx_h, fat_y, met_w); + CC_SHA256_Final(dig_y, &ctx_h); +#else + SHA256_CTX ctx_h; + + SHA256_Init(&ctx_h); + SHA256_Update(&ctx_h, fat_y, met_w); + SHA256_Final(dig_y, &ctx_h); +#endif + pro = u3i_bytes(32, dig_y); u3h_put(u3R->jed.bas_p, bat, u3k(pro)); - u3z(jan); + u3a_wfree(wor_w); break; } } From 6ce5fb681ea4f5ab442c6c7c877c5a31f74aef76 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 14 Jun 2018 12:25:45 -0700 Subject: [PATCH 07/64] bail in _n_edit on invalid path --- noun/nock.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/noun/nock.c b/noun/nock.c index a2e3a9194..1ac6de74f 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1603,6 +1603,9 @@ _n_edit(u3_noun big, u3_noun axe, u3_noun som) } else { u3_noun mor = u3qc_mas(axe); + if ( c3n == u3du(big) ) { + u3m_bail(c3__exit); + } u3_noun pro = ( 2 == u3qc_cap(axe) ) ? u3nc(_n_edit(u3k(u3h(big)), mor, som), u3k(u3t(big))) : u3nc(u3k(u3h(big)), _n_edit(u3k(u3t(big)), mor, som)); From 7dcc2303d119b42389e4a07bd3ab0ab50888a33a Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 26 Jun 2018 11:49:15 -0700 Subject: [PATCH 08/64] mutating edit --- include/noun/allocate.h | 9 +++ include/noun/imprison.h | 8 +++ noun/imprison.c | 144 ++++++++++++++++++++++++++++++++++++++++ noun/nock.c | 26 +------- 4 files changed, 162 insertions(+), 25 deletions(-) diff --git a/include/noun/allocate.h b/include/noun/allocate.h index d2a8a55b6..8533158d9 100644 --- a/include/noun/allocate.h +++ b/include/noun/allocate.h @@ -256,6 +256,15 @@ ? u3a_north_is_senior(r, som) \ : u3a_south_is_senior(r, som) ) +# define u3a_is_mutable(r, som) \ + ( _(u3a_is_atom(som)) \ + ? c3n \ + : _(u3a_is_senior(r, som)) \ + ? c3n \ + : _(u3a_is_junior(r, som)) \ + ? c3n \ + : (u3a_botox(u3a_to_ptr(som))->use_w == 1) \ + ? c3y : c3n ) /** Globals. **/ diff --git a/include/noun/imprison.h b/include/noun/imprison.h index efda35fab..f552c87f5 100644 --- a/include/noun/imprison.h +++ b/include/noun/imprison.h @@ -55,6 +55,14 @@ u3_noun u3i_qual(u3_noun a, u3_noun b, u3_noun c, u3_noun d); + /* u3i_edit(): + ** + ** Mutate `big` at axis `axe` with new value `som` + ** `axe` is RETAINED. + */ + u3_noun + u3i_edit(u3_noun big, u3_noun axe, u3_noun som); + /* u3i_string(): ** ** Produce an LSB-first atom from the C string `a`. diff --git a/noun/imprison.c b/noun/imprison.c index c08e967f4..c0d16c3dc 100644 --- a/noun/imprison.c +++ b/noun/imprison.c @@ -262,6 +262,150 @@ u3i_qual(u3_noun a, u3_noun b, u3_noun c, u3_noun d) return u3i_cell(a, u3i_trel(b, c, d)); } +static u3_noun +_edit_cat(u3_noun big, c3_l axe_l, u3_noun som) +{ + if ( c3n == u3du(big) ) { + return u3m_bail(c3__exit); + } + else { + u3_noun pro; + switch ( axe_l ) { + case 2: + pro = u3nc(som, u3k(u3t(big))); + break; + case 3: + pro = u3nc(u3k(u3h(big)), som); + break; + default: { + c3_l mor_l = u3x_mas(axe_l); + pro = ( 2 == u3x_cap(axe_l) ) + ? u3nc(_edit_cat(u3k(u3h(big)), mor_l, som), u3k(u3t(big))) + : u3nc(u3k(u3h(big)), _edit_cat(u3k(u3t(big)), mor_l, som)); + break; + } + } + u3z(big); + return pro; + } +} + +static u3_noun +_edit(u3_noun big, u3_noun axe, u3_noun som) +{ + if ( c3y == u3a_is_cat(axe) ) { + return _edit_cat(big, (c3_l) axe, som); + } + else if ( c3n == u3du(big) ) { + return u3m_bail(c3__exit); + } + else { + u3_noun mor = u3qc_mas(axe), + pro = ( 2 == u3qc_cap(axe) ) + ? u3nc(_edit(u3k(u3h(big)), mor, som), u3k(u3t(big))) + : u3nc(u3k(u3h(big)), _edit(u3k(u3t(big)), mor, som)); + u3z(mor); + u3z(big); + return pro; + } +} + +static u3_noun _edit_or_mutate_cat(u3_noun, c3_l, u3_noun); +static u3_noun _edit_or_mutate(u3_noun, u3_noun, u3_noun); + +static void +_mutate_cat(u3_noun big, c3_l axe_l, u3_noun som) +{ + if ( c3n == u3du(big) ) { + u3m_bail(c3__exit); + } + else { + u3a_cell* cel_u = (void*) u3a_to_ptr(big); + switch ( axe_l ) { + case 2: + u3z(cel_u->hed); + cel_u->hed = som; + break; + case 3: + u3z(cel_u->tel); + cel_u->tel = som; + break; + default: { + u3_noun* tar = ( 2 == u3x_cap(axe_l) ) + ? &(cel_u->hed) + : &(cel_u->tel); + *tar = _edit_or_mutate_cat(*tar, u3x_mas(axe_l), som); + } + } + } +} + +static void +_mutate(u3_noun big, u3_noun axe, u3_noun som) +{ + if ( c3y == u3a_is_cat(axe) ) { + _mutate_cat(big, (c3_l) axe, som); + } + else if ( c3n == u3du(big) ) { + u3m_bail(c3__exit); + } + else { + u3a_cell* cel_u = (void*) u3a_to_ptr(big); + u3_noun mor = u3qc_mas(axe); + u3_noun* tar = ( 2 == u3qc_cap(axe) ) + ? &(cel_u->hed) + : &(cel_u->tel); + *tar = _edit_or_mutate(*tar, mor, som); + u3z(mor); + } +} + +static u3_noun +_edit_or_mutate_cat(u3_noun big, c3_l axe_l, u3_noun som) +{ + if ( c3y == u3a_is_mutable(u3R, big) ) { + _mutate_cat(big, axe_l, som); + return big; + } + else { + return _edit_cat(big, axe_l, som); + } +} + +static u3_noun +_edit_or_mutate(u3_noun big, u3_noun axe, u3_noun som) +{ + if ( c3y == u3a_is_cat(axe) ) { + return _edit_or_mutate_cat(big, (c3_l) axe, som); + } + else if ( c3y == u3a_is_mutable(u3R, big) ) { + _mutate(big, axe, som); + return big; + } + else { + return _edit(big, axe, som); + } +} + +/* u3i_edit(): +** +** Mutate `big` at axis `axe` with new value `som`. +** `axe` is RETAINED. +*/ +u3_noun +u3i_edit(u3_noun big, u3_noun axe, u3_noun som) +{ + switch ( axe ) { + case 0: + return u3m_bail(c3__exit); + case 1: + u3z(big); + return som; + default: + return _edit_or_mutate(big, axe, som); + } +} + /* u3i_string(): ** ** Produce an LSB-first atom from the C string `a`. diff --git a/noun/nock.c b/noun/nock.c index 1ac6de74f..2150ae223 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1591,30 +1591,6 @@ _n_kale(u3_noun a) return a; } - -/* _n_edit(): PRODUCE a modified big with its axe axis - * changed to som. axe is RETAINED. - */ -static u3_noun -_n_edit(u3_noun big, u3_noun axe, u3_noun som) -{ - if ( c3y == u3a_is_cat(axe) ) { - return u3i_molt(big, axe, som, 0); - } - else { - u3_noun mor = u3qc_mas(axe); - if ( c3n == u3du(big) ) { - u3m_bail(c3__exit); - } - u3_noun pro = ( 2 == u3qc_cap(axe) ) - ? u3nc(_n_edit(u3k(u3h(big)), mor, som), u3k(u3t(big))) - : u3nc(u3k(u3h(big)), _n_edit(u3k(u3t(big)), mor, som)); - u3z(mor); - u3z(big); - return pro; - } -} - typedef struct { u3n_prog* pog_u; c3_w ip_w; @@ -2325,7 +2301,7 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) _n_toss(mov, off); top = _n_peek(off); edit_in: - *top = _n_edit(*top, x, o); + *top = u3i_edit(*top, x, o); BURN(); } } From 2f92e6409fbd40db048e1a30ca62bba9ef456f20 Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Thu, 4 Oct 2018 10:43:21 -0700 Subject: [PATCH 09/64] increased inbound request and ward timeouts to 5 min --- vere/http.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vere/http.c b/vere/http.c index ddd509a80..32211dfe8 100644 --- a/vere/http.c +++ b/vere/http.c @@ -463,7 +463,7 @@ _http_rec_accept(h2o_handler_t* han_u, h2o_req_t* rec_u) req_u->tim_u = c3_malloc(sizeof(*req_u->tim_u)); req_u->tim_u->data = req_u; uv_timer_init(u3L, req_u->tim_u); - uv_timer_start(req_u->tim_u, _http_req_timer_cb, 30 * 1000, 0); + uv_timer_start(req_u->tim_u, _http_req_timer_cb, 300 * 1000, 0); _http_req_dispatch(req_u, req); @@ -2310,7 +2310,7 @@ _proxy_ward_start(u3_pcon* con_u, u3_noun sip) uv_timer_init(u3L, &rev_u->tim_u); // XX how long? - uv_timer_start(&rev_u->tim_u, _proxy_ward_timer_cb, 120 * 1000, 0); + uv_timer_start(&rev_u->tim_u, _proxy_ward_timer_cb, 300 * 1000, 0); // XX u3_lo_shut(c3y); } From c058bae81cbcb2c1664e8f1876cae3905a33474a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 6 Sep 2018 21:35:17 -0400 Subject: [PATCH 10/64] implements initial version of eth-integrated %dawn boot --- include/c/motes.h | 1 + include/vere/vere.h | 1 + vere/main.c | 20 +++- vere/sist.c | 222 +++++++++++++++++++++++++++++++++++--------- 4 files changed, 198 insertions(+), 46 deletions(-) diff --git a/include/c/motes.h b/include/c/motes.h index 652cfa073..9d0b95b75 100644 --- a/include/c/motes.h +++ b/include/c/motes.h @@ -284,6 +284,7 @@ # define c3__dant c3_s4('d','a','n','t') # define c3__dast c3_s4('d','a','s','t') # define c3__data c3_s4('d','a','t','a') +# define c3__dawn c3_s4('d','a','w','n') # define c3__dbug c3_s4('d','b','u','g') # define c3__dec c3_s3('d','e','c') # define c3__deem c3_s4('d','e','e','m') diff --git a/include/vere/vere.h b/include/vere/vere.h index 8e77d7153..2fbea9f2d 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -587,6 +587,7 @@ c3_c* tic_c; // -t, ticket value c3_c* url_c; // -u, pill url c3_c* who_c; // -w, begin with ticket + c3_c* key_c; // -K, private key file c3_o abo; // -a c3_o bat; // -b, batch create c3_o dem; // -d, daemon diff --git a/vere/main.c b/vere/main.c index 74901d790..fa06b1558 100644 --- a/vere/main.c +++ b/vere/main.c @@ -92,7 +92,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.veb = c3n; u3_Host.ops_u.kno_w = DefaultKernel; - while ( (ch_i=getopt(argc, argv,"G:B:A:H:I:w:u:t:f:k:l:n:p:r:NabcdgqsvxFMPDXRS")) != -1 ) { + while ( (ch_i=getopt(argc, argv,"G:B:K:A:H:I:w:u:t:f:k:l:n:p:r:NabcdgqsvxFMPDXRS")) != -1 ) { switch ( ch_i ) { case 'M': { u3_Host.ops_u.mem = c3y; @@ -145,6 +145,11 @@ _main_getopt(c3_i argc, c3_c** argv) } break; } + case 'K': { + u3_Host.ops_u.key_c = strdup(optarg); + u3_Host.ops_u.nuu = c3y; + break; + } case 'k': { if ( c3n == _main_readw(optarg, 256, &u3_Host.ops_u.kno_w) ) { return c3n; @@ -249,6 +254,11 @@ _main_getopt(c3_i argc, c3_c** argv) return c3n; } + if ( u3_Host.ops_u.nuu != c3y && u3_Host.ops_u.key_c != 0) { + fprintf(stderr, "-K only makes sense when bootstrapping a new instance\n"); + return c3n; + } + if ( u3_Host.ops_u.nuu != c3y && u3_Host.ops_u.url_c != 0 ) { fprintf(stderr, "-u only makes sense when bootstrapping a new instance\n"); return c3n; @@ -279,6 +289,14 @@ _main_getopt(c3_i argc, c3_c** argv) } } + if ( u3_Host.ops_u.key_c != 0 ) { + struct stat s; + if ( stat(u3_Host.ops_u.key_c, &s) != 0 ) { + fprintf(stderr, "keyfile %s not found\n", u3_Host.ops_u.key_c); + return c3n; + } + } + if ( u3_Host.ops_u.nam_c == 0 ) { u3_Host.ops_u.nam_c = getenv("HOSTNAME"); if ( u3_Host.ops_u.nam_c == 0 ) { diff --git a/vere/sist.c b/vere/sist.c index acd3ac9fd..b04e5c471 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include "all.h" @@ -1165,6 +1166,181 @@ _sist_zen() return u3i_words(16, rad_w); } +/* _sist_curl_alloc(): allocate a response buffer for curl +*/ +static size_t +_sist_curl_alloc(void* dat_v, size_t uni_t, size_t mem_t, uv_buf_t* buf_u) +{ + size_t siz_t = uni_t * mem_t; + buf_u->base = realloc(buf_u->base, 1 + siz_t + buf_u->len); + + if ( 0 == buf_u->base ) { + fprintf(stderr, "out of memory\n"); + u3_lo_bail(); + } + + memcpy(buf_u->base + buf_u->len, dat_v, siz_t); + buf_u->len += siz_t; + buf_u->base[buf_u->len] = 0; + + return siz_t; +} + +/* _sist_post_json(): POST JSON to url_c +*/ +static uv_buf_t +_sist_post_json(c3_c* url_c, uv_buf_t lod_u) +{ + CURL *curl; + CURLcode result; + long cod_l; + struct curl_slist* hed_u = 0; + + uv_buf_t buf_u = uv_buf_init(c3_malloc(1), 0); + + if ( !(curl = curl_easy_init()) ) { + fprintf(stderr, "failed to initialize libcurl\n"); + u3_lo_bail(); + } + + hed_u = curl_slist_append(hed_u, "Accept: application/json"); + hed_u = curl_slist_append(hed_u, "Content-Type: application/json"); + hed_u = curl_slist_append(hed_u, "charsets: utf-8"); + + curl_easy_setopt(curl, CURLOPT_URL, url_c); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _sist_curl_alloc); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&buf_u); + + // note: must be terminated! + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, lod_u.base); + + result = curl_easy_perform(curl); + curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &cod_l); + + // XX retry? + if ( CURLE_OK != result ) { + fprintf(stderr, "failed to fetch %s: %s\n", + url_c, curl_easy_strerror(result)); + u3_lo_bail(); + } + if ( 300 <= cod_l ) { + fprintf(stderr, "error fetching %s: HTTP %ld\n", url_c, cod_l); + u3_lo_bail(); + } + + curl_easy_cleanup(curl); + + return buf_u; +} + +/* _sist_oct_to_buf(): +octs to uv_buf_t +*/ +static uv_buf_t +_sist_oct_to_buf(u3_noun oct) +{ + if ( c3n == u3a_is_cat(u3h(oct)) ) { + u3_lo_bail(); + } + + c3_w len_w = u3h(oct); + c3_y* buf_y = c3_malloc(1 + len_w); + buf_y[len_w] = 0; + + u3r_bytes(0, len_w, buf_y, u3t(oct)); + + u3z(oct); + return uv_buf_init((void*)buf_y, len_w); +} + +/* _sist_buf_to_oct(): uv_buf_t to +octs +*/ +static u3_noun +_sist_buf_to_oct(uv_buf_t buf_u) +{ + u3_noun len = u3i_words(1, (c3_w*)&buf_u.len); + + if ( c3n == u3a_is_cat(len) ) { + u3_lo_bail(); + } + + return u3nc(len, u3i_bytes(buf_u.len, (const c3_y*)buf_u.base)); +} + +/* _sist_eth_rpc(): ethereum JSON RPC with request/response as +octs +*/ +static u3_noun +_sist_eth_rpc(c3_c* url_c, u3_noun oct) +{ + return _sist_buf_to_oct(_sist_post_json(url_c, _sist_oct_to_buf(oct))); +} + +/* _sist_dawn(): produce %dawn boot card - validate keys and query contract +*/ +static u3_noun +_sist_dawn(void) +{ + if ( c3y == u3_Host.ops_u.fak ) { + // XX generate fake keys, or use separate fake boot event + } + + if ( 0 == u3_Host.ops_u.key_c ) { + // XX print nice error + u3_lo_bail(); + } + + u3_noun eds = u3m_file(u3_Host.ops_u.key_c); + u3_noun des = u3dc("slaw", c3__uw, eds); + + if ( u3_nul == des ) { + // XX print nice error + u3_lo_bail(); + } + + // +seed:dawn: + // [who=ship lyf=life key=ring sig=(unit oath:pki:jael)] + u3_noun sed = u3ke_cue(u3t(des)); + u3_noun who = u3h(sed); + + // u3_noun lyf = u3h(u3t(sed)); + // u3_noun key = u3h(u3t(u3t(sed))); + // u3_noun sig = u3t(u3t(u3t(sed))); + // u3_noun rac = u3do("clan:title", u3k(who)); + + // XX configure default globally, add cli arg to specify + c3_c* url_c = "http://localhost:8545"; + + u3_noun luh = _sist_eth_rpc(url_c, u3do("hull:give:dawn", u3k(who))); + u3_noun hul = u3dc("hull:take:dawn", u3k(who), luh); + + // XX actually make request + // u3_noun liv = _sist_get_json(parent, /some/url) + u3_noun liv = u3_nul; + + u3_noun sas = u3dt("veri:dawn", sed, hul, liv); + + if ( c3n == u3h(sas) ) { + // XX deconstruct sas, print helpful error messages + u3m_p("pre-boot error", u3t(sas)); + u3_lo_bail(); + } + + // XX slow, temporarily disabled + // XX maybe print messages, spin a cursor, etc. + // u3_noun raz = _sist_eth_rpc(url_c, u3v_wish("czar:give:dawn")); + // u3_noun zar = u3do("czar:take:dawn", raz); + u3_noun zar = u3_nul; + + u3_noun fut = _sist_eth_rpc(url_c, u3v_wish("turf:give:dawn")); + u3_noun tuf = u3do("turf:take:dawn", fut); + + // XX extract from sas + // XX or maybe pass entire hull? + u3_noun pon = u3_nul; + + // [%dawn =seed:dawn spon=(unit ship) czar=(map ship [=life =pass]) turf=(list (pair @ud (list @ta)))] + return u3nc(c3__dawn, u3nq(sed, pon, zar, tuf)); +} + /* u3_sist_boot(): restore or create. */ void @@ -1173,51 +1349,7 @@ u3_sist_boot(void) // uL(fprintf(uH, "sist: booting\n")); if ( c3y == u3_Host.ops_u.nuu ) { - u3_noun pig = u3_none; - - if ( 0 == u3_Host.ops_u.imp_c ) { - u3_noun ten = _sist_zen(); - uL(fprintf(uH, "generating curve25519 key pair...\n")); - - pig = u3nq(c3__make, u3_nul, 11, u3nc(ten, u3_Host.ops_u.fak)); - } - else { - u3_noun imp = u3i_string(u3_Host.ops_u.imp_c); - u3_noun whu = u3dc("slaw", 'p', u3k(imp)); - - if ( (u3_nul == whu) ) { - fprintf(stderr, "czar: incorrect format\r\n"); - u3_lo_bail(); - } - else { - u3_noun gen = u3_nul; - u3_noun gun = u3_nul; - if (c3n == u3_Host.ops_u.fak) { - if ( 0 != u3_Host.ops_u.gen_c) { - gen = u3i_string(u3_Host.ops_u.gen_c); - } - else { - gen = _sist_text("generator"); // XX move to main.c - } - gun = u3dc("slaw", c3__uw, gen); - - if ( u3_nul == gun ) { - fprintf(stderr, "czar: incorrect format\r\n"); - u3_lo_bail(); - } - } - else { - gun = u3nc(u3_nul, u3_nul); - } - pig = u3nq(c3__sith, - u3k(u3t(whu)), - u3k(u3t(gun)), - u3_Host.ops_u.fak); - - u3z(whu); u3z(gun); - } - u3z(imp); - } + u3_noun pig = _sist_dawn(); _sist_make(pig); } else { From 91f2d9ed68c857fc3338c0a5dc88a33705a7dae8 Mon Sep 17 00:00:00 2001 From: Joseph Lukasik Date: Wed, 26 Sep 2018 22:24:50 -0700 Subject: [PATCH 11/64] Disable terminal echo on passcode entry --- vere/sist.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/vere/sist.c b/vere/sist.c index acd3ac9fd..4244027fe 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -295,14 +295,28 @@ _sist_cask(c3_c* dir_c, u3_noun nun) { c3_c paw_c[60]; u3_noun key; + u3_utty* uty_u = calloc(1, sizeof(u3_utty)); + uty_u->fid_i = 0; uH; + + // disable terminal echo when typing in passcode + if ( 0 != tcgetattr(uty_u->fid_i, &uty_u->bak_u) ) { + c3_assert(!"init-tcgetattr"); + } + uty_u->raw_u = uty_u->bak_u; + uty_u->raw_u.c_lflag &= ~ECHO; + if ( 0 != tcsetattr(uty_u->fid_i, TCSADRAIN, &uty_u->raw_u) ) { + c3_assert(!"init-tcsetattr"); + } + while ( 1 ) { printf("passcode for %s%s? ~", dir_c, (c3y == nun) ? " [none]" : ""); paw_c[0] = 0; c3_fpurge(stdin); fgets(paw_c, 59, stdin); + printf("\n"); if ( '\n' == paw_c[0] ) { if ( c3y == nun ) { @@ -334,6 +348,10 @@ _sist_cask(c3_c* dir_c, u3_noun nun) break; } } + if ( 0 != tcsetattr(uty_u->fid_i, TCSADRAIN, &uty_u->bak_u) ) { + c3_assert(!"init-tcsetattr"); + } + free(uty_u); uL(0); return key; } From 8fc65462b8f5ee494a615bff9a922399a77b1419 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sat, 15 Sep 2018 01:39:13 -0400 Subject: [PATCH 12/64] minimal fake-key boot - galaxies only for now --- include/c/motes.h | 1 + vere/sist.c | 23 ++++++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/include/c/motes.h b/include/c/motes.h index 9d0b95b75..7914354ca 100644 --- a/include/c/motes.h +++ b/include/c/motes.h @@ -375,6 +375,7 @@ # define c3__face c3_s4('f','a','c','e') # define c3__fail c3_s4('f','a','i','l') # define c3__fair c3_s4('f','a','i','r') +# define c3__fake c3_s4('f','a','k','e') # define c3__fan c3_s3('f','a','n') # define c3__farg c3_s4('f','a','r','g') # define c3__fast c3_s4('f','a','s','t') diff --git a/vere/sist.c b/vere/sist.c index b04e5c471..c1b0a1216 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1279,10 +1279,6 @@ _sist_eth_rpc(c3_c* url_c, u3_noun oct) static u3_noun _sist_dawn(void) { - if ( c3y == u3_Host.ops_u.fak ) { - // XX generate fake keys, or use separate fake boot event - } - if ( 0 == u3_Host.ops_u.key_c ) { // XX print nice error u3_lo_bail(); @@ -1349,7 +1345,24 @@ u3_sist_boot(void) // uL(fprintf(uH, "sist: booting\n")); if ( c3y == u3_Host.ops_u.nuu ) { - u3_noun pig = _sist_dawn(); + u3_noun pig; + + if ( c3y == u3_Host.ops_u.fak ) { + // XX or who_c + u3_noun imp = u3i_string(u3_Host.ops_u.imp_c); + u3_noun whu = u3dc("slaw", 'p', u3k(imp)); + + if ( (u3_nul == whu) ) { + fprintf(stderr, "czar: incorrect format\r\n"); + u3_lo_bail(); + } + + pig = u3nc(c3__fake, u3t(whu)); + } + else { + pig = _sist_dawn(); + } + _sist_make(pig); } else { From bcc1261009bd6510f72cb9132b9ddf840251811b Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 14 Sep 2018 11:17:16 -0400 Subject: [PATCH 13/64] removes first-boot ticket --- include/vere/vere.h | 6 ------ vere/loop.c | 3 --- vere/main.c | 20 +------------------- vere/term.c | 26 -------------------------- 4 files changed, 1 insertion(+), 54 deletions(-) diff --git a/include/vere/vere.h b/include/vere/vere.h index 2fbea9f2d..205b03c28 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -584,7 +584,6 @@ c3_c* nam_c; // -n, unix hostname c3_c* pil_c; // -B, bootstrap from c3_c* raf_c; // -r, raft flotilla - c3_c* tic_c; // -t, ticket value c3_c* url_c; // -u, pill url c3_c* who_c; // -w, begin with ticket c3_c* key_c; // -K, private key file @@ -862,11 +861,6 @@ void u3_term_ef_boil(); - /* u3_term_ef_ticket(): initial effects for new ticket. - */ - void - u3_term_ef_ticket(c3_c* who_c, c3_c* tic_c); - /* u3_term_ef_verb(): initial effects for verbose events. */ void diff --git a/vere/loop.c b/vere/loop.c index 03a015b45..d3362efb3 100644 --- a/vere/loop.c +++ b/vere/loop.c @@ -685,9 +685,6 @@ u3_lo_lead(void) #endif if ( c3y == u3_Host.ops_u.nuu ) { - if ( u3_Host.ops_u.who_c ) { - u3_term_ef_ticket(u3_Host.ops_u.who_c, u3_Host.ops_u.tic_c); - } u3_term_ef_boil(1); } diff --git a/vere/main.c b/vere/main.c index fa06b1558..98d04b07a 100644 --- a/vere/main.c +++ b/vere/main.c @@ -92,7 +92,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.veb = c3n; u3_Host.ops_u.kno_w = DefaultKernel; - while ( (ch_i=getopt(argc, argv,"G:B:K:A:H:I:w:u:t:f:k:l:n:p:r:NabcdgqsvxFMPDXRS")) != -1 ) { + while ( (ch_i=getopt(argc, argv,"G:B:K:A:H:I:w:u:f:k:l:n:p:r:NabcdgqsvxFMPDXRS")) != -1 ) { switch ( ch_i ) { case 'M': { u3_Host.ops_u.mem = c3y; @@ -127,10 +127,6 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.url_c = strdup(optarg); break; } - case 't': { - u3_Host.ops_u.tic_c = _main_presig(optarg); - break; - } case 'x': { u3_Host.ops_u.tex = c3y; break; @@ -226,24 +222,11 @@ _main_getopt(c3_i argc, c3_c** argv) return c3n; } - if ( u3_Host.ops_u.tic_c != 0 && ( u3_Host.ops_u.imp_c != 0 || - u3_Host.ops_u.nuu == c3n ) ) { - fprintf(stderr, "-t only makes sense when creating a new non-galaxy\n"); - return c3n; - } - if ( u3_Host.ops_u.rop_s == 0 && u3_Host.ops_u.raf_c != 0 ) { fprintf(stderr, "The -r flag requires -l.\n"); return c3n; } - if ( u3_Host.ops_u.tic_c == 0 && u3_Host.ops_u.who_c != 0 ) { - c3_c tic_c[29]; - printf("your ticket: ~"); - scanf("%28s",tic_c); - u3_Host.ops_u.tic_c = _main_presig(tic_c); - } - if ( c3y == u3_Host.ops_u.bat ) { u3_Host.ops_u.dem = c3y; u3_Host.ops_u.nuu = c3y; @@ -366,7 +349,6 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-r host Initial peer address\n", "-R Report urbit build info\n", "-s Pill URL from arvo git hash\n", - "-t ticket Use ~ticket automatically\n", "-u url URL from which to download pill\n", "-v Verbose\n", "-w name Immediately upgrade to ~name\n", diff --git a/vere/term.c b/vere/term.c index c6409d5a7..2736e8314 100644 --- a/vere/term.c +++ b/vere/term.c @@ -1032,32 +1032,6 @@ u3_term_ef_verb(void) u3v_plan(pax, u3nc(c3__verb, u3_nul)); } -/* u3_term_ef_ticket(): initial effects for new ticket. -*/ -void -u3_term_ef_ticket(c3_c* who_c, c3_c* tic_c) -{ - u3_noun pax = u3nq(u3_blip, c3__term, '1', u3_nul); - u3_noun who, tic; - u3_noun whu, tuc; - - whu = u3dc("slaw", 'p', u3i_string(who_c)); - if ( u3_nul == whu ) { - fprintf(stderr, "ticket: invalid planet '%s'\r\n", who_c); - exit(1); - } - else { who = u3k(u3t(whu)); u3z(whu); } - - tuc = u3dc("slaw", 'p', u3i_string(tic_c)); - if ( u3_nul == tuc ) { - fprintf(stderr, "ticket: invalid secret '%s'\r\n", tic_c); - exit(1); - } - else { tic = u3k(u3t(tuc)); u3z(tuc); } - - u3v_plan(pax, u3nt(c3__tick, who, tic)); -} - /* u3_term_ef_bake(): initial effects for new terminal. */ void From 0b13837bfafdd0d3118dcc0d8880bba061f06847 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 10 Aug 2018 12:58:21 -0400 Subject: [PATCH 14/64] single-home's arvo, refines fake keys --- include/noun/vortex.h | 1 + include/vere/vere.h | 2 +- vere/http.c | 22 +++++++--------------- vere/main.c | 34 ++++++++++++++++++++++++++++------ vere/reck.c | 19 +++++++++---------- vere/sist.c | 39 +++++++++++++++++++++++++++++---------- 6 files changed, 75 insertions(+), 42 deletions(-) diff --git a/include/noun/vortex.h b/include/noun/vortex.h index e750c45b2..b36cd8f25 100644 --- a/include/noun/vortex.h +++ b/include/noun/vortex.h @@ -26,6 +26,7 @@ u3_noun sev_l; // instance number u3_noun sen; // instance string u3_noun own; // owner list + u3_noun fak; // &=fake XX use c3_o? u3_noun sac; // space profiling diff --git a/include/vere/vere.h b/include/vere/vere.h index 205b03c28..ced7474fd 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -591,7 +591,7 @@ c3_o bat; // -b, batch create c3_o dem; // -d, daemon c3_o dry; // -D, dry compute - c3_o fak; // -F, fake carrier + c3_c* fak_c; // -F, fake ship c3_o fog; // -X, skip last event c3_o gab; // -g, run with garbage collector c3_o has; // -S, Skip battery hashes diff --git a/vere/http.c b/vere/http.c index 2741ad1d9..ea2b006da 100644 --- a/vere/http.c +++ b/vere/http.c @@ -1401,7 +1401,7 @@ _http_serv_start_all(void) htp_u = _http_serv_new(por_s, c3y, c3n); htp_u->h2o_u = _http_serv_init_h2o(u3_Host.tls_u, for_u->log, for_u->red); - if ( (c3y == for_u->pro) || (c3y == u3_Host.ops_u.fak) ) { + if ( c3y == for_u->pro ) { htp_u->rox_u = _proxy_serv_new(htp_u, 443, c3y); } @@ -1416,7 +1416,7 @@ _http_serv_start_all(void) htp_u = _http_serv_new(por_s, c3n, c3n); htp_u->h2o_u = _http_serv_init_h2o(0, for_u->log, for_u->red); - if ( (c3y == for_u->pro) || (c3y == u3_Host.ops_u.fak) ) { + if ( c3y == for_u->pro ) { htp_u->rox_u = _proxy_serv_new(htp_u, 80, c3n); } @@ -2571,25 +2571,16 @@ _proxy_dest(u3_pcon* con_u, u3_noun sip) _proxy_loop_connect(con_u); } else { - u3_noun hip = u3k(u3t(sip)); - u3_noun own = u3A->own; - c3_o our = c3n; + u3_noun hip = u3t(sip); - while ( u3_nul != own ) { - if ( c3y == u3r_sing(hip, u3h(own)) ) { - our = c3y; - break; - } - own = u3t(own); - } - - if ( c3y == our ) { + if ( c3y == u3r_sing(u3A->own, hip) ) { _proxy_loop_connect(con_u); } else { // XX check if (sein:title sip) == our // XX check will - _proxy_ward_start(con_u, hip); + // XX extract bytes from hip, this could leak + _proxy_ward_start(con_u, u3k(hip)); } } @@ -2852,6 +2843,7 @@ u3_http_ef_that(u3_noun tat) return; } + // XX extract bytes from sip, this could leak cli_u = _proxy_warc_new(htp_u, (u3_atom)sip, (c3_s)por, (c3_o)sec); // XX add to constructor diff --git a/vere/main.c b/vere/main.c index 98d04b07a..13f164229 100644 --- a/vere/main.c +++ b/vere/main.c @@ -77,7 +77,6 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.bat = c3n; u3_Host.ops_u.dem = c3n; u3_Host.ops_u.dry = c3n; - u3_Host.ops_u.fak = c3n; u3_Host.ops_u.fog = c3n; u3_Host.ops_u.gab = c3n; u3_Host.ops_u.git = c3n; @@ -92,7 +91,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.veb = c3n; u3_Host.ops_u.kno_w = DefaultKernel; - while ( (ch_i=getopt(argc, argv,"G:B:K:A:H:I:w:u:f:k:l:n:p:r:NabcdgqsvxFMPDXRS")) != -1 ) { + while ( (ch_i=getopt(argc, argv,"G:B:K:A:H:I:w:u:f:F:k:l:n:p:r:NabcdgqsvxMPDXRS")) != -1 ) { switch ( ch_i ) { case 'M': { u3_Host.ops_u.mem = c3y; @@ -114,10 +113,15 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.dns_c = strdup(optarg); break; } + // XX remove in deference to -K case 'I': { u3_Host.ops_u.imp_c = _main_presig(optarg); break; } + case 'F': { + u3_Host.ops_u.fak_c = _main_presig(optarg); + break; + } case 'w': { u3_Host.ops_u.who_c = _main_presig(optarg); u3_Host.ops_u.nuu = c3y; @@ -177,7 +181,6 @@ _main_getopt(c3_i argc, c3_c** argv) return c3y; } case 'N': { u3_Host.ops_u.net = c3y; break; } - case 'F': { u3_Host.ops_u.fak = c3y; break; } case 'a': { u3_Host.ops_u.abo = c3y; break; } case 'b': { u3_Host.ops_u.bat = c3y; break; } case 'c': { u3_Host.ops_u.nuu = c3y; break; } @@ -195,10 +198,29 @@ _main_getopt(c3_i argc, c3_c** argv) } } - if ( u3_Host.ops_u.fak == c3n && u3_Host.ops_u.net == c3y ) { + // XX remove -I + if ( (0 != u3_Host.ops_u.fak_c) && (0 != u3_Host.ops_u.imp_c) ) { + fprintf(stderr, "-I is redundant with -F\n"); + return c3n; + } + + // set galaxy name + // XX need to do this with -K too + // -A is required when booting a galaxy + if ( (0 != u3_Host.ops_u.fak_c) && (4 == strlen(u3_Host.ops_u.fak_c)) ) { + u3_Host.ops_u.imp_c = strdup(u3_Host.ops_u.fak_c); + } + + if ( (0 != u3_Host.ops_u.fak_c) && (c3n == u3_Host.ops_u.nuu) ) { + fprintf(stderr, "-F only makes sense on initial boot\n"); + return c3n; + } + + // XX revisit + if ( (0 == u3_Host.ops_u.fak_c) && (c3y == u3_Host.ops_u.net) ) { fprintf(stderr, "-N only makes sense with -F\n"); return c3n; - } else if ( u3_Host.ops_u.fak == c3n && u3_Host.ops_u.net == c3n ) { + } else if ( (0 == u3_Host.ops_u.fak_c) && (c3n == u3_Host.ops_u.net) ) { u3_Host.ops_u.net = c3y; /* remote networking is always on in real mode. */ } @@ -333,7 +355,7 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-c pier Create a new urbit in pier/\n", "-d Daemon mode\n", "-D Recompute from events\n", - "-F Fake keys; also disables networking\n", + "-F ship Fake keys; also disables networking\n", "-f Fuzz testing\n", "-g Set GC flag\n", "-H domain Set ames bootstrap domain (default urbit.org)\n", diff --git a/vere/reck.c b/vere/reck.c index e66363112..6d3379bec 100644 --- a/vere/reck.c +++ b/vere/reck.c @@ -100,13 +100,10 @@ _reck_kick_term(u3_noun pox, c3_l tid_l, u3_noun fav) case c3__init: p_fav = u3t(fav); { - u3A->own = u3nc(u3k(p_fav), u3A->own); + c3_assert( u3_none == u3A->own ); + u3A->own = u3k(p_fav); - u3_noun hox = u3dc("scot", 'p', u3k(p_fav)); - c3_c* nam_c = u3r_string(hox); - - // uL(fprintf(uH, "kick: init: %s\n", nam_c)); - free(nam_c); u3z(pox); u3z(hox); u3z(fav); return c3y; + u3z(pox); u3z(fav); return c3y; } break; case c3__mass: p_fav = u3t(fav); @@ -224,11 +221,12 @@ _reck_kick_ames(u3_noun pox, u3_noun fav) switch ( u3h(fav) ) { default: break; + // XX remove case c3__init: p_fav = u3t(fav); { - u3A->own = u3nc(u3k(p_fav), u3A->own); + uL(fprintf(uH, "kick: init: ames\n")); + c3_assert(0); - // uL(fprintf(uH, "kick: init: %d\n", p_fav)); u3z(pox); u3z(fav); return c3y; } break; } @@ -313,11 +311,12 @@ _reck_kick_spec(u3_noun pox, u3_noun fav) } } break; + // XX remove case c3__init: p_fav = u3t(fav); { - u3A->own = u3nc(u3k(p_fav), u3A->own); + uL(fprintf(uH, "kick: init: spec\n")); + c3_assert(0); - // uL(fprintf(uH, "kick: init: %d\n", p_fav)); u3z(pox); u3z(fav); return c3y; } break; diff --git a/vere/sist.c b/vere/sist.c index c1b0a1216..5fe7df0e3 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -261,9 +261,11 @@ _sist_sing(u3_noun ovo) u3_noun fex = u3h(vir); u3_noun fav = u3t(fex); - if ( (c3__init == u3h(fav)) || (c3__inuk == u3h(fav)) ) { - u3A->own = u3nc(u3k(u3t(fav)), u3A->own); + // XX is this now just to support ctrl-z during first boot? + if ( c3__init == u3h(fav) ) { + u3A->own = u3k(u3t(fav)); } + vir = u3t(vir); } u3z(nug); @@ -1342,30 +1344,47 @@ _sist_dawn(void) void u3_sist_boot(void) { - // uL(fprintf(uH, "sist: booting\n")); - if ( c3y == u3_Host.ops_u.nuu ) { u3_noun pig; - if ( c3y == u3_Host.ops_u.fak ) { - // XX or who_c - u3_noun imp = u3i_string(u3_Host.ops_u.imp_c); - u3_noun whu = u3dc("slaw", 'p', u3k(imp)); + if ( 0 != u3_Host.ops_u.fak_c ) { + u3_noun whu = u3dc("slaw", 'p', u3i_string(u3_Host.ops_u.fak_c)); if ( (u3_nul == whu) ) { - fprintf(stderr, "czar: incorrect format\r\n"); + fprintf(stderr, "fake: invalid ship: %s\r\n", u3_Host.ops_u.fak_c); u3_lo_bail(); } - pig = u3nc(c3__fake, u3t(whu)); + fprintf(stderr, "fake: %s\r\n", u3_Host.ops_u.fak_c); + + u3A->fak = c3y; + pig = u3nc(c3__fake, u3k(u3t(whu))); + u3z(whu); } else { + u3A->fak = c3n; pig = _sist_dawn(); } + // will be set by %init card in reck.c + u3A->own = u3_none; _sist_make(pig); } else { + if ( c3y == u3A->fak ) { + c3_c* who_c = u3r_string(u3dc("scot", 'p', u3k(u3A->own))); + fprintf(stderr, "fake: %s\r\n", who_c); + + // XX use clan:title + if ( 4 == strlen(who_c) ) { + u3_Host.ops_u.imp_c = who_c; + } else { + free(who_c); + } + + // XX make conditional + u3_Host.ops_u.net = c3n; + } _sist_rest(); } } From 204cf9be09f78784e0bfa4cee2747022181173dd Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 9 Oct 2018 13:35:25 -0400 Subject: [PATCH 15/64] restores u3A->fak on full event replay --- vere/sist.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/vere/sist.c b/vere/sist.c index 5fe7df0e3..3090f836f 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -261,9 +261,10 @@ _sist_sing(u3_noun ovo) u3_noun fex = u3h(vir); u3_noun fav = u3t(fex); - // XX is this now just to support ctrl-z during first boot? if ( c3__init == u3h(fav) ) { u3A->own = u3k(u3t(fav)); + // note: c3__boot == u3h(u3t(ovo)) + u3A->fak = ( c3__fake == u3h(u3t(u3t(ovo))) ) ? c3y : c3n; } vir = u3t(vir); @@ -1064,7 +1065,7 @@ _sist_rest() } u3z(rou); } - uL(fprintf(stderr, "\n---------------- playback complete----------------\n")); + uL(fprintf(stderr, "\n---------------- playback complete----------------\r\n")); #if 0 // If you see this error, your record is totally fscking broken! @@ -1371,6 +1372,8 @@ u3_sist_boot(void) _sist_make(pig); } else { + _sist_rest(); + if ( c3y == u3A->fak ) { c3_c* who_c = u3r_string(u3dc("scot", 'p', u3k(u3A->own))); fprintf(stderr, "fake: %s\r\n", who_c); @@ -1385,6 +1388,5 @@ u3_sist_boot(void) // XX make conditional u3_Host.ops_u.net = c3n; } - _sist_rest(); } } From 82c89c1696a6a049a3c180c1dd16b89f5a236a90 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 16:25:04 -0400 Subject: [PATCH 16/64] 1. duplicates hint (%10) and wish (%11) at %13 and %14 (nock 4K) --- jets/f/ut_mint.c | 16 ++++++++-------- jets/f/ut_mull.c | 10 +++++----- noun/jets.c | 4 ++-- noun/nock.c | 15 +++++++++++++++ 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/jets/f/ut_mint.c b/jets/f/ut_mint.c index 7dd189300..5e4f280ca 100644 --- a/jets/f/ut_mint.c +++ b/jets/f/ut_mint.c @@ -148,16 +148,16 @@ } static u3_noun - _mint_coke(u3_noun nug) + _mint_cove(u3_noun nug) { if ( 0 == u3h(nug) ) { return u3k(u3t(nug)); } - else if ( 10 == u3h(nug) ) { - return _mint_coke(u3t(u3t(nug))); + else if ( (10 == u3h(nug)) || (13 == u3h(nug)) ) { + return _mint_cove(u3t(u3t(nug))); } else { - return u3m_error("mint-coke"); + return u3m_error("mint-cove"); } } @@ -370,7 +370,7 @@ u3_noun wam = u3qfu_play(van, sut, p_gen); u3_noun dok = u3nc(c3__wing, u3k(q_gen)); u3_noun vol = _mint_corn(van, sut, dok); - u3_noun axe = _mint_coke(vol); + u3_noun axe = _mint_cove(vol); ret = u3nc(_mint_nice(van, gol, _mint_bean()), u3qfu_fish(van, wam, axe)); @@ -471,7 +471,7 @@ u3_noun viz = _mint_in(van, sut, c3__noun, q_gen); ret = u3nc(u3k(u3h(nef)), - u3nt(11, u3nc(1, u3nc(151, u3k(u3h(nef)))), u3k(u3t(viz)))); + u3nt(14, u3nc(1, u3nc(151, u3k(u3h(nef)))), u3k(u3t(viz)))); u3z(viz); u3z(nef); @@ -683,7 +683,7 @@ _mint_corn(van, sut, u3t(p_gen))); } ret = u3nc(u3k(u3h(hum)), - u3nt(10, bez, u3k(u3t(hum)))); + u3nt(13, bez, u3k(u3t(hum)))); u3z(hum); return ret; @@ -786,7 +786,7 @@ u3_noun hum = _mint_in(van, sut, gol, q_gen); u3_noun bez = u3nt(c3__spot, 1, u3k(p_gen)); - ret = u3nc(u3k(u3h(hum)), u3nt(10, bez, u3k(u3t(hum)))); + ret = u3nc(u3k(u3h(hum)), u3nt(13, bez, u3k(u3t(hum)))); u3z(hum); } u3t_drop(); diff --git a/jets/f/ut_mull.c b/jets/f/ut_mull.c index e07840743..1a00c6099 100644 --- a/jets/f/ut_mull.c +++ b/jets/f/ut_mull.c @@ -63,16 +63,16 @@ } } static u3_noun - _mull_coke(u3_noun nug) + _mull_cove(u3_noun nug) { if ( 0 == u3h(nug) ) { return u3k(u3t(nug)); } - else if ( 10 == u3h(nug) ) { - return _mull_coke(u3t(u3t(nug))); + else if ( (10 == u3h(nug)) || (13 == u3h(nug)) ) { + return _mull_cove(u3t(u3t(nug))); } else { - return u3m_error("mull-coke"); + return u3m_error("mull-cove"); } } @@ -109,7 +109,7 @@ u3_noun gen) { u3_noun fug = u3qfu_mint(van, sut, c3__noun, gen); - u3_noun axe = _mull_coke(u3t(fug)); + u3_noun axe = _mull_cove(u3t(fug)); u3z(fug); return axe; diff --git a/noun/jets.c b/noun/jets.c index f2c475960..3b27b4a1f 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -249,7 +249,7 @@ _cj_axis(u3_noun fol) { u3_noun p_fol, q_fol, r_fol; - while ( _(u3du(fol)) && (10 == u3h(fol)) ) + while ( _(u3du(fol)) && ((10 == u3h(fol)) || (13 == u3h(fol))) ) { fol = u3t(u3t(fol)); } if ( !_(u3r_trel(fol, &p_fol, &q_fol, &r_fol)) ) { @@ -436,7 +436,7 @@ _cj_je_fsck(u3_noun clu) if ( 0 == (nam_c = _cj_chum(p_clu)) ) { u3z(clu); return u3_none; } - while ( _(u3du(q_clu)) && (10 == u3h(q_clu)) ) { + while ( _(u3du(q_clu)) && ((10 == u3h(q_clu)) || (13 == u3h(q_clu))) ) { q_clu = u3t(u3t(q_clu)); } if ( !_(u3du(q_clu)) ) { diff --git a/noun/nock.c b/noun/nock.c index c784d87ab..a2d77fde1 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1289,6 +1289,21 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) ++tot_w; _n_emit(ops, (c3y == los_o) ? WILS : WISH); break; + // temporary home for hint + case 13: + u3x_cell(arg, &hed, &tel); + tot_w += _n_bint(ops, hed, tel, los_o, tel_o); + break; + + // temporary home for wish + case 14: + u3x_cell(arg, &hed, &tel); + tot_w += _n_comp(ops, hed, c3n, c3n); + ++tot_w; _n_emit(ops, SWAP); + tot_w += _n_comp(ops, tel, c3n, c3n); + ++tot_w; _n_emit(ops, (c3y == los_o) ? WILS : WISH); + break; + default: u3m_bail(c3__exit); return 0; From f64b5c8f801d4ef64c1c9e0a2e4ceefe159bf9e7 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 18:15:37 -0400 Subject: [PATCH 17/64] 2. removes %10 and %11 (nock 4K) --- jets/f/ut_mint.c | 2 +- jets/f/ut_mull.c | 2 +- noun/jets.c | 4 ++-- noun/nock.c | 13 ------------- 4 files changed, 4 insertions(+), 17 deletions(-) diff --git a/jets/f/ut_mint.c b/jets/f/ut_mint.c index 5e4f280ca..a88d32557 100644 --- a/jets/f/ut_mint.c +++ b/jets/f/ut_mint.c @@ -153,7 +153,7 @@ if ( 0 == u3h(nug) ) { return u3k(u3t(nug)); } - else if ( (10 == u3h(nug)) || (13 == u3h(nug)) ) { + else if ( (13 == u3h(nug)) ) { return _mint_cove(u3t(u3t(nug))); } else { diff --git a/jets/f/ut_mull.c b/jets/f/ut_mull.c index 1a00c6099..4474f592c 100644 --- a/jets/f/ut_mull.c +++ b/jets/f/ut_mull.c @@ -68,7 +68,7 @@ if ( 0 == u3h(nug) ) { return u3k(u3t(nug)); } - else if ( (10 == u3h(nug)) || (13 == u3h(nug)) ) { + else if ( (13 == u3h(nug)) ) { return _mull_cove(u3t(u3t(nug))); } else { diff --git a/noun/jets.c b/noun/jets.c index 3b27b4a1f..9cd1ebebc 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -249,7 +249,7 @@ _cj_axis(u3_noun fol) { u3_noun p_fol, q_fol, r_fol; - while ( _(u3du(fol)) && ((10 == u3h(fol)) || (13 == u3h(fol))) ) + while ( _(u3du(fol)) && ((13 == u3h(fol))) ) { fol = u3t(u3t(fol)); } if ( !_(u3r_trel(fol, &p_fol, &q_fol, &r_fol)) ) { @@ -436,7 +436,7 @@ _cj_je_fsck(u3_noun clu) if ( 0 == (nam_c = _cj_chum(p_clu)) ) { u3z(clu); return u3_none; } - while ( _(u3du(q_clu)) && ((10 == u3h(q_clu)) || (13 == u3h(q_clu))) ) { + while ( _(u3du(q_clu)) && ((13 == u3h(q_clu))) ) { q_clu = u3t(u3t(q_clu)); } if ( !_(u3du(q_clu)) ) { diff --git a/noun/nock.c b/noun/nock.c index a2d77fde1..73e6b1743 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1276,19 +1276,6 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) } break; - case 10: - u3x_cell(arg, &hed, &tel); - tot_w += _n_bint(ops, hed, tel, los_o, tel_o); - break; - - case 11: - u3x_cell(arg, &hed, &tel); - tot_w += _n_comp(ops, hed, c3n, c3n); - ++tot_w; _n_emit(ops, SWAP); - tot_w += _n_comp(ops, tel, c3n, c3n); - ++tot_w; _n_emit(ops, (c3y == los_o) ? WILS : WISH); - break; - // temporary home for hint case 13: u3x_cell(arg, &hed, &tel); From 4d6950d68a06f7d8c32eebaa51bbb931c85844f4 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 18:40:13 -0400 Subject: [PATCH 18/64] 3. implements hint at %11 and wish at %12 (nock 4K) --- jets/f/ut_mint.c | 2 +- jets/f/ut_mull.c | 2 +- noun/jets.c | 4 ++-- noun/nock.c | 13 +++++++++++++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/jets/f/ut_mint.c b/jets/f/ut_mint.c index a88d32557..f63b67eda 100644 --- a/jets/f/ut_mint.c +++ b/jets/f/ut_mint.c @@ -153,7 +153,7 @@ if ( 0 == u3h(nug) ) { return u3k(u3t(nug)); } - else if ( (13 == u3h(nug)) ) { + else if ( (11 == u3h(nug)) || (13 == u3h(nug)) ) { return _mint_cove(u3t(u3t(nug))); } else { diff --git a/jets/f/ut_mull.c b/jets/f/ut_mull.c index 4474f592c..c22d91cf7 100644 --- a/jets/f/ut_mull.c +++ b/jets/f/ut_mull.c @@ -68,7 +68,7 @@ if ( 0 == u3h(nug) ) { return u3k(u3t(nug)); } - else if ( (13 == u3h(nug)) ) { + else if ( (11 == u3h(nug)) || (13 == u3h(nug)) ) { return _mull_cove(u3t(u3t(nug))); } else { diff --git a/noun/jets.c b/noun/jets.c index 9cd1ebebc..11df57d4b 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -249,7 +249,7 @@ _cj_axis(u3_noun fol) { u3_noun p_fol, q_fol, r_fol; - while ( _(u3du(fol)) && ((13 == u3h(fol))) ) + while ( _(u3du(fol)) && ((11 == u3h(fol)) || (13 == u3h(fol))) ) { fol = u3t(u3t(fol)); } if ( !_(u3r_trel(fol, &p_fol, &q_fol, &r_fol)) ) { @@ -436,7 +436,7 @@ _cj_je_fsck(u3_noun clu) if ( 0 == (nam_c = _cj_chum(p_clu)) ) { u3z(clu); return u3_none; } - while ( _(u3du(q_clu)) && ((13 == u3h(q_clu))) ) { + while ( _(u3du(q_clu)) && ((11 == u3h(q_clu)) || (13 == u3h(q_clu))) ) { q_clu = u3t(u3t(q_clu)); } if ( !_(u3du(q_clu)) ) { diff --git a/noun/nock.c b/noun/nock.c index 73e6b1743..23be93f0b 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1276,6 +1276,19 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) } break; + case 11: + u3x_cell(arg, &hed, &tel); + tot_w += _n_bint(ops, hed, tel, los_o, tel_o); + break; + + case 12: + u3x_cell(arg, &hed, &tel); + tot_w += _n_comp(ops, hed, c3n, c3n); + ++tot_w; _n_emit(ops, SWAP); + tot_w += _n_comp(ops, tel, c3n, c3n); + ++tot_w; _n_emit(ops, (c3y == los_o) ? WILS : WISH); + break; + // temporary home for hint case 13: u3x_cell(arg, &hed, &tel); From c3ca5c24b6b346b0d00695217c16f4d224e17653 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 18:44:17 -0400 Subject: [PATCH 19/64] 4. emits %11 and %12 (nock 4K) --- jets/f/ut_mint.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jets/f/ut_mint.c b/jets/f/ut_mint.c index f63b67eda..0d0f54e39 100644 --- a/jets/f/ut_mint.c +++ b/jets/f/ut_mint.c @@ -471,7 +471,7 @@ u3_noun viz = _mint_in(van, sut, c3__noun, q_gen); ret = u3nc(u3k(u3h(nef)), - u3nt(14, u3nc(1, u3nc(151, u3k(u3h(nef)))), u3k(u3t(viz)))); + u3nt(12, u3nc(1, u3nc(151, u3k(u3h(nef)))), u3k(u3t(viz)))); u3z(viz); u3z(nef); @@ -683,7 +683,7 @@ _mint_corn(van, sut, u3t(p_gen))); } ret = u3nc(u3k(u3h(hum)), - u3nt(13, bez, u3k(u3t(hum)))); + u3nt(11, bez, u3k(u3t(hum)))); u3z(hum); return ret; @@ -786,7 +786,7 @@ u3_noun hum = _mint_in(van, sut, gol, q_gen); u3_noun bez = u3nt(c3__spot, 1, u3k(p_gen)); - ret = u3nc(u3k(u3h(hum)), u3nt(13, bez, u3k(u3t(hum)))); + ret = u3nc(u3k(u3h(hum)), u3nt(11, bez, u3k(u3t(hum)))); u3z(hum); } u3t_drop(); From 8f42a29933cae14a0c0f3a039bf996faf9cf6588 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 19:15:35 -0400 Subject: [PATCH 20/64] 5. removes %13 and %14 (nock 4K) --- jets/f/ut_mint.c | 2 +- jets/f/ut_mull.c | 2 +- noun/jets.c | 4 ++-- noun/nock.c | 15 --------------- 4 files changed, 4 insertions(+), 19 deletions(-) diff --git a/jets/f/ut_mint.c b/jets/f/ut_mint.c index 0d0f54e39..117c9c0d1 100644 --- a/jets/f/ut_mint.c +++ b/jets/f/ut_mint.c @@ -153,7 +153,7 @@ if ( 0 == u3h(nug) ) { return u3k(u3t(nug)); } - else if ( (11 == u3h(nug)) || (13 == u3h(nug)) ) { + else if ( 11 == u3h(nug) ) { return _mint_cove(u3t(u3t(nug))); } else { diff --git a/jets/f/ut_mull.c b/jets/f/ut_mull.c index c22d91cf7..760ebbf1f 100644 --- a/jets/f/ut_mull.c +++ b/jets/f/ut_mull.c @@ -68,7 +68,7 @@ if ( 0 == u3h(nug) ) { return u3k(u3t(nug)); } - else if ( (11 == u3h(nug)) || (13 == u3h(nug)) ) { + else if ( 11 == u3h(nug) ) { return _mull_cove(u3t(u3t(nug))); } else { diff --git a/noun/jets.c b/noun/jets.c index 11df57d4b..40405b543 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -249,7 +249,7 @@ _cj_axis(u3_noun fol) { u3_noun p_fol, q_fol, r_fol; - while ( _(u3du(fol)) && ((11 == u3h(fol)) || (13 == u3h(fol))) ) + while ( _(u3du(fol)) && (11 == u3h(fol)) ) { fol = u3t(u3t(fol)); } if ( !_(u3r_trel(fol, &p_fol, &q_fol, &r_fol)) ) { @@ -436,7 +436,7 @@ _cj_je_fsck(u3_noun clu) if ( 0 == (nam_c = _cj_chum(p_clu)) ) { u3z(clu); return u3_none; } - while ( _(u3du(q_clu)) && ((11 == u3h(q_clu)) || (13 == u3h(q_clu))) ) { + while ( _(u3du(q_clu)) && (11 == u3h(q_clu)) ) { q_clu = u3t(u3t(q_clu)); } if ( !_(u3du(q_clu)) ) { diff --git a/noun/nock.c b/noun/nock.c index 23be93f0b..459f6cb2e 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1289,21 +1289,6 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) ++tot_w; _n_emit(ops, (c3y == los_o) ? WILS : WISH); break; - // temporary home for hint - case 13: - u3x_cell(arg, &hed, &tel); - tot_w += _n_bint(ops, hed, tel, los_o, tel_o); - break; - - // temporary home for wish - case 14: - u3x_cell(arg, &hed, &tel); - tot_w += _n_comp(ops, hed, c3n, c3n); - ++tot_w; _n_emit(ops, SWAP); - tot_w += _n_comp(ops, tel, c3n, c3n); - ++tot_w; _n_emit(ops, (c3y == los_o) ? WILS : WISH); - break; - default: u3m_bail(c3__exit); return 0; From 147941ba0774eb0c09ee7a5b79cbc2a1b0bbc7ea Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 19:51:37 -0400 Subject: [PATCH 21/64] 6. implements edit at %10 (nock 4K) --- noun/nock.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index b1af247b7..69a4661d1 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -526,7 +526,7 @@ _n_nock_on(u3_noun bus, u3_noun fol) #define SLIB 70 #define SLIS 71 #define SAVE 72 -// nock 12 +// nock 10 #define MUTH 73 #define KUTH 74 #define MUTT 75 @@ -1302,20 +1302,7 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) } break; - case 11: - u3x_cell(arg, &hed, &tel); - tot_w += _n_bint(ops, hed, tel, los_o, tel_o); - break; - - case 12: - u3x_cell(arg, &hed, &tel); - tot_w += _n_comp(ops, hed, c3n, c3n); - ++tot_w; _n_emit(ops, SWAP); - tot_w += _n_comp(ops, tel, c3n, c3n); - ++tot_w; _n_emit(ops, (c3y == los_o) ? WILS : WISH); - break; - - case 12: { + case 10: { u3_noun axe, nef; u3x_cell(arg, &hed, &tel); u3x_cell(hed, &axe, &nef); @@ -1347,6 +1334,19 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) break; } + case 11: + u3x_cell(arg, &hed, &tel); + tot_w += _n_bint(ops, hed, tel, los_o, tel_o); + break; + + case 12: + u3x_cell(arg, &hed, &tel); + tot_w += _n_comp(ops, hed, c3n, c3n); + ++tot_w; _n_emit(ops, SWAP); + tot_w += _n_comp(ops, tel, c3n, c3n); + ++tot_w; _n_emit(ops, (c3y == los_o) ? WILS : WISH); + break; + default: u3m_bail(c3__exit); return 0; From 7507de1e6c2eec01a8d2fb41e8895864cbc26ede Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 20:20:05 -0400 Subject: [PATCH 22/64] 7. updates %5 to require two subformulas (nock 4K) --- noun/nock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index 69a4661d1..adc1cf015 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1211,8 +1211,8 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) u3x_cell(arg, &hed, &tel); if ( c3n == u3du(hed) ) { - tot_w += _n_comp(ops, arg, los_o, c3n); - ++tot_w; _n_emit(ops, SAMC); + u3m_bail(c3__exit); + return 0; } else { c3_t hec_t, tec_t; From 898beb29310508cd8a193ffe14483ce0f8b0113f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 20:25:23 -0400 Subject: [PATCH 23/64] 8. updates nock 4K spec --- Spec/nock/4.txt | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Spec/nock/4.txt b/Spec/nock/4.txt index b6dafee9d..3457d6bf6 100644 --- a/Spec/nock/4.txt +++ b/Spec/nock/4.txt @@ -1,5 +1,7 @@ A noun is an atom or a cell. An atom is a natural number. A cell is an ordered pair of nouns. +Reduce by the first matching pattern; variables match any noun. + nock(a) *a [a b c] [a [b c]] @@ -9,7 +11,6 @@ nock(a) *a +a 1 + a =[a a] 0 =[a b] 1 -=a =a /[1 a] a /[2 a b] a @@ -30,15 +31,15 @@ nock(a) *a *[a 2 b c] *[*[a b] *[a c]] *[a 3 b] ?*[a b] *[a 4 b] +*[a b] -*[a 5 b] =*[a b] +*[a 5 b c] =[*[a b] *[a c]] -*[a 6 b c d] *[a 2 [0 1] 2 [1 c d] [1 0] 2 [1 2 3] [1 0] 4 4 b] -*[a 7 b c] *[a 2 b 1 c] -*[a 8 b c] *[a 7 [[7 [0 1] b] 0 1] c] -*[a 9 b c] *[a 7 c 2 [0 1] 0 b] -*[a 10 [b c] d] *[a 8 c 7 [0 3] d] -*[a 10 b c] *[a c] -*[a 12 [b c] d] #[b *[a c] *[a d]] +*[a 6 b c d] *[a *[[c d] 0 *[[2 3] 0 *[a 4 4 b]]]] +*[a 7 b c] *[*[a b] c] +*[a 8 b c] *[[*[a b] a] c] +*[a 9 b c] *[*[a c] 2 [0 1] 0 b] +*[a 10 [b c] d] #[b *[a c] *[a d]] + +*[a 11 [b c] d] *[[*[a c] *[a d]] 0 3] +*[a 11 b c] *[a c] *a *a - From 25bb368243b69030e86bdffe6ca8b149a4bdcb2c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 16 Oct 2018 17:26:41 -0400 Subject: [PATCH 24/64] accepts all (identical) %init cards --- vere/reck.c | 8 ++++---- vere/sist.c | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/vere/reck.c b/vere/reck.c index 6d3379bec..3a44f2970 100644 --- a/vere/reck.c +++ b/vere/reck.c @@ -100,8 +100,8 @@ _reck_kick_term(u3_noun pox, c3_l tid_l, u3_noun fav) case c3__init: p_fav = u3t(fav); { - c3_assert( u3_none == u3A->own ); - u3A->own = u3k(p_fav); + uL(fprintf(uH, "kick: init: term\n")); + c3_assert( c3y == u3r_sing(u3A->own, p_fav) ); u3z(pox); u3z(fav); return c3y; } break; @@ -225,7 +225,7 @@ _reck_kick_ames(u3_noun pox, u3_noun fav) case c3__init: p_fav = u3t(fav); { uL(fprintf(uH, "kick: init: ames\n")); - c3_assert(0); + c3_assert( c3y == u3r_sing(u3A->own, p_fav) ); u3z(pox); u3z(fav); return c3y; } break; @@ -315,7 +315,7 @@ _reck_kick_spec(u3_noun pox, u3_noun fav) case c3__init: p_fav = u3t(fav); { uL(fprintf(uH, "kick: init: spec\n")); - c3_assert(0); + c3_assert( c3y == u3r_sing(u3A->own, p_fav) ); u3z(pox); u3z(fav); return c3y; } break; diff --git a/vere/sist.c b/vere/sist.c index 3090f836f..2804e8e34 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1346,7 +1346,7 @@ void u3_sist_boot(void) { if ( c3y == u3_Host.ops_u.nuu ) { - u3_noun pig; + u3_noun pig, who; if ( 0 != u3_Host.ops_u.fak_c ) { u3_noun whu = u3dc("slaw", 'p', u3i_string(u3_Host.ops_u.fak_c)); @@ -1359,16 +1359,17 @@ u3_sist_boot(void) fprintf(stderr, "fake: %s\r\n", u3_Host.ops_u.fak_c); u3A->fak = c3y; - pig = u3nc(c3__fake, u3k(u3t(whu))); + who = u3k(u3t(whu)); + pig = u3nc(c3__fake, who); u3z(whu); } else { u3A->fak = c3n; pig = _sist_dawn(); + who = u3k(u3h(u3h(u3t(pig)))); } - // will be set by %init card in reck.c - u3A->own = u3_none; + u3A->own = who; _sist_make(pig); } else { From 5b33f63f6a82dd6bfcfd6c84efc54672d0a52afa Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 16 Oct 2018 17:38:27 -0400 Subject: [PATCH 25/64] restores %dawn galaxy table --- vere/sist.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/vere/sist.c b/vere/sist.c index 2804e8e34..0e1a09c3b 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1323,11 +1323,8 @@ _sist_dawn(void) u3_lo_bail(); } - // XX slow, temporarily disabled - // XX maybe print messages, spin a cursor, etc. - // u3_noun raz = _sist_eth_rpc(url_c, u3v_wish("czar:give:dawn")); - // u3_noun zar = u3do("czar:take:dawn", raz); - u3_noun zar = u3_nul; + u3_noun raz = _sist_eth_rpc(url_c, u3v_wish("czar:give:dawn")); + u3_noun zar = u3do("czar:take:dawn", raz); u3_noun fut = _sist_eth_rpc(url_c, u3v_wish("turf:give:dawn")); u3_noun tuf = u3do("turf:take:dawn", fut); From fc6530fa30adbbe425a72cb048062d646fcb300e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 16 Oct 2018 18:02:55 -0400 Subject: [PATCH 26/64] allows -N without -F (temporary, revisit) --- vere/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vere/main.c b/vere/main.c index 13f164229..eced43364 100644 --- a/vere/main.c +++ b/vere/main.c @@ -218,8 +218,8 @@ _main_getopt(c3_i argc, c3_c** argv) // XX revisit if ( (0 == u3_Host.ops_u.fak_c) && (c3y == u3_Host.ops_u.net) ) { - fprintf(stderr, "-N only makes sense with -F\n"); - return c3n; + // fprintf(stderr, "-N only makes sense with -F\n"); + u3_Host.ops_u.net = c3n; } else if ( (0 == u3_Host.ops_u.fak_c) && (c3n == u3_Host.ops_u.net) ) { u3_Host.ops_u.net = c3y; /* remote networking is always on in real mode. */ } From 6e77aa110aa3776fed386f5bd8cf3a17d5c7e1bc Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 4 Oct 2018 02:43:08 -0400 Subject: [PATCH 27/64] starts ames on %turf card, removes -H uses ames domain for tcp proxy, and moves czar arvo sync after ames initialization --- include/c/motes.h | 1 + include/vere/vere.h | 8 ++- vere/ames.c | 148 +++++++++++++++++++++++++++++++++++++------- vere/http.c | 18 ++++-- vere/loop.c | 5 ++ vere/main.c | 11 +--- vere/reck.c | 5 ++ vere/sist.c | 22 ------- 8 files changed, 159 insertions(+), 59 deletions(-) diff --git a/include/c/motes.h b/include/c/motes.h index 7914354ca..8cb2dbbc7 100644 --- a/include/c/motes.h +++ b/include/c/motes.h @@ -1141,6 +1141,7 @@ # define c3__tung c3_s4('t','u','n','g') # define c3__tupl c3_s4('t','u','p','l') # define c3__turd c3_s4('t','u','r','d') +# define c3__turf c3_s4('t','u','r','f') # define c3__turn c3_s4('t','u','r','n') # define c3__twig c3_s4('t','w','i','g') # define c3__twix c3_s4('t','w','i','x') diff --git a/include/vere/vere.h b/include/vere/vere.h index ced7474fd..2183d483e 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -254,9 +254,11 @@ uv_handle_t had_u; }; uv_timer_t tim_u; // network timer + c3_o liv; // listener on c3_o alm; // alarm on c3_w law_w; // last wakeup, unix time c3_s por_s; // public IPv4 port + c3_c* dns_c; // domain XX multiple/fallback c3_w imp_w[256]; // imperial IPs time_t imp_t[256]; // imperial IP timestamps } u3_ames; @@ -578,7 +580,6 @@ */ typedef struct _u3_opts { c3_c* arv_c; // -A, initial sync from - c3_c* dns_c; // -H, ames bootstrap domain c3_c* gen_c; // -G, czar generator c3_c* imp_c; // -I, czar name c3_c* nam_c; // -n, unix hostname @@ -938,6 +939,11 @@ u3_ames_ef_send(u3_noun lan, u3_noun pac); + /* u3_ames_ef_turf(): initialize ames I/O on domain(s). + */ + void + u3_ames_ef_turf(u3_noun tuf); + /* u3_ames_io_init(): initialize ames I/O. */ void diff --git a/vere/ames.c b/vere/ames.c index 3a9fc0f16..b04d64ecd 100644 --- a/vere/ames.c +++ b/vere/ames.c @@ -197,6 +197,8 @@ _ames_czar(u3_pact* pac_u, c3_c* bos_c) return; } + c3_assert( 0 != bos_c ); + time_t now = time(0); // backoff @@ -269,6 +271,8 @@ _ames_lane_ip(u3_noun lan, c3_s* por_s, c3_w* pip_w) return c3n; } +/* u3_ames_ef_bake(): notify %ames that we're live. +*/ void u3_ames_ef_bake(void) { @@ -303,7 +307,7 @@ u3_ames_ef_send(u3_noun lan, u3_noun pac) if ( (0 == (pac_u->pip_w >> 16)) && (1 == (pac_u->pip_w >> 8)) ) { pac_u->imp_y = (pac_u->pip_w & 0xff); - _ames_czar(pac_u, u3_Host.ops_u.dns_c); + _ames_czar(pac_u, u3_Host.sam_u.dns_c); } else if ( (c3y == u3_Host.ops_u.net) || (0x7f000001 == pac_u->pip_w) ) { _ames_send(pac_u); @@ -326,15 +330,22 @@ static void _ames_time_cb(uv_timer_t* tim_uo) { u3_ames* sam_u = &u3_Host.sam_u; - u3_lo_open(); - sam_u->law_w = time(0); - { - u3v_plan - (u3nt(u3_blip, c3__ames, u3_nul), - u3nc(c3__wake, u3_nul)); + // defer until started via u3_ames_ef_turf() + if ( c3n == sam_u->liv ) { + uv_timer_start(&sam_u->tim_u, _ames_time_cb, 1000, 0); + } + else { + u3_lo_open(); + + sam_u->law_w = time(0); + { + u3v_plan + (u3nt(u3_blip, c3__ames, u3_nul), + u3nc(c3__wake, u3_nul)); + } + u3_lo_shut(c3n); } - u3_lo_shut(c3n); } /* _ames_recv_cb(): receive callback. @@ -376,15 +387,15 @@ _ames_recv_cb(uv_udp_t* wax_u, } } -/* u3_ames_io_init(): initialize ames I/O. +/* _ames_io_start(): initialize ames I/O. */ -void -u3_ames_io_init() +static void +_ames_io_start() { u3_ames* sam_u = &u3_Host.sam_u; - c3_s por_s; + c3_s por_s = u3_Host.ops_u.por_s; - por_s = u3_Host.ops_u.por_s; + // XX use clan:title u3A->own if ( 0 != u3_Host.ops_u.imp_c ) { u3_noun imp = u3i_string(u3_Host.ops_u.imp_c); u3_noun num = u3dc("slaw", 'p', imp); @@ -442,10 +453,103 @@ u3_ames_io_init() sam_u->por_s = ntohs(add_u.sin_port); } - // Timer too. - { - uv_timer_init(u3L, &sam_u->tim_u); + + // uL(fprintf(uH, "ames: on localhost, UDP %d.\n", sam_u->por_s)); + uv_udp_recv_start(&sam_u->wax_u, _ames_alloc, _ames_recv_cb); + + sam_u->liv = c3y; +} + +/* _cttp_mcut_char(): measure/cut character. +*/ +static c3_w +_cttp_mcut_char(c3_c* buf_c, c3_w len_w, c3_c chr_c) +{ + if ( buf_c ) { + buf_c[len_w] = chr_c; } + return len_w + 1; +} + +/* _cttp_mcut_cord(): measure/cut cord. +*/ +static c3_w +_cttp_mcut_cord(c3_c* buf_c, c3_w len_w, u3_noun san) +{ + c3_w ten_w = u3r_met(3, san); + + if ( buf_c ) { + u3r_bytes(0, ten_w, (c3_y *)(buf_c + len_w), san); + } + u3z(san); + return (len_w + ten_w); +} + +/* _cttp_mcut_path(): measure/cut cord list. +*/ +static c3_w +_cttp_mcut_path(c3_c* buf_c, c3_w len_w, c3_c sep_c, u3_noun pax) +{ + u3_noun axp = pax; + + while ( u3_nul != axp ) { + u3_noun h_axp = u3h(axp); + + len_w = _cttp_mcut_cord(buf_c, len_w, u3k(h_axp)); + axp = u3t(axp); + + if ( u3_nul != axp ) { + len_w = _cttp_mcut_char(buf_c, len_w, sep_c); + } + } + u3z(pax); + return len_w; +} + +/* _cttp_mcut_host(): measure/cut host. +*/ +static c3_w +_cttp_mcut_host(c3_c* buf_c, c3_w len_w, u3_noun hot) +{ + len_w = _cttp_mcut_path(buf_c, len_w, '.', u3kb_flop(u3k(hot))); + u3z(hot); + return len_w; +} + +/* u3_ames_ef_turf(): initialize ames I/O on domain(s). +*/ +void +u3_ames_ef_turf(u3_noun tuf) +{ + if ( u3_nul != tuf ) { + // XX save all for fallback, not just first + u3_noun hot = u3k(u3h(tuf)); + c3_w len_w = _cttp_mcut_host(0, 0, u3k(hot)); + + u3_Host.sam_u.dns_c = c3_malloc(1 + len_w); + _cttp_mcut_host(u3_Host.sam_u.dns_c, 0, hot); + u3_Host.sam_u.dns_c[len_w] = 0; + + u3z(tuf); + } + else if ( c3n == u3A->fak ) { + // XX assert? + uL(fprintf(uH, "ames: turf: no domains\n")); + } + + if ( c3n == u3_Host.sam_u.liv ) { + _ames_io_start(); + } +} + +/* u3_ames_io_init(): initialize ames I/O. +*/ +void +u3_ames_io_init() +{ + u3_ames* sam_u = &u3_Host.sam_u; + sam_u->liv = c3n; + uv_timer_init(u3L, &sam_u->tim_u); } /* u3_ames_io_talk(): start receiving ames traffic. @@ -453,10 +557,6 @@ u3_ames_io_init() void u3_ames_io_talk() { - u3_ames* sam_u = &u3_Host.sam_u; - - uL(fprintf(uH, "ames: on localhost, UDP %d.\n", sam_u->por_s)); - uv_udp_recv_start(&sam_u->wax_u, _ames_alloc, _ames_recv_cb); } /* u3_ames_io_exit(): terminate ames I/O. @@ -466,8 +566,12 @@ u3_ames_io_exit() { u3_ames* sam_u = &u3_Host.sam_u; - // XX close wax_u instead - uv_close(&sam_u->had_u, 0); + uv_close((uv_handle_t*)&sam_u->tim_u, 0); + + if ( c3y == sam_u->liv ) { + // XX remove had_u/wax_u union, cast and close wax_u + uv_close(&sam_u->had_u, 0); + } } /* u3_ames_io_poll(): update ames IO state. diff --git a/vere/http.c b/vere/http.c index ea2b006da..14d5fd4af 100644 --- a/vere/http.c +++ b/vere/http.c @@ -1231,6 +1231,7 @@ _http_release_ports_file(c3_c *pax_c) free(paf_c); } + /* _http_czar_host(): galaxy hostname as (unit host:eyre) */ static u3_noun @@ -1238,6 +1239,8 @@ _http_czar_host(void) { u3_noun dom = u3_nul; + // XX revisit +#if 0 if ( (0 == u3_Host.ops_u.imp_c) || (c3n == u3_Host.ops_u.net) ) { return dom; } @@ -1272,6 +1275,7 @@ _http_czar_host(void) } } } +#endif if ( u3_nul == dom ) { return dom; @@ -2424,12 +2428,15 @@ _proxy_ward_resolve(u3_warc* cli_u) hin_u.ai_protocol = IPPROTO_TCP; if ( 0 == cli_u->hot_c ) { + // XX revisit + c3_assert( 0 != u3_Host.sam_u.dns_c ); + u3_noun sip = u3dc("scot", 'p', u3k(cli_u->sip)); c3_c* sip_c = u3r_string(sip); - c3_w len_w = 1 + strlen(sip_c) + strlen(u3_Host.ops_u.dns_c); + c3_w len_w = 1 + strlen(sip_c) + strlen(u3_Host.sam_u.dns_c); cli_u->hot_c = c3_malloc(len_w); // incremented to skip '~' - snprintf(cli_u->hot_c, len_w, "%s.%s", sip_c + 1, u3_Host.ops_u.dns_c); + snprintf(cli_u->hot_c, len_w, "%s.%s", sip_c + 1, u3_Host.sam_u.dns_c); free(sip_c); u3z(sip); @@ -2541,11 +2548,14 @@ _proxy_parse_ship(c3_c* hot_c) return sip; } + // XX revisit + c3_assert( 0 != u3_Host.sam_u.dns_c ); + c3_w dif_w = dom_c - hot_c; - c3_w dns_w = strlen(u3_Host.ops_u.dns_c); + c3_w dns_w = strlen(u3_Host.sam_u.dns_c); if ( (dns_w != strlen(hot_c) - (dif_w + 1)) || - (0 != strncmp(dom_c + 1, u3_Host.ops_u.dns_c, dns_w)) ) { + (0 != strncmp(dom_c + 1, u3_Host.sam_u.dns_c, dns_w)) ) { return sip; } diff --git a/vere/loop.c b/vere/loop.c index d3362efb3..cac36d6ff 100644 --- a/vere/loop.c +++ b/vere/loop.c @@ -667,7 +667,12 @@ u3_lo_lead(void) // Further server configuration. // { + u3_ames_ef_bake(); u3_http_ef_bake(); + + if ( (c3y == u3_Host.ops_u.nuu) && (0 != u3_Host.ops_u.imp_c) ) { + u3_unix_ef_initial_into(); + } } _lo_talk(); diff --git a/vere/main.c b/vere/main.c index eced43364..0f60f735b 100644 --- a/vere/main.c +++ b/vere/main.c @@ -91,7 +91,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.veb = c3n; u3_Host.ops_u.kno_w = DefaultKernel; - while ( (ch_i=getopt(argc, argv,"G:B:K:A:H:I:w:u:f:F:k:l:n:p:r:NabcdgqsvxMPDXRS")) != -1 ) { + while ( (ch_i=getopt(argc, argv,"G:B:K:A:I:w:u:f:F:k:l:n:p:r:NabcdgqsvxMPDXRS")) != -1 ) { switch ( ch_i ) { case 'M': { u3_Host.ops_u.mem = c3y; @@ -109,10 +109,6 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.arv_c = strdup(optarg); break; } - case 'H': { - u3_Host.ops_u.dns_c = strdup(optarg); - break; - } // XX remove in deference to -K case 'I': { u3_Host.ops_u.imp_c = _main_presig(optarg); @@ -282,10 +278,6 @@ _main_getopt(c3_i argc, c3_c** argv) return c3n; } - if ( u3_Host.ops_u.dns_c == 0 ) { - u3_Host.ops_u.dns_c = "urbit.org"; - } - if ( u3_Host.ops_u.pil_c != 0 ) { struct stat s; if ( stat(u3_Host.ops_u.pil_c, &s) != 0 ) { @@ -358,7 +350,6 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-F ship Fake keys; also disables networking\n", "-f Fuzz testing\n", "-g Set GC flag\n", - "-H domain Set ames bootstrap domain (default urbit.org)\n", "-I galaxy Start as ~galaxy\n", "-k stage Start at Hoon kernel version stage\n", "-l port Initial peer port\n", diff --git a/vere/reck.c b/vere/reck.c index 3a44f2970..3515c3268 100644 --- a/vere/reck.c +++ b/vere/reck.c @@ -208,6 +208,11 @@ _reck_kick_newt(u3_noun pox, u3_noun fav) u3_ames_ef_send(lan, pac); u3z(pox); u3z(fav); return c3y; } break; + + case c3__turf: { + u3_ames_ef_turf(u3k(u3t(fav))); + u3z(pox); u3z(fav); return c3y; + } break; } u3z(pox); u3z(fav); return c3n; } diff --git a/vere/sist.c b/vere/sist.c index 0e1a09c3b..9986b45a2 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -277,21 +277,6 @@ _sist_sing(u3_noun ovo) } } - -/* _sist_home(): remains of "create ship directory" after refactor to u3m_boot(). -*/ -static void -_sist_home() -{ -#if 1 - // Copy zod files, if we're generating a carrier. - // - if ( u3_Host.ops_u.imp_c ) { - u3_unix_ef_initial_into(); - } -#endif -} - /* _sist_cask(): ask for a passcode. */ static u3_noun @@ -518,10 +503,6 @@ _sist_zest() c3_c ful_c[8193]; c3_l sal_l; - // Create the ship directory. - // - _sist_home(); - // Create the record file. { c3_i pig_i = O_CREAT | O_WRONLY | O_EXCL; @@ -602,9 +583,6 @@ _sist_zest() static void _sist_make(u3_noun fav) { - // Initialize ames - u3_ames_ef_bake(); - // Authenticate and initialize terminal. // u3_term_ef_bake(fav); From 5207c8321f8f8a1f9dbc7915416996f0f4fd1904 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 9 Oct 2018 23:44:00 -0400 Subject: [PATCH 28/64] use +clan:title to detect galaxy --- include/c/motes.h | 1 + vere/ames.c | 25 +++++++++++-------------- vere/loop.c | 10 ++++++++-- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/include/c/motes.h b/include/c/motes.h index 8cb2dbbc7..6d5dadf76 100644 --- a/include/c/motes.h +++ b/include/c/motes.h @@ -278,6 +278,7 @@ # define c3__ctl c3_s3('c','t','l') # define c3__cut c3_s3('c','u','t') # define c3__cyl c3_s3('c','y','l') +# define c3__czar c3_s4('c','z','a','r') # define c3__d c3_s1('d') # define c3__da c3_s2('d','a') # define c3__dago c3_s4('d','a','g','o') diff --git a/vere/ames.c b/vere/ames.c index b04d64ecd..913c85616 100644 --- a/vere/ames.c +++ b/vere/ames.c @@ -394,28 +394,24 @@ _ames_io_start() { u3_ames* sam_u = &u3_Host.sam_u; c3_s por_s = u3_Host.ops_u.por_s; + u3_noun rac = u3do("clan:title", u3k(u3A->own)); - // XX use clan:title u3A->own - if ( 0 != u3_Host.ops_u.imp_c ) { - u3_noun imp = u3i_string(u3_Host.ops_u.imp_c); - u3_noun num = u3dc("slaw", 'p', imp); - c3_y num_y; + if ( c3__czar == rac ) { + u3_noun imp = u3dc("scot", 'p', u3k(u3A->own)); + c3_c* imp_c = u3r_string(imp); + c3_y num_y = u3r_byte(0, u3A->own); - if ( c3n == u3du(num) ) { - uL(fprintf(uH, "malformed emperor: %s\n", u3_Host.ops_u.imp_c)); - exit(1); - } - num_y = u3r_byte(0, u3t(num)); por_s = _ames_czar_port(num_y); if ( c3y == u3_Host.ops_u.net ) { - uL(fprintf(uH, "ames: czar: %s on %d\n", u3_Host.ops_u.imp_c, por_s)); + uL(fprintf(uH, "ames: czar: %s on %d\n", imp_c, por_s)); } else { - uL(fprintf(uH, "ames: czar: %s on %d (localhost only)\n", - u3_Host.ops_u.imp_c, por_s)); + uL(fprintf(uH, "ames: czar: %s on %d (localhost only)\n", imp_c, por_s)); } - u3z(num); + + u3z(imp); + free(imp_c); } int ret; @@ -458,6 +454,7 @@ _ames_io_start() uv_udp_recv_start(&sam_u->wax_u, _ames_alloc, _ames_recv_cb); sam_u->liv = c3y; + u3z(rac); } /* _cttp_mcut_char(): measure/cut character. diff --git a/vere/loop.c b/vere/loop.c index cac36d6ff..ac830936e 100644 --- a/vere/loop.c +++ b/vere/loop.c @@ -670,8 +670,14 @@ u3_lo_lead(void) u3_ames_ef_bake(); u3_http_ef_bake(); - if ( (c3y == u3_Host.ops_u.nuu) && (0 != u3_Host.ops_u.imp_c) ) { - u3_unix_ef_initial_into(); + if ( c3y == u3_Host.ops_u.nuu ) { + u3_noun rac = u3do("clan:title", u3k(u3A->own)); + + if ( c3__czar == rac ) { + u3_unix_ef_initial_into(); + } + + u3z(rac); } } From f76f8b5363ed8417659cba3e64af6cf1cbc21a9e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 02:04:46 -0400 Subject: [PATCH 29/64] refactors u3_sist_boot and pre-boot validation --- vere/sist.c | 162 ++++++++++++++++++++++++++++------------------------ 1 file changed, 88 insertions(+), 74 deletions(-) diff --git a/vere/sist.c b/vere/sist.c index 9986b45a2..32d79be53 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -578,20 +578,6 @@ _sist_zest() u3_raft_work(); } -/* _sist_make(): boot from scratch. -*/ -static void -_sist_make(u3_noun fav) -{ - // Authenticate and initialize terminal. - // - u3_term_ef_bake(fav); - - // Create the ship directory. - // - _sist_zest(); -} - /* _sist_rest_nuu(): upgrade log from previous format. */ static void @@ -1258,60 +1244,79 @@ _sist_eth_rpc(c3_c* url_c, u3_noun oct) /* _sist_dawn(): produce %dawn boot card - validate keys and query contract */ static u3_noun -_sist_dawn(void) +_sist_dawn(u3_noun des) { - if ( 0 == u3_Host.ops_u.key_c ) { - // XX print nice error - u3_lo_bail(); + u3_noun who, sed, pon, zar, tuf; + + { + u3_noun eds = u3dc("slaw", c3__uw, u3k(des)); + + if ( u3_nul == eds ) { + // XX print nice error + u3_lo_bail(); + } + + // +seed:able:jael: private key file + sed = u3ke_cue(u3k(u3t(eds))); + // XX compare against ops_u.who_c + who = u3h(sed); + + u3z(des); u3z(eds); } - u3_noun eds = u3m_file(u3_Host.ops_u.key_c); - u3_noun des = u3dc("slaw", c3__uw, eds); - - if ( u3_nul == des ) { - // XX print nice error - u3_lo_bail(); - } - - // +seed:dawn: - // [who=ship lyf=life key=ring sig=(unit oath:pki:jael)] - u3_noun sed = u3ke_cue(u3t(des)); - u3_noun who = u3h(sed); - - // u3_noun lyf = u3h(u3t(sed)); - // u3_noun key = u3h(u3t(u3t(sed))); - // u3_noun sig = u3t(u3t(u3t(sed))); - // u3_noun rac = u3do("clan:title", u3k(who)); - // XX configure default globally, add cli arg to specify c3_c* url_c = "http://localhost:8545"; - u3_noun luh = _sist_eth_rpc(url_c, u3do("hull:give:dawn", u3k(who))); - u3_noun hul = u3dc("hull:take:dawn", u3k(who), luh); + // XX leaks nock + { + // +hull:constitution:ethe: on-chain state + u3_noun oct = u3do("hull:give:dawn", u3k(who)); + u3_noun luh = _sist_eth_rpc(url_c, u3k(oct)); + u3_noun hul = u3dc("hull:take:dawn", u3k(who), u3k(luh)); - // XX actually make request - // u3_noun liv = _sist_get_json(parent, /some/url) - u3_noun liv = u3_nul; + // +live:dawn: network state + // XX actually make request + // u3_noun liv = _sist_get_json(parent, /some/url) + u3_noun liv = u3_nul; - u3_noun sas = u3dt("veri:dawn", sed, hul, liv); + // XX revisit + // (each [seed (unit ship)] [rank @tas]) + u3_noun sas = u3dt("veri:dawn", u3k(sed), u3k(hul), u3k(liv)); - if ( c3n == u3h(sas) ) { - // XX deconstruct sas, print helpful error messages - u3m_p("pre-boot error", u3t(sas)); - u3_lo_bail(); + if ( c3n == u3h(sas) ) { + // XX deconstruct sas, print helpful error messages + u3m_p("pre-boot error", u3t(sas)); + u3_lo_bail(); + } + + // (unit ship): sponsor + // produced by +veri:dawn to avoid coupling to +hull structure + pon = u3k(u3t(u3t(sas))); + + u3z(oct); u3z(luh); u3z(hul); u3z(liv); u3z(sas); } - u3_noun raz = _sist_eth_rpc(url_c, u3v_wish("czar:give:dawn")); - u3_noun zar = u3do("czar:take:dawn", raz); + // XX leaks nock + { + // (map ship [=life =pass]): galaxy table + u3_noun oct = u3v_wish("czar:give:dawn"); + u3_noun raz = _sist_eth_rpc(url_c, u3k(oct)); + zar = u3do("czar:take:dawn", u3k(raz)); - u3_noun fut = _sist_eth_rpc(url_c, u3v_wish("turf:give:dawn")); - u3_noun tuf = u3do("turf:take:dawn", fut); + u3z(oct); u3z(raz); + } - // XX extract from sas - // XX or maybe pass entire hull? - u3_noun pon = u3_nul; + // XX leaks nock + { + // (list turf): ames domains + u3_noun oct = u3v_wish("turf:give:dawn"); + u3_noun fut = _sist_eth_rpc(url_c, u3k(oct)); + tuf = u3do("turf:take:dawn", u3k(fut)); - // [%dawn =seed:dawn spon=(unit ship) czar=(map ship [=life =pass]) turf=(list (pair @ud (list @ta)))] + u3z(oct); u3z(fut); + } + + // [%dawn seed sponsor galaxies domains] return u3nc(c3__dawn, u3nq(sed, pon, zar, tuf)); } @@ -1320,7 +1325,19 @@ _sist_dawn(void) void u3_sist_boot(void) { - if ( c3y == u3_Host.ops_u.nuu ) { + if ( c3n == u3_Host.ops_u.nuu ) { + _sist_rest(); + + if ( c3y == u3A->fak ) { + c3_c* who_c = u3r_string(u3dc("scot", 'p', u3k(u3A->own))); + fprintf(stderr, "fake: %s\r\n", who_c); + free(who_c); + + // XX make conditional + u3_Host.ops_u.net = c3n; + } + } + else { u3_noun pig, who; if ( 0 != u3_Host.ops_u.fak_c ) { @@ -1335,34 +1352,31 @@ u3_sist_boot(void) u3A->fak = c3y; who = u3k(u3t(whu)); - pig = u3nc(c3__fake, who); + pig = u3nc(c3__fake, u3k(who)); + u3z(whu); } else { + if ( 0 == u3_Host.ops_u.key_c ) { + // XX print nice error + u3_lo_bail(); + } + + u3_noun des = u3m_file(u3_Host.ops_u.key_c); + u3A->fak = c3n; - pig = _sist_dawn(); + pig = _sist_dawn(u3k(des)); who = u3k(u3h(u3h(u3t(pig)))); + + u3z(des); } u3A->own = who; - _sist_make(pig); - } - else { - _sist_rest(); - if ( c3y == u3A->fak ) { - c3_c* who_c = u3r_string(u3dc("scot", 'p', u3k(u3A->own))); - fprintf(stderr, "fake: %s\r\n", who_c); + // Authenticate and initialize terminal. + u3_term_ef_bake(pig); - // XX use clan:title - if ( 4 == strlen(who_c) ) { - u3_Host.ops_u.imp_c = who_c; - } else { - free(who_c); - } - - // XX make conditional - u3_Host.ops_u.net = c3n; - } + // Create the ship directory. + _sist_zest(); } } From 4bcfcf0b3a283b3484e536394334b2ac2596d59d Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 02:08:43 -0400 Subject: [PATCH 30/64] completely removes -I --- include/vere/vere.h | 1 - vere/http.c | 3 ++- vere/main.c | 32 +++++++------------------------- 3 files changed, 9 insertions(+), 27 deletions(-) diff --git a/include/vere/vere.h b/include/vere/vere.h index 2183d483e..c4c02449f 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -581,7 +581,6 @@ typedef struct _u3_opts { c3_c* arv_c; // -A, initial sync from c3_c* gen_c; // -G, czar generator - c3_c* imp_c; // -I, czar name c3_c* nam_c; // -n, unix hostname c3_c* pil_c; // -B, bootstrap from c3_c* raf_c; // -r, raft flotilla diff --git a/vere/http.c b/vere/http.c index 14d5fd4af..2211ade95 100644 --- a/vere/http.c +++ b/vere/http.c @@ -1238,6 +1238,7 @@ static u3_noun _http_czar_host(void) { u3_noun dom = u3_nul; + return dom; // XX revisit #if 0 @@ -1275,7 +1276,6 @@ _http_czar_host(void) } } } -#endif if ( u3_nul == dom ) { return dom; @@ -1285,6 +1285,7 @@ _http_czar_host(void) dom = u3nc(u3i_string(u3_Host.ops_u.imp_c + 1), u3kb_flop(u3k(dom))); return u3nt(u3_nul, c3y, u3kb_flop(u3k(dom))); +#endif } /* u3_http_ef_bake(): notify %eyre that we're live diff --git a/vere/main.c b/vere/main.c index 0f60f735b..0fbf9783c 100644 --- a/vere/main.c +++ b/vere/main.c @@ -91,7 +91,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.veb = c3n; u3_Host.ops_u.kno_w = DefaultKernel; - while ( (ch_i=getopt(argc, argv,"G:B:K:A:I:w:u:f:F:k:l:n:p:r:NabcdgqsvxMPDXRS")) != -1 ) { + while ( (ch_i=getopt(argc, argv,"G:B:K:A:w:u:f:F:k:l:n:p:r:NabcdgqsvxMPDXRS")) != -1 ) { switch ( ch_i ) { case 'M': { u3_Host.ops_u.mem = c3y; @@ -109,11 +109,6 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.arv_c = strdup(optarg); break; } - // XX remove in deference to -K - case 'I': { - u3_Host.ops_u.imp_c = _main_presig(optarg); - break; - } case 'F': { u3_Host.ops_u.fak_c = _main_presig(optarg); break; @@ -143,7 +138,6 @@ _main_getopt(c3_i argc, c3_c** argv) } case 'K': { u3_Host.ops_u.key_c = strdup(optarg); - u3_Host.ops_u.nuu = c3y; break; } case 'k': { @@ -194,18 +188,11 @@ _main_getopt(c3_i argc, c3_c** argv) } } - // XX remove -I - if ( (0 != u3_Host.ops_u.fak_c) && (0 != u3_Host.ops_u.imp_c) ) { - fprintf(stderr, "-I is redundant with -F\n"); - return c3n; + if ( 0 != u3_Host.ops_u.fak_c ) { + u3_Host.ops_u.who_c = strdup(u3_Host.ops_u.fak_c); } - // set galaxy name - // XX need to do this with -K too - // -A is required when booting a galaxy - if ( (0 != u3_Host.ops_u.fak_c) && (4 == strlen(u3_Host.ops_u.fak_c)) ) { - u3_Host.ops_u.imp_c = strdup(u3_Host.ops_u.fak_c); - } + c3_t imp_t = ( (0 != u3_Host.ops_u.who_c) && (4 == strlen(u3_Host.ops_u.who_c)) ); if ( (0 != u3_Host.ops_u.fak_c) && (c3n == u3_Host.ops_u.nuu) ) { fprintf(stderr, "-F only makes sense on initial boot\n"); @@ -220,22 +207,18 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.net = c3y; /* remote networking is always on in real mode. */ } - if ( u3_Host.ops_u.arv_c != 0 && ( u3_Host.ops_u.imp_c == 0 || - u3_Host.ops_u.nuu == c3n ) ) { + if ( u3_Host.ops_u.arv_c != 0 && !imp_t ) { fprintf(stderr, "-A only makes sense when creating a new galaxy\n"); return c3n; } - if ( u3_Host.ops_u.imp_c != 0 && - u3_Host.ops_u.arv_c == 0 && - u3_Host.ops_u.nuu == c3y ) { + if ( u3_Host.ops_u.arv_c == 0 && imp_t ) { fprintf(stderr, "can't create a new galaxy without specifying " "the initial sync path with -A\n"); return c3n; } - if ( u3_Host.ops_u.gen_c != 0 && ( u3_Host.ops_u.imp_c == 0 || - u3_Host.ops_u.nuu == c3n ) ) { + if ( u3_Host.ops_u.gen_c != 0 && ( !imp_t || u3_Host.ops_u.nuu == c3n ) ) { fprintf(stderr, "-G only makes sense when creating a new galaxy\n"); return c3n; } @@ -350,7 +333,6 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-F ship Fake keys; also disables networking\n", "-f Fuzz testing\n", "-g Set GC flag\n", - "-I galaxy Start as ~galaxy\n", "-k stage Start at Hoon kernel version stage\n", "-l port Initial peer port\n", "-M Memory madness\n", From 178c2212cfef095189412164940ddc77d84ee326 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 11:18:54 -0400 Subject: [PATCH 31/64] adds -e to specify ethereum node url --- include/vere/vere.h | 1 + vere/main.c | 6 +++++- vere/sist.c | 11 ++++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/vere/vere.h b/include/vere/vere.h index c4c02449f..57a3b346b 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -591,6 +591,7 @@ c3_o bat; // -b, batch create c3_o dem; // -d, daemon c3_o dry; // -D, dry compute + c3_c* eth_c; // -e, ethereum node url c3_c* fak_c; // -F, fake ship c3_o fog; // -X, skip last event c3_o gab; // -g, run with garbage collector diff --git a/vere/main.c b/vere/main.c index 0fbf9783c..470b1fb09 100644 --- a/vere/main.c +++ b/vere/main.c @@ -91,7 +91,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.veb = c3n; u3_Host.ops_u.kno_w = DefaultKernel; - while ( (ch_i=getopt(argc, argv,"G:B:K:A:w:u:f:F:k:l:n:p:r:NabcdgqsvxMPDXRS")) != -1 ) { + while ( (ch_i=getopt(argc, argv,"G:B:K:A:w:u:e:f:F:k:l:n:p:r:NabcdgqsvxMPDXRS")) != -1 ) { switch ( ch_i ) { case 'M': { u3_Host.ops_u.mem = c3y; @@ -109,6 +109,10 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.arv_c = strdup(optarg); break; } + case 'e': { + u3_Host.ops_u.eth_c = strdup(optarg); + break; + } case 'F': { u3_Host.ops_u.fak_c = _main_presig(optarg); break; diff --git a/vere/sist.c b/vere/sist.c index 32d79be53..8acb9888e 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1174,6 +1174,8 @@ _sist_post_json(c3_c* url_c, uv_buf_t lod_u) hed_u = curl_slist_append(hed_u, "Content-Type: application/json"); hed_u = curl_slist_append(hed_u, "charsets: utf-8"); + // XX require TLS, pin default cert? + curl_easy_setopt(curl, CURLOPT_URL, url_c); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _sist_curl_alloc); curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&buf_u); @@ -1248,6 +1250,10 @@ _sist_dawn(u3_noun des) { u3_noun who, sed, pon, zar, tuf; + c3_t eth_t = ( 0 != u3_Host.ops_u.eth_c ); + // XX require https? + c3_c* url_c = eth_t ? u3_Host.ops_u.eth_c : "http://localhost:8545"; + { u3_noun eds = u3dc("slaw", c3__uw, u3k(des)); @@ -1264,9 +1270,6 @@ _sist_dawn(u3_noun des) u3z(des); u3z(eds); } - // XX configure default globally, add cli arg to specify - c3_c* url_c = "http://localhost:8545"; - // XX leaks nock { // +hull:constitution:ethe: on-chain state @@ -1316,6 +1319,8 @@ _sist_dawn(u3_noun des) u3z(oct); u3z(fut); } + // XX include ops_u.eth_c if set + // [%dawn seed sponsor galaxies domains] return u3nc(c3__dawn, u3nq(sed, pon, zar, tuf)); } From ca1259bf70498a285053b995212977c07b7f1231 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 11:29:59 -0400 Subject: [PATCH 32/64] check that -w matches the ship in -K --- vere/sist.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/vere/sist.c b/vere/sist.c index 8acb9888e..52a478179 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1258,16 +1258,40 @@ _sist_dawn(u3_noun des) u3_noun eds = u3dc("slaw", c3__uw, u3k(des)); if ( u3_nul == eds ) { - // XX print nice error + c3_c* sed_c = u3r_string(des); + fprintf(stderr, "dawn: invalid private keys: %s\r\n", sed_c); + free(sed_c); + u3_lo_bail(); + } + + if ( 0 == u3_Host.ops_u.who_c ) { + fprintf(stderr, "dawn: -w required\r\n"); + u3_lo_bail(); + } + + u3_noun woh = u3i_string(u3_Host.ops_u.who_c); + u3_noun whu = u3dc("slaw", 'p', u3k(woh)); + + if ( u3_nul == whu ) { + fprintf(stderr, "dawn: invalid ship specificed with -w %s\r\n", + u3_Host.ops_u.who_c); u3_lo_bail(); } // +seed:able:jael: private key file sed = u3ke_cue(u3k(u3t(eds))); - // XX compare against ops_u.who_c who = u3h(sed); - u3z(des); u3z(eds); + if ( who != u3t(whu) ) { + u3_noun how = u3dc("scot", 'p', u3k(who)); + c3_c* how_c = u3r_string(u3k(how)); + fprintf(stderr, "dawn: mismatch between -w %s and -K %s\r\n", + u3_Host.ops_u.who_c, how_c); + free(how_c); + u3_lo_bail(); + } + + u3z(woh); u3z(whu); u3z(des); u3z(eds); } // XX leaks nock From 4b6c6978146c663d648386982235b3e54e1c4207 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 11:38:32 -0400 Subject: [PATCH 33/64] allows -G as an alternative to -K (temporarily) --- vere/main.c | 4 ++-- vere/sist.c | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/vere/main.c b/vere/main.c index 470b1fb09..3b793462d 100644 --- a/vere/main.c +++ b/vere/main.c @@ -222,8 +222,8 @@ _main_getopt(c3_i argc, c3_c** argv) return c3n; } - if ( u3_Host.ops_u.gen_c != 0 && ( !imp_t || u3_Host.ops_u.nuu == c3n ) ) { - fprintf(stderr, "-G only makes sense when creating a new galaxy\n"); + if ( u3_Host.ops_u.gen_c != 0 && u3_Host.ops_u.nuu == c3n ) { + fprintf(stderr, "-G only makes sense when bootstrapping a new instance\n"); return c3n; } diff --git a/vere/sist.c b/vere/sist.c index 52a478179..d9ec09b46 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1386,13 +1386,19 @@ u3_sist_boot(void) u3z(whu); } else { - if ( 0 == u3_Host.ops_u.key_c ) { + u3_noun des = u3_none; + + if ( 0 != u3_Host.ops_u.key_c ) { + des = u3m_file(u3_Host.ops_u.key_c); + } + else if ( 0 != u3_Host.ops_u.gen_c ) { + des = u3i_string(u3_Host.ops_u.gen_c); + } + else { // XX print nice error u3_lo_bail(); } - u3_noun des = u3m_file(u3_Host.ops_u.key_c); - u3A->fak = c3n; pig = _sist_dawn(u3k(des)); who = u3k(u3h(u3h(u3t(pig)))); From f939b63ccae3bdf9040944858da4b1c2ccb04d45 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 12 Oct 2018 13:45:20 -0400 Subject: [PATCH 34/64] simplifies dawn status noun, improves error messages --- include/c/motes.h | 4 ++++ vere/sist.c | 43 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/include/c/motes.h b/include/c/motes.h index 6d5dadf76..52722b371 100644 --- a/include/c/motes.h +++ b/include/c/motes.h @@ -354,9 +354,11 @@ # define c3__dxkt c3_s4('d','x','k','t') # define c3__dub c3_s3('d','u','b') # define c3__duct c3_s4('d','u','c','t') +# define c3__duke c3_s4('d','u','k','e') # define c3__dumb c3_s4('d','u','m','b') # define c3__dump c3_s4('d','u','m','p') # define c3__dust c3_s4('d','u','s','t') +# define c3__earl c3_s4('e','a','r','l') # define c3__east c3_s4('e','a','s','t') # define c3__echo c3_s4('e','c','h','o') # define c3__edge c3_s4('e','d','g','e') @@ -586,6 +588,7 @@ # define c3__kern c3_s4('k','e','r','n') # define c3__kgo c3_s3('k','g','o') # define c3__kick c3_s4('k','i','c','k') +# define c3__king c3_s4('k','i','n','g') # define c3__kit c3_s3('k','i','t') # define c3__knit c3_s4('k','n','i','t') # define c3__kno c3_s3('k','n','o') @@ -803,6 +806,7 @@ # define c3__part c3_s4('p','a','r','t') # define c3__pass c3_s4('p','a','s','s') # define c3__past c3_s4('p','a','s','t') +# define c3__pawn c3_s4('p','a','w','n') # define c3__peek c3_s4('p','e','e','k') # define c3__peep c3_s4('p','e','e','p') # define c3__peft c3_s4('p','e','f','t') diff --git a/vere/sist.c b/vere/sist.c index d9ec09b46..65b74e368 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1287,6 +1287,8 @@ _sist_dawn(u3_noun des) c3_c* how_c = u3r_string(u3k(how)); fprintf(stderr, "dawn: mismatch between -w %s and -K %s\r\n", u3_Host.ops_u.who_c, how_c); + + u3z(how); free(how_c); u3_lo_bail(); } @@ -1306,19 +1308,54 @@ _sist_dawn(u3_noun des) // u3_noun liv = _sist_get_json(parent, /some/url) u3_noun liv = u3_nul; - // XX revisit - // (each [seed (unit ship)] [rank @tas]) + // (each sponsor=(unit ship) error=@tas) u3_noun sas = u3dt("veri:dawn", u3k(sed), u3k(hul), u3k(liv)); if ( c3n == u3h(sas) ) { + u3_noun rac = u3do("clan:title", u3k(who)); + u3_noun how = u3dc("scot", 'p', u3k(who)); + c3_c* how_c = u3r_string(u3k(how)); + + c3_c* rac_c; + + switch (rac) { + default: c3_assert(0); + case c3__czar: { + rac_c = "galaxy"; + break; + } + case c3__king: { + rac_c = "star"; + break; + } + case c3__duke: { + rac_c = "planet"; + break; + } + case c3__earl: { + rac_c = "moon"; + break; + } + case c3__pawn: { + rac_c = "comet"; + break; + } + } + + fprintf(stderr, "dawn: invalid keys for %s '%s'\r\n", rac_c, how_c); + // XX deconstruct sas, print helpful error messages u3m_p("pre-boot error", u3t(sas)); + + u3z(rac); + u3z(how); + free(how_c); u3_lo_bail(); } // (unit ship): sponsor // produced by +veri:dawn to avoid coupling to +hull structure - pon = u3k(u3t(u3t(sas))); + pon = u3k(u3t(sas)); u3z(oct); u3z(luh); u3z(hul); u3z(liv); u3z(sas); } From 07c04e32a7626b8ece483a1dca46828d553cba8e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 17 Oct 2018 11:56:37 -0400 Subject: [PATCH 35/64] initialize %ames (and galxy sync) early on first boot --- vere/ames.c | 3 +-- vere/loop.c | 15 ++++----------- vere/sist.c | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/vere/ames.c b/vere/ames.c index 913c85616..72063ecde 100644 --- a/vere/ames.c +++ b/vere/ames.c @@ -529,8 +529,7 @@ u3_ames_ef_turf(u3_noun tuf) u3z(tuf); } - else if ( c3n == u3A->fak ) { - // XX assert? + else if ( (c3n == u3A->fak) && (0 == u3_Host.sam_u.dns_c) ) { uL(fprintf(uH, "ames: turf: no domains\n")); } diff --git a/vere/loop.c b/vere/loop.c index ac830936e..130ee87fa 100644 --- a/vere/loop.c +++ b/vere/loop.c @@ -667,18 +667,11 @@ u3_lo_lead(void) // Further server configuration. // { - u3_ames_ef_bake(); - u3_http_ef_bake(); - - if ( c3y == u3_Host.ops_u.nuu ) { - u3_noun rac = u3do("clan:title", u3k(u3A->own)); - - if ( c3__czar == rac ) { - u3_unix_ef_initial_into(); - } - - u3z(rac); + if ( c3n == u3_Host.ops_u.nuu ) { + u3_ames_ef_bake(); } + + u3_http_ef_bake(); } _lo_talk(); diff --git a/vere/sist.c b/vere/sist.c index 65b74e368..ddbb9954a 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1445,9 +1445,29 @@ u3_sist_boot(void) u3A->own = who; + // initialize ames + { + u3_noun tuf = (c3y == u3A->fak) ? u3_nul : u3t(u3t(u3t(u3t(pig)))); + // with a fake event to bring up listeners and configure domains + u3_ames_ef_turf(u3k(tuf)); + // and real effect to set the output duct + u3_ames_ef_bake(); + } + // Authenticate and initialize terminal. u3_term_ef_bake(pig); + // queue initial galaxy sync + { + u3_noun rac = u3do("clan:title", u3k(u3A->own)); + + if ( c3__czar == rac ) { + u3_unix_ef_initial_into(); + } + + u3z(rac); + } + // Create the ship directory. _sist_zest(); } From 1f42dfc81203522a72bd08133d7bd198d7628e32 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 17 Oct 2018 17:28:46 -0400 Subject: [PATCH 36/64] documents new cli arguments --- vere/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vere/main.c b/vere/main.c index 3b793462d..b4ef880ce 100644 --- a/vere/main.c +++ b/vere/main.c @@ -334,15 +334,17 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-c pier Create a new urbit in pier/\n", "-d Daemon mode\n", "-D Recompute from events\n", + "-e url Ethereum gateway\n", "-F ship Fake keys; also disables networking\n", "-f Fuzz testing\n", "-g Set GC flag\n", + "-K keys Private key file\n", "-k stage Start at Hoon kernel version stage\n", "-l port Initial peer port\n", "-M Memory madness\n", "-n host Set unix hostname\n", "-N Enable networking in fake mode (-F)\n", - "-p ames_port Set the HTTP port to bind to\n", + "-p ames_port Set the ames port to bind to\n", "-P Profiling\n", "-q Quiet\n", "-r host Initial peer address\n", @@ -350,7 +352,7 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-s Pill URL from arvo git hash\n", "-u url URL from which to download pill\n", "-v Verbose\n", - "-w name Immediately upgrade to ~name\n", + "-w name Boot as ~name\n", "-x Exit immediately\n", "-Xwtf Skip last event\n", "\n", From cc8c01ea70bf2fb0672628a2db797725799b186a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 17 Oct 2018 18:56:12 -0400 Subject: [PATCH 37/64] adds comet mining (temporarily hardcoded under ~marzod) --- vere/main.c | 5 ++ vere/sist.c | 181 ++++++++++++++++++++++++++++++++++------------------ 2 files changed, 124 insertions(+), 62 deletions(-) diff --git a/vere/main.c b/vere/main.c index b4ef880ce..997a2bd72 100644 --- a/vere/main.c +++ b/vere/main.c @@ -193,6 +193,11 @@ _main_getopt(c3_i argc, c3_c** argv) } if ( 0 != u3_Host.ops_u.fak_c ) { + if ( 28 < strlen(u3_Host.ops_u.fak_c) ) { + fprintf(stderr, "fake comets are disallowed\r\n"); + return c3n; + } + u3_Host.ops_u.who_c = strdup(u3_Host.ops_u.fak_c); } diff --git a/vere/sist.c b/vere/sist.c index ddbb9954a..789500c22 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1122,17 +1122,6 @@ _sist_rest() } } -/* _sist_zen(): get OS entropy. -*/ -static u3_noun -_sist_zen() -{ - c3_w rad_w[16]; - - c3_rand(rad_w); - return u3i_words(16, rad_w); -} - /* _sist_curl_alloc(): allocate a response buffer for curl */ static size_t @@ -1246,56 +1235,16 @@ _sist_eth_rpc(c3_c* url_c, u3_noun oct) /* _sist_dawn(): produce %dawn boot card - validate keys and query contract */ static u3_noun -_sist_dawn(u3_noun des) +_sist_dawn(u3_noun sed) { - u3_noun who, sed, pon, zar, tuf; + u3_noun pon, zar, tuf; + + u3_noun who = u3h(sed); c3_t eth_t = ( 0 != u3_Host.ops_u.eth_c ); // XX require https? c3_c* url_c = eth_t ? u3_Host.ops_u.eth_c : "http://localhost:8545"; - { - u3_noun eds = u3dc("slaw", c3__uw, u3k(des)); - - if ( u3_nul == eds ) { - c3_c* sed_c = u3r_string(des); - fprintf(stderr, "dawn: invalid private keys: %s\r\n", sed_c); - free(sed_c); - u3_lo_bail(); - } - - if ( 0 == u3_Host.ops_u.who_c ) { - fprintf(stderr, "dawn: -w required\r\n"); - u3_lo_bail(); - } - - u3_noun woh = u3i_string(u3_Host.ops_u.who_c); - u3_noun whu = u3dc("slaw", 'p', u3k(woh)); - - if ( u3_nul == whu ) { - fprintf(stderr, "dawn: invalid ship specificed with -w %s\r\n", - u3_Host.ops_u.who_c); - u3_lo_bail(); - } - - // +seed:able:jael: private key file - sed = u3ke_cue(u3k(u3t(eds))); - who = u3h(sed); - - if ( who != u3t(whu) ) { - u3_noun how = u3dc("scot", 'p', u3k(who)); - c3_c* how_c = u3r_string(u3k(how)); - fprintf(stderr, "dawn: mismatch between -w %s and -K %s\r\n", - u3_Host.ops_u.who_c, how_c); - - u3z(how); - free(how_c); - u3_lo_bail(); - } - - u3z(woh); u3z(whu); u3z(des); u3z(eds); - } - // XX leaks nock { // +hull:constitution:ethe: on-chain state @@ -1386,6 +1335,103 @@ _sist_dawn(u3_noun des) return u3nc(c3__dawn, u3nq(sed, pon, zar, tuf)); } +/* _sist_zen(): get OS entropy. +*/ +static u3_noun +_sist_zen(void) +{ + c3_w rad_w[16]; + + c3_rand(rad_w); + return u3i_words(16, rad_w); +} + +/* _sist_come(): mine a comet. +*/ +static u3_noun +_sist_come(void) +{ + u3_noun tar, eny, sed; + + // XX choose from list, at random, &c + tar = u3dc("slav", 'p', u3i_string("~marzod")); + eny = _sist_zen(); + + { + u3_noun sar = u3dc("scot", 'p', u3k(tar)); + c3_c* tar_c = u3r_string(sar); + + fprintf(stderr, "boot: mining a comet under %s\r\n", tar_c); + free(tar_c); + u3z(sar); + } + + sed = u3dc("come:dawn", u3k(tar), u3k(eny)); + + { + u3_noun who = u3dc("scot", 'p', u3k(u3h(sed))); + c3_c* who_c = u3r_string(who); + + fprintf(stderr, "boot: found comet %s\r\n", who_c); + free(who_c); + u3z(who); + } + + u3z(tar); u3z(eny); + + return sed; +} + +/* sist_key(): parse a private key-file. +*/ +static u3_noun +sist_key(u3_noun des) +{ + u3_noun sed, who; + + u3_noun eds = u3dc("slaw", c3__uw, u3k(des)); + + if ( u3_nul == eds ) { + c3_c* sed_c = u3r_string(des); + fprintf(stderr, "dawn: invalid private keys: %s\r\n", sed_c); + free(sed_c); + u3_lo_bail(); + } + + if ( 0 == u3_Host.ops_u.who_c ) { + fprintf(stderr, "dawn: -w required\r\n"); + u3_lo_bail(); + } + + u3_noun woh = u3i_string(u3_Host.ops_u.who_c); + u3_noun whu = u3dc("slaw", 'p', u3k(woh)); + + if ( u3_nul == whu ) { + fprintf(stderr, "dawn: invalid ship specificed with -w %s\r\n", + u3_Host.ops_u.who_c); + u3_lo_bail(); + } + + // +seed:able:jael: private key file + sed = u3ke_cue(u3k(u3t(eds))); + who = u3h(sed); + + if ( c3n == u3r_sing(who, u3t(whu)) ) { + u3_noun how = u3dc("scot", 'p', u3k(who)); + c3_c* how_c = u3r_string(u3k(how)); + fprintf(stderr, "dawn: mismatch between -w %s and -K %s\r\n", + u3_Host.ops_u.who_c, how_c); + + u3z(how); + free(how_c); + u3_lo_bail(); + } + + u3z(woh); u3z(whu); u3z(des); u3z(eds); + + return sed; +} + /* u3_sist_boot(): restore or create. */ void @@ -1413,6 +1459,16 @@ u3_sist_boot(void) fprintf(stderr, "fake: invalid ship: %s\r\n", u3_Host.ops_u.fak_c); u3_lo_bail(); } + else { + u3_noun rac = u3do("clan:title", u3k(u3t(whu))); + + if ( c3__pawn == rac ) { + fprintf(stderr, "fake comets are disallowed\r\n"); + u3_lo_bail(); + } + + u3z(rac); + } fprintf(stderr, "fake: %s\r\n", u3_Host.ops_u.fak_c); @@ -1423,24 +1479,25 @@ u3_sist_boot(void) u3z(whu); } else { - u3_noun des = u3_none; + u3_noun sed; if ( 0 != u3_Host.ops_u.key_c ) { - des = u3m_file(u3_Host.ops_u.key_c); + u3_noun des = u3m_file(u3_Host.ops_u.key_c); + sed = sist_key(des); } else if ( 0 != u3_Host.ops_u.gen_c ) { - des = u3i_string(u3_Host.ops_u.gen_c); + u3_noun des = u3i_string(u3_Host.ops_u.gen_c); + sed = sist_key(des); } else { - // XX print nice error - u3_lo_bail(); + sed = _sist_come(); } u3A->fak = c3n; - pig = _sist_dawn(u3k(des)); + pig = _sist_dawn(u3k(sed)); who = u3k(u3h(u3h(u3t(pig)))); - u3z(des); + u3z(sed); } u3A->own = who; From d9cfb8de356512e6bb6abd69b9af5dcced129a0c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 18 Oct 2018 01:26:50 -0400 Subject: [PATCH 38/64] removes extra %init handlers in reck.c --- vere/reck.c | 42 ++---------------------------------------- 1 file changed, 2 insertions(+), 40 deletions(-) diff --git a/vere/reck.c b/vere/reck.c index 3515c3268..28dba1988 100644 --- a/vere/reck.c +++ b/vere/reck.c @@ -100,7 +100,6 @@ _reck_kick_term(u3_noun pox, c3_l tid_l, u3_noun fav) case c3__init: p_fav = u3t(fav); { - uL(fprintf(uH, "kick: init: term\n")); c3_assert( c3y == u3r_sing(u3A->own, p_fav) ); u3z(pox); u3z(fav); return c3y; @@ -196,6 +195,8 @@ _reck_kick_sync(u3_noun pox, u3_noun fav) u3z(pox); u3z(fav); return c3n; } +/* _reck_kick_newt(): apply packet network outputs. +*/ static u3_noun _reck_kick_newt(u3_noun pox, u3_noun fav) { @@ -217,27 +218,6 @@ _reck_kick_newt(u3_noun pox, u3_noun fav) u3z(pox); u3z(fav); return c3n; } -/* _reck_kick_ames(): apply packet network outputs. -*/ -static u3_noun -_reck_kick_ames(u3_noun pox, u3_noun fav) -{ - u3_noun p_fav; - - switch ( u3h(fav) ) { - default: break; - // XX remove - case c3__init: p_fav = u3t(fav); - { - uL(fprintf(uH, "kick: init: ames\n")); - c3_assert( c3y == u3r_sing(u3A->own, p_fav) ); - - u3z(pox); u3z(fav); return c3y; - } break; - } - u3z(pox); u3z(fav); return c3n; -} - /* _reck_kick_spec(): apply an effect, by path. */ static u3_noun @@ -307,24 +287,6 @@ _reck_kick_spec(u3_noun pox, u3_noun fav) return _reck_kick_newt(pox, fav); } break; - case c3__ames: { - if ( (u3_nul != tt_pox) ) { - u3z(pox); u3z(fav); return c3n; - } - else { - return _reck_kick_ames(pox, fav); - } - } break; - - // XX remove - case c3__init: p_fav = u3t(fav); - { - uL(fprintf(uH, "kick: init: spec\n")); - c3_assert( c3y == u3r_sing(u3A->own, p_fav) ); - - u3z(pox); u3z(fav); return c3y; - } break; - case c3__term: { u3_noun pud = tt_pox; u3_noun p_pud, q_pud; From 37f551d65fc7df662ce985ba992f907cdf8de353 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 18 Oct 2018 14:47:15 -0400 Subject: [PATCH 39/64] adds pre-boot validation status printfs --- vere/sist.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vere/sist.c b/vere/sist.c index 789500c22..fb55e0788 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1247,6 +1247,10 @@ _sist_dawn(u3_noun sed) // XX leaks nock { + fprintf(stderr, "boot: retrieving %s's public keys\r\n", + u3_Host.ops_u.who_c); + + // XX check parent if moon // +hull:constitution:ethe: on-chain state u3_noun oct = u3do("hull:give:dawn", u3k(who)); u3_noun luh = _sist_eth_rpc(url_c, u3k(oct)); @@ -1257,6 +1261,8 @@ _sist_dawn(u3_noun sed) // u3_noun liv = _sist_get_json(parent, /some/url) u3_noun liv = u3_nul; + fprintf(stderr, "boot: verifying keys\r\n"); + // (each sponsor=(unit ship) error=@tas) u3_noun sas = u3dt("veri:dawn", u3k(sed), u3k(hul), u3k(liv)); @@ -1311,6 +1317,8 @@ _sist_dawn(u3_noun sed) // XX leaks nock { + fprintf(stderr, "boot: retrieving galaxy table\r\n"); + // (map ship [=life =pass]): galaxy table u3_noun oct = u3v_wish("czar:give:dawn"); u3_noun raz = _sist_eth_rpc(url_c, u3k(oct)); @@ -1321,6 +1329,8 @@ _sist_dawn(u3_noun sed) // XX leaks nock { + fprintf(stderr, "boot: retrieving network domains\r\n"); + // (list turf): ames domains u3_noun oct = u3v_wish("turf:give:dawn"); u3_noun fut = _sist_eth_rpc(url_c, u3k(oct)); From 562c9b310a2b014331864d5135f19e053a50ae44 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 18 Oct 2018 15:13:14 -0400 Subject: [PATCH 40/64] factors out pre-boot verification failure --- vere/sist.c | 88 +++++++++++++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 39 deletions(-) diff --git a/vere/sist.c b/vere/sist.c index fb55e0788..2e6208db2 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1232,6 +1232,50 @@ _sist_eth_rpc(c3_c* url_c, u3_noun oct) return _sist_buf_to_oct(_sist_post_json(url_c, _sist_oct_to_buf(oct))); } +/* _sist_dawn_fail(): pre-boot validation failed +*/ +static void +_sist_dawn_fail(u3_noun who, u3_noun rac, u3_noun sas) +{ + u3_noun how = u3dc("scot", 'p', u3k(who)); + c3_c* how_c = u3r_string(u3k(how)); + + c3_c* rac_c; + + switch (rac) { + default: c3_assert(0); + case c3__czar: { + rac_c = "galaxy"; + break; + } + case c3__king: { + rac_c = "star"; + break; + } + case c3__duke: { + rac_c = "planet"; + break; + } + case c3__earl: { + rac_c = "moon"; + break; + } + case c3__pawn: { + rac_c = "comet"; + break; + } + } + + fprintf(stderr, "dawn: invalid keys for %s '%s'\r\n", rac_c, how_c); + + // XX deconstruct sas, print helpful error messages + u3m_p("pre-boot error", u3t(sas)); + + u3z(how); + free(how_c); + u3_lo_bail(); +} + /* _sist_dawn(): produce %dawn boot card - validate keys and query contract */ static u3_noun @@ -1240,6 +1284,7 @@ _sist_dawn(u3_noun sed) u3_noun pon, zar, tuf; u3_noun who = u3h(sed); + u3_noun rac = u3do("clan:title", u3k(who)); c3_t eth_t = ( 0 != u3_Host.ops_u.eth_c ); // XX require https? @@ -1267,45 +1312,9 @@ _sist_dawn(u3_noun sed) u3_noun sas = u3dt("veri:dawn", u3k(sed), u3k(hul), u3k(liv)); if ( c3n == u3h(sas) ) { - u3_noun rac = u3do("clan:title", u3k(who)); - u3_noun how = u3dc("scot", 'p', u3k(who)); - c3_c* how_c = u3r_string(u3k(how)); - - c3_c* rac_c; - - switch (rac) { - default: c3_assert(0); - case c3__czar: { - rac_c = "galaxy"; - break; - } - case c3__king: { - rac_c = "star"; - break; - } - case c3__duke: { - rac_c = "planet"; - break; - } - case c3__earl: { - rac_c = "moon"; - break; - } - case c3__pawn: { - rac_c = "comet"; - break; - } - } - - fprintf(stderr, "dawn: invalid keys for %s '%s'\r\n", rac_c, how_c); - - // XX deconstruct sas, print helpful error messages - u3m_p("pre-boot error", u3t(sas)); - - u3z(rac); - u3z(how); - free(how_c); - u3_lo_bail(); + // bails, won't return + _sist_dawn_fail(who, rac, sas); + return u3_none; } // (unit ship): sponsor @@ -1339,6 +1348,7 @@ _sist_dawn(u3_noun sed) u3z(oct); u3z(fut); } + u3z(rac); // XX include ops_u.eth_c if set // [%dawn seed sponsor galaxies domains] From 61c1ece9267a62e42a2d33bcfcb80420418fe063 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 18 Oct 2018 15:24:04 -0400 Subject: [PATCH 41/64] corrects public-key retrieval for (parent of) moons --- vere/sist.c | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/vere/sist.c b/vere/sist.c index 2e6208db2..715a12586 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1292,14 +1292,42 @@ _sist_dawn(u3_noun sed) // XX leaks nock { - fprintf(stderr, "boot: retrieving %s's public keys\r\n", - u3_Host.ops_u.who_c); - // XX check parent if moon // +hull:constitution:ethe: on-chain state - u3_noun oct = u3do("hull:give:dawn", u3k(who)); - u3_noun luh = _sist_eth_rpc(url_c, u3k(oct)); - u3_noun hul = u3dc("hull:take:dawn", u3k(who), u3k(luh)); + u3_noun hul; + + { + if ( c3__pawn == rac ) { + // irrelevant, just bunt +hull + hul = u3v_wish("*hull:constitution:ethe"); + } + else { + u3_noun oct; + + if ( c3__earl == rac ) { + u3_noun seg = u3do("^sein:title", u3k(who)); + u3_noun ges = u3dc("scot", 'p', u3k(seg)); + c3_c* seg_c = u3r_string(ges); + + fprintf(stderr, "boot: retrieving %s's public keys (for %s)\r\n", + seg_c, u3_Host.ops_u.who_c); + oct = u3do("hull:give:dawn", u3k(seg)); + + free(seg_c); + u3z(seg); u3z(ges); + } + else { + fprintf(stderr, "boot: retrieving %s's public keys\r\n", + u3_Host.ops_u.who_c); + oct = u3do("hull:give:dawn", u3k(who)); + } + + u3_noun luh = _sist_eth_rpc(url_c, u3k(oct)); + hul = u3dc("hull:take:dawn", u3k(who), u3k(luh)); + + u3z(oct); u3z(luh); + } + } // +live:dawn: network state // XX actually make request @@ -1321,7 +1349,7 @@ _sist_dawn(u3_noun sed) // produced by +veri:dawn to avoid coupling to +hull structure pon = u3k(u3t(sas)); - u3z(oct); u3z(luh); u3z(hul); u3z(liv); u3z(sas); + u3z(hul); u3z(liv); u3z(sas); } // XX leaks nock From 999e82a44a936666248df56413d1e70971cd0342 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Wed, 24 Oct 2018 10:38:09 -0700 Subject: [PATCH 42/64] actually send headers --- vere/sist.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vere/sist.c b/vere/sist.c index 715a12586..5379c9597 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1168,6 +1168,7 @@ _sist_post_json(c3_c* url_c, uv_buf_t lod_u) curl_easy_setopt(curl, CURLOPT_URL, url_c); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _sist_curl_alloc); curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&buf_u); + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, hed_u); // note: must be terminated! curl_easy_setopt(curl, CURLOPT_POSTFIELDS, lod_u.base); @@ -1187,6 +1188,7 @@ _sist_post_json(c3_c* url_c, uv_buf_t lod_u) } curl_easy_cleanup(curl); + curl_slist_free_all(hed_u); return buf_u; } From a8fbd498649bbdb77695dde0ccf9e7788e7cd5ca Mon Sep 17 00:00:00 2001 From: Joshua Reagan Date: Thu, 25 Oct 2018 17:34:49 -0700 Subject: [PATCH 43/64] converting iron and zinc cores to lead bug In the current release candidate, this happens: ``` > ^?(^|(add)) wrap-gold ford: %slim failed: ford: %ride failed to compute type: ``` This is a jet mismatch from `+wrap`, I believe: https://github.com/urbit/arvo/blob/release-candidate/sys/hoon.hoon#L11139 You should be able to convert iron and zinc cores to lead. --- jets/f/ut_wrap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jets/f/ut_wrap.c b/jets/f/ut_wrap.c index 9ef5c85f8..e51d3843f 100644 --- a/jets/f/ut_wrap.c +++ b/jets/f/ut_wrap.c @@ -41,8 +41,9 @@ if ( c3n == u3r_trel(pq_sut, &ppq_sut, &qpq_sut, &rpq_sut) ) { return u3m_bail(c3__fail); } - else if ( c3__gold != rpq_sut ) { - return u3m_error("wrap-gold"); + else if ( (c3__gold != rpq_sut) && + (c3__lead != yoz) ) { + return u3m_error("wrap-metal"); } else { return u3nt(c3__core, From c198b4ff0c2738054949e3946ce90abfc2b1b0f9 Mon Sep 17 00:00:00 2001 From: Benjamin Summers Date: Fri, 26 Oct 2018 14:51:05 -0700 Subject: [PATCH 44/64] Disabled core hashing on fake ships. --- vere/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/vere/main.c b/vere/main.c index 74901d790..9bea0be8c 100644 --- a/vere/main.c +++ b/vere/main.c @@ -197,10 +197,16 @@ _main_getopt(c3_i argc, c3_c** argv) if ( u3_Host.ops_u.fak == c3n && u3_Host.ops_u.net == c3y ) { fprintf(stderr, "-N only makes sense with -F\n"); return c3n; - } else if ( u3_Host.ops_u.fak == c3n && u3_Host.ops_u.net == c3n ) { + } + + if ( u3_Host.ops_u.fak == c3n && u3_Host.ops_u.net == c3n ) { u3_Host.ops_u.net = c3y; /* remote networking is always on in real mode. */ } + if ( u3_Host.ops_u.fak == c3y ) { + u3_Host.ops_u.has = c3y; /* no battery hashing on fake ships. */ + } + if ( u3_Host.ops_u.arv_c != 0 && ( u3_Host.ops_u.imp_c == 0 || u3_Host.ops_u.nuu == c3n ) ) { fprintf(stderr, "-A only makes sense when creating a new galaxy\n"); @@ -348,6 +354,7 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-r host Initial peer address\n", "-R Report urbit build info\n", "-s Pill URL from arvo git hash\n", + "-S Disable battery hashing\n", "-t ticket Use ~ticket automatically\n", "-u url URL from which to download pill\n", "-v Verbose\n", From b88a2b5062decc617bdda630b29bd23dfacce477 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sun, 28 Oct 2018 20:53:02 -0400 Subject: [PATCH 45/64] refactors u3v_wish for clarity --- noun/vortex.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/noun/vortex.c b/noun/vortex.c index eafb3e735..faec49d42 100644 --- a/noun/vortex.c +++ b/noun/vortex.c @@ -89,33 +89,22 @@ u3v_start(u3_noun now) u3_noun u3v_wish(const c3_c* str_c) { - u3_noun exp; + u3_noun txt = u3i_string(str_c); + u3_weak exp = u3kdb_get(u3k(u3A->yot), u3k(txt)); - if ( u3R == &u3H->rod_u ) { - u3_noun txt = u3i_string(str_c); - - exp = u3kdb_get(u3k(u3A->yot), u3k(txt)); + if ( u3_none == exp ) { + exp = _cv_nock_wish(u3k(txt)); - if ( u3_none == exp ) { - exp = _cv_nock_wish(u3k(txt)); + // It's probably not a good idea to use u3v_wish() + // outside the top level... (as the result is uncached) + // + if ( u3R == &u3H->rod_u ) { u3A->yot = u3kdb_put(u3A->yot, u3k(txt), u3k(exp)); } - u3z(txt); - return exp; - } - else { - // It's probably not a good idea to use u3v_wish() - // outside the top level... - // - u3_noun txt = u3i_string(str_c); - u3_noun exp = u3kdb_get(u3A->yot, u3k(txt)); - - if ( u3_none != exp ) { - u3z(txt); - return exp; - } - else return _cv_nock_wish(u3i_string(str_c)); } + + u3z(txt); + return exp; } /* _cv_mung(): formula wrapper with gate and sample. From b7fbd4108ebd38ad3bbecc761d281016154e73d3 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sun, 28 Oct 2018 20:50:05 -0400 Subject: [PATCH 46/64] fixes memory leak (temporarily) by disabling +xeb jet --- jets/tree.c | 8 +++++--- vere/sist.c | 3 --- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/jets/tree.c b/jets/tree.c index 8a749fb95..9804473fb 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -788,8 +788,9 @@ static u3j_harm _141_two_sqt_a[] = {{".2", u3wc_sqt, c3y}, {}}; static c3_c* _141_two_sqt_ha[] = {0}; static u3j_harm _141_two_vor_a[] = {{".2", u3wc_vor, c3y}, {}}; static c3_c* _141_two_vor_ha[] = {0}; -static u3j_harm _141_two_xeb_a[] = {{".2", u3wc_xeb, c3y}, {}}; -static c3_c* _141_two_xeb_ha[] = {0}; +// disabled, leaks +// static u3j_harm _141_two_xeb_a[] = {{".2", u3wc_xeb, c3y}, {}}; +// static c3_c* _141_two_xeb_ha[] = {0}; static u3j_harm _141_two__in_bif_a[] = {{".2", u3wdi_bif}, {}}; static c3_c* _141_two__in_bif_ha[] = {0}; @@ -928,7 +929,8 @@ static u3j_core _141_two_d[] = { "pow", 7, _141_two_pow_a, 0, _141_two_pow_ha }, { "sqt", 7, _141_two_sqt_a, 0, _141_two_sqt_ha }, { "vor", 7, _141_two_vor_a, 0, _141_two_vor_ha }, - { "xeb", 7, _141_two_xeb_a, 0, _141_two_xeb_ha }, + // disabled, leaks + // { "xeb", 7, _141_two_xeb_a, 0, _141_two_xeb_ha }, { "by", 7, 0, _141_two__by_d, _141_two__by_ha }, { "in", 7, 0, _141_two__in_d, _141_two__in_ha }, diff --git a/vere/sist.c b/vere/sist.c index 5379c9597..f38b9ace2 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1292,7 +1292,6 @@ _sist_dawn(u3_noun sed) // XX require https? c3_c* url_c = eth_t ? u3_Host.ops_u.eth_c : "http://localhost:8545"; - // XX leaks nock { // XX check parent if moon // +hull:constitution:ethe: on-chain state @@ -1354,7 +1353,6 @@ _sist_dawn(u3_noun sed) u3z(hul); u3z(liv); u3z(sas); } - // XX leaks nock { fprintf(stderr, "boot: retrieving galaxy table\r\n"); @@ -1366,7 +1364,6 @@ _sist_dawn(u3_noun sed) u3z(oct); u3z(raz); } - // XX leaks nock { fprintf(stderr, "boot: retrieving network domains\r\n"); From f8bf9679124799ee80e03a0d18113f2a721e7390 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sun, 28 Oct 2018 21:15:07 -0400 Subject: [PATCH 47/64] rewrites/re-enables +xeb jet --- jets/c/xeb.c | 18 ++++-------------- jets/tree.c | 8 +++----- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/jets/c/xeb.c b/jets/c/xeb.c index 04e6bab2d..f0a191fcb 100644 --- a/jets/c/xeb.c +++ b/jets/c/xeb.c @@ -9,22 +9,12 @@ u3_noun u3qc_xeb(u3_atom a) { - mpz_t a_mp; + c3_w met_w = u3r_met(0, a); - if ( __(u3a_is_dog(a)) ) { - u3r_mp(a_mp, a); - c3_d x = mpz_sizeinbase(a_mp, 2); - mpz_t b_mp; - mpz_init_set_ui(b_mp, x); - return u3i_mp(b_mp); - } - else { - mpz_init_set_ui(a_mp, a); - c3_d x = mpz_sizeinbase(a_mp, 2); - mpz_t b_mp; - mpz_init_set_ui(b_mp, x); - return u3i_mp(b_mp); + if ( !_(u3a_is_cat(met_w)) ) { + return u3i_words(1, &met_w); } + else return met_w; } u3_noun u3wc_xeb(u3_noun cor) diff --git a/jets/tree.c b/jets/tree.c index 9804473fb..8a749fb95 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -788,9 +788,8 @@ static u3j_harm _141_two_sqt_a[] = {{".2", u3wc_sqt, c3y}, {}}; static c3_c* _141_two_sqt_ha[] = {0}; static u3j_harm _141_two_vor_a[] = {{".2", u3wc_vor, c3y}, {}}; static c3_c* _141_two_vor_ha[] = {0}; -// disabled, leaks -// static u3j_harm _141_two_xeb_a[] = {{".2", u3wc_xeb, c3y}, {}}; -// static c3_c* _141_two_xeb_ha[] = {0}; +static u3j_harm _141_two_xeb_a[] = {{".2", u3wc_xeb, c3y}, {}}; +static c3_c* _141_two_xeb_ha[] = {0}; static u3j_harm _141_two__in_bif_a[] = {{".2", u3wdi_bif}, {}}; static c3_c* _141_two__in_bif_ha[] = {0}; @@ -929,8 +928,7 @@ static u3j_core _141_two_d[] = { "pow", 7, _141_two_pow_a, 0, _141_two_pow_ha }, { "sqt", 7, _141_two_sqt_a, 0, _141_two_sqt_ha }, { "vor", 7, _141_two_vor_a, 0, _141_two_vor_ha }, - // disabled, leaks - // { "xeb", 7, _141_two_xeb_a, 0, _141_two_xeb_ha }, + { "xeb", 7, _141_two_xeb_a, 0, _141_two_xeb_ha }, { "by", 7, 0, _141_two__by_d, _141_two__by_ha }, { "in", 7, 0, _141_two__in_d, _141_two__in_ha }, From 05b4c7726b9b230a30acfad69a31ad0d3316c2fa Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sun, 28 Oct 2018 21:26:42 -0400 Subject: [PATCH 48/64] updates +met jet to always measure only once --- jets/c/met.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jets/c/met.c b/jets/c/met.c index ee9912602..aff53da18 100644 --- a/jets/c/met.c +++ b/jets/c/met.c @@ -22,7 +22,7 @@ if ( !_(u3a_is_cat(met_w)) ) { return u3i_words(1, &met_w); } - else return u3r_met(a, b); + else return met_w; } } u3_noun From b9668c77f907cc8e544d86523c3d15614bbedf13 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sun, 28 Oct 2018 21:29:50 -0400 Subject: [PATCH 49/64] corrects boot comments --- vere/sist.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/vere/sist.c b/vere/sist.c index f38b9ace2..a41f779fe 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1293,7 +1293,6 @@ _sist_dawn(u3_noun sed) c3_c* url_c = eth_t ? u3_Host.ops_u.eth_c : "http://localhost:8545"; { - // XX check parent if moon // +hull:constitution:ethe: on-chain state u3_noun hul; @@ -1572,7 +1571,7 @@ u3_sist_boot(void) u3z(rac); } - // Create the ship directory. + // Create the event log _sist_zest(); } } From 68a2963051bfed5f7a0ca086f7898ef44ace8092 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 29 Oct 2018 11:48:05 -0400 Subject: [PATCH 50/64] swaps -K (now kernel stage) and -k (now key-file) --- vere/main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/vere/main.c b/vere/main.c index 997a2bd72..0af68e5c9 100644 --- a/vere/main.c +++ b/vere/main.c @@ -141,15 +141,15 @@ _main_getopt(c3_i argc, c3_c** argv) break; } case 'K': { - u3_Host.ops_u.key_c = strdup(optarg); - break; - } - case 'k': { if ( c3n == _main_readw(optarg, 256, &u3_Host.ops_u.kno_w) ) { return c3n; } break; } + case 'k': { + u3_Host.ops_u.key_c = strdup(optarg); + break; + } case 'l': { if ( c3n == _main_readw(optarg, 65536, &arg_w) ) { return c3n; @@ -248,7 +248,7 @@ _main_getopt(c3_i argc, c3_c** argv) } if ( u3_Host.ops_u.nuu != c3y && u3_Host.ops_u.key_c != 0) { - fprintf(stderr, "-K only makes sense when bootstrapping a new instance\n"); + fprintf(stderr, "-k only makes sense when bootstrapping a new instance\n"); return c3n; } @@ -343,8 +343,8 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-F ship Fake keys; also disables networking\n", "-f Fuzz testing\n", "-g Set GC flag\n", - "-K keys Private key file\n", - "-k stage Start at Hoon kernel version stage\n", + "-K stage Start at Hoon kernel version stage\n", + "-k keys Private key file\n", "-l port Initial peer port\n", "-M Memory madness\n", "-n host Set unix hostname\n", From 9ebeaeb3dc86f3abf7101e20b099c38892806c5c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 29 Oct 2018 11:52:19 -0400 Subject: [PATCH 51/64] requires ethereum gateway (with -e) for non-fake galaxy boot --- vere/main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vere/main.c b/vere/main.c index 0af68e5c9..a50c026c5 100644 --- a/vere/main.c +++ b/vere/main.c @@ -221,6 +221,12 @@ _main_getopt(c3_i argc, c3_c** argv) return c3n; } + if ( (0 == u3_Host.ops_u.fak_c) && (0 == u3_Host.ops_u.eth_c) && imp_t ) { + fprintf(stderr, "can't create a new galaxy without specifying " + "the Ethereum gateway with -e\n"); + return c3n; + } + if ( u3_Host.ops_u.arv_c == 0 && imp_t ) { fprintf(stderr, "can't create a new galaxy without specifying " "the initial sync path with -A\n"); From 770207e18637fdccdaca4e8408d9c1f87eec0b01 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 29 Oct 2018 14:01:45 -0400 Subject: [PATCH 52/64] pins pre-boot validation eth rpc requests to a single block --- vere/sist.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/vere/sist.c b/vere/sist.c index a41f779fe..dd288b2bb 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1283,14 +1283,26 @@ _sist_dawn_fail(u3_noun who, u3_noun rac, u3_noun sas) static u3_noun _sist_dawn(u3_noun sed) { - u3_noun pon, zar, tuf; + u3_noun bok, pon, zar, tuf; u3_noun who = u3h(sed); u3_noun rac = u3do("clan:title", u3k(who)); - c3_t eth_t = ( 0 != u3_Host.ops_u.eth_c ); // XX require https? - c3_c* url_c = eth_t ? u3_Host.ops_u.eth_c : "http://localhost:8545"; + c3_c* url_c = ( 0 != u3_Host.ops_u.eth_c ) ? + u3_Host.ops_u.eth_c : + "http://localhost:8545"; + + { + fprintf(stderr, "boot: retrieving latest block\r\n"); + + // @ud: block number + u3_noun oct = u3v_wish("bloq:give:dawn"); + u3_noun kob = _sist_eth_rpc(url_c, u3k(oct)); + bok = u3do("bloq:take:dawn", u3k(kob)); + + u3z(oct); u3z(kob); + } { // +hull:constitution:ethe: on-chain state @@ -1311,7 +1323,7 @@ _sist_dawn(u3_noun sed) fprintf(stderr, "boot: retrieving %s's public keys (for %s)\r\n", seg_c, u3_Host.ops_u.who_c); - oct = u3do("hull:give:dawn", u3k(seg)); + oct = u3dc("hull:give:dawn", u3k(bok), u3k(seg)); free(seg_c); u3z(seg); u3z(ges); @@ -1319,7 +1331,7 @@ _sist_dawn(u3_noun sed) else { fprintf(stderr, "boot: retrieving %s's public keys\r\n", u3_Host.ops_u.who_c); - oct = u3do("hull:give:dawn", u3k(who)); + oct = u3dc("hull:give:dawn", u3k(bok), u3k(who)); } u3_noun luh = _sist_eth_rpc(url_c, u3k(oct)); @@ -1356,7 +1368,7 @@ _sist_dawn(u3_noun sed) fprintf(stderr, "boot: retrieving galaxy table\r\n"); // (map ship [=life =pass]): galaxy table - u3_noun oct = u3v_wish("czar:give:dawn"); + u3_noun oct = u3do("czar:give:dawn", u3k(bok)); u3_noun raz = _sist_eth_rpc(url_c, u3k(oct)); zar = u3do("czar:take:dawn", u3k(raz)); @@ -1367,7 +1379,7 @@ _sist_dawn(u3_noun sed) fprintf(stderr, "boot: retrieving network domains\r\n"); // (list turf): ames domains - u3_noun oct = u3v_wish("turf:give:dawn"); + u3_noun oct = u3do("turf:give:dawn", u3k(bok)); u3_noun fut = _sist_eth_rpc(url_c, u3k(oct)); tuf = u3do("turf:take:dawn", u3k(fut)); @@ -1375,7 +1387,9 @@ _sist_dawn(u3_noun sed) } u3z(rac); - // XX include ops_u.eth_c if set + + // XX include bok (and parsed eth url) + u3z(bok); // [%dawn seed sponsor galaxies domains] return u3nc(c3__dawn, u3nq(sed, pon, zar, tuf)); From f0efa1ac1211c686cf2da73df0e86b06f91b98df Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 29 Oct 2018 14:58:07 -0400 Subject: [PATCH 53/64] includes block number and ethereum gateway url in boot event --- vere/sist.c | 48 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/vere/sist.c b/vere/sist.c index dd288b2bb..8dff23d63 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1283,7 +1283,7 @@ _sist_dawn_fail(u3_noun who, u3_noun rac, u3_noun sas) static u3_noun _sist_dawn(u3_noun sed) { - u3_noun bok, pon, zar, tuf; + u3_noun url, bok, pon, zar, tuf; u3_noun who = u3h(sed); u3_noun rac = u3do("clan:title", u3k(who)); @@ -1293,6 +1293,43 @@ _sist_dawn(u3_noun sed) u3_Host.ops_u.eth_c : "http://localhost:8545"; + // ethereum gateway as (unit purl) + if ( 0 == u3_Host.ops_u.eth_c ) { + if ( c3__czar == rac ) { + fprintf(stderr, "boot: galaxy requires ethereum gateway via -e\r\n"); + // bails, won't return + u3_lo_bail(); + return u3_none; + } + + url = u3_nul; + } + else { + u3_noun par = u3v_wish("auru:de-purl:html"); + u3_noun lur = u3i_string(u3_Host.ops_u.eth_c); + u3_noun rul = u3dc("rush", u3k(lur), u3k(par)); + + if ( u3_nul == rul ) { + if ( c3__czar == rac ) { + fprintf(stderr, "boot: galaxy requires ethereum gateway via -e\r\n"); + // bails, won't return + u3_lo_bail(); + return u3_none; + } + + url = u3_nul; + } + else { + // auru:de-purl:html parses to (pair user purl) + // we need (unit purl) + // (we're using it to avoid the +hoke weirdness) + // XX revisit upon merging with release-candidate + url = u3nc(u3_nul, u3k(u3t(u3t(rul)))); + } + + u3z(par); u3z(lur); u3z(rul); + } + { fprintf(stderr, "boot: retrieving latest block\r\n"); @@ -1388,11 +1425,8 @@ _sist_dawn(u3_noun sed) u3z(rac); - // XX include bok (and parsed eth url) - u3z(bok); - - // [%dawn seed sponsor galaxies domains] - return u3nc(c3__dawn, u3nq(sed, pon, zar, tuf)); + // [%dawn seed sponsor galaxies domains block eth-url] + return u3nc(c3__dawn, u3nq(sed, pon, zar, u3nt(tuf, bok, url))); } /* _sist_zen(): get OS entropy. @@ -1564,7 +1598,7 @@ u3_sist_boot(void) // initialize ames { - u3_noun tuf = (c3y == u3A->fak) ? u3_nul : u3t(u3t(u3t(u3t(pig)))); + u3_noun tuf = (c3y == u3A->fak) ? u3_nul : u3h(u3t(u3t(u3t(u3t(pig))))); // with a fake event to bring up listeners and configure domains u3_ames_ef_turf(u3k(tuf)); // and real effect to set the output duct From d6b9d6088c290a31a8e44c605c7dfcfafd368fcb Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 29 Oct 2018 21:52:46 -0400 Subject: [PATCH 54/64] sets default pre-boot validation ethereum gateway to ropsten infura --- vere/sist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vere/sist.c b/vere/sist.c index 8dff23d63..291ad8796 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1291,7 +1291,7 @@ _sist_dawn(u3_noun sed) // XX require https? c3_c* url_c = ( 0 != u3_Host.ops_u.eth_c ) ? u3_Host.ops_u.eth_c : - "http://localhost:8545"; + "https://ropsten.infura.io/v3/196a7f37c7d54211b4a07904ec73ad87"; // ethereum gateway as (unit purl) if ( 0 == u3_Host.ops_u.eth_c ) { From 0a7d338553cfb88d72efed69a517640d8c33bd86 Mon Sep 17 00:00:00 2001 From: Joshua Reagan Date: Wed, 31 Oct 2018 14:02:17 -0500 Subject: [PATCH 55/64] Bug fix for metal-wrapping runes A bug causes this cast to go through: ``` ^+(|=(@ 15) ^&(|=(@ 15))) ``` It should nest-fail. This change makes the cast work correctly with the metal wrapping runes `^&`, `^|`, and `^?`. --- jets/f/ut_mint.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/jets/f/ut_mint.c b/jets/f/ut_mint.c index 117c9c0d1..54ff5c466 100644 --- a/jets/f/ut_mint.c +++ b/jets/f/ut_mint.c @@ -533,7 +533,8 @@ { u3_noun ryd = _mint_in(van, sut, gol, p_gen); u3_noun tyf = u3qfu_wrap(van, u3h(ryd), c3__iron); - u3_noun pro = u3nc(tyf, u3k(u3t(ryd))); + u3_noun tyn = _mint_nice(van, gol, tyf); + u3_noun pro = u3nc(tyn, u3k(u3t(ryd))); u3z(ryd); return pro; @@ -545,7 +546,8 @@ { u3_noun ryd = _mint_in(van, sut, gol, p_gen); u3_noun tyf = u3qfu_wrap(van, u3h(ryd), c3__zinc); - u3_noun pro = u3nc(tyf, u3k(u3t(ryd))); + u3_noun tyn = _mint_nice(van, gol, tyf); + u3_noun pro = u3nc(tyn, u3k(u3t(ryd))); u3z(ryd); return pro; @@ -556,7 +558,8 @@ { u3_noun ryd = _mint_in(van, sut, gol, p_gen); u3_noun tyf = u3qfu_wrap(van, u3h(ryd), c3__lead); - u3_noun pro = u3nc(tyf, u3k(u3t(ryd))); + u3_noun tyn = _mint_nice(van, gol, tyf); + u3_noun pro = u3nc(tyn, u3k(u3t(ryd))); u3z(ryd); return pro; From aadd95bf983e5a3d79851829d04891f2be016254 Mon Sep 17 00:00:00 2001 From: Joshua Reagan Date: Wed, 31 Oct 2018 16:40:37 -0500 Subject: [PATCH 56/64] zinc gate casting bug Casting with a `^&` rune example fails because of a minor jet typo: ``` > ^+(^&(|=(@ 15)) |=(@ 15)) -gene.[%ktpd %brts [%base %atom 0] %sand %ud 15] play-open-z ford: %slim failed: ford: %ride failed to compute type: ``` The above cast should go through. This fix makes that happen. --- jets/f/ut_play.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jets/f/ut_play.c b/jets/f/ut_play.c index 8f982c28b..9a300edf4 100644 --- a/jets/f/ut_play.c +++ b/jets/f/ut_play.c @@ -358,7 +358,7 @@ return pro; } - case c3__ktpm: p_gen = u3t(gen); + case c3__ktpd: p_gen = u3t(gen); _play_used(); { u3_noun boc = _play_x(van, sut, p_gen); From 345459e931464abb84dc0be1afeb801bc5b21764 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Wed, 31 Oct 2018 15:19:42 -0700 Subject: [PATCH 57/64] allow booting from ethereum snapshot --- include/vere/vere.h | 2 ++ vere/main.c | 14 +++++++- vere/sist.c | 80 ++++++++++++++++++++++++++++++--------------- 3 files changed, 68 insertions(+), 28 deletions(-) diff --git a/include/vere/vere.h b/include/vere/vere.h index 57a3b346b..dc5912dce 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -592,6 +592,8 @@ c3_o dem; // -d, daemon c3_o dry; // -D, dry compute c3_c* eth_c; // -e, ethereum node url + c3_o etn; // -t, use snapshot exclusively to boot + c3_c* ets_c; // -E, eth snapshot c3_c* fak_c; // -F, fake ship c3_o fog; // -X, skip last event c3_o gab; // -g, run with garbage collector diff --git a/vere/main.c b/vere/main.c index a50c026c5..75dc2c908 100644 --- a/vere/main.c +++ b/vere/main.c @@ -77,6 +77,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.bat = c3n; u3_Host.ops_u.dem = c3n; u3_Host.ops_u.dry = c3n; + u3_Host.ops_u.etn = c3n; u3_Host.ops_u.fog = c3n; u3_Host.ops_u.gab = c3n; u3_Host.ops_u.git = c3n; @@ -91,7 +92,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.veb = c3n; u3_Host.ops_u.kno_w = DefaultKernel; - while ( (ch_i=getopt(argc, argv,"G:B:K:A:w:u:e:f:F:k:l:n:p:r:NabcdgqsvxMPDXRS")) != -1 ) { + while ( (ch_i=getopt(argc, argv,"G:B:K:A:w:u:e:E:f:F:k:l:n:p:r:NabcdgqstvxMPDXRS")) != -1 ) { switch ( ch_i ) { case 'M': { u3_Host.ops_u.mem = c3y; @@ -113,6 +114,10 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.eth_c = strdup(optarg); break; } + case 'E': { + u3_Host.ops_u.ets_c = strdup(optarg); + break; + } case 'F': { u3_Host.ops_u.fak_c = _main_presig(optarg); break; @@ -186,6 +191,7 @@ _main_getopt(c3_i argc, c3_c** argv) case 'v': { u3_Host.ops_u.veb = c3y; break; } case 's': { u3_Host.ops_u.git = c3y; break; } case 'S': { u3_Host.ops_u.has = c3y; break; } + case 't': { u3_Host.ops_u.etn = c3y; break; } case '?': default: { return c3n; } @@ -221,6 +227,12 @@ _main_getopt(c3_i argc, c3_c** argv) return c3n; } + if ( u3_Host.ops_u.ets_c == 0 && c3y == u3_Host.ops_u.etn ) { + fprintf(stderr, "can't trust Ethereum snapshot without specifying " + "snapshot with -E\n"); + return c3n; + } + if ( (0 == u3_Host.ops_u.fak_c) && (0 == u3_Host.ops_u.eth_c) && imp_t ) { fprintf(stderr, "can't create a new galaxy without specifying " "the Ethereum gateway with -e\n"); diff --git a/vere/sist.c b/vere/sist.c index 291ad8796..c260b783d 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1283,15 +1283,20 @@ _sist_dawn_fail(u3_noun who, u3_noun rac, u3_noun sas) static u3_noun _sist_dawn(u3_noun sed) { - u3_noun url, bok, pon, zar, tuf; + u3_noun url, bok, pon, zar, tuf, sap; u3_noun who = u3h(sed); u3_noun rac = u3do("clan:title", u3k(who)); - // XX require https? - c3_c* url_c = ( 0 != u3_Host.ops_u.eth_c ) ? - u3_Host.ops_u.eth_c : - "https://ropsten.infura.io/v3/196a7f37c7d54211b4a07904ec73ad87"; + // load snapshot if exists + if ( 0 != u3_Host.ops_u.ets_c ) { + fprintf(stderr, "boot: loading ethereum snapshot\r\n"); + u3_noun raw_snap = u3ke_cue(u3m_file(u3_Host.ops_u.ets_c)); + sap = u3nc(u3_nul, raw_snap); + } + else { + sap = u3_nul; + } // ethereum gateway as (unit purl) if ( 0 == u3_Host.ops_u.eth_c ) { @@ -1330,22 +1335,35 @@ _sist_dawn(u3_noun sed) u3z(par); u3z(lur); u3z(rul); } + // XX require https? + c3_c* url_c = ( 0 != u3_Host.ops_u.eth_c ) ? + u3_Host.ops_u.eth_c : + "https://ropsten.infura.io/v3/196a7f37c7d54211b4a07904ec73ad87"; + { fprintf(stderr, "boot: retrieving latest block\r\n"); - // @ud: block number - u3_noun oct = u3v_wish("bloq:give:dawn"); - u3_noun kob = _sist_eth_rpc(url_c, u3k(oct)); - bok = u3do("bloq:take:dawn", u3k(kob)); + if ( c3y == u3_Host.ops_u.etn ) { + bok = u3do("bloq:snap:dawn", u3k(u3t(sap))); + } + else { + // @ud: block number + u3_noun oct = u3v_wish("bloq:give:dawn"); + u3_noun kob = _sist_eth_rpc(url_c, u3k(oct)); + bok = u3do("bloq:take:dawn", u3k(kob)); - u3z(oct); u3z(kob); + u3z(oct); u3z(kob); + } } { // +hull:constitution:ethe: on-chain state u3_noun hul; - { + if ( c3y == u3_Host.ops_u.etn ) { + hul = u3dc("hull:snap:dawn", u3k(who), u3k(u3t(sap))); + } + else { if ( c3__pawn == rac ) { // irrelevant, just bunt +hull hul = u3v_wish("*hull:constitution:ethe"); @@ -1402,31 +1420,39 @@ _sist_dawn(u3_noun sed) } { - fprintf(stderr, "boot: retrieving galaxy table\r\n"); + if ( c3y == u3_Host.ops_u.etn ) { + zar = u3do("czar:snap:dawn", u3k(u3t(sap))); + tuf = u3do("turf:snap:dawn", u3k(u3t(sap))); + } + else { + { + fprintf(stderr, "boot: retrieving galaxy table\r\n"); - // (map ship [=life =pass]): galaxy table - u3_noun oct = u3do("czar:give:dawn", u3k(bok)); - u3_noun raz = _sist_eth_rpc(url_c, u3k(oct)); - zar = u3do("czar:take:dawn", u3k(raz)); + // (map ship [=life =pass]): galaxy table + u3_noun oct = u3do("czar:give:dawn", u3k(bok)); + u3_noun raz = _sist_eth_rpc(url_c, u3k(oct)); + zar = u3do("czar:take:dawn", u3k(raz)); - u3z(oct); u3z(raz); - } + u3z(oct); u3z(raz); + } - { - fprintf(stderr, "boot: retrieving network domains\r\n"); + { + fprintf(stderr, "boot: retrieving network domains\r\n"); - // (list turf): ames domains - u3_noun oct = u3do("turf:give:dawn", u3k(bok)); - u3_noun fut = _sist_eth_rpc(url_c, u3k(oct)); - tuf = u3do("turf:take:dawn", u3k(fut)); + // (list turf): ames domains + u3_noun oct = u3do("turf:give:dawn", u3k(bok)); + u3_noun fut = _sist_eth_rpc(url_c, u3k(oct)); + tuf = u3do("turf:take:dawn", u3k(fut)); - u3z(oct); u3z(fut); + u3z(oct); u3z(fut); + } + } } u3z(rac); - // [%dawn seed sponsor galaxies domains block eth-url] - return u3nc(c3__dawn, u3nq(sed, pon, zar, u3nt(tuf, bok, url))); + // [%dawn seed sponsor galaxies domains block eth-url snap] + return u3nc(c3__dawn, u3nq(sed, pon, zar, u3nq(tuf, bok, url, sap))); } /* _sist_zen(): get OS entropy. From 7027f43563b6de0480eab2d489cb97eb96807e3a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 1 Nov 2018 00:43:09 -0400 Subject: [PATCH 58/64] updates fake-zod examples, removing -I --- CONTRIBUTING.md | 5 ++--- vere/main.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 32be479b1..e821af354 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,12 +24,11 @@ path you specify on the command line with the `-A` option. To start a fake `~zod`, the command is: - $ urbit -c -F -I zod -A [arvo checkout] [pier directory] + $ urbit -c -F zod -A [arvo checkout] [pier directory] To resume one that was already created, just as on the live network, remove `-c` and `-A [arvo checkout]` (but leave the rest of the options -there). `-F` uses the fake network, and `-I` starts an "imperial" -instance - that is, an 8-bit galaxy. +there). `-F` uses the fake network. ## Kernel development diff --git a/vere/main.c b/vere/main.c index 75dc2c908..032a2366d 100644 --- a/vere/main.c +++ b/vere/main.c @@ -381,7 +381,7 @@ u3_ve_usage(c3_i argc, c3_c** argv) "\n", "Development Usage:\n", " To create a development ship, use a fakezod:\n", - " %s -FI zod -A /path/to/arvo/folder -B /path/to/pill -c zod\n", + " %s -F zod -A /path/to/arvo/folder -B /path/to/pill -c zod\n", "\n", " For more information about developing on urbit, see:\n", " https://github.com/urbit/urbit/blob/master/CONTRIBUTING.md\n", From f319cd6c8105e5218ca1e433e7da8fc03c0f8814 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 1 Nov 2018 01:18:50 -0400 Subject: [PATCH 59/64] fixes merge conflict resolution in the previous. mea maxima culpa --- vere/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vere/main.c b/vere/main.c index d7ff119e0..17017fe7c 100644 --- a/vere/main.c +++ b/vere/main.c @@ -222,7 +222,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.net = c3y; /* remote networking is always on in real mode. */ } - if ( u3_Host.ops_u.fak == c3y ) { + if ( 0 != u3_Host.ops_u.fak_c ) { u3_Host.ops_u.has = c3y; /* no battery hashing on fake ships. */ } From aa12e760ba33b53ced161141f5c005d3fc4fe1b9 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 1 Nov 2018 15:04:42 -0400 Subject: [PATCH 60/64] fixes profiling of hinted but unjetted arms --- noun/jets.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index 40405b543..810665b56 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -1465,7 +1465,7 @@ _cj_burn(u3p(u3n_prog) pog_p, u3_noun cor) ** (no validity checks). */ static u3_weak -_cj_site_kick_hot(u3_noun loc, u3_noun cor, u3j_site* sit_u) +_cj_site_kick_hot(u3_noun loc, u3_noun cor, u3j_site* sit_u, c3_o lok_o) { u3_weak pro = u3_none; c3_o jet_o = sit_u->jet_o; @@ -1480,7 +1480,9 @@ _cj_site_kick_hot(u3_noun loc, u3_noun cor, u3j_site* sit_u) u3t_on(glu_o); } if ( u3_none == pro ) { - _cj_site_lock(loc, cor, sit_u); + if ( c3y == lok_o ) { + _cj_site_lock(loc, cor, sit_u); + } } } else { @@ -1491,7 +1493,9 @@ _cj_site_kick_hot(u3_noun loc, u3_noun cor, u3j_site* sit_u) u3t_on(glu_o); } if ( u3_none == pro ) { - _cj_site_lock(loc, cor, sit_u); + if ( c3y == lok_o ) { + _cj_site_lock(loc, cor, sit_u); + } pro = _cj_burn(sit_u->pog_p, cor); } if ( c3y == pof_o ) { @@ -1513,9 +1517,7 @@ _cj_site_kick(u3_noun cor, u3j_site* sit_u) if ( u3_none != sit_u->loc ) { if ( c3y == _cj_fine(cor, sit_u->fin_p) ) { loc = sit_u->loc; - if ( c3y == sit_u->jet_o ) { - pro = _cj_site_kick_hot(loc, cor, sit_u); - } + pro = _cj_site_kick_hot(loc, cor, sit_u, c3y); } } @@ -1537,15 +1539,9 @@ _cj_site_kick(u3_noun cor, u3j_site* sit_u) sit_u->loc = loc; sit_u->fin_p = _cj_cast(cor, loc); sit_u->fon_o = c3y; - if ( c3y == - (sit_u->jet_o = _cj_nail(loc, sit_u->axe, - &(sit_u->lab), &(sit_u->cop_u), &(sit_u->ham_u))) ) - { - pro = _cj_site_kick_hot(loc, cor, sit_u); - } - else { - pro = u3_none; - } + sit_u->jet_o = _cj_nail(loc, sit_u->axe, + &(sit_u->lab), &(sit_u->cop_u), &(sit_u->ham_u)); + pro = _cj_site_kick_hot(loc, cor, sit_u, c3y); if ( u3_none != lod ) { u3z(lod); @@ -1674,8 +1670,8 @@ u3j_gate_slam(u3j_site* sit_u, u3_noun sam) cor = u3nt(u3k(u3h(sit_u->bat)), sam, u3k(u3t(u3t(sit_u->bat)))); - if ( (u3_none != sit_u->loc) && (c3y == sit_u->jet_o) ) { - pro = _cj_site_kick_hot(sit_u->loc, cor, sit_u); + if ( u3_none != sit_u->loc ) { + pro = _cj_site_kick_hot(sit_u->loc, cor, sit_u, c3n); } if ( u3_none == pro ) { pro = _cj_burn(sit_u->pog_p, cor); From 63e16f8d64545e273857c0c52348e0240214964f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 1 Nov 2018 16:16:01 -0400 Subject: [PATCH 61/64] removes no-op conditional in _cj_site_kick_hot() --- noun/jets.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index 810665b56..e17cf6006 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -1471,10 +1471,7 @@ _cj_site_kick_hot(u3_noun loc, u3_noun cor, u3j_site* sit_u, c3_o lok_o) c3_o jet_o = sit_u->jet_o; c3_o pof_o = __(u3C.wag_w & u3o_debug_cpu); if ( c3n == pof_o ) { - if ( c3n == jet_o ) { - pro = u3_none; - } - else { + if ( c3y == jet_o ) { u3t_off(glu_o); pro = _cj_kick_z(cor, sit_u->cop_u, sit_u->ham_u, sit_u->axe); u3t_on(glu_o); From 2c30ab9ec7c51dea851f4f1a800200ea5ef5bb85 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 5 Nov 2018 23:14:33 -0500 Subject: [PATCH 62/64] [CI] enable GC and profiling, boot from pill and run tests --- .travis.yml | 20 +- .travis/.gitattributes | 2 + .travis/.gitignore | 1 + .travis/package-lock.json | 753 ++++++++++++++++++++++++++++++++++++ .travis/package.json | 14 + .travis/pin-arvo-commit.txt | 1 + .travis/test.js | 23 ++ 7 files changed, 812 insertions(+), 2 deletions(-) create mode 100644 .travis/.gitattributes create mode 100644 .travis/.gitignore create mode 100644 .travis/package-lock.json create mode 100644 .travis/package.json create mode 100644 .travis/pin-arvo-commit.txt create mode 100644 .travis/test.js diff --git a/.travis.yml b/.travis.yml index 3380299c7..dca4d038d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,15 @@ -language: c -script: meson build && cd ./build && ninja +language: node_js +node_js: +- 4 + +script: + - meson . ./build --buildtype=debugoptimized -Dgc=true -Dprof=true + - cd ./build + - ninja + - sudo ninja install + - cd ../.travis + - npm install + - npm run test # Uncomment me if this gets annoying # @@ -10,8 +20,14 @@ before_install: - wget https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip - unzip ninja-linux.zip - sudo mv ninja /usr/bin/ + install: + # pwd: ~/urbit - pip3 install --user -I meson==0.44.1 + - git clone https://github.com/urbit/arvo + - cd ./arvo + - git checkout $(cat ../.travis/pin-arvo-commit.txt) + - cd .. addons: apt: diff --git a/.travis/.gitattributes b/.travis/.gitattributes new file mode 100644 index 000000000..c1611b63d --- /dev/null +++ b/.travis/.gitattributes @@ -0,0 +1,2 @@ +# Don't show in diffs or auto-merge +package-lock.json binary diff --git a/.travis/.gitignore b/.travis/.gitignore new file mode 100644 index 000000000..c2658d7d1 --- /dev/null +++ b/.travis/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/.travis/package-lock.json b/.travis/package-lock.json new file mode 100644 index 000000000..1330fa852 --- /dev/null +++ b/.travis/package-lock.json @@ -0,0 +1,753 @@ +{ + "name": "vere-tests", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "ajv": { + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", + "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "requires": { + "co": "^4.6.0", + "fast-deep-equal": "^1.0.0", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.3.0" + } + }, + "array-differ": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/array-differ/-/array-differ-1.0.0.tgz", + "integrity": "sha1-7/UuN1gknTO+QCuLuOVkuytdQDE=" + }, + "array-union": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", + "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", + "requires": { + "array-uniq": "^1.0.1" + } + }, + "array-uniq": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", + "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=" + }, + "arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=" + }, + "asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=" + }, + "asn1": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "requires": { + "safer-buffer": "~2.1.0" + } + }, + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" + }, + "aws4": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", + "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "requires": { + "tweetnacl": "^0.14.3" + } + }, + "bluebird": { + "version": "2.11.0", + "resolved": "http://registry.npmjs.org/bluebird/-/bluebird-2.11.0.tgz", + "integrity": "sha1-U0uQM8AiyVecVro7Plpcqvu2UOE=" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" + }, + "colors": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.3.2.tgz", + "integrity": "sha512-rhP0JSBGYvpcNQj4s5AdShMeE5ahMop96cTeDl/v9qQQm2fYClE2QXZRi8wLzc+GmXSxdIqqbOIAhyObEXDbfQ==" + }, + "combined-stream": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", + "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "core-js": { + "version": "2.5.7", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.7.tgz", + "integrity": "sha512-RszJCAxg/PP6uzXVXL6BsxSXx/B05oJAQ2vkJRjyjrEcNVycaqOmNb5OTxZPE3xa5gwZduqza6L9JOCenh/Ecw==" + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "requires": { + "assert-plus": "^1.0.0" + } + }, + "del": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/del/-/del-2.2.2.tgz", + "integrity": "sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag=", + "requires": { + "globby": "^5.0.0", + "is-path-cwd": "^1.0.0", + "is-path-in-cwd": "^1.0.0", + "object-assign": "^4.0.1", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0", + "rimraf": "^2.2.8" + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "ecc-jsbn": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "requires": { + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" + } + }, + "emitter-mixin": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/emitter-mixin/-/emitter-mixin-0.0.3.tgz", + "integrity": "sha1-WUjLKG8uSO3DslGnz8H3iDOW1lw=" + }, + "errno": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz", + "integrity": "sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg==", + "requires": { + "prr": "~1.0.1" + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "extend": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/extend/-/extend-1.2.1.tgz", + "integrity": "sha1-oPX9bPyDpf5J72mNYOyKYk3UV2w=" + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" + }, + "fast-deep-equal": { + "version": "1.1.0", + "resolved": "http://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", + "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=" + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" + }, + "form-data": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "requires": { + "assert-plus": "^1.0.0" + } + }, + "glob": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "globby": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz", + "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=", + "requires": { + "array-union": "^1.0.1", + "arrify": "^1.0.0", + "glob": "^7.0.3", + "object-assign": "^4.0.1", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" + } + }, + "graceful-fs": { + "version": "4.1.15", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", + "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==" + }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" + }, + "har-validator": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.0.tgz", + "integrity": "sha512-+qnmNjI4OfH2ipQ9VQOw23bBd/ibtfbVdK2fYbY4acTDqKTW/YDp9McimZdDbG8iV9fZizUqQMD5xvriB146TA==", + "requires": { + "ajv": "^5.3.0", + "har-schema": "^2.0.0" + } + }, + "hoek": { + "version": "4.2.1", + "resolved": "http://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==" + }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "requires": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "is-path-cwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", + "integrity": "sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0=" + }, + "is-path-in-cwd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-1.0.1.tgz", + "integrity": "sha512-FjV1RTW48E7CWM7eE/J2NJvAEEVektecDBVBE5Hh3nM1Jd0kvhHtX68Pr3xsDf857xt3Y4AkwVULK1Vku62aaQ==", + "requires": { + "is-path-inside": "^1.0.0" + } + }, + "is-path-inside": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz", + "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", + "requires": { + "path-is-inside": "^1.0.1" + } + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" + }, + "isemail": { + "version": "2.2.1", + "resolved": "http://registry.npmjs.org/isemail/-/isemail-2.2.1.tgz", + "integrity": "sha1-A1PT2aYpUQgMJiwqoKQrjqjp4qY=" + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" + }, + "items": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/items/-/items-2.1.1.tgz", + "integrity": "sha1-i9FtnIOxlSneWuoyGsqtp4NkoZg=" + }, + "joi": { + "version": "9.2.0", + "resolved": "http://registry.npmjs.org/joi/-/joi-9.2.0.tgz", + "integrity": "sha1-M4WseQGSEwy+Iw6ALsAskhW7/to=", + "requires": { + "hoek": "4.x.x", + "isemail": "2.x.x", + "items": "2.x.x", + "moment": "2.x.x", + "topo": "2.x.x" + } + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" + }, + "json-schema-traverse": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", + "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + } + }, + "junk": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/junk/-/junk-1.0.3.tgz", + "integrity": "sha1-h75jSIZJy9ym9Tqzm+yczSNH9ZI=" + }, + "maximatch": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/maximatch/-/maximatch-0.1.0.tgz", + "integrity": "sha1-hs2NawTJ8wfAWmuUGZBtA2D7E6I=", + "requires": { + "array-differ": "^1.0.0", + "array-union": "^1.0.1", + "arrify": "^1.0.0", + "minimatch": "^3.0.0" + } + }, + "mime-db": { + "version": "1.37.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz", + "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==" + }, + "mime-types": { + "version": "2.1.21", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz", + "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==", + "requires": { + "mime-db": "~1.37.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "moment": { + "version": "2.22.2", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.22.2.tgz", + "integrity": "sha1-PCV/mDn8DpP/UxSWMiOeuQeD/2Y=" + }, + "nan": { + "version": "2.3.5", + "resolved": "http://registry.npmjs.org/nan/-/nan-2.3.5.tgz", + "integrity": "sha1-gioNwmYpDOTNOhIoLKPn42Rmigg=" + }, + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=" + }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" + }, + "pify": { + "version": "2.3.0", + "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=" + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "requires": { + "pinkie": "^2.0.0" + } + }, + "promise": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", + "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", + "requires": { + "asap": "~2.0.3" + } + }, + "promise-streams": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/promise-streams/-/promise-streams-2.1.1.tgz", + "integrity": "sha1-cwnx02mDMOp/rasZIvE5iSKayFo=", + "requires": { + "bluebird": "^2.10.2" + } + }, + "prr": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", + "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=" + }, + "psl": { + "version": "1.1.29", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.29.tgz", + "integrity": "sha512-AeUmQ0oLN02flVHXWh9sSJF7mcdFq0ppid/JkErufc3hGIV/AMa8Fo9VgDo/cT2jFdOWoFvHp90qqBH54W+gjQ==" + }, + "pty.js": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/pty.js/-/pty.js-0.3.1.tgz", + "integrity": "sha1-gfW+0zLW5eeraFaI0boDc0ENUbU=", + "requires": { + "extend": "~1.2.1", + "nan": "2.3.5" + } + }, + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + }, + "recursive-copy": { + "version": "2.0.9", + "resolved": "https://registry.npmjs.org/recursive-copy/-/recursive-copy-2.0.9.tgz", + "integrity": "sha512-0AkHV+QtfS/1jW01z3m2t/TRTW56Fpc+xYbsoa/bqn8BCYPwmsaNjlYmUU/dyGg9w8MmGoUWihU5W+s+qjxvBQ==", + "requires": { + "del": "^2.2.0", + "emitter-mixin": "0.0.3", + "errno": "^0.1.2", + "graceful-fs": "^4.1.4", + "junk": "^1.0.1", + "maximatch": "^0.1.0", + "mkdirp": "^0.5.1", + "pify": "^2.3.0", + "promise": "^7.0.1", + "slash": "^1.0.0" + } + }, + "request": { + "version": "2.88.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", + "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.0", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.4.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + }, + "dependencies": { + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + } + } + }, + "rimraf": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "requires": { + "glob": "^7.0.5" + } + }, + "rx": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/rx/-/rx-4.1.0.tgz", + "integrity": "sha1-pfE/957zt0D+MKqAP7CfmIBdR4I=" + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "slash": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz", + "integrity": "sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=" + }, + "split": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", + "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", + "requires": { + "through": "2" + } + }, + "sshpk": { + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.15.2.tgz", + "integrity": "sha512-Ra/OXQtuh0/enyl4ETZAfTaeksa6BXks5ZcjpSUNrjBr0DvrJKX+1fsKDPpT9TBXgHAFsa4510aNVgI8g/+SzA==", + "requires": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + } + }, + "stream-snitch": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/stream-snitch/-/stream-snitch-0.0.3.tgz", + "integrity": "sha1-iXp48TonFPqESqd74VR3qJbYUqk=" + }, + "through": { + "version": "2.3.8", + "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" + }, + "topo": { + "version": "2.0.2", + "resolved": "http://registry.npmjs.org/topo/-/topo-2.0.2.tgz", + "integrity": "sha1-zVYVdSU5BXwNwEkaYhw7xvvh0YI=", + "requires": { + "hoek": "4.x.x" + } + }, + "tough-cookie": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", + "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "requires": { + "psl": "^1.1.24", + "punycode": "^1.4.1" + } + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" + }, + "urbit-runner": { + "version": "github:urbit/runner-js#ee2455015dc4ea243d0e0ec623975632c9249c4e", + "from": "github:urbit/runner-js#ee24550", + "requires": { + "colors": "^1.1.2", + "escape-string-regexp": "^1.0.5", + "once": "^1.4.0", + "promise-streams": "^2.1.1", + "pty.js": "^0.3.1", + "recursive-copy": "^2.0.7", + "split": "^1.0.1", + "stream-snitch": "0.0.3", + "wait-on": "^2.0.2" + } + }, + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" + }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "requires": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + } + }, + "wait-on": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/wait-on/-/wait-on-2.1.2.tgz", + "integrity": "sha512-Jm6pzZkbswtcRUXohxY1Ek5MrL16AwHj83drgW2FTQuglHuhZhVMyBLPIYG0rL1wvr5rdC1uzRuU/7Bc+B9Pwg==", + "requires": { + "core-js": "^2.4.1", + "joi": "^9.2.0", + "minimist": "^1.2.0", + "request": "^2.78.0", + "rx": "^4.1.0" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + } + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + } + } +} diff --git a/.travis/package.json b/.travis/package.json new file mode 100644 index 000000000..a5e7e46f0 --- /dev/null +++ b/.travis/package.json @@ -0,0 +1,14 @@ +{ + "name": "vere-tests", + "version": "1.0.0", + "description": "Test harness for the Urbit runtime", + "scripts": { + "test": "node test.js" + }, + "private": true, + "author": "~fyr", + "license": "MIT", + "dependencies": { + "urbit-runner": "github:urbit/runner-js#ee24550" + } +} diff --git a/.travis/pin-arvo-commit.txt b/.travis/pin-arvo-commit.txt new file mode 100644 index 000000000..0f6ede735 --- /dev/null +++ b/.travis/pin-arvo-commit.txt @@ -0,0 +1 @@ +6deeb7dee9f3d47e4458fac3a0518dcde429ef73 \ No newline at end of file diff --git a/.travis/test.js b/.travis/test.js new file mode 100644 index 000000000..8d7287717 --- /dev/null +++ b/.travis/test.js @@ -0,0 +1,23 @@ +'use strict'; + +var runner = require('urbit-runner') +var Urbit = runner.Urbit; +var ERROR = runner.ERROR; +var actions = runner.actions + +var args = ['-A', '../arvo', '-csgPSF', 'zod', 'zod']; +var urbit = new Urbit(args); + +Promise.resolve(urbit) +.then(actions.safeBoot) +.then(actions.test) +.then(function(){ + return urbit.exit(0); +}) +.catch(function(err){ + return urbit.waitSilent() + .then(function(){ + urbit.warn("Test aborted:", err); + return urbit.exit(1); + }); +}); From a356a8306637dafac194590cf3764aceaae2f6df Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 6 Nov 2018 00:16:26 -0500 Subject: [PATCH 63/64] [CI] print backtrace on bail --- .travis.yml | 8 +++++++- .travis/test.js | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index dca4d038d..cc27f8f22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,13 @@ script: - ninja - sudo ninja install - cd ../.travis + - ulimit -c unlimited -S - npm install - - npm run test + # || true so we continue + - npm run -s test || RESULT=$? + - if [[ ${RESULT} -eq 0 ]]; then exit 0; else for i in $(find ./ -maxdepth 1 -name 'core*' -print); do gdb urbit core* -ex "thread apply all bt" -ex "set pagination 0" -batch; done; fi; + - echo "build failed with status code $RESULT" + - exit $RESULT # Uncomment me if this gets annoying # @@ -47,6 +52,7 @@ addons: - re2c - libcurl4-gnutls-dev - unzip + - gdb # before_deploy: "make deb" # TODO deploy: skip_cleanup: true diff --git a/.travis/test.js b/.travis/test.js index 8d7287717..e957ac7b8 100644 --- a/.travis/test.js +++ b/.travis/test.js @@ -17,7 +17,8 @@ Promise.resolve(urbit) .catch(function(err){ return urbit.waitSilent() .then(function(){ - urbit.warn("Test aborted:", err); - return urbit.exit(1); + urbit.warn("Arvo test aborted:", err); + // we still exit 0, it's not our fault ... + return urbit.exit(0); }); }); From 21233db91ef2f7fc9f5008cce2347b7c144c87a1 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 6 Nov 2018 02:27:56 -0500 Subject: [PATCH 64/64] [CI] sends ctrl-z to work around profiling output hang --- .travis/test.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/.travis/test.js b/.travis/test.js index e957ac7b8..4afc09417 100644 --- a/.travis/test.js +++ b/.travis/test.js @@ -8,17 +8,28 @@ var actions = runner.actions var args = ['-A', '../arvo', '-csgPSF', 'zod', 'zod']; var urbit = new Urbit(args); +// vere hangs (always?) with run in travis-ci with -P +// so we send ^Z if we hang for ~s30 +function exit() { + setTimeout(function(){ + urbit.pty.write('\x1a'); + urbit.pty.on('exit', function(code, signal){ + process.exit(0); + }) + }, 30 * 1000); + + return urbit.exit(0); +} + Promise.resolve(urbit) .then(actions.safeBoot) .then(actions.test) -.then(function(){ - return urbit.exit(0); -}) +.then(exit) .catch(function(err){ + // we still exit 0, Arvo errors are not our fault ... return urbit.waitSilent() .then(function(){ - urbit.warn("Arvo test aborted:", err); - // we still exit 0, it's not our fault ... - return urbit.exit(0); - }); + return urbit.warn("Arvo test aborted:", err); + }) + .then(exit); });