mirror of
https://github.com/urbit/shrub.git
synced 2024-12-14 20:02:51 +03:00
Merge pull request #872 from urbit/philip/ames-eth-keys
Allow booting from ethereum snapshot
This commit is contained in:
commit
369ccc41dd
@ -77,6 +77,7 @@
|
||||
turf=(list turf) :: domains
|
||||
bloq=@ud :: block number
|
||||
node=(unit purl:eyre) :: gateway url
|
||||
snap=(unit snapshot:jael) :: head start
|
||||
== ::
|
||||
[%fake our=ship] :: boot fake
|
||||
:: XX wegh ::
|
||||
|
@ -1243,8 +1243,6 @@
|
||||
$serv `%e
|
||||
$tend `%a
|
||||
$them `%e
|
||||
$turf `%j
|
||||
$vein `%j
|
||||
$wait `%b
|
||||
$want `%a
|
||||
$warp `%c
|
||||
|
@ -84,12 +84,6 @@
|
||||
$: pry/(map ship (map ship safe)) :: promises
|
||||
eve=logs :: on-chain events
|
||||
== ::
|
||||
++ state-eth-node :: node config + meta
|
||||
$: source=(each ship node-src) :: learning from
|
||||
heard=(set event-id) :: processed events
|
||||
latest-block=@ud :: last heard block
|
||||
foreign-block=@ud :: node's latest block
|
||||
== ::
|
||||
++ state-snapshots :: rewind points
|
||||
$: interval=_100 :: block interval
|
||||
max-count=_10 :: max snaps
|
||||
@ -97,21 +91,6 @@
|
||||
last-block=@ud :: number of last snap
|
||||
snaps=(qeu [block-number=@ud snap=snapshot]) :: old states
|
||||
== ::
|
||||
++ snapshot :: rewind point
|
||||
$: eve=logs :: eth absolute state
|
||||
kyz=(map ship public) :: public key state
|
||||
$= eth ::
|
||||
$: dns=dnses :: on-chain dns state
|
||||
hul=(map ship hull) :: on-chain ship state
|
||||
== ::
|
||||
etn=state-eth-node :: eth connection state
|
||||
== ::
|
||||
++ node-src :: ethereum node comms
|
||||
$: node=purl:eyre :: node url
|
||||
filter-id=@ud :: current filter
|
||||
poll-timer=@da :: next filter poll
|
||||
== ::
|
||||
:: ::
|
||||
++ message :: p2p message
|
||||
$% [%hail p=remote] :: reset rights
|
||||
[%nuke ~] :: cancel trackers
|
||||
@ -741,6 +720,11 @@
|
||||
:: set initial domains
|
||||
::
|
||||
=. tuf.own.sub turf.tac
|
||||
:: if we're given a snapshot, restore it
|
||||
::
|
||||
=. +>.$
|
||||
?~ snap.tac +>.$
|
||||
(restore-snap u.snap.tac)
|
||||
::
|
||||
=. moz
|
||||
%+ weld moz
|
||||
@ -1040,6 +1024,18 @@
|
||||
[snap.snap +>.^$]
|
||||
$
|
||||
~& [%wind block latest-block.etn.snap ~(wyt by hul.eth.snap)]
|
||||
=. +>.$ (restore-snap snap)
|
||||
%= +>.$
|
||||
moz
|
||||
=- [[hen %pass /wind/look %j %look our -] moz]
|
||||
?- -.source.etn
|
||||
%& &+p.source.etn
|
||||
%| |+node.p.source.etn
|
||||
==
|
||||
==
|
||||
:: :: ++restore-snap:of
|
||||
++ restore-snap :: restore snapshot
|
||||
|= snap=snapshot
|
||||
:: keep the following in sync with ++extract-snap:file:su
|
||||
%= +>.$
|
||||
eve.urb eve.snap
|
||||
@ -1047,12 +1043,6 @@
|
||||
kyz.puk.sub kyz.snap
|
||||
+.eth.sub eth.snap
|
||||
sap sap(last-block 0)
|
||||
moz
|
||||
=- [[hen %pass /wind/look %j %look our -] moz]
|
||||
?- -.source.etn
|
||||
%& &+p.source.etn
|
||||
%| |+node.p.source.etn
|
||||
==
|
||||
==
|
||||
--
|
||||
:: :: ++su
|
||||
@ -1840,7 +1830,7 @@
|
||||
^+ +>
|
||||
:: TODO: ship or node as sample?
|
||||
::
|
||||
=. latest-block launch:contracts
|
||||
=. latest-block (max latest-block launch:contracts)
|
||||
?: |(=(our bos) ?=(^ nod.own))
|
||||
~| %jael-init-node
|
||||
(listen-to-node (need nod.own))
|
||||
@ -2260,16 +2250,12 @@
|
||||
?: =(~ snaps.sap.lex)
|
||||
`~
|
||||
:^ ~ ~ %noun !>
|
||||
%= sap.lex
|
||||
snaps
|
||||
%- ~(put to *(qeu [block-number=@ud snap=snapshot]))
|
||||
|- ^- [@ud snapshot]
|
||||
=^ snap snaps.sap.lex
|
||||
~(get to snaps.sap.lex)
|
||||
?: =(~ snaps.sap.lex)
|
||||
snap
|
||||
$
|
||||
==
|
||||
|- ^- snapshot
|
||||
=^ snap=[@ud snap=snapshot] snaps.sap.lex
|
||||
~(get to snaps.sap.lex)
|
||||
?: =(~ snaps.sap.lex)
|
||||
snap.snap
|
||||
$
|
||||
==
|
||||
:: :: ++stay
|
||||
++ stay :: preserve
|
||||
|
@ -2035,6 +2035,7 @@
|
||||
{$vine p/(list change)} :: all raw changes
|
||||
[%vent p=chain] :: ethereum changes
|
||||
== ::
|
||||
:: ::
|
||||
++ note :: out request $->
|
||||
=, eyre ::
|
||||
$% $: %b ::
|
||||
@ -2068,7 +2069,7 @@
|
||||
+$ seed [who=ship lyf=life key=ring sig=(unit oath:pki)]
|
||||
::
|
||||
++ sign :: in result $<-
|
||||
$% {$b $wake ~} :: wakeup
|
||||
$% {$b $wake ~} :: wakeup
|
||||
[%e %sigh p=cage] :: marked http response
|
||||
[%j %vent p=chain] :: ethereum changes
|
||||
[%a %woot p=ship q=coop] :: message result
|
||||
@ -2087,6 +2088,7 @@
|
||||
turf=(list turf) :: domains
|
||||
bloq=@ud :: block number
|
||||
node=(unit purl:eyre) :: gateway url
|
||||
snap=(unit snapshot) :: head start
|
||||
== ::
|
||||
[%fake our=ship] :: fake boot
|
||||
[%look our=ship src=(each ship purl:eyre)] :: set ethereum source
|
||||
@ -2104,7 +2106,31 @@
|
||||
[%west p=sack q=path r=*] :: remote request
|
||||
[%wind our=ship p=@ud] :: rewind before block
|
||||
== ::
|
||||
--
|
||||
-- ::
|
||||
:: ::
|
||||
:::: ::
|
||||
:: ::
|
||||
++ node-src :: ethereum node comms
|
||||
$: node=purl:eyre :: node url
|
||||
filter-id=@ud :: current filter
|
||||
poll-timer=@da :: next filter poll
|
||||
== ::
|
||||
++ snapshot :: rewind point
|
||||
=, constitution:ethe ::
|
||||
$: eve=logs:able :: eth absolute state
|
||||
kyz=(map ship public:able) :: public key state
|
||||
$= eth ::
|
||||
$: dns=dnses :: on-chain dns state
|
||||
hul=(map ship hull) :: on-chain ship state
|
||||
== ::
|
||||
etn=state-eth-node :: eth connection state
|
||||
== ::
|
||||
++ state-eth-node :: node config + meta
|
||||
$: source=(each ship node-src) :: learning from
|
||||
heard=(set event-id:ethe) :: processed events
|
||||
latest-block=@ud :: last heard block
|
||||
foreign-block=@ud :: node's latest block
|
||||
== ::
|
||||
:: ::
|
||||
:::: ++pki:jael :: (1h2) certificates
|
||||
:: ::::
|
||||
@ -8135,6 +8161,54 @@
|
||||
(~(put by tuf) q.i.dom p.i.dom)
|
||||
$(dom t.dom)
|
||||
--
|
||||
:: |snap:dawn restore from snapshot
|
||||
::
|
||||
++ snap
|
||||
!:
|
||||
|%
|
||||
:: +bloq:snap:dawn: extract block number
|
||||
::
|
||||
++ bloq
|
||||
|= snap=snapshot:jael
|
||||
^- @ud
|
||||
latest-block.etn.snap
|
||||
:: +czar:snap:dawn: extract galaxy table
|
||||
::
|
||||
++ czar
|
||||
|= snap=snapshot:jael
|
||||
^- (map ship [=life =pass])
|
||||
%- malt
|
||||
%+ turn (gulf 0 255)
|
||||
|= gal=@
|
||||
^- [ship [life pass]]
|
||||
:- gal
|
||||
~| czar-gal=gal
|
||||
[life pass]:(need net:(~(got by hul.eth.snap) gal))
|
||||
:: +hull:snap:dawn: extract ship's contract state
|
||||
::
|
||||
++ hull
|
||||
|= [who=ship snap=snapshot:jael]
|
||||
^- hull:constitution:ethe
|
||||
=/ res (~(get by hul.eth.snap) who)
|
||||
?~ res
|
||||
~& ['hull not found in snapshot; can\'t verify' who=who]
|
||||
!!
|
||||
u.res
|
||||
:: +turf:snap:dawn: extract network domains
|
||||
::
|
||||
++ turf
|
||||
|= snap=snapshot:jael
|
||||
^- (list ^turf)
|
||||
%+ murn
|
||||
^- (list (pair))
|
||||
%+ murn
|
||||
^- (list @t)
|
||||
~[pri sec ter]:dns.eth.snap
|
||||
|= dom=@t
|
||||
^- (unit (pair))
|
||||
(rush dom thos:de-purl:html)
|
||||
|=([* a=*] ((soft ^turf) a))
|
||||
--
|
||||
:: +veri:dawn: validate keys, life, discontinuity, &c
|
||||
::
|
||||
++ veri
|
||||
|
@ -17,7 +17,7 @@
|
||||
-8~kX.3ALiG.rQjOi.HZ9hj.84b6G.P5pCZ.UtNtt.Lh9TE.2DQJ2
|
||||
=/ url (de-purl:html 'http://localhost:8545')
|
||||
=/ dan
|
||||
[`seed:able:jael`[~nul 1 key ~] ~ ~ [/org/urbit ~] 0 url]
|
||||
[`seed:able:jael`[~nul 1 key ~] ~ ~ [/org/urbit ~] 0 url ~]
|
||||
::
|
||||
=^ results1 jael-gate
|
||||
=/ hen=duct
|
||||
|
@ -28,6 +28,21 @@
|
||||
%- crip
|
||||
%+ weld "0x"
|
||||
(render-hex-bytes:ethereum 20 `@`ships:contracts:constitution:ethe)
|
||||
:: snapshot
|
||||
::
|
||||
++ snap
|
||||
^- snapshot:jael
|
||||
:* *logs:able:jael
|
||||
~
|
||||
:* ['urbit.org' 'urbit.org' '']
|
||||
%- malt
|
||||
:* ~zod^hul
|
||||
~marzod^hul
|
||||
(turn (gulf 1 255) |=(gal=@ gal^hul))
|
||||
==
|
||||
==
|
||||
%*(. *state-eth-node:jael latest-block 4.230.000)
|
||||
==
|
||||
::
|
||||
++ test-give-bloq
|
||||
=/ oct
|
||||
@ -167,6 +182,26 @@
|
||||
!> [/org/urbit ~]
|
||||
!> (turf:take:dawn oct)
|
||||
::
|
||||
++ test-snap-bloq
|
||||
%+ expect-eq
|
||||
!> 4.230.000
|
||||
!> (bloq:snap:dawn snap)
|
||||
::
|
||||
++ test-snap-hull
|
||||
%+ expect-eq
|
||||
!> hul
|
||||
!> (hull:snap:dawn ~zod snap)
|
||||
::
|
||||
++ test-snap-czar
|
||||
%+ expect-eq
|
||||
!> 256
|
||||
!> ~(wyt by (czar:snap:dawn snap))
|
||||
::
|
||||
++ test-snap-turf
|
||||
%+ expect-eq
|
||||
!> `(list turf)`~[~['org' 'urbit'] ~['org' 'urbit']]
|
||||
!> (turf:snap:dawn snap)
|
||||
::
|
||||
++ test-veri-good
|
||||
=/ sed [~zod 1 sec ~]
|
||||
%+ expect-eq
|
||||
|
Loading…
Reference in New Issue
Block a user