-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cmd/rpc): Automatically detect running node for RPC requests (#3246
) Closes #2859. TL;DR Previously, the node.store flag had to be specified manually for each RPC request. This commit introduces automatic detection of the running node. Assumptions: - presence of lock indicates a running node - specific order of networks (mainnet, mocha, arabica, private, custom) and type (bridge, full, light) - 1 network will only have 1 running node type. multiple nodes of same network, same type are disallowed (receive `Error: node: store is in use`). - auth token, other flags still retain prev behavior and have priority - address, port read in from config - skipAuth skips auth for trusted setups - aligns with Unix daemon conventions - non-default node store & cel-key still require config flags **Sample Test Cases** 1. Node store set ``` ❯ celestia blob get 1318129 0x42690c204d39600fddd3 0MFhYKQUi2BU+U1jxPzG7QY2BVV1lb3kiU+zAK7nUiY= --node.store=$NODE_STORE { "result": { "namespace": "AAAAAAAAAAAAAAAAAAAAAAAAAEJpDCBNOWAP3dM=", "data": "0x676d", "share_version": 0, "commitment": "0MFhYKQUi2BU+U1jxPzG7QY2BVV1lb3kiU+zAK7nUiY=", "index": 23 } } ``` 2. Node store not set, but flag specified ``` ❯ celestia blob get 1318129 0x42690c204d39600fddd3 0MFhYKQUi2BU+U1jxPzG7QY2BVV1lb3kiU+zAK7nUiY= --node.store= Error: cant access the auth token: root directory was not specified: unable to load in config: open config.toml: no such file or directory ``` 3. No node store flag specified, yay ``` ❯ celestia blob get 1318129 0x42690c204d39600fddd3 0MFhYKQUi2BU+U1jxPzG7QY2BVV1lb3kiU+zAK7nUiY= { // valid result, same as 1. } ``` 4. Multiple networks running, will go to mainnet before mocha ``` ❯ celestia blob get 1318129 0x42690c204d39600fddd3 0MFhYKQUi2BU+U1jxPzG7QY2BVV1lb3kiU+zAK7nUiY= { "result": "RPC client error: sendRequest failed: http status 401 Unauthorized unmarshaling response: EOF" } ``` 5. Multiple networks running, will go to mocha before arabica ``` ❯ celestia blob get 1318129 0x42690c204d39600fddd3 0MFhYKQUi2BU+U1jxPzG7QY2BVV1lb3kiU+zAK7nUiY= { "result": "header: given height is from the future: networkHeight: 802095, requestedHeight: 1318129" } ``` 6. Run node with rpc config Address: 0.0.0.1 and Port: 25231 -- accurately directs request ``` ❯ celestia blob get 1318129 0x42690c204d39600fddd3 0MFhYKQUi2BU+U1jxPzG7QY2BVV1lb3kiU+zAK7nUiY= { "result": "RPC client error: sendRequest failed: Post \"http://0.0.0.1:25231\": dial tcp 0.0.0.1:25231: connect: no route to host" } ``` 7. Run node with --rpc.skip_auth=true and config with SkipAuth: true (prints log in rpc/server [here](https://github.com/celestiaorg/celestia-node/blob/main/api/rpc/server.go#L57)) ``` ❯ celestia blob get 1318129 0x42690c204d39600fddd3 0MFhYKQUi2BU+U1jxPzG7QY2BVV1lb3kiU+zAK7nUiY= { // valid result, same as 1. } ``` 8. Run node with --rpc.skip_auth=true and config with SkipAuth: false (server skips auth, prints log in rpc/server [here](https://github.com/celestiaorg/celestia-node/blob/main/api/rpc/server.go#L57)) ``` ❯ celestia blob get 1318129 0x42690c204d39600fddd3 0MFhYKQUi2BU+U1jxPzG7QY2BVV1lb3kiU+zAK7nUiY= { // valid result, same as 1. } ``` Co-authored-by: Samwise Gamgee <samwisegamgee369@proton.me>
- Loading branch information
1 parent
ad04298
commit 29678cb
Showing
9 changed files
with
269 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.