Skip to content

Commit

Permalink
Rename beacon bridge to portal_bridge and prep for 1 bridge binary (#…
Browse files Browse the repository at this point in the history
…1936)

Renaming the beacon_chain_bridge to portal_bridge and preparing
for stuffing all bridge functionality for all networks under this
  • Loading branch information
kdeme authored Dec 12, 2023
1 parent b623909 commit c99c068
Show file tree
Hide file tree
Showing 8 changed files with 302 additions and 255 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ TOOLS_CSV := $(subst $(SPACE),$(COMMA),$(TOOLS))

# Fluffy debugging tools + testing tools
FLUFFY_TOOLS := \
beacon_chain_bridge \
portal_bridge \
beacon_lc_bridge \
eth_data_exporter \
content_verifier \
Expand All @@ -75,7 +75,7 @@ FLUFFY_TOOLS := \
fcli_db
FLUFFY_TOOLS_DIRS := \
fluffy/tools/beacon_lc_bridge \
fluffy/tools/beacon_chain_bridge \
fluffy/tools/portal_bridge \
fluffy/tools
# comma-separated values for the "clean" target
FLUFFY_TOOLS_CSV := $(subst $(SPACE),$(COMMA),$(FLUFFY_TOOLS))
Expand Down
8 changes: 4 additions & 4 deletions fluffy/docs/the_fluffy_book/docs/beacon-content-bridging.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ Run a Fluffy node with the JSON-RPC API enabled.
./build/fluffy --rpc
```

Build & run the `beacon_chain_bridge`:
Build & run the `portal_bridge` for the beacon network:
```bash
make beacon_chain_bridge
make portal_bridge

TRUSTED_BLOCK_ROOT=0x1234567890123456789012345678901234567890123456789012345678901234 # Replace with trusted block root.
# --rest-url = access to beacon node API, default http://127.0.0.1:5052
./build/beacon_chain_bridge --trusted-block-root:${TRUSTED_BLOCK_ROOT} --rest-url:http://127.0.0.1:5052
./build/portal_bridge beacon --trusted-block-root:${TRUSTED_BLOCK_ROOT} --rest-url:http://127.0.0.1:5052
```

The `beacon_chain_bridge` will connect to Fluffy node over the JSON-RPC
The `portal_bridge` will connect to Fluffy node over the JSON-RPC
interface and start gossiping an `LightClientBootstrap` for
given trusted block root and gossip backfill `LightClientUpdate`s.

Expand Down
18 changes: 9 additions & 9 deletions fluffy/docs/the_fluffy_book/docs/testnet-beacon-network.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ network bridge in order to test if all nodes can do the beacon light client sync
and stay up to date with the latest head of the chain.

To accomodate this, the `launch_local_testnet.sh` script has the option to
launch the Fluffy `beacon_chain_bridge` automatically and connect it to `node0`
launch the Fluffy `portal_bridge` automatically and connect it to `node0`
of the local tesnet.

## Run the local testnet script with bridge
Expand All @@ -15,19 +15,19 @@ The `launch_local_testnet.sh` script must be launched with the
The individual nodes will be started with this `trusted-block-root` and each
node will try to start sync from this block root.

Run the following command to launch the network with the `beacon_chain_bridge`
activated.
Run the following command to launch the network with the `portal_bridge`
activated for the beacon network.

```bash
TRUSTED_BLOCK_ROOT=0x1234567890123456789012345678901234567890123456789012345678901234 # Replace with trusted block root.

# Run the script, start 8 nodes + beacon_chain_bridge
./fluffy/scripts/launch_local_testnet.sh -n8 --trusted-block-root ${TRUSTED_BLOCK_ROOT} --beacon-chain-bridge
# Run the script, start 8 nodes + portal_bridge
./fluffy/scripts/launch_local_testnet.sh -n8 --trusted-block-root ${TRUSTED_BLOCK_ROOT} --portal-bridge
```

## Run the local testnet script and launch the bridge manually

To have control over when to start or restart the `beacon_chain_bridge` on can
To have control over when to start or restart the `portal_bridge` on can
also control the bridge manually, e.g. start the testnet:

```bash
Expand All @@ -37,12 +37,12 @@ TRUSTED_BLOCK_ROOT=0x12345678901234567890123456789012345678901234567890123456789
./fluffy/scripts/launch_local_testnet.sh -n8 --trusted-block-root ${TRUSTED_BLOCK_ROOT}
```

Next, build and run the `beacon_chain_bridge`
Next, build and run the `portal_bridge` for the beacon network:

```bash
make beacon_chain_bridge
make portal_bridge

# --rpc-port 10000 = default node0
# --rest-url = access to beacon node API, default http://127.0.0.1:5052
./build/beacon_chain_bridge --trusted-block-root:${TRUSTED_BLOCK_ROOT} --rest-url:http://127.0.0.1:5052 --backfill-amount:128 --rpc-port:10000
./build/portal_bridge beacon --trusted-block-root:${TRUSTED_BLOCK_ROOT} --rest-url:http://127.0.0.1:5052 --backfill-amount:128 --rpc-port:10000
```
29 changes: 15 additions & 14 deletions fluffy/scripts/launch_local_testnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if [ ${PIPESTATUS[0]} != 4 ]; then
fi

OPTS="h:n:d"
LONGOPTS="help,nodes:,data-dir:,run-tests,log-level:,base-port:,base-rpc-port:,trusted-block-root:,beacon-chain-bridge,base-metrics-port:,reuse-existing-data-dir,timeout:,kill-old-processes"
LONGOPTS="help,nodes:,data-dir:,run-tests,log-level:,base-port:,base-rpc-port:,trusted-block-root:,portal-bridge,base-metrics-port:,reuse-existing-data-dir,timeout:,kill-old-processes"

# default values
NUM_NODES="64"
Expand All @@ -48,9 +48,10 @@ REUSE_EXISTING_DATA_DIR="0"
TIMEOUT_DURATION="0"
KILL_OLD_PROCESSES="0"
SCRIPTS_DIR="fluffy/scripts/"
BEACON_CHAIN_BRIDGE="0"
PORTAL_BRIDGE="0"
TRUSTED_BLOCK_ROOT=""
REST_URL="http://127.0.0.1:5052"
# REST_URL="http://127.0.0.1:5052"
REST_URL="http://testing.mainnet.beacon-api.nimbus.team"

print_help() {
cat <<EOF
Expand All @@ -64,7 +65,7 @@ E.g.: $(basename "$0") --nodes ${NUM_NODES} --data-dir "${DATA_DIR}" # defaults
--base-port bootstrap node's discv5 port (default: ${BASE_PORT})
--base-rpc-port bootstrap node's RPC port (default: ${BASE_RPC_PORT})
--base-metrics-port bootstrap node's metrics server port (default: ${BASE_METRICS_PORT})
--beacon-chain-bridge run a beacon chain bridge attached to the bootstrap node
--portal-bridge run a portal bridge attached to the bootstrap node
--trusted-block-root recent trusted finalized block root to initialize the consensus light client from
--run-tests when enabled run tests else use "htop" to see the fluffy processes without doing any tests
--log-level set the log level (default: ${LOG_LEVEL})
Expand Down Expand Up @@ -116,8 +117,8 @@ while true; do
TRUSTED_BLOCK_ROOT="$2"
shift 2
;;
--beacon-chain-bridge)
BEACON_CHAIN_BRIDGE="1"
--portal-bridge)
PORTAL_BRIDGE="1"
shift
;;
--base-metrics-port)
Expand Down Expand Up @@ -196,8 +197,8 @@ fi

# Build the binaries
BINARIES="fluffy"
if [[ "${BEACON_CHAIN_BRIDGE}" == "1" ]]; then
BINARIES="${BINARIES} beacon_chain_bridge"
if [[ "${PORTAL_BRIDGE}" == "1" ]]; then
BINARIES="${BINARIES} portal_bridge"
fi
$MAKE -j ${NPROC} LOG_LEVEL=TRACE ${BINARIES}

Expand Down Expand Up @@ -242,7 +243,7 @@ if [[ "${TIMEOUT_DURATION}" != "0" ]]; then
fi

PIDS=""
NUM_JOBS=$(( NUM_NODES + BEACON_CHAIN_BRIDGE ))
NUM_JOBS=$(( NUM_NODES + PORTAL_BRIDGE ))

dump_logs() {
LOG_LINES=20
Expand Down Expand Up @@ -326,17 +327,17 @@ for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do
fi
done

if [[ "$BEACON_CHAIN_BRIDGE" == "1" ]]; then
if [[ "$PORTAL_BRIDGE" == "1" ]]; then
# Give the nodes time to connect before the bridge (node 0) starts gossip
sleep 5
echo "Starting beacon chain bridge."
./build/beacon_chain_bridge \
sleep 10
echo "Starting portal bridge for beacon network."
./build/portal_bridge beacon \
--rest-url="${REST_URL}" \
--rpc-address="127.0.0.1" \
--rpc-port="${BASE_RPC_PORT}" \
--backfill-amount=128 \
${TRUSTED_BLOCK_ROOT_ARG} \
> "${DATA_DIR}/log_beacon_chain_bridge.txt" 2>&1 &
> "${DATA_DIR}/log_portal_bridge.txt" 2>&1 &

PIDS="${PIDS},$!"
fi
Expand Down
File renamed without changes.
Loading

0 comments on commit c99c068

Please sign in to comment.