Last active
June 6, 2025 11:56
-
-
Save lordshashank/fb2fbd53b5520a862bd451e3603b4718 to your computer and use it in GitHub Desktop.
Shell scripts to run filecoin locanet. Pre-requisites: Install lotus from https://lotus.filecoin.io/lotus/install/prerequisites/, and boost from https://boost.filecoin.io/getting-started
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function devnet_boost { | |
set -e | |
unset FULLNODE_API_INFO | |
rm -rf ~/.boost | |
# source devnet-env.sh | |
cd $LOTUS_EXEC_PATH | |
export FULLNODE_API_INFO=$(./lotus auth api-info --perm=admin | sed 's/^[^=]*=//') | |
echo "FULLNODE_API_INFO: $FULLNODE_API_INFO" | |
export MINER_API_INFO=$(./lotus-miner auth api-info --perm=admin | sed 's/^[^=]*=//') | |
export PSD_WALLET=$(./lotus wallet new) | |
echo "Sending 100 FIL to $PSD_WALLET" | |
export MESSAGE=$(./lotus send $PSD_WALLET 100) | |
export MESSAGE_CID=$(echo $MESSAGE | awk '{print $NF}') | |
echo "Waiting for message $MESSAGE_CID to be confirmed" | |
./lotus state wait-msg $MESSAGE_CID | |
if [ "$WITH_VERIFIED_REGISTRY" = true ]; then | |
export VRK_PKEY_MSG=$(./lotus send $VRK_PKEY 100) | |
export VRK_PKEY_MSG_CID=$(echo $VRK_PKEY_MSG | awk '{print $NF}') | |
echo "Waiting for message $VRK_PKEY_MSG_CID to be confirmed" | |
./lotus state wait-msg $VRK_PKEY_MSG_CID | |
./lotus-shed verifreg add-verifier-from-account $VRK_PKEY $PSD_WALLET 1000000000000 | |
fi | |
# ./lotus state wait-msg $(./lotus send t410fskm6vskjkirvv2dlsqjc2l34o737nljqcfsu2ji 100 | awk '{print $NF}') | |
./lotus-miner actor control set --really-do-it $PSD_WALLET | |
cd $BOOST_EXEC_PATH | |
## TODO add --nosync when PR merges | |
./boostd -vv init --nosync --api-sealer $MINER_API_INFO --api-sector-index $MINER_API_INFO --wallet-publish-storage-deals $PSD_WALLET --wallet-deal-collateral $PSD_WALLET --max-staging-deals-bytes 100000000 | |
# Modify NChunks to avoid the existing bug that corrupts data when chunking is enabled. We can delete this if that bug ever gets fixed | |
sed -i '/\[HttpDownload\]/,/\[/s/#NChunks = 5/NChunks = 1/' ~/.boost/config.toml | |
# Modify the config to set level db | |
sed -i '/\[LocalIndexDirectory.Leveldb\]/,/\[/s/#Enabled = false/Enabled = true/' ~/.boost/config.toml | |
sed -i '/\[IndexProvider.HttpPublisher\]/,/\[/s/#Enabled = false/Enabled = true/' ~/.boost/config.toml | |
# Enable HTTP publisher for IndexProvider and set PublicHostname | |
sed -i '/\[IndexProvider.HttpPublisher\]/,/\[/s/#PublicHostname = ""/PublicHostname = "127.0.0.1"/' ~/.boost/config.toml | |
# Making sealing buffer to 7 epochs as will be doing frequent sealing during testing | |
sed -i 's/ #StartEpochSealingBuffer = 480/ StartEpochSealingBuffer = 7/' ~/.boost/config.toml | |
./boostd run --nosync & | |
BOOSTD_PID=$! | |
sleep 1 | |
export LOCALHOST_MADDR=$(./boostd net listen | sed -n '/\/ip4\/127\.0\.0\.1/p') | |
export PEER_ID=$(echo $LOCALHOST_MADDR | sed 's|.*/||') | |
echo "peer id: $PEER_ID, maddr: $LOCALHOST_MADDR" | |
cd $LOTUS_EXEC_PATH | |
# Set miner addr and id to the parsed output of boostd maddr id | |
./lotus-miner actor set-addrs $LOCALHOST_MADDR | |
./lotus-miner actor set-peer-id $PEER_ID | |
# Set ask price to 0 without opening a browser! | |
curl -X POST http://localhost:8080/graphql/query \ | |
-H "Content-Type: application/json" \ | |
-H "Origin: http://localhost:8080" \ | |
-d '{"operationName":"AppStorageAskUpdateMutation","variables":{"update":{"Price":"0"}},"query":"mutation AppStorageAskUpdateMutation($update: StorageAskUpdate!) {\n storageAskUpdate(update: $update)\n}\n"}' | |
# Now wait for the boostd run process to finish | |
wait $BOOSTD_PID | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function devnet_clean { | |
rm -rf ~/.lotus | |
rm -rf ~/.lotusminer | |
rm -rf ~/.genesis-sectors | |
rm -rf ~/.boost | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function devnet_env { | |
export LOTUS_PATH="/path/to/.lotus" | |
export LOTUS_MINER_PATH="/path/to/.lotusminer" | |
export BOOST_EXEC_PATH="/path/to/boost" | |
export LOTUS_EXEC_PATH="/path/to/lotus" | |
export LOTUS_SKIP_GENESIS_CHECK="_yes_" | |
export CGO_FLAGS_ALLOW="-D__BLST_PORTABLE_" | |
export CGO_CFLAGS="-D__BLST_PORTABLE__" | |
export LOTUS_FEVM_ENABLEETHRPC="true" | |
export LOTUS_CHAININDEXER_ENABLEINDEXER="true" | |
# Setting sealing buffer to 7 epochs for faster sealing in devnet | |
export LOTUS_DEALMAKING_STARTEPOCHSEALINGBUFFER="7" | |
# public key for the Verified Registry root key | |
export VRK_PKEY="t14mad54cxkdvsfhs4flsxeq55zbi4jmr6tx7k3ai" | |
# path to the VRK key file to import wallet to grant-datacap | |
export VRK_KEY_PATH="$LOTUS_EXEC_PATH/vrk.key" | |
# Enable or disable Verified Registry logic | |
export WITH_VERIFIED_REGISTRY="false" | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function devnet_genesis { | |
# source devnet-env.sh | |
cd $LOTUS_EXEC_PATH | |
./lotus-seed pre-seal --sector-size 2KiB --num-sectors 2 | |
./lotus-seed genesis new localnet.json | |
./lotus-seed genesis set-vrk --account $VRK_PKEY localnet.json | |
./lotus-seed genesis add-miner localnet.json ~/.genesis-sectors/pre-seal-t01000.json | |
./lotus daemon --lotus-make-genesis=devgen.car --genesis-template=localnet.json --bootstrap=false | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function devnet_init { | |
set -e | |
unset FULLNODE_API_INFO | |
# source devnet-env.sh | |
cd $LOTUS_EXEC_PATH | |
./lotus wallet import --as-default ~/.genesis-sectors/pre-seal-t01000.key | |
if [ "$WITH_VERIFIED_REGISTRY" = true ]; then | |
echo "Importing VRK key from $VRK_KEY_PATH" | |
./lotus wallet import "$VRK_KEY_PATH" | |
fi | |
./lotus-miner init --genesis-miner --actor=t01000 --sector-size=2KiB --pre-sealed-sectors=~/.genesis-sectors --pre-sealed-metadata=~/.genesis-sectors/pre-seal-t01000.json --nosync | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function devnet_miner { | |
# source devnet-env.sh | |
cd $LOTUS_EXEC_PATH | |
./lotus-miner run --nosync | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Source the function definitions using relative paths | |
source ./devnet-boost.sh | |
source ./devnet-env.sh | |
# Expects step 1 and 2 to be completed | |
# Step 3: start boost-miner shell | |
echo "Running devnet-env" | |
devnet_env | |
echo "Running devnet-boost" | |
devnet_boost |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Source the function definitions using relative paths | |
source ./devnet-clean.sh | |
source ./devnet-env.sh | |
source ./devnet-genesis.sh | |
# Step 0: build lotus with 2k sectors when running for the first time | |
# cd /usr/local/bin/lotus | |
# make 2k | |
# Step 1: start daemon shell | |
echo "Running devnet_clean" | |
devnet_clean | |
echo "Running devnet_env" | |
devnet_env | |
echo "Running devnet_genesis" | |
devnet_genesis |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Source the function definitions using relative paths | |
source ./devnet-env.sh | |
source ./devnet-init.sh | |
source ./devnet-miner.sh | |
# Expects step 1 to be completed | |
# Step 2: start miner shell | |
echo "Running devnet-env" | |
devnet_env | |
echo "Running devnet-init" | |
devnet_init | |
echo "Running devnet-miner" | |
devnet_miner |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment