|
| 1 | +# Using the Portal Network REPL Client |
| 2 | + |
| 3 | +This document explains the usage and functionality of the Portal Network REPL client script. The script initializes a Portal Network node and allows interaction with it via a REPL (Read-Eval-Print Loop) interface. |
| 4 | + |
| 5 | +## Initialization |
| 6 | + |
| 7 | +The script can be started directly and initializes a Portal Network node with a REPL interface. It binds to a specified UDP port (default: `9090`). |
| 8 | + |
| 9 | +### Start the Client |
| 10 | + |
| 11 | +```bash |
| 12 | +npx tsx examples/portalReplClient.ts |
| 13 | +``` |
| 14 | + |
| 15 | +The REPL interface will start with the `portal>` prompt. |
| 16 | + |
| 17 | +### Default Options |
| 18 | + |
| 19 | +| Option | Description | Default | |
| 20 | +|-----------|----------------------------------|---------| |
| 21 | +| `--port` | Port number for the UDP binding | `9090` | |
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | +## Supported Networks |
| 26 | + |
| 27 | +The client supports two Portal Network types: |
| 28 | +- **History Network** (`0x500b`) |
| 29 | +- **State Network** (`0x500a`) |
| 30 | + |
| 31 | +--- |
| 32 | + |
| 33 | +## REPL Commands |
| 34 | + |
| 35 | +The following commands are supported in the REPL interface: |
| 36 | + |
| 37 | +### 1. `debug` |
| 38 | +Set debug topics for logging. |
| 39 | + |
| 40 | +**Usage**: |
| 41 | +```bash |
| 42 | +portal> .debug <topics> |
| 43 | +``` |
| 44 | +**Example**: |
| 45 | +```bash |
| 46 | +portal> .debug *Portal*,*uTP* |
| 47 | +``` |
| 48 | + |
| 49 | +--- |
| 50 | + |
| 51 | +### 2. `bootstrap` |
| 52 | +Bootstrap the Portal Network by connecting to default bootnodes. |
| 53 | + |
| 54 | +**Usage**: |
| 55 | +```bash |
| 56 | +portal> .bootstrap |
| 57 | +``` |
| 58 | + |
| 59 | +--- |
| 60 | + |
| 61 | +### 3. `ping` |
| 62 | +Send a ping to a specified network. |
| 63 | + |
| 64 | +**Usage**: |
| 65 | +```bash |
| 66 | +portal> .ping <network> |
| 67 | +``` |
| 68 | +**Example**: |
| 69 | +```bash |
| 70 | +portal> .ping history |
| 71 | +``` |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +### 4. `findnodes` |
| 76 | +Find nodes in the network by ENR and distance(s). |
| 77 | + |
| 78 | +**Usage**: |
| 79 | +```bash |
| 80 | +portal> .findnodes <network> <enr> <distances> |
| 81 | +``` |
| 82 | +**Example**: |
| 83 | +```bash |
| 84 | +portal> .findnodes history enr:-... 256 512 |
| 85 | +``` |
| 86 | + |
| 87 | +--- |
| 88 | + |
| 89 | +### 5. `findcontent` |
| 90 | +Find content by content key in the network. |
| 91 | + |
| 92 | +**Usage**: |
| 93 | +```bash |
| 94 | +portal> .findcontent <network> <enr> <contentKey> |
| 95 | +``` |
| 96 | +**Example**: |
| 97 | +```bash |
| 98 | +portal> .findcontent history enr:-... 0xabc123 |
| 99 | +``` |
| 100 | + |
| 101 | +--- |
| 102 | + |
| 103 | +### 6. `offer` |
| 104 | +Offer content to a specific network. |
| 105 | + |
| 106 | +**Usage**: |
| 107 | +```bash |
| 108 | +portal> .offer <network> <enr> <contentKey> <contentValue> |
| 109 | +``` |
| 110 | +**Example**: |
| 111 | +```bash |
| 112 | +portal> .offer state enr:-... 0xabc123 "Hello World" |
| 113 | +``` |
| 114 | + |
| 115 | +--- |
| 116 | + |
| 117 | +### 7. `addENR` |
| 118 | +Add an ENR to the local routing table. |
| 119 | + |
| 120 | +**Usage**: |
| 121 | +```bash |
| 122 | +portal> .addENR <network> <enr> |
| 123 | +``` |
| 124 | +**Example**: |
| 125 | +```bash |
| 126 | +portal> .addENR history enr:-... |
| 127 | +``` |
| 128 | + |
| 129 | +--- |
| 130 | + |
| 131 | +### 8. `status` |
| 132 | +Display the current status of the Portal Network node. |
| 133 | + |
| 134 | +**Usage**: |
| 135 | +```bash |
| 136 | +portal> .status |
| 137 | +``` |
| 138 | + |
| 139 | +--- |
| 140 | + |
| 141 | +## Example Workflow |
| 142 | + |
| 143 | +1. **Initialize the Portal Network node**: |
| 144 | + ```bash |
| 145 | + npx tsx examples/portalReplClient.ts |
| 146 | + ``` |
| 147 | + |
| 148 | +2. **Bootstrap the network**: |
| 149 | + ```bash |
| 150 | + portal> .bootstrap |
| 151 | + ``` |
| 152 | + |
| 153 | +3. **Send a ping to the History Network**: |
| 154 | + ```bash |
| 155 | + portal> .ping history |
| 156 | + ``` |
| 157 | + |
| 158 | +4. **Find nodes in the State Network**: |
| 159 | + ```bash |
| 160 | + portal> .findnodes state enr:-... 246 256 |
| 161 | + ``` |
| 162 | + |
| 163 | +5. **Offer content to the History Network**: |
| 164 | + ```bash |
| 165 | + portal> .offer history enr:-... 0xkey "sample content" |
| 166 | + ``` |
| 167 | + |
| 168 | +6. **Check the status**: |
| 169 | + ```bash |
| 170 | + portal> .status |
| 171 | + ``` |
| 172 | + |
| 173 | +--- |
| 174 | + |
| 175 | +## Notes |
| 176 | + |
| 177 | +- Replace `enr:-...` with the actual ENR (Ethereum Node Record) for the target node. |
| 178 | +- Use valid `contentKey` (hex strings) and `contentValue` (text strings) for `findcontent` and `offer` commands. |
| 179 | +- Logs can be customized using the `.debug` command with appropriate topics. |
0 commit comments