Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

refactor subnet ID and chain ID infered from subnet ID #217

Merged
merged 7 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
/target
docs/diagrams/plantuml.jar
bin
/lotus
/lotus
fx.dot
testing/itest/logs
10 changes: 6 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ tokio-stream = "0.1.12"
tokio-graceful-shutdown = "0.12.1"
tokio-tungstenite = { version = "0.18.0", features = ["native-tls"] }
derive_builder = "0.12.0"
num-traits = "0.2.15"
num-traits = { workspace = true }
num-derive = "0.3.3"
env_logger = "0.10.0"
base64 = { workspace = true }
Expand Down Expand Up @@ -61,6 +61,7 @@ tempfile = "3.4.0"

[workspace.dependencies]
anyhow = "1.0"
num-traits = "0.2.15"
base64 = "0.21.0"
lazy_static = "1.4"
log = "0.4"
Expand All @@ -79,9 +80,9 @@ fvm_ipld_blockstore = "0.1"
fvm_ipld_encoding = "0.3"
fvm_shared = { version = "=3.0.0-alpha.17", default-features = false, features = ["crypto"] }
fil_actors_runtime = { git = "https://github.com/consensus-shipyard/fvm-utils", features = ["fil-actor"] }
ipc-sdk = { git = "https://github.com/consensus-shipyard/ipc-actors.git", tag = "v0.2.0" }
ipc-subnet-actor = { git = "https://github.com/consensus-shipyard/ipc-actors.git", features = [], tag = "v0.2.0" }
ipc-gateway = { git = "https://github.com/consensus-shipyard/ipc-actors.git", features = [], tag = "v0.2.0" }
ipc-sdk = { git = "https://github.com/consensus-shipyard/ipc-actors.git", branch = "adlrocha/subnetid-refactor" }
ipc-subnet-actor = { git = "https://github.com/consensus-shipyard/ipc-actors.git", features = [], branch = "adlrocha/subnetid-refactor" }
ipc-gateway = { git = "https://github.com/consensus-shipyard/ipc-actors.git", features = [], branch = "adlrocha/subnetid-refactor" }
ipc_ipld_resolver = { git = "https://github.com/consensus-shipyard/ipc-ipld-resolver.git", branch = "main" }
libipld = { version = "0.14", default-features = false, features = ["dag-cbor"] }
primitives = { git = "https://github.com/consensus-shipyard/fvm-utils" }
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ For instance, running `./bin/ipc-infra/run-root-docker-1val.sh 1234 1235` will r
$ ./bin/ipc-infra/run-root-docker-1val.sh 1234 1235
(...)
>>> Root daemon running in container: 84711d67cf162e30747c4525d69728c4dea8c6b4b35cd89f6d0947fee14bf908
>>> Token to /root daemon: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBbGxvdyI6WyJyZWFkIiwid3JpdGUiLCJzaWduIiwiYWRtaW4iXX0.j94YYOr8_AWhGGHQd0q8JuQVuNhJA017SK9EUkqDOO0
>>> Token to /r31415926 daemon: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBbGxvdyI6WyJyZWFkIiwid3JpdGUiLCJzaWduIiwiYWRtaW4iXX0.j94YYOr8_AWhGGHQd0q8JuQVuNhJA017SK9EUkqDOO0
>>> Default wallet: t1cp4q4lqsdhob23ysywffg2tvbmar5cshia4rweq
```
This information will be relevant to configure our agent to connect to this rootnet node.
Expand All @@ -117,20 +117,20 @@ The default config path for the agent is `~/.ipc-agent/config.toml`. The agent w
./bin/ipc-agent config init
```

The `/root` section of the agent's `config.toml` must be updated to connect to your node. In the examples above, we need to set the endpoint of our rootnet node to be `127.0.0.1:1234`, and replace the `auth_token` and `account` with the ones provided by our node.
The `/r31415926` section of the agent's `config.toml` must be updated to connect to your node. In the examples above, we need to set the endpoint of our rootnet node to be `127.0.0.1:1234`, and replace the `auth_token` and `account` with the ones provided by our node.

*Example*:
```toml
[[subnets]]
id = "/root"
gateway_addr = "t064"
id = "/r31415926"
gateway_addr = "f064"
network_name = "root"
jsonrpc_api_http = "http://127.0.0.1:1234/rpc/v1"
auth_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBbGxvdyI6WyJyZWFkIiwid3JpdGUiLCJzaWduIiwiYWRtaW4iXX0.j94YYOr8_AWhGGHQd0q8JuQVuNhJA017SK9EUkqDOO0"
accounts = ["t1cp4q4lqsdhob23ysywffg2tvbmar5cshia4rweq"]
```

> 💡 In the current implementation of Spacenet, the gateway is always deployed in the `t064` address. This should be the address always reflected on your config for the gateway. In the future, this will change, and the gateway may be deployed in different addresses.
> 💡 In the current implementation of Spacenet, the gateway is always deployed in the `f064` address. This should be the address always reflected on your config for the gateway. In the future, this will change, and the gateway may be deployed in different addresses.

> 💡 If you are already running the daemon, then run `./bin/ipc-agent config reload` to pick up the config changes.

Expand All @@ -148,8 +148,8 @@ To check if the agent has connected to the rootnet successfully, you can try usi

*Example*:
```console
$ ./bin/ipc-agent wallet new --key-type bls --subnet /root
2023-03-30T12:01:11Z INFO ipc_agent::cli::commands::manager::wallet] created new wallet with address WalletNewResponse { address: "t1om5pijjq5dqic4ccnqqrvv6zgzwrlxf6bh2apvi" } in subnet "/root"
$ ./bin/ipc-agent wallet new --key-type bls --subnet /r31415926
2023-03-30T12:01:11Z INFO ipc_agent::cli::commands::manager::wallet] created new wallet with address WalletNewResponse { address: "t1om5pijjq5dqic4ccnqqrvv6zgzwrlxf6bh2apvi" } in subnet "/r31415926"
```

## Help
Expand Down
4 changes: 2 additions & 2 deletions config/template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ json_rpc_address = "127.0.0.1:3030"
[subnets]

[[subnets]]
id = "/root"
id = "/r31415926"
network_name = "root"
gateway_addr = "t064"
jsonrpc_api_http = "https://example.org/rpc/v0"
jsonrpc_api_ws = "wss://example.org/rpc/v0"
auth_token = "YOUR ROOT AUTH TOKEN"

[[subnets]]
id = "/root/t0100"
id = "/r31415926/t0100"
network_name = "child"
gateway_addr = "t064"
jsonrpc_api_http = "https://example.org/rpc/v2"
Expand Down
6 changes: 3 additions & 3 deletions docs/contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ In order to connect the Ethereum tooling to your subnet, you'll need to get the
./bin/ipc-agent subnet rpc --subnet <subnet-id>

# Sample command
$ ./bin/ipc-agent subnet rpc --subnet /root/t01002
[2023-05-17T15:10:57Z INFO ipc_agent::cli::commands::subnet::rpc] rpc endpoint for subnet /root/t01002: http://127.0.0.1:1240/rpc/v1
[2023-05-17T15:10:57Z INFO ipc_agent::cli::commands::subnet::rpc] chainID for subnet /root/t01002: 31415926
$ ./bin/ipc-agent subnet rpc --subnet /r31415926/t2xwzbdu7z5sam6hc57xxwkctciuaz7oe5omipwbq
[2023-05-17T15:10:57Z INFO ipc_agent::cli::commands::subnet::rpc] rpc endpoint for subnet /r31415926/t2xwzbdu7z5sam6hc57xxwkctciuaz7oe5omipwbq: http://127.0.0.1:1240/rpc/v1
[2023-05-17T15:10:57Z INFO ipc_agent::cli::commands::subnet::rpc] chainID for subnet /r31415926/t2xwzbdu7z5sam6hc57xxwkctciuaz7oe5omipwbq: 31415926
```

You can also inspect the `json_rpcapi_http` field of your subnet on your config directly to get the RPC endpoint for your subnet.
Expand Down
14 changes: 7 additions & 7 deletions docs/ipc_postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"id\": 1,\n \"method\": \"Filecoin.IPCListChildSubnets\",\n \"params\": [\n \"t064\"\n ],\n \"jsonrpc\": \"2.0\"\n}",
"raw": "{\n \"id\": 1,\n \"method\": \"Filecoin.IPCListChildSubnets\",\n \"params\": [\n \"f064\"\n ],\n \"jsonrpc\": \"2.0\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -42,7 +42,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"id\": 1,\n \"method\": \"ipc_listChildSubnets\",\n \"params\": {\n \"gateway_address\": \"t064\",\n \"subnet_id\": \"/root\"\n },\n \"jsonrpc\": \"2.0\"\n}",
"raw": "{\n \"id\": 1,\n \"method\": \"ipc_listChildSubnets\",\n \"params\": {\n \"gateway_address\": \"f064\",\n \"subnet_id\": \"/r31415926\"\n },\n \"jsonrpc\": \"2.0\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -70,7 +70,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"id\": 1,\n \"method\": \"ipc_joinSubnet\",\n \"params\": {\n \"subnet\": \"/root/t01003\",\n \"collateral\": 10,\n \"min_validators\": 0,\n \"validator_net_addr\": \"test\"\n },\n \"jsonrpc\": \"2.0\"\n}",
"raw": "{\n \"id\": 1,\n \"method\": \"ipc_joinSubnet\",\n \"params\": {\n \"subnet\": \"/r31415926/t01003\",\n \"collateral\": 10,\n \"min_validators\": 0,\n \"validator_net_addr\": \"test\"\n },\n \"jsonrpc\": \"2.0\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -98,7 +98,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"id\": 1,\n \"method\": \"ipc_leaveSubnet\",\n \"params\": {\n \"subnet\": \"/root/t01003\"\n },\n \"jsonrpc\": \"2.0\"\n}",
"raw": "{\n \"id\": 1,\n \"method\": \"ipc_leaveSubnet\",\n \"params\": {\n \"subnet\": \"/r31415926/t01003\"\n },\n \"jsonrpc\": \"2.0\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -126,7 +126,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"id\": 1,\n \"method\": \"ipc_killSubnet\",\n \"params\": {\n \"subnet\": \"/root/t01003\"\n },\n \"jsonrpc\": \"2.0\"\n}",
"raw": "{\n \"id\": 1,\n \"method\": \"ipc_killSubnet\",\n \"params\": {\n \"subnet\": \"/r31415926/t01003\"\n },\n \"jsonrpc\": \"2.0\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -154,7 +154,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"id\": 1,\n \"method\": \"ipc_queryValidatorSet\",\n \"params\": {\n \"subnet\": \"/root/t01003\",\n \"tip_set\": \"bafy2bzaced5izm5ns454dlu5niyhunullvjgyepft3gsycziwbem75zom5mx4\"\n },\n \"jsonrpc\": \"2.0\"\n}",
"raw": "{\n \"id\": 1,\n \"method\": \"ipc_queryValidatorSet\",\n \"params\": {\n \"subnet\": \"/r31415926/t01003\",\n \"tip_set\": \"bafy2bzaced5izm5ns454dlu5niyhunullvjgyepft3gsycziwbem75zom5mx4\"\n },\n \"jsonrpc\": \"2.0\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -182,7 +182,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"id\": 1,\n \"method\": \"ipc_createSubnet\",\n \"params\": {\n \"parent\": \"/root\",\n \"name\": \"test2\",\n \"min_validator_stake\": 1,\n \"min_validators\": 0,\n \"finality_threshold\": 2,\n \"check_period\": 10\n },\n \"jsonrpc\": \"2.0\"\n}",
"raw": "{\n \"id\": 1,\n \"method\": \"ipc_createSubnet\",\n \"params\": {\n \"parent\": \"/r31415926\",\n \"name\": \"test2\",\n \"min_validator_stake\": 1,\n \"min_validators\": 0,\n \"finality_threshold\": 2,\n \"check_period\": 10\n },\n \"jsonrpc\": \"2.0\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down
36 changes: 18 additions & 18 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ nano ~/.ipc-agent/config.toml
json_rpc_address = "0.0.0.0:3030"

[[subnets]]
id = "/root"
id = "/r31415926"
gateway_addr = "t064"
network_name = "root"
network_name = "andromeda"
jsonrpc_api_http = "http://127.0.0.1:1234/rpc/v1"
auth_token = "<AUTH_TOKEN_0>"
accounts = []
Expand Down Expand Up @@ -123,11 +123,11 @@ accounts = ["<WALLET_0>"]

## Step 4: Create the subnet

* The next step is to create a subnet under `/root`
* The next step is to create a subnet under `/r31415926`
```bash
./ipc-agent/bin/ipc-agent subnet create --parent /root --name andromeda --min-validator-stake 1 --min-validators 2 --bottomup-check-period 30 --topdown-check-period 30
./ipc-agent/bin/ipc-agent subnet create --parent /r31415926 --name andromeda --min-validator-stake 1 --min-validators 2 --bottomup-check-period 30 --topdown-check-period 30
```
* Make a note of the address of the subnet you created (`/root/<SUBNET_ID>`)
* Make a note of the address of the subnet you created (`/r31415926/<SUBNET_ID>`)


## Step 5: Create and export validator wallets
Expand All @@ -148,9 +148,9 @@ Although we set a minimum of 2 active validators in the previous, we'll deploy 3
```
* We also need to fund the wallets with enough collateral to; we'll send the funds from our default wallet
```bash
./ipc-agent/bin/ipc-agent subnet send-value --subnet /root --to <WALLET_1> 2
./ipc-agent/bin/ipc-agent subnet send-value --subnet /root --to <WALLET_2> 2
./ipc-agent/bin/ipc-agent subnet send-value --subnet /root --to <WALLET_3> 2
./ipc-agent/bin/ipc-agent subnet send-value --subnet /r31415926 --to <WALLET_1> 2
./ipc-agent/bin/ipc-agent subnet send-value --subnet /r31415926 --to <WALLET_2> 2
./ipc-agent/bin/ipc-agent subnet send-value --subnet /r31415926 --to <WALLET_3> 2
```


Expand All @@ -160,14 +160,14 @@ We can deploy the subnet nodes. Note that each node should be importing a differ

* Deploy and run a container for each validator, importing the corresponding wallet keys
```bash
./ipc-agent/bin/ipc-infra/run-subnet-docker.sh 1251 1351 /root/<SUBNET_ID> ~/.ipc-agent/wallet1.key
./ipc-agent/bin/ipc-infra/run-subnet-docker.sh 1252 1352 /root/<SUBNET_ID> ~/.ipc-agent/wallet2.key
./ipc-agent/bin/ipc-infra/run-subnet-docker.sh 1253 1353 /root/<SUBNET_ID> ~/.ipc-agent/wallet3.key
./ipc-agent/bin/ipc-infra/run-subnet-docker.sh 1251 1351 /r31415926/<SUBNET_ID> ~/.ipc-agent/wallet1.key
./ipc-agent/bin/ipc-infra/run-subnet-docker.sh 1252 1352 /r31415926/<SUBNET_ID> ~/.ipc-agent/wallet2.key
./ipc-agent/bin/ipc-infra/run-subnet-docker.sh 1253 1353 /r31415926/<SUBNET_ID> ~/.ipc-agent/wallet3.key
```
* If the deployment is successful, each of these nodes should return the following output at the end of their logs. Save the information for the next step.
```
>>> Subnet /root/<SUBNET_ID> daemon running in container: <CONTAINER_ID_#> (friendly name: <CONTAINER_NAME_#>)
>>> Token to /root/<SUBNET_ID> daemon: <AUTH_TOKEN_#>
>>> Subnet /r31415926/<SUBNET_ID> daemon running in container: <CONTAINER_ID_#> (friendly name: <CONTAINER_NAME_#>)
>>> Token to /r31415926/<SUBNET_ID> daemon: <AUTH_TOKEN_#>
>>> Default wallet: <WALLET_#>
>>> Subnet validator info:
<VALIDATOR_ADDR_#>
Expand All @@ -186,7 +186,7 @@ nano ~/.ipc-agent/config.toml
* Append the new subnet to the configuration
```toml
[[subnets]]
id = "/root/<SUBNET_ID>"
id = "/r31415926/<SUBNET_ID>"
gateway_addr = "t064"
network_name = "andromeda"
jsonrpc_api_http = "http://127.0.0.1:1251/rpc/v1"
Expand All @@ -205,9 +205,9 @@ All the infrastructure for the subnet is now deployed, and we can join our valid

* Join the subnet with each validator
```bash
./ipc-agent/bin/ipc-agent subnet join --from <WALLET_1> --subnet /root/<SUBNET_ID> --collateral 1 --validator-net-addr <VALIDATOR_ADDR_1>
./ipc-agent/bin/ipc-agent subnet join --from <WALLET_2> --subnet /root/<SUBNET_ID> --collateral 1 --validator-net-addr <VALIDATOR_ADDR_2>
./ipc-agent/bin/ipc-agent subnet join --from <WALLET_3> --subnet /root/<SUBNET_ID> --collateral 1 --validator-net-addr <VALIDATOR_ADDR_3>
./ipc-agent/bin/ipc-agent subnet join --from <WALLET_1> --subnet /r31415926/<SUBNET_ID> --collateral 1 --validator-net-addr <VALIDATOR_ADDR_1>
./ipc-agent/bin/ipc-agent subnet join --from <WALLET_2> --subnet /r31415926/<SUBNET_ID> --collateral 1 --validator-net-addr <VALIDATOR_ADDR_2>
./ipc-agent/bin/ipc-agent subnet join --from <WALLET_3> --subnet /r31415926/<SUBNET_ID> --collateral 1 --validator-net-addr <VALIDATOR_ADDR_3>
```


Expand All @@ -225,7 +225,7 @@ We have everything in place now to start validating. Run the following script fo

* Check that the subnet is running
```bash
./ipc-agent/bin/ipc-agent subnet list --gateway-address t064 --subnet /root
./ipc-agent/bin/ipc-agent subnet list --gateway-address t064 --subnet /r31415926
```
* If something went wrong, please have a look at the [README](https://github.com/consensus-shipyard/ipc-agent). If it doesn't help, please join us in #ipc-help. In either case, let us know your experience!
* Please note that to repeat this guide or spawn a new subnet, you may need to change the parameters or reset your system.
Loading