From 7ee9959bbfe605f407968ae9f76ac38384a6622a Mon Sep 17 00:00:00 2001 From: oren-lava <111131399+oren-lava@users.noreply.github.com> Date: Thu, 11 Apr 2024 09:54:25 +0300 Subject: [PATCH 1/3] feat: CNS-940: Goerli deprecation (#1359) * CNS-940: add holesky * CNS-940: added holesky to scripts * CNS-940: deprecate goerli * CNS-940: small fix --- .../full_consumer_example.yml | 7 +- config/provider_examples/all_endpoints.yml | 4 +- .../spec_add_optimism_fast_lookup.json | 19 ---- .../projects/policy_all_chains_with_addon.yml | 2 +- .../policy_all_chains_with_extension.yml | 2 +- cookbook/specs/spec_add_base.json | 44 --------- cookbook/specs/spec_add_ethereum.json | 13 ++- cookbook/specs/spec_add_optimism.json | 44 --------- cookbook/specs/spec_add_polygon.json | 44 --------- cookbook/specs/spec_add_starknet.json | 90 ------------------- scripts/cli_test.sh | 2 +- scripts/init_chain_commands.sh | 2 +- scripts/init_e2e_lava_over_lava.sh | 12 +-- scripts/setup_providers.sh | 5 +- .../e2eProviderConfigs/consumer_policy.yml | 2 +- testutil/e2e/protocolE2E.go | 6 +- 16 files changed, 30 insertions(+), 268 deletions(-) diff --git a/config/consumer_examples/full_consumer_example.yml b/config/consumer_examples/full_consumer_example.yml index 1f56efae20..dcce3d5629 100644 --- a/config/consumer_examples/full_consumer_example.yml +++ b/config/consumer_examples/full_consumer_example.yml @@ -2,7 +2,7 @@ endpoints: - chain-id: ETH1 api-interface: jsonrpc network-address: 127.0.0.1:3333 - - chain-id: GTH1 + - chain-id: SEP1 api-interface: jsonrpc network-address: 127.0.0.1:3334 - chain-id: FTM250 @@ -29,7 +29,7 @@ endpoints: - chain-id: OPTM api-interface: jsonrpc network-address: 127.0.0.1:3352 - - chain-id: BASET + - chain-id: BASES api-interface: jsonrpc network-address: 127.0.0.1:3353 - chain-id: OSMOSIS @@ -152,6 +152,9 @@ endpoints: - chain-id: AVAXT api-interface: jsonrpc network-address: 127.0.0.1:3393 + - chain-id: HOL1 + api-interface: jsonrpc + network-address: 127.0.0.1:3394 metrics-listen-address: ":7779" # referer-be-address: "http://127.0.0.1:6500" # reports-be-address: "http://127.0.0.1:6501" \ No newline at end of file diff --git a/config/provider_examples/all_endpoints.yml b/config/provider_examples/all_endpoints.yml index 4769061d7f..318b2ba133 100644 --- a/config/provider_examples/all_endpoints.yml +++ b/config/provider_examples/all_endpoints.yml @@ -6,7 +6,7 @@ endpoints: node-urls: - url: - api-interface: jsonrpc - chain-id: GTH1 + chain-id: SEP1 network-address: address: "127.0.0.1:2221" node-urls: @@ -60,7 +60,7 @@ endpoints: node-urls: - url: - api-interface: jsonrpc - chain-id: BASET + chain-id: BASES network-address: address: "127.0.0.1:2221" node-urls: diff --git a/cookbook/backups/spec_add_optimism_fast_lookup.json b/cookbook/backups/spec_add_optimism_fast_lookup.json index a2d682a718..4142efc921 100644 --- a/cookbook/backups/spec_add_optimism_fast_lookup.json +++ b/cookbook/backups/spec_add_optimism_fast_lookup.json @@ -144,25 +144,6 @@ ] } ] - }, - { - "index": "OPTMT", - "name": "optimism goerli testnet", - "enabled": true, - "imports": [ - "OPTM" - ], - "reliability_threshold": 268435455, - "data_reliability_enabled": true, - "block_distance_for_finalized_data": 1, - "blocks_in_finalization_proof": 1, - "average_block_time": 250, - "allowed_block_lag_for_qos_sync": 40, - "shares" : 1, - "min_stake_provider": { - "denom": "ulava", - "amount": "50000000000" - } } ] }, diff --git a/cookbook/projects/policy_all_chains_with_addon.yml b/cookbook/projects/policy_all_chains_with_addon.yml index 77da183cd5..e43bb2b42c 100644 --- a/cookbook/projects/policy_all_chains_with_addon.yml +++ b/cookbook/projects/policy_all_chains_with_addon.yml @@ -29,7 +29,7 @@ Policy: api_interface: "jsonrpc" type: "POST" add_on: "debug" - - chain_id: GTH1 + - chain_id: SEP1 requirements: - collection: api_interface: "jsonrpc" diff --git a/cookbook/projects/policy_all_chains_with_extension.yml b/cookbook/projects/policy_all_chains_with_extension.yml index c0d96796f7..3027db2113 100644 --- a/cookbook/projects/policy_all_chains_with_extension.yml +++ b/cookbook/projects/policy_all_chains_with_extension.yml @@ -14,7 +14,7 @@ Policy: extensions: - "archive" mixed: true - - chain_id: GTH1 + - chain_id: SEP1 requirements: - collection: api_interface: "jsonrpc" diff --git a/cookbook/specs/spec_add_base.json b/cookbook/specs/spec_add_base.json index 35b0df90af..ffc8cdc980 100644 --- a/cookbook/specs/spec_add_base.json +++ b/cookbook/specs/spec_add_base.json @@ -68,50 +68,6 @@ } ] }, - { - "index": "BASET", - "name": "base goerli testnet", - "enabled": true, - "imports": [ - "BASE" - ], - "reliability_threshold": 268435455, - "data_reliability_enabled": true, - "block_distance_for_finalized_data": 1, - "blocks_in_finalization_proof": 1, - "average_block_time": 2000, - "allowed_block_lag_for_qos_sync": 5, - "shares": 1, - "min_stake_provider": { - "denom": "ulava", - "amount": "47500000000" - }, - "api_collections": [ - { - "enabled": true, - "collection_data": { - "api_interface": "jsonrpc", - "internal_path": "", - "type": "POST", - "add_on": "" - }, - "apis": [], - "headers": [], - "inheritance_apis": [], - "parse_directives": [], - "verifications": [ - { - "name": "chain-id", - "values": [ - { - "expected_value": "0x14a33" - } - ] - } - ] - } - ] - }, { "index": "BASES", "name": "base sepolia testnet", diff --git a/cookbook/specs/spec_add_ethereum.json b/cookbook/specs/spec_add_ethereum.json index ccef2c2586..3ff1f91664 100644 --- a/cookbook/specs/spec_add_ethereum.json +++ b/cookbook/specs/spec_add_ethereum.json @@ -1357,8 +1357,8 @@ ] }, { - "index": "GTH1", - "name": "ethereum testnet goerli", + "index": "SEP1", + "name": "ethereum testnet sepolia", "enabled": true, "imports": [ "ETH1" @@ -1369,7 +1369,6 @@ "blocks_in_finalization_proof": 3, "average_block_time": 13000, "allowed_block_lag_for_qos_sync": 2, - "shares": 1, "min_stake_provider": { "denom": "ulava", "amount": "47500000000" @@ -1392,7 +1391,7 @@ "name": "chain-id", "values": [ { - "expected_value": "0x5" + "expected_value": "0xaa36a7" } ] } @@ -1401,8 +1400,8 @@ ] }, { - "index": "SEP1", - "name": "ethereum testnet sepolia", + "index": "HOL1", + "name": "ethereum testnet holesky", "enabled": true, "imports": [ "ETH1" @@ -1435,7 +1434,7 @@ "name": "chain-id", "values": [ { - "expected_value": "0xaa36a7" + "expected_value": "0x4268" } ] } diff --git a/cookbook/specs/spec_add_optimism.json b/cookbook/specs/spec_add_optimism.json index 82048f24a3..ae6b00c88e 100644 --- a/cookbook/specs/spec_add_optimism.json +++ b/cookbook/specs/spec_add_optimism.json @@ -159,50 +159,6 @@ } ] }, - { - "index": "OPTMT", - "name": "optimism goerli testnet", - "enabled": true, - "imports": [ - "OPTM" - ], - "reliability_threshold": 268435455, - "data_reliability_enabled": true, - "block_distance_for_finalized_data": 1, - "blocks_in_finalization_proof": 1, - "average_block_time": 5000, - "allowed_block_lag_for_qos_sync": 200, - "shares": 1, - "min_stake_provider": { - "denom": "ulava", - "amount": "47500000000" - }, - "api_collections": [ - { - "enabled": true, - "collection_data": { - "api_interface": "jsonrpc", - "internal_path": "", - "type": "POST", - "add_on": "" - }, - "apis": [], - "headers": [], - "inheritance_apis": [], - "parse_directives": [], - "verifications": [ - { - "name": "chain-id", - "values": [ - { - "expected_value": "0x1a4" - } - ] - } - ] - } - ] - }, { "index": "OPTMS", "name": "optimism sepolia testnet", diff --git a/cookbook/specs/spec_add_polygon.json b/cookbook/specs/spec_add_polygon.json index a39a54fdd8..39cb041c91 100644 --- a/cookbook/specs/spec_add_polygon.json +++ b/cookbook/specs/spec_add_polygon.json @@ -249,50 +249,6 @@ } ] }, - { - "index": "POLYGON1T", - "name": "polygon testnet", - "enabled": true, - "imports": [ - "POLYGON1" - ], - "reliability_threshold": 268435455, - "data_reliability_enabled": true, - "block_distance_for_finalized_data": 1, - "blocks_in_finalization_proof": 3, - "average_block_time": 2000, - "allowed_block_lag_for_qos_sync": 5, - "shares": 1, - "min_stake_provider": { - "denom": "ulava", - "amount": "47500000000" - }, - "api_collections": [ - { - "enabled": true, - "collection_data": { - "api_interface": "jsonrpc", - "internal_path": "", - "type": "POST", - "add_on": "" - }, - "apis": [], - "headers": [], - "inheritance_apis": [], - "parse_directives": [], - "verifications": [ - { - "name": "chain-id", - "values": [ - { - "expected_value": "0x13881" - } - ] - } - ] - } - ] - }, { "index": "POLYGON1A", "name": "polygon amoy testnet", diff --git a/cookbook/specs/spec_add_starknet.json b/cookbook/specs/spec_add_starknet.json index 1c33b0359f..455d13ae04 100644 --- a/cookbook/specs/spec_add_starknet.json +++ b/cookbook/specs/spec_add_starknet.json @@ -727,96 +727,6 @@ } ] }, - { - "index": "STRKT", - "name": "starknet testnet", - "enabled": true, - "imports": [ - "STRK" - ], - "reliability_threshold": 268435455, - "data_reliability_enabled": true, - "block_distance_for_finalized_data": 1, - "blocks_in_finalization_proof": 3, - "average_block_time": 1800000, - "allowed_block_lag_for_qos_sync": 1, - "shares": 1, - "min_stake_provider": { - "denom": "ulava", - "amount": "47500000000" - }, - "api_collections": [ - { - "enabled": true, - "collection_data": { - "api_interface": "jsonrpc", - "internal_path": "", - "type": "POST", - "add_on": "" - }, - "apis": [], - "headers": [], - "inheritance_apis": [], - "parse_directives": [], - "verifications": [ - { - "name": "chain-id", - "values": [ - { - "expected_value": "0x534e5f474f45524c49" - } - ] - } - ] - }, - { - "enabled": true, - "collection_data": { - "api_interface": "jsonrpc", - "internal_path": "/rpc/v0_6", - "type": "POST", - "add_on": "" - }, - "apis": [], - "headers": [], - "inheritance_apis": [], - "parse_directives": [], - "verifications": [ - { - "name": "chain-id", - "values": [ - { - "expected_value": "0x534e5f474f45524c49" - } - ] - } - ] - }, - { - "enabled": true, - "collection_data": { - "api_interface": "jsonrpc", - "internal_path": "/rpc/v0_5", - "type": "POST", - "add_on": "" - }, - "apis": [], - "headers": [], - "inheritance_apis": [], - "parse_directives": [], - "verifications": [ - { - "name": "chain-id", - "values": [ - { - "expected_value": "0x534e5f474f45524c49" - } - ] - } - ] - } - ] - }, { "index": "STRKS", "name": "starknet sepolia testnet", diff --git a/scripts/cli_test.sh b/scripts/cli_test.sh index f7bd410c6f..de2cbeece1 100755 --- a/scripts/cli_test.sh +++ b/scripts/cli_test.sh @@ -126,7 +126,7 @@ wait_count_blocks 1 >/dev/null (trace lavad tx pairing stake-provider ETH1 $PROVIDERSTAKE "$PROVIDER1_LISTENER,1" 1 $(operator_address) --provider-moniker "provider" $txoptions)>/dev/null wait_count_blocks 1 >/dev/null -CHAINS="GTH1,OSMOSIS,FTM250,CELO,LAV1,OSMOSIST,ALFAJORES,ARB1,ARBN,APT1,STRK,JUN1,COSMOSHUB,POLYGON1,EVMOS,OPTM,BASET,CANTO,SUIT,SOLANA,BSC,AXELAR,AVAX,FVM,NEAR" +CHAINS="SEP1,OSMOSIS,FTM250,CELO,LAV1,OSMOSIST,ALFAJORES,ARB1,ARBN,APT1,STRK,JUN1,COSMOSHUB,POLYGON1,EVMOS,OPTM,BASET,CANTO,SUIT,SOLANA,BSC,AXELAR,AVAX,FVM,NEAR" (trace lavad tx pairing bulk-stake-provider $CHAINS $PROVIDERSTAKE "$PROVIDER1_LISTENER,1" 1 $(operator_address) --provider-moniker "provider" $txoptions)>/dev/null sleep_until_next_epoch >/dev/null diff --git a/scripts/init_chain_commands.sh b/scripts/init_chain_commands.sh index efea65abbc..405c42ae4e 100755 --- a/scripts/init_chain_commands.sh +++ b/scripts/init_chain_commands.sh @@ -69,7 +69,7 @@ lavad tx subscription buy DefaultPlan $(lavad keys show user1 -a) --enable-auto- # lavad tx project set-policy $(lavad keys show user1 -a)-admin ./cookbook/projects/policy_all_chains_with_addon.yml -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE # MANTLE -CHAINS="ETH1,GTH1,SEP1,OSMOSIS,FTM250,CELO,LAV1,OSMOSIST,ALFAJORES,ARB1,ARBN,APT1,STRK,JUN1,COSMOSHUB,POLYGON1,EVMOS,OPTM,BASET,CANTO,SUIT,SOLANA,BSC,AXELAR,AVAX,FVM,NEAR,SQDSUBGRAPH,AGR,AGRT,KOIIT,AVAXT" +CHAINS="ETH1,SEP1,HOL1,OSMOSIS,FTM250,CELO,LAV1,OSMOSIST,ALFAJORES,ARB1,ARBN,APT1,STRK,JUN1,COSMOSHUB,POLYGON1,EVMOS,OPTM,BASES,CANTO,SUIT,SOLANA,BSC,AXELAR,AVAX,FVM,NEAR,SQDSUBGRAPH,AGR,AGRT,KOIIT,AVAXT" BASE_CHAINS="ETH1,LAV1" # stake providers on all chains echo; echo "#### Staking provider 1 ####" diff --git a/scripts/init_e2e_lava_over_lava.sh b/scripts/init_e2e_lava_over_lava.sh index e18f57fd06..1e9337af6b 100755 --- a/scripts/init_e2e_lava_over_lava.sh +++ b/scripts/init_e2e_lava_over_lava.sh @@ -7,16 +7,16 @@ GASPRICE="0.000000001ulava" NODE="http://127.0.0.1:3340/1" STAKE="500000000000ulava" -# Goerli providers -lavad tx pairing stake-provider "GTH1" $STAKE "127.0.0.1:2121,1" 1 $(operator_address) -y --from servicer1 --delegate-limit $STAKE --provider-moniker "dummyMoniker" --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE --node $NODE +# Sepolia providers +lavad tx pairing stake-provider "SEP1" $STAKE "127.0.0.1:2121,1" 1 $(operator_address) -y --from servicer1 --delegate-limit $STAKE --provider-moniker "dummyMoniker" --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE --node $NODE wait_next_block -lavad tx pairing stake-provider "GTH1" $STAKE "127.0.0.1:2122,1" 1 $(operator_address) -y --from servicer2 --delegate-limit $STAKE --provider-moniker "dummyMoniker" --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE --node $NODE +lavad tx pairing stake-provider "SEP1" $STAKE "127.0.0.1:2122,1" 1 $(operator_address) -y --from servicer2 --delegate-limit $STAKE --provider-moniker "dummyMoniker" --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE --node $NODE wait_next_block -lavad tx pairing stake-provider "GTH1" $STAKE "127.0.0.1:2123,1" 1 $(operator_address) -y --from servicer3 --delegate-limit $STAKE --provider-moniker "dummyMoniker" --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE --node $NODE +lavad tx pairing stake-provider "SEP1" $STAKE "127.0.0.1:2123,1" 1 $(operator_address) -y --from servicer3 --delegate-limit $STAKE --provider-moniker "dummyMoniker" --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE --node $NODE wait_next_block -lavad tx pairing stake-provider "GTH1" $STAKE "127.0.0.1:2124,1" 1 $(operator_address) -y --from servicer4 --delegate-limit $STAKE --provider-moniker "dummyMoniker" --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE --node $NODE +lavad tx pairing stake-provider "SEP1" $STAKE "127.0.0.1:2124,1" 1 $(operator_address) -y --from servicer4 --delegate-limit $STAKE --provider-moniker "dummyMoniker" --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE --node $NODE wait_next_block -lavad tx pairing stake-provider "GTH1" $STAKE "127.0.0.1:2125,1" 1 $(operator_address) -y --from servicer5 --delegate-limit $STAKE --provider-moniker "dummyMoniker" --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE --node $NODE +lavad tx pairing stake-provider "SEP1" $STAKE "127.0.0.1:2125,1" 1 $(operator_address) -y --from servicer5 --delegate-limit $STAKE --provider-moniker "dummyMoniker" --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE --node $NODE wait_next_block lavad tx subscription buy DefaultPlan $(lavad keys show user1 -a) -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE diff --git a/scripts/setup_providers.sh b/scripts/setup_providers.sh index 8734fc08fd..d4c0f35c75 100755 --- a/scripts/setup_providers.sh +++ b/scripts/setup_providers.sh @@ -26,7 +26,8 @@ screen -d -m -S cache-consumer bash -c "source ~/.bashrc; lavap cache 127.0.0.1: echo; echo "#### Starting provider 1 ####" screen -d -m -S provider1 bash -c "source ~/.bashrc; lavap rpcprovider \ $PROVIDER1_LISTENER ETH1 jsonrpc '$ETH_RPC_WS' \ -$PROVIDER1_LISTENER GTH1 jsonrpc '$GTH_RPC_WS' \ +$PROVIDER1_LISTENER SEP1 jsonrpc '$SEP_RPC_WS' \ +$PROVIDER1_LISTENER HOL1 jsonrpc '$HOL_RPC_WS' \ $PROVIDER1_LISTENER FTM250 jsonrpc '$FTM_RPC_HTTP' \ $PROVIDER1_LISTENER CELO jsonrpc '$CELO_HTTP' \ $PROVIDER1_LISTENER ALFAJORES jsonrpc '$CELO_ALFAJORES_HTTP' \ @@ -35,7 +36,7 @@ $PROVIDER1_LISTENER APT1 rest '$APTOS_REST' \ $PROVIDER1_LISTENER STRK jsonrpc '$STARKNET_RPC' \ $PROVIDER1_LISTENER POLYGON1 jsonrpc '$POLYGON_MAINNET_RPC' \ $PROVIDER1_LISTENER OPTM jsonrpc '$OPTIMISM_RPC' \ -$PROVIDER1_LISTENER BASET jsonrpc '$BASE_GOERLI_RPC' \ +$PROVIDER1_LISTENER BASE jsonrpc '$BASE_RPC' \ $PROVIDER1_LISTENER BSC jsonrpc '$BSC_RPC' \ $PROVIDER1_LISTENER SOLANA jsonrpc '$SOLANA_RPC' \ $PROVIDER1_LISTENER SUIT jsonrpc '$SUI_RPC' \ diff --git a/testutil/e2e/e2eProviderConfigs/consumer_policy.yml b/testutil/e2e/e2eProviderConfigs/consumer_policy.yml index 737988efd6..eff68a5824 100644 --- a/testutil/e2e/e2eProviderConfigs/consumer_policy.yml +++ b/testutil/e2e/e2eProviderConfigs/consumer_policy.yml @@ -27,7 +27,7 @@ Policy: type: "POST" add_on: "debug" mixed: true - - chain_id: GTH1 + - chain_id: SEP1 requirements: - collection: api_interface: "jsonrpc" diff --git a/testutil/e2e/protocolE2E.go b/testutil/e2e/protocolE2E.go index b315733c95..dc5d72d91a 100644 --- a/testutil/e2e/protocolE2E.go +++ b/testutil/e2e/protocolE2E.go @@ -52,7 +52,7 @@ var ( checkedPlansE2E = []string{"DefaultPlan", "EmergencyModePlan"} checkedSubscriptions = []string{"user1", "user2", "user3", "user5"} checkedSpecsE2E = []string{"LAV1", "ETH1"} - checkedSpecsE2ELOL = []string{"GTH1"} + checkedSpecsE2ELOL = []string{"SEP1"} checkedSubscriptionsLOL = []string{"user4"} ) @@ -641,7 +641,7 @@ func (lt *lavaTest) lavaOverLava(ctx context.Context) { lt.execCommand(ctx, "startJSONRPCConsumer", "07_lavaOverLava", command, true) // scripts/init_e2e.sh will: - // - produce 5 specs: ETH1, GTH1, SEP1, IBC, COSMOSSDK, LAV1 (via spec_add_{ethereum,cosmoshub,lava}) + // - produce 5 specs: ETH1, HOL1, SEP1, IBC, COSMOSSDK, LAV1 (via spec_add_{ethereum,cosmoshub,lava}) // - produce 2 plans: "DefaultPlan", "EmergencyModePlan" lt.checkStakeLava(2, 6, 4, 5, checkedPlansE2E, checkedSpecsE2ELOL, checkedSubscriptionsLOL, "Lava Over Lava Test OK") @@ -1218,7 +1218,7 @@ func runProtocolE2E(timeout time.Duration) { lt.stakeLava(ctx) // scripts/init_e2e.sh will: - // - produce 4 specs: ETH1, GTH1, SEP1, IBC, COSMOSSDK, LAV1 (via spec_add_{ethereum,cosmoshub,lava}) + // - produce 4 specs: ETH1, HOL1, SEP1, IBC, COSMOSSDK, LAV1 (via spec_add_{ethereum,cosmoshub,lava}) // - produce 2 plans: "DefaultPlan", "EmergencyModePlan" // - produce 5 staked providers (for each of ETH1, LAV1) // - produce 1 staked client (for each of ETH1, LAV1) From 77e84469e35ed669456218e4468dcd0f191d0a7a Mon Sep 17 00:00:00 2001 From: Ran Mishael <106548467+ranlavanet@users.noreply.github.com> Date: Thu, 11 Apr 2024 09:27:13 +0200 Subject: [PATCH 2/3] chore: PRT-add more info to relay timeout case (#1366) * fixing parsing bug in near * remove spam on api support jsonrpc * remove spam on tendermintrpc * add more info for no pairing available * adding debug prints to parser.go * adding more debug information to relay timeout * fix debugging scripts near * adding get method for better debugging skills * adding get method * adding get method 2 * adding get method 3 * adding get method 4 * adding get method 5 * adding get method 6 * delete unused get all providers * top ten providers for stateful calls. stateful is now limited to 10 providers each time to prevent spam and unnecessary load * increase protocol version * fix null deref --- cookbook/specs/spec_add_near.json | 7 +++-- protocol/chainlib/chainproxy/common.go | 4 +++ .../chainproxy/rpcInterfaceMessages/common.go | 4 +++ .../rpcInterfaceMessages/grpcMessage.go | 4 +++ .../rpcInterfaceMessages/jsonRPCMessage.go | 4 +++ .../rpcInterfaceMessages/restMessage.go | 4 +++ protocol/chainlib/jsonRPC.go | 3 +- protocol/chainlib/tendermintRPC.go | 3 +- protocol/lavasession/common.go | 11 -------- .../lavasession/consumer_session_manager.go | 28 +++++++++++++++++-- protocol/parser/parser.go | 17 +++++++---- protocol/parser/parser_test.go | 4 +++ protocol/rpcconsumer/rpcconsumer_server.go | 1 + .../pre_setups/init_near_only_with_node.sh | 2 +- x/protocol/types/params.go | 2 +- 15 files changed, 72 insertions(+), 26 deletions(-) diff --git a/cookbook/specs/spec_add_near.json b/cookbook/specs/spec_add_near.json index 364e7ae622..d333ddbd75 100644 --- a/cookbook/specs/spec_add_near.json +++ b/cookbook/specs/spec_add_near.json @@ -72,10 +72,11 @@ "name": "block", "block_parsing": { "parser_arg": [ - "0", - "block_id" + "block_id", + "=", + "0" ], - "parser_func": "PARSE_CANONICAL", + "parser_func": "PARSE_DICTIONARY_OR_ORDERED", "default_value": "latest" }, "compute_units": 10, diff --git a/protocol/chainlib/chainproxy/common.go b/protocol/chainlib/chainproxy/common.go index 7986126482..53b0043121 100644 --- a/protocol/chainlib/chainproxy/common.go +++ b/protocol/chainlib/chainproxy/common.go @@ -80,6 +80,10 @@ func (dri DefaultRPCInput) GetParams() interface{} { return nil } +func (dri DefaultRPCInput) GetMethod() string { + return "" +} + func (dri DefaultRPCInput) GetResult() json.RawMessage { return dri.Result } diff --git a/protocol/chainlib/chainproxy/rpcInterfaceMessages/common.go b/protocol/chainlib/chainproxy/rpcInterfaceMessages/common.go index ef924b0d62..b7c5199c62 100644 --- a/protocol/chainlib/chainproxy/rpcInterfaceMessages/common.go +++ b/protocol/chainlib/chainproxy/rpcInterfaceMessages/common.go @@ -21,6 +21,10 @@ func (pri ParsableRPCInput) GetParams() interface{} { return nil } +func (pri ParsableRPCInput) GetMethod() string { + return "" +} + func (pri ParsableRPCInput) GetResult() json.RawMessage { return pri.Result } diff --git a/protocol/chainlib/chainproxy/rpcInterfaceMessages/grpcMessage.go b/protocol/chainlib/chainproxy/rpcInterfaceMessages/grpcMessage.go index c7d5833e07..a9744c9cc7 100644 --- a/protocol/chainlib/chainproxy/rpcInterfaceMessages/grpcMessage.go +++ b/protocol/chainlib/chainproxy/rpcInterfaceMessages/grpcMessage.go @@ -92,6 +92,10 @@ func (gm GrpcMessage) GetResult() json.RawMessage { return nil } +func (gm GrpcMessage) GetMethod() string { + return gm.Path +} + func (gm GrpcMessage) NewParsableRPCInput(input json.RawMessage) (parser.RPCInput, error) { msgFactory := dynamic.NewMessageFactoryWithDefaults() if gm.methodDesc == nil { diff --git a/protocol/chainlib/chainproxy/rpcInterfaceMessages/jsonRPCMessage.go b/protocol/chainlib/chainproxy/rpcInterfaceMessages/jsonRPCMessage.go index 11e0ff49b9..b78349dd89 100644 --- a/protocol/chainlib/chainproxy/rpcInterfaceMessages/jsonRPCMessage.go +++ b/protocol/chainlib/chainproxy/rpcInterfaceMessages/jsonRPCMessage.go @@ -107,6 +107,10 @@ func (cp JsonrpcMessage) GetParams() interface{} { return cp.Params } +func (cp JsonrpcMessage) GetMethod() string { + return cp.Method +} + func (cp JsonrpcMessage) GetResult() json.RawMessage { if cp.Error != nil { utils.LavaFormatWarning("GetResult() Request got an error from the node", nil, utils.Attribute{Key: "error", Value: cp.Error}) diff --git a/protocol/chainlib/chainproxy/rpcInterfaceMessages/restMessage.go b/protocol/chainlib/chainproxy/rpcInterfaceMessages/restMessage.go index f7b51495a3..2ead66aaa3 100644 --- a/protocol/chainlib/chainproxy/rpcInterfaceMessages/restMessage.go +++ b/protocol/chainlib/chainproxy/rpcInterfaceMessages/restMessage.go @@ -78,6 +78,10 @@ func (cp RestMessage) GetResult() json.RawMessage { return nil } +func (cp RestMessage) GetMethod() string { + return cp.Path +} + // ParseBlock parses default block number from string to int func (cp RestMessage) ParseBlock(inp string) (int64, error) { return parser.ParseDefaultBlockParameter(inp) diff --git a/protocol/chainlib/jsonRPC.go b/protocol/chainlib/jsonRPC.go index 8c0f95442d..00b1b6e436 100644 --- a/protocol/chainlib/jsonRPC.go +++ b/protocol/chainlib/jsonRPC.go @@ -106,7 +106,8 @@ func (apip *JsonRPCChainParser) ParseMsg(url string, data []byte, connectionType // Check api is supported and save it in nodeMsg apiCont, err := apip.getSupportedApi(msg.Method, connectionType) if err != nil { - return nil, utils.LavaFormatWarning("getSupportedApi jsonrpc failed", err, utils.LogAttr("method", msg.Method)) + utils.LavaFormatInfo("getSupportedApi jsonrpc failed", utils.LogAttr("method", msg.Method), utils.LogAttr("error", err)) + return nil, err } apiCollectionForMessage, err := apip.getApiCollection(connectionType, apiCont.collectionKey.InternalPath, apiCont.collectionKey.Addon) diff --git a/protocol/chainlib/tendermintRPC.go b/protocol/chainlib/tendermintRPC.go index c0568e3f43..9cfa8fbdfd 100644 --- a/protocol/chainlib/tendermintRPC.go +++ b/protocol/chainlib/tendermintRPC.go @@ -137,7 +137,8 @@ func (apip *TendermintChainParser) ParseMsg(urlPath string, data []byte, connect // Check api is supported and save it in nodeMsg apiCont, err := apip.getSupportedApi(msg.Method, connectionType) if err != nil { - return nil, utils.LavaFormatWarning("getSupportedApi jsonrpc failed", err, utils.LogAttr("method", msg.Method)) + utils.LavaFormatInfo("getSupportedApi jsonrpc failed", utils.LogAttr("method", msg.Method), utils.LogAttr("error", err)) + return nil, err } apiCollectionForMessage, err := apip.getApiCollection(connectionType, apiCont.collectionKey.InternalPath, apiCont.collectionKey.Addon) diff --git a/protocol/lavasession/common.go b/protocol/lavasession/common.go index 5aeed0a0a4..00bd892fca 100644 --- a/protocol/lavasession/common.go +++ b/protocol/lavasession/common.go @@ -141,17 +141,6 @@ func GetTlsConfig(networkAddress NetworkAddressData) *tls.Config { return tlsConfig } -func GetAllProviders(allAddresses []string, ignoredProviders map[string]struct{}) (returnedProviders []string) { - for _, providerAddress := range allAddresses { - if _, ok := ignoredProviders[providerAddress]; ok { - // ignored provider, skip it - continue - } - returnedProviders = append(returnedProviders, providerAddress) - } - return returnedProviders -} - func SortByGeolocations(pairingEndpoints []*Endpoint, currentGeo planstypes.Geolocation) { latencyToGeo := func(a, b planstypes.Geolocation) uint64 { _, latency := scores.CalcGeoLatency(a, []planstypes.Geolocation{b}) diff --git a/protocol/lavasession/consumer_session_manager.go b/protocol/lavasession/consumer_session_manager.go index 418aade5dc..d552ff80ea 100644 --- a/protocol/lavasession/consumer_session_manager.go +++ b/protocol/lavasession/consumer_session_manager.go @@ -499,6 +499,30 @@ func (csm *ConsumerSessionManager) GetSessions(ctx context.Context, cuNeededForS } } +// csm must be rlocked here +func (csm *ConsumerSessionManager) getTopTenProvidersForStatefulCalls(validAddresses []string, ignoredProvidersList map[string]struct{}) []string { + // sort by cu used, easiest to sort by that factor as it probably means highest QOS and easily read by atomic + customSort := func(i, j int) bool { + return csm.pairing[validAddresses[i]].atomicReadUsedComputeUnits() > csm.pairing[validAddresses[j]].atomicReadUsedComputeUnits() + } + // Sort the slice using the custom sorting rule + sort.Slice(validAddresses, customSort) + validAddressesMaxIndex := len(validAddresses) - 1 + addresses := []string{} + for i := 0; i < 10; i++ { + // do not overflow + if i > validAddressesMaxIndex { + break + } + // skip ignored providers + if _, foundInIgnoredProviderList := ignoredProvidersList[validAddresses[i]]; foundInIgnoredProviderList { + continue + } + addresses = append(addresses, validAddresses[i]) + } + return addresses +} + // Get a valid provider address. func (csm *ConsumerSessionManager) getValidProviderAddresses(ignoredProvidersList map[string]struct{}, cu uint64, requestedBlock int64, addon string, extensions []string, stateful uint32) (addresses []string, err error) { // cs.Lock must be Rlocked here. @@ -522,7 +546,7 @@ func (csm *ConsumerSessionManager) getValidProviderAddresses(ignoredProvidersLis } var providers []string if stateful == common.CONSISTENCY_SELECT_ALL_PROVIDERS && csm.providerOptimizer.Strategy() != provideroptimizer.STRATEGY_COST { - providers = GetAllProviders(validAddresses, ignoredProvidersList) + providers = csm.getTopTenProvidersForStatefulCalls(validAddresses, ignoredProvidersList) } else { providers = csm.providerOptimizer.ChooseProvider(validAddresses, ignoredProvidersList, cu, requestedBlock, OptimizerPerturbation) } @@ -603,7 +627,7 @@ func (csm *ConsumerSessionManager) tryGetConsumerSessionWithProviderFromBlockedP } // if we got here we failed to fetch a valid provider meaning no pairing available. - return nil, utils.LavaFormatError(csm.rpcEndpoint.ChainID+" could not get a provider address from blocked provider list", PairingListEmptyError, utils.LogAttr("csm.currentlyBlockedProviderAddresses", csm.currentlyBlockedProviderAddresses), utils.LogAttr("addons", addon), utils.LogAttr("extensions", extensions)) + return nil, utils.LavaFormatError(csm.rpcEndpoint.ChainID+" could not get a provider address from blocked provider list", PairingListEmptyError, utils.LogAttr("csm.currentlyBlockedProviderAddresses", csm.currentlyBlockedProviderAddresses), utils.LogAttr("addons", addon), utils.LogAttr("extensions", extensions), utils.LogAttr("ignoredProviders", ignoredProviders.providers)) } func (csm *ConsumerSessionManager) getValidConsumerSessionsWithProvider(ignoredProviders *ignoredProviders, cuNeededForSession uint64, requestedBlock int64, addon string, extensions []string, stateful uint32, virtualEpoch uint64) (sessionWithProviderMap SessionWithProviderMap, err error) { diff --git a/protocol/parser/parser.go b/protocol/parser/parser.go index 711ce148eb..086efc3337 100644 --- a/protocol/parser/parser.go +++ b/protocol/parser/parser.go @@ -17,6 +17,7 @@ import ( const ( PARSE_PARAMS = 0 PARSE_RESULT = 1 + debug = false ) var ValueNotSetError = sdkerrors.New("Value Not Set ", 6662, "when trying to parse, the value that we attempted to parse did not exist") @@ -26,6 +27,7 @@ type RPCInput interface { GetResult() json.RawMessage ParseBlock(block string) (int64, error) GetHeaders() []pairingtypes.Metadata + GetMethod() string } func ParseDefaultBlockParameter(block string) (int64, error) { @@ -138,7 +140,7 @@ func parse(rpcInput RPCInput, blockParser spectypes.BlockParser, dataSource int) case spectypes.PARSER_FUNC_PARSE_DICTIONARY_OR_ORDERED: retval, err = parseDictionaryOrOrdered(rpcInput, blockParser.ParserArg, dataSource) case spectypes.PARSER_FUNC_DEFAULT: - retval = parseDefault(rpcInput, blockParser.ParserArg, dataSource) + retval = parseDefault(blockParser.ParserArg) default: return nil, fmt.Errorf("unsupported block parser parserFunc") } @@ -152,10 +154,14 @@ func parse(rpcInput RPCInput, blockParser spectypes.BlockParser, dataSource int) } } + if debug { + utils.LavaFormatDebug("parsed block:", utils.LogAttr("retval", retval)) + } + return retval, nil } -func parseDefault(rpcInput RPCInput, input []string, dataSource int) []interface{} { +func parseDefault(input []string) []interface{} { retArr := make([]interface{}, 0) retArr = append(retArr, input[0]) return retArr @@ -214,7 +220,6 @@ func blockInterfaceToString(block interface{}) string { return castedBlock case float64: return strconv.FormatFloat(castedBlock, 'f', -1, 64) - case int64: return strconv.FormatInt(castedBlock, 10) case uint64: @@ -287,14 +292,14 @@ func parseCanonical(rpcInput RPCInput, input []string, dataSource int) ([]interf for _, key := range input[1:] { // type assertion for blockcontainer if blockContainer, ok := blockContainer.(map[string]interface{}); !ok { - return nil, utils.LavaFormatWarning("invalid parser input format, blockContainer is not map[string]interface{}", ValueNotSetError, utils.LogAttr("blockContainer", fmt.Sprintf("%v", blockContainer)), utils.LogAttr("key", key), utils.LogAttr("unmarshaledDataTyped", unmarshaledDataTyped)) + return nil, utils.LavaFormatWarning("invalid parser input format, blockContainer is not map[string]interface{}", ValueNotSetError, utils.LogAttr("method", rpcInput.GetMethod()), utils.LogAttr("blockContainer", fmt.Sprintf("%v", blockContainer)), utils.LogAttr("key", key), utils.LogAttr("unmarshaledDataTyped", unmarshaledDataTyped)) } // assertion for key if container, ok := blockContainer.(map[string]interface{})[key]; ok { blockContainer = container } else { - return nil, utils.LavaFormatWarning("invalid parser input format, blockContainer does not have the field searched inside", ValueNotSetError, utils.LogAttr("blockContainer", fmt.Sprintf("%v", blockContainer)), utils.LogAttr("key", key), utils.LogAttr("unmarshaledDataTyped", unmarshaledDataTyped)) + return nil, utils.LavaFormatWarning("invalid parser input format, blockContainer does not have the field searched inside", ValueNotSetError, utils.LogAttr("method", rpcInput.GetMethod()), utils.LogAttr("blockContainer", fmt.Sprintf("%v", blockContainer)), utils.LogAttr("key", key), utils.LogAttr("unmarshaledDataTyped", unmarshaledDataTyped)) } } retArr := make([]interface{}, 0) @@ -432,7 +437,7 @@ func parseDictionaryOrOrdered(rpcInput RPCInput, input []string, dataSource int) } // Else return not set error - return nil, ValueNotSetError + return nil, utils.LavaFormatWarning("Failed parsing parseDictionaryOrOrdered", ValueNotSetError, utils.LogAttr("propName", propName), utils.LogAttr("inp", inp), utils.LogAttr("unmarshalledDataTyped", unmarshalledDataTyped), utils.LogAttr("method", rpcInput.GetMethod())) default: return nil, fmt.Errorf("not Supported ParseDictionary with other types: %T", unmarshalledData) } diff --git a/protocol/parser/parser_test.go b/protocol/parser/parser_test.go index ed00d61792..a39bc5ff79 100644 --- a/protocol/parser/parser_test.go +++ b/protocol/parser/parser_test.go @@ -19,6 +19,10 @@ type RPCInputTest struct { GetHeadersFunc func() []pairingtypes.Metadata } +func (rpcInputTest *RPCInputTest) GetMethod() string { + return "" +} + func (rpcInputTest *RPCInputTest) GetParams() interface{} { return rpcInputTest.Params } diff --git a/protocol/rpcconsumer/rpcconsumer_server.go b/protocol/rpcconsumer/rpcconsumer_server.go index a69debad8b..c00679a531 100644 --- a/protocol/rpcconsumer/rpcconsumer_server.go +++ b/protocol/rpcconsumer/rpcconsumer_server.go @@ -399,6 +399,7 @@ func (rpccs *RPCConsumerServer) ProcessRelaySend(ctx context.Context, directiveH case <-processingCtx.Done(): // in case we got a processing timeout we return context deadline exceeded to the user. utils.LavaFormatWarning("Relay Got processingCtx timeout", nil, + utils.LogAttr("processingTimeout", processingTimeout), utils.LogAttr("dappId", dappID), utils.LogAttr("consumerIp", consumerIp), utils.LogAttr("chainMessage.GetApi().Name", chainMessage.GetApi().Name), diff --git a/scripts/pre_setups/init_near_only_with_node.sh b/scripts/pre_setups/init_near_only_with_node.sh index 4b56228fc3..c5e9f79747 100755 --- a/scripts/pre_setups/init_near_only_with_node.sh +++ b/scripts/pre_setups/init_near_only_with_node.sh @@ -42,7 +42,7 @@ PROVIDER1_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 "NEAR" $PROVIDERSTAKE "$PROVIDER1_LISTENER,1" 1 $(operator_address) -y --from servicer1 --provider-moniker "dummyMoniker" --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE +lavad tx pairing stake-provider "NEAR" $PROVIDERSTAKE "$PROVIDER1_LISTENER,1" 1 $(operator_address) -y --from servicer1 --provider-moniker "dummyMoniker" --delegate-limit 1000ulava --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE sleep_until_next_epoch diff --git a/x/protocol/types/params.go b/x/protocol/types/params.go index ead7716231..f08a395bbe 100644 --- a/x/protocol/types/params.go +++ b/x/protocol/types/params.go @@ -12,7 +12,7 @@ import ( var _ paramtypes.ParamSet = (*Params)(nil) const ( - TARGET_VERSION = "1.2.1" + TARGET_VERSION = "1.2.2" MIN_VERSION = "1.0.2" ) From d220effb086ed502e41f4f0e5d0362b4d8a1ddd2 Mon Sep 17 00:00:00 2001 From: Denis Policastro Date: Thu, 11 Apr 2024 05:39:22 -0300 Subject: [PATCH 3/3] docs: update docker README (#1341) Co-authored-by: Yaroms <103432884+Yaroms@users.noreply.github.com> --- docker/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/README.md b/docker/README.md index cdc0794f7e..faba5bca55 100644 --- a/docker/README.md +++ b/docker/README.md @@ -10,7 +10,7 @@ 2. Build the lava docker image locally ``` # to build from the current checked-out code: - make docker-build + LAVA_BINARY=all make docker-build # to build a specific lava version LAVA_BUILD_OPTIONS="release" LAVA_VERSION=0.4.3 make docker-build