├── importKeys.sh ├── .gitignore ├── package.json ├── le.sh ├── validator.js ├── beaconchain.js ├── index.js ├── LICENSE ├── README.md └── proxy.js /importKeys.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ./prysm.sh validator accounts import --keys-dir=eth2_validator_keys/ 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | jwt.hex 2 | node_modules 3 | beaconchain.log 4 | geth.log 5 | prysm/ 6 | server.cert 7 | server.key 8 | yarn.lock 9 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "axios": "^1.6.8", 4 | "chalk": "^5.3.0", 5 | "cors": "^2.8.5", 6 | "ethers": "^5.7.1", 7 | "express": "^4.18.2", 8 | "http-proxy": "^1.18.1", 9 | "https": "^1.0.0", 10 | "ssl-root-cas": "^1.3.1" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /le.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | sudo certbot certonly --standalone -d rpc.scaffoldeth.io --config-dir ~/.certbot/config --logs-dir ~/.certbot/logs --work-dir ~/.certbot/work 3 | 4 | #if you run it without the dirs, it will be in /etc/letsencrypt/live/rpc.eth.build 5 | 6 | sudo cp -f ~/.certbot/config/live/rpc.scaffoldeth.io/privkey.pem server.key;sudo chmod 0777 server.key 7 | sudo cp -f ~/.certbot/config/live/rpc.scaffoldeth.io/fullchain.pem server.cert;sudo chmod 0777 server.cert 8 | -------------------------------------------------------------------------------- /validator.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | const { exec } = require('child_process'); 3 | 4 | console.log("Starting up validator node...") 5 | try{ 6 | exec('./prysm.sh validator --suggested-fee-recipient=0x34aA3F359A9D614239015126635CE7732c18fDF3 --graffiti="🛠atg.eth🔥" --wallet-dir=atg --wallet-password-file=walletPassword.txt >> ./validator.log 2>&1', (err, stdout, stderr) => { 7 | console.log(`stdout: ${stdout}`); 8 | console.log(`stderr: ${stderr}`); 9 | }) 10 | }catch(e){ 11 | console.log(e) 12 | } 13 | -------------------------------------------------------------------------------- /beaconchain.js: -------------------------------------------------------------------------------- 1 | ///home/ec2-user/go-ethereum/build/bin/geth --rpcport 48545 --allow-insecure-unlock --cache=4096 --maxpeers=50 --rpc --rpcaddr "0.0.0.0" --rpccorsdomain "*" --rpcapi="db,eth,net,web3,personal,admin,debug,miner,txpool" >> /home/ec2-user/geth.log 2>&1 & 2 | const fs = require('fs') 3 | const { exec } = require('child_process'); 4 | 5 | console.log("Starting up beaconchain...") 6 | try{ 7 | 8 | exec('./prysm.sh beacon-chain --execution-endpoint=http://localhost:8551 --jwt-secret=jwt.hex --suggested-fee-recipient=0x34aa3f359a9d614239015126635ce7732c18fdf3 >> ./beaconchain.log 2>&1', (err, stdout, stderr) => { 9 | console.log(`stdout: ${stdout}`); 10 | console.log(`stderr: ${stderr}`); 11 | }) 12 | }catch(e){ 13 | console.log(e) 14 | } 15 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | ///home/ec2-user/go-ethereum/build/bin/geth --rpcport 48545 --allow-insecure-unlock --cache=4096 --maxpeers=50 --rpc --rpcaddr "0.0.0.0" --rpccorsdomain "*" --rpcapi="db,eth,net,web3,personal,admin,debug,miner,txpool" >> /home/ec2-user/geth.log 2>&1 & 2 | const fs = require('fs') 3 | const { exec } = require('child_process'); 4 | 5 | console.log("Starting up geth node...") 6 | try{ 7 | // --http.port 48545 --http.vhosts=* --cache=4096 --maxpeers=50 --http --http.addr "0.0.0.0" --http.corsdomain "*" --http.api="db,eth,net,web3,debug,txpool" 8 | exec('geth --cache=4096 --http --http.addr "0.0.0.0" --http.port 48545 --http.vhosts=* --http.api="db,eth,net,web3,engine,admin,debug,txpool" --http.corsdomain "*" --authrpc.jwtsecret="./prysm/jwt.hex" >> ./geth.log 2>&1', (err, stdout, stderr) => { 9 | console.log(`stdout: ${stdout}`); 10 | console.log(`stderr: ${stderr}`); 11 | }) 12 | }catch(e){ 13 | console.log(e) 14 | } 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Austin Griffith 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | UBUNTU RPC (scaffold-rpc) 2 | 3 | sudo add-apt-repository -y ppa:ethereum/ethereum 4 | 5 | sudo apt-get update 6 | 7 | sudo apt-get upgrade -y 8 | 9 | // current node version 10 | 11 | curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash - 12 | 13 | // or LTS node verion 14 | 15 | curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - 16 | 17 | sudo apt install -y nodejs 18 | 19 | sudo npm i -g pm2 20 | 21 | sudo npm i yarn -g 22 | 23 | sudo apt install -y certbot 24 | 25 | sudo apt-get install -y ethereum 26 | 27 | = created geth script = 28 | 29 | git clone https://github.com/austintgriffith/geth-node-ssl-proxy 30 | 31 | cd geth-node-ssl-proxy 32 | 33 | == before you start geth you need the prysm dir in place with the jwt... 34 | 35 | ====----- add prysm ( https://docs.prylabs.network/docs/install/install-with-script ) 36 | 37 | mkdir prysm && cd prysm 38 | 39 | curl https://raw.githubusercontent.com/prysmaticlabs/prysm/master/prysm.sh --output prysm.sh && chmod +x prysm.sh 40 | 41 | openssl rand -hex 32 | tr -d "\n" > "jwt.hex" 42 | 43 | manually run prysm to crush the dialog: 44 | 45 | ./prysm.sh beacon-chain 46 | 47 | type "accept" 48 | 49 | cp ../beaconchain.js . 50 | 51 | pm2 start beaconchain.js 52 | 53 | tail -f ~/geth-node-ssl-proxy/prysm/beaconchain.log 54 | 55 | cd .. 56 | 57 | ====----- start geth 58 | 59 | pm2 start index.js --name geth 60 | 61 | tail -f ~/geth-node-ssl-proxy/geth.log 62 | 63 | pm2 startup 64 | (and then run the command it comes back with) 65 | 66 | = created proxy script = 67 | 68 | yarn add https http-proxy express cors ssl-root-cas 69 | 70 | = time for ssl = had to open port 80 but closed and then left 443 open 71 | 72 | = ec2 security group **open http for le script** and then keep only https open 73 | 74 | pm2 start proxy.js 75 | 76 | pm2 save 77 | 78 | ===----- update geth 79 | 80 | sudo apt-get update 81 | 82 | sudo apt-get install ethereum 83 | 84 | sudo apt-get upgrade geth 85 | 86 | = added admin,web3 and the jwtsecret to the geth command (index.js) 87 | 88 | = created beaconchain script to run prysm and fired it up with pm2 89 | 90 | ====----- upgrading prysm happens on the sh command BUT you need to update your db: 91 | 92 | ./prysm.sh validator db migrate down --datadir=/home/ubuntu/prysm/prysm_wallet/direct 93 | 94 | ====----- Installing nethermind 95 | 96 | // https://docs.nethermind.io/nethermind/ethereum-client/running-nethermind/running-the-client 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /proxy.js: -------------------------------------------------------------------------------- 1 | const https = require("https"); 2 | var httpProxy = require("http-proxy"); 3 | const express = require("express"); 4 | const axios = require("axios"); 5 | const fs = require("fs"); 6 | var cors = require("cors"); 7 | var bodyParser = require("body-parser"); 8 | var app = express(); 9 | const ethers = require("ethers"); 10 | https.globalAgent.options.ca = require("ssl-root-cas").create(); 11 | process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0; 12 | 13 | const localProviderUrl = "http://localhost:48545"; 14 | app.use(bodyParser.json()); 15 | app.use(cors()); 16 | //app.use(express.json()) 17 | //app.use(express.bodyParser()); 18 | //app.use(bodyParser.json()); 19 | 20 | var proxy = httpProxy.createProxyServer(); 21 | 22 | var last = ""; 23 | 24 | var memcache = {}; 25 | var methods = {}; 26 | var methodsByReferer = {}; 27 | /* 28 | setInterval(()=>{ 29 | console.log("--------------------=============------------------") 30 | var sortable = []; 31 | for (var item in memcache) { 32 | sortable.push([item, memcache[item]]); 33 | } 34 | ≈ sortable.sort(function(a, b) { 35 | return a[1] - b[1]; 36 | }); 37 | console.log(sortable) 38 | console.log("--------------------=============------------------") 39 | },60000) 40 | */ 41 | 42 | const targetUrl = "https://office.buidlguidl.com:48544"; 43 | 44 | app.post("/", (req, res) => { 45 | if (req.headers && req.headers.referer) { 46 | if (last === req.connection.remoteAddress) { 47 | //process.stdout.write("."); 48 | //process.stdout.write("-") 49 | } else { 50 | last = req.connection.remoteAddress; 51 | if (!memcache[req.headers.referer]) { 52 | memcache[req.headers.referer] = 1; 53 | process.stdout.write( 54 | "NEW SITE " + 55 | req.headers.referer + 56 | " --> " + 57 | req.connection.remoteAddress 58 | ); 59 | process.stdout.write("🪐 " + req.connection.remoteAddress); 60 | } else { 61 | memcache[req.headers.referer]++; 62 | } 63 | } 64 | } 65 | 66 | if (req.body && req.body.method) { 67 | methods[req.body.method] = methods[req.body.method] 68 | ? methods[req.body.method] + 1 69 | : 1; 70 | console.log("--> METHOD", req.body.method, "REFERER", req.headers.referer); 71 | 72 | if (!methodsByReferer[req.headers.referer]) { 73 | methodsByReferer[req.headers.referer] = {}; 74 | } 75 | 76 | methodsByReferer[req.headers.referer] && 77 | methodsByReferer[req.headers.referer][req.body.method] 78 | ? methodsByReferer[req.headers.referer][req.body.method]++ 79 | : (methodsByReferer[req.headers.referer][req.body.method] = 1); 80 | } 81 | axios 82 | .post(targetUrl, req.body, { 83 | headers: { 84 | "Content-Type": "application/json", 85 | ...req.headers, 86 | }, 87 | }) 88 | .then((response) => { 89 | console.log("POST RESPONSE", response.data); 90 | res.status(response.status).send(response.data); 91 | }) 92 | .catch((error) => { 93 | console.log("POST ERROR", error); 94 | res 95 | .status(error.response ? error.response.status : 500) 96 | .send(error.message); 97 | }); 98 | 99 | console.log("POST SERVED", req.body); 100 | }); 101 | 102 | app.get("/", (req, res) => { 103 | console.log("GET", req.headers.referer); 104 | axios 105 | .get(targetUrl, { 106 | headers: { 107 | ...req.headers, 108 | }, 109 | }) 110 | .then((response) => { 111 | console.log("GET RESPONSE", response.data); 112 | res.status(response.status).send(response.data); 113 | }) 114 | .catch((error) => { 115 | console.log("GET ERROR", error.message); 116 | res 117 | .status(error.response ? error.response.status : 500) 118 | .send(error.message); 119 | }); 120 | 121 | console.log("GET REQUEST SERVED"); 122 | }); 123 | 124 | app.get("/proxy", (req, res) => { 125 | console.log("/PROXY", req.headers.referer); 126 | res.send( 127 | "

PROXY TO:

" +
128 |       targetUrl +
129 |       "
" 130 | ); 131 | }); 132 | 133 | app.get("/methods", (req, res) => { 134 | console.log("/methods", req.headers.referer); 135 | res.send( 136 | "

methods:

" +
137 |       JSON.stringify(methods) +
138 |       "
" 139 | ); 140 | }); 141 | 142 | app.get("/methodsByReferer", (req, res) => { 143 | console.log("/methods", req.headers.referer); 144 | res.send( 145 | "

methods by referer:

" +
146 |       JSON.stringify(methodsByReferer) +
147 |       "
" 148 | ); 149 | }); 150 | 151 | app.get("/letathousandscaffoldethsbloom", (req, res) => { 152 | //if(req.headers&&req.headers.referer&&req.headers.referer.indexOf("sandbox.eth.build")>=0){ 153 | var sortable = []; 154 | for (var item in memcache) { 155 | sortable.push([item, memcache[item]]); 156 | } 157 | sortable.sort(function (a, b) { 158 | return b[1] - a[1]; 159 | }); 160 | let finalBody = ""; 161 | for (let s in sortable) { 162 | console.log(sortable[s]); 163 | finalBody += 164 | "
" + 167 | sortable[s][0] + 168 | "(" + 169 | sortable[s][1] + 170 | ")
"; 171 | } 172 | //JSON.stringify(sortable) 173 | res.send( 174 | "

RPC TRAFFIC

" +
175 |       finalBody +
176 |       "
" 177 | ); 178 | }); 179 | 180 | app.get("/sync", (req, res) => { 181 | //if(req.headers&&req.headers.referer&&req.headers.referer.indexOf("sandbox.eth.build")>=0){ 182 | console.log(" 🏷 sync "); 183 | 184 | let localProvider = new ethers.providers.JsonRpcProvider(localProviderUrl); 185 | 186 | localProvider.send("eth_syncing").then( 187 | (a, b) => { 188 | console.log("DONE", a, b, a.currentBlock); 189 | if (a === "false") { 190 | let currentBlock = ethers.BigNumber.from("" + a.currentBlock); 191 | console.log("currentBlock", currentBlock); 192 | res.send( 193 | "

SYNCING

" +
194 |             JSON.stringify(a) +
195 |             "
currentBlock
" + 196 | currentBlock.toNumber() + 197 | "" 198 | ); 199 | } else { 200 | res.send( 201 | "

IN SYNC!

"
202 |         );
203 |       }
204 |     },
205 |     (a, b) => {
206 |       console.log("REJECT", a, b);
207 |       res.send(
208 |         "

SYNC REJECT

"
209 |       );
210 |     }
211 |   );
212 | 
213 |   //JSON.stringify(sortable)
214 | });
215 | 
216 | app.get("/block", (req, res) => {
217 |   //if(req.headers&&req.headers.referer&&req.headers.referer.indexOf("sandbox.eth.build")>=0){
218 |   console.log(" 🛰 block ");
219 | 
220 |   let localProvider = new ethers.providers.JsonRpcProvider(localProviderUrl);
221 | 
222 |   localProvider.getBlockNumber().then(
223 |     (a, b) => {
224 |       console.log("DONE", a, b);
225 |       res.send(
226 |         "

BLOCK

" +
227 |           a +
228 |           "
" 229 | ); 230 | }, 231 | (a, b) => { 232 | console.log("REJECT", a, b); 233 | res.send( 234 | "

BLOCK REJECT

" +
235 |           a +
236 |           "
" 237 | ); 238 | } 239 | ); 240 | 241 | //JSON.stringify(sortable) 242 | }); 243 | 244 | https 245 | .createServer( 246 | { 247 | key: fs.readFileSync("server.key"), 248 | cert: fs.readFileSync("server.cert"), 249 | }, 250 | app 251 | ) 252 | .listen(48544, () => { 253 | console.log("Listening 48544..."); 254 | }); 255 | --------------------------------------------------------------------------------