From 2745cd6a2cbe5a0a651757f9db2c79b7da762792 Mon Sep 17 00:00:00 2001 From: omerlavanet Date: Sun, 18 Aug 2024 21:22:39 +0300 Subject: [PATCH] added examples prints and script to run static provider --- .../lava_consumer_static_peers.yml | 23 ++++++++ protocol/rpcconsumer/rpcconsumer.go | 5 +- protocol/rpcprovider/rpcprovider.go | 4 ++ .../pre_setups/init_lava_static_provider.sh | 57 +++++++++++++++++++ 4 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 config/consumer_examples/lava_consumer_static_peers.yml create mode 100755 scripts/pre_setups/init_lava_static_provider.sh diff --git a/config/consumer_examples/lava_consumer_static_peers.yml b/config/consumer_examples/lava_consumer_static_peers.yml new file mode 100644 index 0000000000..5e3a6bfe5f --- /dev/null +++ b/config/consumer_examples/lava_consumer_static_peers.yml @@ -0,0 +1,23 @@ +endpoints: + - chain-id: LAV1 + api-interface: rest + network-address: 127.0.0.1:3360 + - chain-id: LAV1 + api-interface: tendermintrpc + network-address: 127.0.0.1:3361 + - chain-id: LAV1 + api-interface: grpc + network-address: 127.0.0.1:3362 +static-providers: + - api-interface: tendermintrpc + chain-id: LAV1 + node-urls: + - url: 127.0.0.1:2220 + - api-interface: grpc + chain-id: LAV1 + node-urls: + - url: 127.0.0.1:2220 + - api-interface: rest + chain-id: LAV1 + node-urls: + - url: 127.0.0.1:2220 \ No newline at end of file diff --git a/protocol/rpcconsumer/rpcconsumer.go b/protocol/rpcconsumer/rpcconsumer.go index d979a65f61..8cee4014e9 100644 --- a/protocol/rpcconsumer/rpcconsumer.go +++ b/protocol/rpcconsumer/rpcconsumer.go @@ -511,10 +511,13 @@ rpcconsumer consumer_examples/full_consumer_example.yml --cache-be "127.0.0.1:77 // check if StaticProvidersConfigName exists in viper, if it does parse it with ParseStaticProvider function var staticProviderEndpoints []*lavasession.RPCProviderEndpoint if viper.IsSet(common.StaticProvidersConfigName) { - _, err = rpcprovider.ParseEndpointsCustomName(viper.GetViper(), common.StaticProvidersConfigName, geolocation) + staticProviderEndpoints, err = rpcprovider.ParseEndpointsCustomName(viper.GetViper(), common.StaticProvidersConfigName, geolocation) if err != nil { return utils.LavaFormatError("invalid static providers definition", err) } + for _, endpoint := range staticProviderEndpoints { + utils.LavaFormatInfo("Static Provider Endpoint:", utils.Attribute{Key: "Urls", Value: endpoint.NodeUrls}, utils.Attribute{Key: "Chain ID", Value: endpoint.ChainID}, utils.Attribute{Key: "API Interface", Value: endpoint.ApiInterface}) + } } // set up the txFactory with gas adjustments and gas diff --git a/protocol/rpcprovider/rpcprovider.go b/protocol/rpcprovider/rpcprovider.go index 191ff875bc..225f175d57 100644 --- a/protocol/rpcprovider/rpcprovider.go +++ b/protocol/rpcprovider/rpcprovider.go @@ -701,6 +701,10 @@ rpcprovider 127.0.0.1:3333 OSMOSIS tendermintrpc "wss://www.node-path.com:80,htt healthCheckURLPath := viper.GetString(HealthCheckURLPathFlagName) staticProvider := viper.GetBool(common.StaticProvidersConfigName) + if staticProvider { + utils.LavaFormatWarning("Running in static provider mode, skipping rewards and allowing requests from anyone", nil) + } + rpcProviderHealthCheckMetricsOptions := rpcProviderHealthCheckMetricsOptions{ enableRelaysHealth, relaysHealthInterval, diff --git a/scripts/pre_setups/init_lava_static_provider.sh b/scripts/pre_setups/init_lava_static_provider.sh new file mode 100755 index 0000000000..c3e1b57ab3 --- /dev/null +++ b/scripts/pre_setups/init_lava_static_provider.sh @@ -0,0 +1,57 @@ +#!/bin/bash +__dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +source "$__dir"/../useful_commands.sh +. "${__dir}"/../vars/variables.sh + +LOGS_DIR=${__dir}/../../testutil/debugging/logs +mkdir -p $LOGS_DIR +rm $LOGS_DIR/*.log + +killall screen +screen -wipe + +echo "[Test Setup] installing all binaries" +make install-all + +echo "[Test Setup] setting up a new lava node" +screen -d -m -S node bash -c "./scripts/start_env_dev.sh" +screen -ls +echo "[Lavavisor Setup] sleeping 20 seconds for node to finish setup (if its not enough increase timeout)" +sleep 20 + +GASPRICE="0.00002ulava" +lavad tx gov submit-legacy-proposal spec-add ./cookbook/specs/ibc.json,./cookbook/specs/cosmoswasm.json,./cookbook/specs/tendermint.json,./cookbook/specs/cosmossdk.json,./cookbook/specs/cosmossdk_45.json,./cookbook/specs/cosmossdk_full.json,./cookbook/specs/ethermint.json,./cookbook/specs/ethereum.json,./cookbook/specs/cosmoshub.json,./cookbook/specs/lava.json,./cookbook/specs/osmosis.json,./cookbook/specs/fantom.json,./cookbook/specs/celo.json,./cookbook/specs/optimism.json,./cookbook/specs/arbitrum.json,./cookbook/specs/starknet.json,./cookbook/specs/aptos.json,./cookbook/specs/juno.json,./cookbook/specs/polygon.json,./cookbook/specs/evmos.json,./cookbook/specs/base.json,./cookbook/specs/canto.json,./cookbook/specs/sui.json,./cookbook/specs/solana.json,./cookbook/specs/bsc.json,./cookbook/specs/axelar.json,./cookbook/specs/avalanche.json,./cookbook/specs/fvm.json --lava-dev-test -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE & +wait_next_block +wait_next_block +lavad tx gov vote 1 yes -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE +sleep 4 + +# Plans proposal +lavad tx gov submit-legacy-proposal plans-add ./cookbook/plans/test_plans/default.json,./cookbook/plans/test_plans/temporary-add.json -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE +wait_next_block +wait_next_block +lavad tx gov vote 2 yes -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE + +sleep 4 + +CLIENTSTAKE="500000000000ulava" +PROVIDERSTAKE="500000000000ulava" + +PROVIDER1_LISTENER="127.0.0.1:2221" +# static configuration +PROVIDER4_LISTENER="127.0.0.1:2220" + +lavad tx subscription buy DefaultPlan $(lavad keys show user1 -a) -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE +wait_next_block +lavad tx pairing stake-provider "LAV1" $PROVIDERSTAKE "$PROVIDER1_LISTENER,1" --delegate-limit 0ulava 1 $(operator_address) -y --from servicer1 --provider-moniker "dummyMoniker" --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE + +sleep_until_next_epoch + +screen -d -m -S provider4 bash -c "source ~/.bashrc; lavap rpcprovider provider_examples/lava_example.yml\ +$EXTRA_PROVIDER_FLAGS --geolocation 1 --log_level debug --from servicer4 --static-providers --chain-id lava 2>&1 | tee $LOGS_DIR/PROVIDER4.log" && sleep 0.25 + +screen -d -m -S consumers bash -c "source ~/.bashrc; lavap rpcconsumer consumer_examples/lava_consumer_static_peers.yml \ +$EXTRA_PORTAL_FLAGS --geolocation 1 --log_level debug --from user1 --chain-id lava --allow-insecure-provider-dialing --metrics-listen-address ":7779" 2>&1 | tee $LOGS_DIR/CONSUMERS.log" && sleep 0.25 + +echo "--- setting up screens done ---" +screen -ls \ No newline at end of file