Skip to content

Commit

Permalink
feat: PRT-improve-timeout-handling (#1249)
Browse files Browse the repository at this point in the history
* refactored the rpcconsumer send, WIP

* added TODO

* progress, WIP

* wip

* wip

* relay_processor done

* change timeouts across the protocol

* handle non deterministic apis in the quorum

* lint

* fix tests

* fix deadlock

* fix nil getSessions

* increase hanging api time

* add unitest for usedProviders

* added tests + refactor for simplicity

* added more tests

* added more testing

* lint

* add unitests

* on init do not fail init relays on pairing

* change csm get provider error to warning

* added errors when failing relays

* remove data reliability errors on latest block requests

* disabled data reliability latest also on node errors

* add more information on error during quorum

* allow empty results for queries without an error

* add missing consumer consistency

* empty response quorum

* add more info on provider error

* added basic consumer unitest

* added a check for consumer to be up during unitest

* refactor code for reuse in unitest

* added provider and consumer unitests

* added rpcproviderServer creation to unitest

* added provider dialing

* fixed bug in rpcconsumer, finished unitest

* fix panic in relayErrors

* sanitize unique errors get

* prevent port conflict

* rename

* fix addUsed with len(0) resetting the wait

* simplify port selection in unitests

* add timeouts and fails to relays in unitest

* fix tests

* added timeout to the scenarios

* lint

* add a new test for tx sending

* sort logs better :)

* fix Caching error spam when missing cache

* adding nil protection for used Providers

* set default 0

* adding error logs and nil protection.

* adding some checks to avoid nil deref

* allow error for connection reset by peer when in emergency mode.. as we shut down the node.

* adding debugging information for next time ts fails.

* es lint..

* eslint fix

---------

Co-authored-by: Ran Mishael <[email protected]>
  • Loading branch information
omerlavanet and ranlavanet authored Mar 24, 2024
1 parent 3b60662 commit 1a9aae2
Show file tree
Hide file tree
Showing 47 changed files with 2,606 additions and 820 deletions.
21 changes: 11 additions & 10 deletions ecosystem/cache/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,17 @@ func (s *RelayerCacheServer) GetRelay(ctx context.Context, relayCacheGet *pairin
}()
// wait for all reads to complete before moving forward
waitGroup.Wait()

// validate that the response seen block is larger or equal to our expectations.
if cacheReply.SeenBlock < slices.Min([]int64{relayCacheGet.SeenBlock, relayCacheGet.RequestedBlock}) { // TODO unitest this.
// Error, our reply seen block is not larger than our expectations, meaning we got an old response
// this can happen only in the case relayCacheGet.SeenBlock < relayCacheGet.RequestedBlock
// by setting the err variable we will get a cache miss, and the relay will continue to the node.
err = utils.LavaFormatDebug("reply seen block is smaller than our expectations",
utils.LogAttr("cacheReply.SeenBlock", cacheReply.SeenBlock),
utils.LogAttr("seenBlock", relayCacheGet.SeenBlock),
)
if err == nil { // in case we got a hit validate seen block of the reply.
// validate that the response seen block is larger or equal to our expectations.
if cacheReply.SeenBlock < slices.Min([]int64{relayCacheGet.SeenBlock, relayCacheGet.RequestedBlock}) { // TODO unitest this.
// Error, our reply seen block is not larger than our expectations, meaning we got an old response
// this can happen only in the case relayCacheGet.SeenBlock < relayCacheGet.RequestedBlock
// by setting the err variable we will get a cache miss, and the relay will continue to the node.
err = utils.LavaFormatDebug("reply seen block is smaller than our expectations",
utils.LogAttr("cacheReply.SeenBlock", cacheReply.SeenBlock),
utils.LogAttr("seenBlock", relayCacheGet.SeenBlock),
)
}
}
// set seen block.
if relayCacheGet.SeenBlock > cacheReply.SeenBlock {
Expand Down
4 changes: 2 additions & 2 deletions ecosystem/lava-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"bignumber.js": "^9.1.1",
"chalk": "4.1.2",
"commander": "^9.4.1",
"eslint": "^8.29.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"google-protobuf": "^3.21.2",
Expand Down Expand Up @@ -113,4 +113,4 @@
"node": ">=18",
"npm": ">=6.12.0"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,15 @@ describe("ProviderOptimizer", () => {
perturbationPercentage
);
expect(returnedProviders).toHaveLength(1);
console.log(
"[Debugging] expect(returnedProviders[0]).toBe(providers[skipIndex]); Optimizer Issue",
"returnedProviders",
returnedProviders,
"providers",
providers,
"skipIndex",
skipIndex
);
expect(returnedProviders[0]).toBe(providers[skipIndex]);

returnedProviders = providerOptimizer.chooseProvider(
Expand Down
Loading

0 comments on commit 1a9aae2

Please sign in to comment.