Skip to content

Commit

Permalink
feat: PRT - Support StarkNet pathfinder (#1666)
Browse files Browse the repository at this point in the history
* Exported the check of ws:// to a funciton

* Add support for StarkNet Pathfinder in the rpcclient

* Small script fix

* Improve the router key usage

* Fix to RouterKey to init with empty extension

* Fix internal paths issues

* Warn provider when the configured internal paths are different than onchain

* Small fix to the router key

* Update the starknet spec with new internal paths changes

* Fix lint

* Add test for new difference function

* Add more info to NodeUrl String func

* Prefer non internal path when choosing websocket as http node url

* Add TestChainRouterWithInternalPaths

* Add TestGetVerifications

* Small fix to the router key

* Add tests for the router key

* Add TestCraftChainMessage

* Post merge fix

* CR Fix: Reuse router key string

* Remove unused code

* Small test fix

* Add an example for starknet with internal paths

* CR Fix: Reduce conn map to one conn

* CR Fix: Move into if..else

* CR Fix: Remove unnecessary field

* CR Fix: Small bug fix

* CR Fix: Break if true

* dynamic internal path population

* Add ContainsPredicate to lavaslices

* Fixes to the router key

* Remove the warning of non configured internal paths

* Fix the chain router and its tests

---------

Co-authored-by: Omer <[email protected]>
Co-authored-by: Ran Mishael <[email protected]>
  • Loading branch information
3 people authored Nov 7, 2024
1 parent ba6f093 commit f7061ab
Show file tree
Hide file tree
Showing 28 changed files with 2,025 additions and 214 deletions.
17 changes: 17 additions & 0 deletions config/provider_examples/strk_example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
endpoints:
- api-interface: jsonrpc
chain-id: STRK
network-address:
address: "127.0.0.1:2220"
node-urls:
- url: <wss url here>/ws
internal-path: ""
- url: <wss url here>/ws/rpc/v0_6
internal-path: "/rpc/v0_6"

- url: <https url here>
internal-path: ""
- url: <https url here>/rpc/v0_5
internal-path: "/rpc/v0_5"
- url: <https url here>/rpc/v0_6
internal-path: "/rpc/v0_6"
323 changes: 323 additions & 0 deletions cookbook/specs/starknet.json
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,87 @@
}
]
},
{
"enabled": false,
"collection_data": {
"api_interface": "jsonrpc",
"internal_path": "WS-ONLY",
"type": "POST",
"add_on": ""
},
"apis": [
{
"name": "pathfinder_subscribe",
"block_parsing": {
"parser_arg": [
"latest"
],
"parser_func": "DEFAULT"
},
"compute_units": 1000,
"enabled": true,
"category": {
"deterministic": false,
"local": true,
"subscription": true,
"stateful": 0
},
"extra_compute_units": 0
},
{
"name": "pathfinder_unsubscribe",
"block_parsing": {
"parser_arg": [
"latest"
],
"parser_func": "DEFAULT"
},
"compute_units": 10,
"enabled": true,
"category": {
"deterministic": false,
"local": true,
"subscription": true,
"stateful": 0
},
"extra_compute_units": 0
}
],
"parse_directives": [
{
"function_tag": "SUBSCRIBE",
"api_name": "pathfinder_subscribe"
},
{
"function_template": "{\"jsonrpc\":\"2.0\",\"method\":\"pathfinder_unsubscribe\",\"params\":[%s],\"id\":1}",
"function_tag": "UNSUBSCRIBE",
"api_name": "pathfinder_unsubscribe"
}
]
},
{
"enabled": true,
"collection_data": {
"api_interface": "jsonrpc",
"internal_path": "/ws",
"type": "POST",
"add_on": ""
},
"inheritance_apis": [
{
"api_interface": "jsonrpc",
"internal_path": "",
"type": "POST",
"add_on": ""
},
{
"api_interface": "jsonrpc",
"internal_path": "WS-ONLY",
"type": "POST",
"add_on": ""
}
]
},
{
"enabled": true,
"collection_data": {
Expand Down Expand Up @@ -635,6 +716,69 @@
}
]
},
{
"enabled": true,
"collection_data": {
"api_interface": "jsonrpc",
"internal_path": "/ws/rpc/v0_6",
"type": "POST",
"add_on": ""
},
"inheritance_apis": [
{
"api_interface": "jsonrpc",
"internal_path": "/rpc/v0_6",
"type": "POST",
"add_on": ""
},
{
"api_interface": "jsonrpc",
"internal_path": "WS-ONLY",
"type": "POST",
"add_on": ""
}
]
},
{
"enabled": true,
"collection_data": {
"api_interface": "jsonrpc",
"internal_path": "/rpc/v0_7",
"type": "POST",
"add_on": ""
},
"inheritance_apis": [
{
"api_interface": "jsonrpc",
"internal_path": "",
"type": "POST",
"add_on": ""
}
]
},
{
"enabled": true,
"collection_data": {
"api_interface": "jsonrpc",
"internal_path": "/ws/rpc/v0_7",
"type": "POST",
"add_on": ""
},
"inheritance_apis": [
{
"api_interface": "jsonrpc",
"internal_path": "/rpc/v0_7",
"type": "POST",
"add_on": ""
},
{
"api_interface": "jsonrpc",
"internal_path": "WS-ONLY",
"type": "POST",
"add_on": ""
}
]
},
{
"enabled": true,
"collection_data": {
Expand Down Expand Up @@ -724,6 +868,93 @@
]
}
]
},
{
"enabled": true,
"collection_data": {
"api_interface": "jsonrpc",
"internal_path": "/rpc/pathfinder/v0.1",
"type": "POST",
"add_on": ""
},
"apis": [
{
"name": "pathfinder_version",
"block_parsing": {
"parser_arg": [
"latest"
],
"parser_func": "DEFAULT"
},
"compute_units": 10,
"enabled": true,
"category": {
"deterministic": true,
"local": false,
"subscription": false,
"stateful": 0
},
"extra_compute_units": 0
},
{
"name": "pathfinder_getProof",
"block_parsing": {
"parser_arg": [
"latest"
],
"parser_func": "DEFAULT"
},
"compute_units": 10,
"enabled": true,
"category": {
"deterministic": true,
"local": false,
"subscription": false,
"stateful": 0
},
"extra_compute_units": 0
},
{
"name": "pathfinder_getTransactionStatus",
"block_parsing": {
"parser_arg": [
"latest"
],
"parser_func": "DEFAULT"
},
"compute_units": 10,
"enabled": true,
"category": {
"deterministic": true,
"local": false,
"subscription": false,
"stateful": 0
},
"extra_compute_units": 0
}
],
"verifications": [
{
"name": "enabled",
"parse_directive": {
"function_template": "{\"jsonrpc\":\"2.0\",\"method\":\"pathfinder_version\",\"params\":[],\"id\":1}",
"function_tag": "VERIFICATION",
"result_parsing": {
"parser_arg": [
"latest"
],
"parser_func": "DEFAULT"
},
"api_name": "pathfinder_version"
},
"values": [
{
"expected_value": "*",
"severity": "Warning"
}
]
}
]
}
]
},
Expand Down Expand Up @@ -768,6 +999,29 @@
}
]
},
{
"enabled": true,
"collection_data": {
"api_interface": "jsonrpc",
"internal_path": "/ws",
"type": "POST",
"add_on": ""
},
"apis": [],
"headers": [],
"inheritance_apis": [],
"parse_directives": [],
"verifications": [
{
"name": "chain-id",
"values": [
{
"expected_value": "0x534e5f5345504f4c4941"
}
]
}
]
},
{
"enabled": true,
"collection_data": {
Expand All @@ -791,6 +1045,29 @@
}
]
},
{
"enabled": true,
"collection_data": {
"api_interface": "jsonrpc",
"internal_path": "/ws/rpc/v0_6",
"type": "POST",
"add_on": ""
},
"apis": [],
"headers": [],
"inheritance_apis": [],
"parse_directives": [],
"verifications": [
{
"name": "chain-id",
"values": [
{
"expected_value": "0x534e5f5345504f4c4941"
}
]
}
]
},
{
"enabled": true,
"collection_data": {
Expand All @@ -813,6 +1090,52 @@
]
}
]
},
{
"enabled": true,
"collection_data": {
"api_interface": "jsonrpc",
"internal_path": "/rpc/v0_7",
"type": "POST",
"add_on": ""
},
"apis": [],
"headers": [],
"inheritance_apis": [],
"parse_directives": [],
"verifications": [
{
"name": "chain-id",
"values": [
{
"expected_value": "0x534e5f5345504f4c4941"
}
]
}
]
},
{
"enabled": true,
"collection_data": {
"api_interface": "jsonrpc",
"internal_path": "/ws/rpc/v0_7",
"type": "POST",
"add_on": ""
},
"apis": [],
"headers": [],
"inheritance_apis": [],
"parse_directives": [],
"verifications": [
{
"name": "chain-id",
"values": [
{
"expected_value": "0x534e5f5345504f4c4941"
}
]
}
]
}
]
}
Expand Down
Loading

0 comments on commit f7061ab

Please sign in to comment.