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

feat: PRT-1178: Subscriptions phase 1 (without handover) #1462

Merged
merged 199 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
199 commits
Select commit Hold shift + click to select a range
c5d09cc
Enable the subscription again
shleikes Apr 3, 2024
b4a4ece
Add GetParams() to GenericMessage struct
shleikes May 7, 2024
611b4af
Fix tendermint small bug
shleikes May 7, 2024
8e75303
RelayProcessor to skip some logic on subscription
shleikes May 7, 2024
37e3408
Add subscription management in the provider - some TODOs are left
shleikes May 19, 2024
a7ccc34
Fix the subscription category for supported chains
shleikes May 19, 2024
8c7b467
Remove unused functions
shleikes May 19, 2024
350b851
Small fix to the provider web socket manager
shleikes May 19, 2024
7f72a9a
Small fixes to the provider
shleikes May 20, 2024
2ec447c
Move finalization consensus to a new package
shleikes May 23, 2024
49eeda9
Split the SendRelay into 2 functions: ParseRelay & SendParsedRelay
shleikes May 23, 2024
da69039
Add an utility function for readable hex
shleikes May 23, 2024
7813dc6
Remove the logic of disconnecting consumers after the end of epoch
shleikes May 23, 2024
0171606
Fix to the sage channel sender
shleikes May 23, 2024
31bb594
Use a utility function CreateHashFromParams
shleikes May 23, 2024
96c0e19
Add some trace logs
shleikes May 23, 2024
781eecc
Rename IsSubscription -> IsSubscriptionCategory
shleikes May 23, 2024
a21de48
Add LongLastingProvidersStorage
shleikes May 23, 2024
5ca0201
Add the cancellable context to subscription relays int he rpcconsumer…
shleikes May 23, 2024
7f04c47
Add ConsumerWebsocketManager & ConsumerWSSubscriptionManager
shleikes May 23, 2024
3c7acde
Move the subscription closing logic to a new function
shleikes May 23, 2024
9e8cce6
Rename to make the code more sense
shleikes May 23, 2024
f77016d
Implemented timeout of 15 minutes for open subscription
shleikes May 23, 2024
f5b34ee
Add the subscription function tags
shleikes May 26, 2024
5761f74
Updated cosmos and ethereum specs with new subscription parse directives
shleikes May 26, 2024
420995c
Implemented unsubscribe logic in the consumer
shleikes May 26, 2024
7fb9291
Small logs improvements
shleikes May 26, 2024
7a32b05
Rename CreateSubscriptionKey -> CreateDappKey
shleikes May 27, 2024
5961c66
Use hashed params as map keys for subscription context
shleikes May 27, 2024
1fe0917
Move the websocket replies channel creation to the subscription manager
shleikes May 27, 2024
706456f
Rethink the storing of connected dapps and active subscriptions in th…
shleikes May 27, 2024
d17e7ea
Some small fixes to the Unsubscribe function
shleikes May 27, 2024
80cca49
Small rename
shleikes May 27, 2024
aa252f5
Implement unsubscribe_all for consumer
shleikes May 27, 2024
98693ec
Typos fix
shleikes May 28, 2024
09734e5
Improved some logs
shleikes May 28, 2024
54e3499
Add a missing lock
shleikes May 28, 2024
1ef3b36
Make the websocket channel writing a little bit safer
shleikes May 28, 2024
cfdbe3a
Fix a small bug
shleikes May 28, 2024
ff8a7a2
Don't support ubsubscribe_all in Relay flow
shleikes May 28, 2024
8ebc728
Split the TryRelay into smaller pieces
shleikes May 28, 2024
48271f4
Add GetID to RPCInput interface
shleikes May 28, 2024
a528a5a
Add support for unsubscribe relay in the provider
shleikes May 28, 2024
580fffb
Safe channel sender improvements
shleikes May 28, 2024
d3fd48d
Use SafeChannelSender for the subscription in the consumer and fix bugs
shleikes May 28, 2024
8bc5fa8
Use formatter to preserve original jsonrpc ID
shleikes May 28, 2024
83fa17d
Add some comments
shleikes May 29, 2024
90bb6b3
Small fixes
shleikes May 29, 2024
8b85bd7
Rename and fix AnalyzeWebSocketErrorAndWriteMessage
shleikes May 29, 2024
48b171c
Add a comment
shleikes May 31, 2024
6e6f662
Remove done TODO
shleikes May 31, 2024
fa8e5b1
Merge branch 'main' into PRT-1178-subscriptions-phase-1-without-handover
shleikes Jun 2, 2024
954feda
Some log improvements
shleikes Jun 2, 2024
28983e6
Provider subscription manager fix
shleikes Jun 2, 2024
e8af54b
Move UpdateCU call to start of subscription instead of its end
shleikes Jun 2, 2024
a458643
Updated subscription CU cost
shleikes Jun 2, 2024
ec3e5c5
Fix finalization consensus test
shleikes Jun 2, 2024
d24aa55
Lint fixes
shleikes Jun 2, 2024
b4f15fb
Add LongLastingProvidersStorage tests
shleikes Jun 2, 2024
eb81fb0
Add SafeChannelSender tests
shleikes Jun 2, 2024
2a7e4e0
Add 10 seconds timeout to handle hang when waiting for first message …
shleikes Jun 3, 2024
0153989
Move the first subscription reply verification into the rpcconsumer_s…
shleikes Jun 3, 2024
4f4e0fa
Handle bad provider signature better
shleikes Jun 4, 2024
87ac3d9
Fix a small bug and remove redundant return value
shleikes Jun 4, 2024
93d453e
Fix typos
shleikes Jun 4, 2024
bcc8f61
Move ProviderNodeSubscriptionManager to chainlib
shleikes Jun 4, 2024
2c010f7
Fix to the UnsubscribeAll call
shleikes Jun 5, 2024
ac8da0d
Create a const for the subscription relay timeout
shleikes Jun 5, 2024
4e9f787
Sync the consumer and provider on session failure
shleikes Jun 5, 2024
da37f8f
Change the type of replyServer to not be a pointer to interface
shleikes Jun 5, 2024
c80ab90
Small fix for the consumer subscription manager
shleikes Jun 5, 2024
9122693
Fix a small bug in the provider node subscription manager
shleikes Jun 5, 2024
548d691
Small fix to the consumer subscription manager
shleikes Jun 6, 2024
baa0bf0
Remove epochs from provider subscription manager
shleikes Jun 6, 2024
ecc3c2a
Small fix to the safe channel sender
shleikes Jun 6, 2024
bf1ebfe
Tiny log fix
shleikes Jun 6, 2024
0a5d142
Allow weboscket and http connectors in jsonRPC
shleikes Jun 6, 2024
de96a73
Small log fix to connector.go
shleikes Jun 6, 2024
d739f36
Add websocket server to mock chain lib
shleikes Jun 6, 2024
7717693
Add tests for provider and consumer subscription manager
shleikes Jun 6, 2024
75ac860
Merge branch 'main' into PRT-1178-subscriptions-phase-1-without-handover
shleikes Jun 6, 2024
05a94b6
Post merge fixes
shleikes Jun 6, 2024
d882a53
Fix lint errors
shleikes Jun 6, 2024
754b4eb
Verify webSocket is up in consumer in protocol integration tests
shleikes Jun 6, 2024
0490ce5
Revert "Allow weboscket and http connectors in jsonRPC"
shleikes Jun 6, 2024
12d2daf
WIP
shleikes Jun 7, 2024
b8dd924
Merge branch 'main' into PRT-1178-subscriptions-phase-1-without-handover
ranlavanet Jun 10, 2024
7bf73c8
changing functionality of parsed directive to be saved on the chain m…
ranlavanet Jun 10, 2024
db31712
rename long lasting to active subscription provider storage
ranlavanet Jun 10, 2024
c032cf4
adding purge callback.
ranlavanet Jun 10, 2024
9ed2249
two consumers setup
ranlavanet Jun 10, 2024
39e7d22
fix a bug where 2 consumers wouldn't be able to subscribe.
ranlavanet Jun 10, 2024
d1faaae
fixing test for subscriptions, fixing bug in chain router, and managi…
ranlavanet Jun 11, 2024
8a0d892
fixing safe channel sender functionality
ranlavanet Jun 12, 2024
91b6509
fixing provider subscription manager test.
ranlavanet Jun 12, 2024
c71712f
fix problem with websocket listener in tests.
ranlavanet Jun 12, 2024
cfcb508
fixing test routine condition.
ranlavanet Jun 12, 2024
6cb691a
lint
ranlavanet Jun 12, 2024
57c0d8b
fix ws issue on generic chain lib mocks
ranlavanet Jun 12, 2024
8bd629c
fix e2e for jsonrpc.
ranlavanet Jun 12, 2024
b238107
removing unused code.
ranlavanet Jun 12, 2024
99f0e94
fix typo
ranlavanet Jun 12, 2024
e45a40d
adding comments
ranlavanet Jun 12, 2024
d8ea9c3
comment fix
ranlavanet Jun 12, 2024
95d3b10
adding more comments.
ranlavanet Jun 12, 2024
6bfb630
removing spam trace logs
ranlavanet Jun 12, 2024
f9fd760
undoing WIP changes
ranlavanet Jun 16, 2024
94dedf1
adding seen block to rpc consumer's consistency.
ranlavanet Jun 16, 2024
ef14a5e
handling same consumer subscription hash.
ranlavanet Jun 16, 2024
bcdb0b8
rename to a proper convention
ranlavanet Jun 16, 2024
93fdfdb
fixing case where two subscriptions at the same time could trigger a …
ranlavanet Jun 16, 2024
af50c00
improve readability
ranlavanet Jun 16, 2024
e448e42
adding comments for better readability
ranlavanet Jun 17, 2024
203fe71
insert sdk address inside the consumer container to avoid unnecessary…
ranlavanet Jun 17, 2024
1ffcd56
improve json marshalling by using gojson :)
ranlavanet Jun 17, 2024
3627649
remove unused code
ranlavanet Jun 17, 2024
c9e4763
change json marshaling package
ranlavanet Jun 17, 2024
812363e
improve flow on rpcconsumer server.
ranlavanet Jun 17, 2024
032afbb
improved encoding on rpc consumer server
ranlavanet Jun 17, 2024
82d21a6
mistakenly forgotten unlock.
ranlavanet Jun 17, 2024
3ca0d60
Small log fix
shleikes Jun 18, 2024
41ba8f0
Pass also the ws connection to the provider in the setup_providers.sh…
shleikes Jun 18, 2024
d22219f
Add websocket subscription test in e2e
shleikes Jun 18, 2024
fe6214b
fix mock tests
ranlavanet Jun 18, 2024
6b90b76
add replace channel method to safe channel sender
ranlavanet Jun 18, 2024
5694708
fix test
ranlavanet Jun 18, 2024
4f6f7a6
use replace channel instead of close
ranlavanet Jun 18, 2024
b1ce171
add more documentation
ranlavanet Jun 18, 2024
005c246
fix sub manager test
ranlavanet Jun 18, 2024
81d23d0
Fix lint
shleikes Jun 18, 2024
a4de7eb
Merge branch 'PRT-1178-subscriptions-phase-1-without-handover' into P…
shleikes Jun 18, 2024
43576bf
fix pending subscription race issue and add tests
ranlavanet Jun 19, 2024
f5ab2ea
Checking for errors when writing to file in e2e
shleikes Jun 19, 2024
554a8af
Add websocket response to log
shleikes Jun 19, 2024
25b0387
Allow more than 2 websocket in e2e test for subscriptions
shleikes Jun 19, 2024
a11aff5
Merge branch 'PRT-1178-subscriptions-phase-1-without-handover' into P…
shleikes Jun 19, 2024
d3d1148
fix nil deref on a race between read and close connection
ranlavanet Jun 19, 2024
a1612b0
Remove log
shleikes Jun 19, 2024
a3cd28e
Merge branch 'PRT-1178-subscriptions-phase-1-without-handover' into P…
shleikes Jun 19, 2024
2ff548f
add comments
ranlavanet Jun 19, 2024
ce7db00
remove log spam and make addon print better
ranlavanet Jun 19, 2024
fef9648
fix ws message bug
ranlavanet Jun 19, 2024
4191c11
Merge branch 'PRT-1178-subscriptions-phase-1-e2e' into PRT-1178-subsc…
shleikes Jun 27, 2024
d77763f
Leftovers from committed WIP
shleikes Jul 3, 2024
e53a9ed
Merge branch 'main' into PRT-1178-subscriptions-phase-1-without-handover
shleikes Jul 3, 2024
590a5a9
Small code cleaning
shleikes Jul 8, 2024
91dea08
Merge branch 'main' into PRT-1178-subscriptions-phase-1-without-handover
shleikes Jul 8, 2024
0610ad5
Post merge fix
shleikes Jul 8, 2024
c4fba04
Merge branch 'main' into PRT-1178-subscriptions-phase-1-without-handover
shleikes Jul 10, 2024
381326a
Merge branch 'main' into PRT-1178-subscriptions-phase-1-without-handover
shleikes Jul 14, 2024
a933a3c
Merge branch 'main' into PRT-1178-subscriptions-phase-1-without-handover
shleikes Jul 15, 2024
355949b
Small test fix
shleikes Jul 15, 2024
c682d76
fix: PRT-1178: Subscription phase 1 unsubscribe fix (#1575)
shleikes Jul 21, 2024
dea5cbe
Fix lint issues
shleikes Jul 22, 2024
ba5234f
Merge branch 'main' into PRT-1178-subscriptions-phase-1-without-handover
omerlavanet Jul 22, 2024
03a81d1
Merge branch 'main' into PRT-1178-subscriptions-phase-1-without-handover
omerlavanet Jul 22, 2024
619a9ff
Make the logs clear to investigate test fail on GH
shleikes Jul 23, 2024
a2e50ad
Add some logs for the SDK to trace the E2E test failure
shleikes Jul 23, 2024
e8bbc41
Attempt to fix test by removing go routines
shleikes Jul 21, 2024
c5ef365
Another attempt to fix the protocol tests
shleikes Jul 23, 2024
891ddb4
Small lint fix
shleikes Jul 23, 2024
ac8e61b
Merge branch 'main' into PRT-1178-subscriptions-phase-1-without-handover
shleikes Jul 23, 2024
5a59689
Merge branch 'main' into PRT-1178-subscriptions-phase-1-without-handover
ranlavanet Jul 29, 2024
0479427
merged
ranlavanet Jul 29, 2024
8d64944
Merge branch 'PRT-1178-subscriptions-phase-1-without-handover' of git…
ranlavanet Jul 29, 2024
39fa8c3
Adding better search func for requirements
ranlavanet Jul 29, 2024
c83584f
fix unused else
ranlavanet Jul 29, 2024
92ac689
adding consumer guid for subscription requests from multiple consumer…
ranlavanet Jul 31, 2024
b933858
consumer websocket manager fixes
ranlavanet Jul 31, 2024
c666333
fix 7 more comments
ranlavanet Jul 31, 2024
2024b34
fixing more comments :)
ranlavanet Jul 31, 2024
04569a1
set all id parsing in chain message.
ranlavanet Jul 31, 2024
abd509a
fixing more comments
ranlavanet Jul 31, 2024
76c68b7
Merge branch 'main' into PRT-1178-subscriptions-phase-1-without-handover
ranlavanet Aug 1, 2024
37fb900
merged v2 changes
ranlavanet Aug 1, 2024
4e2c1af
merge conflict fixes
ranlavanet Aug 1, 2024
8da5e57
terminate connection in handleNewNodeMessage on error
ranlavanet Aug 1, 2024
2df97ad
fixing missing websocket id for unique dapp key for websocket subscri…
ranlavanet Aug 1, 2024
12c5e2b
another review bites the dust
ranlavanet Aug 1, 2024
a18be30
another one bites the dust
ranlavanet Aug 1, 2024
019239d
logs
ranlavanet Aug 1, 2024
a4be29b
fixing a bug in unsubscribe brackets
ranlavanet Aug 4, 2024
2341a4f
do not purge providers if they have more than one subscription
ranlavanet Aug 4, 2024
4c495e2
solving issue after issue. I love to call it, Hero mode.
ranlavanet Aug 4, 2024
05f8547
solve the safe channel sender issue when sending a message and waitin…
ranlavanet Aug 4, 2024
684f17d
Merge branch 'main' into PRT-1178-subscriptions-phase-1-without-handover
ranlavanet Aug 4, 2024
f6f47f3
remove log.
ranlavanet Aug 4, 2024
aa15c28
fix lint
ranlavanet Aug 4, 2024
e621294
lint v2
ranlavanet Aug 4, 2024
4d31385
lint v3
ranlavanet Aug 4, 2024
2429156
lint v4
ranlavanet Aug 5, 2024
28947ff
fixing context issue reading headers on subscription.
ranlavanet Aug 5, 2024
9d87700
nil deref fix
ranlavanet Aug 5, 2024
f995ae9
fix initialize redundancy
ranlavanet Aug 5, 2024
8886fb8
adding multiple unique id on same dapp etc..
ranlavanet Aug 5, 2024
b8d4af5
fixing pending race for more than one pending subscriptions
ranlavanet Aug 6, 2024
81030d1
adding a test to validate the queue mechanism
ranlavanet Aug 6, 2024
6327f5f
fixed.
ranlavanet Aug 6, 2024
c933944
Merge branch 'main' into PRT-1178-subscriptions-phase-1-without-handover
omerlavanet Aug 6, 2024
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
9 changes: 8 additions & 1 deletion .github/workflows/lava.yml
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,14 @@ jobs:

report-tests-results:
runs-on: ubuntu-latest
needs: [test-consensus, test-protocol, test-protocol-e2e, test-payment-e2e] # test-sdk-e2e,
needs:
[
test-consensus,
test-protocol,
test-protocol-e2e,
# test-sdk-e2e,
test-payment-e2e,
]
if: always()
steps:
- name: Download Artifacts
Expand Down
26 changes: 13 additions & 13 deletions config/provider_examples/avalanch_internal_paths_example.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# this example show cases how you can setup Avalanche
# this example show cases how you can setup Avalanche
endpoints:
- api-interface: jsonrpc
chain-id: AVAX
network-address: 127.0.0.1:2221
node-urls:
- url: ws://127.0.0.1:3333/C/rpc/ws
internal-path: "/C/rpc" # c chain like specified in the spec
- url: https://127.0.0.1:3334/C/avax
internal-path: "/C/avax" # c/avax like specified in the spec
- url: https://127.0.0.1:3335/X
internal-path: "/X" # x chain like specified in the spec
- url: https://127.0.0.1:3336/P
internal-path: "/P" # p chain like specified in the spec
- api-interface: jsonrpc
chain-id: AVAX
network-address: 127.0.0.1:2221
node-urls:
- url: ws://127.0.0.1:3333/C/rpc/ws
internal-path: "/C/rpc" # c chain like specified in the spec
- url: https://127.0.0.1:3334/C/avax
internal-path: "/C/avax" # c/avax like specified in the spec
- url: https://127.0.0.1:3335/X
internal-path: "/X" # x chain like specified in the spec
- url: https://127.0.0.1:3336/P
internal-path: "/P" # p chain like specified in the spec
21 changes: 15 additions & 6 deletions cookbook/specs/ethereum.json
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@
"category": {
"deterministic": false,
"local": true,
"subscription": true,
"subscription": false,
"stateful": 0
},
"extra_compute_units": 0
Expand Down Expand Up @@ -833,7 +833,7 @@
],
"parser_func": "DEFAULT"
},
"compute_units": 10,
"compute_units": 1000,
"enabled": true,
"category": {
"deterministic": false,
Expand Down Expand Up @@ -874,7 +874,7 @@
"category": {
"deterministic": false,
"local": true,
"subscription": true,
"subscription": false,
"stateful": 0
},
"extra_compute_units": 0
Expand All @@ -883,16 +883,16 @@
"name": "eth_unsubscribe",
"block_parsing": {
"parser_arg": [
""
"latest"
],
"parser_func": "EMPTY"
"parser_func": "DEFAULT"
},
"compute_units": 10,
"enabled": true,
"category": {
"deterministic": false,
"local": true,
"subscription": false,
"subscription": true,
"stateful": 0
},
"extra_compute_units": 0
Expand Down Expand Up @@ -1045,6 +1045,15 @@
"encoding": "hex"
},
"api_name": "eth_getBlockByNumber"
},
{
"function_tag": "SUBSCRIBE",
"api_name": "eth_subscribe"
},
{
"function_template": "{\"jsonrpc\":\"2.0\",\"method\":\"eth_unsubscribe\",\"params\":[\"%s\"],\"id\":1}",
"function_tag": "UNSUBSCRIBE",
"api_name": "eth_unsubscribe"
}
],
"verifications": [
Expand Down
6 changes: 3 additions & 3 deletions cookbook/specs/fantom.json
ranlavanet marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"category": {
ranlavanet marked this conversation as resolved.
Show resolved Hide resolved
"deterministic": false,
"local": true,
"subscription": false,
"subscription": true,
"stateful": 0
},
"extra_compute_units": 0
Expand Down Expand Up @@ -387,7 +387,7 @@
"category": {
"deterministic": false,
"local": true,
"subscription": true,
"subscription": false,
"stateful": 0
},
"extra_compute_units": 0
Expand Down Expand Up @@ -477,7 +477,7 @@
"category": {
"deterministic": false,
"local": true,
"subscription": true,
"subscription": false,
"stateful": 0
},
"extra_compute_units": 0
Expand Down
32 changes: 23 additions & 9 deletions cookbook/specs/tendermint.json
Original file line number Diff line number Diff line change
Expand Up @@ -449,11 +449,11 @@
"name": "subscribe",
"block_parsing": {
"parser_arg": [
""
"latest"
],
"parser_func": "EMPTY"
"parser_func": "DEFAULT"
},
"compute_units": 10,
"compute_units": 1000,
"enabled": true,
"category": {
"deterministic": false,
Expand Down Expand Up @@ -521,16 +521,16 @@
"name": "unsubscribe",
"block_parsing": {
"parser_arg": [
""
"latest"
],
"parser_func": "EMPTY"
"parser_func": "DEFAULT"
},
"compute_units": 10,
"enabled": true,
"category": {
"deterministic": false,
"local": true,
"subscription": false,
"subscription": true,
"stateful": 0
},
"extra_compute_units": 0
Expand All @@ -539,16 +539,16 @@
"name": "unsubscribe_all",
"block_parsing": {
"parser_arg": [
""
"latest"
],
"parser_func": "EMPTY"
"parser_func": "DEFAULT"
},
"compute_units": 10,
"enabled": true,
"category": {
"deterministic": false,
"local": true,
"subscription": false,
"subscription": true,
"stateful": 0
},
"extra_compute_units": 0
Expand Down Expand Up @@ -618,6 +618,20 @@
"encoding": "base64"
},
"api_name": "earliest_block"
},
{
"function_tag": "SUBSCRIBE",
"api_name": "subscribe"
},
{
"function_template": "{\"jsonrpc\":\"2.0\",\"method\":\"unsubscribe\",\"params\":%s,\"id\":1}",
"function_tag": "UNSUBSCRIBE",
"api_name": "unsubscribe"
},
{
"function_template": "{\"jsonrpc\":\"2.0\",\"method\":\"unsubscribe_all\",\"params\":[],\"id\":1}",
"function_tag": "UNSUBSCRIBE_ALL",
"api_name": "unsubscribe_all"
}
],
"verifications": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class StateBadgeQuery {

// fetchPairing fetches pairing for all chainIDs we support
public async fetchPairing(): Promise<number> {
Logger.debug("Fetching pairing started");
Logger.debug("Fetching pairing from badge started");

let timeLeftToNextPairing;
let virtualEpoch;
Expand Down Expand Up @@ -110,7 +110,7 @@ export class StateBadgeQuery {
this.virtualEpoch = virtualEpoch;
this.currentEpoch = currentEpoch;

Logger.debug("Fetching pairing ended");
Logger.debug("Fetching pairing from badge ended", timeLeftToNextPairing);

return timeLeftToNextPairing;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class StateChainQuery {
// fetchPairing fetches pairing for all chainIDs we support
public async fetchPairing(): Promise<number> {
try {
Logger.debug("Fetching pairing started");
Logger.debug("Fetching pairing from chain started");
// Save time till next epoch
let timeLeftToNextPairing;
let currentEpoch;
Expand Down Expand Up @@ -154,7 +154,7 @@ export class StateChainQuery {
this.currentEpoch = currentEpoch;
this.downtimeParams = downtimeParams;

Logger.debug("Fetching pairing ended");
Logger.debug("Fetching pairing from chain ended", timeLeftToNextPairing);

// Return timeLeftToNextPairing
return timeLeftToNextPairing;
Expand Down
3 changes: 3 additions & 0 deletions proto/lavanet/lava/spec/api_collection.proto
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ enum FUNCTION_TAG {
SET_LATEST_IN_BODY = 4;
VERIFICATION = 5;
GET_EARLIEST_BLOCK = 6;
SUBSCRIBE = 7;
UNSUBSCRIBE = 8;
UNSUBSCRIBE_ALL = 9;
}

enum PARSER_TYPE {
Expand Down
10 changes: 6 additions & 4 deletions protocol/chainlib/base_chain_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,14 @@ func (bcp *BaseChainParser) SeparateAddonsExtensions(supported []string) (addons
if supportedToCheck == "" {
continue
}
if bcp.isExtension(supportedToCheck) {
if bcp.isExtension(supportedToCheck) || supportedToCheck == WebSocketExtension {
extensions = append(extensions, supportedToCheck)
continue
}
// neither is an error
err = utils.LavaFormatError("invalid supported to check, is neither an addon or an extension", err, utils.Attribute{Key: "spec", Value: bcp.spec.Index}, utils.Attribute{Key: "supported", Value: supportedToCheck})
err = utils.LavaFormatError("invalid supported to check, is neither an addon or an extension", err,
utils.Attribute{Key: "spec", Value: bcp.spec.Index},
utils.Attribute{Key: "supported", Value: supportedToCheck})
}
}
return addons, extensions, err
Expand Down Expand Up @@ -252,15 +254,15 @@ func (bcp *BaseChainParser) Construct(spec spectypes.Spec, internalPaths map[str
bcp.extensionParser.SetConfiguredExtensions(extensionParser.GetConfiguredExtensions())
}

func (bcp *BaseChainParser) GetParsingByTag(tag spectypes.FUNCTION_TAG) (parsing *spectypes.ParseDirective, collectionData *spectypes.CollectionData, existed bool) {
func (bcp *BaseChainParser) GetParsingByTag(tag spectypes.FUNCTION_TAG) (parsing *spectypes.ParseDirective, apiCollection *spectypes.ApiCollection, existed bool) {
bcp.rwLock.RLock()
defer bcp.rwLock.RUnlock()

val, ok := bcp.taggedApis[tag]
if !ok {
return nil, nil, false
}
return val.Parsing, &val.ApiCollection.CollectionData, ok
return val.Parsing, val.ApiCollection, ok
}

func (bcp *BaseChainParser) ExtensionParsing(addon string, parsedMessageArg *baseChainMessageContainer, extensionInfo extensionslib.ExtensionInfo) {
Expand Down
7 changes: 5 additions & 2 deletions protocol/chainlib/chain_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,12 @@ func (cf *ChainFetcher) ChainFetcherMetadata() []pairingtypes.Metadata {
}

func (cf *ChainFetcher) FetchLatestBlockNum(ctx context.Context) (int64, error) {
parsing, collectionData, ok := cf.chainParser.GetParsingByTag(spectypes.FUNCTION_TAG_GET_BLOCKNUM)
parsing, apiCollection, ok := cf.chainParser.GetParsingByTag(spectypes.FUNCTION_TAG_GET_BLOCKNUM)
tagName := spectypes.FUNCTION_TAG_GET_BLOCKNUM.String()
if !ok {
return spectypes.NOT_APPLICABLE, utils.LavaFormatError(tagName+" tag function not found", nil, []utils.Attribute{{Key: "chainID", Value: cf.endpoint.ChainID}, {Key: "APIInterface", Value: cf.endpoint.ApiInterface}}...)
}
collectionData := apiCollection.CollectionData
var craftData *CraftData
if parsing.FunctionTemplate != "" {
path := parsing.ApiName
Expand Down Expand Up @@ -321,11 +322,13 @@ func (cf *ChainFetcher) constructRelayData(conectionType string, path string, da
}

func (cf *ChainFetcher) FetchBlockHashByNum(ctx context.Context, blockNum int64) (string, error) {
parsing, collectionData, ok := cf.chainParser.GetParsingByTag(spectypes.FUNCTION_TAG_GET_BLOCK_BY_NUM)
parsing, apiCollection, ok := cf.chainParser.GetParsingByTag(spectypes.FUNCTION_TAG_GET_BLOCK_BY_NUM)
tagName := spectypes.FUNCTION_TAG_GET_BLOCK_BY_NUM.String()
if !ok {
return "", utils.LavaFormatError(tagName+" tag function not found", nil, []utils.Attribute{{Key: "chainID", Value: cf.endpoint.ChainID}, {Key: "APIInterface", Value: cf.endpoint.ApiInterface}}...)
}
collectionData := apiCollection.CollectionData

if parsing.FunctionTemplate == "" {
return "", utils.LavaFormatError(tagName+" missing function template", nil, []utils.Attribute{{Key: "chainID", Value: cf.endpoint.ChainID}, {Key: "APIInterface", Value: cf.endpoint.ApiInterface}}...)
}
Expand Down
Loading
Loading