Skip to content

Commit

Permalink
Add external manifest and scripts to run docker container on host mac…
Browse files Browse the repository at this point in the history
…hine
  • Loading branch information
fridrik01 committed Apr 29, 2024
1 parent 9841ec3 commit 8b53824
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 1 deletion.
12 changes: 12 additions & 0 deletions fendermint/testing/materializer/scripts/cometbft.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export FM_NETWORK=mainnet
export IPC_NETWORK=mainnet
export NETWORK=mainnet
export CMTHOME=/home/fridrik/.cometbft
export PROXY_APP=kvstore
export MONIKER=localnode
export CHAIN_ID=314159
export CMT_P2P_MAX_NUM_OUTBOUND_PEERS=0
export CMT_P2P_PEX=true
export CMT_PROXY_APP=tcp://127.0.0.1:26658
export CMT_RPC_MAX_SUBSCRIPTIONS_PER_CLIENT=1000
export CMT_RPC_MAX_SUBSCRIPTION_CLIENTS=10
31 changes: 31 additions & 0 deletions fendermint/testing/materializer/scripts/fendermint.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export FM_NETWORK=mainnet
export IPC_NETWORK=mainnet
export NETWORK=mainnet
export FM_HOME_DIR=/home/fridrik/.fendermint
export FM_ABCI__LISTEN__HOST=0.0.0.0
export FM_ETH__LISTEN__HOST=0.0.0.0
export FM_METRICS__LISTEN__HOST=0.0.0.0

export FM_ABCI__LISTEN__PORT=26658
export FM_CHAIN_NAME=/r314159/f410f4oj5b6u2olifl6m37qzvoa6xsm6hn4kz5nan2gy
export FM_DATA_DIR=/home/fridrik/.fendermint/data
export FM_ETH__LISTEN__PORT=8445
export FM_IPC__SUBNET_ID=/r314159/f410f4oj5b6u2olifl6m37qzvoa6xsm6hn4kz5nan2gy
export FM_IPC__TOPDOWN__CHAIN_HEAD_DELAY=20
export FM_IPC__TOPDOWN__EXPONENTIAL_BACK_OFF=5
export FM_IPC__TOPDOWN__EXPONENTIAL_RETRY_LIMIT=5
export FM_IPC__TOPDOWN__MAX_PROPOSAL_RANGE=100
export FM_IPC__TOPDOWN__PARENT_GATEWAY=0x6d25fbfac9e6215e03c687e54f7c74f489949eaf
export FM_IPC__TOPDOWN__PARENT_HTTP_ENDPOINT=https://filecoin-calibration.chainup.net/rpc/v1
export FM_IPC__TOPDOWN__PARENT_REGISTRY=0xc938b2b862d4ef9896e641b3f1269dabfb2d2103
export FM_IPC__TOPDOWN__POLLING_INTERVAL=10
export FM_IPC__TOPDOWN__PROPOSAL_DELAY=2
export FM_LOG_DIR=/home/fridrik/.fendermint/logs
export FM_LOG_LEVEL=info,fendermint=debug
export FM_METRICS__LISTEN__PORT=9184
export FM_RESOLVER__CONNECTION__LISTEN_ADDR=/ip4/0.0.0.0/tcp/26655
export FM_RESOLVER__NETWORK__LOCAL_KEY=/home/fridrik/.fendermint/keys/network_key.sk
export FM_SNAPSHOTS_DIR=/home/fridrik/.fendermint/snapshots
export FM_VALIDATOR_KEY__KIND=ethereum
export FM_VALIDATOR_KEY__PATH=/home/fridrik/.fendermint/keys/validator_key.sk
export RUST_BACKTRACE=1
63 changes: 63 additions & 0 deletions fendermint/testing/materializer/scripts/standalone-export.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env bash

# This script exports the standalone testnet files setup by the materializer to the guest machine so we can run them locally

set -e

fendermint_cid=$(docker ps -aqf name=moso-fendermint)
if [ -z "$fendermint_cid" ]; then
echo "Fendermint container does not exist"
exit 1
fi
echo "Fendermint container id: $fendermint_cid"

ethapi_cid=$(docker ps -aqf name=moso-ethapi)
if [ -z "$ethapi_cid" ]; then
echo "Ethapi container does not exist"
exit 1
fi
echo "Ethapi container id: $ethapi_cid"

cometbft_cid=$(docker ps -aqf name=moso-cometbft)
if [ -z "$cometbft_cid" ]; then
echo "Cometbft container does not exist"
exit 1
fi
echo "Cometbft container id: $cometbft_cid"

# Create the out directory
rm -rf out
mkdir -p out/fendermint out/cometbft

# Stop the containers
echo docker stop $fendermint_cid $ethapi_cid $cometbft_cid
docker stop $fendermint_cid $ethapi_cid $cometbft_cid

# Copy the data from the containers
docker cp $fendermint_cid:/fendermint out
docker cp $cometbft_cid:/cometbft out

rm -rf ~/.fendermint && cp -r out/fendermint ~/.fendermint
rm -rf ~/.cometbft && cp -r out/cometbft ~/.cometbft

echo "Data exported successfully"

echo "start fendermint eth api"
echo source ~/workspace/ipc/fendermint/testing/materializer/scripts/fendermint.env
echo ~/workspace/ipc/target/release/fendermint eth run
echo
echo "start fendermint"
echo source ~/workspace/ipc/fendermint/testing/materializer/scripts/fendermint.env
echo ~/workspace/ipc/target/release/fendermint run
echo
echo "start cometbft"
echo cd ~/.cometbft
echo source ~/workspace/ipc/fendermint/testing/materializer/scripts/cometbft.env
echo cometbft start


# query cometbft
# curl http://localhost:26657/status
#
# query fendermint eth api
# curl -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":0,"method":"eth_chainId","params":[]}' http://localhost:8445
3 changes: 2 additions & 1 deletion fendermint/testing/materializer/src/docker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,8 @@ impl Materializer<DockerMaterials> for DockerMaterializer {
where
's: 'a,
{
todo!("use curl or something to trigger the faucet")
//todo!("use curl or something to trigger the faucet")
Ok(())
}

async fn new_deployment<'s, 'a>(
Expand Down
33 changes: 33 additions & 0 deletions fendermint/testing/materializer/tests/manifests/external.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
accounts:
fridrik: {}

rootnet:
type: External
chain_id: 314159
deployment:
type: Existing
gateway: 0x6d25fbFac9e6215E03C687E54F7c74f489949EaF
registry: 0xc938B2B862d4Ef9896E641b3f1269DabFB2D2103
urls:
- https://filecoin-calibration.chainup.net/rpc/v1

subnets:
iceland:
creator: fridrik
validators:
fridrik: '1000000000'
balances:
fridrik: '20000000000000000000'
bottom_up_checkpoint:
period: 100
env:
FM_LOG_LEVEL: info,fendermint=debug
relayers:
nodes:
moso:
mode:
type: Validator
validator: fridrik
parent_node: "https://filecoin-calibration.chainup.net/rpc/v1"
seed_nodes: []
ethapi: true
55 changes: 55 additions & 0 deletions scripts/deploy_subnet_under_calibration_net/deploy_single_node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@


export FM_NETWORK=test
export GATEWAY=0x47C59245435cfDd7717E974d3A9F9FaE9D01730f
export REGISTRY=0xfF05a6FE75402Fd0828244AfbD591b23e30487c6

cd ipc
rm -rf test-network && mkdir test-network
rm -rf ~/.fendermint/
rm -rf ~/.cometbft
rm -rf .ipc/

mkdir -p ~/.fendermint/data
cp -r ./fendermint/app/config ~/.fendermint/config

# setup wallet
cd scripts/deploy_subnet_under_calibration_net
./prepare_local.sh

# Single Node
./target/release/ipc-cli subnet create --parent /r314159 --min-validator-stake 0.01 --min-cross-msg-fee 0 --min-validators 0 --bottomup-check-period 50 --permission-mode collateral --supply-source-kind native

export SUBNET=t410fp7ghvl5hczznloihmmxer3m27ap3iwcvrjj4uaa

# open ~/.ipc/config.toml and change the subnet id to the one you just created and the gateway and registry to the GATEWAY and REGISTRY
# open ~/.fendermint/config/config.toml and update the ipc and topdown section

./target/release/ipc-cli subnet join --subnet /r314159/${SUBNET} --collateral 0.02

# Fund an address
./target/release/ipc-cli cross-msg fund --subnet /r314159/${SUBNET} 0.01

# create genesis
cargo run -p fendermint_app --release -- genesis --genesis-file test-network/genesis.json ipc from-parent -s /r314159/${SUBNET} --parent-endpoint "https://api.calibration.node.glif.io/rpc/v1" --parent-gateway ${GATEWAY} --parent-registry ${REGISTRY}

# convert private key
cargo run -p fendermint_app --release -- key eth-to-fendermint --secret-key <path to private key> --name alice --out-dir test-network/keys
cargo run -p fendermint_app --release -- key eth-to-fendermint --secret-key /home/admin/secret_key --name alice --out-dir test-network/keys

# add account to genesis
cargo run -p fendermint_app --release -- \
genesis --genesis-file test-network/genesis.json \
add-account --public-key test-network/keys/alice.pk --balance 10 --kind ethereum

cat test-network/genesis.json

cargo run -p fendermint_app --release -- \
genesis --genesis-file test-network/genesis.json \
into-tendermint --out ~/.cometbft/config/genesis.json

cargo run -p fendermint_app --release -- \
key into-tendermint --secret-key test-network/keys/alice.sk --out ~/.cometbft/config/priv_validator_key.json


cargo run -p fendermint_app --release -- run
2 changes: 2 additions & 0 deletions scripts/deploy_subnet_under_calibration_net/prepare_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ echo "- Wallet2: $wallet2"
wallet3=$(cargo run -q -p ipc-cli --release -- wallet new --wallet-type evm | tr -d '"')
echo "- Wallet3: $wallet3"

cargo run -q -p ipc-cli --release -- wallet set-default --wallet-type evm --address $wallet1

echo "--- GO TO Calibration faucet (https://faucet.calibnet.chainsafe-fil.io/) and get some tokens for the wallets ---"

0 comments on commit 8b53824

Please sign in to comment.