Add demo instructions to fixturenet-payments stack #556
@ -31,7 +31,7 @@ services:
|
||||
start_period: 10s
|
||||
ports:
|
||||
- "3005"
|
||||
- "4005"
|
||||
- "4005:4005"
|
||||
- "5005:5005"
|
||||
|
||||
volumes:
|
||||
|
@ -1,7 +1,7 @@
|
||||
github.com/cerc-io/ipld-eth-db
|
||||
github.com/cerc-io/go-ethereum
|
||||
github.com/cerc-io/ipld-eth-server
|
||||
github.com/cerc-io/eth-statediff-service
|
||||
git.vdb.to/cerc-io/ipld-eth-db
|
||||
git.vdb.to/cerc-io/go-ethereum
|
||||
git.vdb.to/cerc-io/ipld-eth-server
|
||||
git.vdb.to/cerc-io/eth-statediff-service
|
||||
github.com/cerc-io/eth-statediff-fill-service
|
||||
github.com/cerc-io/ipld-eth-db-validator
|
||||
github.com/cerc-io/ipld-eth-beacon-indexer
|
||||
@ -18,7 +18,7 @@ github.com/vulcanize/uniswap-watcher-ts
|
||||
github.com/vulcanize/uniswap-v3-info
|
||||
github.com/vulcanize/assemblyscript
|
||||
github.com/cerc-io/eth-probe
|
||||
github.com/cerc-io/tx-spammer
|
||||
git.vdb.to/cerc-io/tx-spammer
|
||||
github.com/dboreham/foundry
|
||||
github.com/lirewine/gem
|
||||
github.com/lirewine/debug
|
||||
@ -30,7 +30,7 @@ github.com/ethereum-optimism/optimism
|
||||
github.com/pokt-network/pocket-core
|
||||
github.com/pokt-network/pocket-core-deployments
|
||||
github.com/cerc-io/azimuth-watcher-ts
|
||||
github.com/cerc-io/ipld-eth-state-snapshot
|
||||
git.vdb.to/cerc-io/ipld-eth-state-snapshot
|
||||
github.com/cerc-io/gelato-watcher-ts
|
||||
github.com/filecoin-project/lotus
|
||||
git.vdb.to/cerc-io/test-project
|
||||
|
@ -66,7 +66,7 @@ It is not necessary to use them all at once, but a complete example follows:
|
||||
|
||||
```
|
||||
# Setup
|
||||
$ laconic-so setup-repositories --include github.com/cerc-io/go-ethereum,github.com/cerc-io/ipld-eth-db,github.com/cerc-io/ipld-eth-server,github.com/cerc-io/ipld-eth-beacon-db,github.com/cerc-io/ipld-eth-beacon-indexer,github.com/cerc-io/eth-probe,github.com/cerc-io/tx-spammer
|
||||
$ laconic-so setup-repositories --include git.vdb.to/cerc-io/go-ethereum,git.vdb.to/cerc-io/ipld-eth-db,git.vdb.to/cerc-io/ipld-eth-server,github.com/cerc-io/ipld-eth-beacon-db,github.com/cerc-io/ipld-eth-beacon-indexer,github.com/cerc-io/eth-probe,git.vdb.to/cerc-io/tx-spammer
|
||||
|
||||
# Build
|
||||
$ laconic-so build-containers --include cerc/go-ethereum,cerc/lighthouse,cerc/fixturenet-eth-geth,cerc/fixturenet-eth-lighthouse,cerc/ipld-eth-db,cerc/ipld-eth-server,cerc/ipld-eth-beacon-db,cerc/ipld-eth-beacon-indexer,cerc/eth-probe,cerc/keycloak,cerc/tx-spammer
|
||||
|
@ -9,7 +9,7 @@ Prerequisite: An L1 Ethereum RPC endpoint
|
||||
Clone required repositories:
|
||||
|
||||
```bash
|
||||
laconic-so --stack fixturenet-optimism setup-repositories --exclude github.com/cerc-io/go-ethereum
|
||||
laconic-so --stack fixturenet-optimism setup-repositories --exclude git.vdb.to/cerc-io/go-ethereum
|
||||
|
||||
# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the repositories mentioned below and re-run the command
|
||||
```
|
||||
|
@ -1,25 +0,0 @@
|
||||
# Required for:
|
||||
# Nitro contracts deployment
|
||||
# MobyMask contract deployment
|
||||
CERC_PRIVATE_KEY_DEPLOYER="0x888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218"
|
||||
|
||||
# ipld-eth-server's go-nitro node credentials
|
||||
NITRO_PK=2d999770f7b5d49b694080f987b82bbc9fc9ac2b4dcc10b0f8aba7d700f69c6d
|
||||
NITRO_CHAIN_PK=570b909da9669b2f35a0b1ac70b8358516d55ae1b5b3710e95e9a94395090597
|
||||
|
||||
# Watcher's nitro node credentials
|
||||
CERC_WATCHER_NITRO_PK="0279651921cd800ac560c21ceea27aab0107b67daf436cdd25ce84cad30159b4"
|
||||
|
||||
# Used for sending MobyMask chain txs; also serves as chain pk for watcher's nitro node
|
||||
CERC_PRIVATE_KEY_PEER="111b7500bdce494d6f4bcfe8c2a0dde2ef92f751d9070fac6475dbd6d8021b3f"
|
||||
|
||||
# Ponder app's nitro node credentials
|
||||
CERC_PONDER_NITRO_PK=58368d20ff12f17669c06158c21d885897aa56f9be430edc789614bf9851d53f
|
||||
CERC_PONDER_NITRO_CHAIN_PK=fb1e9af328c283ca3e2486e7c24d13582b7912057d8b9542ff41503c85bc05c0
|
||||
|
||||
# Used by watcher and ponder app for sending upstream payments
|
||||
CERC_UPSTREAM_NITRO_ADDRESS="0xAAA6628Ec44A8a742987EF3A114dDFE2D4F7aDCE" # corresponds to NITRO_PK
|
||||
CERC_UPSTREAM_NITRO_MULTIADDR="/dns4/go-nitro/tcp/5005/ws/p2p/16Uiu2HAmSjXJqsyBJgcBUU2HQmykxGseafSatbpq5471XmuaUqyv"
|
||||
|
||||
# Used by the the MobyMask app to make payments to watcher
|
||||
CERC_PAYMENT_NITRO_ADDRESS="0xBBB676f9cFF8D242e9eaC39D063848807d3D1D94" # corresponds to CERC_WATCHER_NITRO_PK
|
@ -16,15 +16,14 @@ laconic-so --stack fixturenet-payments build-containers
|
||||
|
||||
## Deploy
|
||||
|
||||
### Configuration
|
||||
|
||||
Deploy the stack:
|
||||
|
||||
```bash
|
||||
laconic-so --stack fixturenet-payments deploy --cluster payments up
|
||||
|
||||
# Exposed on host ports:
|
||||
# 5005: go-nitro node's p2p msg port
|
||||
# 4005: go-nitro node's RPC endpoint
|
||||
# 5005: go-nitro node's p2p endpoint
|
||||
# 8081: reverse payment proxy's RPC endpoint
|
||||
# 15432: MobyMask v3 watcher's db endpoint
|
||||
# 3001: MobyMask v3 watcher endpoint
|
||||
@ -33,23 +32,9 @@ laconic-so --stack fixturenet-payments deploy --cluster payments up
|
||||
# 3004: MobyMask v3 app
|
||||
```
|
||||
|
||||
Check the logs of the MobyMask contract deployment container to get the deployed contract's address and generated root invite link:
|
||||
## Demo
|
||||
|
||||
```bash
|
||||
docker logs -f $(docker ps -aq --filter name="mobymask-1")
|
||||
```
|
||||
|
||||
Check the reverse payment proxy container logs:
|
||||
|
||||
```bash
|
||||
docker logs -f $(docker ps -aq --filter name="nitro-reverse-payment-proxy")
|
||||
```
|
||||
|
||||
Run the ponder app:
|
||||
|
||||
```bash
|
||||
docker exec -it payments-ponder-app-1 bash -c "pnpm start"
|
||||
```
|
||||
Follow the [demo](./demo.md) to try out end-to-end payments
|
||||
|
||||
## Clean up
|
||||
|
||||
|
216
app/data/stacks/fixturenet-payments/demo.md
Normal file
216
app/data/stacks/fixturenet-payments/demo.md
Normal file
@ -0,0 +1,216 @@
|
||||
# Demo
|
||||
|
||||
## MobyMask Watcher
|
||||
|
||||
* Check watcher logs and wait for the payment channel to be created with upstream go-nitro node:
|
||||
|
||||
```bash
|
||||
docker logs -f $(docker ps -aq --filter name="mobymask-watcher-server")
|
||||
|
||||
# Expected output:
|
||||
# vulcanize:server Using rpcProviderEndpoint as chain URL for Nitro node +0ms
|
||||
# ...
|
||||
# ts-nitro:util:nitro Ledger channel created with id 0x65703ccdfacab09ac35367bdbe6c5a337e7a6651aad526807607b1c59b28bc1e
|
||||
# ...
|
||||
# ts-nitro:util:nitro Virtual payment channel created with id 0x29ff1335d73391a50e8fde3e9b34f00c3d81c39ddc7f89187f44dd51df96140e
|
||||
```
|
||||
|
||||
* Export the payment channel id to a variable:
|
||||
|
||||
```bash
|
||||
export WATCHER_UPSTREAM_PAYMENT_CHANNEL=<PAYMENT_CHANNEL_ID>
|
||||
```
|
||||
|
||||
* Generate an auth token required to query the go-nitro node's RPC endpoint:
|
||||
|
||||
```bash
|
||||
export AUTH_TOKEN=$(curl -s -X POST -H "Content-Type: application/json" --data '{
|
||||
"jsonrpc": "2.0", "id": 1,
|
||||
"method": "get_auth_token",
|
||||
"params": {}
|
||||
}' http://127.0.0.1:4005/api/v1 | jq -r '.result')
|
||||
```
|
||||
|
||||
* Check the payment channel status:
|
||||
|
||||
```bash
|
||||
curl -X POST -H "Content-Type: application/json" --data "{
|
||||
\"jsonrpc\": \"2.0\", \"id\": 1,
|
||||
\"method\": \"get_payment_channel\",
|
||||
\"params\": { \"authtoken\": \"$AUTH_TOKEN\", \"payload\": { \"Id\": \"$WATCHER_UPSTREAM_PAYMENT_CHANNEL\" } }
|
||||
}" http://127.0.0.1:4005/api/v1 | jq
|
||||
|
||||
# Expected output:
|
||||
# {
|
||||
# "jsonrpc": "2.0",
|
||||
# "id": 1,
|
||||
# "result": {
|
||||
# "ID": "0xfe1231722d6c2cd7af8606afe039582ebc438ee5ca2b956f8284cb497597583f",
|
||||
# "Status": "Open",
|
||||
# "Balance": {
|
||||
# "AssetAddress": "0x0000000000000000000000000000000000000000",
|
||||
# "Payee": "0xaaa6628ec44a8a742987ef3a114ddfe2d4f7adce",
|
||||
# "Payer": "0xbbb676f9cff8d242e9eac39d063848807d3d1d94",
|
||||
# "PaidSoFar": "0x0",
|
||||
# "RemainingFunds": "0x3b9aca00"
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
```
|
||||
|
||||
## MobyMask App
|
||||
|
||||
* Track the reverse payment proxy container logs in a terminal:
|
||||
|
||||
```bash
|
||||
docker logs -f $(docker ps -aq --filter name="nitro-reverse-payment-proxy")
|
||||
```
|
||||
|
||||
* Get the geth node’s port mapped to host:
|
||||
|
||||
```bash
|
||||
docker port payments-fixturenet-eth-geth-1-1 8545
|
||||
```
|
||||
|
||||
* In MetaMask Flask, add a custom network with the following settings:
|
||||
|
||||
```bash
|
||||
# New RPC URL
|
||||
http://127.0.0.1:<GETH_PORT>
|
||||
|
||||
# Chain ID
|
||||
1212
|
||||
|
||||
# Currency symbol
|
||||
ETH
|
||||
```
|
||||
|
||||
* Import the faucet account in MetaMask and fund an additional account for usage in the app:
|
||||
|
||||
```bash
|
||||
# Faucet PK
|
||||
# 0x570b909da9669b2f35a0b1ac70b8358516d55ae1b5b3710e95e9a94395090597
|
||||
|
||||
# Clear activity tab for the accounts on chain restart
|
||||
```
|
||||
|
||||
* Get the generated root invite link for the app from MobyMask contract deployment container logs:
|
||||
|
||||
```bash
|
||||
docker logs -f $(docker ps -aq --filter name="mobymask-1")
|
||||
|
||||
# Expected output:
|
||||
# ...
|
||||
# "key": "0x60e706fda4639fe0a8eb102cb0ce81231cf6e819f41cb4eadf72d865ea4c11ad"
|
||||
# }
|
||||
# http://127.0.0.1:3004/#/members?invitation=<INVITATION>
|
||||
```
|
||||
|
||||
* Open app in a browser using the invite link
|
||||
|
||||
* Run the following in the browser console to enable logs:
|
||||
|
||||
```bash
|
||||
localStorage.debug = 'ts-nitro:*'
|
||||
# Refresh the tab for taking effect
|
||||
```
|
||||
|
||||
* In the app’s debug panel, check that the peer gets connected to relay node and watcher peer
|
||||
|
||||
* Open the `NITRO` tab in debug panel
|
||||
* Click on `Connect Wallet` to connect to MetaMask (make sure that the newly funded account is active)
|
||||
* Click on `Connect Snap` to install/connect snap
|
||||
|
||||
* Perform `DIRECT FUND` with the preset amount
|
||||
|
||||
* Perform `VIRTUAL FUND` with amount set to `10000`
|
||||
|
||||
* Perform phisher status check queries now that a payment channel is created:
|
||||
* Check the watcher logs for received payments
|
||||
* Check the payment proxy server logs for charged RPC requests (`eth_getBlockByHash`, `eth_getStorageAt`) made from watcher to upstream ETH server
|
||||
|
||||
* Change the amount besides `PAY` button to `>=100` for phisher reports next
|
||||
|
||||
* Perform a phisher report and check the watcher logs for received payments; the RPC mutation request is sent to geth node and is not charged
|
||||
|
||||
* Check the watcher - eth-server payment channel status after a few requests:
|
||||
|
||||
```bash
|
||||
curl -X POST -H "Content-Type: application/json" --data "{
|
||||
\"jsonrpc\": \"2.0\", \"id\": 1,
|
||||
\"method\": \"get_payment_channel\",
|
||||
\"params\": { \"authtoken\": \"$AUTH_TOKEN\", \"payload\": { \"Id\": \"$WATCHER_UPSTREAM_PAYMENT_CHANNEL\" } }
|
||||
}" http://127.0.0.1:4005/api/v1 | jq
|
||||
|
||||
# Expected output ('PaidSoFar' should be non zero):
|
||||
# {
|
||||
# "jsonrpc": "2.0",
|
||||
# "id": 1,
|
||||
# "result": {
|
||||
# "ID": "0xfe1231722d6c2cd7af8606afe039582ebc438ee5ca2b956f8284cb497597583f",
|
||||
# "Status": "Open",
|
||||
# "Balance": {
|
||||
# "AssetAddress": "0x0000000000000000000000000000000000000000",
|
||||
# "Payee": "0xaaa6628ec44a8a742987ef3a114ddfe2d4f7adce",
|
||||
# "Payer": "0xbbb676f9cff8d242e9eac39d063848807d3d1d94",
|
||||
# "PaidSoFar": "0x2710",
|
||||
# "RemainingFunds": "0x3b9aa2f0"
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
```
|
||||
|
||||
## Ponder App
|
||||
|
||||
* Run the ponder app in it's container:
|
||||
|
||||
```bash
|
||||
docker exec -it payments-ponder-app-1 bash -c "pnpm start"
|
||||
|
||||
# Expected output:
|
||||
# 09:58:54.288 INFO payment Creating ledger channel with nitro node 0xAAA6628Ec44A8a742987EF3A114dDFE2D4F7aDCE
|
||||
# ...
|
||||
# 09:59:14.230 INFO payment Creating payment channel with nitro node 0xAAA6628Ec44A8a742987EF3A114dDFE2D4F7aDCE
|
||||
# ...
|
||||
# 09:59:14.329 INFO payment Using payment channel 0x10f049519bc3f862e2b26e974be8666886228f30ea54aab06e2f23718afffab0
|
||||
```
|
||||
|
||||
* Export the payment channel id to a variable:
|
||||
|
||||
```bash
|
||||
export PONDER_UPSTREAM_PAYMENT_CHANNEL=<PAYMENT_CHANNEL_ID>
|
||||
```
|
||||
|
||||
* Check the ponder - eth-server payment channel status:
|
||||
|
||||
```bash
|
||||
curl -X POST -H "Content-Type: application/json" --data "{
|
||||
\"jsonrpc\": \"2.0\", \"id\": 1,
|
||||
\"method\": \"get_payment_channel\",
|
||||
\"params\": { \"authtoken\": \"$AUTH_TOKEN\", \"payload\": { \"Id\": \"$PONDER_UPSTREAM_PAYMENT_CHANNEL\" } }
|
||||
}" http://127.0.0.1:4005/api/v1 | jq
|
||||
|
||||
# Expected output:
|
||||
# TODO
|
||||
```
|
||||
|
||||
* Check reverse payment proxy server logs for charged RPC requests made from ponder app to upstream ETH server:
|
||||
|
||||
```bash
|
||||
# Expected output:
|
||||
# ...
|
||||
# {"time":"2023-09-28T09:59:14.499841999Z","level":"DEBUG","msg":"Request cost","cost-per-byte":1,"response-length":61,"cost":61}
|
||||
# {"time":"2023-09-28T09:59:14.500060006Z","level":"DEBUG","msg":"sent message","address":"0xAAA6628Ec44A8a742987EF3A114dDFE2D4F7aDCE","method":"receive_voucher"}
|
||||
# {"time":"2023-09-28T09:59:14.501221898Z","level":"DEBUG","msg":"Received voucher","delta":5000}
|
||||
# {"time":"2023-09-28T09:59:14.501245984Z","level":"DEBUG","msg":"Destination request","url":"http://ipld-eth-server:8081/?method=eth_getLogs"}
|
||||
```
|
||||
|
||||
## Clean Up
|
||||
|
||||
* In the MobyMask app, perform `VIRTUAL DEFUND` and `DIRECT DEFUND` (in this order) for closing the payment channel created with watcher
|
||||
|
||||
* Run the following in the browser console to delete the Nitro node's data:
|
||||
|
||||
```bash
|
||||
await clearNodeStorage()
|
||||
```
|
@ -3,10 +3,10 @@ name: fixturenet-payments
|
||||
description: "Stack to demonstrate payments between various services"
|
||||
repos:
|
||||
# fixturenet repos
|
||||
- github.com/cerc-io/go-ethereum
|
||||
- github.com/cerc-io/lighthouse
|
||||
- github.com/cerc-io/ipld-eth-db
|
||||
- github.com/cerc-io/ipld-eth-server
|
||||
- git.vdb.to/cerc-io/go-ethereum@v1.11.6-statediff-v5
|
||||
- git.vdb.to/cerc-io/lighthouse
|
||||
- git.vdb.to/cerc-io/ipld-eth-db@v5
|
||||
- git.vdb.to/cerc-io/ipld-eth-server@v1.11.6-statediff-v5
|
||||
# nitro repos
|
||||
- github.com/cerc-io/ts-nitro@v0.1.12
|
||||
- github.com/cerc-io/go-nitro@v0.1.0-ts-port-0.1.4 # TODO: Update after fixes
|
||||
|
Loading…
Reference in New Issue
Block a user