From 7aa15ab5d047ebc48a72f32e7d3f9cbe5d8c1445 Mon Sep 17 00:00:00 2001 From: Eric <5089238+emizzle@users.noreply.github.com> Date: Tue, 24 Sep 2024 15:25:11 +1000 Subject: [PATCH] Uses --persistence in the two node test --- docs/TwoClientTest.md | 56 +++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 37 deletions(-) diff --git a/docs/TwoClientTest.md b/docs/TwoClientTest.md index 4859247c..197e5192 100644 --- a/docs/TwoClientTest.md +++ b/docs/TwoClientTest.md @@ -8,7 +8,7 @@ Make sure you have built the client, and can run it as explained in the [README] ## Steps -### 0. Setup blockchain node (optional) +### 0. Setup blockchain node You need to have installed NodeJS and npm in order to spinup a local blockchain node. @@ -20,13 +20,12 @@ npm start This will launch a local Ganache blockchain. -### 1. Launch Node #1 - +### 1. Launch Node #1 - The Client Node Open a terminal and run: -- Mac/Unx: `"build/codex" --data-dir="$(pwd)/Data1" --listen-addrs="/ip4/127.0.0.1/tcp/8070" --api-port=8080 --disc-port=8090` -- Windows: `"build/codex.exe" --data-dir="Data1" --listen-addrs="/ip4/127.0.0.1/tcp/8070" --api-port=8080 --disc-port=8090` +- Mac/Unx: `build/codex --data-dir="$(pwd)/Data1" --listen-addrs="/ip4/127.0.0.1/tcp/8070" --api-port=8080 --disc-port=8090 persistence --eth-account=0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC` +- Windows: `build/codex.exe --data-dir="Data1" --listen-addrs="/ip4/127.0.0.1/tcp/8070" --api-port=8080 --disc-port=8090 persistence --eth-account=0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC` -Optionally, if you want to use the Marketplace blockchain functionality, you need to also include these flags: `--persistence --eth-account=`, where `account` can be one following: +Optionally, if you want to use different `eth-account` it can be one of following: - `0x70997970C51812dc3A010C7d01b50e0d17dc79C8` - `0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC` @@ -94,51 +93,32 @@ This GET request will return the node's debug information. The response will be | `table` | Table of nodes present in the node's DHT | `codex` | Codex version information -### 3. Launch Node #2 +### 3. Launch Node #2 - The Storage Provider Node We will need the signed peer record (SPR) from the first node that you got in the previous step. Replace `` in the following command with the SPR returned from the previous command. (Note that it should include the `spr:` at the beginning.) Open a new terminal and run: -- Mac/Linux: `"build/codex" --data-dir="$(pwd)/Data2" --listen-addrs=/ip4/127.0.0.1/tcp/8071 --api-port=8081 --disc-port=8091 --bootstrap-node=` -- Windows: `"build/codex.exe" --data-dir="Data2" --listen-addrs=/ip4/127.0.0.1/tcp/8071 --api-port=8081 --disc-port=8091 --bootstrap-node=` +- Mac/Linux: `"build/codex" --data-dir="$(pwd)/Data2" --listen-addrs=/ip4/127.0.0.1/tcp/8071 --api-port=8081 --disc-port=8091 --bootstrap-node= persistence --eth-account=0x90F79bf6EB2c4f870365E785982E1f101E93b906` +- Windows: `"build/codex.exe" --data-dir="Data2" --listen-addrs=/ip4/127.0.0.1/tcp/8071 --api-port=8081 --disc-port=8091 --bootstrap-node= persistence --eth-account=0x90F79bf6EB2c4f870365E785982E1f101E93b906` Alternatively on Mac, Linux, or MSYS2 and a recent Codex binary you can run it in one command like: ```sh -"build/codex" --data-dir="$(pwd)/Data2" --listen-addrs=/ip4/127.0.0.1/tcp/8071 --api-port=8081 --disc-port=8091 --bootstrap-node=$(curl -H "Accept: text/plain" http://127.0.0.1:8080/api/codex/v1/spr) +build/codex --data-dir="$(pwd)/Data2" --listen-addrs=/ip4/127.0.0.1/tcp/8071 --api-port=8081 --disc-port=8091 --bootstrap-node=$(curl -H "Accept: text/plain" http://127.0.0.1:8080/api/codex/v1/spr) \ + persistence --eth-account=0x90F79bf6EB2c4f870365E785982E1f101E93b906 --validator --validator-max-slots=1000 \ + prover \ + --circom-r1cs=vendor/codex-contracts-eth/verifier/networks/hardhat/proof_main.r1cs\ + --circom-wasm=vendor/codex-contracts-eth/verifier/networks/hardhat/proof_main.wasm\ + --circom-zkey=vendor/codex-contracts-eth/verifier/networks/hardhat/proof_main.zkey ``` Notice we're using a new data-dir, and we've increased each port number by one. This is needed so that the new node won't try to open ports already in use by the first node. We're now also including the `bootstrap-node` argument. This allows us to link the new node to another one, bootstrapping our own little peer-to-peer network. (SPR strings always start with "spr:".) -### 4. Connect The Two - -Normally the two nodes will automatically connect. If they do not automatically connect or you want to manually connect nodes you can use the peerId to connect nodes. - -You can get the first node's peer id by running the following command and finding the `"peerId"` in the results: - -```bash -curl -X GET -H "Accept: text/plain" http://127.0.0.1:8081/api/codex/v1/debug/info -``` - -Next replace `` in the following command with the peerId returned from the previous command: - -```bash -curl -X GET http://127.0.0.1:8080/api/codex/v1/connect/?addrs=/ip4/127.0.0.1/tcp/8071 -``` - -Alternatively on Mac, Linux, or MSYS2 and a recent Codex binary you can run it in one command like: - -```bash -curl -X GET http://127.0.0.1:8080/api/codex/v1/connect/$(curl -X GET -H "Accept: text/plain" http://127.0.0.1:8081/api/codex/v1/peerid)\?addrs=/ip4/127.0.0.1/tcp/8071 -``` - -Notice that we are sending the peerId and the multiaddress of node 2 to the `/connect` endpoint of node 1. This provides node 1 all the information it needs to communicate with node 2. The response to this request should be `Successfully connected to peer`. - -### 5. Upload The File +### 4. Upload The File We're now ready to upload a file to the network. In this example we'll use node 1 for uploading and node 2 for downloading. But the reverse also works. @@ -152,7 +132,7 @@ Next replace `` with the path to the file you want to upload in the f Depending on the file size this may take a moment. Codex is processing the file by cutting it into blocks and generating erasure-recovery data. When the process is finished, the request will return the content-identifier (CID) of the uploaded file. It should look something like `zdj7WVxH8HHHenKtid8Vkgv5Z5eSUbCxxr8xguTUBMCBD8F2S`. -### 6. Download The File +### 5. Download The File Replace `` with the identifier returned in the previous step. Replace `` with the filename where you want to store the downloaded file. @@ -162,10 +142,12 @@ Replace `` with the identifier returned in the previous step. Replace `