diff --git a/dappnode_package.json b/dappnode_package.json index 0d45704..5c9c922 100644 --- a/dappnode_package.json +++ b/dappnode_package.json @@ -7,18 +7,24 @@ "shortDescription": "Web3 Infrastructure The Right Way.", "description": "Instead of deploying to a single service provider, paying absurd fees for random outages and leaked data, tap into Pocket's trustless API protocol and route your requests to 1000's of independent full nodes. Available for all major blockchain networks.", "type": "service", + "architectures": ["linux/amd64"], "mainService": "pocket", "author": "DAppNode Association (https://github.com/dappnode)", - "contributors": ["eduadiez (https://github.com/eduadiez)", - "Voss (https://github.com/alexpeterson91)", + "contributors": ["Voss (https://github.com/alexpeterson91)", + "eduadiez (https://github.com/eduadiez)", "mgarciate (https://github.com/mgarciate)"], - "categories": ["Blockchain"], + "categories": ["Blockchain", "Economic incentive"], + "keywords": ["blockchain", "ethereum", "web3", "infrastructure", "pocket", "pokt", "rpc", "dappnode"], "license": "GPL-3.0", "links": { - "ui": "http://pocket.pocket.dappnode/", - "homepage": "https://www.pokt.network", - "Wallet": "https://wallet.pokt.network/", - "Explorer": "https://explorer.pokt.network/" + "ui": "http://pocket.dappnode", + "homepage": "https://pokt.network", + "Wallet": "https://wallet.pokt.network", + "Explorer": "https://poktscan.com", + "Docs": "https://docs.pokt.network", + "api": "http://pocket.dappnode:8081", + "forum": "https://forum.pokt.network", + "discord": "https://discord.gg/pokt" }, "repository": { "type": "git", @@ -48,16 +54,6 @@ "name": "keyfile", "path": "/home/app/.pocket/config/keyfile.json", "service": "pocket" - }, - { - "name": "addrbook", - "path": "/home/app/.pocket/config/addrbook.json", - "service": "pocket" - }, - { - "name": "chains_mainnet_template", - "path": "/home/app/chains_mainnet_template.json", - "service": "pocket" } ] } diff --git a/docker-compose.yml b/docker-compose.yml index 89c6a8e..943407f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,17 +1,16 @@ version: "3.5" services: pocket: - image: "pocket.pocket.dnp.dappnode.eth:0.1.0" + image: pocket.pocket.dnp.dappnode.eth:0.1.0 build: context: pocket args: UPSTREAM_VERSION: RC-0.11.1 restart: unless-stopped volumes: - - "pocket-mainnet:/home/app/.pocket/" + - pocket-mainnet:/home/app/.pocket/ ports: - - "26656:26656/udp" - - "26656:26656/tcp" + - 26656:26656/tcp environment: KEYFILE_PASSPHRASE: null NETWORK: mainnet @@ -20,6 +19,14 @@ services: ARIA2_SNAPSHOT: "Yes" PRUNED_SNAPSHOT: "Yes" COMPRESSED_SNAPSHOT: "Yes" + BACKFIRE_PREVENTION: "false" + PERSISTENT_PEERS: "" + MAX_PEERS_INBOUND: 28 + MAX_PEERS_OUTBOUND: 7 + SEEDS: >- + 7c0d7ec36db6594c1ffaa99724e1f8300bbd52d0@seed1.mainnet.pokt.network:26662,cdcf936d70726dd724e0e6a8353d8e5ba5abdd20@seed2.mainnet.pokt.network:26663,74b4322a91c4a7f3e774648d0730c1e610494691@seed3.mainnet.pokt.network:26662,b3235089ff302c9615ba661e13e601d9d6265b15@seed4.mainnet.pokt.network:26663,ab5776d1c9a50d47e30e90a0600e787d9fb74643@seed5.mainnet.pokt.network:26664,a6dec84acfe1bae887cd6c4f2eeb864fae29c9f7@seed6.mainnet.pokt.network:26664 + SESSION_ROLLOVER: "0" + ADVANCED_CONFIG: "No" EXTRA_OPTS: "" ulimits: nofile: diff --git a/pocket/Dockerfile b/pocket/Dockerfile index 4a92f7f..e057acc 100644 --- a/pocket/Dockerfile +++ b/pocket/Dockerfile @@ -1,15 +1,20 @@ -# build environment +# Build UI Environment ARG UPSTREAM_VERSION -FROM node:16.17.0-alpine as build-ui + +FROM node:18.20.3-alpine as build-ui + WORKDIR /app + COPY ui /app/ui # COPY ui/package.json ./ # COPY ui/yarn.lock ./ WORKDIR /app/ui + RUN yarn && yarn build +RUN npx update-browserslist-db@latest -#Starting with version BETA-0.10.2 of the v0 Pokt Core, the Docker package registry has been replaced by the Github Container Registry at ghcr.io/pokt-network/pocket-v0:BETA-0.10.2 +#Starting with version BETA-0.10.2 of the v0 Pokt Core, the DockerHub package registry has been replaced by the Github Container Registry at ghcr.io/pokt-network/pocket-v0:latest. FROM ghcr.io/pokt-network/pocket-v0:${UPSTREAM_VERSION} WORKDIR /home/app/ @@ -17,10 +22,10 @@ WORKDIR /home/app/ USER root # RUN apk add -u gettext curl jq nginx supervisor lz4 aria2 +RUN apk update RUN apk add -u gettext curl jq nodejs npm supervisor lz4 aria2 ADD entrypoint.sh /usr/local/bin/entrypoint.sh - ADD chains/chains_mainnet.json /home/app/.pocket/config/chains.json ADD genesis_mainnet.json /home/app/.pocket/config/genesis.json ADD config_template.json /home/app/.pocket/config/config_template.json @@ -31,11 +36,21 @@ ADD supervisord.conf /etc/supervisord/supervisord.conf ADD app.js /home/app/app.js ADD chains/chains_mainnet_template.json /home/app/chains_mainnet_template.json ADD chains/chains_testnet_template.json /home/app/chains_testnet_template.json +ADD config_template.json /home/app/config_template.json + RUN npm install express shelljs +RUN npx update-browserslist-db@latest COPY --from=build-ui /app/ui/build /home/app/build COPY dummyui /home/app/dummyui +# UI Internal +EXPOSE 80 +# RPC Proxy via HTTPS External EXPOSE 8081 +# P2P External EXPOSE 26656 +# Tendermint RPC Internal +EXPOSE 26657 + ENTRYPOINT ["entrypoint.sh"] diff --git a/pocket/app.js b/pocket/app.js index dd438a3..4638ca7 100644 --- a/pocket/app.js +++ b/pocket/app.js @@ -17,13 +17,6 @@ app.get('/version', (req, res) => { res.send(version) }) -function upoktToPokt(upokt) { - return upokt / 1000000; -} - -function poktToUpokt(pokt) { - return pokt * 1000000; -} app.get('/api/account', (req, res) => { // res.send( @@ -51,6 +44,9 @@ app.get('/api/account', (req, res) => { network: network, initialized: account != null ? true : false, node: node, + jailed: node?.jailed ?? false, + publicKey: node?.public_key ?? "Unknown", + unstakingTime: node?.unstaking_time ?? "0001-01-01T00:00:00Z", }; res.send(response); }); @@ -84,6 +80,32 @@ function checkEthereumState(url) { } } +// curl -X GET http://lighthouse-holesky.dappnode:3500/eth/v1/node/syncing -H "accept: application/json" | jq + +// % Total % Received % Xferd Average Speed Time Time Time Current +// Dload Upload Total Spent Left Speed +// 100 112 100 112 0 0 245 0 --:--:-- --:--:-- --:--:-- 245 +// { +// "data": { +// "is_syncing": false, +// "is_optimistic": false, +// "el_offline": false, +// "head_slot": "1475263", +// "sync_distance": "1" +// } +// } +function checkBeaconState(url) { + try { + const syncing = JSON.parse(shell.exec(`curl -X GET -H "accept: application/json" ${url}/eth/v1/node/syncing`).stdout.trim()); + if (syncing.data.is_syncing === false && syncing.data.is_optimistic === false && syncing.data.el_offline === false) { + return 2; + } + return 1; + } catch (error) { + return 0; + } +} + function checkNearState(url) { try { const syncing = JSON.parse(shell.exec(`curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"status","params":[],"id":1}' ${url}`).stdout.trim()); @@ -108,17 +130,24 @@ function checkAvalancheState(url) { } } -// TODO: Test Pokt State Functionality +// TODO: Test Pokt State Functionality + Remove other params commented out when successful with current params function checkPoktState(url) { try { - url = `https://pocket-pocket.${domain}` - const localHeight = JSON.parse(shell.exec(`curl -X POST -H {Content-Type:\ application/json} --json {} ${url}/v1/query/height`).stdout.trim()); - const currentHeight = JSON.parse(shell.exec(`curl https://mainnet.rpc.grove.city/v1/e6abbfca/v1/query/height`).stdout.trim()); - // const nodeHeight = JSON.parse(shell.exec(`pocket query height --datadir=/home/app/.pocket/ | tail -n +2`).stdout.trim()); - if (currentHeight.result.height - localHeight.result.height === 0) { + //url = `tcp://localhost:26657`; MUST USE HTTP for cURL to work doesn't support tcp://localhost:26657 + var newUrl = url.replace(/:8081$/, ':26657'); + //const syncing = JSON.parse(shell.exec(`curl ${newUrl}/status`).stdout.trim()); + const syncing = JSON.parse(shell.exec(`curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"status","params":[],"id":-1}' "${newUrl}"`).stdout.trim()); + //const syncing = JSON.parse(shell.exec(`curl http://localhost:26657/status`).stdout.trim()); + var prunedSnapshot = shell.exec(`echo $PRUNED_SNAPSHOT`).stdout.trim(); + //const localHeight = JSON.parse(shell.exec(`curl -X POST -H {Content-Type:\ application/json} --json {} ${url}/v1/query/height`).stdout.trim()); + //const currentHeight = JSON.parse(shell.exec(`curl https://mainnet.rpc.grove.city/v1/xxxxxxxx/v1/query/height`).stdout.trim()); + //const nodeHeight = JSON.parse(shell.exec(`pocket query height --datadir=/home/app/.pocket/ | tail -n +2`).stdout.trim()); + if (syncing.result.sync_info.catching_up === false && prunedSnapshot == 'Yes') { + return 3; + } else if (syncing.result.sync_info.catching_up === false && prunedSnapshot == 'No') { return 2; - } - return 1; + } else if (syncing.result.sync_info.catching_up === true) { + } return 1; } catch (error) { return 0; } @@ -132,9 +161,10 @@ function checkStateChain(type, url) { return checkNearState(url); case "avalanche": return checkAvalancheState(url); + case "beacon": + return checkBeaconState(url); case "pokt": - return 2; - // return checkPoktState(); + return checkPoktState(url); default: return 0; } @@ -159,7 +189,6 @@ app.get('/api/availableChains', (req, res) => { state: checkStateChain(chains[chain.id].type, chain.url), } }); - res.send(response); }) @@ -183,14 +212,23 @@ app.post('/api/replaceChains', (req, res) => { if (chainsFiltered && chainsFiltered.length > 0) { let response = JSON.stringify(chainsFiltered, null, 2); shell.exec(`echo '${response}' > /home/app/.pocket/config/chains.json`); - shell.exec(`pkill pocket`); +// shell.exec(`pkill pocket`); This should no longer be needed since the addition of the config option for hot chains reload to be set to `true` this command no longer kills the Pocket process improving performance on initial test nodes so far, with no errors without kiling the process everytime it needs to reload the chains.json file. res.send(response); } else { throw new Error("Empty json"); } }) -app.post('/api/stake', (req, res) => { +app.post('/api/unjailNode', (req, res) => { + // pocket nodes unjail [flags] + const account = shell.exec(`pocket accounts list --datadir=/home/app/.pocket/ | cut -d' ' -f2- `).stdout.trim(); + const network = shell.exec(`echo $NETWORK`).stdout.trim(); + const passphrase = shell.exec(`echo $KEYFILE_PASSPHRASE`).stdout.trim(); + const response = shell.exec(`pocket nodes unjail ${account} ${account} ${network} 10000 false --datadir=/home/app/.pocket/ --pwd ${passphrase} | tail -n +3`).stdout.trim(); + res.send(response); +}) + +app.post('/api/stakeCustodial', (req, res) => { // console.log(req.body.amount); // console.log(req.body.chains); // res.send({}); @@ -200,10 +238,18 @@ app.post('/api/stake', (req, res) => { const address = shell.exec(`pocket accounts list --datadir=/home/app/.pocket/ | cut -d' ' -f2- `).stdout.trim(); const domain = shell.exec(`echo $_DAPPNODE_GLOBAL_DOMAIN`).stdout.trim(); // https://discord.com/channels/553741558869131266/564836328202567725/967105908347895819 - const response = shell.exec(`pocket nodes stake custodial ${address} ${req.body.amount} ${req.body.chains} https://pocket-pocket.${domain}:443 ${network} 10000 false --datadir=/home/app/.pocket/ --pwd "${passphrase}" | tail -n +3`).stdout.trim(); + const response = shell.exec(`pocket nodes stake custodial ${address} ${req.body.amount} ${req.body.chains} https://pocket-pocket.${domain}:443 ${network} 10000 false --datadir=/home/app/.pocket/ --pwd ${passphrase} | tail -n +3`).stdout.trim(); res.send(response); }) +// app.post('/api/stakeNonCustodial', (req, res) => { +// // pocket nodes stake non-custodial [flags] +// const network = shell.exec(`echo $NETWORK`).stdout.trim(); +// const passphrase = shell.exec(`echo $KEYFILE_PASSPHRASE`).stdout.trim(); +// const domain = shell.exec(`echo $_DAPPNODE_GLOBAL_DOMAIN`).stdout.trim(); +// const operatorPublicKey = shell.exec().stdout.trim(); +// }) + var server = app.listen(CUSTOM_UI_HTTP_PORT, function () { var host = server.address().address; var port = server.address().port; @@ -244,5 +290,6 @@ const mainnetChains = { "03DF": {"name": "EVM AVAX DFK Subnet", "type": "avalanche"}, "A003": {"name": "Avalanche Archival", "type": "avalanche"}, "A053": {"name": "Optimism Archival", "type": "ethereum"}, -} - + "B021": {"name": "Ethereum Beacon", "type": "beacon"}, + "B081": {"name": "Holesky Beacon", "type": "beacon"}, +}; diff --git a/pocket/chains/chains_mainnet_template.json b/pocket/chains/chains_mainnet_template.json index 62cca69..a576249 100644 --- a/pocket/chains/chains_mainnet_template.json +++ b/pocket/chains/chains_mainnet_template.json @@ -33,7 +33,7 @@ }, { "id": "0053", - "url": "http://optimism.optimism.public.dappnode:8545" + "url": "http://op-node.op-node.dappnode:9545" }, { "id": "0063", @@ -61,6 +61,14 @@ }, { "id": "A053", - "url": "http://optimism.optimism.public.dappnode:8545" + "url": "http://op-node.op-node.dappnode:9545" + }, + { + "id": "B021", + "url": "http://beacon-chain.lodestar.dappnode:3500" + }, + { + "id": "B081", + "url": "http://beacon-chain.teku-holesky.dappnode:3500" } ] diff --git a/pocket/config_template.json b/pocket/config_template.json index f8b6672..4aaf231 100644 --- a/pocket/config_template.json +++ b/pocket/config_template.json @@ -2,7 +2,7 @@ "tendermint_config": { "RootDir": "/home/app/.pocket", "ProxyApp": "tcp://127.0.0.1:26658", - "Moniker": "node1-DOMAIN", + "Moniker": "${DOMAIN}", "FastSyncMode": true, "DBBackend": "goleveldb", "LevelDBOptions": { @@ -27,7 +27,7 @@ "RPC": { "RootDir": "/home/app/.pocket", "ListenAddress": "tcp://0.0.0.0:26657", - "CORSAllowedOrigins": [], + "CORSAllowedOrigins": ["*"], "CORSAllowedMethods": [ "HEAD", "GET", @@ -56,13 +56,13 @@ "RootDir": "/home/app/.pocket", "ListenAddress": "tcp://0.0.0.0:26656", "ExternalAddress": "tcp://${_DAPPNODE_GLOBAL_DOMAIN}:26656", - "Seeds": "7c0d7ec36db6594c1ffaa99724e1f8300bbd52d0@seed1.mainnet.pokt.network:26662,cdcf936d70726dd724e0e6a8353d8e5ba5abdd20@seed2.mainnet.pokt.network:26663,74b4322a91c4a7f3e774648d0730c1e610494691@seed3.mainnet.pokt.network:26662,b3235089ff302c9615ba661e13e601d9d6265b15@seed4.mainnet.pokt.network:26663", - "PersistentPeers": "", + "Seeds": "${SEEDS}", + "PersistentPeers": "${PERSISTENT_PEERS}", "UPNP": false, "AddrBook": "config/addrbook.json", "AddrBookStrict": false, "MaxNumInboundPeers": 28, - "MaxNumOutboundPeers": 16, + "MaxNumOutboundPeers": 7, "UnconditionalPeerIDs": "", "PersistentPeersMaxDialPeriod": 0, "FlushThrottleTimeout": 100000000, @@ -130,12 +130,11 @@ "data_dir": "/home/app/.pocket", "genesis_file": "genesis.json", "chains_name": "chains.json", - "session_db_name": "session", "evidence_db_name": "pocket_evidence", "tendermint_uri": "tcp://localhost:26657", "keybase_name": "pocket-keybase", "rpc_port": "8081", - "client_session_sync_allowance": 1, + "client_session_sync_allowance": 0, "client_block_sync_allowance": 10, "max_evidence_cache_entries": 500, "max_session_cache_entries": 500, @@ -147,7 +146,7 @@ "rpc_timeout": 30000, "pocket_prometheus_port": "8083", "prometheus_max_open_files": 3, - "max_claim_age_for_proof_retry": 32, + "max_claim_age_for_proof_retry": 96, "proof_prevalidation": false, "ctx_cache_size": 20, "abci_logging": false, @@ -157,6 +156,7 @@ "chains_hot_reload": true, "generate_token_on_start": false, "lean_pocket": false, - "lean_pocket_user_key_file": "lean_nodes_keys.json" + "lean_pocket_user_key_file": "lean_nodes_keys.json", + "prevent_negative_reward_claim": false } } diff --git a/pocket/dummyui/index.html b/pocket/dummyui/index.html index b430193..1ee42a1 100644 --- a/pocket/dummyui/index.html +++ b/pocket/dummyui/index.html @@ -3,7 +3,7 @@ - Downloading snapshot + Downloading Snapshot