Skip to content

Instantly share code, notes, and snippets.

View run-faucet.sh
#!/usr/bin/env bash
[[ -z $1 ]] && { echo "Pass [mordor|kotti] as ARG1"; exit 1; }
set -e
[[ -d $HOME/.faucet ]] && { echo "Backing up exiting .faucet datadir" && mv $HOME/.faucet $HOME/.faucet.bak; }
onexit()
{
View openrpc_doc.json
{
"info": {
"title": "Lotus RPC API",
"version": "1.2.1"
},
"methods": [
{
"deprecated": false,
"description": "```go\nfunc (c *FullNodeStruct) BeaconGetEntry(ctx context.Context, epoch abi.ChainEpoch) (*types.BeaconEntry, error) {\n\treturn c.Internal.BeaconGetEntry(ctx, epoch)\n}\n```",
"externalDocs": {
@meowsbits
meowsbits / geth-jsonrpc-transports-shell.sh
Last active Dec 7, 2020
How to hit geth's JSON RPC over different transports.
View geth-jsonrpc-transports-shell.sh
#!/usr/bin/env bash
# HTTP
curl -X POST $(curl icanhazip.com/v4):8545 --data '{"jsonrpc":"2.0","method":"trace_transaction","params":["0x552280896083bfe801a1f70c84011d1b4195a2c08d2221f80245380775cd6270"],"id":1}' -H "Content-Type: application/json
http --json POST http://localhost:8545 id:=$(date +%s) method='rpc_discover' params:='[]'
# Websocket
echo rpc.discover | websocat -B 650000 -n1 --jsonrpc ws://localhost:8546
# IPC
View geth.3.log
-- Logs begin at Mon 2020-11-16 09:00:20 CST, end at Tue 2020-12-01 07:55:24 CST. --
Dec 01 07:46:02 ubp52 systemd[1]: Starting core-geth classic service...
Dec 01 07:46:02 ubp52 sh[16822]: INFO [12-01|07:46:02.314|internal/debug/flags.go:212] Starting pprof server addr=http://127.0.0.1:6060/debug/pprof
Dec 01 07:46:02 ubp52 sh[16822]: INFO [12-01|07:46:02.314|geth/main.go:317] Starting Geth on Ethereum Classic...
Dec 01 07:46:02 ubp52 sh[16822]: INFO [12-01|07:46:02.314|cmd/utils/flags.go:1910] Enabling metrics collection
Dec 01 07:46:02 ubp52 sh[16822]: INFO [12-01|07:46:02.314|cmd/utils/flags.go:1930] Enabling stand-alone metrics HTTP endpoint address=0.0.0.0:6060
Dec 01 07:46:02 ubp52 sh[16822]: INFO [12-01|07:46:02.315|metrics/exp/exp.go:62] Starting metrics server addr=http://0.0.0.0:6060/debug/metrics
Dec 01 07:46:02 ubp52 sh[16822]: ERROR[12-01|07:46:02.315|metrics/exp/exp.go:65] Failure in running metrics server err="listen tcp
View lotus-openrpc-spec.json
{
"openrpc": "1.2.6",
"info": {
"title": "Lotus RPC API",
"version": "1.1.2+git.3ccacf2e2.dirty/generated=2020-10-30T10:50:39-05:00"
},
"methods": [
{
"name": "Filecoin.BeaconGetEntry",
"description": "```go\nfunc (c *FullNodeStruct) BeaconGetEntry(ctx context.Context, epoch abi.ChainEpoch) (*types.BeaconEntry, error) {\n\treturn c.Internal.BeaconGetEntry(ctx, epoch)\n}\n```",
View lotus-openrpc-spec.json
{
"info": {
"title": "Lotus RPC API",
"version": "1.2.1"
},
"methods": [
{
"deprecated": false,
"description": "```go\nfunc (c *FullNodeStruct) BeaconGetEntry(ctx context.Context, epoch abi.ChainEpoch) (*types.BeaconEntry, error) {\n\treturn c.Internal.BeaconGetEntry(ctx, epoch)\n}\n```",
"externalDocs": {
@meowsbits
meowsbits / coregeth_mordor.service.sh
Last active Jun 2, 2020
Example systemd unit file for running Mordor network on core-geth.
View coregeth_mordor.service.sh
#!/usr/bin/env bash
cat <<EOF > /etc/systemd/system/coregeth_mordor.service
[Unit]
Description=CoreGeth Mordor
[Service]
Type=simple
User=root
Restart=always
@meowsbits
meowsbits / geth.core.block_validator.go-block-gaslimit-max-step.diff
Created May 28, 2020
Maximized block gas limit steps for miners with strong opinions.
View geth.core.block_validator.go-block-gaslimit-max-step.diff
diff --git a/core/block_validator.go b/core/block_validator.go
index 37bea2b246..862ee952cc 100644
--- a/core/block_validator.go
+++ b/core/block_validator.go
@@ -107,34 +107,19 @@ func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateD
// ceil if the blocks are full. If the ceil is exceeded, it will always decrease
// the gas allowance.
func CalcGasLimit(parent *types.Block, gasFloor, gasCeil uint64) uint64 {
- // contrib = (parentGasUsed * 3 / 2) / 1024
- contrib := (parent.GasUsed() + parent.GasUsed()/2) / vars.GasLimitBoundDivisor
@meowsbits
meowsbits / geth.miner-hashrate-floor-monitor.js
Created May 28, 2020
When and if geth's CPU miner drops below floor hashrate, switch off and restart mining after an interval.
View geth.miner-hashrate-floor-monitor.js
var hashrateFloor = 20000;
for (;true;) {
var sleepInterval = 60;
if (!eth.mining) {
console.log(Date(), "starting miner")
miner.start();
sleepInterval = 60*10;
}
var hashrate = miner.getHashrate();
console.log(Date() , "hashrate", hashrate);
@meowsbits
meowsbits / swapfile.sh
Created May 23, 2020
Create and enable a swap file.
View swapfile.sh
# Is swap memory already in use?
root@my-computer:~$ free
total used free shared buff/cache available
Mem: 4039400 2454264 105892 1152 1479244 1346484
Swap: 0 0 0
root@my-computer:~$ touch /var/swap.img
root@my-computer:~$ chmod 600 /var/swap.img
root@my-computer:~$ swap_megabytes=1000