Merge pull request #965 from urbit/murmug

switch +mug hash from FNV to Murmur3
This commit is contained in:
Joe Bryan 2019-01-09 01:47:49 -05:00 committed by GitHub
commit 177a48e2d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 152 additions and 120 deletions

View File

@ -1 +1 @@
https://ci-piers.urbit.org/zod-3a7fea5537efe2ccbbb43257478677e5688e6acb.tgz
https://ci-piers.urbit.org/zod-5294dec6408f8952d1a8e363362bbb58058852b6.tgz

View File

@ -1 +1 @@
4d7a04d4d9db334fb34558a7537a741d17319ce9
8807423b01e586579946209828bb1bfa3d6d1c5e

View File

@ -68,6 +68,16 @@ function rePill(urb) {
}
Promise.resolve(urbit)
// XX temporary
// send ctrl-x to select dojo
//
.then(function(){
return urbit.expect(/talk\[\] /)
.then(function() {
return urbit.pty.write("\x18")
})
.then(function() { return urbit })
})
.then(actions.safeBoot)
.then(actions.test)
.then(actions.testCores)

View File

@ -42,7 +42,7 @@
tan+(flop (turn a message))
::
++ adrs
=- (sort - lor)
=- (sort - |=([a=[=time *] b=[=time *]] (lth time.a time.b)))
%+ turn ~(tap by adr)
|=({a/email b/time c/invited} [tym=b ask=a inv=c])
::

View File

@ -565,11 +565,11 @@
:: larval Arvo structural interface
::
|%
++ come ^come :: 22
++ load ^load :: 46
++ peek |=(* ~) :: 47
++ come ^come :: 4
++ load ^load :: 10
++ peek |=(* ~) :: 46
::
++ poke |= * :: 10
++ poke |= * :: 47
^- [(list ovum) *]
=> .(+< ((hard ,[now=@da ovo=ovum]) +<))
^- [(list ovum) *]
@ -614,7 +614,7 @@
(turn vanes.^poke |=([label=@tas =vane] [label vase.vane]))
(load u.who now u.eny ova=~ u.bod nyf)
::
++ wish |= txt=* :: 4
++ wish |= txt=* :: 22
?> ?=(@ txt)
q:(slap ?~(bod pit u.bod) (ream txt))
--
@ -632,21 +632,21 @@
=< :: Arvo structural interface
::
|%
++ come |= {@ @ @ (list ovum) vise pone} :: 22
++ come |= {@ @ @ (list ovum) vise pone} :: 4
^- {(list ovum) _+>}
~& %hoon-come
=^ rey +>+ (^come +<)
[rey +>.$]
::
++ load |= {@ @ @ (list ovum) vase pane} :: 46
++ load |= {@ @ @ (list ovum) vase pane} :: 10
^- {(list ovum) _+>}
~& %hoon-load
=^ rey +>+ (^load +<)
[rey +>.$]
::
++ peek |=(* (^peek ((hard {@da path}) +<))) :: 47
++ peek |=(* (^peek ((hard {@da path}) +<))) :: 46
::
++ poke |= * :: 10
++ poke |= * :: 47
^- [(list ovum) *]
=> .(+< ((hard ,[now=@da ovo=ovum]) +<))
=^ ova +>+.$ (^poke now ovo)
@ -668,7 +668,7 @@
=/ avo $(ova t.ova)
[[+.vov -.avo] +.avo]
::
++ wish |=(* (^wish ((hard @ta) +<))) :: 4
++ wish |=(* (^wish ((hard @ta) +<))) :: 22
--
:: Arvo implementation core
::

View File

@ -1052,8 +1052,6 @@
:::: 2e: insecure hashing ::
:: ::
::
++ fnv |=(a/@ (end 5 1 (mul 16.777.619 a))) :: FNV scrambler
::
++ muk :: standard murmur3
~% %muk ..muk ~
=+ ~(. fe 5)
@ -1111,9 +1109,9 @@
=. h (mix h (rsh 0 16 h))
h
--
::
++ mum :: mug with murmur3
~/ %mum
::
++ mug :: mug with murmur3
~/ %mug
|= a/*
|^ (trim ?@(a a (mix $(a -.a) (mix 0x7fff.ffff $(a +.a)))))
++ trim :: 31-bit nonzero
@ -1124,33 +1122,16 @@
=+ ham=(mix (rsh 0 31 haz) (end 0 31 haz))
?.(=(0 ham) ham $(syd +(syd)))
--
::
++ mug :: 31bit nonzero FNV1a
~/ %mug
|= a/*
?^ a
=+ b=[p=$(a -.a) q=$(a +.a)]
|- ^- @
=+ c=(fnv (mix p.b (fnv q.b)))
=+ d=(mix (rsh 0 31 c) (end 0 31 c))
?. =(0 d) d
$(q.b +(q.b))
=+ b=2.166.136.261
|- ^- @
=+ c=b
=+ [d=0 e=(met 3 a)]
|- ^- @
?: =(d e)
=+ f=(mix (rsh 0 31 c) (end 0 31 c))
?. =(0 f) f
^$(b +(b))
$(c (fnv (mix c (cut 3 [d 1] a))), d +(d))
:: ::
:::: 2f: noun ordering ::
:: ::
:: aor, dor, gor, hor, lor, vor ::
:: aor, dor, gor, mor ::
::
++ aor :: a-order
:: +aor: alphabetical order
::
:: Orders atoms before cells, and atoms in ascending LSB order.
::
++ aor
~/ %aor
|= {a/* b/*}
^- ?
@ -1166,8 +1147,11 @@
?: =(c d)
$(a (rsh 3 1 a), b (rsh 3 1 b))
(lth c d)
:: +dor: depth order
::
++ dor :: d-order
:: Orders in ascending tree depth.
::
++ dor
~/ %dor
|= {a/* b/*}
^- ?
@ -1179,8 +1163,11 @@
$(a -.a, b -.b)
?. ?=(@ b) &
(lth a b)
:: +gor: mug order
::
++ gor :: g-order
:: Orders in ascending +mug hash order, collisions fall back to +dor.
::
++ gor
~/ %gor
|= {a/* b/*}
^- ?
@ -1188,33 +1175,12 @@
?: =(c d)
(dor a b)
(lth c d)
:: +mor: (more) mug order
::
++ hor :: h-order
~/ %hor
|= {a/* b/*}
^- ?
?: ?=(@ a)
?. ?=(@ b) &
(gor a b)
?: ?=(@ b) |
?: =(-.a -.b)
(gor +.a +.b)
(gor -.a -.b)
:: Orders in ascending double +mug hash order, collisions fall back to +dor.
::
++ lor :: l-order
~/ %lor
|= {a/* b/*}
^- ?
?: =(a b) &
?@ a
?^ b &
(lth a b)
?: =(-.a -.b)
$(a +.a, b +.b)
$(a -.a, b -.b)
::
++ vor :: v-order
~/ %vor
++ mor
~/ %mor
|= {a/* b/*}
^- ?
=+ [c=(mug (mug a)) d=(mug (mug b))]
@ -1279,10 +1245,10 @@
=| {l/(unit) r/(unit)}
|- ^- ?
?~ a &
?& ?~(l & (hor n.a u.l))
?~(r & (hor u.r n.a))
?~(l.a & ?&((vor n.a n.l.a) $(a l.a, l `n.a)))
?~(r.a & ?&((vor n.a n.r.a) $(a r.a, r `n.a)))
?& ?~(l & (gor n.a u.l))
?~(r & (gor u.r n.a))
?~(l.a & ?&((mor n.a n.l.a) $(a l.a, l `n.a)))
?~(r.a & ?&((mor n.a n.r.a) $(a r.a, r `n.a)))
==
::
++ bif :: splits a by b
@ -1295,7 +1261,7 @@
[b ~ ~]
?: =(b n.a)
a
?: (hor b n.a)
?: (gor b n.a)
=+ c=$(a l.a)
?> ?=(^ c)
[n.c l.c [n.a r.c r.a]]
@ -1310,13 +1276,13 @@
?~ a
~
?. =(b n.a)
?: (hor b n.a)
?: (gor b n.a)
[n.a $(a l.a) r.a]
[n.a l.a $(a r.a)]
|- ^- {$?(~ _a)}
?~ l.a r.a
?~ r.a l.a
?: (vor n.l.a n.r.a)
?: (mor n.l.a n.r.a)
[n.l.a l.l.a $(l.a r.l.a)]
[n.r.a $(r.a l.r.a) r.r.a]
::
@ -1335,7 +1301,7 @@
|- ^- {$?(~ _a)}
?~ d e
?~ e d
?: (vor n.d n.e)
?: (mor n.d n.e)
[n.d l.d $(d r.d)]
[n.e $(e l.e) r.e]
--
@ -1346,7 +1312,7 @@
|- ^- (unit @)
?~ a ~
?: =(b n.a) [~ u=(peg c 2)]
?: (hor b n.a)
?: (gor b n.a)
$(a l.a, c (peg c 6))
$(a r.a, c (peg c 7))
::
@ -1366,7 +1332,7 @@
|
?: =(b n.a)
&
?: (hor b n.a)
?: (gor b n.a)
$(a l.a)
$(a r.a)
::
@ -1380,11 +1346,11 @@
~
?~ a
~
?. (vor n.a n.b)
?. (mor n.a n.b)
$(a b, b a)
?: =(n.b n.a)
[n.a $(a l.a, b l.b) $(a r.a, b r.b)]
?: (hor n.b n.a)
?: (gor n.b n.a)
%- uni(a $(a l.a, b [n.b l.b ~])) $(b r.b)
%- uni(a $(a r.a, b [n.b ~ r.b])) $(b l.b)
--
@ -1397,15 +1363,15 @@
[b ~ ~]
?: =(b n.a)
a
?: (hor b n.a)
?: (gor b n.a)
=+ c=$(a l.a)
?> ?=(^ c)
?: (vor n.a n.c)
?: (mor n.a n.c)
[n.a c r.a]
[n.c l.c [n.a r.c r.a]]
=+ c=$(a r.a)
?> ?=(^ c)
?: (vor n.a n.c)
?: (mor n.a n.c)
[n.a l.a c]
[n.c [n.a l.a l.c] r.c]
::
@ -1444,15 +1410,15 @@
a
?~ a
b
?: (vor n.a n.b)
?: (mor n.a n.b)
?: =(n.b n.a)
[n.b $(a l.a, b l.b) $(a r.a, b r.b)]
?: (hor n.b n.a)
?: (gor n.b n.a)
$(a [n.a $(a l.a, b [n.b l.b ~]) r.a], b r.b)
$(a [n.a l.a $(a r.a, b [n.b ~ r.b])], b l.b)
?: =(n.a n.b)
[n.b $(b l.b, a l.a) $(b r.b, a r.a)]
?: (hor n.a n.b)
?: (gor n.a n.b)
$(b [n.b $(b l.b, a [n.a l.a ~]) r.b], a r.a)
$(b [n.b l.b $(b r.b, a [n.a ~ r.a])], a l.a)
--
@ -1521,7 +1487,7 @@
|- ^- {$?(~ _a)}
?~ l.a r.a
?~ r.a l.a
?: (vor p.n.l.a p.n.r.a)
?: (mor p.n.l.a p.n.r.a)
[n.l.a l.l.a $(l.a r.l.a)]
[n.r.a $(r.a l.r.a) r.r.a]
::
@ -1540,7 +1506,7 @@
|- ^- {$?(~ _a)}
?~ d e
?~ e d
?: (vor p.n.d p.n.e)
?: (mor p.n.d p.n.e)
[n.d l.d $(d r.d)]
[n.e $(e l.e) r.e]
--
@ -1561,8 +1527,8 @@
?~ a &
?& ?~(l & (gor p.n.a u.l))
?~(r & (gor u.r p.n.a))
?~(l.a & ?&((vor p.n.a p.n.l.a) $(a l.a, l `p.n.a)))
?~(r.a & ?&((vor p.n.a p.n.r.a) $(a r.a, r `p.n.a)))
?~(l.a & ?&((mor p.n.a p.n.l.a) $(a l.a, l `p.n.a)))
?~(r.a & ?&((mor p.n.a p.n.r.a) $(a r.a, r `p.n.a)))
==
::
++ gas :: concatenate
@ -1606,7 +1572,7 @@
~
?~ a
~
?: (vor p.n.a p.n.b)
?: (mor p.n.a p.n.b)
?: =(p.n.b p.n.a)
[n.b $(a l.a, b l.b) $(a r.a, b r.b)]
?: (gor p.n.b p.n.a)
@ -1653,12 +1619,12 @@
?: (gor b p.n.a)
=+ d=$(a l.a)
?> ?=(^ d)
?: (vor p.n.a p.n.d)
?: (mor p.n.a p.n.d)
[n.a d r.a]
[n.d l.d [n.a r.d r.a]]
=+ d=$(a r.a)
?> ?=(^ d)
?: (vor p.n.a p.n.d)
?: (mor p.n.a p.n.d)
[n.a l.a d]
[n.d [n.a l.a l.d] r.d]
::
@ -1709,7 +1675,7 @@
a
?~ a
b
?: (vor p.n.a p.n.b)
?: (mor p.n.a p.n.b)
?: =(p.n.b p.n.a)
[n.b $(a l.a, b l.b) $(a r.a, b r.b)]
?: (gor p.n.b p.n.a)
@ -1732,7 +1698,7 @@
a
?~ a
b
?: (vor p.n.a p.n.b)
?: (mor p.n.a p.n.b)
?: =(p.n.b p.n.a)
[n.b $(a l.a, b l.b) $(a r.a, b r.b)]
?: (gor p.n.b p.n.a)
@ -1833,9 +1799,9 @@
++ bal
|- ^+ a
?~ a ~
?. |(?=(~ l.a) (vor n.a n.l.a))
?. |(?=(~ l.a) (mor n.a n.l.a))
$(a [n.l.a l.l.a $(a [n.a r.l.a r.a])])
?. |(?=(~ r.a) (vor n.a n.r.a))
?. |(?=(~ r.a) (mor n.a n.r.a))
$(a [n.r.a $(a [n.a l.a l.r.a]) r.r.a])
a
::
@ -1857,7 +1823,7 @@
[n.a l.a]
=+ b=$(a r.a)
:- p.b
?: |(?=(~ q.b) (vor n.a n.q.b))
?: |(?=(~ q.b) (mor n.a n.q.b))
[n.a l.a q.b]
[n.q.b [n.a l.a l.q.b] r.q.b]
::
@ -1866,7 +1832,7 @@
?~ a ~
?~ l.a r.a
?~ r.a l.a
?: (vor n.l.a n.r.a)
?: (mor n.l.a n.r.a)
[n.l.a l.l.a $(l.a r.l.a)]
[n.r.a $(r.a l.r.a) r.r.a]
::
@ -5163,12 +5129,12 @@
?: (wor p.i.leh p.n.yal)
=+ nuc=$(yal l.yal)
?> ?=(^ nuc)
?: (vor p.n.yal p.n.nuc)
?: (mor p.n.yal p.n.nuc)
[n.yal nuc r.yal]
[n.nuc l.nuc [n.yal r.nuc r.yal]]
=+ nuc=$(yal r.yal)
?> ?=(^ nuc)
?: (vor p.n.yal p.n.nuc)
?: (mor p.n.yal p.n.nuc)
[n.yal l.yal nuc]
[n.nuc [n.yal l.yal l.nuc] r.nuc]
~% %fun ..^$ ~

View File

@ -157,10 +157,10 @@
?~(top & (lth +(q.n.a) u.top))
?~(bot & (gth p.n.a +(u.bot)))
::
?~(l.a & (vor p.n.a p.n.l.a))
?~(l.a & (mor p.n.a p.n.l.a))
$(a l.a, top `p.n.a)
::
?~(l.a & (vor p.n.a p.n.l.a))
?~(l.a & (mor p.n.a p.n.l.a))
$(a r.a, bot `q.n.a)
==
:: :: ++int:py
@ -168,7 +168,7 @@
|= b/pile ^- pile
?~ a ~
?~ b ~
?. (vor p.n.a p.n.b) $(a b, b a)
?. (mor p.n.a p.n.b) $(a b, b a)
?: (gth p.n.a q.n.b)
(uni(a $(b r.b)) $(a l.a, r.b ~))
?: (lth q.n.a p.n.b)
@ -218,7 +218,7 @@
^- pile
?~ b a
?~ a b
?. (vor p.n.a p.n.b) $(a b, b a)
?. (mor p.n.a p.n.b) $(a b, b a)
?: (lth +(q.n.b) p.n.a)
$(b r.b, l.a $(a l.a, r.b ~))
?: (lth +(q.n.a) p.n.b)
@ -402,7 +402,7 @@
:: ::::
++ up
:: a set of rites is stored as a tree (++safe), sorted
:: by ++gor on the stem, balanced by ++vor on the stem.
:: by ++gor on the stem, balanced by ++mor on the stem.
:: (this is essentially a ++map with stem as key, but
:: ++map doesn't know how to link stem and bulb types.)
:: the goal of the design is to make it easy to add new
@ -436,7 +436,7 @@
|- ^- safe
?~ l.pig r.pig
?~ r.pig l.pig
?: (vor -.n.l.pig -.n.r.pig)
?: (mor -.n.l.pig -.n.r.pig)
[n.l.pig l.l.pig $(l.pig r.l.pig)]
[n.r.pig $(r.pig l.r.pig) r.r.pig]
:: :: ++differ:up
@ -472,12 +472,12 @@
?: (gor -.ryt -.n.pig)
=. l.pig $(pig l.pig)
?> ?=(^ l.pig)
?: (vor -.n.pig -.n.l.pig)
?: (mor -.n.pig -.n.l.pig)
[n.pig l.pig r.pig]
[n.l.pig l.l.pig [n.pig r.l.pig r.pig]]
=. r.pig $(pig r.pig)
?> ?=(^ r.pig)
?: (vor -.n.pig -.n.r.pig)
?: (mor -.n.pig -.n.r.pig)
[n.pig l.pig r.pig]
[n.r.pig [n.pig l.pig l.r.pig] r.r.pig]
:: :: ++intern:up

View File

@ -0,0 +1,56 @@
/+ *test
|%
++ test-muk
;: weld
%+ expect-eq
!> 0xfaf6.cdb3
!> (muk 1.234 13 'Hello, world!')
::
%+ expect-eq
!> 0xbf50.5788
!> (muk 4.321 13 'Hello, world!')
::
%+ expect-eq
!> 0xf2c.c00b
!> (muk 1.234 0 0)
::
%+ expect-eq
!> 0x8905.ac28
!> (muk 1.234 28 (crip (reap 28 'x')))
::
%+ expect-eq
!> 0x566f.7173
!> (muk 0xcafe.babe 16 (dec (bex 128)))
==
::
++ test-mug
;: weld
%+ expect-eq
!> 0x4d44.1035
!> (mug 'Hello, world!')
::
%+ expect-eq
!> 0x79ff.04e8
!> (mug 0)
::
%+ expect-eq
!> 0x64df.da5c
!> (mug (crip (reap 28 'x')))
::
%+ expect-eq
!> 0x389c.a03a
!> (mug [0 0])
::
%+ expect-eq
!> 0x389c.a03a
!> (mug [1 1])
::
%+ expect-eq
!> 0x5258.a6c0
!> (mug [0 (bex 32)])
::
%+ expect-eq
!> 0x2ad3.9968
!> (mug [(dec (bex 128)) 1])
==
--

View File

@ -764,10 +764,10 @@
==
::
^= moves
:~ :* duct=~[/one] %give %made ~1234.5.6 %complete %success
:~ :* duct=~[/two] %give %made ~1234.5.7 %complete %success
[%scry %noun !>(42)]
==
:* duct=~[/two] %give %made ~1234.5.7 %complete %success
:* duct=~[/one] %give %made ~1234.5.6 %complete %success
[%scry %noun !>(42)]
== == ==
::

View File

@ -51,7 +51,7 @@
++ test-give-bloq
=/ oct
%- as-octs:mimes:html
'{"jsonrpc":"2.0","id":"0","method":"eth_blockNumber","params":[]}'
'{"params":[],"id":"0","jsonrpc":"2.0","method":"eth_blockNumber"}'
%+ expect-eq
!> oct
!> bloq:give:dawn
@ -68,10 +68,10 @@
=/ oct
%- as-octs:mimes:html
%+ rap 3
:~ '{"jsonrpc":"2.0","id":"0","method":"eth_call","params":[{"data":"'
:~ '{"params":[{"to":"' azimuth '","data":"'
'0x63fa9a87'
'0000000000000000000000000000000000000000000000000000000000000000'
'","to":"' azimuth '"},"0x0"]}'
'"},"0x0"],"id":"0","jsonrpc":"2.0","method":"eth_call"}'
==
%+ expect-eq
!> oct
@ -81,18 +81,18 @@
=/ oct
%- as-octs:mimes:html
%+ rap 3
:~ '[{"jsonrpc":"2.0","id":"turf-0","method":"eth_call","params":[{"data":"'
:~ '[{"params":[{"to":"' azimuth '","data":"'
'0xeccc8ff1'
'0000000000000000000000000000000000000000000000000000000000000000'
'","to":"' azimuth '"},"0x0"]},'
'{"jsonrpc":"2.0","id":"turf-1","method":"eth_call","params":[{"data":"'
'"},"0x0"],"id":"turf-0","jsonrpc":"2.0","method":"eth_call"},'
'{"params":[{"to":"' azimuth '","data":"'
'0xeccc8ff1'
'0000000000000000000000000000000000000000000000000000000000000001'
'","to":"' azimuth '"},"0x0"]},'
'{"jsonrpc":"2.0","id":"turf-2","method":"eth_call","params":[{"data":"'
'"},"0x0"],"id":"turf-1","jsonrpc":"2.0","method":"eth_call"},'
'{"params":[{"to":"' azimuth '","data":"'
'0xeccc8ff1'
'0000000000000000000000000000000000000000000000000000000000000002'
'","to":"' azimuth '"},"0x0"]}]'
'"},"0x0"],"id":"turf-2","jsonrpc":"2.0","method":"eth_call"}]'
==
%+ expect-eq
!> oct