- To demonstrate how to connect to cardano nodes as a node
- Configure cardano nodes in configuration file viz. App.yaml
- I/O should be non-blocking
- Represent messages as close to CDDL encoding specification mentioned in Ref. 3.6.5 (Node to node handshake mini-protocol) section of 'network spec' of cardano.
- Handling cardano node responses viz Succuess & Errors
- Test cases to demonstrate usages of functions
- Documentation
- How to run cardano-node locally
- Documenting cardano handshake mini-protocol relevant for this application in PROTOCOL.md file
- Adding references
- In future what can be added
- Read list of hosts from App.yaml config
- For each host:
- open a TCP connection with the node
- negotiating the protocol version with the handshake mini-protocol
- discovering and classifying exceptions thrown by mini-protocols
- In case of an error, print the error message received
- Print the time to complete negotiation
- Close the TCP connection and shutdown thread
- Exit when handshake with all nodes are attempted
-
Open link given in Reference [5]. Check at the bottom of the page, section 'Assets'.
-
Download cardano-node-8.1.2-linux.tar.gz or your platform specific file from Assets section.
-
Extract folder under local user's bin folder viz. ~/bin/cardano-node-8.1.2
- Which means cardano-node binary is available at ~/bin/cardano-node-8.1.2/cardano-node location
-
Open link given in Reference [4]. Download files named mentioned below, and store it under './cardano-rust-node/cardano-local folder' which is under current project's root folder.
- Node Config
- DB Sync Config
- Submit API Config
- Node Topology
- Byron Genesis
- Shelley Genesis
- Alonzo Genesis
- Conway Genesis
-
Open command line and cd to ./cardano-rust-node/cardano-local folder.
-
Run command below to run cardano-node
~/bin/cardano-node-8.1.2/cardano-node run \ --topology ./topology.json \ --database-path ./db \ --socket-path ./db/node.socket \ --host-addr 0.0.0.0 \ --port 3001 \ --config ./config.json
-
It will create db folder when above command is run. Also above command expects all configs to be in same folder.
This file externalizes configurations. It has host names & magic numbers of cardano nodes such as mainnet, testnet and also local node run by above command. These nodes will be used by the code to perform handshake negotiation.
-
Success Scenario: with local cardano-node
- Run local cardano-node with the help of section 3. above.
- No change in App.yaml file. It uses local node configuration.
- Run command:
- RUST_LOG=info cargo run --release
-
Success Scenario: with "Main Net"
-
Enable "Main Net" section of hosts and disable "Local Dev Net" section of hosts parameter. Config will look like this:
hosts: # Main Net - network_id: "Main_Net" host: "relays-new.cardano-mainnet.iohk.io:3001" network_magic: 764824073 . . # Local Dev Net #- network_id: "Local_Dev_Net" #host: "0.0.0.0:3001" #network_magic: 1
Note: In Above config sample . in between vertical values represents other existing config should be kept as it is.
-
Run command:
- RUST_LOG=info cargo run --release
-
-
RefuseReasonVersionMismatch Scenario: Version 3 not supported
-
Run local cardano-node with the help of section 3. above.
-
Change App.yaml file. In supported_versions section, enable 3 version and disable rest of the versions. Keep "hosts" section as per 1st or 2nd scenario. "supported_versions" section will be as below:
supported_versions: # RefuseReasonVersionMismatch scenario - 3 # Success scenario #- 7 #- 8 #- 9 #- 10 # RefuseReasonHandshakeDecodeError scenario #- 11
-
Run command:
- RUST_LOG=info cargo run --release
-
-
RefuseReasonHandshakeDecodeError Scenario: Version 11 needs extra parameters which is yet to be implemented, thus decode error.
-
Run local cardano-node with the help of section 3. above.
-
Change App.yaml file. In supported_versions section, enable 3 version and disable rest of the versions. Keep "hosts" section as per 1st or 2nd scenario. "supported_versions" section will be as below:
supported_versions: # RefuseReasonVersionMismatch scenario #- 3 # Success scenario #- 7 #- 8 #- 9 #- 10 # RefuseReasonHandshakeDecodeError scenario - 11
-
Run command:
- RUST_LOG=info cargo run --release
-
-
Test cases execution:
There are two ways to run test cases. First way:
cargo test -- --nocapture
Second way: Install nextest using command
cargo install nextest
Then run below command:
cargo nextest run
- Server failure response with RefuseReason is handled
- If there is wrong message passed to server, it sends error code 104 (DecodeFailure). And shuts down the connection. Handled gracefully.
- Provide way to connect as a Client to other cardano-nodes
- Support for ≥ 11 version_numbers in protocol
- https://input-output-hk.github.io/ouroboros-network/pdfs/network-spec/network-spec.pdf
- https://input-output-hk.github.io/ouroboros-network/ouroboros-network-framework/Ouroboros-Network-Protocol-Handshake-Type#t:Handshake
- https://github.com/input-output-hk/ouroboros-network/blob/d4e8622955145c97d49cbeb85d964d6b44ed87b7/ouroboros-network-framework/src/Ouroboros/Network/Protocol/Handshake.hs#L8
- https://book.world.dev.cardano.org/environments.html#pre-production-testnet
- https://github.com/input-output-hk/cardano-node/releases/tag/8.1.2
General Reading about cardano nodes:
- https://docs.cardano.org/explore-cardano/cardano-network/about-the-cardano-network/
- https://developers.cardano.org/docs/get-started/testnets-and-devnets/
- https://developers.cardano.org/docs/integrate-cardano/testnet-faucet
- https://docs.cardano.org/explore-cardano/cardano-network/p2p-networking/
- https://developers.cardano.org/docs/get-started/running-cardano/