You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To setup the explorer, an installation of the DB is needed.
874
+
875
+
First you'll need to install docker if you don't have it already. You can follow the instructions [here](https://docs.docker.com/get-docker/).
876
+
877
+
The explorer uses a PostgreSQL database. To build and start the DB using docker, just run:
878
+
879
+
```bash
880
+
make build_db
881
+
```
882
+
883
+
This will build the docker image to be used as our database.
884
+
885
+
After this, both `make run_explorer` and `make run_devnet_explorer` (see [this](#running-for-local-devnet) for more details) will automatically start, setup and connect to the database, which will be available on `localhost:5432` and the data is persisted in a volume.
886
+
887
+
<details>
888
+
889
+
<summary>
890
+
(Optional) The steps to manually execute the database are as follows...
891
+
</summary>
892
+
893
+
- Run the database container, opening port `5432`:
894
+
895
+
```bash
896
+
make run_db
897
+
```
898
+
899
+
- Configure the database with ecto running `ecto.create` and `ecto.migrate`:
900
+
901
+
```bash
902
+
make ecto_setup_db
903
+
```
904
+
905
+
- Start the explorer:
906
+
907
+
```bash
908
+
make run_explorer # or make run_devnet_explorer
909
+
```
910
+
911
+
</details>
912
+
913
+
<br>
914
+
915
+
In order to clear the DB, you can run:
916
+
917
+
```bash
918
+
make clean_db
919
+
```
920
+
921
+
If you need to dumb the data from the DB, you can run:
922
+
923
+
```bash
924
+
make dump_db
925
+
```
926
+
927
+
This will create a `dump.$date.sql` SQL script on the `explorer` directory with all the existing data.
928
+
929
+
Data can be recovered from a `dump.$date.sql` using the following command:
930
+
931
+
```bash
932
+
make recover_db
933
+
```
934
+
935
+
Then you'll be requested to enter the file name of the dump you want to recover already positioned in the `/explorer` directory.
936
+
937
+
This will update your database with the dumped database data.
938
+
939
+
### Extra scripts
940
+
941
+
If you want to fetch past batches that for any reason were not inserted into the DB, you will first need to make sure you have the ELIXIR_HOSTNAME .env variable configured. You can get the hostname of your elixir by running `elixir -e 'IO.puts(:inet.gethostname() |> elem(1))'`
942
+
943
+
Then you can run:
944
+
945
+
```bash
946
+
make explorer_fetch_old_batches
947
+
```
948
+
949
+
You can modify which blocks are being fetched by modify the parameters the `explorer_fetch_old_batches.sh` is being recieved
871
950
872
951
### Running for local devnet
873
952
874
-
```make run_devnet_explorer```
953
+
To run the explorer for the local devnet, you'll need to have the devnet running (see [local devnet setup](#local-devnet-setup)) and the DB already setup.
954
+
955
+
To run the explorer, just run:
956
+
957
+
```bash
958
+
make run_devnet_explorer
959
+
```
875
960
876
961
Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.
877
962
You can access to a tasks information by visiting `localhost:4000/batches/:merkle_root`.
@@ -885,6 +970,13 @@ Create a `.env` file in the `/explorer` directory of the project. The `.env` fil
885
970
|`RPC_URL`| The RPC URL of the network you want to connect to. |
886
971
|`ENVIRONMENT`| The environment you want to run the application in. It can be `devnet`, `holesky` or `mainnet`. |
887
972
|`PHX_HOST`| The host URL where the Phoenix server will be running. |
973
+
|`DB_NAME`| The name of the postgres database. |
974
+
|`DB_USER`| The username of the postgres database. |
975
+
|`DB_PASS`| The password of the postgres database. |
976
+
|`DB_HOST`| The host URL where the postgres database will be running. |
977
+
|`ELIXIR_HOSTNAME`| The hostname of your running elixir. Read [Extra Scripts](#extra-scripts) section for more details |
978
+
979
+
Then you can run the explorer with this env file config by entering the following command:
0 commit comments