mirror of
https://github.com/urbit/shrub.git
synced 2024-11-23 20:26:54 +03:00
Merge remote-tracking branch 'origin/master' into philip/tomb
This commit is contained in:
commit
0c3eee07b5
6
.gitattributes
vendored
6
.gitattributes
vendored
@ -1,9 +1,15 @@
|
||||
bin/* filter=lfs diff=lfs merge=lfs -text
|
||||
bin/*/* filter=lfs diff=lfs merge=lfs -text
|
||||
pkg/arvo/**/*.css binary
|
||||
pkg/arvo/app/naive/logs.eth-logs filter=lfs diff=lfs merge=lfs -text
|
||||
**/package-lock.json binary merge=theirs
|
||||
pkg/arvo/tmp/garden.jam filter=lfs diff=lfs merge=lfs -text
|
||||
pkg/arvo/tmp/landscape.jam filter=lfs diff=lfs merge=lfs -text
|
||||
pkg/arvo/tmp/base.jam filter=lfs diff=lfs merge=lfs -text
|
||||
pkg/arvo/tmp/bitcoin.jam filter=lfs diff=lfs merge=lfs -text
|
||||
pkg/arvo/tmp/webterm.jam filter=lfs diff=lfs merge=lfs -text
|
||||
*.hoon text eol=lf
|
||||
*.kelvin text eol=lf
|
||||
*.bill text eol=lf
|
||||
*.docket-0 text eol=lf
|
||||
*.ship text eol=lf
|
||||
|
28
.github/workflows/build.yml
vendored
28
.github/workflows/build.yml
vendored
@ -39,7 +39,6 @@ on:
|
||||
- 'pkg/docker-image/**'
|
||||
- 'pkg/ent/**'
|
||||
- 'pkg/ge-additions/**'
|
||||
- 'pkg/hs/**'
|
||||
- 'pkg/libaes_siv/**'
|
||||
- 'pkg/urbit/**'
|
||||
- 'bin/**'
|
||||
@ -50,7 +49,6 @@ on:
|
||||
- 'pkg/docker-image/**'
|
||||
- 'pkg/ent/**'
|
||||
- 'pkg/ge-additions/**'
|
||||
- 'pkg/hs/**'
|
||||
- 'pkg/libaes_siv/**'
|
||||
- 'pkg/urbit/**'
|
||||
- 'bin/**'
|
||||
@ -74,12 +72,12 @@ jobs:
|
||||
# for the docker build. We don't want in on Mac, where it isn't but
|
||||
# it breaks the nix install. The two `if` clauses should be mutually
|
||||
# exclusive
|
||||
- uses: cachix/install-nix-action@v13
|
||||
- uses: cachix/install-nix-action@v16
|
||||
with:
|
||||
extra_nix_config: |
|
||||
system-features = nixos-test benchmark big-parallel kvm
|
||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||
- uses: cachix/install-nix-action@v13
|
||||
- uses: cachix/install-nix-action@v16
|
||||
if: ${{ matrix.os != 'ubuntu-latest' }}
|
||||
|
||||
- uses: cachix/cachix-action@v10
|
||||
@ -95,28 +93,6 @@ jobs:
|
||||
- if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||
run: nix-build -A docker-image
|
||||
|
||||
haskell:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { os: ubuntu-latest }
|
||||
- { os: macos-latest }
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: cachix/install-nix-action@v13
|
||||
- uses: cachix/cachix-action@v10
|
||||
with:
|
||||
name: ares
|
||||
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
|
||||
|
||||
- run: nix-build -A hs.urbit-king.components.exes.urbit-king --arg enableStatic true
|
||||
- run: nix-build -A hs-checks
|
||||
- run: nix-build shell.nix
|
||||
|
||||
mingw:
|
||||
runs-on: windows-latest
|
||||
defaults:
|
||||
|
2
.github/workflows/release-docker.yml
vendored
2
.github/workflows/release-docker.yml
vendored
@ -16,7 +16,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: cachix/install-nix-action@v13
|
||||
- uses: cachix/install-nix-action@v16
|
||||
with:
|
||||
extra_nix_config: |
|
||||
system-features = nixos-test benchmark big-parallel kvm
|
||||
|
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -17,7 +17,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: cachix/install-nix-action@v13
|
||||
- uses: cachix/install-nix-action@v16
|
||||
- uses: cachix/cachix-action@v10
|
||||
with:
|
||||
name: ${{ secrets.CACHIX_NAME }}
|
||||
|
@ -9,8 +9,12 @@ interface, see its [contribution guidelines][interface].
|
||||
|
||||
For information on Arvo's maintainers, see [pkg/arvo][main].
|
||||
|
||||
For more extensive information on Urbit development, such as how to set up an
|
||||
environment and how to submit a grant, see the [developer documentation][dev].
|
||||
|
||||
[start]: https://urbit.org/using/install
|
||||
[interface]: /pkg/interface/CONTRIBUTING.md
|
||||
[dev]: https://urbit.org/docs/development
|
||||
|
||||
## Fake ships
|
||||
|
||||
@ -55,8 +59,9 @@ urbit -F zod -B "bin/solid.pill" -A "pkg/arvo"
|
||||
|
||||
The canonical source tree is the `master` branch of
|
||||
[https://github.com/urbit/urbit][repo]. You should typically branch off of
|
||||
`master` when commencing new work; similarly, when we pull in your
|
||||
contribution, we'll do so by merging it to `master`.
|
||||
`master` when commencing new work. Most pull requests should be merging into
|
||||
one of the `next/*` branches, depending on what part of the system the pull
|
||||
request is targeting.
|
||||
|
||||
Since we use GitHub, we request you contribute via a GitHub pull request. Tag
|
||||
the [maintainer][main] for the component. If you have a question for the
|
||||
@ -294,5 +299,5 @@ Questions or other communications about contributing to Urbit can go to
|
||||
[repo]: https://github.com/urbit/urbit
|
||||
[reba]: https://git-rebase.io/
|
||||
[issu]: https://github.com/urbit/urbit/issues
|
||||
[hoon]: https://urbit.org/docs/learn/hoon/style/
|
||||
[hoon]: https://urbit.org/docs/hoon/reference/style
|
||||
[main]: https://github.com/urbit/urbit/tree/master/pkg/arvo#maintainers
|
157
MAINTAINERS.md
157
MAINTAINERS.md
@ -29,7 +29,7 @@ released.
|
||||
### Release branches
|
||||
|
||||
Release branches are code that is ready to release. All release branch names
|
||||
should start with `release/`.
|
||||
should start with `next/`.
|
||||
|
||||
All code must be reviewed before being pushed to a release branch. Thus,
|
||||
feature branches should be PR'd against a release branch, not master.
|
||||
@ -41,57 +41,55 @@ be released together -- unless one of the underlying commits is separately put
|
||||
on a release branch.
|
||||
|
||||
Here's a worked example. The rule is to make however many branches are useful,
|
||||
and no more. This example is not prescriptive, the developers making the
|
||||
and no more. This example is not prescriptive; the developers making the
|
||||
changes may add, remove, or rename branches in this flow at will.
|
||||
|
||||
Suppose you (plural, the dev community at large) complete some work in a
|
||||
userspace app, and you put it in `release/next-userspace`. Separately, you make
|
||||
a small JS change. If you PR it to `release/next-userspace`, then it will only
|
||||
be released at the same time as the app changes. Maybe this is fine, or maybe
|
||||
you want this change to go out quickly, and the change in
|
||||
`release/next-userspace` is relatively risky, so you don't want to push it out
|
||||
on Friday afternoon. In this case, put the change in another release branch,
|
||||
say `release/next-js`. Now either can be released independently.
|
||||
userspace app, and you put it in `next/landscape`. Separately, you make a small
|
||||
JS change. If you PR it to `next/landscape`, then it will only be released at
|
||||
the same time as the app changes. Maybe this is fine, or maybe you want this
|
||||
change to go out quickly, and the change in `next/landscape` is relatively
|
||||
risky, so you don't want to push it out on Friday afternoon. In this case, put
|
||||
the change in another release branch, say `next/js`. Now either can be released
|
||||
independently.
|
||||
|
||||
Suppose you do further work that you want to PR to `release/next-userspace`, but
|
||||
it depends on your fixes in `release/next-js`. Simply merge `release/next-js`
|
||||
into either your feature branch or `release/next-userspace` and PR your finished
|
||||
work to `release/next-userspace`. Now there is a one-way coupling:
|
||||
`release/next-userspace` contains `release/next-js`, so releasing it will
|
||||
implicitly release `release/next-js`. However, you can still release
|
||||
`release/next-js` independently.
|
||||
Suppose you do further work that you want to PR to `next/landscape`, but it
|
||||
depends on your fixes in `next/js`. Simply merge `next/js` into either your
|
||||
feature branch or `next/landscape` and PR your finished work to
|
||||
`next/landscape`. Now there is a one-way coupling: `next/landscape` contains
|
||||
`next/js`, so releasing it will implicitly release `next/js`. However, you can
|
||||
still release `next/js` independently.
|
||||
|
||||
This scheme extends to other branches, like `release/next-kernel` or
|
||||
`release/os1.1` or `release/ford-fusion`. Some branches may be long-lived and
|
||||
represent simply the "next" release of something, while others will have a
|
||||
definite lifetime that corresponds to development of a particular feature or
|
||||
numbered release.
|
||||
This scheme extends to other branches, like `next/base` or `next/os1.1` or
|
||||
`next/ford-fusion`. Some branches may be long-lived and represent simply the
|
||||
"next" release of something, while others will have a definite lifetime that
|
||||
corresponds to development of a particular feature or numbered release.
|
||||
|
||||
Since they are "done", release branches should be considered "public", in the
|
||||
sense that others may depend on them at will. Thus, never rebase a release
|
||||
branch.
|
||||
|
||||
When cutting a new release, you can filter branches with `git branch --list
|
||||
'release/*'` or by typing "release/" in the branch filter on Github. This will
|
||||
give you the list of branches which have passed review and may be merged to
|
||||
master and released. When choosing which branches to release, make sure you
|
||||
understand the risks of releasing them immediately. If merging these produces
|
||||
nontrivial conflicts, consider asking the developers on those branches to merge
|
||||
between themselves. In many cases a developer can do this directly, but if it's
|
||||
'next/*'` or by typing "next/" in the branch filter on Github. This will give
|
||||
you the list of branches which have passed review and may be merged to master
|
||||
and released. When choosing which branches to release, make sure you understand
|
||||
the risks of releasing them immediately. If merging these produces nontrivial
|
||||
conflicts, consider asking the developers on those branches to merge between
|
||||
themselves. In many cases a developer can do this directly, but if it's
|
||||
sufficiently nontrivial, this may be a reviewed PR of one release branch into
|
||||
another.
|
||||
|
||||
### Non-OTAable release branches
|
||||
#### Standard release branches
|
||||
|
||||
In some cases, work is completed which cannot be OTA'd as written. For example,
|
||||
the code may lack state adapters, or it may not properly handle outstanding
|
||||
subscriptions. It could also be code which is planned to be released only upon
|
||||
a breach (network-wide or rolling).
|
||||
While you can always create non-standard release branches to stage for a
|
||||
particular release, most changes should go through the following:
|
||||
|
||||
In this case, the code may be PR'd to a `na-release/` branch. All rules are the
|
||||
same as for release branches, except that the code does not need to apply
|
||||
cleanly to an existing ship. If you later write state adapter or otherwise make
|
||||
it OTAable, then you may PR it to a release branch.
|
||||
- next/base -- changes to the %base desk in pkg/arvo
|
||||
- next/garden -- changes to the %garden desk
|
||||
- next/landscape -- changes to the %landscape desk
|
||||
- next/bitcoin -- changes to the %bitcoin desk
|
||||
- next/webterm -- changes to the %webterm desk
|
||||
- next/vere -- changes to the runtime
|
||||
|
||||
### Other cases
|
||||
|
||||
@ -161,11 +159,49 @@ so that I can type e.g. `git mu origin/foo 1337`.
|
||||
|
||||
If you're making a Vere release, just play it safe and update all the pills.
|
||||
|
||||
To produce multi pills, you will need to set up an environment with the
|
||||
appropriate desks with the appropriate contents, doing something like the
|
||||
following (where `> ` denotes an urbit command and `% ` denotes a unix shell
|
||||
command):
|
||||
|
||||
```console
|
||||
> |merge %garden our %base
|
||||
> |merge %landscape our %base
|
||||
> |merge %bitcoin our %base
|
||||
> |merge %webterm our %base
|
||||
> |mount %
|
||||
> |mount %garden
|
||||
> |mount %landscape
|
||||
> |mount %bitcoin
|
||||
> |mount %webterm
|
||||
% rsync -avL --delete pkg/arvo/ zod/base/
|
||||
% rm -rf zod/base/tests/
|
||||
% for desk in garden landscape bitcoin webterm; do \
|
||||
rsync -avL --delete pkg/$desk/ zod/$desk/ \
|
||||
done
|
||||
> |commit %base
|
||||
> |commit %garden
|
||||
> |commit %landscape
|
||||
> |commit %bitcoin
|
||||
> |commit %webterm
|
||||
> .multi/pill +solid %base %garden %landscape %bitcoin %webterm
|
||||
> .multi-brass/pill +brass %base %garden %landscape %bitcoin %webterm
|
||||
```
|
||||
|
||||
And then of course:
|
||||
|
||||
```console
|
||||
> .solid/pill +solid
|
||||
> .brass/pill +brass
|
||||
> .ivory/pill +ivory
|
||||
```
|
||||
|
||||
For an Urbit OS release, after all the merge commits, make a release with the
|
||||
commit message "release: urbit-os-v1.0.xx". This commit should have up-to-date
|
||||
artifacts from pkg/interface and a new solid pill. If neither the pill nor the
|
||||
JS need to be updated (e.g if the pill was already updated in the previous merge
|
||||
commit), consider making the release commit with --allow-empty.
|
||||
artifacts from pkg/interface and a new version number in the desk.docket-0 of
|
||||
any desk which changed. If neither the pill nor the JS need to be updated (e.g
|
||||
if the pill was already updated in the previous merge commit), consider making
|
||||
the release commit with --allow-empty.
|
||||
|
||||
If anything in `pkg/interface` has changed, ensure it has been built and
|
||||
deployed properly. You'll want to do this before making a pill, since you want
|
||||
@ -191,21 +227,23 @@ What you should do here depends on the type of release being made.
|
||||
|
||||
First, for Urbit OS releases:
|
||||
|
||||
If it's a very trivial hotfix that you know isn't going to break
|
||||
anything, tag it as `urbit-os-vx.y.z`. Here 'x' refers to the product version
|
||||
(e.g. OS1, OS2..), 'y' to the continuity era in that version, and 'z' to an
|
||||
OTA patch counter. So for a hotfix version, you'll just want to increment 'z'.
|
||||
If it's a very trivial hotfix that you know isn't going to break anything, tag
|
||||
it as `urbit-os-vx.y`. Here 'x' is the major version and 'y' is an OTA patch
|
||||
counter. Change `urbit-os` to e.g. `landscape` or another desk if that's what you're
|
||||
releasing. If you're releasing changes to more than one desk, add a separate
|
||||
tag for each desk (but only make one announcment email/post, with all of the
|
||||
desks listed).
|
||||
|
||||
Use an annotated tag, i.e.
|
||||
|
||||
```
|
||||
git tag -a urbit-os-vx.y.z
|
||||
git tag -a urbit-os-vx.y
|
||||
```
|
||||
|
||||
The tag format should look something like this:
|
||||
|
||||
```
|
||||
urbit-os-vx.y.z
|
||||
urbit-os-vx.y
|
||||
|
||||
This release will be pushed to the network as an over-the-air update.
|
||||
|
||||
@ -236,17 +274,17 @@ If the commit descriptions are too poor to easily do this, then again, yell at
|
||||
your fellow contributors to make them better in the future.
|
||||
|
||||
If it's *not* a trivial hotfix, you should probably make any number of release
|
||||
candidate tags (e.g. `urbit-os-vx.y.z.rc1`, `urbit-os-vx.y.z.rc2`, ..), test
|
||||
candidate tags (e.g. `urbit-os-vx.y.rc1`, `urbit-os-vx.y.rc2`, ..), test
|
||||
them, and after you confirm one of them is good, tag the release as
|
||||
`urbit-os-vx.y.z`.
|
||||
`urbit-os-vx.y`.
|
||||
|
||||
For Vere releases:
|
||||
|
||||
Tag the release as `urbit-vx.y.z`. The tag format should look something like
|
||||
Tag the release as `urbit-vx.y`. The tag format should look something like
|
||||
this:
|
||||
|
||||
```
|
||||
urbit-vx.y.z
|
||||
urbit-vx.y
|
||||
|
||||
Note that this Vere release will by default boot fresh ships using an Urbit OS
|
||||
va.b.c pill.
|
||||
@ -254,10 +292,10 @@ va.b.c pill.
|
||||
Release binaries:
|
||||
|
||||
(linux64)
|
||||
https://bootstrap.urbit.org/urbit-vx.y.z-linux64.tgz
|
||||
https://bootstrap.urbit.org/urbit-vx.y-linux64.tgz
|
||||
|
||||
(macOS)
|
||||
https://bootstrap.urbit.org/urbit-vx.y.z-darwin.tgz
|
||||
https://bootstrap.urbit.org/urbit-vx.y-darwin.tgz
|
||||
|
||||
Release notes:
|
||||
|
||||
@ -295,10 +333,10 @@ and stars to the rest of the network.
|
||||
For consistency, I create a release tarball and then rsync the files in.
|
||||
|
||||
```
|
||||
$ wget https://github.com/urbit/urbit/archive/urbit-os-vx.y.z.tar.gz
|
||||
$ tar xzf urbit-os-vx.y.z.tar.gz
|
||||
$ wget https://github.com/urbit/urbit/archive/urbit-os-vx.y.tar.gz
|
||||
$ tar xzf urbit-os-vx.y.tar.gz
|
||||
$ herb zod -p hood -d "+hood/mount /=home="
|
||||
$ rsync -zr --delete urbit-urbit-os-vx.y.z/pkg/arvo/ zod/home
|
||||
$ rsync -zr --delete urbit-urbit-os-vx.y/pkg/arvo/ zod/home
|
||||
$ herb zod -p hood -d "+hood/commit %home"
|
||||
$ herb zod -p hood -d "+hood/merge %kids our %home"
|
||||
```
|
||||
@ -306,16 +344,11 @@ $ herb zod -p hood -d "+hood/merge %kids our %home"
|
||||
For Vere updates, this means simply shutting down each desired ship, installing
|
||||
the new binary, and restarting the pier with it.
|
||||
|
||||
#### Continuous deployment
|
||||
|
||||
A subset of release branches are deployed continuously to the network. Thus far
|
||||
this only includes `release/next-userspace`, which deploys livenet-compatible
|
||||
changes to select QA ships. Any push to master will automatically
|
||||
merge master into `release/next-userspace` to keep the streams at parity.
|
||||
|
||||
### Announce the update
|
||||
|
||||
Post an announcement to urbit-dev. The tag annotation, basically, is fine here
|
||||
-- I usually add the %base hash (for Urbit OS releases) and the release binary
|
||||
-- I usually add the %cz hash (for Urbit OS releases) and the release binary
|
||||
URLs (for Vere releases). Check the urbit-dev archives for examples of these
|
||||
announcements.
|
||||
|
||||
Post the same announcement to the group feed of Urbit Community.
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:9a56f675d2a6c5dafa92a9e2d55040d994f3d3d27a1ed827bd87d1158b1e69d0
|
||||
size 3749183
|
||||
oid sha256:ae4a7a69fe81c5f2114d7b7360c05602f614fe66b96d1db4c3dc0c2a2a5d856e
|
||||
size 7536000
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f50aee74e4f3dd6685d36520bbc924ab94d3d47a7bc86e649882e58ab069e7dd
|
||||
size 991930
|
||||
oid sha256:f59ec4eaf907227a1fd64e1d54810b769b5d39f6811c6bb254b2e89de528ca04
|
||||
size 1209494
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:049801d388b4cb7203854b4668826688c21089f90430bd547d276e7b59386e8d
|
||||
size 5588170
|
||||
oid sha256:e660fba934c5b80eeda64037a1f28c71eff4b2ea0bd28809b91432ca3d5ef08a
|
||||
size 23052691
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:013089a71925d4904273cab9c1f9844b8d4896ddc7700875dcb7b2f696f14ce6
|
||||
size 6754562
|
||||
oid sha256:772c757007ef9297e7b8ae37864098ee2f40ac5202553b749cccbc5f5f7db52a
|
||||
size 9559562
|
||||
|
29
default.nix
29
default.nix
@ -14,10 +14,6 @@
|
||||
$ nix-build -A urbit --argstr crossSystem x86_64-unknown-linux-musl \
|
||||
--arg enableStatic true
|
||||
|
||||
Static urbit-king binary:
|
||||
|
||||
$ nix-build -A hs.urbit-king.components.exes.urbit-king --arg enableStatic true
|
||||
|
||||
Static release tarball:
|
||||
|
||||
$ nix-build -A tarball --arg enableStatic true
|
||||
@ -28,15 +24,6 @@
|
||||
$ nix-build -A brass.build
|
||||
$ nix-build -A solid.build
|
||||
|
||||
Run the king-haskell checks (.tests are _build_ the test code, .checks _runs_):
|
||||
|
||||
$ nix-build -A hs.urbit-king.checks.urbit-king-tests
|
||||
|
||||
Build a specific Haskell package from ./pkg/hs:
|
||||
|
||||
$ nix-build -A hs.urbit-noun.components.library
|
||||
$ nix-build -A hs.urbit-atom.components.benchmarks.urbit-atom-bench
|
||||
$ nix-build -A hs.urbit-atom.components.tests.urbit-atom-tests
|
||||
*/
|
||||
|
||||
# The build system where packages will be _built_.
|
||||
@ -76,7 +63,7 @@ let
|
||||
|
||||
# Enrich the global package set with our local functions and packages.
|
||||
# Cross vs static build dependencies can be selectively overridden for
|
||||
# inputs like python and haskell-nix
|
||||
# inputs like python etc.
|
||||
callPackage =
|
||||
pkgsNative.lib.callPackageWith (pkgsStatic // libLocal // pkgsLocal);
|
||||
|
||||
@ -113,22 +100,12 @@ let
|
||||
urcrypt = callPackage ./nix/pkgs/urcrypt { inherit enableStatic; };
|
||||
|
||||
docker-image = callPackage ./nix/pkgs/docker-image { };
|
||||
|
||||
hs = callPackage ./nix/pkgs/hs {
|
||||
inherit enableStatic;
|
||||
inherit (pkgsCross) haskell-nix;
|
||||
};
|
||||
};
|
||||
|
||||
# Additional top-level packages and attributes exposed for convenience.
|
||||
pkgsExtra = with pkgsLocal; rec {
|
||||
# Expose packages with local customisations (like patches) for dev access.
|
||||
inherit (pkgsCross) libsigsegv;
|
||||
|
||||
# Collect haskell check (aka "run the tests") attributes so we can run every
|
||||
# test for our local haskell packages, similar to the urbit-tests attribute.
|
||||
hs-checks = (pkgsNative.recurseIntoAttrs
|
||||
(libLocal.collectHaskellComponents pkgsLocal.hs)).checks;
|
||||
inherit (pkgsStatic) libsigsegv lmdb;
|
||||
|
||||
urbit-debug = urbit.override { enableDebug = true; };
|
||||
urbit-tests = libLocal.testFakeShip {
|
||||
@ -145,14 +122,12 @@ let
|
||||
# Create a .tgz of the primary binaries.
|
||||
tarball = let
|
||||
name = "urbit-v${urbit.version}-${urbit.system}";
|
||||
urbit-king = hs.urbit-king.components.exes.urbit-king;
|
||||
in libLocal.makeReleaseTarball {
|
||||
inherit name;
|
||||
|
||||
contents = {
|
||||
"${name}/urbit" = "${urbit}/bin/urbit";
|
||||
"${name}/urbit-worker" = "${urbit}/bin/urbit-worker";
|
||||
"${name}/urbit-king" = "${urbit-king}/bin/urbit-king";
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -13,42 +13,19 @@
|
||||
|
||||
let
|
||||
|
||||
sourcesFinal = import ./sources.nix { inherit pkgs; } // sources;
|
||||
finalSources = import ./sources.nix { } // sources;
|
||||
|
||||
haskellNix = import sourcesFinal."haskell.nix" {
|
||||
sourcesOverride = {
|
||||
hackage = sourcesFinal."hackage.nix";
|
||||
stackage = sourcesFinal."stackage.nix";
|
||||
};
|
||||
};
|
||||
pkgs = import finalSources.nixpkgs {
|
||||
inherit system config crossSystem crossOverlays;
|
||||
|
||||
configFinal = haskellNix.config // config;
|
||||
|
||||
overlaysFinal = haskellNix.overlays ++ [
|
||||
(_final: prev: {
|
||||
# Add top-level .sources attribute for other overlays to access sources.
|
||||
sources = sourcesFinal;
|
||||
|
||||
# Additional non-convential package/exe mappings for shellFor.tools.
|
||||
haskell-nix = prev.haskell-nix // {
|
||||
toolPackageName = prev.haskell-nix.toolPackageName // {
|
||||
shellcheck = "ShellCheck";
|
||||
};
|
||||
};
|
||||
})
|
||||
|
||||
# General unguarded (native) overrides for nixpkgs.
|
||||
(import ./overlays/native.nix)
|
||||
|
||||
# Specific overrides guarded by the host platform.
|
||||
(import ./overlays/musl.nix)
|
||||
] ++ overlays;
|
||||
|
||||
pkgs = import sourcesFinal.nixpkgs {
|
||||
inherit system crossSystem crossOverlays;
|
||||
|
||||
config = configFinal;
|
||||
overlays = overlaysFinal;
|
||||
overlays = [
|
||||
# Make prev.sources available to subsequent overlays.
|
||||
(_final: _prev: { sources = finalSources; })
|
||||
# General unguarded (native) overrides for nixpkgs.
|
||||
(import ./overlays/native.nix)
|
||||
# Specific overrides guarded by the host platform.
|
||||
(import ./overlays/musl.nix)
|
||||
];
|
||||
};
|
||||
|
||||
in pkgs // {
|
||||
|
@ -41,6 +41,10 @@ in stdenvNoCC.mkDerivation {
|
||||
if check && sleep 10 && check; then
|
||||
header "boot success"
|
||||
herb ./pier -p hood -d '+hood/exit'
|
||||
while [ -f ./pier/.vere.lock ]; do
|
||||
echo "waiting for pier to shut down"
|
||||
sleep 5
|
||||
done
|
||||
else
|
||||
header "boot failure"
|
||||
kill $(< ./pier/.vere.lock) || true
|
||||
@ -49,6 +53,8 @@ in stdenvNoCC.mkDerivation {
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
ls
|
||||
ls -a ./pier
|
||||
mv ./pier $out
|
||||
'';
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Functions that are expected run on the native (non-cross) system.
|
||||
|
||||
{ lib, recurseIntoAttrs, haskell-nix, callPackage }:
|
||||
{ callPackage }:
|
||||
|
||||
rec {
|
||||
bootFakeShip = callPackage ./boot-fake-ship.nix { };
|
||||
@ -10,28 +10,4 @@ rec {
|
||||
fetchGitHubLFS = callPackage ./fetch-github-lfs.nix { };
|
||||
|
||||
makeReleaseTarball = callPackage ./make-release-tarball.nix { };
|
||||
|
||||
collectHaskellComponents = project:
|
||||
let
|
||||
|
||||
# These functions pull out from the Haskell project either all the
|
||||
# components of a particular type, or all the checks.
|
||||
|
||||
pkgs = haskell-nix.haskellLib.selectProjectPackages project;
|
||||
|
||||
collectChecks = _:
|
||||
recurseIntoAttrs (builtins.mapAttrs (_: p: p.checks) pkgs);
|
||||
|
||||
collectComponents = type:
|
||||
haskell-nix.haskellLib.collectComponents' type pkgs;
|
||||
|
||||
# Recompute the Haskell package set sliced by component type
|
||||
in builtins.mapAttrs (type: f: f type) {
|
||||
# These names must match the subcomponent: components.<name>.<...>
|
||||
"library" = collectComponents;
|
||||
"tests" = collectComponents;
|
||||
"benchmarks" = collectComponents;
|
||||
"exes" = collectComponents;
|
||||
"checks" = collectChecks;
|
||||
};
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ let
|
||||
"''${curl[@]}" -s --output "$out" "$href"
|
||||
'';
|
||||
|
||||
impureEnvVars = stdenvNoCC.lib.fetchers.proxyImpureEnvVars;
|
||||
impureEnvVars = lib.fetchers.proxyImpureEnvVars;
|
||||
|
||||
SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";
|
||||
|
||||
|
@ -23,6 +23,4 @@ in prev.lib.optionalAttrs isMusl {
|
||||
rhash = overrideStdenv prev.rhash;
|
||||
|
||||
numactl = overrideStdenv prev.numactl;
|
||||
|
||||
lmdb = overrideStdenv prev.lmdb;
|
||||
}
|
||||
|
@ -9,11 +9,7 @@ in {
|
||||
version = final.sources.h2o.rev;
|
||||
src = final.sources.h2o;
|
||||
outputs = [ "out" "dev" "lib" ];
|
||||
});
|
||||
|
||||
secp256k1 = prev.secp256k1.overrideAttrs (_attrs: {
|
||||
version = final.sources.secp256k1.rev;
|
||||
src = final.sources.secp256k1;
|
||||
meta.platforms = prev.lib.platforms.linux ++ prev.lib.platforms.darwin;
|
||||
});
|
||||
|
||||
libsigsegv = prev.libsigsegv.overrideAttrs (attrs: {
|
||||
@ -23,7 +19,7 @@ in {
|
||||
];
|
||||
});
|
||||
|
||||
curlMinimal = prev.curl.override {
|
||||
curlUrbit = prev.curlMinimal.override {
|
||||
http2Support = false;
|
||||
scpSupport = false;
|
||||
gssSupport = false;
|
||||
|
@ -16,7 +16,7 @@ let
|
||||
in {
|
||||
gmp = enableStatic prev.gmp;
|
||||
|
||||
curlMinimal = enableStatic prev.curlMinimal;
|
||||
curlUrbit = enableStatic prev.curlUrbit;
|
||||
|
||||
libuv = enableStatic prev.libuv;
|
||||
|
||||
@ -26,12 +26,8 @@ in {
|
||||
|
||||
lmdb = prev.lmdb.overrideAttrs (old:
|
||||
configureFlags old // {
|
||||
# Why remove the so version? It's easier than preventing it from being
|
||||
# built with lmdb's custom Makefiles, and it can't exist in the output
|
||||
# because otherwise the linker will preferentially choose the .so over
|
||||
# the .a.
|
||||
postInstall = ''
|
||||
rm $out/lib/liblmdb.so
|
||||
postPatch = ''
|
||||
sed '/^ILIBS\t/s/liblmdb\$(SOEXT)//' -i Makefile
|
||||
'';
|
||||
});
|
||||
}
|
||||
|
@ -1,90 +0,0 @@
|
||||
{ lib, stdenv, darwin, haskell-nix, lmdb, gmp, zlib, libffi, brass
|
||||
, enableStatic ? stdenv.hostPlatform.isStatic }:
|
||||
|
||||
haskell-nix.stackProject {
|
||||
compiler-nix-name = "ghc884";
|
||||
index-state = "2020-09-24T00:00:00Z";
|
||||
|
||||
# This is incredibly difficult to get right, almost everything goes wrong.
|
||||
# See: https://github.com/input-output-hk/haskell.nix/issues/496
|
||||
src = haskell-nix.haskellLib.cleanSourceWith {
|
||||
# Otherwise this depends on the name in the parent directory, which
|
||||
# reduces caching, and is particularly bad on Hercules.
|
||||
# See: https://github.com/hercules-ci/support/issues/40
|
||||
name = "urbit-hs";
|
||||
src = ../../../pkg/hs;
|
||||
};
|
||||
|
||||
modules = [{
|
||||
# This corresponds to the set of packages (boot libs) that ship with GHC.
|
||||
# We declare them yere to ensure any dependency gets them from GHC itself
|
||||
# rather than trying to re-install them into the package database.
|
||||
nonReinstallablePkgs = [
|
||||
"Cabal"
|
||||
"Win32"
|
||||
"array"
|
||||
"base"
|
||||
"binary"
|
||||
"bytestring"
|
||||
"containers"
|
||||
"deepseq"
|
||||
"directory"
|
||||
"filepath"
|
||||
"ghc"
|
||||
"ghc-boot"
|
||||
"ghc-boot-th"
|
||||
"ghc-compact"
|
||||
"ghc-heap"
|
||||
"ghc-prim"
|
||||
"ghci"
|
||||
"ghcjs-prim"
|
||||
"ghcjs-th"
|
||||
"haskeline"
|
||||
"hpc"
|
||||
"integer-gmp"
|
||||
"integer-simple"
|
||||
"mtl"
|
||||
"parsec"
|
||||
"pretty"
|
||||
"process"
|
||||
"rts"
|
||||
"stm"
|
||||
"template-haskell"
|
||||
"terminfo"
|
||||
"text"
|
||||
"time"
|
||||
"transformers"
|
||||
"unix"
|
||||
"xhtml"
|
||||
];
|
||||
|
||||
# Override various project-local flags and build configuration.
|
||||
packages = {
|
||||
urbit-king.components.exes.urbit-king = {
|
||||
enableStatic = enableStatic;
|
||||
enableShared = !enableStatic;
|
||||
|
||||
configureFlags = lib.optionals enableStatic [
|
||||
"--ghc-option=-optl=-L${lmdb}/lib"
|
||||
"--ghc-option=-optl=-L${gmp}/lib"
|
||||
"--ghc-option=-optl=-L${libffi}/lib"
|
||||
"--ghc-option=-optl=-L${zlib}/lib"
|
||||
] ++ lib.optionals (enableStatic && stdenv.isDarwin)
|
||||
[ "--ghc-option=-optl=-L${darwin.libiconv}/lib" ];
|
||||
|
||||
postInstall = lib.optionalString (enableStatic && stdenv.isDarwin) ''
|
||||
find "$out/bin" -type f -exec \
|
||||
install_name_tool -change \
|
||||
${stdenv.cc.libc}/lib/libSystem.B.dylib \
|
||||
/usr/lib/libSystem.B.dylib {} \;
|
||||
'';
|
||||
};
|
||||
|
||||
urbit-king.components.tests.urbit-king-tests.testFlags =
|
||||
[ "--brass-pill=${brass.lfs}" ];
|
||||
|
||||
lmdb.components.library.libs = lib.mkForce [ lmdb ];
|
||||
};
|
||||
}];
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{ lib, stdenv, coreutils, pkgconfig # build/env
|
||||
, cacert, ca-bundle, ivory # codegen
|
||||
, curlMinimal, ent, gmp, h2o, libsigsegv, libuv, lmdb # libs
|
||||
, curlUrbit, ent, gmp, h2o, libsigsegv, libuv, lmdb # libs
|
||||
, murmur3, openssl, softfloat3, urcrypt, zlib #
|
||||
, enableStatic ? stdenv.hostPlatform.isStatic # opts
|
||||
, enableDebug ? false
|
||||
@ -25,7 +25,7 @@ in stdenv.mkDerivation {
|
||||
buildInputs = [
|
||||
cacert
|
||||
ca-bundle
|
||||
curlMinimal
|
||||
curlUrbit
|
||||
ent
|
||||
gmp
|
||||
h2o
|
||||
|
@ -31,6 +31,24 @@
|
||||
"url": "https://github.com/LMDB/lmdb/archive/48a7fed59a8aae623deff415dda27097198ca0c1.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"secp256k1": {
|
||||
"branch": "master",
|
||||
"description": "Optimized C library for ECDSA signatures and secret/public key operations on curve secp256k1.",
|
||||
"homepage": null,
|
||||
"owner": "bitcoin-core",
|
||||
"pmnsh": {
|
||||
"include": "include",
|
||||
"lib": ".libs",
|
||||
"make": "libsecp256k1.la",
|
||||
"prepare": "./autogen.sh && ./configure --disable-shared --enable-benchmark=no --enable-exhaustive-tests=no --enable-experimental --enable-module-ecdh --enable-module-recovery --enable-module-schnorrsig --enable-tests=yes CFLAGS=-DSECP256K1_API="
|
||||
},
|
||||
"repo": "secp256k1",
|
||||
"rev": "7973576f6e3ab27d036a09397152b124d747f4ae",
|
||||
"sha256": "0vjk55dv0mkph4k6bqgkykmxn05ngzvhc4rzjnvn33xzi8dzlvah",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/bitcoin-core/secp256k1/archive/7973576f6e3ab27d036a09397152b124d747f4ae.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"uv": {
|
||||
"branch": "v1.x",
|
||||
"description": "Cross-platform asynchronous I/O",
|
||||
|
104
nix/sources.json
104
nix/sources.json
@ -3,17 +3,17 @@
|
||||
"branch": "master",
|
||||
"description": "H2O - the optimized HTTP/1, HTTP/2, HTTP/3 server",
|
||||
"homepage": "https://h2o.examp1e.net",
|
||||
"pmnsh": {
|
||||
"include": "include",
|
||||
"prepare": "cmake .",
|
||||
"make": "libh2o",
|
||||
"compat": {
|
||||
"mingw": {
|
||||
"prepare": "cmake -G\"MSYS Makefiles\" -DCMAKE_INSTALL_PREFIX=. ."
|
||||
}
|
||||
}
|
||||
},
|
||||
"owner": "h2o",
|
||||
"pmnsh": {
|
||||
"compat": {
|
||||
"mingw": {
|
||||
"prepare": "cmake -G\"MSYS Makefiles\" -DCMAKE_INSTALL_PREFIX=. ."
|
||||
}
|
||||
},
|
||||
"include": "include",
|
||||
"make": "libh2o",
|
||||
"prepare": "cmake ."
|
||||
},
|
||||
"repo": "h2o",
|
||||
"rev": "v2.2.6",
|
||||
"sha256": "0qni676wqvxx0sl0pw9j0ph7zf2krrzqc1zwj73mgpdnsr8rsib7",
|
||||
@ -21,47 +21,23 @@
|
||||
"url": "https://github.com/h2o/h2o/archive/v2.2.6.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"hackage.nix": {
|
||||
"branch": "master",
|
||||
"description": "Automatically generated Nix expressions for Hackage",
|
||||
"homepage": "",
|
||||
"owner": "input-output-hk",
|
||||
"repo": "hackage.nix",
|
||||
"rev": "ed4d2759c9e6ca8133a4170f99fabdd76f30f51a",
|
||||
"sha256": "1n5fk8zsxnbca96zk4ikh74iz3lzh35m302q65zk1rx3nmy4027d",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/input-output-hk/hackage.nix/archive/ed4d2759c9e6ca8133a4170f99fabdd76f30f51a.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"haskell.nix": {
|
||||
"branch": "master",
|
||||
"description": "Alternative Haskell Infrastructure for Nixpkgs",
|
||||
"homepage": "https://input-output-hk.github.io/haskell.nix",
|
||||
"owner": "input-output-hk",
|
||||
"repo": "haskell.nix",
|
||||
"rev": "bbb34dcdf7b90d478002f91713531f418ddf1b53",
|
||||
"sha256": "1qq397j8vnlp5npk8r675fzjfimg74fcvrkxcdgx7vj48315bh2w",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/input-output-hk/haskell.nix/archive/bbb34dcdf7b90d478002f91713531f418ddf1b53.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"libaes_siv": {
|
||||
"branch": "master",
|
||||
"description": null,
|
||||
"homepage": null,
|
||||
"owner": "dfoxfranke",
|
||||
"pmnsh": {
|
||||
"compat": {
|
||||
"m1brew": {
|
||||
"prepare": "cmake .",
|
||||
"make": "install CFLAGS=$(pkg-config --cflags openssl)"
|
||||
"make": "install CFLAGS=$(pkg-config --cflags openssl)",
|
||||
"prepare": "cmake ."
|
||||
},
|
||||
"mingw": {
|
||||
"prepare": "cmake -G\"MSYS Makefiles\" -DDISABLE_DOCS:BOOL=ON .",
|
||||
"make": "aes_siv_static"
|
||||
"make": "aes_siv_static",
|
||||
"prepare": "cmake -G\"MSYS Makefiles\" -DDISABLE_DOCS:BOOL=ON ."
|
||||
}
|
||||
}
|
||||
},
|
||||
"owner":"dfoxfranke",
|
||||
"repo": "libaes_siv",
|
||||
"rev": "9681279cfaa6e6399bb7ca3afbbc27fc2e19df4b",
|
||||
"sha256": "1g4wy0m5wpqx7z6nillppkh5zki9fkx9rdw149qcxh7mc5vlszzi",
|
||||
@ -73,10 +49,10 @@
|
||||
"branch": "master",
|
||||
"description": null,
|
||||
"homepage": null,
|
||||
"owner": "urbit",
|
||||
"pmnsh": {
|
||||
"make": "static"
|
||||
},
|
||||
"owner": "urbit",
|
||||
"repo": "murmur3",
|
||||
"rev": "71a75d57ca4e7ca0f7fc2fd84abd93595b0624ca",
|
||||
"sha256": "0k7jq2nb4ad9ajkr6wc4w2yy2f2hkwm3nkbj2pklqgwsg6flxzwg",
|
||||
@ -97,23 +73,23 @@
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nixpkgs": {
|
||||
"branch": "master",
|
||||
"branch": "nixos-21.11",
|
||||
"description": "Nix Packages collection",
|
||||
"homepage": null,
|
||||
"owner": "nixos",
|
||||
"homepage": "",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "166ab9d237409c4b74b1f8ca31476ead35e8fe53",
|
||||
"sha256": "13i43kvbkdl3dh8b986j6mxbn355mqjhcxrd8cni8zfx1z0wrscr",
|
||||
"rev": "573095944e7c1d58d30fc679c81af63668b54056",
|
||||
"sha256": "07s5cwhskqvy82b4rld9b14ljc0013pig23i3jx3l3f957rk95pg",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/nixos/nixpkgs/archive/166ab9d237409c4b74b1f8ca31476ead35e8fe53.tar.gz",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/573095944e7c1d58d30fc679c81af63668b54056.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"softfloat3": {
|
||||
"branch": "master",
|
||||
"description": null,
|
||||
"homepage": null,
|
||||
"owner": "urbit",
|
||||
"pmnsh": {
|
||||
"include": "source/include",
|
||||
"compat": {
|
||||
"m1brew": {
|
||||
"lib": "build/template-FAST_INT64",
|
||||
@ -123,44 +99,14 @@
|
||||
"lib": "build/Win64-MinGW-w64",
|
||||
"make": "-C build/Win64-MinGW-w64 libsoftfloat3.a"
|
||||
}
|
||||
}
|
||||
},
|
||||
"include": "source/include"
|
||||
},
|
||||
"owner": "urbit",
|
||||
"repo": "berkeley-softfloat-3",
|
||||
"rev": "ec4c7e31b32e07aad80e52f65ff46ac6d6aad986",
|
||||
"sha256": "1lz4bazbf7lns1xh8aam19c814a4n4czq5xsq5rmi9sgqw910339",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/urbit/berkeley-softfloat-3/archive/ec4c7e31b32e07aad80e52f65ff46ac6d6aad986.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"secp256k1": {
|
||||
"branch": "master",
|
||||
"description": "Optimized C library for ECDSA signatures and secret/public key operations on curve secp256k1.",
|
||||
"homepage": null,
|
||||
"pmnsh": {
|
||||
"include": "include",
|
||||
"lib": ".libs",
|
||||
"prepare": "./autogen.sh && ./configure --disable-shared --enable-module-recovery CFLAGS=-DSECP256K1_API=",
|
||||
"make": "libsecp256k1.la"
|
||||
},
|
||||
"owner": "bitcoin-core",
|
||||
"repo": "secp256k1",
|
||||
"rev": "26de4dfeb1f1436dae1fcf17f57bdaa43540f940",
|
||||
"sha256": "03i3nv8d3ci7q9y98q11rrp3rvwdqc0hc0ss0pr6xckybvizsmbb",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/bitcoin-core/secp256k1/archive/26de4dfeb1f1436dae1fcf17f57bdaa43540f940.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"stackage.nix": {
|
||||
"branch": "master",
|
||||
"description": "Automatically generated Nix expressions of Stackage snapshots",
|
||||
"homepage": "",
|
||||
"owner": "input-output-hk",
|
||||
"repo": "stackage.nix",
|
||||
"rev": "08312f475f4f5f3b6578e7a78dc501de6fea8792",
|
||||
"sha256": "15j1l6616kfv7351jxwgb9kj6y8227fcm87nxwabmbn1q6a8q2kf",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/input-output-hk/stackage.nix/archive/08312f475f4f5f3b6578e7a78dc501de6fea8792.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
}
|
||||
}
|
||||
|
210
nix/sources.nix
210
nix/sources.nix
@ -6,149 +6,169 @@ let
|
||||
# The fetchers. fetch_<type> fetches specs of type <type>.
|
||||
#
|
||||
|
||||
fetch_file = pkgs: spec:
|
||||
if spec.builtin or true then
|
||||
builtins_fetchurl { inherit (spec) url sha256; }
|
||||
else
|
||||
pkgs.fetchurl { inherit (spec) url sha256; };
|
||||
fetch_file = pkgs: name: spec:
|
||||
let
|
||||
name' = sanitizeName name + "-src";
|
||||
in
|
||||
if spec.builtin or true then
|
||||
builtins_fetchurl { inherit (spec) url sha256; name = name'; }
|
||||
else
|
||||
pkgs.fetchurl { inherit (spec) url sha256; name = name'; };
|
||||
|
||||
fetch_tarball = pkgs: name: spec:
|
||||
let
|
||||
ok = str: !builtins.isNull (builtins.match "[a-zA-Z0-9+-._?=]" str);
|
||||
# sanitize the name, though nix will still fail if name starts with period
|
||||
name' = stringAsChars (x: if !ok x then "-" else x) "${name}-src";
|
||||
in if spec.builtin or true then
|
||||
builtins_fetchTarball {
|
||||
name = name';
|
||||
inherit (spec) url sha256;
|
||||
}
|
||||
else
|
||||
pkgs.fetchzip {
|
||||
name = name';
|
||||
inherit (spec) url sha256;
|
||||
};
|
||||
name' = sanitizeName name + "-src";
|
||||
in
|
||||
if spec.builtin or true then
|
||||
builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
|
||||
else
|
||||
pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
|
||||
|
||||
fetch_git = spec:
|
||||
builtins.fetchGit {
|
||||
url = spec.repo;
|
||||
inherit (spec) rev ref;
|
||||
};
|
||||
fetch_git = name: spec:
|
||||
let
|
||||
ref =
|
||||
if spec ? ref then spec.ref else
|
||||
if spec ? branch then "refs/heads/${spec.branch}" else
|
||||
if spec ? tag then "refs/tags/${spec.tag}" else
|
||||
abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
|
||||
in
|
||||
builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; };
|
||||
|
||||
fetch_local = spec: spec.path;
|
||||
|
||||
fetch_builtin-tarball = name:
|
||||
throw ''
|
||||
[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`.
|
||||
$ niv modify ${name} -a type=tarball -a builtin=true'';
|
||||
fetch_builtin-tarball = name: throw
|
||||
''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`.
|
||||
$ niv modify ${name} -a type=tarball -a builtin=true'';
|
||||
|
||||
fetch_builtin-url = name:
|
||||
throw ''
|
||||
[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`.
|
||||
$ niv modify ${name} -a type=file -a builtin=true'';
|
||||
fetch_builtin-url = name: throw
|
||||
''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`.
|
||||
$ niv modify ${name} -a type=file -a builtin=true'';
|
||||
|
||||
#
|
||||
# Various helpers
|
||||
#
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695
|
||||
sanitizeName = name:
|
||||
(
|
||||
concatMapStrings (s: if builtins.isList s then "-" else s)
|
||||
(
|
||||
builtins.split "[^[:alnum:]+._?=-]+"
|
||||
((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name)
|
||||
)
|
||||
);
|
||||
|
||||
# The set of packages used when specs are fetched using non-builtins.
|
||||
mkPkgs = sources:
|
||||
mkPkgs = sources: system:
|
||||
let
|
||||
sourcesNixpkgs =
|
||||
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; })
|
||||
{ };
|
||||
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; };
|
||||
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
|
||||
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
|
||||
in if builtins.hasAttr "nixpkgs" sources then
|
||||
sourcesNixpkgs
|
||||
else if hasNixpkgsPath && !hasThisAsNixpkgsPath then
|
||||
import <nixpkgs> { }
|
||||
else
|
||||
abort ''
|
||||
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
|
||||
add a package called "nixpkgs" to your sources.json.
|
||||
'';
|
||||
in
|
||||
if builtins.hasAttr "nixpkgs" sources
|
||||
then sourcesNixpkgs
|
||||
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
|
||||
import <nixpkgs> {}
|
||||
else
|
||||
abort
|
||||
''
|
||||
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
|
||||
add a package called "nixpkgs" to your sources.json.
|
||||
'';
|
||||
|
||||
# The actual fetching function.
|
||||
fetch = pkgs: name: spec:
|
||||
|
||||
if !builtins.hasAttr "type" spec then
|
||||
if ! builtins.hasAttr "type" spec then
|
||||
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
|
||||
else if spec.type == "file" then
|
||||
fetch_file pkgs spec
|
||||
else if spec.type == "tarball" then
|
||||
fetch_tarball pkgs name spec
|
||||
else if spec.type == "git" then
|
||||
fetch_git spec
|
||||
else if spec.type == "local" then
|
||||
fetch_local spec
|
||||
else if spec.type == "builtin-tarball" then
|
||||
fetch_builtin-tarball name
|
||||
else if spec.type == "builtin-url" then
|
||||
fetch_builtin-url name
|
||||
else if spec.type == "file" then fetch_file pkgs name spec
|
||||
else if spec.type == "tarball" then fetch_tarball pkgs name spec
|
||||
else if spec.type == "git" then fetch_git name spec
|
||||
else if spec.type == "local" then fetch_local spec
|
||||
else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
|
||||
else if spec.type == "builtin-url" then fetch_builtin-url name
|
||||
else
|
||||
abort
|
||||
"ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
|
||||
abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
|
||||
|
||||
# If the environment variable NIV_OVERRIDE_${name} is set, then use
|
||||
# the path directly as opposed to the fetched source.
|
||||
replace = name: drv:
|
||||
let
|
||||
saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
|
||||
ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
|
||||
in
|
||||
if ersatz == "" then drv else
|
||||
# this turns the string into an actual Nix path (for both absolute and
|
||||
# relative paths)
|
||||
if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}";
|
||||
|
||||
# Ports of functions for older nix versions
|
||||
|
||||
# a Nix version of mapAttrs if the built-in doesn't exist
|
||||
mapAttrs = builtins.mapAttrs or (f: set:
|
||||
with builtins;
|
||||
listToAttrs (map (attr: {
|
||||
name = attr;
|
||||
value = f attr set.${attr};
|
||||
}) (attrNames set)));
|
||||
mapAttrs = builtins.mapAttrs or (
|
||||
f: set: with builtins;
|
||||
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
|
||||
);
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
|
||||
range = first: last:
|
||||
if first > last then
|
||||
[ ]
|
||||
else
|
||||
builtins.genList (n: first + n) (last - first + 1);
|
||||
range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1);
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
|
||||
stringToCharacters = s:
|
||||
map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
|
||||
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
|
||||
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
|
||||
concatMapStrings = f: list: concatStrings (map f list);
|
||||
concatStrings = builtins.concatStringsSep "";
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
|
||||
optionalAttrs = cond: as: if cond then as else {};
|
||||
|
||||
# fetchTarball version that is compatible between all the versions of Nix
|
||||
builtins_fetchTarball = { url, name, sha256 }@attrs:
|
||||
let inherit (builtins) lessThan nixVersion fetchTarball;
|
||||
in if lessThan nixVersion "1.12" then
|
||||
fetchTarball { inherit name url; }
|
||||
else
|
||||
fetchTarball attrs;
|
||||
builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
|
||||
let
|
||||
inherit (builtins) lessThan nixVersion fetchTarball;
|
||||
in
|
||||
if lessThan nixVersion "1.12" then
|
||||
fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
|
||||
else
|
||||
fetchTarball attrs;
|
||||
|
||||
# fetchurl version that is compatible between all the versions of Nix
|
||||
builtins_fetchurl = { url, sha256 }@attrs:
|
||||
let inherit (builtins) lessThan nixVersion fetchurl;
|
||||
in if lessThan nixVersion "1.12" then
|
||||
fetchurl { inherit url; }
|
||||
else
|
||||
fetchurl attrs;
|
||||
builtins_fetchurl = { url, name ? null, sha256 }@attrs:
|
||||
let
|
||||
inherit (builtins) lessThan nixVersion fetchurl;
|
||||
in
|
||||
if lessThan nixVersion "1.12" then
|
||||
fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
|
||||
else
|
||||
fetchurl attrs;
|
||||
|
||||
# Create the final "sources" from the config
|
||||
mkSources = config:
|
||||
mapAttrs (name: spec:
|
||||
if builtins.hasAttr "outPath" spec then
|
||||
abort
|
||||
"The values in sources.json should not have an 'outPath' attribute"
|
||||
else
|
||||
spec // { outPath = fetch config.pkgs name spec; }) config.sources;
|
||||
mapAttrs (
|
||||
name: spec:
|
||||
if builtins.hasAttr "outPath" spec
|
||||
then abort
|
||||
"The values in sources.json should not have an 'outPath' attribute"
|
||||
else
|
||||
spec // { outPath = replace name (fetch config.pkgs name spec); }
|
||||
) config.sources;
|
||||
|
||||
# The "config" used by the fetchers
|
||||
mkConfig = { sourcesFile ? ./sources.json
|
||||
, sources ? builtins.fromJSON (builtins.readFile sourcesFile)
|
||||
, pkgs ? mkPkgs sources }: rec {
|
||||
mkConfig =
|
||||
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
|
||||
, sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
|
||||
, system ? builtins.currentSystem
|
||||
, pkgs ? mkPkgs sources system
|
||||
}: rec {
|
||||
# The sources, i.e. the attribute set of spec name to spec
|
||||
inherit sources;
|
||||
|
||||
# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
|
||||
inherit pkgs;
|
||||
};
|
||||
in mkSources (mkConfig { }) // {
|
||||
__functor = _: settings: mkSources (mkConfig settings);
|
||||
}
|
||||
|
||||
in
|
||||
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }
|
||||
|
@ -1,6 +1,9 @@
|
||||
{
|
||||
"name": "root",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"node": "16.14.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^7.29.0",
|
||||
"husky": "^6.0.0",
|
||||
|
@ -588,7 +588,7 @@
|
||||
::
|
||||
=/ =purl
|
||||
:- [sec=| por=~ host=[%& turf.next]]
|
||||
[[ext=`~.udon path=/static] query=~]
|
||||
[[ext=~ path=/'~debug'] query=~]
|
||||
=/ =wire
|
||||
(acme-wire try %validate-domain /idx/(scot %ud idx.next))
|
||||
(emit (request wire purl %get ~ ~))
|
||||
@ -1300,11 +1300,11 @@
|
||||
~& [%failed-order-history fal.hit]
|
||||
this
|
||||
::
|
||||
:: install privkey and cert .pem from /=home=/acme, ignores app state
|
||||
:: install privkey and cert .pem from /=base=/acme, ignores app state
|
||||
::TODO refactor this out of %acme, see also arvo#1151
|
||||
::
|
||||
%install-from-clay
|
||||
=/ bas=path /(scot %p our.bow)/home/(scot %da now.bow)/acme
|
||||
=/ bas=path /(scot %p our.bow)/base/(scot %da now.bow)/acme
|
||||
=/ key=wain .^(wain %cx (weld bas /privkey/pem))
|
||||
=/ cer=wain .^(wain %cx (weld bas /cert/pem))
|
||||
(emit %pass /install %arvo %e %rule %cert `[key cer])
|
||||
|
182
pkg/arvo/app/azimuth-rpc.hoon
Normal file
182
pkg/arvo/app/azimuth-rpc.hoon
Normal file
@ -0,0 +1,182 @@
|
||||
:: Azimuth JSON-RPC API
|
||||
::
|
||||
/- rpc=json-rpc
|
||||
/+ naive,
|
||||
azimuth-roll-rpc,
|
||||
json-rpc,
|
||||
*server,
|
||||
default-agent,
|
||||
verb,
|
||||
dbug,
|
||||
agentio
|
||||
|%
|
||||
::
|
||||
+$ card card:agent:gall
|
||||
::
|
||||
+$ state-0 [%0 ~]
|
||||
--
|
||||
::
|
||||
%+ verb |
|
||||
%- agent:dbug
|
||||
::
|
||||
=| state-0
|
||||
=* state -
|
||||
::
|
||||
^- agent:gall
|
||||
=<
|
||||
|_ =bowl:gall
|
||||
+* this .
|
||||
do ~(. +> bowl)
|
||||
def ~(. (default-agent this %|) bowl)
|
||||
::
|
||||
++ on-init
|
||||
^- (quip card _this)
|
||||
~& > 'init'
|
||||
:_ this
|
||||
[%pass /bind %arvo %e %connect [~ /v1/azimuth] dap.bowl]~
|
||||
::
|
||||
++ on-save !>(state)
|
||||
++ on-load
|
||||
|= old=vase
|
||||
^- (quip card _this)
|
||||
[~ this(state !<(state-0 old))]
|
||||
::
|
||||
++ on-poke
|
||||
|= [=mark =vase]
|
||||
^- (quip card _this)
|
||||
|^
|
||||
?> (team:title our.bowl src.bowl)
|
||||
?+ mark (on-poke:def mark vase)
|
||||
%handle-http-request
|
||||
=+ !<([id=@ta req=inbound-request:eyre] vase)
|
||||
:_ this
|
||||
(handle-http-request id req)
|
||||
::
|
||||
%azimuth-action
|
||||
=+ !<([%disconnect bind=binding:eyre] vase)
|
||||
~& >>> "disconnecting at {<bind>}"
|
||||
:_ this
|
||||
[%pass /bind %arvo %e %disconnect bind]~
|
||||
==
|
||||
::
|
||||
++ handle-http-request
|
||||
|= [id=@ta =inbound-request:eyre]
|
||||
^- (list card)
|
||||
|^
|
||||
=* req request.inbound-request
|
||||
=* headers header-list.req
|
||||
=/ req-line (parse-request-line url.req)
|
||||
?. =(method.req %'POST')
|
||||
:: TODO: method not supported
|
||||
::
|
||||
(give-simple-payload:app id not-found:gen)
|
||||
?~ rpc-request=(validate-request:json-rpc body.req)
|
||||
:: TODO: malformed request
|
||||
::
|
||||
(give-simple-payload:app id not-found:gen)
|
||||
=/ [data=(list cage) response=simple-payload:http]
|
||||
(process-rpc-request:do u.rpc-request)
|
||||
%+ weld
|
||||
(give-simple-payload:app id response)
|
||||
|-
|
||||
?~ data ~
|
||||
:_ $(data t.data)
|
||||
^- card
|
||||
[%pass / %agent [our.bowl %azimuth] %poke i.data]
|
||||
--
|
||||
--
|
||||
::
|
||||
++ on-watch
|
||||
|= =path
|
||||
^- (quip card _this)
|
||||
?> (team:title our.bowl src.bowl)
|
||||
?+ path (on-watch:def path)
|
||||
[%http-response *] [~ this]
|
||||
==
|
||||
::
|
||||
++ on-arvo
|
||||
|= [=wire =sign-arvo]
|
||||
^- (quip card _this)
|
||||
?+ sign-arvo (on-arvo:def wire sign-arvo)
|
||||
[%eyre %bound *]
|
||||
~? !accepted.sign-arvo
|
||||
[dap.bowl 'bind rejected!' binding.sign-arvo]
|
||||
[~ this]
|
||||
==
|
||||
::
|
||||
++ on-leave on-leave:def
|
||||
++ on-peek on-peek:def
|
||||
++ on-agent on-agent:def
|
||||
++ on-fail on-fail:def
|
||||
--
|
||||
::
|
||||
|_ =bowl:gall
|
||||
++ process-rpc-request
|
||||
|= req=batch-request:rpc
|
||||
^- [(list cage) simple-payload:http]
|
||||
|^
|
||||
?- -.req
|
||||
%o
|
||||
=/ [data=(unit cage) =response:rpc]
|
||||
(process p.req)
|
||||
[(drop data) (render response)]
|
||||
::
|
||||
%a
|
||||
=| data=(list cage)
|
||||
=| resp=(list response:rpc)
|
||||
|-
|
||||
?~ p.req
|
||||
[(flop data) (render %batch (flop resp))]
|
||||
=/ [dat=(unit cage) res=response:rpc]
|
||||
(process i.p.req)
|
||||
=? data ?=(^ dat) [u.dat data]
|
||||
$(p.req t.p.req, resp [res resp])
|
||||
==
|
||||
::
|
||||
++ render
|
||||
|= res=response:rpc
|
||||
%- json-response:gen
|
||||
(response-to-json:json-rpc res)
|
||||
::
|
||||
++ process
|
||||
|= request:rpc
|
||||
=, azimuth-roll-rpc
|
||||
?. ?=([%map *] params)
|
||||
[~ ~(parse error:json-rpc id)]
|
||||
=/ method=@tas (enkebab method)
|
||||
?+ method [~ ~(method error:json-rpc id)]
|
||||
%get-point `(get-point id +.params point:scry)
|
||||
%get-dns `(get-dns id +.params dns:scry)
|
||||
%get-naive-state `(get-naive id +.params naive-state:scry)
|
||||
%get-refresh `(get-refresh id +.params refresh:scry)
|
||||
==
|
||||
--
|
||||
::
|
||||
++ scry
|
||||
|%
|
||||
++ point
|
||||
|= =ship
|
||||
.^ (unit point:naive)
|
||||
%gx
|
||||
(~(scry agentio bowl) %azimuth /point/(scot %p ship)/noun)
|
||||
==
|
||||
::
|
||||
++ dns
|
||||
.^ (list @t)
|
||||
%gx
|
||||
(~(scry agentio bowl) %azimuth /dns/noun)
|
||||
==
|
||||
::
|
||||
++ naive-state
|
||||
.^ ^state:naive
|
||||
%gx
|
||||
(~(scry agentio bowl) %azimuth /nas/noun)
|
||||
==
|
||||
::
|
||||
++ refresh
|
||||
.^ @dr
|
||||
%gx
|
||||
(~(scry agentio bowl) %azimuth /refresh/noun)
|
||||
==
|
||||
--
|
||||
--
|
@ -54,13 +54,13 @@
|
||||
?: =(broke-continuity i.topics.event-log)
|
||||
=/ who=@ (decode-topics t.topics.event-log ~[%uint])
|
||||
=/ num=@ (decode-results data.event-log ~[%uint])
|
||||
`[who id %rift num]
|
||||
`[who id %rift num %.n]
|
||||
?: =(changed-keys i.topics.event-log)
|
||||
=/ who=@ (decode-topics t.topics.event-log ~[%uint])
|
||||
=/ [enc=octs aut=octs sut=@ud rev=@ud]
|
||||
%+ decode-results data.event-log
|
||||
~[[%bytes-n 32] [%bytes-n 32] %uint %uint]
|
||||
`[who id %keys rev sut (pass-from-eth:azimuth enc aut sut)]
|
||||
`[who id %keys [rev sut (pass-from-eth:azimuth enc aut sut)] %.n]
|
||||
?: =(lost-sponsor i.topics.event-log)
|
||||
=/ [who=@ pos=@]
|
||||
(decode-topics t.topics.event-log ~[%uint %uint])
|
||||
@ -94,6 +94,7 @@
|
||||
:* url.state =(%czar (clan:title our)) ~m5 ~m30
|
||||
launch:contracts:azimuth
|
||||
~[azimuth:contracts:azimuth]
|
||||
~
|
||||
(topics whos.state)
|
||||
==
|
||||
[%pass /wa %agent [our %eth-watcher] %poke %eth-watcher-poke args]
|
||||
|
451
pkg/arvo/app/azimuth.hoon
Normal file
451
pkg/arvo/app/azimuth.hoon
Normal file
@ -0,0 +1,451 @@
|
||||
/- eth-watcher, *dice
|
||||
/+ ethereum,
|
||||
azimuth,
|
||||
naive,
|
||||
dice,
|
||||
default-agent,
|
||||
verb,
|
||||
dbug
|
||||
:: Generally don't update the snapshot until we have clay tombstoning.
|
||||
::
|
||||
/* snap %azimuth-snapshot /app/azimuth/version-0/azimuth-snapshot
|
||||
:: To update, run from dojo:
|
||||
:: -azimuth-snap-state %default 'version-0'
|
||||
::
|
||||
:: To recreate from a full list of logs (at /app/azimuth/logs/eth-logs):
|
||||
:: -azimuth-snap-logs %default 'version-0'
|
||||
::
|
||||
=/ snap=snap-state snap
|
||||
=/ last-snap=@ number.id.snap
|
||||
::
|
||||
=, jael
|
||||
|%
|
||||
+$ app-state
|
||||
$: %5
|
||||
url=@ta
|
||||
=net
|
||||
whos=(set ship)
|
||||
nas=^state:naive
|
||||
own=owners
|
||||
spo=sponsors
|
||||
logs=(list =event-log:rpc:ethereum)
|
||||
==
|
||||
::
|
||||
+$ poke-data
|
||||
$% :: %listen
|
||||
::
|
||||
[%listen whos=(list ship) =source:jael]
|
||||
:: %watch: configure node url and network
|
||||
::
|
||||
[%watch url=@ta =net]
|
||||
==
|
||||
::
|
||||
+$ tagged-diff [=id:block diff:naive]
|
||||
+$ card card:agent:gall
|
||||
:: TODO: add to state?
|
||||
::
|
||||
++ refresh ~m5
|
||||
--
|
||||
::
|
||||
=| state=app-state
|
||||
%- agent:dbug
|
||||
%+ verb |
|
||||
^- agent:gall
|
||||
=<
|
||||
|_ =bowl:gall
|
||||
+* this .
|
||||
do ~(. +> bowl)
|
||||
def ~(. (default-agent this %|) bowl)
|
||||
::
|
||||
++ on-init
|
||||
^- (quip card _this)
|
||||
=/ points=@ud ~(wyt by points.nas.snap)
|
||||
%- %- slog
|
||||
[leaf+"ship: loading azimuth snapshot ({<points>} points)"]~
|
||||
::
|
||||
=: net.state %default
|
||||
nas.state nas.snap
|
||||
own.state owners.snap
|
||||
spo.state sponsors.snap
|
||||
url.state 'http://eth-mainnet.urbit.org:8545'
|
||||
==
|
||||
:_ this
|
||||
?: .^(? %j /(scot %p our.bowl)/fake/(scot %da now.bowl))
|
||||
~
|
||||
:~ :* %pass /old-tracker %agent [our.bowl %hood]
|
||||
%poke %kiln-nuke !>([%azimuth-tracker %|])
|
||||
==
|
||||
::
|
||||
[%pass /init %arvo %b %wait now.bowl]
|
||||
==
|
||||
::
|
||||
++ on-save !>(state)
|
||||
++ on-load
|
||||
|= old=vase
|
||||
^- (quip card _this)
|
||||
|^
|
||||
=+ !<(old-state=app-states old)
|
||||
=? old-state ?=(%0 -.old-state)
|
||||
=, old-state
|
||||
[%1 url net whos nas own *sponsors logs]
|
||||
=^ cards-1 old-state
|
||||
?. ?=(%1 -.old-state)
|
||||
`old-state
|
||||
%- %- slog :_ ~
|
||||
leaf+"ship: loading snapshot with {<(lent logs.old-state)>} events"
|
||||
=. +.state +.old-state
|
||||
=^ cards state
|
||||
(%*(run-logs do nas.state *^state:naive) logs.state)
|
||||
[(jael-update:do (to-udiffs:do cards)) state]
|
||||
=^ cards-2 old-state
|
||||
?. ?=(%2 -.old-state)
|
||||
`old-state
|
||||
~& > '%azimuth: updating to state 3'
|
||||
=. +.state +.old-state
|
||||
:: replace naive state and indices with snapshot
|
||||
::
|
||||
=: nas.state nas.snap
|
||||
own.state owners.snap
|
||||
spo.state sponsors.snap
|
||||
logs.state ~
|
||||
:: TODO: shouldn't be needed but have seen eth-watcher
|
||||
:: threads use a url='' if this is not used
|
||||
::
|
||||
url.state 'http://eth-mainnet.urbit.org:8545'
|
||||
==
|
||||
=/ points=@ud ~(wyt by points.nas.state)
|
||||
%- %- slog :_ ~
|
||||
leaf+"ship: processing azimuth snapshot ({<points>} points)"
|
||||
=/ snap-cards=udiffs:point (run-state:do id.snap points.nas.state)
|
||||
:_ [%3 +.state]
|
||||
%+ weld
|
||||
(jael-update:do snap-cards)
|
||||
:: start getting new logs after the last id:block in the snapshot
|
||||
::
|
||||
start:do
|
||||
=^ cards-3 old-state
|
||||
?. ?=(%3 -.old-state) [cards-2 old-state]
|
||||
:_ old-state(- %4)
|
||||
~& > '%azimuth: updating to state 4'
|
||||
[%pass /resend-pk %arvo %j %resend ~]^cards-2
|
||||
=^ cards-4 old-state
|
||||
?. ?=(%4 -.old-state) [cards-3 old-state]
|
||||
=^ cards this
|
||||
%- %*(. on-poke +.state.this +.old-state)
|
||||
[%azimuth-poke !>([%watch [url net]:old-state])]
|
||||
~& > '%azimuth: updating to state 5'
|
||||
[cards state.this(- %5)]
|
||||
?> ?=(%5 -.old-state)
|
||||
[cards-4 this(state old-state)]
|
||||
::
|
||||
++ app-states $%(state-0 state-1-2-3-4 app-state)
|
||||
::
|
||||
+$ state-1-2-3-4
|
||||
$: ?(%1 %2 %3 %4)
|
||||
url=@ta
|
||||
=net
|
||||
whos=(set ship)
|
||||
nas=^state:naive
|
||||
own=owners
|
||||
spo=sponsors
|
||||
logs=(list =event-log:rpc:ethereum)
|
||||
==
|
||||
::
|
||||
++ state-0
|
||||
$: %0
|
||||
url=@ta
|
||||
=net
|
||||
whos=(set ship)
|
||||
nas=^state:naive
|
||||
own=owners
|
||||
logs=(list =event-log:rpc:ethereum)
|
||||
==
|
||||
--
|
||||
::
|
||||
++ on-poke
|
||||
|= [=mark =vase]
|
||||
^- (quip card _this)
|
||||
?: =(%noun mark)
|
||||
?+ q.vase !!
|
||||
::
|
||||
%rerun
|
||||
=/ points=@ud ~(wyt by points.nas.state)
|
||||
~& > "rerunning ({<points>} points)"
|
||||
=/ =udiffs:point
|
||||
(run-state:do (last-block-id:dice logs.state) points.nas.state)
|
||||
[(jael-update:do udiffs) this]
|
||||
::
|
||||
%resub
|
||||
:_ this :_ ~
|
||||
:* %pass /eth-watcher %agent [our.bowl %eth-watcher]
|
||||
%watch /logs/[dap.bowl]
|
||||
==
|
||||
::
|
||||
%resnap
|
||||
=: nas.state nas.snap
|
||||
own.state owners.snap
|
||||
spo.state sponsors.snap
|
||||
==
|
||||
`this
|
||||
==
|
||||
::
|
||||
?. ?=(%azimuth-poke mark)
|
||||
(on-poke:def mark vase)
|
||||
=+ !<(poke=poke-data vase)
|
||||
?- -.poke
|
||||
%listen
|
||||
[[%pass /lo %arvo %j %listen (silt whos.poke) source.poke]~ this]
|
||||
::
|
||||
%watch
|
||||
=: nas.state ?:(?=(%default net.poke) nas.snap *^state:naive)
|
||||
own.state ?:(?=(%default net.poke) owners.snap ~)
|
||||
spo.state ?:(?=(%default net.poke) sponsors.snap ~)
|
||||
net.state net.poke
|
||||
url.state url.poke
|
||||
logs.state ~
|
||||
==
|
||||
[start:do this]
|
||||
==
|
||||
::
|
||||
++ on-watch
|
||||
|= =path
|
||||
^- (quip card _this)
|
||||
?< =(/sole/drum path)
|
||||
?: =(/event path)
|
||||
:_ this
|
||||
[%give %fact ~ %naive-state !>([nas.state own.state spo.state])]~
|
||||
=/ who=(unit ship)
|
||||
?~ path ~
|
||||
?: ?=([@ ~] path) ~
|
||||
`(slav %p i.path)
|
||||
=. whos.state
|
||||
?~ who
|
||||
~
|
||||
(~(put in whos.state) u.who)
|
||||
^- (quip card _this)
|
||||
:: Slow to recalculate all the diffs, but this is necessary to make
|
||||
:: sure Jael gets the updates from the snapshot
|
||||
::
|
||||
=/ points=@ud ~(wyt by points.nas.state)
|
||||
%- %- slog :_ ~
|
||||
:- %leaf
|
||||
"ship: processing azimuth snapshot ({<points>} points)"
|
||||
=/ snap-cards=udiffs:point
|
||||
(%*(run-state do logs.state ~) id.snap points.nas.state)
|
||||
[(weld (jael-update:do snap-cards) start:do) this]
|
||||
::
|
||||
++ on-leave on-leave:def
|
||||
++ on-peek
|
||||
|= =path
|
||||
^- (unit (unit cage))
|
||||
|^
|
||||
?+ path (on-peek:def path)
|
||||
[%x %logs ~] ``noun+!>(logs.state)
|
||||
[%x %nas ~] ``noun+!>(nas.state)
|
||||
[%x %dns ~] ``noun+!>(dns.nas.state)
|
||||
[%x %own ~] ``noun+!>(own.state)
|
||||
[%x %spo ~] ``noun+!>(spo.state)
|
||||
[%x %refresh ~] ``atom+!>(refresh)
|
||||
[%x %point @ ~] ``noun+(point i.t.t.path)
|
||||
==
|
||||
::
|
||||
++ point
|
||||
|= wat=@t
|
||||
^- vase
|
||||
!> ^- (unit point:naive)
|
||||
?~ ship=(rush wat ;~(pfix sig fed:ag))
|
||||
~
|
||||
(get:orm:naive points.nas.state u.ship)
|
||||
--
|
||||
::
|
||||
++ on-agent
|
||||
|= [=wire =sign:agent:gall]
|
||||
^- (quip card _this)
|
||||
?. ?=([%eth-watcher ~] wire)
|
||||
(on-agent:def wire sign)
|
||||
?. ?=(%fact -.sign)
|
||||
(on-agent:def wire sign)
|
||||
?. ?=(%eth-watcher-diff p.cage.sign)
|
||||
(on-agent:def wire sign)
|
||||
=+ !<(diff=diff:eth-watcher q.cage.sign)
|
||||
?: ?=(%disavow -.diff)
|
||||
[(jael-update:do [*ship id.diff %disavow ~]~) this]
|
||||
::
|
||||
=. logs.state
|
||||
?- -.diff
|
||||
:: %history loglist.diff
|
||||
%history (welp logs.state loglist.diff)
|
||||
%logs (welp logs.state loglist.diff)
|
||||
==
|
||||
:: doing :azimuth|watch caused a l2-sig-fail when using the eth-log
|
||||
:: snapshot because we were not updating nas with the saved logs.
|
||||
::
|
||||
:: now (L: 189) nas.state is loaded with the contents of the snapshot,
|
||||
:: if we are on the %default network.
|
||||
::
|
||||
=^ effects state (run-logs:do loglist.diff)
|
||||
:_ this
|
||||
%+ weld
|
||||
(event-update:do effects)
|
||||
(jael-update:do (to-udiffs:do effects))
|
||||
::
|
||||
++ on-arvo
|
||||
|= [=wire =sign-arvo]
|
||||
?. &(=(/init wire) ?=(%wake +<.sign-arvo))
|
||||
(on-arvo:def wire sign-arvo)
|
||||
?^ error.sign-arvo
|
||||
%- (slog 'azimuth: failed to initialize!' ~)
|
||||
`this
|
||||
:_ this
|
||||
:~ :* %pass /eth-watcher %agent [our.bowl %eth-watcher]
|
||||
%watch /logs/[dap.bowl]
|
||||
==
|
||||
::
|
||||
[%pass /lo %arvo %j %listen ~ [%| dap.bowl]]
|
||||
==
|
||||
::
|
||||
++ on-fail on-fail:def
|
||||
--
|
||||
|_ =bowl:gall
|
||||
:: TODO: maybe flop the endianness here so metamask signs it in normal
|
||||
:: order?
|
||||
::
|
||||
++ verifier
|
||||
^- ^verifier:naive
|
||||
|= [dat=octs v=@ r=@ s=@]
|
||||
?: (gth v 3) ~ :: TODO: move to jet
|
||||
=/ result
|
||||
%- mule
|
||||
|.
|
||||
=, secp256k1:secp:crypto
|
||||
%- address-from-pub:key:ethereum
|
||||
%- serialize-point
|
||||
(ecdsa-raw-recover (keccak-256:keccak:crypto dat) v r s)
|
||||
?- -.result
|
||||
%| ~
|
||||
%& `p.result
|
||||
==
|
||||
::
|
||||
++ topics
|
||||
|= ships=(set ship)
|
||||
^- (list ?(@ux (list @ux)))
|
||||
~
|
||||
::
|
||||
++ run-state
|
||||
|= [=id:block =points:naive]
|
||||
::%- road |. :: count memory usage in a separate road
|
||||
^- =udiffs:point
|
||||
%- flop
|
||||
%+ roll (tap:orp:dice points)
|
||||
|= [[=ship naive-point=point:naive] =udiffs:point]
|
||||
=, naive-point
|
||||
=/ =pass
|
||||
(pass-from-eth:azimuth [32^crypt 32^auth suite]:keys.net)
|
||||
^- (list [@p udiff:point])
|
||||
:* [ship id %rift rift.net %.y]
|
||||
[ship id %keys [life.keys.net suite.keys.net pass] %.y]
|
||||
[ship id %spon ?:(has.sponsor.net `who.sponsor.net ~)]
|
||||
udiffs
|
||||
==
|
||||
::
|
||||
++ run-logs
|
||||
|= [logs=(list event-log:rpc:ethereum)]
|
||||
^- (quip tagged-diff _state)
|
||||
=+ net=(get-network:dice net.state)
|
||||
=| effects=(list tagged-diff)
|
||||
!. :: saves 700MB replaying snapshot
|
||||
=- =/ res (mule -)
|
||||
?- -.res
|
||||
%& p.res
|
||||
%| (mean 'naive: fail!' p.res)
|
||||
==
|
||||
|.
|
||||
?~ logs
|
||||
[(flop effects) state]
|
||||
?~ mined.i.logs
|
||||
$(logs t.logs)
|
||||
=+ cache=nas.state
|
||||
=^ raw-effects nas.state
|
||||
=/ =^input:naive
|
||||
:- block-number.u.mined.i.logs
|
||||
?: =(azimuth.net address.i.logs)
|
||||
=/ data (data-to-hex:dice data.i.logs)
|
||||
=/ =event-log:naive
|
||||
[address.i.logs data topics.i.logs]
|
||||
[%log event-log]
|
||||
?~ input.u.mined.i.logs
|
||||
[%bat *@]
|
||||
[%bat u.input.u.mined.i.logs]
|
||||
(%*(. naive lac |) verifier chain-id.net nas.state input)
|
||||
:: TODO: make index update optional?
|
||||
::
|
||||
=/ =indices [own spo]:state
|
||||
=. indices
|
||||
?: =(naive.net address.i.logs)
|
||||
(tx-effects:dice chain-id.net raw-effects cache indices)
|
||||
=< indices
|
||||
(point-effects:dice raw-effects points.cache points.nas.state indices)
|
||||
=: own.state own.indices
|
||||
spo.state spo.indices
|
||||
==
|
||||
=/ effects-1
|
||||
=/ =id:block [block-hash block-number]:u.mined.i.logs
|
||||
(turn raw-effects |=(=diff:naive [id diff]))
|
||||
=. effects (welp (flop effects-1) effects)
|
||||
$(logs t.logs)
|
||||
::
|
||||
++ to-udiffs
|
||||
|= effects=(list tagged-diff)
|
||||
^- =udiffs:point
|
||||
%+ murn effects
|
||||
|= tag=tagged-diff
|
||||
^- (unit [=ship =udiff:point])
|
||||
?. ?=(%point +<.tag) ~
|
||||
?+ +>+<.tag ~
|
||||
%rift `[ship.tag id.tag %rift rift.tag %.n]
|
||||
%sponsor `[ship.tag id.tag %spon sponsor.tag]
|
||||
%keys
|
||||
=/ =pass
|
||||
(pass-from-eth:azimuth 32^crypt.keys.tag 32^auth.keys.tag suite.keys.tag)
|
||||
`[ship.tag id.tag %keys [life.keys.tag suite.keys.tag pass] %.n]
|
||||
==
|
||||
::
|
||||
++ jael-update
|
||||
|= =udiffs:point
|
||||
^- (list card)
|
||||
:: ?: & ~ :: XX
|
||||
:- [%give %fact ~[/] %azimuth-udiffs !>(udiffs)]
|
||||
|- ^- (list card)
|
||||
?~ udiffs
|
||||
~
|
||||
=/ =path /(scot %p ship.i.udiffs)
|
||||
:: Should really give all diffs involving each ship at the same time
|
||||
::
|
||||
:- [%give %fact ~[path] %azimuth-udiffs !>(~[i.udiffs])]
|
||||
$(udiffs t.udiffs)
|
||||
::
|
||||
++ event-update
|
||||
|= effects=(list tagged-diff)
|
||||
^- (list card)
|
||||
%+ murn effects
|
||||
|= tag=tagged-diff
|
||||
^- (unit card)
|
||||
?. |(?=(%tx +<.tag) ?=(%point +<.tag)) ~
|
||||
%- some
|
||||
^- card
|
||||
[%give %fact ~[/event] %naive-diffs !>(+.tag)]
|
||||
::
|
||||
++ start
|
||||
^- (list card)
|
||||
=+ net=(get-network:dice net.state)
|
||||
=/ args=vase !>
|
||||
:+ %watch /[dap.bowl]
|
||||
^- config:eth-watcher
|
||||
:* url.state =(%czar (clan:title our.bowl)) refresh ~h30
|
||||
(max launch.net ?:(=(net.state %default) +(last-snap) 0))
|
||||
~[azimuth.net]
|
||||
~[naive.net]
|
||||
(topics whos.state)
|
||||
==
|
||||
[%pass /wa %agent [our.bowl %eth-watcher] %poke %eth-watcher-poke args]~
|
||||
--
|
BIN
pkg/arvo/app/azimuth/version-0.azimuth-snapshot
Normal file
BIN
pkg/arvo/app/azimuth/version-0.azimuth-snapshot
Normal file
Binary file not shown.
@ -200,6 +200,9 @@
|
||||
=/ contracts (get-contracts network)
|
||||
?+ -.call ecliptic:contracts
|
||||
%send-point delegated-sending:contracts
|
||||
::
|
||||
?(%approve-batch-transfer %transfer-batch %withdraw)
|
||||
linear-star-release:contracts
|
||||
==
|
||||
::
|
||||
++ deed
|
||||
@ -379,7 +382,7 @@
|
||||
?> =(%king (clan:title s))
|
||||
(~(put in ss) (^sein:title s))
|
||||
|-
|
||||
?~ parents txs
|
||||
?~ parents !! ::txs
|
||||
=. txs
|
||||
%+ do-here ecliptic:mainnet-contracts
|
||||
(set-spawn-proxy:dat i.parents lockup-contract)
|
||||
@ -394,15 +397,18 @@
|
||||
=. txs
|
||||
%+ do-here ecliptic:mainnet-contracts
|
||||
(set-transfer-proxy:dat i.what lockup-contract)
|
||||
=. txs
|
||||
%+ do-here lockup-contract
|
||||
(deposit:dat to i.what)
|
||||
$(what t.what)
|
||||
==
|
||||
:: depositing
|
||||
::
|
||||
|-
|
||||
?~ what txs
|
||||
=. txs
|
||||
%+ do-here lockup-contract
|
||||
(deposit:dat to i.what)
|
||||
:: =. txs
|
||||
:: %+ do-here lockup-contract
|
||||
:: (deposit:dat to i.what)
|
||||
$(what t.what)
|
||||
++ do-here
|
||||
|= [contract=address dat=tape]
|
||||
|
@ -902,6 +902,9 @@
|
||||
%dv (dy-sing hand+q.bil %a p.bil (snoc q.bil %hoon))
|
||||
%ge (dy-run-generator (dy-cage p.p.p.bil) q.p.bil)
|
||||
%sa
|
||||
=/ has-mark .?((get-fit:clay he-beak %mar p.bil))
|
||||
?. has-mark
|
||||
(he-diff(poy ~) %tan leaf+"dojo: %{(trip p.bil)} missing" ~)
|
||||
=+ .^(=dais:clay cb+(en-beam he-beak /[p.bil]))
|
||||
(dy-hand p.bil *vale:dais)
|
||||
::
|
||||
@ -910,8 +913,12 @@
|
||||
=/ has-mark .?((get-fit:clay he-beak %mar p.bil))
|
||||
?. has-mark :: yolo
|
||||
(dy-hand p.bil q.cag)
|
||||
=+ .^(=tube:clay cc+(en-beam he-beak /[p.cag]/[p.bil]))
|
||||
(dy-hand p.bil (tube q.cag))
|
||||
=/ res
|
||||
=+ .^(=tube:clay cc+(en-beam he-beak /[p.cag]/[p.bil]))
|
||||
(mule |.((tube q.cag)))
|
||||
?: ?=(%| -.res)
|
||||
(he-diff(poy ~) %tan leaf+"dojo: %as %{(trip p.bil)} failed" p.res)
|
||||
(dy-hand p.bil p.res)
|
||||
::
|
||||
%do
|
||||
=/ gat (dy-eval p.bil)
|
||||
|
@ -8,7 +8,7 @@
|
||||
=> |%
|
||||
+$ card card:agent:gall
|
||||
+$ app-state
|
||||
$: %4
|
||||
$: %5
|
||||
dogs=(map path watchdog)
|
||||
==
|
||||
::
|
||||
@ -23,7 +23,7 @@
|
||||
==
|
||||
::
|
||||
:: history: newest block first, oldest event first
|
||||
+$ history (list loglist)
|
||||
+$ history (list loglist)
|
||||
--
|
||||
::
|
||||
:: Helpers
|
||||
@ -112,14 +112,16 @@
|
||||
::
|
||||
=? old-state ?=(%3 -.old-state)
|
||||
%- (slog leaf+"upgrading eth-watcher from %3" ~)
|
||||
^- app-state
|
||||
^- app-state-4
|
||||
%= old-state
|
||||
- %4
|
||||
dogs
|
||||
%- ~(run by dogs.old-state)
|
||||
|= dog=watchdog-3
|
||||
^- watchdog-4
|
||||
%= dog
|
||||
-
|
||||
^- config-4
|
||||
=, -.dog
|
||||
[url eager refresh-rate (mul refresh-rate 6) from contracts topics]
|
||||
::
|
||||
@ -129,10 +131,80 @@
|
||||
==
|
||||
==
|
||||
::
|
||||
[cards-1 this(state ?>(?=(%4 -.old-state) old-state))]
|
||||
=? old-state ?=(%4 -.old-state)
|
||||
%- (slog leaf+"upgrading eth-watcher from %4" ~)
|
||||
^- app-state
|
||||
%= old-state
|
||||
- %5
|
||||
dogs
|
||||
%- ~(run by dogs.old-state)
|
||||
|= dog=watchdog-4
|
||||
%= dog
|
||||
-
|
||||
=, -.dog
|
||||
[url eager refresh-rate timeout-time from contracts ~ topics]
|
||||
::
|
||||
pending-logs-4
|
||||
%- ~(run by pending-logs-4.dog)
|
||||
|= =loglist-4
|
||||
%+ turn loglist-4
|
||||
|= =event-log-4
|
||||
event-log-4(mined ?~(mined.event-log-4 ~ `mined.event-log-4))
|
||||
::
|
||||
history-4
|
||||
%+ turn history-4.dog
|
||||
|= =loglist-4
|
||||
%+ turn loglist-4
|
||||
|= =event-log-4
|
||||
event-log-4(mined ?~(mined.event-log-4 ~ `mined.event-log-4))
|
||||
==
|
||||
==
|
||||
::
|
||||
[cards-1 this(state ?>(?=(%5 -.old-state) old-state))]
|
||||
::
|
||||
+$ app-states
|
||||
$%(app-state-0 app-state-1 app-state-2 app-state-3 app-state)
|
||||
$%(app-state-0 app-state-1 app-state-2 app-state-3 app-state-4 app-state)
|
||||
::
|
||||
+$ app-state-4
|
||||
$: %4
|
||||
dogs=(map path watchdog-4)
|
||||
==
|
||||
::
|
||||
+$ watchdog-4
|
||||
$: config-4
|
||||
running=(unit [since=@da =tid:spider])
|
||||
=number:block
|
||||
=pending-logs-4
|
||||
=history-4
|
||||
blocks=(list block)
|
||||
==
|
||||
::
|
||||
+$ config-4
|
||||
$: url=@ta
|
||||
eager=?
|
||||
refresh-rate=@dr
|
||||
timeout-time=@dr
|
||||
from=number:block
|
||||
contracts=(list address:ethereum)
|
||||
=topics
|
||||
==
|
||||
+$ pending-logs-4 (map number:block loglist-4)
|
||||
+$ history-4 (list loglist-4)
|
||||
+$ loglist-4 (list event-log-4)
|
||||
+$ event-log-4
|
||||
$: $= mined %- unit
|
||||
$: log-index=@ud
|
||||
transaction-index=@ud
|
||||
transaction-hash=@ux
|
||||
block-number=@ud
|
||||
block-hash=@ux
|
||||
removed=?
|
||||
==
|
||||
::
|
||||
address=@ux
|
||||
data=@t
|
||||
topics=(lest @ux)
|
||||
==
|
||||
::
|
||||
+$ app-state-3
|
||||
$: %3
|
||||
@ -143,8 +215,8 @@
|
||||
$: config-3
|
||||
running=(unit =tid:spider)
|
||||
=number:block
|
||||
=pending-logs
|
||||
=history
|
||||
=pending-logs-4
|
||||
=history-4
|
||||
blocks=(list block)
|
||||
==
|
||||
::
|
||||
@ -171,8 +243,8 @@
|
||||
$: config-1
|
||||
running=(unit =tid:spider)
|
||||
=number:block
|
||||
=pending-logs
|
||||
=history
|
||||
=pending-logs-4
|
||||
=history-4
|
||||
blocks=(list block)
|
||||
==
|
||||
::
|
||||
@ -193,8 +265,8 @@
|
||||
$: config-0
|
||||
running=(unit =tid:spider)
|
||||
=number:block
|
||||
=pending-logs
|
||||
=history
|
||||
=pending-logs-4
|
||||
=history-4
|
||||
blocks=(list block)
|
||||
==
|
||||
::
|
||||
|
@ -212,6 +212,7 @@
|
||||
public:mainnet-contracts
|
||||
~[azimuth delegated-sending]:mainnet-contracts
|
||||
~
|
||||
~
|
||||
==
|
||||
::
|
||||
:: see also comment in +setup-cards
|
||||
|
@ -32,7 +32,8 @@
|
||||
++ on-watch
|
||||
|= =path
|
||||
^- (quip card:agent:gall _this)
|
||||
?> ?=([%session @ ~] path)
|
||||
?> =(our src):bowl
|
||||
?> ?=([%session @ %view ~] path)
|
||||
:_ this
|
||||
:: scry prompt and cursor position out of dill for initial response
|
||||
::
|
||||
@ -57,12 +58,13 @@
|
||||
:_ this
|
||||
%+ turn p.sign-arvo
|
||||
|= =blit:dill
|
||||
[%give %fact [%session %$ ~]~ %blit !>(blit)]
|
||||
[%give %fact [%session %$ %view ~]~ %blit !>(blit)]
|
||||
==
|
||||
::
|
||||
++ on-poke
|
||||
|= [=mark =vase]
|
||||
^- (quip card:agent:gall _this)
|
||||
?> =(our src):bowl
|
||||
?. ?=(%belt mark)
|
||||
~| [%unexpected-mark mark]
|
||||
!!
|
||||
|
@ -2,27 +2,28 @@
|
||||
/+ drum=hood-drum, helm=hood-helm, kiln=hood-kiln
|
||||
|%
|
||||
+$ state
|
||||
$~ [%22 *state:drum *state:helm *state:kiln]
|
||||
$>(%22 any-state)
|
||||
$~ [%23 *state:drum *state:helm *state:kiln]
|
||||
$>(%23 any-state)
|
||||
::
|
||||
+$ any-state
|
||||
$% [ver=?(%1 %2 %3 %4 %5 %6) lac=(map @tas fin-any-state)]
|
||||
[%7 drum=state-2:drum helm=state:helm kiln=state-0:kiln]
|
||||
[%8 drum=state-2:drum helm=state:helm kiln=state-0:kiln]
|
||||
[%9 drum=state-2:drum helm=state:helm kiln=state-0:kiln]
|
||||
[%10 drum=state-2:drum helm=state:helm kiln=state-0:kiln]
|
||||
[%11 drum=state-2:drum helm=state:helm kiln=state-0:kiln]
|
||||
[%12 drum=state-2:drum helm=state:helm kiln=state-0:kiln]
|
||||
[%13 drum=state-2:drum helm=state:helm kiln=state-1:kiln]
|
||||
[%14 drum=state-2:drum helm=state:helm kiln=state-1:kiln]
|
||||
[%15 drum=state-2:drum helm=state:helm kiln=state-2:kiln]
|
||||
[%16 drum=state-4:drum helm=state:helm kiln=state-3:kiln]
|
||||
[%17 drum=state-4:drum helm=state:helm kiln=state-4:kiln]
|
||||
[%18 drum=state-4:drum helm=state:helm kiln=state-5:kiln]
|
||||
[%19 drum=state-4:drum helm=state:helm kiln=state-6:kiln]
|
||||
[%20 drum=state-4:drum helm=state:helm kiln=state-7:kiln]
|
||||
[%21 drum=state-4:drum helm=state:helm kiln=state-8:kiln]
|
||||
[%22 drum=state-4:drum helm=state:helm kiln=state-9:kiln]
|
||||
[%7 drum=state-2:drum helm=state-1:helm kiln=state-0:kiln]
|
||||
[%8 drum=state-2:drum helm=state-1:helm kiln=state-0:kiln]
|
||||
[%9 drum=state-2:drum helm=state-1:helm kiln=state-0:kiln]
|
||||
[%10 drum=state-2:drum helm=state-1:helm kiln=state-0:kiln]
|
||||
[%11 drum=state-2:drum helm=state-1:helm kiln=state-0:kiln]
|
||||
[%12 drum=state-2:drum helm=state-1:helm kiln=state-0:kiln]
|
||||
[%13 drum=state-2:drum helm=state-1:helm kiln=state-1:kiln]
|
||||
[%14 drum=state-2:drum helm=state-1:helm kiln=state-1:kiln]
|
||||
[%15 drum=state-2:drum helm=state-1:helm kiln=state-2:kiln]
|
||||
[%16 drum=state-4:drum helm=state-1:helm kiln=state-3:kiln]
|
||||
[%17 drum=state-4:drum helm=state-1:helm kiln=state-4:kiln]
|
||||
[%18 drum=state-4:drum helm=state-1:helm kiln=state-5:kiln]
|
||||
[%19 drum=state-4:drum helm=state-1:helm kiln=state-6:kiln]
|
||||
[%20 drum=state-4:drum helm=state-1:helm kiln=state-7:kiln]
|
||||
[%21 drum=state-4:drum helm=state-1:helm kiln=state-8:kiln]
|
||||
[%22 drum=state-4:drum helm=state-1:helm kiln=state-9:kiln]
|
||||
[%23 drum=state-4:drum helm=state-2:helm kiln=state-9:kiln]
|
||||
==
|
||||
+$ any-state-tuple
|
||||
$: drum=any-state:drum
|
||||
@ -48,6 +49,7 @@
|
||||
++ on-fail on-fail:def
|
||||
++ on-init
|
||||
^- step:agent:gall
|
||||
=^ h helm.state on-init:helm-core
|
||||
=^ d drum.state on-init:drum-core
|
||||
=^ k kiln.state on-init:kiln-core
|
||||
[:(welp d k) this]
|
||||
|
384
pkg/arvo/app/roller-rpc.hoon
Normal file
384
pkg/arvo/app/roller-rpc.hoon
Normal file
@ -0,0 +1,384 @@
|
||||
:: Roller JSON-RPC API
|
||||
::
|
||||
/- rpc=json-rpc, *dice
|
||||
/+ naive,
|
||||
azimuth-roll-rpc,
|
||||
json-rpc,
|
||||
*server,
|
||||
default-agent,
|
||||
verb,
|
||||
dbug,
|
||||
agentio
|
||||
|%
|
||||
::
|
||||
+$ card card:agent:gall
|
||||
::
|
||||
+$ state-0 [%0 ~]
|
||||
--
|
||||
::
|
||||
%+ verb |
|
||||
%- agent:dbug
|
||||
::
|
||||
=| state-0
|
||||
=* state -
|
||||
::
|
||||
^- agent:gall
|
||||
=<
|
||||
|_ =bowl:gall
|
||||
+* this .
|
||||
do ~(. +> bowl)
|
||||
def ~(. (default-agent this %|) bowl)
|
||||
::
|
||||
++ on-init
|
||||
^- (quip card _this)
|
||||
~& > 'init'
|
||||
:_ this
|
||||
[%pass /bind %arvo %e %connect [~ /v1/roller] dap.bowl]~
|
||||
::
|
||||
++ on-save !>(state)
|
||||
++ on-load
|
||||
|= old=vase
|
||||
^- (quip card _this)
|
||||
[~ this(state !<(state-0 old))]
|
||||
::
|
||||
++ on-poke
|
||||
|= [=mark =vase]
|
||||
^- (quip card _this)
|
||||
|^
|
||||
?> (team:title our.bowl src.bowl)
|
||||
?+ mark (on-poke:def mark vase)
|
||||
%handle-http-request
|
||||
=+ !<([id=@ta req=inbound-request:eyre] vase)
|
||||
:_ this
|
||||
(handle-http-request id req)
|
||||
::
|
||||
%azimuth-action
|
||||
=+ !<([%disconnect bind=binding:eyre] vase)
|
||||
~& >>> "disconnecting at {<bind>}"
|
||||
:_ this
|
||||
[%pass /bind %arvo %e %disconnect bind]~
|
||||
==
|
||||
::
|
||||
++ handle-http-request
|
||||
|= [id=@ta =inbound-request:eyre]
|
||||
^- (list card)
|
||||
|^
|
||||
=* req request.inbound-request
|
||||
=* headers header-list.req
|
||||
=/ req-line (parse-request-line url.req)
|
||||
?. =(method.req %'POST')
|
||||
:: TODO: method not supported
|
||||
::
|
||||
(give-simple-payload:app id not-found:gen)
|
||||
?~ rpc-request=(validate-request:json-rpc body.req)
|
||||
:: TODO: malformed request
|
||||
::
|
||||
(give-simple-payload:app id not-found:gen)
|
||||
=/ [data=(list cage) response=simple-payload:http]
|
||||
(process-rpc-request:do u.rpc-request)
|
||||
%+ weld
|
||||
(give-simple-payload:app id response)
|
||||
|-
|
||||
?~ data ~
|
||||
:_ $(data t.data)
|
||||
^- card
|
||||
[%pass / %agent [our.bowl %roller] %poke i.data]
|
||||
--
|
||||
--
|
||||
::
|
||||
++ on-watch
|
||||
|= =path
|
||||
^- (quip card _this)
|
||||
?> (team:title our.bowl src.bowl)
|
||||
?+ path (on-watch:def path)
|
||||
[%http-response *] [~ this]
|
||||
==
|
||||
::
|
||||
++ on-arvo
|
||||
|= [=wire =sign-arvo]
|
||||
^- (quip card _this)
|
||||
?+ sign-arvo (on-arvo:def wire sign-arvo)
|
||||
[%eyre %bound *]
|
||||
~? !accepted.sign-arvo
|
||||
[dap.bowl 'bind rejected!' binding.sign-arvo]
|
||||
[~ this]
|
||||
==
|
||||
::
|
||||
++ on-leave on-leave:def
|
||||
++ on-peek on-peek:def
|
||||
++ on-agent on-agent:def
|
||||
++ on-fail on-fail:def
|
||||
--
|
||||
::
|
||||
|_ =bowl:gall
|
||||
++ process-rpc-request
|
||||
|= req=batch-request:rpc
|
||||
^- [(list cage) simple-payload:http]
|
||||
|^
|
||||
?- -.req
|
||||
%o
|
||||
=/ [data=(unit cage) =response:rpc]
|
||||
(process p.req)
|
||||
[(drop data) (render response)]
|
||||
::
|
||||
%a
|
||||
=| data=(list cage)
|
||||
=| resp=(list response:rpc)
|
||||
|-
|
||||
?~ p.req
|
||||
[(flop data) (render %batch (flop resp))]
|
||||
=/ [dat=(unit cage) res=response:rpc]
|
||||
(process i.p.req)
|
||||
=? data ?=(^ dat) [u.dat data]
|
||||
$(p.req t.p.req, resp [res resp])
|
||||
==
|
||||
::
|
||||
++ render
|
||||
|= res=response:rpc
|
||||
%- json-response:gen
|
||||
(response-to-json:json-rpc res)
|
||||
::
|
||||
++ process
|
||||
|= request:rpc
|
||||
?. ready:scry
|
||||
:: TODO: move to lib
|
||||
::
|
||||
`[%error id '-32003' 'Roller is not ready']
|
||||
=, azimuth-roll-rpc
|
||||
?. ?=([%map *] params)
|
||||
[~ ~(parse error:json-rpc id)]
|
||||
=/ method=@tas (enkebab method)
|
||||
?: ?=(l2-tx method)
|
||||
(process-rpc id +.params method over-quota:scry)
|
||||
?+ method [~ ~(method error:json-rpc id)]
|
||||
%cancel-transaction (cancel-tx id +.params)
|
||||
%when-next-batch `(next-timer id +.params next-batch:scry)
|
||||
%when-next-slice `(next-timer id +.params next-slice:scry)
|
||||
%spawns-remaining `(spawns-remaining id +.params unspawned:scry)
|
||||
%get-remaining-quota `(quota-remaining id +.params ship-quota:scry)
|
||||
%get-allowance `(ship-allowance id +.params allowance:scry)
|
||||
%get-point `(get-point id +.params point:scry)
|
||||
%get-ships `(get-ships id +.params ships:scry)
|
||||
%get-spawned `(get-spawned id +.params spawned:scry)
|
||||
%get-unspawned `(get-spawned id +.params unspawned:scry)
|
||||
%get-sponsored-points `(sponsored-points id +.params sponsored:scry)
|
||||
%get-owned-points `(get-ships id +.params owned:scry)
|
||||
%get-transferring-for `(get-ships id +.params transfers:scry)
|
||||
%get-manager-for `(get-ships id +.params manager:scry)
|
||||
%get-voting-for `(get-ships id +.params voting:scry)
|
||||
%get-spawning-for `(get-ships id +.params spawning:scry)
|
||||
%get-all-pending `(all:pending id +.params all:pending:scry)
|
||||
%get-pending-by-ship `(ship:pending id +.params ship:pending:scry)
|
||||
%get-pending-by-address `(addr:pending id +.params addr:pending:scry)
|
||||
%get-pending-tx `(hash:pending id +.params hash:pending:scry)
|
||||
%get-transaction-status `(status id +.params tx-status:scry)
|
||||
%get-predicted-state `(get-naive id +.params predicted:scry)
|
||||
%get-nonce `(nonce id +.params nonce:scry)
|
||||
%get-history `(history id +.params addr:history:scry)
|
||||
%get-roller-config `(get-config id +.params config:scry)
|
||||
%get-unsigned-tx `(hash-transaction id +.params chain:scry & |)
|
||||
%prepare-for-signing `(hash-transaction id +.params chain:scry | &)
|
||||
%hash-raw-transaction `(hash-raw-transaction id +.params)
|
||||
==
|
||||
--
|
||||
::
|
||||
++ scry
|
||||
|%
|
||||
++ point
|
||||
|= =ship
|
||||
.^ (unit point:naive)
|
||||
%gx
|
||||
(~(scry agentio bowl) %roller /point/(scot %p ship)/noun)
|
||||
==
|
||||
::
|
||||
++ ships
|
||||
|= =address:naive
|
||||
.^ (list ship)
|
||||
%gx
|
||||
(~(scry agentio bowl) %roller /ships/(scot %ux address)/noun)
|
||||
==
|
||||
::
|
||||
++ spawned
|
||||
|= =ship
|
||||
.^ (list @p)
|
||||
%gx
|
||||
(~(scry agentio bowl) %roller /spawned/(scot %p ship)/noun)
|
||||
==
|
||||
::
|
||||
++ unspawned
|
||||
|= =ship
|
||||
.^ (list @p)
|
||||
%gx
|
||||
(~(scry agentio bowl) %roller /unspawned/(scot %p ship)/noun)
|
||||
==
|
||||
::
|
||||
++ owned
|
||||
|= =address:naive
|
||||
.^ (list ship)
|
||||
%gx
|
||||
(~(scry agentio bowl) %roller /owned/(scot %ux address)/noun)
|
||||
==
|
||||
::
|
||||
++ sponsored
|
||||
|= parent=ship
|
||||
.^ [residents=(list ship) requests=(list ship)]
|
||||
%gx
|
||||
(~(scry agentio bowl) %roller /sponsored/(scot %p parent)/noun)
|
||||
==
|
||||
::
|
||||
++ transfers
|
||||
|= =address:naive
|
||||
.^ (list ship)
|
||||
%gx
|
||||
(~(scry agentio bowl) %roller /transfers/(scot %ux address)/noun)
|
||||
==
|
||||
::
|
||||
++ manager
|
||||
|= =address:naive
|
||||
.^ (list ship)
|
||||
%gx
|
||||
(~(scry agentio bowl) %roller /manager/(scot %ux address)/noun)
|
||||
==
|
||||
::
|
||||
++ voting
|
||||
|= =address:naive
|
||||
.^ (list ship)
|
||||
%gx
|
||||
(~(scry agentio bowl) %roller /voting/(scot %ux address)/noun)
|
||||
==
|
||||
::
|
||||
++ spawning
|
||||
|= =address:naive
|
||||
.^ (list ship)
|
||||
%gx
|
||||
(~(scry agentio bowl) %roller /spawning/(scot %ux address)/noun)
|
||||
==
|
||||
::
|
||||
++ pending
|
||||
|%
|
||||
++ all
|
||||
.^ (list pend-tx)
|
||||
%gx
|
||||
(~(scry agentio bowl) %roller /pending/noun)
|
||||
==
|
||||
::
|
||||
++ ship
|
||||
|= =^ship
|
||||
.^ (list pend-tx)
|
||||
%gx
|
||||
(~(scry agentio bowl) %roller /pending/(scot %p ship)/noun)
|
||||
==
|
||||
::
|
||||
++ addr
|
||||
|= =address:naive
|
||||
.^ (list pend-tx)
|
||||
%gx
|
||||
%+ ~(scry agentio bowl) %roller
|
||||
/pending/[(scot %ux address)]/noun
|
||||
==
|
||||
::
|
||||
++ hash
|
||||
|= keccak=@ux
|
||||
.^ (unit pend-tx)
|
||||
%gx
|
||||
%+ ~(scry agentio bowl) %roller
|
||||
/pending-tx/[(scot %ux keccak)]/noun
|
||||
==
|
||||
--
|
||||
::
|
||||
++ history
|
||||
|%
|
||||
++ addr
|
||||
|= =address:naive
|
||||
.^ (list hist-tx)
|
||||
%gx
|
||||
(~(scry agentio bowl) %roller /history/(scot %ux address)/noun)
|
||||
==
|
||||
--
|
||||
::
|
||||
++ tx-status
|
||||
|= keccak=@ux
|
||||
.^ ^tx-status
|
||||
%gx
|
||||
(~(scry agentio bowl) %roller /tx/(scot %ux keccak)/status/noun)
|
||||
==
|
||||
::
|
||||
++ next-batch
|
||||
.^ time
|
||||
%gx
|
||||
(~(scry agentio bowl) %roller /next-batch/atom)
|
||||
==
|
||||
::
|
||||
++ next-slice
|
||||
.^ time
|
||||
%gx
|
||||
(~(scry agentio bowl) %roller /next-slice/atom)
|
||||
==
|
||||
::
|
||||
++ nonce
|
||||
|= [=ship =proxy:naive]
|
||||
.^ (unit @)
|
||||
%gx
|
||||
%+ ~(scry agentio bowl)
|
||||
%roller
|
||||
/nonce/(scot %p ship)/[proxy]/noun
|
||||
==
|
||||
::
|
||||
++ config
|
||||
^- [azimuth-config roller-config]
|
||||
:- refresh
|
||||
.^ roller-config
|
||||
%gx
|
||||
%+ ~(scry agentio bowl)
|
||||
%roller
|
||||
/config/noun
|
||||
==
|
||||
::
|
||||
++ chain
|
||||
.^ @
|
||||
%gx
|
||||
%+ ~(scry agentio bowl)
|
||||
%roller
|
||||
/chain-id/noun
|
||||
==
|
||||
::
|
||||
++ predicted
|
||||
.^ ^state:naive
|
||||
%gx
|
||||
(~(scry agentio bowl) %roller /predicted/noun)
|
||||
==
|
||||
::
|
||||
++ refresh
|
||||
.^ @dr
|
||||
%gx
|
||||
(~(scry agentio bowl) %azimuth /refresh/noun)
|
||||
==
|
||||
::
|
||||
++ over-quota
|
||||
|= =ship
|
||||
.^ ?
|
||||
%gx
|
||||
(~(scry agentio bowl) %roller /over-quota/(scot %p ship)/atom)
|
||||
==
|
||||
::
|
||||
++ ship-quota
|
||||
|= =ship
|
||||
.^ @ud
|
||||
%gx
|
||||
(~(scry agentio bowl) %roller /ship-quota/(scot %p ship)/atom)
|
||||
==
|
||||
::
|
||||
++ allowance
|
||||
|= =ship
|
||||
.^ (unit @ud)
|
||||
%gx
|
||||
(~(scry agentio bowl) %roller /allowance/(scot %p ship)/noun)
|
||||
==
|
||||
::
|
||||
++ ready
|
||||
.^ ?
|
||||
%gx
|
||||
(~(scry agentio bowl) %roller /ready/atom)
|
||||
==
|
||||
--
|
||||
--
|
1526
pkg/arvo/app/roller.hoon
Normal file
1526
pkg/arvo/app/roller.hoon
Normal file
File diff suppressed because it is too large
Load Diff
@ -50,7 +50,7 @@
|
||||
|=(c=@tD `@tD`?:(=('/' c) '-' c))
|
||||
=/ sing=card
|
||||
:+ %pass /build/mar/[mak]
|
||||
[%arvo %c %warp our.bowl %home ~ %sing %b da+now.bowl /[mak]]
|
||||
[%arvo %c %warp our.bowl q.byk.bowl ~ %sing %b da+now.bowl /[mak]]
|
||||
%_ $
|
||||
paz t.paz
|
||||
fex [sing fex]
|
||||
@ -72,7 +72,7 @@
|
||||
$(daz t.daz)
|
||||
=/ sing=card
|
||||
:+ %pass /build/app/[i.daz]
|
||||
[%arvo %c %warp our.bowl %home ~ %sing %a da+now.bowl dap-pax]
|
||||
[%arvo %c %warp our.bowl q.byk.bowl ~ %sing %a da+now.bowl dap-pax]
|
||||
%_ $
|
||||
daz t.daz
|
||||
fex [sing fex]
|
||||
@ -92,7 +92,7 @@
|
||||
$(paz t.paz)
|
||||
=/ sing=card
|
||||
:+ %pass build+i.paz
|
||||
[%arvo %c %warp our.bowl %home ~ %sing %a da+now.bowl i.paz]
|
||||
[%arvo %c %warp our.bowl q.byk.bowl ~ %sing %a da+now.bowl i.paz]
|
||||
%_ $
|
||||
paz t.paz
|
||||
fex [sing fex]
|
||||
|
@ -1,5 +1,5 @@
|
||||
:~ %acme
|
||||
%azimuth-tracker
|
||||
%azimuth
|
||||
%dbug
|
||||
%dojo
|
||||
%eth-watcher
|
||||
|
@ -10,5 +10,5 @@
|
||||
[leaf+(scow %ud block)]~
|
||||
.^ @ud
|
||||
%gx
|
||||
/(scot %p our)/eth-watcher/(scot %da now)/block/azimuth-tracker/noun
|
||||
/(scot %p our)/eth-watcher/(scot %da now)/block/azimuth/noun
|
||||
==
|
||||
|
4
pkg/arvo/gen/azimuth-rpc/disconnect.hoon
Normal file
4
pkg/arvo/gen/azimuth-rpc/disconnect.hoon
Normal file
@ -0,0 +1,4 @@
|
||||
::
|
||||
:- %say
|
||||
|= [* [=binding:eyre ~] ~]
|
||||
[%azimuth-action %disconnect binding]
|
@ -1,4 +0,0 @@
|
||||
:: Kick azimuth-tracker
|
||||
:- %say
|
||||
|= *
|
||||
[%azimuth-tracker-poke %listen ~ %| %azimuth-tracker]
|
@ -1,4 +0,0 @@
|
||||
:: Change node url for azimuth-tracker
|
||||
:- %say
|
||||
|= [* [url=@ta ~] ~]
|
||||
[%azimuth-tracker-poke %watch url]
|
4
pkg/arvo/gen/azimuth/kick.hoon
Normal file
4
pkg/arvo/gen/azimuth/kick.hoon
Normal file
@ -0,0 +1,4 @@
|
||||
:: Kick azimuth
|
||||
:- %say
|
||||
|= *
|
||||
[%azimuth-poke %listen ~ %| %azimuth]
|
@ -1,4 +1,5 @@
|
||||
:: Add a source for azimuth-tracker
|
||||
:: Add a source for azimuth
|
||||
::
|
||||
=> |%
|
||||
+$ src
|
||||
$% [%ship =ship ~]
|
||||
@ -12,4 +13,4 @@
|
||||
%ship [%& ship.src]
|
||||
%app [%| term.src]
|
||||
==
|
||||
[%azimuth-tracker-poke %listen whos source]
|
||||
[%azimuth-poke %listen whos source]
|
4
pkg/arvo/gen/azimuth/watch.hoon
Normal file
4
pkg/arvo/gen/azimuth/watch.hoon
Normal file
@ -0,0 +1,4 @@
|
||||
:: Change node url and network for azimuth
|
||||
:- %say
|
||||
|= [* [url=@ta net=?(%mainnet %ropsten %local %default) ~] ~]
|
||||
[%azimuth-poke %watch url net]
|
@ -1,30 +0,0 @@
|
||||
/- ms=metadata-store
|
||||
/+ crunch
|
||||
:- %say
|
||||
|= [[now=@da * bec=beak] [csv-path=path from=@da ~] [to=@da groups=(list path) content=(unit ?) ~]]
|
||||
=/ our=@p p.bec
|
||||
:: check given path has `csv` mark
|
||||
::
|
||||
?> =(%csv (snag (dec (lent csv-path)) csv-path))
|
||||
:: get all graph associations ship is a part of
|
||||
::
|
||||
=/ associations=associations:ms
|
||||
(~(scry-graph-associations crunch [our now]))
|
||||
:: filter by input groups, if any (default: all from scry)
|
||||
::
|
||||
=/ filtered-associations=associations:ms
|
||||
?~ groups
|
||||
associations
|
||||
%+ filter-associations-by-group-resources.crunch
|
||||
associations
|
||||
(paths-to-resources.crunch groups)
|
||||
:: walk graphs to extract content
|
||||
::
|
||||
=/ file-content=wain
|
||||
%: ~(walk-graph-associations crunch [our now])
|
||||
filtered-associations
|
||||
?~ content %.n u.content
|
||||
from
|
||||
?: =(*@da to) now to
|
||||
==
|
||||
[%helm-pass (note-write-csv-to-clay.crunch csv-path file-content)]
|
@ -8,7 +8,13 @@
|
||||
::
|
||||
:- %say
|
||||
|= $: [now=@da eny=@uvJ bec=beak]
|
||||
[arg=[syd=desk lab=@tas ~] ~]
|
||||
[arg=[syd=desk lab=@tas ~] aeon=aeon:clay ~]
|
||||
==
|
||||
:: handle optional aeon
|
||||
::
|
||||
=/ aey=(unit aeon:clay)
|
||||
?: =(0 aeon)
|
||||
~
|
||||
`aeon
|
||||
:- %kiln-label
|
||||
[syd lab]:arg
|
||||
[syd.arg lab.arg aey]
|
||||
|
@ -30,4 +30,4 @@
|
||||
?. =(*^rift rift)
|
||||
rift
|
||||
+(.^(^rift j+/(scot %p our)/rift/(scot %da now)/(scot %p mon)))
|
||||
`[mon *id:block:jael %rift rift]
|
||||
`[mon *id:block:jael %rift rift %.n]
|
||||
|
@ -42,4 +42,4 @@
|
||||
leaf+(scow %uw (jam seed))
|
||||
==
|
||||
pub:ex:cub
|
||||
`[mon *id:block:jael %keys life 1 pass]
|
||||
`[mon *id:block:jael %keys [life 1 pass] %.n]
|
||||
|
@ -41,4 +41,4 @@
|
||||
leaf+(scow %uw (jam seed))
|
||||
==
|
||||
pub:ex:cub
|
||||
`[mon *id:block:jael %keys 1 1 pass]
|
||||
`[mon *id:block:jael %keys [1 1 pass] %.n]
|
||||
|
@ -10,7 +10,7 @@
|
||||
:- desk
|
||||
%+ roll arg
|
||||
=| =rein:hood
|
||||
|: [*[on=? =dude:gall] rein(liv liv)]
|
||||
|: [*[on=? =dude:gall] rein=rein(liv liv)]
|
||||
?: on
|
||||
rein(add (~(put in add.rein) dude))
|
||||
rein(sub (~(put in sub.rein) dude))
|
||||
|
@ -10,8 +10,9 @@
|
||||
|= $: [now=@da eny=@uvJ bec=beak]
|
||||
[arg=[@ $@(~ [@ ~])] ~]
|
||||
==
|
||||
:- %drum-start
|
||||
?> ((sane %tas) -.arg)
|
||||
?@ +.arg [q.bec -.arg]
|
||||
?> ((sane %tas) +<.arg)
|
||||
[-.arg +<.arg]
|
||||
=/ [des=@tas dap=@tas]
|
||||
?> ((sane %tas) -.arg)
|
||||
?@ +.arg [q.bec -.arg]
|
||||
?> ((sane %tas) +<.arg)
|
||||
[-.arg +<.arg]
|
||||
[%kiln-rein des & [dap ~ ~] ~]
|
||||
|
6
pkg/arvo/gen/roller/assign.hoon
Normal file
6
pkg/arvo/gen/roller/assign.hoon
Normal file
@ -0,0 +1,6 @@
|
||||
:: Assigns a specific quota to the given ship
|
||||
:: Not providing a quota allows the ship to submit any number of transactions
|
||||
::
|
||||
:- %say
|
||||
|= [* [=ship quota=(unit @ud) ~] ~]
|
||||
[%roller-action %assign ship quota]
|
5
pkg/arvo/gen/roller/commit.hoon
Normal file
5
pkg/arvo/gen/roller/commit.hoon
Normal file
@ -0,0 +1,5 @@
|
||||
:: Submits a new L2 batch with all pending transactions
|
||||
::
|
||||
:- %say
|
||||
|= *
|
||||
[%roller-action %commit ~]
|
7
pkg/arvo/gen/roller/config.hoon
Normal file
7
pkg/arvo/gen/roller/config.hoon
Normal file
@ -0,0 +1,7 @@
|
||||
:: Updates a configuration option for /app/roller
|
||||
::
|
||||
/- *dice
|
||||
::
|
||||
:- %say
|
||||
|= [* [=config ~] ~]
|
||||
[%roller-action %config config]
|
4
pkg/arvo/gen/roller/endpoint.hoon
Normal file
4
pkg/arvo/gen/roller/endpoint.hoon
Normal file
@ -0,0 +1,4 @@
|
||||
::
|
||||
:- %say
|
||||
|= [* [url=@t net=?(%mainnet %ropsten %local) ~] ~]
|
||||
[%roller-action %config %endpoint url net]
|
4
pkg/arvo/gen/roller/frequency.hoon
Normal file
4
pkg/arvo/gen/roller/frequency.hoon
Normal file
@ -0,0 +1,4 @@
|
||||
::
|
||||
:- %say
|
||||
|= [* [freq=@dr ~] ~]
|
||||
[%roller-action %config %frequency freq]
|
5
pkg/arvo/gen/roller/local.hoon
Normal file
5
pkg/arvo/gen/roller/local.hoon
Normal file
@ -0,0 +1,5 @@
|
||||
:: Configures /app/roller to listen to a local Ethereum node
|
||||
::
|
||||
:- %say
|
||||
|= *
|
||||
[%roller-action %config %endpoint 'http://0.0.0.0:8545' %local]
|
5
pkg/arvo/gen/roller/quota.hoon
Normal file
5
pkg/arvo/gen/roller/quota.hoon
Normal file
@ -0,0 +1,5 @@
|
||||
:: Modifies the number of txs a ship is allowed to send, per unit of time (slice)
|
||||
::
|
||||
:- %say
|
||||
|= [* [quota=@ud ~] ~]
|
||||
[%roller-action %config %quota quota]
|
5
pkg/arvo/gen/roller/refuel.hoon
Normal file
5
pkg/arvo/gen/roller/refuel.hoon
Normal file
@ -0,0 +1,5 @@
|
||||
:: Bumps the gas price for a sending transaction
|
||||
::
|
||||
:- %say
|
||||
|= [* [nonce=@ gas=@ud address=(unit @ux) ~] ~]
|
||||
[%roller-action %refuel nonce address gas]
|
10
pkg/arvo/gen/roller/ropsten.hoon
Normal file
10
pkg/arvo/gen/roller/ropsten.hoon
Normal file
@ -0,0 +1,10 @@
|
||||
:: Configures /app/roller to listen to a Ropsten Infura node
|
||||
::
|
||||
:- %say
|
||||
|= *
|
||||
:* %roller-action
|
||||
%config
|
||||
%endpoint
|
||||
'https://ropsten.infura.io/v3/2599df54929b47099bda360958d75aaf'
|
||||
%ropsten
|
||||
==
|
5
pkg/arvo/gen/roller/setkey.hoon
Normal file
5
pkg/arvo/gen/roller/setkey.hoon
Normal file
@ -0,0 +1,5 @@
|
||||
:: Loads a private key into the roller and retrieves its L1 nonce
|
||||
::
|
||||
:- %say
|
||||
|= [* [pk=@t ~] ~]
|
||||
[%roller-action %config %setkey pk]
|
5
pkg/arvo/gen/roller/slice.hoon
Normal file
5
pkg/arvo/gen/roller/slice.hoon
Normal file
@ -0,0 +1,5 @@
|
||||
:: Modifies the unit of time (e.g. ~d1) for each ship's quota
|
||||
::
|
||||
:- %say
|
||||
|= [* [slice=@dr ~] ~]
|
||||
[%roller-action %config %slice slice]
|
@ -1,4 +1,3 @@
|
||||
/- *bill
|
||||
:- %say
|
||||
|= $: [now=@da eny=@uvJ bec=beak]
|
||||
[=desk ~]
|
||||
@ -11,5 +10,5 @@
|
||||
:~ 'sys.kelvin:'
|
||||
leaf/"[%{<lal>} %{<num>}]"
|
||||
'desk.bill:'
|
||||
(sell !>(.^(bill cx+(weld pax /desk/bill))))
|
||||
(sell !>(.^((list dude:gall) cx+(weld pax /desk/bill))))
|
||||
==
|
||||
|
56
pkg/arvo/gen/tx.hoon
Normal file
56
pkg/arvo/gen/tx.hoon
Normal file
@ -0,0 +1,56 @@
|
||||
:: ethereum.request({method: 'personal_sign', params: ['tx',count]}).then(console.log)
|
||||
:: ethereum.request({method: 'eth_sendTransaction', params: [{from: count, gasPrice: '0x2540be400', to: '0xb58101cd3bbbcc6fa40bcdb04bb71623b5c7d39b', gas: '0x10000', data: 'batch', chainId: '0x3'}]}).then(console.log)
|
||||
::
|
||||
/+ eth=ethereum
|
||||
/= tt /tests/lib/naive
|
||||
|%
|
||||
:: Generated by running these commands after modifying eth-sig-util
|
||||
:: such that TypedDataUtils.sign returns the domain separator instead
|
||||
:: of continuing to sign. I think this is basically EIP-712
|
||||
:: compatible, but it also doesn't matter much because we're not
|
||||
:: compatible with the whole EIP anyway. The main thing is to be
|
||||
:: distinct from other names, versions, and chainIds.
|
||||
::
|
||||
:: Alter chainId as necessary
|
||||
::
|
||||
:: sig = require('eth-sig-util')
|
||||
:: domain = [{ name: "name", type: "string" },{ name: "version", type: "string" },{ name: "chainId", type: "uint256" }]
|
||||
:: domainData = {name: "Urbit", version: "1", chainId: 0x1}
|
||||
:: sig.TypedDataUtils.sign({domain: domainData, types: {EIP712Domain: domain}, primaryType: 'EIP712Domain'}, true).toString('hex')
|
||||
::
|
||||
++ domain-separator ropsten-separator
|
||||
++ mainnet-separator
|
||||
0x30e4.9840.ca87.cf16.b969.f49e.4b8d.488f.
|
||||
08a6.88f9.43f5.b07e.7671.6c0d.b2fb.b44b
|
||||
++ ropsten-separator
|
||||
0x77e7.083f.92f9.321e.0a71.a78d.238a.a25a.
|
||||
5689.19d4.6a58.abf6.7bed.2c83.80e1.8692
|
||||
::
|
||||
++ print-for-web3
|
||||
|= =octs
|
||||
^- @t
|
||||
=/ txt (crip (render-hex-bytes:eth octs))
|
||||
?> =(p.octs (met 4 txt))
|
||||
(cat 3 '0x' (rev 4 (met 4 txt) txt))
|
||||
::
|
||||
++ print-for-batch
|
||||
|= =octs
|
||||
^- @t
|
||||
(crip (render-hex-bytes:eth octs))
|
||||
--
|
||||
|= sig=(unit @t)
|
||||
^- @t
|
||||
=/ account (hex-to-num:eth '0xb026b0AA6e686F2386051b31A03E5fB95513e1c0')
|
||||
=/ tx=octs
|
||||
(gen-tx-octs:tt [~ravmun-mitbus %own] %set-spawn-proxy account)
|
||||
=/ prepped=octs (prepare-for-sig:tt 3 0 tx)
|
||||
?~ sig
|
||||
(cat 3 'sign: ' (print-for-web3 prepped))
|
||||
=/ batch=@t
|
||||
%: rap 3
|
||||
'0x26887f26'
|
||||
(print-for-batch tx)
|
||||
(rsh 3^2 u.sig)
|
||||
~
|
||||
==
|
||||
(cat 3 'batch: ' batch)
|
704
pkg/arvo/lib/azimuth-roll-rpc.hoon
Normal file
704
pkg/arvo/lib/azimuth-roll-rpc.hoon
Normal file
@ -0,0 +1,704 @@
|
||||
:: azimuth/roll rpc: command parsing and utilities
|
||||
::
|
||||
/- rpc=json-rpc, *dice
|
||||
/+ naive, json-rpc, lib=naive-transactions
|
||||
::
|
||||
=> :: Utilities
|
||||
::
|
||||
|%
|
||||
+$ spawn-action
|
||||
$? %escape
|
||||
%cancel-escape
|
||||
%adopt
|
||||
%reject
|
||||
%detach
|
||||
==
|
||||
::
|
||||
+$ proxy-action
|
||||
$? %set-management-proxy
|
||||
%set-spawn-proxy
|
||||
%set-transfer-proxy
|
||||
==
|
||||
::
|
||||
++ parse-ship
|
||||
|= jon=json
|
||||
^- (unit @p)
|
||||
?: ?=([%n *] jon)
|
||||
(rush p.jon dem)
|
||||
?. ?=([%s *] jon) ~
|
||||
(rush p.jon ;~(pfix sig fed:ag))
|
||||
:: TODO: from /lib/group-store (move to zuse?)
|
||||
++ enkebab
|
||||
|= str=cord
|
||||
^- @tas
|
||||
~| str
|
||||
=- (fall - str)
|
||||
%+ rush str
|
||||
=/ name
|
||||
%+ cook
|
||||
|= part=tape
|
||||
^- tape
|
||||
?~ part part
|
||||
:- (add i.part 32)
|
||||
t.part
|
||||
;~(plug hig (star low))
|
||||
%+ cook
|
||||
|=(a=(list tape) (crip (zing (join "-" a))))
|
||||
;~(plug (star low) (star name))
|
||||
::
|
||||
++ from-json
|
||||
=, dejs-soft:format
|
||||
|%
|
||||
++ data
|
||||
|%
|
||||
++ keys
|
||||
|= params=(map @t json)
|
||||
^- (unit [encrypt=@ auth=@ crypto-suite=@ breach=?])
|
||||
?~ data=(~(get by params) 'data') ~
|
||||
=; ans=(unit [cryp=(unit @ux) auth=(unit @ux) suit=@ brec=?])
|
||||
?~ ans ~
|
||||
?: |(?=(~ cryp.u.ans) ?=(~ auth.u.ans)) ~
|
||||
(some [u.cryp.u.ans u.auth.u.ans suit.u.ans brec.u.ans])
|
||||
%. u.data
|
||||
%- ot
|
||||
:~ ['encrypt' (cu to-hex so)]
|
||||
['auth' (cu to-hex so)]
|
||||
['cryptoSuite' (su dem)]
|
||||
['breach' bo]
|
||||
==
|
||||
::
|
||||
++ address-transfer
|
||||
|= params=(map @t json)
|
||||
^- (unit [@ux ?])
|
||||
?~ data=(~(get by params) 'data') ~
|
||||
=; ans=(unit [add=(unit @ux) r=?])
|
||||
?~ ans ~
|
||||
?~ add.u.ans ~
|
||||
(some [u.add.u.ans r.u.ans])
|
||||
%. u.data
|
||||
%- ot
|
||||
~[['address' (cu to-hex so)] ['reset' bo]]
|
||||
::
|
||||
++ address-ship
|
||||
|= params=(map @t json)
|
||||
^- (unit [@p @ux])
|
||||
?~ data=(~(get by params) 'data') ~
|
||||
=; ans=(unit [ship=@p add=(unit @ux)])
|
||||
?~ ans ~
|
||||
?~ add.u.ans ~
|
||||
(some [ship.u.ans u.add.u.ans])
|
||||
%. u.data
|
||||
%- ot
|
||||
:~ ['ship' parse-ship]
|
||||
['address' (cu to-hex so)]
|
||||
==
|
||||
::
|
||||
++ address
|
||||
|= params=(map @t json)
|
||||
^- (unit @ux)
|
||||
?~ data=(~(get by params) 'data') ~
|
||||
=; ans=(unit (unit @ux))
|
||||
?~(ans ~ u.ans)
|
||||
%. u.data
|
||||
(ot ['address' (cu to-hex so)]~)
|
||||
::
|
||||
++ ship
|
||||
|= params=(map @t json)
|
||||
^- (unit @p)
|
||||
?~ data=(~(get by params) 'data') ~
|
||||
%. u.data
|
||||
(ot ['ship' parse-ship]~)
|
||||
::
|
||||
++ cancel
|
||||
|= params=(map @t json)
|
||||
^- (unit [l2-tx @p])
|
||||
?~ data=(~(get by params) 'data') ~
|
||||
%. u.data
|
||||
%- ot
|
||||
:~ ['type' (cu l2-tx so)]
|
||||
['ship' parse-ship]
|
||||
==
|
||||
--
|
||||
::
|
||||
++ ship
|
||||
|= params=(map @t json)
|
||||
^- (unit @p)
|
||||
?~ data=(~(get by params) 'ship') ~
|
||||
(parse-ship u.data)
|
||||
::
|
||||
++ address
|
||||
|= params=(map @t json)
|
||||
^- (unit @ux)
|
||||
?~ data=(~(get by params) 'address') ~
|
||||
?~ ans=((cu to-hex so) u.data) ~
|
||||
u.ans
|
||||
::
|
||||
++ sig
|
||||
|= params=(map @t json)
|
||||
^- (unit @)
|
||||
?~ sig=(~(get by params) 'sig') ~
|
||||
?~ ans=((cu to-hex so) u.sig) ~
|
||||
u.ans
|
||||
::
|
||||
++ from
|
||||
|= params=(map @t json)
|
||||
^- (unit [@p proxy:naive])
|
||||
?~ from=(~(get by params) 'from') ~
|
||||
%. u.from
|
||||
%- ot
|
||||
:~ ['ship' parse-ship]
|
||||
['proxy' (cu proxy:naive so)]
|
||||
==
|
||||
::
|
||||
++ hash
|
||||
|= params=(map @t json)
|
||||
^- (unit @ux)
|
||||
?~ hash=(~(get by params) 'hash') ~
|
||||
?~ ans=((cu to-hex so) u.hash) ~
|
||||
u.ans
|
||||
::
|
||||
++ raw
|
||||
|= params=(map @t json)
|
||||
^- (unit octs)
|
||||
?~ raw=(~(get by params) 'raw') ~
|
||||
?~ ans=((cu to-hex so) u.raw) ~
|
||||
?~ u.ans ~
|
||||
(some (as-octs:mimes:html u.u.ans))
|
||||
::
|
||||
++ tx
|
||||
|= params=(map @t json)
|
||||
^- (unit l2-tx)
|
||||
?~ data=(~(get by params) 'tx') ~
|
||||
?~ tx=(so u.data) ~
|
||||
=/ method=@tas (enkebab u.tx)
|
||||
?. ?=(l2-tx method) ~
|
||||
`method
|
||||
::
|
||||
++ nonce
|
||||
|= params=(map @t json)
|
||||
^- (unit @ud)
|
||||
?~ nonce=(~(get by params) 'nonce') ~
|
||||
(ni u.nonce)
|
||||
--
|
||||
::
|
||||
++ to-json
|
||||
=, enjs:format
|
||||
|%
|
||||
++ pending-tx
|
||||
|= pend-tx
|
||||
^- json
|
||||
%- pairs
|
||||
:~ ['force' b+force]
|
||||
['time' (^time time)]
|
||||
['rawTx' (^raw-tx raw-tx)]
|
||||
(en-address address)
|
||||
==
|
||||
::
|
||||
++ pending-txs
|
||||
|= pending=(list pend-tx)
|
||||
^- json
|
||||
a+(turn pending pending-tx)
|
||||
::
|
||||
++ en-address |=(a=@ux address+(hex 20 a))
|
||||
::
|
||||
++ raw-tx
|
||||
|= raw-tx:naive
|
||||
^- json
|
||||
|^
|
||||
%- pairs
|
||||
:~ ['tx' (parse-tx +.tx)]
|
||||
['sig' (hex (as-octs:mimes:html sig))]
|
||||
::
|
||||
:- 'from'
|
||||
%- pairs
|
||||
~[['ship' (ship ship.from.tx)] ['proxy' s+proxy.from.tx]]
|
||||
==
|
||||
::
|
||||
++ parse-tx
|
||||
|= tx=skim-tx:naive
|
||||
^- json
|
||||
%- pairs
|
||||
:~ ['type' s+-.tx]
|
||||
::
|
||||
:- 'data'
|
||||
%- pairs
|
||||
?- -.tx
|
||||
%transfer-point (en-transfer +.tx)
|
||||
%spawn (en-spawn +.tx)
|
||||
%configure-keys (en-keys +.tx)
|
||||
%escape ~[(en-ship parent.tx)]
|
||||
%cancel-escape ~[(en-ship parent.tx)]
|
||||
%adopt ~[(en-ship ship.tx)]
|
||||
%reject ~[(en-ship ship.tx)]
|
||||
%detach ~[(en-ship ship.tx)]
|
||||
%set-management-proxy ~[(en-address address.tx)]
|
||||
%set-spawn-proxy ~[(en-address address.tx)]
|
||||
%set-transfer-proxy ~[(en-address address.tx)]
|
||||
== ==
|
||||
::
|
||||
++ en-ship |=(s=@p ship+(numb `@ud`s))
|
||||
++ en-spawn |=([s=@p a=@ux] ~[(en-ship s) (en-address a)])
|
||||
++ en-transfer |=([a=@ux r=?] ~[(en-address a) reset+b+r])
|
||||
++ en-keys
|
||||
|= [encrypt=@ auth=@ crypto-suite=@ breach=?]
|
||||
^- (list [@t json])
|
||||
:~ ['encrypt' (numb encrypt)]
|
||||
['auth' (numb auth)]
|
||||
['cryptoSuite' (numb crypto-suite)]
|
||||
['breach' b+breach]
|
||||
==
|
||||
--
|
||||
::
|
||||
++ hist-txs
|
||||
|= txs=(list hist-tx)
|
||||
^- json
|
||||
:- %a
|
||||
%+ turn txs
|
||||
|= hist-tx
|
||||
^- json
|
||||
%- pairs
|
||||
:~ ['time' (time p)]
|
||||
['status' s+status.q]
|
||||
['hash' (hex (as-octs:mimes:html hash.q))]
|
||||
['type' s+type.q]
|
||||
['ship' (ship ship.q)]
|
||||
==
|
||||
::
|
||||
++ point
|
||||
|= =point:naive
|
||||
^- json
|
||||
%- pairs
|
||||
:~ ['dominion' s+dominion.point]
|
||||
::
|
||||
:- 'ownership'
|
||||
%- pairs
|
||||
=* own own.point
|
||||
^- (list [@t json])
|
||||
:~ ['owner' (ownership owner.own)]
|
||||
['spawnProxy' (ownership spawn-proxy.own)]
|
||||
['managementProxy' (ownership management-proxy.own)]
|
||||
['votingProxy' (ownership voting-proxy.own)]
|
||||
['transferProxy' (ownership transfer-proxy.own)]
|
||||
==
|
||||
::
|
||||
:- 'network'
|
||||
%- pairs
|
||||
=* net net.point
|
||||
:* ['rift' s+(json-number rift.net)]
|
||||
::
|
||||
:- 'keys'
|
||||
%- pairs
|
||||
:~ ['life' s+(json-number life.keys.net)]
|
||||
['suite' s+(json-number suite.keys.net)]
|
||||
['auth' (hex 32 auth.keys.net)]
|
||||
['crypt' (hex 32 crypt.keys.net)]
|
||||
==
|
||||
::
|
||||
:- 'sponsor'
|
||||
%- pairs
|
||||
~[['has' b+has.sponsor.net] ['who' (numb `@ud`who.sponsor.net)]]
|
||||
::
|
||||
?~ escape.net ~
|
||||
['escape' (numb `@ud`u.escape.net)]~
|
||||
== ==
|
||||
::
|
||||
++ json-number
|
||||
|= num=@
|
||||
^- @t
|
||||
=/ jon=json (numb num)
|
||||
?>(?=([%n *] jon) p.jon)
|
||||
::
|
||||
++ points
|
||||
|= points=(list [@p point:naive])
|
||||
^- json
|
||||
:- %a
|
||||
%+ turn points
|
||||
|= [ship=@p =point:naive]
|
||||
%- pairs
|
||||
:~ ['ship' (^ship ship)]
|
||||
['point' (^point point)]
|
||||
==
|
||||
::
|
||||
++ ships
|
||||
|= ships=(list @p)
|
||||
^- json
|
||||
a+(turn ships (cork @ud numb))
|
||||
::
|
||||
++ ownership
|
||||
|= [=address:naive =nonce:naive]
|
||||
^- json
|
||||
%- pairs
|
||||
:~ (en-address address)
|
||||
['nonce' (numb nonce)]
|
||||
==
|
||||
::
|
||||
++ spawned
|
||||
|= children=(list [@p @ux])
|
||||
^- json
|
||||
:- %a
|
||||
%+ turn children
|
||||
|= [child=@p address=@ux]
|
||||
%- pairs
|
||||
:~ ['ship' (ship child)]
|
||||
(en-address address)
|
||||
==
|
||||
::
|
||||
++ sponsored
|
||||
|= [res=(list @p) req=(list @p)]
|
||||
^- json
|
||||
%- pairs
|
||||
:~ ['residents' (ships res)]
|
||||
['requests' (ships req)]
|
||||
==
|
||||
::
|
||||
++ tx-status |=(=^tx-status ^-(json s+status.tx-status))
|
||||
::
|
||||
++ roller-config
|
||||
|= [az=^azimuth-config ro=^roller-config]
|
||||
^- json
|
||||
%- pairs
|
||||
:~ ['azimuthRefreshRate' (numb (div refresh-rate.az ~s1))]
|
||||
['nextBatch' (time next-batch.ro)]
|
||||
['frequency' (numb (div frequency.ro ~s1))]
|
||||
['rollerResendTime' (numb (div resend-time.ro ~s1))]
|
||||
['rollerUpdateRate' (numb (div update-rate.ro ~s1))]
|
||||
['contract' (hex 20 contract.ro)]
|
||||
['chainId' (numb chain-id.ro)]
|
||||
['timeSlice' (numb (div slice.ro ~s1))]
|
||||
['rollerQuota' (numb quota.ro)]
|
||||
==
|
||||
::
|
||||
++ azimuth-config
|
||||
|= config=^azimuth-config
|
||||
^- json
|
||||
%- pairs
|
||||
['refreshRate' (numb (div refresh-rate.config ~s1))]~
|
||||
::
|
||||
++ hex
|
||||
|= [p=@ q=@]
|
||||
^- json
|
||||
s+(crip ['0' 'x' ((x-co:co (mul 2 p)) q)])
|
||||
::
|
||||
++ naive-state
|
||||
|= =^state:naive
|
||||
^- json
|
||||
|^
|
||||
%- pairs
|
||||
:~ ['points' (points (tap:orp points.state))]
|
||||
['operators' (operators operators.state)]
|
||||
['dns' a+(turn dns.state (lead %s))]
|
||||
==
|
||||
::
|
||||
++ orp ((on ^ship point:naive) por:naive)
|
||||
::
|
||||
++ operators
|
||||
|= =operators:naive
|
||||
^- json
|
||||
:- %a
|
||||
%+ turn ~(tap by operators)
|
||||
|= [op=@ux addrs=(set @ux)]
|
||||
^- json
|
||||
%- pairs
|
||||
:~ ['operator' (hex 20 op)]
|
||||
['addresses' a+(turn ~(tap in addrs) (cury hex 20))]
|
||||
==
|
||||
--
|
||||
--
|
||||
::
|
||||
++ to-hex
|
||||
|= =cord
|
||||
^- (unit @ux)
|
||||
?. =((end [3 2] cord) '0x') ~
|
||||
(rush (rsh [3 2] cord) hex)
|
||||
::
|
||||
++ build-l2-tx
|
||||
|= [=l2-tx from=[@p proxy:naive] params=(map @t json)]
|
||||
^- (unit tx:naive)
|
||||
?: =(l2-tx %transfer-point)
|
||||
?~ data=(address-transfer:data:from-json params)
|
||||
~
|
||||
`[from %transfer-point u.data]
|
||||
?: =(l2-tx %spawn)
|
||||
?~ data=(address-ship:data:from-json params)
|
||||
~
|
||||
`[from %spawn u.data]
|
||||
?: =(l2-tx %configure-keys)
|
||||
?~ data=(keys:data:from-json params)
|
||||
~
|
||||
`[from %configure-keys u.data]
|
||||
?: ?=(spawn-action l2-tx)
|
||||
?~ data=(ship:data:from-json params)
|
||||
~
|
||||
?- l2-tx
|
||||
%escape `[from %escape u.data]
|
||||
%cancel-escape `[from %cancel-escape u.data]
|
||||
%adopt `[from %adopt u.data]
|
||||
%reject `[from %reject u.data]
|
||||
%detach `[from %detach u.data]
|
||||
==
|
||||
?. ?=(proxy-action l2-tx)
|
||||
~
|
||||
?~ data=(address:data:from-json params)
|
||||
~
|
||||
?- l2-tx
|
||||
%set-management-proxy `[from %set-management-proxy u.data]
|
||||
%set-spawn-proxy `[from %set-spawn-proxy u.data]
|
||||
%set-transfer-proxy `[from %set-transfer-proxy u.data]
|
||||
==
|
||||
--
|
||||
|%
|
||||
++ get-point
|
||||
|= [id=@t params=(map @t json) scry=$-(ship (unit point:naive))]
|
||||
^- response:rpc
|
||||
?. =(~(wyt by params) 1)
|
||||
~(params error:json-rpc id)
|
||||
?~ ship=(~(get by params) 'ship')
|
||||
~(params error:json-rpc id)
|
||||
?~ ship=(parse-ship u.ship)
|
||||
~(params error:json-rpc id)
|
||||
?~ point=(scry u.ship)
|
||||
~(not-found error:json-rpc id)
|
||||
[%result id (point:to-json u.point)]
|
||||
::
|
||||
++ get-ships
|
||||
|= [id=@t params=(map @t json) scry=$-(@ux (list @p))]
|
||||
^- response:rpc
|
||||
?. =(~(wyt by params) 1)
|
||||
~(params error:json-rpc id)
|
||||
?~ address=(address:from-json params)
|
||||
~(parse error:json-rpc id)
|
||||
[%result id (ships:to-json (scry u.address))]
|
||||
::
|
||||
++ get-dns
|
||||
|= [id=@t params=(map @t json) dns=(list @t)]
|
||||
^- response:rpc
|
||||
?. =((lent ~(tap by params)) 0)
|
||||
~(params error:json-rpc id)
|
||||
[%result id a+(turn dns (cork same (lead %s)))]
|
||||
::
|
||||
++ cancel-tx
|
||||
|= [id=@t params=(map @t json)]
|
||||
^- [(unit cage) response:rpc]
|
||||
?. =(~(wyt by params) 3)
|
||||
[~ ~(params error:json-rpc id)]
|
||||
=/ sig=(unit @) (sig:from-json params)
|
||||
=/ keccak=(unit @ux) (hash:from-json params)
|
||||
=/ data=(unit [l2-tx ship]) (cancel:data:from-json params)
|
||||
?. &(?=(^ sig) ?=(^ keccak) ?=(^ data))
|
||||
[~ ~(parse error:json-rpc id)]
|
||||
:_ [%result id s+'ok']
|
||||
%- some
|
||||
roller-action+!>([%cancel u.sig u.keccak u.data])
|
||||
::
|
||||
++ get-spawned
|
||||
|= [id=@t params=(map @t json) scry=$-(@p (list @p))]
|
||||
^- response:rpc
|
||||
?. =((lent ~(tap by params)) 1)
|
||||
~(params error:json-rpc id)
|
||||
?~ ship=(ship:from-json params)
|
||||
~(params error:json-rpc id)
|
||||
[%result id (ships:to-json (scry u.ship))]
|
||||
::
|
||||
++ spawns-remaining
|
||||
|= [id=@t params=(map @t json) scry=$-(@p (list @p))]
|
||||
^- response:rpc
|
||||
?. =((lent ~(tap by params)) 1)
|
||||
~(params error:json-rpc id)
|
||||
?~ ship=(ship:from-json params)
|
||||
~(params error:json-rpc id)
|
||||
[%result id (numb:enjs:format (lent (scry u.ship)))]
|
||||
::
|
||||
++ sponsored-points
|
||||
|= [id=@t params=(map @t json) scry=$-(@p [(list @p) (list @p)])]
|
||||
^- response:rpc
|
||||
?. =((lent ~(tap by params)) 1)
|
||||
~(params error:json-rpc id)
|
||||
?~ ship=(ship:from-json params)
|
||||
~(params error:json-rpc id)
|
||||
[%result id (sponsored:to-json (scry u.ship))]
|
||||
::
|
||||
++ process-rpc
|
||||
|= [id=@t params=(map @t json) action=l2-tx over-quota=$-(@p ?)]
|
||||
^- [(unit cage) response:rpc]
|
||||
?. =((lent ~(tap by params)) 4)
|
||||
[~ ~(params error:json-rpc id)]
|
||||
=+ ^- $: sig=(unit @)
|
||||
from=(unit [=ship proxy:naive])
|
||||
addr=(unit @ux)
|
||||
==
|
||||
=, from-json
|
||||
[(sig params) (from params) (address params)]
|
||||
?: |(?=(~ sig) ?=(~ from) ?=(~ addr))
|
||||
[~ ~(parse error:json-rpc id)]
|
||||
?: (over-quota ship.u.from)
|
||||
`[%error id '-32002' 'Max tx quota exceeded']
|
||||
=/ tx=(unit tx:naive) (build-l2-tx action u.from params)
|
||||
?~ tx [~ ~(parse error:json-rpc id)]
|
||||
=+ (gen-tx-octs:lib u.tx)
|
||||
:_ [%result id (hex:to-json 32 (hash-tx:lib p q))]
|
||||
%- some
|
||||
roller-action+!>([%submit | u.addr u.sig %don u.tx])
|
||||
::
|
||||
++ nonce
|
||||
|= [id=@t params=(map @t json) scry=$-([ship proxy:naive] (unit @))]
|
||||
^- response:rpc
|
||||
?. =((lent ~(tap by params)) 1)
|
||||
~(params error:json-rpc id)
|
||||
?~ from=(from:from-json params)
|
||||
~(parse error:json-rpc id)
|
||||
?~ nonce=(scry u.from)
|
||||
~(not-found error:json-rpc id)
|
||||
[%result id (numb:enjs:format u.nonce)]
|
||||
::
|
||||
++ pending
|
||||
|%
|
||||
::
|
||||
++ all
|
||||
|= [id=@t params=(map @t json) pending=(list pend-tx)]
|
||||
^- response:rpc
|
||||
?. =((lent ~(tap by params)) 0)
|
||||
~(params error:json-rpc id)
|
||||
[%result id (pending-txs:to-json pending)]
|
||||
::
|
||||
++ ship
|
||||
|= [id=@t params=(map @t json) scry=$-(@p (list pend-tx))]
|
||||
^- response:rpc
|
||||
?. =((lent ~(tap by params)) 1)
|
||||
~(params error:json-rpc id)
|
||||
?~ ship=(ship:from-json params)
|
||||
~(parse error:json-rpc id)
|
||||
[%result id (pending-txs:to-json (scry u.ship))]
|
||||
::
|
||||
++ addr
|
||||
|= [id=@t params=(map @t json) scry=$-(@ux (list pend-tx))]
|
||||
^- response:rpc
|
||||
?. =((lent ~(tap by params)) 1)
|
||||
~(params error:json-rpc id)
|
||||
?~ address=(address:from-json params)
|
||||
~(parse error:json-rpc id)
|
||||
[%result id (pending-txs:to-json (scry u.address))]
|
||||
::
|
||||
++ hash
|
||||
|= [id=@t params=(map @t json) scry=$-(@ux (unit pend-tx))]
|
||||
^- response:rpc
|
||||
?. =((lent ~(tap by params)) 1)
|
||||
~(params error:json-rpc id)
|
||||
?~ hash=(hash:from-json params)
|
||||
~(parse error:json-rpc id)
|
||||
?~ tx=(scry u.hash)
|
||||
~(not-found error:json-rpc id)
|
||||
[%result id (pending-tx:to-json u.tx)]
|
||||
--
|
||||
::
|
||||
++ status
|
||||
|= [id=@t params=(map @t json) scry=$-(@ tx-status)]
|
||||
^- response:rpc
|
||||
?. =((lent ~(tap by params)) 1)
|
||||
~(params error:json-rpc id)
|
||||
?~ hash=(hash:from-json params)
|
||||
~(parse error:json-rpc id)
|
||||
[%result id (tx-status:to-json (scry u.hash))]
|
||||
::
|
||||
++ next-timer
|
||||
|= [id=@t params=(map @t json) when=time]
|
||||
^- response:rpc
|
||||
?. =((lent ~(tap by params)) 0)
|
||||
~(params error:json-rpc id)
|
||||
[%result id (time:enjs:format when)]
|
||||
::
|
||||
++ history
|
||||
|= [id=@t params=(map @t json) scry=$-(address:naive (list hist-tx))]
|
||||
^- response:rpc
|
||||
?. =((lent ~(tap by params)) 1)
|
||||
~(params error:json-rpc id)
|
||||
?~ address=(address:from-json params)
|
||||
~(parse error:json-rpc id)
|
||||
[%result id (hist-txs:to-json (scry u.address))]
|
||||
::
|
||||
++ get-config
|
||||
|= [id=@t params=(map @t json) config=[azimuth-config roller-config]]
|
||||
^- response:rpc
|
||||
?. =((lent ~(tap by params)) 0)
|
||||
~(params error:json-rpc id)
|
||||
[%result id (roller-config:to-json config)]
|
||||
::
|
||||
++ hash-transaction
|
||||
|= [id=@t params=(map @t json) chain-id=@ header=? reverse=?]
|
||||
^- response:rpc
|
||||
?. =((lent ~(tap by params)) 4)
|
||||
~(params error:json-rpc id)
|
||||
=+ ^- $: l2-tx=(unit l2-tx)
|
||||
nonce=(unit @ud)
|
||||
from=(unit [@p proxy:naive])
|
||||
==
|
||||
=, from-json
|
||||
[(tx params) (nonce params) (from params)]
|
||||
?: |(?=(~ nonce) ?=(~ from) ?=(~ l2-tx))
|
||||
~(parse error:json-rpc id)
|
||||
=/ tx=(unit tx:naive) (build-l2-tx u.l2-tx u.from params)
|
||||
?~ tx ~(parse error:json-rpc id)
|
||||
=/ =octs
|
||||
%. [chain-id u.nonce (gen-tx-octs:lib u.tx)]
|
||||
?: header
|
||||
unsigned-tx:lib
|
||||
prepare-for-sig:lib
|
||||
:+ %result id
|
||||
%- hex:to-json
|
||||
?: reverse
|
||||
p.octs^(rev 3 octs)
|
||||
32^(hash-tx:lib octs)
|
||||
::
|
||||
++ hash-raw-transaction
|
||||
|= [id=@t params=(map @t json)]
|
||||
^- response:rpc
|
||||
?. =((lent ~(tap by params)) 4)
|
||||
~(params error:json-rpc id)
|
||||
=+ ^- $: sig=(unit @)
|
||||
l2-tx=(unit l2-tx)
|
||||
from=(unit [=ship proxy:naive])
|
||||
==
|
||||
=, from-json
|
||||
[(sig params) (tx params) (from params)]
|
||||
?: |(?=(~ sig) ?=(~ from) ?=(~ l2-tx))
|
||||
~(parse error:json-rpc id)
|
||||
=/ tx=(unit tx:naive) (build-l2-tx u.l2-tx u.from params)
|
||||
?~ tx ~(parse error:json-rpc id)
|
||||
:+ %result id
|
||||
%+ hex:to-json 32
|
||||
(hash-raw-tx:lib u.sig (gen-tx-octs:lib u.tx) u.tx)
|
||||
::
|
||||
++ get-naive
|
||||
|= [id=@t params=(map @t json) =^state:naive]
|
||||
^- response:rpc
|
||||
?. =((lent ~(tap by params)) 0)
|
||||
~(params error:json-rpc id)
|
||||
[%result id (naive-state:to-json state)]
|
||||
::
|
||||
++ get-refresh
|
||||
|= [id=@t params=(map @t json) =azimuth-config]
|
||||
^- response:rpc
|
||||
?. =((lent ~(tap by params)) 0)
|
||||
~(params error:json-rpc id)
|
||||
[%result id (azimuth-config:to-json azimuth-config)]
|
||||
::
|
||||
++ quota-remaining
|
||||
|= [id=@t params=(map @t json) quota-left=$-(@p @ud)]
|
||||
^- response:rpc
|
||||
?. =((lent ~(tap by params)) 1)
|
||||
~(params error:json-rpc id)
|
||||
?~ ship=(ship:from-json params)
|
||||
~(params error:json-rpc id)
|
||||
[%result id (numb:enjs:format (quota-left u.ship))]
|
||||
::
|
||||
++ ship-allowance
|
||||
|= [id=@t params=(map @t json) allowance=$-(@p (unit @ud))]
|
||||
^- response:rpc
|
||||
?. =((lent ~(tap by params)) 1)
|
||||
~(params error:json-rpc id)
|
||||
?~ ship=(ship:from-json params)
|
||||
~(params error:json-rpc id)
|
||||
:+ %result id
|
||||
?^ allow=(allowance u.ship)
|
||||
(numb:enjs:format u.allow)
|
||||
s+(crip "No quota restrictions for {(scow %p u.ship)}")
|
||||
--
|
@ -1,454 +0,0 @@
|
||||
:: azimuth: constants and utilities
|
||||
::
|
||||
/+ ethereum
|
||||
::
|
||||
=> => [azimuth-types ethereum-types .]
|
||||
|%
|
||||
+$ complete-ship
|
||||
$: state=point
|
||||
history=(list diff-point) ::TODO maybe block/event nr? :: newest first
|
||||
keys=(map life pass)
|
||||
==
|
||||
::
|
||||
++ fleet (map @p complete-ship)
|
||||
::
|
||||
++ eth-type
|
||||
|%
|
||||
++ point
|
||||
:~ [%bytes-n 32] :: encryptionKey
|
||||
[%bytes-n 32] :: authenticationKey
|
||||
%bool :: hasSponsor
|
||||
%bool :: active
|
||||
%bool :: escapeRequested
|
||||
%uint :: sponsor
|
||||
%uint :: escapeRequestedTo
|
||||
%uint :: cryptoSuiteVersion
|
||||
%uint :: keyRevisionNumber
|
||||
%uint :: continuityNumber
|
||||
==
|
||||
++ deed
|
||||
:~ %address :: owner
|
||||
%address :: managementProxy
|
||||
%address :: spawnProxy
|
||||
%address :: votingProxy
|
||||
%address :: transferProxy
|
||||
==
|
||||
--
|
||||
::
|
||||
++ eth-noun
|
||||
|%
|
||||
+$ point
|
||||
$: encryption-key=octs
|
||||
authentication-key=octs
|
||||
has-sponsor=?
|
||||
active=?
|
||||
escape-requested=?
|
||||
sponsor=@ud
|
||||
escape-to=@ud
|
||||
crypto-suite=@ud
|
||||
key-revision=@ud
|
||||
continuity-number=@ud
|
||||
==
|
||||
+$ deed
|
||||
$: owner=address
|
||||
management-proxy=address
|
||||
spawn-proxy=address
|
||||
voting-proxy=address
|
||||
transfer-proxy=address
|
||||
==
|
||||
--
|
||||
::
|
||||
++ function
|
||||
|%
|
||||
++ azimuth
|
||||
$% [%points who=@p]
|
||||
[%rights who=@p]
|
||||
[%get-spawned who=@p]
|
||||
[%dns-domains ind=@ud]
|
||||
==
|
||||
--
|
||||
::
|
||||
:: # diffs
|
||||
::
|
||||
++ update
|
||||
$% [%full ships=(map ship point) dns=dnses heard=events]
|
||||
[%difs dis=(list (pair event-id diff-azimuth))]
|
||||
==
|
||||
::
|
||||
:: # constants
|
||||
::
|
||||
:: contract addresses
|
||||
++ contracts mainnet-contracts
|
||||
++ mainnet-contracts
|
||||
|%
|
||||
:: azimuth: data contract
|
||||
::
|
||||
++ azimuth
|
||||
0x223c.067f.8cf2.8ae1.73ee.5caf.ea60.ca44.c335.fecb
|
||||
::
|
||||
++ ecliptic
|
||||
0xa5b6.109a.d2d3.5191.b3bc.32c0.0e45.26be.56fe.321f
|
||||
::
|
||||
++ linear-star-release
|
||||
0x86cd.9cd0.992f.0423.1751.e376.1de4.5cec.ea5d.1801
|
||||
::
|
||||
++ conditional-star-release
|
||||
0x8c24.1098.c3d3.498f.e126.1421.633f.d579.86d7.4aea
|
||||
::
|
||||
++ delegated-sending
|
||||
0xf790.8ab1.f1e3.52f8.3c5e.bc75.051c.0565.aeae.a5fb
|
||||
::
|
||||
:: launch: block number of azimuth deploy
|
||||
::
|
||||
++ launch 6.784.800
|
||||
::
|
||||
:: public: block number of azimuth becoming independent
|
||||
::
|
||||
++ public 7.033.765
|
||||
--
|
||||
::
|
||||
:: Testnet contract addresses
|
||||
::
|
||||
++ ropsten-contracts
|
||||
|%
|
||||
++ azimuth
|
||||
0x308a.b6a6.024c.f198.b57e.008d.0ac9.ad02.1988.6579
|
||||
::
|
||||
++ ecliptic
|
||||
0x8b9f.86a2.8921.d9c7.05b3.113a.755f.b979.e1bd.1bce
|
||||
::
|
||||
++ linear-star-release
|
||||
0x1f8e.dd03.1ee4.1474.0aed.b39b.84fb.8f2f.66ca.422f
|
||||
::
|
||||
++ conditional-star-release
|
||||
0x0
|
||||
::
|
||||
++ delegated-sending
|
||||
0x3e8c.a510.354b.c2fd.bbd6.1502.52d9.3105.c9c2.7bbe
|
||||
::
|
||||
++ launch 4.601.630
|
||||
++ public launch
|
||||
--
|
||||
::
|
||||
:: Local contract addresses
|
||||
::
|
||||
:: These addresses are only reproducible if you use the deploy
|
||||
:: script in bridge
|
||||
::
|
||||
++ local-contracts
|
||||
|%
|
||||
++ ecliptic
|
||||
0x56db.68f2.9203.ff44.a803.faa2.404a.44ec.bb7a.7480
|
||||
++ azimuth
|
||||
0x863d.9c2e.5c4c.1335.96cf.ac29.d552.55f0.d0f8.6381
|
||||
++ delegated-sending
|
||||
0xb71c.0b6c.ee1b.cae5.6dfe.95cd.9d3e.41dd.d7ea.fc43
|
||||
++ linear-star-release
|
||||
0x3c3.dc12.be65.8158.d1d7.f9e6.6e08.ec40.99c5.68e4
|
||||
++ conditional-star-release
|
||||
0x35eb.3b10.2d9c.1b69.ac14.69c1.b1fe.1799.850c.d3eb
|
||||
++ launch 0
|
||||
++ public 0
|
||||
--
|
||||
::
|
||||
:: ++ azimuth 0x863d.9c2e.5c4c.1335.96cf.ac29.d552.55f0.d0f8.6381 :: local bridge
|
||||
:: hashes of ship event signatures
|
||||
++ azimuth-events
|
||||
|%
|
||||
::
|
||||
:: OwnerChanged(uint32,address)
|
||||
++ owner-changed
|
||||
0x16d0.f539.d49c.6cad.822b.767a.9445.bfb1.
|
||||
cf7e.a6f2.a6c2.b120.a7ea.4cc7.660d.8fda
|
||||
::
|
||||
:: Activated(uint32)
|
||||
++ activated
|
||||
0xe74c.0380.9d07.69e1.b1f7.06cc.8414.258c.
|
||||
d1f3.b6fe.020c.d15d.0165.c210.ba50.3a0f
|
||||
::
|
||||
:: Spawned(uint32,uint32)
|
||||
++ spawned
|
||||
0xb2d3.a6e7.a339.f5c8.ff96.265e.2f03.a010.
|
||||
a854.1070.f374.4a24.7090.9644.1508.1546
|
||||
::
|
||||
:: EscapeRequested(uint32,uint32)
|
||||
++ escape-requested
|
||||
0xb4d4.850b.8f21.8218.141c.5665.cba3.79e5.
|
||||
3e9b.b015.b51e.8d93.4be7.0210.aead.874a
|
||||
::
|
||||
:: EscapeCanceled(uint32,uint32)
|
||||
++ escape-canceled
|
||||
0xd653.bb0e.0bb7.ce83.93e6.24d9.8fbf.17cd.
|
||||
a590.2c83.28ed.0cd0.9988.f368.90d9.932a
|
||||
::
|
||||
:: EscapeAccepted(uint32,uint32)
|
||||
++ escape-accepted
|
||||
0x7e44.7c9b.1bda.4b17.4b07.96e1.00bf.7f34.
|
||||
ebf3.6dbb.7fe6.6549.0b1b.fce6.246a.9da5
|
||||
::
|
||||
:: LostSponsor(uint32,uint32)
|
||||
++ lost-sponsor
|
||||
0xd770.4f9a.2519.3dbd.0b0c.b4a8.09fe.ffff.
|
||||
a7f1.9d1a.ae88.17a7.1346.c194.4482.10d5
|
||||
::
|
||||
:: ChangedKeys(uint32,bytes32,bytes32,uint32,uint32)
|
||||
++ changed-keys
|
||||
0xaa10.e7a0.117d.4323.f1d9.9d63.0ec1.69be.
|
||||
bb3a.988e.8957.70e3.5198.7e01.ff54.23d5
|
||||
::
|
||||
:: BrokeContinuity(uint32,uint32)
|
||||
++ broke-continuity
|
||||
0x2929.4799.f1c2.1a37.ef83.8e15.f79d.d91b.
|
||||
cee2.df99.d63c.d1c1.8ac9.68b1.2951.4e6e
|
||||
::
|
||||
:: ChangedSpawnProxy(uint32,address)
|
||||
++ changed-spawn-proxy
|
||||
0x9027.36af.7b3c.efe1.0d9e.840a.ed0d.687e.
|
||||
35c8.4095.122b.2505.1a20.ead8.866f.006d
|
||||
::
|
||||
:: ChangedTransferProxy(uint32,address)
|
||||
++ changed-transfer-proxy
|
||||
0xcfe3.69b7.197e.7f0c.f067.93ae.2472.a9b1.
|
||||
3583.fecb.ed2f.78df.a14d.1f10.796b.847c
|
||||
::
|
||||
:: ChangedManagementProxy(uint32,address)
|
||||
++ changed-management-proxy
|
||||
0xab9c.9327.cffd.2acc.168f.afed.be06.139f.
|
||||
5f55.cb84.c761.df05.e051.1c25.1e2e.e9bf
|
||||
::
|
||||
:: ChangedVotingProxy(uint32,address)
|
||||
++ changed-voting-proxy
|
||||
0xcbd6.269e.c714.57f2.c7b1.a227.74f2.46f6.
|
||||
c5a2.eae3.795e.d730.0db5.1768.0c61.c805
|
||||
::
|
||||
:: ChangedDns(string,string,string)
|
||||
++ changed-dns
|
||||
0xfafd.04ad.e1da.ae2e.1fdb.0fc1.cc6a.899f.
|
||||
d424.063e.d5c9.2120.e67e.0730.53b9.4898
|
||||
--
|
||||
--
|
||||
::
|
||||
:: logic
|
||||
::
|
||||
|%
|
||||
++ pass-from-eth
|
||||
|= [enc=octs aut=octs sut=@ud]
|
||||
^- pass
|
||||
%^ cat 3 'b'
|
||||
?. &(=(1 sut) =(p.enc 32) =(p.aut 32))
|
||||
(cat 8 0 0)
|
||||
(cat 8 q.aut q.enc)
|
||||
::
|
||||
++ point-from-eth
|
||||
|= [who=@p point:eth-noun deed:eth-noun]
|
||||
^- point
|
||||
::
|
||||
:: ownership
|
||||
::
|
||||
:+ :* owner
|
||||
management-proxy
|
||||
voting-proxy
|
||||
transfer-proxy
|
||||
==
|
||||
::
|
||||
:: network state
|
||||
::
|
||||
?. active ~
|
||||
:- ~
|
||||
:* key-revision
|
||||
::
|
||||
(pass-from-eth encryption-key authentication-key crypto-suite)
|
||||
::
|
||||
continuity-number
|
||||
::
|
||||
[has-sponsor `@p`sponsor]
|
||||
::
|
||||
?. escape-requested ~
|
||||
``@p`escape-to
|
||||
==
|
||||
::
|
||||
:: spawn state
|
||||
::
|
||||
?. ?=(?(%czar %king) (clan:title who)) ~
|
||||
:- ~
|
||||
:* spawn-proxy
|
||||
~ ::TODO call getSpawned to fill this
|
||||
==
|
||||
::
|
||||
++ event-log-to-point-diff
|
||||
=, azimuth-events
|
||||
=, abi:ethereum
|
||||
|= log=event-log:rpc:ethereum
|
||||
^- (unit (pair ship diff-point))
|
||||
~? ?=(~ mined.log) %processing-unmined-event
|
||||
::
|
||||
?: =(i.topics.log owner-changed)
|
||||
=/ [who=@ wer=address]
|
||||
(decode-topics t.topics.log ~[%uint %address])
|
||||
`[who %owner wer]
|
||||
::
|
||||
?: =(i.topics.log activated)
|
||||
=/ who=@
|
||||
(decode-topics t.topics.log ~[%uint])
|
||||
`[who %activated who]
|
||||
::
|
||||
?: =(i.topics.log spawned)
|
||||
=/ [pre=@ who=@]
|
||||
(decode-topics t.topics.log ~[%uint %uint])
|
||||
`[pre %spawned who]
|
||||
::
|
||||
?: =(i.topics.log escape-requested)
|
||||
=/ [who=@ wer=@]
|
||||
(decode-topics t.topics.log ~[%uint %uint])
|
||||
`[who %escape `wer]
|
||||
::
|
||||
?: =(i.topics.log escape-canceled)
|
||||
=/ who=@ (decode-topics t.topics.log ~[%uint])
|
||||
`[who %escape ~]
|
||||
::
|
||||
?: =(i.topics.log escape-accepted)
|
||||
=/ [who=@ wer=@]
|
||||
(decode-topics t.topics.log ~[%uint %uint])
|
||||
`[who %sponsor & wer]
|
||||
::
|
||||
?: =(i.topics.log lost-sponsor)
|
||||
=/ [who=@ pos=@]
|
||||
(decode-topics t.topics.log ~[%uint %uint])
|
||||
`[who %sponsor | pos]
|
||||
::
|
||||
?: =(i.topics.log changed-keys)
|
||||
=/ who=@ (decode-topics t.topics.log ~[%uint])
|
||||
=/ [enc=octs aut=octs sut=@ud rev=@ud]
|
||||
%+ decode-results data.log
|
||||
~[[%bytes-n 32] [%bytes-n 32] %uint %uint]
|
||||
`[who %keys rev (pass-from-eth enc aut sut)]
|
||||
::
|
||||
?: =(i.topics.log broke-continuity)
|
||||
=/ who=@ (decode-topics t.topics.log ~[%uint])
|
||||
=/ num=@ (decode-results data.log ~[%uint])
|
||||
`[who %continuity num]
|
||||
::
|
||||
?: =(i.topics.log changed-management-proxy)
|
||||
=/ [who=@ sox=address]
|
||||
(decode-topics t.topics.log ~[%uint %address])
|
||||
`[who %management-proxy sox]
|
||||
::
|
||||
?: =(i.topics.log changed-voting-proxy)
|
||||
=/ [who=@ tox=address]
|
||||
(decode-topics t.topics.log ~[%uint %address])
|
||||
`[who %voting-proxy tox]
|
||||
::
|
||||
?: =(i.topics.log changed-spawn-proxy)
|
||||
=/ [who=@ sox=address]
|
||||
(decode-topics t.topics.log ~[%uint %address])
|
||||
`[who %spawn-proxy sox]
|
||||
::
|
||||
?: =(i.topics.log changed-transfer-proxy)
|
||||
=/ [who=@ tox=address]
|
||||
(decode-topics t.topics.log ~[%uint %address])
|
||||
`[who %transfer-proxy tox]
|
||||
::
|
||||
:: warn about unimplemented events, but ignore
|
||||
:: the ones we know are harmless.
|
||||
~? ?! .= i.topics.log
|
||||
:: OwnershipTransferred(address,address)
|
||||
0x8be0.079c.5316.5914.1344.cd1f.d0a4.f284.
|
||||
1949.7f97.22a3.daaf.e3b4.186f.6b64.57e0
|
||||
[%unimplemented-event i.topics.log]
|
||||
~
|
||||
::
|
||||
++ apply-point-diff
|
||||
|= [pot=point dif=diff-point]
|
||||
^- point
|
||||
?- -.dif
|
||||
%full new.dif
|
||||
::
|
||||
%activated
|
||||
%_ pot
|
||||
net `[0 0 0 &^(^sein:title who.dif) ~]
|
||||
kid ?. ?=(?(%czar %king) (clan:title who.dif)) ~
|
||||
`[0x0 ~]
|
||||
==
|
||||
::
|
||||
:: ownership
|
||||
::
|
||||
%owner pot(owner.own new.dif)
|
||||
%transfer-proxy pot(transfer-proxy.own new.dif)
|
||||
%management-proxy pot(management-proxy.own new.dif)
|
||||
%voting-proxy pot(voting-proxy.own new.dif)
|
||||
::
|
||||
:: networking
|
||||
::
|
||||
?(%keys %continuity %sponsor %escape)
|
||||
?> ?=(^ net.pot)
|
||||
?- -.dif
|
||||
%keys
|
||||
pot(life.u.net life.dif, pass.u.net pass.dif)
|
||||
::
|
||||
%sponsor
|
||||
%= pot
|
||||
sponsor.u.net new.dif
|
||||
escape.u.net ?:(has.new.dif ~ escape.u.net.pot)
|
||||
==
|
||||
::
|
||||
%continuity pot(continuity-number.u.net new.dif)
|
||||
%escape pot(escape.u.net new.dif)
|
||||
==
|
||||
::
|
||||
:: spawning
|
||||
::
|
||||
?(%spawned %spawn-proxy)
|
||||
?> ?=(^ kid.pot)
|
||||
?- -.dif
|
||||
%spawned
|
||||
=- pot(spawned.u.kid -)
|
||||
(~(put in spawned.u.kid.pot) who.dif)
|
||||
::
|
||||
%spawn-proxy pot(spawn-proxy.u.kid new.dif)
|
||||
==
|
||||
==
|
||||
::
|
||||
++ parse-id
|
||||
|= id=@t
|
||||
^- azimuth:function
|
||||
|^
|
||||
~| id
|
||||
%+ rash id
|
||||
;~ pose
|
||||
(function %points 'points' shipname)
|
||||
(function %get-spawned 'getSpawned' shipname)
|
||||
(function %dns-domains 'dnsDomains' dem:ag)
|
||||
==
|
||||
::
|
||||
++ function
|
||||
|* [tag=@tas fun=@t rul=rule]
|
||||
;~(plug (cold tag (jest fun)) (ifix [pal par] rul))
|
||||
::
|
||||
++ shipname
|
||||
;~(pfix sig fed:ag)
|
||||
--
|
||||
::
|
||||
++ function-to-call
|
||||
|%
|
||||
++ azimuth
|
||||
|= cal=azimuth:function
|
||||
^- [id=@t dat=call-data:rpc:ethereum]
|
||||
?- -.cal
|
||||
%points
|
||||
:- (crip "points({(scow %p who.cal)})")
|
||||
['points(uint32)' ~[uint+`@`who.cal]]
|
||||
::
|
||||
%rights
|
||||
:- (crip "rights({(scow %p who.cal)})")
|
||||
['rights(uint32)' ~[uint+`@`who.cal]]
|
||||
::
|
||||
%get-spawned
|
||||
:- (crip "getSpawned({(scow %p who.cal)})")
|
||||
['getSpawned(uint32)' ~[uint+`@`who.cal]]
|
||||
::
|
||||
%dns-domains
|
||||
:- (crip "dnsDomains({(scow %ud ind.cal)})")
|
||||
['dnsDomains(uint256)' ~[uint+ind.cal]]
|
||||
==
|
||||
--
|
||||
--
|
1
pkg/arvo/lib/azimuth.hoon
Symbolic link
1
pkg/arvo/lib/azimuth.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/lib/azimuth.hoon
|
@ -42,8 +42,14 @@
|
||||
%adopt (adopt:dat +.call)
|
||||
%start-document-poll (start-document-poll:dat +.call)
|
||||
%cast-document-vote (cast-document-vote:dat +.call)
|
||||
%start-upgrade-poll (start-upgrade-poll:dat +.call)
|
||||
%cast-upgrade-vote (cast-upgrade-vote:dat +.call)
|
||||
::
|
||||
%send-point (send-point:dat +.call)
|
||||
::
|
||||
%approve-batch-transfer (approve-batch-transfer:dat +.call)
|
||||
%transfer-batch (transfer-batch:dat +.call)
|
||||
%withdraw (withdraw:dat +.call)
|
||||
==
|
||||
::
|
||||
+$ call-data call-data:rpc
|
||||
@ -67,12 +73,18 @@
|
||||
++ adopt (enc adopt:cal)
|
||||
++ start-document-poll (enc start-document-poll:cal)
|
||||
++ cast-document-vote (enc cast-document-vote:cal)
|
||||
++ start-upgrade-poll (enc start-upgrade-poll:cal)
|
||||
++ cast-upgrade-vote (enc cast-upgrade-vote:cal)
|
||||
::
|
||||
++ register-linear (enc register-linear:cal)
|
||||
++ register-conditional (enc register-conditional:cal)
|
||||
++ deposit (enc deposit:cal)
|
||||
::
|
||||
++ send-point (enc send-point:cal)
|
||||
::
|
||||
++ approve-batch-transfer (enc approve-batch-transfer:cal)
|
||||
++ transfer-batch (enc transfer-batch:cal)
|
||||
++ withdraw (enc withdraw:cal)
|
||||
--
|
||||
::
|
||||
::TODO lib
|
||||
@ -170,6 +182,25 @@
|
||||
[%bool support]
|
||||
==
|
||||
::
|
||||
++ start-upgrade-poll
|
||||
|= [gal=ship =address]
|
||||
^- call-data
|
||||
?> =(%czar (clan:title gal))
|
||||
:- 'startUpgradePoll(uint8,address)'
|
||||
:~ [%uint `@`gal]
|
||||
[%address address]
|
||||
==
|
||||
::
|
||||
++ cast-upgrade-vote
|
||||
|= [gal=ship =address support=?]
|
||||
^- call-data
|
||||
?> =(%czar (clan:title gal))
|
||||
:- 'castUpgradeVote(uint8,address,bool)'
|
||||
:~ [%uint `@`gal]
|
||||
[%address address]
|
||||
[%bool support]
|
||||
==
|
||||
::
|
||||
::
|
||||
++ set-dns-domains
|
||||
|= [pri=tape sec=tape ter=tape]
|
||||
@ -252,6 +283,27 @@
|
||||
[%address to]
|
||||
==
|
||||
::
|
||||
++ approve-batch-transfer
|
||||
|= to=address
|
||||
^- call-data
|
||||
:- 'approveBatchTransfer(address)'
|
||||
:~ [%address to]
|
||||
==
|
||||
::
|
||||
++ transfer-batch
|
||||
|= from=address
|
||||
^- call-data
|
||||
:- 'transferBatch(address)'
|
||||
:~ [%address from]
|
||||
==
|
||||
::
|
||||
++ withdraw
|
||||
|= to=address
|
||||
^- call-data
|
||||
:- 'withdraw(address)'
|
||||
:~ [%address to]
|
||||
==
|
||||
::
|
||||
:: read calls
|
||||
::
|
||||
++ rights
|
||||
|
@ -1,356 +0,0 @@
|
||||
/- c=crunch, gs=graph-store, ms=metadata-store, p=post, r=resource
|
||||
::
|
||||
=<
|
||||
|_ [our=ship now=@da]
|
||||
++ walk-graph-associations
|
||||
|= [=associations:ms content=? from=@da to=@da]
|
||||
^- wain
|
||||
:: graph resources in `our`; used to avoid scrying, e.g.,
|
||||
:: a graph `our` has left and can no longer access
|
||||
::
|
||||
=/ accessible-graphs=(set resource:r) (scry-graph-resources)
|
||||
%- ~(rep by associations)
|
||||
|= [[=md-resource:ms =association:ms] out=wain]
|
||||
^- wain
|
||||
?. ?=(%graph app-name.md-resource)
|
||||
out
|
||||
?. ?=(%graph -.config.metadatum.association)
|
||||
out
|
||||
:: ensure graph, given by association, exists in `our`
|
||||
::
|
||||
?. (~(has in accessible-graphs) resource.md-resource)
|
||||
out
|
||||
:: scry the graph
|
||||
::
|
||||
=/ graph=(unit graph:gs) (scry-graph resource.md-resource)
|
||||
?~ graph
|
||||
out
|
||||
:: prepare channel-info argument
|
||||
::
|
||||
=/ channel-info=channel-info:c
|
||||
:* group.association
|
||||
resource.md-resource
|
||||
module.config.metadatum.association
|
||||
==
|
||||
:: walk the graph
|
||||
::
|
||||
?+ module.config.metadatum.association
|
||||
:: non-chat (e.g. links & notes)
|
||||
::
|
||||
%+ weld out
|
||||
%: walk-nested-graph-for-most-recent-entries
|
||||
u.graph
|
||||
content
|
||||
channel-info
|
||||
from
|
||||
to
|
||||
==
|
||||
::
|
||||
%chat
|
||||
%+ weld out
|
||||
%: walk-chat-graph
|
||||
u.graph
|
||||
content
|
||||
channel-info
|
||||
from
|
||||
to
|
||||
==
|
||||
==
|
||||
::
|
||||
++ scry-graph
|
||||
|= graph-resource=resource:r
|
||||
^- (unit graph:gs)
|
||||
=/ scry-response=update:gs
|
||||
.^ update:gs
|
||||
%gx
|
||||
(scot %p our)
|
||||
%graph-store
|
||||
(scot %da now)
|
||||
%graph
|
||||
(scot %p entity.graph-resource)
|
||||
name.graph-resource
|
||||
/noun
|
||||
==
|
||||
?. ?=(%add-graph -.q.scry-response)
|
||||
~
|
||||
?~ graph.q.scry-response
|
||||
~
|
||||
[~ graph.q.scry-response]
|
||||
::
|
||||
++ scry-graph-resources
|
||||
|= ~
|
||||
^- (set resource:r)
|
||||
=/ scry-response=update:gs
|
||||
.^ update:gs
|
||||
%gx
|
||||
(scot %p our)
|
||||
%graph-store
|
||||
(scot %da now)
|
||||
/keys/noun
|
||||
==
|
||||
?. ?=(%keys -.q.scry-response)
|
||||
~
|
||||
resources.q.scry-response
|
||||
:: helper arm for callers to get graph associations
|
||||
:: to pass to `walk-graph-associations`
|
||||
::
|
||||
++ scry-graph-associations
|
||||
|= ~
|
||||
^- associations:ms
|
||||
.^ associations:ms
|
||||
%gx
|
||||
(scot %p our)
|
||||
%metadata-store
|
||||
(scot %da now)
|
||||
/app-name/graph/noun
|
||||
==
|
||||
--
|
||||
::
|
||||
|%
|
||||
::
|
||||
:: parsing and formatting
|
||||
::
|
||||
++ resource-to-cord
|
||||
|= =resource:r
|
||||
^- @t
|
||||
(rap 3 (scot %p entity.resource) '/' (scot %tas name.resource) ~)
|
||||
::
|
||||
++ paths-to-resources
|
||||
|= paxs=(list path)
|
||||
^- (set resource:r)
|
||||
%- ~(gas in *(set resource:r))
|
||||
(turn paxs path-to-resource)
|
||||
::
|
||||
++ path-to-resource
|
||||
|= pax=path
|
||||
^- resource:r
|
||||
=/ entity=@p (slav %p -.pax)
|
||||
=/ name=@tas -.+.pax
|
||||
[entity name]
|
||||
::
|
||||
++ escape-characters-in-cord
|
||||
|= =cord
|
||||
^- @t
|
||||
%- crip
|
||||
%- mesc
|
||||
:: specific to CSVs: make sure content does not
|
||||
:: contain commas (only allowed as delimiters)
|
||||
::
|
||||
%- replace-tape-commas-with-semicolons
|
||||
%- trip
|
||||
cord
|
||||
::
|
||||
++ replace-tape-commas-with-semicolons
|
||||
|= string=tape
|
||||
^- tape
|
||||
=/ comma-indices=(list @ud) (fand "," string)
|
||||
|-
|
||||
^- tape
|
||||
?~ comma-indices
|
||||
string
|
||||
$(string (snap string i.comma-indices ';'), comma-indices t.comma-indices)
|
||||
::
|
||||
++ contents-to-cord
|
||||
|= contents=(list content:p)
|
||||
^- @t
|
||||
?~ contents
|
||||
''
|
||||
%+ join-cords
|
||||
' '
|
||||
(turn contents content-to-cord)
|
||||
::
|
||||
++ content-to-cord
|
||||
|= =content:p
|
||||
^- @t
|
||||
?- -.content
|
||||
%text (escape-characters-in-cord text.content)
|
||||
%mention (scot %p ship.content)
|
||||
%url url.content
|
||||
%code expression.content :: TODO: also print output?
|
||||
%reference (reference-content-to-cord reference.content)
|
||||
==
|
||||
::
|
||||
++ reference-content-to-cord
|
||||
|= =reference:p
|
||||
^- @t
|
||||
?- -.reference
|
||||
%group (resource-to-cord group.reference)
|
||||
%graph (rap 3 (resource-to-cord group.reference) ': ' (resource-to-cord resource.uid.reference) ~)
|
||||
==
|
||||
::
|
||||
++ format-post-to-comma-separated-cord
|
||||
|= [=post:gs =channel-info:c]
|
||||
^- @t
|
||||
%+ join-cords
|
||||
','
|
||||
:~ (scot %da time-sent.post)
|
||||
(scot %p author.post)
|
||||
(resource-to-cord group.channel-info)
|
||||
(resource-to-cord channel.channel-info)
|
||||
(scot %tas channel-type.channel-info)
|
||||
:: exclude content; optionally add later
|
||||
::
|
||||
==
|
||||
::
|
||||
++ join-cords
|
||||
|= [delimiter=@t cords=(list @t)]
|
||||
^- @t
|
||||
%+ roll cords
|
||||
|= [cord=@t out=@t]
|
||||
^- @t
|
||||
?: =('' out)
|
||||
:: don't put delimiter before first element
|
||||
::
|
||||
cord
|
||||
(rap 3 out delimiter cord ~)
|
||||
::
|
||||
:: walking graphs
|
||||
::
|
||||
++ walk-chat-graph
|
||||
|= [=graph:gs content=? =channel-info:c from=@da to=@da]
|
||||
^- wain
|
||||
%- flop
|
||||
%+ roll
|
||||
:: filter by time
|
||||
::
|
||||
%+ only-nodes-older-than to
|
||||
%+ only-nodes-newer-than from
|
||||
~(val by graph)
|
||||
|= [=node:gs out=wain]
|
||||
^- wain
|
||||
?- -.post.node
|
||||
%|
|
||||
:: do not output deleted posts
|
||||
::
|
||||
out
|
||||
%&
|
||||
?~ contents.p.post.node
|
||||
:: do not output structural nodes
|
||||
::
|
||||
out
|
||||
:_ out
|
||||
=/ post-no-content=@t (format-post-to-comma-separated-cord p.post.node channel-info)
|
||||
?- content
|
||||
%| post-no-content
|
||||
%&
|
||||
%+ join-cords ','
|
||||
~[post-no-content (contents-to-cord contents.p.post.node)]
|
||||
==
|
||||
==
|
||||
::
|
||||
++ walk-nested-graph-for-most-recent-entries
|
||||
|= [=graph:gs content=? =channel-info:c from=@da to=@da]
|
||||
^- wain
|
||||
=| out=wain
|
||||
=| most-recent-post-content=@t
|
||||
=/ nodes
|
||||
:: filter by time
|
||||
::
|
||||
%+ only-nodes-older-than to
|
||||
%+ only-nodes-newer-than from
|
||||
~(val by graph)
|
||||
%- flop
|
||||
|-
|
||||
^- wain
|
||||
?~ nodes
|
||||
?: =('' most-recent-post-content)
|
||||
:: don't return a cell: `['' ~]`
|
||||
:: we want either an empty list `~`
|
||||
:: or a list populated with actual entries
|
||||
::
|
||||
out
|
||||
[most-recent-post-content out]
|
||||
::
|
||||
=? out ?=(%graph -.children.i.nodes)
|
||||
%+ weld out
|
||||
%: walk-nested-graph-for-most-recent-entries
|
||||
p.children.i.nodes
|
||||
content
|
||||
channel-info
|
||||
from
|
||||
to
|
||||
==
|
||||
::
|
||||
?- -.post.i.nodes
|
||||
%|
|
||||
:: do not keep deleted posts
|
||||
::
|
||||
$(nodes t.nodes)
|
||||
%&
|
||||
?~ contents.p.post.i.nodes
|
||||
:: do not keep structural nodes
|
||||
::
|
||||
$(nodes t.nodes)
|
||||
=/ post-no-content=@t (format-post-to-comma-separated-cord p.post.i.nodes channel-info)
|
||||
%= $
|
||||
nodes t.nodes
|
||||
most-recent-post-content
|
||||
?- content
|
||||
%| post-no-content
|
||||
%&
|
||||
%+ join-cords ','
|
||||
~[post-no-content (contents-to-cord contents.p.post.i.nodes)]
|
||||
==
|
||||
==
|
||||
==
|
||||
::
|
||||
:: filters
|
||||
::
|
||||
++ filter-associations-by-group-resources
|
||||
|= [=associations:ms group-resources=(set resource:r)]
|
||||
^- associations:ms
|
||||
%- ~(rep by associations)
|
||||
|= [[=md-resource:ms =association:ms] out=associations:ms]
|
||||
^- associations:ms
|
||||
?. (~(has in group-resources) group.association)
|
||||
out
|
||||
(~(put by out) md-resource association)
|
||||
:: wrappers for intuitive use of `filter-nodes-by-timestamp`:
|
||||
:: pass `nodes` as given by the `graph-store` scry and no
|
||||
:: need to worry about comparators
|
||||
::
|
||||
++ only-nodes-older-than
|
||||
|= [time=@da nodes=(list node:gs)]
|
||||
(filter-nodes-by-timestamp nodes lte time)
|
||||
::
|
||||
++ only-nodes-newer-than
|
||||
|= [time=@da nodes=(list node:gs)]
|
||||
%- flop
|
||||
(filter-nodes-by-timestamp (flop nodes) gte time)
|
||||
::
|
||||
++ filter-nodes-by-timestamp
|
||||
|= [nodes=(list node:gs) comparator=$-([@ @] ?) time=@da]
|
||||
=| out=(list node:gs)
|
||||
:: return `out` in same time-order as `nodes`
|
||||
::
|
||||
%- flop
|
||||
|-
|
||||
^- (list node:gs)
|
||||
?~ nodes
|
||||
out
|
||||
?- -.post.i.nodes
|
||||
%|
|
||||
:: skip deleted posts
|
||||
::
|
||||
$(nodes t.nodes)
|
||||
%&
|
||||
?. (comparator time-sent.p.post.i.nodes time)
|
||||
:: assume:
|
||||
:: * time is monotonic
|
||||
:: * first `%.n` we hit indicates nodes further on are `%.n`
|
||||
:: (i.e. `nodes` must be ordered st. they start `%.y`,
|
||||
:: e.g. if want all `nodes` older than given time,
|
||||
:: `nodes` must start with oldest and comparator is `lth`)
|
||||
::
|
||||
out
|
||||
$(nodes t.nodes, out [i.nodes out])
|
||||
==
|
||||
::
|
||||
:: io
|
||||
::
|
||||
++ note-write-csv-to-clay
|
||||
|= [pax=path file-content=wain]
|
||||
?> =(%csv (snag (dec (lent pax)) pax))
|
||||
[%c [%info %base %& [pax %ins %csv !>(file-content)]~]]
|
||||
::
|
||||
--
|
388
pkg/arvo/lib/dice.hoon
Normal file
388
pkg/arvo/lib/dice.hoon
Normal file
@ -0,0 +1,388 @@
|
||||
:: dice: helper functions for L2 Rollers
|
||||
::
|
||||
/- *dice
|
||||
/+ naive, *naive-transactions, ethereum, azimuth
|
||||
:: verbose bit
|
||||
::
|
||||
=| verb=?
|
||||
::
|
||||
|%
|
||||
:: orp: ordered points in naive state by parent ship
|
||||
::
|
||||
++ orp ((on ship point:naive) por:naive)
|
||||
:: ors: ordered sending map by (increasing) L1 nonce
|
||||
::
|
||||
++ ors ((on l1-tx-pointer send-tx) nonce-order)
|
||||
:: orh: ordered tx history by (decreasing) timestamp
|
||||
::
|
||||
++ orh ((on time roll-tx) gth)
|
||||
::
|
||||
++ nonce-order
|
||||
|= [a=[* =nonce:naive] b=[* =nonce:naive]]
|
||||
(lte nonce.a nonce.b)
|
||||
::
|
||||
++ data-to-hex
|
||||
|= data=@t
|
||||
?~ data *@ux
|
||||
?: =(data '0x') *@ux
|
||||
(hex-to-num:ethereum data)
|
||||
::
|
||||
++ get-network
|
||||
|= =net
|
||||
^- [azimuth=@ux naive=@ux chain-id=@ launch=@]
|
||||
=< [azimuth naive chain-id launch]
|
||||
=, azimuth
|
||||
?- net
|
||||
%mainnet mainnet-contracts
|
||||
%ropsten ropsten-contracts
|
||||
%local local-contracts
|
||||
%default contracts
|
||||
==
|
||||
::
|
||||
++ last-block-id
|
||||
|= logs=(list event-log:rpc:ethereum)
|
||||
^- id:block:jael
|
||||
%+ roll logs
|
||||
|= [log=event-log:rpc:ethereum =id:block:jael]
|
||||
?~ mined.log id
|
||||
?. (gth block-number.u.mined.log number.id)
|
||||
id
|
||||
[block-hash block-number]:u.mined.log
|
||||
::
|
||||
++ tx-effects
|
||||
|= [chain-t=@ =effects:naive nas=^state:naive =indices]
|
||||
^+ indices
|
||||
=< indices
|
||||
%+ roll effects
|
||||
|= [=diff:naive nas=_nas indices=_indices]
|
||||
?. ?=([%tx *] diff) [nas indices]
|
||||
=< [nas indices]
|
||||
%- %*(. apply-raw-tx verb |)
|
||||
[| chain-t raw-tx.diff nas indices]
|
||||
::
|
||||
++ apply-raw-tx
|
||||
|= [force=? chain-t=@ =raw-tx:naive nas=^state:naive =indices]
|
||||
^- [? (list update) nas=_nas indices=_indices]
|
||||
=+ cache=nas
|
||||
=/ chain-t=@t (ud-to-ascii:naive chain-t)
|
||||
?. (verify-sig-and-nonce:naive verifier chain-t nas raw-tx)
|
||||
=+ [force ~ nas indices]
|
||||
?. verb -
|
||||
~& >>> [verb+verb %verify-sig-and-nonce %failed tx.raw-tx] -
|
||||
=^ effects-1 points.nas
|
||||
(increment-nonce:naive nas from.tx.raw-tx)
|
||||
?~ nex=(receive-tx:naive nas tx.raw-tx)
|
||||
=+ [force ~ ?:(force nas cache) indices]
|
||||
?. verb -
|
||||
~& >>> [verb+verb %receive-tx %failed] -
|
||||
=* new-nas +.u.nex
|
||||
=/ effects (welp effects-1 -.u.nex)
|
||||
=^ updates indices
|
||||
(point-effects effects points.cache points.new-nas [own spo]:indices)
|
||||
[& updates new-nas indices]
|
||||
::
|
||||
++ point-effects
|
||||
|= [=effects:naive cache=points:naive =points:naive =indices]
|
||||
^- [(list update) indices=_indices]
|
||||
=^ updates=(list update) indices
|
||||
%+ roll effects
|
||||
|= [=diff:naive updates=(list update) indices=_indices]
|
||||
?. |(?=([%point *] diff) ?=([%nonce *] diff))
|
||||
[updates indices]
|
||||
?: ?=([%nonce *] diff)
|
||||
:_ indices
|
||||
(welp (nonce-updates diff cache points) updates)
|
||||
?> ?=([%point *] diff)
|
||||
=* ship ship.diff
|
||||
=* sponsors spo.indices
|
||||
=* owners own.indices
|
||||
=/ old=(unit point:naive) (get:orp cache ship)
|
||||
=/ new=point:naive (need (get:orp points ship))
|
||||
=^ update-1 sponsors
|
||||
(sponsorship-diff diff ship new old sponsors)
|
||||
=^ update-2 owners
|
||||
(ownership-diff diff ship new old owners)
|
||||
=/ update-3=_updates
|
||||
(point-data-updates diff ship new old)
|
||||
:_ indices
|
||||
:(welp update-3 update-2 update-1 updates)
|
||||
[(flop updates) indices]
|
||||
::
|
||||
++ sponsorship-diff
|
||||
|= [=diff:naive =ship new=point:naive old=(unit point:naive) =sponsors]
|
||||
^- (quip update _sponsors)
|
||||
?. ?=([%point *] diff) `sponsors
|
||||
=* event +>.diff
|
||||
?+ -.event `sponsors
|
||||
%owner
|
||||
?^ old
|
||||
:: ownership change
|
||||
::
|
||||
`sponsors
|
||||
:: owner event with ?=(~ old) is a spawn
|
||||
::
|
||||
=* parent who.sponsor.net.new
|
||||
?: =(parent ship) `sponsors
|
||||
:: updates for proxy %own are taken care of
|
||||
:: in +sponsorship to avoid duplicates
|
||||
::
|
||||
:- ~
|
||||
%+ ~(put by sponsors) parent
|
||||
?~ sponsor=(~(get by sponsors) parent)
|
||||
:_ *(set @p)
|
||||
(~(put in *(set @p)) ship)
|
||||
:_ requests.u.sponsor
|
||||
(~(put in residents.u.sponsor) ship)
|
||||
::
|
||||
%escape
|
||||
?~ old `sponsors
|
||||
=* from who.sponsor.net.u.old
|
||||
=* to to.event
|
||||
=* escape escape.net.u.old
|
||||
?~ to
|
||||
:: cancel/reject escape
|
||||
::
|
||||
?~ escape `sponsors
|
||||
?~ receiver=(~(get by sponsors) u.escape)
|
||||
`sponsors
|
||||
::
|
||||
:- (proxy-updates diff ship new old)
|
||||
::
|
||||
%+ ~(put by sponsors) u.escape
|
||||
:- residents.u.receiver
|
||||
(~(del in requests.u.receiver) ship)
|
||||
:: normal escape
|
||||
::
|
||||
:- (proxy-updates diff ship new old)
|
||||
::
|
||||
%+ ~(put by sponsors) u.to
|
||||
?~ receiver=(~(get by sponsors) u.to)
|
||||
:- *(set @p)
|
||||
(~(put in *(set @p)) ship)
|
||||
:- residents.u.receiver
|
||||
(~(put in requests.u.receiver) ship)
|
||||
::
|
||||
%sponsor
|
||||
?~ old `sponsors
|
||||
=* from who.sponsor.net.u.old
|
||||
=* to sponsor.event
|
||||
=/ previous (~(get by sponsors) from)
|
||||
?~ to
|
||||
:: detach
|
||||
::
|
||||
?~ previous `sponsors
|
||||
::
|
||||
:- (proxy-updates diff ship new old)
|
||||
::
|
||||
%+ ~(put by sponsors) from
|
||||
:_ requests.u.previous
|
||||
(~(del in residents.u.previous) ship)
|
||||
:: accepted
|
||||
::
|
||||
=/ receiver (~(get by sponsors) u.to)
|
||||
=? sponsors ?=(^ receiver)
|
||||
%+ ~(put by sponsors) u.to
|
||||
:- (~(put in residents.u.receiver) ship)
|
||||
(~(del in requests.u.receiver) ship)
|
||||
=? sponsors ?=(^ previous)
|
||||
%+ ~(put by sponsors) from
|
||||
:_ requests.u.previous
|
||||
(~(del in residents.u.previous) ship)
|
||||
:_ sponsors
|
||||
(proxy-updates diff ship new old)
|
||||
==
|
||||
::
|
||||
++ ownership-diff
|
||||
|= [=diff:naive =ship new=point:naive old=(unit point:naive) =owners]
|
||||
^- (quip update _owners)
|
||||
?. ?=([%point *] diff) `owners
|
||||
=* event +>.diff
|
||||
=; [to=(unit owner) from=(unit owner)]
|
||||
=? owners &(?=(^ from) !=(address.u.from 0x0))
|
||||
(~(del ju owners) u.from ship)
|
||||
?: ?| =(~ to)
|
||||
&(?=(^ to) =(address.u.to 0x0))
|
||||
==
|
||||
[~ owners]
|
||||
?~ to [~ owners]
|
||||
:_ (~(put ju owners) u.to ship)
|
||||
[%point diff ship new old u.to from]~
|
||||
?+ -.event [~ ~]
|
||||
%owner
|
||||
:- `[%own +.event]
|
||||
?~ old ~
|
||||
`[%own address.owner.own.u.old]
|
||||
::
|
||||
%management-proxy
|
||||
:- `[%manage +.event]
|
||||
?~ old ~
|
||||
`[%manage address.management-proxy.own.u.old]
|
||||
::
|
||||
%spawn-proxy
|
||||
:- `[%spawn +.event]
|
||||
?~ old ~
|
||||
`[%spawn address.spawn-proxy.own.u.old]
|
||||
::
|
||||
%voting-proxy
|
||||
:- `[%vote +.event]
|
||||
?~ old ~
|
||||
`[%vote address.voting-proxy.own.u.old]
|
||||
::
|
||||
%transfer-proxy
|
||||
:- `[%transfer +.event]
|
||||
?~ old ~
|
||||
`[%transfer address.transfer-proxy.own.u.old]
|
||||
==
|
||||
::
|
||||
++ create-indices
|
||||
|= nas=^state:naive
|
||||
^- [sponsors owners]
|
||||
%+ roll (tap:orp points.nas)
|
||||
|= [[=ship =point:naive] =sponsors =owners]
|
||||
|^
|
||||
=? sponsors has.sponsor.net.point
|
||||
^+ sponsors
|
||||
(add-resident who.sponsor.net.point)
|
||||
=? sponsors ?=(^ escape.net.point)
|
||||
(add-request u.escape.net.point)
|
||||
[sponsors add-ownership]
|
||||
::
|
||||
++ add-resident
|
||||
|= sponsor=@p
|
||||
^+ sponsors
|
||||
:: galaxies have themselves as their sponsors
|
||||
::
|
||||
?: =(sponsor ship) sponsors
|
||||
%+ ~(put by sponsors) sponsor
|
||||
?~ sponsees=(~(get by sponsors) sponsor)
|
||||
:_ *(set @p)
|
||||
(~(put in *(set @p)) ship)
|
||||
:_ requests.u.sponsees
|
||||
(~(put in residents.u.sponsees) ship)
|
||||
::
|
||||
++ add-request
|
||||
|= sponsor=@p
|
||||
^+ sponsors
|
||||
:: galaxies have themselves as their sponsors
|
||||
::
|
||||
?: =(sponsor ship) sponsors
|
||||
%+ ~(put by sponsors) sponsor
|
||||
?~ receiver=(~(get by sponsors) sponsor)
|
||||
:- *(set @p)
|
||||
(~(put in *(set @p)) ship)
|
||||
:- residents.u.receiver
|
||||
(~(put in requests.u.receiver) ship)
|
||||
::
|
||||
++ add-ownership
|
||||
^+ owners
|
||||
=/ proxies=(list proxy:naive)
|
||||
~[%own %spawn %manage %vote %transfer]
|
||||
%+ roll proxies
|
||||
|= [=proxy:naive own=_owners]
|
||||
?~ owner=(get-owner point proxy)
|
||||
own
|
||||
(~(put ju own) u.owner ship)
|
||||
--
|
||||
::
|
||||
++ proxy-updates
|
||||
|= [=diff:naive =ship =point:naive old=(unit point:naive)]
|
||||
^- (list update)
|
||||
=/ proxies=(list proxy:naive)
|
||||
~[%own %spawn %manage %vote %transfer]
|
||||
?~ old ~
|
||||
%- flop
|
||||
%+ roll proxies
|
||||
|= [=proxy:naive updates=(list update)]
|
||||
?~ owner=(get-owner u.old proxy) updates
|
||||
:_ updates
|
||||
[%point diff ship point old u.owner ~]
|
||||
::
|
||||
++ nonce-updates
|
||||
|= [=diff:naive cache=points:naive =points:naive]
|
||||
^- (list update)
|
||||
?. ?=([%nonce *] diff) ~
|
||||
=/ old=(unit point:naive) (get:orp cache ship.diff)
|
||||
=/ new=point:naive (need (get:orp points ship.diff))
|
||||
(point-data-updates diff ship.diff new old)
|
||||
::
|
||||
++ point-data-updates
|
||||
|= [=diff:naive =ship =point:naive old=(unit point:naive)]
|
||||
^- (list update)
|
||||
?. ?=([%point *] diff) ~
|
||||
=* event +>.diff
|
||||
?+ -.event ~
|
||||
%rift (proxy-updates +<)
|
||||
%keys (proxy-updates +<)
|
||||
%dominion (proxy-updates +<)
|
||||
==
|
||||
::
|
||||
++ get-owner
|
||||
|= [=point:naive =proxy:naive]
|
||||
^- (unit owner)
|
||||
=, own.point
|
||||
?- proxy
|
||||
%own
|
||||
?:(=(address.owner 0x0) ~ `own+address.owner)
|
||||
::
|
||||
%spawn
|
||||
?:(=(address.spawn-proxy 0x0) ~ `spawn+address.spawn-proxy)
|
||||
::
|
||||
%manage
|
||||
?:(=(address.management-proxy 0x0) ~ `manage+address.management-proxy)
|
||||
::
|
||||
%vote
|
||||
?:(=(address.voting-proxy 0x0) ~ `vote+address.voting-proxy)
|
||||
::
|
||||
%transfer
|
||||
?:(=(address.transfer-proxy 0x0) ~ `transfer+address.transfer-proxy)
|
||||
==
|
||||
::
|
||||
++ get-nonce
|
||||
|= [=point:naive =proxy:naive]
|
||||
^- nonce:naive
|
||||
=, own.point
|
||||
?- proxy
|
||||
%own nonce.owner
|
||||
%spawn nonce.spawn-proxy
|
||||
%manage nonce.management-proxy
|
||||
%vote nonce.voting-proxy
|
||||
%transfer nonce.transfer-proxy
|
||||
==
|
||||
::
|
||||
++ controlled-ships
|
||||
|= [=address:ethereum =owners]
|
||||
^- (list [=proxy:naive =ship])
|
||||
=/ proxies=(list proxy:naive)
|
||||
~[%own %spawn %manage %vote %transfer]
|
||||
%+ roll proxies
|
||||
|= [=proxy:naive ships=(list [=proxy:naive ship])]
|
||||
%+ welp
|
||||
%+ turn
|
||||
~(tap in (~(get ju owners) [proxy address]))
|
||||
(lead proxy)
|
||||
ships
|
||||
:: +update-history: updates status for all given list of transaction
|
||||
::
|
||||
++ update-history
|
||||
|= [=history txs=(list pend-tx) =status]
|
||||
^- (quip update _history)
|
||||
=^ updates=(list update) history
|
||||
%+ roll txs
|
||||
|= [=pend-tx ups=(list update) history=_history]
|
||||
=, pend-tx
|
||||
=/ =roll-tx
|
||||
=, pend-tx
|
||||
:* ship.from.tx.raw-tx
|
||||
status
|
||||
(hash-raw-tx raw-tx)
|
||||
(l2-tx +<.tx.raw-tx)
|
||||
==
|
||||
=/ txs=(tree hist-tx)
|
||||
?~ txs=(~(get by history) address) ~
|
||||
u.txs
|
||||
=? txs ?=(^ txs) +:(del:orh txs time)
|
||||
:- [tx+[pend-tx status] ups]
|
||||
%+ ~(put by history) address
|
||||
(put:orh txs [time roll-tx])
|
||||
[(flop updates) history]
|
||||
--
|
@ -136,6 +136,7 @@
|
||||
::
|
||||
++ poke
|
||||
|= [=mark =vase]
|
||||
?> =(our src):hid
|
||||
?+ mark ~|([%poke-drum-bad-mark mark] !!)
|
||||
%drum-dill-belt =;(f (f !<(_+<.f vase)) poke-dill-belt)
|
||||
%drum-dill-blit =;(f (f !<(_+<.f vase)) poke-dill-blit)
|
||||
|
@ -1,27 +1,33 @@
|
||||
/+ pill
|
||||
=* card card:agent:gall
|
||||
|%
|
||||
+$ state state-1
|
||||
+$ state state-2
|
||||
+$ any-state
|
||||
$~ *state
|
||||
$% state-1
|
||||
$% state-2
|
||||
state-1
|
||||
state-0
|
||||
==
|
||||
+$ state-1
|
||||
$: %1
|
||||
mass-timer=[way=wire nex=@da tim=@dr]
|
||||
==
|
||||
+$ state-2 [%2 =mass-timer]
|
||||
+$ state-1 [%1 =mass-timer]
|
||||
+$ state-0 [%0 hoc=(map bone session-0)]
|
||||
+$ session-0
|
||||
$: say=*
|
||||
mud=*
|
||||
mass-timer=[way=wire nex=@da tim=@dr]
|
||||
=mass-timer
|
||||
==
|
||||
::
|
||||
+$ mass-timer [way=wire nex=@da tim=@dr]
|
||||
::
|
||||
++ state-0-to-1
|
||||
|= s=state-0
|
||||
^- state
|
||||
^- state-1
|
||||
[%1 mass-timer:(~(got by hoc.s) 0)]
|
||||
::
|
||||
++ state-1-to-2
|
||||
|= s=state-1
|
||||
^- state-2
|
||||
[%2 +.s]
|
||||
--
|
||||
|= [=bowl:gall sat=state]
|
||||
=| moz=(list card)
|
||||
@ -39,27 +45,46 @@
|
||||
^+ this
|
||||
?~(caz this $(caz t.caz, this (emit i.caz)))
|
||||
::
|
||||
++ on-init
|
||||
(poke-serve [~ /who] %base /gen/who/hoon ~)
|
||||
::
|
||||
++ on-load
|
||||
|= [hood-version=@ud old=any-state]
|
||||
=< abet
|
||||
=? old ?=(%0 -.old) (state-0-to-1 old)
|
||||
?> ?=(%1 -.old)
|
||||
=? old ?=(%0 -.old) (state-0-to-1 old)
|
||||
=? this ?=(%1 -.old)
|
||||
(emil -:(poke-serve [~ /who] %base /gen/who/hoon ~))
|
||||
=? old ?=(%1 -.old) (state-1-to-2 old)
|
||||
?> ?=(%2 -.old)
|
||||
this(sat old)
|
||||
::
|
||||
++ poke-rekey :: rotate private keys
|
||||
|= des=@t
|
||||
=/ sed=(unit seed:jael)
|
||||
=/ fud=(unit feed:jael)
|
||||
%+ biff
|
||||
(bind (slaw %uw des) cue)
|
||||
(soft seed:jael)
|
||||
(soft feed:jael)
|
||||
=< abet
|
||||
?~ sed
|
||||
?~ fud
|
||||
~& %invalid-private-key
|
||||
this
|
||||
?. =(our.bowl who.u.sed)
|
||||
~& [%wrong-private-key-ship who.u.sed]
|
||||
=/ fed (need fud)
|
||||
?@ -.fed
|
||||
?. =(our.bowl who.fed)
|
||||
~& [%wrong-private-key-ship who.fed]
|
||||
this
|
||||
(emit %pass / %arvo %j %rekey lyf.fed key.fed)
|
||||
?. =(our.bowl who.fed)
|
||||
~& [%wrong-private-key-ship who.fed]
|
||||
this
|
||||
(emit %pass / %arvo %j %rekey lyf.u.sed key.u.sed)
|
||||
=| caz=(list card)
|
||||
%- emil
|
||||
|-
|
||||
?~ kyz.fed (flop caz)
|
||||
%= $
|
||||
kyz.fed t.kyz.fed
|
||||
caz [[%pass / %arvo %j %rekey i.kyz.fed] caz]
|
||||
==
|
||||
::
|
||||
++ ames-secret
|
||||
^- @t
|
||||
@ -199,6 +224,9 @@
|
||||
::
|
||||
++ poke
|
||||
|= [=mark =vase]
|
||||
?> ?| ?=(%helm-hi mark)
|
||||
=(our src):bowl
|
||||
==
|
||||
?+ mark ~|([%poke-helm-bad-mark mark] !!)
|
||||
%helm-ames-sift =;(f (f !<(_+<.f vase)) poke-ames-sift)
|
||||
%helm-ames-verb =;(f (f !<(_+<.f vase)) poke-ames-verb)
|
||||
|
@ -408,9 +408,6 @@
|
||||
.^([rev=@ud @da] %cw /(scot %p our)/[d]/(scot %da now))
|
||||
==
|
||||
take-commit:(abed:vats %base)
|
||||
=? kiln ?=(^ wef)
|
||||
=/ except=(set desk) (sy %base %kids ~)
|
||||
(bump:vats u.wef except force=%.n)
|
||||
=. wef ~
|
||||
abet:kiln
|
||||
::
|
||||
@ -605,7 +602,7 @@
|
||||
vats
|
||||
~> %slog.(fmt "{<lac>} pausing updates")
|
||||
=/ rel ral
|
||||
=. rail.rak `rel(paused &, aeon 0)
|
||||
=. rail.rak `rel(paused &, aeon 0, next ~)
|
||||
vats
|
||||
::
|
||||
:: +gall-lyv: watch gall source for reloading
|
||||
@ -683,11 +680,11 @@
|
||||
|= [kel=weft except=(set desk) force=?]
|
||||
^+ kiln
|
||||
=/ ded (find-blocked kel except)
|
||||
?: force
|
||||
=. kiln (suspend-many ded)
|
||||
(bump-many kel (all-desks-but (~(uni in except) ded)))
|
||||
?: =(~ ded)
|
||||
(bump-many kel (all-desks-but except))
|
||||
=? kiln force (suspend-many ded)
|
||||
?: |(force =(~ ded))
|
||||
?: !=(zuse+zuse kel)
|
||||
(bump-one kel %base)
|
||||
(bump-many (all-desks-but (~(uni in except) ded)))
|
||||
=- (^emit (pyre:pass leaf/- ~))
|
||||
"kiln: desks blocked upgrade to {<zuse/zuse>}: {<ded>}"
|
||||
::
|
||||
@ -707,7 +704,7 @@
|
||||
$(ded t.ded, kiln abet:(suspend i.ded))
|
||||
::
|
||||
++ bump-many
|
||||
|= [kel=weft live=(set desk)]
|
||||
|= live=(set desk)
|
||||
^+ kiln
|
||||
:: ensure %base is always reloaded first
|
||||
::
|
||||
@ -721,7 +718,7 @@
|
||||
::
|
||||
|- ^+ kiln
|
||||
?~ liv kiln
|
||||
$(liv t.liv, kiln (bump-one kel i.liv))
|
||||
$(liv t.liv, kiln (bump-one zuse+zuse i.liv))
|
||||
::
|
||||
++ bump-one
|
||||
|= [kel=weft =desk]
|
||||
@ -736,7 +733,7 @@
|
||||
?: =(kel u.kul)
|
||||
~> %slog.(fmt "{here} already at {<[lal num]:kel>}")
|
||||
update-running-dudes
|
||||
=^ tem rail.rak (crank-next %| kel)
|
||||
=^ tem rail.rak (crank-next kel)
|
||||
?^ tem
|
||||
(emit merge-main:pass)
|
||||
=- (emit (pyre:pass leaf/- ~))
|
||||
@ -864,7 +861,8 @@
|
||||
++ kelvin-same
|
||||
^+ vats
|
||||
~> %slog.(fmt "merging into {here}")
|
||||
=. rail.rak +:(crank-next %& (dec aeon:ral))
|
||||
?> ?=(^ rail.rak)
|
||||
=. next.u.rail.rak ~
|
||||
(emil ~[merge-main sync-ud]:pass)
|
||||
::
|
||||
++ do-base
|
||||
@ -881,7 +879,8 @@
|
||||
=/ =diff [%block loc rak new-weft blockers]
|
||||
(emil sync-ud:pass (diff:give diff) ~)
|
||||
~> %slog.(fmt "applying OTA to {here}, kelvin: {<new-weft>}")
|
||||
=. rail.rak +:(crank-next %& (dec aeon:ral))
|
||||
?> ?=(^ rail.rak)
|
||||
=. next.u.rail.rak ~
|
||||
=. wef
|
||||
?: =(old-weft new-weft) ~
|
||||
`new-weft
|
||||
@ -915,11 +914,7 @@
|
||||
update-running-dudes
|
||||
?. =(%base loc)
|
||||
kiln
|
||||
=/ kel=[@tas @ud]
|
||||
?~ rail.rak zuse/zuse
|
||||
?~ next.u.rail.rak zuse/zuse
|
||||
weft.i.next.u.rail.rak
|
||||
(bump-many kel (all-desks-but (sy %base ~)))
|
||||
(bump-many (all-desks-but (get-unblockers ark)))
|
||||
::
|
||||
++ take-merge-main
|
||||
|= syn=sign-arvo
|
||||
@ -994,7 +989,7 @@
|
||||
:: +crank-next: pop stale items from .next until one matches
|
||||
::
|
||||
++ crank-next
|
||||
|= new=(each aeon weft)
|
||||
|= new=weft
|
||||
^+ [match=*(unit rung) rail.rak]
|
||||
?~ rail.rak
|
||||
~| [%no-rail-for desk=loc]
|
||||
@ -1003,10 +998,7 @@
|
||||
=- [match `u.rail.rak(next next)]
|
||||
|- ^- [match=(unit rung) next=(list rung)]
|
||||
?~ rog [~ next.u.rail.rak]
|
||||
?: ?- -.new
|
||||
%& =(p.new aeon.i.rog)
|
||||
%| =(p.new weft.i.rog)
|
||||
==
|
||||
?: =(new weft.i.rog)
|
||||
[`i.rog t.rog]
|
||||
$(rog t.rog)
|
||||
::
|
||||
@ -1034,6 +1026,19 @@
|
||||
?: (lien next.u.rail.arak |=([* k=weft] =(k kel)))
|
||||
~
|
||||
`desk
|
||||
:: +get-unblockers: find desks which shouldn't block a kernel upgrade
|
||||
::
|
||||
++ get-unblockers
|
||||
|= ark=(map desk arak)
|
||||
=/ base=(set desk) (sy %base %kids ~)
|
||||
%- ~(gas in base)
|
||||
%+ murn ~(tap by ark)
|
||||
|= [loc=desk ark=arak]
|
||||
^- (unit desk)
|
||||
?. liv.rein.ark `loc
|
||||
?~ rail.ark `loc
|
||||
?: paused.u.rail.ark `loc
|
||||
~
|
||||
:: +get-germ: select merge strategy into local desk
|
||||
::
|
||||
:: If destination desk doesn't exist, need a %init merge. If this is
|
||||
@ -1202,9 +1207,9 @@
|
||||
abet:abet:(install:vats +<)
|
||||
::
|
||||
++ poke-label
|
||||
|= [syd=desk lab=@tas]
|
||||
|= [syd=desk lab=@tas aey=(unit aeon)]
|
||||
=+ pax=/(scot %p our)/[syd]/[lab]
|
||||
(poke-info "labeled {(spud pax)}" `[syd %| lab])
|
||||
(poke-info "labeled {(spud pax)}" `[syd %| lab aey])
|
||||
::
|
||||
++ poke-merge
|
||||
|= kiln-merge
|
||||
|
@ -17,15 +17,85 @@
|
||||
|= request
|
||||
^- json
|
||||
%- pairs:enjs:format
|
||||
:~ jsonrpc+s+'0.2'
|
||||
:~ jsonrpc+s+'2.0'
|
||||
id+s+id
|
||||
method+s+method
|
||||
::
|
||||
:- %params
|
||||
^- json
|
||||
?- -.params
|
||||
%list [%a +.params]
|
||||
%object [%o (~(gas by *(map @t json)) +.params)]
|
||||
==
|
||||
%list [%a +.params]
|
||||
:: FIXME: support either %map or %object (also in /sur/json/rpc)
|
||||
::
|
||||
%map [%o +.params]
|
||||
%object [%o (~(gas by *(map @t json)) +.params)]
|
||||
== ==
|
||||
::
|
||||
++ response-to-json
|
||||
|= =response
|
||||
^- json
|
||||
:: TODO: consider all cases
|
||||
::
|
||||
?+ -.response ~|([%unsupported-rpc-response response] !!)
|
||||
%batch a+(turn bas.response response-to-json)
|
||||
::
|
||||
%result
|
||||
%- pairs:enjs:format
|
||||
:: FIXME: return 'id' as string, number or NULL
|
||||
::
|
||||
:~ ['jsonrpc' s+'2.0']
|
||||
['id' s+id.response]
|
||||
['result' res.response]
|
||||
==
|
||||
::
|
||||
%error
|
||||
=, enjs:format
|
||||
%- pairs
|
||||
:~ ['jsonrpc' s+'2.0']
|
||||
['id' ?~(id.response ~ s+id.response)]
|
||||
::
|
||||
:- 'error'
|
||||
%- pairs
|
||||
:~ ['code' n+code.response]
|
||||
['message' s+message.response]
|
||||
== ==
|
||||
==
|
||||
::
|
||||
++ validate-request
|
||||
|= body=(unit octs)
|
||||
^- (unit batch-request)
|
||||
?~ body ~
|
||||
?~ jon=(de-json:html q.u.body) ~
|
||||
=, dejs-soft:format
|
||||
=; reparser
|
||||
?: ?=([%a *] u.jon)
|
||||
(bind ((ar reparser) u.jon) (lead %a))
|
||||
(bind (reparser u.jon) (lead %o))
|
||||
%- ot
|
||||
:~ :: FIXME: parse 'id' as string, number or NULL
|
||||
::
|
||||
['id' so]
|
||||
['jsonrpc' (su (jest '2.0'))]
|
||||
['method' so]
|
||||
::
|
||||
:- 'params'
|
||||
|= =json
|
||||
^- (unit request-params)
|
||||
?+ -.json ~
|
||||
%a `[%list ((ar:dejs:format same) json)]
|
||||
%o `[%map ((om:dejs:format same) json)]
|
||||
== ==
|
||||
::
|
||||
++ error
|
||||
|_ id=@t
|
||||
:: https://www.jsonrpc.org/specification#error_object
|
||||
::
|
||||
++ parse [%error id '-32700' 'Failed to parse']
|
||||
++ request [%error id '-32600' 'Invalid Request']
|
||||
++ method [%error id '-32601' 'Method not found']
|
||||
++ params [%error id '-32602' 'Invalid params']
|
||||
++ internal [%error id '-32603' 'Internal error']
|
||||
++ not-found [%error id '-32000' 'Resource not found']
|
||||
++ todo [%error id '-32001' 'Method not implemented']
|
||||
--
|
||||
--
|
||||
|
218
pkg/arvo/lib/naive-transactions.hoon
Normal file
218
pkg/arvo/lib/naive-transactions.hoon
Normal file
@ -0,0 +1,218 @@
|
||||
/+ naive, ethereum
|
||||
:: Types
|
||||
|%
|
||||
+$ address address:ethereum
|
||||
+$ nonce @ud
|
||||
+$ proxy ?(%own %spawn %manage %vote %transfer)
|
||||
--
|
||||
::
|
||||
|%
|
||||
::
|
||||
:: TODO: does this uniquely produce the pubkey?
|
||||
++ verifier
|
||||
^- ^verifier:naive
|
||||
|= [dat=octs v=@ r=@ s=@]
|
||||
?: (gth v 3) ~ :: TODO: move to jet
|
||||
=/ result
|
||||
%- mule
|
||||
|.
|
||||
=, secp256k1:secp:crypto
|
||||
%- address-from-pub:key:ethereum
|
||||
%- serialize-point
|
||||
(ecdsa-raw-recover (hash-tx dat) v r s)
|
||||
?- -.result
|
||||
%| ~
|
||||
%& `p.result
|
||||
==
|
||||
:: Verify signature and produce signer address
|
||||
::
|
||||
++ verify-sig
|
||||
|= [sig=@ txdata=octs]
|
||||
^- (unit address)
|
||||
|^
|
||||
:: Reversed of the usual r-s-v order because Ethereum integers are
|
||||
:: big-endian
|
||||
::
|
||||
=^ v sig (take 3)
|
||||
=^ s sig (take 3 32)
|
||||
=^ r sig (take 3 32)
|
||||
:: In Ethereum, v is generally 27 + recid, and verifier expects a
|
||||
:: recid. Old versions of geth used 0 + recid, so most software
|
||||
:: now supports either format. See:
|
||||
::
|
||||
:: https://github.com/ethereum/go-ethereum/issues/2053
|
||||
::
|
||||
=? v (gte v 27) (sub v 27)
|
||||
(verifier txdata v r s)
|
||||
::
|
||||
++ take
|
||||
|= =bite
|
||||
[(end bite sig) (rsh bite sig)]
|
||||
--
|
||||
::
|
||||
++ unsigned-tx
|
||||
|= [chain-id=@ud =nonce tx=octs]
|
||||
^- octs
|
||||
=/ prepared-data (prepare-for-sig chain-id nonce tx)
|
||||
=/ len (rsh [3 2] (scot %ui p.prepared-data))
|
||||
%: cad:naive 3
|
||||
26^'\19Ethereum Signed Message:\0a'
|
||||
(met 3 len)^len
|
||||
prepared-data
|
||||
~
|
||||
==
|
||||
::
|
||||
++ sign-tx
|
||||
|= [pk=@ =nonce tx=octs] ^- octs
|
||||
=/ sign-data
|
||||
%- hash-tx
|
||||
(unsigned-tx 1.337 nonce tx)
|
||||
=+ (ecdsa-raw-sign:secp256k1:secp:crypto sign-data pk)
|
||||
(cad:naive 3 1^v 32^s 32^r tx ~)
|
||||
::
|
||||
++ prepare-for-sig
|
||||
|= [chain-id=@ud =nonce tx=octs]
|
||||
^- octs
|
||||
=/ chain-t (rsh [3 2] (scot %ui chain-id))
|
||||
%: cad:naive 3
|
||||
14^'UrbitIDV1Chain'
|
||||
(met 3 chain-t)^chain-t
|
||||
1^':'
|
||||
4^nonce
|
||||
tx
|
||||
~
|
||||
==
|
||||
::
|
||||
++ extract-address
|
||||
|= [=raw-tx:naive nas=^state:naive chain-id=@]
|
||||
^- (unit @ux)
|
||||
?~ point=(get:orm:naive points.nas ship.from.tx.raw-tx)
|
||||
~
|
||||
=/ =nonce:naive
|
||||
=< nonce
|
||||
(proxy-from-point:naive proxy.from.tx.raw-tx u.point)
|
||||
=/ message=octs
|
||||
(unsigned-tx chain-id nonce raw.raw-tx)
|
||||
(verify-sig sig.raw-tx message)
|
||||
::
|
||||
++ gen-tx
|
||||
|= [=nonce tx=tx:naive pk=@] ^- octs
|
||||
:: takes in a nonce, tx:naive, and private key and returned a signed transactions as octs
|
||||
%^ sign-tx pk nonce (gen-tx-octs tx)
|
||||
::
|
||||
++ gen-tx-octs
|
||||
:: generates octs for a transaction
|
||||
|= tx=tx:naive
|
||||
|^
|
||||
^- octs
|
||||
=/ raw=octs
|
||||
?- +<.tx
|
||||
%spawn (get-spawn +>.tx)
|
||||
%transfer-point (get-transfer +>.tx)
|
||||
%configure-keys (get-keys +>.tx)
|
||||
%escape (get-escape +.tx)
|
||||
%cancel-escape (get-escape +.tx)
|
||||
%adopt (get-escape +.tx)
|
||||
%reject (get-escape +.tx)
|
||||
%detach (get-escape +.tx)
|
||||
%set-management-proxy (get-ship-address +.tx)
|
||||
%set-spawn-proxy (get-ship-address +.tx)
|
||||
%set-transfer-proxy (get-ship-address +.tx)
|
||||
==
|
||||
raw
|
||||
::
|
||||
++ get-spawn
|
||||
|= [child=ship to=address] ^- octs
|
||||
%: cad:naive 3
|
||||
(from-proxy proxy.from.tx)
|
||||
4^ship.from.tx
|
||||
1^%1 :: %spawn
|
||||
4^child
|
||||
20^to
|
||||
~
|
||||
==
|
||||
::
|
||||
++ get-transfer
|
||||
|= [=address reset=?] ^- octs
|
||||
%: cad:naive 3
|
||||
(from-proxy proxy.from.tx)
|
||||
4^ship.from.tx
|
||||
1^(can 0 7^%0 1^reset ~) :: %transfer-point
|
||||
20^address
|
||||
~
|
||||
==
|
||||
::
|
||||
++ get-keys
|
||||
|= [crypt=@ auth=@ suite=@ breach=?] ^- octs
|
||||
%: cad:naive 3
|
||||
(from-proxy proxy.from.tx)
|
||||
4^ship.from.tx
|
||||
1^(can 0 7^%2 1^breach ~) :: %configure-keys
|
||||
32^crypt
|
||||
32^auth
|
||||
4^suite
|
||||
~
|
||||
==
|
||||
::
|
||||
++ get-escape
|
||||
|= [action=@tas other=ship] ^- octs
|
||||
=/ op
|
||||
?+ action !!
|
||||
%escape %3
|
||||
%cancel-escape %4
|
||||
%adopt %5
|
||||
%reject %6
|
||||
%detach %7
|
||||
==
|
||||
%: cad:naive 3
|
||||
(from-proxy proxy.from.tx)
|
||||
4^ship.from.tx
|
||||
1^(can 0 7^op 1^0 ~)
|
||||
4^other
|
||||
~
|
||||
==
|
||||
::
|
||||
++ get-ship-address
|
||||
|= [action=@tas =address] ^- octs
|
||||
=/ op
|
||||
?+ action !!
|
||||
%set-management-proxy %8
|
||||
%set-spawn-proxy %9
|
||||
%set-transfer-proxy %10
|
||||
==
|
||||
%: cad:naive 3
|
||||
(from-proxy proxy.from.tx)
|
||||
4^ship.from.tx
|
||||
1^(can 0 7^op 1^0 ~)
|
||||
20^address
|
||||
~
|
||||
==
|
||||
::
|
||||
++ from-proxy
|
||||
|= prx=@tas
|
||||
^- [@ @]
|
||||
=/ proxy
|
||||
?+ prx !!
|
||||
%own %0
|
||||
%spawn %1
|
||||
%manage %2
|
||||
%vote %3
|
||||
%transfer %4
|
||||
==
|
||||
1^(can 0 3^proxy 5^0 ~)
|
||||
::
|
||||
--
|
||||
::
|
||||
++ hash-tx keccak-256:keccak:crypto
|
||||
::
|
||||
++ hash-raw-tx
|
||||
|= raw-tx:naive
|
||||
^- @ux
|
||||
%- hash-tx
|
||||
%: cad:naive 3
|
||||
65^sig
|
||||
raw
|
||||
~
|
||||
==
|
||||
::
|
||||
--
|
926
pkg/arvo/lib/naive.hoon
Normal file
926
pkg/arvo/lib/naive.hoon
Normal file
@ -0,0 +1,926 @@
|
||||
/+ tiny
|
||||
!.
|
||||
=> => tiny
|
||||
:: Laconic bit
|
||||
::
|
||||
=| lac=?
|
||||
:: Constants
|
||||
::
|
||||
|%
|
||||
:: Transfers on L1 to this address count as depositing to L2
|
||||
::
|
||||
++ deposit-address 0x1111.1111.1111.1111.1111.1111.1111.1111.1111.1111
|
||||
++ log-names
|
||||
|%
|
||||
:: Generated with (keccak-256:keccak:crypto (as-octs:mimes:html name))
|
||||
::
|
||||
:: OwnerChanged(uint32,address)
|
||||
++ owner-changed
|
||||
0x16d0.f539.d49c.6cad.822b.767a.9445.bfb1.
|
||||
cf7e.a6f2.a6c2.b120.a7ea.4cc7.660d.8fda
|
||||
::
|
||||
:: Activated(uint32)
|
||||
++ activated
|
||||
0xe74c.0380.9d07.69e1.b1f7.06cc.8414.258c.
|
||||
d1f3.b6fe.020c.d15d.0165.c210.ba50.3a0f
|
||||
::
|
||||
:: Spawned(uint32,uint32)
|
||||
++ spawned
|
||||
0xb2d3.a6e7.a339.f5c8.ff96.265e.2f03.a010.
|
||||
a854.1070.f374.4a24.7090.9644.1508.1546
|
||||
::
|
||||
:: OwnershipTransferred(address,address)
|
||||
++ ownership-transferred
|
||||
0x8be0.079c.5316.5914.1344.cd1f.d0a4.f284.
|
||||
1949.7f97.22a3.daaf.e3b4.186f.6b64.57e0
|
||||
::
|
||||
:: EscapeRequested(uint32,uint32)
|
||||
++ escape-requested
|
||||
0xb4d4.850b.8f21.8218.141c.5665.cba3.79e5.
|
||||
3e9b.b015.b51e.8d93.4be7.0210.aead.874a
|
||||
::
|
||||
:: EscapeCanceled(uint32,uint32)
|
||||
++ escape-canceled
|
||||
0xd653.bb0e.0bb7.ce83.93e6.24d9.8fbf.17cd.
|
||||
a590.2c83.28ed.0cd0.9988.f368.90d9.932a
|
||||
::
|
||||
:: EscapeAccepted(uint32,uint32)
|
||||
++ escape-accepted
|
||||
0x7e44.7c9b.1bda.4b17.4b07.96e1.00bf.7f34.
|
||||
ebf3.6dbb.7fe6.6549.0b1b.fce6.246a.9da5
|
||||
::
|
||||
:: LostSponsor(uint32,uint32)
|
||||
++ lost-sponsor
|
||||
0xd770.4f9a.2519.3dbd.0b0c.b4a8.09fe.ffff.
|
||||
a7f1.9d1a.ae88.17a7.1346.c194.4482.10d5
|
||||
::
|
||||
:: ChangedKeys(uint32,bytes32,bytes32,uint32,uint32)
|
||||
++ changed-keys
|
||||
0xaa10.e7a0.117d.4323.f1d9.9d63.0ec1.69be.
|
||||
bb3a.988e.8957.70e3.5198.7e01.ff54.23d5
|
||||
::
|
||||
:: BrokeContinuity(uint32,uint32)
|
||||
++ broke-continuity
|
||||
0x2929.4799.f1c2.1a37.ef83.8e15.f79d.d91b.
|
||||
cee2.df99.d63c.d1c1.8ac9.68b1.2951.4e6e
|
||||
::
|
||||
:: ChangedSpawnProxy(uint32,address)
|
||||
++ changed-spawn-proxy
|
||||
0x9027.36af.7b3c.efe1.0d9e.840a.ed0d.687e.
|
||||
35c8.4095.122b.2505.1a20.ead8.866f.006d
|
||||
::
|
||||
:: ChangedTransferProxy(uint32,address)
|
||||
++ changed-transfer-proxy
|
||||
0xcfe3.69b7.197e.7f0c.f067.93ae.2472.a9b1.
|
||||
3583.fecb.ed2f.78df.a14d.1f10.796b.847c
|
||||
::
|
||||
:: ChangedManagementProxy(uint32,address)
|
||||
++ changed-management-proxy
|
||||
0xab9c.9327.cffd.2acc.168f.afed.be06.139f.
|
||||
5f55.cb84.c761.df05.e051.1c25.1e2e.e9bf
|
||||
::
|
||||
:: ChangedVotingProxy(uint32,address)
|
||||
++ changed-voting-proxy
|
||||
0xcbd6.269e.c714.57f2.c7b1.a227.74f2.46f6.
|
||||
c5a2.eae3.795e.d730.0db5.1768.0c61.c805
|
||||
::
|
||||
:: ChangedDns(string,string,string)
|
||||
++ changed-dns
|
||||
0xfafd.04ad.e1da.ae2e.1fdb.0fc1.cc6a.899f.
|
||||
d424.063e.d5c9.2120.e67e.0730.53b9.4898
|
||||
::
|
||||
:: ApprovalForAll(address,address,bool)
|
||||
++ approval-for-all
|
||||
0x1730.7eab.39ab.6107.e889.9845.ad3d.59bd.
|
||||
9653.f200.f220.9204.89ca.2b59.3769.6c31
|
||||
--
|
||||
-- =>
|
||||
:: Types
|
||||
|%
|
||||
:: ethereum address, 20 bytes.
|
||||
::
|
||||
+$ address @ux
|
||||
+$ nonce @ud
|
||||
+$ dominion ?(%l1 %l2 %spawn)
|
||||
+$ keys [=life suite=@ud auth=@ crypt=@]
|
||||
++ orm ((on ship point) por)
|
||||
++ point
|
||||
$: :: domain
|
||||
::
|
||||
=dominion
|
||||
::
|
||||
:: ownership
|
||||
::
|
||||
$= own
|
||||
$: owner=[=address =nonce]
|
||||
spawn-proxy=[=address =nonce]
|
||||
management-proxy=[=address =nonce]
|
||||
voting-proxy=[=address =nonce]
|
||||
transfer-proxy=[=address =nonce]
|
||||
==
|
||||
::
|
||||
:: networking
|
||||
::
|
||||
$= net
|
||||
$: rift=@ud
|
||||
=keys
|
||||
sponsor=[has=? who=@p]
|
||||
escape=(unit @p)
|
||||
==
|
||||
==
|
||||
::
|
||||
++ diff
|
||||
$% [%nonce =ship =proxy =nonce]
|
||||
[%tx =raw-tx err=(unit @tas)]
|
||||
[%operator owner=address operator=address approved=?]
|
||||
[%dns domains=(list @t)]
|
||||
$: %point =ship
|
||||
$% [%rift =rift]
|
||||
[%keys =keys]
|
||||
[%sponsor sponsor=(unit @p)]
|
||||
[%escape to=(unit @p)]
|
||||
[%owner =address]
|
||||
[%spawn-proxy =address]
|
||||
[%management-proxy =address]
|
||||
[%voting-proxy =address]
|
||||
[%transfer-proxy =address]
|
||||
[%dominion =dominion]
|
||||
== == ==
|
||||
::
|
||||
+$ state
|
||||
$: %0
|
||||
=points
|
||||
=operators
|
||||
dns=(list @t)
|
||||
==
|
||||
+$ points (tree [ship point])
|
||||
+$ operators (jug address address)
|
||||
+$ effects (list diff)
|
||||
+$ proxy ?(%own %spawn %manage %vote %transfer)
|
||||
+$ roll (list raw-tx)
|
||||
+$ raw-tx [sig=@ raw=octs =tx]
|
||||
+$ tx [from=[=ship =proxy] skim-tx]
|
||||
+$ skim-tx
|
||||
$% [%transfer-point =address reset=?]
|
||||
[%spawn =ship =address]
|
||||
[%configure-keys encrypt=@ auth=@ crypto-suite=@ breach=?]
|
||||
[%escape parent=ship]
|
||||
[%cancel-escape parent=ship]
|
||||
[%adopt =ship]
|
||||
[%reject =ship]
|
||||
[%detach =ship]
|
||||
[%set-management-proxy =address]
|
||||
[%set-spawn-proxy =address]
|
||||
[%set-transfer-proxy =address]
|
||||
==
|
||||
::
|
||||
+$ event-log
|
||||
$: address=@ux
|
||||
data=@ux
|
||||
topics=(lest @ux)
|
||||
==
|
||||
+$ input
|
||||
$: block=@ud
|
||||
$% [%bat batch=@]
|
||||
[%log =event-log]
|
||||
== ==
|
||||
:: ECDSA verifier.
|
||||
::
|
||||
:: Must keccak `dat` and recover the ethereum address which signed.
|
||||
:: Must not crash. `v` will normally be between 0 and 3; if it is not,
|
||||
:: should produce null.
|
||||
::
|
||||
+$ verifier $-([dat=octs v=@ r=@ s=@] (unit address))
|
||||
-- =>
|
||||
::
|
||||
|%
|
||||
++ debug
|
||||
|* [meg=@t *]
|
||||
?: lac
|
||||
+<+
|
||||
~> %slog.[0 meg]
|
||||
+<+
|
||||
::
|
||||
++ parse-roll
|
||||
|= batch=@
|
||||
=| =roll
|
||||
=| pos=@ud
|
||||
=/ las (met 0 batch)
|
||||
|- ^+ roll
|
||||
?: (gte pos las)
|
||||
(flop roll)
|
||||
=/ parse-result (parse-raw-tx pos batch)
|
||||
:: Parsing failed, abort batch
|
||||
::
|
||||
?~ parse-result
|
||||
(debug %parse-failed ~)
|
||||
=^ =raw-tx pos u.parse-result
|
||||
$(roll [raw-tx roll])
|
||||
::
|
||||
++ parse-raw-tx
|
||||
|= [pos=@ud batch=@]
|
||||
^- (unit [raw-tx pos=@ud])
|
||||
|^
|
||||
=^ sig pos (take 3 65)
|
||||
=/ res=(unit [=tx pos=@ud]) parse-tx
|
||||
?~ res ~
|
||||
=/ dif (sub pos.u.res pos)
|
||||
=/ len =>((dvr dif 8) ?>(=(0 q) p))
|
||||
:- ~ :_ pos.u.res
|
||||
[sig [len (cut 0 [pos dif] batch)] tx.u.res]
|
||||
::
|
||||
++ parse-tx
|
||||
^- (unit [tx pos=@ud])
|
||||
=^ from-proxy=@ pos (take 0 3)
|
||||
?. ?=(?(%0 %1 %2 %3 %4) from-proxy) (debug %bad-proxy ~)
|
||||
=/ =proxy
|
||||
?- from-proxy
|
||||
%0 %own
|
||||
%1 %spawn
|
||||
%2 %manage
|
||||
%3 %vote
|
||||
%4 %transfer
|
||||
==
|
||||
=^ pad pos (take 0 5)
|
||||
=^ from-ship=ship pos (take 3 4)
|
||||
=- ?~ res
|
||||
~
|
||||
`[[[from-ship proxy] skim-tx.u.res] pos.u.res]
|
||||
^- res=(unit [=skim-tx pos=@ud])
|
||||
=^ op pos (take 0 7)
|
||||
?+ op (debug %strange-opcode ~)
|
||||
%0
|
||||
=^ reset=@ pos (take 0)
|
||||
=^ =address pos (take 3 20)
|
||||
`[[%transfer-point address =(0 reset)] pos]
|
||||
::
|
||||
%1
|
||||
=^ pad=@ pos (take 0)
|
||||
=^ =ship pos (take 3 4)
|
||||
=^ =address pos (take 3 20)
|
||||
`[[%spawn ship address] pos]
|
||||
::
|
||||
%2
|
||||
=^ breach=@ pos (take 0)
|
||||
=^ encrypt=@ pos (take 3 32)
|
||||
=^ auth=@ pos (take 3 32)
|
||||
=^ crypto-suite=@ pos (take 3 4)
|
||||
`[[%configure-keys encrypt auth crypto-suite =(0 breach)] pos]
|
||||
::
|
||||
%3 =^(res pos take-ship `[[%escape res] pos])
|
||||
%4 =^(res pos take-ship `[[%cancel-escape res] pos])
|
||||
%5 =^(res pos take-ship `[[%adopt res] pos])
|
||||
%6 =^(res pos take-ship `[[%reject res] pos])
|
||||
%7 =^(res pos take-ship `[[%detach res] pos])
|
||||
%8 =^(res pos take-address `[[%set-management-proxy res] pos])
|
||||
%9 =^(res pos take-address `[[%set-spawn-proxy res] pos])
|
||||
%10 =^(res pos take-address `[[%set-transfer-proxy res] pos])
|
||||
==
|
||||
::
|
||||
:: Take a bite
|
||||
::
|
||||
++ take
|
||||
|= =bite
|
||||
^- [@ @ud]
|
||||
=/ =step
|
||||
?@ bite (bex bite)
|
||||
(mul step.bite (bex bloq.bite))
|
||||
[(cut 0 [pos step] batch) (add pos step)]
|
||||
:: Encode ship and address
|
||||
::
|
||||
++ take-address
|
||||
^- [address @ud]
|
||||
=^ pad=@ pos (take 0)
|
||||
=^ =address pos (take 3 20)
|
||||
[address pos]
|
||||
:: Encode escape-related txs
|
||||
::
|
||||
++ take-ship
|
||||
^- [ship @ud]
|
||||
=^ pad=@ pos (take 0)
|
||||
=^ other=ship pos (take 3 4)
|
||||
[other pos]
|
||||
--
|
||||
::
|
||||
++ proxy-from-point
|
||||
|= [=proxy point]
|
||||
^- [=address =nonce]
|
||||
?- proxy
|
||||
%own owner.own
|
||||
%spawn spawn-proxy.own
|
||||
%manage management-proxy.own
|
||||
%vote voting-proxy.own
|
||||
%transfer transfer-proxy.own
|
||||
==
|
||||
::
|
||||
++ verify-sig-and-nonce
|
||||
|= [=verifier chain-t=@t =state =raw-tx]
|
||||
^- ?
|
||||
|^
|
||||
=/ point (get-point state ship.from.tx.raw-tx)
|
||||
?> ?=(^ point) :: we never parse more than four bytes for a ship
|
||||
=/ need=[=address =nonce]
|
||||
(proxy-from-point proxy.from.tx.raw-tx u.point)
|
||||
:: We include a domain separator to avoid letting signatures be
|
||||
:: accidentally reused with other applications. We include the name
|
||||
:: UrbitID, a signature format version number, and the EIP-155 chain
|
||||
:: ID.
|
||||
::
|
||||
:: We also include a nonce so that a transaction cannot be
|
||||
:: rebroadcast.
|
||||
::
|
||||
=/ prepared-data=octs
|
||||
%: cad 3
|
||||
14^'UrbitIDV1Chain'
|
||||
(met 3 chain-t)^chain-t
|
||||
1^':'
|
||||
4^nonce.need
|
||||
raw.raw-tx
|
||||
~
|
||||
==
|
||||
:: Wallets which support personal_sign include this preamble to avoid
|
||||
:: letting personal_sign be used to sign ethereum transactions
|
||||
::
|
||||
=/ signed-data=octs
|
||||
=/ len (ud-to-ascii p.prepared-data)
|
||||
%: cad 3
|
||||
26^'\19Ethereum Signed Message:\0a'
|
||||
(met 3 len)^len
|
||||
prepared-data
|
||||
~
|
||||
==
|
||||
=/ dress (verify-sig sig.raw-tx signed-data)
|
||||
?~ dress
|
||||
|
|
||||
=(address.need u.dress)
|
||||
:: Verify signature and produce signer address
|
||||
::
|
||||
++ verify-sig
|
||||
|= [sig=@ txdata=octs]
|
||||
^- (unit address)
|
||||
|^
|
||||
:: Reversed of the usual r-s-v order because Ethereum integers are
|
||||
:: big-endian
|
||||
::
|
||||
=^ v sig (take 3)
|
||||
=^ s sig (take 3 32)
|
||||
=^ r sig (take 3 32)
|
||||
:: In Ethereum, v is generally 27 + recid, and verifier expects a
|
||||
:: recid. Old versions of geth used 0 + recid, so most software
|
||||
:: now supports either format. See:
|
||||
::
|
||||
:: https://github.com/ethereum/go-ethereum/issues/2053
|
||||
::
|
||||
=? v (gte v 27) (sub v 27)
|
||||
(verifier txdata v r s)
|
||||
::
|
||||
++ take
|
||||
|= =bite
|
||||
[(end bite sig) (rsh bite sig)]
|
||||
--
|
||||
--
|
||||
:: ASCII-decimal encode
|
||||
::
|
||||
++ ud-to-ascii
|
||||
|= n=@ud
|
||||
?~ n '0'
|
||||
=| l=(list @)
|
||||
|- ^- @t
|
||||
?~ n (rep 3 l)
|
||||
=+ (dvr n 10)
|
||||
$(n p, l [(add '0' q) l])
|
||||
::
|
||||
++ ship-rank
|
||||
|= =ship
|
||||
^- ?(%0 %1 %2 %3 %4)
|
||||
?: (lth ship 0x100) %0
|
||||
?: (lth ship 0x1.0000) %1
|
||||
?: (lth ship 0x1.0000.0000) %2
|
||||
?: (lth ship 0x1.0000.0000.0000.0000) %3
|
||||
%4
|
||||
::
|
||||
++ sein :: autoboss
|
||||
|= who=ship
|
||||
^- ship
|
||||
=/ mir (ship-rank who)
|
||||
?- mir
|
||||
%0 who
|
||||
%1 (end 3 who)
|
||||
%2 (end 4 who)
|
||||
%3 (end 5 who)
|
||||
%4 (end 4 who)
|
||||
==
|
||||
::
|
||||
:: Produces null only if ship is not a galaxy, star, or planet
|
||||
::
|
||||
++ get-point
|
||||
|= [=state =ship]
|
||||
^- (unit point)
|
||||
=/ existing (get:orm points.state ship)
|
||||
?^ existing
|
||||
`u.existing
|
||||
=| =point
|
||||
=. who.sponsor.net.point (sein ship)
|
||||
?+ (ship-rank ship) (debug %strange-point ~)
|
||||
%0 `point(dominion %l1)
|
||||
?(%1 %2)
|
||||
=/ existing-parent $(ship (sein ship))
|
||||
?~ existing-parent ~
|
||||
:- ~
|
||||
%= point
|
||||
dominion
|
||||
?- dominion.u.existing-parent
|
||||
%l1 %l1
|
||||
%l2 %l2
|
||||
%spawn %l2
|
||||
==
|
||||
==
|
||||
==
|
||||
-- =>
|
||||
|%
|
||||
:: Receive log from L1 transaction
|
||||
::
|
||||
++ receive-log
|
||||
|= [=state log=event-log]
|
||||
^- [effects ^state]
|
||||
=* log-name i.topics.log
|
||||
?: =(log-name activated:log-names) `state
|
||||
?: =(log-name spawned:log-names) `state
|
||||
?: =(log-name ownership-transferred:log-names) `state
|
||||
?: =(log-name changed-dns:log-names)
|
||||
?> ?=(~ t.topics.log)
|
||||
=/ words (rip 8 data.log)
|
||||
:: This is only true if each domain is <= 32 bytes
|
||||
::
|
||||
?. ?=([c=@ @ b=@ @ a=@ @ @ @ @ ~] words) `state
|
||||
=* one &5.words
|
||||
=* two &3.words
|
||||
=* tri &1.words
|
||||
=/ domains ~[(swp 3 one) (swp 3 two) (swp 3 tri)]
|
||||
:- [%dns domains]~
|
||||
state(dns domains)
|
||||
::
|
||||
?: =(log-name approval-for-all:log-names)
|
||||
?> ?=([@ @ ~] t.topics.log)
|
||||
=* owner i.t.topics.log
|
||||
=* operator i.t.t.topics.log
|
||||
=/ approved !=(0 data.log)
|
||||
:- [%operator owner operator approved]~
|
||||
=- state(operators -)
|
||||
?: approved
|
||||
(~(put ju operators.state) owner operator)
|
||||
(~(del ju operators.state) owner operator)
|
||||
::
|
||||
:: The rest of the logs modify a particular ship, specified in the
|
||||
:: second topic. We fetch it, and insert the modification back into
|
||||
:: our state.
|
||||
::
|
||||
?> ?=([@ *] t.topics.log)
|
||||
=* ship=@ i.t.topics.log
|
||||
=/ the-point (get-point state ship)
|
||||
?> ?=(^ the-point)
|
||||
=* point u.the-point
|
||||
::
|
||||
:: Important to fully no-op on failure so we don't insert an entry
|
||||
:: into points.state
|
||||
::
|
||||
=- ?~ res
|
||||
`state
|
||||
[effects.u.res state(points (put:orm points.state ship new-point.u.res))]
|
||||
^- res=(unit [=effects new-point=^point])
|
||||
::
|
||||
?: =(log-name changed-spawn-proxy:log-names)
|
||||
?. ?=(%l1 -.point) ~
|
||||
?> ?=([@ ~] t.t.topics.log)
|
||||
=* to i.t.t.topics.log
|
||||
:: Depositing to L2 is represented by a spawn proxy change on L1,
|
||||
:: but it doesn't change the actual spawn proxy.
|
||||
::
|
||||
?: =(deposit-address to)
|
||||
:+ ~ [%point ship %dominion %spawn]~
|
||||
point(dominion %spawn)
|
||||
:+ ~ [%point ship %spawn-proxy to]~
|
||||
point(address.spawn-proxy.own to)
|
||||
::
|
||||
?: =(log-name escape-accepted:log-names)
|
||||
?> ?=([@ ~] t.t.topics.log)
|
||||
=* parent=@ i.t.t.topics.log
|
||||
=/ parent-point (get-point state parent)
|
||||
?> ?=(^ parent-point)
|
||||
?: ?=(%l2 -.u.parent-point) ~
|
||||
:+ ~ [%point ship %sponsor `parent]~
|
||||
point(escape.net ~, sponsor.net [%& parent])
|
||||
::
|
||||
?: =(log-name lost-sponsor:log-names)
|
||||
?> ?=([@ ~] t.t.topics.log)
|
||||
=* parent=@ i.t.t.topics.log
|
||||
:: If the sponsor we lost was not our actual sponsor, we didn't
|
||||
:: actually lose anything.
|
||||
::
|
||||
?. =(parent who.sponsor.net.point) ~
|
||||
::
|
||||
=/ parent-point (get-point state parent)
|
||||
?> ?=(^ parent-point)
|
||||
::
|
||||
:: We can detach even if the child is on L2, as long as the parent
|
||||
:: is on L1.
|
||||
::
|
||||
?: ?=(%l2 -.u.parent-point) ~
|
||||
:+ ~ [%point ship %sponsor ~]~
|
||||
point(has.sponsor.net %|)
|
||||
::
|
||||
:: The rest can be done by any ship on L1, even if their spawn proxy
|
||||
:: is set to L2
|
||||
::
|
||||
?: ?=(%l2 -.point) ~
|
||||
::
|
||||
?: =(log-name escape-requested:log-names)
|
||||
?> ?=([@ ~] t.t.topics.log)
|
||||
=* parent=@ i.t.t.topics.log
|
||||
=/ parent-point (get-point state parent)
|
||||
?> ?=(^ parent-point)
|
||||
:+ ~ [%point ship %escape `parent]~
|
||||
point(escape.net `parent)
|
||||
::
|
||||
?: =(log-name escape-canceled:log-names)
|
||||
?> ?=([@ ~] t.t.topics.log)
|
||||
=* parent=@ i.t.t.topics.log
|
||||
=/ parent-point (get-point state parent)
|
||||
?> ?=(^ parent-point)
|
||||
:+ ~ [%point ship %escape ~]~
|
||||
point(escape.net ~)
|
||||
::
|
||||
?: =(log-name broke-continuity:log-names)
|
||||
?> ?=(~ t.t.topics.log)
|
||||
=* rift=@ data.log
|
||||
:+ ~ [%point ship %rift rift]~
|
||||
point(rift.net rift)
|
||||
::
|
||||
?: =(log-name changed-keys:log-names)
|
||||
?> ?=(~ t.t.topics.log)
|
||||
=/ =keys
|
||||
:* life=(cut 8 [0 1] data.log)
|
||||
suite=(cut 8 [1 1] data.log)
|
||||
auth=(cut 8 [2 1] data.log)
|
||||
crypt=(cut 8 [3 1] data.log)
|
||||
==
|
||||
:+ ~ [%point ship %keys keys]~
|
||||
point(keys.net keys)
|
||||
::
|
||||
?: =(log-name owner-changed:log-names)
|
||||
?> ?=([@ ~] t.t.topics.log)
|
||||
=* to i.t.t.topics.log
|
||||
:: Depositing to L2 is represented by an ownership change on L1,
|
||||
:: but it doesn't change who actually owns the ship.
|
||||
::
|
||||
?: =(deposit-address to)
|
||||
:+ ~ [%point ship %dominion %l2]~
|
||||
point(dominion %l2)
|
||||
:+ ~ [%point ship %owner to]~
|
||||
point(address.owner.own to)
|
||||
::
|
||||
?: =(log-name changed-transfer-proxy:log-names)
|
||||
?> ?=([@ ~] t.t.topics.log)
|
||||
=* to i.t.t.topics.log
|
||||
:+ ~ [%point ship %transfer-proxy to]~
|
||||
point(address.transfer-proxy.own to)
|
||||
::
|
||||
?: =(log-name changed-management-proxy:log-names)
|
||||
?> ?=([@ ~] t.t.topics.log)
|
||||
=* to i.t.t.topics.log
|
||||
:+ ~ [%point ship %management-proxy to]~
|
||||
point(address.management-proxy.own to)
|
||||
::
|
||||
?: =(log-name changed-voting-proxy:log-names)
|
||||
?> ?=([@ ~] t.t.topics.log)
|
||||
=* to i.t.t.topics.log
|
||||
:+ ~ [%point ship %voting-proxy to]~
|
||||
point(address.voting-proxy.own to)
|
||||
::
|
||||
(debug %unknown-log ~)
|
||||
::
|
||||
:: Receive batch of L2 transactions
|
||||
::
|
||||
++ receive-batch
|
||||
|= [=verifier chain-id=@ud =state batch=@]
|
||||
=/ chain-t (ud-to-ascii chain-id)
|
||||
=/ =roll (parse-roll batch)
|
||||
|- ^- [effects ^state]
|
||||
?~ roll
|
||||
[~ state]
|
||||
:: Verify signature, else skip tx
|
||||
::
|
||||
?. (verify-sig-and-nonce verifier chain-t state i.roll)
|
||||
%+ debug %l2-sig-failed
|
||||
=^ effects state $(roll t.roll)
|
||||
:_ state
|
||||
[[%tx i.roll `%sig-or-nonce-failed] effects]
|
||||
:: Increment nonce, even if it later fails
|
||||
::
|
||||
=^ effects-1 points.state (increment-nonce state from.tx.i.roll)
|
||||
:: Process tx
|
||||
::
|
||||
=^ effects-2 state
|
||||
=/ tx-result=(unit [=effects =^state]) (receive-tx state tx.i.roll)
|
||||
?~ tx-result
|
||||
%+ debug %l2-tx-failed
|
||||
[[%tx i.roll `%tx-failed]~ state]
|
||||
[[[%tx i.roll ~] effects.u.tx-result] state.u.tx-result]
|
||||
=^ effects-3 state $(roll t.roll)
|
||||
[:(welp effects-1 effects-2 effects-3) state]
|
||||
::
|
||||
++ increment-nonce
|
||||
|= [=state =ship =proxy]
|
||||
=/ point (get-point state ship)
|
||||
?> ?=(^ point) :: we only parsed 4 bytes
|
||||
=* own own.u.point
|
||||
=^ nonce u.point
|
||||
?- proxy
|
||||
%own
|
||||
:- nonce.owner.own
|
||||
u.point(nonce.owner.own +(nonce.owner.own))
|
||||
::
|
||||
%spawn
|
||||
:- nonce.spawn-proxy.own
|
||||
u.point(nonce.spawn-proxy.own +(nonce.spawn-proxy.own))
|
||||
::
|
||||
%manage
|
||||
:- nonce.management-proxy.own
|
||||
u.point(nonce.management-proxy.own +(nonce.management-proxy.own))
|
||||
::
|
||||
%vote
|
||||
:- nonce.voting-proxy.own
|
||||
u.point(nonce.voting-proxy.own +(nonce.voting-proxy.own))
|
||||
::
|
||||
%transfer
|
||||
:- nonce.transfer-proxy.own
|
||||
u.point(nonce.transfer-proxy.own +(nonce.transfer-proxy.own))
|
||||
==
|
||||
::
|
||||
:- [%nonce ship proxy nonce]~
|
||||
(put:orm points.state ship u.point)
|
||||
::
|
||||
:: Receive an individual L2 transaction
|
||||
::
|
||||
++ receive-tx
|
||||
|= [=state =tx]
|
||||
|^
|
||||
^- (unit [effects ^state])
|
||||
?- +<.tx
|
||||
%spawn (process-spawn +>.tx)
|
||||
%transfer-point (w-point process-transfer-point ship.from.tx +>.tx)
|
||||
%configure-keys (w-point process-configure-keys ship.from.tx +>.tx)
|
||||
%escape (w-point-esc process-escape ship.from.tx +>.tx)
|
||||
%cancel-escape (w-point-esc process-cancel-escape ship.from.tx +>.tx)
|
||||
%adopt (w-point-esc process-adopt ship.tx +>.tx)
|
||||
%reject (w-point-esc process-reject ship.tx +>.tx)
|
||||
%detach (w-point-esc process-detach ship.tx +>.tx)
|
||||
%set-spawn-proxy
|
||||
(w-point-spawn process-set-spawn-proxy ship.from.tx +>.tx)
|
||||
::
|
||||
%set-transfer-proxy
|
||||
(w-point process-set-transfer-proxy ship.from.tx +>.tx)
|
||||
::
|
||||
%set-management-proxy
|
||||
(w-point process-set-management-proxy ship.from.tx +>.tx)
|
||||
==
|
||||
::
|
||||
++ w-point
|
||||
|* [fun=$-([ship point *] (unit [effects point])) =ship rest=*]
|
||||
^- (unit [effects ^state])
|
||||
=/ point (get-point state ship)
|
||||
?~ point (debug %strange-ship ~)
|
||||
?. ?=(%l2 -.u.point) (debug %ship-not-on-l2 ~)
|
||||
:: Important to fully no-op on failure so we don't insert an entry
|
||||
:: into points.state
|
||||
::
|
||||
=/ res=(unit [=effects new-point=^point]) (fun u.point rest)
|
||||
?~ res
|
||||
~
|
||||
`[effects.u.res state(points (put:orm points.state ship new-point.u.res))]
|
||||
::
|
||||
++ w-point-esc
|
||||
|* [fun=$-([ship point *] (unit [effects point])) =ship rest=*]
|
||||
^- (unit [effects ^state])
|
||||
=/ point (get-point state ship)
|
||||
?~ point (debug %strange-ship ~)
|
||||
=/ res=(unit [=effects new-point=^point]) (fun u.point rest)
|
||||
?~ res
|
||||
~
|
||||
`[effects.u.res state(points (put:orm points.state ship new-point.u.res))]
|
||||
::
|
||||
++ w-point-spawn
|
||||
|* [fun=$-([ship point *] (unit [effects point])) =ship rest=*]
|
||||
^- (unit [effects ^state])
|
||||
=/ point (get-point state ship)
|
||||
?~ point (debug %strange-ship ~)
|
||||
?: ?=(%l1 -.u.point) (debug %ship-on-l2 ~)
|
||||
=/ res=(unit [=effects new-point=^point]) (fun u.point rest)
|
||||
?~ res
|
||||
~
|
||||
`[effects.u.res state(points (put:orm points.state ship new-point.u.res))]
|
||||
::
|
||||
++ process-transfer-point
|
||||
|= [=point to=address reset=?]
|
||||
=* ship ship.from.tx
|
||||
:: Assert from owner or transfer prxoy
|
||||
::
|
||||
?. |(=(%own proxy.from.tx) =(%transfer proxy.from.tx))
|
||||
(debug %bad-permission ~)
|
||||
:: Execute transfer
|
||||
::
|
||||
=/ effects-1
|
||||
~[[%point ship %owner to] [%point ship %transfer-proxy *address]]
|
||||
=: address.owner.own.point to
|
||||
address.transfer-proxy.own.point *address
|
||||
==
|
||||
:: Execute reset if requested
|
||||
::
|
||||
?. reset
|
||||
`[effects-1 point]
|
||||
::
|
||||
=^ effects-2 net.point
|
||||
?: =([0 0 0] +.keys.net.point)
|
||||
`net.point
|
||||
=/ =keys [+(life.keys.net.point) 0 0 0]
|
||||
:- [%point ship %keys keys]~
|
||||
[rift.net.point keys sponsor.net.point escape.net.point]
|
||||
=^ effects-3 rift.net.point
|
||||
?: =(0 life.keys.net.point)
|
||||
`rift.net.point
|
||||
:- [%point ship %rift +(rift.net.point)]~
|
||||
+(rift.net.point)
|
||||
=/ effects-4
|
||||
:~ [%point ship %spawn-proxy *address]
|
||||
[%point ship %management-proxy *address]
|
||||
[%point ship %voting-proxy *address]
|
||||
[%point ship %transfer-proxy *address]
|
||||
==
|
||||
=: address.spawn-proxy.own.point *address
|
||||
address.management-proxy.own.point *address
|
||||
address.voting-proxy.own.point *address
|
||||
address.transfer-proxy.own.point *address
|
||||
==
|
||||
`[:(welp effects-1 effects-2 effects-3 effects-4) point]
|
||||
::
|
||||
++ process-spawn
|
||||
|= [=ship to=address]
|
||||
^- (unit [effects ^state])
|
||||
=/ parent=^ship (sein ship)
|
||||
:: Assert parent is on L2
|
||||
::
|
||||
=/ parent-point (get-point state parent)
|
||||
?~ parent-point ~
|
||||
?. ?=(?(%l2 %spawn) -.u.parent-point) ~
|
||||
:: Assert from owner or spawn proxy
|
||||
::
|
||||
?. ?& =(parent ship.from.tx)
|
||||
|(=(%own proxy.from.tx) =(%spawn proxy.from.tx))
|
||||
==
|
||||
(debug %bad-permission ~)
|
||||
:: Assert child not already spawned
|
||||
::
|
||||
?^ (get:orm points.state ship) (debug %spawn-exists ~)
|
||||
:: Assert one-level-down
|
||||
::
|
||||
?. =(+((ship-rank parent)) (ship-rank ship)) (debug %bad-rank ~)
|
||||
::
|
||||
=/ [=effects new-point=point]
|
||||
=/ point=(unit point) (get-point state ship)
|
||||
?> ?=(^ point) :: only parsed 4 bytes
|
||||
:: If spawning to self, just do it
|
||||
::
|
||||
?: ?| ?& =(%own proxy.from.tx)
|
||||
=(to address.owner.own.u.parent-point)
|
||||
==
|
||||
?& =(%spawn proxy.from.tx)
|
||||
=(to address.spawn-proxy.own.u.parent-point)
|
||||
==
|
||||
==
|
||||
:- ~[[%point ship %dominion %l2] [%point ship %owner to]]
|
||||
u.point(address.owner.own to)
|
||||
:: Else spawn to parent and set transfer proxy
|
||||
::
|
||||
:- :~ [%point ship %dominion %l2]
|
||||
[%point ship %owner address.owner.own.u.parent-point]
|
||||
[%point ship %transfer-proxy to]
|
||||
==
|
||||
%= u.point
|
||||
address.owner.own address.owner.own.u.parent-point
|
||||
address.transfer-proxy.own to
|
||||
==
|
||||
`[effects state(points (put:orm points.state ship new-point))]
|
||||
::
|
||||
++ process-configure-keys
|
||||
|= [=point crypt=@ auth=@ suite=@ breach=?]
|
||||
=* ship ship.from.tx
|
||||
::
|
||||
?. |(=(%own proxy.from.tx) =(%manage proxy.from.tx))
|
||||
(debug %bad-permission ~)
|
||||
::
|
||||
=^ rift-effects rift.net.point
|
||||
?. breach
|
||||
`rift.net.point
|
||||
[[%point ship %rift +(rift.net.point)]~ +(rift.net.point)]
|
||||
::
|
||||
=^ keys-effects keys.net.point
|
||||
?: =(+.keys.net.point [suite auth crypt])
|
||||
`keys.net.point
|
||||
=/ =keys
|
||||
[+(life.keys.net.point) suite auth crypt]
|
||||
[[%point ship %keys keys]~ keys]
|
||||
::
|
||||
`[(welp rift-effects keys-effects) point]
|
||||
::
|
||||
++ process-escape
|
||||
|= [=point parent=ship]
|
||||
=* ship ship.from.tx
|
||||
?. |(=(%own proxy.from.tx) =(%manage proxy.from.tx))
|
||||
(debug %bad-permission ~)
|
||||
::
|
||||
?. =(+((ship-rank parent)) (ship-rank ship))
|
||||
(debug %bad-rank ~)
|
||||
::
|
||||
:+ ~ [%point ship %escape `parent]~
|
||||
point(escape.net `parent)
|
||||
::
|
||||
++ process-cancel-escape
|
||||
|= [=point parent=ship]
|
||||
=* ship ship.from.tx
|
||||
?. |(=(%own proxy.from.tx) =(%manage proxy.from.tx))
|
||||
(debug %bad-permission ~)
|
||||
::
|
||||
:+ ~ [%point ship %escape ~]~
|
||||
point(escape.net ~)
|
||||
::
|
||||
++ process-adopt
|
||||
|= [=point =ship]
|
||||
=* parent ship.from.tx
|
||||
?. |(=(%own proxy.from.tx) =(%manage proxy.from.tx))
|
||||
(debug %bad-permission ~)
|
||||
::
|
||||
?. =(escape.net.point `parent) (debug %no-adopt ~)
|
||||
:+ ~ [%point ship %sponsor `parent]~
|
||||
point(escape.net ~, sponsor.net [%& parent])
|
||||
::
|
||||
++ process-reject
|
||||
|= [=point =ship]
|
||||
=* parent ship.from.tx
|
||||
?. |(=(%own proxy.from.tx) =(%manage proxy.from.tx))
|
||||
(debug %bad-permission ~)
|
||||
::
|
||||
?. =(escape.net.point `parent) (debug %no-reject ~)
|
||||
:+ ~ [%point ship %escape ~]~
|
||||
point(escape.net ~)
|
||||
::
|
||||
++ process-detach
|
||||
|= [=point =ship]
|
||||
=* parent ship.from.tx
|
||||
?. |(=(%own proxy.from.tx) =(%manage proxy.from.tx))
|
||||
(debug %bad-permission ~)
|
||||
::
|
||||
?. =(who.sponsor.net.point parent) (debug %no-detach ~)
|
||||
:+ ~ [%point ship %sponsor ~]~
|
||||
point(has.sponsor.net %|)
|
||||
::
|
||||
++ process-set-management-proxy
|
||||
|= [=point =address]
|
||||
?. |(=(%own proxy.from.tx) =(%manage proxy.from.tx))
|
||||
(debug %bad-permission ~)
|
||||
::
|
||||
:+ ~ [%point ship.from.tx %management-proxy address]~
|
||||
point(address.management-proxy.own address)
|
||||
::
|
||||
++ process-set-spawn-proxy
|
||||
|= [=point =address]
|
||||
?. |(=(%own proxy.from.tx) =(%spawn proxy.from.tx))
|
||||
(debug %bad-permission ~)
|
||||
::
|
||||
?: (gte (ship-rank ship.from.tx) 2)
|
||||
(debug %spawn-proxy-planet ~)
|
||||
::
|
||||
:+ ~ [%point ship.from.tx %spawn-proxy address]~
|
||||
point(address.spawn-proxy.own address)
|
||||
::
|
||||
++ process-set-transfer-proxy
|
||||
|= [=point =address]
|
||||
?. |(=(%own proxy.from.tx) =(%transfer proxy.from.tx))
|
||||
(debug %bad-permission ~)
|
||||
::
|
||||
:+ ~ [%point ship.from.tx %transfer-proxy address]~
|
||||
point(address.transfer-proxy.own address)
|
||||
--
|
||||
--
|
||||
::
|
||||
:: State transition function
|
||||
::
|
||||
|= [=verifier chain-id=@ud =state =input]
|
||||
^- [effects ^state]
|
||||
?: ?=(%log +<.input)
|
||||
:: Received log from L1 transaction
|
||||
::
|
||||
(receive-log state event-log.input)
|
||||
:: Received L2 batch
|
||||
::
|
||||
:: %+ debug %batch
|
||||
(receive-batch verifier chain-id state batch.input)
|
670
pkg/arvo/lib/tiny.hoon
Normal file
670
pkg/arvo/lib/tiny.hoon
Normal file
@ -0,0 +1,670 @@
|
||||
!.
|
||||
=> %a50
|
||||
~% %a.50 ~ ~
|
||||
|%
|
||||
:: Types
|
||||
::
|
||||
+$ ship @p
|
||||
+$ life @ud
|
||||
+$ rift @ud
|
||||
+$ pass @
|
||||
+$ bloq @
|
||||
+$ step _`@u`1
|
||||
+$ bite $@(bloq [=bloq =step])
|
||||
+$ octs [p=@ud q=@]
|
||||
+$ mold $~(* $-(* *))
|
||||
++ unit |$ [item] $@(~ [~ u=item])
|
||||
++ list |$ [item] $@(~ [i=item t=(list item)])
|
||||
++ lest |$ [item] [i=item t=(list item)]
|
||||
++ tree |$ [node] $@(~ [n=node l=(tree node) r=(tree node)])
|
||||
++ pair |$ [head tail] [p=head q=tail]
|
||||
++ map
|
||||
|$ [key value]
|
||||
$| (tree (pair key value))
|
||||
|=(a=(tree (pair)) ?:(=(~ a) & ~(apt by a)))
|
||||
::
|
||||
++ set
|
||||
|$ [item]
|
||||
$| (tree item)
|
||||
|=(a=(tree) ?:(=(~ a) & ~(apt in a)))
|
||||
::
|
||||
++ jug |$ [key value] (map key (set value))
|
||||
::
|
||||
:: Bits
|
||||
::
|
||||
++ dec :: decrement
|
||||
~/ %dec
|
||||
|= a=@
|
||||
~_ leaf+"decrement-underflow"
|
||||
?< =(0 a)
|
||||
=+ b=0
|
||||
|- ^- @
|
||||
?: =(a +(b)) b
|
||||
$(b +(b))
|
||||
::
|
||||
++ add :: plus
|
||||
~/ %add
|
||||
|= [a=@ b=@]
|
||||
^- @
|
||||
?: =(0 a) b
|
||||
$(a (dec a), b +(b))
|
||||
::
|
||||
++ sub :: subtract
|
||||
~/ %sub
|
||||
|= [a=@ b=@]
|
||||
~_ leaf+"subtract-underflow"
|
||||
:: difference
|
||||
^- @
|
||||
?: =(0 b) a
|
||||
$(a (dec a), b (dec b))
|
||||
::
|
||||
++ mul :: multiply
|
||||
~/ %mul
|
||||
|: [a=`@`1 b=`@`1]
|
||||
^- @
|
||||
=+ c=0
|
||||
|-
|
||||
?: =(0 a) c
|
||||
$(a (dec a), c (add b c))
|
||||
::
|
||||
++ div :: divide
|
||||
~/ %div
|
||||
|: [a=`@`1 b=`@`1]
|
||||
^- @
|
||||
~_ leaf+"divide-by-zero"
|
||||
?< =(0 b)
|
||||
=+ c=0
|
||||
|-
|
||||
?: (lth a b) c
|
||||
$(a (sub a b), c +(c))
|
||||
::
|
||||
++ dvr :: divide w/remainder
|
||||
~/ %dvr
|
||||
|: [a=`@`1 b=`@`1]
|
||||
^- [p=@ q=@]
|
||||
[(div a b) (mod a b)]
|
||||
::
|
||||
++ mod :: modulus
|
||||
~/ %mod
|
||||
|: [a=`@`1 b=`@`1]
|
||||
^- @
|
||||
?< =(0 b)
|
||||
(sub a (mul b (div a b)))
|
||||
::
|
||||
++ bex :: binary exponent
|
||||
~/ %bex
|
||||
|= a=bloq
|
||||
^- @
|
||||
?: =(0 a) 1
|
||||
(mul 2 $(a (dec a)))
|
||||
::
|
||||
++ lsh :: left-shift
|
||||
~/ %lsh
|
||||
|= [a=bite b=@]
|
||||
=/ [=bloq =step] ?^(a a [a *step])
|
||||
(mul b (bex (mul (bex bloq) step)))
|
||||
::
|
||||
++ rsh :: right-shift
|
||||
~/ %rsh
|
||||
|= [a=bite b=@]
|
||||
=/ [=bloq =step] ?^(a a [a *step])
|
||||
(div b (bex (mul (bex bloq) step)))
|
||||
::
|
||||
++ con :: binary or
|
||||
~/ %con
|
||||
|= [a=@ b=@]
|
||||
=+ [c=0 d=0]
|
||||
|- ^- @
|
||||
?: ?&(=(0 a) =(0 b)) d
|
||||
%= $
|
||||
a (rsh 0 a)
|
||||
b (rsh 0 b)
|
||||
c +(c)
|
||||
d %+ add d
|
||||
%+ lsh [0 c]
|
||||
?& =(0 (end 0 a))
|
||||
=(0 (end 0 b))
|
||||
==
|
||||
==
|
||||
::
|
||||
++ dis :: binary and
|
||||
~/ %dis
|
||||
|= [a=@ b=@]
|
||||
=| [c=@ d=@]
|
||||
|- ^- @
|
||||
?: ?|(=(0 a) =(0 b)) d
|
||||
%= $
|
||||
a (rsh 0 a)
|
||||
b (rsh 0 b)
|
||||
c +(c)
|
||||
d %+ add d
|
||||
%+ lsh [0 c]
|
||||
?| =(0 (end 0 a))
|
||||
=(0 (end 0 b))
|
||||
==
|
||||
==
|
||||
::
|
||||
++ mix :: binary xor
|
||||
~/ %mix
|
||||
|= [a=@ b=@]
|
||||
^- @
|
||||
=+ [c=0 d=0]
|
||||
|-
|
||||
?: ?&(=(0 a) =(0 b)) d
|
||||
%= $
|
||||
a (rsh 0 a)
|
||||
b (rsh 0 b)
|
||||
c +(c)
|
||||
d (add d (lsh [0 c] =((end 0 a) (end 0 b))))
|
||||
==
|
||||
::
|
||||
++ lth :: less
|
||||
~/ %lth
|
||||
|= [a=@ b=@]
|
||||
^- ?
|
||||
?& !=(a b)
|
||||
|-
|
||||
?| =(0 a)
|
||||
?& !=(0 b)
|
||||
$(a (dec a), b (dec b))
|
||||
== == ==
|
||||
::
|
||||
++ lte :: less or equal
|
||||
~/ %lte
|
||||
|= [a=@ b=@]
|
||||
|(=(a b) (lth a b))
|
||||
::
|
||||
++ gte :: greater or equal
|
||||
~/ %gte
|
||||
|= [a=@ b=@]
|
||||
^- ?
|
||||
!(lth a b)
|
||||
::
|
||||
++ gth :: greater
|
||||
~/ %gth
|
||||
|= [a=@ b=@]
|
||||
^- ?
|
||||
!(lte a b)
|
||||
::
|
||||
++ swp :: naive rev bloq order
|
||||
~/ %swp
|
||||
|= [a=bloq b=@]
|
||||
(rep a (flop (rip a b)))
|
||||
::
|
||||
++ met :: measure
|
||||
~/ %met
|
||||
|= [a=bloq b=@]
|
||||
^- @
|
||||
=+ c=0
|
||||
|-
|
||||
?: =(0 b) c
|
||||
$(b (rsh a b), c +(c))
|
||||
::
|
||||
++ end :: tail
|
||||
~/ %end
|
||||
|= [a=bite b=@]
|
||||
=/ [=bloq =step] ?^(a a [a *step])
|
||||
(mod b (bex (mul (bex bloq) step)))
|
||||
::
|
||||
++ cat :: concatenate
|
||||
~/ %cat
|
||||
|= [a=bloq b=@ c=@]
|
||||
(add (lsh [a (met a b)] c) b)
|
||||
::
|
||||
++ cut :: slice
|
||||
~/ %cut
|
||||
|= [a=bloq [b=step c=step] d=@]
|
||||
(end [a c] (rsh [a b] d))
|
||||
::
|
||||
++ can :: assemble
|
||||
~/ %can
|
||||
|= [a=bloq b=(list [p=step q=@])]
|
||||
^- @
|
||||
?~ b 0
|
||||
(add (end [a p.i.b] q.i.b) (lsh [a p.i.b] $(b t.b)))
|
||||
::
|
||||
++ cad :: assemble specific
|
||||
~/ %cad
|
||||
|= [a=bloq b=(list [p=step q=@])]
|
||||
^- [=step @]
|
||||
:_ (can a b)
|
||||
|-
|
||||
?~ b
|
||||
0
|
||||
(add p.i.b $(b t.b))
|
||||
::
|
||||
++ rep :: assemble fixed
|
||||
~/ %rep
|
||||
|= [a=bite b=(list @)]
|
||||
=/ [=bloq =step] ?^(a a [a *step])
|
||||
=| i=@ud
|
||||
|- ^- @
|
||||
?~ b 0
|
||||
%+ add $(i +(i), b t.b)
|
||||
(lsh [bloq (mul step i)] (end [bloq step] i.b))
|
||||
::
|
||||
++ rip :: disassemble
|
||||
~/ %rip
|
||||
|= [a=bite b=@]
|
||||
^- (list @)
|
||||
?: =(0 b) ~
|
||||
[(end a b) $(b (rsh a b))]
|
||||
::
|
||||
::
|
||||
:: Lists
|
||||
::
|
||||
++ lent :: length
|
||||
~/ %lent
|
||||
|= a=(list)
|
||||
^- @
|
||||
=+ b=0
|
||||
|-
|
||||
?~ a b
|
||||
$(a t.a, b +(b))
|
||||
::
|
||||
++ slag :: suffix
|
||||
~/ %slag
|
||||
|* [a=@ b=(list)]
|
||||
|- ^+ b
|
||||
?: =(0 a) b
|
||||
?~ b ~
|
||||
$(b t.b, a (dec a))
|
||||
::
|
||||
++ snag :: index
|
||||
~/ %snag
|
||||
|* [a=@ b=(list)]
|
||||
|- ^+ ?>(?=(^ b) i.b)
|
||||
?~ b
|
||||
~_ leaf+"snag-fail"
|
||||
!!
|
||||
?: =(0 a) i.b
|
||||
$(b t.b, a (dec a))
|
||||
::
|
||||
++ homo :: homogenize
|
||||
|* a=(list)
|
||||
^+ =< $
|
||||
|@ ++ $ ?:(*? ~ [i=(snag 0 a) t=$])
|
||||
--
|
||||
a
|
||||
::
|
||||
++ flop :: reverse
|
||||
~/ %flop
|
||||
|* a=(list)
|
||||
=> .(a (homo a))
|
||||
^+ a
|
||||
=+ b=`_a`~
|
||||
|-
|
||||
?~ a b
|
||||
$(a t.a, b [i.a b])
|
||||
::
|
||||
++ welp :: concatenate
|
||||
~/ %welp
|
||||
=| [* *]
|
||||
|@
|
||||
++ $
|
||||
?~ +<-
|
||||
+<-(. +<+)
|
||||
+<-(+ $(+<- +<->))
|
||||
--
|
||||
::
|
||||
++ reap :: replicate
|
||||
~/ %reap
|
||||
|* [a=@ b=*]
|
||||
|- ^- (list _b)
|
||||
?~ a ~
|
||||
[b $(a (dec a))]
|
||||
::
|
||||
:: Modular arithmetic
|
||||
::
|
||||
++ fe :: modulo bloq
|
||||
|_ a=bloq
|
||||
++ rol |= [b=bloq c=@ d=@] ^- @ :: roll left
|
||||
=+ e=(sit d)
|
||||
=+ f=(bex (sub a b))
|
||||
=+ g=(mod c f)
|
||||
(sit (con (lsh [b g] e) (rsh [b (sub f g)] e)))
|
||||
++ sum |=([b=@ c=@] (sit (add b c))) :: wrapping add
|
||||
++ sit |=(b=@ (end a b)) :: enforce modulo
|
||||
--
|
||||
::
|
||||
:: Hashes
|
||||
::
|
||||
++ muk :: standard murmur3
|
||||
~% %muk ..muk ~
|
||||
=+ ~(. fe 5)
|
||||
|= [syd=@ len=@ key=@]
|
||||
=. syd (end 5 syd)
|
||||
=/ pad (sub len (met 3 key))
|
||||
=/ data (welp (rip 3 key) (reap pad 0))
|
||||
=/ nblocks (div len 4) :: intentionally off-by-one
|
||||
=/ h1 syd
|
||||
=+ [c1=0xcc9e.2d51 c2=0x1b87.3593]
|
||||
=/ blocks (rip 5 key)
|
||||
=/ i nblocks
|
||||
=. h1 =/ hi h1 |-
|
||||
?: =(0 i) hi
|
||||
=/ k1 (snag (sub nblocks i) blocks) :: negative array index
|
||||
=. k1 (sit (mul k1 c1))
|
||||
=. k1 (rol 0 15 k1)
|
||||
=. k1 (sit (mul k1 c2))
|
||||
=. hi (mix hi k1)
|
||||
=. hi (rol 0 13 hi)
|
||||
=. hi (sum (sit (mul hi 5)) 0xe654.6b64)
|
||||
$(i (dec i))
|
||||
=/ tail (slag (mul 4 nblocks) data)
|
||||
=/ k1 0
|
||||
=/ tlen (dis len 3)
|
||||
=. h1
|
||||
?+ tlen h1 :: fallthrough switch
|
||||
%3 =. k1 (mix k1 (lsh [0 16] (snag 2 tail)))
|
||||
=. k1 (mix k1 (lsh [0 8] (snag 1 tail)))
|
||||
=. k1 (mix k1 (snag 0 tail))
|
||||
=. k1 (sit (mul k1 c1))
|
||||
=. k1 (rol 0 15 k1)
|
||||
=. k1 (sit (mul k1 c2))
|
||||
(mix h1 k1)
|
||||
%2 =. k1 (mix k1 (lsh [0 8] (snag 1 tail)))
|
||||
=. k1 (mix k1 (snag 0 tail))
|
||||
=. k1 (sit (mul k1 c1))
|
||||
=. k1 (rol 0 15 k1)
|
||||
=. k1 (sit (mul k1 c2))
|
||||
(mix h1 k1)
|
||||
%1 =. k1 (mix k1 (snag 0 tail))
|
||||
=. k1 (sit (mul k1 c1))
|
||||
=. k1 (rol 0 15 k1)
|
||||
=. k1 (sit (mul k1 c2))
|
||||
(mix h1 k1)
|
||||
==
|
||||
=. h1 (mix h1 len)
|
||||
|^ (fmix32 h1)
|
||||
++ fmix32
|
||||
|= h=@
|
||||
=. h (mix h (rsh [0 16] h))
|
||||
=. h (sit (mul h 0x85eb.ca6b))
|
||||
=. h (mix h (rsh [0 13] h))
|
||||
=. h (sit (mul h 0xc2b2.ae35))
|
||||
=. h (mix h (rsh [0 16] h))
|
||||
h
|
||||
--
|
||||
::
|
||||
++ mug :: mug with murmur3
|
||||
~/ %mug
|
||||
|= a=*
|
||||
|^ ?@ a (mum 0xcafe.babe 0x7fff a)
|
||||
=/ b (cat 5 $(a -.a) $(a +.a))
|
||||
(mum 0xdead.beef 0xfffe b)
|
||||
::
|
||||
++ mum
|
||||
|= [syd=@uxF fal=@F key=@]
|
||||
=/ wyd (met 3 key)
|
||||
=| i=@ud
|
||||
|- ^- @F
|
||||
?: =(8 i) fal
|
||||
=/ haz=@F (muk syd wyd key)
|
||||
=/ ham=@F (mix (rsh [0 31] haz) (end [0 31] haz))
|
||||
?.(=(0 ham) ham $(i +(i), syd +(syd)))
|
||||
--
|
||||
::
|
||||
++ gor :: mug order
|
||||
~/ %gor
|
||||
|= [a=* b=*]
|
||||
^- ?
|
||||
=+ [c=(mug a) d=(mug b)]
|
||||
?: =(c d)
|
||||
(dor a b)
|
||||
(lth c d)
|
||||
::
|
||||
++ mor :: more mug order
|
||||
~/ %mor
|
||||
|= [a=* b=*]
|
||||
^- ?
|
||||
=+ [c=(mug (mug a)) d=(mug (mug b))]
|
||||
?: =(c d)
|
||||
(dor a b)
|
||||
(lth c d)
|
||||
::
|
||||
++ dor :: tree order
|
||||
~/ %dor
|
||||
|= [a=* b=*]
|
||||
^- ?
|
||||
?: =(a b) &
|
||||
?. ?=(@ a)
|
||||
?: ?=(@ b) |
|
||||
?: =(-.a -.b)
|
||||
$(a +.a, b +.b)
|
||||
$(a -.a, b -.b)
|
||||
?. ?=(@ b) &
|
||||
(lth a b)
|
||||
::
|
||||
++ por :: parent order
|
||||
~/ %por
|
||||
|= [a=@p b=@p]
|
||||
^- ?
|
||||
?: =(a b) &
|
||||
=| i=@
|
||||
|-
|
||||
?: =(i 2)
|
||||
:: second two bytes
|
||||
(lte a b)
|
||||
:: first two bytes
|
||||
=+ [c=(end 3 a) d=(end 3 b)]
|
||||
?: =(c d)
|
||||
$(a (rsh 3 a), b (rsh 3 b), i +(i))
|
||||
(lth c d)
|
||||
::
|
||||
:: Maps
|
||||
::
|
||||
++ by
|
||||
~/ %by
|
||||
=| a=(tree (pair)) :: (map)
|
||||
=* node ?>(?=(^ a) n.a)
|
||||
|@
|
||||
++ get
|
||||
~/ %get
|
||||
|* b=*
|
||||
=> .(b `_?>(?=(^ a) p.n.a)`b)
|
||||
|- ^- (unit _?>(?=(^ a) q.n.a))
|
||||
?~ a
|
||||
~
|
||||
?: =(b p.n.a)
|
||||
`q.n.a
|
||||
?: (gor b p.n.a)
|
||||
$(a l.a)
|
||||
$(a r.a)
|
||||
::
|
||||
++ put
|
||||
~/ %put
|
||||
|* [b=* c=*]
|
||||
|- ^+ a
|
||||
?~ a
|
||||
[[b c] ~ ~]
|
||||
?: =(b p.n.a)
|
||||
?: =(c q.n.a)
|
||||
a
|
||||
a(n [b c])
|
||||
?: (gor b p.n.a)
|
||||
=+ d=$(a l.a)
|
||||
?> ?=(^ d)
|
||||
?: (mor p.n.a p.n.d)
|
||||
a(l d)
|
||||
d(r a(l r.d))
|
||||
=+ d=$(a r.a)
|
||||
?> ?=(^ d)
|
||||
?: (mor p.n.a p.n.d)
|
||||
a(r d)
|
||||
d(l a(r l.d))
|
||||
::
|
||||
++ del
|
||||
~/ %del
|
||||
|* b=*
|
||||
|- ^+ a
|
||||
?~ a
|
||||
~
|
||||
?. =(b p.n.a)
|
||||
?: (gor b p.n.a)
|
||||
a(l $(a l.a))
|
||||
a(r $(a r.a))
|
||||
|- ^- [$?(~ _a)]
|
||||
?~ l.a r.a
|
||||
?~ r.a l.a
|
||||
?: (mor p.n.l.a p.n.r.a)
|
||||
l.a(r $(l.a r.l.a))
|
||||
r.a(l $(r.a l.r.a))
|
||||
::
|
||||
++ apt
|
||||
=< $
|
||||
~/ %apt
|
||||
=| [l=(unit) r=(unit)]
|
||||
|. ^- ?
|
||||
?~ a &
|
||||
?& ?~(l & &((gor p.n.a u.l) !=(p.n.a u.l)))
|
||||
?~(r & &((gor u.r p.n.a) !=(u.r p.n.a)))
|
||||
?~ l.a &
|
||||
&((mor p.n.a p.n.l.a) !=(p.n.a p.n.l.a) $(a l.a, l `p.n.a))
|
||||
?~ r.a &
|
||||
&((mor p.n.a p.n.r.a) !=(p.n.a p.n.r.a) $(a r.a, r `p.n.a))
|
||||
==
|
||||
--
|
||||
::
|
||||
++ on :: ordered map
|
||||
~/ %on
|
||||
|* [key=mold val=mold]
|
||||
=> |%
|
||||
+$ item [key=key val=val]
|
||||
--
|
||||
::
|
||||
~% %comp +>+ ~
|
||||
|= compare=$-([key key] ?)
|
||||
~% %core + ~
|
||||
|%
|
||||
::
|
||||
++ apt
|
||||
~/ %apt
|
||||
|= a=(tree item)
|
||||
=| [l=(unit key) r=(unit key)]
|
||||
|- ^- ?
|
||||
?~ a %.y
|
||||
?& ?~(l %.y (compare key.n.a u.l))
|
||||
?~(r %.y (compare u.r key.n.a))
|
||||
?~(l.a %.y &((mor key.n.a key.n.l.a) $(a l.a, l `key.n.a)))
|
||||
?~(r.a %.y &((mor key.n.a key.n.r.a) $(a r.a, r `key.n.a)))
|
||||
==
|
||||
::
|
||||
++ get
|
||||
~/ %get
|
||||
|= [a=(tree item) b=key]
|
||||
^- (unit val)
|
||||
?~ a ~
|
||||
?: =(b key.n.a)
|
||||
`val.n.a
|
||||
?: (compare b key.n.a)
|
||||
$(a l.a)
|
||||
$(a r.a)
|
||||
::
|
||||
++ has
|
||||
~/ %has
|
||||
|= [a=(tree item) b=key]
|
||||
^- ?
|
||||
!=(~ (get a b))
|
||||
::
|
||||
++ put
|
||||
~/ %put
|
||||
|= [a=(tree item) =key =val]
|
||||
^- (tree item)
|
||||
?~ a [n=[key val] l=~ r=~]
|
||||
?: =(key.n.a key) a(val.n val)
|
||||
?: (compare key key.n.a)
|
||||
=/ l $(a l.a)
|
||||
?> ?=(^ l)
|
||||
?: (mor key.n.a key.n.l)
|
||||
a(l l)
|
||||
l(r a(l r.l))
|
||||
=/ r $(a r.a)
|
||||
?> ?=(^ r)
|
||||
?: (mor key.n.a key.n.r)
|
||||
a(r r)
|
||||
r(l a(r l.r))
|
||||
--
|
||||
::
|
||||
:: Sets
|
||||
::
|
||||
++ in
|
||||
~/ %in
|
||||
=| a=(tree) :: (set)
|
||||
|@
|
||||
++ put
|
||||
~/ %put
|
||||
|* b=*
|
||||
|- ^+ a
|
||||
?~ a
|
||||
[b ~ ~]
|
||||
?: =(b n.a)
|
||||
a
|
||||
?: (gor b n.a)
|
||||
=+ c=$(a l.a)
|
||||
?> ?=(^ c)
|
||||
?: (mor n.a n.c)
|
||||
a(l c)
|
||||
c(r a(l r.c))
|
||||
=+ c=$(a r.a)
|
||||
?> ?=(^ c)
|
||||
?: (mor n.a n.c)
|
||||
a(r c)
|
||||
c(l a(r l.c))
|
||||
::
|
||||
++ del
|
||||
~/ %del
|
||||
|* b=*
|
||||
|- ^+ a
|
||||
?~ a
|
||||
~
|
||||
?. =(b n.a)
|
||||
?: (gor b n.a)
|
||||
a(l $(a l.a))
|
||||
a(r $(a r.a))
|
||||
|- ^- [$?(~ _a)]
|
||||
?~ l.a r.a
|
||||
?~ r.a l.a
|
||||
?: (mor n.l.a n.r.a)
|
||||
l.a(r $(l.a r.l.a))
|
||||
r.a(l $(r.a l.r.a))
|
||||
::
|
||||
++ apt
|
||||
=< $
|
||||
~/ %apt
|
||||
=| [l=(unit) r=(unit)]
|
||||
|. ^- ?
|
||||
?~ 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)))
|
||||
==
|
||||
--
|
||||
::
|
||||
:: Jugs
|
||||
::
|
||||
++ ju
|
||||
=| a=(tree (pair * (tree))) :: (jug)
|
||||
|@
|
||||
++ get
|
||||
|* b=*
|
||||
=+ c=(~(get by a) b)
|
||||
?~(c ~ u.c)
|
||||
::
|
||||
++ del
|
||||
|* [b=* c=*]
|
||||
^+ a
|
||||
=+ d=(get b)
|
||||
=+ e=(~(del in d) c)
|
||||
?~ e
|
||||
(~(del by a) b)
|
||||
(~(put by a) b e)
|
||||
::
|
||||
++ put
|
||||
|* [b=* c=*]
|
||||
^+ a
|
||||
=+ d=(get b)
|
||||
(~(put by a) b (~(put in d) c))
|
||||
--
|
||||
--
|
@ -44,23 +44,10 @@
|
||||
:: |give:dawn: produce requests for pre-boot validation
|
||||
::
|
||||
++ give
|
||||
=, rpc:ethereum
|
||||
=, abi:ethereum
|
||||
=/ tract azimuth:contracts:azimuth
|
||||
|%
|
||||
:: +bloq:give:dawn: Eth RPC for latest block number
|
||||
::
|
||||
++ bloq
|
||||
^- octs
|
||||
%- as-octt:mimes:html
|
||||
%- en-json:html
|
||||
%+ request-to-json
|
||||
`~.0
|
||||
[%eth-block-number ~]
|
||||
:: +czar:give:dawn: Eth RPC for galaxy table
|
||||
::
|
||||
++ czar
|
||||
|= boq=@ud
|
||||
^- octs
|
||||
%- as-octt:mimes:html
|
||||
%- en-json:html
|
||||
@ -68,40 +55,43 @@
|
||||
%+ turn (gulf 0 255)
|
||||
|= gal=@
|
||||
%+ request-to-json
|
||||
`(cat 3 'gal-' (scot %ud gal))
|
||||
:+ %eth-call
|
||||
=- [from=~ to=tract gas=~ price=~ value=~ data=-]
|
||||
(encode-call 'points(uint32)' [%uint gal]~)
|
||||
[%number boq]
|
||||
(cat 3 'gal-' (scot %ud gal))
|
||||
:- 'getPoint'
|
||||
(~(put by *(map @t json)) 'ship' s+(scot %p gal))
|
||||
:: +point:give:dawn: Eth RPC for ship's contract state
|
||||
::
|
||||
++ point
|
||||
|= [boq=@ud who=ship]
|
||||
|= who=ship
|
||||
^- octs
|
||||
%- as-octt:mimes:html
|
||||
%- en-json:html
|
||||
%+ request-to-json
|
||||
`~.0
|
||||
:+ %eth-call
|
||||
=- [from=~ to=tract gas=~ price=~ value=~ data=-]
|
||||
(encode-call 'points(uint32)' [%uint `@`who]~)
|
||||
[%number boq]
|
||||
~.
|
||||
:- 'getPoint'
|
||||
(~(put by *(map @t json)) 'ship' s+(scot %p who))
|
||||
:: +turf:give:dawn: Eth RPC for network domains
|
||||
::
|
||||
++ turf
|
||||
|= boq=@ud
|
||||
^- octs
|
||||
%- as-octt:mimes:html
|
||||
%- en-json:html
|
||||
:- %a
|
||||
%+ turn (gulf 0 2)
|
||||
|= idx=@
|
||||
%+ request-to-json
|
||||
`(cat 3 'turf-' (scot %ud idx))
|
||||
:+ %eth-call
|
||||
=- [from=~ to=tract gas=~ price=~ value=~ data=-]
|
||||
(encode-call 'dnsDomains(uint256)' [%uint idx]~)
|
||||
[%number boq]
|
||||
'turf'
|
||||
['getDns' ~]
|
||||
:: +request-to-json:give:dawn: internally used for request generation
|
||||
::
|
||||
::NOTE we could import this from /lib/json/rpc, but adding that as a
|
||||
:: dependency seems a bit unclean
|
||||
::
|
||||
++ request-to-json
|
||||
|= [id=@t method=@t params=(map @t json)]
|
||||
^- json
|
||||
%- pairs:enjs:format
|
||||
:~ jsonrpc+s+'2.0'
|
||||
id+s+id
|
||||
method+s+method
|
||||
params+o+params
|
||||
==
|
||||
--
|
||||
:: |take:dawn: parse responses for pre-boot validation
|
||||
::
|
||||
@ -111,23 +101,6 @@
|
||||
=, azimuth
|
||||
=, dejs-soft:format
|
||||
|%
|
||||
:: +bloq:take:dawn: parse block number
|
||||
::
|
||||
++ bloq
|
||||
|= rep=octs
|
||||
^- (unit @ud)
|
||||
=/ jon=(unit json) (de-json:html q.rep)
|
||||
?~ jon
|
||||
~&([%bloq-take-dawn %invalid-json] ~)
|
||||
=/ res=(unit cord) ((ot result+so ~) u.jon)
|
||||
?~ res
|
||||
~&([%bloq-take-dawn %invalid-response rep] ~)
|
||||
=/ out
|
||||
%- mule |.
|
||||
(hex-to-num:ethereum u.res)
|
||||
?: ?=(%& -.out)
|
||||
(some p.out)
|
||||
~&([%bloq-take-dawn %invalid-block-number] ~)
|
||||
:: +czar:take:dawn: parse galaxy table
|
||||
::
|
||||
++ czar
|
||||
@ -136,58 +109,94 @@
|
||||
=/ jon=(unit json) (de-json:html q.rep)
|
||||
?~ jon
|
||||
~&([%czar-take-dawn %invalid-json] ~)
|
||||
=/ res=(unit (list [@t @t]))
|
||||
((ar (ot id+so result+so ~)) u.jon)
|
||||
=/ res=(unit (list [@t @ud @ud @]))
|
||||
%. u.jon
|
||||
=, dejs-soft:format
|
||||
=- (ar (ot id+so result+(ot network+- ~) ~))
|
||||
%- ot
|
||||
:~ :- 'rift' (su dim:ag)
|
||||
:- 'keys' (ot 'life'^(su dim:ag) ~)
|
||||
:- 'keys' %+ cu pass-from-eth:azimuth
|
||||
%- ot
|
||||
:~ 'crypt'^(cu (lead 32) (su ;~(pfix (jest '0x') hex)))
|
||||
'auth'^(cu (lead 32) (su ;~(pfix (jest '0x') hex)))
|
||||
'suite'^(su dim:ag)
|
||||
==
|
||||
==
|
||||
?~ res
|
||||
~&([%czar-take-dawn %invalid-response rep] ~)
|
||||
=/ dat=(unit (list [who=@p point:azimuth-types]))
|
||||
=- ?:(?=(%| -.out) ~ (some p.out))
|
||||
^= out %- mule |.
|
||||
%+ turn u.res
|
||||
|= [id=@t result=@t]
|
||||
^- [who=ship point:azimuth-types]
|
||||
=/ who `@p`(slav %ud (rsh [3 4] id))
|
||||
:- who
|
||||
%+ point-from-eth
|
||||
who
|
||||
:_ *deed:eth-noun
|
||||
%+ decode-results
|
||||
result
|
||||
point:eth-type
|
||||
?~ dat
|
||||
~&([%bloq-take-dawn %invalid-galaxy-table] ~)
|
||||
~&([%czar-take-dawn %incomplete-json] ~)
|
||||
:- ~
|
||||
%+ roll u.dat
|
||||
|= $: [who=ship =point:azimuth-types]
|
||||
%+ roll u.res
|
||||
|= $: [id=@t deet=[=rift =life =pass]]
|
||||
kyz=(map ship [=rift =life =pass])
|
||||
==
|
||||
^+ kyz
|
||||
?~ net.point
|
||||
?: =(0 life.deet)
|
||||
kyz
|
||||
(~(put by kyz) who [continuity-number life pass]:u.net.point)
|
||||
%+ ~(put by kyz)
|
||||
(slav %ud (rsh [3 4] id))
|
||||
deet
|
||||
:: +point:take:dawn: parse ship's contract state
|
||||
::
|
||||
++ point
|
||||
|= [who=ship rep=octs]
|
||||
^- (unit point:azimuth)
|
||||
~! *point:azimuth
|
||||
=/ jon=(unit json) (de-json:html q.rep)
|
||||
?~ jon
|
||||
~&([%point-take-dawn %invalid-json] ~)
|
||||
=/ res=(unit cord) ((ot result+so ~) u.jon)
|
||||
?~ res
|
||||
~&([%point-take-dawn %invalid-response rep] ~)
|
||||
~? =(u.res '0x')
|
||||
:- 'bad result from node; is azimuth address correct?'
|
||||
azimuth:contracts
|
||||
=/ out
|
||||
%- mule |.
|
||||
%+ point-from-eth
|
||||
who
|
||||
:_ *deed:eth-noun ::TODO call rights to fill
|
||||
(decode-results u.res point:eth-type)
|
||||
?: ?=(%& -.out)
|
||||
(some p.out)
|
||||
~&([%point-take-dawn %invalid-point] ~)
|
||||
=- ?~ res
|
||||
~&([%point-take-dawn %incomplete-json] ~)
|
||||
=, u.res
|
||||
%- some
|
||||
:+ own
|
||||
?: =(0 life) ~
|
||||
`[life pass rift sponsor ~] ::NOTE escape unknown ::TODO could be!
|
||||
?. (gth who 0xffff) ~
|
||||
`[spawn ~] ::NOTE spawned unknown
|
||||
^- $= res
|
||||
%- unit
|
||||
$: [spawn=@ own=[@ @ @ @]]
|
||||
[=rift =life =pass sponsor=[? ship]]
|
||||
==
|
||||
%. u.jon
|
||||
=, dejs-soft:format
|
||||
=- (ot result+- ~)
|
||||
%- ot
|
||||
:~ :- 'ownership'
|
||||
%- ot
|
||||
|^ :~ 'spawnProxy'^address
|
||||
'owner'^address
|
||||
'managementProxy'^address
|
||||
'votingProxy'^address
|
||||
'transferProxy'^address
|
||||
==
|
||||
::
|
||||
++ address
|
||||
(ot 'address'^(cu hex-to-num:ethereum so) ~)
|
||||
--
|
||||
::
|
||||
:- 'network'
|
||||
%- ot
|
||||
::TODO dedupe with +czar
|
||||
:~ 'rift'^(su dim:ag)
|
||||
'keys'^(ot 'life'^(su dim:ag) ~)
|
||||
::
|
||||
:- 'keys'
|
||||
%+ cu pass-from-eth:azimuth
|
||||
%- ot
|
||||
:~ 'crypt'^(cu (lead 32) (su ;~(pfix (jest '0x') hex)))
|
||||
'auth'^(cu (lead 32) (su ;~(pfix (jest '0x') hex)))
|
||||
'suite'^(su dim:ag)
|
||||
==
|
||||
::
|
||||
::TODO inconsistent @p string
|
||||
'sponsor'^(ot 'has'^bo 'who'^ni ~)
|
||||
::
|
||||
::TODO escape
|
||||
::TODO what if escape or sponsor not present? possible?
|
||||
==
|
||||
==
|
||||
:: +turf:take:dawn: parse network domains
|
||||
::
|
||||
++ turf
|
||||
@ -196,38 +205,21 @@
|
||||
=/ jon=(unit json) (de-json:html q.rep)
|
||||
?~ jon
|
||||
~&([%turf-take-dawn %invalid-json] ~)
|
||||
=/ res=(unit (list [@t @t]))
|
||||
((ar (ot id+so result+so ~)) u.jon)
|
||||
=/ res=(unit (list @t))
|
||||
((ot result+(ar so) ~) u.jon)
|
||||
?~ res
|
||||
~&([%turf-take-dawn %invalid-response rep] ~)
|
||||
=/ dat=(unit (list (pair @ud ^turf)))
|
||||
=- ?:(?=(%| -.out) ~ (some p.out))
|
||||
^= out %- mule |.
|
||||
%+ turn u.res
|
||||
|= [id=@t result=@t]
|
||||
^- (pair @ud ^turf)
|
||||
:- (slav %ud (rsh [3 5] id))
|
||||
=/ dom=tape
|
||||
(decode-results result [%string]~)
|
||||
=/ hot=host:eyre
|
||||
(scan dom thos:de-purl:html)
|
||||
?>(?=(%& -.hot) p.hot)
|
||||
?~ dat
|
||||
~&([%turf-take-dawn %invalid-domains] ~)
|
||||
:- ~
|
||||
=* dom u.dat
|
||||
:: sort by id, ascending, removing duplicates
|
||||
~&([%turf-take-dawn %invalid-response] ~)
|
||||
:: remove duplicates, parse into turfs
|
||||
::
|
||||
=| tuf=(map ^turf @ud)
|
||||
|- ^- (list ^turf)
|
||||
?~ dom
|
||||
%+ turn
|
||||
%+ sort ~(tap by tuf)
|
||||
|=([a=(pair ^turf @ud) b=(pair ^turf @ud)] (lth q.a q.b))
|
||||
head
|
||||
=? tuf !(~(has by tuf) q.i.dom)
|
||||
(~(put by tuf) q.i.dom p.i.dom)
|
||||
$(dom t.dom)
|
||||
=- `doz
|
||||
%+ roll u.res
|
||||
|= [dom=@t doh=(set @t) doz=(list ^turf)]
|
||||
?: (~(has in doh) dom) [doh doz]
|
||||
:- (~(put in doh) dom)
|
||||
=/ hot=host:eyre
|
||||
(rash dom thos:de-purl:html)
|
||||
?. ?=(%& -.hot) doz
|
||||
(snoc doz p.hot)
|
||||
--
|
||||
:: +veri:dawn: validate keys, life, discontinuity, &c
|
||||
::
|
||||
|
@ -1,18 +0,0 @@
|
||||
::
|
||||
:::: /hoon/atom/mar
|
||||
::
|
||||
/? 310
|
||||
::
|
||||
:::: A minimal atom mark
|
||||
::
|
||||
=, mimes:html
|
||||
|_ ato=@
|
||||
++ grab |%
|
||||
++ noun @
|
||||
++ mime |=([* p=octs] q.p)
|
||||
--
|
||||
++ grow |%
|
||||
++ mime [/application/x-urb-unknown (as-octs ato)]
|
||||
--
|
||||
++ grad %mime
|
||||
--
|
1
pkg/arvo/mar/atom.hoon
Symbolic link
1
pkg/arvo/mar/atom.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/mar/atom.hoon
|
20
pkg/arvo/mar/azimuth/snapshot.hoon
Normal file
20
pkg/arvo/mar/azimuth/snapshot.hoon
Normal file
@ -0,0 +1,20 @@
|
||||
:: /app/azimuth state snapshot
|
||||
::
|
||||
/- *dice
|
||||
::
|
||||
|_ snap=snap-state
|
||||
++ grab
|
||||
|%
|
||||
++ noun snap-state
|
||||
++ mime
|
||||
|= [mite =octs]
|
||||
(noun (cue q.octs))
|
||||
--
|
||||
::
|
||||
++ grow
|
||||
|%
|
||||
++ mime
|
||||
[/application/octet-stream (as-octs:mimes:html (jam snap))]
|
||||
--
|
||||
++ grad %mime
|
||||
--
|
@ -1,15 +0,0 @@
|
||||
=, format
|
||||
=, mimes:html
|
||||
|_ csv=wain
|
||||
::
|
||||
++ grab :: convert from
|
||||
|%
|
||||
++ mime |=((pair mite octs) (to-wain q.q))
|
||||
++ noun wain :: clam from %noun
|
||||
--
|
||||
++ grow
|
||||
|%
|
||||
++ mime [/text/csv (as-octs (of-wain csv))]
|
||||
--
|
||||
++ grad %mime
|
||||
--
|
20
pkg/arvo/mar/eth/logs.hoon
Normal file
20
pkg/arvo/mar/eth/logs.hoon
Normal file
@ -0,0 +1,20 @@
|
||||
:: list of ethereum logs
|
||||
::
|
||||
/+ ethereum
|
||||
::
|
||||
|_ logs=(list event-log:rpc:ethereum)
|
||||
++ grab
|
||||
|%
|
||||
++ noun (list event-log:rpc:ethereum)
|
||||
++ mime
|
||||
|= [mite =octs]
|
||||
(noun (cue q.octs))
|
||||
--
|
||||
::
|
||||
++ grow
|
||||
|%
|
||||
++ mime
|
||||
[/application/x-ethereum-logs (as-octs:mimes:html (jam logs))]
|
||||
--
|
||||
++ grad %mime
|
||||
--
|
@ -1,5 +1,5 @@
|
||||
|%
|
||||
+$ bump [%kiln-bump except=(set desk) force=_|]
|
||||
+$ bump [except=(set desk) force=_|]
|
||||
--
|
||||
|_ b=bump
|
||||
++ grad %noun
|
||||
@ -9,7 +9,6 @@
|
||||
++ json
|
||||
^- $-(^json bump)
|
||||
=, dejs:format
|
||||
%+ pe %kiln-bump
|
||||
%- ot
|
||||
:~ except+(as so)
|
||||
force+bo
|
||||
|
@ -66,8 +66,14 @@
|
||||
[%adopt who=ship]
|
||||
[%start-document-poll gal=ship hash=@]
|
||||
[%cast-document-vote gal=ship hash=@ vote=?]
|
||||
[%start-upgrade-poll gal=ship =address]
|
||||
[%cast-upgrade-vote gal=ship =address vote=?]
|
||||
::
|
||||
[%send-point as=ship point=ship to=address]
|
||||
::
|
||||
[%approve-batch-transfer to=address]
|
||||
[%transfer-batch from=address]
|
||||
[%withdraw to=address]
|
||||
==
|
||||
::
|
||||
++ prep-result
|
||||
|
@ -1,9 +0,0 @@
|
||||
/- resource
|
||||
::
|
||||
|%
|
||||
+$ channel-info
|
||||
$: group=resource:resource
|
||||
channel=resource:resource
|
||||
channel-type=term
|
||||
==
|
||||
--
|
110
pkg/arvo/sur/dice.hoon
Normal file
110
pkg/arvo/sur/dice.hoon
Normal file
@ -0,0 +1,110 @@
|
||||
:: dice: structures for Azimuth L2 rollers
|
||||
::
|
||||
/+ naive, ethereum
|
||||
::
|
||||
|%
|
||||
+$ owner [=proxy:naive =address:naive]
|
||||
+$ owners (jug owner ship)
|
||||
+$ sponsors (map ship [residents=(set ship) requests=(set ship)])
|
||||
+$ history (map address:ethereum (tree hist-tx))
|
||||
+$ net ?(%mainnet %ropsten %local %default)
|
||||
+$ snap-state [%0 =id:block:jael nas=^state:naive =owners =sponsors]
|
||||
::
|
||||
+$ config
|
||||
$% [%frequency frequency=@dr]
|
||||
[%fallback gas=@ud]
|
||||
[%setkey pk=@]
|
||||
[%endpoint endpoint=@t =net]
|
||||
[%resend-time time=@dr]
|
||||
[%update-rate rate=@dr]
|
||||
[%slice slice=@dr]
|
||||
[%quota quota=@ud]
|
||||
==
|
||||
::
|
||||
+$ indices
|
||||
$: own=owners
|
||||
spo=sponsors
|
||||
==
|
||||
::
|
||||
+$ azimuth-config
|
||||
$: refresh-rate=@dr
|
||||
==
|
||||
::
|
||||
+$ roller-config
|
||||
$: next-batch=time
|
||||
frequency=@dr
|
||||
resend-time=@dr
|
||||
update-rate=@dr
|
||||
contract=@ux
|
||||
chain-id=@
|
||||
slice=@dr
|
||||
quota=@ud
|
||||
==
|
||||
::
|
||||
+$ keccak @ux
|
||||
::
|
||||
+$ status
|
||||
?(%unknown %pending %sending %confirmed %failed %cancelled)
|
||||
::
|
||||
+$ tx-status
|
||||
$: =status
|
||||
pointer=(unit l1-tx-pointer)
|
||||
==
|
||||
::
|
||||
+$ l1-tx-pointer
|
||||
$: =address:ethereum
|
||||
nonce=@ud
|
||||
==
|
||||
::
|
||||
+$ l2-tx
|
||||
$? %transfer-point
|
||||
%spawn
|
||||
%configure-keys
|
||||
%escape
|
||||
%cancel-escape
|
||||
%adopt
|
||||
%reject
|
||||
%detach
|
||||
%set-management-proxy
|
||||
%set-spawn-proxy
|
||||
%set-transfer-proxy
|
||||
==
|
||||
::
|
||||
+$ update
|
||||
$% [%tx =pend-tx =status]
|
||||
::
|
||||
$: %point
|
||||
=diff:naive
|
||||
=ship
|
||||
new=point:naive
|
||||
old=(unit point:naive)
|
||||
to=owner
|
||||
from=(unit owner)
|
||||
== ==
|
||||
::
|
||||
+$ hist-tx [p=time q=roll-tx]
|
||||
+$ roll-tx [=ship =status hash=keccak type=l2-tx]
|
||||
+$ pend-tx [force=? =address:naive =time =raw-tx:naive]
|
||||
+$ send-tx [next-gas-price=@ud sent=? txs=(list raw-tx:naive)]
|
||||
+$ part-tx
|
||||
$% [%raw raw=octs]
|
||||
[%don =tx:naive]
|
||||
[%ful raw=octs =tx:naive] ::TODO redundant?
|
||||
==
|
||||
::
|
||||
+$ rpc-send-roll
|
||||
$: endpoint=@t
|
||||
contract=address:ethereum
|
||||
chain-id=@
|
||||
pk=@
|
||||
::
|
||||
nonce=@ud
|
||||
fallback-gas-price=@ud
|
||||
next-gas-price=@ud
|
||||
txs=(list raw-tx:naive)
|
||||
==
|
||||
::
|
||||
+$ roller-data
|
||||
[chain-id=@ =points:naive history=(tree hist-tx) =owners =sponsors]
|
||||
::
|
||||
--
|
@ -18,6 +18,7 @@
|
||||
timeout-time=@dr
|
||||
from=number:block
|
||||
contracts=(list address:ethereum)
|
||||
batchers=(list address:ethereum)
|
||||
=topics
|
||||
==
|
||||
::
|
||||
|
@ -1 +1 @@
|
||||
[%zuse 420]
|
||||
[%zuse 419]
|
||||
|
@ -48,7 +48,7 @@
|
||||
+$ dock (pair @p term)
|
||||
+$ gang (unit (set ship))
|
||||
+$ mark @tas
|
||||
+$ mein [our=ship now=@da eny=@uvJ]
|
||||
+$ mien [our=ship now=@da eny=@uvJ]
|
||||
++ omen |$ [a] (pair path (cask a))
|
||||
+$ ship @p
|
||||
+$ sink (trel bone ship path)
|
||||
@ -214,7 +214,7 @@
|
||||
:: zen: Outside knowledge
|
||||
:: mod: internal modules
|
||||
::
|
||||
mein
|
||||
mien
|
||||
$= fad
|
||||
$: :: lac: not verbose
|
||||
::
|
||||
@ -1294,31 +1294,30 @@
|
||||
^- mass
|
||||
=; sam=(list mass)
|
||||
:+ %arvo %|
|
||||
:~ hoon+&+pit
|
||||
zuse+&+zus.mod
|
||||
:~ :+ %hoon %|
|
||||
:~ one+&+..bloq
|
||||
two+&+..turn
|
||||
tri+&+..year
|
||||
qua+&+..sane
|
||||
pen+&+..ride
|
||||
==
|
||||
hex+&+..part
|
||||
pit+&+pit
|
||||
lull+|+[dot+&+q typ+&+p ~]:lul.mod
|
||||
zuse+|+[dot+&+q typ+&+p ~]:zus.mod
|
||||
vane+|+sam
|
||||
==
|
||||
::
|
||||
=/ von
|
||||
%+ turn
|
||||
(sort ~(tap by van.mod) |=([[a=@tas *] [b=@tas *]] (aor a b)))
|
||||
::
|
||||
:~ :+ %reports %|
|
||||
=/ bem=beam [[our %home da+now] /whey] ::TODO %base?
|
||||
%+ turn von
|
||||
|= [nam=term =vane]
|
||||
=/ met (peek [~ ~] nam bem)
|
||||
~| mass/nam
|
||||
?> &(?=(^ met) ?=(^ u.met)) :: XX make optional
|
||||
nam^|+;;((list mass) q.q.u.u.met)
|
||||
::
|
||||
:+ %caches %|
|
||||
%+ turn von
|
||||
|=([nam=term =vane] nam^&+worm.vane)
|
||||
::
|
||||
:+ %dregs %|
|
||||
%+ turn von
|
||||
|=([nam=term =vane] nam^&+vase.vane)
|
||||
==
|
||||
=/ bem=beam [[our %home da+now] /whey] ::TODO %base?
|
||||
|= [nam=term =vane]
|
||||
=; mas=(list mass)
|
||||
nam^|+(welp mas [dot+&+q.vase typ+&+p.vase sac+&+worm ~]:vane)
|
||||
?~ met=(peek [~ ~] nam bem) ~
|
||||
?~ u.met ~
|
||||
~| mass+nam
|
||||
;;((list mass) q.q.u.u.met)
|
||||
:: +peek: read from the entire namespace
|
||||
::
|
||||
++ peek
|
||||
|
@ -5962,7 +5962,14 @@
|
||||
++ spat |=(pax=path (crip (spud pax))) :: render path to cord
|
||||
++ spud |=(pax=path ~(ram re (smyt pax))) :: render path to tape
|
||||
++ stab |=(zep=@t `path`(rash zep stap)) :: parse cord to path
|
||||
++ stap ;~(pfix fas (more fas urs:ab)) :: path parser
|
||||
++ stap :: path parser
|
||||
%+ sear
|
||||
|= p=path
|
||||
^- (unit path)
|
||||
?: ?=([~ ~] p) `~
|
||||
?. =(~ (rear p)) `p
|
||||
~
|
||||
;~(pfix fas (most fas urs:ab))
|
||||
::
|
||||
:::: 4n: virtualization
|
||||
::
|
||||
@ -9247,144 +9254,6 @@
|
||||
hag [q.p.dix q.q.dix]
|
||||
==
|
||||
::
|
||||
++ ad
|
||||
|%
|
||||
++ arc
|
||||
|%
|
||||
++ deft :: generic
|
||||
|%
|
||||
++ bath * :: leg match type
|
||||
++ claw * :: arm match type
|
||||
++ form |*([* *] p=+<-) :: attach build state
|
||||
++ skin |*(p=* p) :: reveal build state
|
||||
++ meat |*(p=* p) :: remove build state
|
||||
--
|
||||
++ make :: for mint
|
||||
|%
|
||||
++ bath type :: leg match type
|
||||
++ claw onyx :: arm
|
||||
++ form |*([* *] [p=+<- q=+<+]) ::
|
||||
++ skin |*([p=* q=*] q) :: unwrap baggage
|
||||
++ meat |*([p=* q=*] p) :: unwrap filling
|
||||
--
|
||||
--
|
||||
++ def
|
||||
=+ deft:arc
|
||||
|@ ++ $
|
||||
=> +<
|
||||
|%
|
||||
++ pord |*(* (form +< *nock)) :: wrap mint formula
|
||||
++ rosh |*(* (form +< *(list pock))) :: wrap mint changes
|
||||
++ fleg _(pord $:bath) :: legmatch + code
|
||||
++ fram _(pord $:claw) :: armmatch +
|
||||
++ foat _(rosh $:bath) :: leg with changes
|
||||
++ fult _(rosh $:claw) :: arm with changes
|
||||
-- --
|
||||
::
|
||||
++ lib
|
||||
|%
|
||||
++ deft
|
||||
=> (def deft:arc)
|
||||
|%
|
||||
++ halp ^|(|:($:hoon $:fleg))
|
||||
++ vant
|
||||
|% ++ trep ^|(|:($:,[bath wing bath] $:,[axis bath]))
|
||||
++ tasp ^|(|:($:,[[axis bath] fleg foat] $:foat))
|
||||
++ tyle ^|(|:($:foat $:foat))
|
||||
--
|
||||
++ vunt
|
||||
|% ++ trep ^|(|:($:,[claw wing bath] $:,[axis claw]))
|
||||
++ tasp ^|(|:($:,[[axis claw] fleg fult] $:fult))
|
||||
++ tyle ^|(|:($:fult $:foat))
|
||||
-- --
|
||||
::
|
||||
++ make
|
||||
=> (def make:arc)
|
||||
|%
|
||||
++ halp |~ a=hoon
|
||||
^- fleg
|
||||
(mint %noun a)
|
||||
++ vant
|
||||
|% ++ trep |: $:,[a=type b=wing c=type]
|
||||
^- [axis type]
|
||||
(tack(sut a) b c)
|
||||
++ tasp |: $:,[a=(pair axis type) b=fleg c=foat]
|
||||
^- foat
|
||||
[q.a [[p.a (skin b)] (skin c)]]
|
||||
++ tyle |:($:foat +<)
|
||||
--
|
||||
++ vunt
|
||||
|% ++ trep |: $:,[a=claw b=wing c=bath]
|
||||
^- (pair axis claw)
|
||||
(toss b c a)
|
||||
++ tasp |: $:,[a=(pair axis claw) b=fleg c=fult]
|
||||
^- fult
|
||||
[q.a [[p.a (skin b)] (skin c)]]
|
||||
++ tyle |: $:fult
|
||||
^- foat
|
||||
[(fire +<-) +<+]
|
||||
-- -- --
|
||||
::
|
||||
++ bin
|
||||
=+ deft:lib
|
||||
|@ ++ $
|
||||
=> +<
|
||||
|%
|
||||
++ rame
|
||||
=> vant |%
|
||||
++ clom bath
|
||||
++ chog fleg
|
||||
++ ceut foat
|
||||
--
|
||||
++ gelp
|
||||
=> vunt |%
|
||||
++ clom claw
|
||||
++ chog fram
|
||||
++ ceut fult
|
||||
--
|
||||
++ ecbo (ecco rame)
|
||||
++ eclo (ecco gelp)
|
||||
++ ecco
|
||||
=+ rame
|
||||
|@ ++ $
|
||||
=> +<
|
||||
|: $:,[rum=clom rig=(list (pair wing hoon))]
|
||||
^- foat
|
||||
%- tyle
|
||||
|- ^- ceut
|
||||
?~ rig (rosh rum)
|
||||
=+ mor=$(rig t.rig)
|
||||
=+ zil=(halp q.i.rig)
|
||||
=+ dar=(trep (meat mor) p.i.rig (meat zil))
|
||||
(tasp dar zil mor)
|
||||
-- -- -- --
|
||||
::
|
||||
++ oc
|
||||
=+ inc=(bin:ad)
|
||||
|@ ++ $
|
||||
=> inc
|
||||
|%
|
||||
++ echo
|
||||
|: $:,[rum=bath rig=(list (pair wing hoon))]
|
||||
(ecbo rum rig)
|
||||
::
|
||||
++ ecmo
|
||||
|: $:,[hag=claw rig=(list (pair wing hoon))]
|
||||
(eclo hag rig)
|
||||
-- --
|
||||
::
|
||||
++ etco
|
||||
|= [lop=palo rig=(list (pair wing hoon))]
|
||||
^- (pair type nock)
|
||||
=+ cin=(oc (bin:ad make:lib:ad))
|
||||
=. rig (flop rig) :: XX this unbreaks, void order in devulc
|
||||
=+ axe=(tend p.lop)
|
||||
?: ?=(%& -.q.lop)
|
||||
=- [p.- (hike axe q.-)]
|
||||
(echo:cin p.q.lop rig)
|
||||
=- [p.- [%9 p.q.lop (hike axe q.-)]]
|
||||
(ecmo:cin ~(tap in q.q.lop) rig)
|
||||
::
|
||||
++ et
|
||||
|_ [hyp=wing rig=(list (pair wing hoon))]
|
||||
::
|
||||
@ -9400,7 +9269,7 @@
|
||||
=+ lug=(find %read hyp)
|
||||
?: ?=(%| -.lug) ~>(%mean.'hoon' ?>(?=(~ rig) p.lug))
|
||||
=- ?>(?|(!vet (nest(sut gol) & p.-)) -)
|
||||
(etco p.lug rig)
|
||||
(ergo p.lug rig)
|
||||
::
|
||||
++ mull
|
||||
|= [gol=type dox=type]
|
||||
@ -10088,7 +9957,6 @@
|
||||
[(nice %noun) [%2 q:$(gen p.gen, gol %noun) q:$(gen q.gen, gol %noun)]]
|
||||
::
|
||||
[%dtts *]
|
||||
=+ [one two]=[$(gen p.gen, gol %noun) $(gen q.gen, gol %noun)]
|
||||
[(nice bool) [%5 q:$(gen p.gen, gol %noun) q:$(gen q.gen, gol %noun)]]
|
||||
::
|
||||
[%dtwt *] [(nice bool) [%3 q:$(gen p.gen, gol %noun)]]
|
||||
|
@ -851,7 +851,7 @@
|
||||
+$ mool [=case paths=(set (pair care path))] :: requests in desk
|
||||
+$ nori :: repository action
|
||||
$% [%& p=soba] :: delta
|
||||
[%| p=@tas] :: label
|
||||
[%| p=@tas q=(unit aeon)] :: label
|
||||
== ::
|
||||
+$ nuri :: repository action
|
||||
$% [%& p=suba] :: delta
|
||||
@ -1907,6 +1907,8 @@
|
||||
[%private-keys ~] :: sub to privates
|
||||
[%public-keys ships=(set ship)] :: sub to publics
|
||||
[%rekey =life =ring] :: update private keys
|
||||
[%resend ~] :: resend private key
|
||||
[%ruin ships=(set ship)] :: pretend breach
|
||||
$>(%trim vane-task) :: trim state
|
||||
[%turf ~] :: view domains
|
||||
$>(%vega vane-task) :: report upgrade
|
||||
@ -1980,8 +1982,8 @@
|
||||
+$ udiffs (list [=ship =udiff])
|
||||
+$ udiff
|
||||
$: =id:block
|
||||
$% [%rift =rift]
|
||||
[%keys key-update]
|
||||
$% [%rift =rift boot=?]
|
||||
[%keys key-update boot=?]
|
||||
[%spon sponsor=(unit @p)]
|
||||
[%disavow ~]
|
||||
== ==
|
||||
@ -1995,14 +1997,14 @@
|
||||
%rift
|
||||
?. (gth rift.a-udiff rift.a-point)
|
||||
~
|
||||
~? !=(rift.a-udiff +(rift.a-point))
|
||||
~? &(!=(rift.a-udiff +(rift.a-point)) !boot.a-udiff)
|
||||
[%udiff-to-diff-skipped-rift a-udiff a-point]
|
||||
`[%rift rift.a-point rift.a-udiff]
|
||||
::
|
||||
%keys
|
||||
?. (gth life.a-udiff life.a-point)
|
||||
~
|
||||
~? !=(life.a-udiff +(life.a-point))
|
||||
~? &(!=(life.a-udiff +(life.a-point)) !boot.a-udiff)
|
||||
[%udiff-to-diff-skipped-life a-udiff a-point]
|
||||
:^ ~ %keys
|
||||
[life.a-point (~(gut by keys.a-point) life.a-point *[@ud pass])]
|
||||
|
@ -1593,10 +1593,12 @@
|
||||
?~ sponsor
|
||||
~| %ames-lost-sponsor^our^ship !!
|
||||
::
|
||||
=/ =peer-state (got-peer-state ship)
|
||||
=. sponsor.peer-state u.sponsor
|
||||
::
|
||||
=. peers.ames-state (~(put by peers.ames-state) ship %known peer-state)
|
||||
=/ state=(unit peer-state) (get-peer-state ship)
|
||||
?~ state
|
||||
%- (slog leaf+"ames: missing peer-state, ignoring" ~)
|
||||
event-core
|
||||
=. sponsor.u.state u.sponsor
|
||||
=. peers.ames-state (~(put by peers.ames-state) ship %known u.state)
|
||||
event-core
|
||||
:: +on-publ-full: handle new pki data for peer(s)
|
||||
::
|
||||
|
@ -1399,6 +1399,32 @@
|
||||
==
|
||||
==
|
||||
::
|
||||
:: Attach label to aeon
|
||||
::
|
||||
++ label
|
||||
|= [bel=@tas aey=(unit aeon)]
|
||||
^+ ..park
|
||||
=/ yon ?~(aey let.dom u.aey)
|
||||
=/ yen (~(get by lab.dom) bel) :: existing aeon?
|
||||
:: no existing aeon is bound to this label
|
||||
::
|
||||
?~ yen
|
||||
=. lab.dom (~(put by lab.dom) bel yon)
|
||||
..park
|
||||
:: an aeon is bound to this label,
|
||||
:: but it is the same as the existing one, so we no-op
|
||||
::
|
||||
?: =(u.yen yon)
|
||||
~& "clay: tried to rebind existing label {<bel>} to equivalent aeon {<yon>}"
|
||||
..park
|
||||
:: an existing aeon bound to the label
|
||||
:: that is distinct from the requested one.
|
||||
:: rewriting would violate referential transparency
|
||||
::
|
||||
~| %tried-to-rewrite-existing-label
|
||||
~| "requested aeon: {<yon>}, existing aeon: {<u.yen>}"
|
||||
!!
|
||||
::
|
||||
:: Porcelain commit
|
||||
::
|
||||
++ info
|
||||
@ -4284,8 +4310,12 @@
|
||||
::
|
||||
%info
|
||||
?: ?=(%| -.dit.req)
|
||||
~| %labelling-not-implemented
|
||||
!!
|
||||
=/ bel=@tas p.dit.req
|
||||
=/ aey=(unit aeon) q.dit.req
|
||||
=^ mos ruf
|
||||
=/ den ((de now rof hen ruf) our des.req)
|
||||
abet:(label:den bel aey)
|
||||
[mos ..^$]
|
||||
=/ [deletes=(set path) changes=(map path cage)]
|
||||
=/ =soba p.dit.req
|
||||
=| deletes=(set path)
|
||||
|
@ -34,18 +34,16 @@
|
||||
:: manage subscriptions efficiently.
|
||||
::
|
||||
=> |%
|
||||
+$ state-1
|
||||
$: %1
|
||||
pki=state-pki-1 ::
|
||||
+$ state-2
|
||||
$: %2
|
||||
pki=state-pki-2 ::
|
||||
etn=state-eth-node :: eth connection state
|
||||
== ::
|
||||
+$ state-pki-1 :: urbit metadata
|
||||
+$ state-pki-2 :: urbit metadata
|
||||
$: $= own :: vault (vein)
|
||||
$: yen=(set duct) :: trackers
|
||||
sig=(unit oath) :: for a moon
|
||||
tuf=(list turf) :: domains
|
||||
boq=@ud :: boot block
|
||||
nod=purl:eyre :: eth gateway
|
||||
fak=_| :: fake keys
|
||||
lyf=life :: version
|
||||
step=@ud :: login code step
|
||||
@ -181,7 +179,7 @@
|
||||
==
|
||||
:: all vane state
|
||||
::
|
||||
state-1
|
||||
state-2
|
||||
==
|
||||
:: lex: all durable state
|
||||
:: moz: pending actions
|
||||
@ -207,8 +205,8 @@
|
||||
[our our]
|
||||
app
|
||||
%poke
|
||||
%azimuth-tracker-poke
|
||||
!>([%watch (crip (en-purl:html purl))])
|
||||
%azimuth-poke
|
||||
!>([%watch (crip (en-purl:html purl)) %default])
|
||||
==
|
||||
::
|
||||
++ sein :: sponsor
|
||||
@ -254,14 +252,6 @@
|
||||
::
|
||||
~| [our who.seed.tac]
|
||||
?> =(our who.seed.tac)
|
||||
:: save our boot block
|
||||
::
|
||||
=. boq.own.pki bloq.tac
|
||||
:: save our ethereum gateway (required for galaxies)
|
||||
::
|
||||
=. nod.own.pki
|
||||
%+ fall node.tac
|
||||
(need (de-purl:html 'http://eth-mainnet.urbit.org:8545'))
|
||||
:: save our parent signature (only for moons)
|
||||
::
|
||||
=. sig.own.pki sig.seed.tac
|
||||
@ -312,26 +302,29 @@
|
||||
::
|
||||
:: start subscriptions
|
||||
::
|
||||
=. +>.$ (poke-watch hen %azimuth-tracker nod.own.pki)
|
||||
=. +>.$
|
||||
:: get everything from azimuth-tracker because jael subscriptions
|
||||
%^ poke-watch hen %azimuth
|
||||
%+ fall node.tac
|
||||
(need (de-purl:html 'http://eth-mainnet.urbit.org:8545'))
|
||||
=. +>.$
|
||||
:: get everything from /app/azimuth because jael subscriptions
|
||||
:: seem to be flaky for now
|
||||
::
|
||||
?: &
|
||||
%- curd =< abet
|
||||
(sources:~(feel su hen now pki etn) ~ [%| %azimuth-tracker])
|
||||
(sources:~(feel su hen now pki etn) ~ [%| %azimuth])
|
||||
::
|
||||
?- (clan:title our)
|
||||
%czar
|
||||
%- curd =< abet
|
||||
(sources:~(feel su hen now pki etn) ~ [%| %azimuth-tracker])
|
||||
(sources:~(feel su hen now pki etn) ~ [%| %azimuth])
|
||||
::
|
||||
*
|
||||
=. +>.$
|
||||
%- curd =< abet
|
||||
%+ sources:~(feel su hen now pki etn)
|
||||
(silt (turn spon-points head))
|
||||
[%| %azimuth-tracker]
|
||||
[%| %azimuth]
|
||||
%- curd =< abet
|
||||
(sources:~(feel su hen now pki etn) ~ [%& (need spon-ship)])
|
||||
==
|
||||
@ -434,6 +427,13 @@
|
||||
%- curd =< abet
|
||||
(private-keys:~(feel su hen now pki etn) life.tac ring.tac)
|
||||
::
|
||||
:: resend private key to subscribers
|
||||
::
|
||||
%resend
|
||||
%- curd =< abet
|
||||
%- ~(exec su hen now pki etn)
|
||||
[yen.own.pki [%give %private-keys [lyf jaw]:own.pki]]
|
||||
::
|
||||
:: register moon keys
|
||||
::
|
||||
%moon
|
||||
@ -489,6 +489,7 @@
|
||||
:: [%trim p=@ud]
|
||||
::
|
||||
%trim
|
||||
::TODO consider %ruin-ing long-offline comets
|
||||
+>.$
|
||||
::
|
||||
:: watch private keys
|
||||
@ -521,6 +522,20 @@
|
||||
=. moz [[hen %give %done ~] moz]
|
||||
$(tac message)
|
||||
==
|
||||
::
|
||||
:: pretend ships breached
|
||||
:: [%ruin ships=(set ship)]
|
||||
::
|
||||
%ruin
|
||||
::NOTE we blast this out to _all_ known ducts, because the common
|
||||
:: use case for this is comets, about who nobody cares.
|
||||
=/ dus ~(key by yen.zim.pki)
|
||||
=/ sus ~(. su hen now pki etn)
|
||||
=/ sis ~(tap in ships.tac)
|
||||
|-
|
||||
?~ sis (curd abet:sus)
|
||||
=. sus (exec:sus dus %give %public-keys %breach i.sis)
|
||||
$(sis t.sis)
|
||||
==
|
||||
::
|
||||
++ take
|
||||
@ -548,7 +563,7 @@
|
||||
[%behn %wake *]
|
||||
?^ error.hin
|
||||
%- %+ slog
|
||||
leaf+"jael unable to resubscribe, run :azimuth-tracker|listen"
|
||||
leaf+"jael unable to resubscribe, run :azimuth|listen"
|
||||
u.error.hin
|
||||
+>.$
|
||||
?> ?=([%breach @ ~] tea)
|
||||
@ -565,7 +580,14 @@
|
||||
[%gall %unto *]
|
||||
?- +>-.hin
|
||||
%raw-fact !!
|
||||
%kick ~|([%jael-unexpected-quit tea hin] !!)
|
||||
::
|
||||
%kick
|
||||
?> ?=([@ *] tea)
|
||||
=* app i.tea
|
||||
::NOTE we expect azimuth-tracker to be kill
|
||||
?: =(%azimuth-tracker app) +>.$
|
||||
~|([%jael-unexpected-quit tea hin] !!)
|
||||
::
|
||||
%poke-ack
|
||||
?~ p.p.+>.hin
|
||||
+>.$
|
||||
@ -589,7 +611,7 @@
|
||||
:: :: ++curd:of
|
||||
++ curd :: relative moves
|
||||
|= $: moz=(list move)
|
||||
pki=state-pki-1
|
||||
pki=state-pki-2
|
||||
etn=state-eth-node
|
||||
==
|
||||
+>(pki pki, etn etn, moz (weld (flop moz) ^moz))
|
||||
@ -609,7 +631,7 @@
|
||||
=| moz=(list move)
|
||||
=| $: hen=duct
|
||||
now=@da
|
||||
state-pki-1
|
||||
state-pki-2
|
||||
state-eth-node
|
||||
==
|
||||
:: moz: moves in reverse order
|
||||
@ -718,14 +740,18 @@
|
||||
=/ a-point=point (~(gut by pos.zim.pki) ship.i.udiffs *point)
|
||||
=/ a-diff=(unit diff:point) (udiff-to-diff:point udiff.i.udiffs a-point)
|
||||
=? this-su ?=(^ a-diff)
|
||||
:: if this about our keys, and we already know these, start using them
|
||||
::
|
||||
=? lyf.own
|
||||
=? this-su
|
||||
?& =(our ship.i.udiffs)
|
||||
?=(%keys -.u.a-diff)
|
||||
(~(has by jaw.own) life.to.u.a-diff)
|
||||
==
|
||||
life.to.u.a-diff
|
||||
:: if this about our keys, and we already know these, start using them
|
||||
::
|
||||
=. lyf.own life.to.u.a-diff
|
||||
:: notify subscribers (ames) to start using our new private keys
|
||||
::
|
||||
(exec yen.own [%give %private-keys [lyf jaw]:own])
|
||||
::
|
||||
(public-keys:feel original-pos %diff ship.i.udiffs u.a-diff)
|
||||
$(udiffs t.udiffs)
|
||||
::
|
||||
@ -990,7 +1016,7 @@
|
||||
::
|
||||
:: lex: all durable %jael state
|
||||
::
|
||||
=| lex=state-1
|
||||
=| lex=state-2
|
||||
|= $: :: now: current time
|
||||
:: eny: unique entropy
|
||||
:: ski: namespace resolver
|
||||
@ -1020,8 +1046,42 @@
|
||||
[did ..^$]
|
||||
:: :: ++load
|
||||
++ load :: upgrade
|
||||
|= old=state-1
|
||||
=> |%
|
||||
::
|
||||
+$ any-state $%(state-1 state-2)
|
||||
+$ state-1
|
||||
$: %1
|
||||
pki=state-pki-1
|
||||
etn=state-eth-node
|
||||
==
|
||||
+$ state-pki-1
|
||||
$: $= own
|
||||
$: yen=(set duct)
|
||||
sig=(unit oath)
|
||||
tuf=(list turf)
|
||||
boq=@ud
|
||||
nod=purl:eyre
|
||||
fak=_|
|
||||
lyf=life
|
||||
step=@ud
|
||||
jaw=(map life ring)
|
||||
==
|
||||
$= zim
|
||||
$: yen=(jug duct ship)
|
||||
ney=(jug ship duct)
|
||||
nel=(set duct)
|
||||
dns=dnses
|
||||
pos=(map ship point)
|
||||
== ==
|
||||
--
|
||||
|= old=any-state
|
||||
^+ ..^$
|
||||
=? old ?=(%1 -.old)
|
||||
%= old
|
||||
- %2
|
||||
own.pki own.pki.old(+>+ +>.+>+.own.pki.old)
|
||||
==
|
||||
?> ?=(%2 -.old)
|
||||
..^$(lex old)
|
||||
:: :: ++scry
|
||||
++ scry :: inspect
|
||||
@ -1064,6 +1124,12 @@
|
||||
=/ sec (~(got by jaw.own.pki.lex) lyf.own.pki.lex)
|
||||
=/ sal (add %pass step.own.pki.lex)
|
||||
``[%noun !>((end 6 (shaf sal (shax sec))))]
|
||||
::
|
||||
%fake
|
||||
?. ?=(~ tyl) [~ ~]
|
||||
?. =([%& our] why)
|
||||
[~ ~]
|
||||
``[%noun !>(fak.own.pki.lex)]
|
||||
::
|
||||
%life
|
||||
?. ?=([@ ~] tyl) [~ ~]
|
||||
|
@ -4,7 +4,7 @@
|
||||
=> ..lull
|
||||
~% %zuse ..part ~
|
||||
|%
|
||||
++ zuse %420
|
||||
++ zuse %419
|
||||
:: :: ::
|
||||
:::: :: :: (2) engines
|
||||
:: :: ::
|
||||
@ -2235,6 +2235,112 @@
|
||||
=/ pub (from.j qj)
|
||||
?< =([0 0] pub)
|
||||
pub
|
||||
++ schnorr
|
||||
~% %schnorr ..schnorr ~
|
||||
=> |%
|
||||
++ tagged-hash
|
||||
|= [tag=@ [l=@ x=@]]
|
||||
=+ hat=(sha-256:sha (swp 3 tag))
|
||||
%- sha-256l:sha
|
||||
:- (add 64 l)
|
||||
(can 3 ~[[l x] [32 hat] [32 hat]])
|
||||
++ lift-x
|
||||
|= x=@I
|
||||
^- (unit point)
|
||||
=/ c curve
|
||||
?. (lth x p.domain.c)
|
||||
~
|
||||
=/ fop field-p.c
|
||||
=+ [fadd fpow]=[sum.fop exp.fop]
|
||||
=/ cp (fadd (fpow 3 x) 7)
|
||||
=/ y (fpow (rsh [0 2] +(p.domain.c)) cp)
|
||||
?. =(cp (fpow 2 y))
|
||||
~
|
||||
%- some :- x
|
||||
?: =(0 (mod y 2))
|
||||
y
|
||||
(sub p.domain.c y)
|
||||
--
|
||||
|%
|
||||
::
|
||||
++ sign :: schnorr signature
|
||||
~/ %sosi
|
||||
|= [sk=@I m=@I a=@I]
|
||||
^- @J
|
||||
?> (gte 32 (met 3 m))
|
||||
?> (gte 32 (met 3 a))
|
||||
=/ c curve
|
||||
:: implies (gte 32 (met 3 sk))
|
||||
::
|
||||
?< |(=(0 sk) (gte sk n.domain.c))
|
||||
=/ pp
|
||||
(mul-point-scalar g.domain.c sk)
|
||||
=/ d
|
||||
?: =(0 (mod y.pp 2))
|
||||
sk
|
||||
(sub n.domain.c sk)
|
||||
=/ t
|
||||
%+ mix d
|
||||
(tagged-hash 'BIP0340/aux' [32 a])
|
||||
=/ rand
|
||||
%+ tagged-hash 'BIP0340/nonce'
|
||||
:- 96
|
||||
(rep 8 ~[m x.pp t])
|
||||
=/ kp (mod rand n.domain.c)
|
||||
?< =(0 kp)
|
||||
=/ rr (mul-point-scalar g.domain.c kp)
|
||||
=/ k
|
||||
?: =(0 (mod y.rr 2))
|
||||
kp
|
||||
(sub n.domain.c kp)
|
||||
=/ e
|
||||
%- mod
|
||||
:_ n.domain.c
|
||||
%+ tagged-hash 'BIP0340/challenge'
|
||||
:- 96
|
||||
(rep 8 ~[m x.pp x.rr])
|
||||
=/ sig
|
||||
%^ cat 8
|
||||
(mod (add k (mul e d)) n.domain.c)
|
||||
x.rr
|
||||
?> (verify x.pp m sig)
|
||||
sig
|
||||
::
|
||||
++ verify :: schnorr verify
|
||||
~/ %sove
|
||||
|= [pk=@I m=@I sig=@J]
|
||||
^- ?
|
||||
?> (gte 32 (met 3 pk))
|
||||
?> (gte 32 (met 3 m))
|
||||
?> (gte 64 (met 3 sig))
|
||||
=/ c curve
|
||||
=/ pup (lift-x pk)
|
||||
?~ pup
|
||||
%.n
|
||||
=/ pp u.pup
|
||||
=/ r (cut 8 [1 1] sig)
|
||||
?: (gte r p.domain.c)
|
||||
%.n
|
||||
=/ s (end 8 sig)
|
||||
?: (gte s n.domain.c)
|
||||
%.n
|
||||
=/ e
|
||||
%- mod
|
||||
:_ n.domain.c
|
||||
%+ tagged-hash 'BIP0340/challenge'
|
||||
:- 96
|
||||
(rep 8 ~[m x.pp r])
|
||||
=/ aa
|
||||
(mul-point-scalar g.domain.c s)
|
||||
=/ bb
|
||||
(mul-point-scalar pp (sub n.domain.c e))
|
||||
?: &(=(x.aa x.bb) !=(y.aa y.bb)) :: infinite?
|
||||
%.n
|
||||
=/ rr (add-points aa bb)
|
||||
?. =(0 (mod y.rr 2))
|
||||
%.n
|
||||
=(r x.rr)
|
||||
--
|
||||
--
|
||||
--
|
||||
::
|
||||
@ -4422,7 +4528,7 @@
|
||||
:: :: ++chrd:de-xml:html
|
||||
++ chrd :: character data
|
||||
%+ cook |=(a=tape ^-(mars ;/(a)))
|
||||
(plus ;~(less doq ;~(pose (just `@`10) escp)))
|
||||
(plus ;~(pose (just `@`10) escp))
|
||||
:: :: ++comt:de-xml:html
|
||||
++ comt :: comments
|
||||
=- (ifix [(jest '<!--') (jest '-->')] (star -))
|
||||
@ -4910,13 +5016,20 @@
|
||||
++ cite :: render ship
|
||||
|= who=@p
|
||||
^- tape
|
||||
=+ kind=(clan who)
|
||||
=+ name=(scow %p who)
|
||||
?: =(%earl kind)
|
||||
:(weld "~" (swag [15 6] name) "^" (swag [22 6] name))
|
||||
?: =(%pawn kind)
|
||||
:(weld (swag [0 7] name) "_" (swag [51 6] name))
|
||||
name
|
||||
=/ wid (met 4 who)
|
||||
?: (lte wid 2) (scow %p who)
|
||||
?: (lte wid 4)
|
||||
=/ nom (scow %p (end 5 who))
|
||||
:(weld (scag 7 nom) "^" (slag 8 nom))
|
||||
%- trip
|
||||
%+ rap 3
|
||||
:~ '~'
|
||||
(tos:po (cut 3 [(dec (mul wid 2)) 1] who))
|
||||
(tod:po (cut 3 [(mul (dec wid) 2) 1] who))
|
||||
'_'
|
||||
(tos:po (cut 3 [1 1] who))
|
||||
(tod:po (end 3 who))
|
||||
==
|
||||
:: :: ++saxo:title
|
||||
++ saxo :: autocanon
|
||||
|= [our=ship now=@da who=ship]
|
||||
|
72
pkg/arvo/ted/azimuth/snap-logs.hoon
Normal file
72
pkg/arvo/ted/azimuth/snap-logs.hoon
Normal file
@ -0,0 +1,72 @@
|
||||
:: Creates a snapshot of the azimuth state and its indices
|
||||
:: (owners and sposnors) from a list of ethereum logs
|
||||
::
|
||||
/- spider, *dice
|
||||
/+ strand,
|
||||
azimuth,
|
||||
strandio,
|
||||
naive,
|
||||
lib=naive-transactions,
|
||||
ethereum,
|
||||
dice
|
||||
/* logs %eth-logs /app/azimuth/logs/eth-logs
|
||||
=, strand=strand:spider
|
||||
::
|
||||
=> |% +$ card card:agent:gall
|
||||
+$ task task:clay
|
||||
+$ id id:block:jael
|
||||
+$ events (list event-log:rpc:ethereum)
|
||||
--
|
||||
::
|
||||
^- thread:spider
|
||||
|= arg=vase
|
||||
=/ m (strand ,vase)
|
||||
^- form:m
|
||||
=+ !<([~ =net file-name=@t] arg)
|
||||
::
|
||||
=/ [azimuth-contract=@ux chain-id=@]
|
||||
[azimuth chain-id]:(get-network:dice net)
|
||||
::
|
||||
%- %- slog :_ ~
|
||||
leaf+"azimuth: creating snapshot with {<(lent logs)>} events"
|
||||
::
|
||||
=/ [=id nas=^state:naive]
|
||||
%+ roll `events`logs
|
||||
|= [log=event-log:rpc:ethereum =id nas=^state:naive]
|
||||
?~ mined.log
|
||||
id^nas
|
||||
=/ =^input:naive
|
||||
:- block-number.u.mined.log
|
||||
?: =(azimuth-contract address.log)
|
||||
:- %log
|
||||
[address.log (data-to-hex:dice data.log) topics.log]
|
||||
?~ input.u.mined.log
|
||||
[%bat *@]
|
||||
[%bat u.input.u.mined.log]
|
||||
=. id
|
||||
?. (gth block-number.u.mined.log number.id)
|
||||
id
|
||||
[block-hash block-number]:u.mined.log
|
||||
=^ * nas
|
||||
(%*(. naive lac |) verifier:lib chain-id nas input)
|
||||
id^nas
|
||||
::
|
||||
=/ [=sponsors =owners] (create-indices:dice nas)
|
||||
::
|
||||
%- %- slog
|
||||
:~ leaf+"points: {<~(wyt by points.nas)>}"
|
||||
leaf+"sponsors: {<~(wyt by sponsors)>}"
|
||||
leaf+"owners: {<~(wyt by owners)>}"
|
||||
leaf+"block-number: {<number.id>}"
|
||||
leaf+"block-hash: {<hash.id>}"
|
||||
==
|
||||
::
|
||||
=/ =path /app/azimuth/[file-name]/azimuth-snapshot
|
||||
=/ =cage
|
||||
:- %azimuth-snapshot
|
||||
!> ^- snap-state
|
||||
[%0 id nas owners sponsors]
|
||||
=/ =task [%info %base %& [path %ins cage]~]
|
||||
=/ =card [%pass /next %arvo %c task]
|
||||
;< ~ bind:m (send-raw-card:strandio card)
|
||||
(pure:m !>('azimuth logs processed'))
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user