Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add shell to run l2node #1156

Merged
merged 5 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions demo/run_chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ TEST_MNEMONIC="mind flame tobacco sense move hammer drift crime ring globe art g
BASE_DIR=~/.simapp
CHAIN_ID=sim

./L1/simd-darwin-arm64 init rollupdemo --home $BASE_DIR --chain-id $CHAIN_ID > /dev/null 2>&1
./L1/simd-darwin-arm64 keys add validator --keyring-backend=test --home $BASE_DIR --recover --account=0 <<< ${TEST_MNEMONIC} > /dev/null 2>&1
./L1/simd-darwin-arm64 keys add sequencer --keyring-backend=test --home $BASE_DIR --recover --account=1 <<< ${TEST_MNEMONIC} > /dev/null 2>&1
./L1/simd-darwin-arm64 keys add challenger --keyring-backend=test --home $BASE_DIR --recover --account=2 <<< ${TEST_MNEMONIC} > /dev/null 2>&1
./L1/simd-darwin-arm64 add-genesis-account $(./L1/simd-darwin-arm64 --home $BASE_DIR keys show validator -a --keyring-backend=test) 100000000000stake,100000000000tcony --home $BASE_DIR > /dev/null 2>&1
./L1/simd-darwin-arm64 add-genesis-account $(./L1/simd-darwin-arm64 --home $BASE_DIR keys show sequencer -a --keyring-backend=test) 100000000000stake,100000000000tcony --home $BASE_DIR > /dev/null 2>&1
./L1/simd-darwin-arm64 add-genesis-account $(./L1/simd-darwin-arm64 --home $BASE_DIR keys show challenger -a --keyring-backend=test) 100000000000stake,100000000000tcony --home $BASE_DIR > /dev/null 2>&1
./L1/simd-darwin-arm64 gentx validator 10000000000stake --keyring-backend=test --home $BASE_DIR --chain-id=$CHAIN_ID > /dev/null 2>&1
./L1/simd-darwin-arm64 collect-gentxs --home $BASE_DIR > /dev/null 2>&1
./L1/simd-darwin-arm64 init rollupdemo --home $BASE_DIR --chain-id $CHAIN_ID || exit 1
./L1/simd-darwin-arm64 keys add validator --keyring-backend=test --home $BASE_DIR --recover --account=0 <<< ${TEST_MNEMONIC} || exit 1
./L1/simd-darwin-arm64 keys add sequencer --keyring-backend=test --home $BASE_DIR --recover --account=1 <<< ${TEST_MNEMONIC} || exit 1
./L1/simd-darwin-arm64 keys add challenger --keyring-backend=test --home $BASE_DIR --recover --account=2 <<< ${TEST_MNEMONIC} || exit 1
./L1/simd-darwin-arm64 add-genesis-account $(./L1/simd-darwin-arm64 --home $BASE_DIR keys show validator -a --keyring-backend=test) 100000000000stake,100000000000tcony --home $BASE_DIR || exit 1
./L1/simd-darwin-arm64 add-genesis-account $(./L1/simd-darwin-arm64 --home $BASE_DIR keys show sequencer -a --keyring-backend=test) 100000000000stake,100000000000tcony --home $BASE_DIR || exit 1
./L1/simd-darwin-arm64 add-genesis-account $(./L1/simd-darwin-arm64 --home $BASE_DIR keys show challenger -a --keyring-backend=test) 100000000000stake,100000000000tcony --home $BASE_DIR || exit 1
./L1/simd-darwin-arm64 gentx validator 10000000000stake --keyring-backend=test --home $BASE_DIR --chain-id=$CHAIN_ID || exit 1
./L1/simd-darwin-arm64 collect-gentxs --home $BASE_DIR || exit 1

# Run chain
./L1/simd-darwin-arm64 start --rpc.laddr "tcp://127.0.0.1:26659" --home $BASE_DIR > $BASE_DIR/$CHAIN_ID.log 2>&1 &
43 changes: 43 additions & 0 deletions demo/run_l2node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

# validate arg
if [ $# -ne 1 ]; then
echo "Please enter only the sequencer's p2p ID as an argument" 1>&2
exit 1
fi

L2NODE_BINARYNAME=rollupd2
ROLLUP_NAME=test-rollup
L1_CHAIN_ID=sim
L2_CHAIN_ID=sim2
L1_KEYRING_DIR=~/.simapp
L2_KEYRING_DIR=~/.l2simapp2
NAMESPACE_ID=$(openssl rand -hex 8)
RPC_URI=http://localhost:26659
TEST_SEQUENCER_P2P_ID=$1
TEST_SEQUENCER_ADDRESS=link1twsfmuj28ndph54k4nw8crwu8h9c8mh3rtx705
DA_BLOCK_HEIGHT=1
SEQUENCER_DIR=simapp0
TEST_MNEMONIC="mind flame tobacco sense move hammer drift crime ring globe art gaze cinnamon helmet cruise special produce notable negative wait path scrap recall have"

# Reset
rm -rf $L2_KEYRING_DIR
pkill $L2NODE_BINARYNAME
rm $GOPATH/bin/$L2NODE_BINARYNAME

cd ..

# Build & rename
make build && cp -r build/simd $GOPATH/bin/$L2NODE_BINARYNAME
$L2NODE_BINARYNAME version

# Init sequencer

$L2NODE_BINARYNAME init rollupdemo --home $L2_KEYRING_DIR/$SEQUENCER_DIR --chain-id $L2_CHAIN_ID || exit 1
$L2NODE_BINARYNAME keys add validator --keyring-backend=test --home $L2_KEYRING_DIR/$SEQUENCER_DIR --recover --account=0 <<< ${TEST_MNEMONIC} || exit 1
$L2NODE_BINARYNAME add-genesis-account $($L2NODE_BINARYNAME --home $L2_KEYRING_DIR/$SEQUENCER_DIR keys show validator -a --keyring-backend=test) 100000000000stake,100000000000tcony --home $L2_KEYRING_DIR/$SEQUENCER_DIR || exit 1
$L2NODE_BINARYNAME gentx validator 10000000000stake --keyring-backend=test --home $L2_KEYRING_DIR/$SEQUENCER_DIR --chain-id=$L2_CHAIN_ID || exit 1
$L2NODE_BINARYNAME collect-gentxs --home $L2_KEYRING_DIR/$SEQUENCER_DIR || exit 1

# Run L2 sequencer
$L2NODE_BINARYNAME start --log_level "debug" --home $L2_KEYRING_DIR/$SEQUENCER_DIR --p2p.laddr "tcp://0.0.0.0:26555" --p2p.seeds="tcp://${TEST_SEQUENCER_P2P_ID}@127.0.0.1:26556" --rpc.laddr=tcp://0.0.0.0:26654 --grpc.address "0.0.0.0:9192" --grpc-web.address "0.0.0.0:9193" --rollkit.da_layer finschia --rollkit.da_config='{"rpc_uri":"'$RPC_URI'","chain_id":"'$L1_CHAIN_ID'","keyring_dir":"'$L1_KEYRING_DIR'","from":"'$TEST_SEQUENCER_ADDRESS'", "rollup_name":"'$ROLLUP_NAME'"}' --rollkit.namespace_id $NAMESPACE_ID --rollkit.da_start_height $DA_BLOCK_HEIGHT > $L2_KEYRING_DIR/$L2_CHAIN_ID.log 2>&1 &
52 changes: 44 additions & 8 deletions demo/test_sequencer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,68 @@ TEST_SEQUENCER_ADDRESS=link1twsfmuj28ndph54k4nw8crwu8h9c8mh3rtx705
SEQUENCER_DIR=simapp0
TEST_MNEMONIC="mind flame tobacco sense move hammer drift crime ring globe art gaze cinnamon helmet cruise special produce notable negative wait path scrap recall have"

# Reset
rm -rf $L2_KEYRING_DIR
pkill $L2BINARYNAME
rm $GOPATH/bin/$L2BINARYNAME

# Run L1 chain
./run_chain.sh

sleep 10

# Prepare rollup info
./prepare_rollup.sh

cd ..

# Build & rename
make build && cp -r build/simd $GOPATH/bin/$L2BINARYNAME
$L2BINARYNAME version

# Init sequencer

$L2BINARYNAME init rollupdemo --home $L2_KEYRING_DIR/$SEQUENCER_DIR --chain-id $L2_CHAIN_ID || exit 1
$L2BINARYNAME keys add validator --keyring-backend=test --home $L2_KEYRING_DIR/$SEQUENCER_DIR --recover --account=0 <<< ${TEST_MNEMONIC} || exit 1
$L2BINARYNAME add-genesis-account $($L2BINARYNAME --home $L2_KEYRING_DIR/$SEQUENCER_DIR keys show validator -a --keyring-backend=test) 100000000000stake,100000000000tcony --home $L2_KEYRING_DIR/$SEQUENCER_DIR || exit 1
$L2BINARYNAME gentx validator 10000000000stake --keyring-backend=test --home $L2_KEYRING_DIR/$SEQUENCER_DIR --chain-id=$L2_CHAIN_ID || exit 1
$L2BINARYNAME collect-gentxs --home $L2_KEYRING_DIR/$SEQUENCER_DIR || exit 1

# Run L2 sequencer
$L2BINARYNAME start --home $L2_KEYRING_DIR/$SEQUENCER_DIR --p2p.laddr "tcp://0.0.0.0:26556" --grpc.address "0.0.0.0:9190" --grpc-web.address "0.0.0.0:9191" --rollkit.sequencer "true" --rollkit.da_layer finschia --rollkit.da_config='{"rpc_uri":"'$RPC_URI'","chain_id":"'$L1_CHAIN_ID'","keyring_dir":"'$L1_KEYRING_DIR'","from":"'$TEST_SEQUENCER_ADDRESS'", "rollup_name":"'$ROLLUP_NAME'"}' --rollkit.namespace_id $NAMESPACE_ID --rollkit.da_start_height $DA_BLOCK_HEIGH > $L2_KEYRING_DIR/$L2_CHAIN_ID.log 2>&1 &
sleep 10

# Run L2 fullnode
cd ./demo
TEST_SEQUENCER_P2P_ID=$(cat $L2_KEYRING_DIR/$L2_CHAIN_ID.log | sed -n 's/.*127.0.0.1\/tcp\/26556\/p2p\/\([^ ]*\).*/\1/p')
./run_l2node.sh $TEST_SEQUENCER_P2P_ID

# Send test
${L2BINARYNAME} keys add alice --home $L2_KEYRING_DIR/$SEQUENCER_DIR --keyring-backend=test
$L2BINARYNAME keys add alice --home $L2_KEYRING_DIR/$SEQUENCER_DIR --keyring-backend=test
sleep 1
ALICE_ADDR=$(${L2BINARYNAME} keys show alice -a --home $L2_KEYRING_DIR/$SEQUENCER_DIR --keyring-backend=test)
ALICE_ADDR=$($L2BINARYNAME keys show alice -a --home $L2_KEYRING_DIR/$SEQUENCER_DIR --keyring-backend=test)
echo $ALICE_ADDR
${L2BINARYNAME} tx bank send validator $ALICE_ADDR 100stake --home $L2_KEYRING_DIR/$SEQUENCER_DIR --keyring-backend=test --chain-id $L2_CHAIN_ID -y
$L2BINARYNAME tx bank send validator $ALICE_ADDR 100stake --home $L2_KEYRING_DIR/$SEQUENCER_DIR --keyring-backend=test --chain-id $L2_CHAIN_ID -y
sleep 30

# Check alice's balance
BALANCE=$(${L2BINARYNAME} query bank balances $ALICE_ADDR --home $L2_KEYRING_DIR/$SEQUENCER_DIR --output json | jq -r '.balances[0].amount')
BALANCE=$($L2BINARYNAME query bank balances $ALICE_ADDR --home $L2_KEYRING_DIR/$SEQUENCER_DIR --output json | jq -r '.balances[0].amount')
if [ 100 -eq ${BALANCE} ]; then
echo "send success!"
else
echo "send failed..."
fi

# NOTE: There is a bug in the current Ramus that only validators can execute tx.
${L2BINARYNAME} keys add bob --home $L2_KEYRING_DIR/$SEQUENCER_DIR --keyring-backend=test
$L2BINARYNAME keys add bob --home $L2_KEYRING_DIR/$SEQUENCER_DIR --keyring-backend=test
sleep 1
BOB_ADDR=$(${L2BINARYNAME} keys show bob -a --home $L2_KEYRING_DIR/$SEQUENCER_DIR --keyring-backend=test)
BOB_ADDR=$($L2BINARYNAME keys show bob -a --home $L2_KEYRING_DIR/$SEQUENCER_DIR --keyring-backend=test)
echo $ALICE_ADDR
${L2BINARYNAME} tx bank send $ALICE_ADDR $BOB_ADDR 10stake --home $L2_KEYRING_DIR/$SEQUENCER_DIR --keyring-backend=test --chain-id $L2_CHAIN_ID -y
$L2BINARYNAME tx bank send $ALICE_ADDR $BOB_ADDR 10stake --home $L2_KEYRING_DIR/$SEQUENCER_DIR --keyring-backend=test --chain-id $L2_CHAIN_ID -y
sleep 30

# Check alice's balance
BALANCE=$(${L2BINARYNAME} query bank balances $BOB_ADDR --home $L2_KEYRING_DIR/$SEQUENCER_DIR --output json | jq -r '.balances[0].amount')
BALANCE=$($L2BINARYNAME query bank balances $BOB_ADDR --home $L2_KEYRING_DIR/$SEQUENCER_DIR --output json | jq -r '.balances[0].amount')
if [ 10 -eq ${BALANCE} ]; then
echo "send success!"
else
Expand Down