Skip to content

Instantly share code, notes, and snippets.

#!/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()
{
{
"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 December 7, 2020 17:22
How to hit geth's JSON RPC over different transports.
#!/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
-- 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
{
"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```",
{
"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 June 2, 2020 12:22
Example systemd unit file for running Mordor network on core-geth.
#!/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 18:54
Maximized block gas limit steps for miners with strong opinions.
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 12:42
When and if geth's CPU miner drops below floor hashrate, switch off and restart mining after an interval.
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 19:04
Create and enable a swap file.
# 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