Skip to content

Commit

Permalink
PRT-594 provider optimizer (lavanet#399)
Browse files Browse the repository at this point in the history
* provider state tracker work in progress

* reliability manager added vote handler

* finished implementing vote updater and it's registration and transactions

* added apiInterface to relay.pb and implemented provider listener

* continue work rpcprovider

* added single provider preparation function

* added verification for proof

* added tryRelay

* added onSessionFailure usage

* added onSessionDone

* sync

* changed onSessionDone interface

* handle proof sending

* fix reference

* WIP psm

* added subscribe support

* WIP psm

* WIP

* WIP

* continued subscription code

* finished provide side subscribe

* handle subscription failure in consumer

* handle subscribe success without an error on provider side

* handle error status on relaySubscribe

* added cache to statequery

* added deps

* added retry on txSender sequence mismatch

* move common code to a method

* added option for reward server to reject a proof when it has an updated value

* wrap common code in a method

* reward server work

* relaynumber fixed

* go mod tidy

* finished normal flow of get session.

* finished normal flow of get session.

* adding sync loss handling

* adding consumer blocked handling

* adding on session done functionality

* added rewards claims and tracking

* bug fix

* refactored chainproxy into parsableChainProxy so we can implement chain fetcher with the existing classes

* revert, parsableChainMessage isn't needed

* continued work on chainFetcher WIP

* WIP psm methods almost done

* finished implementing chainFetcher

* adding recommendedEpochNumToCollectPayment

* adding recommendedEpochNumToCollectPayment

* adjusting code in state_query

* indicative error in reward server

* finished missing chain fetcher block parsing

* fixing reward server provider session manager reward sync

* tendermintrpc chain_fetcher now works

* added support for rest chain fetcher

* added support for all apiInterfaces, using chain fetcher

* example configuration to run rpc provider

* added examples for configs

* Fixed context shutdown issues, fixed bugs

* new configurations for rpcprovider

* change lava conf

* adding data reliability

* Finished provider session manager integration and implementation!!!

* fixing is valid epoch mistake.

* changed chain tracker range to be inclusive and fixed a bug

* fix reference overwriting

* handle initialization on ProviderSessionManager

* fix providerSessionsManager bugs

* fixed wrong lock checks

* fixed tx sender parsing issue

* changed IP:PORT to HOST:PORT

* do not crash if cache isn't connected

* still some bugs to fix

* git ignore generated conf file

* changed init chain commands, added some prints, modified fatals into errors on multiple chains so they won't kill the process

* removed check for websocket on tendermint until we decide what to do

* better handling of missing urls and endpoints definitions

* better capture grpc endpoint misconfiguration

* happy flow for provider session manager

* adding happy flow, session failure, epoch update tests

* adding more tests to psm

* changing test names

* Fixing data reliability in PSM

* data reliability psm WIP

* fixing subscription in PSM. adding unitests for the entire package.

* using generics to trigger delete event instead of using the code twice

* remove print

* fixing some issues related to connector crashing

* extract cobra commands from main

* refactored proto bufs, now changes to the code

* WIP changing fields in relay

* wip

* adding config files for e2e

* fixing provider cu charge in case consumer pays more

* changed some tests to use new format

* fixed gov test

* continue refactor

* provider error update

* Bug fixing session

* successfully build relay after changes

* successfully compiled after refactoring relay.pb now to unitesting

* rename relay fields to better represent what they are

* added some fields to badge

* added chain id verification to relays

* Fixing VRF issue with rpcprovider

* panic protection

* finished merging

* lint + fix

* fixed data reliability miss protection to surface problems and fix unitests

* fix unitests failing

* go mod tidy

* merge fixes

* merge main

* fix unitest merge problem

* make E2E great again

* fixed lint, added debug print

* fix tests

* removed deprecated relayer code

* fix problem in dev script

* removed relayer/ unit tests after migrating to protocol

* fixed comment naming convention

* added parsable options to rpcprovider configuration, as preperation to auth adding

* added auth to rpcprovider

* added test-mode flag for RPCCconsumer to print the input it's receiving

* better default chain tracker print params

* lint

* fix e2e configurations

* typo in conf

* finished adding ip forwarding header

* also in connector

* added example config for ip-forwarding

* added default parameter to spec blockParsing so all blockParser can now have default configured

* lint

* modified utils logging function format to use interface variadic call

* lint

* added guid to consumer and provider

* lint

* sync go sum

* fix unitests

* lint

* undo the merge problem in cosmos sdk spec

* fixed issue setting guid in salt

* go mod fix

* add probing

* wip

* added probing

* lint

* fix unitest

* fix blocking probing behavior when no pairings are available

* save optimizers per chain in consumer

* building provider storage for QoS data WIP

* added provioder data updates, still left to do the decay calculations and latency/sync updates

* added availability score

* moved timeout calculations to a common library, implementd optimizer data gathering

* finished provider optimizer logic, now need to support using it in the rpcconsumer

* lint

* added gud on lock failure, added retry on trylock, added backoff on context timeout

* send proof runs in parallel

* backoff mechanism

* reduce cache size

* fixing relay number related issues

* added timeout

* fixing csm dr issue

* fixing timeout.

* fixing update session cu behavior

* adding upgrade handler

* added missing cu support for mismatch to continue giving service up to threshold

* lint

* refactor sending a session in order to construct data reliability relay

* fix deadlocks in UpdateSessionCU

* fixed a mistake in missing cu checks

* refactor relayInner for better handling of context cancel

* use the saved threshold instead of a placeholder

* fixed some issues, reduced probing overhead

* added prints

* added perturbation to optimizer, fixed a few bugs

* make probing to different providers parallel

* log change

* added TODOs for handover

* handle startup races in provider, and an error nil reference on subscription

* solve concurrency races in optimizers creation

* fix unitests

* fix bugs

* prevent nil clients

* merge garbage

* added sync score, changed normal distribution to poisson distribution which is more correct and easier to code

* wip

* fixed all known issues, unit tests wip

* lint

* added tests, fixed bugs

* lint

* revert modifications to probing

* merged probing with main

* comments

* fix bug not setting a timeout on probe

* remove unnecessary call

* give better availability score for new entries making bad service providers

---------

Co-authored-by: Ran Mishael <[email protected]>
  • Loading branch information
omerlavanet and ranlavanet authored May 8, 2023
1 parent 5640d23 commit 3cb4b62
Show file tree
Hide file tree
Showing 25 changed files with 1,178 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/protocol_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ jobs:
### Run protocol unitests
######################################################
- name: Run Lava Protocol Tests
run: go test ./protocol/... -v
run: go test ./protocol/...
201 changes: 201 additions & 0 deletions config/provider_examples/all_endpoints:.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
endpoints:
- api-interface: jsonrpc
chain-id: ETH1
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: jsonrpc
chain-id: GTH1
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: jsonrpc
chain-id: FTM250
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: jsonrpc
chain-id: CELO
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: jsonrpc
chain-id: ALFAJORES
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: jsonrpc
chain-id: ARB1
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: jsonrpc
chain-id: STRK
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: rest
chain-id: APT1
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: jsonrpc
chain-id: POLYGON1
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: jsonrpc
chain-id: OPTM
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: jsonrpc
chain-id: BASET
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: rest
chain-id: COS3
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: tendermintrpc
chain-id: COS3
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: grpc
chain-id: COS3
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: rest
chain-id: COS4
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: tendermintrpc
chain-id: COS4
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: grpc
chain-id: COS4
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: rest
chain-id: LAV1
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: tendermintrpc
chain-id: LAV1
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: grpc
chain-id: LAV1
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: rest
chain-id: COS5
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: tendermintrpc
chain-id: COS5
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: grpc
chain-id: COS5
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: rest
chain-id: JUN1
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: tendermintrpc
chain-id: JUN1
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: grpc
chain-id: JUN1
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: jsonrpc
chain-id: EVMOS
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: rest
chain-id: EVMOS
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: tendermintrpc
chain-id: EVMOS
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: grpc
chain-id: EVMOS
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: jsonrpc
chain-id: CANTO
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: rest
chain-id: CANTO
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: tendermintrpc
chain-id: CANTO
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: grpc
chain-id: CANTO
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: rest
chain-id: AXELAR
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: tendermintrpc
chain-id: AXELAR
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: grpc
chain-id: AXELAR
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: jsonrpc
chain-id: BSC
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: jsonrpc
chain-id: SOLANA
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
- api-interface: jsonrpc
chain-id: SUIT
network-address: 127.0.0.1:2221
node-urls:
- url: <enter-here>
20 changes: 20 additions & 0 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29674,6 +29674,16 @@ paths:
in: query
required: false
type: boolean
- name: pagination.reverse
description: >-
reverse is set to true if results are to be returned in the
descending order.


Since: cosmos-sdk 0.43
in: query
required: false
type: boolean
tags:
- Query
'/lavanet/lava/epochstorage/fixated_params/{index}':
Expand Down Expand Up @@ -29933,6 +29943,16 @@ paths:
in: query
required: false
type: boolean
- name: pagination.reverse
description: >-
reverse is set to true if results are to be returned in the
descending order.


Since: cosmos-sdk 0.43
in: query
required: false
type: boolean
tags:
- Query
'/lavanet/lava/epochstorage/stake_storage/{index}':
Expand Down
15 changes: 8 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ require (
github.com/gogo/googleapis v1.4.0 // indirect
github.com/golang/glog v1.0.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
golang.org/x/mod v0.7.0 // indirect
golang.org/x/tools v0.2.0 // indirect
golang.org/x/mod v0.9.0 // indirect
golang.org/x/tools v0.7.0 // indirect
gonum.org/v1/gonum v0.13.0 // indirect
)

require (
Expand Down Expand Up @@ -185,12 +186,12 @@ require (
go.etcd.io/bbolt v1.3.6 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e
golang.org/x/net v0.7.0
golang.org/x/exp v0.0.0-20230321023759-10a507213a29
golang.org/x/net v0.8.0
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/term v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce
Expand Down
16 changes: 16 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,8 @@ golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8H
golang.org/x/exp v0.0.0-20220426173459-3bcf042a4bf5/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA=
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA=
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug=
golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
Expand Down Expand Up @@ -1567,6 +1569,8 @@ golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/mod v0.6.0-dev.0.20211013180041-c96bc1413d57/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=
golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs=
golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -1633,6 +1637,8 @@ golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -1772,11 +1778,15 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand All @@ -1788,6 +1798,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down Expand Up @@ -1871,6 +1883,8 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.8-0.20211029000441-d6a9af8af023/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE=
golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA=
golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4=
golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand All @@ -1880,6 +1894,8 @@ golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNq
gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo=
gonum.org/v1/gonum v0.0.0-20181121035319-3f7ecaa7e8ca/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo=
gonum.org/v1/gonum v0.6.0/go.mod h1:9mxDZsDKxgMAuccQkewq682L+0eCu4dCN2yonUJTCLU=
gonum.org/v1/gonum v0.13.0 h1:a0T3bh+7fhRyqeNbiC3qVHYmkiQgit3wnNan/2c0HMM=
gonum.org/v1/gonum v0.13.0/go.mod h1:/WPYRckkfWrhWefxyYTfrTtQR0KH4iyHNuzxqXAKyAU=
gonum.org/v1/netlib v0.0.0-20181029234149-ec6d1f5cefe6/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw=
gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw=
gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc=
Expand Down
10 changes: 0 additions & 10 deletions protocol/chainlib/chainlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ import (
spectypes "github.com/lavanet/lava/x/spec/types"
)

const (
TimePerCU = uint64(100 * time.Millisecond)
MinimumTimePerRelayDelay = time.Second
DataReliabilityTimeoutIncrease = 5 * time.Second
)

func NewChainParser(apiInterface string) (chainParser ChainParser, err error) {
switch apiInterface {
case spectypes.APIInterfaceJsonRPC:
Expand Down Expand Up @@ -101,7 +95,3 @@ func GetChainProxy(ctx context.Context, nConns uint, rpcProviderEndpoint *lavase
}
return nil, fmt.Errorf("chain proxy for apiInterface (%s) not found", rpcProviderEndpoint.ApiInterface)
}

func LocalNodeTimePerCu(cu uint64) time.Duration {
return time.Duration(cu*TimePerCU) + lavasession.AverageWorldLatency // TODO: remove average world latency once our providers run locally, or allow a flag that says local to make it tight, tighter timeouts are better
}
3 changes: 1 addition & 2 deletions protocol/chainlib/chainproxy/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ func (connector *Connector) Close() {
}

func (connector *Connector) increaseNumberOfClients(ctx context.Context, numberOfFreeClients int) {
utils.LavaFormatDebug("increasing number of clients", utils.Attribute{Key: "numberOfFreeClients", Value: numberOfFreeClients},
utils.Attribute{Key: "url", Value: connector.nodeUrl.Url})
utils.LavaFormatDebug("increasing number of clients", utils.Attribute{Key: "numberOfFreeClients", Value: numberOfFreeClients}, utils.Attribute{Key: "url", Value: connector.nodeUrl.Url})
var rpcClient *rpcclient.Client
var err error
for connectionAttempt := 0; connectionAttempt < MaximumNumberOfParallelConnectionsAttempts; connectionAttempt++ {
Expand Down
2 changes: 1 addition & 1 deletion protocol/chainlib/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func (cp *GrpcChainProxy) SendNodeMsg(ctx context.Context, ch chan interface{},
if !ok {
return nil, "", nil, utils.LavaFormatError("invalid message type in grpc failed to cast RPCInput from chainMessage", nil, utils.Attribute{Key: "GUID", Value: ctx}, utils.Attribute{Key: "rpcMessage", Value: rpcInputMessage})
}
relayTimeout := LocalNodeTimePerCu(chainMessage.GetServiceApi().ComputeUnits)
relayTimeout := common.LocalNodeTimePerCu(chainMessage.GetServiceApi().ComputeUnits)
// check if this API is hanging (waiting for block confirmation)
if chainMessage.GetInterface().Category.HangingApi {
relayTimeout += cp.averageBlockTime
Expand Down
Loading

0 comments on commit 3cb4b62

Please sign in to comment.