Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Commit

Permalink
Change default host to 127.0.0.1 and port to 5050 (#76) [skip ci]
Browse files Browse the repository at this point in the history
* Avoid using a port MacOS uses already

* Remove settings.ini

Co-authored-by: Jorik Schellekens <[email protected]>
Co-authored-by: FabijanC <[email protected]>
  • Loading branch information
3 people authored May 5, 2022
1 parent 9ac4811 commit b687e76
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ RUN pip3 install --no-cache /wheels/*

RUN rm -rf /wheels

ENTRYPOINT [ "starknet-devnet", "--host", "0.0.0.0", "--port", "5000" ]
ENTRYPOINT [ "starknet-devnet", "--host", "0.0.0.0", "--port", "5050" ]
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ Run a local instance of Starknet Devnet
optional arguments:
-h, --help show this help message and exit
-v, --version Print the version
--host HOST Specify the address to listen at; defaults to localhost (use the address the program outputs on start)
--port PORT, -p PORT Specify the port to listen at; defaults to 5000
--host HOST Specify the address to listen at; defaults to 127.0.0.1 (use the address the program outputs on start)
--port PORT, -p PORT Specify the port to listen at; defaults to 5050
--load-path LOAD_PATH
Specify the path from which the state is loaded on
startup
Expand All @@ -73,7 +73,7 @@ You can run `starknet-devnet` in a separate shell, or you can run it in backgrou
Check that it's alive by running the following (address and port my vary if you specified a different one with `--host` or `--port`):

```
curl http://localhost:5000/is_alive
curl http://127.0.0.1:5050/is_alive
```

### Run with Docker
Expand All @@ -91,19 +91,19 @@ Image tags correspond to Devnet versions as on PyPI and GitHub, with the `latest
docker pull shardlabs/starknet-devnet
```

The server inside the container listens to the port 5000, which you need to publish to a desired `<PORT>` on your host machine:
The server inside the container listens to the port 5050, which you need to publish to a desired `<PORT>` on your host machine:

```text
docker run -p [HOST:]<PORT>:5000 shardlabs/starknet-devnet
docker run -p [HOST:]<PORT>:5050 shardlabs/starknet-devnet
```

E.g. if you want to use your host machine's `127.0.0.1:5000`, you need to run:
E.g. if you want to use your host machine's `127.0.0.1:5050`, you need to run:

```text
docker run -p 127.0.0.1:5000:5000 shardlabs/starknet-devnet
docker run -p 127.0.0.1:5050:5050 shardlabs/starknet-devnet
```

You may ignore any address-related output logged on container startup (e.g. `Running on all addresses` or `Running on http://172.17.0.2:5000`). What you will use is what you specified with the `-p` argument.
You may ignore any address-related output logged on container startup (e.g. `Running on all addresses` or `Running on http://172.17.0.2:5050`). What you will use is what you specified with the `-p` argument.

If you don't specify the `HOST` part, the server will indeed be available on all of your host machine's addresses (localhost, local network IP, etc.), which may present a security issue if you don't want anyone from the local network to access your Devnet instance.

Expand Down Expand Up @@ -140,7 +140,7 @@ Postman is a Starknet utility that allows testing L1 <> L2 interactions. To util
- Load a `StarknetMockMessaging` contract. The `address` parameter is optional; if provided, the `StarknetMockMessaging` contract will be fetched from that address, otherwise a new one will be deployed:

- `POST /postman/load_l1_messaging_contract`
- body: `{ "networkUrl": "http://localhost:5005", "address": "0x83D76591560d9CD02CE16c060c92118d19F996b3" }`
- body: `{ "networkUrl": "http://localhost:8545", "address": "0x83D76591560d9CD02CE16c060c92118d19F996b3" }`
- `networkUrl` - the URL of the L1 network you've run locally or that already exists; possibilities include, and are not limited to:
- [Goerli testnet](https://goerli.net/)
- [Ganache node](https://www.npmjs.com/package/ganache)
Expand Down Expand Up @@ -204,13 +204,13 @@ This example:

- Relies on [Docker bind mount](https://docs.docker.com/storage/bind-mounts/); try [Docker volume](https://docs.docker.com/storage/volumes/) instead.
- Assumes that `/actual/dumpdir` exists. If unsure, use absolute paths.
- Assumes you are listening on `127.0.0.1:5000`.
- Assumes you are listening on `127.0.0.1:5050`.

If there is `dump.pkl` inside `/actual/dumpdir`, you can load it with:

```
docker run \
-p 127.0.0.1:5000:5000 \
-p 127.0.0.1:5050:5050 \
--mount type=bind,source=/actual/dumpdir,target=/dumpdir \
shardlabs/starknet-devnet \
--load-path /dumpdir/dump.pkl
Expand All @@ -220,7 +220,7 @@ To dump to `/actual/dumpdir/dump.pkl` on Devnet shutdown, run:

```
docker run \
-p 127.0.0.1:5000:5000 \
-p 127.0.0.1:5050:5050 \
--mount type=bind,source=/actual/dumpdir,target=/dumpdir \
shardlabs/starknet-devnet \
--dump-on exit --dump-path /dumpdir/dump.pkl
Expand Down Expand Up @@ -253,7 +253,7 @@ starknet-devnet 2> /dev/null
To enable printing with a dockerized version of Devnet set `PYTHONUNBUFFERED=1`:

```
docker run -p 127.0.0.1:5000:5000 -e PYTHONUNBUFFERED=1 shardlabs/starknet-devnet
docker run -p 127.0.0.1:5050:5050 -e PYTHONUNBUFFERED=1 shardlabs/starknet-devnet
```

## Development
Expand Down
6 changes: 3 additions & 3 deletions scripts/image_build_and_push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ docker build -t "$IMAGE:$LOCAL_VERSION_TAG" -t "$IMAGE:$LATEST_VERSION_TAG" .

echo "Run a devnet instance in background; sleep to allow it to start"
# can't use "localhost" because docker doesn't allow such mapping
docker run -d -p 127.0.0.1:5000:5000 --name devnet "$IMAGE:$LATEST_VERSION_TAG"
docker run -d -p 127.0.0.1:5050:5050 --name devnet "$IMAGE:$LATEST_VERSION_TAG"
sleep 10
docker logs devnet

echo "Checking if devnet instance is alive"
if [ ! -z $REMOTE ]; then
ssh remote-docker curl localhost:5000/is_alive
ssh remote-docker curl localhost:5050/is_alive
else
curl localhost:5000/is_alive
curl localhost:5050/is_alive
fi

# curling the url fails with 404
Expand Down
5 changes: 3 additions & 2 deletions starknet_devnet/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ def parse_dump_on(option: str):
return DumpOn[option.upper()]
sys.exit(f"Error: Invalid --dump-on option: {option}. Valid options: {DUMP_ON_OPTIONS_STRINGIFIED}")

DEFAULT_HOST = "localhost"
DEFAULT_PORT = 5000
DEFAULT_HOST = "127.0.0.1"
DEFAULT_PORT = 5050

def parse_args():
"""
Parses CLI arguments.
Expand Down
5 changes: 0 additions & 5 deletions test/settings.ini

This file was deleted.

4 changes: 2 additions & 2 deletions test/settings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Constants used in test files."""

HOST = "localhost"
PORT = "5000"
HOST = "127.0.0.1"
PORT = "5050"
L1_HOST = "localhost"
L1_PORT = "8545"

Expand Down

0 comments on commit b687e76

Please sign in to comment.